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

Commit 73346918 authored by Raj Yengisetty's avatar Raj Yengisetty Committed by Matt Garnes
Browse files

Protected apps

Change-Id: Ic690387cd21fdfa09ef5fb19bd3de9305050cf6e
parent e5197799
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -1609,6 +1609,15 @@ final class ApplicationPackageManager extends PackageManager {
        return null;
    }

    @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
@@ -587,6 +587,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) {
@@ -709,6 +716,7 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
        descriptionRes = orig.descriptionRes;
        uiOptions = orig.uiOptions;
        backupAgentName = orig.backupAgentName;
        protect = orig.protect;
    }


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

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

    /**
+4 −0
Original line number Diff line number Diff line
@@ -455,4 +455,8 @@ interface IPackageManager {
    KeySet getSigningKeySet(String packageName);
    boolean isPackageSignedByKeySet(String packageName, in KeySet ks);
    boolean isPackageSignedByKeySetExactly(String packageName, in KeySet ks);

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

    /**
     * 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
@@ -3896,6 +3910,12 @@ public abstract class PackageManager {
                + "/" + packageName;
    }
 
    /**
     * 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
@@ -4604,6 +4604,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;
    }

@@ -4637,6 +4643,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