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

Commit 1058d632 authored by Jorim Jaggi's avatar Jorim Jaggi Committed by Android (Google) Code Review
Browse files

Merge "Fix VoiceInteraction permission issues"

parents 053dee79 b09f8e29
Loading
Loading
Loading
Loading
+4 −14
Original line number Diff line number Diff line
@@ -393,12 +393,9 @@ public class VoiceInteractionManagerService extends SystemService {
                    throw new SecurityException(
                            "Caller is not the current voice interaction service");
                }
                final int callingPid = Binder.getCallingPid();
                final int callingUid = Binder.getCallingUid();
                final long caller = Binder.clearCallingIdentity();
                try {
                    mImpl.showSessionLocked(callingPid, callingUid, args, flags,
                            null /* showCallback */);
                    mImpl.showSessionLocked(args, flags, null /* showCallback */);
                } finally {
                    Binder.restoreCallingIdentity(caller);
                }
@@ -432,12 +429,9 @@ public class VoiceInteractionManagerService extends SystemService {
                    Slog.w(TAG, "showSessionFromSession without running voice interaction service");
                    return false;
                }
                final int callingPid = Binder.getCallingPid();
                final int callingUid = Binder.getCallingUid();
                final long caller = Binder.clearCallingIdentity();
                try {
                    return mImpl.showSessionLocked(callingPid, callingUid, sessionArgs, flags,
                            null /* showCallback */);
                    return mImpl.showSessionLocked(sessionArgs, flags, null /* showCallback */);
                } finally {
                    Binder.restoreCallingIdentity(caller);
                }
@@ -506,11 +500,9 @@ public class VoiceInteractionManagerService extends SystemService {
                    Slog.w(TAG, "finish without running voice interaction service");
                    return;
                }
                final int callingPid = Binder.getCallingPid();
                final int callingUid = Binder.getCallingUid();
                final long caller = Binder.clearCallingIdentity();
                try {
                    mImpl.finishLocked(callingPid, callingUid, token);
                    mImpl.finishLocked(token);
                } finally {
                    Binder.restoreCallingIdentity(caller);
                }
@@ -708,11 +700,9 @@ public class VoiceInteractionManagerService extends SystemService {
                            + "service");
                    return;
                }
                final int callingPid = Binder.getCallingPid();
                final int callingUid = Binder.getCallingUid();
                final long caller = Binder.clearCallingIdentity();
                try {
                    mImpl.showSessionLocked(callingPid, callingUid, new Bundle() /* sessionArgs */,
                    mImpl.showSessionLocked(new Bundle() /* sessionArgs */,
                            VoiceInteractionService.START_SOURCE_ASSIST_GESTURE
                                    | VoiceInteractionService.START_WITH_ASSIST
                                    | VoiceInteractionService.START_WITH_SCREENSHOT,
+4 −4
Original line number Diff line number Diff line
@@ -135,11 +135,11 @@ class VoiceInteractionManagerServiceImpl implements VoiceInteractionSessionConne
        mContext.registerReceiver(mBroadcastReceiver, filter, null, handler);
    }

    public boolean showSessionLocked(int callingPid, int callingUid, Bundle args, int flags,
    public boolean showSessionLocked(Bundle args, int flags,
            IVoiceInteractionSessionShowCallback showCallback) {
        if (mActiveSession == null) {
            mActiveSession = new VoiceInteractionSessionConnection(mLock, mSessionComponentName,
                    mUser, mContext, this, callingPid, callingUid);
                    mUser, mContext, this, mInfo.getServiceInfo().applicationInfo.uid);
        }
        return mActiveSession.showLocked(args, flags, showCallback);
    }
@@ -196,7 +196,7 @@ class VoiceInteractionManagerServiceImpl implements VoiceInteractionSessionConne
        }
    }

    public void finishLocked(int callingPid, int callingUid, IBinder token) {
    public void finishLocked(IBinder token) {
        if (mActiveSession == null || token != mActiveSession.mToken) {
            Slog.w(TAG, "finish does not match active session");
            return;
@@ -267,7 +267,7 @@ class VoiceInteractionManagerServiceImpl implements VoiceInteractionSessionConne
    @Override
    public void sessionConnectionGone(VoiceInteractionSessionConnection connection) {
        synchronized (mLock) {
            finishLocked(connection.mCallingPid, connection.mCallingUid, connection.mToken);
            finishLocked(connection.mToken);
        }
    }
}
+1 −3
Original line number Diff line number Diff line
@@ -59,7 +59,6 @@ final class VoiceInteractionSessionConnection implements ServiceConnection {
    final int mUser;
    final Context mContext;
    final Callback mCallback;
    final int mCallingPid;
    final int mCallingUid;
    final IActivityManager mAm;
    final IWindowManager mIWindowManager;
@@ -139,13 +138,12 @@ final class VoiceInteractionSessionConnection implements ServiceConnection {
    };

    public VoiceInteractionSessionConnection(Object lock, ComponentName component, int user,
            Context context, Callback callback, int callingPid, int callingUid) {
            Context context, Callback callback, int callingUid) {
        mLock = lock;
        mSessionComponentName = component;
        mUser = user;
        mContext = context;
        mCallback = callback;
        mCallingPid = callingPid;
        mCallingUid = callingUid;
        mAm = ActivityManagerNative.getDefault();
        mIWindowManager = IWindowManager.Stub.asInterface(