Merge "Handle night display state when timezone changes" into oc-mr1-dev

This commit is contained in:
Christine Franks
2017-09-20 00:23:29 +00:00
committed by Android (Google) Code Review
5 changed files with 47 additions and 21 deletions

View File

@@ -58,6 +58,7 @@ import com.android.settings.testutils.shadow.ShadowSecureSettings;
import com.android.settingslib.drawer.Tile;
import com.android.settingslib.suggestions.SuggestionParser;
import java.time.LocalDateTime;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -402,14 +403,35 @@ public class SuggestionFeatureProviderImplTest {
}
@Test
public void hasUsedNightDisplay_returnsTrue_ifPreviouslyActivated() {
Secure.putLong(mContext.getContentResolver(), Secure.NIGHT_DISPLAY_LAST_ACTIVATED_TIME, 1L);
public void hasUsedNightDisplay_returnsTrue_ifPreviouslyActivatedAndManual() {
Secure.putString(mContext.getContentResolver(), Secure.NIGHT_DISPLAY_LAST_ACTIVATED_TIME,
LocalDateTime.now().toString());
Secure.putInt(mContext.getContentResolver(), Secure.NIGHT_DISPLAY_AUTO_MODE, 1);
assertThat(mProvider.hasUsedNightDisplay(mContext)).isTrue();
}
@Test
public void nightDisplaySuggestion_isCompleted_ifPreviouslyActivated() {
Secure.putLong(mContext.getContentResolver(), Secure.NIGHT_DISPLAY_LAST_ACTIVATED_TIME, 1L);
Secure.putString(mContext.getContentResolver(), Secure.NIGHT_DISPLAY_LAST_ACTIVATED_TIME,
LocalDateTime.now().toString());
final ComponentName componentName =
new ComponentName(mContext, NightDisplaySuggestionActivity.class);
assertThat(mProvider.isSuggestionCompleted(mContext, componentName)).isTrue();
}
@Test
public void nightDisplaySuggestion_isCompleted_ifNonManualMode() {
Secure.putInt(mContext.getContentResolver(), Secure.NIGHT_DISPLAY_AUTO_MODE, 1);
final ComponentName componentName =
new ComponentName(mContext, NightDisplaySuggestionActivity.class);
assertThat(mProvider.isSuggestionCompleted(mContext, componentName)).isTrue();
}
@Test
public void nightDisplaySuggestion_isCompleted_ifPreviouslyCleared() {
Secure.putString(mContext.getContentResolver(), Secure.NIGHT_DISPLAY_LAST_ACTIVATED_TIME,
null);
Secure.putInt(mContext.getContentResolver(), Secure.NIGHT_DISPLAY_AUTO_MODE, 1);
final ComponentName componentName =
new ComponentName(mContext, NightDisplaySuggestionActivity.class);
assertThat(mProvider.isSuggestionCompleted(mContext, componentName)).isTrue();

View File

@@ -36,7 +36,11 @@ public class ShadowSecureSettings {
int userHandle) {
final Table<Integer, String, Object> userTable = getUserTable(resolver);
synchronized (userTable) {
userTable.put(userHandle, name, value);
if (value != null) {
userTable.put(userHandle, name, value);
} else {
userTable.remove(userHandle, name);
}
return true;
}
}