Merge "Add missing Settings constants." into tm-dev am: ef3ac99de6
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17665790 Change-Id: Ia2a1f48c8569439d408420735e3b196b87b0df6e Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -1173,7 +1173,62 @@ public final class DevicePolicyResources {
|
|||||||
/**
|
/**
|
||||||
* Header for items under the personal user
|
* Header for items under the personal user
|
||||||
*/
|
*/
|
||||||
public static final String PERSONAL_CATEGORY_HEADER = PREFIX + "category_personal";
|
public static final String PERSONAL_CATEGORY_HEADER = PREFIX + "CATEGORY_PERSONAL";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Text to indicate work notification content will be shown on the lockscreen.
|
||||||
|
*/
|
||||||
|
public static final String LOCK_SCREEN_SHOW_WORK_NOTIFICATION_CONTENT =
|
||||||
|
PREFIX + "LOCK_SCREEN_SHOW_WORK_NOTIFICATION_CONTENT";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Text to indicate work notification content will be shown on the lockscreen.
|
||||||
|
*/
|
||||||
|
public static final String LOCK_SCREEN_HIDE_WORK_NOTIFICATION_CONTENT =
|
||||||
|
PREFIX + "LOCK_SCREEN_HIDE_WORK_NOTIFICATION_CONTENT";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Text for toggle to enable auto-sycing personal data
|
||||||
|
*/
|
||||||
|
public static final String AUTO_SYNC_PERSONAL_DATA = PREFIX
|
||||||
|
+ "AUTO_SYNC_PERSONAL_DATA";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Text for toggle to enable auto-sycing work data
|
||||||
|
*/
|
||||||
|
public static final String AUTO_SYNC_WORK_DATA = PREFIX
|
||||||
|
+ "AUTO_SYNC_WORK_DATA";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Summary for "More security settings" section when a work profile is on the device.
|
||||||
|
*/
|
||||||
|
public static final String MORE_SECURITY_SETTINGS_WORK_PROFILE_SUMMARY = PREFIX
|
||||||
|
+ "MORE_SECURITY_SETTINGS_WORK_PROFILE_SUMMARY";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Title for screen asking the user to choose a type of screen lock (such as a pattern,
|
||||||
|
* PIN, or password) that they need to enter to use their work apps
|
||||||
|
*/
|
||||||
|
public static final String LOCK_SETTINGS_NEW_PROFILE_LOCK_TITLE = PREFIX
|
||||||
|
+ "LOCK_SETTINGS_NEW_PROFILE_LOCK_TITLE";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Title for section listing information that can be seen by organization
|
||||||
|
*/
|
||||||
|
public static final String INFORMATION_SEEN_BY_ORGANIZATION_TITLE = PREFIX
|
||||||
|
+ "information_seen_by_organization_title";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Title for section listing changes made by the organization.
|
||||||
|
*/
|
||||||
|
public static final String CHANGES_BY_ORGANIZATION_TITLE =
|
||||||
|
PREFIX + "CHANGES_BY_ORGANIZATION_TITLE";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Footer for enterprise privacy screen.
|
||||||
|
*/
|
||||||
|
public static final String ENTERPRISE_PRIVACY_FOOTER =
|
||||||
|
PREFIX + "ENTERPRISE_PRIVACY_FOOTER";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,9 +1,13 @@
|
|||||||
package com.android.settingslib.core;
|
package com.android.settingslib.core;
|
||||||
|
|
||||||
|
import android.app.admin.DevicePolicyManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.os.Build;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import androidx.annotation.RequiresApi;
|
||||||
|
import androidx.core.os.BuildCompat;
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
import androidx.preference.PreferenceGroup;
|
import androidx.preference.PreferenceGroup;
|
||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
@@ -16,9 +20,12 @@ public abstract class AbstractPreferenceController {
|
|||||||
private static final String TAG = "AbstractPrefController";
|
private static final String TAG = "AbstractPrefController";
|
||||||
|
|
||||||
protected final Context mContext;
|
protected final Context mContext;
|
||||||
|
private final DevicePolicyManager mDevicePolicyManager;
|
||||||
|
|
||||||
public AbstractPreferenceController(Context context) {
|
public AbstractPreferenceController(Context context) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
|
mDevicePolicyManager =
|
||||||
|
(DevicePolicyManager) mContext.getSystemService(Context.DEVICE_POLICY_SERVICE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -102,4 +109,40 @@ public abstract class AbstractPreferenceController {
|
|||||||
public CharSequence getSummary() {
|
public CharSequence getSummary() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequiresApi(Build.VERSION_CODES.TIRAMISU)
|
||||||
|
protected void replaceEnterpriseStringTitle(PreferenceScreen screen,
|
||||||
|
String preferenceKey, String overrideKey, int resource) {
|
||||||
|
if (!BuildCompat.isAtLeastT() || mDevicePolicyManager == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Preference preference = screen.findPreference(preferenceKey);
|
||||||
|
if (preference == null) {
|
||||||
|
Log.d(TAG, "Could not find enterprise preference " + preferenceKey);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
preference.setTitle(
|
||||||
|
mDevicePolicyManager.getResources().getString(overrideKey,
|
||||||
|
() -> mContext.getString(resource)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequiresApi(Build.VERSION_CODES.TIRAMISU)
|
||||||
|
protected void replaceEnterpriseStringSummary(
|
||||||
|
PreferenceScreen screen, String preferenceKey, String overrideKey, int resource) {
|
||||||
|
if (!BuildCompat.isAtLeastT() || mDevicePolicyManager == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Preference preference = screen.findPreference(preferenceKey);
|
||||||
|
if (preference == null) {
|
||||||
|
Log.d(TAG, "Could not find enterprise preference " + preferenceKey);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
preference.setSummary(
|
||||||
|
mDevicePolicyManager.getResources().getString(overrideKey,
|
||||||
|
() -> mContext.getString(resource)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,12 +16,16 @@
|
|||||||
|
|
||||||
package com.android.settingslib;
|
package com.android.settingslib;
|
||||||
|
|
||||||
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
|
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
|
||||||
|
import static org.mockito.Mockito.doReturn;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.never;
|
import static org.mockito.Mockito.never;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
import android.app.admin.DevicePolicyManager;
|
||||||
|
import android.app.admin.DevicePolicyResourcesManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
@@ -30,7 +34,6 @@ import androidx.preference.Preference;
|
|||||||
import androidx.preference.PreferenceViewHolder;
|
import androidx.preference.PreferenceViewHolder;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Ignore;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
@@ -45,6 +48,10 @@ public class RestrictedPreferenceHelperTest {
|
|||||||
@Mock
|
@Mock
|
||||||
private Preference mPreference;
|
private Preference mPreference;
|
||||||
@Mock
|
@Mock
|
||||||
|
private DevicePolicyManager mDevicePolicyManager;
|
||||||
|
@Mock
|
||||||
|
private DevicePolicyResourcesManager mDevicePolicyResourcesManager;
|
||||||
|
@Mock
|
||||||
private RestrictedTopLevelPreference mRestrictedTopLevelPreference;
|
private RestrictedTopLevelPreference mRestrictedTopLevelPreference;
|
||||||
|
|
||||||
private PreferenceViewHolder mViewHolder;
|
private PreferenceViewHolder mViewHolder;
|
||||||
@@ -53,18 +60,22 @@ public class RestrictedPreferenceHelperTest {
|
|||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
|
doReturn(mDevicePolicyResourcesManager).when(mDevicePolicyManager)
|
||||||
|
.getResources();
|
||||||
|
doReturn(mDevicePolicyManager).when(mContext)
|
||||||
|
.getSystemService(DevicePolicyManager.class);
|
||||||
mViewHolder = PreferenceViewHolder.createInstanceForTests(mock(View.class));
|
mViewHolder = PreferenceViewHolder.createInstanceForTests(mock(View.class));
|
||||||
mHelper = new RestrictedPreferenceHelper(mContext, mPreference, null);
|
mHelper = new RestrictedPreferenceHelper(mContext, mPreference, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore
|
|
||||||
public void bindPreference_disabled_shouldDisplayDisabledSummary() {
|
public void bindPreference_disabled_shouldDisplayDisabledSummary() {
|
||||||
final TextView summaryView = mock(TextView.class, RETURNS_DEEP_STUBS);
|
final TextView summaryView = mock(TextView.class, RETURNS_DEEP_STUBS);
|
||||||
when(mViewHolder.itemView.findViewById(android.R.id.summary))
|
when(mViewHolder.itemView.findViewById(android.R.id.summary))
|
||||||
.thenReturn(summaryView);
|
.thenReturn(summaryView);
|
||||||
when(summaryView.getContext().getText(R.string.disabled_by_admin_summary_text))
|
when(summaryView.getContext().getText(R.string.disabled_by_admin_summary_text))
|
||||||
.thenReturn("test");
|
.thenReturn("test");
|
||||||
|
when(mDevicePolicyResourcesManager.getString(any(), any())).thenReturn("test");
|
||||||
|
|
||||||
mHelper.useAdminDisabledSummary(true);
|
mHelper.useAdminDisabledSummary(true);
|
||||||
mHelper.setDisabledByAdmin(new RestrictedLockUtils.EnforcedAdmin());
|
mHelper.setDisabledByAdmin(new RestrictedLockUtils.EnforcedAdmin());
|
||||||
@@ -75,13 +86,13 @@ public class RestrictedPreferenceHelperTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore
|
|
||||||
public void bindPreference_notDisabled_shouldNotHideSummary() {
|
public void bindPreference_notDisabled_shouldNotHideSummary() {
|
||||||
final TextView summaryView = mock(TextView.class, RETURNS_DEEP_STUBS);
|
final TextView summaryView = mock(TextView.class, RETURNS_DEEP_STUBS);
|
||||||
when(mViewHolder.itemView.findViewById(android.R.id.summary))
|
when(mViewHolder.itemView.findViewById(android.R.id.summary))
|
||||||
.thenReturn(summaryView);
|
.thenReturn(summaryView);
|
||||||
when(summaryView.getContext().getText(R.string.disabled_by_admin_summary_text))
|
when(summaryView.getContext().getText(R.string.disabled_by_admin_summary_text))
|
||||||
.thenReturn("test");
|
.thenReturn("test");
|
||||||
|
when(mDevicePolicyResourcesManager.getString(any(), any())).thenReturn("test");
|
||||||
when(summaryView.getText()).thenReturn("test");
|
when(summaryView.getText()).thenReturn("test");
|
||||||
|
|
||||||
mHelper.useAdminDisabledSummary(true);
|
mHelper.useAdminDisabledSummary(true);
|
||||||
|
|||||||
Reference in New Issue
Block a user