Merge "Add a new test API for getting the list of approved rule providers." into rvc-dev am: 74739ff81b am: 2995e71682 am: b4f850e5ef am: b07b772709

Change-Id: If491a8dd91d1d364c27a80fbf4875283c0478ae6
This commit is contained in:
Automerger Merge Worker
2020-03-16 13:55:33 +00:00
5 changed files with 35 additions and 0 deletions

View File

@@ -857,6 +857,7 @@ package android.content.integrity {
method @NonNull public android.content.integrity.RuleSet getCurrentRuleSet();
method @NonNull public String getCurrentRuleSetProvider();
method @NonNull public String getCurrentRuleSetVersion();
method @NonNull public java.util.List<java.lang.String> getWhitelistedRuleProviders();
method public void updateRuleSet(@NonNull android.content.integrity.RuleSet, @NonNull android.content.IntentSender);
field public static final String EXTRA_STATUS = "android.content.integrity.extra.STATUS";
field public static final int STATUS_FAILURE = 1; // 0x1

View File

@@ -25,6 +25,8 @@ import android.content.IntentSender;
import android.content.pm.ParceledListSlice;
import android.os.RemoteException;
import java.util.List;
/**
* Class for pushing rules used to check the integrity of app installs.
*
@@ -121,4 +123,21 @@ public class AppIntegrityManager {
throw e.rethrowAsRuntimeException();
}
}
/**
* Get the package names of all whitelisted rule providers.
*
* <p>Warning: this method is only used for tests.
*
* @hide
*/
@TestApi
@NonNull
public List<String> getWhitelistedRuleProviders() {
try {
return mManager.getWhitelistedRuleProviders();
} catch (RemoteException e) {
throw e.rethrowAsRuntimeException();
}
}
}

View File

@@ -19,6 +19,7 @@ package android.content.integrity;
import android.content.integrity.Rule;
import android.content.IntentSender;
import android.content.pm.ParceledListSlice;
import java.util.List;
/** @hide */
interface IAppIntegrityManager {
@@ -26,4 +27,5 @@ interface IAppIntegrityManager {
String getCurrentRuleSetVersion();
String getCurrentRuleSetProvider();
ParceledListSlice<Rule> getCurrentRules();
List<String> getWhitelistedRuleProviders();
}

View File

@@ -50,6 +50,7 @@ import android.os.Binder;
import android.os.Bundle;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.RemoteException;
import android.os.UserHandle;
import android.provider.Settings;
import android.util.Slog;
@@ -244,6 +245,11 @@ public class AppIntegrityManagerServiceImpl extends IAppIntegrityManager.Stub {
return new ParceledListSlice<>(rules);
}
@Override
public List<String> getWhitelistedRuleProviders() throws RemoteException {
return getAllowedRuleProviders();
}
private void handleIntegrityVerification(Intent intent) {
int verificationId = intent.getIntExtra(EXTRA_VERIFICATION_ID, -1);

View File

@@ -480,6 +480,13 @@ public class AppIntegrityManagerServiceImplTest {
assertThat(mService.getCurrentRules().getList()).containsExactly(rule);
}
@Test
public void getWhitelistedRuleProviders() throws Exception {
whitelistUsAsRuleProvider();
assertThat(mService.getWhitelistedRuleProviders()).containsExactly(TEST_FRAMEWORK_PACKAGE);
}
private void whitelistUsAsRuleProvider() {
Resources mockResources = mock(Resources.class);
when(mockResources.getStringArray(R.array.config_integrityRuleProviderPackages))