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

Commit b7f72925 authored by chihtinglo's avatar chihtinglo Committed by Candice
Browse files

feat(EvenDimmer): Add popup for removing accessibility shortcuts

We do the following changes to show a popup for helping users to
deprecate Extra Dim shortcuts:
1. Send ACTION_LAUNCH_EXTRA_DIM_DIALOG when the Extra Dim shortcuts are
   triggered on the devices with EvenDimmer
2. The ACTION is received in SystemUI
3. Show popup for removing Extra Dim shortcuts(Dismiss keyguard if
   needed)
4. Remove all potential Extra Dim shortcuts when users click on the
   "Remove Extra Dim shortcut" button
5. Show the instructions with a toast after removing the shortcuts

Bug: 349458355
Test: atest ExtraDimDialogDelegateTest
      atest ExtraDimDialogReceiverTest
      atest ExtraDimDialogManagerTest
Flag: com.android.server.display.feature.flags.even_dimmer
Change-Id: I7fcda2ad38b780f2b83478c7170b45497cb25624
parent 10d1fca8
Loading
Loading
Loading
Loading
+16 −3
Original line number Original line Diff line number Diff line
@@ -36,6 +36,7 @@ import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.content.res.Configuration;
import android.database.ContentObserver;
import android.database.ContentObserver;
@@ -63,6 +64,7 @@ import android.widget.Toast;
import com.android.internal.R;
import com.android.internal.R;
import com.android.internal.accessibility.dialog.AccessibilityTarget;
import com.android.internal.accessibility.dialog.AccessibilityTarget;
import com.android.internal.accessibility.util.ShortcutUtils;
import com.android.internal.accessibility.util.ShortcutUtils;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.function.pooled.PooledLambda;
import com.android.internal.util.function.pooled.PooledLambda;


import java.lang.annotation.Retention;
import java.lang.annotation.Retention;
@@ -122,6 +124,13 @@ public class AccessibilityShortcutController {
            .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
            .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
            .setUsage(AudioAttributes.USAGE_ASSISTANCE_ACCESSIBILITY)
            .setUsage(AudioAttributes.USAGE_ASSISTANCE_ACCESSIBILITY)
            .build();
            .build();

    /**
     * An intent action to launch Extra Dim dialog.
     */
    @VisibleForTesting
    static final String ACTION_LAUNCH_REMOVE_EXTRA_DIM_DIALOG =
            "com.android.systemui.action.LAUNCH_REMOVE_EXTRA_DIM_DIALOG";
    private static Map<ComponentName, FrameworkFeatureInfo> sFrameworkShortcutFeaturesMap;
    private static Map<ComponentName, FrameworkFeatureInfo> sFrameworkShortcutFeaturesMap;


    private final Context mContext;
    private final Context mContext;
@@ -846,7 +855,7 @@ public class AccessibilityShortcutController {
            if (com.android.server.display.feature.flags.Flags.evenDimmer()
            if (com.android.server.display.feature.flags.Flags.evenDimmer()
                    && context.getResources().getBoolean(
                    && context.getResources().getBoolean(
                    com.android.internal.R.bool.config_evenDimmerEnabled)) {
                    com.android.internal.R.bool.config_evenDimmerEnabled)) {
                launchExtraDimDialog();
                launchExtraDimDialog(context);
                return true;
                return true;
            } else {
            } else {
                // Assuming that the default state will be to have the feature off
                // Assuming that the default state will be to have the feature off
@@ -863,8 +872,12 @@ public class AccessibilityShortcutController {
            }
            }
        }
        }


        private void launchExtraDimDialog() {
        private void launchExtraDimDialog(Context context) {
            // TODO: launch Extra dim dialog for feature migration
            final Intent intent = new Intent(ACTION_LAUNCH_REMOVE_EXTRA_DIM_DIALOG);
            intent.setFlags(Intent.FLAG_RECEIVER_FOREGROUND);
            intent.setPackage(
                    context.getString(com.android.internal.R.string.config_systemUi));
            context.sendBroadcastAsUser(intent, UserHandle.SYSTEM);
        }
        }
    }
    }


