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

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

Merge "Removed userId from ContentCapture binder calls."

parents 7079a551 f2aa0d22
Loading
Loading
Loading
Loading
+4 −5
Original line number Diff line number Diff line
@@ -156,8 +156,7 @@ public final class ContentCaptureManager {
        // Wait for system server to return the component name.
        final SyncResultReceiver resultReceiver = new SyncResultReceiver(SYNC_CALLS_TIMEOUT_MS);
        mHandler.sendMessage(obtainMessage(
                ContentCaptureManager::handleReceiverServiceComponentName,
                this, mContext.getUserId(), resultReceiver));
                ContentCaptureManager::handleGetComponentName, this, resultReceiver));

        try {
            return resultReceiver.getParcelableResult();
@@ -198,7 +197,7 @@ public final class ContentCaptureManager {
        Preconditions.checkNotNull(request);

        try {
            mService.removeUserData(mContext.getUserId(), request);
            mService.removeUserData(request);
        } catch (RemoteException e) {
            e.rethrowFromSystemServer();
        }
@@ -227,9 +226,9 @@ public final class ContentCaptureManager {


    /** Retrieves the component name of the target content capture service through system_server. */
    private void handleReceiverServiceComponentName(int userId, IResultReceiver resultReceiver) {
    private void handleGetComponentName(@NonNull IResultReceiver resultReceiver) {
        try {
            mService.getReceiverServiceComponentName(userId, resultReceiver);
            mService.getServiceComponentName(resultReceiver);
        } catch (RemoteException e) {
            Log.w(TAG, "Unable to retrieve service component name: " + e);
        }
+7 −7
Original line number Diff line number Diff line
@@ -34,21 +34,21 @@ import java.util.List;
  */
oneway interface IContentCaptureManager {
    /**
     * Starts a new session for the provided {@code userId} running as part of the
     * Starts a new session for the calling user running as part of the
     * app's activity identified by {@code activityToken}/{@code componentName}.
     *
     * @param sessionId Unique session id as provided by the app.
     * @param flags Meta flags that enable or disable content capture (see
     *     {@link IContentCaptureContext#flags}).
     */
    void startSession(int userId, IBinder activityToken, in ComponentName componentName,
    void startSession(IBinder activityToken, in ComponentName componentName,
                      String sessionId, int flags, in IResultReceiver result);

    /**
     * Marks the end of a session for the provided {@code userId} identified by
     * Marks the end of a session for the calling user identified by
     * the corresponding {@code startSession}'s {@code sessionId}.
     */
    void finishSession(int userId, String sessionId);
    void finishSession(String sessionId);

    /**
     * Returns the content capture service's component name (if enabled and
@@ -56,10 +56,10 @@ oneway interface IContentCaptureManager {
     * @param Receiver of the content capture service's @{code ComponentName}
     *     provided {@code Bundle} with key "{@code EXTRA}".
     */
    void getReceiverServiceComponentName(int userId, in IResultReceiver result);
    void getServiceComponentName(in IResultReceiver result);

    /**
     * Requests the removal of user data for the provided {@code userId}.
     * Requests the removal of user data for the calling user.
     */
    void removeUserData(int userId, in UserDataRemovalRequest request);
    void removeUserData(in UserDataRemovalRequest request);
}
+3 −3
Original line number Diff line number Diff line
@@ -211,8 +211,8 @@ public final class MainContentCaptureSession extends ContentCaptureSession {
        try {
            if (mSystemServerInterface == null) return;

            mSystemServerInterface.startSession(mContext.getUserId(), mApplicationToken,
                    componentName, mId, flags, new IResultReceiver.Stub() {
            mSystemServerInterface.startSession(mApplicationToken, componentName, mId, flags,
                    new IResultReceiver.Stub() {
                        @Override
                        public void send(int resultCode, Bundle resultData) {
                            IBinder binder = null;
@@ -473,7 +473,7 @@ public final class MainContentCaptureSession extends ContentCaptureSession {
        try {
            if (mSystemServerInterface == null) return;

            mSystemServerInterface.finishSession(mContext.getUserId(), mId);
            mSystemServerInterface.finishSession(mId);
        } catch (RemoteException e) {
            Log.e(TAG, "Error destroying system-service session " + mId + " for "
                    + getDebugState() + ": " + e);
+10 −6
Original line number Diff line number Diff line
@@ -177,12 +177,13 @@ public final class ContentCaptureManagerService extends
    final class ContentCaptureManagerServiceStub extends IContentCaptureManager.Stub {

        @Override
        public void startSession(@UserIdInt int userId, @NonNull IBinder activityToken,
        public void startSession(@NonNull IBinder activityToken,
                @NonNull ComponentName componentName, @NonNull String sessionId, int flags,
                @NonNull IResultReceiver result) {
            Preconditions.checkNotNull(activityToken);
            Preconditions.checkNotNull(componentName);
            Preconditions.checkNotNull(sessionId);
            final int userId = UserHandle.getCallingUserId();

            // TODO(b/111276913): refactor getTaskIdForActivity() to also return ComponentName,
            // so we don't pass it on startSession (same for Autofill)
@@ -199,8 +200,9 @@ public final class ContentCaptureManagerService extends
        }

        @Override
        public void finishSession(@UserIdInt int userId, @NonNull String sessionId) {
        public void finishSession(@NonNull String sessionId) {
            Preconditions.checkNotNull(sessionId);
            final int userId = UserHandle.getCallingUserId();

            synchronized (mLock) {
                final ContentCapturePerUserService service = getServiceForUserLocked(userId);
@@ -209,15 +211,16 @@ public final class ContentCaptureManagerService extends
        }

        @Override
        public void getReceiverServiceComponentName(@UserIdInt int userId,
                IResultReceiver receiver) {
        public void getServiceComponentName(@NonNull IResultReceiver result) {
            final int userId = UserHandle.getCallingUserId();
            ComponentName connectedServiceComponentName;
            synchronized (mLock) {
                final ContentCapturePerUserService service = getServiceForUserLocked(userId);
                connectedServiceComponentName = service.getServiceComponentName();
            }
            try {
                receiver.send(0, SyncResultReceiver.bundleFor(connectedServiceComponentName));
                result.send(/* resultCode= */ 0,
                        SyncResultReceiver.bundleFor(connectedServiceComponentName));
            } catch (RemoteException e) {
                // Ignore exception as we need to be resilient against app behavior.
                Slog.w(TAG, "Unable to send service component name: " + e);
@@ -225,8 +228,9 @@ public final class ContentCaptureManagerService extends
        }

        @Override
        public void removeUserData(@UserIdInt int userId, @NonNull UserDataRemovalRequest request) {
        public void removeUserData(@NonNull UserDataRemovalRequest request) {
            Preconditions.checkNotNull(request);
            final int userId = UserHandle.getCallingUserId();
            synchronized (mLock) {
                final ContentCapturePerUserService service = getServiceForUserLocked(userId);
                service.removeUserDataLocked(request);