Loading services/java/com/android/server/DevicePolicyManagerService.java +39 −32 Original line number Original line Diff line number Diff line Loading @@ -112,6 +112,8 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { int mPasswordOwner = -1; int mPasswordOwner = -1; Handler mHandler = new Handler(); Handler mHandler = new Handler(); long mLastMaximumTimeToLock = -1; final HashMap<ComponentName, ActiveAdmin> mAdminMap final HashMap<ComponentName, ActiveAdmin> mAdminMap = new HashMap<ComponentName, ActiveAdmin>(); = new HashMap<ComponentName, ActiveAdmin>(); final ArrayList<ActiveAdmin> mAdminList final ArrayList<ActiveAdmin> mAdminList Loading Loading @@ -595,7 +597,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { new BroadcastReceiver() { new BroadcastReceiver() { @Override @Override public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) { synchronized (this) { synchronized (DevicePolicyManagerService.this) { boolean doProxyCleanup = admin.info.usesPolicy( boolean doProxyCleanup = admin.info.usesPolicy( DeviceAdminInfo.USES_POLICY_SETS_GLOBAL_PROXY); DeviceAdminInfo.USES_POLICY_SETS_GLOBAL_PROXY); mAdminList.remove(admin); mAdminList.remove(admin); Loading @@ -603,9 +605,10 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { validatePasswordOwnerLocked(); validatePasswordOwnerLocked(); syncDeviceCapabilitiesLocked(); syncDeviceCapabilitiesLocked(); if (doProxyCleanup) { if (doProxyCleanup) { resetGlobalProxy(); resetGlobalProxyLocked(); } } saveSettingsLocked(); saveSettingsLocked(); updateMaximumTimeToLockLocked(); } } } } }); }); Loading Loading @@ -826,16 +829,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { validatePasswordOwnerLocked(); validatePasswordOwnerLocked(); syncDeviceCapabilitiesLocked(); syncDeviceCapabilitiesLocked(); updateMaximumTimeToLockLocked(); long timeMs = getMaximumTimeToLock(null); if (timeMs <= 0) { timeMs = Integer.MAX_VALUE; } try { getIPowerManager().setMaximumScreenOffTimeount((int)timeMs); } catch (RemoteException e) { Slog.w(TAG, "Failure talking with power manager", e); } } } static void validateQualityConstant(int quality) { static void validateQualityConstant(int quality) { Loading Loading @@ -1606,16 +1600,31 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { DeviceAdminInfo.USES_POLICY_FORCE_LOCK); DeviceAdminInfo.USES_POLICY_FORCE_LOCK); if (ap.maximumTimeToUnlock != timeMs) { if (ap.maximumTimeToUnlock != timeMs) { ap.maximumTimeToUnlock = timeMs; ap.maximumTimeToUnlock = timeMs; saveSettingsLocked(); updateMaximumTimeToLockLocked(); } } } void updateMaximumTimeToLockLocked() { long timeMs = getMaximumTimeToLock(null); if (mLastMaximumTimeToLock == timeMs) { return; } long ident = Binder.clearCallingIdentity(); long ident = Binder.clearCallingIdentity(); try { try { saveSettingsLocked(); timeMs = getMaximumTimeToLock(null); if (timeMs <= 0) { if (timeMs <= 0) { timeMs = Integer.MAX_VALUE; timeMs = Integer.MAX_VALUE; } else { // Make sure KEEP_SCREEN_ON is disabled, since that // would allow bypassing of the maximum time to lock. Settings.System.putInt(mContext.getContentResolver(), Settings.System.STAY_ON_WHILE_PLUGGED_IN, 0); } } mLastMaximumTimeToLock = timeMs; try { try { getIPowerManager().setMaximumScreenOffTimeount((int)timeMs); getIPowerManager().setMaximumScreenOffTimeount((int)timeMs); } catch (RemoteException e) { } catch (RemoteException e) { Loading @@ -1625,8 +1634,6 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { Binder.restoreCallingIdentity(ident); Binder.restoreCallingIdentity(ident); } } } } } } public long getMaximumTimeToLock(ComponentName who) { public long getMaximumTimeToLock(ComponentName who) { synchronized (this) { synchronized (this) { Loading Loading @@ -1869,7 +1876,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { // Reset the global proxy accordingly // Reset the global proxy accordingly // Do this using system permissions, as apps cannot write to secure settings // Do this using system permissions, as apps cannot write to secure settings long origId = Binder.clearCallingIdentity(); long origId = Binder.clearCallingIdentity(); resetGlobalProxy(); resetGlobalProxyLocked(); Binder.restoreCallingIdentity(origId); Binder.restoreCallingIdentity(origId); return null; return null; } } Loading @@ -1893,20 +1900,20 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { return null; return null; } } private void resetGlobalProxy() { private void resetGlobalProxyLocked() { final int N = mAdminList.size(); final int N = mAdminList.size(); for (int i = 0; i < N; i++) { for (int i = 0; i < N; i++) { ActiveAdmin ap = mAdminList.get(i); ActiveAdmin ap = mAdminList.get(i); if (ap.specifiesGlobalProxy) { if (ap.specifiesGlobalProxy) { saveGlobalProxy(ap.globalProxySpec, ap.globalProxyExclusionList); saveGlobalProxyLocked(ap.globalProxySpec, ap.globalProxyExclusionList); return; return; } } } } // No device admins defining global proxies - reset global proxy settings to none // No device admins defining global proxies - reset global proxy settings to none saveGlobalProxy(null, null); saveGlobalProxyLocked(null, null); } } private void saveGlobalProxy(String proxySpec, String exclusionList) { private void saveGlobalProxyLocked(String proxySpec, String exclusionList) { if (exclusionList == null) { if (exclusionList == null) { exclusionList = ""; exclusionList = ""; } } Loading services/java/com/android/server/PowerManagerService.java +9 −2 Original line number Original line Diff line number Diff line Loading @@ -477,6 +477,11 @@ public class PowerManagerService extends IPowerManager.Stub } } } } int getStayOnConditionsLocked() { return mMaximumScreenOffTimeout <= 0 || mMaximumScreenOffTimeout == Integer.MAX_VALUE ? mStayOnConditions : 0; } private class SettingsObserver implements Observer { private class SettingsObserver implements Observer { private int getInt(String name, int defValue) { private int getInt(String name, int defValue) { ContentValues values = mSettings.getValues(name); ContentValues values = mSettings.getValues(name); Loading Loading @@ -760,7 +765,8 @@ public class PowerManagerService extends IPowerManager.Stub } } private void updateWakeLockLocked() { private void updateWakeLockLocked() { if (mStayOnConditions != 0 && mBatteryService.isPowered(mStayOnConditions)) { final int stayOnConditions = getStayOnConditionsLocked(); if (stayOnConditions != 0 && mBatteryService.isPowered(stayOnConditions)) { // keep the device on if we're plugged in and mStayOnWhilePluggedIn is set. // keep the device on if we're plugged in and mStayOnWhilePluggedIn is set. mStayOnWhilePluggedInScreenDimLock.acquire(); mStayOnWhilePluggedInScreenDimLock.acquire(); mStayOnWhilePluggedInPartialLock.acquire(); mStayOnWhilePluggedInPartialLock.acquire(); Loading Loading @@ -2099,7 +2105,8 @@ public class PowerManagerService extends IPowerManager.Stub // was dim // was dim steps = (int)(ANIM_STEPS*ratio); steps = (int)(ANIM_STEPS*ratio); } } if (mStayOnConditions != 0 && mBatteryService.isPowered(mStayOnConditions)) { final int stayOnConditions = getStayOnConditionsLocked(); if (stayOnConditions != 0 && mBatteryService.isPowered(stayOnConditions)) { // If the "stay on while plugged in" option is // If the "stay on while plugged in" option is // turned on, then the screen will often not // turned on, then the screen will often not // automatically turn off while plugged in. To // automatically turn off while plugged in. To Loading Loading
services/java/com/android/server/DevicePolicyManagerService.java +39 −32 Original line number Original line Diff line number Diff line Loading @@ -112,6 +112,8 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { int mPasswordOwner = -1; int mPasswordOwner = -1; Handler mHandler = new Handler(); Handler mHandler = new Handler(); long mLastMaximumTimeToLock = -1; final HashMap<ComponentName, ActiveAdmin> mAdminMap final HashMap<ComponentName, ActiveAdmin> mAdminMap = new HashMap<ComponentName, ActiveAdmin>(); = new HashMap<ComponentName, ActiveAdmin>(); final ArrayList<ActiveAdmin> mAdminList final ArrayList<ActiveAdmin> mAdminList Loading Loading @@ -595,7 +597,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { new BroadcastReceiver() { new BroadcastReceiver() { @Override @Override public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) { synchronized (this) { synchronized (DevicePolicyManagerService.this) { boolean doProxyCleanup = admin.info.usesPolicy( boolean doProxyCleanup = admin.info.usesPolicy( DeviceAdminInfo.USES_POLICY_SETS_GLOBAL_PROXY); DeviceAdminInfo.USES_POLICY_SETS_GLOBAL_PROXY); mAdminList.remove(admin); mAdminList.remove(admin); Loading @@ -603,9 +605,10 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { validatePasswordOwnerLocked(); validatePasswordOwnerLocked(); syncDeviceCapabilitiesLocked(); syncDeviceCapabilitiesLocked(); if (doProxyCleanup) { if (doProxyCleanup) { resetGlobalProxy(); resetGlobalProxyLocked(); } } saveSettingsLocked(); saveSettingsLocked(); updateMaximumTimeToLockLocked(); } } } } }); }); Loading Loading @@ -826,16 +829,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { validatePasswordOwnerLocked(); validatePasswordOwnerLocked(); syncDeviceCapabilitiesLocked(); syncDeviceCapabilitiesLocked(); updateMaximumTimeToLockLocked(); long timeMs = getMaximumTimeToLock(null); if (timeMs <= 0) { timeMs = Integer.MAX_VALUE; } try { getIPowerManager().setMaximumScreenOffTimeount((int)timeMs); } catch (RemoteException e) { Slog.w(TAG, "Failure talking with power manager", e); } } } static void validateQualityConstant(int quality) { static void validateQualityConstant(int quality) { Loading Loading @@ -1606,16 +1600,31 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { DeviceAdminInfo.USES_POLICY_FORCE_LOCK); DeviceAdminInfo.USES_POLICY_FORCE_LOCK); if (ap.maximumTimeToUnlock != timeMs) { if (ap.maximumTimeToUnlock != timeMs) { ap.maximumTimeToUnlock = timeMs; ap.maximumTimeToUnlock = timeMs; saveSettingsLocked(); updateMaximumTimeToLockLocked(); } } } void updateMaximumTimeToLockLocked() { long timeMs = getMaximumTimeToLock(null); if (mLastMaximumTimeToLock == timeMs) { return; } long ident = Binder.clearCallingIdentity(); long ident = Binder.clearCallingIdentity(); try { try { saveSettingsLocked(); timeMs = getMaximumTimeToLock(null); if (timeMs <= 0) { if (timeMs <= 0) { timeMs = Integer.MAX_VALUE; timeMs = Integer.MAX_VALUE; } else { // Make sure KEEP_SCREEN_ON is disabled, since that // would allow bypassing of the maximum time to lock. Settings.System.putInt(mContext.getContentResolver(), Settings.System.STAY_ON_WHILE_PLUGGED_IN, 0); } } mLastMaximumTimeToLock = timeMs; try { try { getIPowerManager().setMaximumScreenOffTimeount((int)timeMs); getIPowerManager().setMaximumScreenOffTimeount((int)timeMs); } catch (RemoteException e) { } catch (RemoteException e) { Loading @@ -1625,8 +1634,6 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { Binder.restoreCallingIdentity(ident); Binder.restoreCallingIdentity(ident); } } } } } } public long getMaximumTimeToLock(ComponentName who) { public long getMaximumTimeToLock(ComponentName who) { synchronized (this) { synchronized (this) { Loading Loading @@ -1869,7 +1876,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { // Reset the global proxy accordingly // Reset the global proxy accordingly // Do this using system permissions, as apps cannot write to secure settings // Do this using system permissions, as apps cannot write to secure settings long origId = Binder.clearCallingIdentity(); long origId = Binder.clearCallingIdentity(); resetGlobalProxy(); resetGlobalProxyLocked(); Binder.restoreCallingIdentity(origId); Binder.restoreCallingIdentity(origId); return null; return null; } } Loading @@ -1893,20 +1900,20 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { return null; return null; } } private void resetGlobalProxy() { private void resetGlobalProxyLocked() { final int N = mAdminList.size(); final int N = mAdminList.size(); for (int i = 0; i < N; i++) { for (int i = 0; i < N; i++) { ActiveAdmin ap = mAdminList.get(i); ActiveAdmin ap = mAdminList.get(i); if (ap.specifiesGlobalProxy) { if (ap.specifiesGlobalProxy) { saveGlobalProxy(ap.globalProxySpec, ap.globalProxyExclusionList); saveGlobalProxyLocked(ap.globalProxySpec, ap.globalProxyExclusionList); return; return; } } } } // No device admins defining global proxies - reset global proxy settings to none // No device admins defining global proxies - reset global proxy settings to none saveGlobalProxy(null, null); saveGlobalProxyLocked(null, null); } } private void saveGlobalProxy(String proxySpec, String exclusionList) { private void saveGlobalProxyLocked(String proxySpec, String exclusionList) { if (exclusionList == null) { if (exclusionList == null) { exclusionList = ""; exclusionList = ""; } } Loading
services/java/com/android/server/PowerManagerService.java +9 −2 Original line number Original line Diff line number Diff line Loading @@ -477,6 +477,11 @@ public class PowerManagerService extends IPowerManager.Stub } } } } int getStayOnConditionsLocked() { return mMaximumScreenOffTimeout <= 0 || mMaximumScreenOffTimeout == Integer.MAX_VALUE ? mStayOnConditions : 0; } private class SettingsObserver implements Observer { private class SettingsObserver implements Observer { private int getInt(String name, int defValue) { private int getInt(String name, int defValue) { ContentValues values = mSettings.getValues(name); ContentValues values = mSettings.getValues(name); Loading Loading @@ -760,7 +765,8 @@ public class PowerManagerService extends IPowerManager.Stub } } private void updateWakeLockLocked() { private void updateWakeLockLocked() { if (mStayOnConditions != 0 && mBatteryService.isPowered(mStayOnConditions)) { final int stayOnConditions = getStayOnConditionsLocked(); if (stayOnConditions != 0 && mBatteryService.isPowered(stayOnConditions)) { // keep the device on if we're plugged in and mStayOnWhilePluggedIn is set. // keep the device on if we're plugged in and mStayOnWhilePluggedIn is set. mStayOnWhilePluggedInScreenDimLock.acquire(); mStayOnWhilePluggedInScreenDimLock.acquire(); mStayOnWhilePluggedInPartialLock.acquire(); mStayOnWhilePluggedInPartialLock.acquire(); Loading Loading @@ -2099,7 +2105,8 @@ public class PowerManagerService extends IPowerManager.Stub // was dim // was dim steps = (int)(ANIM_STEPS*ratio); steps = (int)(ANIM_STEPS*ratio); } } if (mStayOnConditions != 0 && mBatteryService.isPowered(mStayOnConditions)) { final int stayOnConditions = getStayOnConditionsLocked(); if (stayOnConditions != 0 && mBatteryService.isPowered(stayOnConditions)) { // If the "stay on while plugged in" option is // If the "stay on while plugged in" option is // turned on, then the screen will often not // turned on, then the screen will often not // automatically turn off while plugged in. To // automatically turn off while plugged in. To Loading