Disable bubbles for low ram devices

Fixes: 167677013
Test: set low ram true => bubble settings hidden
Test: make -j80 RunSettingsRoboTests ROBOTEST_FILTER="Bubble"

Change-Id: I1c40a05404ea7c78cc82102b33e4bc3cb3528075
This commit is contained in:
Lyn Han
2020-09-17 12:02:47 -07:00
parent f537a702dd
commit 29559b1645
8 changed files with 103 additions and 5 deletions

View File

@@ -18,6 +18,7 @@ package com.android.settings.notification;
import static android.provider.Settings.Global.NOTIFICATION_BUBBLES;
import android.app.ActivityManager;
import android.content.ContentResolver;
import android.content.Context;
import android.database.ContentObserver;
@@ -81,7 +82,8 @@ public class BubbleNotificationPreferenceController extends TogglePreferenceCont
@Override
public int getAvailabilityStatus() {
return AVAILABLE;
ActivityManager am = mContext.getSystemService(ActivityManager.class);
return am.isLowRamDevice() ? UNSUPPORTED_ON_DEVICE : AVAILABLE;
}
@Override

View File

@@ -18,6 +18,7 @@ package com.android.settings.notification;
import static android.provider.Settings.Global.NOTIFICATION_BUBBLES;
import android.app.ActivityManager;
import android.content.Context;
import android.provider.Settings;
@@ -48,7 +49,8 @@ public class BubbleSummaryNotificationPreferenceController extends BasePreferenc
@Override
public int getAvailabilityStatus() {
return AVAILABLE;
ActivityManager am = mContext.getSystemService(ActivityManager.class);
return am.isLowRamDevice() ? UNSUPPORTED_ON_DEVICE : AVAILABLE;
}
private boolean areBubblesEnabled() {

View File

@@ -19,6 +19,7 @@ package com.android.settings.notification.app;
import static android.app.NotificationManager.BUBBLE_PREFERENCE_NONE;
import static android.provider.Settings.Global.NOTIFICATION_BUBBLES;
import android.app.ActivityManager;
import android.annotation.Nullable;
import android.content.Context;
import android.provider.Settings;
@@ -139,7 +140,8 @@ public class BubblePreferenceController extends NotificationPreferenceController
}
private boolean isGloballyEnabled() {
return Settings.Global.getInt(mContext.getContentResolver(),
ActivityManager am = mContext.getSystemService(ActivityManager.class);
return !am.isLowRamDevice() && Settings.Global.getInt(mContext.getContentResolver(),
NOTIFICATION_BUBBLES, SYSTEM_WIDE_OFF) == SYSTEM_WIDE_ON;
}

View File

@@ -20,6 +20,7 @@ import static android.app.NotificationManager.BUBBLE_PREFERENCE_ALL;
import static android.app.NotificationManager.BUBBLE_PREFERENCE_NONE;
import static android.provider.Settings.Global.NOTIFICATION_BUBBLES;
import android.app.ActivityManager;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
@@ -99,7 +100,8 @@ public class BubbleSummaryPreferenceController extends NotificationPreferenceCon
}
private boolean isGloballyEnabled() {
return Settings.Global.getInt(mContext.getContentResolver(),
ActivityManager am = mContext.getSystemService(ActivityManager.class);
return !am.isLowRamDevice() && Settings.Global.getInt(mContext.getContentResolver(),
NOTIFICATION_BUBBLES, ON) == ON;
}
}