Android AOSP定制去掉Google搜索栏

2024-06-10 07:28

本文主要是介绍Android AOSP定制去掉Google搜索栏,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

Android AOSP定制去掉Google搜索栏

1.前言:

​ 最近接触了Android系统定制的需求,感觉非常有意思,之前做过Launcher和串口,也自己安装过虚拟机,不过几年没用Linux系统了有点不习惯,Linux命令也不熟悉,刚开始连安装打开AndroidStudio都不会,这里如果不熟悉的小伙伴可以参数以下博客,毕竟Android源码编译都是在Linux环境下进行的,所以熟悉Linux命令还是非常有必要的,此篇作为AOSP定制开发的开篇遇到了很多问题,这里记录一下,废话不多说,直接上代码.

2.简介:

AOSP 概览

Android 是适用于各种不同规格设备的操作系统。任何人都可以通过 Android 开源项目 (AOSP) 查看 Android 的文档和源代码。您可以使用 AOSP 为自己的设备创建自定义 Android OS 变体。

AOSP 的设计可确保不存在一个集中瓶颈,即没有任何行业参与者可一手限制或控制其他参与者的创新。因此,AOSP 是一款功能完善且达到生产质量的开发者产品,其源代码可以开放自定义和移植。

AOSP(Android Open Source Project)是Android的开放源代码项目,为开发者提供了详细的源代码和工具,使得我们能够深入了解Android系统的运作原理。阅读AOSP源码并熟悉其目录结构是了解Android系统内部实现和架构的关键。

3.文章参考:

这里推荐豪哥的FrameWork教程,非常详细和实用,最开始也是跟着豪哥的博客学习了不少知识.

https://juejin.cn/post/7207374216127103033

https://juejin.cn/post/7125309442341961765

https://babyyn.github.io/Sources/AOSP/build.html

4.隐藏Google搜索栏

修改变量配置 QSB_ON_FIRST_SCREEN = false

  • 源码路径:packages\apps\Launcher3\src\com\android\launcher3\config\BaseFlags.java

  • 源码

    abstract class BaseFlags {BaseFlags() {}public static final boolean IS_DOGFOOD_BUILD = false;public static final String AUTHORITY = "com.android.launcher3.settings".intern();// When enabled allows to use any point on the fast scrollbar to start dragging.public static final boolean LAUNCHER3_DIRECT_SCROLL = true;// When enabled the promise icon is visible in all apps while installation an app.public static final boolean LAUNCHER3_PROMISE_APPS_IN_ALL_APPS = false;// When enabled allows use of spring motions on the icons.public static final boolean LAUNCHER3_SPRING_ICONS = true;// Feature flag to enable moving the QSB on the 0th screen of the workspace.public static final boolean QSB_ON_FIRST_SCREEN = true;// When enabled the all-apps icon is not added to the hotseat.public static final boolean NO_ALL_APPS_ICON = true;// When true, custom widgets are loaded using CustomWidgetParser.public static final boolean ENABLE_CUSTOM_WIDGETS = false;// Features to control Launcher3Go behaviorpublic static final boolean GO_DISABLE_WIDGETS = false;// When enabled shows a work profile tab in all appspublic static final boolean ALL_APPS_TABS_ENABLED = true;// When true, overview shows screenshots in the orientation they were taken rather than// trying to make them fit the orientation the device is in.public static final boolean OVERVIEW_USE_SCREENSHOT_ORIENTATION = true;
    }
    

