Merge "Add a new test API for getting the list of approved rule providers." into rvc-dev am: 74739ff81b am: 2995e71682 am: b4f850e5ef
Change-Id: I843601742aeda1aad109635f529bf0ebe0e4b5d0
This commit is contained in:
@@ -857,6 +857,7 @@ package android.content.integrity {
|
|||||||
method @NonNull public android.content.integrity.RuleSet getCurrentRuleSet();
|
method @NonNull public android.content.integrity.RuleSet getCurrentRuleSet();
|
||||||
method @NonNull public String getCurrentRuleSetProvider();
|
method @NonNull public String getCurrentRuleSetProvider();
|
||||||
method @NonNull public String getCurrentRuleSetVersion();
|
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);
|
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 String EXTRA_STATUS = "android.content.integrity.extra.STATUS";
|
||||||
field public static final int STATUS_FAILURE = 1; // 0x1
|
field public static final int STATUS_FAILURE = 1; // 0x1
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ import android.content.IntentSender;
|
|||||||
import android.content.pm.ParceledListSlice;
|
import android.content.pm.ParceledListSlice;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class for pushing rules used to check the integrity of app installs.
|
* Class for pushing rules used to check the integrity of app installs.
|
||||||
*
|
*
|
||||||
@@ -121,4 +123,21 @@ public class AppIntegrityManager {
|
|||||||
throw e.rethrowAsRuntimeException();
|
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.integrity.Rule;
|
||||||
import android.content.IntentSender;
|
import android.content.IntentSender;
|
||||||
import android.content.pm.ParceledListSlice;
|
import android.content.pm.ParceledListSlice;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
interface IAppIntegrityManager {
|
interface IAppIntegrityManager {
|
||||||
@@ -26,4 +27,5 @@ interface IAppIntegrityManager {
|
|||||||
String getCurrentRuleSetVersion();
|
String getCurrentRuleSetVersion();
|
||||||
String getCurrentRuleSetProvider();
|
String getCurrentRuleSetProvider();
|
||||||
ParceledListSlice<Rule> getCurrentRules();
|
ParceledListSlice<Rule> getCurrentRules();
|
||||||
|
List<String> getWhitelistedRuleProviders();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ import android.os.Binder;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.HandlerThread;
|
import android.os.HandlerThread;
|
||||||
|
import android.os.RemoteException;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.util.Slog;
|
import android.util.Slog;
|
||||||
@@ -244,6 +245,11 @@ public class AppIntegrityManagerServiceImpl extends IAppIntegrityManager.Stub {
|
|||||||
return new ParceledListSlice<>(rules);
|
return new ParceledListSlice<>(rules);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getWhitelistedRuleProviders() throws RemoteException {
|
||||||
|
return getAllowedRuleProviders();
|
||||||
|
}
|
||||||
|
|
||||||
private void handleIntegrityVerification(Intent intent) {
|
private void handleIntegrityVerification(Intent intent) {
|
||||||
int verificationId = intent.getIntExtra(EXTRA_VERIFICATION_ID, -1);
|
int verificationId = intent.getIntExtra(EXTRA_VERIFICATION_ID, -1);
|
||||||
|
|
||||||
|
|||||||
@@ -480,6 +480,13 @@ public class AppIntegrityManagerServiceImplTest {
|
|||||||
assertThat(mService.getCurrentRules().getList()).containsExactly(rule);
|
assertThat(mService.getCurrentRules().getList()).containsExactly(rule);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getWhitelistedRuleProviders() throws Exception {
|
||||||
|
whitelistUsAsRuleProvider();
|
||||||
|
|
||||||
|
assertThat(mService.getWhitelistedRuleProviders()).containsExactly(TEST_FRAMEWORK_PACKAGE);
|
||||||
|
}
|
||||||
|
|
||||||
private void whitelistUsAsRuleProvider() {
|
private void whitelistUsAsRuleProvider() {
|
||||||
Resources mockResources = mock(Resources.class);
|
Resources mockResources = mock(Resources.class);
|
||||||
when(mockResources.getStringArray(R.array.config_integrityRuleProviderPackages))
|
when(mockResources.getStringArray(R.array.config_integrityRuleProviderPackages))
|
||||||
|
|||||||
Reference in New Issue
Block a user