Merge "Update Privacy Settings text for a financed device" into sc-dev am: d85317e4e5
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/13879465 Change-Id: I4c4c00f7709c86669824cc18667c39c825f93726
This commit is contained in:
@@ -11542,6 +11542,25 @@
|
||||
<!-- Button label to allow the user to view additional information [CHAR LIMIT=NONE BACKUP_MESSAGE_ID=2416766240581561009] -->
|
||||
<string name="learn_more">Learn more</string>
|
||||
|
||||
<!-- Financed device Privacy --> <skip />
|
||||
|
||||
<!-- Title of setting on security settings screen on a financed device. This will take the user to a screen with information about what a device administrator can control and their impact on the user's privacy on a financed device. Shown on financed-managed devices only. [CHAR LIMIT=NONE] -->
|
||||
<string name="financed_privacy_settings">Financed device info</string>
|
||||
<!-- Section header. This section shows what information a device administrator can see on a financed device. [CHAR LIMIT=60] -->
|
||||
<string name="financed_privacy_exposure_category">Types of information your device administrator can see</string>
|
||||
<!-- Label explaining that the device administrator can see data associated on the user's financed device. [CHAR LIMIT=NONE] -->
|
||||
<string name="financed_privacy_data">Data associated with your account, such as email and calendar info</string>
|
||||
<!-- Section header. This section shows what changes a device administrator made to a financed device. [CHAR LIMIT=60] -->
|
||||
<string name="financed_privacy_exposure_changes_category">Changes made by your device administrator</string>
|
||||
<!-- Label explaining that the device admin can lock the device and change the user's password on their financed device. [CHAR LIMIT=NONE] -->
|
||||
<string name="financed_privacy_lock_device">Device administrator can lock this device and reset password</string>
|
||||
<!-- Label explaining that the device admin can wipe the device remotely for a financed device. [CHAR LIMIT=NONE] -->
|
||||
<string name="financed_privacy_wipe_device">Device administrator can delete all device data</string>
|
||||
<!-- Label explaining that the device admin configured the device to wipe itself when an incorrect password is entered too many times on a financed device. [CHAR LIMIT=NONE] -->
|
||||
<string name="financed_privacy_failed_password_wipe_device">Failed password attempts before deleting device data</string>
|
||||
<!-- Financed Privacy settings activity header, summarizing the changes a credit provider can make to a financed device. [CHAR LIMIT=NONE] -->
|
||||
<string name="financed_privacy_header">Your credit provider can change settings and install software on this device.\n\nTo learn more, contact your creditor provider.</string>
|
||||
|
||||
<!-- Strings for displaying which applications were set as default for specific actions. -->
|
||||
<!-- Title for the apps that have been set as default handlers of camera-related intents. [CHAR LIMIT=30] -->
|
||||
<plurals name="default_camera_app_title">
|
||||
|
84
res/xml/financed_privacy_settings.xml
Normal file
84
res/xml/financed_privacy_settings.xml
Normal file
@@ -0,0 +1,84 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright (C) 2021 The Android Open Source Project
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
||||
android:title="@string/financed_privacy_settings">
|
||||
|
||||
<PreferenceCategory android:key="exposure_category"
|
||||
android:order="200"
|
||||
android:title="@string/financed_privacy_exposure_category"
|
||||
android:contentDescription="@string/financed_privacy_exposure_category">
|
||||
<Preference android:key="enterprise_privacy_enterprise_data"
|
||||
android:order="210"
|
||||
android:layout_height="wrap_content"
|
||||
android:title="@string/financed_privacy_data"
|
||||
android:selectable="false"/>
|
||||
<Preference android:key="enterprise_privacy_installed_packages"
|
||||
android:order="220"
|
||||
android:title="@string/enterprise_privacy_installed_packages"
|
||||
android:selectable="false"/>
|
||||
<Preference android:key="enterprise_privacy_usage_stats"
|
||||
android:order="230"
|
||||
android:title="@string/enterprise_privacy_usage_stats"
|
||||
android:selectable="false"/>
|
||||
<Preference android:key="network_logs"
|
||||
android:order="240"
|
||||
android:title="@string/enterprise_privacy_network_logs"
|
||||
android:selectable="false"/>
|
||||
<Preference android:key="bug_reports"
|
||||
android:order="250"
|
||||
android:title="@string/enterprise_privacy_bug_reports"
|
||||
android:selectable="false"/>
|
||||
<Preference android:key="security_logs"
|
||||
android:order="260"
|
||||
android:title="@string/enterprise_privacy_security_logs"
|
||||
android:selectable="false"/>
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory android:title="@string/financed_privacy_exposure_changes_category"
|
||||
android:order="300"
|
||||
android:key="exposure_changes_category">
|
||||
<Preference android:fragment="com.android.settings.enterprise.ApplicationListFragment$EnterpriseInstalledPackages"
|
||||
android:order="310"
|
||||
android:key="number_enterprise_installed_packages"
|
||||
android:title="@string/enterprise_privacy_enterprise_installed_packages"/>
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory android:key="device_access_category"
|
||||
android:order="500"
|
||||
android:title="@string/enterprise_privacy_device_access_category">
|
||||
<Preference android:key="enterprise_privacy_lock_device"
|
||||
android:order="510"
|
||||
android:title="@string/financed_privacy_lock_device"
|
||||
android:selectable="false"/>
|
||||
<Preference android:key="enterprise_privacy_wipe_device"
|
||||
android:order="520"
|
||||
android:title="@string/financed_privacy_wipe_device"
|
||||
android:selectable="false"/>
|
||||
<Preference android:key="failed_password_wipe_current_user"
|
||||
android:order="530"
|
||||
android:title="@string/financed_privacy_failed_password_wipe_device"
|
||||
android:selectable="false"/>
|
||||
</PreferenceCategory>
|
||||
|
||||
<com.android.settingslib.widget.FooterPreference
|
||||
android:key="financed_privacy_footer"
|
||||
android:title="@string/financed_privacy_header"
|
||||
android:selectable="false"
|
||||
settings:searchable="false"/>
|
||||
</PreferenceScreen>
|
@@ -20,16 +20,13 @@ import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.provider.SearchIndexableResource;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settings.widget.PreferenceCategoryController;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
import com.android.settingslib.search.SearchIndexable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@SearchIndexable
|
||||
@@ -37,6 +34,23 @@ public class EnterprisePrivacySettings extends DashboardFragment {
|
||||
|
||||
static final String TAG = "EnterprisePrivacySettings";
|
||||
|
||||
@VisibleForTesting
|
||||
PrivacySettingsPreference mPrivacySettingsPreference;
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
mPrivacySettingsPreference =
|
||||
PrivacySettingsPreferenceFactory.createPrivacySettingsPreference(context);
|
||||
|
||||
super.onAttach(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetach() {
|
||||
mPrivacySettingsPreference = null;
|
||||
super.onDetach();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return SettingsEnums.ENTERPRISE_PRIVACY_SETTINGS;
|
||||
@@ -49,47 +63,12 @@ public class EnterprisePrivacySettings extends DashboardFragment {
|
||||
|
||||
@Override
|
||||
protected int getPreferenceScreenResId() {
|
||||
return R.xml.enterprise_privacy_settings;
|
||||
return mPrivacySettingsPreference.getPreferenceScreenResId();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
|
||||
return buildPreferenceControllers(context, true /* async */);
|
||||
}
|
||||
|
||||
private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
|
||||
boolean async) {
|
||||
final List<AbstractPreferenceController> controllers = new ArrayList<>();
|
||||
controllers.add(new NetworkLogsPreferenceController(context));
|
||||
controllers.add(new BugReportsPreferenceController(context));
|
||||
controllers.add(new SecurityLogsPreferenceController(context));
|
||||
final List<AbstractPreferenceController> exposureChangesCategoryControllers =
|
||||
new ArrayList<>();
|
||||
exposureChangesCategoryControllers.add(new EnterpriseInstalledPackagesPreferenceController(
|
||||
context, async));
|
||||
exposureChangesCategoryControllers.add(
|
||||
new AdminGrantedLocationPermissionsPreferenceController(context, async));
|
||||
exposureChangesCategoryControllers.add(
|
||||
new AdminGrantedMicrophonePermissionPreferenceController(context, async));
|
||||
exposureChangesCategoryControllers.add(new AdminGrantedCameraPermissionPreferenceController(
|
||||
context, async));
|
||||
exposureChangesCategoryControllers.add(new EnterpriseSetDefaultAppsPreferenceController(
|
||||
context));
|
||||
exposureChangesCategoryControllers.add(new AlwaysOnVpnCurrentUserPreferenceController(
|
||||
context));
|
||||
exposureChangesCategoryControllers.add(new AlwaysOnVpnManagedProfilePreferenceController(
|
||||
context));
|
||||
exposureChangesCategoryControllers.add(new ImePreferenceController(context));
|
||||
exposureChangesCategoryControllers.add(new GlobalHttpProxyPreferenceController(context));
|
||||
exposureChangesCategoryControllers.add(new CaCertsCurrentUserPreferenceController(context));
|
||||
exposureChangesCategoryControllers.add(new CaCertsManagedProfilePreferenceController(
|
||||
context));
|
||||
controllers.addAll(exposureChangesCategoryControllers);
|
||||
controllers.add(new PreferenceCategoryController(context, "exposure_changes_category")
|
||||
.setChildren(exposureChangesCategoryControllers));
|
||||
controllers.add(new FailedPasswordWipeCurrentUserPreferenceController(context));
|
||||
controllers.add(new FailedPasswordWipeManagedProfilePreferenceController(context));
|
||||
return controllers;
|
||||
return mPrivacySettingsPreference.createPreferenceControllers(true /* async */);
|
||||
}
|
||||
|
||||
public static boolean isPageEnabled(Context context) {
|
||||
@@ -99,17 +78,32 @@ public class EnterprisePrivacySettings extends DashboardFragment {
|
||||
}
|
||||
|
||||
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||
new BaseSearchIndexProvider(R.xml.enterprise_privacy_settings) {
|
||||
new BaseSearchIndexProvider() {
|
||||
|
||||
private PrivacySettingsPreference mPrivacySettingsPreference;
|
||||
|
||||
@Override
|
||||
protected boolean isPageSearchEnabled(Context context) {
|
||||
return isPageEnabled(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
|
||||
boolean enabled) {
|
||||
mPrivacySettingsPreference =
|
||||
PrivacySettingsPreferenceFactory.createPrivacySettingsPreference(
|
||||
context);
|
||||
return mPrivacySettingsPreference.getXmlResourcesToIndex();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AbstractPreferenceController> createPreferenceControllers(
|
||||
Context context) {
|
||||
return buildPreferenceControllers(context, false /* async */);
|
||||
mPrivacySettingsPreference =
|
||||
PrivacySettingsPreferenceFactory.createPrivacySettingsPreference(
|
||||
context);
|
||||
return mPrivacySettingsPreference.createPreferenceControllers(
|
||||
false /* async */);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright (C) 2021 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.enterprise;
|
||||
|
||||
import android.content.Context;
|
||||
import android.provider.SearchIndexableResource;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.widget.PreferenceCategoryController;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/** Privacy Settings preferences for an Enterprise device. */
|
||||
public class PrivacySettingsEnterprisePreference implements PrivacySettingsPreference {
|
||||
private static final String KEY_EXPOSURE_CHANGES_CATEGORY = "exposure_changes_category";
|
||||
|
||||
private final Context mContext;
|
||||
|
||||
public PrivacySettingsEnterprisePreference(Context context) {
|
||||
mContext = context.getApplicationContext();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the XML Res Id that is used for an Enterprise device in the Privacy Settings screen.
|
||||
*/
|
||||
@Override
|
||||
public int getPreferenceScreenResId() {
|
||||
return R.xml.enterprise_privacy_settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Enterprise XML resources to index for an Enterprise device.
|
||||
*/
|
||||
@Override
|
||||
public List<SearchIndexableResource> getXmlResourcesToIndex() {
|
||||
final SearchIndexableResource sir = new SearchIndexableResource(mContext);
|
||||
sir.xmlResId = getPreferenceScreenResId();
|
||||
return Collections.singletonList(sir);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the preference controllers used to populate the privacy preferences in the Privacy
|
||||
* Settings screen for Enterprise devices.
|
||||
*/
|
||||
@Override
|
||||
public List<AbstractPreferenceController> createPreferenceControllers(boolean async) {
|
||||
final List<AbstractPreferenceController> controllers = new ArrayList<>();
|
||||
controllers.add(new NetworkLogsPreferenceController(mContext));
|
||||
controllers.add(new BugReportsPreferenceController(mContext));
|
||||
controllers.add(new SecurityLogsPreferenceController(mContext));
|
||||
final List<AbstractPreferenceController> exposureChangesCategoryControllers =
|
||||
new ArrayList<>();
|
||||
exposureChangesCategoryControllers.add(new EnterpriseInstalledPackagesPreferenceController(
|
||||
mContext, async));
|
||||
exposureChangesCategoryControllers.add(
|
||||
new AdminGrantedLocationPermissionsPreferenceController(mContext, async));
|
||||
exposureChangesCategoryControllers.add(
|
||||
new AdminGrantedMicrophonePermissionPreferenceController(mContext, async));
|
||||
exposureChangesCategoryControllers.add(new AdminGrantedCameraPermissionPreferenceController(
|
||||
mContext, async));
|
||||
exposureChangesCategoryControllers.add(new EnterpriseSetDefaultAppsPreferenceController(
|
||||
mContext));
|
||||
exposureChangesCategoryControllers.add(new AlwaysOnVpnCurrentUserPreferenceController(
|
||||
mContext));
|
||||
exposureChangesCategoryControllers.add(new AlwaysOnVpnManagedProfilePreferenceController(
|
||||
mContext));
|
||||
exposureChangesCategoryControllers.add(new ImePreferenceController(mContext));
|
||||
exposureChangesCategoryControllers.add(new GlobalHttpProxyPreferenceController(mContext));
|
||||
exposureChangesCategoryControllers.add(new CaCertsCurrentUserPreferenceController(
|
||||
mContext));
|
||||
exposureChangesCategoryControllers.add(new CaCertsManagedProfilePreferenceController(
|
||||
mContext));
|
||||
controllers.addAll(exposureChangesCategoryControllers);
|
||||
controllers.add(new PreferenceCategoryController(mContext, KEY_EXPOSURE_CHANGES_CATEGORY)
|
||||
.setChildren(exposureChangesCategoryControllers));
|
||||
controllers.add(new FailedPasswordWipeCurrentUserPreferenceController(mContext));
|
||||
controllers.add(new FailedPasswordWipeManagedProfilePreferenceController(mContext));
|
||||
return controllers;
|
||||
}
|
||||
}
|
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright (C) 2021 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.enterprise;
|
||||
|
||||
import android.content.Context;
|
||||
import android.provider.SearchIndexableResource;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.widget.PreferenceCategoryController;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/** Privacy Settings preferences for a financed device. */
|
||||
public class PrivacySettingsFinancedPreference implements PrivacySettingsPreference {
|
||||
private static final String KEY_EXPOSURE_CHANGES_CATEGORY = "exposure_changes_category";
|
||||
|
||||
private final Context mContext;
|
||||
|
||||
public PrivacySettingsFinancedPreference(Context context) {
|
||||
mContext = context.getApplicationContext();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the XML Res Id that is used for financed devices in the Privacy Settings screen.
|
||||
*/
|
||||
@Override
|
||||
public int getPreferenceScreenResId() {
|
||||
return R.xml.financed_privacy_settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the XML resources to index for a financed device.
|
||||
*/
|
||||
@Override
|
||||
public List<SearchIndexableResource> getXmlResourcesToIndex() {
|
||||
final SearchIndexableResource sir = new SearchIndexableResource(mContext);
|
||||
sir.xmlResId = getPreferenceScreenResId();
|
||||
return Collections.singletonList(sir);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the preference controllers used to populate the privacy preferences in the Privacy
|
||||
* Settings screen for a financed device.
|
||||
*/
|
||||
@Override
|
||||
public List<AbstractPreferenceController> createPreferenceControllers(boolean async) {
|
||||
final List<AbstractPreferenceController> controllers = new ArrayList<>();
|
||||
controllers.add(new NetworkLogsPreferenceController(mContext));
|
||||
controllers.add(new BugReportsPreferenceController(mContext));
|
||||
controllers.add(new SecurityLogsPreferenceController(mContext));
|
||||
final List<AbstractPreferenceController> exposureChangesCategoryControllers =
|
||||
new ArrayList<>();
|
||||
exposureChangesCategoryControllers.add(new EnterpriseInstalledPackagesPreferenceController(
|
||||
mContext, async));
|
||||
controllers.addAll(exposureChangesCategoryControllers);
|
||||
controllers.add(new PreferenceCategoryController(mContext, KEY_EXPOSURE_CHANGES_CATEGORY)
|
||||
.setChildren(exposureChangesCategoryControllers));
|
||||
controllers.add(new FailedPasswordWipeCurrentUserPreferenceController(mContext));
|
||||
return controllers;
|
||||
}
|
||||
}
|
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (C) 2021 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.enterprise;
|
||||
|
||||
import android.provider.SearchIndexableResource;
|
||||
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/** Interface for configuring what is displayed on the Privacy Settings. */
|
||||
public interface PrivacySettingsPreference {
|
||||
|
||||
/**
|
||||
* Returns the XML Res Id that is used in the Privacy Settings screen.
|
||||
*/
|
||||
int getPreferenceScreenResId();
|
||||
|
||||
/**
|
||||
* Returns the XML resources to index.
|
||||
*/
|
||||
List<SearchIndexableResource> getXmlResourcesToIndex();
|
||||
|
||||
/**
|
||||
* Returns the preference controllers used to populate the privacy preferences.
|
||||
*/
|
||||
List<AbstractPreferenceController> createPreferenceControllers(boolean async);
|
||||
}
|
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (C) 2021 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.enterprise;
|
||||
|
||||
import static android.app.admin.DevicePolicyManager.DEVICE_OWNER_TYPE_FINANCED;
|
||||
|
||||
import android.app.admin.DevicePolicyManager;
|
||||
import android.content.Context;
|
||||
|
||||
/** Factory for creating the privacy settings preference for a managed device. */
|
||||
public class PrivacySettingsPreferenceFactory {
|
||||
|
||||
/**
|
||||
* Determines which preference to use in the Privacy Settings based off of the type of managed
|
||||
* device.
|
||||
*/
|
||||
public static PrivacySettingsPreference createPrivacySettingsPreference(Context context) {
|
||||
if (isFinancedDevice(context)) {
|
||||
return createPrivacySettingsFinancedPreference(context);
|
||||
} else {
|
||||
return createPrivacySettingsEnterprisePreference(context);
|
||||
}
|
||||
}
|
||||
|
||||
private static PrivacySettingsEnterprisePreference createPrivacySettingsEnterprisePreference(
|
||||
Context context) {
|
||||
return new PrivacySettingsEnterprisePreference(context);
|
||||
}
|
||||
|
||||
private static PrivacySettingsFinancedPreference createPrivacySettingsFinancedPreference(
|
||||
Context context) {
|
||||
return new PrivacySettingsFinancedPreference(context);
|
||||
}
|
||||
|
||||
private static boolean isFinancedDevice(Context context) {
|
||||
final DevicePolicyManager dpm = context.getSystemService(DevicePolicyManager.class);
|
||||
return dpm.isDeviceManaged() && dpm.getDeviceOwnerType(
|
||||
dpm.getDeviceOwnerComponentOnAnyUser()) == DEVICE_OWNER_TYPE_FINANCED;
|
||||
}
|
||||
}
|
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* Copyright (C) 2021 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.enterprise;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.content.Context;
|
||||
import android.provider.SearchIndexableResource;
|
||||
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.widget.PreferenceCategoryController;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public abstract class BasePrivacySettingsPreferenceTest {
|
||||
|
||||
protected Context mContext;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
mContext = ApplicationProvider.getApplicationContext();
|
||||
}
|
||||
|
||||
protected static void verifyEnterpriseSearchIndexableResources(
|
||||
List<SearchIndexableResource> searchIndexableResources) {
|
||||
assertThat(searchIndexableResources).isNotEmpty();
|
||||
assertThat(searchIndexableResources.size()).isEqualTo(1);
|
||||
assertThat(searchIndexableResources.get(0).xmlResId)
|
||||
.isEqualTo(R.xml.enterprise_privacy_settings);
|
||||
}
|
||||
|
||||
protected static void verifyEnterprisePreferenceControllers(
|
||||
List<AbstractPreferenceController> controllers) {
|
||||
assertThat(controllers).isNotNull();
|
||||
assertThat(controllers.size()).isEqualTo(17);
|
||||
int position = 0;
|
||||
assertThat(controllers.get(position++)).isInstanceOf(NetworkLogsPreferenceController.class);
|
||||
assertThat(controllers.get(position++)).isInstanceOf(BugReportsPreferenceController.class);
|
||||
assertThat(controllers.get(position++)).isInstanceOf(
|
||||
SecurityLogsPreferenceController.class);
|
||||
assertThat(controllers.get(position++)).isInstanceOf(
|
||||
EnterpriseInstalledPackagesPreferenceController.class);
|
||||
assertThat(controllers.get(position++)).isInstanceOf(
|
||||
AdminGrantedLocationPermissionsPreferenceController.class);
|
||||
assertThat(controllers.get(position++)).isInstanceOf(
|
||||
AdminGrantedMicrophonePermissionPreferenceController.class);
|
||||
assertThat(controllers.get(position++)).isInstanceOf(
|
||||
AdminGrantedCameraPermissionPreferenceController.class);
|
||||
assertThat(controllers.get(position++)).isInstanceOf(
|
||||
EnterpriseSetDefaultAppsPreferenceController.class);
|
||||
assertThat(controllers.get(position++)).isInstanceOf(
|
||||
AlwaysOnVpnCurrentUserPreferenceController.class);
|
||||
assertThat(controllers.get(position++)).isInstanceOf(
|
||||
AlwaysOnVpnManagedProfilePreferenceController.class);
|
||||
assertThat(controllers.get(position++)).isInstanceOf(ImePreferenceController.class);
|
||||
assertThat(controllers.get(position++)).isInstanceOf(
|
||||
GlobalHttpProxyPreferenceController.class);
|
||||
assertThat(controllers.get(position++)).isInstanceOf(
|
||||
CaCertsCurrentUserPreferenceController.class);
|
||||
assertThat(controllers.get(position++)).isInstanceOf(
|
||||
CaCertsManagedProfilePreferenceController.class);
|
||||
assertThat(controllers.get(position++)).isInstanceOf(
|
||||
PreferenceCategoryController.class);
|
||||
assertThat(controllers.get(position++)).isInstanceOf(
|
||||
FailedPasswordWipeCurrentUserPreferenceController.class);
|
||||
assertThat(controllers.get(position)).isInstanceOf(
|
||||
FailedPasswordWipeManagedProfilePreferenceController.class);
|
||||
}
|
||||
|
||||
protected static void verifyFinancedSearchIndexableResources(
|
||||
List<SearchIndexableResource> searchIndexableResources) {
|
||||
assertThat(searchIndexableResources).isNotEmpty();
|
||||
assertThat(searchIndexableResources.size()).isEqualTo(1);
|
||||
assertThat(searchIndexableResources.get(0).xmlResId)
|
||||
.isEqualTo(R.xml.financed_privacy_settings);
|
||||
}
|
||||
|
||||
protected static void verifyFinancedPreferenceControllers(
|
||||
List<AbstractPreferenceController> controllers) {
|
||||
assertThat(controllers).isNotNull();
|
||||
assertThat(controllers.size()).isEqualTo(6);
|
||||
int position = 0;
|
||||
assertThat(controllers.get(position++)).isInstanceOf(NetworkLogsPreferenceController.class);
|
||||
assertThat(controllers.get(position++)).isInstanceOf(BugReportsPreferenceController.class);
|
||||
assertThat(controllers.get(position++)).isInstanceOf(
|
||||
SecurityLogsPreferenceController.class);
|
||||
assertThat(controllers.get(position++)).isInstanceOf(
|
||||
EnterpriseInstalledPackagesPreferenceController.class);
|
||||
assertThat(controllers.get(position++)).isInstanceOf(
|
||||
PreferenceCategoryController.class);
|
||||
assertThat(controllers.get(position)).isInstanceOf(
|
||||
FailedPasswordWipeCurrentUserPreferenceController.class);
|
||||
}
|
||||
}
|
@@ -16,47 +16,70 @@
|
||||
|
||||
package com.android.settings.enterprise;
|
||||
|
||||
import static android.app.admin.DevicePolicyManager.DEVICE_OWNER_TYPE_DEFAULT;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.Context;
|
||||
import android.app.admin.DevicePolicyManager;
|
||||
import android.content.ComponentName;
|
||||
import android.provider.SearchIndexableResource;
|
||||
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.testutils.FakeFeatureFactory;
|
||||
import com.android.settings.widget.PreferenceCategoryController;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
import com.android.settingslib.drawer.CategoryKey;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Answers;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class EnterprisePrivacySettingsTest {
|
||||
public class EnterprisePrivacySettingsTest extends BasePrivacySettingsPreferenceTest {
|
||||
private static final ComponentName DEVICE_OWNER_COMPONENT =
|
||||
new ComponentName("com.android.foo", "bar");
|
||||
|
||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||
private Context mContext;
|
||||
@Mock
|
||||
private DevicePolicyManager mDevicePolicyManager;
|
||||
@Mock
|
||||
private PrivacySettingsPreference mPrivacySettingsPreference;
|
||||
private FakeFeatureFactory mFeatureFactory;
|
||||
private EnterprisePrivacySettings mSettings;
|
||||
|
||||
@Override
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mContext = spy(ApplicationProvider.getApplicationContext());
|
||||
mFeatureFactory = FakeFeatureFactory.setupForTest();
|
||||
mSettings = new EnterprisePrivacySettings();
|
||||
mSettings.mPrivacySettingsPreference = mPrivacySettingsPreference;
|
||||
|
||||
when(mContext.getSystemService(DevicePolicyManager.class)).thenReturn(mDevicePolicyManager);
|
||||
when(mDevicePolicyManager.isDeviceManaged()).thenReturn(true);
|
||||
when(mDevicePolicyManager.getDeviceOwnerComponentOnAnyUser())
|
||||
.thenReturn(DEVICE_OWNER_COMPONENT);
|
||||
when(mDevicePolicyManager.getDeviceOwnerType(DEVICE_OWNER_COMPONENT))
|
||||
.thenReturn(DEVICE_OWNER_TYPE_DEFAULT);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void verifyConstants() {
|
||||
when(mPrivacySettingsPreference.getPreferenceScreenResId())
|
||||
.thenReturn(R.xml.enterprise_privacy_settings);
|
||||
|
||||
assertThat(mSettings.getMetricsCategory())
|
||||
.isEqualTo(MetricsEvent.ENTERPRISE_PRIVACY_SETTINGS);
|
||||
assertThat(mSettings.getLogTag()).isEqualTo("EnterprisePrivacySettings");
|
||||
@@ -76,6 +99,7 @@ public class EnterprisePrivacySettingsTest {
|
||||
|
||||
@Test
|
||||
public void isPageEnabled_noDeviceOwner_shouldReturnFalse() {
|
||||
when(mDevicePolicyManager.isDeviceManaged()).thenReturn(false);
|
||||
when(mFeatureFactory.enterprisePrivacyFeatureProvider.hasDeviceOwner())
|
||||
.thenReturn(false);
|
||||
|
||||
@@ -85,53 +109,35 @@ public class EnterprisePrivacySettingsTest {
|
||||
|
||||
@Test
|
||||
public void getPreferenceControllers() {
|
||||
final List<AbstractPreferenceController> controllers =
|
||||
mSettings.createPreferenceControllers(RuntimeEnvironment.application);
|
||||
verifyPreferenceControllers(controllers);
|
||||
final List<AbstractPreferenceController> controllers = new ArrayList<>();
|
||||
controllers.add(new NetworkLogsPreferenceController(mContext));
|
||||
when(mPrivacySettingsPreference.createPreferenceControllers(anyBoolean()))
|
||||
.thenReturn(controllers);
|
||||
|
||||
final List<AbstractPreferenceController> privacyControllers =
|
||||
mSettings.createPreferenceControllers(mContext);
|
||||
|
||||
assertThat(privacyControllers).isNotNull();
|
||||
assertThat(privacyControllers.size()).isEqualTo(1);
|
||||
assertThat(controllers.get(0)).isInstanceOf(NetworkLogsPreferenceController.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSearchIndexProviderPreferenceControllers() {
|
||||
public void
|
||||
getSearchIndexProviderPreferenceControllers_returnsEnterpriseSearchIndexPreferenceControllers() {
|
||||
final List<AbstractPreferenceController> controllers =
|
||||
EnterprisePrivacySettings.SEARCH_INDEX_DATA_PROVIDER
|
||||
.getPreferenceControllers(RuntimeEnvironment.application);
|
||||
verifyPreferenceControllers(controllers);
|
||||
.getPreferenceControllers(mContext);
|
||||
|
||||
verifyEnterprisePreferenceControllers(controllers);
|
||||
}
|
||||
|
||||
private void verifyPreferenceControllers(List<AbstractPreferenceController> controllers) {
|
||||
assertThat(controllers).isNotNull();
|
||||
assertThat(controllers.size()).isEqualTo(17);
|
||||
int position = 0;
|
||||
assertThat(controllers.get(position++)).isInstanceOf(NetworkLogsPreferenceController.class);
|
||||
assertThat(controllers.get(position++)).isInstanceOf(BugReportsPreferenceController.class);
|
||||
assertThat(controllers.get(position++)).isInstanceOf(
|
||||
SecurityLogsPreferenceController.class);
|
||||
assertThat(controllers.get(position++)).isInstanceOf(
|
||||
EnterpriseInstalledPackagesPreferenceController.class);
|
||||
assertThat(controllers.get(position++)).isInstanceOf(
|
||||
AdminGrantedLocationPermissionsPreferenceController.class);
|
||||
assertThat(controllers.get(position++)).isInstanceOf(
|
||||
AdminGrantedMicrophonePermissionPreferenceController.class);
|
||||
assertThat(controllers.get(position++)).isInstanceOf(
|
||||
AdminGrantedCameraPermissionPreferenceController.class);
|
||||
assertThat(controllers.get(position++)).isInstanceOf(
|
||||
EnterpriseSetDefaultAppsPreferenceController.class);
|
||||
assertThat(controllers.get(position++)).isInstanceOf(
|
||||
AlwaysOnVpnCurrentUserPreferenceController.class);
|
||||
assertThat(controllers.get(position++)).isInstanceOf(
|
||||
AlwaysOnVpnManagedProfilePreferenceController.class);
|
||||
assertThat(controllers.get(position++)).isInstanceOf(ImePreferenceController.class);
|
||||
assertThat(controllers.get(position++)).isInstanceOf(
|
||||
GlobalHttpProxyPreferenceController.class);
|
||||
assertThat(controllers.get(position++)).isInstanceOf(
|
||||
CaCertsCurrentUserPreferenceController.class);
|
||||
assertThat(controllers.get(position++)).isInstanceOf(
|
||||
CaCertsManagedProfilePreferenceController.class);
|
||||
assertThat(controllers.get(position++)).isInstanceOf(
|
||||
PreferenceCategoryController.class);
|
||||
assertThat(controllers.get(position++)).isInstanceOf(
|
||||
FailedPasswordWipeCurrentUserPreferenceController.class);
|
||||
assertThat(controllers.get(position)).isInstanceOf(
|
||||
FailedPasswordWipeManagedProfilePreferenceController.class);
|
||||
@Test
|
||||
public void getXmlResourcesToIndex_returnsEnterpriseXmlResources() {
|
||||
final List<SearchIndexableResource> searchIndexableResources =
|
||||
EnterprisePrivacySettings.SEARCH_INDEX_DATA_PROVIDER
|
||||
.getXmlResourcesToIndex(mContext, true);
|
||||
|
||||
verifyEnterpriseSearchIndexableResources(searchIndexableResources);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (C) 2021 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.enterprise;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.provider.SearchIndexableResource;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class PrivacySettingsEnterprisePreferenceTest extends BasePrivacySettingsPreferenceTest {
|
||||
|
||||
private PrivacySettingsEnterprisePreference mPrivacySettingsEnterprisePreference;
|
||||
|
||||
@Override
|
||||
@Before
|
||||
public void setUp() {
|
||||
super.setUp();
|
||||
mPrivacySettingsEnterprisePreference = new PrivacySettingsEnterprisePreference(mContext);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getPreferenceScreenResId() {
|
||||
assertThat(mPrivacySettingsEnterprisePreference.getPreferenceScreenResId())
|
||||
.isEqualTo(R.xml.enterprise_privacy_settings);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getXmlResourcesToIndex() {
|
||||
final List<SearchIndexableResource> searchIndexableResources =
|
||||
mPrivacySettingsEnterprisePreference.getXmlResourcesToIndex();
|
||||
|
||||
verifyEnterpriseSearchIndexableResources(searchIndexableResources);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getPreferenceControllers() {
|
||||
final List<AbstractPreferenceController> controllers =
|
||||
mPrivacySettingsEnterprisePreference.createPreferenceControllers(true);
|
||||
|
||||
verifyEnterprisePreferenceControllers(controllers);
|
||||
}
|
||||
}
|
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (C) 2021 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.enterprise;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.provider.SearchIndexableResource;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class PrivacySettingsFinancedPreferenceTest extends BasePrivacySettingsPreferenceTest {
|
||||
|
||||
private PrivacySettingsFinancedPreference mPrivacySettingsFinancedPreference;
|
||||
|
||||
@Override
|
||||
@Before
|
||||
public void setUp() {
|
||||
super.setUp();
|
||||
mPrivacySettingsFinancedPreference = new PrivacySettingsFinancedPreference(mContext);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getPreferenceScreenResId() {
|
||||
assertThat(mPrivacySettingsFinancedPreference.getPreferenceScreenResId())
|
||||
.isEqualTo(R.xml.financed_privacy_settings);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getXmlResourcesToIndex() {
|
||||
final List<SearchIndexableResource> searchIndexableResources =
|
||||
mPrivacySettingsFinancedPreference.getXmlResourcesToIndex();
|
||||
|
||||
verifyFinancedSearchIndexableResources(searchIndexableResources);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getPreferenceControllers() {
|
||||
final List<AbstractPreferenceController> controllers =
|
||||
mPrivacySettingsFinancedPreference.createPreferenceControllers(true);
|
||||
|
||||
verifyFinancedPreferenceControllers(controllers);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user