Further fixes on VIMS.onPreCreatedUserConversion()
Previously, when onRoleHoldersChanged() was called in a pre-created user, VoiceInteractionManagerService (A.K.A. VIMS) would store that user id and call the method again when the pre-converted user is converted to a real user (on onPreCreatedUserConversion()), as the assistant role holders is not available for pre-created users. But if the system restarts between the user pre-creation and conversion, onPreCreatedUserConversion() would log a warning and do nothing. So, this CL gets rids of the "save the user id" part, and simply re-call onRoleHoldersChanged() whenever a pre-created user is converted. Test: manual verification on automotive builds Bug: 242254421 Change-Id: Id933b2bc4f887da8b2f4959955bd174ed5879a47
This commit is contained in:
@@ -135,9 +135,6 @@ public class VoiceInteractionManagerService extends SystemService {
|
||||
private final RemoteCallbackList<IVoiceInteractionSessionListener>
|
||||
mVoiceInteractionSessionListeners = new RemoteCallbackList<>();
|
||||
|
||||
// TODO(b/226201975): remove once RoleService supports pre-created users
|
||||
private final ArrayList<UserHandle> mIgnoredPreCreatedUsers = new ArrayList<>();
|
||||
|
||||
public VoiceInteractionManagerService(Context context) {
|
||||
super(context);
|
||||
mContext = context;
|
||||
@@ -306,24 +303,14 @@ public class VoiceInteractionManagerService extends SystemService {
|
||||
return hotwordDetectionConnection.mIdentity;
|
||||
}
|
||||
|
||||
// TODO(b/226201975): remove this method once RoleService supports pre-created users
|
||||
@Override
|
||||
public void onPreCreatedUserConversion(int userId) {
|
||||
Slogf.d(TAG, "onPreCreatedUserConversion(%d)", userId);
|
||||
|
||||
for (int i = 0; i < mIgnoredPreCreatedUsers.size(); i++) {
|
||||
UserHandle preCreatedUser = mIgnoredPreCreatedUsers.get(i);
|
||||
if (preCreatedUser.getIdentifier() == userId) {
|
||||
Slogf.d(TAG, "Updating role on pre-created user %d", userId);
|
||||
mServiceStub.mRoleObserver.onRoleHoldersChanged(RoleManager.ROLE_ASSISTANT,
|
||||
preCreatedUser);
|
||||
mIgnoredPreCreatedUsers.remove(i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
Slogf.w(TAG, "onPreCreatedUserConversion(%d): not available on "
|
||||
+ "mIgnoredPreCreatedUserIds (%s)", userId, mIgnoredPreCreatedUsers);
|
||||
Slogf.d(TAG, "onPreCreatedUserConversion(%d): calling onRoleHoldersChanged() again",
|
||||
userId);
|
||||
mServiceStub.mRoleObserver.onRoleHoldersChanged(RoleManager.ROLE_ASSISTANT,
|
||||
UserHandle.of(userId));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// implementation entry point and binder service
|
||||
@@ -806,8 +793,10 @@ public class VoiceInteractionManagerService extends SystemService {
|
||||
if (TextUtils.isEmpty(curInteractor)) {
|
||||
return null;
|
||||
}
|
||||
if (DEBUG) Slog.d(TAG, "getCurInteractor curInteractor=" + curInteractor
|
||||
if (DEBUG) {
|
||||
Slog.d(TAG, "getCurInteractor curInteractor=" + curInteractor
|
||||
+ " user=" + userHandle);
|
||||
}
|
||||
return ComponentName.unflattenFromString(curInteractor);
|
||||
}
|
||||
|
||||
@@ -815,8 +804,9 @@ public class VoiceInteractionManagerService extends SystemService {
|
||||
Settings.Secure.putStringForUser(mContext.getContentResolver(),
|
||||
Settings.Secure.VOICE_INTERACTION_SERVICE,
|
||||
comp != null ? comp.flattenToShortString() : "", userHandle);
|
||||
if (DEBUG) Slog.d(TAG, "setCurInteractor comp=" + comp
|
||||
+ " user=" + userHandle);
|
||||
if (DEBUG) {
|
||||
Slog.d(TAG, "setCurInteractor comp=" + comp + " user=" + userHandle);
|
||||
}
|
||||
}
|
||||
|
||||
ComponentName findAvailRecognizer(String prefPackage, int userHandle) {
|
||||
@@ -1914,7 +1904,6 @@ public class VoiceInteractionManagerService extends SystemService {
|
||||
pw.println(" mTemporarilyDisabled: " + mTemporarilyDisabled);
|
||||
pw.println(" mCurUser: " + mCurUser);
|
||||
pw.println(" mCurUserSupported: " + mCurUserSupported);
|
||||
pw.println(" mIgnoredPreCreatedUsers: " + mIgnoredPreCreatedUsers);
|
||||
dumpSupportedUsers(pw, " ");
|
||||
mDbHelper.dump(pw);
|
||||
if (mImpl == null) {
|
||||
@@ -2028,6 +2017,11 @@ public class VoiceInteractionManagerService extends SystemService {
|
||||
|
||||
List<String> roleHolders = mRm.getRoleHoldersAsUser(roleName, user);
|
||||
|
||||
if (DEBUG) {
|
||||
Slogf.d(TAG, "onRoleHoldersChanged(%s, %s): roleHolders=%s", roleName, user,
|
||||
roleHolders);
|
||||
}
|
||||
|
||||
// TODO(b/226201975): this method is beling called when a pre-created user is added,
|
||||
// at which point it doesn't have any role holders. But it's not called again when
|
||||
// the actual user is added (i.e., when the pre-created user is converted), so we
|
||||
@@ -2038,9 +2032,9 @@ public class VoiceInteractionManagerService extends SystemService {
|
||||
if (roleHolders.isEmpty()) {
|
||||
UserInfo userInfo = mUserManagerInternal.getUserInfo(user.getIdentifier());
|
||||
if (userInfo != null && userInfo.preCreated) {
|
||||
Slogf.d(TAG, "onRoleHoldersChanged(): ignoring pre-created user %s for now",
|
||||
userInfo.toFullString());
|
||||
mIgnoredPreCreatedUsers.add(user);
|
||||
Slogf.d(TAG, "onRoleHoldersChanged(): ignoring pre-created user %s for now,"
|
||||
+ " this method will be called again when it's converted to a real"
|
||||
+ " user", userInfo.toFullString());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user