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初始时间。文章来源:https://www.toymoban.com/news/detail-498456.html
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。文章来源地址https://www.toymoban.com/news/detail-498456.html
# 2020-01-01 08:00:00
ro.earliest_time=1577836800000
到了这里,关于【干货】Android系统定制基础篇:第二部分(Launcher3支持键盘切换焦点、开发者模式密码确认、禁止非预装应用安装、配置时间)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!