use of com.android.settingslib.bluetooth.LocalBluetoothProfile in project android_packages_apps_Settings by SudaMod.
the class BluetoothDetailsProfilesControllerTest method addFakeProfile.
/**
* Creates and adds a mock LocalBluetoothProfile to the list of connectable profiles for the
* device.
* @param profileNameResId the resource id for the name used by this profile
* @param deviceIsPreferred whether this profile should start out as enabled for the device
*/
private LocalBluetoothProfile addFakeProfile(int profileNameResId, boolean deviceIsPreferred) {
LocalBluetoothProfile profile = new FakeBluetoothProfile(mContext, profileNameResId);
profile.setPreferred(mDevice, deviceIsPreferred);
mConnectableProfiles.add(profile);
when(mProfileManager.getProfileByName(eq(profile.toString()))).thenReturn(profile);
return profile;
}
use of com.android.settingslib.bluetooth.LocalBluetoothProfile in project android_packages_apps_Settings by SudaMod.
the class BluetoothDetailsProfilesController method onPreferenceClick.
/**
* When the pref for a bluetooth profile is clicked on, we want to toggle the enabled/disabled
* state for that profile.
*/
@Override
public boolean onPreferenceClick(Preference preference) {
LocalBluetoothProfile profile = mProfileManager.getProfileByName(preference.getKey());
if (profile == null) {
// It might be the PbapServerProfile, which is not stored by name.
PbapServerProfile psp = mManager.getProfileManager().getPbapProfile();
if (TextUtils.equals(preference.getKey(), psp.toString())) {
profile = psp;
} else {
return false;
}
}
SwitchPreference profilePref = (SwitchPreference) preference;
BluetoothDevice device = mCachedDevice.getDevice();
if (profilePref.isChecked()) {
enableProfile(profile, device, profilePref);
} else {
disableProfile(profile, device, profilePref);
}
refreshProfilePreference(profilePref, profile);
return true;
}
use of com.android.settingslib.bluetooth.LocalBluetoothProfile in project android_packages_apps_Settings by SudaMod.
the class BluetoothDetailsProfilesController method refresh.
/**
* Refreshes the state of the switches for all profiles, possibly adding or removing switches as
* needed.
*/
@Override
protected void refresh() {
for (LocalBluetoothProfile profile : getProfiles()) {
SwitchPreference pref = (SwitchPreference) mProfilesContainer.findPreference(profile.toString());
if (pref == null) {
pref = createProfilePreference(mProfilesContainer.getContext(), profile);
mProfilesContainer.addPreference(pref);
maybeAddHighQualityAudioPref(profile);
}
refreshProfilePreference(pref, profile);
}
for (LocalBluetoothProfile removedProfile : mCachedDevice.getRemovedProfiles()) {
SwitchPreference pref = (SwitchPreference) mProfilesContainer.findPreference(removedProfile.toString());
if (pref != null) {
mProfilesContainer.removePreference(pref);
}
}
}
use of com.android.settingslib.bluetooth.LocalBluetoothProfile in project android_packages_apps_Settings by DirtyUnicorns.
the class BluetoothDetailsProfilesControllerTest method addFakeProfile.
/**
* Creates and adds a mock LocalBluetoothProfile to the list of connectable profiles for the
* device.
* @param profileNameResId the resource id for the name used by this profile
* @param deviceIsPreferred whether this profile should start out as enabled for the device
*/
private LocalBluetoothProfile addFakeProfile(int profileNameResId, boolean deviceIsPreferred) {
LocalBluetoothProfile profile = new FakeBluetoothProfile(mContext, profileNameResId);
profile.setPreferred(mDevice, deviceIsPreferred);
mConnectableProfiles.add(profile);
when(mProfileManager.getProfileByName(eq(profile.toString()))).thenReturn(profile);
return profile;
}
use of com.android.settingslib.bluetooth.LocalBluetoothProfile in project android_packages_apps_Settings by DirtyUnicorns.
the class BluetoothDetailsProfilesController method getProfiles.
/**
* Helper to get the list of connectable and special profiles.
*/
private List<LocalBluetoothProfile> getProfiles() {
List<LocalBluetoothProfile> result = mCachedDevice.getConnectableProfiles();
final int pbapPermission = mCachedDevice.getPhonebookPermissionChoice();
// Only provide PBAP cabability if the client device has requested PBAP.
if (pbapPermission != CachedBluetoothDevice.ACCESS_UNKNOWN) {
final PbapServerProfile psp = mManager.getProfileManager().getPbapProfile();
result.add(psp);
}
final MapProfile mapProfile = mManager.getProfileManager().getMapProfile();
final int mapPermission = mCachedDevice.getMessagePermissionChoice();
if (mapPermission != CachedBluetoothDevice.ACCESS_UNKNOWN) {
result.add(mapProfile);
}
return result;
}
Aggregations