Merge "Specify temp-allowlist reasonCode while calling addPowerSaveTempWhitelistApp()." into sc-dev

This commit is contained in:
Hui Yu
2021-03-01 18:35:24 +00:00
committed by Android (Google) Code Review
4 changed files with 13 additions and 4 deletions

View File

@@ -22,6 +22,7 @@ import static android.net.NetworkCapabilities.NET_CAPABILITY_NOT_METERED;
import static android.net.RouteInfo.RTN_THROW;
import static android.net.RouteInfo.RTN_UNREACHABLE;
import static android.net.VpnManager.NOTIFICATION_CHANNEL_VPN;
import static android.os.PowerWhitelistManager.REASON_VPN;
import static com.android.internal.util.Preconditions.checkArgument;
import static com.android.internal.util.Preconditions.checkNotNull;
@@ -825,7 +826,8 @@ public class Vpn {
// a short time, so we can bootstrap the VPN service.
DeviceIdleInternal idleController = mDeps.getDeviceIdleInternal();
idleController.addPowerSaveTempWhitelistApp(Process.myUid(), alwaysOnPackage,
VPN_LAUNCH_IDLE_ALLOWLIST_DURATION_MS, mUserId, false, "vpn");
VPN_LAUNCH_IDLE_ALLOWLIST_DURATION_MS, mUserId, false, REASON_VPN,
"vpn");
// Start the VPN service declared in the app's manifest.
Intent serviceIntent = new Intent(VpnConfig.SERVICE_INTERFACE);

View File

@@ -16,6 +16,8 @@
package com.android.server.content;
import static android.os.PowerWhitelistManager.REASON_SYNC_MANAGER;
import static com.android.server.content.SyncLogger.logSafe;
import android.accounts.Account;
@@ -1671,7 +1673,7 @@ public class SyncManager {
syncOperation.owningPackage,
mConstants.getKeyExemptionTempWhitelistDurationInSeconds() * 1000,
UserHandle.getUserId(syncOperation.owningUid),
/* sync=*/ false, "sync by top app");
/* sync=*/ false, REASON_SYNC_MANAGER, "sync by top app");
}
}

View File

@@ -16,6 +16,8 @@
package com.android.server.security;
import static android.os.PowerWhitelistManager.REASON_KEY_CHAIN;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
@@ -102,7 +104,8 @@ public class KeyChainSystemService extends SystemService {
final DeviceIdleInternal idleController =
LocalServices.getService(DeviceIdleInternal.class);
idleController.addPowerSaveTempWhitelistApp(Process.myUid(), packageName,
KEYCHAIN_IDLE_WHITELIST_DURATION_MS, user.getIdentifier(), false, "keychain");
KEYCHAIN_IDLE_WHITELIST_DURATION_MS, user.getIdentifier(), false,
REASON_KEY_CHAIN, "keychain");
getContext().startServiceAsUser(intent, user);
}

View File

@@ -16,6 +16,8 @@
package com.android.server.telecom;
import static android.os.PowerWhitelistManager.REASON_UNKNOWN;
import android.content.Context;
import android.os.Binder;
import android.os.Process;
@@ -38,7 +40,7 @@ public class InternalServiceRepository extends IInternalServiceRetriever.Stub {
public void exemptAppTemporarilyForEvent(String packageName, long duration, int userHandle,
String reason) {
mDeviceIdleController.addPowerSaveTempWhitelistApp(Process.myUid(), packageName,
duration, userHandle, true /*sync*/, reason);
duration, userHandle, true /*sync*/, REASON_UNKNOWN, reason);
}
};