Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit aad54ab6 authored by vadimt's avatar vadimt
Browse files

Using grantRuntimePermission()

"pm grant" is considered obsolete

Bug: 145686584
Change-Id: Ieeec76b2fdb666f89957a0a3039956bd69e9f315
parent 0fd48b51
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@

    <uses-permission android:name="android.permission.PACKAGE_USAGE_STATS"/>
    <uses-permission android:name="android.permission.READ_LOGS"/>
    <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS"/>

    <application android:debuggable="true">
        <uses-library android:name="android.test.runner"/>
+7 −15
Original line number Diff line number Diff line
@@ -183,13 +183,8 @@ public final class LauncherInstrumentation {
                .authority(testProviderAuthority)
                .build();

        try {
            mDevice.executeShellCommand("pm grant " + testPackage +
                    " android.permission.WRITE_SECURE_SETTINGS");
        } catch (IOException e) {
            fail(e.toString());
        }

        mInstrumentation.getUiAutomation().grantRuntimePermission(
                testPackage, "android.permission.WRITE_SECURE_SETTINGS");

        PackageManager pm = getContext().getPackageManager();
        ProviderInfo pi = pm.resolveContentProvider(
@@ -336,14 +331,11 @@ public final class LauncherInstrumentation {

    private String getSystemHealthMessage() {
        final String testPackage = getContext().getPackageName();
        try {
            mDevice.executeShellCommand("pm grant " + testPackage +
                    " android.permission.READ_LOGS");
            mDevice.executeShellCommand("pm grant " + testPackage +
                    " android.permission.PACKAGE_USAGE_STATS");
        } catch (IOException e) {
            e.printStackTrace();
        }

        mInstrumentation.getUiAutomation().grantRuntimePermission(
                testPackage, "android.permission.READ_LOGS");
        mInstrumentation.getUiAutomation().grantRuntimePermission(
                testPackage, "android.permission.PACKAGE_USAGE_STATS");

        return mSystemHealthSupplier != null
                ? mSystemHealthSupplier.apply(START_TIME)