国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

【干貨】Android系統(tǒng)定制基礎(chǔ)篇:第二部分(Launcher3支持鍵盤切換焦點、開發(fā)者模式密碼確認(rèn)、禁止非預(yù)裝應(yīng)用安裝、配置時間)

這篇具有很好參考價值的文章主要介紹了【干貨】Android系統(tǒng)定制基礎(chǔ)篇:第二部分(Launcher3支持鍵盤切換焦點、開發(fā)者模式密碼確認(rèn)、禁止非預(yù)裝應(yīng)用安裝、配置時間)。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

1、Android Launcher3支持鍵盤切換焦點

Android Launcher3 默認(rèn)并不支持鍵盤操作,無法切換焦點,在一些需要支持鍵盤或遙控操作的設(shè)備中無法使用,因些對 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打開開發(fā)者模式需要密碼確認(rèn)

在安全性要求比較高的產(chǎn)品中,一般會默認(rèn)關(guān)閉『adb調(diào)試』,同時禁止用戶打開『adb調(diào)試』功能。在Android8.1中默認(rèn)禁止『adb調(diào)試』只需要將下面屬性:

persist.sys.usb.config=mtp,adb

改為:

persist.sys.usb.config=mtp

Android默認(rèn)通過連續(xù)點擊『版本號』可以打開『開發(fā)者選項』,在『開發(fā)者選項』中可以打開『adb調(diào)試』,所以要禁止用戶打開『adb調(diào)試』功能,我們在用戶點擊『版本號』時彈出管理員密碼對話框,只有輸入正確的管理員密碼才可以打開『開發(fā)者選項』。修改如下:

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;
     }

彈窗預(yù)覽:
【干貨】Android系統(tǒng)定制基礎(chǔ)篇:第二部分(Launcher3支持鍵盤切換焦點、開發(fā)者模式密碼確認(rèn)、禁止非預(yù)裝應(yīng)用安裝、配置時間)密碼通過下面屬性配置:

ro.topband.password=123456

3、Android禁止非預(yù)裝應(yīng)用安裝

禁止非預(yù)裝應(yīng)用安裝,應(yīng)用安裝時提取文件包名,判斷系統(tǒng)是否有預(yù)裝此應(yīng)用,如果沒有預(yù)裝則結(jié)束安裝流程。此方案修改 PackageInstaller,不影響adb安裝應(yīng)用。

合入下面修改前請先合入 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);
+    }
 }

屬性:

# 禁止非預(yù)裝應(yīng)用安裝,0:允許,1:禁止
ro.unallow_install=1

4、Android配置初始時間

Android默認(rèn)初始時間是1970年,首次開機后通過網(wǎng)絡(luò)同步時間。有時候我們期望默認(rèn)時間為最近時間,因此通過下面修改來定制通過屬性『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);

配置屬性
通過 在線時間戳轉(zhuǎn)換 工具將目標(biāo)日期轉(zhuǎn)為時間戳,比如日期:2020-01-01 08:00:00,轉(zhuǎn)換為時間戳:1577836800000。文章來源地址http://www.zghlxwxcb.cn/news/detail-498456.html

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

到了這里,關(guān)于【干貨】Android系統(tǒng)定制基礎(chǔ)篇:第二部分(Launcher3支持鍵盤切換焦點、開發(fā)者模式密碼確認(rèn)、禁止非預(yù)裝應(yīng)用安裝、配置時間)的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實不符,請點擊違法舉報進行投訴反饋,一經(jīng)查實,立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費用

相關(guān)文章

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包