SystemUI: TunerActivity: Remove icon toggles if not supported

Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
This commit is contained in:
Pranav Vashi
2025-11-15 05:31:26 +05:30
committed by Zabuka_zuzu
parent e1668a7343
commit eb72f6870d

View File

@@ -15,9 +15,13 @@
*/
package com.android.systemui.tuner;
import android.content.Context;
import android.os.Bundle;
import android.telephony.TelephonyManager;
import androidx.annotation.Nullable;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
@@ -32,6 +36,35 @@ public class StatusBarTuner extends SettingsBasePreferenceFragment {
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
addPreferencesFromResource(R.xml.status_bar_prefs);
if (!isVoiceCapable(requireContext())) {
removeMobilePreferences();
}
}
public static boolean isVoiceCapable(Context context) {
TelephonyManager telephony =
(TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
return telephony != null && telephony.isVoiceCapable();
}
private void removeMobilePreferences() {
String[] mobileKeys = new String[] {
"mobile",
"system:data_disabled_icon",
"call_strength",
"roaming",
"system:show_fourg_icon",
"status_bar_show_hd_calling",
"status_bar_show_vowifi"
};
PreferenceScreen screen = getPreferenceScreen();
for (String key : mobileKeys) {
Preference pref = findPreference(key);
if (pref != null) {
screen.removePreference(pref);
}
}
}
@Override