Move isolatable bluetooth code to SettingsLib
Move the non-ui bluetooth control/tracking code to SettingsLib so that it can be shared with others. Mostly just move classes to frameworks/base/packages/SettingsLib, however a few things had to move around. - Dock handling had to move back to code still in settings - Local preference related code had to be moved back to settings - Added an error flow from SettingsLib to Settings Depends on I69fd888362c6dbb325f6113b32c4b15cc6a23a41 Bug: 19180466 Change-Id: Ie57fe26a27bbb0adc2ef69e042a05c7290c6a52a
This commit is contained in:
@@ -17,24 +17,27 @@
|
||||
package com.android.settings.bluetooth;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.bluetooth.BluetoothClass;
|
||||
import android.bluetooth.BluetoothProfile;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.bluetooth.DockService.DockBluetoothCallback;
|
||||
import com.android.settings.search.Index;
|
||||
import com.android.settings.search.SearchIndexableRaw;
|
||||
import com.android.settingslib.bluetooth.LocalBluetoothManager;
|
||||
import com.android.settingslib.bluetooth.LocalBluetoothManager.BluetoothManagerCallback;
|
||||
import com.android.settingslib.bluetooth.Utils.ErrorListener;
|
||||
|
||||
/**
|
||||
* Utils is a helper class that contains constants for various
|
||||
* Android resource IDs, debug logging flags, and static methods
|
||||
* for creating dialogs.
|
||||
*/
|
||||
final class Utils {
|
||||
static final boolean V = false; // verbose logging
|
||||
static final boolean D = true; // regular logging
|
||||
public final class Utils {
|
||||
static final boolean V = com.android.settingslib.bluetooth.Utils.V; // verbose logging
|
||||
static final boolean D = com.android.settingslib.bluetooth.Utils.D; // regular logging
|
||||
|
||||
private Utils() {
|
||||
}
|
||||
@@ -91,7 +94,7 @@ final class Utils {
|
||||
|
||||
static void showError(Context context, String name, int messageResId) {
|
||||
String message = context.getString(messageResId, name);
|
||||
LocalBluetoothManager manager = LocalBluetoothManager.getInstance(context);
|
||||
LocalBluetoothManager manager = getLocalBtManager(context);
|
||||
Context activity = manager.getForegroundActivity();
|
||||
if(manager.isForegroundActivity()) {
|
||||
new AlertDialog.Builder(activity)
|
||||
@@ -118,4 +121,25 @@ final class Utils {
|
||||
|
||||
Index.getInstance(context).updateFromSearchIndexableData(data);
|
||||
}
|
||||
|
||||
public static LocalBluetoothManager getLocalBtManager(Context context) {
|
||||
return LocalBluetoothManager.getInstance(context, mOnInitCallback);
|
||||
}
|
||||
|
||||
private static final ErrorListener mErrorListener = new ErrorListener() {
|
||||
@Override
|
||||
public void onShowError(Context context, String name, int messageResId) {
|
||||
showError(context, name, messageResId);
|
||||
}
|
||||
};
|
||||
|
||||
private static final BluetoothManagerCallback mOnInitCallback = new BluetoothManagerCallback() {
|
||||
@Override
|
||||
public void onBluetoothManagerInitialized(Context appContext,
|
||||
LocalBluetoothManager bluetoothManager) {
|
||||
bluetoothManager.getEventManager().registerCallback(
|
||||
new DockBluetoothCallback(appContext));
|
||||
com.android.settingslib.bluetooth.Utils.setErrorListener(mErrorListener);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user