【干货】Android系统定制基础篇:第二部分

news2024/10/5 13:00:49

1、Android Launcher3支持键盘切换焦点

Android Launcher3 默认并不支持键盘操作,无法切换焦点,在一些需要支持键盘或遥控操作的设备中无法使用,因些对 Launcher3 做简单修改,使其支持键盘切换焦点。

diff --git a/packages/apps/Launcher3/res/layout/all_apps.xml b/packages/apps/Launcher3/res/layout/all_apps.xml
old mode 100644
new mode 100755
diff --git a/packages/apps/Launcher3/res/layout/all_apps_icon.xml b/packages/apps/Launcher3/res/layout/all_apps_ic
index 3c2f842..1c22ec3 100755
--- a/packages/apps/Launcher3/res/layout/all_apps_icon.xml
+++ b/packages/apps/Launcher3/res/layout/all_apps_icon.xml
@@ -24,5 +24,7 @@
     launcher:iconDisplay="all_apps"
     launcher:centerVertically="true"
     android:paddingLeft="@dimen/dynamic_grid_cell_padding_x"
-    android:paddingRight="@dimen/dynamic_grid_cell_padding_x" />
+    android:paddingRight="@dimen/dynamic_grid_cell_padding_x"
+    android:focusable="true"
+    android:focusableInTouchMode="false" />
 
diff --git a/packages/apps/Launcher3/res/layout/page_indicator.xml b/packages/apps/Launcher3/res/layout/page_indic
old mode 100644
new mode 100755
diff --git a/packages/apps/Launcher3/res/layout/search_container_workspace.xml b/packages/apps/Launcher3/res/layou
old mode 100644
new mode 100755
index 1c617b1..161431f
--- a/packages/apps/Launcher3/res/layout/search_container_workspace.xml
+++ b/packages/apps/Launcher3/res/layout/search_container_workspace.xml
@@ -22,9 +22,11 @@
         android:id="@id/search_container_workspace"
         android:padding="0dp" >
 
-    <fragment
-        android:name="com.android.launcher3.qsb.QsbContainerView$QsbFragment"
-        android:layout_width="match_parent"
-        android:tag="qsb_view"
-        android:layout_height="match_parent"/>
+    <!--Modified by shenhb@topband.com.cn,remove search box.-->
+    <!--<fragment-->
+        <!--android:name="com.android.launcher3.qsb.QsbContainerView$QsbFragment"-->
+        <!--android:layout_width="match_parent"-->
+        <!--android:tag="qsb_view"-->
+        <!--android:layout_height="match_parent"/>-->
+    <!--End of modify-->
 </com.android.launcher3.qsb.QsbContainerView>
\ No newline at end of file
diff --git a/packages/apps/Launcher3/src/com/android/launcher3/Workspace.java b/packages/apps/Launcher3/src/com/an
old mode 100644
new mode 100755
index 6ce3ad6..8a03091
--- a/packages/apps/Launcher3/src/com/android/launcher3/Workspace.java
+++ b/packages/apps/Launcher3/src/com/android/launcher3/Workspace.java
@@ -606,11 +606,13 @@ public class Workspace extends PagedView
                     .inflate(R.layout.search_container_workspace,firstPage, false);
         }
 
+        /* Modified by shenhb@topband.com.cn,remove search box.
         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");
         }
+        End of Modify */
     }
 
     public void removeAllWorkspaceScreens() {
diff --git a/packages/apps/Launcher3/src/com/android/launcher3/config/BaseFlags.java b/packages/apps/Launcher3/src
old mode 100644
new mode 100755
index 6a4cbcb..5bc4df8
--- a/packages/apps/Launcher3/src/com/android/launcher3/config/BaseFlags.java
+++ b/packages/apps/Launcher3/src/com/android/launcher3/config/BaseFlags.java
@@ -51,7 +51,7 @@ abstract class BaseFlags {
     // 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;
+    public static final boolean NO_ALL_APPS_ICON = false;
     // When enabled fling down gesture on the first workspace triggers search.
     public static final boolean PULLDOWN_SEARCH = false;
     // When enabled the status bar may show dark icons based on the top of the wallpaper.

2、Android打开开发者模式需要密码确认

在安全性要求比较高的产品中,一般会默认关闭『adb调试』,同时禁止用户打开『adb调试』功能。在Android8.1中默认禁止『adb调试』只需要将下面属性:

persist.sys.usb.config=mtp,adb

改为:

persist.sys.usb.config=mtp

Android默认通过连续点击『版本号』可以打开『开发者选项』,在『开发者选项』中可以打开『adb调试』,所以要禁止用户打开『adb调试』功能,我们在用户点击『版本号』时弹出管理员密码对话框,只有输入正确的管理员密码才可以打开『开发者选项』。修改如下:

diff --git a/packages/apps/Settings/src/com/android/settings/deviceinfo/BuildNumberPreferenceController.java b/pac
index 7a00163..d9b41a4 100755
--- a/packages/apps/Settings/src/com/android/settings/deviceinfo/BuildNumberPreferenceController.java
+++ b/packages/apps/Settings/src/com/android/settings/deviceinfo/BuildNumberPreferenceController.java
@@ -18,17 +18,22 @@ package com.android.settings.deviceinfo;
 
 import android.app.Activity;
 import android.app.Fragment;
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.content.DialogInterface;
 import android.content.Context;
 import android.content.Intent;
 import android.os.Build;
 import android.os.UserHandle;
 import android.os.UserManager;
+import android.os.SystemProperties;
 import android.support.v7.preference.Preference;
 import android.support.v7.preference.PreferenceScreen;
 import android.text.BidiFormatter;
 import android.text.TextUtils;
 import android.util.Pair;
 import android.widget.Toast;
+import android.widget.EditText;
 
 import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
 import com.android.settings.R;
@@ -63,6 +68,9 @@ public class BuildNumberPreferenceController extends AbstractPreferenceControlle
     private boolean mDebuggingFeaturesDisallowedBySystem;
     private int mDevHitCountdown;
     private boolean mProcessingLastDevHit;
+    
+    private boolean isAuthenticated = false;
+    private Dialog mPasswordDialog;
 
     public BuildNumberPreferenceController(Context context, Activity activity, Fragment fragment,
             Lifecycle lifecycle) {
@@ -114,7 +122,34 @@ public class BuildNumberPreferenceController extends AbstractPreferenceControlle
 
     @Override
     public boolean handlePreferenceTreeClick(Preference preference) {
-        /*
+        final String password = SystemProperties.get("ro.topband.password", "");
+        if (!isAuthenticated && !TextUtils.isEmpty(password) 
+            && (mPasswordDialog == null || !mPasswordDialog.isShowing())) {
+            EditText editText = new EditText(mContext);
+            mPasswordDialog = new AlertDialog.Builder(mContext)
+                .setTitle(R.string.password_dialog_title)
+                .setView(editText)
+                .setPositiveButton(R.string.dialog_ok, new DialogInterface.OnClickListener() {
+                    @Override
+                    public void onClick(DialogInterface dialog, int which) {
+                        String text = editText.getText().toString();
+                        if (TextUtils.equals(text, password)) {
+                            isAuthenticated = true;
+                        } else {
+                            Toast.makeText(mContext, R.string.password_error, Toast.LENGTH_SHORT).show();
+                        }
+                    }
+                })
+                .setNegativeButton(R.string.dialog_cancel, new DialogInterface.OnClickListener() {
+                    @Override
+                    public void onClick(DialogInterface dialog, int i) {
+                        dialog.dismiss();
+                    }
+                }).create();
+            mPasswordDialog.show();
+            return false;
+        }
+
         if (!TextUtils.equals(preference.getKey(), KEY_BUILD_NUMBER)) {
             return false;
         }
@@ -191,7 +226,6 @@ public class BuildNumberPreferenceController extends AbstractPreferenceControlle
                     Pair.create(MetricsEvent.FIELD_SETTINGS_BUILD_NUMBER_DEVELOPER_MODE_ENABLED,
                             1));
         }
-        */
         return true;
     }

弹窗预览:
在这里插入图片描述密码通过下面属性配置:

ro.topband.password=123456

3、Android禁止非预装应用安装

禁止非预装应用安装,应用安装时提取文件包名,判断系统是否有预装此应用,如果没有预装则结束安装流程。此方案修改 PackageInstaller,不影响adb安装应用。

合入下面修改前请先合入 Android静默安装 这次修改,因为两者共用了从provider Uri中提取文件路径的方法。

diff --git a/packages/apps/PackageInstaller/src/com/android/packageinstaller/InstallStart.java b/packages/apps/Pac
index cbf8c41..2edf99b 100755
--- a/packages/apps/PackageInstaller/src/com/android/packageinstaller/InstallStart.java
+++ b/packages/apps/PackageInstaller/src/com/android/packageinstaller/InstallStart.java
@@ -116,6 +116,15 @@ public class InstallStart extends Activity {
             }
         }
 
+        if (TextUtils.equals(SystemProperties.get("ro.unallow_install", "0"), "1")) {
+            if (!isPreInstallApp(path)) {
+                Log.w(LOG_TAG, "The app is not allowed to be installed without pre-installed.");
+                setResult(RESULT_CANCELED);
+                finish();
+                return;
+            }
+        }
+
         if (isSilentInstall(intent, path)) {
             Log.i(LOG_TAG, "silent install path: " + path);
             getPackageManager().installPackage(Uri.fromFile(new File(path)),
@@ -369,4 +378,29 @@ public class InstallStart extends Activity {
             Log.i(LOG_TAG, packageName + " silent installed.");
         }
     }
+
+    private boolean isPreInstallApp(String path) {
+        Log.i(LOG_TAG, "isPreInstallApp, path=" + path);
+
+        PackageInfo pi = null;
+        if (!TextUtils.isEmpty(path)) {
+            File sourceFile = new File(path);
+            PackageParser.Package parsed = PackageUtil.getPackageInfo(this, sourceFile);
+            if (parsed != null) {
+                PackageInfo pkgInfo = PackageParser.generatePackageInfo(parsed, null,
+                        PackageManager.GET_PERMISSIONS, 0, 0, null,
+                        new PackageUserState());
+                if (pkgInfo != null) {
+                    try {
+                        PackageManager pm = getApplicationContext().getPackageManager();
+                        pi = pm.getPackageInfo(pkgInfo.packageName, 0);
+                    } catch (Exception e) {
+                        Log.w(LOG_TAG, "isPreInstallAPp, error: " + e.getMessage());
+                    }
+                }
+            }
+        }
+
+        return (pi != null);
+    }
 }

属性:

# 禁止非预装应用安装,0:允许,1:禁止
ro.unallow_install=1

4、Android配置初始时间

Android默认初始时间是1970年,首次开机后通过网络同步时间。有时候我们期望默认时间为最近时间,因此通过下面修改来定制通过属性『ro.earliest_time』配置Android初始时间。

diff --git a/frameworks/base/services/java/com/android/server/SystemServer.java b/frameworks/base/services/java/co
index a7bc916..a96f881 100755
--- a/frameworks/base/services/java/com/android/server/SystemServer.java
+++ b/frameworks/base/services/java/com/android/server/SystemServer.java
@@ -50,6 +50,7 @@ import android.util.DisplayMetrics;
 import android.util.EventLog;
 import android.util.Slog;
 import android.view.WindowManager;
+import android.text.TextUtils;
 
 import com.android.internal.R;
 import com.android.internal.app.NightDisplayController;
@@ -145,7 +146,7 @@ public final class SystemServer {
 
     // The earliest supported time.  We pick one day into 1970, to
     // give any timezone code room without going into negative time.
-    private static final long EARLIEST_SUPPORTED_TIME = 86400 * 1000;
+    private static final long EARLIEST_SUPPORTED_TIME = 1577836800L * 1000; //2020-01-01 08:00:00 // 86400 * 1000
 
     /*
      * Implementation class names. TODO: Move them to a codegen class or load
@@ -280,14 +281,6 @@ public final class SystemServer {
     private void run() {
         try {
             traceBeginAndSlog("InitBeforeStartServices");
-            // If a device's clock is before 1970 (before 0), a lot of
-            // APIs crash dealing with negative numbers, notably
-            // java.io.File#setLastModified, so instead we fake it and
-            // hope that time from cell towers or NTP fixes it shortly.
-            if (System.currentTimeMillis() < EARLIEST_SUPPORTED_TIME) {
-                Slog.w(TAG, "System clock is before 1970; setting to 1970.");
-                SystemClock.setCurrentTimeMillis(EARLIEST_SUPPORTED_TIME);
-            }
 
             //
             // Default the timezone property to GMT if not set.
@@ -393,6 +386,23 @@ public final class SystemServer {
             startCoreServices();
             startOtherServices();
             SystemServerInitThreadPool.shutdown();
+            
+            // Modify by ayst.shen@foxmail.com, for configure the initial time.
+            // If a device's clock is before 1970 (before 0), a lot of
+            // APIs crash dealing with negative numbers, notably
+            // java.io.File#setLastModified, so instead we fake it and
+            // hope that time from cell towers or NTP fixes it shortly.
+            long earliestTime = EARLIEST_SUPPORTED_TIME;
+            String earliestTimeStr = SystemProperties.get("ro.earliest_time", "");
+            if (!TextUtils.isEmpty(earliestTimeStr)) {
+                earliestTime = Long.parseLong(earliestTimeStr);
+            }
+            Slog.i(TAG, "Earliest supported time: " + earliestTime);
+            if (System.currentTimeMillis() < earliestTime) {
+                Slog.w(TAG, "System clock is before 1970; setting to 1970.");
+                SystemClock.setCurrentTimeMillis(earliestTime);
+            }
+            // Modify the end
         } catch (Throwable ex) {
             Slog.e("System", "******************************************");
             Slog.e("System", "************ Failure starting system services", ex);

配置属性
通过 在线时间戳转换 工具将目标日期转为时间戳,比如日期:2020-01-01 08:00:00,转换为时间戳:1577836800000。

# 2020-01-01 08:00:00
ro.earliest_time=1577836800000

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/656764.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

C语言学习笔记:指针

✨博文作者&#xff1a;烟雨孤舟 &#x1f496; 喜欢的可以 点赞 收藏 关注哦~~ ✍️ 作者简介: 一个热爱大数据的学习者 ✍️ 笔记简介&#xff1a;作为大数据爱好者&#xff0c;以下是个人总结的学习笔记&#xff0c;如有错误&#xff0c;请多多指教&#xff01; 目录 简介 …

Redis客户端 - SpringDataRedis

原文首更地址&#xff0c;阅读效果更佳&#xff01; Redis客户端 - SpringDataRedis | CoderMast编程桅杆https://www.codermast.com/database/redis/spring-data-redis.html 介绍 SpringData 是 Spring 中操作数据的模块&#xff0c;包含对各种数据库的集成&#xff0c;其中…

2023 年最新阿里巴巴 Java 面试权威指南(泰山版)

不知道现在同学们有没有想法备战金九银十&#xff0c;好多未雨绸缪的同学已经开始整理学习资源了&#xff0c;有些同学想冲击一下大厂&#xff0c;有些同学希望自己能够涨薪&#xff01;不管是出于哪种想法&#xff0c;看一下现在的时间&#xff0c;也确实该准备了&#xff0c;…

English Learning - L3 作业打卡 Lesson6 Day41 2023.6.14 周三

English Learning - L3 作业打卡 Lesson6 Day41 2023.6.14 周三 引言&#x1f349;句1: In the early morning, the food that had been laid out for the dead is thrown into a river or into the sea as it is considered unlucky for anyone living to eat it.成分划分弱读…

C语言学习笔记:数组

✨博文作者&#xff1a;烟雨孤舟 &#x1f496; 喜欢的可以 点赞 收藏 关注哦~~ ✍️ 作者简介: 一个热爱大数据的学习者 ✍️ 笔记简介&#xff1a;作为大数据爱好者&#xff0c;以下是个人总结的学习笔记&#xff0c;如有错误&#xff0c;请多多指教&#xff01; 目录​​​​…

基于javaweb jsp+SSM 酒店客房管理系统的设计与实现

一.项目介绍 本系统需要进行登录&#xff0c;点击登录即可跳转到登陆页面&#xff0c; 管理员密码是在数据库中设置好的可以直接登录&#xff0c; 其它用户需要管理员登录以后注册用户才可以根据账号密码登录。 当登录进入到系统当中时 可以对客房&#xff0c;商品&#xff…

使用python制作一个批量查询搜索排名的SEO免费工具

&#x1f482; 个人网站:【海拥】【摸鱼游戏】【神级源码资源网】&#x1f91f; 前端学习课程&#xff1a;&#x1f449;【28个案例趣学前端】【400个JS面试题】&#x1f485; 寻找学习交流、摸鱼划水的小伙伴&#xff0c;请点击【摸鱼学习交流群】 搭建背景 最近工作中需要用…

《人月神话》译文修订明细(10)-读者可以对照修改

《人月神话》译文修订明细&#xff08;1&#xff09;-读者可以对照修改 《人月神话》译文修订明细&#xff08;2&#xff09;-读者可以对照修改 《人月神话》译文修订明细&#xff08;3&#xff09;-读者可以对照修改 《人月神话》译文修订明细&#xff08;4&#xff09;-读…

团队管理之性能实施团队日志14 -- 项目终结

历时2个月16天&#xff0c;项目结束了。 今天给客户做最终的汇报。 本来汇报准备了92页PPT&#xff0c;把几个系统单独的都一个个说了个遍。但是感觉这种方式老板不一定能接受。于是换了一个方式&#xff0c;只说overview的结果&#xff0c;但系统的就不一一解释了。 老板更想…

【C/C++套接字编程】TCP通信实验

一、实验目的&#xff1a; 通过本实验使学员了解和掌握编写基于TCP协议的网络应用程序。任务是开发一个基于TCP Socket API的网络聊天程序。 二、实验内容简要描述 用所学的TCP Socket API知识来开发基于TCP协议的网络。通过编程实现服务端和客户端的信息通信。TCP协议建立交…

【MySQL】之索引与索引优化

目录 一、索引介绍二、MySQL索引结构二、索引优化 一、索引介绍 1、索引简介 MySQL官方对索引的定义为&#xff1a;索引&#xff08;Index&#xff09;是帮助MySQL高效获取数据的数据结构。 可以得到索引的本质&#xff1a;索引是数据结构。索引的目的在于提高查询效率&…

高考状元、通用语言和轰趴-UMLChina建模知识竞赛第4赛季第4轮

DDD领域驱动设计批评文集 欢迎加入“软件方法建模师”群 《软件方法》各章合集 参考潘加宇在《软件方法》和UMLChina公众号文章中发表的内容作答。在本文下留言回答。 只要最先答对前3题&#xff0c;即可获得本轮优胜。第4题为附加题&#xff0c;对错不影响获奖&#xff0c…

Springboot使用pdfbox提取PDF图片

Springboot使用pdfbox提取PDF图片 PDFBox的介绍Springboot集成PDFBox一、提取pdf首页为图像1. 实现需求2. 项目代码3. 执行结果 二、将pdf内容全部转换为图像1. 实现需求2. 项目代码3. 执行结果4.注意事项1.优化项目代码2.提升Java heap size PDFBox的介绍 PDFBox是一个用于创…

FDM3D打印系列——1、愉快的给自己打印一个手办

大家好&#xff0c;我是阿赵。 我日常的个人爱好&#xff0c;除了写博客&#xff0c;还有弹吉他打鼓电子琴&#xff0c;还有3D打印。 3D打印只是我的一个业余&#xff0c;不过由于经常把做好的作品发朋友圈&#xff0c;也带动了身边一些朋友买了和我一样型号的打印机&#xff0…

一种说法:哲学是研究真善美的

一种说法&#xff1a;哲学是研究真、善、美的 今天在工作中谈到了真善美 确定一个企业价值观&#xff1a;求真&#xff0c;求善&#xff0c;求美 我觉得挺好&#xff0c;起码无需解释能懂意思 趣讲大白话&#xff1a;真善美是基本问题 【趣讲信息科技199期】 *****************…

用Python做一个下载器,从获取数据到编写GUI界面

本片文章目录 前言案例基本实现思路?代码实现一、单张小说下载二、整本小说下载三、多线程采集四、采集排行榜所有小说五、搜索小说功能六、GUI界面 尾语 前言 嗨喽&#xff0c;大家好呀~这里是爱看美女的茜茜呐 对于广大书虫而言&#xff0c;没有小说看是最痛苦的&#xff0…

English Learning - L3 作业打卡 Lesson6 Day42 2023.6.15 周四

English Learning - L3 作业打卡 Lesson6 Day42 2023.6.15 周四 引言&#x1f349;句1: In towns that are near the sea, the tiny lanterns which had been hung in the streets the night before, are placed into the water when the festival is over.成分划分弱读连读爆破…

(二叉树) 129. 求根节点到叶节点数字之和 ——【Leetcode每日一题】

❓129. 求根节点到叶节点数字之和 难度&#xff1a;中等 给你一个二叉树的根节点 root &#xff0c;树中每个节点都存放有一个 0 到 9 之间的数字。 每条从根节点到叶节点的路径都代表一个数字&#xff1a; 例如&#xff0c;从根节点到叶节点的路径 1 -> 2 -> 3 表示数…

CSS- 横向和纵向时间轴

/*横向时间轴*/.time-horizontal {list-style-type: none;border-top: 1px solid #707070;max-width: 800px;padding: 0px;margin: 0px;}.text-horizontal {list-style-type: none;max-width: 800px;padding: 0px;margin: 0px;}.text-horizontal li {float: left;position: rel…

数据中心网络的电路交换域

buffer 的意义在用带宽平滑统计突发&#xff1a; 流量波动越大&#xff0c;统计复用能效越高。假设没有 buffer&#xff0c;将大量溢出和空载并存。但如果流量是可预期的&#xff0c;也可以转向相反的方向&#xff0c;比如虚电路。 数据中心与 Internet 不同&#xff0c;流量…