Disable bluetooth controller if unsupported
Only disable the controllers not the whole fragment because user might need to have entry for other features. Change-Id: I9c44cca97189a2115785cf70aee8eb580ac56000 Fixes: 73664409 Signed-off-by: Weilun Du <wdu@google.com>
This commit is contained in:
@@ -16,12 +16,14 @@
|
||||
|
||||
package com.android.settings.bluetooth;
|
||||
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.support.annotation.VisibleForTesting;
|
||||
import android.support.v7.preference.Preference;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.core.PreferenceControllerMixin;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
@@ -30,7 +32,7 @@ import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
||||
/**
|
||||
* Controller that shows received files
|
||||
*/
|
||||
public class BluetoothFilesPreferenceController extends AbstractPreferenceController
|
||||
public class BluetoothFilesPreferenceController extends BasePreferenceController
|
||||
implements PreferenceControllerMixin {
|
||||
private static final String TAG = "BluetoothFilesPrefCtrl";
|
||||
|
||||
@@ -47,13 +49,15 @@ public class BluetoothFilesPreferenceController extends AbstractPreferenceContro
|
||||
private MetricsFeatureProvider mMetricsFeatureProvider;
|
||||
|
||||
public BluetoothFilesPreferenceController(Context context) {
|
||||
super(context);
|
||||
super(context, KEY_RECEIVED_FILES);
|
||||
mMetricsFeatureProvider = FeatureFactory.getFactory(context).getMetricsFeatureProvider();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
return true;
|
||||
public int getAvailabilityStatus() {
|
||||
return mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)
|
||||
? AVAILABLE
|
||||
: DISABLED_UNSUPPORTED;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -23,6 +23,7 @@ import android.bluetooth.BluetoothDevice;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.VisibleForTesting;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.settings.R;
|
||||
@@ -71,7 +72,10 @@ public class BluetoothPairingDetail extends DeviceListPreferenceFragment impleme
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
|
||||
if (mLocalManager == null){
|
||||
Log.e(TAG, "Bluetooth is not supported on this device");
|
||||
return;
|
||||
}
|
||||
updateBluetooth();
|
||||
mAvailableDevicesCategory.setProgress(mLocalAdapter.isDiscovering());
|
||||
}
|
||||
@@ -89,7 +93,10 @@ public class BluetoothPairingDetail extends DeviceListPreferenceFragment impleme
|
||||
@Override
|
||||
public void onStop() {
|
||||
super.onStop();
|
||||
|
||||
if (mLocalManager == null){
|
||||
Log.e(TAG, "Bluetooth is not supported on this device");
|
||||
return;
|
||||
}
|
||||
// Make the device only visible to connected devices.
|
||||
mAlwaysDiscoverable.stop();
|
||||
disableScanning();
|
||||
|
||||
Reference in New Issue
Block a user