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

Commit d4310ac9 authored by Dianne Hackborn's avatar Dianne Hackborn
Browse files

Rework permissions to be retained when an app is temporarily uninstalled.

This allows us to keep the assigned permissions when apps are temporarily
removed due to the SD card being unmounted, and also if you use the
facility to uninstall an app but keep its data.

Also fixes issue #2515189: Potential permission spoofing attack in
Android (external bug 7166)

Change-Id: I2a120ec938552028c989f9e0e890c32773957738
parent 694f79b5
Loading
Loading
Loading
Loading
+51 −21
Original line number Diff line number Diff line
@@ -91,38 +91,64 @@ public class IntentResolver<F extends IntentFilter, R extends Object> {
        }
    }

    void dumpMap(PrintWriter out, String prefix, Map<String, ArrayList<F>> map) {
    boolean dumpMap(PrintWriter out, String titlePrefix, String title,
            String prefix, Map<String, ArrayList<F>> map, String packageName) {
        String eprefix = prefix + "  ";
        String fprefix = prefix + "    ";
        boolean printedSomething = false;
        for (Map.Entry<String, ArrayList<F>> e : map.entrySet()) {
            out.print(eprefix); out.print(e.getKey()); out.println(":");
            ArrayList<F> a = e.getValue();
            final int N = a.size();
            boolean printedHeader = false;
            for (int i=0; i<N; i++) {
                dumpFilter(out, fprefix, a.get(i));
                F filter = a.get(i);
                if (packageName != null && !packageName.equals(packageForFilter(filter))) {
                    continue;
                }
                if (title != null) {
                    out.print(titlePrefix); out.println(title);
                    title = null;
                }
                if (!printedHeader) {
                    out.print(eprefix); out.print(e.getKey()); out.println(":");
                    printedHeader = true;
                }
                printedSomething = true;
                dumpFilter(out, fprefix, filter);
            }
        }
        return printedSomething;
    }

    public void dump(PrintWriter out, String prefix) {
    public boolean dump(PrintWriter out, String title, String prefix, String packageName) {
        String innerPrefix = prefix + "  ";
        out.print(prefix); out.println("Full MIME Types:");
        dumpMap(out, innerPrefix, mTypeToFilter);
        out.println(" ");
        out.print(prefix); out.println("Base MIME Types:");
        dumpMap(out, innerPrefix, mBaseTypeToFilter);
        out.println(" ");
        out.print(prefix); out.println("Wild MIME Types:");
        dumpMap(out, innerPrefix, mWildTypeToFilter);
        out.println(" ");
        out.print(prefix); out.println("Schemes:");
        dumpMap(out, innerPrefix, mSchemeToFilter);
        out.println(" ");
        out.print(prefix); out.println("Non-Data Actions:");
        dumpMap(out, innerPrefix, mActionToFilter);
        out.println(" ");
        out.print(prefix); out.println("MIME Typed Actions:");
        dumpMap(out, innerPrefix, mTypedActionToFilter);
        String sepPrefix = "\n" + prefix;
        String curPrefix = title + "\n" + prefix;
        if (dumpMap(out, curPrefix, "Full MIME Types:", innerPrefix,
                mTypeToFilter, packageName)) {
            curPrefix = sepPrefix;
        }
        if (dumpMap(out, curPrefix, "Base MIME Types:", innerPrefix,
                mBaseTypeToFilter, packageName)) {
            curPrefix = sepPrefix;
        }
        if (dumpMap(out, curPrefix, "Wild MIME Types:", innerPrefix,
                mWildTypeToFilter, packageName)) {
            curPrefix = sepPrefix;
        }
        if (dumpMap(out, curPrefix, "Schemes:", innerPrefix,
                mSchemeToFilter, packageName)) {
            curPrefix = sepPrefix;
        }
        if (dumpMap(out, curPrefix, "Non-Data Actions:", innerPrefix,
                mActionToFilter, packageName)) {
            curPrefix = sepPrefix;
        }
        if (dumpMap(out, curPrefix, "MIME Typed Actions:", innerPrefix,
                mTypedActionToFilter, packageName)) {
            curPrefix = sepPrefix;
        }
        return curPrefix == sepPrefix;
    }

    private class IteratorWrapper implements Iterator<F> {
@@ -286,6 +312,10 @@ public class IntentResolver<F extends IntentFilter, R extends Object> {
        return true;
    }

    protected String packageForFilter(F filter) {
        return null;
    }
    
    protected R newResult(F filter, int match) {
        return (R)filter;
    }
+359 −115

File changed.

Preview size limit exceeded, changes collapsed.

+2 −2
Original line number Diff line number Diff line
@@ -9356,7 +9356,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
                dumpAll = true;
            } else if ("-h".equals(opt)) {
                pw.println("Activity manager dump options:");
                pw.println("  [-a] [h- [cmd] ...");
                pw.println("  [-a] [-h] [cmd] ...");
                pw.println("  cmd may be one of:");
                pw.println("    activities: activity stack state");
                pw.println("    broadcasts: broadcast state");
@@ -9756,7 +9756,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
    
            pw.println(" ");
            pw.println("Receiver Resolver Table:");
            mReceiverResolver.dump(pw, "  ");
            mReceiverResolver.dump(pw, null, "  ", null);
            needSep = true;
        }
        
+3 −1
Original line number Diff line number Diff line
@@ -16,4 +16,6 @@ LOCAL_CERTIFICATE := platform

include $(BUILD_PACKAGE)

include $(call all-makefiles-under,$(LOCAL_PATH))
LOCAL_STORED_PATH:= $(LOCAL_PATH)
include $(call all-makefiles-under,$(LOCAL_STORED_PATH))
include $(call all-makefiles-under,$(LOCAL_STORED_PATH)/apks)
+11 −0
Original line number Diff line number Diff line
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)

LOCAL_MODULE_TAGS := tests

LOCAL_SRC_FILES := $(call all-subdir-java-files)

LOCAL_PACKAGE_NAME := AndroidTests_install_decl_perm

include $(BUILD_PACKAGE)
Loading