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

Commit 9cc842f0 authored by Dianne Hackborn's avatar Dianne Hackborn Committed by Android (Google) Code Review
Browse files

Merge "Fix issue #21816660 (app standby), work on issue #20882522 (voice interact)" into mnc-dev

parents 98f98dd1 b8004ff3
Loading
Loading
Loading
Loading
+18 −23
Original line number Diff line number Diff line
@@ -31,7 +31,6 @@ import static com.android.server.am.ActivityManagerDebugConfig.*;
import static com.android.server.am.ActivityStackSupervisor.HOME_STACK_ID;
import static com.android.server.am.TaskRecord.INVALID_TASK_ID;
import static com.android.server.am.TaskRecord.LOCK_TASK_AUTH_DONT_LOCK;
import static com.android.server.am.TaskRecord.LOCK_TASK_AUTH_LAUNCHABLE;
import static com.android.server.am.TaskRecord.LOCK_TASK_AUTH_LAUNCHABLE_PRIV;
import static com.android.server.am.TaskRecord.LOCK_TASK_AUTH_PINNABLE;
import static org.xmlpull.v1.XmlPullParser.END_DOCUMENT;
@@ -10338,11 +10337,12 @@ public final class ActivityManagerService extends ActivityManagerNative
    void startRunningVoiceLocked(IVoiceInteractionSession session, int targetUid) {
        mVoiceWakeLock.setWorkSource(new WorkSource(targetUid));
        if (mRunningVoice == null || mRunningVoice.asBinder() != session.asBinder()) {
            if (mRunningVoice == null) {
            boolean wasRunningVoice = mRunningVoice != null;
            mRunningVoice = session;
            if (!wasRunningVoice) {
                mVoiceWakeLock.acquire();
                updateSleepIfNeededLocked();
            }
            mRunningVoice = session;
        }
    }
@@ -18595,13 +18595,9 @@ public final class ActivityManagerService extends ActivityManagerNative
            return;
        }
        boolean isInteraction;
        if (!mSleeping) {
            isInteraction = app.curProcState <= ActivityManager.PROCESS_STATE_IMPORTANT_FOREGROUND;
            app.fgInteractionTime = 0;
        } else {
            // If the display is off, we are going to be more restrictive about what we consider
            // to be an app interaction.  Being the top activity doesn't count, nor do generally
            // foreground services.
        // To avoid some abuse patterns, we are going to be careful about what we consider
        // to be an app interaction.  Being the top activity doesn't count while the display
        // is sleeping, nor do short foreground services.
        if (app.curProcState <= ActivityManager.PROCESS_STATE_BOUND_FOREGROUND_SERVICE) {
            isInteraction = true;
            app.fgInteractionTime = 0;
@@ -18618,7 +18614,6 @@ public final class ActivityManagerService extends ActivityManagerNative
                    <= ActivityManager.PROCESS_STATE_IMPORTANT_FOREGROUND;
            app.fgInteractionTime = 0;
        }
        }
        if (isInteraction && !app.reportedInteraction) {
            String[] packages = app.getPackageList();
            if (packages != null) {
+71 −38
Original line number Diff line number Diff line
@@ -853,7 +853,38 @@ public class VoiceInteractionManagerService extends SystemService {
        PackageMonitor mPackageMonitor = new PackageMonitor() {
            @Override
            public boolean onHandleForceStop(Intent intent, String[] packages, int uid, boolean doit) {
                return super.onHandleForceStop(intent, packages, uid, doit);
                if (DEBUG) Slog.d(TAG, "onHandleForceStop uid=" + uid + " doit=" + doit);

                int userHandle = UserHandle.getUserId(uid);
                ComponentName curInteractor = getCurInteractor(userHandle);
                ComponentName curRecognizer = getCurRecognizer(userHandle);
                boolean hit = false;
                for (String pkg : packages) {
                    if (curInteractor != null && pkg.equals(curInteractor.getPackageName())) {
                        hit = true;
                        break;
                    } else if (curRecognizer != null
                            && pkg.equals(curRecognizer.getPackageName())) {
                        hit = true;
                        break;
                    }
                }
                if (hit && doit) {
                    // The user is force stopping our current interactor/recognizer.
                    // Clear the current settings and restore default state.
                    synchronized (VoiceInteractionManagerService.this) {
                        mSoundTriggerHelper.stopAllRecognitions();
                        if (mImpl != null) {
                            mImpl.shutdownLocked();
                            mImpl = null;
                        }
                        setCurInteractor(null, userHandle);
                        setCurRecognizer(null, userHandle);
                        initForUser(userHandle);
                        switchImplementationIfNeededLocked(true);
                    }
                }
                return hit;
            }

            @Override
@@ -865,6 +896,7 @@ public class VoiceInteractionManagerService extends SystemService {
                int userHandle = getChangingUserId();
                if (DEBUG) Slog.d(TAG, "onSomePackagesChanged user=" + userHandle);

                synchronized (VoiceInteractionManagerService.this) {
                    ComponentName curInteractor = getCurInteractor(userHandle);
                    ComponentName curRecognizer = getCurRecognizer(userHandle);
                    if (curRecognizer == null) {
@@ -912,6 +944,7 @@ public class VoiceInteractionManagerService extends SystemService {
                                userHandle), userHandle);
                    }
                }
            }
        };
    }
}