Settings: Hide radio info if device don't support voice
Change-Id: I481485b2563fdb27b35b31fa95795db94a863f2f Signed-off-by: LynnrinChan <lynnrin@lynnrin.moe>
This commit is contained in:
@@ -96,7 +96,8 @@
|
||||
<Preference
|
||||
android:title="@string/radio_info_title"
|
||||
android:key="radio_info_settings"
|
||||
android:order="6">
|
||||
android:order="6"
|
||||
settings:controller="com.android.settings.deviceinfo.RadioInfoPreferenceController">
|
||||
<intent android:action="android.intent.action.MAIN"
|
||||
android:targetPackage="com.android.phone"
|
||||
android:targetClass="com.android.phone.settings.RadioInfo" />
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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.deviceinfo;
|
||||
|
||||
import android.content.Context;
|
||||
import android.telephony.TelephonyManager;
|
||||
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
|
||||
public class RadioInfoPreferenceController extends BasePreferenceController {
|
||||
|
||||
private TelephonyManager mTelephonyManager;
|
||||
|
||||
public RadioInfoPreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
mTelephonyManager = mContext.getSystemService(TelephonyManager.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void displayPreference(PreferenceScreen screen) {
|
||||
super.displayPreference(screen);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return mTelephonyManager.isVoiceCapable()
|
||||
? AVAILABLE
|
||||
: UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user