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

Commit 3d0409b0 authored by Adam He's avatar Adam He
Browse files

Implement onUserDataRemovalRequest

Change-Id: I7c818d42000b6155f9dcaad85b7f9f761741a484
Fixes: 121289354
Test: atest CtsContentCaptureServiceTestCases # still passing
Test: manual verification
parent cc249beb
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -116,6 +116,13 @@ public abstract class ContentCaptureService extends Service {
            mHandler.sendMessage(obtainMessage(ContentCaptureService::handleFinishSession,
                    ContentCaptureService.this, sessionId));
        }

        @Override
        public void onUserDataRemovalRequest(UserDataRemovalRequest request) {
            mHandler.sendMessage(
                    obtainMessage(ContentCaptureService::handleOnUserDataRemovalRequest,
                            ContentCaptureService.this, request));
        }
    };

    /**
@@ -431,6 +438,10 @@ public abstract class ContentCaptureService extends Service {
        onDestroyContentCaptureSession(new ContentCaptureSessionId(sessionId));
    }

    private void handleOnUserDataRemovalRequest(@NonNull UserDataRemovalRequest request) {
        onUserDataRemovalRequest(request);
    }

    /**
     * Checks if the given {@code uid} owns the session associated with the event.
     */
+2 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package android.service.contentcapture;
import android.os.IBinder;
import android.service.contentcapture.SnapshotData;
import android.view.contentcapture.ContentCaptureContext;
import android.view.contentcapture.UserDataRemovalRequest;

import com.android.internal.os.IResultReceiver;

@@ -36,4 +37,5 @@ oneway interface IContentCaptureService {
                          in IResultReceiver clientReceiver);
    void onSessionFinished(String sessionId);
    void onActivitySnapshot(String sessionId, in SnapshotData snapshotData);
    void onUserDataRemovalRequest(in UserDataRemovalRequest request);
}
+8 −2
Original line number Diff line number Diff line
@@ -191,13 +191,19 @@ public final class ContentCaptureManager {
    }

    /**
     * Called by the ap to request the Content Capture service to remove user-data associated with
     * Called by the app to request the Content Capture service to remove user-data associated with
     * some context.
     *
     * @param request object specifying what user data should be removed.
     */
    public void removeUserData(@NonNull UserDataRemovalRequest request) {
        //TODO(b/111276913): implement
        Preconditions.checkNotNull(request);

        try {
            mService.removeUserData(mContext.getUserId(), request);
        } catch (RemoteException e) {
            e.rethrowFromSystemServer();
        }
    }

    /** @hide */
+6 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package android.view.contentcapture;
import android.content.ComponentName;
import android.view.contentcapture.ContentCaptureContext;
import android.view.contentcapture.ContentCaptureEvent;
import android.view.contentcapture.UserDataRemovalRequest;
import android.os.IBinder;

import com.android.internal.os.IResultReceiver;
@@ -56,4 +57,9 @@ oneway interface IContentCaptureManager {
     *     provided {@code Bundle} with key "{@code EXTRA}".
     */
    void getReceiverServiceComponentName(int userId, in IResultReceiver result);

    /**
     * Requests the removal of user data for the provided {@code userId}.
     */
    void removeUserData(int userId, in UserDataRemovalRequest request);
}
+19 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2019 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.view.contentcapture;

parcelable UserDataRemovalRequest;
Loading