Snap for 7230642 from cafc769a51 to sc-v2-release
Change-Id: Icbb7742555801f242b177ffa4d6cb64df43be5bb
This commit is contained in:
@@ -19,6 +19,8 @@
|
|||||||
<uses-permission android:name="android.permission.VIBRATE" />
|
<uses-permission android:name="android.permission.VIBRATE" />
|
||||||
<uses-permission android:name="android.permission.BLUETOOTH" />
|
<uses-permission android:name="android.permission.BLUETOOTH" />
|
||||||
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
|
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
|
||||||
|
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
|
||||||
|
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
|
||||||
<uses-permission android:name="android.permission.BLUETOOTH_PRIVILEGED" />
|
<uses-permission android:name="android.permission.BLUETOOTH_PRIVILEGED" />
|
||||||
<uses-permission android:name="android.permission.NFC" />
|
<uses-permission android:name="android.permission.NFC" />
|
||||||
<uses-permission android:name="android.permission.HARDWARE_TEST" />
|
<uses-permission android:name="android.permission.HARDWARE_TEST" />
|
||||||
|
|||||||
@@ -11526,6 +11526,25 @@
|
|||||||
<!-- Button label to allow the user to view additional information [CHAR LIMIT=NONE BACKUP_MESSAGE_ID=2416766240581561009] -->
|
<!-- Button label to allow the user to view additional information [CHAR LIMIT=NONE BACKUP_MESSAGE_ID=2416766240581561009] -->
|
||||||
<string name="learn_more">Learn more</string>
|
<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. -->
|
<!-- 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] -->
|
<!-- Title for the apps that have been set as default handlers of camera-related intents. [CHAR LIMIT=30] -->
|
||||||
<plurals name="default_camera_app_title">
|
<plurals name="default_camera_app_title">
|
||||||
@@ -12788,10 +12807,6 @@
|
|||||||
<string name="network_and_internet_preferences_summary">Connect to public networks</string>
|
<string name="network_and_internet_preferences_summary">Connect to public networks</string>
|
||||||
<!-- Search keywords for "Internet" settings [CHAR_LIMIT=NONE] -->
|
<!-- Search keywords for "Internet" settings [CHAR_LIMIT=NONE] -->
|
||||||
<string name="keywords_internet">network connection, internet, wireless, data, wifi, wi-fi, wi fi, cellular, mobile, cell carrier, 4g, 3g, 2g, lte</string>
|
<string name="keywords_internet">network connection, internet, wireless, data, wifi, wi-fi, wi fi, cellular, mobile, cell carrier, 4g, 3g, 2g, lte</string>
|
||||||
<!-- Label text to view airplane-safe networks. [CHAR LIMIT=40] -->
|
|
||||||
<string name="view_airplane_safe_networks">View airplane mode networks</string>
|
|
||||||
<!-- Text of message for viewing the networks that are available in airplane mode. [CHAR LIMIT=60] -->
|
|
||||||
<string name="viewing_airplane_mode_networks">Viewing airplane mode networks</string>
|
|
||||||
<!-- Slice title text for turning on the Wi-Fi networks. [CHAR LIMIT=40] -->
|
<!-- Slice title text for turning on the Wi-Fi networks. [CHAR LIMIT=40] -->
|
||||||
<string name="turn_on_wifi">Turn on Wi\u2011Fi</string>
|
<string name="turn_on_wifi">Turn on Wi\u2011Fi</string>
|
||||||
<!-- Title for interrupting the voice call alert. [CHAR_LIMIT=NONE] -->
|
<!-- Title for interrupting the voice call alert. [CHAR_LIMIT=NONE] -->
|
||||||
@@ -12804,6 +12819,8 @@
|
|||||||
<string name="resetting_internet_text">Resetting your internet\u2026</string>
|
<string name="resetting_internet_text">Resetting your internet\u2026</string>
|
||||||
<!-- Menu option for data connectivity recovery for all requested technologies. [CHAR_LIMIT=NONE] -->
|
<!-- Menu option for data connectivity recovery for all requested technologies. [CHAR_LIMIT=NONE] -->
|
||||||
<string name="fix_connectivity">Fix connectivity</string>
|
<string name="fix_connectivity">Fix connectivity</string>
|
||||||
|
<!-- Summary for networks available (includes no network connected). [CHAR_LIMIT=NONE] -->
|
||||||
|
<string name="networks_available">Networks available</string>
|
||||||
<!-- Summary for warning to disconnect ethernet first then switch to other networks. [CHAR LIMIT=60] -->
|
<!-- Summary for warning to disconnect ethernet first then switch to other networks. [CHAR LIMIT=60] -->
|
||||||
<string name="to_switch_networks_disconnect_ethernet">To switch networks, disconnect ethernet</string>
|
<string name="to_switch_networks_disconnect_ethernet">To switch networks, disconnect ethernet</string>
|
||||||
<!-- Panel subtitle for Wi-Fi turned on. [CHAR LIMIT=60] -->
|
<!-- Panel subtitle for Wi-Fi turned on. [CHAR LIMIT=60] -->
|
||||||
@@ -12935,8 +12952,8 @@
|
|||||||
<string name="extra_app_info_label" translatable="false"></string>
|
<string name="extra_app_info_label" translatable="false"></string>
|
||||||
|
|
||||||
<!-- Title for toggle controlling whether notifications are shown when an app pastes from clipboard. [CHAR LIMIT=50] -->
|
<!-- Title for toggle controlling whether notifications are shown when an app pastes from clipboard. [CHAR LIMIT=50] -->
|
||||||
<string name="show_clip_access_notification">Copy & paste notifications</string>
|
<string name="show_clip_access_notification">Show clipboard access</string>
|
||||||
|
|
||||||
<!-- Summary for toggle controlling whether notifications are shown when an app pastes from clipboard. [CHAR LIMIT=NONE] -->
|
<!-- Summary for toggle controlling whether notifications are shown when an app pastes from clipboard. [CHAR LIMIT=NONE] -->
|
||||||
<string name="show_clip_access_notification_summary">Show a message when apps access text or data you have copied</string>
|
<string name="show_clip_access_notification_summary">Show a message when apps access text, images, or other content you\u2019ve copied</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
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>
|
||||||
@@ -445,6 +445,13 @@ public abstract class SettingsPreferenceFragment extends InstrumentedPreferenceF
|
|||||||
return getActivity().getSystemService(name);
|
return getActivity().getSystemService(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the specified system service from the owning Activity.
|
||||||
|
*/
|
||||||
|
protected <T> T getSystemService(final Class<T> serviceClass) {
|
||||||
|
return getActivity().getSystemService(serviceClass);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the PackageManager from the owning Activity.
|
* Returns the PackageManager from the owning Activity.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ import android.security.Credentials;
|
|||||||
import android.security.IKeyChainService;
|
import android.security.IKeyChainService;
|
||||||
import android.security.KeyChain;
|
import android.security.KeyChain;
|
||||||
import android.security.KeyChain.KeyChainConnection;
|
import android.security.KeyChain.KeyChainConnection;
|
||||||
import android.security.keystore.AndroidKeyStoreProvider;
|
|
||||||
import android.security.keystore.KeyProperties;
|
import android.security.keystore.KeyProperties;
|
||||||
import android.security.keystore2.AndroidKeyStoreLoadStoreParameter;
|
import android.security.keystore2.AndroidKeyStoreLoadStoreParameter;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@@ -74,6 +73,8 @@ public class UserCredentialsSettings extends SettingsPreferenceFragment
|
|||||||
implements View.OnClickListener {
|
implements View.OnClickListener {
|
||||||
private static final String TAG = "UserCredentialsSettings";
|
private static final String TAG = "UserCredentialsSettings";
|
||||||
|
|
||||||
|
private static final String KEYSTORE_PROVIDER = "AndroidKeyStore";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMetricsCategory() {
|
public int getMetricsCategory() {
|
||||||
return SettingsEnums.USER_CREDENTIALS;
|
return SettingsEnums.USER_CREDENTIALS;
|
||||||
@@ -210,15 +211,10 @@ public class UserCredentialsSettings extends SettingsPreferenceFragment
|
|||||||
|
|
||||||
private void deleteWifiCredential(final Credential credential) {
|
private void deleteWifiCredential(final Credential credential) {
|
||||||
try {
|
try {
|
||||||
KeyStore keyStore = null;
|
final KeyStore keyStore = KeyStore.getInstance(KEYSTORE_PROVIDER);
|
||||||
if (AndroidKeyStoreProvider.isKeystore2Enabled()) {
|
keyStore.load(
|
||||||
keyStore = KeyStore.getInstance("AndroidKeyStore");
|
new AndroidKeyStoreLoadStoreParameter(
|
||||||
keyStore.load(
|
KeyProperties.NAMESPACE_WIFI));
|
||||||
new AndroidKeyStoreLoadStoreParameter(
|
|
||||||
KeyProperties.NAMESPACE_WIFI));
|
|
||||||
} else {
|
|
||||||
keyStore = AndroidKeyStoreProvider.getKeyStoreForUid(Process.WIFI_UID);
|
|
||||||
}
|
|
||||||
keyStore.deleteEntry(credential.getAlias());
|
keyStore.deleteEntry(credential.getAlias());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException("Failed to delete keys from keystore.");
|
throw new RuntimeException("Failed to delete keys from keystore.");
|
||||||
@@ -278,18 +274,13 @@ public class UserCredentialsSettings extends SettingsPreferenceFragment
|
|||||||
final int wifiUid = UserHandle.getUid(myUserId, Process.WIFI_UID);
|
final int wifiUid = UserHandle.getUid(myUserId, Process.WIFI_UID);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
KeyStore processKeystore = KeyStore.getInstance("AndroidKeyStore");
|
KeyStore processKeystore = KeyStore.getInstance(KEYSTORE_PROVIDER);
|
||||||
processKeystore.load(null);
|
processKeystore.load(null);
|
||||||
KeyStore wifiKeystore = null;
|
KeyStore wifiKeystore = null;
|
||||||
if (myUserId == 0) {
|
if (myUserId == 0) {
|
||||||
// Only the primary user may see wifi configurations.
|
wifiKeystore = KeyStore.getInstance(KEYSTORE_PROVIDER);
|
||||||
if (AndroidKeyStoreProvider.isKeystore2Enabled()) {
|
wifiKeystore.load(new AndroidKeyStoreLoadStoreParameter(
|
||||||
wifiKeystore = KeyStore.getInstance("AndroidKeyStore");
|
KeyProperties.NAMESPACE_WIFI));
|
||||||
wifiKeystore.load(new AndroidKeyStoreLoadStoreParameter(
|
|
||||||
KeyProperties.NAMESPACE_WIFI));
|
|
||||||
} else {
|
|
||||||
wifiKeystore = AndroidKeyStoreProvider.getKeyStoreForUid(Process.WIFI_UID);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Credential> credentials = new ArrayList<>();
|
List<Credential> credentials = new ArrayList<>();
|
||||||
|
|||||||
@@ -174,8 +174,8 @@ public class ChartDataUsagePreference extends Preference {
|
|||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
List<DataUsageSummaryNode> getDensedStatsData(List<NetworkCycleData> usageSummary) {
|
List<DataUsageSummaryNode> getDensedStatsData(List<NetworkCycleData> usageSummary) {
|
||||||
final List<DataUsageSummaryNode> dataUsageSummaryNodes = new ArrayList<>();
|
final List<DataUsageSummaryNode> dataUsageSummaryNodes = new ArrayList<>();
|
||||||
final long overallDataUsage = usageSummary.stream()
|
final long overallDataUsage = Math.max(1L, usageSummary.stream()
|
||||||
.mapToLong(NetworkCycleData::getTotalUsage).sum();
|
.mapToLong(NetworkCycleData::getTotalUsage).sum());
|
||||||
long cumulatedDataUsage = 0L;
|
long cumulatedDataUsage = 0L;
|
||||||
int cumulatedDataUsagePercentage = 0;
|
int cumulatedDataUsagePercentage = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,9 @@
|
|||||||
*/
|
*/
|
||||||
package com.android.settings.enterprise;
|
package com.android.settings.enterprise;
|
||||||
|
|
||||||
|
import static android.app.admin.DevicePolicyManager.DEVICE_OWNER_TYPE_FINANCED;
|
||||||
|
|
||||||
|
import android.app.admin.DevicePolicyManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
@@ -39,6 +42,10 @@ public class EnterprisePrivacyPreferenceController extends AbstractPreferenceCon
|
|||||||
if (preference == null) {
|
if (preference == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (isFinancedDevice()) {
|
||||||
|
preference.setTitle(R.string.financed_privacy_settings);
|
||||||
|
}
|
||||||
|
|
||||||
final String organizationName = mFeatureProvider.getDeviceOwnerOrganizationName();
|
final String organizationName = mFeatureProvider.getDeviceOwnerOrganizationName();
|
||||||
if (organizationName == null) {
|
if (organizationName == null) {
|
||||||
preference.setSummary(R.string.enterprise_privacy_settings_summary_generic);
|
preference.setSummary(R.string.enterprise_privacy_settings_summary_generic);
|
||||||
@@ -57,4 +64,10 @@ public class EnterprisePrivacyPreferenceController extends AbstractPreferenceCon
|
|||||||
public String getPreferenceKey() {
|
public String getPreferenceKey() {
|
||||||
return KEY_ENTERPRISE_PRIVACY;
|
return KEY_ENTERPRISE_PRIVACY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isFinancedDevice() {
|
||||||
|
final DevicePolicyManager dpm = mContext.getSystemService(DevicePolicyManager.class);
|
||||||
|
return dpm.isDeviceManaged() && dpm.getDeviceOwnerType(
|
||||||
|
dpm.getDeviceOwnerComponentOnAnyUser()) == DEVICE_OWNER_TYPE_FINANCED;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,16 +20,13 @@ import android.app.settings.SettingsEnums;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.provider.SearchIndexableResource;
|
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.dashboard.DashboardFragment;
|
||||||
import com.android.settings.overlay.FeatureFactory;
|
import com.android.settings.overlay.FeatureFactory;
|
||||||
import com.android.settings.search.BaseSearchIndexProvider;
|
import com.android.settings.search.BaseSearchIndexProvider;
|
||||||
import com.android.settings.widget.PreferenceCategoryController;
|
|
||||||
import com.android.settingslib.core.AbstractPreferenceController;
|
import com.android.settingslib.core.AbstractPreferenceController;
|
||||||
import com.android.settingslib.search.SearchIndexable;
|
import com.android.settingslib.search.SearchIndexable;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@SearchIndexable
|
@SearchIndexable
|
||||||
@@ -37,6 +34,23 @@ public class EnterprisePrivacySettings extends DashboardFragment {
|
|||||||
|
|
||||||
static final String TAG = "EnterprisePrivacySettings";
|
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
|
@Override
|
||||||
public int getMetricsCategory() {
|
public int getMetricsCategory() {
|
||||||
return SettingsEnums.ENTERPRISE_PRIVACY_SETTINGS;
|
return SettingsEnums.ENTERPRISE_PRIVACY_SETTINGS;
|
||||||
@@ -49,47 +63,12 @@ public class EnterprisePrivacySettings extends DashboardFragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getPreferenceScreenResId() {
|
protected int getPreferenceScreenResId() {
|
||||||
return R.xml.enterprise_privacy_settings;
|
return mPrivacySettingsPreference.getPreferenceScreenResId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
|
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
|
||||||
return buildPreferenceControllers(context, true /* async */);
|
return mPrivacySettingsPreference.createPreferenceControllers(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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isPageEnabled(Context context) {
|
public static boolean isPageEnabled(Context context) {
|
||||||
@@ -99,17 +78,32 @@ public class EnterprisePrivacySettings extends DashboardFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||||
new BaseSearchIndexProvider(R.xml.enterprise_privacy_settings) {
|
new BaseSearchIndexProvider() {
|
||||||
|
|
||||||
|
private PrivacySettingsPreference mPrivacySettingsPreference;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isPageSearchEnabled(Context context) {
|
protected boolean isPageSearchEnabled(Context context) {
|
||||||
return isPageEnabled(context);
|
return isPageEnabled(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
|
||||||
|
boolean enabled) {
|
||||||
|
mPrivacySettingsPreference =
|
||||||
|
PrivacySettingsPreferenceFactory.createPrivacySettingsPreference(
|
||||||
|
context);
|
||||||
|
return mPrivacySettingsPreference.getXmlResourcesToIndex();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<AbstractPreferenceController> createPreferenceControllers(
|
public List<AbstractPreferenceController> createPreferenceControllers(
|
||||||
Context context) {
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -298,7 +298,7 @@ public class BatteryUtils {
|
|||||||
*/
|
*/
|
||||||
public long calculateLastFullChargeTime(BatteryUsageStats batteryUsageStats,
|
public long calculateLastFullChargeTime(BatteryUsageStats batteryUsageStats,
|
||||||
long currentTimeMs) {
|
long currentTimeMs) {
|
||||||
return currentTimeMs - batteryUsageStats.getStatsStartRealtime();
|
return currentTimeMs - batteryUsageStats.getStatsStartTimestamp();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void logRuntime(String tag, String message, long startTime) {
|
public static void logRuntime(String tag, String message, long startTime) {
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ import com.android.settings.fuelgauge.batterytip.detectors.EarlyWarningDetector;
|
|||||||
import com.android.settings.fuelgauge.batterytip.detectors.HighUsageDetector;
|
import com.android.settings.fuelgauge.batterytip.detectors.HighUsageDetector;
|
||||||
import com.android.settings.fuelgauge.batterytip.detectors.LowBatteryDetector;
|
import com.android.settings.fuelgauge.batterytip.detectors.LowBatteryDetector;
|
||||||
import com.android.settings.fuelgauge.batterytip.detectors.SmartBatteryDetector;
|
import com.android.settings.fuelgauge.batterytip.detectors.SmartBatteryDetector;
|
||||||
import com.android.settings.fuelgauge.batterytip.detectors.SummaryDetector;
|
|
||||||
import com.android.settings.fuelgauge.batterytip.tips.BatteryTip;
|
import com.android.settings.fuelgauge.batterytip.tips.BatteryTip;
|
||||||
import com.android.settings.fuelgauge.batterytip.tips.LowBatteryTip;
|
import com.android.settings.fuelgauge.batterytip.tips.LowBatteryTip;
|
||||||
import com.android.settings.fuelgauge.batterytip.tips.SummaryTip;
|
import com.android.settings.fuelgauge.batterytip.tips.SummaryTip;
|
||||||
@@ -73,7 +72,6 @@ public class BatteryTipLoader extends AsyncLoaderCompat<List<BatteryTip>> {
|
|||||||
tips.add(new SmartBatteryDetector(policy, context.getContentResolver()).detect());
|
tips.add(new SmartBatteryDetector(policy, context.getContentResolver()).detect());
|
||||||
tips.add(new EarlyWarningDetector(policy, context).detect());
|
tips.add(new EarlyWarningDetector(policy, context).detect());
|
||||||
tips.add(new BatteryDefenderDetector(batteryInfo).detect());
|
tips.add(new BatteryDefenderDetector(batteryInfo).detect());
|
||||||
tips.add(new SummaryDetector(policy, batteryInfo.averageTimeToDischarge).detect());
|
|
||||||
// Disable this feature now since it introduces false positive cases. We will try to improve
|
// Disable this feature now since it introduces false positive cases. We will try to improve
|
||||||
// it in the future.
|
// it in the future.
|
||||||
// tips.add(new RestrictAppDetector(context, policy).detect());
|
// tips.add(new RestrictAppDetector(context, policy).detect());
|
||||||
|
|||||||
@@ -230,7 +230,7 @@ public class BatteryTipPolicy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
batteryTipEnabled = mParser.getBoolean(KEY_BATTERY_TIP_ENABLED, true);
|
batteryTipEnabled = mParser.getBoolean(KEY_BATTERY_TIP_ENABLED, true);
|
||||||
summaryEnabled = mParser.getBoolean(KEY_SUMMARY_ENABLED, true);
|
summaryEnabled = mParser.getBoolean(KEY_SUMMARY_ENABLED, false);
|
||||||
batterySaverTipEnabled = mParser.getBoolean(KEY_BATTERY_SAVER_TIP_ENABLED, true);
|
batterySaverTipEnabled = mParser.getBoolean(KEY_BATTERY_SAVER_TIP_ENABLED, true);
|
||||||
highUsageEnabled = mParser.getBoolean(KEY_HIGH_USAGE_ENABLED, true);
|
highUsageEnabled = mParser.getBoolean(KEY_HIGH_USAGE_ENABLED, true);
|
||||||
highUsageAppCount = mParser.getInt(KEY_HIGH_USAGE_APP_COUNT, 3);
|
highUsageAppCount = mParser.getInt(KEY_HIGH_USAGE_APP_COUNT, 3);
|
||||||
|
|||||||
@@ -28,11 +28,9 @@ import com.android.settings.core.BasePreferenceController;
|
|||||||
import com.android.settings.core.InstrumentedPreferenceFragment;
|
import com.android.settings.core.InstrumentedPreferenceFragment;
|
||||||
import com.android.settings.fuelgauge.batterytip.actions.BatteryTipAction;
|
import com.android.settings.fuelgauge.batterytip.actions.BatteryTipAction;
|
||||||
import com.android.settings.fuelgauge.batterytip.tips.BatteryTip;
|
import com.android.settings.fuelgauge.batterytip.tips.BatteryTip;
|
||||||
import com.android.settings.fuelgauge.batterytip.tips.SummaryTip;
|
|
||||||
import com.android.settings.overlay.FeatureFactory;
|
import com.android.settings.overlay.FeatureFactory;
|
||||||
import com.android.settings.widget.CardPreference;
|
import com.android.settings.widget.CardPreference;
|
||||||
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
||||||
import com.android.settingslib.fuelgauge.EstimateKt;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -91,10 +89,8 @@ public class BatteryTipPreferenceController extends BasePreferenceController {
|
|||||||
mPrefContext = screen.getContext();
|
mPrefContext = screen.getContext();
|
||||||
mCardPreference = screen.findPreference(getPreferenceKey());
|
mCardPreference = screen.findPreference(getPreferenceKey());
|
||||||
|
|
||||||
// Add summary tip in advance to avoid UI flakiness
|
// Set preference as invisible since there is no default tips.
|
||||||
final SummaryTip summaryTip = new SummaryTip(BatteryTip.StateType.NEW,
|
mCardPreference.setVisible(false);
|
||||||
EstimateKt.AVERAGE_TIME_TO_DISCHARGE_UNKNOWN);
|
|
||||||
summaryTip.updatePreference(mCardPreference);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateBatteryTips(List<BatteryTip> batteryTips) {
|
public void updateBatteryTips(List<BatteryTip> batteryTips) {
|
||||||
@@ -110,10 +106,12 @@ public class BatteryTipPreferenceController extends BasePreferenceController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mCardPreference.setVisible(false);
|
||||||
for (int i = 0, size = batteryTips.size(); i < size; i++) {
|
for (int i = 0, size = batteryTips.size(); i < size; i++) {
|
||||||
final BatteryTip batteryTip = mBatteryTips.get(i);
|
final BatteryTip batteryTip = mBatteryTips.get(i);
|
||||||
batteryTip.validateCheck(mContext);
|
batteryTip.validateCheck(mContext);
|
||||||
if (batteryTip.getState() != BatteryTip.StateType.INVISIBLE) {
|
if (batteryTip.getState() != BatteryTip.StateType.INVISIBLE) {
|
||||||
|
mCardPreference.setVisible(true);
|
||||||
batteryTip.updatePreference(mCardPreference);
|
batteryTip.updatePreference(mCardPreference);
|
||||||
mBatteryTipMap.put(mCardPreference.getKey(), batteryTip);
|
mBatteryTipMap.put(mCardPreference.getKey(), batteryTip);
|
||||||
batteryTip.log(mContext, mMetricsFeatureProvider);
|
batteryTip.log(mContext, mMetricsFeatureProvider);
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ public class SwipeBottomToNotificationPreferenceController extends TogglePrefere
|
|||||||
@Override
|
@Override
|
||||||
public boolean isChecked() {
|
public boolean isChecked() {
|
||||||
return Settings.Secure.getInt(mContext.getContentResolver(),
|
return Settings.Secure.getInt(mContext.getContentResolver(),
|
||||||
SWIPE_BOTTOM_TO_NOTIFICATION_ENABLED, ON) == ON;
|
SWIPE_BOTTOM_TO_NOTIFICATION_ENABLED, OFF) == ON;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ public class InternetPreferenceController extends AbstractPreferenceController i
|
|||||||
private static Map<Integer, Integer> sSummaryMap = new HashMap<>();
|
private static Map<Integer, Integer> sSummaryMap = new HashMap<>();
|
||||||
static {
|
static {
|
||||||
sSummaryMap.put(INTERNET_OFF, R.string.condition_airplane_title);
|
sSummaryMap.put(INTERNET_OFF, R.string.condition_airplane_title);
|
||||||
sSummaryMap.put(INTERNET_NETWORKS_AVAILABLE, R.string.disconnected);
|
sSummaryMap.put(INTERNET_NETWORKS_AVAILABLE, R.string.networks_available);
|
||||||
sSummaryMap.put(INTERNET_WIFI, 0);
|
sSummaryMap.put(INTERNET_WIFI, 0);
|
||||||
sSummaryMap.put(INTERNET_CELLULAR, 0);
|
sSummaryMap.put(INTERNET_CELLULAR, 0);
|
||||||
sSummaryMap.put(INTERNET_ETHERNET, R.string.to_switch_networks_disconnect_ethernet);
|
sSummaryMap.put(INTERNET_ETHERNET, R.string.to_switch_networks_disconnect_ethernet);
|
||||||
|
|||||||
@@ -16,8 +16,6 @@
|
|||||||
|
|
||||||
package com.android.settings.utils;
|
package com.android.settings.utils;
|
||||||
|
|
||||||
import android.os.Process;
|
|
||||||
import android.security.keystore.AndroidKeyStoreProvider;
|
|
||||||
import android.security.keystore.KeyProperties;
|
import android.security.keystore.KeyProperties;
|
||||||
import android.security.keystore2.AndroidKeyStoreLoadStoreParameter;
|
import android.security.keystore2.AndroidKeyStoreLoadStoreParameter;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@@ -41,6 +39,8 @@ import java.util.Enumeration;
|
|||||||
public class AndroidKeystoreAliasLoader {
|
public class AndroidKeystoreAliasLoader {
|
||||||
private static final String TAG = "SettingsKeystoreUtils";
|
private static final String TAG = "SettingsKeystoreUtils";
|
||||||
|
|
||||||
|
private static final String KEYSTORE_PROVIDER = "AndroidKeyStore";
|
||||||
|
|
||||||
private final Collection<String> mKeyCertAliases;
|
private final Collection<String> mKeyCertAliases;
|
||||||
private final Collection<String> mCaCertAliases;
|
private final Collection<String> mCaCertAliases;
|
||||||
/**
|
/**
|
||||||
@@ -58,21 +58,13 @@ public class AndroidKeystoreAliasLoader {
|
|||||||
public AndroidKeystoreAliasLoader(Integer namespace) {
|
public AndroidKeystoreAliasLoader(Integer namespace) {
|
||||||
mKeyCertAliases = new ArrayList<>();
|
mKeyCertAliases = new ArrayList<>();
|
||||||
mCaCertAliases = new ArrayList<>();
|
mCaCertAliases = new ArrayList<>();
|
||||||
KeyStore keyStore = null;
|
final KeyStore keyStore;
|
||||||
final Enumeration<String> aliases;
|
final Enumeration<String> aliases;
|
||||||
try {
|
try {
|
||||||
|
keyStore = KeyStore.getInstance(KEYSTORE_PROVIDER);
|
||||||
if (namespace != null && namespace != KeyProperties.NAMESPACE_APPLICATION) {
|
if (namespace != null && namespace != KeyProperties.NAMESPACE_APPLICATION) {
|
||||||
if (AndroidKeyStoreProvider.isKeystore2Enabled()) {
|
keyStore.load(new AndroidKeyStoreLoadStoreParameter(namespace));
|
||||||
keyStore = KeyStore.getInstance("AndroidKeyStore");
|
|
||||||
keyStore.load(new AndroidKeyStoreLoadStoreParameter(namespace));
|
|
||||||
} else {
|
|
||||||
// In the legacy case we pass in the WIFI UID because that is the only
|
|
||||||
// possible special namespace that existed as of this writing,
|
|
||||||
// and new namespaces must only be added using the new mechanism.
|
|
||||||
keyStore = AndroidKeyStoreProvider.getKeyStoreForUid(Process.WIFI_UID);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
keyStore = KeyStore.getInstance("AndroidKeyStore");
|
|
||||||
keyStore.load(null);
|
keyStore.load(null);
|
||||||
}
|
}
|
||||||
aliases = keyStore.aliases();
|
aliases = keyStore.aliases();
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ import android.content.IntentFilter;
|
|||||||
import android.location.LocationManager;
|
import android.location.LocationManager;
|
||||||
import android.net.wifi.WifiManager;
|
import android.net.wifi.WifiManager;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.util.FeatureFlagUtils;
|
|
||||||
|
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
@@ -45,7 +44,6 @@ import com.android.settingslib.core.lifecycle.events.OnResume;
|
|||||||
* {@link TogglePreferenceController} that controls whether the Wi-Fi Wakeup feature should be
|
* {@link TogglePreferenceController} that controls whether the Wi-Fi Wakeup feature should be
|
||||||
* enabled.
|
* enabled.
|
||||||
*/
|
*/
|
||||||
// TODO(b/167474581): Should clean up this controller when Provider Model finished.
|
|
||||||
public class WifiWakeupPreferenceController extends TogglePreferenceController implements
|
public class WifiWakeupPreferenceController extends TogglePreferenceController implements
|
||||||
LifecycleObserver, OnPause, OnResume {
|
LifecycleObserver, OnPause, OnResume {
|
||||||
|
|
||||||
@@ -91,9 +89,6 @@ public class WifiWakeupPreferenceController extends TogglePreferenceController i
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getAvailabilityStatus() {
|
public int getAvailabilityStatus() {
|
||||||
if (FeatureFlagUtils.isEnabled(mContext, FeatureFlagUtils.SETTINGS_PROVIDER_MODEL)) {
|
|
||||||
return CONDITIONALLY_UNAVAILABLE;
|
|
||||||
}
|
|
||||||
return AVAILABLE;
|
return AVAILABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,8 @@
|
|||||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
|
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
|
||||||
<uses-permission android:name="android.permission.BLUETOOTH"/>
|
<uses-permission android:name="android.permission.BLUETOOTH"/>
|
||||||
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
|
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
|
||||||
|
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT"/>
|
||||||
|
<uses-permission android:name="android.permission.BLUETOOTH_SCAN"/>
|
||||||
<uses-permission android:name="android.permission.WAKE_LOCK"/>
|
<uses-permission android:name="android.permission.WAKE_LOCK"/>
|
||||||
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS"/>
|
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS"/>
|
||||||
<uses-permission android:name="android.permission.WRITE_SETTINGS"/>
|
<uses-permission android:name="android.permission.WRITE_SETTINGS"/>
|
||||||
@@ -49,4 +51,4 @@
|
|||||||
android:label="Settings Test Cases">
|
android:label="Settings Test Cases">
|
||||||
</instrumentation>
|
</instrumentation>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
|
|||||||
@@ -20,6 +20,8 @@
|
|||||||
|
|
||||||
<uses-permission android:name="android.permission.BLUETOOTH" />
|
<uses-permission android:name="android.permission.BLUETOOTH" />
|
||||||
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
|
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
|
||||||
|
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
|
||||||
|
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||||
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
|
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
|
||||||
@@ -37,4 +39,4 @@
|
|||||||
android:label="Settings Test Cases">
|
android:label="Settings Test Cases">
|
||||||
</instrumentation>
|
</instrumentation>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
|
|||||||
@@ -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,10 +16,15 @@
|
|||||||
|
|
||||||
package com.android.settings.enterprise;
|
package com.android.settings.enterprise;
|
||||||
|
|
||||||
|
import static android.app.admin.DevicePolicyManager.DEVICE_OWNER_TYPE_DEFAULT;
|
||||||
|
import static android.app.admin.DevicePolicyManager.DEVICE_OWNER_TYPE_FINANCED;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
import android.app.admin.DevicePolicyManager;
|
||||||
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
@@ -42,9 +47,14 @@ public class EnterprisePrivacyPreferenceControllerTest {
|
|||||||
private static final String MANAGED_WITH_NAME = "managed by Foo, Inc.";
|
private static final String MANAGED_WITH_NAME = "managed by Foo, Inc.";
|
||||||
private static final String MANAGING_ORGANIZATION = "Foo, Inc.";
|
private static final String MANAGING_ORGANIZATION = "Foo, Inc.";
|
||||||
private static final String KEY_ENTERPRISE_PRIVACY = "enterprise_privacy";
|
private static final String KEY_ENTERPRISE_PRIVACY = "enterprise_privacy";
|
||||||
|
private static final String FINANCED_PREFERENCE_TITLE = "Financed device info";
|
||||||
|
private static final ComponentName DEVICE_OWNER_COMPONENT =
|
||||||
|
new ComponentName("com.android.foo", "bar");
|
||||||
|
|
||||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
|
@Mock
|
||||||
|
private DevicePolicyManager mDevicePolicyManager;
|
||||||
private FakeFeatureFactory mFeatureFactory;
|
private FakeFeatureFactory mFeatureFactory;
|
||||||
|
|
||||||
private EnterprisePrivacyPreferenceController mController;
|
private EnterprisePrivacyPreferenceController mController;
|
||||||
@@ -54,6 +64,14 @@ public class EnterprisePrivacyPreferenceControllerTest {
|
|||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
mFeatureFactory = FakeFeatureFactory.setupForTest();
|
mFeatureFactory = FakeFeatureFactory.setupForTest();
|
||||||
mController = new EnterprisePrivacyPreferenceController(mContext);
|
mController = new EnterprisePrivacyPreferenceController(mContext);
|
||||||
|
|
||||||
|
when((Object) 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
|
@Test
|
||||||
@@ -76,6 +94,25 @@ public class EnterprisePrivacyPreferenceControllerTest {
|
|||||||
assertThat(preference.getSummary()).isEqualTo(MANAGED_WITH_NAME);
|
assertThat(preference.getSummary()).isEqualTo(MANAGED_WITH_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpdateState_verifyPreferenceTitleIsUpdatedForFinancedDevice() {
|
||||||
|
final Preference preference = new Preference(mContext, null, 0, 0);
|
||||||
|
when(mContext.getResources().getString(
|
||||||
|
R.string.enterprise_privacy_settings_summary_with_name, MANAGING_ORGANIZATION))
|
||||||
|
.thenReturn(MANAGED_WITH_NAME);
|
||||||
|
when(mContext.getString(R.string.financed_privacy_settings))
|
||||||
|
.thenReturn(FINANCED_PREFERENCE_TITLE);
|
||||||
|
when(mFeatureFactory.enterprisePrivacyFeatureProvider.getDeviceOwnerOrganizationName())
|
||||||
|
.thenReturn(MANAGING_ORGANIZATION);
|
||||||
|
when(mDevicePolicyManager.getDeviceOwnerType(DEVICE_OWNER_COMPONENT))
|
||||||
|
.thenReturn(DEVICE_OWNER_TYPE_FINANCED);
|
||||||
|
|
||||||
|
mController.updateState(preference);
|
||||||
|
|
||||||
|
assertThat(preference.getTitle()).isEqualTo(FINANCED_PREFERENCE_TITLE);
|
||||||
|
assertThat(preference.getSummary()).isEqualTo(MANAGED_WITH_NAME);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIsAvailable() {
|
public void testIsAvailable() {
|
||||||
when(mFeatureFactory.enterprisePrivacyFeatureProvider.hasDeviceOwner()).thenReturn(false);
|
when(mFeatureFactory.enterprisePrivacyFeatureProvider.hasDeviceOwner()).thenReturn(false);
|
||||||
|
|||||||
@@ -16,47 +16,70 @@
|
|||||||
|
|
||||||
package com.android.settings.enterprise;
|
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 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 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.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.testutils.FakeFeatureFactory;
|
import com.android.settings.testutils.FakeFeatureFactory;
|
||||||
import com.android.settings.widget.PreferenceCategoryController;
|
|
||||||
import com.android.settingslib.core.AbstractPreferenceController;
|
import com.android.settingslib.core.AbstractPreferenceController;
|
||||||
import com.android.settingslib.drawer.CategoryKey;
|
import com.android.settingslib.drawer.CategoryKey;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.Answers;
|
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
import org.robolectric.RobolectricTestRunner;
|
import org.robolectric.RobolectricTestRunner;
|
||||||
import org.robolectric.RuntimeEnvironment;
|
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@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)
|
@Mock
|
||||||
private Context mContext;
|
private DevicePolicyManager mDevicePolicyManager;
|
||||||
|
@Mock
|
||||||
|
private PrivacySettingsPreference mPrivacySettingsPreference;
|
||||||
private FakeFeatureFactory mFeatureFactory;
|
private FakeFeatureFactory mFeatureFactory;
|
||||||
private EnterprisePrivacySettings mSettings;
|
private EnterprisePrivacySettings mSettings;
|
||||||
|
|
||||||
|
@Override
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
|
mContext = spy(ApplicationProvider.getApplicationContext());
|
||||||
mFeatureFactory = FakeFeatureFactory.setupForTest();
|
mFeatureFactory = FakeFeatureFactory.setupForTest();
|
||||||
mSettings = new EnterprisePrivacySettings();
|
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
|
@Test
|
||||||
public void verifyConstants() {
|
public void verifyConstants() {
|
||||||
|
when(mPrivacySettingsPreference.getPreferenceScreenResId())
|
||||||
|
.thenReturn(R.xml.enterprise_privacy_settings);
|
||||||
|
|
||||||
assertThat(mSettings.getMetricsCategory())
|
assertThat(mSettings.getMetricsCategory())
|
||||||
.isEqualTo(MetricsEvent.ENTERPRISE_PRIVACY_SETTINGS);
|
.isEqualTo(MetricsEvent.ENTERPRISE_PRIVACY_SETTINGS);
|
||||||
assertThat(mSettings.getLogTag()).isEqualTo("EnterprisePrivacySettings");
|
assertThat(mSettings.getLogTag()).isEqualTo("EnterprisePrivacySettings");
|
||||||
@@ -76,6 +99,7 @@ public class EnterprisePrivacySettingsTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void isPageEnabled_noDeviceOwner_shouldReturnFalse() {
|
public void isPageEnabled_noDeviceOwner_shouldReturnFalse() {
|
||||||
|
when(mDevicePolicyManager.isDeviceManaged()).thenReturn(false);
|
||||||
when(mFeatureFactory.enterprisePrivacyFeatureProvider.hasDeviceOwner())
|
when(mFeatureFactory.enterprisePrivacyFeatureProvider.hasDeviceOwner())
|
||||||
.thenReturn(false);
|
.thenReturn(false);
|
||||||
|
|
||||||
@@ -85,53 +109,35 @@ public class EnterprisePrivacySettingsTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getPreferenceControllers() {
|
public void getPreferenceControllers() {
|
||||||
final List<AbstractPreferenceController> controllers =
|
final List<AbstractPreferenceController> controllers = new ArrayList<>();
|
||||||
mSettings.createPreferenceControllers(RuntimeEnvironment.application);
|
controllers.add(new NetworkLogsPreferenceController(mContext));
|
||||||
verifyPreferenceControllers(controllers);
|
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
|
@Test
|
||||||
public void getSearchIndexProviderPreferenceControllers() {
|
public void
|
||||||
|
getSearchIndexProviderPreferenceControllers_returnsEnterpriseSearchIndexPreferenceControllers() {
|
||||||
final List<AbstractPreferenceController> controllers =
|
final List<AbstractPreferenceController> controllers =
|
||||||
EnterprisePrivacySettings.SEARCH_INDEX_DATA_PROVIDER
|
EnterprisePrivacySettings.SEARCH_INDEX_DATA_PROVIDER
|
||||||
.getPreferenceControllers(RuntimeEnvironment.application);
|
.getPreferenceControllers(mContext);
|
||||||
verifyPreferenceControllers(controllers);
|
|
||||||
|
verifyEnterprisePreferenceControllers(controllers);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void verifyPreferenceControllers(List<AbstractPreferenceController> controllers) {
|
@Test
|
||||||
assertThat(controllers).isNotNull();
|
public void getXmlResourcesToIndex_returnsEnterpriseXmlResources() {
|
||||||
assertThat(controllers.size()).isEqualTo(17);
|
final List<SearchIndexableResource> searchIndexableResources =
|
||||||
int position = 0;
|
EnterprisePrivacySettings.SEARCH_INDEX_DATA_PROVIDER
|
||||||
assertThat(controllers.get(position++)).isInstanceOf(NetworkLogsPreferenceController.class);
|
.getXmlResourcesToIndex(mContext, true);
|
||||||
assertThat(controllers.get(position++)).isInstanceOf(BugReportsPreferenceController.class);
|
|
||||||
assertThat(controllers.get(position++)).isInstanceOf(
|
verifyEnterpriseSearchIndexableResources(searchIndexableResources);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -277,7 +277,7 @@ public class BatteryUtilsTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testCalculateLastFullChargeTime() {
|
public void testCalculateLastFullChargeTime() {
|
||||||
final long currentTimeMs = System.currentTimeMillis();
|
final long currentTimeMs = System.currentTimeMillis();
|
||||||
when(mBatteryUsageStats.getStatsStartRealtime()).thenReturn(
|
when(mBatteryUsageStats.getStatsStartTimestamp()).thenReturn(
|
||||||
currentTimeMs - TIME_SINCE_LAST_FULL_CHARGE_MS);
|
currentTimeMs - TIME_SINCE_LAST_FULL_CHARGE_MS);
|
||||||
|
|
||||||
assertThat(mBatteryUtils.calculateLastFullChargeTime(mBatteryUsageStats, currentTimeMs))
|
assertThat(mBatteryUtils.calculateLastFullChargeTime(mBatteryUsageStats, currentTimeMs))
|
||||||
|
|||||||
@@ -54,7 +54,6 @@ public class BatteryTipLoaderTest {
|
|||||||
BatteryTip.TipType.BATTERY_SAVER,
|
BatteryTip.TipType.BATTERY_SAVER,
|
||||||
BatteryTip.TipType.HIGH_DEVICE_USAGE,
|
BatteryTip.TipType.HIGH_DEVICE_USAGE,
|
||||||
BatteryTip.TipType.LOW_BATTERY,
|
BatteryTip.TipType.LOW_BATTERY,
|
||||||
BatteryTip.TipType.SUMMARY,
|
|
||||||
BatteryTip.TipType.SMART_BATTERY_MANAGER};
|
BatteryTip.TipType.SMART_BATTERY_MANAGER};
|
||||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||||
private BatteryUsageStats mBatteryUsageStats;
|
private BatteryUsageStats mBatteryUsageStats;
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ import static com.android.settings.fuelgauge.batterytip.tips.BatteryTip.TipType
|
|||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
|
||||||
import static org.mockito.Mockito.doReturn;
|
import static org.mockito.Mockito.doReturn;
|
||||||
import static org.mockito.Mockito.spy;
|
import static org.mockito.Mockito.spy;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
@@ -30,10 +29,6 @@ import android.content.Context;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.format.DateUtils;
|
import android.text.format.DateUtils;
|
||||||
|
|
||||||
import androidx.preference.Preference;
|
|
||||||
import androidx.preference.PreferenceCategory;
|
|
||||||
import androidx.preference.PreferenceGroup;
|
|
||||||
import androidx.preference.PreferenceManager;
|
|
||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
import com.android.internal.logging.nano.MetricsProto;
|
import com.android.internal.logging.nano.MetricsProto;
|
||||||
@@ -49,7 +44,6 @@ import com.android.settings.widget.CardPreference;
|
|||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.Answers;
|
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
import org.robolectric.RobolectricTestRunner;
|
import org.robolectric.RobolectricTestRunner;
|
||||||
@@ -104,10 +98,24 @@ public class BatteryTipPreferenceControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDisplayPreference_addSummaryTip() {
|
public void testDisplayPreference_isInvisible() {
|
||||||
mBatteryTipPreferenceController.displayPreference(mPreferenceScreen);
|
mBatteryTipPreferenceController.displayPreference(mPreferenceScreen);
|
||||||
|
|
||||||
assertOnlyContainsSummaryTip(mCardPreference);
|
assertThat(mCardPreference.isVisible()).isFalse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpdateBatteryTips_tipsStateNew_isVisible() {
|
||||||
|
mBatteryTipPreferenceController.updateBatteryTips(mOldBatteryTips);
|
||||||
|
|
||||||
|
assertThat(mCardPreference.isVisible()).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpdateBatteryTips_tipsStateInvisible_isInvisible() {
|
||||||
|
mBatteryTipPreferenceController.updateBatteryTips(mNewBatteryTips);
|
||||||
|
|
||||||
|
assertThat(mCardPreference.isVisible()).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ public class SwipeBottomToNotificationPreferenceControllerTest {
|
|||||||
mController.setChecked(true);
|
mController.setChecked(true);
|
||||||
|
|
||||||
assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
|
assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
|
||||||
SWIPE_BOTTOM_TO_NOTIFICATION_ENABLED, 1)).isEqualTo(1);
|
SWIPE_BOTTOM_TO_NOTIFICATION_ENABLED, 0)).isEqualTo(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -66,7 +66,7 @@ public class SwipeBottomToNotificationPreferenceControllerTest {
|
|||||||
mController.setChecked(false);
|
mController.setChecked(false);
|
||||||
|
|
||||||
assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
|
assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
|
||||||
SWIPE_BOTTOM_TO_NOTIFICATION_ENABLED, 1)).isEqualTo(0);
|
SWIPE_BOTTOM_TO_NOTIFICATION_ENABLED, 0)).isEqualTo(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -109,4 +109,13 @@ public class SwipeBottomToNotificationPreferenceControllerTest {
|
|||||||
assertThat(mController.getSummary()).isEqualTo(
|
assertThat(mController.getSummary()).isEqualTo(
|
||||||
mContext.getText(R.string.gesture_setting_off));
|
mContext.getText(R.string.gesture_setting_off));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getDefaultConfig_returnsOffState() {
|
||||||
|
SystemProperties.set(OneHandedEnablePreferenceController.SUPPORT_ONE_HANDED_MODE, "false");
|
||||||
|
Settings.Secure.resetToDefaults(mContext.getContentResolver(),
|
||||||
|
Settings.Secure.ONE_HANDED_MODE_ENABLED);
|
||||||
|
|
||||||
|
assertThat(mController.isChecked()).isFalse();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,8 @@
|
|||||||
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
|
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
|
||||||
<uses-permission android:name="android.permission.BLUETOOTH" />
|
<uses-permission android:name="android.permission.BLUETOOTH" />
|
||||||
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
|
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
|
||||||
|
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
|
||||||
|
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
|
||||||
<uses-permission android:name="android.permission.READ_LOGS" />
|
<uses-permission android:name="android.permission.READ_LOGS" />
|
||||||
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
|
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
|
||||||
<uses-permission android:name="android.permission.READ_SEARCH_INDEXABLES"/>
|
<uses-permission android:name="android.permission.READ_SEARCH_INDEXABLES"/>
|
||||||
|
|||||||
@@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
<uses-permission android:name="android.permission.BLUETOOTH" />
|
<uses-permission android:name="android.permission.BLUETOOTH" />
|
||||||
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
|
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
|
||||||
|
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
|
||||||
|
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||||
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
|
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ public class BatteryTipPolicyTest {
|
|||||||
final BatteryTipPolicy batteryTipPolicy = new BatteryTipPolicy(mContext);
|
final BatteryTipPolicy batteryTipPolicy = new BatteryTipPolicy(mContext);
|
||||||
|
|
||||||
assertThat(batteryTipPolicy.batteryTipEnabled).isTrue();
|
assertThat(batteryTipPolicy.batteryTipEnabled).isTrue();
|
||||||
assertThat(batteryTipPolicy.summaryEnabled).isTrue();
|
assertThat(batteryTipPolicy.summaryEnabled).isFalse();
|
||||||
assertThat(batteryTipPolicy.batterySaverTipEnabled).isTrue();
|
assertThat(batteryTipPolicy.batterySaverTipEnabled).isTrue();
|
||||||
assertThat(batteryTipPolicy.highUsageEnabled).isTrue();
|
assertThat(batteryTipPolicy.highUsageEnabled).isTrue();
|
||||||
assertThat(batteryTipPolicy.highUsageAppCount).isEqualTo(3);
|
assertThat(batteryTipPolicy.highUsageAppCount).isEqualTo(3);
|
||||||
|
|||||||
Reference in New Issue
Block a user