Merge "Add event log for content capture" into tm-qpr-dev
This commit is contained in:
@@ -17,6 +17,9 @@ filegroup {
|
||||
java_library_static {
|
||||
name: "services.contentcapture",
|
||||
defaults: ["platform_service_defaults"],
|
||||
srcs: [":services.contentcapture-sources"],
|
||||
srcs: [
|
||||
":services.contentcapture-sources",
|
||||
"java/**/*.logtags",
|
||||
],
|
||||
libs: ["services.core"],
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -88,6 +89,11 @@ 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,13 @@ 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,
|
||||
serviceComponent != null ? serviceComponent.flattenToShortString() : "",
|
||||
EVENT_LOG_CONNECT_STATE_DIED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -614,11 +624,16 @@ final class ContentCapturePerUserService
|
||||
? "null_activities" : activities.size() + " activities") + ")"
|
||||
+ " for user " + mUserId);
|
||||
}
|
||||
int packageCount = packages != null ? packages.size() : 0;
|
||||
int activityCount = activities != null ? activities.size() : 0;
|
||||
|
||||
ArraySet<String> oldList =
|
||||
mMaster.mGlobalContentCaptureOptions.getWhitelistedPackages(mUserId);
|
||||
EventLog.writeEvent(EventLogTags.CC_CURRENT_ALLOWLIST, mUserId, oldList.size());
|
||||
|
||||
mMaster.mGlobalContentCaptureOptions.setWhitelist(mUserId, packages, activities);
|
||||
EventLog.writeEvent(EventLogTags.CC_SET_ALLOWLIST, mUserId,
|
||||
packageCount, activityCount);
|
||||
writeSetWhitelistEvent(getServiceComponentName(), packages, activities);
|
||||
|
||||
updateContentCaptureOptions(oldList);
|
||||
@@ -699,12 +714,14 @@ final class ContentCapturePerUserService
|
||||
private void updateContentCaptureOptions(@Nullable ArraySet<String> oldList) {
|
||||
ArraySet<String> adding = mMaster.mGlobalContentCaptureOptions
|
||||
.getWhitelistedPackages(mUserId);
|
||||
EventLog.writeEvent(EventLogTags.CC_CURRENT_ALLOWLIST, mUserId, adding.size());
|
||||
|
||||
if (oldList != null && adding != null) {
|
||||
adding.removeAll(oldList);
|
||||
}
|
||||
|
||||
int N = adding != null ? adding.size() : 0;
|
||||
EventLog.writeEvent(EventLogTags.CC_UPDATE_OPTIONS, mUserId, N);
|
||||
for (int i = 0; i < N; i++) {
|
||||
String packageName = adding.valueAt(i);
|
||||
ContentCaptureOptions options = mMaster.mGlobalContentCaptureOptions
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
# See system/logging/logcat/event.logtags for a description of the format of this file.
|
||||
|
||||
option java_package com.android.server.contentcapture
|
||||
|
||||
53200 cc_connect_state_changed (User|1|5),(component|3),(type|1)
|
||||
53201 cc_set_allowlist (User|1|5),(package_count|1),(activity_count|1)
|
||||
53202 cc_current_allowlist (User|1|5),(count|1)
|
||||
53203 cc_update_options (User|1|5),(count|1)
|
||||
@@ -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;
|
||||
@@ -47,6 +48,7 @@ final class RemoteContentCaptureService
|
||||
private final IBinder mServerCallback;
|
||||
private final int mIdleUnbindTimeoutMs;
|
||||
private final ContentCapturePerUserService mPerUserService;
|
||||
private final int mUserId;
|
||||
|
||||
RemoteContentCaptureService(Context context, String serviceInterface,
|
||||
ComponentName serviceComponentName, IContentCaptureServiceCallback callback, int userId,
|
||||
@@ -61,6 +63,7 @@ final class RemoteContentCaptureService
|
||||
mPerUserService = perUserService;
|
||||
mServerCallback = callback.asBinder();
|
||||
mIdleUnbindTimeoutMs = idleUnbindTimeoutMs;
|
||||
mUserId = userId;
|
||||
|
||||
// Bind right away, which will trigger a onConnected() on service's
|
||||
ensureBoundLocked();
|
||||
@@ -88,6 +91,9 @@ final class RemoteContentCaptureService
|
||||
writeServiceEvent(
|
||||
FrameworkStatsLog.CONTENT_CAPTURE_SERVICE_EVENTS__EVENT__ON_CONNECTED,
|
||||
mComponentName);
|
||||
EventLog.writeEvent(EventLogTags.CC_CONNECT_STATE_CHANGED, mUserId,
|
||||
mComponentName != null ? mComponentName.flattenToShortString() : "",
|
||||
ContentCapturePerUserService.EVENT_LOG_CONNECT_STATE_CONNECTED);
|
||||
} 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, mUserId,
|
||||
mComponentName != null ? mComponentName.flattenToShortString() : "",
|
||||
ContentCapturePerUserService.EVENT_LOG_CONNECT_STATE_DISCONNECTED);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Slog.w(mTag, "Exception calling onConnectedStateChanged(" + connected + "): " + e);
|
||||
|
||||
Reference in New Issue
Block a user