当前位置: 首页 > news >正文

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。

相关文章:

  • 北京网站建设多少钱?
  • 辽宁网页制作哪家好_网站建设
  • 高端品牌网站建设_汉中网站制作
  • 单词记忆(第二周)
  • 如何提高工作效率?
  • Git【版本控制命令】
  • 【C51】DIY电子音乐贺卡:C51单片机项目设计与实现
  • Activity->Activity中动态添加Fragment->Fragment回退栈BackStack
  • C# WPF入门学习主线篇(二十一)—— 静态资源和动态资源
  • 查询SQL02:寻找用户推荐人
  • 影子,介绍一下自己
  • 【嵌入式】波特率9600,发送8个字节需要多少时间,如何计算?
  • Spring运维之boo项目表现层测试匹配响应执行状态响应体JSON和响应头
  • 【DevOps】VyOS:功能强大的开源网络操作系统和实战
  • Vue——初识组件
  • 为什么会有虚像(完美解释焦距和像大小和透镜的关系)
  • EverWeb 强大的零基础Mac网页设计制作软件
  • 最大似然估计、贝叶斯估计、最小二乘估计与贝叶斯学习的本质区别
  • 【技术性】Search知识
  • AHK 中 = 和 == 等比较运算符的用法
  • DOM的那些事
  • emacs初体验
  • ES学习笔记(10)--ES6中的函数和数组补漏
  • java B2B2C 源码多租户电子商城系统-Kafka基本使用介绍
  • Javascript基础之Array数组API
  • Material Design
  • nodejs:开发并发布一个nodejs包
  • Promise面试题2实现异步串行执行
  • Python学习笔记 字符串拼接
  • tab.js分享及浏览器兼容性问题汇总
  • Vue 动态创建 component
  • vue-cli在webpack的配置文件探究
  • Vue实战(四)登录/注册页的实现
  • Webpack 4 学习01(基础配置)
  • 测试开发系类之接口自动化测试
  • 搭建gitbook 和 访问权限认证
  • 电商搜索引擎的架构设计和性能优化
  • 构建二叉树进行数值数组的去重及优化
  • 和 || 运算
  • 利用jquery编写加法运算验证码
  • 前端面试题总结
  • 少走弯路,给Java 1~5 年程序员的建议
  • Spring Batch JSON 支持
  • ​configparser --- 配置文件解析器​
  • ​LeetCode解法汇总1276. 不浪费原料的汉堡制作方案
  • ​LeetCode解法汇总2808. 使循环数组所有元素相等的最少秒数
  • # windows 运行框输入mrt提示错误:Windows 找不到文件‘mrt‘。请确定文件名是否正确后,再试一次
  • #单片机(TB6600驱动42步进电机)
  • #职场发展#其他
  • (12)目标检测_SSD基于pytorch搭建代码
  • (2)(2.10) LTM telemetry
  • (3)医疗图像处理:MRI磁共振成像-快速采集--(杨正汉)
  • (C++二叉树05) 合并二叉树 二叉搜索树中的搜索 验证二叉搜索树
  • (Python第六天)文件处理
  • (补充)IDEA项目结构
  • (二)【Jmeter】专栏实战项目靶场drupal部署
  • (附源码)spring boot网络空间安全实验教学示范中心网站 毕业设计 111454
  • (附源码)springboot工单管理系统 毕业设计 964158