Move all custom slice uris to a registry class.
Change-Id: I192320f95ac81d14c8891ce2531d603912e59f56 Fixes: 119776308 Test: robotests
This commit is contained in:
@@ -101,13 +101,13 @@ public class CustomSliceManager {
|
||||
}
|
||||
|
||||
private void addSlices() {
|
||||
mUriMap.put(WifiSlice.WIFI_URI, WifiSlice.class);
|
||||
mUriMap.put(DataUsageSlice.DATA_USAGE_CARD_URI, DataUsageSlice.class);
|
||||
mUriMap.put(DeviceInfoSlice.DEVICE_INFO_CARD_URI, DeviceInfoSlice.class);
|
||||
mUriMap.put(StorageSlice.STORAGE_CARD_URI, StorageSlice.class);
|
||||
mUriMap.put(BatterySlice.BATTERY_CARD_URI, BatterySlice.class);
|
||||
mUriMap.put(ConnectedDeviceSlice.CONNECTED_DEVICE_URI, ConnectedDeviceSlice.class);
|
||||
mUriMap.put(LowStorageSlice.LOW_STORAGE_URI, LowStorageSlice.class);
|
||||
mUriMap.put(BatteryFixSlice.BATTERY_FIX_URI, BatteryFixSlice.class);
|
||||
mUriMap.put(CustomSliceRegistry.BATTERY_FIX_SLICE_URI, BatteryFixSlice.class);
|
||||
mUriMap.put(CustomSliceRegistry.BATTERY_INFO_SLICE_URI, BatterySlice.class);
|
||||
mUriMap.put(CustomSliceRegistry.CONNECTED_DEVICE_SLICE_URI, ConnectedDeviceSlice.class);
|
||||
mUriMap.put(CustomSliceRegistry.DATA_USAGE_SLICE_URI, DataUsageSlice.class);
|
||||
mUriMap.put(CustomSliceRegistry.DEVICE_INFO_SLICE_URI, DeviceInfoSlice.class);
|
||||
mUriMap.put(CustomSliceRegistry.LOW_STORAGE_SLICE_URI, LowStorageSlice.class);
|
||||
mUriMap.put(CustomSliceRegistry.STORAGE_SLICE_URI, StorageSlice.class);
|
||||
mUriMap.put(CustomSliceRegistry.WIFI_SLICE_URI, WifiSlice.class);
|
||||
}
|
||||
}
|
||||
|
||||
184
src/com/android/settings/slices/CustomSliceRegistry.java
Normal file
184
src/com/android/settings/slices/CustomSliceRegistry.java
Normal file
@@ -0,0 +1,184 @@
|
||||
/*
|
||||
* Copyright (C) 2018 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.slices;
|
||||
|
||||
import static android.provider.SettingsSlicesContract.KEY_LOCATION;
|
||||
import static android.provider.SettingsSlicesContract.KEY_WIFI;
|
||||
|
||||
import static com.android.settings.notification.ZenModePreferenceController.ZEN_MODE_KEY;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.net.Uri;
|
||||
import android.provider.SettingsSlicesContract;
|
||||
|
||||
import com.android.settings.fuelgauge.batterytip.BatteryTipPreferenceController;
|
||||
import com.android.settings.wifi.calling.WifiCallingSliceHelper;
|
||||
|
||||
/**
|
||||
* A registry of custom slice Uris.
|
||||
*/
|
||||
public class CustomSliceRegistry {
|
||||
|
||||
/**
|
||||
* Uri for Airplane mode Slice.
|
||||
*/
|
||||
public static final Uri AIRPLANE_URI = new Uri.Builder()
|
||||
.scheme(ContentResolver.SCHEME_CONTENT)
|
||||
.authority(SettingsSlicesContract.AUTHORITY)
|
||||
.appendPath(SettingsSlicesContract.PATH_SETTING_ACTION)
|
||||
.appendPath(SettingsSlicesContract.KEY_AIRPLANE_MODE)
|
||||
.build();
|
||||
|
||||
/**
|
||||
* Uri for Battery Fix Slice.
|
||||
*/
|
||||
public static final Uri BATTERY_FIX_SLICE_URI = new Uri.Builder()
|
||||
.scheme(ContentResolver.SCHEME_CONTENT)
|
||||
.authority(SettingsSliceProvider.SLICE_AUTHORITY)
|
||||
.appendEncodedPath(SettingsSlicesContract.PATH_SETTING_INTENT)
|
||||
.appendPath(BatteryTipPreferenceController.PREF_NAME)
|
||||
.build();
|
||||
/**
|
||||
* Backing Uri for the Battery info Slice.
|
||||
*/
|
||||
public static final Uri BATTERY_INFO_SLICE_URI = new Uri.Builder()
|
||||
.scheme(ContentResolver.SCHEME_CONTENT)
|
||||
.authority(SettingsSliceProvider.SLICE_AUTHORITY)
|
||||
.appendEncodedPath(SettingsSlicesContract.PATH_SETTING_INTENT)
|
||||
.appendPath("battery_card")
|
||||
.build();
|
||||
/**
|
||||
* Backing Uri for the Bluetooth Slice.
|
||||
*/
|
||||
public static final Uri BLUETOOTH_URI = new Uri.Builder()
|
||||
.scheme(ContentResolver.SCHEME_CONTENT)
|
||||
.authority(SettingsSlicesContract.AUTHORITY)
|
||||
.appendPath(SettingsSlicesContract.PATH_SETTING_ACTION)
|
||||
.appendPath(SettingsSlicesContract.KEY_BLUETOOTH)
|
||||
.build();
|
||||
|
||||
/**
|
||||
* Backing Uri for Connected device Slice.
|
||||
*/
|
||||
public static final Uri CONNECTED_DEVICE_SLICE_URI = new Uri.Builder()
|
||||
.scheme(ContentResolver.SCHEME_CONTENT)
|
||||
.authority(SettingsSliceProvider.SLICE_AUTHORITY)
|
||||
.appendPath(SettingsSlicesContract.PATH_SETTING_ACTION)
|
||||
.appendPath("connected_device")
|
||||
.build();
|
||||
/**
|
||||
* Backing Uri for the Data usage Slice.
|
||||
*/
|
||||
public static final Uri DATA_USAGE_SLICE_URI = new Uri.Builder()
|
||||
.scheme(ContentResolver.SCHEME_CONTENT)
|
||||
.authority(SettingsSliceProvider.SLICE_AUTHORITY)
|
||||
.appendPath("data_usage_card")
|
||||
.build();
|
||||
/**
|
||||
* Backing Uri for the Device info Slice.
|
||||
*/
|
||||
public static final Uri DEVICE_INFO_SLICE_URI = new Uri.Builder()
|
||||
.scheme(ContentResolver.SCHEME_CONTENT)
|
||||
.authority(SettingsSliceProvider.SLICE_AUTHORITY)
|
||||
.appendPath("device_info_card")
|
||||
.build();
|
||||
/**
|
||||
* Backing Uri for the Emergency Info Slice.
|
||||
*/
|
||||
public static final Uri EMERGENCY_INFO_SLICE_URI = new Uri.Builder()
|
||||
.scheme(ContentResolver.SCHEME_CONTENT)
|
||||
.authority(SettingsSliceProvider.SLICE_AUTHORITY)
|
||||
.appendPath("emergency_info_card")
|
||||
.build();
|
||||
/**
|
||||
* Slice Uri for Enhanced 4G slice
|
||||
*/
|
||||
public static final Uri ENHANCED_4G_SLICE_URI = new Uri.Builder()
|
||||
.scheme(ContentResolver.SCHEME_CONTENT)
|
||||
.authority(SettingsSliceProvider.SLICE_AUTHORITY)
|
||||
.appendPath("enhanced_4g_lte")
|
||||
.build();
|
||||
/**
|
||||
* Backing Uri for the Flashlight Slice.
|
||||
*/
|
||||
public static final Uri FLASHLIGHT_SLICE_URI = new Uri.Builder()
|
||||
.scheme(ContentResolver.SCHEME_CONTENT)
|
||||
.authority(SettingsSliceProvider.SLICE_AUTHORITY)
|
||||
.appendPath(SettingsSlicesContract.PATH_SETTING_ACTION)
|
||||
.appendPath("flashlight")
|
||||
.build();
|
||||
/**
|
||||
* Backing Uri for the Location Slice.
|
||||
*/
|
||||
public static final Uri LOCATION_SLICE_URI = new Uri.Builder()
|
||||
.scheme(ContentResolver.SCHEME_CONTENT)
|
||||
.authority(SettingsSlicesContract.AUTHORITY)
|
||||
.appendPath(SettingsSlicesContract.PATH_SETTING_ACTION)
|
||||
.appendPath(KEY_LOCATION)
|
||||
.build();
|
||||
/**
|
||||
* Backing Uri for Low storage Slice.
|
||||
*/
|
||||
public static final Uri LOW_STORAGE_SLICE_URI = new Uri.Builder()
|
||||
.scheme(ContentResolver.SCHEME_CONTENT)
|
||||
.authority(SettingsSliceProvider.SLICE_AUTHORITY)
|
||||
.appendEncodedPath(SettingsSlicesContract.PATH_SETTING_INTENT)
|
||||
.appendPath("low_storage")
|
||||
.build();
|
||||
/**
|
||||
* Backing Uri for the storage slice.
|
||||
*/
|
||||
public static final Uri STORAGE_SLICE_URI = new Uri.Builder()
|
||||
.scheme(ContentResolver.SCHEME_CONTENT)
|
||||
.authority(SettingsSliceProvider.SLICE_AUTHORITY)
|
||||
.appendPath("storage_card")
|
||||
.build();
|
||||
/**
|
||||
* Full {@link Uri} for the Wifi Calling Slice.
|
||||
*/
|
||||
public static final Uri WIFI_CALLING_URI = new Uri.Builder()
|
||||
.scheme(ContentResolver.SCHEME_CONTENT)
|
||||
.authority(SettingsSliceProvider.SLICE_AUTHORITY)
|
||||
.appendPath(WifiCallingSliceHelper.PATH_WIFI_CALLING)
|
||||
.build();
|
||||
/**
|
||||
* Full {@link Uri} for the Wifi Calling Preference Slice.
|
||||
*/
|
||||
public static final Uri WIFI_CALLING_PREFERENCE_URI = new Uri.Builder()
|
||||
.scheme(ContentResolver.SCHEME_CONTENT)
|
||||
.authority(SettingsSliceProvider.SLICE_AUTHORITY)
|
||||
.appendPath(WifiCallingSliceHelper.PATH_WIFI_CALLING_PREFERENCE)
|
||||
.build();
|
||||
/**
|
||||
* Backing Uri for the Wifi Slice.
|
||||
*/
|
||||
public static final Uri WIFI_SLICE_URI = new Uri.Builder()
|
||||
.scheme(ContentResolver.SCHEME_CONTENT)
|
||||
.authority(SettingsSlicesContract.AUTHORITY)
|
||||
.appendPath(SettingsSlicesContract.PATH_SETTING_ACTION)
|
||||
.appendPath(KEY_WIFI)
|
||||
.build();
|
||||
/**
|
||||
* Backing Uri for the Zen Mode Slice.
|
||||
*/
|
||||
public static final Uri ZEN_MODE_SLICE_URI = new Uri.Builder()
|
||||
.scheme(ContentResolver.SCHEME_CONTENT)
|
||||
.authority(SettingsSliceProvider.SLICE_AUTHORITY)
|
||||
.appendPath(SettingsSlicesContract.PATH_SETTING_ACTION)
|
||||
.appendPath(ZEN_MODE_KEY)
|
||||
.build();
|
||||
}
|
||||
@@ -44,11 +44,8 @@ import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.flashlight.FlashlightSliceBuilder;
|
||||
import com.android.settings.homepage.contextualcards.deviceinfo.EmergencyInfoSlice;
|
||||
import com.android.settings.location.LocationSliceBuilder;
|
||||
import com.android.settings.network.telephony.Enhanced4gLteSliceHelper;
|
||||
import com.android.settings.notification.ZenModeSliceBuilder;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settings.wifi.WifiSlice;
|
||||
import com.android.settings.wifi.calling.WifiCallingSliceHelper;
|
||||
import com.android.settingslib.SliceBroadcastRelay;
|
||||
import com.android.settingslib.utils.ThreadUtils;
|
||||
|
||||
@@ -175,23 +172,21 @@ public class SettingsSliceProvider extends SliceProvider {
|
||||
if (filter != null) {
|
||||
registerIntentToUri(filter, sliceUri);
|
||||
}
|
||||
ThreadUtils.postOnMainThread(() -> {
|
||||
startBackgroundWorker(sliceable);
|
||||
});
|
||||
ThreadUtils.postOnMainThread(() -> startBackgroundWorker(sliceable));
|
||||
return;
|
||||
}
|
||||
|
||||
if (ZenModeSliceBuilder.ZEN_MODE_URI.equals(sliceUri)) {
|
||||
if (CustomSliceRegistry.ZEN_MODE_SLICE_URI.equals(sliceUri)) {
|
||||
registerIntentToUri(ZenModeSliceBuilder.INTENT_FILTER, sliceUri);
|
||||
return;
|
||||
} else if (BluetoothSliceBuilder.BLUETOOTH_URI.equals(sliceUri)) {
|
||||
} else if (CustomSliceRegistry.BLUETOOTH_URI.equals(sliceUri)) {
|
||||
registerIntentToUri(BluetoothSliceBuilder.INTENT_FILTER, sliceUri);
|
||||
return;
|
||||
} else if (FlashlightSliceBuilder.FLASHLIGHT_URI.equals(sliceUri)) {
|
||||
} else if (CustomSliceRegistry.FLASHLIGHT_SLICE_URI.equals(sliceUri)) {
|
||||
registerIntentToUri(FlashlightSliceBuilder.INTENT_FILTER, sliceUri);
|
||||
mRegisteredUris.add(sliceUri);
|
||||
return;
|
||||
} else if (EmergencyInfoSlice.EMERGENCY_INFO_CARD_URI.equals(sliceUri)) {
|
||||
} else if (CustomSliceRegistry.EMERGENCY_INFO_SLICE_URI.equals(sliceUri)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -236,30 +231,30 @@ public class SettingsSliceProvider extends SliceProvider {
|
||||
return sliceable.getSlice();
|
||||
}
|
||||
|
||||
if (WifiCallingSliceHelper.WIFI_CALLING_URI.equals(sliceUri)) {
|
||||
if (CustomSliceRegistry.WIFI_CALLING_URI.equals(sliceUri)) {
|
||||
return FeatureFactory.getFactory(getContext())
|
||||
.getSlicesFeatureProvider()
|
||||
.getNewWifiCallingSliceHelper(getContext())
|
||||
.createWifiCallingSlice(sliceUri);
|
||||
} else if (ZenModeSliceBuilder.ZEN_MODE_URI.equals(sliceUri)) {
|
||||
} else if (CustomSliceRegistry.ZEN_MODE_SLICE_URI.equals(sliceUri)) {
|
||||
return ZenModeSliceBuilder.getSlice(getContext());
|
||||
} else if (BluetoothSliceBuilder.BLUETOOTH_URI.equals(sliceUri)) {
|
||||
} else if (CustomSliceRegistry.BLUETOOTH_URI.equals(sliceUri)) {
|
||||
return BluetoothSliceBuilder.getSlice(getContext());
|
||||
} else if (LocationSliceBuilder.LOCATION_URI.equals(sliceUri)) {
|
||||
} else if (CustomSliceRegistry.LOCATION_SLICE_URI.equals(sliceUri)) {
|
||||
return LocationSliceBuilder.getSlice(getContext());
|
||||
} else if (Enhanced4gLteSliceHelper.SLICE_URI.equals(sliceUri)) {
|
||||
} else if (CustomSliceRegistry.ENHANCED_4G_SLICE_URI.equals(sliceUri)) {
|
||||
return FeatureFactory.getFactory(getContext())
|
||||
.getSlicesFeatureProvider()
|
||||
.getNewEnhanced4gLteSliceHelper(getContext())
|
||||
.createEnhanced4gLteSlice(sliceUri);
|
||||
} else if (WifiCallingSliceHelper.WIFI_CALLING_PREFERENCE_URI.equals(sliceUri)) {
|
||||
} else if (CustomSliceRegistry.WIFI_CALLING_PREFERENCE_URI.equals(sliceUri)) {
|
||||
return FeatureFactory.getFactory(getContext())
|
||||
.getSlicesFeatureProvider()
|
||||
.getNewWifiCallingSliceHelper(getContext())
|
||||
.createWifiCallingPreferenceSlice(sliceUri);
|
||||
} else if (FlashlightSliceBuilder.FLASHLIGHT_URI.equals(sliceUri)) {
|
||||
} else if (CustomSliceRegistry.FLASHLIGHT_SLICE_URI.equals(sliceUri)) {
|
||||
return FlashlightSliceBuilder.getSlice(getContext());
|
||||
} else if (EmergencyInfoSlice.EMERGENCY_INFO_CARD_URI.equals(sliceUri)) {
|
||||
} else if (CustomSliceRegistry.EMERGENCY_INFO_SLICE_URI.equals(sliceUri)) {
|
||||
return EmergencyInfoSlice.getSlice(getContext());
|
||||
}
|
||||
|
||||
@@ -476,16 +471,16 @@ public class SettingsSliceProvider extends SliceProvider {
|
||||
|
||||
private List<Uri> getSpecialCasePlatformUris() {
|
||||
return Arrays.asList(
|
||||
WifiSlice.WIFI_URI,
|
||||
BluetoothSliceBuilder.BLUETOOTH_URI,
|
||||
LocationSliceBuilder.LOCATION_URI
|
||||
CustomSliceRegistry.WIFI_SLICE_URI,
|
||||
CustomSliceRegistry.BLUETOOTH_URI,
|
||||
CustomSliceRegistry.LOCATION_SLICE_URI
|
||||
);
|
||||
}
|
||||
|
||||
private List<Uri> getSpecialCaseOemUris() {
|
||||
return Arrays.asList(
|
||||
ZenModeSliceBuilder.ZEN_MODE_URI,
|
||||
FlashlightSliceBuilder.FLASHLIGHT_URI
|
||||
CustomSliceRegistry.ZEN_MODE_SLICE_URI,
|
||||
CustomSliceRegistry.FLASHLIGHT_SLICE_URI
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -62,11 +62,11 @@ public class SliceDeepLinkSpringBoard extends Activity {
|
||||
final CustomSliceable sliceable =
|
||||
customSliceManager.getSliceableFromUri(sliceUri);
|
||||
launchIntent = sliceable.getIntent();
|
||||
} else if (ZenModeSliceBuilder.ZEN_MODE_URI.equals(sliceUri)) {
|
||||
} else if (CustomSliceRegistry.ZEN_MODE_SLICE_URI.equals(sliceUri)) {
|
||||
launchIntent = ZenModeSliceBuilder.getIntent(this /* context */);
|
||||
} else if (BluetoothSliceBuilder.BLUETOOTH_URI.equals(sliceUri)) {
|
||||
} else if (CustomSliceRegistry.BLUETOOTH_URI.equals(sliceUri)) {
|
||||
launchIntent = BluetoothSliceBuilder.getIntent(this /* context */);
|
||||
} else if (LocationSliceBuilder.LOCATION_URI.equals(sliceUri)) {
|
||||
} else if (CustomSliceRegistry.LOCATION_SLICE_URI.equals(sliceUri)) {
|
||||
launchIntent = LocationSliceBuilder.getIntent(this /* context */);
|
||||
} else {
|
||||
final SlicesDatabaseAccessor slicesDatabaseAccessor =
|
||||
|
||||
Reference in New Issue
Block a user