Loading tests/PlatformCompatGating/test-rules/src/android/compat/testing/PlatformCompatChangeRule.java +10 −4 Original line number Diff line number Diff line Loading @@ -94,17 +94,16 @@ public class PlatformCompatChangeRule extends CoreCompatChangeRule { if (platformCompat == null) { throw new IllegalStateException("Could not get IPlatformCompat service!"); } uiAutomation.adoptShellPermissionIdentity( Manifest.permission.LOG_COMPAT_CHANGE, Manifest.permission.OVERRIDE_COMPAT_CHANGE_CONFIG, Manifest.permission.READ_COMPAT_CHANGE_CONFIG); adoptShellPermissions(uiAutomation); Compatibility.setOverrides(mConfig); try { platformCompat.setOverridesForTest(new CompatibilityChangeConfig(mConfig), packageName); try { uiAutomation.dropShellPermissionIdentity(); mTestStatement.evaluate(); } finally { adoptShellPermissions(uiAutomation); platformCompat.clearOverridesForTest(packageName); } } catch (RemoteException e) { Loading @@ -114,5 +113,12 @@ public class PlatformCompatChangeRule extends CoreCompatChangeRule { Compatibility.clearOverrides(); } } private static void adoptShellPermissions(UiAutomation uiAutomation) { uiAutomation.adoptShellPermissionIdentity( Manifest.permission.LOG_COMPAT_CHANGE, Manifest.permission.OVERRIDE_COMPAT_CHANGE_CONFIG, Manifest.permission.READ_COMPAT_CHANGE_CONFIG); } } } Loading
tests/PlatformCompatGating/test-rules/src/android/compat/testing/PlatformCompatChangeRule.java +10 −4 Original line number Diff line number Diff line Loading @@ -94,17 +94,16 @@ public class PlatformCompatChangeRule extends CoreCompatChangeRule { if (platformCompat == null) { throw new IllegalStateException("Could not get IPlatformCompat service!"); } uiAutomation.adoptShellPermissionIdentity( Manifest.permission.LOG_COMPAT_CHANGE, Manifest.permission.OVERRIDE_COMPAT_CHANGE_CONFIG, Manifest.permission.READ_COMPAT_CHANGE_CONFIG); adoptShellPermissions(uiAutomation); Compatibility.setOverrides(mConfig); try { platformCompat.setOverridesForTest(new CompatibilityChangeConfig(mConfig), packageName); try { uiAutomation.dropShellPermissionIdentity(); mTestStatement.evaluate(); } finally { adoptShellPermissions(uiAutomation); platformCompat.clearOverridesForTest(packageName); } } catch (RemoteException e) { Loading @@ -114,5 +113,12 @@ public class PlatformCompatChangeRule extends CoreCompatChangeRule { Compatibility.clearOverrides(); } } private static void adoptShellPermissions(UiAutomation uiAutomation) { uiAutomation.adoptShellPermissionIdentity( Manifest.permission.LOG_COMPAT_CHANGE, Manifest.permission.OVERRIDE_COMPAT_CHANGE_CONFIG, Manifest.permission.READ_COMPAT_CHANGE_CONFIG); } } }