Merge "Clear calling identity before calling to DeviceIdleController"

This commit is contained in:
Chiachang Wang
2023-04-13 06:06:50 +00:00
committed by Gerrit Code Review

View File

@@ -969,15 +969,21 @@ public class Vpn {
// Allow VpnManager app to temporarily run background services to handle this error. // Allow VpnManager app to temporarily run background services to handle this error.
// If an app requires anything beyond this grace period, they MUST either declare // If an app requires anything beyond this grace period, they MUST either declare
// themselves as a foreground service, or schedule a job/workitem. // themselves as a foreground service, or schedule a job/workitem.
DeviceIdleInternal idleController = mDeps.getDeviceIdleInternal(); final long token = Binder.clearCallingIdentity();
idleController.addPowerSaveTempWhitelistApp(Process.myUid(), packageName,
VPN_MANAGER_EVENT_ALLOWLIST_DURATION_MS, mUserId, false, REASON_VPN,
"VpnManager event");
try { try {
return mUserIdContext.startService(intent) != null; final DeviceIdleInternal idleController = mDeps.getDeviceIdleInternal();
} catch (RuntimeException e) { idleController.addPowerSaveTempWhitelistApp(Process.myUid(), packageName,
Log.e(TAG, "Service of VpnManager app " + intent + " failed to start", e); VPN_MANAGER_EVENT_ALLOWLIST_DURATION_MS, mUserId, false, REASON_VPN,
return false; "VpnManager event");
try {
return mUserIdContext.startService(intent) != null;
} catch (RuntimeException e) {
Log.e(TAG, "Service of VpnManager app " + intent + " failed to start", e);
return false;
}
} finally {
Binder.restoreCallingIdentity(token);
} }
} }