如何从 AOSP 的 android 源代码中删除主屏幕的 google 搜索栏

How to remove google search bar of home screen from android source code of AOSP

我已经在我的系统上安装并构建了 android 开源项目,并且有 运行 模拟器。它在主屏幕顶部显示默认的 google 搜索栏。我想从那里删除 google 搜索栏以使主屏幕清晰。 为了删除它,我已经修改了一个文件,但我不确定我必须修改哪个文件才能删除该部分。

我修改了目录“Android_AOSP/packages/apps/QuickSearchBox/AndroidManifest.xml”中的一个AndroidManifest.xml文件,但该文件只删除了搜索图标,但背景布局仍然显示那里。 在编辑以下代码之前,上面的搜索布局与下面的 google 搜索布局相同。

我刚刚评论了以下代码的一部分。

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2009 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.android.quicksearchbox" >

    <original-package android:name="com.android.quicksearchbox" />

    <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="28" />

    <uses-permission android:name="android.permission.GLOBAL_SEARCH" />

    <!-- Permissions needed by the default corpora. We request these instead of just relying on
         GLOBAL_SEARCH so that we can use the default corpora when not in the system
         partition. -->
    <uses-permission android:name="android.permission.READ_CONTACTS" />
    <uses-permission android:name="com.android.browser.permission.READ_HISTORY_BOOKMARKS"/>

    <!-- Permissions used by GoogleSearch. -->
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WRITE_SETTINGS" />

    <application android:label="@string/app_name"
                 android:icon="@mipmap/search_app_icon"
                 android:name=".QsbApplicationWrapper"
                 android:theme="@style/Theme.QuickSearchBox"
                 android:hardwareAccelerated="true">
        <uses-library android:name="org.apache.http.legacy" android:required="false" />
<!--
        <activity android:name=".SearchActivity"
                  android:label="@string/app_name"
                  android:launchMode="singleTask"
                  android:theme="@style/Theme.QuickSearchBox.Search">
 -->                 
            <!-- Show app icon in Launcher. -->
<!--
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
-->            <!-- Handle global search. -->
<!--            <intent-filter>
                <action android:name="android.search.action.GLOBAL_SEARCH" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.search.action.GLOBAL_SEARCH" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
            <meta-data android:name="com.android.launcher.toolbar_icon" android:resource="@drawable/ic_google_logo_normal" />
        </activity>

-->
        <receiver android:name=".SearchWidgetProvider"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
            </intent-filter>
            <meta-data android:name="android.appwidget.provider" android:resource="@xml/search_widget_info" />
        </receiver>

        <activity android:name=".google.GoogleSearch"
                android:label="@string/google_search_label"
                android:icon="@mipmap/google_icon"
                android:theme="@android:style/Theme.NoDisplay"
                android:excludeFromRecents="true">
            <intent-filter>
                <action android:name="android.intent.action.WEB_SEARCH" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
            <meta-data android:name="android.app.searchable"
                android:resource="@xml/google_searchable" />
        </activity>

        <provider android:name=".google.GoogleSuggestionProvider"
            android:label="@string/google_search_label"
            android:authorities="com.android.quicksearchbox.google"
            android:exported="true" />

    </application>
</manifest>

我更改了仅在给定图像文件中显示的选定代码。 并且在模拟器中显示的再次构建之后发生了变化。 我想从主屏幕上完全删除上面的搜索布局,但它没有发生。 在编辑代码之前,它看起来与下面的搜索布局相同。 我还尝试通过注释清单标记部分中编写的所有代码来进行尝试。但它除了显示更改外没有做任何更改。如果我删除这个文件,它就会开始报错。 我尝试删除整个 'QuickSearchBox' 文件夹,但在删除之后该部分没有任何变化。

那不是 Android 系统的一部分,它的启动器应用程序和设计。我找不到专门的文档页面,但找到了一些教程 how to make own Launcher app。您可以自己编写或找到一些具有开源和“友好”许可证的第三方,并通过删除此栏(如果存在)对其进行修改,然后您可以替换系统文件中的默认启动器应用程序

你做了什么:你刚刚修改了负责处理这个小部件操作的应用程序,实际上还有另一个应用程序(启动器)正在为自己的“桌面”设计实现这个小部件

我以前删除默认主屏幕google搜索框的方法是错误的。

我找到了删除它的主要解决方案,而无需对代码进行太多更改。 请按照以下步骤将其删除。

第 1 步:转到 AOSP 源目录

中的以下目录

路径:packages/apps/Launcher3/src/com/android/launcher3/config/

第 2 步:打开名为“BaseFlags.java”的文件

第 3 步:找到以下代码行,并将“true”更改为“false”

// Enable moving the QSB on the 0th screen of the workspace

public static final boolean QSB_ON_FIRST_SCREEN = false;    // For show 'home screen search bar' make it true. // By default it was true

第 4 步:保存文件。

第五步:制作源代码并查看结果。 Google 删除了搜索栏。