[美格2290][Android11]常用的framework修改

文章目录

    • 开发平台基本信息
    • 问题描述
    • 解决方法
      • 修复耳机图标不显示问题
      • 时间显示修改为24小时制
      • 移除安全模式
      • 修复系统自带文件浏览器无法识别U盘的问题
      • 关闭双击电源键打开摄像头的功能
      • 去除Launcher3顶部搜索栏
      • 默认关闭GPS
      • Settings去掉电池剩余可用时间显示

开发平台基本信息

芯片: QCM2290
版本: Android 11
kernel: msm-4.9

问题描述

Android原生默认开启了很多功能,是我们不需要用到的,在系统移植的第一步,就是将一些不必要的东西进行移除,并且添加一些公司系统的通用功能,本文主要针对一些原生功能的简单定制,主要是framework的修改。

解决方法

修复耳机图标不显示问题

diff --git a/frameworks/base/packages/SystemUI/res/values/config.xml b/frameworks/base/packages/SystemUI/res/values/config.xml
index 9b760d6a5c..1d0a48f13e 100644
--- a/frameworks/base/packages/SystemUI/res/values/config.xml
+++ b/frameworks/base/packages/SystemUI/res/values/config.xml
@@ -540,7 +540,6 @@
      -->
     <string-array name="config_statusBarIconBlackList" translatable="false">
         <item>@*android:string/status_bar_rotateitem>
-        <item>@*android:string/status_bar_headsetitem>
     string-array>

     
-    <string name="def_time_format" translatable="false">12string>
+    <string name="def_time_format" translatable="false">24string>
 resources>

移除安全模式

diff --git a/frameworks/base/services/core/java/com/android/server/power/ShutdownThread.java b/frameworks/base/services/core/java/com/android/server/power/ShutdownThread.java
index e787d16163..b5fc2d7ba5 100644
--- a/frameworks/base/services/core/java/com/android/server/power/ShutdownThread.java
+++ b/frameworks/base/services/core/java/com/android/server/power/ShutdownThread.java
@@ -258,7 +258,7 @@ public final class ShutdownThread extends Thread {
         }

         mReboot = true;
-        mRebootSafeMode = true;
+        mRebootSafeMode = false;
         mRebootHasProgressBar = false;
         mReason = null;
         shutdownInner(context, confirm);
diff --git a/frameworks/base/services/core/java/com/android/server/wm/WindowManagerService.java b/frameworks/base/services/core/java/com/android/server/wm/WindowManagerService.java
index f01b0694a6..a028fb6021 100644
--- a/frameworks/base/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/frameworks/base/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -4654,7 +4654,8 @@ public class WindowManagerService extends IWindowManager.Stub
             ProtoLog.i(WM_ERROR, "SAFE MODE not enabled");
         }
         mPolicy.setSafeMode(mSafeMode);
