Merge "Add a new test API for getting the list of approved rule providers." into rvc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
74739ff81b
@@ -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
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user