Loading core/java/com/android/internal/app/AppPredictionServiceResolverComparator.java +1 −1 Original line number Diff line number Diff line Loading @@ -188,7 +188,7 @@ class AppPredictionServiceResolverComparator extends AbstractResolverComparator } Integer rank = mTargetRanks.get(name); if (rank == null) { Log.w(TAG, "Score requested for unknown component."); Log.w(TAG, "Score requested for unknown component. Did you call compute yet?"); return 0f; } int consecutiveSumOfRanks = (mTargetRanks.size() - 1) * (mTargetRanks.size()) / 2; Loading core/java/com/android/internal/app/ChooserActivity.java +7 −35 Original line number Diff line number Diff line Loading @@ -826,8 +826,6 @@ public class ChooserActivity extends ResolverActivity implements queryDirectShareTargets(chooserListAdapter, true); return; } final List<DisplayResolveInfo> driList = getDisplayResolveInfos(chooserListAdapter); final List<ShortcutManager.ShareShortcutInfo> shareShortcutInfos = new ArrayList<>(); Loading Loading @@ -855,7 +853,7 @@ public class ChooserActivity extends ResolverActivity implements new ComponentName( appTarget.getPackageName(), appTarget.getClassName()))); } sendShareShortcutInfoList(shareShortcutInfos, driList, resultList, sendShareShortcutInfoList(shareShortcutInfos, chooserListAdapter, resultList, chooserListAdapter.getUserHandle()); }; } Loading Loading @@ -1974,32 +1972,6 @@ public class ChooserActivity extends ResolverActivity implements } } private List<DisplayResolveInfo> getDisplayResolveInfos(ChooserListAdapter adapter) { // Need to keep the original DisplayResolveInfos to be able to reconstruct ServiceResultInfo // and use the old code path. This Ugliness should go away when Sharesheet is refactored. List<DisplayResolveInfo> driList = new ArrayList<>(); int targetsToQuery = 0; for (int i = 0, n = adapter.getDisplayResolveInfoCount(); i < n; i++) { final DisplayResolveInfo dri = adapter.getDisplayResolveInfo(i); if (adapter.getScore(dri) == 0) { // A score of 0 means the app hasn't been used in some time; // don't query it as it's not likely to be relevant. continue; } driList.add(dri); targetsToQuery++; // TODO(b/121287224): Do we need this here? (similar to queryTargetServices) if (targetsToQuery >= SHARE_TARGET_QUERY_PACKAGE_LIMIT) { if (DEBUG) { Log.d(TAG, "queryTargets hit query target limit " + SHARE_TARGET_QUERY_PACKAGE_LIMIT); } break; } } return driList; } @VisibleForTesting protected void queryDirectShareTargets( ChooserListAdapter adapter, boolean skipAppPredictionService) { Loading @@ -2017,14 +1989,13 @@ public class ChooserActivity extends ResolverActivity implements if (filter == null) { return; } final List<DisplayResolveInfo> driList = getDisplayResolveInfos(adapter); AsyncTask.execute(() -> { Context selectedProfileContext = createContextAsUser(userHandle, 0 /* flags */); ShortcutManager sm = (ShortcutManager) selectedProfileContext .getSystemService(Context.SHORTCUT_SERVICE); List<ShortcutManager.ShareShortcutInfo> resultList = sm.getShareTargets(filter); sendShareShortcutInfoList(resultList, driList, null, userHandle); sendShareShortcutInfoList(resultList, adapter, null, userHandle); }); } Loading Loading @@ -2061,7 +2032,7 @@ public class ChooserActivity extends ResolverActivity implements private void sendShareShortcutInfoList( List<ShortcutManager.ShareShortcutInfo> resultList, List<DisplayResolveInfo> driList, ChooserListAdapter chooserListAdapter, @Nullable List<AppTarget> appTargets, UserHandle userHandle) { if (appTargets != null && appTargets.size() != resultList.size()) { throw new RuntimeException("resultList and appTargets must have the same size." Loading @@ -2087,10 +2058,10 @@ public class ChooserActivity extends ResolverActivity implements // for direct share targets. After ShareSheet is refactored we should use the // ShareShortcutInfos directly. boolean resultMessageSent = false; for (int i = 0; i < driList.size(); i++) { for (int i = 0; i < chooserListAdapter.getDisplayResolveInfoCount(); i++) { List<ShortcutManager.ShareShortcutInfo> matchingShortcuts = new ArrayList<>(); for (int j = 0; j < resultList.size(); j++) { if (driList.get(i).getResolvedComponentName().equals( if (chooserListAdapter.getDisplayResolveInfo(i).getResolvedComponentName().equals( resultList.get(j).getTargetComponent())) { matchingShortcuts.add(resultList.get(j)); } Loading @@ -2105,7 +2076,8 @@ public class ChooserActivity extends ResolverActivity implements final Message msg = Message.obtain(); msg.what = ChooserHandler.SHORTCUT_MANAGER_SHARE_TARGET_RESULT; msg.obj = new ServiceResultInfo(driList.get(i), chooserTargets, null, userHandle); msg.obj = new ServiceResultInfo(chooserListAdapter.getDisplayResolveInfo(i), chooserTargets, null, userHandle); msg.arg1 = shortcutType; mChooserHandler.sendMessage(msg); resultMessageSent = true; Loading Loading
core/java/com/android/internal/app/AppPredictionServiceResolverComparator.java +1 −1 Original line number Diff line number Diff line Loading @@ -188,7 +188,7 @@ class AppPredictionServiceResolverComparator extends AbstractResolverComparator } Integer rank = mTargetRanks.get(name); if (rank == null) { Log.w(TAG, "Score requested for unknown component."); Log.w(TAG, "Score requested for unknown component. Did you call compute yet?"); return 0f; } int consecutiveSumOfRanks = (mTargetRanks.size() - 1) * (mTargetRanks.size()) / 2; Loading
core/java/com/android/internal/app/ChooserActivity.java +7 −35 Original line number Diff line number Diff line Loading @@ -826,8 +826,6 @@ public class ChooserActivity extends ResolverActivity implements queryDirectShareTargets(chooserListAdapter, true); return; } final List<DisplayResolveInfo> driList = getDisplayResolveInfos(chooserListAdapter); final List<ShortcutManager.ShareShortcutInfo> shareShortcutInfos = new ArrayList<>(); Loading Loading @@ -855,7 +853,7 @@ public class ChooserActivity extends ResolverActivity implements new ComponentName( appTarget.getPackageName(), appTarget.getClassName()))); } sendShareShortcutInfoList(shareShortcutInfos, driList, resultList, sendShareShortcutInfoList(shareShortcutInfos, chooserListAdapter, resultList, chooserListAdapter.getUserHandle()); }; } Loading Loading @@ -1974,32 +1972,6 @@ public class ChooserActivity extends ResolverActivity implements } } private List<DisplayResolveInfo> getDisplayResolveInfos(ChooserListAdapter adapter) { // Need to keep the original DisplayResolveInfos to be able to reconstruct ServiceResultInfo // and use the old code path. This Ugliness should go away when Sharesheet is refactored. List<DisplayResolveInfo> driList = new ArrayList<>(); int targetsToQuery = 0; for (int i = 0, n = adapter.getDisplayResolveInfoCount(); i < n; i++) { final DisplayResolveInfo dri = adapter.getDisplayResolveInfo(i); if (adapter.getScore(dri) == 0) { // A score of 0 means the app hasn't been used in some time; // don't query it as it's not likely to be relevant. continue; } driList.add(dri); targetsToQuery++; // TODO(b/121287224): Do we need this here? (similar to queryTargetServices) if (targetsToQuery >= SHARE_TARGET_QUERY_PACKAGE_LIMIT) { if (DEBUG) { Log.d(TAG, "queryTargets hit query target limit " + SHARE_TARGET_QUERY_PACKAGE_LIMIT); } break; } } return driList; } @VisibleForTesting protected void queryDirectShareTargets( ChooserListAdapter adapter, boolean skipAppPredictionService) { Loading @@ -2017,14 +1989,13 @@ public class ChooserActivity extends ResolverActivity implements if (filter == null) { return; } final List<DisplayResolveInfo> driList = getDisplayResolveInfos(adapter); AsyncTask.execute(() -> { Context selectedProfileContext = createContextAsUser(userHandle, 0 /* flags */); ShortcutManager sm = (ShortcutManager) selectedProfileContext .getSystemService(Context.SHORTCUT_SERVICE); List<ShortcutManager.ShareShortcutInfo> resultList = sm.getShareTargets(filter); sendShareShortcutInfoList(resultList, driList, null, userHandle); sendShareShortcutInfoList(resultList, adapter, null, userHandle); }); } Loading Loading @@ -2061,7 +2032,7 @@ public class ChooserActivity extends ResolverActivity implements private void sendShareShortcutInfoList( List<ShortcutManager.ShareShortcutInfo> resultList, List<DisplayResolveInfo> driList, ChooserListAdapter chooserListAdapter, @Nullable List<AppTarget> appTargets, UserHandle userHandle) { if (appTargets != null && appTargets.size() != resultList.size()) { throw new RuntimeException("resultList and appTargets must have the same size." Loading @@ -2087,10 +2058,10 @@ public class ChooserActivity extends ResolverActivity implements // for direct share targets. After ShareSheet is refactored we should use the // ShareShortcutInfos directly. boolean resultMessageSent = false; for (int i = 0; i < driList.size(); i++) { for (int i = 0; i < chooserListAdapter.getDisplayResolveInfoCount(); i++) { List<ShortcutManager.ShareShortcutInfo> matchingShortcuts = new ArrayList<>(); for (int j = 0; j < resultList.size(); j++) { if (driList.get(i).getResolvedComponentName().equals( if (chooserListAdapter.getDisplayResolveInfo(i).getResolvedComponentName().equals( resultList.get(j).getTargetComponent())) { matchingShortcuts.add(resultList.get(j)); } Loading @@ -2105,7 +2076,8 @@ public class ChooserActivity extends ResolverActivity implements final Message msg = Message.obtain(); msg.what = ChooserHandler.SHORTCUT_MANAGER_SHARE_TARGET_RESULT; msg.obj = new ServiceResultInfo(driList.get(i), chooserTargets, null, userHandle); msg.obj = new ServiceResultInfo(chooserListAdapter.getDisplayResolveInfo(i), chooserTargets, null, userHandle); msg.arg1 = shortcutType; mChooserHandler.sendMessage(msg); resultMessageSent = true; Loading