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

Commit 9513cbfa authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix deadlock when fetching active voice interaction service component."

parents 2cea154e bccd4b5b
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -260,6 +260,11 @@ public abstract class ActivityManagerInternal {
     */
    public abstract void notifyNetworkPolicyRulesUpdated(int uid, long procStateSeq);

    /**
     * Called after the voice interaction service has changed.
     */
    public abstract void notifyActiveVoiceInteractionServiceChanged(ComponentName component);

    /**
     * Called after virtual display Id is updated by
     * {@link com.android.server.vr.Vr2dDisplay} with a specific
+14 −2
Original line number Diff line number Diff line
@@ -250,7 +250,6 @@ import android.app.assist.AssistStructure;
import android.app.backup.IBackupManager;
import android.app.servertransaction.ConfigurationChangeItem;
import android.app.usage.UsageEvents;
import android.app.usage.UsageStats;
import android.app.usage.UsageStatsManagerInternal;
import android.appwidget.AppWidgetManager;
import android.content.ActivityNotFoundException;
@@ -630,7 +629,13 @@ public class ActivityManagerService extends IActivityManager.Stub
    /** All system services */
    SystemServiceManager mSystemServiceManager;
    AssistUtils mAssistUtils;
    // Wrapper around VoiceInteractionServiceManager
    private AssistUtils mAssistUtils;
    // Keeps track of the active voice interaction service component, notified from
    // VoiceInteractionManagerService
    ComponentName mActiveVoiceInteractionServiceComponent;
    private Installer mInstaller;
@@ -24407,6 +24412,13 @@ public class ActivityManagerService extends IActivityManager.Stub
            }
        }
        @Override
        public void notifyActiveVoiceInteractionServiceChanged(ComponentName component) {
            synchronized (ActivityManagerService.this) {
                mActiveVoiceInteractionServiceComponent = component;
            }
        }
        /**
         * Called after virtual display Id is updated by
         * {@link com.android.server.vr.Vr2dDisplay} with a specific
+1 −5
Original line number Diff line number Diff line
@@ -1050,11 +1050,7 @@ final class ActivityRecord extends ConfigurationContainer implements AppWindowCo
     * @return whether the given package name can launch an assist activity.
     */
    private boolean canLaunchAssistActivity(String packageName) {
        if (service.mAssistUtils == null) {
            return false;
        }

        final ComponentName assistComponent = service.mAssistUtils.getActiveServiceComponentName();
        final ComponentName assistComponent = service.mActiveVoiceInteractionServiceComponent;
        if (assistComponent != null) {
            return assistComponent.getPackageName().equals(packageName);
        }
+10 −5
Original line number Diff line number Diff line
@@ -75,7 +75,6 @@ import com.android.server.soundtrigger.SoundTriggerInternal;
import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.List;
import java.util.TreeSet;

/**
 * SystemService that publishes an IVoiceInteractionManagerService.
@@ -442,11 +441,11 @@ public class VoiceInteractionManagerService extends SystemService {
                        mImpl.shutdownLocked();
                    }
                    if (hasComponent) {
                        mImpl = new VoiceInteractionManagerServiceImpl(mContext,
                                UiThread.getHandler(), this, mCurUser, serviceComponent);
                        setImplLocked(new VoiceInteractionManagerServiceImpl(mContext,
                                UiThread.getHandler(), this, mCurUser, serviceComponent));
                        mImpl.startLocked();
                    } else {
                        mImpl = null;
                        setImplLocked(null);
                    }
                }
            }
@@ -1177,6 +1176,12 @@ public class VoiceInteractionManagerService extends SystemService {
            }
        }

        private void setImplLocked(VoiceInteractionManagerServiceImpl impl) {
            mImpl = impl;
            mAmInternal.notifyActiveVoiceInteractionServiceChanged(
                    getActiveServiceComponentName());
        }

        class SettingsObserver extends ContentObserver {
            SettingsObserver(Handler handler) {
                super(handler);
@@ -1219,7 +1224,7 @@ public class VoiceInteractionManagerService extends SystemService {
                        unloadAllKeyphraseModels();
                        if (mImpl != null) {
                            mImpl.shutdownLocked();
                            mImpl = null;
                            setImplLocked(null);
                        }
                        setCurInteractor(null, userHandle);
                        setCurRecognizer(null, userHandle);