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

Commit f52233df authored by Nicolas Prevot's avatar Nicolas Prevot Committed by Android (Google) Code Review
Browse files

Merge "When forwarding intents, ignoring the package set in the intent." into lmp-dev

parents 3c50bf00 376e4ba9
Loading
Loading
Loading
Loading
+6 −4
Original line number Original line Diff line number Diff line
@@ -76,17 +76,19 @@ public class IntentForwarderActivity extends Activity {
        }
        }
        Intent newIntent = new Intent(intentReceived);
        Intent newIntent = new Intent(intentReceived);
        newIntent.setComponent(null);
        newIntent.setComponent(null);
        // Apps should not be allowed to target a specific package in the target user.
        newIntent.setPackage(null);
        newIntent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT
        newIntent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT
                |Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
                |Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
        int callingUserId = getUserId();
        int callingUserId = getUserId();
        IPackageManager ipm = AppGlobals.getPackageManager();
        IPackageManager ipm = AppGlobals.getPackageManager();
        String resolvedType = newIntent.resolveTypeIfNeeded(getContentResolver());
        String resolvedType = newIntent.resolveTypeIfNeeded(getContentResolver());
        boolean canForward = false;
        boolean canForward = false;
        try {
        Intent selector = newIntent.getSelector();
        Intent selector = newIntent.getSelector();
        if (selector == null) {
        if (selector == null) {
            selector = newIntent;
            selector = newIntent;
        }
        }
        try {
            canForward = ipm.canForwardTo(selector, resolvedType, callingUserId,
            canForward = ipm.canForwardTo(selector, resolvedType, callingUserId,
                    userDest.getIdentifier());
                    userDest.getIdentifier());
        } catch (RemoteException e) {
        } catch (RemoteException e) {
+11 −13
Original line number Original line Diff line number Diff line
@@ -3204,19 +3204,15 @@ public class PackageManagerService extends IPackageManager.Stub {
                if (matches.get(i).getTargetUserId() == targetUserId) return true;
                if (matches.get(i).getTargetUserId() == targetUserId) return true;
            }
            }
        }
        }
        ArrayList<String> packageNames = null;
        ArrayList<String> packageNames = null;
        SparseArray<ArrayList<String>> fromSource =
        SparseArray<ArrayList<String>> fromSource =
                mSettings.mCrossProfilePackageInfo.get(sourceUserId);
                mSettings.mCrossProfilePackageInfo.get(sourceUserId);
        if (fromSource != null) {
        if (fromSource != null) {
            packageNames = fromSource.get(targetUserId);
            packageNames = fromSource.get(targetUserId);
        }
            if (packageNames != null) {
        if (packageNames != null && packageNames.contains(intent.getPackage())) {
            return true;
        }
                // We need the package name, so we try to resolve with the loosest flags possible
                // We need the package name, so we try to resolve with the loosest flags possible
        List<ResolveInfo> resolveInfos = mActivities.queryIntent(
                List<ResolveInfo> resolveInfos = mActivities.queryIntent(intent, resolvedType,
                intent, resolvedType, PackageManager.GET_UNINSTALLED_PACKAGES, targetUserId);
                        PackageManager.GET_UNINSTALLED_PACKAGES, targetUserId);
                int count = resolveInfos.size();
                int count = resolveInfos.size();
                for (int i = 0; i < count; i++) {
                for (int i = 0; i < count; i++) {
                    ResolveInfo resolveInfo = resolveInfos.get(i);
                    ResolveInfo resolveInfo = resolveInfos.get(i);
@@ -3224,6 +3220,8 @@ public class PackageManagerService extends IPackageManager.Stub {
                        return true;
                        return true;
                    }
                    }
                }
                }
            }
        }
        return false;
        return false;
    }
    }