在这里插入图片描述

  • 源码修改

    /** Copyright (C) 2017 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.*/package com.android.launcher3.config;/*** Defines a set of flags used to control various launcher behaviors.** All the flags should be defined here with appropriate default values. To override a value,* redefine it in {@link FeatureFlags}.** This class is kept package-private to prevent direct access.*/
    abstract class BaseFlags {BaseFlags() {}public static final boolean IS_DOGFOOD_BUILD = false;public static final String AUTHORITY = "com.android.launcher3.settings".intern();// When enabled allows to use any point on the fast scrollbar to start dragging.public static final boolean LAUNCHER3_DIRECT_SCROLL = true;// When enabled the promise icon is visible in all apps while installation an app.public static final boolean LAUNCHER3_PROMISE_APPS_IN_ALL_APPS = false;// When enabled allows use of spring motions on the icons.public static final boolean LAUNCHER3_SPRING_ICONS = true;// Feature flag to enable moving the QSB on the 0th screen of the workspace.public static final boolean QSB_ON_FIRST_SCREEN = false;// When enabled the all-apps icon is not added to the hotseat.public static final boolean NO_ALL_APPS_ICON = true;// When true, custom widgets are loaded using CustomWidgetParser.public static final boolean ENABLE_CUSTOM_WIDGETS = false;// Features to control Launcher3Go behaviorpublic static final boolean GO_DISABLE_WIDGETS = false;// When enabled shows a work profile tab in all appspublic static final boolean ALL_APPS_TABS_ENABLED = true;// When true, overview shows screenshots in the orientation they were taken rather than// trying to make them fit the orientation the device is in.public static final boolean OVERVIEW_USE_SCREENSHOT_ORIENTATION = true;
    }
    

5.注释xml代码

  • 源码路径:/packages/apps/Launcher3/res/layout/search_container_workspace.xml

  • 源码

    在这里插入图片描述

<?xml version="1.0" encoding="utf-8"?>
<!--Copyright (C) 2016 The Android Open Source ProjectLicensed 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 athttp://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, softwaredistributed 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 andlimitations under the License.
-->
<com.android.launcher3.qsb.QsbContainerViewxmlns:android="http://schemas.android.com/apk/res/android"android:orientation="vertical"android:layout_width="match_parent"android:layout_height="0dp"android:id="@id/search_container_workspace"android:padding="0dp" ><fragmentandroid:name="com.android.launcher3.qsb.QsbContainerView$QsbFragment"android:layout_width="match_parent"android:tag="qsb_view"android:layout_height="match_parent"/>
</com.android.launcher3.qsb.QsbContainerView>
  • 源码修改

在这里插入图片描述

<?xml version="1.0" encoding="utf-8"?>
<!--Copyright (C) 2016 The Android Open Source ProjectLicensed 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 athttp://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, softwaredistributed 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 andlimitations under the License.
-->
<com.android.launcher3.qsb.QsbContainerViewxmlns:android="http://schemas.android.com/apk/res/android"android:orientation="vertical"android:layout_width="match_parent"android:layout_height="0dp"android:id="@id/search_container_workspace"android:padding="0dp" ><!--<fragmentandroid:name="com.android.launcher3.qsb.QsbContainerView$QsbFragment"android:layout_width="match_parent"android:tag="qsb_view"android:layout_height="match_parent"/>-->
</com.android.launcher3.qsb.QsbContainerView>

