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

Commit 2028e7b4 authored by chenjean's avatar chenjean
Browse files

Increment TeX counters for the HCT migration about notification dismissed.

Bug: 391672253
Flag: com.android.graphics.hwui.flags.high_contrast_text_small_text_rect
Test: Ensure dismissing a notification from open settings does not trigger multiple counter increments
Change-Id: I6ddccd40427cf2364d3fb5df4efaa0b16db26133
parent 7bfa6724
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -57,6 +57,8 @@ public class HighContrastTextMigrationReceiver extends BroadcastReceiver {
    @VisibleForTesting
    static final String ACTION_OPEN_SETTINGS =
            "com.android.settings.accessibility.ACTION_OPEN_HIGH_CONTRAST_TEXT_SETTINGS";
    private static final String ACTION_NOTIFICATION_DISMISSED =
            "com.android.settings.accessibility.ACTION_HIGH_CONTRAST_TEXT_NOTIFICATION_DISMISSED";
    @VisibleForTesting
    static final int NOTIFICATION_ID = R.string.accessibility_notification_high_contrast_text_title;

@@ -87,6 +89,8 @@ public class HighContrastTextMigrationReceiver extends BroadcastReceiver {
            context.startActivity(settingsIntent);

            context.getSystemService(NotificationManager.class).cancel(NOTIFICATION_ID);
        } else if (ACTION_NOTIFICATION_DISMISSED.equals(intent.getAction())) {
            Counter.logIncrement("accessibility.value_hct_notification_dismissed");
        } else if (ACTION_RESTORED.equals(intent.getAction())) {
            Log.i(TAG, "HCT attempted to be restored from backup; showing notification for userId: "
                    + context.getUserId());
@@ -159,6 +163,13 @@ public class HighContrastTextMigrationReceiver extends BroadcastReceiver {
                    .addAction(settingsAction)
                    .setAutoCancel(true);
        }

        Intent deleteIntent = new Intent(context, HighContrastTextMigrationReceiver.class);
        deleteIntent.setAction(ACTION_NOTIFICATION_DISMISSED);
        PendingIntent deletePendingIntent = PendingIntent.getBroadcast(context, 0,
                deleteIntent, PendingIntent.FLAG_IMMUTABLE);
        notificationBuilder.setDeleteIntent(deletePendingIntent);

        NotificationManager notificationManager =
                context.getSystemService(NotificationManager.class);
        NotificationChannel notificationChannel = new NotificationChannel(