-        return mSafeMode;
+        // return mSafeMode;
+        return false;
     }

     public void displayReady() {

修复系统自带文件浏览器无法识别U盘的问题

diff --git a/frameworks/base/services/core/java/com/android/server/StorageManagerService.java b/frameworks/base/services/core/java/com/android/server/StorageManagerService.java
index c5b7695b4a..646309d86b 100644
--- a/frameworks/base/services/core/java/com/android/server/StorageManagerService.java
+++ b/frameworks/base/services/core/java/com/android/server/StorageManagerService.java
@@ -1526,7 +1526,7 @@ class StorageManagerService extends IStorageManager.Stub

             // Adoptable public disks are visible to apps, since they meet
             // public API requirement of being in a stable location.
-            if (vol.disk.isAdoptable()) {
+            if (vol.disk.isAdoptable() || vol.disk.isUsb()) {
                 vol.mountFlags |= VolumeInfo.MOUNT_FLAG_VISIBLE;
             }

关闭双击电源键打开摄像头的功能

diff --git a/frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java b/frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
index 48c1b20cad..f868c5d507 100644
--- a/frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
+++ b/frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
@@ -2329,6 +2329,7 @@ class DatabaseHelper extends SQLiteOpenHelper {
             // Allow mock locations default, based on build
             loadSetting(stmt, Settings.Secure.ALLOW_MOCK_LOCATION,
                     "1".equals(SystemProperties.get("ro.allow.mock.location")) ? 1 : 0);
+            loadSetting(stmt, "camera_double_tap_power_gesture_disabled", 1);

             loadSecure35Settings(stmt);


去除Launcher3顶部搜索栏

diff --git a/packages/apps/Launcher3/res/layout/search_container_workspace.xml b/packages/apps/Launcher3/res/layout/search_container_workspace.xml
index 1c617b1742..1fd1721393 100644
--- a/packages/apps/Launcher3/res/layout/search_container_workspace.xml
+++ b/packages/apps/Launcher3/res/layout/search_container_workspace.xml
@@ -21,10 +21,4 @@
         android:layout_height="0dp"
         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"/>
-</com.android.launcher3.qsb.QsbContainerView>
\ No newline at end of file
+</com.android.launcher3.qsb.QsbContainerView>
diff --git a/packages/apps/Launcher3/src/com/android/launcher3/Workspace.java b/packages/apps/Launcher3/src/com/android/launcher3/Workspace.java
index a6283ff253..c7344d02c7 100644
--- a/packages/apps/Launcher3/src/com/android/launcher3/Workspace.java
+++ b/packages/apps/Launcher3/src/com/android/launcher3/Workspace.java
@@ -513,11 +513,11 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
                     .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");
-        }
+        // 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 removeAllWorkspaceScreens() {


默认关闭GPS

diff --git a/frameworks/base/packages/SettingsProvider/res/values/defaults.xml b/frameworks/base/packages/SettingsProvider/res/values/defaults.xml
old mode 100644
new mode 100755
index 5f47cfe02a..5d81a0d2aa
--- a/frameworks/base/packages/SettingsProvider/res/values/defaults.xml
+++ b/frameworks/base/packages/SettingsProvider/res/values/defaults.xml
@@ -40,7 +40,7 @@
     <bool name="def_wifi_display_on">falsebool>
     <bool name="def_install_non_market_apps">falsebool>
     
-    <integer name="def_location_mode">3integer>
+    <integer name="def_location_mode">0integer>
     <bool name="assisted_gps_enabled">truebool>
     <bool name="def_netstats_enabled">truebool>
     <bool name="def_usb_mass_storage_enabled">truebool>

Settings去掉电池剩余可用时间显示

diff --git a/packages/apps/Settings/res/layout/battery_header.xml b/packages/apps/Settings/res/layout/battery_header.xml
old mode 100644
new mode 100755
index dca0972a79..6033f0b8d5
--- a/packages/apps/Settings/res/layout/battery_header.xml
+++ b/packages/apps/Settings/res/layout/battery_header.xml
@@ -39,14 +39,14 @@
             android:textAppearance="@style/TextAppearance.EntityHeaderTitle"
             android:textSize="36sp" />

-        <TextView
-            android:id="@+id/summary1"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:layout_marginTop="8dp"
-            android:minLines="3"
-            android:textAppearance="@android:style/TextAppearance.DeviceDefault.Small"/>
-            android:textColor="?android:attr/textColorPrimary"/>
+        <!-- <TextView                                                                        -->
+        <!--     android:id="@+id/summary1"                                                   -->
+        <!--     android:layout_width="match_parent"                                          -->
+        <!--     android:layout_height="wrap_content"                                         -->
+        <!--     android:layout_marginTop="8dp"                                               -->
+        <!--     android:minLines="3"                                                         -->
+        <!--     android:textAppearance="@android:style/TextAppearance.DeviceDefault.Small"/> -->
+        <!--     android:textColor="?android:attr/textColorPrimary"/>                         -->

     </LinearLayout>

diff --git a/packages/apps/Settings/res/xml/power_usage_summary.xml b/packages/apps/Settings/res/xml/power_usage_summary.xml
old mode 100644
new mode 100755
index 005ce17f36..166d609910
--- a/packages/apps/Settings/res/xml/power_usage_summary.xml
+++ b/packages/apps/Settings/res/xml/power_usage_summary.xml
@@ -51,7 +51,7 @@
         android:summary="@string/battery_percentage_description"
         settings:controller="com.android.settings.display.BatteryPercentagePreferenceController" />

-
+    <!--
     <com.android.settings.fuelgauge.PowerGaugePreference
         android:key="last_full_charge"
         android:title="@string/battery_last_full_charge"
@@ -62,7 +62,7 @@
         android:key="screen_usage"
         android:title="@string/device_screen_usage"
         android:selectable="false" />
-
+-->
     <com.android.settingslib.widget.FooterPreference
         android:key="power_usage_footer"
         android:title="@string/battery_footer_summary"
diff --git a/packages/apps/Settings/src/com/android/settings/fuelgauge/BatteryHeaderPreferenceController.java b/packages/apps/Settings/src/com/android/settings/fuelgauge/BatteryHeaderPreferenceController.java
old mode 100644
new mode 100755
index 468d8c52a4..0605de5e71
--- a/packages/apps/Settings/src/com/android/settings/fuelgauge/BatteryHeaderPreferenceController.java
+++ b/packages/apps/Settings/src/com/android/settings/fuelgauge/BatteryHeaderPreferenceController.java
@@ -92,7 +92,7 @@ public class BatteryHeaderPreferenceController extends BasePreferenceController
         mBatteryMeterView = mBatteryLayoutPref
                 .findViewById(R.id.battery_header_icon);
         mBatteryPercentText = mBatteryLayoutPref.findViewById(R.id.battery_percent);
-        mSummary1 = mBatteryLayoutPref.findViewById(R.id.summary1);
+        // mSummary1 = mBatteryLayoutPref.findViewById(R.id.summary1);

         quickUpdateHeaderPreference();
     }
@@ -114,9 +114,9 @@ public class BatteryHeaderPreferenceController extends BasePreferenceController
         mBatteryPercentText.setText(formatBatteryPercentageText(info.batteryLevel));
         if (!mBatteryStatusFeatureProvider.triggerBatteryStatusUpdate(this, info)) {
             if (info.remainingLabel == null) {
-                mSummary1.setText(info.statusLabel);
+            // mSummary1.setText(info.statusLabel);
             } else {
-                mSummary1.setText(info.remainingLabel);
+            // mSummary1.setText(info.remainingLabel);
             }
         }

diff --git a/packages/apps/Settings/src/com/android/settings/fuelgauge/BatteryInfo.java b/packages/apps/Settings/src/com/android/settings/fuelgauge/BatteryInfo.java
old mode 100644
new mode 100755
index 1935c35218..8027046e9e
--- a/packages/apps/Settings/src/com/android/settings/fuelgauge/BatteryInfo.java
+++ b/packages/apps/Settings/src/com/android/settings/fuelgauge/BatteryInfo.java
@@ -255,10 +255,12 @@ public class BatteryInfo {
             info.remainingTimeUs = chargeTime;
             CharSequence timeString = StringUtil.formatElapsedTime(context,
                     PowerUtil.convertUsToMs(info.remainingTimeUs), false /* withSeconds */);
-            int resId = R.string.power_charging_duration;
-            info.remainingLabel = context.getString(
-                    R.string.power_remaining_charging_duration_only, timeString);
-            info.chargeLabel = context.getString(resId, info.batteryPercentString, timeString);
+            info.remainingLabel = null;
+            info.chargeLabel = info.batteryPercentString;
+            // int resId = R.string.power_charging_duration;
+            // info.remainingLabel = context.getString(
+                    // R.string.power_remaining_charging_duration_only, timeString);
+            // info.chargeLabel = context.getString(resId, info.batteryPercentString, timeString);
         } else {
             final String chargeStatusLabel = Utils.getBatteryStatus(context, batteryBroadcast);
             info.remainingLabel = null;
@@ -273,20 +275,23 @@ public class BatteryInfo {
         final long drainTimeUs = PowerUtil.convertMsToUs(estimate.getEstimateMillis());
         if (drainTimeUs > 0) {
             info.remainingTimeUs = drainTimeUs;
-            info.remainingLabel = PowerUtil.getBatteryRemainingStringFormatted(
-                    context,
-                    PowerUtil.convertUsToMs(drainTimeUs),
-                    null /* percentageString */,
-                    estimate.isBasedOnUsage() && !shortString
-            );
-            info.chargeLabel = PowerUtil.getBatteryRemainingStringFormatted(
-                    context,
-                    PowerUtil.convertUsToMs(drainTimeUs),
-                    info.batteryPercentString,
-                    estimate.isBasedOnUsage() && !shortString
-            );
-            info.suggestionLabel = PowerUtil.getBatteryTipStringFormatted(
-                    context, PowerUtil.convertUsToMs(drainTimeUs));
+            //info.remainingLabel = PowerUtil.getBatteryRemainingStringFormatted(
+            //        context,
+            //        PowerUtil.convertUsToMs(drainTimeUs),
+            //        null /* percentageString */,
+            //        estimate.isBasedOnUsage() && !shortString
+            //);
+            //info.chargeLabel = PowerUtil.getBatteryRemainingStringFormatted(
+            //        context,
+             //       PowerUtil.convertUsToMs(drainTimeUs),
+            //        info.batteryPercentString,
+            //        estimate.isBasedOnUsage() && !shortString
+           // );
+           // info.suggestionLabel = PowerUtil.getBatteryTipStringFormatted(
+           //         context, PowerUtil.convertUsToMs(drainTimeUs));
+            info.remainingLabel = null;
+            info.suggestionLabel = null;
+            info.chargeLabel = info.batteryPercentString;
         } else {
             info.remainingLabel = null;
             info.suggestionLabel = null;
diff --git a/packages/apps/Settings/src/com/android/settings/fuelgauge/PowerUsageSummary.java b/packages/apps/Settings/src/com/android/settings/fuelgauge/PowerUsageSummary.java
old mode 100644
new mode 100755
index 3a5f0ba8d2..caa6939a48
--- a/packages/apps/Settings/src/com/android/settings/fuelgauge/PowerUsageSummary.java
+++ b/packages/apps/Settings/src/com/android/settings/fuelgauge/PowerUsageSummary.java
@@ -67,8 +67,8 @@ public class PowerUsageSummary extends PowerUsageBase implements OnLongClickList

     private static final String KEY_BATTERY_HEADER = "battery_header";

-    private static final String KEY_SCREEN_USAGE = "screen_usage";
-    private static final String KEY_TIME_SINCE_LAST_FULL_CHARGE = "last_full_charge";
+    // private static final String KEY_SCREEN_USAGE = "screen_usage";
+    // private static final String KEY_TIME_SINCE_LAST_FULL_CHARGE = "last_full_charge";

     @VisibleForTesting
     static final int BATTERY_INFO_LOADER = 1;
@@ -78,10 +78,10 @@ public class PowerUsageSummary extends PowerUsageBase implements OnLongClickList
     static final int MENU_ADVANCED_BATTERY = Menu.FIRST + 1;
     public static final int DEBUG_INFO_LOADER = 3;

-    @VisibleForTesting
-    PowerGaugePreference mScreenUsagePref;
-    @VisibleForTesting
-    PowerGaugePreference mLastFullChargePref;
+    // @VisibleForTesting
+    // PowerGaugePreference mScreenUsagePref;
+    // @VisibleForTesting
+    // PowerGaugePreference mLastFullChargePref;
     @VisibleForTesting
     PowerUsageFeatureProvider mPowerFeatureProvider;
     @VisibleForTesting
@@ -119,7 +119,7 @@ public class PowerUsageSummary extends PowerUsageBase implements OnLongClickList
                 public void onLoadFinished(Loader<BatteryInfo> loader, BatteryInfo batteryInfo) {
                     mBatteryHeaderPreferenceController.updateHeaderPreference(batteryInfo);
                     mBatteryInfo = batteryInfo;
-                    updateLastFullChargePreference();
+                    // updateLastFullChargePreference();
                 }

                 @Override
@@ -151,7 +151,7 @@ public class PowerUsageSummary extends PowerUsageBase implements OnLongClickList
                 .findViewById(R.id.battery_header_icon);
         final TextView percentRemaining =
                 mBatteryLayoutPref.findViewById(R.id.battery_percent);
-        final TextView summary1 = mBatteryLayoutPref.findViewById(R.id.summary1);
+        // final TextView summary1 = mBatteryLayoutPref.findViewById(R.id.summary1);
         BatteryInfo oldInfo = batteryInfos.get(0);
         BatteryInfo newInfo = batteryInfos.get(1);
         percentRemaining.setText(Utils.formatPercentage(oldInfo.batteryLevel));
@@ -165,7 +165,7 @@ public class PowerUsageSummary extends PowerUsageBase implements OnLongClickList
         final String NewEstimateString = mPowerFeatureProvider.getEnhancedEstimateDebugString(
                 Formatter.formatShortElapsedTime(getContext(),
                         PowerUtil.convertUsToMs(newInfo.remainingTimeUs)));
-        summary1.setText(OldEstimateString + "\n" + NewEstimateString);
+        // summary1.setText(OldEstimateString + "\n" + NewEstimateString);

         batteryView.setBatteryLevel(oldInfo.batteryLevel);
         batteryView.setCharging(!oldInfo.discharging);
@@ -215,9 +215,9 @@ public class PowerUsageSummary extends PowerUsageBase implements OnLongClickList
         initFeatureProvider();
         mBatteryLayoutPref = (LayoutPreference) findPreference(KEY_BATTERY_HEADER);

-        mScreenUsagePref = (PowerGaugePreference) findPreference(KEY_SCREEN_USAGE);
-        mLastFullChargePref = (PowerGaugePreference) findPreference(
-                KEY_TIME_SINCE_LAST_FULL_CHARGE);
+        // mScreenUsagePref = (PowerGaugePreference) findPreference(KEY_SCREEN_USAGE);
+        // mLastFullChargePref = (PowerGaugePreference) findPreference(
+        //         KEY_TIME_SINCE_LAST_FULL_CHARGE);
         mBatteryUtils = BatteryUtils.getInstance(getContext());

         restartBatteryInfoLoader();
@@ -257,7 +257,7 @@ public class PowerUsageSummary extends PowerUsageBase implements OnLongClickList

     @Override
     public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
-        menu.add(Menu.NONE, MENU_ADVANCED_BATTERY, Menu.NONE, R.string.advanced_battery_title);
+        // menu.add(Menu.NONE, MENU_ADVANCED_BATTERY, Menu.NONE, R.string.advanced_battery_title);

         super.onCreateOptionsMenu(menu, inflater);
     }
@@ -298,9 +298,9 @@ public class PowerUsageSummary extends PowerUsageBase implements OnLongClickList

         // reload BatteryInfo and updateUI
         restartBatteryInfoLoader();
-        updateLastFullChargePreference();
-        mScreenUsagePref.setSubtitle(StringUtil.formatElapsedTime(getContext(),
-                mBatteryUtils.calculateScreenUsageTime(mStatsHelper), false));
+        // updateLastFullChargePreference();
+        // mScreenUsagePref.setSubtitle(StringUtil.formatElapsedTime(getContext(),
+        //         mBatteryUtils.calculateScreenUsageTime(mStatsHelper), false));
     }

     @VisibleForTesting
@@ -317,17 +317,17 @@ public class PowerUsageSummary extends PowerUsageBase implements OnLongClickList
     void updateLastFullChargePreference() {
         if (mBatteryInfo != null && mBatteryInfo.averageTimeToDischarge
                 != EstimateKt.AVERAGE_TIME_TO_DISCHARGE_UNKNOWN) {
-            mLastFullChargePref.setTitle(R.string.battery_full_charge_last);
-            mLastFullChargePref.setSubtitle(
-                    StringUtil.formatElapsedTime(getContext(), mBatteryInfo.averageTimeToDischarge,
-                            false /* withSeconds */));
+           // mLastFullChargePref.setTitle(R.string.battery_full_charge_last);
+          //  mLastFullChargePref.setSubtitle(
+          //          StringUtil.formatElapsedTime(getContext(), mBatteryInfo.averageTimeToDischarge,
+          //                  false /* withSeconds */));
         } else {
             final long lastFullChargeTime = mBatteryUtils.calculateLastFullChargeTime(mStatsHelper,
                     System.currentTimeMillis());
-            mLastFullChargePref.setTitle(R.string.battery_last_full_charge);
-            mLastFullChargePref.setSubtitle(
-                    StringUtil.formatRelativeTime(getContext(), lastFullChargeTime,
-                            false /* withSeconds */));
+           // mLastFullChargePref.setTitle(R.string.battery_last_full_charge);
+            //mLastFullChargePref.setSubtitle(
+            //        StringUtil.formatRelativeTime(getContext(), lastFullChargeTime,
+           //                 false /* withSeconds */));
         }
     }

@@ -358,8 +358,8 @@ public class PowerUsageSummary extends PowerUsageBase implements OnLongClickList
                 mBatteryInfoLoaderCallbacks);
         if (mPowerFeatureProvider.isEstimateDebugEnabled()) {
             // Set long click action for summary to show debug info
-            View header = mBatteryLayoutPref.findViewById(R.id.summary1);
-            header.setOnLongClickListener(this);
+            // View header = mBatteryLayoutPref.findViewById(R.id.summary1);
+            // header.setOnLongClickListener(this);
         }
     }


你可能感兴趣的:(Android11,framework,Android11,美格2290,耳机图标,24小时制)