6.注释资源加载代码:

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

  • 源码

     /*** Initializes and binds the first page* @param qsb an existing qsb to recycle or null.*/public void bindAndInitFirstWorkspaceScreen(View qsb) {if (!FeatureFlags.QSB_ON_FIRST_SCREEN) {return;}// Add the first pageCellLayout firstPage = insertNewWorkspaceScreen(Workspace.FIRST_SCREEN_ID, 0);// 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");}}
    

在这里插入图片描述

源码修改:

 public void bindAndInitFirstWorkspaceScreen(View qsb) {if (!FeatureFlags.QSB_ON_FIRST_SCREEN) {return;}// Add the first pageCellLayout firstPage = insertNewWorkspaceScreen(Workspace.FIRST_SCREEN_ID, 0);// 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");}*/}

在这里插入图片描述

7.实现的效果如下:

从下图可以看出我们需要的效果已经实现,已经满足我们的需求.

在这里插入图片描述

8.文章总结:

以上就是今天的内容,AndroidAOSP开发去掉Google搜索栏,如果熟悉AOSP源码的同学肯定会认为很简单,但是我是最近才刚接触的,过程中遇到了很多,比如Linux环境搭建,Linux命令的使用,AOSP源码的编译和下载,AOSP定制和App开发的有很大区别,必须去看源码,要不然你不知道从哪里下手,看了源码之后,熟悉了流程在去开发得心应手,后面会一步步讲解系统保活、系统深度定制、系统签名
等等。阅读源码是一个很好的习惯,分析源码更是一个好习惯,我们不仅要学会1+1=2,更要学会如何更好地阅读和分析源码,今天的代码先到这里,下一篇我们讲解AOSP如何定制gms。

这篇关于Android AOSP定制去掉Google搜索栏的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1047524

相关文章

苹果macOS 26 Tahoe主题功能大升级:可定制图标/高亮文本/文件夹颜色

《苹果macOS26Tahoe主题功能大升级:可定制图标/高亮文本/文件夹颜色》在整体系统设计方面,macOS26采用了全新的玻璃质感视觉风格,应用于Dock栏、应用图标以及桌面小部件等多个界面... 科技媒体 MACRumors 昨日(6 月 13 日)发布博文,报道称在 macOS 26 Tahoe 中

HTML5 搜索框Search Box详解

《HTML5搜索框SearchBox详解》HTML5的搜索框是一个强大的工具,能够有效提升用户体验,通过结合自动补全功能和适当的样式,可以创建出既美观又实用的搜索界面,这篇文章给大家介绍HTML5... html5 搜索框(Search Box)详解搜索框是一个用于输入查询内容的控件,通常用于网站或应用程

C#如何去掉文件夹或文件名非法字符

《C#如何去掉文件夹或文件名非法字符》:本文主要介绍C#如何去掉文件夹或文件名非法字符的问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录C#去掉文件夹或文件名非法字符net类库提供了非法字符的数组这里还有个小窍门总结C#去掉文件夹或文件名非法字符实现有输入字

Android学习总结之Java和kotlin区别超详细分析

《Android学习总结之Java和kotlin区别超详细分析》Java和Kotlin都是用于Android开发的编程语言,它们各自具有独特的特点和优势,:本文主要介绍Android学习总结之Ja... 目录一、空安全机制真题 1:Kotlin 如何解决 Java 的 NullPointerExceptio

Android NDK版本迭代与FFmpeg交叉编译完全指南

《AndroidNDK版本迭代与FFmpeg交叉编译完全指南》在Android开发中,使用NDK进行原生代码开发是一项常见需求,特别是当我们需要集成FFmpeg这样的多媒体处理库时,本文将深入分析A... 目录一、android NDK版本迭代分界线二、FFmpeg交叉编译关键注意事项三、完整编译脚本示例四

Android与iOS设备MAC地址生成原理及Java实现详解

《Android与iOS设备MAC地址生成原理及Java实现详解》在无线网络通信中,MAC(MediaAccessControl)地址是设备的唯一网络标识符,本文主要介绍了Android与iOS设备M... 目录引言1. MAC地址基础1.1 MAC地址的组成1.2 MAC地址的分类2. android与I

Android 实现一个隐私弹窗功能

《Android实现一个隐私弹窗功能》:本文主要介绍Android实现一个隐私弹窗功能,本文通过实例代码给大家介绍的非常详细,感兴趣的朋友一起看看吧... 效果图如下:1. 设置同意、退出、点击用户协议、点击隐私协议的函数参数2. 《用户协议》、《隐私政策》设置成可点击的,且颜色要区分出来res/l

Android实现一键录屏功能(附源码)

《Android实现一键录屏功能(附源码)》在Android5.0及以上版本,系统提供了MediaProjectionAPI,允许应用在用户授权下录制屏幕内容并输出到视频文件,所以本文将基于此实现一个... 目录一、项目介绍二、相关技术与原理三、系统权限与用户授权四、项目架构与流程五、环境配置与依赖六、完整

Android 12解决push framework.jar无法开机的方法小结

《Android12解决pushframework.jar无法开机的方法小结》:本文主要介绍在Android12中解决pushframework.jar无法开机的方法,包括编译指令、框架层和s... 目录1. android 编译指令1.1 framework层的编译指令1.2 替换framework.ja

Android开发环境配置避坑指南

《Android开发环境配置避坑指南》本文主要介绍了Android开发环境配置过程中遇到的问题及解决方案,包括VPN注意事项、工具版本统一、Gerrit邮箱配置、Git拉取和提交代码、MergevsR... 目录网络环境:VPN 注意事项工具版本统一:android Studio & JDKGerrit的邮