Create special case mobile data slice
Build the special case mobile data slice for general use, and for the Internet Connectivity Panel. The Slice controls the default data subscription, and links to the subscriptions page. Bug: 117804089 Fixse: 119411534 Test: robotests & test app. Change-Id: I31b524a8fe3182a244d940848090e97250632f39
This commit is contained in:
@@ -18,7 +18,6 @@ package com.android.settings.slices;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import android.text.TextUtils;
|
||||
import android.util.ArrayMap;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
@@ -35,6 +34,7 @@ import com.android.settings.homepage.contextualcards.slices.LowStorageSlice;
|
||||
import com.android.settings.homepage.contextualcards.slices.NotificationChannelSlice;
|
||||
import com.android.settings.location.LocationSlice;
|
||||
import com.android.settings.media.MediaOutputSlice;
|
||||
import com.android.settings.network.telephony.MobileDataSlice;
|
||||
import com.android.settings.wifi.slice.ContextualWifiSlice;
|
||||
import com.android.settings.wifi.slice.WifiSlice;
|
||||
|
||||
@@ -123,6 +123,7 @@ public class CustomSliceManager {
|
||||
mUriMap.put(CustomSliceRegistry.FLASHLIGHT_SLICE_URI, FlashlightSlice.class);
|
||||
mUriMap.put(CustomSliceRegistry.LOCATION_SLICE_URI, LocationSlice.class);
|
||||
mUriMap.put(CustomSliceRegistry.LOW_STORAGE_SLICE_URI, LowStorageSlice.class);
|
||||
mUriMap.put(CustomSliceRegistry.MOBILE_DATA_SLICE_URI, MobileDataSlice.class);
|
||||
mUriMap.put(CustomSliceRegistry.NOTIFICATION_CHANNEL_SLICE_URI,
|
||||
NotificationChannelSlice.class);
|
||||
mUriMap.put(CustomSliceRegistry.STORAGE_SLICE_URI, StorageSlice.class);
|
||||
|
||||
@@ -164,6 +164,16 @@ public class CustomSliceRegistry {
|
||||
.appendPath(SettingsSlicesContract.PATH_SETTING_ACTION)
|
||||
.appendPath("toggle_nfc")
|
||||
.build();
|
||||
|
||||
/**
|
||||
* Backing Uri for Mobile Data Slice.
|
||||
*/
|
||||
public static final Uri MOBILE_DATA_SLICE_URI = new Uri.Builder()
|
||||
.scheme(ContentResolver.SCHEME_CONTENT)
|
||||
.authority(SettingsSliceProvider.SLICE_AUTHORITY)
|
||||
.appendEncodedPath(SettingsSlicesContract.PATH_SETTING_ACTION)
|
||||
.appendPath("mobile_data")
|
||||
.build();
|
||||
/**
|
||||
* Backing Uri for Notification channel Slice.
|
||||
*/
|
||||
|
||||
@@ -71,7 +71,7 @@ public interface CustomSliceable {
|
||||
*
|
||||
* @param intent which has the action taken on a {@link Slice}.
|
||||
*/
|
||||
void onNotifyChange(Intent intent);
|
||||
default void onNotifyChange(Intent intent) {}
|
||||
|
||||
/**
|
||||
* @return an {@link Intent} to the source of the Slice data.
|
||||
@@ -90,11 +90,12 @@ public interface CustomSliceable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Settings Slices which can represent component lists that are updatable by the
|
||||
* {@link SliceBackgroundWorker} class returned here.
|
||||
* Settings Slices which require background work, such as updating lists should implement a
|
||||
* {@link SliceBackgroundWorker} and return it here. An example of background work is updating
|
||||
* a list of Wifi networks available in the area.
|
||||
*
|
||||
* @return a {@link SliceBackgroundWorker} class for fetching the list of results in the
|
||||
* background.
|
||||
* @return a {@link Class<? extends SliceBackgroundWorker>} to perform background work for the
|
||||
* slice.
|
||||
*/
|
||||
default Class<? extends SliceBackgroundWorker> getBackgroundWorkerClass() {
|
||||
return null;
|
||||
|
||||
@@ -464,8 +464,9 @@ public class SettingsSliceProvider extends SliceProvider {
|
||||
|
||||
private List<Uri> getSpecialCaseOemUris() {
|
||||
return Arrays.asList(
|
||||
CustomSliceRegistry.ZEN_MODE_SLICE_URI,
|
||||
CustomSliceRegistry.FLASHLIGHT_SLICE_URI
|
||||
CustomSliceRegistry.FLASHLIGHT_SLICE_URI,
|
||||
CustomSliceRegistry.MOBILE_DATA_SLICE_URI,
|
||||
CustomSliceRegistry.ZEN_MODE_SLICE_URI
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -59,6 +59,14 @@ public abstract class SliceBackgroundWorker<E> implements Closeable {
|
||||
mUri = uri;
|
||||
}
|
||||
|
||||
protected Uri getUri() {
|
||||
return mUri;
|
||||
}
|
||||
|
||||
protected Context getContext() {
|
||||
return mContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the singleton instance of the {@link SliceBackgroundWorker} for specified {@link Uri}
|
||||
* if exists
|
||||
@@ -151,7 +159,7 @@ public abstract class SliceBackgroundWorker<E> implements Closeable {
|
||||
/**
|
||||
* Notify that data was updated and attempt to sync changes to the Slice.
|
||||
*/
|
||||
protected void notifySliceChange() {
|
||||
protected final void notifySliceChange() {
|
||||
mContext.getContentResolver().notifyChange(mUri, null);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user