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

Commit 86c3e388 authored by Raj Yengisetty's avatar Raj Yengisetty Committed by Steve Kondik
Browse files

Protected apps

Fix up protected apps filter.

Move filtering to correct place (when querying providers,
ResolveInfo.activityInfo is null), and port over commit
4dad4a4e from cm-11.0.

Protected Apps: do not filter components from the same UID

pm: Use ArraySet instead of HashSet

packagemanager: Use ArrayMap/ArraySet as per AOSP

 * To reduce memory consumption

Change-Id: Ic690387cd21fdfa09ef5fb19bd3de9305050cf6e
parent d8826da4
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -1991,6 +1991,15 @@ final class ApplicationPackageManager extends PackageManager {
        }
    }

    @Override
    public void setComponentProtectedSetting(ComponentName componentName, boolean newState) {
        try {
            mPM.setComponentProtectedSetting(componentName, newState, mContext.getUserId());
        } catch (RemoteException re) {
            Log.e(TAG, "Failed to set component protected setting", re);
        }
    }

    @Override
    public PackageInstaller getPackageInstaller() {
        synchronized (mLock) {
+10 −0
Original line number Diff line number Diff line
@@ -661,6 +661,13 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
     */
    public int installLocation = PackageInfo.INSTALL_LOCATION_UNSPECIFIED;

    /**
     * When true, indicates that any one component within this application is
     * protected.
     * @hide
     */
    public boolean protect = false;

    public void dump(Printer pw, String prefix) {
        super.dumpFront(pw, prefix);
        if (className != null) {
@@ -793,6 +800,7 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
        uiOptions = orig.uiOptions;
        backupAgentName = orig.backupAgentName;
        fullBackupContent = orig.fullBackupContent;
        protect = orig.protect;
    }


@@ -847,6 +855,7 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
        dest.writeInt(descriptionRes);
        dest.writeInt(uiOptions);
        dest.writeInt(fullBackupContent);
        dest.writeInt(protect ? 1 : 0);
    }

    public static final Parcelable.Creator<ApplicationInfo> CREATOR
@@ -900,6 +909,7 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
        descriptionRes = source.readInt();
        uiOptions = source.readInt();
        fullBackupContent = source.readInt();
        protect = source.readInt() != 0;
    }

    /**
+4 −0
Original line number Diff line number Diff line
@@ -507,4 +507,8 @@ interface IPackageManager {
    boolean isPermissionRevokedByPolicy(String permission, String packageName, int userId);

    String getPermissionControllerPackageName();

    /** Protected Apps */
    void setComponentProtectedSetting(in ComponentName componentName,
    in boolean newState, int userId);
}
+20 −0
Original line number Diff line number Diff line
@@ -1911,6 +1911,20 @@ public abstract class PackageManager {
    public static final String EXTRA_REQUEST_PERMISSIONS_RESULTS
            = "android.content.pm.extra.REQUEST_PERMISSIONS_RESULTS";

    /**
     * Flag for {@link #setComponentProtectedSetting(android.content.ComponentName, boolean)}:
     * This component or application has set to protected status
     * @hide
     */
    public static final boolean COMPONENT_PROTECTED_STATUS = false;

    /**
     * Flag for {@link #setComponentProtectedSetting(android.content.ComponentName, boolean)}:
     * This component or application has been explicitly set to visible status
     * @hide
     */
    public static final boolean COMPONENT_VISIBLE_STATUS = true;

    /**
     * String extra for {@link PackageInstallObserver} in the 'extras' Bundle in case of
     * {@link #INSTALL_FAILED_DUPLICATE_PERMISSION}.  This extra names the package which provides
@@ -4483,6 +4497,12 @@ public abstract class PackageManager {
     */
    public abstract @NonNull PackageInstaller getPackageInstaller();

    /**
     * Update Component protection state
     * @hide
     */
    public abstract void setComponentProtectedSetting(ComponentName componentName, boolean newState);

    /**
     * Adds a {@link CrossProfileIntentFilter}. After calling this method all intents sent from the
     * user with id sourceUserId can also be be resolved by activities in the user with id
+9 −0
Original line number Diff line number Diff line
@@ -4731,6 +4731,12 @@ public class PackageParser {
                && p.usesLibraryFiles != null) {
            return true;
        }
        if (state.protectedComponents != null) {
            boolean protect = state.protectedComponents.size() > 0;
            if (p.applicationInfo.protect != protect) {
                return true;
            }
        }
        return false;
    }

@@ -4764,6 +4770,9 @@ public class PackageParser {
            ai.enabled = false;
        }
        ai.enabledSetting = state.enabled;
        if (state.protectedComponents != null) {
            ai.protect = state.protectedComponents.size() > 0;
        }
    }

    public static ApplicationInfo generateApplicationInfo(Package p, int flags,
Loading