feat(MultiFingerMultiTap): Add two-finger triple-tap shortcut on magnification dialog

The shortcut is separate from single-finger triple-tap. It’s under hardware shortcut and above/outside of Advanced section.

Bug: 297805269
Test: manual
Test: atest ToggleScreenMagnificationPreferenceFragmentTest
Change-Id: Id74cf3e457c04e167f3100d977b6c70c5d601026
diff --git a/Android.bp b/Android.bp
index 54137ec..03f9c10 100644
--- a/Android.bp
+++ b/Android.bp
@@ -99,6 +99,7 @@
         "settings-logtags",
         "settings-telephony-protos-lite",
         "statslog-settings",
+        "com_android_server_accessibility_flags_lib",
     ],
 
     plugins: ["androidx.room_room-compiler-plugin"],
diff --git a/res/layout/accessibility_edit_shortcut_magnification.xml b/res/layout/accessibility_edit_shortcut_magnification.xml
index 725c4c7..0f30a01 100644
--- a/res/layout/accessibility_edit_shortcut_magnification.xml
+++ b/res/layout/accessibility_edit_shortcut_magnification.xml
@@ -46,6 +46,14 @@
                 android:layout_height="wrap_content"
                 android:layout_marginBottom="32dp" />
 
+            <include
+                android:id="@+id/two_finger_triple_tap_shortcut"
+                layout="@layout/accessibility_edit_shortcut_component"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_marginBottom="32dp"
+                android:visibility="gone" />
+
             <LinearLayout
                 android:id="@+id/advanced_shortcut"
                 android:layout_width="match_parent"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index c908152..dc6efe9 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -4623,6 +4623,12 @@
     <string name="accessibility_shortcut_hardware_keyword">hold volume keys</string>
     <!-- Summary for hardware shortcut in accessibility edit shortcut dialog. [CHAR LIMIT=NONE] -->
     <string name="accessibility_shortcut_edit_dialog_summary_hardware">Press &amp; hold both volume keys</string>
+    <!-- Title for two finger triple tap shortcut in accessibility edit shortcut dialog. [CHAR LIMIT=NONE] -->
+    <string name="accessibility_shortcut_edit_dialog_title_two_finger_triple_tap">Two-finger triple-tap screen</string>
+    <!-- Part of list to compose user's accessibility shortcut list. [CHAR LIMIT=NONE] -->
+    <string name="accessibility_shortcut_two_finger_triple_tap_keyword">two-finger triple-tap screen</string>
+    <!-- Summary for two finger triple tap shortcut in accessibility edit shortcut dialog. [CHAR LIMIT=NONE] -->
+    <string name="accessibility_shortcut_edit_dialog_summary_two_finger_triple_tap">Quickly tap screen {0,number,integer} times with two fingers</string>
     <!-- Title for triple tap shortcut in accessibility edit shortcut dialog. [CHAR LIMIT=NONE] -->
     <string name="accessibility_shortcut_edit_dialog_title_triple_tap">Triple-tap screen</string>
     <!-- Part of list to compose user's accessibility shortcut list. [CHAR LIMIT=NONE] -->
diff --git a/src/com/android/settings/accessibility/AccessibilityDialogUtils.java b/src/com/android/settings/accessibility/AccessibilityDialogUtils.java
index f744984..c429e0b 100644
--- a/src/com/android/settings/accessibility/AccessibilityDialogUtils.java
+++ b/src/com/android/settings/accessibility/AccessibilityDialogUtils.java
@@ -52,6 +52,7 @@
 import androidx.appcompat.app.AlertDialog;
 import androidx.core.content.ContextCompat;
 
+import com.android.server.accessibility.Flags;
 import com.android.settings.R;
 import com.android.settings.core.SubSettingLauncher;
 import com.android.settings.utils.AnnotationSpan;
@@ -247,6 +248,9 @@
                         R.layout.accessibility_edit_shortcut_magnification, null);
                 initSoftwareShortcut(context, contentView);
                 initHardwareShortcut(context, contentView);
+                if (Flags.enableMagnificationMultipleFingerMultipleTapGesture()) {
+                    initTwoFingerTripleTapMagnificationShortcut(context, contentView);
+                }
                 initMagnifyShortcut(context, contentView);
                 initAdvancedWidget(contentView);
                 break;
