am 5d1462f7: Merge "Fix issue #21930140: Add config to turn off auto power features" into mnc-dev

* commit '5d1462f708e88b54e5afe4a3c20902b05c37db97':
  Fix issue #21930140: Add config to turn off auto power features
This commit is contained in:
Dianne Hackborn
2015-06-22 18:40:37 +00:00
committed by Android Git Automerger
4 changed files with 60 additions and 23 deletions

View File

@@ -157,6 +157,15 @@
ActivityManager based on screen size. --> ActivityManager based on screen size. -->
<integer name="config_extraFreeKbytesAdjust">0</integer> <integer name="config_extraFreeKbytesAdjust">0</integer>
<!-- Set this to true to enable the platform's auto-power-save modes like doze and
app standby. These are not enabled by default because they require a standard
cloud-to-device messaging service for apps to interact correctly with the modes
(such as to be able to deliver an instant message to the device even when it is
dozing). This should be enabled if you have such services and expect apps to
correctly use them when installed on your device. Otherwise, keep this disabled
so that applications can still use their own mechanisms. -->
<bool name="config_enableAutoPowerModes">false</bool>
<!-- The duration (in milliseconds) that the radio will scan for a signal <!-- The duration (in milliseconds) that the radio will scan for a signal
when there's no network connection. If the scan doesn't timeout, use zero --> when there's no network connection. If the scan doesn't timeout, use zero -->
<integer name="config_radioScanningTimeout">0</integer> <integer name="config_radioScanningTimeout">0</integer>

View File

@@ -251,6 +251,7 @@
<java-symbol type="bool" name="config_bluetooth_le_peripheral_mode_supported" /> <java-symbol type="bool" name="config_bluetooth_le_peripheral_mode_supported" />
<java-symbol type="bool" name="config_cellBroadcastAppLinks" /> <java-symbol type="bool" name="config_cellBroadcastAppLinks" />
<java-symbol type="bool" name="config_duplicate_port_omadm_wappush" /> <java-symbol type="bool" name="config_duplicate_port_omadm_wappush" />
<java-symbol type="bool" name="config_enableAutoPowerModes" />
<java-symbol type="bool" name="config_enable_emergency_call_while_sim_locked" /> <java-symbol type="bool" name="config_enable_emergency_call_while_sim_locked" />
<java-symbol type="bool" name="config_enable_puk_unlock_screen" /> <java-symbol type="bool" name="config_enable_puk_unlock_screen" />
<java-symbol type="bool" name="config_enableBurnInProtection" /> <java-symbol type="bool" name="config_enableBurnInProtection" />

View File

