Check target is empty before showing it in AccessibilityFloatingMenu
Root Cause: From ag/17686873, we remove the protect mechanism that AccessibilityManagerService might not ready to retrieve information when the phone get booted without keyguard lock, but it will still happen if the sequence of the object created got change, just like b/184272107 in android sc-dev. Solution: Change to check target is empty first before showing it, this way, we can show a11y FAB both in onUserUnlocked() and onKeyguardVisibilityChanged(false) stage without showing empty content a11y FAB. Bug: 192635136 Fix: 184272107 Test: atest AccessibilityFloatingMenuTest Change-Id: Icca1c2bbae3f0bf6cad4fb28c53b5a9e6cd9b271
This commit is contained in:
@@ -39,10 +39,13 @@ import android.text.TextUtils;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.android.internal.accessibility.dialog.AccessibilityTarget;
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.systemui.Prefs;
|
||||
import com.android.systemui.shared.system.SysUiStatsLog;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Contains logic for an accessibility floating menu view.
|
||||
*/
|
||||
@@ -120,9 +123,13 @@ public class AccessibilityFloatingMenu implements IAccessibilityFloatingMenu {
|
||||
if (isShowing()) {
|
||||
return;
|
||||
}
|
||||
final List<AccessibilityTarget> targetList = getTargets(mContext, ACCESSIBILITY_BUTTON);
|
||||
if (targetList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
mMenuView.show();
|
||||
mMenuView.onTargetsChanged(getTargets(mContext, ACCESSIBILITY_BUTTON));
|
||||
mMenuView.onTargetsChanged(targetList);
|
||||
mMenuView.updateOpacityWith(isFadeEffectEnabled(mContext),
|
||||
getOpacityValue(mContext));
|
||||
mMenuView.setSizeType(getSizeType(mContext));
|
||||
|
||||
@@ -87,6 +87,17 @@ public class AccessibilityFloatingMenuTest extends SysuiTestCase {
|
||||
assertThat(mMenuView.isShowing()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void showMenuView_emptyTarget_notShow() {
|
||||
final List<String> emptyTargets = new ArrayList<>();
|
||||
doReturn(emptyTargets).when(mAccessibilityManager).getAccessibilityShortcutTargets(
|
||||
anyInt());
|
||||
|
||||
mMenu.show();
|
||||
|
||||
assertThat(mMenuView.isShowing()).isFalse();
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
mMenu.hide();
|
||||
|
||||
Reference in New Issue
Block a user