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

Commit 85d8f23f authored by Danny Baumann's avatar Danny Baumann
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
parent a394f4a4
Loading
Loading
Loading
Loading
+14 −12
Original line number Diff line number Diff line
@@ -7173,8 +7173,20 @@ public class PackageManagerService extends IPackageManager.Stub {
                int userId) {
            if (!sUserManager.exists(userId)) return null;
            mFlags = flags;
            return super.queryIntent(intent, resolvedType,
            List<ResolveInfo> list = super.queryIntent(intent, resolvedType,
                    (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,
@@ -7580,18 +7592,8 @@ public class PackageManagerService extends IPackageManager.Stub {
            if (!sUserManager.exists(userId))
                return null;
            mFlags = flags;
            List<ResolveInfo> list = super.queryIntent(intent, resolvedType,
            return super.queryIntent(intent, resolvedType,
                    (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,