@@ -97,9 +97,6 @@ public class DeviceIdleController extends SystemService
private static final String ACTION_STEP_IDLE_STATE = private static final String ACTION_STEP_IDLE_STATE =
"com.android.server.device_idle.STEP_IDLE_STATE"; "com.android.server.device_idle.STEP_IDLE_STATE";
private static final String ACTION_ENTER_INACTIVE_STATE =
"com.android.server.device_idle.ENTER_INACTIVE_STATE";
private AlarmManager mAlarmManager; private AlarmManager mAlarmManager;
private IBatteryStats mBatteryStats; private IBatteryStats mBatteryStats;
private PowerManagerInternal mLocalPowerManager; private PowerManagerInternal mLocalPowerManager;
@@ -112,7 +109,7 @@ public class DeviceIdleController extends SystemService
private Intent mIdleIntent; private Intent mIdleIntent;
private Display mCurDisplay; private Display mCurDisplay;
private AnyMotionDetector mAnyMotionDetector; private AnyMotionDetector mAnyMotionDetector;
private boolean mIdleDisabled; private boolean mEnabled;
private boolean mScreenOn; private boolean mScreenOn;
private boolean mCharging; private boolean mCharging;
private boolean mSigMotionActive; private boolean mSigMotionActive;
@@ -191,10 +188,6 @@ public class DeviceIdleController extends SystemService
synchronized (DeviceIdleController.this) { synchronized (DeviceIdleController.this) {
stepIdleStateLocked(); stepIdleStateLocked();
} }
} else if (ACTION_ENTER_INACTIVE_STATE.equals(intent.getAction())) {
synchronized (DeviceIdleController.this) {
enterInactiveStateLocked();
}
} }
} }
}; };
@@ -612,6 +605,8 @@ public class DeviceIdleController extends SystemService
final PackageManager pm = getContext().getPackageManager(); final PackageManager pm = getContext().getPackageManager();
synchronized (this) { synchronized (this) {
mEnabled = getContext().getResources().getBoolean(
com.android.internal.R.bool.config_enableAutoPowerModes);
SystemConfig sysConfig = SystemConfig.getInstance(); SystemConfig sysConfig = SystemConfig.getInstance();
ArraySet<String> allowPower = sysConfig.getAllowInPowerSave(); ArraySet<String> allowPower = sysConfig.getAllowInPowerSave();
for (int i=0; i<allowPower.size(); i++) { for (int i=0; i<allowPower.size(); i++) {
@@ -881,7 +876,7 @@ public class DeviceIdleController extends SystemService
void becomeInactiveIfAppropriateLocked() { void becomeInactiveIfAppropriateLocked() {
if (DEBUG) Slog.d(TAG, "becomeInactiveIfAppropriateLocked()"); if (DEBUG) Slog.d(TAG, "becomeInactiveIfAppropriateLocked()");
if (!mScreenOn && !mCharging && !mIdleDisabled && mState == STATE_ACTIVE) { if (!mScreenOn && !mCharging && mEnabled && mState == STATE_ACTIVE) {
// Screen has turned off; we are now going to become inactive and start // Screen has turned off; we are now going to become inactive and start
// waiting to see if we will ultimately go idle. // waiting to see if we will ultimately go idle.
mState = STATE_INACTIVE; mState = STATE_INACTIVE;
@@ -1216,8 +1211,12 @@ public class DeviceIdleController extends SystemService
pw.println(" Completely disable device idle mode."); pw.println(" Completely disable device idle mode.");
pw.println(" enable"); pw.println(" enable");
pw.println(" Re-enable device idle mode after it had previously been disabled."); pw.println(" Re-enable device idle mode after it had previously been disabled.");
pw.println(" whitelist"); pw.println(" enabled");
pw.println(" Print 1 if device idle mode is currently enabled, else 0.");
pw.println(" whitelist [package ...]");
pw.println(" Add (prefix with +) or remove (prefix with -) packages."); pw.println(" Add (prefix with +) or remove (prefix with -) packages.");
pw.println(" tempwhitelist [package ..]");
pw.println(" Temporarily place packages in whitelist for 10 seconds.");
} }
void dump(FileDescriptor fd, PrintWriter pw, String[] args) { void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
@@ -1252,8 +1251,8 @@ public class DeviceIdleController extends SystemService
return; return;
} else if ("disable".equals(arg)) { } else if ("disable".equals(arg)) {
synchronized (this) { synchronized (this) {
if (!mIdleDisabled) { if (mEnabled) {
mIdleDisabled = true; mEnabled = false;
becomeActiveLocked("disabled", Process.myUid()); becomeActiveLocked("disabled", Process.myUid());
pw.println("Idle mode disabled"); pw.println("Idle mode disabled");
} }
@@ -1261,13 +1260,18 @@ public class DeviceIdleController extends SystemService
return; return;
} else if ("enable".equals(arg)) { } else if ("enable".equals(arg)) {
synchronized (this) { synchronized (this) {
if (mIdleDisabled) { if (!mEnabled) {
mIdleDisabled = false; mEnabled = true;
becomeInactiveIfAppropriateLocked(); becomeInactiveIfAppropriateLocked();
pw.println("Idle mode enabled"); pw.println("Idle mode enabled");
} }
} }
return; return;
} else if ("enabled".equals(arg)) {
synchronized (this) {
pw.println(mEnabled ? "1" : " 0");
}
return;
} else if ("whitelist".equals(arg)) { } else if ("whitelist".equals(arg)) {
i++; i++;
while (i < args.length) { while (i < args.length) {
@@ -1364,9 +1368,9 @@ public class DeviceIdleController extends SystemService
} }
} }
pw.print(" mEnabled="); pw.println(mEnabled);
pw.print(" mSigMotionSensor="); pw.println(mSigMotionSensor); pw.print(" mSigMotionSensor="); pw.println(mSigMotionSensor);
pw.print(" mCurDisplay="); pw.println(mCurDisplay); pw.print(" mCurDisplay="); pw.println(mCurDisplay);
pw.print(" mIdleDisabled="); pw.println(mIdleDisabled);
pw.print(" mScreenOn="); pw.println(mScreenOn); pw.print(" mScreenOn="); pw.println(mScreenOn);
pw.print(" mCharging="); pw.println(mCharging); pw.print(" mCharging="); pw.println(mCharging);
pw.print(" mSigMotionActive="); pw.println(mSigMotionActive); pw.print(" mSigMotionActive="); pw.println(mSigMotionActive);

View File

@@ -35,8 +35,6 @@ import android.content.ContentResolver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
import android.content.SyncAdapterType;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo; import android.content.pm.PackageInfo;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.content.pm.ParceledListSlice; import android.content.pm.ParceledListSlice;
@@ -74,7 +72,6 @@ import com.android.internal.app.IBatteryStats;
import com.android.internal.os.BackgroundThread; import com.android.internal.os.BackgroundThread;
import com.android.internal.os.SomeArgs; import com.android.internal.os.SomeArgs;
import com.android.internal.util.IndentingPrintWriter; import com.android.internal.util.IndentingPrintWriter;
import com.android.server.DeviceIdleController;
import com.android.server.SystemService; import com.android.server.SystemService;
import java.io.BufferedReader; import java.io.BufferedReader;
@@ -138,6 +135,7 @@ public class UsageStatsService extends SystemService implements
long mRealTimeSnapshot; long mRealTimeSnapshot;
long mSystemTimeSnapshot; long mSystemTimeSnapshot;
boolean mAppIdleEnabled;
boolean mAppIdleParoled; boolean mAppIdleParoled;
private boolean mScreenOn; private boolean mScreenOn;
private long mLastAppIdleParoledTime; private long mLastAppIdleParoledTime;
@@ -175,10 +173,15 @@ public class UsageStatsService extends SystemService implements
getContext().registerReceiverAsUser(new UserActionsReceiver(), UserHandle.ALL, userActions, getContext().registerReceiverAsUser(new UserActionsReceiver(), UserHandle.ALL, userActions,
null, null); null, null);
IntentFilter deviceStates = new IntentFilter(BatteryManager.ACTION_CHARGING); mAppIdleEnabled = getContext().getResources().getBoolean(
deviceStates.addAction(BatteryManager.ACTION_DISCHARGING); com.android.internal.R.bool.config_enableAutoPowerModes);
deviceStates.addAction(PowerManager.ACTION_DEVICE_IDLE_MODE_CHANGED); if (mAppIdleEnabled) {
getContext().registerReceiver(new DeviceStateReceiver(), deviceStates); IntentFilter deviceStates = new IntentFilter(BatteryManager.ACTION_CHARGING);
deviceStates.addAction(BatteryManager.ACTION_DISCHARGING);
deviceStates.addAction(PowerManager.ACTION_DEVICE_IDLE_MODE_CHANGED);
getContext().registerReceiver(new DeviceStateReceiver(), deviceStates);
}
synchronized (mLock) { synchronized (mLock) {
cleanUpRemovedUsersLocked(); cleanUpRemovedUsersLocked();
} }
@@ -186,7 +189,6 @@ public class UsageStatsService extends SystemService implements
mRealTimeSnapshot = SystemClock.elapsedRealtime(); mRealTimeSnapshot = SystemClock.elapsedRealtime();
mSystemTimeSnapshot = System.currentTimeMillis(); mSystemTimeSnapshot = System.currentTimeMillis();
publishLocalService(UsageStatsManagerInternal.class, new LocalService()); publishLocalService(UsageStatsManagerInternal.class, new LocalService());
publishBinderService(Context.USAGE_STATS_SERVICE, new BinderService()); publishBinderService(Context.USAGE_STATS_SERVICE, new BinderService());
} }
@@ -342,6 +344,10 @@ public class UsageStatsService extends SystemService implements
/** Check all running users' or specified user's apps to see if they enter an idle state. */ /** Check all running users' or specified user's apps to see if they enter an idle state. */
void checkIdleStates(int checkUserId) { void checkIdleStates(int checkUserId) {
if (!mAppIdleEnabled) {
return;
}
final int[] userIds; final int[] userIds;
try { try {
if (checkUserId == UserHandle.USER_ALL) { if (checkUserId == UserHandle.USER_ALL) {
@@ -772,6 +778,10 @@ public class UsageStatsService extends SystemService implements
private boolean isAppIdleFiltered(String packageName, int userId, private boolean isAppIdleFiltered(String packageName, int userId,
UserUsageStatsService userService, long timeNow, long screenOnTime) { UserUsageStatsService userService, long timeNow, long screenOnTime) {
if (packageName == null) return false; if (packageName == null) return false;
// If not enabled at all, of course nobody is ever idle.
if (!mAppIdleEnabled) {
return false;
}
synchronized (mLock) { synchronized (mLock) {
// Temporary exemption, probably due to device charging or occasional allowance to // Temporary exemption, probably due to device charging or occasional allowance to
// be allowed to sync, etc. // be allowed to sync, etc.
@@ -900,6 +910,19 @@ public class UsageStatsService extends SystemService implements
pw.print(" mAppIdleParoleDurationMillis="); pw.print(" mAppIdleParoleDurationMillis=");
TimeUtils.formatDuration(mAppIdleParoleDurationMillis, pw); TimeUtils.formatDuration(mAppIdleParoleDurationMillis, pw);
pw.println(); pw.println();
pw.println();
pw.print("mAppIdleEnabled="); pw.print(mAppIdleEnabled);
pw.print(" mAppIdleParoled="); pw.print(mAppIdleParoled);
pw.print(" mScreenOn="); pw.println(mScreenOn);
pw.print("mLastAppIdleParoledTime=");
TimeUtils.formatDuration(mLastAppIdleParoledTime, pw);
pw.println();
pw.print("mScreenOnTime="); TimeUtils.formatDuration(mScreenOnTime, pw);
pw.println();
pw.print("mScreenOnSystemTimeSnapshot=");
TimeUtils.formatDuration(mScreenOnSystemTimeSnapshot, pw);
pw.println();
} }
} }