From: zhoujinjian
Date: Thu, 14 Feb 2019 17:24:00 +0800
Subject: [PATCH] feat(Policy) : 保持屏幕不灭屏feature实现
Description:
Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.SCREEN_STAY_ON_ANYWAY, 1);
说明:1保持常亮,0规定时间灭屏,系统初始化默认保持常亮
Project:android/platform/frameworks/base
---
diff --git a/api/current.txt b/api/current.txt
index 2836067..806665c 100755
--- a/api/current.txt
+++ b/api/current.txt
@@ -35044,6 +35044,7 @@
field public static final java.lang.String RADIO_CELL = "cell";
field public static final java.lang.String RADIO_NFC = "nfc";
field public static final java.lang.String RADIO_WIFI = "wifi";
+ field public static final java.lang.String SCREEN_STAY_ON_ANYWAY = "screen_stay_on_anyway";
field public static final deprecated java.lang.String SHOW_PROCESSES = "show_processes";
field public static final java.lang.String STAY_ON_WHILE_PLUGGED_IN = "stay_on_while_plugged_in";
field public static final java.lang.String TRANSITION_ANIMATION_SCALE = "transition_animation_scale";
diff --git a/api/system-current.txt b/api/system-current.txt
index a6b1cee..33bd8c9 100755
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -38098,6 +38098,7 @@
field public static final java.lang.String RADIO_CELL = "cell";
field public static final java.lang.String RADIO_NFC = "nfc";
field public static final java.lang.String RADIO_WIFI = "wifi";
+ field public static final java.lang.String SCREEN_STAY_ON_ANYWAY = "screen_stay_on_anyway";
field public static final deprecated java.lang.String SHOW_PROCESSES = "show_processes";
field public static final java.lang.String STAY_ON_WHILE_PLUGGED_IN = "stay_on_while_plugged_in";
field public static final java.lang.String THEATER_MODE_ON = "theater_mode_on";
diff --git a/api/test-current.txt b/api/test-current.txt
index e0bdeb3..40b4c5b 100755
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -35234,6 +35234,7 @@
field public static final java.lang.String RADIO_CELL = "cell";
field public static final java.lang.String RADIO_NFC = "nfc";
field public static final java.lang.String RADIO_WIFI = "wifi";
+ field public static final java.lang.String SCREEN_STAY_ON_ANYWAY = "screen_stay_on_anyway";
field public static final deprecated java.lang.String SHOW_PROCESSES = "show_processes";
field public static final java.lang.String STAY_ON_WHILE_PLUGGED_IN = "stay_on_while_plugged_in";
field public static final java.lang.String TRANSITION_ANIMATION_SCALE = "transition_animation_scale";
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
old mode 100644
new mode 100755
index 2d54fde..5961654
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -7721,6 +7721,9 @@
*/
public static final String STAY_ON_WHILE_PLUGGED_IN = "stay_on_while_plugged_in";
+ /* zhoujinjian add for disable screen off */
+ public static final String SCREEN_STAY_ON_ANYWAY = "screen_stay_on_anyway";
+
/**
* When the user has enable the option to have a "bug report" command
* in the power menu.
diff --git a/packages/SettingsProvider/res/values/defaults.xml b/packages/SettingsProvider/res/values/defaults.xml
old mode 100644
new mode 100755
index e6a14ec..5131a12
--- a/packages/SettingsProvider/res/values/defaults.xml
+++ b/packages/SettingsProvider/res/values/defaults.xml
@@ -19,6 +19,7 @@
true60000
+ 1-1falsefalse
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
old mode 100644
new mode 100755
index 9274f39..782153a
--- a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
@@ -2517,6 +2517,11 @@
mContext.getResources().getBoolean(R.bool.def_stay_on_while_plugged_in))
? 1 : 0);
+ /* zhoujinjian add for disable screen off start */
+ loadIntegerSetting(stmt, Settings.Global.SCREEN_STAY_ON_ANYWAY,
+ R.integer.def_screen_on_anyway);
+ /* zhoujinjian add for disable screen off end */
+
loadIntegerSetting(stmt, Settings.Global.WIFI_SLEEP_POLICY,
R.integer.def_wifi_sleep_policy);
diff --git a/services/core/java/com/android/server/power/PowerManagerService.java b/services/core/java/com/android/server/power/PowerManagerService.java
index f320aa2..334504e 100755
--- a/services/core/java/com/android/server/power/PowerManagerService.java
+++ b/services/core/java/com/android/server/power/PowerManagerService.java
@@ -442,6 +442,8 @@
// The stay on while plugged in setting.
// A bitfield of battery conditions under which to make the screen stay on.
private int mStayOnWhilePluggedInSetting;
+ /* zhoujinjian add for disable screen off */
+ private int mScreenStayOnAnyway;
// True if the device should stay on.
private boolean mStayOn;
@@ -785,6 +787,10 @@
resolver.registerContentObserver(Settings.Global.getUriFor(
Settings.Global.STAY_ON_WHILE_PLUGGED_IN),
false, mSettingsObserver, UserHandle.USER_ALL);
+ /* zhoujinjian add for disable screen off */
+ resolver.registerContentObserver(Settings.Global.getUriFor(
+ Settings.Global.SCREEN_STAY_ON_ANYWAY),
+ false, mSettingsObserver, UserHandle.USER_ALL);
resolver.registerContentObserver(Settings.System.getUriFor(
Settings.System.SCREEN_BRIGHTNESS),
false, mSettingsObserver, UserHandle.USER_ALL);
@@ -908,6 +914,10 @@
UserHandle.USER_CURRENT);
mStayOnWhilePluggedInSetting = Settings.Global.getInt(resolver,
Settings.Global.STAY_ON_WHILE_PLUGGED_IN, BatteryManager.BATTERY_PLUGGED_AC);
+ /* zhoujinjian add for disable screen off start*/
+ mScreenStayOnAnyway = Settings.Global.getInt(resolver,
+ Settings.Global.SCREEN_STAY_ON_ANYWAY, 0);
+ /* zhoujinjian add for disable screen off end*/
mTheaterModeEnabled = Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.THEATER_MODE_ON, 0) == 1;
mAlwaysOnEnabled = mAmbientDisplayConfiguration.alwaysOnEnabled(UserHandle.USER_CURRENT);
@@ -1653,6 +1663,13 @@
// Phase 0: Basic state updates.
updateIsPoweredLocked(mDirty);
updateStayOnLocked(mDirty);
+ /* zhoujinjian add for disable screen off start */
+ if(mScreenStayOnAnyway != 0){
+ mStayOn = true;
+ mDirty |= DIRTY_STAY_ON;
+ }
+ /* zhoujinjian add for disable screen off end */
+
updateScreenBrightnessBoostLocked(mDirty);
// Phase 1: Update wakefulness.