From 53656a17493f7a5db4d0b66991beeb0951d51f35 Mon Sep 17 00:00:00 2001 From: Yanting Yang Date: Fri, 15 Feb 2019 21:03:54 +0800 Subject: [PATCH] Hide "Pair new device" from connected device slice Fixes:124460897 Test: visual, robotests Change-Id: Id702bf77eacf29d831e00f56d0b1ab9c1f945fbb --- .../slices/BluetoothDevicesSlice.java | 28 ------------------ .../slices/BluetoothDevicesSliceTest.java | 29 ------------------- 2 files changed, 57 deletions(-) diff --git a/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSlice.java b/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSlice.java index 5673948dde8..0156ac61d0c 100644 --- a/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSlice.java +++ b/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSlice.java @@ -37,7 +37,6 @@ import com.android.settings.R; import com.android.settings.SubSettings; import com.android.settings.Utils; import com.android.settings.bluetooth.BluetoothDeviceDetailsFragment; -import com.android.settings.bluetooth.BluetoothPairingDetail; import com.android.settings.connecteddevice.ConnectedDeviceDashboardFragment; import com.android.settings.core.SubSettingLauncher; import com.android.settings.slices.CustomSliceRegistry; @@ -127,11 +126,6 @@ public class BluetoothDevicesSlice implements CustomSliceable { listBuilder.addRow(rows.get(i)); } - // Add "Pair new device" if need. - if (rows.size() < DEFAULT_EXPANDED_ROW_COUNT) { - listBuilder.addRow(getPairNewDeviceRowBuilder()); - } - return listBuilder.build(); } @@ -268,26 +262,4 @@ public class BluetoothDevicesSlice implements CustomSliceable { return mContext.getResources().getQuantityString(R.plurals.show_bluetooth_devices, deviceCount, deviceCount); } - - private ListBuilder.RowBuilder getPairNewDeviceRowBuilder() { - final CharSequence title = mContext.getText(R.string.bluetooth_pairing_pref_title); - final IconCompat icon = IconCompat.createWithResource(mContext, R.drawable.ic_menu_add); - final SliceAction sliceAction = SliceAction.createDeeplink( - getPairNewDeviceIntent(), icon, ListBuilder.ICON_IMAGE, title); - - return new ListBuilder.RowBuilder() - .setTitleItem(icon, ListBuilder.ICON_IMAGE) - .setTitle(title) - .setPrimaryAction(sliceAction); - } - - private PendingIntent getPairNewDeviceIntent() { - final Intent intent = new SubSettingLauncher(mContext) - .setDestination(BluetoothPairingDetail.class.getName()) - .setTitleRes(R.string.bluetooth_pairing_page_title) - .setSourceMetricsCategory(SettingsEnums.BLUETOOTH_PAIRING) - .toIntent(); - - return PendingIntent.getActivity(mContext, 0 /* requestCode */, intent, 0 /* flags */); - } } diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSliceTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSliceTest.java index 02d7a9da679..77fc5d94eee 100644 --- a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSliceTest.java +++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSliceTest.java @@ -30,7 +30,6 @@ import static org.mockito.Mockito.when; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; -import android.text.TextUtils; import androidx.core.graphics.drawable.IconCompat; import androidx.slice.Slice; @@ -122,18 +121,6 @@ public class BluetoothDevicesSliceTest { SliceTester.assertAnySliceItemContainsTitle(sliceItems, BLUETOOTH_MOCK_TITLE); } - @Test - public void getSlice_hasBluetoothDevices_shouldHavePairNewDevice() { - mockBluetoothDeviceList(1); - doReturn(mBluetoothDeviceList).when(mBluetoothDevicesSlice).getConnectedBluetoothDevices(); - - final Slice slice = mBluetoothDevicesSlice.getSlice(); - - final List sliceItems = slice.getItems(); - SliceTester.assertAnySliceItemContainsTitle(sliceItems, - mContext.getString(R.string.bluetooth_pairing_pref_title)); - } - @Test public void getSlice_noBluetoothDevices_shouldHaveNoBluetoothDevicesTitle() { doReturn(mBluetoothDeviceList).when(mBluetoothDevicesSlice).getConnectedBluetoothDevices(); @@ -145,17 +132,6 @@ public class BluetoothDevicesSliceTest { mContext.getString(R.string.no_bluetooth_devices)); } - @Test - public void getSlice_noBluetoothDevices_shouldNotHavePairNewDevice() { - doReturn(mBluetoothDeviceList).when(mBluetoothDevicesSlice).getConnectedBluetoothDevices(); - - final Slice slice = mBluetoothDevicesSlice.getSlice(); - - final SliceMetadata metadata = SliceMetadata.from(mContext, slice); - assertThat(hasTitle(metadata, - mContext.getString(R.string.bluetooth_pairing_pref_title))).isFalse(); - } - @Test public void getSlice_exceedDefaultRowCount_shouldOnlyShowDefaultRows() { mockBluetoothDeviceList(BluetoothDevicesSlice.DEFAULT_EXPANDED_ROW_COUNT + 1); @@ -204,9 +180,4 @@ public class BluetoothDevicesSliceTest { mBluetoothDeviceList.add(mCachedBluetoothDevice); } } - - private boolean hasTitle(SliceMetadata metadata, String title) { - final CharSequence sliceTitle = metadata.getTitle(); - return TextUtils.equals(sliceTitle, title); - } }