Override 2 getSliceUri() instance to return platform slice
Bug: 126222433 Test: robotest Change-Id: I3f9c8202d9b75b24b80ebcf385abc95f8df851e2
This commit is contained in:
@@ -37,8 +37,7 @@
|
||||
android:fragment="com.android.settings.fuelgauge.batterysaver.BatterySaverSettings"
|
||||
android:key="battery_saver_summary"
|
||||
android:title="@string/battery_saver"
|
||||
settings:controller="com.android.settings.fuelgauge.BatterySaverController"
|
||||
settings:platform_slice="true" />
|
||||
settings:controller="com.android.settings.fuelgauge.BatterySaverController" />
|
||||
|
||||
<Preference
|
||||
android:fragment="com.android.settings.fuelgauge.SmartBatterySettings"
|
||||
|
@@ -16,8 +16,11 @@
|
||||
|
||||
package com.android.settings.fuelgauge.batterysaver;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import android.os.PowerManager;
|
||||
import android.provider.SettingsSlicesContract;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
@@ -38,6 +41,7 @@ public class BatterySaverButtonPreferenceController extends
|
||||
LifecycleObserver, OnStart, OnStop, BatterySaverReceiver.BatterySaverListener {
|
||||
|
||||
private final BatterySaverReceiver mBatterySaverReceiver;
|
||||
|
||||
private final PowerManager mPowerManager;
|
||||
|
||||
private TwoStateButtonPreference mPreference;
|
||||
@@ -59,6 +63,16 @@ public class BatterySaverButtonPreferenceController extends
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Uri getSliceUri() {
|
||||
return new Uri.Builder()
|
||||
.scheme(ContentResolver.SCHEME_CONTENT)
|
||||
.authority(SettingsSlicesContract.AUTHORITY)
|
||||
.appendPath(SettingsSlicesContract.PATH_SETTING_ACTION)
|
||||
.appendPath(SettingsSlicesContract.KEY_BATTERY_SAVER)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
mBatterySaverReceiver.setListening(true);
|
||||
|
@@ -17,10 +17,13 @@ package com.android.settings.network;
|
||||
|
||||
import static android.provider.SettingsSlicesContract.KEY_AIRPLANE_MODE;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import android.os.SystemProperties;
|
||||
import android.provider.SettingsSlicesContract;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.preference.Preference;
|
||||
@@ -44,6 +47,15 @@ public class AirplaneModePreferenceController extends TogglePreferenceController
|
||||
|
||||
public static final int REQUEST_CODE_EXIT_ECM = 1;
|
||||
|
||||
/**
|
||||
* Uri for Airplane mode Slice.
|
||||
*/
|
||||
public static final Uri SLICE_URI = new Uri.Builder()
|
||||
.scheme(ContentResolver.SCHEME_CONTENT)
|
||||
.authority(SettingsSlicesContract.AUTHORITY)
|
||||
.appendPath(SettingsSlicesContract.PATH_SETTING_ACTION)
|
||||
.appendPath(SettingsSlicesContract.KEY_AIRPLANE_MODE)
|
||||
.build();
|
||||
private static final String EXIT_ECM_RESULT = "exit_ecm_result";
|
||||
|
||||
private Fragment mFragment;
|
||||
@@ -77,6 +89,11 @@ public class AirplaneModePreferenceController extends TogglePreferenceController
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Uri getSliceUri() {
|
||||
return SLICE_URI;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void displayPreference(PreferenceScreen screen) {
|
||||
super.displayPreference(screen);
|
||||
|
@@ -23,6 +23,7 @@ import android.net.Uri;
|
||||
import android.provider.Settings;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.network.AirplaneModePreferenceController;
|
||||
import com.android.settings.slices.CustomSliceRegistry;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -57,7 +58,7 @@ public class InternetConnectivityPanel implements PanelContent {
|
||||
final List<Uri> uris = new ArrayList<>();
|
||||
uris.add(CustomSliceRegistry.WIFI_SLICE_URI);
|
||||
uris.add(CustomSliceRegistry.MOBILE_DATA_SLICE_URI);
|
||||
uris.add(CustomSliceRegistry.AIRPLANE_URI);
|
||||
uris.add(AirplaneModePreferenceController.SLICE_URI);
|
||||
return uris;
|
||||
}
|
||||
|
||||
|
@@ -57,17 +57,7 @@ import java.util.Map;
|
||||
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 Contextual Adaptive Sleep Slice
|
||||
* Uri for Contextual Adaptive Sleep Slice
|
||||
*/
|
||||
public static final Uri CONTEXTUAL_ADAPTIVE_SLEEP_URI = new Uri.Builder()
|
||||
.scheme(ContentResolver.SCHEME_CONTENT)
|
||||
|
@@ -26,6 +26,7 @@ import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.PowerManager;
|
||||
import android.provider.SettingsSlicesContract;
|
||||
import android.widget.Button;
|
||||
|
||||
import androidx.preference.PreferenceScreen;
|
||||
@@ -72,6 +73,12 @@ public class BatterySaverButtonPreferenceControllerTest {
|
||||
mController.displayPreference(mPreferenceScreen);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSliceUri_shouldUsePlatformAuthority() {
|
||||
assertThat(mController.getSliceUri().getAuthority())
|
||||
.isEqualTo(SettingsSlicesContract.AUTHORITY);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateState_lowPowerOn_preferenceIsChecked() {
|
||||
when(mPowerManager.isPowerSaveMode()).thenReturn(true);
|
||||
|
@@ -85,6 +85,12 @@ public class AirplaneModePreferenceControllerTest {
|
||||
mLifecycle.addObserver(mController);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSliceUri_shouldUsePlatformAuthority() {
|
||||
assertThat(mController.getSliceUri().getAuthority())
|
||||
.isEqualTo(SettingsSlicesContract.AUTHORITY);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Config(qualifiers = "mcc999")
|
||||
public void airplaneModePreference_shouldNotBeAvailable_ifSetToNotVisible() {
|
||||
@@ -182,9 +188,7 @@ public class AirplaneModePreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSliceableCorrectKey_returnsTrue() {
|
||||
final AirplaneModePreferenceController controller =
|
||||
new AirplaneModePreferenceController(mContext,"toggle_airplane");
|
||||
assertThat(controller.isSliceable()).isTrue();
|
||||
public void isSliceable_returnsTrue() {
|
||||
assertThat(mController.isSliceable()).isTrue();
|
||||
}
|
||||
}
|
||||
|
@@ -21,6 +21,7 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.net.Uri;
|
||||
|
||||
import com.android.settings.network.AirplaneModePreferenceController;
|
||||
import com.android.settings.slices.CustomSliceRegistry;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -47,7 +48,7 @@ public class InternetConnectivityPanelTest {
|
||||
final List<Uri> uris = mPanel.getSlices();
|
||||
|
||||
assertThat(uris).containsExactly(
|
||||
CustomSliceRegistry.AIRPLANE_URI,
|
||||
AirplaneModePreferenceController.SLICE_URI,
|
||||
CustomSliceRegistry.MOBILE_DATA_SLICE_URI,
|
||||
CustomSliceRegistry.WIFI_SLICE_URI);
|
||||
}
|
||||
|
Reference in New Issue
Block a user