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

Commit e751c7ec authored by Joshua Trask's avatar Joshua Trask Committed by Android (Google) Code Review
Browse files

Merge "Add explicit completion condition for Direct Share"

parents 3b81b74b 04b56be7
Loading
Loading
Loading
Loading
+7 −8
Original line number Diff line number Diff line
@@ -468,6 +468,7 @@ public class ChooserActivity extends ResolverActivity implements
        private static final int WATCHDOG_TIMEOUT_MIN_MILLIS = 300;

        private boolean mMinTimeoutPassed = false;
        private boolean mReceivedDirectShareTargets = false;

        private void removeAllMessages() {
            removeMessages(LIST_VIEW_UPDATE_MESSAGE);
@@ -498,7 +499,7 @@ public class ChooserActivity extends ResolverActivity implements
            // Set a minimum timeout threshold, to ensure both apis, sharing shortcuts
            // and older-style direct share services, have had time to load, otherwise
            // just checking mServiceConnections could force us to end prematurely
            if (mMinTimeoutPassed && mServiceConnections.isEmpty()) {
            if (mMinTimeoutPassed && mServiceConnections.isEmpty() && mReceivedDirectShareTargets) {
                logDirectShareTargetReceived(
                        MetricsEvent.ACTION_DIRECT_SHARE_TARGETS_LOADED_CHOOSER_SERVICE);
                sendVoiceChoicesIfNeeded();
@@ -585,10 +586,14 @@ public class ChooserActivity extends ResolverActivity implements
                    break;

                case SHORTCUT_MANAGER_SHARE_TARGET_RESULT_COMPLETED:
                    mReceivedDirectShareTargets = true;

                    logDirectShareTargetReceived(
                            MetricsEvent.ACTION_DIRECT_SHARE_TARGETS_LOADED_SHORTCUT_MANAGER);
                    sendVoiceChoicesIfNeeded();
                    getChooserActivityLogger().logSharesheetDirectLoadComplete();

                    maybeStopServiceRequestTimer();
                    break;

                default:
@@ -2140,7 +2145,6 @@ public class ChooserActivity extends ResolverActivity implements
        // Match ShareShortcutInfos with DisplayResolveInfos to be able to use the old code path
        // for direct share targets. After ShareSheet is refactored we should use the
        // ShareShortcutInfos directly.
        boolean resultMessageSent = false;
        for (int i = 0; i < chooserListAdapter.getDisplayResolveInfoCount(); i++) {
            List<ShortcutManager.ShareShortcutInfo> matchingShortcuts = new ArrayList<>();
            for (int j = 0; j < resultList.size(); j++) {
@@ -2155,21 +2159,16 @@ public class ChooserActivity extends ResolverActivity implements
            List<ChooserTarget> chooserTargets = convertToChooserTarget(
                    matchingShortcuts, resultList, appTargets, shortcutType);



            final Message msg = Message.obtain();
            msg.what = ChooserHandler.SHORTCUT_MANAGER_SHARE_TARGET_RESULT;
            msg.obj = new ServiceResultInfo(chooserListAdapter.getDisplayResolveInfo(i),
                    chooserTargets, null, userHandle);
            msg.arg1 = shortcutType;
            mChooserHandler.sendMessage(msg);
            resultMessageSent = true;
        }

        if (resultMessageSent) {
        sendShortcutManagerShareTargetResultCompleted();
    }
    }

    private void sendShortcutManagerShareTargetResultCompleted() {
        final Message msg = Message.obtain();