From c9b2cd1ccc38f1f87b1fd68625bb58497462ffc9 Mon Sep 17 00:00:00 2001 From: Dianne Hackborn Date: Wed, 20 Jan 2016 10:54:29 -0800 Subject: [PATCH] Fix issue #26434415: APR: SecurityException in android.process.media Change-Id: Id8c8932428ffb154b38b5dc75bca1f9d3a1cf7e6 --- .../android/server/DeviceIdleController.java | 35 ++++++++++++++++--- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/services/core/java/com/android/server/DeviceIdleController.java b/services/core/java/com/android/server/DeviceIdleController.java index 58a0356e23b64..9bd79c9cf6c94 100644 --- a/services/core/java/com/android/server/DeviceIdleController.java +++ b/services/core/java/com/android/server/DeviceIdleController.java @@ -936,13 +936,23 @@ public class DeviceIdleController extends SystemService @Override public void addPowerSaveWhitelistApp(String name) { getContext().enforceCallingOrSelfPermission(android.Manifest.permission.DEVICE_POWER, null); - addPowerSaveWhitelistAppInternal(name); + long ident = Binder.clearCallingIdentity(); + try { + addPowerSaveWhitelistAppInternal(name); + } finally { + Binder.restoreCallingIdentity(ident); + } } @Override public void removePowerSaveWhitelistApp(String name) { getContext().enforceCallingOrSelfPermission(android.Manifest.permission.DEVICE_POWER, null); - removePowerSaveWhitelistAppInternal(name); + long ident = Binder.clearCallingIdentity(); + try { + removePowerSaveWhitelistAppInternal(name); + } finally { + Binder.restoreCallingIdentity(ident); + } } @Override public String[] getSystemPowerWhitelistExceptIdle() { @@ -1003,19 +1013,34 @@ public class DeviceIdleController extends SystemService @Override public void exitIdle(String reason) { getContext().enforceCallingOrSelfPermission(Manifest.permission.DEVICE_POWER, null); - exitIdleInternal(reason); + long ident = Binder.clearCallingIdentity(); + try { + exitIdleInternal(reason); + } finally { + Binder.restoreCallingIdentity(ident); + } } @Override public void downloadServiceActive(IBinder token) { getContext().enforceCallingOrSelfPermission( "android.permission.SEND_DOWNLOAD_COMPLETED_INTENTS", null); - DeviceIdleController.this.downloadServiceActive(token); + long ident = Binder.clearCallingIdentity(); + try { + DeviceIdleController.this.downloadServiceActive(token); + } finally { + Binder.restoreCallingIdentity(ident); + } } @Override public void downloadServiceInactive() { getContext().enforceCallingOrSelfPermission( "android.permission.SEND_DOWNLOAD_COMPLETED_INTENTS", null); - DeviceIdleController.this.downloadServiceInactive(); + long ident = Binder.clearCallingIdentity(); + try { + DeviceIdleController.this.downloadServiceInactive(); + } finally { + Binder.restoreCallingIdentity(ident); + } } @Override public boolean registerMaintenanceActivityListener(