Search in sources :

Example 1 with LocalBluetoothManager

use of com.android.settingslib.bluetooth.LocalBluetoothManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class Utils method showError.

static void showError(Context context, String name, int messageResId) {
    String message = context.getString(messageResId, name);
    LocalBluetoothManager manager = getLocalBtManager(context);
    Context activity = manager.getForegroundActivity();
    if (manager.isForegroundActivity()) {
        new AlertDialog.Builder(activity).setTitle(R.string.bluetooth_error_title).setMessage(message).setPositiveButton(android.R.string.ok, null).show();
    } else {
        Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
    }
}
Also used : Context(android.content.Context) LocalBluetoothManager(com.android.settingslib.bluetooth.LocalBluetoothManager)

Example 2 with LocalBluetoothManager

use of com.android.settingslib.bluetooth.LocalBluetoothManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class DockService method onCreate.

@Override
public void onCreate() {
    if (DEBUG)
        Log.d(TAG, "onCreate");
    LocalBluetoothManager manager = Utils.getLocalBtManager(this);
    if (manager == null) {
        Log.e(TAG, "Can't get LocalBluetoothManager: exiting");
        return;
    }
    mLocalAdapter = manager.getBluetoothAdapter();
    mDeviceManager = manager.getCachedDeviceManager();
    mProfileManager = manager.getProfileManager();
    if (mProfileManager == null) {
        Log.e(TAG, "Can't get LocalBluetoothProfileManager: exiting");
        return;
    }
    HandlerThread thread = new HandlerThread("DockService");
    thread.start();
    mServiceLooper = thread.getLooper();
    mServiceHandler = new ServiceHandler(mServiceLooper);
}
Also used : HandlerThread(android.os.HandlerThread) LocalBluetoothManager(com.android.settingslib.bluetooth.LocalBluetoothManager)

Example 3 with LocalBluetoothManager

use of com.android.settingslib.bluetooth.LocalBluetoothManager in project android_frameworks_base by crdroidandroid.

the class KeyboardUI method init.

// Shoud only be called on the handler thread
private void init() {
    Context context = mContext;
    mKeyboardName = context.getString(com.android.internal.R.string.config_packagedKeyboardName);
    if (TextUtils.isEmpty(mKeyboardName)) {
        if (DEBUG) {
            Slog.d(TAG, "No packaged keyboard name given.");
        }
        return;
    }
    LocalBluetoothManager bluetoothManager = LocalBluetoothManager.getInstance(context, null);
    if (bluetoothManager == null) {
        if (DEBUG) {
            Slog.e(TAG, "Failed to retrieve LocalBluetoothManager instance");
        }
        return;
    }
    mEnabled = true;
    mCachedDeviceManager = bluetoothManager.getCachedDeviceManager();
    mLocalBluetoothAdapter = bluetoothManager.getBluetoothAdapter();
    mProfileManager = bluetoothManager.getProfileManager();
    bluetoothManager.getEventManager().registerCallback(new BluetoothCallbackHandler());
    Utils.setErrorListener(new BluetoothErrorListener());
    InputManager im = context.getSystemService(InputManager.class);
    im.registerOnTabletModeChangedListener(this, mHandler);
    mInTabletMode = im.isInTabletMode();
    processKeyboardState();
    mUIHandler = new KeyboardUIHandler();
}
Also used : Context(android.content.Context) LocalBluetoothManager(com.android.settingslib.bluetooth.LocalBluetoothManager) InputManager(android.hardware.input.InputManager)

Example 4 with LocalBluetoothManager

use of com.android.settingslib.bluetooth.LocalBluetoothManager in project android_frameworks_base by AOSPA.

the class KeyboardUI method init.

// Shoud only be called on the handler thread
private void init() {
    Context context = mContext;
    mKeyboardName = context.getString(com.android.internal.R.string.config_packagedKeyboardName);
    if (TextUtils.isEmpty(mKeyboardName)) {
        if (DEBUG) {
            Slog.d(TAG, "No packaged keyboard name given.");
        }
        return;
    }
    LocalBluetoothManager bluetoothManager = LocalBluetoothManager.getInstance(context, null);
    if (bluetoothManager == null) {
        if (DEBUG) {
            Slog.e(TAG, "Failed to retrieve LocalBluetoothManager instance");
        }
        return;
    }
    mEnabled = true;
    mCachedDeviceManager = bluetoothManager.getCachedDeviceManager();
    mLocalBluetoothAdapter = bluetoothManager.getBluetoothAdapter();
    mProfileManager = bluetoothManager.getProfileManager();
    bluetoothManager.getEventManager().registerCallback(new BluetoothCallbackHandler());
    Utils.setErrorListener(new BluetoothErrorListener());
    InputManager im = context.getSystemService(InputManager.class);
    im.registerOnTabletModeChangedListener(this, mHandler);
    mInTabletMode = im.isInTabletMode();
    processKeyboardState();
    mUIHandler = new KeyboardUIHandler();
}
Also used : Context(android.content.Context) LocalBluetoothManager(com.android.settingslib.bluetooth.LocalBluetoothManager) InputManager(android.hardware.input.InputManager)

Example 5 with LocalBluetoothManager

use of com.android.settingslib.bluetooth.LocalBluetoothManager in project android_packages_apps_Settings by LineageOS.

the class LocalDeviceNameDialogFragment method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    LocalBluetoothManager localManager = Utils.getLocalBtManager(getActivity());
    mLocalAdapter = localManager.getBluetoothAdapter();
}
Also used : LocalBluetoothManager(com.android.settingslib.bluetooth.LocalBluetoothManager)

Aggregations

LocalBluetoothManager (com.android.settingslib.bluetooth.LocalBluetoothManager)61 CachedBluetoothDevice (com.android.settingslib.bluetooth.CachedBluetoothDevice)29 BluetoothDevice (android.bluetooth.BluetoothDevice)14 CachedBluetoothDeviceManager (com.android.settingslib.bluetooth.CachedBluetoothDeviceManager)14 VisibleForTesting (com.android.internal.annotations.VisibleForTesting)13 Intent (android.content.Intent)12 SharedPreferences (android.content.SharedPreferences)7 Context (android.content.Context)6 ApplicationInfo (android.content.pm.ApplicationInfo)6 PackageManager (android.content.pm.PackageManager)6 LocalBluetoothAdapter (com.android.settingslib.bluetooth.LocalBluetoothAdapter)6 InputManager (android.hardware.input.InputManager)5 VisibleForTesting (androidx.annotation.VisibleForTesting)2 BluetoothAdapter (android.bluetooth.BluetoothAdapter)1 HandlerThread (android.os.HandlerThread)1 ArrayList (java.util.ArrayList)1