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

Commit dfd89b14 authored by Danny Baumann's avatar Danny Baumann Committed by Matt Garnes
Browse files

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.

Change-Id: I355642d3c1c45be39148d913ab03651aebb5a4e8
(cherry picked from commit 85d8f23f)
parent 964c7df9
Loading
Loading
Loading
Loading
+14 −12
Original line number Original line Diff line number Diff line
@@ -7173,8 +7173,20 @@ public class PackageManagerService extends IPackageManager.Stub {
                int userId) {
                int userId) {
            if (!sUserManager.exists(userId)) return null;
            if (!sUserManager.exists(userId)) return null;
            mFlags = flags;
            mFlags = flags;
            return super.queryIntent(intent, resolvedType,
            List<ResolveInfo> list = super.queryIntent(intent, resolvedType,
                    (flags & PackageManager.MATCH_DEFAULT_ONLY) != 0, userId);
                    (flags & PackageManager.MATCH_DEFAULT_ONLY) != 0, userId);
            // Remove protected Application components
            int callingUid = Binder.getCallingUid();
            if (callingUid != Process.SYSTEM_UID &&
                    (getFlagsForUid(callingUid) & ApplicationInfo.FLAG_SYSTEM) == 0) {
               Iterator<ResolveInfo> itr = list.iterator();
                while (itr.hasNext()) {
                    if (itr.next().activityInfo.applicationInfo.protect) {
                        itr.remove();
                    }
                }
            }
            return list;
        }
        }
        public List<ResolveInfo> queryIntentForPackage(Intent intent, String resolvedType,
        public List<ResolveInfo> queryIntentForPackage(Intent intent, String resolvedType,
@@ -7580,18 +7592,8 @@ public class PackageManagerService extends IPackageManager.Stub {
            if (!sUserManager.exists(userId))
            if (!sUserManager.exists(userId))
                return null;
                return null;
            mFlags = flags;
            mFlags = flags;
            List<ResolveInfo> list = super.queryIntent(intent, resolvedType,
            return super.queryIntent(intent, resolvedType,
                    (flags & PackageManager.MATCH_DEFAULT_ONLY) != 0, userId);
                    (flags & PackageManager.MATCH_DEFAULT_ONLY) != 0, userId);
            // Remove protected Application components
            if (Binder.getCallingUid() != Process.SYSTEM_UID) {
               Iterator<ResolveInfo> itr = list.iterator();
                while (itr.hasNext()) {
                    if (itr.next().activityInfo.applicationInfo.protect) {
                        itr.remove();
                    }
                }
            }
            return list;
        }
        }
        public List<ResolveInfo> queryIntentForPackage(Intent intent, String resolvedType,
        public List<ResolveInfo> queryIntentForPackage(Intent intent, String resolvedType,