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

Commit 81abbf0d authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

Tidy up permissions for unbundling.

Remove two permissions that we're no longer using for managing
permission grants, and stop trying to manage preferred/default apps.

Bug: 117745631
Test: manual
Change-Id: I52be94e262d04f3360c2121406a0063571d73e8f
parent c3166b25
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -19,15 +19,12 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.android.documentsui">

    <uses-permission android:name="android.permission.GET_APP_GRANTED_URI_PERMISSIONS" />
    <uses-permission android:name="android.permission.FORCE_PERSISTABLE_URI_PERMISSIONS" />
    <uses-permission android:name="android.permission.MANAGE_DOCUMENTS" />
    <uses-permission android:name="android.permission.REMOVE_TASKS" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.CACHE_CONTENT" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <uses-permission android:name="android.permission.SET_PREFERRED_APPLICATIONS" />

    <uses-sdk android:minSdkVersion="21"/>

+0 −21
Original line number Diff line number Diff line
@@ -180,13 +180,6 @@ public final class InspectorController {
                    new ClearDefaultAppAction(mContext, mPackageManager, docInfo);

                mAppDefaults.setVisible(defaultAction.canPerformAction());
                if (defaultAction.canPerformAction()) {
                    mAppDefaults.init(
                        defaultAction,
                        (View) -> {
                            clearDefaultApp(defaultAction.getPackageName());
                        });
                }
            }

            if (docInfo.isMetadataSupported()) {
@@ -276,20 +269,6 @@ public final class InspectorController {
        mContext.startActivity(intent);
    }

    /**
     * Clears the default app that's opens that file type.
     *
     * @param packageName of the preferred app.
     */
    public void clearDefaultApp(String packageName) {
        assert packageName != null;
        mPackageManager.clearPackagePreferredActivities(packageName);

        mAppDefaults.setAppIcon(null);
        mAppDefaults.setAppName(mContext.getString(R.string.handler_app_not_selected));
        mAppDefaults.showAction(false);
    }

    /**
     * Interface for loading all the various forms of document data. This primarily
     * allows us to easily supply test data in tests.
+1 −16
Original line number Diff line number Diff line
@@ -55,23 +55,8 @@ public final class ClearDefaultAppAction extends Action {
     */
    @Override
    public boolean canPerformAction() {
        Intent intent = new Intent(Intent.ACTION_VIEW, mDoc.derivedUri);
        List<ResolveInfo> list = mPm.queryIntentActivities(intent,
            PackageManager.MATCH_DEFAULT_ONLY);

        if (list.size() > 1) {
            String packageName = getPackageName();
            if (packageName == null) {
                return false;
            } else if (APP_NOT_CHOSEN.equals(packageName)) {
                return false;
            } else {
                return true;
            }
        } else {
        return false;
    }
    }

    @Override
    public String getPackageName() {
+1 −36
Original line number Diff line number Diff line
@@ -225,41 +225,6 @@ public class InspectorControllerTest {
        assertFalse(mShowInProvider.becameVisible);
    }

    /**
     * Test that the action clear app defaults is visible when conditions are met.
     * @throws Exception
     */
    @Test
    public void testAppDefaults_visible() throws Exception {
        mPm.queryIntentProvidersResults = new ArrayList<>();
        mPm.queryIntentProvidersResults.add(new TestResolveInfo());
        mPm.queryIntentProvidersResults.add(new TestResolveInfo());
        DocumentInfo doc = new DocumentInfo();
        doc.derivedUri =
            DocumentsContract.buildDocumentUri(InspectorProvider.AUTHORITY, OPEN_IN_PROVIDER_DOC);

        mDataSupplier.mDoc = doc;
        mController.loadInfo(doc.derivedUri);  // actual URI doesn't matter :)
        assertTrue(mDefaultsTestDouble.becameVisible);
    }

    /**
     * Test that action clear app defaults is invisible when conditions have not been met.
     * @throws Exception
     */
    @Test
    public void testAppDefaults_invisible() throws Exception {
        mPm.queryIntentProvidersResults = new ArrayList<>();
        mPm.queryIntentProvidersResults.add(new TestResolveInfo());
        DocumentInfo doc = new DocumentInfo();
        doc.derivedUri =
            DocumentsContract.buildDocumentUri(InspectorProvider.AUTHORITY, OPEN_IN_PROVIDER_DOC);

        mDataSupplier.mDoc = doc;
        mController.loadInfo(doc.derivedUri);  // actual URI doesn't matter :)
        assertFalse(mDefaultsTestDouble.becameVisible);
    }

    /**
     * Test that update view will handle a null value properly. It uses a runnable to verify that
     * the static method Snackbars.showInspectorError(Activity activity) is called.