diff options
author | Jeff Brown <jeffbrown@google.com> | 2014-11-11 22:27:43 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-11-11 22:27:45 +0000 |
commit | 32f7a6d813d7f936c7aa6a1f3abe2f05022a6cd9 (patch) | |
tree | bcaa623d3f45b6e98f2cbb156d19467a5ef66585 /services | |
parent | da772234f6f9498bf02f31448bda16e9fcbd6bd2 (diff) | |
parent | 5ce1cb240b13db98fbdc21e1ef069b5f9cec8d72 (diff) | |
download | frameworks_base-32f7a6d813d7f936c7aa6a1f3abe2f05022a6cd9.zip frameworks_base-32f7a6d813d7f936c7aa6a1f3abe2f05022a6cd9.tar.gz frameworks_base-32f7a6d813d7f936c7aa6a1f3abe2f05022a6cd9.tar.bz2 |
Merge "Move device admin max screen off timeout to internal interface." into lmp-mr1-dev
Diffstat (limited to 'services')
-rw-r--r-- | services/core/java/com/android/server/power/PowerManagerService.java | 20 | ||||
-rw-r--r-- | services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java | 28 |
2 files changed, 14 insertions, 34 deletions
diff --git a/services/core/java/com/android/server/power/PowerManagerService.java b/services/core/java/com/android/server/power/PowerManagerService.java index 8682f5c..c054e6c 100644 --- a/services/core/java/com/android/server/power/PowerManagerService.java +++ b/services/core/java/com/android/server/power/PowerManagerService.java @@ -3141,21 +3141,6 @@ public final class PowerManagerService extends SystemService } /** - * Used by device administration to set the maximum screen off timeout. - * - * This method must only be called by the device administration policy manager. - */ - @Override // Binder call - public void setMaximumScreenOffTimeoutFromDeviceAdmin(int timeMs) { - final long ident = Binder.clearCallingIdentity(); - try { - setMaximumScreenOffTimeoutFromDeviceAdminInternal(timeMs); - } finally { - Binder.restoreCallingIdentity(ident); - } - } - - /** * Used by the settings application and brightness control widgets to * temporarily override the current screen brightness setting so that the * user can observe the effect of an intended settings change without applying @@ -3300,6 +3285,11 @@ public final class PowerManagerService extends SystemService } @Override + public void setMaximumScreenOffTimeoutFromDeviceAdmin(int timeMs) { + setMaximumScreenOffTimeoutFromDeviceAdminInternal(timeMs); + } + + @Override public boolean getLowPowerModeEnabled() { synchronized (mLock) { return mLowPowerModeEnabled; diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java index 2c6a222..b3c2155 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java @@ -59,9 +59,9 @@ import android.os.Bundle; import android.os.Environment; import android.os.Handler; import android.os.IBinder; -import android.os.IPowerManager; import android.os.PersistableBundle; import android.os.PowerManager; +import android.os.PowerManagerInternal; import android.os.Process; import android.os.RecoverySystem; import android.os.RemoteCallback; @@ -204,7 +204,9 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { final LocalService mLocalService; - IPowerManager mIPowerManager; + final PowerManager mPowerManager; + final PowerManagerInternal mPowerManagerInternal; + IWindowManager mIWindowManager; NotificationManager mNotificationManager; @@ -925,8 +927,9 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { mUserManager = UserManager.get(mContext); mHasFeature = context.getPackageManager().hasSystemFeature( PackageManager.FEATURE_DEVICE_ADMIN); - mWakeLock = ((PowerManager)context.getSystemService(Context.POWER_SERVICE)) - .newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "DPM"); + mPowerManager = (PowerManager)context.getSystemService(Context.POWER_SERVICE); + mPowerManagerInternal = LocalServices.getService(PowerManagerInternal.class); + mWakeLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "DPM"); mLocalService = new LocalService(); if (!mHasFeature) { // Skip the rest of the initialization @@ -1038,14 +1041,6 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { } } - private IPowerManager getIPowerManager() { - if (mIPowerManager == null) { - IBinder b = ServiceManager.getService(Context.POWER_SERVICE); - mIPowerManager = IPowerManager.Stub.asInterface(b); - } - return mIPowerManager; - } - private IWindowManager getWindowManager() { if (mIWindowManager == null) { IBinder b = ServiceManager.getService(Context.WINDOW_SERVICE); @@ -2729,12 +2724,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { } policy.mLastMaximumTimeToLock = timeMs; - - try { - getIPowerManager().setMaximumScreenOffTimeoutFromDeviceAdmin((int)timeMs); - } catch (RemoteException e) { - Slog.w(LOG_TAG, "Failure talking with power manager", e); - } + mPowerManagerInternal.setMaximumScreenOffTimeoutFromDeviceAdmin((int)timeMs); } finally { Binder.restoreCallingIdentity(ident); } @@ -2789,7 +2779,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { long ident = Binder.clearCallingIdentity(); try { // Power off the display - getIPowerManager().goToSleep(SystemClock.uptimeMillis(), + mPowerManager.goToSleep(SystemClock.uptimeMillis(), PowerManager.GO_TO_SLEEP_REASON_DEVICE_ADMIN, 0); // Ensure the device is locked new LockPatternUtils(mContext).requireCredentialEntry(UserHandle.USER_ALL); |