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

Commit eeed06c1 authored by Amith Yamasani's avatar Amith Yamasani
Browse files

Clear active requests on switching voice interactor

When voice interactor goes null or changes, cancel all existing
active requests and clear them so that they can be re-submitted.

Bug: 28487567
Change-Id: Ibcf024efcc81ff18ef3babfa9a169292207bc816
parent 65fad184
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import android.annotation.Nullable;
import android.annotation.RequiresPermission;
import android.annotation.StyleRes;
import android.annotation.SystemApi;
import android.app.VoiceInteractor.Request;
import android.app.admin.DevicePolicyManager;
import android.app.assist.AssistContent;
import android.content.ComponentCallbacks2;
@@ -1272,6 +1273,12 @@ public class Activity extends ContextThemeWrapper
    }

    void setVoiceInteractor(IVoiceInteractor voiceInteractor) {
        if (mVoiceInteractor != null) {
            for (Request activeRequest: mVoiceInteractor.getActiveRequests()) {
                activeRequest.cancel();
                activeRequest.clear();
            }
        }
        if (voiceInteractor == null) {
            mVoiceInteractor = null;
        } else {