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

相关文章

Android中Dialog的使用详解

《Android中Dialog的使用详解》Dialog(对话框)是Android中常用的UI组件,用于临时显示重要信息或获取用户输入,本文给大家介绍Android中Dialog的使用,感兴趣的朋友一起... 目录android中Dialog的使用详解1. 基本Dialog类型1.1 AlertDialog(

Android Kotlin 高阶函数详解及其在协程中的应用小结

《AndroidKotlin高阶函数详解及其在协程中的应用小结》高阶函数是Kotlin中的一个重要特性,它能够将函数作为一等公民(First-ClassCitizen),使得代码更加简洁、灵活和可... 目录1. 引言2. 什么是高阶函数?3. 高阶函数的基础用法3.1 传递函数作为参数3.2 Lambda

Android自定义Scrollbar的两种实现方式

《Android自定义Scrollbar的两种实现方式》本文介绍两种实现自定义滚动条的方法,分别通过ItemDecoration方案和独立View方案实现滚动条定制化,文章通过代码示例讲解的非常详细,... 目录方案一:ItemDecoration实现(推荐用于RecyclerView)实现原理完整代码实现

Android App安装列表获取方法(实践方案)

《AndroidApp安装列表获取方法(实践方案)》文章介绍了Android11及以上版本获取应用列表的方案调整,包括权限配置、白名单配置和action配置三种方式,并提供了相应的Java和Kotl... 目录前言实现方案         方案概述一、 androidManifest 三种配置方式

最新Spring Security实战教程之表单登录定制到处理逻辑的深度改造(最新推荐)

《最新SpringSecurity实战教程之表单登录定制到处理逻辑的深度改造(最新推荐)》本章节介绍了如何通过SpringSecurity实现从配置自定义登录页面、表单登录处理逻辑的配置,并简单模拟... 目录前言改造准备开始登录页改造自定义用户名密码登陆成功失败跳转问题自定义登出前后端分离适配方案结语前言

Android WebView无法加载H5页面的常见问题和解决方法

《AndroidWebView无法加载H5页面的常见问题和解决方法》AndroidWebView是一种视图组件,使得Android应用能够显示网页内容,它基于Chromium,具备现代浏览器的许多功... 目录1. WebView 简介2. 常见问题3. 网络权限设置4. 启用 JavaScript5. D

Android如何获取当前CPU频率和占用率

《Android如何获取当前CPU频率和占用率》最近在优化App的性能,需要获取当前CPU视频频率和占用率,所以本文小编就来和大家总结一下如何在Android中获取当前CPU频率和占用率吧... 最近在优化 App 的性能,需要获取当前 CPU视频频率和占用率,通过查询资料,大致思路如下:目前没有标准的

Python使用DeepSeek进行联网搜索功能详解

《Python使用DeepSeek进行联网搜索功能详解》Python作为一种非常流行的编程语言,结合DeepSeek这一高性能的深度学习工具包,可以方便地处理各种深度学习任务,本文将介绍一下如何使用P... 目录一、环境准备与依赖安装二、DeepSeek简介三、联网搜索与数据集准备四、实践示例:图像分类1.

Android开发中gradle下载缓慢的问题级解决方法

《Android开发中gradle下载缓慢的问题级解决方法》本文介绍了解决Android开发中Gradle下载缓慢问题的几种方法,本文给大家介绍的非常详细,感兴趣的朋友跟随小编一起看看吧... 目录一、网络环境优化二、Gradle版本与配置优化三、其他优化措施针对android开发中Gradle下载缓慢的问

Android 悬浮窗开发示例((动态权限请求 | 前台服务和通知 | 悬浮窗创建 )

《Android悬浮窗开发示例((动态权限请求|前台服务和通知|悬浮窗创建)》本文介绍了Android悬浮窗的实现效果,包括动态权限请求、前台服务和通知的使用,悬浮窗权限需要动态申请并引导... 目录一、悬浮窗 动态权限请求1、动态请求权限2、悬浮窗权限说明3、检查动态权限4、申请动态权限5、权限设置完毕后