Allow clearing a single change id for tests usage.

Add clearOverrideForTest(changeId, packageName) to remove a single id
from package overrdies.

Bug: 147113465
Test: N/A
Change-Id: I35c6fe418abb9bc562218444878188bc393725e5
This commit is contained in:
Artur Satayev
2021-01-19 17:58:03 +00:00
parent 5d640c39a3
commit 21900cb6ee
2 changed files with 17 additions and 0 deletions

View File

@@ -172,6 +172,17 @@ interface IPlatformCompat {
*/
boolean clearOverride(long changeId, String packageName);
/**
* Restores the default behaviour for the given change and app.
*
* <p>Does not kill the app; to be only used in tests.
*
* @param changeId the ID of the change that was overridden
* @param packageName the app package name that was overridden
* @throws SecurityException if overriding changes is not permitted
*/
void clearOverrideForTest(long changeId, String packageName);
/**
* Enables all compatibility changes that have enabledSinceTargetSdk ==
* {@param targetSdkVersion} for an app, subject to the policy.

View File

@@ -210,6 +210,12 @@ public class PlatformCompat extends IPlatformCompat.Stub {
return existed;
}
@Override
public void clearOverrideForTest(long changeId, String packageName) {
checkCompatChangeOverridePermission();
mCompatConfig.removeOverride(changeId, packageName);
}
@Override
public CompatibilityChangeConfig getAppConfig(ApplicationInfo appInfo) {
checkCompatChangeReadAndLogPermission();