Update Privacy Settings text for a financed device
Bug: 182802692 Test: Used a test device that is registered via ZT Test: m RunSettingsRoboTests ROBOTEST_FILTER=EnterprisePrivacySettingsTest Test: m RunSettingsRoboTests ROBOTEST_FILTER=PrivacySettingsEnterprisePreferenceTest Test: m RunSettingsRoboTests ROBOTEST_FILTER=PrivacySettingsFinancedPreferenceTest Change-Id: Icc131252430cd147e2a06ba2aa260f6ea26734bb
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user