Fix sharing shortcuts not showing for Work Profile. Check package by
using selected profile PackageManager.
Test: test on local device
Bug: 175240616
Fixes: 179798044
Change-Id: I30728705dbc60d0506b7d20a16bcc8f1eed9b6d0
(cherry picked from commit 0e4b75a215)
This commit is contained in:
@@ -2120,10 +2120,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);
|
||||
@@ -2175,13 +2175,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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user