@@ -255,6 +259,9 @@
                         R.layout.accessibility_edit_shortcut_magnification, null);
                 initSoftwareShortcutForSUW(context, contentView);
                 initHardwareShortcut(context, contentView);
+                if (Flags.enableMagnificationMultipleFingerMultipleTapGesture()) {
+                    initTwoFingerTripleTapMagnificationShortcut(context, contentView);
+                }
                 initMagnifyShortcut(context, contentView);
                 initAdvancedWidget(contentView);
                 break;
@@ -358,6 +365,23 @@
                 R.raw.a11y_shortcut_type_triple_tap);
     }
 
+    private static void initTwoFingerTripleTapMagnificationShortcut(Context context, View view) {
+        // TODO(b/306153204): Update shortcut string and image when UX provides them
+        final View dialogView = view.findViewById(R.id.two_finger_triple_tap_shortcut);
+        final CharSequence title = context.getText(
+                R.string.accessibility_shortcut_edit_dialog_title_two_finger_triple_tap);
+        String summary = context.getString(
+                R.string.accessibility_shortcut_edit_dialog_summary_two_finger_triple_tap);
+        // Format the number '3' in the summary.
+        final Object[] arguments = {3};
+        summary = MessageFormat.format(summary, arguments);
+
+        setupShortcutWidgetWithImageRawResource(context, dialogView, title, summary,
+                R.raw.a11y_shortcut_type_triple_tap);
+
+        dialogView.setVisibility(View.VISIBLE);
+    }
+
     private static void initAdvancedWidget(View view) {
         final LinearLayout advanced = view.findViewById(R.id.advanced_shortcut);
         final View tripleTap = view.findViewById(R.id.triple_tap_shortcut);
diff --git a/src/com/android/settings/accessibility/AccessibilityUtil.java b/src/com/android/settings/accessibility/AccessibilityUtil.java
index 36c99f1..3b81bdb 100644
--- a/src/com/android/settings/accessibility/AccessibilityUtil.java
+++ b/src/com/android/settings/accessibility/AccessibilityUtil.java
@@ -94,6 +94,7 @@
             UserShortcutType.SOFTWARE,
             UserShortcutType.HARDWARE,
             UserShortcutType.TRIPLETAP,
+            UserShortcutType.TWOFINGERTRIPLETAP,
     })
 
     /** Denotes the user shortcut type. */
@@ -102,6 +103,7 @@
         int SOFTWARE = 1; // 1 << 0
         int HARDWARE = 2; // 1 << 1
         int TRIPLETAP = 4; // 1 << 2
