diff options
| author | 2022-09-23 17:05:31 +0000 | |
|---|---|---|
| committer | 2022-09-23 17:05:31 +0000 | |
| commit | 223025a234c3c14cf7ad107a67b45cdf5f3f11fb (patch) | |
| tree | 8adc0c741ba2914f449b84576e3fe6f55b36bb2b /services/contentcapture/java | |
| parent | c54f78f47068661a3272a983aa1e9a46898a7546 (diff) | |
| parent | 03a4e9a0e9df118f4dfb279b439393e767f31a72 (diff) | |
Merge "Add event log for content capture" into tm-qpr-dev am: 801dd043f3 am: 03a4e9a0e9
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/19799941
Change-Id: I6d97738c981a1983d4453f0b87c58d4bbc9ee33f
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
Diffstat (limited to 'services/contentcapture/java')
3 files changed, 49 insertions, 3 deletions
diff --git a/services/contentcapture/java/com/android/server/contentcapture/ContentCapturePerUserService.java b/services/contentcapture/java/com/android/server/contentcapture/ContentCapturePerUserService.java index 7a95a8fe8c7f..a08687f86719 100644 --- a/services/contentcapture/java/com/android/server/contentcapture/ContentCapturePerUserService.java +++ b/services/contentcapture/java/com/android/server/contentcapture/ContentCapturePerUserService.java @@ -60,6 +60,7 @@ import android.service.contentcapture.SnapshotData; import android.service.voice.VoiceInteractionManagerInternal; import android.util.ArrayMap; import android.util.ArraySet; +import android.util.EventLog; import android.util.Slog; import android.util.SparseArray; import android.util.SparseBooleanArray; @@ -69,6 +70,7 @@ import android.view.contentcapture.DataShareRequest; import com.android.internal.annotations.GuardedBy; import com.android.internal.os.IResultReceiver; +import com.android.internal.util.CollectionUtils; import com.android.internal.util.FrameworkStatsLog; import com.android.server.LocalServices; import com.android.server.contentcapture.RemoteContentCaptureService.ContentCaptureServiceCallbacks; @@ -88,6 +90,10 @@ final class ContentCapturePerUserService private static final String TAG = ContentCapturePerUserService.class.getSimpleName(); + private static final int EVENT_LOG_CONNECT_STATE_DIED = 0; + static final int EVENT_LOG_CONNECT_STATE_CONNECTED = 1; + static final int EVENT_LOG_CONNECT_STATE_DISCONNECTED = 2; + @GuardedBy("mLock") private final SparseArray<ContentCaptureServerSession> mSessions = new SparseArray<>(); @@ -190,9 +196,12 @@ final class ContentCapturePerUserService Slog.w(TAG, "remote service died: " + service); synchronized (mLock) { mZombie = true; + ComponentName serviceComponent = getServiceComponentName(); writeServiceEvent( FrameworkStatsLog.CONTENT_CAPTURE_SERVICE_EVENTS__EVENT__ON_REMOTE_SERVICE_DIED, - getServiceComponentName()); + serviceComponent); + EventLog.writeEvent(EventLogTags.CC_CONNECT_STATE_CHANGED, mUserId, + EVENT_LOG_CONNECT_STATE_DIED, 0); } } @@ -529,6 +538,15 @@ final class ContentCapturePerUserService return mConditionsByPkg.get(packageName); } + @Nullable + ArraySet<String> getContentCaptureAllowlist() { + ArraySet<String> allowPackages; + synchronized (mLock) { + allowPackages = mMaster.mGlobalContentCaptureOptions.getWhitelistedPackages(mUserId); + } + return allowPackages; + } + @GuardedBy("mLock") void onActivityEventLocked(@NonNull ComponentName componentName, @ActivityEventType int type) { if (mRemoteService == null) { @@ -617,8 +635,12 @@ final class ContentCapturePerUserService ArraySet<String> oldList = mMaster.mGlobalContentCaptureOptions.getWhitelistedPackages(mUserId); + EventLog.writeEvent(EventLogTags.CC_CURRENT_ALLOWLIST, mUserId, + CollectionUtils.size(oldList)); mMaster.mGlobalContentCaptureOptions.setWhitelist(mUserId, packages, activities); + EventLog.writeEvent(EventLogTags.CC_SET_ALLOWLIST, mUserId, + CollectionUtils.size(packages), CollectionUtils.size(activities)); writeSetWhitelistEvent(getServiceComponentName(), packages, activities); updateContentCaptureOptions(oldList); @@ -699,13 +721,15 @@ final class ContentCapturePerUserService private void updateContentCaptureOptions(@Nullable ArraySet<String> oldList) { ArraySet<String> adding = mMaster.mGlobalContentCaptureOptions .getWhitelistedPackages(mUserId); + int addingCount = CollectionUtils.size(adding); + EventLog.writeEvent(EventLogTags.CC_CURRENT_ALLOWLIST, mUserId, addingCount); if (oldList != null && adding != null) { adding.removeAll(oldList); } - int N = adding != null ? adding.size() : 0; - for (int i = 0; i < N; i++) { + EventLog.writeEvent(EventLogTags.CC_UPDATE_OPTIONS, mUserId, addingCount); + for (int i = 0; i < addingCount; i++) { String packageName = adding.valueAt(i); ContentCaptureOptions options = mMaster.mGlobalContentCaptureOptions .getOptions(mUserId, packageName); diff --git a/services/contentcapture/java/com/android/server/contentcapture/EventLogTags.logtags b/services/contentcapture/java/com/android/server/contentcapture/EventLogTags.logtags new file mode 100644 index 000000000000..5218b26397df --- /dev/null +++ b/services/contentcapture/java/com/android/server/contentcapture/EventLogTags.logtags @@ -0,0 +1,13 @@ +# See system/logging/logcat/event.logtags for a description of the format of this file. + +option java_package com.android.server.contentcapture + +# ContentCaptureService connection state change, refer to ContentCapturePerUserService +# for type definition +53200 cc_connect_state_changed (user|1|5),(type|1|5),(package_count|1|1) +# Set the package and activity allowlist +53201 cc_set_allowlist (user|1|5),(package_count|1|1),(activity_count|1|1) +# Get the current allowlist +53202 cc_current_allowlist (user|1|5),(count|1|1) +# update content capture client option with new allow list count +53203 cc_update_options (user|1|5),(count|1) diff --git a/services/contentcapture/java/com/android/server/contentcapture/RemoteContentCaptureService.java b/services/contentcapture/java/com/android/server/contentcapture/RemoteContentCaptureService.java index 1efe55aa0767..3907de4d903a 100644 --- a/services/contentcapture/java/com/android/server/contentcapture/RemoteContentCaptureService.java +++ b/services/contentcapture/java/com/android/server/contentcapture/RemoteContentCaptureService.java @@ -31,6 +31,7 @@ import android.service.contentcapture.IContentCaptureService; import android.service.contentcapture.IContentCaptureServiceCallback; import android.service.contentcapture.IDataShareCallback; import android.service.contentcapture.SnapshotData; +import android.util.EventLog; import android.util.Slog; import android.view.contentcapture.ContentCaptureContext; import android.view.contentcapture.DataRemovalRequest; @@ -38,6 +39,7 @@ import android.view.contentcapture.DataShareRequest; import com.android.internal.infra.AbstractMultiplePendingRequestsRemoteService; import com.android.internal.os.IResultReceiver; +import com.android.internal.util.CollectionUtils; import com.android.internal.util.FrameworkStatsLog; final class RemoteContentCaptureService @@ -88,6 +90,10 @@ final class RemoteContentCaptureService writeServiceEvent( FrameworkStatsLog.CONTENT_CAPTURE_SERVICE_EVENTS__EVENT__ON_CONNECTED, mComponentName); + EventLog.writeEvent(EventLogTags.CC_CONNECT_STATE_CHANGED, + mPerUserService.getUserId(), + ContentCapturePerUserService.EVENT_LOG_CONNECT_STATE_CONNECTED, + CollectionUtils.size(mPerUserService.getContentCaptureAllowlist())); } finally { // Update the system-service state, in case the service reconnected after // dying @@ -98,6 +104,9 @@ final class RemoteContentCaptureService writeServiceEvent( FrameworkStatsLog.CONTENT_CAPTURE_SERVICE_EVENTS__EVENT__ON_DISCONNECTED, mComponentName); + EventLog.writeEvent(EventLogTags.CC_CONNECT_STATE_CHANGED, + mPerUserService.getUserId(), + ContentCapturePerUserService.EVENT_LOG_CONNECT_STATE_DISCONNECTED, 0); } } catch (Exception e) { Slog.w(mTag, "Exception calling onConnectedStateChanged(" + connected + "): " + e); |