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

Commit 81ef9832 authored by Raj Yengisetty's avatar Raj Yengisetty
Browse files

Protected App [1/3]

 PackageManager:
   Add support for Protected App Components
   Adding protect flag to ApplicationInfo

 SettingsProvider:
   New DB entry for protected app components

Change-Id: If04843e93b572191d4654c01f4da8f087ba9fba8
parent 8ea85bd6
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -1373,4 +1373,13 @@ final class ApplicationPackageManager extends PackageManager {
            Log.e(TAG, "Failed to update icon maps", re);
        }
    }

    @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);
        }
    }
}
+9 −0
Original line number Diff line number Diff line
@@ -482,6 +482,12 @@ 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.
     */
    public boolean protect = false;
    
    public void dump(Printer pw, String prefix) {
        super.dumpFront(pw, prefix);
        if (className != null) {
@@ -591,6 +597,7 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
        uiOptions = orig.uiOptions;
        backupAgentName = orig.backupAgentName;
        isThemeable = orig.isThemeable;
        protect = orig.protect;
    }


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

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

    /**
+4 −0
Original line number Diff line number Diff line
@@ -425,4 +425,8 @@ interface IPackageManager {
    /** Themes */
    void updateIconMapping(String pkgName);
    ComposedIconInfo getComposedIconInfo();

    /** Protected Apps */
    void setComponentProtectedSetting(in ComponentName componentName, in boolean newState,
            int userId);
}
+17 −0
Original line number Diff line number Diff line
@@ -1374,6 +1374,18 @@ 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
     */
    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
     */
    public static final boolean COMPONENT_VISIBLE_STATUS = true;

    /**
     * Retrieve overall information about an application package that is
     * installed on the system.
@@ -3261,4 +3273,9 @@ public abstract class PackageManager {
     * @hide
     */
    public abstract void updateIconMaps(String pkgName);

    /**
     * Update Component protection state
     */
    public abstract void setComponentProtectedSetting(ComponentName componentName, boolean newState);
}
+9 −0
Original line number Diff line number Diff line
@@ -4251,6 +4251,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;
    }

@@ -4284,6 +4290,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