Skip to content

Commit 30ed33b

Browse files
sganovAndroid (Google) Code Review
authored andcommitted
Merge "Owner should not be announces as a user switch." into jb-mr1-dev
2 parents 0a551d6 + 59f0769 commit 30ed33b

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

core/res/res/values/strings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3933,6 +3933,6 @@
39333933
<!-- Text spoken when the user stops preforming a gesture that would enable accessibility. [CHAR LIMIT=none] -->
39343934
<string name="enable_accessibility_canceled">Accessibility canceled.</string>
39353935
<!-- Text spoken when the current user is switched if accessibility is enabled. [CHAR LIMIT=none] -->
3936-
<string name="user_switched">Switched to user <xliff:g id="name" example="Bob">%1$s</xliff:g>.</string>
3936+
<string name="user_switched">Current user <xliff:g id="name" example="Bob">%1$s</xliff:g>.</string>
39373937

39383938
</resources>

services/java/com/android/server/accessibility/AccessibilityManagerService.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
111111

112112
// TODO: This is arbitrary. When there is time implement this by watching
113113
// when that accessibility services are bound.
114-
private static final int WAIT_FOR_USER_STATE_FULLY_INITIALIZED_MILLIS = 5000;
114+
private static final int WAIT_FOR_USER_STATE_FULLY_INITIALIZED_MILLIS = 3000;
115115

116116
private static final String FUNCTION_REGISTER_UI_TEST_AUTOMATION_SERVICE =
117117
"registerUiTestAutomationService";
@@ -659,16 +659,22 @@ private void switchUser(int userId) {
659659
oldUserState.mUserId, 0).sendToTarget();
660660
}
661661

662+
// Announce user changes only if more that one exist.
663+
UserManager userManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
664+
final boolean announceNewUser = userManager.getUsers().size() > 1;
665+
662666
// The user changed.
663667
mCurrentUserId = userId;
664668

665669
// Recreate the internal state for the new user.
666670
mMainHandler.obtainMessage(MainHandler.MSG_SEND_RECREATE_INTERNAL_STATE,
667671
mCurrentUserId, 0).sendToTarget();
668672

669-
// Schedule announcement of the current user if needed.
670-
mMainHandler.sendEmptyMessageDelayed(MainHandler.MSG_ANNOUNCE_NEW_USER_IF_NEEDED,
671-
WAIT_FOR_USER_STATE_FULLY_INITIALIZED_MILLIS);
673+
if (announceNewUser) {
674+
// Schedule announcement of the current user if needed.
675+
mMainHandler.sendEmptyMessageDelayed(MainHandler.MSG_ANNOUNCE_NEW_USER_IF_NEEDED,
676+
WAIT_FOR_USER_STATE_FULLY_INITIALIZED_MILLIS);
677+
}
672678
}
673679
}
674680

0 commit comments

Comments
 (0)