直接上patch
commit ab21c0433523aa79de8a8136f51c8a1e2d03c298
Author: fjasmin <fjasmin@szmadigi.com>
Date: Mon Feb 1 20:53:24 2021 +0800
add power button in the Settings app option
diff --git a/packages/apps/Settings/AndroidManifest.xml b/packages/apps/Settings/AndroidManifest.xml
index 1fd87d4c39..fe72ada00d 100755
--- a/packages/apps/Settings/AndroidManifest.xml
+++ b/packages/apps/Settings/AndroidManifest.xml
@@ -571,6 +571,34 @@
android:value="true" />
</activity>
+
+ <activity android:name="Settings$PoweroffActivity"
+ android:label="@string/poweroff"
+ android:icon="@drawable/ic_settings_security"
+ android:taskAffinity="">
+
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.DEFAULT" />
+ <category android:name="android.intent.category.VOICE_LAUNCH" />
+ <category android:name="com.android.settings.SHORTCUT" />
+ </intent-filter>
+
+ <intent-filter>
+ <action android:name="com.android.settings.action.SETTINGS" />
+ </intent-filter>
+
+ <meta-data android:name="com.android.settings.category"
+ android:value="com.android.settings.category.system" />
+
+ <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
+ android:value="com.android.settings.Poweroff" />
+
+ <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
+ android:value="true" />
+
+ </activity>
+<!-- end -->
<activity android:name="Settings$VpnSettingsActivity"
android:label="@string/vpn_settings_title"
diff --git a/packages/apps/Settings/res/values-zh-rTW/strings.xml b/packages/apps/Settings/res/values-zh-rTW/strings.xml
index 680a87aa24..ba1e790fd9 100755
--- a/packages/apps/Settings/res/values-zh-rTW/strings.xml
+++ b/packages/apps/Settings/res/values-zh-rTW/strings.xml
@@ -3278,6 +3278,7 @@
<string name="timer_invalid_time">設置失敗,設置定時開關機時間間隔需要大於3秒</string>
<string name="timer_invalid_setting">設置失敗,需要先設置定時關機時間</string>
<string name="gotolauncher">返回桌面</string>
+ <string name="poweroff">關機</string>
<string name="hide_statusbar_title">隱藏狀態欄</string>
<string name="hide_navigationbar_title">隱藏導航欄</string>
<string name="hide_lock_title">鎖定隱藏</string>
diff --git a/packages/apps/Settings/res/values/strings.xml b/packages/apps/Settings/res/values/strings.xml
index 9a1f31cbf3..0a27bdf48e 100755
--- a/packages/apps/Settings/res/values/strings.xml
+++ b/packages/apps/Settings/res/values/strings.xml
@@ -30,6 +30,7 @@
<string name="hide_navigationbar_title">Hide Navigation Bar</string>
<string name="hide_lock_title">Lock Hide Mode</string>
<string name="gotolauncher">Go to launcher3</string>
+ <string name="poweroff">Power Off</string>
<string name="dpi_setting">Screen density</string>
<!-- Strings for Dialog yes button -->
<string name="yes">"Yes"</string>
diff --git a/packages/apps/Settings/src/com/android/settings/Poweroff.java b/packages/apps/Settings/src/com/android/settings/Poweroff.java
new file mode 100755
index 0000000000..ae7b82c28e
--- /dev/null
+++ b/packages/apps/Settings/src/com/android/settings/Poweroff.java
@@ -0,0 +1,51 @@
+package com.android.settings;
+
+import android.content.Context;
+import android.os.Build;
+import android.support.v7.preference.Preference;
+import android.support.v7.preference.PreferenceGroup;
+import com.android.settings.search.Indexable;
+import com.android.internal.logging.MetricsProto.MetricsEvent;
+import android.app.Activity;
+import android.content.ComponentName;
+import android.content.Intent;
+import android.os.Bundle;
+import android.util.Log;
+
+import android.support.v7.preference.CheckBoxPreference;
+import android.support.v7.preference.ListPreference;
+import android.support.v7.preference.Preference;
+import android.support.v7.preference.PreferenceScreen;
+import android.support.v7.preference.Preference.OnPreferenceChangeListener;
+import android.provider.Settings;
+
+import android.view.Gravity;
+import android.view.WindowManager;
+import android.view.ViewGroup.LayoutParams;
+import android.widget.TextView;
+import android.graphics.PixelFormat;
+import android.graphics.PorterDuff;
+import android.os.SystemProperties;
+import android.content.res.Resources;
+
+
+public class Poweroff extends SettingsPreferenceFragment
+ implements Indexable {
+ @Override
+ public void onCreate(Bundle icicle){
+ super.onCreate(icicle);
+
+ Intent intent = new Intent();
+ intent.setAction("com.android.settings.poweroff");
+ getActivity().getApplicationContext().sendBroadcast(intent);
+
+ finish();
+ }
+
+ @Override
+ protected int getMetricsCategory() {
+ return MetricsEvent.DEVICEINFO;
+ }
+
+}
+
diff --git a/packages/apps/Settings/src/com/android/settings/Settings.java b/packages/apps/Settings/src/com/android/settings/Settings.java
index 26a9f2657b..65fb3668fe 100755
--- a/packages/apps/Settings/src/com/android/settings/Settings.java
+++ b/packages/apps/Settings/src/com/android/settings/Settings.java
@@ -73,6 +73,7 @@ public class Settings extends SettingsActivity {
public static class DevelopmentSettingsActivity extends SettingsActivity { /* empty */ }
public static class AccessibilitySettingsActivity extends SettingsActivity { /* empty */ }
public static class GotoLauncher3Activity extends SettingsActivity { /* empty */ }
+ public static class PoweroffActivity extends SettingsActivity { /* empty */ }
public static class CaptioningSettingsActivity extends SettingsActivity { /* empty */ }
public static class AccessibilityInversionSettingsActivity extends SettingsActivity { /* empty */ }
public static class AccessibilityContrastSettingsActivity extends SettingsActivity { /* empty */ }
diff --git a/packages/apps/Settings/src/com/android/settings/SettingsActivity.java b/packages/apps/Settings/src/com/android/settings/SettingsActivity.java
index e7ee9ab8f0..9c8102005e 100755
--- a/packages/apps/Settings/src/com/android/settings/SettingsActivity.java
+++ b/packages/apps/Settings/src/com/android/settings/SettingsActivity.java
@@ -260,6 +260,7 @@ public class SettingsActivity extends SettingsDrawerActivity
Settings.DeviceInfoSettingsActivity.class.getName(),
Settings.AccessibilitySettingsActivity.class.getName(),
Settings.GotoLauncher3Activity.class.getName(),
+ Settings.PoweroffActivity.class.getName(),
Settings.PrintSettingsActivity.class.getName(),
Settings.PaymentSettingsActivity.class.getName(),
Settings.HdmiSettingsActivity.class.getName()
@@ -275,6 +276,7 @@ public class SettingsActivity extends SettingsDrawerActivity
TetherSettings.class.getName(),
WifiP2pSettings.class.getName(),
GotoLauncher3.class.getName(),
+ Poweroff.class.getName(),
VpnSettings.class.getName(),
DateTimeSettings.class.getName(),
LocaleListEditor.class.getName(),
@@ -1075,6 +1077,9 @@ public class SettingsActivity extends SettingsDrawerActivity
setTileEnabled(new ComponentName(packageName,
Settings.GotoLauncher3Activity.class.getName()),
true, isAdmin, pm);
+ setTileEnabled(new ComponentName(packageName,
+ Settings.PoweroffActivity.class.getName()),
+ true, isAdmin, pm);
setTileEnabled(new ComponentName(packageName,