Search in sources :

Example 1 with CachedBluetoothDeviceManager

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

the class BluetoothPermissionRequest method checkUserChoice.

/**
     * @return true user had made a choice, this method replies to the request according
     *              to user's previous decision
     *         false user hadnot made any choice on this device
     */
private boolean checkUserChoice() {
    boolean processed = false;
    // ignore if it is something else than phonebook/message settings it wants us to remember
    if (mRequestType != BluetoothDevice.REQUEST_TYPE_PHONEBOOK_ACCESS && mRequestType != BluetoothDevice.REQUEST_TYPE_MESSAGE_ACCESS && mRequestType != BluetoothDevice.REQUEST_TYPE_SIM_ACCESS) {
        if (DEBUG)
            Log.d(TAG, "checkUserChoice(): Unknown RequestType " + mRequestType);
        return processed;
    }
    LocalBluetoothManager bluetoothManager = Utils.getLocalBtManager(mContext);
    CachedBluetoothDeviceManager cachedDeviceManager = bluetoothManager.getCachedDeviceManager();
    CachedBluetoothDevice cachedDevice = cachedDeviceManager.findDevice(mDevice);
    if (cachedDevice == null) {
        cachedDevice = cachedDeviceManager.addDevice(bluetoothManager.getBluetoothAdapter(), bluetoothManager.getProfileManager(), mDevice);
    }
    String intentName = BluetoothDevice.ACTION_CONNECTION_ACCESS_REPLY;
    if (mRequestType == BluetoothDevice.REQUEST_TYPE_PHONEBOOK_ACCESS) {
        int phonebookPermission = cachedDevice.getPhonebookPermissionChoice();
        if (phonebookPermission == CachedBluetoothDevice.ACCESS_UNKNOWN) {
        // Leave 'processed' as false.
        } else if (phonebookPermission == CachedBluetoothDevice.ACCESS_ALLOWED) {
            sendReplyIntentToReceiver(true);
            processed = true;
        } else if (phonebookPermission == CachedBluetoothDevice.ACCESS_REJECTED) {
            sendReplyIntentToReceiver(false);
            processed = true;
        } else {
            Log.e(TAG, "Bad phonebookPermission: " + phonebookPermission);
        }
    } else if (mRequestType == BluetoothDevice.REQUEST_TYPE_MESSAGE_ACCESS) {
        int messagePermission = cachedDevice.getMessagePermissionChoice();
        if (messagePermission == CachedBluetoothDevice.ACCESS_UNKNOWN) {
        // Leave 'processed' as false.
        } else if (messagePermission == CachedBluetoothDevice.ACCESS_ALLOWED) {
            sendReplyIntentToReceiver(true);
            processed = true;
        } else if (messagePermission == CachedBluetoothDevice.ACCESS_REJECTED) {
            sendReplyIntentToReceiver(false);
            processed = true;
        } else {
            Log.e(TAG, "Bad messagePermission: " + messagePermission);
        }
    } else if (mRequestType == BluetoothDevice.REQUEST_TYPE_SIM_ACCESS) {
        int simPermission = cachedDevice.getSimPermissionChoice();
        if (simPermission == CachedBluetoothDevice.ACCESS_UNKNOWN) {
        // Leave 'processed' as false.
        } else if (simPermission == CachedBluetoothDevice.ACCESS_ALLOWED) {
            sendReplyIntentToReceiver(true);
            processed = true;
        } else if (simPermission == CachedBluetoothDevice.ACCESS_REJECTED) {
            sendReplyIntentToReceiver(false);
            processed = true;
        } else {
            Log.e(TAG, "Bad simPermission: " + simPermission);
        }
    }
    if (DEBUG)
        Log.d(TAG, "checkUserChoice(): returning " + processed);
    return processed;
}
Also used : CachedBluetoothDeviceManager(com.android.settingslib.bluetooth.CachedBluetoothDeviceManager) CachedBluetoothDevice(com.android.settingslib.bluetooth.CachedBluetoothDevice) LocalBluetoothManager(com.android.settingslib.bluetooth.LocalBluetoothManager)

Example 2 with CachedBluetoothDeviceManager

use of com.android.settingslib.bluetooth.CachedBluetoothDeviceManager 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);
}
Also used : CachedBluetoothDeviceManager(com.android.settingslib.bluetooth.CachedBluetoothDeviceManager) CachedBluetoothDevice(com.android.settingslib.bluetooth.CachedBluetoothDevice) LocalBluetoothManager(com.android.settingslib.bluetooth.LocalBluetoothManager)

Example 3 with CachedBluetoothDeviceManager

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

the class DeviceProfilesSettings method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mManager = Utils.getLocalBtManager(getActivity());
    CachedBluetoothDeviceManager deviceManager = mManager.getCachedDeviceManager();
    String address = getArguments().getString(ARG_DEVICE_ADDRESS);
    BluetoothDevice remoteDevice = mManager.getBluetoothAdapter().getRemoteDevice(address);
    mCachedDevice = deviceManager.findDevice(remoteDevice);
    if (mCachedDevice == null) {
        mCachedDevice = deviceManager.addDevice(mManager.getBluetoothAdapter(), mManager.getProfileManager(), remoteDevice);
    }
    mProfileManager = mManager.getProfileManager();
}
Also used : CachedBluetoothDeviceManager(com.android.settingslib.bluetooth.CachedBluetoothDeviceManager) BluetoothDevice(android.bluetooth.BluetoothDevice) CachedBluetoothDevice(com.android.settingslib.bluetooth.CachedBluetoothDevice)

Aggregations

CachedBluetoothDevice (com.android.settingslib.bluetooth.CachedBluetoothDevice)3 CachedBluetoothDeviceManager (com.android.settingslib.bluetooth.CachedBluetoothDeviceManager)3 LocalBluetoothManager (com.android.settingslib.bluetooth.LocalBluetoothManager)2 BluetoothDevice (android.bluetooth.BluetoothDevice)1