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

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

Merge "Changed ContentCaptureManager API so service can only disable itself."

parents b30e8b8a 72e83d8c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -6369,6 +6369,7 @@ package android.service.contentcapture {
  public abstract class ContentCaptureService extends android.app.Service {
    ctor public ContentCaptureService();
    method public final void disableContentCaptureServices();
    method public void onActivitySnapshot(@NonNull android.view.contentcapture.ContentCaptureSessionId, @NonNull android.service.contentcapture.SnapshotData);
    method public void onConnected();
    method public void onContentCaptureEvent(@NonNull android.view.contentcapture.ContentCaptureSessionId, @NonNull android.view.contentcapture.ContentCaptureEvent);
@@ -9386,7 +9387,6 @@ package android.view.contentcapture {
  public final class ContentCaptureManager {
    method public boolean isContentCaptureFeatureEnabled();
    method public void setContentCaptureFeatureEnabled(boolean);
  }
  public final class ViewNode extends android.app.assist.AssistStructure.ViewNode {
+1 −1
Original line number Diff line number Diff line
@@ -2116,6 +2116,7 @@ package android.service.contentcapture {

  public abstract class ContentCaptureService extends android.app.Service {
    ctor public ContentCaptureService();
    method public final void disableContentCaptureServices();
    method public void onActivitySnapshot(@NonNull android.view.contentcapture.ContentCaptureSessionId, @NonNull android.service.contentcapture.SnapshotData);
    method public void onConnected();
    method public void onContentCaptureEvent(@NonNull android.view.contentcapture.ContentCaptureSessionId, @NonNull android.view.contentcapture.ContentCaptureEvent);
@@ -2760,7 +2761,6 @@ package android.view.contentcapture {

  public final class ContentCaptureManager {
    method public boolean isContentCaptureFeatureEnabled();
    method public void setContentCaptureFeatureEnabled(boolean);
    field public static final String DEVICE_CONFIG_PROPERTY_IDLE_FLUSH_FREQUENCY = "idle_flush_frequency";
    field public static final String DEVICE_CONFIG_PROPERTY_LOGGING_LEVEL = "logging_level";
    field public static final String DEVICE_CONFIG_PROPERTY_LOG_HISTORY_SIZE = "log_history_size";
+18 −0
Original line number Diff line number Diff line
@@ -283,6 +283,24 @@ public abstract class ContentCaptureService extends Service {
        if (VERBOSE) Log.v(TAG, "onDestroyContentCaptureSession(id=" + sessionId + ")");
    }

    /**
     * Disables the Content Capture service for the given user.
     */
    public final void disableContentCaptureServices() {
        if (DEBUG) Log.d(TAG, "disableContentCaptureServices()");

        final IContentCaptureServiceCallback callback = mCallback;
        if (callback == null) {
            Log.w(TAG, "disableContentCaptureServices(): no server callback");
            return;
        }
        try {
            callback.disableSelf();
        } catch (RemoteException e) {
            e.rethrowFromSystemServer();
        }
    }

    /**
     * Called when the Android system disconnects from the service.
     *
+2 −2
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
package android.service.contentcapture;

import android.content.ComponentName;
import com.android.internal.os.IResultReceiver;

import java.util.List;

@@ -28,4 +27,5 @@ import java.util.List;
 */
oneway interface IContentCaptureServiceCallback {
    void setContentCaptureWhitelist(in List<String> packages, in List<ComponentName> activities);
    void disableSelf();
 }
+2 −33
Original line number Diff line number Diff line
@@ -327,39 +327,8 @@ public final class ContentCaptureManager {
            case RESULT_CODE_NOT_SERVICE:
                throw new SecurityException("caller is not user's ContentCapture service");
            default:
                throw new IllegalStateException("received invalid result: " + resultCode);
        }
    }

    /**
     * Sets whether Content Capture is enabled for the given user.
     *
     * @throws SecurityException if caller is not the app that owns the Content Capture service
     * associated with the user.
     *
     * @hide
     */
    @SystemApi
    @TestApi
    public void setContentCaptureFeatureEnabled(boolean enabled) {
        if (sDebug) Log.d(TAG, "setContentCaptureFeatureEnabled(): setting to " + enabled);

        final SyncResultReceiver resultReceiver = new SyncResultReceiver(SYNC_CALLS_TIMEOUT_MS);
        final int resultCode;
        try {
            mService.setContentCaptureFeatureEnabled(enabled, resultReceiver);
            resultCode = resultReceiver.getIntResult();
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
        switch (resultCode) {
            case RESULT_CODE_TRUE:
                // Our work is done here, in our void existance...
                return;
            case RESULT_CODE_NOT_SERVICE:
                throw new SecurityException("caller is not user's ContentCapture service");
            default:
                throw new IllegalStateException("received invalid result: " + resultCode);
                Log.wtf(TAG, "received invalid result: " + resultCode);
                return false;
        }
    }

Loading