use of com.android.settingslib.bluetooth.LocalBluetoothManager in project platform_packages_apps_Settings by BlissRoms.
the class RequestPermissionHelperActivity method parseIntent.
/**
* Parse the received Intent and initialize mLocalBluetoothAdapter.
* @return true if an error occurred; false otherwise
*/
private boolean parseIntent() {
Intent intent = getIntent();
if (intent == null) {
return false;
}
String action = intent.getAction();
if (ACTION_INTERNAL_REQUEST_BT_ON.equals(action)) {
mRequest = RequestPermissionActivity.REQUEST_ENABLE;
if (intent.hasExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION)) {
// Value used for display purposes. Not range checking.
mTimeout = intent.getIntExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, BluetoothDiscoverableEnabler.DEFAULT_DISCOVERABLE_TIMEOUT);
}
} else if (ACTION_INTERNAL_REQUEST_BT_OFF.equals(action)) {
mRequest = RequestPermissionActivity.REQUEST_DISABLE;
} else {
return false;
}
LocalBluetoothManager manager = Utils.getLocalBtManager(this);
if (manager == null) {
Log.e(TAG, "Error: there's a problem starting Bluetooth");
return false;
}
mAppLabel = getIntent().getCharSequenceExtra(EXTRA_APP_LABEL);
mLocalAdapter = manager.getBluetoothAdapter();
return true;
}
use of com.android.settingslib.bluetooth.LocalBluetoothManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class BluetoothDevicesSlice method getConnectedBluetoothDevices.
@VisibleForTesting
List<CachedBluetoothDevice> getConnectedBluetoothDevices() {
final List<CachedBluetoothDevice> bluetoothDeviceList = new ArrayList<>();
// If Bluetooth is disable, skip to get the Bluetooth devices.
if (!BluetoothAdapter.getDefaultAdapter().isEnabled()) {
Log.i(TAG, "Cannot get Bluetooth devices, Bluetooth is disabled.");
return bluetoothDeviceList;
}
// Get the Bluetooth devices from LocalBluetoothManager.
final LocalBluetoothManager bluetoothManager = com.android.settings.bluetooth.Utils.getLocalBtManager(mContext);
if (bluetoothManager == null) {
Log.i(TAG, "Cannot get Bluetooth devices, Bluetooth is unsupported.");
return bluetoothDeviceList;
}
final Collection<CachedBluetoothDevice> cachedDevices = bluetoothManager.getCachedDeviceManager().getCachedDevicesCopy();
// Get all connected devices and sort them.
return cachedDevices.stream().filter(device -> device.getDevice().isConnected()).sorted(COMPARATOR).collect(Collectors.toList());
}
use of com.android.settingslib.bluetooth.LocalBluetoothManager in project platform_frameworks_base by android.
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();
}
use of com.android.settingslib.bluetooth.LocalBluetoothManager in project android_frameworks_base by ResurrectionRemix.
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();
}
use of com.android.settingslib.bluetooth.LocalBluetoothManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class BluetoothPermissionActivity method onNegative.
private void onNegative() {
if (DEBUG)
Log.d(TAG, "onNegative");
boolean always = true;
if (mRequestType == BluetoothDevice.REQUEST_TYPE_MESSAGE_ACCESS) {
LocalBluetoothManager bluetoothManager = Utils.getLocalBtManager(this);
CachedBluetoothDeviceManager cachedDeviceManager = bluetoothManager.getCachedDeviceManager();
CachedBluetoothDevice cachedDevice = cachedDeviceManager.findDevice(mDevice);
if (cachedDevice == null) {
cachedDevice = cachedDeviceManager.addDevice(bluetoothManager.getBluetoothAdapter(), bluetoothManager.getProfileManager(), mDevice);
}
always = cachedDevice.checkAndIncreaseMessageRejectionCount();
}
sendReplyIntentToReceiver(false, always);
}
Aggregations