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

Commit 8cba1a29 authored by Joanne Chung's avatar Joanne Chung Committed by Automerger Merge Worker
Browse files

Merge "Remove application package name from ContentCapture logging" into...

Merge "Remove application package name from ContentCapture logging" into tm-dev am: 65f8aea1 am: 742c3eed

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18281616



Change-Id: If69161a744154b340472aaaab8e632643bff2920
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 04ded0be 742c3eed
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -730,7 +730,7 @@ public final class ContentCaptureManagerService extends
                        String serviceName = mServiceNameResolver.getServiceName(userId);
                        ContentCaptureMetricsLogger.writeServiceEvent(
                                EVENT__DATA_SHARE_ERROR_CONCURRENT_REQUEST,
                                serviceName, request.getPackageName());
                                serviceName);
                        clientAdapter.error(
                                ContentCaptureManager.DATA_SHARE_ERROR_CONCURRENT_REQUEST);
                    } catch (RemoteException e) {
@@ -1303,8 +1303,7 @@ public final class ContentCaptureManagerService extends
        private void logServiceEvent(int eventType) {
            int userId = UserHandle.getCallingUserId();
            String serviceName = mParentService.mServiceNameResolver.getServiceName(userId);
            ContentCaptureMetricsLogger.writeServiceEvent(eventType, serviceName,
                    mDataShareRequest.getPackageName());
            ContentCaptureMetricsLogger.writeServiceEvent(eventType, serviceName);
        }
    }
}
+17 −41
Original line number Diff line number Diff line
@@ -34,72 +34,48 @@ public final class ContentCaptureMetricsLogger {
    }

    /** @hide */
    public static void writeServiceEvent(int eventType, @NonNull String serviceName,
            @Nullable String targetPackage) {
    public static void writeServiceEvent(int eventType, @NonNull String serviceName) {
        // we should not logging the application package name
        FrameworkStatsLog.write(FrameworkStatsLog.CONTENT_CAPTURE_SERVICE_EVENTS, eventType,
                serviceName, targetPackage);
    }

    /** @hide */
    public static void writeServiceEvent(int eventType, @NonNull ComponentName service,
            @Nullable ComponentName target) {
        writeServiceEvent(eventType, ComponentName.flattenToShortString(service),
                ComponentName.flattenToShortString(target));
    }

    /** @hide */
    public static void writeServiceEvent(int eventType, @NonNull ComponentName service,
            @Nullable String targetPackage) {
        writeServiceEvent(eventType, ComponentName.flattenToShortString(service), targetPackage);
                serviceName, /* componentName= */ null);
    }

    /** @hide */
    public static void writeServiceEvent(int eventType, @NonNull ComponentName service) {
        writeServiceEvent(eventType, ComponentName.flattenToShortString(service), null);
        writeServiceEvent(eventType, ComponentName.flattenToShortString(service));
    }

    /** @hide */
    public static void writeSetWhitelistEvent(@Nullable ComponentName service,
            @Nullable List<String> packages, @Nullable List<ComponentName> activities) {
        final String serviceName = ComponentName.flattenToShortString(service);
        StringBuilder stringBuilder = new StringBuilder();
        if (packages != null && packages.size() > 0) {
            final int size = packages.size();
            stringBuilder.append(packages.get(0));
            for (int i = 1; i < size; i++) {
                stringBuilder.append(" ");
                stringBuilder.append(packages.get(i));
            }
        }
        if (activities != null && activities.size() > 0) {
            stringBuilder.append(" ");
            stringBuilder.append(activities.get(0).flattenToShortString());
            final int size = activities.size();
            for (int i = 1; i < size; i++) {
                stringBuilder.append(" ");
                stringBuilder.append(activities.get(i).flattenToShortString());
            }
        }
        // TODO: log allow list count.
        int packageCount = packages != null ? packages.size() : 0;
        int activityCount = activities != null ? activities.size() : 0;
        // we should not logging the application package name
        // log the allow list package and activity count instead
        FrameworkStatsLog.write(FrameworkStatsLog.CONTENT_CAPTURE_SERVICE_EVENTS,
                FrameworkStatsLog.CONTENT_CAPTURE_SERVICE_EVENTS__EVENT__SET_WHITELIST,
                serviceName, stringBuilder.toString());
                serviceName, /* allowListStr= */ null);
    }

    /** @hide */
    public static void writeSessionEvent(int sessionId, int event, int flags,
            @NonNull ComponentName service, @Nullable ComponentName app, boolean isChildSession) {
            @NonNull ComponentName service, boolean isChildSession) {
        // we should not logging the application package name
        FrameworkStatsLog.write(FrameworkStatsLog.CONTENT_CAPTURE_SESSION_EVENTS, sessionId, event,
                flags, ComponentName.flattenToShortString(service),
                ComponentName.flattenToShortString(app), isChildSession);
            /* componentName= */ null, isChildSession);
    }

    /** @hide */
    public static void writeSessionFlush(int sessionId, @NonNull ComponentName service,
            @Nullable ComponentName app, @NonNull FlushMetrics fm,
            @NonNull ContentCaptureOptions options, int flushReason) {
            @NonNull FlushMetrics fm, @NonNull ContentCaptureOptions options,
            int flushReason) {
        // we should not logging the application package name
        FrameworkStatsLog.write(FrameworkStatsLog.CONTENT_CAPTURE_FLUSHED, sessionId,
                ComponentName.flattenToShortString(service),
                ComponentName.flattenToShortString(app), fm.sessionStarted, fm.sessionFinished,
                /* componentName= */ null, fm.sessionStarted, fm.sessionFinished,
                fm.viewAppearedCount, fm.viewDisappearedCount, fm.viewTextChangedCount,
                options.maxBufferSize, options.idleFlushingFrequencyMs,
                options.textChangeFlushingFrequencyMs, flushReason);
+5 −5
Original line number Diff line number Diff line
@@ -330,7 +330,7 @@ final class ContentCapturePerUserService
            writeSessionEvent(sessionId,
                    FrameworkStatsLog.CONTENT_CAPTURE_SESSION_EVENTS__EVENT__SESSION_NOT_CREATED,
                    STATE_DISABLED | STATE_NO_SERVICE, serviceComponentName,
                    componentName, /* isChildSession= */ false);
                    /* isChildSession= */ false);
            return;
        }
        if (serviceComponentName == null) {
@@ -354,7 +354,7 @@ final class ContentCapturePerUserService
            writeSessionEvent(sessionId,
                    FrameworkStatsLog.CONTENT_CAPTURE_SESSION_EVENTS__EVENT__SESSION_NOT_CREATED,
                    STATE_DISABLED | STATE_NOT_WHITELISTED, serviceComponentName,
                    componentName, /* isChildSession= */ false);
                    /* isChildSession= */ false);
            return;
        }

