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

Commit d5fb4b13 authored by Narayan Kamath's avatar Narayan Kamath Committed by android-build-merger
Browse files

Merge "SettingsLib: Add an API method to query whether a package is a system module." into qt-dev

am: e1bbd0b1

Change-Id: I31913d14a8a2e87f1c945349ebaa0fa45a8da372
parents ac3cdf15 e1bbd0b1
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -132,4 +132,12 @@ public class AppUtils {
            .isHiddenModule(packageName);
    }

    /**
     * Returns a boolean indicating whether a given package is a system module.
     */
    public static boolean isSystemModule(Context context, String packageName) {
        return ApplicationsState.getInstance((Application) context.getApplicationContext())
                .isSystemModule(packageName);
    }

}
+17 −6
Original line number Diff line number Diff line
@@ -139,7 +139,8 @@ public class ApplicationsState {
    String mCurComputingSizePkg;
    int mCurComputingSizeUserId;
    boolean mSessionsChanged;
    final HashSet<String> mHiddenModules = new HashSet<>();
    // Maps all installed modules on the system to whether they're hidden or not.
    final HashMap<String, Boolean> mSystemModules = new HashMap<>();

    // Temporary for dispatching session callbacks.  Only touched by main thread.
    final ArrayList<WeakReference<Session>> mActiveSessions = new ArrayList<>();
@@ -212,9 +213,7 @@ public class ApplicationsState {

        final List<ModuleInfo> moduleInfos = mPm.getInstalledModules(0 /* flags */);
        for (ModuleInfo info : moduleInfos) {
            if (info.isHidden()) {
                mHiddenModules.add(info.getPackageName());
            }
            mSystemModules.put(info.getPackageName(), info.isHidden());
        }

        /**
@@ -426,7 +425,16 @@ public class ApplicationsState {
    }

    boolean isHiddenModule(String packageName) {
        return mHiddenModules.contains(packageName);
        Boolean isHidden = mSystemModules.get(packageName);
        if (isHidden == null) {
            return false;
        }

        return isHidden;
    }

    boolean isSystemModule(String packageName) {
        return mSystemModules.containsKey(packageName);
    }

    void doPauseIfNeededLocked() {
@@ -688,7 +696,10 @@ public class ApplicationsState {
            Log.i(TAG, "Looking up entry of pkg " + info.packageName + ": " + entry);
        }
        if (entry == null) {
            if (mHiddenModules.contains(info.packageName)) {
            if (isHiddenModule(info.packageName)) {
                if (DEBUG) {
                    Log.i(TAG, "No AppEntry for " + info.packageName + " (hidden module)");
                }
                return null;
            }
            if (DEBUG) {