Loading services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java +4 −1 Original line number Diff line number Diff line Loading @@ -27,6 +27,8 @@ import static com.android.internal.util.CollectionUtils.any; import static com.android.internal.util.Preconditions.checkState; import static com.android.internal.util.function.pooled.PooledLambda.obtainMessage; import static com.android.server.companion.AssociationStore.CHANGE_TYPE_UPDATED_ADDRESS_UNCHANGED; import static com.android.server.companion.MetricUtils.logCreateAssociation; import static com.android.server.companion.MetricUtils.logRemoveAssociation; import static com.android.server.companion.PackageUtils.enforceUsesCompanionDeviceFeature; import static com.android.server.companion.PackageUtils.getPackageInfo; import static com.android.server.companion.PermissionsUtils.checkCallerCanManageCompanionDevice; Loading Loading @@ -771,7 +773,7 @@ public class CompanionDeviceManagerService extends SystemService { } updateSpecialAccessPermissionForAssociatedPackage(association); logCreateAssociation(deviceProfile); return association; } Loading Loading @@ -856,6 +858,7 @@ public class CompanionDeviceManagerService extends SystemService { // Removing the association. mAssociationStore.removeAssociation(associationId); logRemoveAssociation(deviceProfile); final List<AssociationInfo> otherAssociations = mAssociationStore.getAssociationsForPackage(userId, packageName); Loading services/companion/java/com/android/server/companion/MetricUtils.java 0 → 100644 +77 −0 Original line number Diff line number Diff line /* * Copyright (C) 2022 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.server.companion; import static android.companion.AssociationRequest.DEVICE_PROFILE_APP_STREAMING; import static android.companion.AssociationRequest.DEVICE_PROFILE_AUTOMOTIVE_PROJECTION; import static android.companion.AssociationRequest.DEVICE_PROFILE_COMPUTER; import static android.companion.AssociationRequest.DEVICE_PROFILE_WATCH; import static com.android.internal.util.FrameworkStatsLog.CDM_ASSOCIATION_ACTION; import static com.android.internal.util.FrameworkStatsLog.CDM_ASSOCIATION_ACTION__ACTION__CREATED; import static com.android.internal.util.FrameworkStatsLog.CDM_ASSOCIATION_ACTION__ACTION__REMOVED; import static com.android.internal.util.FrameworkStatsLog.CDM_ASSOCIATION_ACTION__DEVICE_PROFILE__DEVICE_PROFILE_APP_STREAMING; import static com.android.internal.util.FrameworkStatsLog.CDM_ASSOCIATION_ACTION__DEVICE_PROFILE__DEVICE_PROFILE_AUTO_PROJECTION; import static com.android.internal.util.FrameworkStatsLog.CDM_ASSOCIATION_ACTION__DEVICE_PROFILE__DEVICE_PROFILE_COMPUTER; import static com.android.internal.util.FrameworkStatsLog.CDM_ASSOCIATION_ACTION__DEVICE_PROFILE__DEVICE_PROFILE_NULL; import static com.android.internal.util.FrameworkStatsLog.CDM_ASSOCIATION_ACTION__DEVICE_PROFILE__DEVICE_PROFILE_WATCH; import static com.android.internal.util.FrameworkStatsLog.write; import static java.util.Collections.unmodifiableMap; import android.util.ArrayMap; import java.util.Map; final class MetricUtils { private static final Map<String, Integer> METRIC_DEVICE_PROFILE; static { final Map<String, Integer> map = new ArrayMap<>(); map.put(null, CDM_ASSOCIATION_ACTION__DEVICE_PROFILE__DEVICE_PROFILE_NULL); map.put( DEVICE_PROFILE_WATCH, CDM_ASSOCIATION_ACTION__DEVICE_PROFILE__DEVICE_PROFILE_WATCH ); map.put( DEVICE_PROFILE_APP_STREAMING, CDM_ASSOCIATION_ACTION__DEVICE_PROFILE__DEVICE_PROFILE_APP_STREAMING ); map.put( DEVICE_PROFILE_AUTOMOTIVE_PROJECTION, CDM_ASSOCIATION_ACTION__DEVICE_PROFILE__DEVICE_PROFILE_AUTO_PROJECTION ); map.put( DEVICE_PROFILE_COMPUTER, CDM_ASSOCIATION_ACTION__DEVICE_PROFILE__DEVICE_PROFILE_COMPUTER ); METRIC_DEVICE_PROFILE = unmodifiableMap(map); } static void logCreateAssociation(String profile) { write(CDM_ASSOCIATION_ACTION, CDM_ASSOCIATION_ACTION__ACTION__CREATED, METRIC_DEVICE_PROFILE.get(profile)); } static void logRemoveAssociation(String profile) { write(CDM_ASSOCIATION_ACTION, CDM_ASSOCIATION_ACTION__ACTION__REMOVED, METRIC_DEVICE_PROFILE.get(profile)); } } Loading
services/companion/java/com/android/server/companion/CompanionDeviceManagerService.java +4 −1 Original line number Diff line number Diff line Loading @@ -27,6 +27,8 @@ import static com.android.internal.util.CollectionUtils.any; import static com.android.internal.util.Preconditions.checkState; import static com.android.internal.util.function.pooled.PooledLambda.obtainMessage; import static com.android.server.companion.AssociationStore.CHANGE_TYPE_UPDATED_ADDRESS_UNCHANGED; import static com.android.server.companion.MetricUtils.logCreateAssociation; import static com.android.server.companion.MetricUtils.logRemoveAssociation; import static com.android.server.companion.PackageUtils.enforceUsesCompanionDeviceFeature; import static com.android.server.companion.PackageUtils.getPackageInfo; import static com.android.server.companion.PermissionsUtils.checkCallerCanManageCompanionDevice; Loading Loading @@ -771,7 +773,7 @@ public class CompanionDeviceManagerService extends SystemService { } updateSpecialAccessPermissionForAssociatedPackage(association); logCreateAssociation(deviceProfile); return association; } Loading Loading @@ -856,6 +858,7 @@ public class CompanionDeviceManagerService extends SystemService { // Removing the association. mAssociationStore.removeAssociation(associationId); logRemoveAssociation(deviceProfile); final List<AssociationInfo> otherAssociations = mAssociationStore.getAssociationsForPackage(userId, packageName); Loading
services/companion/java/com/android/server/companion/MetricUtils.java 0 → 100644 +77 −0 Original line number Diff line number Diff line /* * Copyright (C) 2022 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.server.companion; import static android.companion.AssociationRequest.DEVICE_PROFILE_APP_STREAMING; import static android.companion.AssociationRequest.DEVICE_PROFILE_AUTOMOTIVE_PROJECTION; import static android.companion.AssociationRequest.DEVICE_PROFILE_COMPUTER; import static android.companion.AssociationRequest.DEVICE_PROFILE_WATCH; import static com.android.internal.util.FrameworkStatsLog.CDM_ASSOCIATION_ACTION; import static com.android.internal.util.FrameworkStatsLog.CDM_ASSOCIATION_ACTION__ACTION__CREATED; import static com.android.internal.util.FrameworkStatsLog.CDM_ASSOCIATION_ACTION__ACTION__REMOVED; import static com.android.internal.util.FrameworkStatsLog.CDM_ASSOCIATION_ACTION__DEVICE_PROFILE__DEVICE_PROFILE_APP_STREAMING; import static com.android.internal.util.FrameworkStatsLog.CDM_ASSOCIATION_ACTION__DEVICE_PROFILE__DEVICE_PROFILE_AUTO_PROJECTION; import static com.android.internal.util.FrameworkStatsLog.CDM_ASSOCIATION_ACTION__DEVICE_PROFILE__DEVICE_PROFILE_COMPUTER; import static com.android.internal.util.FrameworkStatsLog.CDM_ASSOCIATION_ACTION__DEVICE_PROFILE__DEVICE_PROFILE_NULL; import static com.android.internal.util.FrameworkStatsLog.CDM_ASSOCIATION_ACTION__DEVICE_PROFILE__DEVICE_PROFILE_WATCH; import static com.android.internal.util.FrameworkStatsLog.write; import static java.util.Collections.unmodifiableMap; import android.util.ArrayMap; import java.util.Map; final class MetricUtils { private static final Map<String, Integer> METRIC_DEVICE_PROFILE; static { final Map<String, Integer> map = new ArrayMap<>(); map.put(null, CDM_ASSOCIATION_ACTION__DEVICE_PROFILE__DEVICE_PROFILE_NULL); map.put( DEVICE_PROFILE_WATCH, CDM_ASSOCIATION_ACTION__DEVICE_PROFILE__DEVICE_PROFILE_WATCH ); map.put( DEVICE_PROFILE_APP_STREAMING, CDM_ASSOCIATION_ACTION__DEVICE_PROFILE__DEVICE_PROFILE_APP_STREAMING ); map.put( DEVICE_PROFILE_AUTOMOTIVE_PROJECTION, CDM_ASSOCIATION_ACTION__DEVICE_PROFILE__DEVICE_PROFILE_AUTO_PROJECTION ); map.put( DEVICE_PROFILE_COMPUTER, CDM_ASSOCIATION_ACTION__DEVICE_PROFILE__DEVICE_PROFILE_COMPUTER ); METRIC_DEVICE_PROFILE = unmodifiableMap(map); } static void logCreateAssociation(String profile) { write(CDM_ASSOCIATION_ACTION, CDM_ASSOCIATION_ACTION__ACTION__CREATED, METRIC_DEVICE_PROFILE.get(profile)); } static void logRemoveAssociation(String profile) { write(CDM_ASSOCIATION_ACTION, CDM_ASSOCIATION_ACTION__ACTION__REMOVED, METRIC_DEVICE_PROFILE.get(profile)); } }