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

Commit e9f796ca authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix sharing shortcuts not showing for Work Profile. Check package by...

Merge "Fix sharing shortcuts not showing for Work Profile. Check package by using selected profile PackageManager."
parents dfc06ad7 0e4b75a2
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -2165,10 +2165,10 @@ public class ChooserActivity extends ResolverActivity implements
                    + " resultList.size()=" + resultList.size()
                    + " appTargets.size()=" + appTargets.size());
        }

        Context selectedProfileContext = createContextAsUser(userHandle, 0 /* flags */);
        for (int i = resultList.size() - 1; i >= 0; i--) {
            final String packageName = resultList.get(i).getTargetComponent().getPackageName();
            if (!isPackageEnabled(packageName)) {
            if (!isPackageEnabled(selectedProfileContext, packageName)) {
                resultList.remove(i);
                if (appTargets != null) {
                    appTargets.remove(i);
@@ -2220,13 +2220,13 @@ public class ChooserActivity extends ResolverActivity implements
        mChooserHandler.sendMessage(msg);
    }

    private boolean isPackageEnabled(String packageName) {
    private boolean isPackageEnabled(Context context, String packageName) {
        if (TextUtils.isEmpty(packageName)) {
            return false;
        }
        ApplicationInfo appInfo;
        try {
            appInfo = getPackageManager().getApplicationInfo(packageName, 0);
            appInfo = context.getPackageManager().getApplicationInfo(packageName, 0);
        } catch (NameNotFoundException e) {
            return false;
        }