@@ -368,7 +368,7 @@ final class ContentCapturePerUserService
            writeSessionEvent(sessionId,
                    FrameworkStatsLog.CONTENT_CAPTURE_SESSION_EVENTS__EVENT__SESSION_NOT_CREATED,
                    STATE_DISABLED | STATE_DUPLICATED_ID,
                    serviceComponentName, componentName, /* isChildSession= */ false);
                    serviceComponentName, /* isChildSession= */ false);
            return;
        }

@@ -385,7 +385,7 @@ final class ContentCapturePerUserService
            writeSessionEvent(sessionId,
                    FrameworkStatsLog.CONTENT_CAPTURE_SESSION_EVENTS__EVENT__SESSION_NOT_CREATED,
                    STATE_DISABLED | STATE_NO_SERVICE, serviceComponentName,
                    componentName, /* isChildSession= */ false);
                    /* isChildSession= */ false);
            return;
        }

@@ -740,7 +740,7 @@ final class ContentCapturePerUserService
        @Override
        public void writeSessionFlush(int sessionId, ComponentName app, FlushMetrics flushMetrics,
                ContentCaptureOptions options, int flushReason) {
            ContentCaptureMetricsLogger.writeSessionFlush(sessionId, getServiceComponentName(), app,
            ContentCaptureMetricsLogger.writeSessionFlush(sessionId, getServiceComponentName(),
                    flushMetrics, options, flushReason);
        }

+3 −5
Original line number Diff line number Diff line
@@ -119,8 +119,7 @@ final class RemoteContentCaptureService
        // Metrics logging.
        writeSessionEvent(sessionId,
                FrameworkStatsLog.CONTENT_CAPTURE_SESSION_EVENTS__EVENT__ON_SESSION_STARTED,
                initialState, getComponentName(), context.getActivityComponent(),
                /* is_child_session= */ false);
                initialState, getComponentName(), /* is_child_session= */ false);
    }

    /**
@@ -132,8 +131,7 @@ final class RemoteContentCaptureService
        // Metrics logging.
        writeSessionEvent(sessionId,
                FrameworkStatsLog.CONTENT_CAPTURE_SESSION_EVENTS__EVENT__ON_SESSION_FINISHED,
                /* flags= */ 0, getComponentName(), /* app= */ null,
                /* is_child_session= */ false);
                /* flags= */ 0, getComponentName(), /* is_child_session= */ false);
    }

    /**
@@ -158,7 +156,7 @@ final class RemoteContentCaptureService
        scheduleAsyncRequest((s) -> s.onDataShared(request, dataShareCallback));
        writeServiceEvent(
                FrameworkStatsLog.CONTENT_CAPTURE_SERVICE_EVENTS__EVENT__ON_DATA_SHARE_REQUEST,
                mComponentName, request.getPackageName());
                mComponentName);
    }

    /**