Add prompt to help troubleshoot slow notifications.

This commit is contained in:
Clark
2023-08-15 12:31:54 -04:00
committed by Cody Henthorne
parent 98ec2cceb4
commit 4cbcee85d6
16 changed files with 329 additions and 10 deletions

View File

@@ -111,6 +111,7 @@ public final class FeatureFlags {
private static final String SAFETY_NUMBER_ACI = "global.safetyNumberAci";
public static final String PROMPT_FOR_NOTIFICATION_LOGS = "android.logs.promptNotifications";
private static final String PROMPT_FOR_NOTIFICATION_CONFIG = "android.logs.promptNotificationsConfig";
public static final String PROMPT_BATTERY_SAVER = "android.promptBatterySaver";
/**
* We will only store remote values for flags in this set. If you want a flag to be controllable
@@ -173,7 +174,8 @@ public final class FeatureFlags {
SAFETY_NUMBER_ACI,
FCM_MAY_HAVE_MESSAGES_KILL_SWITCH,
PROMPT_FOR_NOTIFICATION_LOGS,
PROMPT_FOR_NOTIFICATION_CONFIG
PROMPT_FOR_NOTIFICATION_CONFIG,
PROMPT_BATTERY_SAVER
);
@VisibleForTesting
@@ -242,7 +244,8 @@ public final class FeatureFlags {
SAFETY_NUMBER_ACI,
FCM_MAY_HAVE_MESSAGES_KILL_SWITCH,
PROMPT_FOR_NOTIFICATION_LOGS,
PROMPT_FOR_NOTIFICATION_CONFIG
PROMPT_FOR_NOTIFICATION_CONFIG,
PROMPT_BATTERY_SAVER
);
/**
@@ -631,6 +634,11 @@ public final class FeatureFlags {
public static String delayedNotificationsPromptConfig() {
return getString(PROMPT_FOR_NOTIFICATION_CONFIG, "");
}
public static String promptBatterySaver() {
return getString(PROMPT_BATTERY_SAVER, "*");
}
/** Only for rendering debug info. */
public static synchronized @NonNull Map<String, Object> getMemoryValues() {
return new TreeMap<>(REMOTE_VALUES);

View File

@@ -68,6 +68,11 @@ public final class LocaleFeatureFlags {
public static boolean isDelayedNotificationPromptEnabled() {
return isEnabled(FeatureFlags.PROMPT_FOR_NOTIFICATION_LOGS, FeatureFlags.promptForDelayedNotificationLogs());
}
public static boolean isBatterySaverPromptEnabled() {
return isEnabled(FeatureFlags.PROMPT_BATTERY_SAVER, FeatureFlags.PROMPT_BATTERY_SAVER);
}
/**
* Parses a comma-separated list of country codes colon-separated from how many buckets out of 1 million
* should be enabled to see this megaphone in that country code. At the end of the list, an optional

View File

@@ -19,6 +19,13 @@ public class PowerManagerCompat {
return false;
}
public static boolean isIgnoringBatteryOptimizations(@NonNull Context context) {
if (Build.VERSION.SDK_INT < 23) {
return true;
}
return ServiceUtil.getPowerManager(context).isIgnoringBatteryOptimizations(context.getPackageName());
}
@RequiresApi(api = 23)
public static void requestIgnoreBatteryOptimizations(@NonNull Context context) {
Intent intent = new Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS,