diff --git a/AndroidManifest.xml b/AndroidManifest.xml index a12c9825111..524003583f5 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -2978,6 +2978,10 @@ + + + + getSlices() { + final List uris = new ArrayList<>(); + uris.add(CustomSliceRegistry.NFC_SLICE_URI); + return uris; + } + + @Override + public Intent getSeeMoreIntent() { + final String screenTitle = + mContext.getText(R.string.connected_device_connections_title).toString(); + Intent intent = SliceBuilderUtils.buildSearchResultPageIntent(mContext, + AdvancedConnectedDeviceDashboardFragment.class.getName(), + null /* key */, + screenTitle, + SettingsEnums.SETTINGS_CONNECTED_DEVICE_CATEGORY); + intent.setClassName(mContext.getPackageName(), SubSettings.class.getName()); + return intent; + } +} diff --git a/src/com/android/settings/panel/PanelFeatureProviderImpl.java b/src/com/android/settings/panel/PanelFeatureProviderImpl.java index ade2ffdc946..b4c37bf39a1 100644 --- a/src/com/android/settings/panel/PanelFeatureProviderImpl.java +++ b/src/com/android/settings/panel/PanelFeatureProviderImpl.java @@ -28,6 +28,8 @@ public class PanelFeatureProviderImpl implements PanelFeatureProvider { return InternetConnectivityPanel.create(context); case Settings.Panel.ACTION_VOLUME: return VolumePanel.create(context); + case Settings.Panel.ACTION_NFC: + return NfcPanel.create(context); } throw new IllegalStateException("No matching panel for: " + panelType); diff --git a/src/com/android/settings/slices/CustomSliceRegistry.java b/src/com/android/settings/slices/CustomSliceRegistry.java index e842cb97857..3a213df6742 100644 --- a/src/com/android/settings/slices/CustomSliceRegistry.java +++ b/src/com/android/settings/slices/CustomSliceRegistry.java @@ -154,6 +154,15 @@ public class CustomSliceRegistry { .appendEncodedPath(SettingsSlicesContract.PATH_SETTING_INTENT) .appendPath("low_storage") .build(); + /** + * Backing Uri for NFC Slice + */ + public static final Uri NFC_SLICE_URI = new Uri.Builder() + .scheme(ContentResolver.SCHEME_CONTENT) + .authority(SettingsSliceProvider.SLICE_AUTHORITY) + .appendPath(SettingsSlicesContract.PATH_SETTING_ACTION) + .appendPath("toggle_nfc") + .build(); /** * Backing Uri for Notification channel Slice. */ diff --git a/tests/robotests/src/com/android/settings/panel/NfcPanelTest.java b/tests/robotests/src/com/android/settings/panel/NfcPanelTest.java new file mode 100644 index 00000000000..bf6662dc946 --- /dev/null +++ b/tests/robotests/src/com/android/settings/panel/NfcPanelTest.java @@ -0,0 +1,40 @@ +package com.android.settings.panel; + +import static com.google.common.truth.Truth.assertThat; + +import android.net.Uri; + +import com.android.settings.slices.CustomSliceRegistry; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.robolectric.RobolectricTestRunner; +import org.robolectric.RuntimeEnvironment; + + +import java.util.List; + +@RunWith(RobolectricTestRunner.class) +public class NfcPanelTest { + + private NfcPanel mPanel; + + @Before + public void setUp() { + mPanel = NfcPanel.create(RuntimeEnvironment.application); + } + + @Test + public void getSlices_containsNecessarySlices() { + final List uris = mPanel.getSlices(); + + assertThat(uris).containsExactly( + CustomSliceRegistry.NFC_SLICE_URI); + } + + @Test + public void getSeeMoreIntent_notNull() { + assertThat(mPanel.getSeeMoreIntent()).isNotNull(); + } +}