AOSP8.1-移除桌面Google搜索框

892 阅读1分钟

首先放一张带有Google搜索框的图片,这个搜索框基本没什么用,而且还不能长按删除,下面我们从源码里面移除掉它。

代码位置: packages/apps/Launcher3/src/com/android/launcher3/Workspace.java

将如下代码注释掉即可(对于asop8.1来说,其在601行)

// Always add a QSB on the first screen.
if (qsb == null) {
	// In transposed layout, we add the QSB in the Grid. As workspace does not touch the edges, we do not need a full width QSB.
	qsb = LayoutInflater.from(getContext())
	.inflate(R.layout.search_container_workspace,firstPage, false);
}

CellLayout.LayoutParams lp = new CellLayout.LayoutParams(0, 0, firstPage.getCountX(), 1);
lp.canReorder = false;
if (!firstPage.addViewToCellLayout(qsb, 0, R.id.search_container_workspace, lp, true)) {
	Log.e(TAG, "Failed to add to item at (0, 0) to CellLayout");
}

修改完成后,需要重新编译Launcher3模块

1.cd到packages/apps/Launcher3/,执行mm命令编译

2.编译完成后,会在 out/target/product/xxx/system/priv-app/Launcher3/ 目录下生成Launcher3.apk以及oat目录(oat目录下面是系统预先编译的文件,用于加快应用首次启动的速度)

3.连接手机,将生成的Launcher3.apk以及oat目录下的预编译文件刷入到设备

具体刷入步骤如下:

adb remount
adb push Launcher3.apk /system/priv-app/Launcher3/
adb push oat/arm64/Launcher3.odex /system/priv-app/Launcher3/oat/arm64/
adb push oat/arm64/Launcher3.vdex /system/priv-app/Launcher3/oat/arm64/

4.重启设备生效