Merge "Make summary text update after settings changes" into pi-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
b915f3566b
@@ -27,6 +27,7 @@ import static com.android.settings.wifi.WifiSliceBuilder.ACTION_WIFI_SLICE_CHANG
|
||||
|
||||
import android.app.slice.Slice;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
@@ -155,6 +156,7 @@ public class SliceBroadcastReceiver extends BroadcastReceiver {
|
||||
|
||||
sliderController.setSliderPosition(newPosition);
|
||||
logSliceValueChange(context, key, newPosition);
|
||||
updateUri(context, key, isPlatformSlice);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -177,8 +179,15 @@ public class SliceBroadcastReceiver extends BroadcastReceiver {
|
||||
}
|
||||
|
||||
private void updateUri(Context context, String key, boolean isPlatformDefined) {
|
||||
final String path = SettingsSlicesContract.PATH_SETTING_ACTION + "/" + key;
|
||||
final Uri uri = SliceBuilderUtils.getUri(path, isPlatformDefined);
|
||||
final String authority = isPlatformDefined
|
||||
? SettingsSlicesContract.AUTHORITY
|
||||
: SettingsSliceProvider.SLICE_AUTHORITY;
|
||||
final Uri uri = new Uri.Builder()
|
||||
.scheme(ContentResolver.SCHEME_CONTENT)
|
||||
.authority(authority)
|
||||
.appendPath(SettingsSlicesContract.PATH_SETTING_ACTION)
|
||||
.appendPath(key)
|
||||
.build();
|
||||
context.getContentResolver().notifyChange(uri, null /* observer */);
|
||||
}
|
||||
}
|
||||
|
@@ -96,8 +96,16 @@ public class SliceBroadcastReceiverTest {
|
||||
@Test
|
||||
public void onReceive_toggleChanged() {
|
||||
final String key = "key";
|
||||
final Uri uri = new Uri.Builder()
|
||||
.scheme(ContentResolver.SCHEME_CONTENT)
|
||||
.authority(SettingsSliceProvider.SLICE_AUTHORITY)
|
||||
.appendPath(SettingsSlicesContract.PATH_SETTING_ACTION)
|
||||
.appendPath(key)
|
||||
.build();
|
||||
mSearchFeatureProvider.getSearchIndexableResources().getProviderValues().clear();
|
||||
insertSpecialCase(key);
|
||||
final ContentResolver resolver = mock(ContentResolver.class);
|
||||
doReturn(resolver).when(mContext).getContentResolver();
|
||||
// Turn on toggle setting
|
||||
FakeToggleController fakeToggleController = new FakeToggleController(mContext, key);
|
||||
fakeToggleController.setChecked(true);
|
||||
@@ -121,6 +129,7 @@ public class SliceBroadcastReceiverTest {
|
||||
assertThat(namePair.first).isEqualTo(MetricsEvent.FIELD_SETTINGS_PREFERENCE_CHANGE_NAME);
|
||||
assertThat(namePair.second).isEqualTo(fakeToggleController.getPreferenceKey());
|
||||
|
||||
verify(resolver).notifyChange(uri, null);
|
||||
assertThat(valuePair.first)
|
||||
.isEqualTo(MetricsEvent.FIELD_SETTINGS_PREFERENCE_CHANGE_INT_VALUE);
|
||||
assertThat(valuePair.second).isEqualTo(0);
|
||||
@@ -183,6 +192,14 @@ public class SliceBroadcastReceiverTest {
|
||||
@Test
|
||||
public void onReceive_sliderChanged() {
|
||||
final String key = "key";
|
||||
final Uri uri = new Uri.Builder()
|
||||
.scheme(ContentResolver.SCHEME_CONTENT)
|
||||
.authority(SettingsSliceProvider.SLICE_AUTHORITY)
|
||||
.appendPath(SettingsSlicesContract.PATH_SETTING_ACTION)
|
||||
.appendPath(key)
|
||||
.build();
|
||||
final ContentResolver resolver = mock(ContentResolver.class);
|
||||
doReturn(resolver).when(mContext).getContentResolver();
|
||||
final int position = FakeSliderController.MAX_STEPS - 1;
|
||||
final int oldPosition = FakeSliderController.MAX_STEPS;
|
||||
mSearchFeatureProvider.getSearchIndexableResources().getProviderValues().clear();
|
||||
@@ -213,6 +230,7 @@ public class SliceBroadcastReceiverTest {
|
||||
assertThat(namePair.first).isEqualTo(MetricsEvent.FIELD_SETTINGS_PREFERENCE_CHANGE_NAME);
|
||||
assertThat(namePair.second).isEqualTo(key);
|
||||
|
||||
verify(resolver).notifyChange(uri, null);
|
||||
assertThat(valuePair.first)
|
||||
.isEqualTo(MetricsEvent.FIELD_SETTINGS_PREFERENCE_CHANGE_INT_VALUE);
|
||||
assertThat(valuePair.second).isEqualTo(position);
|
||||
@@ -286,8 +304,12 @@ public class SliceBroadcastReceiverTest {
|
||||
|
||||
// Check the value is the same and the Uri has been notified.
|
||||
assertThat(fakeToggleController.isChecked()).isTrue();
|
||||
final Uri expectedUri = SliceBuilderUtils.getUri(
|
||||
SettingsSlicesContract.PATH_SETTING_ACTION + "/" + key, false);
|
||||
final Uri expectedUri = new Uri.Builder()
|
||||
.scheme(ContentResolver.SCHEME_CONTENT)
|
||||
.authority(SettingsSliceProvider.SLICE_AUTHORITY)
|
||||
.appendPath(SettingsSlicesContract.PATH_SETTING_ACTION)
|
||||
.appendPath(key)
|
||||
.build();
|
||||
verify(resolver).notifyChange(eq(expectedUri), eq(null));
|
||||
}
|
||||
|
||||
@@ -323,8 +345,12 @@ public class SliceBroadcastReceiverTest {
|
||||
|
||||
// Check position is the same and the Uri has been notified.
|
||||
assertThat(fakeSliderController.getSliderPosition()).isEqualTo(oldPosition);
|
||||
final Uri expectedUri = SliceBuilderUtils.getUri(
|
||||
SettingsSlicesContract.PATH_SETTING_ACTION + "/" + key, false);
|
||||
final Uri expectedUri = new Uri.Builder()
|
||||
.scheme(ContentResolver.SCHEME_CONTENT)
|
||||
.authority(SettingsSliceProvider.SLICE_AUTHORITY)
|
||||
.appendPath(SettingsSlicesContract.PATH_SETTING_ACTION)
|
||||
.appendPath(key)
|
||||
.build();
|
||||
verify(resolver).notifyChange(eq(expectedUri), eq(null));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user