Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1cce133a authored by Daniel Norman's avatar Daniel Norman Committed by Android (Google) Code Review
Browse files

Merge "cleanup: clean up flag floating_menu_notify_targets_changed_on_strict_diff" into main

parents 2ceccac3 1d41c451
Loading
Loading
Loading
Loading
+0 −10
Original line number Diff line number Diff line
@@ -109,16 +109,6 @@ flag {
    bug: "357882387"
}

flag {
    name: "floating_menu_notify_targets_changed_on_strict_diff"
    namespace: "accessibility"
    description: "Only notify listeners that the list of accessibility targets has changed if the lists are not identical."
    bug: "376473165"
    metadata {
      purpose: PURPOSE_BUGFIX
    }
}

flag {
    name: "privacy_dot_live_region"
    namespace: "accessibility"
+0 −32
Original line number Diff line number Diff line
@@ -36,7 +36,6 @@ import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Rect;
import android.graphics.drawable.GradientDrawable;
import android.platform.test.annotations.DisableFlags;
import android.platform.test.annotations.EnableFlags;
import android.testing.TestableLooper;
import android.view.WindowManager;
@@ -216,37 +215,6 @@ public class MenuViewTest extends SysuiTestCase {
    }

    @Test
    @DisableFlags(Flags.FLAG_FLOATING_MENU_NOTIFY_TARGETS_CHANGED_ON_STRICT_DIFF)
    public void onTargetFeaturesChanged_listenerCalled_flagDisabled() {
        // Call show() to start observing the target features change listener.
        mMenuView.show();

        // The target features change listener should be called when the observer is added.
        verify(mOnTargetFeaturesChangeListener, times(1)).onChange(any());

        // When the target features list changes, the listener should be called.
        mMenuViewModel.onTargetFeaturesChanged(
                List.of(
                        new TestAccessibilityTarget(mContext, 123),
                        new TestAccessibilityTarget(mContext, 456)));
        verify(mOnTargetFeaturesChangeListener, times(2)).onChange(any());

        // Double check that when the target features list changes, the listener should be called.
        List<AccessibilityTarget> newFeaturesList =
                List.of(
                        new TestAccessibilityTarget(mContext, 123),
                        new TestAccessibilityTarget(mContext, 789),
                        new TestAccessibilityTarget(mContext, 456));
        mMenuViewModel.onTargetFeaturesChanged(newFeaturesList);
        verify(mOnTargetFeaturesChangeListener, times(3)).onChange(any());

        // When the target features list doesn't change, the listener will still be called.
        mMenuViewModel.onTargetFeaturesChanged(newFeaturesList);
        verify(mOnTargetFeaturesChangeListener, times(4)).onChange(any());
    }

    @Test
    @EnableFlags(Flags.FLAG_FLOATING_MENU_NOTIFY_TARGETS_CHANGED_ON_STRICT_DIFF)
    public void onTargetFeaturesChanged_listenerCalled_flagEnabled() {
        // Call show() to start observing the target features change listener.
        mMenuView.show();
+9 −15
Original line number Diff line number Diff line
@@ -266,13 +266,11 @@ class MenuInfoRepository {
                mSecureSettings.getUriFor(Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS),
                /* notifyForDescendants */ false, mMenuTargetFeaturesContentObserver,
                UserHandle.USER_CURRENT);
        if (com.android.systemui.Flags.floatingMenuNotifyTargetsChangedOnStrictDiff()) {
        mSecureSettings.registerContentObserverForUserSync(
                mSecureSettings.getUriFor(ENABLED_ACCESSIBILITY_SERVICES),
                /* notifyForDescendants */ false,
                mMenuTargetFeaturesContentObserver,
                UserHandle.USER_CURRENT);
        }
        mSecureSettings.registerContentObserverForUserSync(
                mSecureSettings.getUriFor(Settings.Secure.ACCESSIBILITY_FLOATING_MENU_SIZE),
                /* notifyForDescendants */ false, mMenuSizeContentObserver,
@@ -287,10 +285,8 @@ class MenuInfoRepository {
                UserHandle.USER_CURRENT);
        mContext.registerComponentCallbacks(mComponentCallbacks);

        if (com.android.systemui.Flags.floatingMenuNotifyTargetsChangedOnStrictDiff()) {
        mAccessibilityManager.addAccessibilityServicesStateChangeListener(
                mA11yServicesStateChangeListener);
        }

        if (com.android.settingslib.flags.Flags.hearingDeviceSetConnectionStatusReport()) {
            registerConnectionStatusListener();
@@ -317,10 +313,8 @@ class MenuInfoRepository {
        mContext.getContentResolver().unregisterContentObserver(mMenuFadeOutContentObserver);
        mContext.unregisterComponentCallbacks(mComponentCallbacks);

        if (com.android.systemui.Flags.floatingMenuNotifyTargetsChangedOnStrictDiff()) {
        mAccessibilityManager.removeAccessibilityServicesStateChangeListener(
                mA11yServicesStateChangeListener);
        }

        unregisterConnectionStatusListener();
    }
+1 −3
Original line number Diff line number Diff line
@@ -284,9 +284,7 @@ class MenuView extends FrameLayout implements
        onPositionChanged();

        boolean shouldSendFeatureChangeNotification =
                com.android.systemui.Flags.floatingMenuNotifyTargetsChangedOnStrictDiff()
                    ? !areFeatureListsIdentical(targetFeatures, newTargetFeatures)
                    : true;
                !areFeatureListsIdentical(targetFeatures, newTargetFeatures);
        if (mFeaturesChangeListener != null && shouldSendFeatureChangeNotification) {
            mFeaturesChangeListener.onChange(newTargetFeatures);
        }