+        int TWOFINGERTRIPLETAP = 8; // 1 << 3
     }
 
     /**
diff --git a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
index 16cf85d..886719d 100644
--- a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
@@ -42,12 +42,14 @@
 import android.view.accessibility.AccessibilityManager.TouchExplorationStateChangeListener;
 import android.widget.CheckBox;
 
+import androidx.annotation.Nullable;
 import androidx.preference.Preference;
 import androidx.preference.PreferenceCategory;
 import androidx.preference.SwitchPreferenceCompat;
 import androidx.preference.TwoStatePreference;
 
 import com.android.internal.annotations.VisibleForTesting;
+import com.android.server.accessibility.Flags;
 import com.android.settings.DialogCreatable;
 import com.android.settings.R;
 import com.android.settings.accessibility.AccessibilityDialogUtils.DialogType;
@@ -83,6 +85,7 @@
     private CheckBox mSoftwareTypeCheckBox;
     private CheckBox mHardwareTypeCheckBox;
     private CheckBox mTripleTapTypeCheckBox;
+    @Nullable private CheckBox mTwoFingerTripleTapTypeCheckBox;
     private DialogCreatable mDialogDelegate;
     private MagnificationFollowTypingPreferenceController mFollowTypingPreferenceController;
 
@@ -330,6 +333,11 @@
         if (mTripleTapTypeCheckBox.isChecked()) {
             value |= UserShortcutType.TRIPLETAP;
         }
+        if (Flags.enableMagnificationMultipleFingerMultipleTapGesture()) {
+            if (mTwoFingerTripleTapTypeCheckBox.isChecked()) {
+                value |= UserShortcutType.TWOFINGERTRIPLETAP;
+            }
+        }
         return value;
     }
 
@@ -343,6 +351,15 @@
         mHardwareTypeCheckBox = dialogHardwareView.findViewById(R.id.checkbox);
         setDialogTextAreaClickListener(dialogHardwareView, mHardwareTypeCheckBox);
 
+        if (Flags.enableMagnificationMultipleFingerMultipleTapGesture()) {
+            final View dialogTwoFignerTripleTapView =
+                    dialog.findViewById(R.id.two_finger_triple_tap_shortcut);
+            mTwoFingerTripleTapTypeCheckBox = dialogTwoFignerTripleTapView.findViewById(
+                    R.id.checkbox);
+            setDialogTextAreaClickListener(
+                    dialogTwoFignerTripleTapView, mTwoFingerTripleTapTypeCheckBox);
+        }
+
         final View dialogTripleTapView = dialog.findViewById(R.id.triple_tap_shortcut);
         mTripleTapTypeCheckBox = dialogTripleTapView.findViewById(R.id.checkbox);
         setDialogTextAreaClickListener(dialogTripleTapView, mTripleTapTypeCheckBox);
@@ -378,6 +395,10 @@
                 hasShortcutType(value, UserShortcutType.HARDWARE));
         mTripleTapTypeCheckBox.setChecked(
                 hasShortcutType(value, UserShortcutType.TRIPLETAP));
+        if (Flags.enableMagnificationMultipleFingerMultipleTapGesture()) {
+            mTwoFingerTripleTapTypeCheckBox.setChecked(
+                    hasShortcutType(value, UserShortcutType.TWOFINGERTRIPLETAP));
+        }
     }
 
     private int restoreOnConfigChangedValue() {
@@ -453,6 +474,13 @@
                     R.string.accessibility_shortcut_triple_tap_keyword);
             list.add(tripleTapTitle);
         }
+        if (Flags.enableMagnificationMultipleFingerMultipleTapGesture()) {
+            if (hasShortcutType(shortcutTypes, UserShortcutType.TWOFINGERTRIPLETAP)) {
+                final CharSequence twoFingerTripleTapTitle = context.getText(
+                        R.string.accessibility_shortcut_two_finger_triple_tap_keyword);
+                list.add(twoFingerTripleTapTitle);
+            }
+        }
 
         // Show software shortcut if first time to use.
         if (list.isEmpty()) {
@@ -618,6 +646,12 @@
         if (((shortcutTypes & UserShortcutType.TRIPLETAP) == UserShortcutType.TRIPLETAP)) {
             optInMagnificationValueToSettings(context, UserShortcutType.TRIPLETAP);
         }
+        if (Flags.enableMagnificationMultipleFingerMultipleTapGesture()) {
+            if (((shortcutTypes & UserShortcutType.TWOFINGERTRIPLETAP)
+                    == UserShortcutType.TWOFINGERTRIPLETAP)) {
+                optInMagnificationValueToSettings(context, UserShortcutType.TWOFINGERTRIPLETAP);
+            }
+        }
     }
 
     private static void optInMagnificationValueToSettings(Context context,
@@ -628,6 +662,15 @@
             return;
         }
 
+        if (Flags.enableMagnificationMultipleFingerMultipleTapGesture()) {
+            if (shortcutType == UserShortcutType.TWOFINGERTRIPLETAP) {
+                Settings.Secure.putInt(context.getContentResolver(),
+                        Settings.Secure.ACCESSIBILITY_MAGNIFICATION_TWO_FINGER_TRIPLE_TAP_ENABLED,
+                        ON);
+                return;
+            }
+        }
+
         if (hasMagnificationValueInSettings(context, shortcutType)) {
             return;
         }
@@ -668,6 +711,12 @@
         if (((shortcutTypes & UserShortcutType.TRIPLETAP) == UserShortcutType.TRIPLETAP)) {
             optOutMagnificationValueFromSettings(context, UserShortcutType.TRIPLETAP);
         }
+        if (Flags.enableMagnificationMultipleFingerMultipleTapGesture()) {
+            if (((shortcutTypes & UserShortcutType.TWOFINGERTRIPLETAP)
+                    == UserShortcutType.TWOFINGERTRIPLETAP)) {
+                optOutMagnificationValueFromSettings(context, UserShortcutType.TWOFINGERTRIPLETAP);
+            }
+        }
     }
 
     private static void optOutMagnificationValueFromSettings(Context context,
@@ -678,6 +727,15 @@
             return;
         }
 
+        if (Flags.enableMagnificationMultipleFingerMultipleTapGesture()) {
+            if (shortcutType == UserShortcutType.TWOFINGERTRIPLETAP) {
+                Settings.Secure.putInt(context.getContentResolver(),
+                        Settings.Secure.ACCESSIBILITY_MAGNIFICATION_TWO_FINGER_TRIPLE_TAP_ENABLED,
+                        OFF);
+                return;
+            }
+        }
+
         final String targetKey = AccessibilityUtil.convertKeyFromSettings(shortcutType);
         final String targetString = Settings.Secure.getString(context.getContentResolver(),
                 targetKey);
@@ -713,6 +771,13 @@
         if (((shortcutTypes & UserShortcutType.TRIPLETAP) == UserShortcutType.TRIPLETAP)) {
             exist |= hasMagnificationValueInSettings(context, UserShortcutType.TRIPLETAP);
         }
+        if (Flags.enableMagnificationMultipleFingerMultipleTapGesture()) {
+            if (((shortcutTypes & UserShortcutType.TWOFINGERTRIPLETAP)
+                    == UserShortcutType.TWOFINGERTRIPLETAP)) {
+                exist |= hasMagnificationValueInSettings(context,
+                        UserShortcutType.TWOFINGERTRIPLETAP);
+            }
+        }
         return exist;
     }
 
@@ -723,6 +788,14 @@
                     Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED, OFF) == ON;
         }
 
+        if (Flags.enableMagnificationMultipleFingerMultipleTapGesture()) {
+            if (shortcutType == UserShortcutType.TWOFINGERTRIPLETAP) {
+                return Settings.Secure.getInt(context.getContentResolver(),
+                        Settings.Secure.ACCESSIBILITY_MAGNIFICATION_TWO_FINGER_TRIPLE_TAP_ENABLED,
+                        OFF) == ON;
+            }
+        }
+
         final String targetKey = AccessibilityUtil.convertKeyFromSettings(shortcutType);
         final String targetString = Settings.Secure.getString(context.getContentResolver(),
                 targetKey);
@@ -752,6 +825,11 @@
         if (hasMagnificationValuesInSettings(context, UserShortcutType.TRIPLETAP)) {
             shortcutTypes |= UserShortcutType.TRIPLETAP;
         }
+        if (Flags.enableMagnificationMultipleFingerMultipleTapGesture()) {
+            if (hasMagnificationValuesInSettings(context, UserShortcutType.TWOFINGERTRIPLETAP)) {
+                shortcutTypes |= UserShortcutType.TWOFINGERTRIPLETAP;
+            }
+        }
         return shortcutTypes;
     }
 
diff --git a/tests/robotests/Android.bp b/tests/robotests/Android.bp
index 68793a1..fa55f35 100644
--- a/tests/robotests/Android.bp
+++ b/tests/robotests/Android.bp
@@ -66,6 +66,7 @@
         "platform-test-annotations",
         "Settings-testutils2",
         "notification_flags_lib",
+        "com_android_server_accessibility_flags_lib",
     ],
 
     libs: [
diff --git a/tests/robotests/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragmentTest.java b/tests/robotests/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragmentTest.java
index 539c503..e5ac793 100644
--- a/tests/robotests/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragmentTest.java
@@ -40,12 +40,16 @@
 import android.database.ContentObserver;
 import android.net.Uri;
 import android.os.Bundle;
+import android.platform.test.annotations.RequiresFlagsEnabled;
+import android.platform.test.flag.junit.CheckFlagsRule;
+import android.platform.test.flag.junit.DeviceFlagsValueProvider;
 import android.provider.Settings;
 
 import androidx.appcompat.app.AlertDialog;
 import androidx.preference.TwoStatePreference;
 import androidx.test.core.app.ApplicationProvider;
 
+import com.android.server.accessibility.Flags;
 import com.android.settings.DialogCreatable;
 import com.android.settings.R;
 import com.android.settings.SettingsActivity;
@@ -57,6 +61,7 @@
 import com.google.common.truth.Correspondence;
 
 import org.junit.Before;
+import org.junit.Rule;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.robolectric.RobolectricTestRunner;
@@ -80,6 +85,9 @@
 })
 public class ToggleScreenMagnificationPreferenceFragmentTest {
 
+    @Rule
+    public final CheckFlagsRule mCheckFlagsRule = DeviceFlagsValueProvider.createCheckFlagsRule();
+
     private static final String PLACEHOLDER_PACKAGE_NAME = "com.mock.example";
     private static final String PLACEHOLDER_CLASS_NAME =
             PLACEHOLDER_PACKAGE_NAME + ".mock_a11y_service";
@@ -93,6 +101,8 @@
             Settings.Secure.ACCESSIBILITY_SHORTCUT_TARGET_SERVICE;
     private static final String TRIPLETAP_SHORTCUT_KEY =
             Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED;
+    private static final String TWO_FINGER_TRIPLE_TAP_SHORTCUT_KEY =
+            Settings.Secure.ACCESSIBILITY_MAGNIFICATION_TWO_FINGER_TRIPLE_TAP_ENABLED;
 
     private static final String MAGNIFICATION_CONTROLLER_NAME =
             "com.android.server.accessibility.MagnificationController";
@@ -190,6 +200,26 @@
     }
 
     @Test
+    @RequiresFlagsEnabled(Flags.FLAG_ENABLE_MAGNIFICATION_MULTIPLE_FINGER_MULTIPLE_TAP_GESTURE)
+    public void hasMagnificationValuesInSettings_twoFingerTripleTapIsOn_isTrue() {
+        Settings.Secure.putInt(
+                mContext.getContentResolver(), TWO_FINGER_TRIPLE_TAP_SHORTCUT_KEY, ON);
+
+        assertThat(ToggleScreenMagnificationPreferenceFragment.hasMagnificationValuesInSettings(
+                mContext, UserShortcutType.TWOFINGERTRIPLETAP)).isTrue();
+    }
+
+    @Test
+    @RequiresFlagsEnabled(Flags.FLAG_ENABLE_MAGNIFICATION_MULTIPLE_FINGER_MULTIPLE_TAP_GESTURE)
+    public void hasMagnificationValuesInSettings_twoFingerTripleTapIsOff_isFalse() {
+        Settings.Secure.putInt(
+                mContext.getContentResolver(), TWO_FINGER_TRIPLE_TAP_SHORTCUT_KEY, OFF);
+
+        assertThat(ToggleScreenMagnificationPreferenceFragment.hasMagnificationValuesInSettings(
+                mContext, UserShortcutType.TWOFINGERTRIPLETAP)).isFalse();
+    }
+
+    @Test
     public void optInAllValuesToSettings_optInValue_haveMatchString() {
         int shortcutTypes = UserShortcutType.SOFTWARE | UserShortcutType.TRIPLETAP;
 
@@ -199,7 +229,18 @@
         assertThat(getStringFromSettings(SOFTWARE_SHORTCUT_KEY)).isEqualTo(
                 MAGNIFICATION_CONTROLLER_NAME);
         assertThat(getMagnificationTripleTapStatus()).isTrue();
+    }
 
+    @Test
+    @RequiresFlagsEnabled(Flags.FLAG_ENABLE_MAGNIFICATION_MULTIPLE_FINGER_MULTIPLE_TAP_GESTURE)
+    public void optInAllValuesToSettings_twoFingerTripleTap_haveMatchString() {
+        int shortcutTypes = UserShortcutType.TWOFINGERTRIPLETAP;
+
+        ToggleScreenMagnificationPreferenceFragment.optInAllMagnificationValuesToSettings(mContext,
+                shortcutTypes);
+
+        assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
+                TWO_FINGER_TRIPLE_TAP_SHORTCUT_KEY, OFF)).isEqualTo(ON);
     }
 
     @Test
@@ -297,6 +338,19 @@
     }
 
     @Test
+    @RequiresFlagsEnabled(Flags.FLAG_ENABLE_MAGNIFICATION_MULTIPLE_FINGER_MULTIPLE_TAP_GESTURE)
+    public void optOutAllValuesToSettings_twoFingerTripleTap_settingsValueIsOff() {
+        Settings.Secure.putInt(mContext.getContentResolver(),
+                TWO_FINGER_TRIPLE_TAP_SHORTCUT_KEY, ON);
+
+        ToggleScreenMagnificationPreferenceFragment.optOutAllMagnificationValuesFromSettings(
+                mContext, UserShortcutType.TWOFINGERTRIPLETAP);
+
+        assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
+                TWO_FINGER_TRIPLE_TAP_SHORTCUT_KEY, ON)).isEqualTo(OFF);
+    }
+
+    @Test
     public void optOutValueFromSettings_existOtherValue_optOutValue_haveMatchString() {
         putStringIntoSettings(SOFTWARE_SHORTCUT_KEY,
                 PLACEHOLDER_COMPONENT_NAME.flattenToString() + ":" + MAGNIFICATION_CONTROLLER_NAME);
@@ -353,6 +407,35 @@
     }
 
     @Test
+    @RequiresFlagsEnabled(Flags.FLAG_ENABLE_MAGNIFICATION_MULTIPLE_FINGER_MULTIPLE_TAP_GESTURE)
+    public void updateShortcutPreferenceData_hasTwoFingerTripleTapInSettings_assignToVariable() {
+        Settings.Secure.putInt(
+                mContext.getContentResolver(), TWO_FINGER_TRIPLE_TAP_SHORTCUT_KEY, ON);
+        mFragController.create(R.id.main_content, /* bundle= */ null).start().resume();
+
+        mFragController.get().updateShortcutPreferenceData();
+
+        final int expectedType = PreferredShortcuts.retrieveUserShortcutType(mContext,
+                MAGNIFICATION_CONTROLLER_NAME, UserShortcutType.SOFTWARE);
+        assertThat(expectedType).isEqualTo(UserShortcutType.TWOFINGERTRIPLETAP);
+    }
+
+    @Test
+    @RequiresFlagsEnabled(Flags.FLAG_ENABLE_MAGNIFICATION_MULTIPLE_FINGER_MULTIPLE_TAP_GESTURE)
+    public void updateShortcutPreferenceData_hasTwoFingerTripleTapInSharedPref_assignToVariable() {
+        final PreferredShortcut tripleTapShortcut = new PreferredShortcut(
+                MAGNIFICATION_CONTROLLER_NAME, UserShortcutType.TWOFINGERTRIPLETAP);
+        putUserShortcutTypeIntoSharedPreference(mContext, tripleTapShortcut);
+        mFragController.create(R.id.main_content, /* bundle= */ null).start().resume();
+
+        mFragController.get().updateShortcutPreferenceData();
+
+        final int expectedType = PreferredShortcuts.retrieveUserShortcutType(mContext,
+                MAGNIFICATION_CONTROLLER_NAME, UserShortcutType.SOFTWARE);
+        assertThat(expectedType).isEqualTo(UserShortcutType.TWOFINGERTRIPLETAP);
+    }
+
+    @Test
     public void setupMagnificationEditShortcutDialog_shortcutPreferenceOff_checkboxIsEmptyValue() {
         ToggleScreenMagnificationPreferenceFragment fragment =
                 mFragController.create(R.id.main_content, /* bundle= */
@@ -388,6 +471,27 @@
     }
 
     @Test
+    @RequiresFlagsEnabled(Flags.FLAG_ENABLE_MAGNIFICATION_MULTIPLE_FINGER_MULTIPLE_TAP_GESTURE)
+    public void setupMagnificationEditShortcutDialog_twoFingerTripleTapOn_checkboxIsSavedValue() {
+        ToggleScreenMagnificationPreferenceFragment fragment =
+                mFragController.create(R.id.main_content, /* bundle= */
+                        null).start().resume().get();
+        final ShortcutPreference shortcutPreference = new ShortcutPreference(mContext, /* attrs= */
+                null);
+        final PreferredShortcut twoFingerTripleTapShortcut = new PreferredShortcut(
+                MAGNIFICATION_CONTROLLER_NAME, UserShortcutType.TWOFINGERTRIPLETAP);
+        fragment.mShortcutPreference = shortcutPreference;
+
+        PreferredShortcuts.saveUserShortcutType(mContext, twoFingerTripleTapShortcut);
+        fragment.mShortcutPreference.setChecked(true);
+        fragment.setupMagnificationEditShortcutDialog(
+                createEditShortcutDialog(fragment.getActivity()));
+
+        final int checkboxValue = fragment.getShortcutTypeCheckBoxValue();
+        assertThat(checkboxValue).isEqualTo(UserShortcutType.TWOFINGERTRIPLETAP);
+    }
+
+    @Test
     public void restoreValueFromSavedInstanceState_assignToVariable() {
         final Bundle fragmentState = createFragmentSavedInstanceState(
                 UserShortcutType.HARDWARE | UserShortcutType.TRIPLETAP);
@@ -409,6 +513,28 @@
     }
 
     @Test
+    @RequiresFlagsEnabled(Flags.FLAG_ENABLE_MAGNIFICATION_MULTIPLE_FINGER_MULTIPLE_TAP_GESTURE)
+    public void restoreValueFromSavedInstanceState_twoFingerTripleTap_assignToVariable() {
+        final Bundle fragmentState =
+                createFragmentSavedInstanceState(UserShortcutType.TWOFINGERTRIPLETAP);
+        ToggleScreenMagnificationPreferenceFragment fragment = mFragController.get();
+        // Had to use reflection to pass the savedInstanceState when launching the fragment
+        ReflectionHelpers.setField(fragment, "mSavedFragmentState", fragmentState);
+
+        FragmentController.of(fragment, SettingsActivity.class).create(
+                R.id.main_content, /* bundle= */ null).start().resume().get();
+        fragment.setupMagnificationEditShortcutDialog(
+                createEditShortcutDialog(fragment.getActivity()));
+        final int value = fragment.getShortcutTypeCheckBoxValue();
+        fragment.saveNonEmptyUserShortcutType(value);
+
+        final int expectedType = PreferredShortcuts.retrieveUserShortcutType(mContext,
+                MAGNIFICATION_CONTROLLER_NAME, UserShortcutType.SOFTWARE);
+        assertThat(value).isEqualTo(UserShortcutType.TWOFINGERTRIPLETAP);
+        assertThat(expectedType).isEqualTo(UserShortcutType.TWOFINGERTRIPLETAP);
+    }
+
+    @Test
     public void onCreateView_magnificationAreaNotSupported_settingsPreferenceIsNull() {
         setWindowMagnificationSupported(
                 /* magnificationAreaSupported= */ false,
@@ -516,6 +642,29 @@
                         mContext.getString(R.string.generic_accessibility_feature_shortcut_off));
     }
 
+    @Test
+    @RequiresFlagsEnabled(Flags.FLAG_ENABLE_MAGNIFICATION_MULTIPLE_FINGER_MULTIPLE_TAP_GESTURE)
+    public void getSummary_magnificationGestureEnabled_returnShortcutOnWithSummary() {
+        Settings.Secure.putInt(
+                mContext.getContentResolver(), TWO_FINGER_TRIPLE_TAP_SHORTCUT_KEY, ON);
+
+        assertThat(
+                ToggleScreenMagnificationPreferenceFragment.getServiceSummary(mContext).toString())
+                .isEqualTo(mContext.getString(R.string.accessibility_summary_shortcut_enabled));
+    }
+
+    @Test
+    @RequiresFlagsEnabled(Flags.FLAG_ENABLE_MAGNIFICATION_MULTIPLE_FINGER_MULTIPLE_TAP_GESTURE)
+    public void getSummary_magnificationGestureDisabled_returnShortcutOffWithSummary() {
+        Settings.Secure.putInt(
+                mContext.getContentResolver(), TWO_FINGER_TRIPLE_TAP_SHORTCUT_KEY, OFF);
+
+        assertThat(
+                ToggleScreenMagnificationPreferenceFragment.getServiceSummary(mContext).toString())
+                .isEqualTo(
+                        mContext.getString(R.string.generic_accessibility_feature_shortcut_off));
+    }
+
     private void putStringIntoSettings(String key, String componentName) {
         Settings.Secure.putString(mContext.getContentResolver(), key, componentName);
     }