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

Commit 8089d489 authored by Fan Zhang's avatar Fan Zhang
Browse files

Allow system home app to show when filtering app list.

Bug: 28796031

Sometimes system app can handle CATEGORY_HOME but it doesn't have a
launcher icon in launcher itself. We should allow it to show in default
app list so user can take action on such app.

Change-Id: Ie85b8f2519be4ccb41b1bb831f4d7cf2531e466f
parent c8c60f59
Loading
Loading
Loading
Loading
+30 −2
Original line number Diff line number Diff line
@@ -749,6 +749,7 @@ public class ApplicationsState {
        static final int MSG_LOAD_ICONS = 3;
        static final int MSG_LOAD_SIZES = 4;
        static final int MSG_LOAD_LAUNCHER = 5;
        static final int MSG_LOAD_HOME_APP = 6;

        boolean mRunning;

@@ -817,13 +818,33 @@ public class ApplicationsState {
                        if (!mMainHandler.hasMessages(MainHandler.MSG_LOAD_ENTRIES_COMPLETE)) {
                            mMainHandler.sendEmptyMessage(MainHandler.MSG_LOAD_ENTRIES_COMPLETE);
                        }
                        sendEmptyMessage(MSG_LOAD_LAUNCHER);
                        sendEmptyMessage(MSG_LOAD_HOME_APP);
                    }
                } break;
                case MSG_LOAD_HOME_APP: {
                    final List<ResolveInfo> homeActivities = new ArrayList<>();
                    mPm.getHomeActivities(homeActivities);
                    synchronized (mEntriesMap) {
                        final int entryCount = mEntriesMap.size();
                        for (int i = 0; i < entryCount; i++) {
                            if (DEBUG_LOCKING) Log.v(TAG, "MSG_LOAD_HOME_APP acquired lock");
                            final HashMap<String, AppEntry> userEntries = mEntriesMap.valueAt(i);
                            for (ResolveInfo activity : homeActivities) {
                                String packageName = activity.activityInfo.packageName;
                                AppEntry entry = userEntries.get(packageName);
                                if (entry != null) {
                                    entry.isHomeApp = true;
                                }
                            }
                            if (DEBUG_LOCKING) Log.v(TAG, "MSG_LOAD_HOME_APP releasing lock");
                        }
                    }
                    sendEmptyMessage(MSG_LOAD_LAUNCHER);
                }
                break;
                case MSG_LOAD_LAUNCHER: {
                    Intent launchIntent = new Intent(Intent.ACTION_MAIN, null)
                            .addCategory(Intent.CATEGORY_LAUNCHER);

                    for (int i = 0; i < mEntriesMap.size(); i++) {
                        int userId = mEntriesMap.keyAt(i);
                        // If we do not specify MATCH_DIRECT_BOOT_AWARE or
@@ -1119,6 +1140,11 @@ public class ApplicationsState {
         */
        public boolean hasLauncherEntry;

        /**
         * Whether or not it's a Home app.
         */
        public boolean isHomeApp;

        public String getNormalizedLabel() {
            if (normalizedLabel != null) {
                return normalizedLabel;
@@ -1310,6 +1336,8 @@ public class ApplicationsState {
                return true;
            } else if (entry.hasLauncherEntry) {
                return true;
            } else if ((entry.info.flags & ApplicationInfo.FLAG_SYSTEM) != 0 && entry.isHomeApp) {
                return true;
            }
            return false;
        }