Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 88d6b2f9 authored by Lei Yu's avatar Lei Yu Committed by Android (Google) Code Review
Browse files

Merge "Add intent action for BT device detail page"

parents ca5786fd 715408e5
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -2987,6 +2987,18 @@
                       android:value="true" />
        </activity>

        <activity android:name="Settings$BluetoothDeviceDetailActivity"
                  android:label="@string/device_details_title"
                  android:permission="android.permission.BLUETOOTH_PRIVILEGED"
                  android:parentActivityName="Settings$ConnectedDeviceDashboardActivity">
            <intent-filter android:priority="1">
                <action android:name="com.android.settings.BLUETOOTH_DEVICE_DETAIL_SETTINGS" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
            <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
                       android:value="com.android.settings.bluetooth.BluetoothDeviceDetailsFragment" />
        </activity>

        <activity android:name=".panel.SettingsPanelActivity"
            android:label="@string/settings_panel_title"
            android:theme="@style/Theme.BottomDialog"
+1 −0
Original line number Diff line number Diff line
@@ -156,6 +156,7 @@ public class Settings extends SettingsActivity {
    }
    public static class WebViewAppPickerActivity extends SettingsActivity { /* empty */ }
    public static class AdvancedConnectedDeviceActivity extends SettingsActivity { /* empty */ }
    public static class BluetoothDeviceDetailActivity extends SettingsActivity { /* empty */ }

    // Top level categories for new IA
    public static class NetworkDashboardActivity extends SettingsActivity {}
+31 −4
Original line number Diff line number Diff line
@@ -45,7 +45,8 @@ import java.util.List;
 * supports, such as "Phone audio", "Media audio", "Contact sharing", etc.
 */
