Some devices don't support bubbles by configuring config_supportsBubble value. When the value is set false, it doesn't make sense to show bubble related preferences. This CL disables showing bubble preferences when device doesn't support it. Bug: 274711609 Test: Set config_supportsBubble false, and check UI. Test: m -j80 RunSettingsRoboTests ROBOTEST_FILTER="Bubble" Change-Id: I670ad2a9e243819ea014e5e1ddb9d62ad76d2168
66 lines
2.0 KiB
Java
66 lines
2.0 KiB
Java
/*
|
|
* Copyright 2023 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.
|
|
*/
|
|
|
|
package com.android.settings.notification;
|
|
|
|
import static android.provider.Settings.Secure.NOTIFICATION_BUBBLES;
|
|
|
|
import android.app.ActivityManager;
|
|
import android.content.Context;
|
|
import android.content.res.Resources;
|
|
import android.provider.Settings;
|
|
|
|
/**
|
|
* Helper class for configuring notification bubbles.
|
|
*/
|
|
public class BubbleHelper {
|
|
|
|
/**
|
|
* {@link Settings.Secure.NOTIFICATION_BUBBLES} is enabled.
|
|
*/
|
|
public static final int SYSTEM_WIDE_ON = 1;
|
|
|
|
/**
|
|
* {@link Settings.Secure.NOTIFICATION_BUBBLES} is disabled.
|
|
*/
|
|
public static final int SYSTEM_WIDE_OFF = 0;
|
|
|
|
/**
|
|
* Returns true if the device supports bubbles.
|
|
*/
|
|
public static boolean isSupportedByDevice(Context context) {
|
|
ActivityManager am = context.getSystemService(ActivityManager.class);
|
|
if (am.isLowRamDevice()) {
|
|
return false;
|
|
}
|
|
if (!Resources.getSystem().getBoolean(com.android.internal.R.bool.config_supportsBubble)) {
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Returns true if the device supports bubbles and the global settings is enabled.
|
|
*/
|
|
public static boolean isEnabledSystemWide(Context context) {
|
|
if (!isSupportedByDevice(context)) {
|
|
return false;
|
|
}
|
|
return Settings.Secure.getInt(context.getContentResolver(), NOTIFICATION_BUBBLES,
|
|
SYSTEM_WIDE_ON) == SYSTEM_WIDE_ON;
|
|
}
|
|
}
|