diff options
author | atrost <atrost@google.com> | 2019-11-06 16:56:51 +0000 |
---|---|---|
committer | atrost <atrost@google.com> | 2019-11-18 12:54:09 +0000 |
commit | ca44391d0e2ca461ca5f6b8e701bdc6b8d74456b (patch) | |
tree | 8a8ec5a59aa2af5d0c2d994021e72f46ec79bd61 /test-rules | |
parent | 351b5c83c21b3163393c968fae54c49b690d3f0c (diff) |
Use setOverridesFromTest in the test rule to avoid app kill.
Test: https://r.android.com/1155184
Change-Id: Ib801c3df3cd0987309c2b5770c301b24261b3e73
Diffstat (limited to 'test-rules')
-rw-r--r-- | test-rules/src/platform_compat/java/android/compat/CompatChangeRule.java | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/test-rules/src/platform_compat/java/android/compat/CompatChangeRule.java b/test-rules/src/platform_compat/java/android/compat/CompatChangeRule.java index 1bae1a2c31..d9c800ab44 100644 --- a/test-rules/src/platform_compat/java/android/compat/CompatChangeRule.java +++ b/test-rules/src/platform_compat/java/android/compat/CompatChangeRule.java @@ -108,19 +108,20 @@ public class CompatChangeRule implements TestRule { Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation(); String packageName = instrumentation.getTargetContext().getPackageName(); IPlatformCompat platformCompat = IPlatformCompat.Stub - .asInterface(ServiceManager.getService(Context.PLATFORM_COMPAT_SERVICE)); + .asInterface(ServiceManager.getService(Context.PLATFORM_COMPAT_SERVICE)); if (platformCompat == null) { throw new IllegalStateException("Could not get IPlatformCompat service!"); } Compatibility.setOverrides(config); try { - platformCompat.setOverrides(new CompatibilityChangeConfig(config), packageName); + platformCompat.setOverridesForTest(new CompatibilityChangeConfig(config), + packageName); try { testStatement.evaluate(); } finally { platformCompat.clearOverrides(packageName); } - } catch(RemoteException e) { + } catch (RemoteException e) { throw new RuntimeException("Could not call IPlatformCompat binder method!", e); } finally { Compatibility.clearOverrides(); |