+3 −1
Original line number Original line Diff line number Diff line
@@ -72,7 +72,8 @@ public final class ShortcutConstants {
            UserShortcutType.TRIPLETAP,
            UserShortcutType.TRIPLETAP,
            UserShortcutType.TWOFINGER_DOUBLETAP,
            UserShortcutType.TWOFINGER_DOUBLETAP,
            UserShortcutType.QUICK_SETTINGS,
            UserShortcutType.QUICK_SETTINGS,
            UserShortcutType.GESTURE
            UserShortcutType.GESTURE,
            UserShortcutType.ALL
    })
    })
    public @interface UserShortcutType {
    public @interface UserShortcutType {
        int DEFAULT = 0;
        int DEFAULT = 0;
@@ -84,6 +85,7 @@ public final class ShortcutConstants {
        int QUICK_SETTINGS = 1 << 4;
        int QUICK_SETTINGS = 1 << 4;
        int GESTURE = 1 << 5;
        int GESTURE = 1 << 5;
        // LINT.ThenChange(:shortcut_type_array)
        // LINT.ThenChange(:shortcut_type_array)
        int ALL = SOFTWARE | HARDWARE | TRIPLETAP | TWOFINGER_DOUBLETAP | QUICK_SETTINGS | GESTURE;
    }
    }


    /**
    /**
+8 −0
Original line number Original line Diff line number Diff line
@@ -1062,6 +1062,14 @@
            </intent-filter>
            </intent-filter>
        </receiver>
        </receiver>


        <receiver android:name=".accessibility.extradim.ExtraDimDialogReceiver"
            android:singleUser="true"
            android:exported="false">
            <intent-filter android:priority="1">
                <action android:name="com.android.systemui.action.LAUNCH_REMOVE_EXTRA_DIM_DIALOG" />
            </intent-filter>
        </receiver>

        <activity android:name=".logcat.LogAccessDialogActivity"
        <activity android:name=".logcat.LogAccessDialogActivity"
                  android:theme="@android:style/Theme.Translucent.NoTitleBar"
                  android:theme="@android:style/Theme.Translucent.NoTitleBar"
                  android:excludeFromRecents="true"
                  android:excludeFromRecents="true"
+36 −0
Original line number Original line Diff line number Diff line
<!--
  ~ Copyright (C) 2024 The Android Open Source Project
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~      http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
        android:width="200dp"
        android:height="32dp"
        android:viewportWidth="304"
        android:viewportHeight="48">
<path
    android:pathData="M2,22L302,22A2,2 0,0 1,304 24L304,24A2,2 0,0 1,302 26L2,26A2,2 0,0 1,0 24L0,24A2,2 0,0 1,2 22z"
    android:fillColor="@color/brightness_slider_track"/>
<path
    android:pathData="M24,0L205.71,0A24,24 0,0 1,229.71 24L229.71,24A24,24 0,0 1,205.71 48L24,48A24,24 0,0 1,0 24L0,24A24,24 0,0 1,24 0z"
    android:fillColor="?attr/shadeActive"/>
<path
    android:pathData="M0,24C0,10.75 10.75,0 24,0H63.85V48H24C10.75,48 0,37.25 0,24Z"
    android:fillColor="?androidprv:attr/colorAccentPrimaryVariant"/>
<path
    android:pathData="M208.98,21.26V17.37H205.09L202.34,14.62L199.6,17.37H195.71V21.26L192.96,24L195.71,26.75V30.63H199.6L202.34,33.38L205.09,30.63H208.98V26.75L211.72,24L208.98,21.26ZM207.32,26.06V28.98H204.4L202.34,31.03L200.29,28.98H197.37V26.06L195.31,24L197.37,21.94V19.02H200.29L202.34,16.97L204.4,19.02H207.32V21.94L209.37,24L207.32,26.06ZM206.49,24C206.49,26.29 204.63,28.15 202.34,28.15V19.85C204.63,19.85 206.49,21.71 206.49,24Z"
    android:fillColor="?attr/onShadeActive"
    android:fillType="evenOdd"/>
</vector>
+41 −0
Original line number Original line Diff line number Diff line
<!--
  ~ Copyright (C) 2024 The Android Open Source Project
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~      http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/illustration_frame"
    android:orientation="vertical"
    android:paddingHorizontal="16dp"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center">

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:adjustViewBounds="true"
        android:layout_marginVertical="24dp"
        android:scaleType="fitCenter"
        android:importantForAccessibility="no"
        android:theme="@style/Theme.SystemUI.QuickSettings"
        android:src="@drawable/brightness_bar"/>
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:textSize="16sp"
        android:text="@string/accessibility_deprecate_extra_dim_dialog_description"
        android:textAppearance="@style/TextAppearance.Dialog.Body"/>
</LinearLayout>
 No newline at end of file
Loading