public class BluetoothDetailsProfilesController extends BluetoothDetailsController
        implements Preference.OnPreferenceClickListener {
        implements Preference.OnPreferenceClickListener,
        LocalBluetoothProfileManager.ServiceListener {
    private static final String KEY_PROFILES_GROUP = "bluetooth_profiles";

    @VisibleForTesting
@@ -87,6 +88,7 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll
        pref.setKey(profile.toString());
        pref.setTitle(profile.getNameResource(mCachedDevice.getDevice()));
        pref.setOnPreferenceClickListener(this);
        pref.setOrder(profile.getOrdinal());
        return pref;
    }

@@ -221,7 +223,7 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll
        }
        BluetoothDevice device = mCachedDevice.getDevice();
        A2dpProfile a2dp = (A2dpProfile) profile;
        if (a2dp.supportsHighQualityAudio(device)) {
        if (a2dp.isProfileReady() && a2dp.supportsHighQualityAudio(device)) {
            SwitchPreference highQualityAudioPref = new SwitchPreference(
                    mProfilesContainer.getContext());
            highQualityAudioPref.setKey(HIGH_QUALITY_AUDIO_PREF_TAG);
@@ -235,6 +237,28 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll
        }
    }

    @Override
    public void onPause() {
        super.onPause();
        mProfileManager.removeServiceListener(this);
    }

    @Override
    public void onResume() {
        super.onResume();
        mProfileManager.addServiceListener(this);
    }

    @Override
    public void onServiceConnected() {
        refresh();
    }

    @Override
    public void onServiceDisconnected() {
        refresh();
    }

    /**
     * Refreshes the state of the switches for all profiles, possibly adding or removing switches as
     * needed.
@@ -242,7 +266,10 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll
    @Override
    protected void refresh() {
        for (LocalBluetoothProfile profile : getProfiles()) {
            SwitchPreference pref = (SwitchPreference) mProfilesContainer.findPreference(
            if (!profile.isProfileReady()) {
                continue;
            }
            SwitchPreference pref = mProfilesContainer.findPreference(
                    profile.toString());
            if (pref == null) {
                pref = createProfilePreference(mProfilesContainer.getContext(), profile);
@@ -252,7 +279,7 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll
            refreshProfilePreference(pref, profile);
        }
        for (LocalBluetoothProfile removedProfile : mCachedDevice.getRemovedProfiles()) {
            SwitchPreference pref = (SwitchPreference) mProfilesContainer.findPreference(
            final SwitchPreference pref = mProfilesContainer.findPreference(
                    removedProfile.toString());
            if (pref != null) {
                mProfilesContainer.removePreference(pref);
+5 −0
Original line number Diff line number Diff line
@@ -107,6 +107,11 @@ public class BluetoothDeviceDetailsFragment extends RestrictedDashboardFragment
        mDeviceAddress = getArguments().getString(KEY_DEVICE_ADDRESS);
        mManager = getLocalBluetoothManager(context);
        mCachedDevice = getCachedDevice(mDeviceAddress);
        if (mCachedDevice == null) {
            // Close this page if device is null with invalid device mac address
            finish();
            return;
        }
        super.onAttach(context);
        use(AdvancedBluetoothDetailsHeaderController.class).init(mCachedDevice);

+19 −2
Original line number Diff line number Diff line
@@ -294,6 +294,7 @@ public class BluetoothDetailsProfilesControllerTest extends BluetoothDetailsCont
        PbapServerProfile psp = mock(PbapServerProfile.class);
        when(psp.getNameResource(mDevice)).thenReturn(R.string.bluetooth_profile_pbap);
        when(psp.toString()).thenReturn(PbapServerProfile.NAME);
        when(psp.isProfileReady()).thenReturn(true);
        when(mProfileManager.getPbapProfile()).thenReturn(psp);

        showScreen(mController);
@@ -316,6 +317,7 @@ public class BluetoothDetailsProfilesControllerTest extends BluetoothDetailsCont
        PbapServerProfile psp = mock(PbapServerProfile.class);
        when(psp.getNameResource(mDevice)).thenReturn(R.string.bluetooth_profile_pbap);
        when(psp.toString()).thenReturn(PbapServerProfile.NAME);
        when(psp.isProfileReady()).thenReturn(true);
        when(mProfileManager.getPbapProfile()).thenReturn(psp);

        showScreen(mController);
@@ -336,6 +338,7 @@ public class BluetoothDetailsProfilesControllerTest extends BluetoothDetailsCont
        setupDevice(makeDefaultDeviceConfig());
        MapProfile mapProfile = mock(MapProfile.class);
        when(mapProfile.getNameResource(mDevice)).thenReturn(R.string.bluetooth_profile_map);
        when(mapProfile.isProfileReady()).thenReturn(true);
        when(mProfileManager.getMapProfile()).thenReturn(mapProfile);
        when(mProfileManager.getProfileByName(eq(mapProfile.toString()))).thenReturn(mapProfile);
        mDevice.setMessageAccessPermission(BluetoothDevice.ACCESS_REJECTED);
@@ -361,6 +364,7 @@ public class BluetoothDetailsProfilesControllerTest extends BluetoothDetailsCont
        when(profile.supportsHighQualityAudio(mDevice)).thenReturn(supportsHighQualityAudio);
        when(profile.isHighQualityAudioEnabled(mDevice)).thenReturn(highQualityAudioEnabled);
        when(profile.isPreferred(mDevice)).thenReturn(preferred);
        when(profile.isProfileReady()).thenReturn(true);
        mConnectableProfiles.add(profile);
        return profile;
    }
@@ -442,12 +446,25 @@ public class BluetoothDetailsProfilesControllerTest extends BluetoothDetailsCont
        setupDevice(makeDefaultDeviceConfig());
        A2dpProfile audioProfile = addMockA2dpProfile(false, true, true);
        showScreen(mController);
        SwitchPreference audioPref =
            (SwitchPreference) mScreen.findPreference(audioProfile.toString());
        SwitchPreference audioPref = mScreen.findPreference(audioProfile.toString());
        SwitchPreference highQualityAudioPref = getHighQualityAudioPref();
        assertThat(audioPref).isNotNull();
        assertThat(audioPref.isChecked()).isFalse();
        assertThat(highQualityAudioPref).isNotNull();
        assertThat(highQualityAudioPref.isVisible()).isFalse();
    }

    @Test
    public void onResume_addServiceListener() {
        mController.onResume();

        verify(mProfileManager).addServiceListener(mController);
    }

    @Test
    public void onPause_removeServiceListener() {
        mController.onPause();

        verify(mProfileManager).removeServiceListener(mController);
    }
}
+10 −10

File changed.

Contains only whitespace changes.

Loading