Search in sources :

Example 1 with IVoiceInteractionSession

use of android.service.voice.IVoiceInteractionSession in project android_frameworks_base by DirtyUnicorns.

the class ActivityManagerService method setFocusedActivityLocked.

boolean setFocusedActivityLocked(ActivityRecord r, String reason) {
    if (r == null || mFocusedActivity == r) {
        return false;
    }
    if (!r.isFocusable()) {
        if (DEBUG_FOCUS)
            Slog.d(TAG_FOCUS, "setFocusedActivityLocked: unfocusable r=" + r);
        return false;
    }
    if (DEBUG_FOCUS)
        Slog.d(TAG_FOCUS, "setFocusedActivityLocked: r=" + r);
    final boolean wasDoingSetFocusedActivity = mDoingSetFocusedActivity;
    if (wasDoingSetFocusedActivity)
        Slog.w(TAG, "setFocusedActivityLocked: called recursively, r=" + r + ", reason=" + reason);
    mDoingSetFocusedActivity = true;
    final ActivityRecord last = mFocusedActivity;
    mFocusedActivity = r;
    if (r.task.isApplicationTask()) {
        if (mCurAppTimeTracker != r.appTimeTracker) {
            // We are switching app tracking.  Complete the current one.
            if (mCurAppTimeTracker != null) {
                mCurAppTimeTracker.stop();
                mHandler.obtainMessage(REPORT_TIME_TRACKER_MSG, mCurAppTimeTracker).sendToTarget();
                mStackSupervisor.clearOtherAppTimeTrackers(r.appTimeTracker);
                mCurAppTimeTracker = null;
            }
            if (r.appTimeTracker != null) {
                mCurAppTimeTracker = r.appTimeTracker;
                startTimeTrackingFocusedActivityLocked();
            }
        } else {
            startTimeTrackingFocusedActivityLocked();
        }
    } else {
        r.appTimeTracker = null;
    }
    // back to this activity
    if (r.task.voiceInteractor != null) {
        startRunningVoiceLocked(r.task.voiceSession, r.info.applicationInfo.uid);
    } else {
        finishRunningVoiceLocked();
        IVoiceInteractionSession session;
        if (last != null && ((session = last.task.voiceSession) != null || (session = last.voiceSession) != null)) {
            // We had been in a voice interaction session, but now focused has
            // move to something different.  Just finish the session, we can't
            // return to it and retain the proper state and synchronization with
            // the voice interaction service.
            finishVoiceTask(session);
        }
    }
    if (mStackSupervisor.moveActivityStackToFront(r, reason + " setFocusedActivity")) {
        mWindowManager.setFocusedApp(r.appToken, true);
    }
    applyUpdateLockStateLocked(r);
    applyUpdateVrModeLocked(r);
    if (mFocusedActivity.userId != mLastFocusedUserId) {
        mHandler.removeMessages(FOREGROUND_PROFILE_CHANGED_MSG);
        mHandler.obtainMessage(FOREGROUND_PROFILE_CHANGED_MSG, mFocusedActivity.userId, 0).sendToTarget();
        mLastFocusedUserId = mFocusedActivity.userId;
    }
    // indicate a problem of the focus setting logic!
    if (mFocusedActivity != r)
        Slog.w(TAG, "setFocusedActivityLocked: r=" + r + " but focused to " + mFocusedActivity);
    mDoingSetFocusedActivity = wasDoingSetFocusedActivity;
    EventLogTags.writeAmFocusedActivity(mFocusedActivity == null ? -1 : mFocusedActivity.userId, mFocusedActivity == null ? "NULL" : mFocusedActivity.shortComponentName, reason);
    return true;
}
Also used : IVoiceInteractionSession(android.service.voice.IVoiceInteractionSession)

Example 2 with IVoiceInteractionSession

use of android.service.voice.IVoiceInteractionSession in project platform_frameworks_base by android.

the class ActivityManagerService method setFocusedActivityLocked.

boolean setFocusedActivityLocked(ActivityRecord r, String reason) {
    if (r == null || mFocusedActivity == r) {
        return false;
    }
    if (!r.isFocusable()) {
        if (DEBUG_FOCUS)
            Slog.d(TAG_FOCUS, "setFocusedActivityLocked: unfocusable r=" + r);
        return false;
    }
    if (DEBUG_FOCUS)
        Slog.d(TAG_FOCUS, "setFocusedActivityLocked: r=" + r);
    final boolean wasDoingSetFocusedActivity = mDoingSetFocusedActivity;
    if (wasDoingSetFocusedActivity)
        Slog.w(TAG, "setFocusedActivityLocked: called recursively, r=" + r + ", reason=" + reason);
    mDoingSetFocusedActivity = true;
    final ActivityRecord last = mFocusedActivity;
    mFocusedActivity = r;
    if (r.task.isApplicationTask()) {
        if (mCurAppTimeTracker != r.appTimeTracker) {
            // We are switching app tracking.  Complete the current one.
            if (mCurAppTimeTracker != null) {
                mCurAppTimeTracker.stop();
                mHandler.obtainMessage(REPORT_TIME_TRACKER_MSG, mCurAppTimeTracker).sendToTarget();
                mStackSupervisor.clearOtherAppTimeTrackers(r.appTimeTracker);
                mCurAppTimeTracker = null;
            }
            if (r.appTimeTracker != null) {
                mCurAppTimeTracker = r.appTimeTracker;
                startTimeTrackingFocusedActivityLocked();
            }
        } else {
            startTimeTrackingFocusedActivityLocked();
        }
    } else {
        r.appTimeTracker = null;
    }
    // back to this activity
    if (r.task.voiceInteractor != null) {
        startRunningVoiceLocked(r.task.voiceSession, r.info.applicationInfo.uid);
    } else {
        finishRunningVoiceLocked();
        IVoiceInteractionSession session;
        if (last != null && ((session = last.task.voiceSession) != null || (session = last.voiceSession) != null)) {
            // We had been in a voice interaction session, but now focused has
            // move to something different.  Just finish the session, we can't
            // return to it and retain the proper state and synchronization with
            // the voice interaction service.
            finishVoiceTask(session);
        }
    }
    if (mStackSupervisor.moveActivityStackToFront(r, reason + " setFocusedActivity")) {
        mWindowManager.setFocusedApp(r.appToken, true);
    }
    applyUpdateLockStateLocked(r);
    applyUpdateVrModeLocked(r);
    if (mFocusedActivity.userId != mLastFocusedUserId) {
        mHandler.removeMessages(FOREGROUND_PROFILE_CHANGED_MSG);
        mHandler.obtainMessage(FOREGROUND_PROFILE_CHANGED_MSG, mFocusedActivity.userId, 0).sendToTarget();
        mLastFocusedUserId = mFocusedActivity.userId;
    }
    // indicate a problem of the focus setting logic!
    if (mFocusedActivity != r)
        Slog.w(TAG, "setFocusedActivityLocked: r=" + r + " but focused to " + mFocusedActivity);
    mDoingSetFocusedActivity = wasDoingSetFocusedActivity;
    EventLogTags.writeAmFocusedActivity(mFocusedActivity == null ? -1 : mFocusedActivity.userId, mFocusedActivity == null ? "NULL" : mFocusedActivity.shortComponentName, reason);
    return true;
}
Also used : IVoiceInteractionSession(android.service.voice.IVoiceInteractionSession)

Aggregations

IVoiceInteractionSession (android.service.voice.IVoiceInteractionSession)2