use of com.android.settingslib.bluetooth.PbapServerProfile in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class DeviceProfilesSettings method refreshProfiles.
private void refreshProfiles() {
for (LocalBluetoothProfile profile : mCachedDevice.getConnectableProfiles()) {
CheckBox profilePref = findProfile(profile.toString());
if (profilePref == null) {
profilePref = createProfilePreference(profile);
mProfileContainer.addView(profilePref);
} else {
refreshProfilePreference(profilePref, profile);
}
}
for (LocalBluetoothProfile profile : mCachedDevice.getRemovedProfiles()) {
CheckBox profilePref = findProfile(profile.toString());
if (profilePref != null) {
if (profile instanceof PbapServerProfile) {
final int pbapPermission = mCachedDevice.getPhonebookPermissionChoice();
Log.d(TAG, "refreshProfiles: pbapPermission = " + pbapPermission);
if (pbapPermission != CachedBluetoothDevice.ACCESS_UNKNOWN)
continue;
}
if (profile instanceof MapProfile) {
final int mapPermission = mCachedDevice.getMessagePermissionChoice();
Log.d(TAG, "refreshProfiles: mapPermission = " + mapPermission);
if (mapPermission != CachedBluetoothDevice.ACCESS_UNKNOWN)
continue;
}
Log.d(TAG, "Removing " + profile.toString() + " from profile list");
mProfileContainer.removeView(profilePref);
}
}
showOrHideProfileGroup();
}
use of com.android.settingslib.bluetooth.PbapServerProfile in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class DeviceProfilesSettings method onProfileClicked.
private void onProfileClicked(LocalBluetoothProfile profile, CheckBox profilePref) {
BluetoothDevice device = mCachedDevice.getDevice();
if (!profilePref.isChecked()) {
// Recheck it, until the dialog is done.
profilePref.setChecked(true);
askDisconnect(mManager.getForegroundActivity(), profile);
} else {
if (profile instanceof MapProfile) {
mCachedDevice.setMessagePermissionChoice(BluetoothDevice.ACCESS_ALLOWED);
}
if (profile instanceof PbapServerProfile) {
mCachedDevice.setPhonebookPermissionChoice(BluetoothDevice.ACCESS_ALLOWED);
refreshProfilePreference(profilePref, profile);
return;
}
if (profile.isPreferred(device)) {
// profile is preferred but not connected: disable auto-connect
if (profile instanceof PanProfile) {
mCachedDevice.connectProfile(profile);
} else {
profile.setPreferred(device, false);
}
} else {
profile.setPreferred(device, true);
mCachedDevice.connectProfile(profile);
}
refreshProfilePreference(profilePref, profile);
}
}
use of com.android.settingslib.bluetooth.PbapServerProfile in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class DeviceProfilesSettings method addPreferencesForProfiles.
private void addPreferencesForProfiles() {
mProfileContainer.removeAllViews();
for (LocalBluetoothProfile profile : mCachedDevice.getConnectableProfiles()) {
// MAP and PBAP profiles would be added based on permission access
if (!((profile instanceof PbapServerProfile) || (profile instanceof MapProfile))) {
CheckBox pref = createProfilePreference(profile);
mProfileContainer.addView(pref);
}
}
final int pbapPermission = mCachedDevice.getPhonebookPermissionChoice();
Log.d(TAG, "addPreferencesForProfiles: pbapPermission = " + pbapPermission);
// Only provide PBAP cabability if the client device has requested PBAP.
if (pbapPermission != CachedBluetoothDevice.ACCESS_UNKNOWN) {
final PbapServerProfile psp = mManager.getProfileManager().getPbapProfile();
CheckBox pbapPref = createProfilePreference(psp);
mProfileContainer.addView(pbapPref);
}
final MapProfile mapProfile = mManager.getProfileManager().getMapProfile();
final int mapPermission = mCachedDevice.getMessagePermissionChoice();
Log.d(TAG, "addPreferencesForProfiles: mapPermission = " + mapPermission);
if (mapPermission != CachedBluetoothDevice.ACCESS_UNKNOWN) {
CheckBox mapPreference = createProfilePreference(mapProfile);
mProfileContainer.addView(mapPreference);
}
showOrHideProfileGroup();
}
use of com.android.settingslib.bluetooth.PbapServerProfile in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class DeviceProfilesSettings method refreshProfilePreference.
private void refreshProfilePreference(CheckBox profilePref, LocalBluetoothProfile profile) {
BluetoothDevice device = mCachedDevice.getDevice();
// Gray out checkbox while connecting and disconnecting.
profilePref.setEnabled(!mCachedDevice.isBusy());
if (profile instanceof MapProfile) {
profilePref.setChecked(mCachedDevice.getMessagePermissionChoice() == CachedBluetoothDevice.ACCESS_ALLOWED);
} else if (profile instanceof PbapServerProfile) {
profilePref.setChecked(mCachedDevice.getPhonebookPermissionChoice() == CachedBluetoothDevice.ACCESS_ALLOWED);
} else if (profile instanceof PanProfile) {
profilePref.setChecked(profile.getConnectionStatus(device) == BluetoothProfile.STATE_CONNECTED);
} else {
profilePref.setChecked(profile.isPreferred(device));
}
}
use of com.android.settingslib.bluetooth.PbapServerProfile in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class DeviceProfilesSettings method askDisconnect.
private void askDisconnect(Context context, final LocalBluetoothProfile profile) {
// local reference for callback
final CachedBluetoothDevice device = mCachedDevice;
String name = device.getName();
if (TextUtils.isEmpty(name)) {
name = context.getString(R.string.bluetooth_device);
}
String profileName = context.getString(profile.getNameResource(device.getDevice()));
String title = context.getString(R.string.bluetooth_disable_profile_title);
String message = context.getString(R.string.bluetooth_disable_profile_message, profileName, name);
DialogInterface.OnClickListener disconnectListener = new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// Disconnect only when user has selected OK
if (which == OK_BUTTON) {
device.disconnect(profile);
profile.setPreferred(device.getDevice(), false);
if (profile instanceof MapProfile) {
device.setMessagePermissionChoice(BluetoothDevice.ACCESS_REJECTED);
}
if (profile instanceof PbapServerProfile) {
device.setPhonebookPermissionChoice(BluetoothDevice.ACCESS_REJECTED);
}
}
refreshProfilePreference(findProfile(profile.toString()), profile);
}
};
mDisconnectDialog = Utils.showDisconnectDialog(context, mDisconnectDialog, disconnectListener, title, Html.fromHtml(message));
}
Aggregations