Loading cmds/statsd/src/atoms.proto +15 −0 Original line number Diff line number Diff line Loading @@ -288,6 +288,7 @@ message Atom { DebugElapsedClock debug_elapsed_clock = 10046; DebugFailingElapsedClock debug_failing_elapsed_clock = 10047; NumBiometricsEnrolled num_faces_enrolled = 10048; RoleHolder role_holder = 10049; } // DO NOT USE field numbers above 100,000 in AOSP. Loading Loading @@ -3973,6 +3974,20 @@ message NumBiometricsEnrolled { optional int32 num_enrolled = 2; } /** * A mapping of role holder -> role */ message RoleHolder { // uid of the role holder optional int32 uid = 1 [(is_uid) = true]; // package name of the role holder optional string package_name = 2; // the role held optional string role = 3; } message AggStats { optional int64 min = 1; Loading cmds/statsd/src/external/StatsPullerManager.cpp +3 −0 Original line number Diff line number Diff line Loading @@ -220,6 +220,9 @@ const std::map<int, PullAtomInfo> StatsPullerManager::kAllPullAtomInfo = { // BuildInformation. {android::util::BUILD_INFORMATION, {.puller = new StatsCompanionServicePuller(android::util::BUILD_INFORMATION)}}, // RoleHolder. {android::util::ROLE_HOLDER, {.puller = new StatsCompanionServicePuller(android::util::ROLE_HOLDER)}}, }; StatsPullerManager::StatsPullerManager() : mNextPullTimeNs(NO_ALARM_UPDATE) { Loading services/core/java/com/android/server/role/RoleManagerService.java +29 −0 Original line number Diff line number Diff line Loading @@ -52,6 +52,7 @@ import android.os.UserManagerInternal; import android.service.sms.FinancialSmsService; import android.telephony.IFinancialSmsCallback; import android.text.TextUtils; import android.util.ArrayMap; import android.util.ArraySet; import android.util.PackageUtils; import android.util.Slog; Loading Loading @@ -145,6 +146,9 @@ public class RoleManagerService extends SystemService implements RoleUserState.C mUserManagerInternal = LocalServices.getService(UserManagerInternal.class); mAppOpsManager = context.getSystemService(AppOpsManager.class); LocalServices.addService(RoleManagerServiceInternal.class, new RoleManagerServiceInternalImpl()); registerUserRemovedReceiver(); } Loading Loading @@ -382,6 +386,19 @@ public class RoleManagerService extends SystemService implements RoleUserState.C } } /** * Get all roles and packages hold them. * * @param user The user to query to roles for * * @return The roles and their holders */ @NonNull private ArrayMap<String, ArraySet<String>> getRoleHoldersAsUser(@NonNull UserHandle user) { RoleUserState userState = getOrCreateUserState(user.getIdentifier()); return userState.getRoleHolders(); } private class Stub extends IRoleManager.Stub { @Override Loading Loading @@ -676,4 +693,16 @@ public class RoleManagerService extends SystemService implements RoleUserState.C } } } /** * Entry point for internal calls into role manager */ private final class RoleManagerServiceInternalImpl extends RoleManagerServiceInternal { @NonNull @Override public ArrayMap<String, ArraySet<String>> getRoleHoldersAsUser(@NonNull UserHandle user) { return RoleManagerService.this.getRoleHoldersAsUser(user); } } } services/core/java/com/android/server/role/RoleManagerServiceInternal.java 0 → 100644 +38 −0 Original line number Diff line number Diff line /* * Copyright (C) 2019 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.role; import android.annotation.NonNull; import android.os.UserHandle; import android.util.ArrayMap; import android.util.ArraySet; /** * Internal calls into {@link RoleManagerService} */ public abstract class RoleManagerServiceInternal { /** * Get all roles and packages hold them. * * @param user The user to query to roles for * * @return The roles and their holders */ @NonNull public abstract ArrayMap<String, ArraySet<String>> getRoleHoldersAsUser( @NonNull UserHandle user); } services/core/java/com/android/server/role/RoleUserState.java +19 −12 Original line number Diff line number Diff line Loading @@ -376,7 +376,7 @@ public class RoleUserState { version = mVersion; packagesHash = mPackagesHash; roles = snapshotRolesLocked(); roles = getRoleHolders(); } AtomicFile atomicFile = new AtomicFile(getFile(mUserId), "roles-" + mUserId); Loading Loading @@ -541,7 +541,7 @@ public class RoleUserState { version = mVersion; packagesHash = mPackagesHash; roles = snapshotRolesLocked(); roles = getRoleHolders(); } long fieldToken = dumpOutputStream.start(fieldName, fieldId); Loading Loading @@ -570,8 +570,14 @@ public class RoleUserState { dumpOutputStream.end(fieldToken); } @GuardedBy("mLock") private ArrayMap<String, ArraySet<String>> snapshotRolesLocked() { /** * Get the roles and their holders. * * @return A copy of the roles and their holders */ @NonNull public ArrayMap<String, ArraySet<String>> getRoleHolders() { synchronized (mLock) { ArrayMap<String, ArraySet<String>> roles = new ArrayMap<>(); for (int i = 0, size = CollectionUtils.size(mRoles); i < size; ++i) { String roleName = mRoles.keyAt(i); Loading @@ -582,6 +588,7 @@ public class RoleUserState { } return roles; } } /** * Destroy this user state and delete the corresponding file. Any pending writes to the file Loading Loading
cmds/statsd/src/atoms.proto +15 −0 Original line number Diff line number Diff line Loading @@ -288,6 +288,7 @@ message Atom { DebugElapsedClock debug_elapsed_clock = 10046; DebugFailingElapsedClock debug_failing_elapsed_clock = 10047; NumBiometricsEnrolled num_faces_enrolled = 10048; RoleHolder role_holder = 10049; } // DO NOT USE field numbers above 100,000 in AOSP. Loading Loading @@ -3973,6 +3974,20 @@ message NumBiometricsEnrolled { optional int32 num_enrolled = 2; } /** * A mapping of role holder -> role */ message RoleHolder { // uid of the role holder optional int32 uid = 1 [(is_uid) = true]; // package name of the role holder optional string package_name = 2; // the role held optional string role = 3; } message AggStats { optional int64 min = 1; Loading
cmds/statsd/src/external/StatsPullerManager.cpp +3 −0 Original line number Diff line number Diff line Loading @@ -220,6 +220,9 @@ const std::map<int, PullAtomInfo> StatsPullerManager::kAllPullAtomInfo = { // BuildInformation. {android::util::BUILD_INFORMATION, {.puller = new StatsCompanionServicePuller(android::util::BUILD_INFORMATION)}}, // RoleHolder. {android::util::ROLE_HOLDER, {.puller = new StatsCompanionServicePuller(android::util::ROLE_HOLDER)}}, }; StatsPullerManager::StatsPullerManager() : mNextPullTimeNs(NO_ALARM_UPDATE) { Loading
services/core/java/com/android/server/role/RoleManagerService.java +29 −0 Original line number Diff line number Diff line Loading @@ -52,6 +52,7 @@ import android.os.UserManagerInternal; import android.service.sms.FinancialSmsService; import android.telephony.IFinancialSmsCallback; import android.text.TextUtils; import android.util.ArrayMap; import android.util.ArraySet; import android.util.PackageUtils; import android.util.Slog; Loading Loading @@ -145,6 +146,9 @@ public class RoleManagerService extends SystemService implements RoleUserState.C mUserManagerInternal = LocalServices.getService(UserManagerInternal.class); mAppOpsManager = context.getSystemService(AppOpsManager.class); LocalServices.addService(RoleManagerServiceInternal.class, new RoleManagerServiceInternalImpl()); registerUserRemovedReceiver(); } Loading Loading @@ -382,6 +386,19 @@ public class RoleManagerService extends SystemService implements RoleUserState.C } } /** * Get all roles and packages hold them. * * @param user The user to query to roles for * * @return The roles and their holders */ @NonNull private ArrayMap<String, ArraySet<String>> getRoleHoldersAsUser(@NonNull UserHandle user) { RoleUserState userState = getOrCreateUserState(user.getIdentifier()); return userState.getRoleHolders(); } private class Stub extends IRoleManager.Stub { @Override Loading Loading @@ -676,4 +693,16 @@ public class RoleManagerService extends SystemService implements RoleUserState.C } } } /** * Entry point for internal calls into role manager */ private final class RoleManagerServiceInternalImpl extends RoleManagerServiceInternal { @NonNull @Override public ArrayMap<String, ArraySet<String>> getRoleHoldersAsUser(@NonNull UserHandle user) { return RoleManagerService.this.getRoleHoldersAsUser(user); } } }
services/core/java/com/android/server/role/RoleManagerServiceInternal.java 0 → 100644 +38 −0 Original line number Diff line number Diff line /* * Copyright (C) 2019 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.role; import android.annotation.NonNull; import android.os.UserHandle; import android.util.ArrayMap; import android.util.ArraySet; /** * Internal calls into {@link RoleManagerService} */ public abstract class RoleManagerServiceInternal { /** * Get all roles and packages hold them. * * @param user The user to query to roles for * * @return The roles and their holders */ @NonNull public abstract ArrayMap<String, ArraySet<String>> getRoleHoldersAsUser( @NonNull UserHandle user); }
services/core/java/com/android/server/role/RoleUserState.java +19 −12 Original line number Diff line number Diff line Loading @@ -376,7 +376,7 @@ public class RoleUserState { version = mVersion; packagesHash = mPackagesHash; roles = snapshotRolesLocked(); roles = getRoleHolders(); } AtomicFile atomicFile = new AtomicFile(getFile(mUserId), "roles-" + mUserId); Loading Loading @@ -541,7 +541,7 @@ public class RoleUserState { version = mVersion; packagesHash = mPackagesHash; roles = snapshotRolesLocked(); roles = getRoleHolders(); } long fieldToken = dumpOutputStream.start(fieldName, fieldId); Loading Loading @@ -570,8 +570,14 @@ public class RoleUserState { dumpOutputStream.end(fieldToken); } @GuardedBy("mLock") private ArrayMap<String, ArraySet<String>> snapshotRolesLocked() { /** * Get the roles and their holders. * * @return A copy of the roles and their holders */ @NonNull public ArrayMap<String, ArraySet<String>> getRoleHolders() { synchronized (mLock) { ArrayMap<String, ArraySet<String>> roles = new ArrayMap<>(); for (int i = 0, size = CollectionUtils.size(mRoles); i < size; ++i) { String roleName = mRoles.keyAt(i); Loading @@ -582,6 +588,7 @@ public class RoleUserState { } return roles; } } /** * Destroy this user state and delete the corresponding file. Any pending writes to the file Loading