summaryrefslogtreecommitdiff
path: root/services/contentcapture
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2019-05-01 23:50:58 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2019-05-01 23:50:58 +0000
commit9f590ef1a9e10fe63784d1dcd5b227acd036d914 (patch)
tree79e071cacc890502dfc7db801aad974115f5f0df /services/contentcapture
parent4e4108923c1c45940d33aacc68bfa02ec0566399 (diff)
parent6c0afca46a0e2f417836e8ef5763ed6c18898f53 (diff)
Merge "Propogate disabled state to content capture session after changing user restrictions or on ccm.setContentCaptureEnabled()." into qt-dev
Diffstat (limited to 'services/contentcapture')
-rw-r--r--services/contentcapture/java/com/android/server/contentcapture/ContentCapturePerUserService.java11
-rw-r--r--services/contentcapture/java/com/android/server/contentcapture/ContentCaptureServerSession.java19
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 a7921b5f3892..4399e4267fda 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")