将Launcher中搜索框去除
将FeatureFlags.java文件中的QSB_ON_FIRST_SCREEN变量修改为false
java
\system\vendor\mediatek\proprietary\packages\apps\Launcher3\src\com\android\launcher3\config\FeatureFlags.java
/**
* Defines a set of flags used to control various launcher behaviors.
*
* <p>All the flags should be defined here with appropriate default values.
*/
public final class FeatureFlags {
/**
* Enable moving the QSB on the 0th screen of the workspace. This is not a configuration feature
* and should be modified at a project level.
*/
public static final boolean QSB_ON_FIRST_SCREEN = BuildConfig.QSB_ON_FIRST_SCREEN;
在源码中是通过launcher3中的BuildConfig.java去获取变量(默认true),那么在这里将变量修改为false即可(自行添加系统变量进行灵活控制也行)
java
\system\vendor\mediatek\proprietary\packages\apps\Launcher3\src_build_config\com\android\launcher3\BuildConfig.java
public final class BuildConfig {
public static final String APPLICATION_ID = "com.android.launcher3";
public static final boolean DEBUG = false;
/**
* Flag to state if the QSB is on the first screen and placed on the top,
* this can be overwritten in other launchers with a different value, if needed.
*/
public static final boolean QSB_ON_FIRST_SCREEN = false;
}
最近在Android 13平台修改以上代码后,在Launcher中并不生效,后来发现,如果SearchLauncherQuickStep存在会默认使用,那么我们的修改就不会生效,因此在这里也需要把它注释掉
java
system\vendor\partner_gms\products\gms.mk
GMS_PRODUCT_PACKAGES += \
#SearchLauncherQuickStep
如何将默认的Search替换为其他的? 比如项目是出货RU(俄罗斯)的,根据要求需要将Launcher中的默认Google Search 要更换为 Chrome Search
String providerPkg 为 Chrome 浏览器应用的包名
String className 为 launcher中Chrome Search组件的名字
Boolean ruSupport 为了判断当前版本是否为RU版本(一般只有RU地区才需要这样替换Search)
在getSearchWidgetProviderInfo方法中进行修改判断
java
system\vendor\mediatek\proprietary\packages\apps\Launcher3\src\com\android\launcher3\qsb\QsbContainerView.java
/**
* returns it's AppWidgetProviderInfo using package name from getSearchWidgetPackageName
* @param context
* @return AppWidgetProviderInfo
*/
@Nullable
public static AppWidgetProviderInfo getSearchWidgetProviderInfo(@NonNull Context context) {
String providerPkg = getSearchWidgetPackageName(context);
if (providerPkg == null) {
return null;
}
//add ---------------------------------------------------------
String providerPkg = "com.android.chrome";
String className = "org.chromium.chrome.browser.searchwidget.SearchWidgetProvider";
Boolean ruSupport = SystemProperties.get("ro.product.name");
//end ---------------------------------------------------------
AppWidgetProviderInfo defaultWidgetForSearchPackage = null;
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
for (AppWidgetProviderInfo info :
appWidgetManager.getInstalledProvidersForPackage(providerPkg, null)) {
if (info.provider.getPackageName().equals(providerPkg) && info.configure == null) {
if ((info.widgetCategory
& AppWidgetProviderInfo.WIDGET_CATEGORY_SEARCHBOX) != 0) {
//add ---------------------------------------------------------
if(ruSupport){
if(className.equals(info.provider.getClassName())){
return info;
}
}else{
return info;
}
//end ---------------------------------------------------------
} else if (defaultWidgetForSearchPackage == null) {
defaultWidgetForSearchPackage = info;
}
}
}
return defaultWidgetForSearchPackage;
}
人的精神思想方面的优势越大,给无聊留下的空间就越小。