diff options
author | Adam He <adamhe@google.com> | 2019-05-02 16:00:24 -0700 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2019-05-02 16:00:24 -0700 |
commit | bfd799ad8acb77883a65e8cc5bc89a2e38c2f9d5 (patch) | |
tree | 17f69cdc718040169cf33be12a9d8efa88a895b7 /services/contentcapture | |
parent | 705033d9f798f09b3f50f9b6c9bb2ad2a5b6bc6f (diff) | |
parent | e82f16f82c18a0867b8c2756f4427af3c7d3c050 (diff) |
Merge "Propogate disabled state to content capture session after changing user restrictions or on ccm.setContentCaptureEnabled()." into qt-dev am: 9f590ef1a9
am: e82f16f82c
Change-Id: I795acfb113c76eb30cea34138410eaff560cfcf7
Diffstat (limited to 'services/contentcapture')
2 files changed, 28 insertions, 2 deletions
diff --git a/services/contentcapture/java/com/android/server/contentcapture/ContentCapturePerUserService.java b/services/contentcapture/java/com/android/server/contentcapture/ContentCapturePerUserService.java index 35d345287048..5ff0ee95cd0c 100644 --- a/services/contentcapture/java/com/android/server/contentcapture/ContentCapturePerUserService.java +++ b/services/contentcapture/java/com/android/server/contentcapture/ContentCapturePerUserService.java @@ -161,8 +161,14 @@ final class ContentCapturePerUserService @Override // from PerUserSystemService @GuardedBy("mLock") protected boolean updateLocked(boolean disabled) { - destroyLocked(); final boolean disabledStateChanged = super.updateLocked(disabled); + if (disabledStateChanged) { + // update session content capture enabled state. + for (int i = 0; i < mSessions.size(); i++) { + mSessions.valueAt(i).setContentCaptureEnabledLocked(!disabled); + } + } + destroyLocked(); updateRemoteServiceLocked(disabled); return disabledStateChanged; } @@ -542,7 +548,8 @@ final class ContentCapturePerUserService Slog.v(TAG, "setContentCaptureWhitelist(" + (packages == null ? "null_packages" : packages.size() + " packages") + ", " + (activities == null - ? "null_activities" : activities.size() + " activities") + ")"); + ? "null_activities" : activities.size() + " activities") + ")" + + " for user " + mUserId); } mMaster.mGlobalContentCaptureOptions.setWhitelist(mUserId, packages, activities); } diff --git a/services/contentcapture/java/com/android/server/contentcapture/ContentCaptureServerSession.java b/services/contentcapture/java/com/android/server/contentcapture/ContentCaptureServerSession.java index d38dfd409439..2643db1d5851 100644 --- a/services/contentcapture/java/com/android/server/contentcapture/ContentCaptureServerSession.java +++ b/services/contentcapture/java/com/android/server/contentcapture/ContentCaptureServerSession.java @@ -16,6 +16,8 @@ package com.android.server.contentcapture; import static android.service.contentcapture.ContentCaptureService.setClientState; +import static android.view.contentcapture.ContentCaptureManager.RESULT_CODE_FALSE; +import static android.view.contentcapture.ContentCaptureManager.RESULT_CODE_TRUE; import static android.view.contentcapture.ContentCaptureSession.NO_SESSION_ID; import static android.view.contentcapture.ContentCaptureSession.STATE_ACTIVE; import static android.view.contentcapture.ContentCaptureSession.STATE_DISABLED; @@ -24,13 +26,16 @@ import static android.view.contentcapture.ContentCaptureSession.STATE_SERVICE_UP import android.annotation.NonNull; import android.content.ComponentName; +import android.os.Bundle; import android.os.IBinder; +import android.os.RemoteException; import android.service.contentcapture.ContentCaptureService; import android.service.contentcapture.SnapshotData; import android.util.LocalLog; import android.util.Slog; import android.view.contentcapture.ContentCaptureContext; import android.view.contentcapture.ContentCaptureSessionId; +import android.view.contentcapture.MainContentCaptureSession; import com.android.internal.annotations.GuardedBy; import com.android.internal.os.IResultReceiver; @@ -108,6 +113,20 @@ final class ContentCaptureServerSession { } /** + * Changes the {@link ContentCaptureService} enabled state. + */ + @GuardedBy("mLock") + public void setContentCaptureEnabledLocked(boolean enabled) { + try { + final Bundle extras = new Bundle(); + extras.putBoolean(MainContentCaptureSession.EXTRA_ENABLED_STATE, true); + mSessionStateReceiver.send(enabled ? RESULT_CODE_TRUE : RESULT_CODE_FALSE, extras); + } catch (RemoteException e) { + Slog.w(TAG, "Error async reporting result to client: " + e); + } + } + + /** * Notifies the {@link ContentCaptureService} of a snapshot of an activity. */ @GuardedBy("mLock") |