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

Commit affaf8ca authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
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." into sc-dev am: 1bbe3ab3

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15180074

Change-Id: I06cb12ab283518b0bc4a345a1024bd00688ae914
parents d27d3a5d 1bbe3ab3
Loading
Loading
Loading
Loading
+4 −4
Original line number Original line Diff line number Diff line
@@ -2120,10 +2120,10 @@ public class ChooserActivity extends ResolverActivity implements
                    + " resultList.size()=" + resultList.size()
                    + " resultList.size()=" + resultList.size()
                    + " appTargets.size()=" + appTargets.size());
                    + " appTargets.size()=" + appTargets.size());
        }
        }

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


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