Merge "Brings back "Control from locked device" setting." into tm-qpr-dev am: d81ae0a645
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/20590947 Change-Id: I0c201a2a1fd594d81162c9e84fe5c775e602e5a3 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -50,9 +50,11 @@ public class ControlsTrivialPrivacyPreferenceController extends TogglePreference
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CharSequence getSummary() {
|
public CharSequence getSummary() {
|
||||||
if (getAvailabilityStatus() == DISABLED_DEPENDENT_SETTING) {
|
if (!CustomizableLockScreenUtils.isFeatureEnabled(mContext)
|
||||||
|
&& getAvailabilityStatus() == DISABLED_DEPENDENT_SETTING) {
|
||||||
return mContext.getText(R.string.lockscreen_trivial_disabled_controls_summary);
|
return mContext.getText(R.string.lockscreen_trivial_disabled_controls_summary);
|
||||||
}
|
}
|
||||||
|
|
||||||
return mContext.getText(R.string.lockscreen_trivial_controls_summary);
|
return mContext.getText(R.string.lockscreen_trivial_controls_summary);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,21 +72,22 @@ public class ControlsTrivialPrivacyPreferenceController extends TogglePreference
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getAvailabilityStatus() {
|
public int getAvailabilityStatus() {
|
||||||
if (CustomizableLockScreenUtils.isFeatureEnabled(mContext)) {
|
|
||||||
return UNSUPPORTED_ON_DEVICE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return showDeviceControlsSettingsEnabled() ? AVAILABLE : DISABLED_DEPENDENT_SETTING;
|
return showDeviceControlsSettingsEnabled() ? AVAILABLE : DISABLED_DEPENDENT_SETTING;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean showDeviceControlsSettingsEnabled() {
|
private boolean showDeviceControlsSettingsEnabled() {
|
||||||
return Settings.Secure.getInt(mContext.getContentResolver(), DEPENDENCY_SETTING_KEY, 0)
|
return CustomizableLockScreenUtils.isFeatureEnabled(mContext)
|
||||||
!= 0;
|
|| Settings.Secure.getInt(
|
||||||
|
mContext.getContentResolver(), DEPENDENCY_SETTING_KEY, 0) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void displayPreference(PreferenceScreen screen) {
|
public void displayPreference(PreferenceScreen screen) {
|
||||||
super.displayPreference(screen);
|
super.displayPreference(screen);
|
||||||
|
if (CustomizableLockScreenUtils.isFeatureEnabled(mContext)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Preference currentPreference = screen.findPreference(getPreferenceKey());
|
Preference currentPreference = screen.findPreference(getPreferenceKey());
|
||||||
currentPreference.setDependency("lockscreen_privacy_controls_switch");
|
currentPreference.setDependency("lockscreen_privacy_controls_switch");
|
||||||
}
|
}
|
||||||
|
@@ -21,10 +21,14 @@ import static com.google.common.truth.Truth.assertThat;
|
|||||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||||
import static org.mockito.ArgumentMatchers.anyString;
|
import static org.mockito.ArgumentMatchers.anyString;
|
||||||
import static org.mockito.Mockito.atLeastOnce;
|
import static org.mockito.Mockito.atLeastOnce;
|
||||||
|
import static org.mockito.Mockito.spy;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.database.Cursor;
|
||||||
|
import android.database.MatrixCursor;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
|
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
@@ -40,6 +44,7 @@ import org.junit.runner.RunWith;
|
|||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
|
import org.mockito.stubbing.Answer;
|
||||||
import org.robolectric.RobolectricTestRunner;
|
import org.robolectric.RobolectricTestRunner;
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricTestRunner.class)
|
||||||
@@ -62,9 +67,11 @@ public class ControlsTrivialPrivacyPreferenceControllerTest {
|
|||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
mContext = ApplicationProvider.getApplicationContext();
|
mContext = spy(ApplicationProvider.getApplicationContext());
|
||||||
|
mContentResolver = spy(mContext.getContentResolver());
|
||||||
|
when(mContext.getContentResolver()).thenReturn(mContentResolver);
|
||||||
|
|
||||||
mContentResolver = mContext.getContentResolver();
|
setCustomizableLockScreenQuickAffordancesEnabled(false);
|
||||||
|
|
||||||
mController = new ControlsTrivialPrivacyPreferenceController(mContext, TEST_KEY);
|
mController = new ControlsTrivialPrivacyPreferenceController(mContext, TEST_KEY);
|
||||||
}
|
}
|
||||||
@@ -130,6 +137,18 @@ public class ControlsTrivialPrivacyPreferenceControllerTest {
|
|||||||
verify(mPreference, atLeastOnce()).setSummary(mController.getSummary());
|
verify(mPreference, atLeastOnce()).setSummary(mController.getSummary());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updateStateWithCustomizableLockScreenQuickAffordancesEnabled() {
|
||||||
|
setCustomizableLockScreenQuickAffordancesEnabled(true);
|
||||||
|
Settings.Secure.putInt(mContentResolver, DEPENDENCY_SETTING_KEY, 0);
|
||||||
|
|
||||||
|
mController.updateState(mPreference);
|
||||||
|
|
||||||
|
verify(mPreference).setEnabled(true);
|
||||||
|
verify(mPreference, atLeastOnce()).setSummary(
|
||||||
|
mContext.getString(R.string.lockscreen_trivial_controls_summary));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getAvailabilityStatusWithoutDeviceControls() {
|
public void getAvailabilityStatusWithoutDeviceControls() {
|
||||||
Settings.Secure.putInt(mContentResolver, DEPENDENCY_SETTING_KEY, 0);
|
Settings.Secure.putInt(mContentResolver, DEPENDENCY_SETTING_KEY, 0);
|
||||||
@@ -138,6 +157,15 @@ public class ControlsTrivialPrivacyPreferenceControllerTest {
|
|||||||
BasePreferenceController.DISABLED_DEPENDENT_SETTING);
|
BasePreferenceController.DISABLED_DEPENDENT_SETTING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getAvailabilityStatusWithCustomizableLockScreenQuickAffordancesEnabled() {
|
||||||
|
setCustomizableLockScreenQuickAffordancesEnabled(true);
|
||||||
|
Settings.Secure.putInt(mContentResolver, DEPENDENCY_SETTING_KEY, 0);
|
||||||
|
|
||||||
|
assertThat(mController.getAvailabilityStatus()).isEqualTo(
|
||||||
|
BasePreferenceController.AVAILABLE);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getAvailabilityStatusWithDeviceControls() {
|
public void getAvailabilityStatusWithDeviceControls() {
|
||||||
Settings.Secure.putInt(mContentResolver, DEPENDENCY_SETTING_KEY, 1);
|
Settings.Secure.putInt(mContentResolver, DEPENDENCY_SETTING_KEY, 1);
|
||||||
@@ -154,4 +182,22 @@ public class ControlsTrivialPrivacyPreferenceControllerTest {
|
|||||||
mController.displayPreference(mPreferenceScreen);
|
mController.displayPreference(mPreferenceScreen);
|
||||||
verify(mPreference).setDependency(anyString());
|
verify(mPreference).setDependency(anyString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setCustomizableLockScreenQuickAffordancesEnabled(boolean isEnabled) {
|
||||||
|
when(
|
||||||
|
mContentResolver.query(
|
||||||
|
CustomizableLockScreenUtils.FLAGS_URI, null, null, null))
|
||||||
|
.thenAnswer((Answer<Cursor>) invocation -> {
|
||||||
|
final MatrixCursor cursor = new MatrixCursor(
|
||||||
|
new String[] {
|
||||||
|
CustomizableLockScreenUtils.NAME,
|
||||||
|
CustomizableLockScreenUtils.VALUE
|
||||||
|
});
|
||||||
|
cursor.addRow(
|
||||||
|
new Object[] {
|
||||||
|
CustomizableLockScreenUtils.ENABLED_FLAG, isEnabled ? 1 : 0
|
||||||
|
});
|
||||||
|
return cursor;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user