Merge "Move apn settings to network" into pi-dev
diff --git a/res/xml/enterprise_privacy_settings.xml b/res/xml/enterprise_privacy_settings.xml
index 4fa50e7..0aa1415 100644
--- a/res/xml/enterprise_privacy_settings.xml
+++ b/res/xml/enterprise_privacy_settings.xml
@@ -83,6 +83,9 @@
<Preference android:key="ca_certs_managed_profile"
android:title="@string/enterprise_privacy_ca_certs_work"
android:selectable="false"/>
+ <Preference android:key="backups_enabled"
+ android:title="@string/enterprise_privacy_backups_enabled"
+ android:selectable="false"/>
</PreferenceCategory>
<PreferenceCategory android:key="device_access_category"
diff --git a/res/xml/network_and_internet.xml b/res/xml/network_and_internet.xml
index a28b1e6..ee99998 100644
--- a/res/xml/network_and_internet.xml
+++ b/res/xml/network_and_internet.xml
@@ -18,7 +18,8 @@
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:key="network_and_internet_screen"
- android:title="@string/network_dashboard_title">
+ android:title="@string/network_dashboard_title"
+ settings:initialExpandedChildrenCount="5">
<com.android.settings.widget.MasterSwitchPreference
android:fragment="com.android.settings.wifi.WifiSettings"
@@ -59,19 +60,10 @@
settings:useAdminDisabledSummary="true" />
<com.android.settingslib.RestrictedPreference
- android:fragment="com.android.settings.vpn2.VpnSettings"
- android:key="vpn_settings"
- android:title="@string/vpn_settings_title"
- android:icon="@drawable/ic_vpn_key"
- android:order="0"
- android:summary="@string/summary_placeholder"
- settings:userRestriction="no_config_vpn"
- settings:useAdminDisabledSummary="true" />
-
- <com.android.settingslib.RestrictedPreference
android:key="manage_mobile_plan"
android:title="@string/manage_mobile_plan_title"
android:persistent="false"
+ android:order="0"
settings:userRestriction="no_config_mobile_networks"
settings:useAdminDisabledSummary="true" />
@@ -88,4 +80,22 @@
android:key="proxy_settings"
android:title="@string/proxy_settings_title" />
-</PreferenceScreen>
\ No newline at end of file
+ <com.android.settingslib.RestrictedPreference
+ android:fragment="com.android.settings.vpn2.VpnSettings"
+ android:key="vpn_settings"
+ android:title="@string/vpn_settings_title"
+ android:icon="@drawable/ic_vpn_key"
+ android:order="10"
+ android:summary="@string/summary_placeholder"
+ settings:userRestriction="no_config_vpn"
+ settings:useAdminDisabledSummary="true" />
+
+ <com.android.settings.network.PrivateDnsModeDialogPreference
+ android:key="private_dns_settings"
+ android:title="@string/select_private_dns_configuration_title"
+ android:order="15"
+ android:dialogTitle="@string/select_private_dns_configuration_dialog_title"
+ android:dialogLayout="@layout/private_dns_mode_dialog"
+ android:positiveButtonText="@string/save" />
+
+</PreferenceScreen>
diff --git a/src/com/android/settings/applications/AppStateAppOpsBridge.java b/src/com/android/settings/applications/AppStateAppOpsBridge.java
index e0c19ff..1f843b9 100755
--- a/src/com/android/settings/applications/AppStateAppOpsBridge.java
+++ b/src/com/android/settings/applications/AppStateAppOpsBridge.java
@@ -19,6 +19,7 @@
import android.app.AppOpsManager;
import android.app.AppOpsManager.PackageOps;
import android.content.Context;
+import android.content.pm.IPackageManager;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.RemoteException;
@@ -31,7 +32,6 @@
import com.android.settingslib.applications.ApplicationsState;
import com.android.settingslib.applications.ApplicationsState.AppEntry;
-import com.android.settings.wrapper.IPackageManagerWrapper;
import java.util.Arrays;
import java.util.Collection;
@@ -47,7 +47,7 @@
private static final String TAG = "AppStateAppOpsBridge";
- private final IPackageManagerWrapper mIPackageManager;
+ private final IPackageManager mIPackageManager;
private final UserManager mUserManager;
private final List<UserHandle> mProfiles;
private final AppOpsManager mAppOpsManager;
@@ -58,12 +58,12 @@
public AppStateAppOpsBridge(Context context, ApplicationsState appState, Callback callback,
int appOpsOpCode, String[] permissions) {
this(context, appState, callback, appOpsOpCode, permissions,
- new IPackageManagerWrapper(AppGlobals.getPackageManager()));
+ AppGlobals.getPackageManager());
}
@VisibleForTesting
AppStateAppOpsBridge(Context context, ApplicationsState appState, Callback callback,
- int appOpsOpCode, String[] permissions, IPackageManagerWrapper packageManager) {
+ int appOpsOpCode, String[] permissions, IPackageManager packageManager) {
super(appState, callback);
mContext = context;
mIPackageManager = packageManager;
@@ -210,9 +210,10 @@
if (entriesForProfile == null) {
continue;
}
- @SuppressWarnings("unchecked")
- final List<PackageInfo> packageInfos = mIPackageManager
- .getPackagesHoldingPermissions(mPermissions, 0, profileId).getList();
+ @SuppressWarnings("unchecked") final List<PackageInfo> packageInfos =
+ mIPackageManager
+ .getPackagesHoldingPermissions(mPermissions, 0,
+ profileId).getList();
final int packageInfoCount = packageInfos != null ? packageInfos.size() : 0;
for (int i = 0; i < packageInfoCount; i++) {
final PackageInfo packageInfo = packageInfos.get(i);
diff --git a/src/com/android/settings/applications/AppWithAdminGrantedPermissionsCounter.java b/src/com/android/settings/applications/AppWithAdminGrantedPermissionsCounter.java
index 77cecd2..9bb7a4b 100644
--- a/src/com/android/settings/applications/AppWithAdminGrantedPermissionsCounter.java
+++ b/src/com/android/settings/applications/AppWithAdminGrantedPermissionsCounter.java
@@ -17,12 +17,12 @@
import android.app.admin.DevicePolicyManager;
import android.content.Context;
import android.content.pm.ApplicationInfo;
+import android.content.pm.IPackageManager;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.RemoteException;
import android.os.UserHandle;
-import com.android.settings.wrapper.IPackageManagerWrapper;
import com.android.settingslib.wrapper.PackageManagerWrapper;
/**
@@ -32,11 +32,11 @@
public abstract class AppWithAdminGrantedPermissionsCounter extends AppCounter {
private final String[] mPermissions;
- private final IPackageManagerWrapper mPackageManagerService;
+ private final IPackageManager mPackageManagerService;
private final DevicePolicyManager mDevicePolicyManager;
public AppWithAdminGrantedPermissionsCounter(Context context, String[] permissions,
- PackageManagerWrapper packageManager, IPackageManagerWrapper packageManagerService,
+ PackageManagerWrapper packageManager, IPackageManager packageManagerService,
DevicePolicyManager devicePolicyManager) {
super(context, packageManager);
mPermissions = permissions;
@@ -52,7 +52,7 @@
public static boolean includeInCount(String[] permissions,
DevicePolicyManager devicePolicyManager, PackageManagerWrapper packageManager,
- IPackageManagerWrapper packageManagerService, ApplicationInfo info) {
+ IPackageManager packageManagerService, ApplicationInfo info) {
if (info.targetSdkVersion >= Build.VERSION_CODES.M) {
// The app uses run-time permissions. Check whether one or more of the permissions were
// granted by enterprise policy.
diff --git a/src/com/android/settings/applications/AppWithAdminGrantedPermissionsLister.java b/src/com/android/settings/applications/AppWithAdminGrantedPermissionsLister.java
index 655758a..1308620 100644
--- a/src/com/android/settings/applications/AppWithAdminGrantedPermissionsLister.java
+++ b/src/com/android/settings/applications/AppWithAdminGrantedPermissionsLister.java
@@ -18,9 +18,9 @@
import android.app.admin.DevicePolicyManager;
import android.content.pm.ApplicationInfo;
+import android.content.pm.IPackageManager;
import android.os.UserManager;
-import com.android.settings.wrapper.IPackageManagerWrapper;
import com.android.settingslib.wrapper.PackageManagerWrapper;
/**
@@ -29,11 +29,11 @@
*/
public abstract class AppWithAdminGrantedPermissionsLister extends AppLister {
private final String[] mPermissions;
- private final IPackageManagerWrapper mPackageManagerService;
+ private final IPackageManager mPackageManagerService;
private final DevicePolicyManager mDevicePolicyManager;
public AppWithAdminGrantedPermissionsLister(String[] permissions,
- PackageManagerWrapper packageManager, IPackageManagerWrapper packageManagerService,
+ PackageManagerWrapper packageManager, IPackageManager packageManagerService,
DevicePolicyManager devicePolicyManager, UserManager userManager) {
super(packageManager, userManager);
mPermissions = permissions;
diff --git a/src/com/android/settings/applications/ApplicationFeatureProviderImpl.java b/src/com/android/settings/applications/ApplicationFeatureProviderImpl.java
index cd54f79..f592865 100644
--- a/src/com/android/settings/applications/ApplicationFeatureProviderImpl.java
+++ b/src/com/android/settings/applications/ApplicationFeatureProviderImpl.java
@@ -20,6 +20,7 @@
import android.content.Context;
import android.content.Intent;
import android.content.pm.ComponentInfo;
+import android.content.pm.IPackageManager;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.pm.UserInfo;
@@ -27,7 +28,6 @@
import android.os.UserManager;
import android.util.ArraySet;
-import com.android.settings.wrapper.IPackageManagerWrapper;
import com.android.settingslib.wrapper.PackageManagerWrapper;
import java.util.ArrayList;
@@ -38,12 +38,12 @@
private final Context mContext;
private final PackageManagerWrapper mPm;
- private final IPackageManagerWrapper mPms;
+ private final IPackageManager mPms;
private final DevicePolicyManager mDpm;
private final UserManager mUm;
public ApplicationFeatureProviderImpl(Context context, PackageManagerWrapper pm,
- IPackageManagerWrapper pms, DevicePolicyManager dpm) {
+ IPackageManager pms, DevicePolicyManager dpm) {
mContext = context.getApplicationContext();
mPm = pm;
mPms = pms;
@@ -149,7 +149,7 @@
CurrentUserAndManagedProfileAppWithAdminGrantedPermissionsCounter(Context context,
String[] permissions, PackageManagerWrapper packageManager,
- IPackageManagerWrapper packageManagerService,
+ IPackageManager packageManagerService,
DevicePolicyManager devicePolicyManager, NumberOfAppsCallback callback) {
super(context, permissions, packageManager, packageManagerService, devicePolicyManager);
mCallback = callback;
@@ -181,7 +181,7 @@
private ListOfAppsCallback mCallback;
CurrentUserAppWithAdminGrantedPermissionsLister(String[] permissions,
- PackageManagerWrapper packageManager, IPackageManagerWrapper packageManagerService,
+ PackageManagerWrapper packageManager, IPackageManager packageManagerService,
DevicePolicyManager devicePolicyManager, UserManager userManager,
ListOfAppsCallback callback) {
super(permissions, packageManager, packageManagerService, devicePolicyManager,
diff --git a/src/com/android/settings/applications/appinfo/PictureInPictureSettings.java b/src/com/android/settings/applications/appinfo/PictureInPictureSettings.java
index e2caa41..ef2c7a9 100644
--- a/src/com/android/settings/applications/appinfo/PictureInPictureSettings.java
+++ b/src/com/android/settings/applications/appinfo/PictureInPictureSettings.java
@@ -40,7 +40,6 @@
import com.android.settings.applications.AppInfoBase;
import com.android.settings.notification.EmptyTextSettings;
import com.android.settings.widget.AppPreference;
-import com.android.settings.wrapper.UserManagerWrapper;
import com.android.settingslib.wrapper.PackageManagerWrapper;
import java.text.Collator;
@@ -88,7 +87,7 @@
private Context mContext;
private PackageManagerWrapper mPackageManager;
- private UserManagerWrapper mUserManager;
+ private UserManager mUserManager;
private IconDrawableFactory mIconDrawableFactory;
/**
@@ -119,7 +118,7 @@
// Do nothing
}
- public PictureInPictureSettings(PackageManagerWrapper pm, UserManagerWrapper um) {
+ public PictureInPictureSettings(PackageManagerWrapper pm, UserManager um) {
mPackageManager = pm;
mUserManager = um;
}
@@ -130,7 +129,7 @@
mContext = getActivity();
mPackageManager = new PackageManagerWrapper(mContext.getPackageManager());
- mUserManager = new UserManagerWrapper(mContext.getSystemService(UserManager.class));
+ mUserManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
mIconDrawableFactory = IconDrawableFactory.newInstance(mContext);
}
diff --git a/src/com/android/settings/connecteddevice/usb/UsbBackend.java b/src/com/android/settings/connecteddevice/usb/UsbBackend.java
index 333449f..54811c8 100644
--- a/src/com/android/settings/connecteddevice/usb/UsbBackend.java
+++ b/src/com/android/settings/connecteddevice/usb/UsbBackend.java
@@ -22,11 +22,10 @@
import android.hardware.usb.UsbPort;
import android.hardware.usb.UsbPortStatus;
import android.net.ConnectivityManager;
+import android.os.UserHandle;
import android.os.UserManager;
import android.support.annotation.VisibleForTesting;
-import com.android.settings.wrapper.UserManagerWrapper;
-
/**
* Provides access to underlying system USB functionality.
*/
@@ -50,17 +49,17 @@
private UsbPortStatus mPortStatus;
public UsbBackend(Context context) {
- this(context, new UserManagerWrapper(UserManager.get(context)));
+ this(context, (UserManager) context.getSystemService(Context.USER_SERVICE));
}
@VisibleForTesting
- public UsbBackend(Context context, UserManagerWrapper userManagerWrapper) {
+ public UsbBackend(Context context, UserManager userManager) {
mUsbManager = context.getSystemService(UsbManager.class);
- mFileTransferRestricted = userManagerWrapper.isUsbFileTransferRestricted();
- mFileTransferRestrictedBySystem = userManagerWrapper.isUsbFileTransferRestrictedBySystem();
- mTetheringRestricted = userManagerWrapper.isUsbTetheringRestricted();
- mTetheringRestrictedBySystem = userManagerWrapper.isUsbTetheringRestrictedBySystem();
+ mFileTransferRestricted = isUsbFileTransferRestricted(userManager);
+ mFileTransferRestrictedBySystem = isUsbFileTransferRestrictedBySystem(userManager);
+ mTetheringRestricted = isUsbTetheringRestricted(userManager);
+ mTetheringRestrictedBySystem = isUsbTetheringRestrictedBySystem(userManager);
mMidiSupported = context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_MIDI);
ConnectivityManager cm =
@@ -172,6 +171,24 @@
return Integer.parseInt(role);
}
+ private static boolean isUsbFileTransferRestricted(UserManager userManager) {
+ return userManager.hasUserRestriction(UserManager.DISALLOW_USB_FILE_TRANSFER);
+ }
+
+ private static boolean isUsbTetheringRestricted(UserManager userManager) {
+ return userManager.hasUserRestriction(UserManager.DISALLOW_CONFIG_TETHERING);
+ }
+
+ private static boolean isUsbFileTransferRestrictedBySystem(UserManager userManager) {
+ return userManager.hasBaseUserRestriction(
+ UserManager.DISALLOW_USB_FILE_TRANSFER, UserHandle.of(UserHandle.myUserId()));
+ }
+
+ private static boolean isUsbTetheringRestrictedBySystem(UserManager userManager) {
+ return userManager.hasBaseUserRestriction(
+ UserManager.DISALLOW_CONFIG_TETHERING, UserHandle.of(UserHandle.myUserId()));
+ }
+
private boolean areFunctionDisallowed(long functions) {
return (mFileTransferRestricted && ((functions & UsbManager.FUNCTION_MTP) != 0
|| (functions & UsbManager.FUNCTION_PTP) != 0))
diff --git a/src/com/android/settings/deviceinfo/StorageDashboardFragment.java b/src/com/android/settings/deviceinfo/StorageDashboardFragment.java
index ead941f..8e56b12 100644
--- a/src/com/android/settings/deviceinfo/StorageDashboardFragment.java
+++ b/src/com/android/settings/deviceinfo/StorageDashboardFragment.java
@@ -47,7 +47,6 @@
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.Indexable;
import com.android.settings.widget.EntityHeaderController;
-import com.android.settings.wrapper.UserManagerWrapper;
import com.android.settingslib.applications.StorageStatsSource;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.deviceinfo.PrivateStorageInfo;
@@ -185,8 +184,7 @@
mVolume, new StorageManagerVolumeProvider(sm));
controllers.add(mPreferenceController);
- UserManagerWrapper userManager =
- new UserManagerWrapper(context.getSystemService(UserManager.class));
+ final UserManager userManager = context.getSystemService(UserManager.class);
mSecondaryUsers = SecondaryUserController.getSecondaryUserControllers(context, userManager);
controllers.addAll(mSecondaryUsers);
@@ -235,8 +233,7 @@
public List<AbstractPreferenceController> createPreferenceControllers(
Context context) {
final StorageManager sm = context.getSystemService(StorageManager.class);
- final UserManagerWrapper userManager =
- new UserManagerWrapper(context.getSystemService(UserManager.class));
+ final UserManager userManager = context.getSystemService(UserManager.class);
final List<AbstractPreferenceController> controllers = new ArrayList<>();
controllers.add(new StorageSummaryDonutPreferenceController(context));
controllers.add(new StorageItemPreferenceController(context, null /* host */,
@@ -251,9 +248,8 @@
@Override
public Loader<SparseArray<StorageAsyncLoader.AppsStorageResult>> onCreateLoader(int id,
Bundle args) {
- Context context = getContext();
- return new StorageAsyncLoader(context,
- new UserManagerWrapper(context.getSystemService(UserManager.class)),
+ final Context context = getContext();
+ return new StorageAsyncLoader(context, context.getSystemService(UserManager.class),
mVolume.fsUuid,
new StorageStatsSource(context),
new PackageManagerWrapper(context.getPackageManager()));
diff --git a/src/com/android/settings/deviceinfo/StorageProfileFragment.java b/src/com/android/settings/deviceinfo/StorageProfileFragment.java
index 3f75f5c..a312a81 100644
--- a/src/com/android/settings/deviceinfo/StorageProfileFragment.java
+++ b/src/com/android/settings/deviceinfo/StorageProfileFragment.java
@@ -34,7 +34,6 @@
import com.android.settings.deviceinfo.storage.StorageAsyncLoader;
import com.android.settings.deviceinfo.storage.StorageAsyncLoader.AppsStorageResult;
import com.android.settings.deviceinfo.storage.StorageItemPreferenceController;
-import com.android.settings.wrapper.UserManagerWrapper;
import com.android.settingslib.applications.StorageStatsSource;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.deviceinfo.StorageManagerVolumeProvider;
@@ -114,9 +113,9 @@
@Override
public Loader<SparseArray<AppsStorageResult>> onCreateLoader(int id, Bundle args) {
- Context context = getContext();
+ final Context context = getContext();
return new StorageAsyncLoader(context,
- new UserManagerWrapper(context.getSystemService(UserManager.class)),
+ context.getSystemService(UserManager.class),
mVolume.fsUuid,
new StorageStatsSource(context),
new PackageManagerWrapper(context.getPackageManager()));
diff --git a/src/com/android/settings/deviceinfo/storage/SecondaryUserController.java b/src/com/android/settings/deviceinfo/storage/SecondaryUserController.java
index 4aeb782..d63436f 100644
--- a/src/com/android/settings/deviceinfo/storage/SecondaryUserController.java
+++ b/src/com/android/settings/deviceinfo/storage/SecondaryUserController.java
@@ -19,6 +19,7 @@
import android.content.Context;
import android.content.pm.UserInfo;
import android.graphics.drawable.Drawable;
+import android.os.UserManager;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.VisibleForTesting;
@@ -29,7 +30,6 @@
import com.android.settings.Utils;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settings.deviceinfo.StorageItemPreference;
-import com.android.settings.wrapper.UserManagerWrapper;
import com.android.settingslib.core.AbstractPreferenceController;
import java.util.ArrayList;
@@ -61,7 +61,7 @@
* @param userManager UserManagerWrapper for figuring out which controllers to add.
*/
public static List<AbstractPreferenceController> getSecondaryUserControllers(
- Context context, UserManagerWrapper userManager) {
+ Context context, UserManager userManager) {
List<AbstractPreferenceController> controllers = new ArrayList<>();
UserInfo primaryUser = userManager.getPrimaryUser();
boolean addedUser = false;
@@ -74,8 +74,7 @@
if (info == null || Utils.isProfileOf(primaryUser, info)) {
controllers.add(
- new UserProfileController(
- context, info, userManager, USER_PROFILE_INSERTION_LOCATION));
+ new UserProfileController(context, info, USER_PROFILE_INSERTION_LOCATION));
continue;
}
diff --git a/src/com/android/settings/deviceinfo/storage/StorageAsyncLoader.java b/src/com/android/settings/deviceinfo/storage/StorageAsyncLoader.java
index 0b9b697..affcbc9 100644
--- a/src/com/android/settings/deviceinfo/storage/StorageAsyncLoader.java
+++ b/src/com/android/settings/deviceinfo/storage/StorageAsyncLoader.java
@@ -26,11 +26,11 @@
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.UserInfo;
import android.os.UserHandle;
+import android.os.UserManager;
import android.util.ArraySet;
import android.util.Log;
import android.util.SparseArray;
-import com.android.settings.wrapper.UserManagerWrapper;
import com.android.settingslib.applications.StorageStatsSource;
import com.android.settingslib.utils.AsyncLoader;
import com.android.settingslib.wrapper.PackageManagerWrapper;
@@ -46,7 +46,7 @@
*/
public class StorageAsyncLoader
extends AsyncLoader<SparseArray<StorageAsyncLoader.AppsStorageResult>> {
- private UserManagerWrapper mUserManager;
+ private UserManager mUserManager;
private static final String TAG = "StorageAsyncLoader";
private String mUuid;
@@ -54,7 +54,7 @@
private PackageManagerWrapper mPackageManager;
private ArraySet<String> mSeenPackages;
- public StorageAsyncLoader(Context context, UserManagerWrapper userManager,
+ public StorageAsyncLoader(Context context, UserManager userManager,
String uuid, StorageStatsSource source, PackageManagerWrapper pm) {
super(context);
mUserManager = userManager;
diff --git a/src/com/android/settings/deviceinfo/storage/UserProfileController.java b/src/com/android/settings/deviceinfo/storage/UserProfileController.java
index 081a0be..510b0c0 100644
--- a/src/com/android/settings/deviceinfo/storage/UserProfileController.java
+++ b/src/com/android/settings/deviceinfo/storage/UserProfileController.java
@@ -32,7 +32,6 @@
import com.android.settings.core.SubSettingLauncher;
import com.android.settings.deviceinfo.StorageItemPreference;
import com.android.settings.deviceinfo.StorageProfileFragment;
-import com.android.settings.wrapper.UserManagerWrapper;
import com.android.settingslib.core.AbstractPreferenceController;
/**
@@ -44,16 +43,13 @@
UserIconLoader.UserIconHandler {
private static final String PREFERENCE_KEY_BASE = "pref_profile_";
private StorageItemPreference mStoragePreference;
- private UserManagerWrapper mUserManager;
private UserInfo mUser;
private long mTotalSizeBytes;
private final int mPreferenceOrder;
- public UserProfileController(
- Context context, UserInfo info, UserManagerWrapper userManager, int preferenceOrder) {
+ public UserProfileController(Context context, UserInfo info, int preferenceOrder) {
super(context);
mUser = Preconditions.checkNotNull(info);
- mUserManager = userManager;
mPreferenceOrder = preferenceOrder;
}
diff --git a/src/com/android/settings/enterprise/BackupsEnabledPreferenceController.java b/src/com/android/settings/enterprise/BackupsEnabledPreferenceController.java
new file mode 100644
index 0000000..b24f8dc
--- /dev/null
+++ b/src/com/android/settings/enterprise/BackupsEnabledPreferenceController.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2018 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 com.android.settings.core.BasePreferenceController;
+import com.android.settings.overlay.FeatureFactory;
+
+public class BackupsEnabledPreferenceController extends BasePreferenceController {
+
+ private static final String KEY_BACKUPS_ENABLED = "backups_enabled";
+ private final EnterprisePrivacyFeatureProvider mFeatureProvider;
+
+ public BackupsEnabledPreferenceController(Context context) {
+ super(context, KEY_BACKUPS_ENABLED);
+ mFeatureProvider = FeatureFactory.getFactory(context)
+ .getEnterprisePrivacyFeatureProvider(context);
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ return mFeatureProvider.areBackupsMandatory() ? AVAILABLE : DISABLED_FOR_USER;
+ }
+}
+
diff --git a/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProvider.java b/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProvider.java
index 048782e..51d125d 100644
--- a/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProvider.java
+++ b/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProvider.java
@@ -124,4 +124,9 @@
* profile (if any).
*/
int getNumberOfActiveDeviceAdminsForCurrentUserAndManagedProfile();
+
+ /*
+ * Returns whether backups are mandatory.
+ */
+ boolean areBackupsMandatory();
}
diff --git a/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProviderImpl.java b/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProviderImpl.java
index 17d7f0d..eead69f 100644
--- a/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProviderImpl.java
+++ b/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProviderImpl.java
@@ -23,6 +23,7 @@
import android.content.pm.PackageManager;
import android.content.pm.UserInfo;
import android.content.res.Resources;
+import android.net.ConnectivityManager;
import android.os.UserHandle;
import android.os.UserManager;
import android.provider.Settings;
@@ -32,7 +33,6 @@
import com.android.settings.R;
import com.android.settings.vpn2.VpnUtils;
-import com.android.settings.wrapper.ConnectivityManagerWrapper;
import com.android.settingslib.wrapper.PackageManagerWrapper;
import java.util.Date;
@@ -44,13 +44,13 @@
private final DevicePolicyManager mDpm;
private final PackageManagerWrapper mPm;
private final UserManager mUm;
- private final ConnectivityManagerWrapper mCm;
+ private final ConnectivityManager mCm;
private final Resources mResources;
private static final int MY_USER_ID = UserHandle.myUserId();
public EnterprisePrivacyFeatureProviderImpl(Context context, DevicePolicyManager dpm,
- PackageManagerWrapper pm, UserManager um, ConnectivityManagerWrapper cm,
+ PackageManagerWrapper pm, UserManager um, ConnectivityManager cm,
Resources resources) {
mContext = context.getApplicationContext();
mDpm = dpm;
@@ -235,6 +235,11 @@
return activeAdmins;
}
+ @Override
+ public boolean areBackupsMandatory() {
+ return null != mDpm.getMandatoryBackupTransport();
+ }
+
protected static class EnterprisePrivacySpan extends ClickableSpan {
private final Context mContext;
diff --git a/src/com/android/settings/enterprise/EnterprisePrivacySettings.java b/src/com/android/settings/enterprise/EnterprisePrivacySettings.java
index b426d28..92ae38d 100644
--- a/src/com/android/settings/enterprise/EnterprisePrivacySettings.java
+++ b/src/com/android/settings/enterprise/EnterprisePrivacySettings.java
@@ -82,6 +82,7 @@
exposureChangesCategoryControllers.add(new CaCertsCurrentUserPreferenceController(context));
exposureChangesCategoryControllers.add(new CaCertsManagedProfilePreferenceController(
context));
+ exposureChangesCategoryControllers.add(new BackupsEnabledPreferenceController(context));
controllers.addAll(exposureChangesCategoryControllers);
controllers.add(new PreferenceCategoryController(context, "exposure_changes_category")
.setChildren(exposureChangesCategoryControllers));
diff --git a/src/com/android/settings/fuelgauge/batterytip/detectors/HighUsageDetector.java b/src/com/android/settings/fuelgauge/batterytip/detectors/HighUsageDetector.java
index fd150e4..1b6e2f0 100644
--- a/src/com/android/settings/fuelgauge/batterytip/detectors/HighUsageDetector.java
+++ b/src/com/android/settings/fuelgauge/batterytip/detectors/HighUsageDetector.java
@@ -19,6 +19,7 @@
import android.content.Context;
import android.os.BatteryStats;
import android.support.annotation.VisibleForTesting;
+import android.text.format.DateUtils;
import com.android.internal.os.BatterySipper;
import com.android.internal.os.BatteryStatsHelper;
@@ -72,18 +73,20 @@
final long foregroundTimeMs = mBatteryUtils.getProcessTimeMs(
BatteryUtils.StatusType.FOREGROUND, batterySipper.uidObj,
BatteryStats.STATS_SINCE_CHARGED);
- mHighUsageAppList.add(new AppInfo.Builder()
- .setUid(batterySipper.getUid())
- .setPackageName(
- mBatteryUtils.getPackageName(batterySipper.getUid()))
- .setScreenOnTimeMs(foregroundTimeMs)
- .build());
+ if (foregroundTimeMs >= DateUtils.MINUTE_IN_MILLIS) {
+ mHighUsageAppList.add(new AppInfo.Builder()
+ .setUid(batterySipper.getUid())
+ .setPackageName(
+ mBatteryUtils.getPackageName(batterySipper.getUid()))
+ .setScreenOnTimeMs(foregroundTimeMs)
+ .build());
+ }
}
}
+ Collections.sort(mHighUsageAppList, Collections.reverseOrder());
mHighUsageAppList = mHighUsageAppList.subList(0,
Math.min(mPolicy.highUsageAppCount, mHighUsageAppList.size()));
- Collections.sort(mHighUsageAppList, Collections.reverseOrder());
}
}
diff --git a/src/com/android/settings/network/NetworkDashboardFragment.java b/src/com/android/settings/network/NetworkDashboardFragment.java
index 7d8ea18..955c503 100644
--- a/src/com/android/settings/network/NetworkDashboardFragment.java
+++ b/src/com/android/settings/network/NetworkDashboardFragment.java
@@ -49,10 +49,8 @@
private static final String TAG = "NetworkDashboardFrag";
private static final int MENU_NETWORK_RESET = Menu.FIRST;
- private static final int MENU_PRIVATE_DNS = Menu.FIRST + 1;
private NetworkResetActionMenuController mNetworkResetController;
- private PrivateDnsMenuController mPrivateDnsMenuController;
@Override
public int getMetricsCategory() {
@@ -73,8 +71,6 @@
public void onAttach(Context context) {
super.onAttach(context);
mNetworkResetController = new NetworkResetActionMenuController(context, MENU_NETWORK_RESET);
- mPrivateDnsMenuController = new PrivateDnsMenuController(getFragmentManager(),
- MENU_PRIVATE_DNS);
}
@Override
@@ -86,7 +82,6 @@
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
mNetworkResetController.buildMenuItem(menu);
- mPrivateDnsMenuController.buildMenuItem(menu);
}
@Override
@@ -109,6 +104,8 @@
new MobileNetworkPreferenceController(context);
final VpnPreferenceController vpnPreferenceController =
new VpnPreferenceController(context);
+ final PrivateDnsPreferenceController privateDnsPreferenceController =
+ new PrivateDnsPreferenceController(context);
if (lifecycle != null) {
lifecycle.addObserver(airplaneModePreferenceController);
@@ -116,6 +113,7 @@
lifecycle.addObserver(wifiPreferenceController);
lifecycle.addObserver(mobileNetworkPreferenceController);
lifecycle.addObserver(vpnPreferenceController);
+ lifecycle.addObserver(privateDnsPreferenceController);
}
final List<AbstractPreferenceController> controllers = new ArrayList<>();
@@ -126,6 +124,7 @@
controllers.add(new ProxyPreferenceController(context));
controllers.add(mobilePlanPreferenceController);
controllers.add(wifiPreferenceController);
+ controllers.add(privateDnsPreferenceController);
return controllers;
}
diff --git a/src/com/android/settings/network/PrivateDnsMenuController.java b/src/com/android/settings/network/PrivateDnsMenuController.java
deleted file mode 100644
index a811775..0000000
--- a/src/com/android/settings/network/PrivateDnsMenuController.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2017 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.network;
-
-import android.app.FragmentManager;
-import android.view.Menu;
-import android.view.MenuItem;
-
-import com.android.settings.R;
-
-public class PrivateDnsMenuController {
- private final FragmentManager mFragmentManager;
- private final int mMenuId;
-
- public PrivateDnsMenuController(FragmentManager fragmentManager, int menuId) {
- mFragmentManager = fragmentManager;
- mMenuId = menuId;
- }
-
- public void buildMenuItem(Menu menu) {
- if (menu != null) {
- MenuItem item = menu.add(0 /* groupId */, mMenuId, 0 /* order */,
- R.string.select_private_dns_configuration_title);
- item.setOnMenuItemClickListener(target -> {
- PrivateDnsModeDialogFragment.show(mFragmentManager);
- return true;
- });
- }
- }
-}
diff --git a/src/com/android/settings/network/PrivateDnsModeDialogFragment.java b/src/com/android/settings/network/PrivateDnsModeDialogPreference.java
similarity index 71%
rename from src/com/android/settings/network/PrivateDnsModeDialogFragment.java
rename to src/com/android/settings/network/PrivateDnsModeDialogPreference.java
index 00950c3..3b09cc2 100644
--- a/src/com/android/settings/network/PrivateDnsModeDialogFragment.java
+++ b/src/com/android/settings/network/PrivateDnsModeDialogPreference.java
@@ -20,19 +20,18 @@
import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_PROVIDER_HOSTNAME;
import android.app.AlertDialog;
-import android.app.Dialog;
-import android.app.FragmentManager;
+import android.content.ActivityNotFoundException;
import android.content.ContentResolver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
-import android.os.Bundle;
import android.provider.Settings;
import android.support.annotation.VisibleForTesting;
import android.text.Editable;
import android.text.TextWatcher;
import android.text.method.LinkMovementMethod;
-import android.view.LayoutInflater;
+import android.util.AttributeSet;
+import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
@@ -41,8 +40,9 @@
import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
-import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
+import com.android.settings.overlay.FeatureFactory;
import com.android.settings.utils.AnnotationSpan;
+import com.android.settingslib.CustomDialogPreference;
import com.android.settingslib.HelpUtils;
import java.util.HashMap;
@@ -51,7 +51,7 @@
/**
* Dialog to set the private dns
*/
-public class PrivateDnsModeDialogFragment extends InstrumentedDialogFragment implements
+public class PrivateDnsModeDialogPreference extends CustomDialogPreference implements
DialogInterface.OnClickListener, RadioGroup.OnCheckedChangeListener, TextWatcher {
public static final String ANNOTATION_URL = "url";
@@ -77,41 +77,44 @@
@VisibleForTesting
RadioGroup mRadioGroup;
@VisibleForTesting
- Button mSaveButton;
- @VisibleForTesting
String mMode;
- public static void show(FragmentManager fragmentManager) {
- if (fragmentManager.findFragmentByTag(TAG) == null) {
- final PrivateDnsModeDialogFragment fragment = new PrivateDnsModeDialogFragment();
- fragment.show(fragmentManager, TAG);
- }
+ public PrivateDnsModeDialogPreference(Context context) {
+ super(context);
}
+ public PrivateDnsModeDialogPreference(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ public PrivateDnsModeDialogPreference(Context context, AttributeSet attrs, int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+ }
+
+ public PrivateDnsModeDialogPreference(Context context, AttributeSet attrs, int defStyleAttr,
+ int defStyleRes) {
+ super(context, attrs, defStyleAttr, defStyleRes);
+ }
+
+ private final AnnotationSpan.LinkInfo mUrlLinkInfo = new AnnotationSpan.LinkInfo(
+ ANNOTATION_URL, (widget) -> {
+ final Context context = widget.getContext();
+ final Intent intent = HelpUtils.getHelpIntent(context,
+ context.getString(R.string.help_uri_private_dns),
+ context.getClass().getName());
+ if (intent != null) {
+ try {
+ widget.startActivityForResult(intent, 0);
+ } catch (ActivityNotFoundException e) {
+ Log.w(TAG, "Activity was not found for intent, " + intent.toString());
+ }
+ }
+ });
+
@Override
- public Dialog onCreateDialog(Bundle savedInstanceState) {
+ protected void onBindDialogView(View view) {
final Context context = getContext();
-
- final AlertDialog dialog = new AlertDialog.Builder(context)
- .setTitle(R.string.select_private_dns_configuration_title)
- .setView(buildPrivateDnsView(context))
- .setPositiveButton(R.string.save, this)
- .setNegativeButton(R.string.dlg_cancel, null)
- .create();
-
- dialog.setOnShowListener(dialogInterface -> {
- mSaveButton = dialog.getButton(DialogInterface.BUTTON_POSITIVE);
- updateDialogInfo();
- });
- return dialog;
- }
-
- private View buildPrivateDnsView(final Context context) {
final ContentResolver contentResolver = context.getContentResolver();
- mMode = Settings.Global.getString(contentResolver, MODE_KEY);
- final View view = LayoutInflater.from(context).inflate(R.layout.private_dns_mode_dialog,
- null);
-
mEditText = view.findViewById(R.id.private_dns_mode_provider_hostname);
mEditText.addTextChangedListener(this);
mEditText.setText(Settings.Global.getString(contentResolver, HOSTNAME_KEY));
@@ -131,26 +134,20 @@
helpTextView.setText(AnnotationSpan.linkify(
context.getText(R.string.private_dns_help_message), linkInfo));
}
-
- return view;
}
@Override
public void onClick(DialogInterface dialog, int which) {
+ final Context context = getContext();
if (mMode.equals(PRIVATE_DNS_MODE_PROVIDER_HOSTNAME)) {
// Only clickable if hostname is valid, so we could save it safely
- Settings.Global.putString(getContext().getContentResolver(), HOSTNAME_KEY,
+ Settings.Global.putString(context.getContentResolver(), HOSTNAME_KEY,
mEditText.getText().toString());
}
- mMetricsFeatureProvider.action(getContext(),
+ FeatureFactory.getFactory(context).getMetricsFeatureProvider().action(context,
MetricsProto.MetricsEvent.ACTION_PRIVATE_DNS_MODE, mMode);
- Settings.Global.putString(getContext().getContentResolver(), MODE_KEY, mMode);
- }
-
- @Override
- public int getMetricsCategory() {
- return MetricsProto.MetricsEvent.DIALOG_PRIVATE_DNS;
+ Settings.Global.putString(context.getContentResolver(), MODE_KEY, mMode);
}
@Override
@@ -179,9 +176,7 @@
@Override
public void afterTextChanged(Editable s) {
- if (mSaveButton != null) {
- mSaveButton.setEnabled(isWeaklyValidatedHostname(mEditText.getText().toString()));
- }
+ updateDialogInfo();
}
private boolean isWeaklyValidatedHostname(String hostname) {
@@ -193,17 +188,24 @@
return hostname.matches(WEAK_HOSTNAME_REGEX);
}
+ private Button getSaveButton() {
+ final AlertDialog dialog = (AlertDialog) getDialog();
+ if (dialog == null) {
+ return null;
+ }
+ return dialog.getButton(DialogInterface.BUTTON_POSITIVE);
+ }
+
private void updateDialogInfo() {
final boolean modeProvider = PRIVATE_DNS_MODE_PROVIDER_HOSTNAME.equals(mMode);
if (mEditText != null) {
mEditText.setEnabled(modeProvider);
}
- if (mSaveButton != null) {
- mSaveButton.setEnabled(
- modeProvider
- ? isWeaklyValidatedHostname(mEditText.getText().toString())
- : true);
+ final Button saveButton = getSaveButton();
+ if (saveButton != null) {
+ saveButton.setEnabled(modeProvider
+ ? isWeaklyValidatedHostname(mEditText.getText().toString())
+ : true);
}
}
-
}
diff --git a/src/com/android/settings/network/PrivateDnsPreferenceController.java b/src/com/android/settings/network/PrivateDnsPreferenceController.java
new file mode 100644
index 0000000..e317530
--- /dev/null
+++ b/src/com/android/settings/network/PrivateDnsPreferenceController.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2017 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.network;
+
+import android.content.Context;
+
+import com.android.settings.R;
+import com.android.settings.core.BasePreferenceController;
+import com.android.settings.core.PreferenceControllerMixin;
+import com.android.settingslib.core.lifecycle.LifecycleObserver;
+
+public class PrivateDnsPreferenceController extends BasePreferenceController
+ implements PreferenceControllerMixin, LifecycleObserver {
+ private static final String KEY_PRIVATE_DNS_SETTINGS = "private_dns_settings";
+
+ public PrivateDnsPreferenceController(Context context) {
+ super(context, KEY_PRIVATE_DNS_SETTINGS);
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return KEY_PRIVATE_DNS_SETTINGS;
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ return AVAILABLE;
+ }
+}
diff --git a/src/com/android/settings/network/VpnPreferenceController.java b/src/com/android/settings/network/VpnPreferenceController.java
index 95513e0..c4ecf4f 100644
--- a/src/com/android/settings/network/VpnPreferenceController.java
+++ b/src/com/android/settings/network/VpnPreferenceController.java
@@ -180,13 +180,11 @@
mNetworkCallback = new ConnectivityManager.NetworkCallback() {
@Override
public void onAvailable(Network network) {
- Log.d(TAG, "onAvailable " + network.netId);
updateSummary();
}
@Override
public void onLost(Network network) {
- Log.d(TAG, "onLost " + network.netId);
updateSummary();
}
};
diff --git a/src/com/android/settings/notification/VolumeSeekBarPreference.java b/src/com/android/settings/notification/VolumeSeekBarPreference.java
index 89f1e27..478a7d6 100644
--- a/src/com/android/settings/notification/VolumeSeekBarPreference.java
+++ b/src/com/android/settings/notification/VolumeSeekBarPreference.java
@@ -83,6 +83,7 @@
public void setStream(int stream) {
mStream = stream;
setMax(mAudioManager.getStreamMaxVolume(mStream));
+ setMin(mAudioManager.getStreamMinVolume(mStream));
setProgress(mAudioManager.getStreamVolume(mStream));
}
diff --git a/src/com/android/settings/overlay/FeatureFactoryImpl.java b/src/com/android/settings/overlay/FeatureFactoryImpl.java
index f0bbe2e..b652c66 100644
--- a/src/com/android/settings/overlay/FeatureFactoryImpl.java
+++ b/src/com/android/settings/overlay/FeatureFactoryImpl.java
@@ -51,8 +51,6 @@
import com.android.settings.slices.SlicesFeatureProviderImpl;
import com.android.settings.users.UserFeatureProvider;
import com.android.settings.users.UserFeatureProviderImpl;
-import com.android.settings.wrapper.ConnectivityManagerWrapper;
-import com.android.settings.wrapper.IPackageManagerWrapper;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
import com.android.settingslib.wrapper.PackageManagerWrapper;
@@ -112,7 +110,7 @@
if (mApplicationFeatureProvider == null) {
mApplicationFeatureProvider = new ApplicationFeatureProviderImpl(context,
new PackageManagerWrapper(context.getPackageManager()),
- new IPackageManagerWrapper(AppGlobals.getPackageManager()),
+ AppGlobals.getPackageManager(),
(DevicePolicyManager) context
.getSystemService(Context.DEVICE_POLICY_SERVICE));
}
@@ -134,8 +132,7 @@
(DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE),
new PackageManagerWrapper(context.getPackageManager()),
UserManager.get(context),
- new ConnectivityManagerWrapper((ConnectivityManager) context
- .getSystemService(Context.CONNECTIVITY_SERVICE)),
+ (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE),
context.getResources());
}
return mEnterprisePrivacyFeatureProvider;
diff --git a/src/com/android/settings/vpn2/VpnUtils.java b/src/com/android/settings/vpn2/VpnUtils.java
index 1aa4ada..4528180 100644
--- a/src/com/android/settings/vpn2/VpnUtils.java
+++ b/src/com/android/settings/vpn2/VpnUtils.java
@@ -27,7 +27,6 @@
import com.android.internal.net.LegacyVpnInfo;
import com.android.internal.net.VpnConfig;
-import com.android.settings.wrapper.ConnectivityManagerWrapper;
/**
* Utility functions for vpn.
@@ -89,7 +88,7 @@
ServiceManager.getService(Context.CONNECTIVITY_SERVICE));
}
- public static boolean isAlwaysOnVpnSet(ConnectivityManagerWrapper cm, final int userId) {
+ public static boolean isAlwaysOnVpnSet(ConnectivityManager cm, final int userId) {
return cm.getAlwaysOnVpnPackageForUser(userId) != null;
}
diff --git a/src/com/android/settings/wallpaper/WallpaperSuggestionActivity.java b/src/com/android/settings/wallpaper/WallpaperSuggestionActivity.java
index 0874cea..22835f3 100644
--- a/src/com/android/settings/wallpaper/WallpaperSuggestionActivity.java
+++ b/src/com/android/settings/wallpaper/WallpaperSuggestionActivity.java
@@ -27,7 +27,6 @@
import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
import com.android.settings.core.SubSettingLauncher;
-import com.android.settings.wrapper.WallpaperManagerWrapper;
public class WallpaperSuggestionActivity extends Activity {
@@ -61,9 +60,16 @@
@VisibleForTesting
public static boolean isSuggestionComplete(Context context) {
- final WallpaperManagerWrapper manager = new WallpaperManagerWrapper(context);
- return manager.isWallpaperServiceEnabled() ? manager.getWallpaperId(
- WallpaperManager.FLAG_SYSTEM) > 0 : false;
+ if (!isWallpaperServiceEnabled(context)) {
+ return true;
+ }
+ final WallpaperManager manager = (WallpaperManager) context.getSystemService(
+ WALLPAPER_SERVICE);
+ return manager.getWallpaperId(WallpaperManager.FLAG_SYSTEM) > 0;
}
+ private static boolean isWallpaperServiceEnabled(Context context) {
+ return context.getResources().getBoolean(
+ com.android.internal.R.bool.config_enableWallpaperService);
+ }
}
diff --git a/src/com/android/settings/wifi/WifiEnabler.java b/src/com/android/settings/wifi/WifiEnabler.java
index c5e79b2..cdb9292 100644
--- a/src/com/android/settings/wifi/WifiEnabler.java
+++ b/src/com/android/settings/wifi/WifiEnabler.java
@@ -34,11 +34,10 @@
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.R;
import com.android.settings.widget.SwitchWidgetController;
-import com.android.settings.wrapper.ConnectivityManagerWrapper;
-import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
import com.android.settingslib.WirelessUtils;
+import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -46,7 +45,7 @@
private final SwitchWidgetController mSwitchWidget;
private final WifiManager mWifiManager;
- private final ConnectivityManagerWrapper mConnectivityManager;
+ private final ConnectivityManager mConnectivityManager;
private final MetricsFeatureProvider mMetricsFeatureProvider;
private Context mContext;
@@ -81,20 +80,20 @@
public WifiEnabler(Context context, SwitchWidgetController switchWidget,
MetricsFeatureProvider metricsFeatureProvider) {
- this(context, switchWidget, metricsFeatureProvider, new ConnectivityManagerWrapper(
- (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE)));
+ this(context, switchWidget, metricsFeatureProvider,
+ (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE));
}
@VisibleForTesting
WifiEnabler(Context context, SwitchWidgetController switchWidget,
MetricsFeatureProvider metricsFeatureProvider,
- ConnectivityManagerWrapper connectivityManagerWrapper) {
+ ConnectivityManager connectivityManager) {
mContext = context;
mSwitchWidget = switchWidget;
mSwitchWidget.setListener(this);
mMetricsFeatureProvider = metricsFeatureProvider;
mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
- mConnectivityManager = connectivityManagerWrapper;
+ mConnectivityManager = connectivityManager;
mIntentFilter = new IntentFilter(WifiManager.WIFI_STATE_CHANGED_ACTION);
// The order matters! We really should not depend on this. :(
diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java
index 5f29922..4f1c832 100644
--- a/src/com/android/settings/wifi/WifiSettings.java
+++ b/src/com/android/settings/wifi/WifiSettings.java
@@ -64,7 +64,6 @@
import com.android.settings.widget.SummaryUpdater.OnSummaryChangeListener;
import com.android.settings.widget.SwitchBarController;
import com.android.settings.wifi.details.WifiNetworkDetailsFragment;
-import com.android.settings.wrapper.ConnectivityManagerWrapper;
import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.wifi.AccessPoint;
import com.android.settingslib.wifi.AccessPoint.AccessPointListener;
@@ -852,9 +851,7 @@
pref.getAccessPoint().saveWifiState(pref.getExtras());
if (mCaptivePortalNetworkCallback != null
&& mCaptivePortalNetworkCallback.isCaptivePortal()) {
- ConnectivityManagerWrapper connectivityManagerWrapper =
- new ConnectivityManagerWrapper(mConnectivityManager);
- connectivityManagerWrapper.startCaptivePortalApp(
+ mConnectivityManager.startCaptivePortalApp(
mCaptivePortalNetworkCallback.getNetwork());
} else {
launchNetworkDetailsFragment(pref);
diff --git a/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java b/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
index e7f0fdd..2339e38 100644
--- a/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
+++ b/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
@@ -48,6 +48,7 @@
import android.util.Log;
import android.widget.ImageView;
import android.widget.Toast;
+
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
@@ -60,7 +61,6 @@
import com.android.settings.wifi.WifiDialog;
import com.android.settings.wifi.WifiDialog.WifiDialogListener;
import com.android.settings.wifi.WifiUtils;
-import com.android.settings.wrapper.ConnectivityManagerWrapper;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
import com.android.settingslib.core.lifecycle.Lifecycle;
@@ -68,6 +68,7 @@
import com.android.settingslib.core.lifecycle.events.OnPause;
import com.android.settingslib.core.lifecycle.events.OnResume;
import com.android.settingslib.wifi.AccessPoint;
+
import java.net.Inet4Address;
import java.net.Inet6Address;
import java.net.InetAddress;
@@ -114,7 +115,6 @@
static final String KEY_IPV6_ADDRESSES_PREF = "ipv6_addresses";
private AccessPoint mAccessPoint;
- private final ConnectivityManagerWrapper mConnectivityManagerWrapper;
private final ConnectivityManager mConnectivityManager;
private final Fragment mFragment;
private final Handler mHandler;
@@ -152,10 +152,10 @@
switch (intent.getAction()) {
case WifiManager.CONFIGURED_NETWORKS_CHANGED_ACTION:
if (!intent.getBooleanExtra(WifiManager.EXTRA_MULTIPLE_NETWORKS_CHANGED,
- false /* defaultValue */)) {
+ false /* defaultValue */)) {
// only one network changed
WifiConfiguration wifiConfiguration = intent
- .getParcelableExtra(WifiManager.EXTRA_WIFI_CONFIGURATION);
+ .getParcelableExtra(WifiManager.EXTRA_WIFI_CONFIGURATION);
if (mAccessPoint.matches(wifiConfiguration)) {
mWifiConfig = wifiConfiguration;
}
@@ -215,7 +215,7 @@
public static WifiDetailPreferenceController newInstance(
AccessPoint accessPoint,
- ConnectivityManagerWrapper connectivityManagerWrapper,
+ ConnectivityManager connectivityManager,
Context context,
Fragment fragment,
Handler handler,
@@ -223,14 +223,14 @@
WifiManager wifiManager,
MetricsFeatureProvider metricsFeatureProvider) {
return new WifiDetailPreferenceController(
- accessPoint, connectivityManagerWrapper, context, fragment, handler, lifecycle,
+ accessPoint, connectivityManager, context, fragment, handler, lifecycle,
wifiManager, metricsFeatureProvider, new IconInjector(context));
}
@VisibleForTesting
- /* package */ WifiDetailPreferenceController(
+ /* package */ WifiDetailPreferenceController(
AccessPoint accessPoint,
- ConnectivityManagerWrapper connectivityManagerWrapper,
+ ConnectivityManager connectivityManager,
Context context,
Fragment fragment,
Handler handler,
@@ -241,8 +241,7 @@
super(context);
mAccessPoint = accessPoint;
- mConnectivityManager = connectivityManagerWrapper.getConnectivityManager();
- mConnectivityManagerWrapper = connectivityManagerWrapper;
+ mConnectivityManager = connectivityManager;
mFragment = fragment;
mHandler = handler;
mSignalStr = context.getResources().getStringArray(R.array.wifi_signal);
@@ -326,7 +325,7 @@
mNetworkCapabilities = mConnectivityManager.getNetworkCapabilities(mNetwork);
updateInfo();
mContext.registerReceiver(mReceiver, mFilter);
- mConnectivityManagerWrapper.registerNetworkCallback(mNetworkRequest, mNetworkCallback,
+ mConnectivityManager.registerNetworkCallback(mNetworkRequest, mNetworkCallback,
mHandler);
}
@@ -486,7 +485,7 @@
private static String ipv4PrefixLengthToSubnetMask(int prefixLength) {
try {
InetAddress all = InetAddress.getByAddress(
- new byte[]{(byte) 255, (byte) 255, (byte) 255, (byte) 255});
+ new byte[] {(byte) 255, (byte) 255, (byte) 255, (byte) 255});
return NetworkUtils.getNetworkPart(all, prefixLength).getHostAddress();
} catch (UnknownHostException e) {
return null;
@@ -538,7 +537,7 @@
private void signIntoNetwork() {
mMetricsFeatureProvider.action(
mFragment.getActivity(), MetricsProto.MetricsEvent.ACTION_WIFI_SIGNIN);
- mConnectivityManagerWrapper.startCaptivePortalApp(mNetwork);
+ mConnectivityManager.startCaptivePortalApp(mNetwork);
}
@Override
diff --git a/src/com/android/settings/wifi/details/WifiNetworkDetailsFragment.java b/src/com/android/settings/wifi/details/WifiNetworkDetailsFragment.java
index b2e56b9..3438035 100644
--- a/src/com/android/settings/wifi/details/WifiNetworkDetailsFragment.java
+++ b/src/com/android/settings/wifi/details/WifiNetworkDetailsFragment.java
@@ -20,13 +20,10 @@
import android.app.Dialog;
import android.content.Context;
import android.net.ConnectivityManager;
-import android.net.NetworkPolicyManager;
-import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiManager;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
-import android.support.v7.preference.DropDownPreference;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
@@ -37,13 +34,11 @@
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.wifi.WifiConfigUiBase;
import com.android.settings.wifi.WifiDialog;
-import com.android.settings.wrapper.ConnectivityManagerWrapper;
import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.wifi.AccessPoint;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
/**
@@ -126,10 +121,10 @@
@Override
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
final List<AbstractPreferenceController> controllers = new ArrayList<>();
- ConnectivityManager cm = context.getSystemService(ConnectivityManager.class);
+ final ConnectivityManager cm = context.getSystemService(ConnectivityManager.class);
mWifiDetailPreferenceController = WifiDetailPreferenceController.newInstance(
mAccessPoint,
- new ConnectivityManagerWrapper(cm),
+ cm,
context,
this,
new Handler(Looper.getMainLooper()), // UI thread.
diff --git a/src/com/android/settings/wrapper/ConnectivityManagerWrapper.java b/src/com/android/settings/wrapper/ConnectivityManagerWrapper.java
deleted file mode 100644
index c80a97b..0000000
--- a/src/com/android/settings/wrapper/ConnectivityManagerWrapper.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright (C) 2017 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.wrapper;
-
-import android.net.ConnectivityManager;
-import android.net.ConnectivityManager.NetworkCallback;
-import android.net.Network;
-import android.net.NetworkRequest;
-import android.os.Handler;
-import android.net.ProxyInfo;
-
-/**
- * This class replicates a subset of the android.net.ConnectivityManager (CM). The class
- * exists so that we can use a thin wrapper around the CM in production code and a mock in tests.
- * We cannot directly mock or shadow the CM, because some of the methods we rely on are marked as
- * hidden and are thus invisible to Robolectric.
- */
-public class ConnectivityManagerWrapper {
-
- private final ConnectivityManager mCm;
-
- public ConnectivityManagerWrapper(ConnectivityManager cm) {
- mCm = cm;
- }
-
- /**
- * Returns the real ConnectivityManager object wrapped by this wrapper.
- */
- public ConnectivityManager getConnectivityManager() {
- return mCm;
- }
-
- /**
- * Calls {@code ConnectivityManager.getAlwaysOnVpnPackageForUser()}.
- *
- * @see android.net.ConnectivityManager#getAlwaysOnVpnPackageForUser
- */
- public String getAlwaysOnVpnPackageForUser(int userId) {
- return mCm.getAlwaysOnVpnPackageForUser(userId);
- }
-
- /**
- * Calls {@code ConnectivityManager.getGlobalProxy()}.
- *
- * @see android.net.ConnectivityManager#getGlobalProxy
- */
- public ProxyInfo getGlobalProxy() {
- return mCm.getGlobalProxy();
- }
-
- /**
- * Calls {@code ConnectivityManager.registerNetworkCallback()}.
- *
- * This is part of the ConnectivityManager public API in SDK 26 or above, but is not yet visible
- * to the robolectric tests, which currently build with SDK 23.
- * TODO: delete this once the robolectric tests build with SDK 26 or above.
- *
- * @see android.net.ConnectivityManager#registerNetworkCallback(NetworkRequest,NetworkCallback,Handler)
- */
- public void registerNetworkCallback(NetworkRequest request, NetworkCallback callback,
- Handler handler) {
- mCm.registerNetworkCallback(request, callback, handler);
- }
-
- /**
- * Calls {@code ConnectivityManager.startCaptivePortalApp()}.
- *
- * This is part of the ConnectivityManager public API in SDK 26 or above, but is not yet visible
- * to the robolectric tests, which currently build with SDK 23.
- * TODO: delete this once the robolectric tests build with SDK 26 or above.
- *
- * @see android.net.ConnectivityManager#startCaptivePortalApp(Network)
- */
- public void startCaptivePortalApp(Network network) {
- mCm.startCaptivePortalApp(network);
- }
-
- /**
- * {@link ConnectivityManager#stopTethering}
- */
- public void stopTethering(int type) {
- mCm.stopTethering(type);
- }
-}
diff --git a/src/com/android/settings/wrapper/IPackageManagerWrapper.java b/src/com/android/settings/wrapper/IPackageManagerWrapper.java
deleted file mode 100644
index 9bb2df7..0000000
--- a/src/com/android/settings/wrapper/IPackageManagerWrapper.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright (C) 2017 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.wrapper;
-
-import android.content.Intent;
-import android.content.pm.IPackageManager;
-import android.content.pm.PackageInfo;
-import android.content.pm.ParceledListSlice;
-import android.content.pm.ResolveInfo;
-import android.os.RemoteException;
-
-/**
- * This class replicates a subset of the android.content.pm.IPackageManager (PMS). The class
- * exists so that we can use a thin wrapper around the PMS in production code and a mock in tests.
- * We cannot directly mock or shadow the PMS, because some of the methods we rely on are newer than
- * the API version supported by Robolectric.
- */
-public class IPackageManagerWrapper {
-
- private final IPackageManager mPms;
-
- public IPackageManagerWrapper(IPackageManager pms) {
- mPms = pms;
- }
-
- /**
- * Calls {@code IPackageManager.checkUidPermission()}.
- *
- * @see android.content.pm.IPackageManager#checkUidPermission
- */
- public int checkUidPermission(String permName, int uid) throws RemoteException {
- return mPms.checkUidPermission(permName, uid);
- }
-
- /**
- * Calls {@code IPackageManager.findPersistentPreferredActivity()}.
- *
- * @see android.content.pm.IPackageManager#findPersistentPreferredActivity
- */
- public ResolveInfo findPersistentPreferredActivity(Intent intent, int userId)
- throws RemoteException {
- return mPms.findPersistentPreferredActivity(intent, userId);
- }
-
- /**
- * Calls {@code IPackageManager.getPackageInfo()}.
- *
- * @see android.content.pm.IPackageManager#getPackageInfo
- */
- public PackageInfo getPackageInfo(String packageName, int flags, int userId)
- throws RemoteException {
- return mPms.getPackageInfo(packageName, flags, userId);
- }
-
- /**
- * Calls {@code IPackageManager.getAppOpPermissionPackages()}.
- *
- * @see android.content.pm.IPackageManager#getAppOpPermissionPackages
- */
- public String[] getAppOpPermissionPackages(String permissionName) throws RemoteException {
- return mPms.getAppOpPermissionPackages(permissionName);
- }
-
- /**
- * Calls {@code IPackageManager.isPackageAvailable()}.
- *
- * @see android.content.pm.IPackageManager#isPackageAvailable
- */
- public boolean isPackageAvailable(String packageName, int userId) throws RemoteException {
- return mPms.isPackageAvailable(packageName, userId);
- }
-
- /**
- * Calls {@code IPackageManager.getPackagesHoldingPermissions()}.
- *
- * @see android.content.pm.IPackageManager#getPackagesHoldingPermissions
- */
- public ParceledListSlice<PackageInfo> getPackagesHoldingPermissions(
- String[] permissions, int flags, int userId) throws RemoteException {
- return mPms.getPackagesHoldingPermissions(permissions, flags, userId);
- }
-
-}
diff --git a/src/com/android/settings/wrapper/UserManagerWrapper.java b/src/com/android/settings/wrapper/UserManagerWrapper.java
deleted file mode 100644
index 8c3a01d..0000000
--- a/src/com/android/settings/wrapper/UserManagerWrapper.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (C) 2017 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.wrapper;
-
-import android.content.pm.UserInfo;
-import android.os.UserHandle;
-import android.os.UserManager;
-
-import java.util.List;
-
-/**
- * This class replicates a subset of the android.os.UserManager. The class
- * exists so that we can use a thin wrapper around the UserManager in production code and a mock in
- * tests. We cannot directly mock or shadow the UserManager, because some of the methods we rely on
- * are newer than the API version supported by Robolectric or are hidden.
- */
-public class UserManagerWrapper {
- private UserManager mUserManager;
-
- public UserManagerWrapper(UserManager userManager) {
- mUserManager = userManager;
- }
-
- public UserInfo getPrimaryUser() {
- return mUserManager.getPrimaryUser();
- }
-
- public List<UserInfo> getUsers() {
- return mUserManager.getUsers();
- }
-
- public List<UserInfo> getProfiles(int userHandle) {
- return mUserManager.getProfiles(userHandle);
- }
-
- public boolean isUsbFileTransferRestricted() {
- return mUserManager.hasUserRestriction(UserManager.DISALLOW_USB_FILE_TRANSFER);
- }
-
- public boolean isUsbTetheringRestricted() {
- return mUserManager.hasUserRestriction(UserManager.DISALLOW_CONFIG_TETHERING);
- }
-
- public boolean isUsbFileTransferRestrictedBySystem() {
- return mUserManager.hasBaseUserRestriction(
- UserManager.DISALLOW_USB_FILE_TRANSFER, UserHandle.of(UserHandle.myUserId()));
- }
-
- public boolean isUsbTetheringRestrictedBySystem() {
- return mUserManager.hasBaseUserRestriction(
- UserManager.DISALLOW_CONFIG_TETHERING, UserHandle.of(UserHandle.myUserId()));
- }
-}
diff --git a/src/com/android/settings/wrapper/WallpaperManagerWrapper.java b/src/com/android/settings/wrapper/WallpaperManagerWrapper.java
deleted file mode 100644
index eabc5bb..0000000
--- a/src/com/android/settings/wrapper/WallpaperManagerWrapper.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2017 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.wrapper;
-
-import android.app.WallpaperManager;
-import android.content.Context;
-
-public class WallpaperManagerWrapper {
-
- private final WallpaperManager mWallpaperManager;
- private final boolean mWallpaperServiceEnabled;
-
- public WallpaperManagerWrapper(Context context) {
- mWallpaperServiceEnabled = context.getResources().getBoolean(
- com.android.internal.R.bool.config_enableWallpaperService);
- mWallpaperManager = mWallpaperServiceEnabled ? (WallpaperManager) context.getSystemService(
- Context.WALLPAPER_SERVICE) : null;
- }
-
- public boolean isWallpaperServiceEnabled() {
- return mWallpaperServiceEnabled;
- }
-
- public int getWallpaperId(int which) {
- if (!mWallpaperServiceEnabled) {
- throw new RuntimeException("This device does not have wallpaper service enabled.");
- }
- return mWallpaperManager.getWallpaperId(which);
- }
-}
diff --git a/tests/robotests/src/com/android/settings/applications/AppStateAppOpsBridgeTest.java b/tests/robotests/src/com/android/settings/applications/AppStateAppOpsBridgeTest.java
index 2df0117..a4eeacd 100644
--- a/tests/robotests/src/com/android/settings/applications/AppStateAppOpsBridgeTest.java
+++ b/tests/robotests/src/com/android/settings/applications/AppStateAppOpsBridgeTest.java
@@ -23,11 +23,11 @@
import android.Manifest;
import android.app.AppOpsManager;
import android.content.Context;
+import android.content.pm.IPackageManager;
import android.os.RemoteException;
import android.os.UserManager;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settings.wrapper.IPackageManagerWrapper;
import com.android.settingslib.applications.ApplicationsState.AppEntry;
import org.junit.Before;
@@ -41,7 +41,7 @@
@Mock private Context mContext;
@Mock private UserManager mUserManager;
- @Mock private IPackageManagerWrapper mPackageManagerService;
+ @Mock private IPackageManager mPackageManagerService;
@Mock private AppOpsManager mAppOpsManager;
@Before
diff --git a/tests/robotests/src/com/android/settings/applications/AppWithAdminGrantedPermissionsCounterTest.java b/tests/robotests/src/com/android/settings/applications/AppWithAdminGrantedPermissionsCounterTest.java
index a0bae85..dcc6a1e 100644
--- a/tests/robotests/src/com/android/settings/applications/AppWithAdminGrantedPermissionsCounterTest.java
+++ b/tests/robotests/src/com/android/settings/applications/AppWithAdminGrantedPermissionsCounterTest.java
@@ -29,6 +29,7 @@
import android.app.admin.DevicePolicyManager;
import android.content.Context;
import android.content.pm.ApplicationInfo;
+import android.content.pm.IPackageManager;
import android.content.pm.PackageManager;
import android.content.pm.UserInfo;
import android.os.Build;
@@ -37,7 +38,6 @@
import android.os.UserManager;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settings.wrapper.IPackageManagerWrapper;
import com.android.settingslib.wrapper.PackageManagerWrapper;
import org.junit.Before;
@@ -81,7 +81,7 @@
@Mock
private PackageManagerWrapper mPackageManager;
@Mock
- private IPackageManagerWrapper mPackageManagerService;
+ private IPackageManager mPackageManagerService;
@Mock
private DevicePolicyManager mDevicePolicyManager;
diff --git a/tests/robotests/src/com/android/settings/applications/AppWithAdminGrantedPermissionsListerTest.java b/tests/robotests/src/com/android/settings/applications/AppWithAdminGrantedPermissionsListerTest.java
index 940fd4b..8365db2 100644
--- a/tests/robotests/src/com/android/settings/applications/AppWithAdminGrantedPermissionsListerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/AppWithAdminGrantedPermissionsListerTest.java
@@ -27,6 +27,7 @@
import static org.mockito.Mockito.when;
import android.app.admin.DevicePolicyManager;
+import android.content.pm.IPackageManager;
import android.content.pm.PackageManager;
import android.content.pm.UserInfo;
import android.os.Build;
@@ -34,7 +35,6 @@
import android.os.UserManager;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settings.wrapper.IPackageManagerWrapper;
import com.android.settingslib.wrapper.PackageManagerWrapper;
import org.junit.Before;
@@ -78,7 +78,7 @@
@Mock
private PackageManagerWrapper mPackageManager;
@Mock
- private IPackageManagerWrapper mPackageManagerService;
+ private IPackageManager mPackageManagerService;
@Mock
private DevicePolicyManager mDevicePolicyManager;
diff --git a/tests/robotests/src/com/android/settings/applications/ApplicationFeatureProviderImplTest.java b/tests/robotests/src/com/android/settings/applications/ApplicationFeatureProviderImplTest.java
index 8afb798..a457ba2 100644
--- a/tests/robotests/src/com/android/settings/applications/ApplicationFeatureProviderImplTest.java
+++ b/tests/robotests/src/com/android/settings/applications/ApplicationFeatureProviderImplTest.java
@@ -24,6 +24,7 @@
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
+import android.content.pm.IPackageManager;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.pm.UserInfo;
@@ -33,7 +34,6 @@
import com.android.settings.testutils.ApplicationTestUtils;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settings.wrapper.IPackageManagerWrapper;
import com.android.settingslib.wrapper.PackageManagerWrapper;
import org.junit.Before;
@@ -72,7 +72,7 @@
@Mock
private PackageManagerWrapper mPackageManager;
@Mock
- private IPackageManagerWrapper mPackageManagerService;
+ private IPackageManager mPackageManagerService;
@Mock
private DevicePolicyManager mDevicePolicyManager;
diff --git a/tests/robotests/src/com/android/settings/applications/appinfo/PictureInPictureSettingsTest.java b/tests/robotests/src/com/android/settings/applications/appinfo/PictureInPictureSettingsTest.java
index 3ea2a16..87dedad 100644
--- a/tests/robotests/src/com/android/settings/applications/appinfo/PictureInPictureSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/applications/appinfo/PictureInPictureSettingsTest.java
@@ -25,12 +25,13 @@
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.UserInfo;
+import android.os.UserManager;
import android.util.Pair;
import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settings.wrapper.UserManagerWrapper;
import com.android.settingslib.wrapper.PackageManagerWrapper;
+
import com.google.common.collect.ImmutableList;
import org.junit.Before;
@@ -52,7 +53,7 @@
@Mock
private PackageManagerWrapper mPackageManager;
@Mock
- private UserManagerWrapper mUserManager;
+ private UserManager mUserManager;
private ArrayList<PackageInfo> mPrimaryUserPackages;
private ArrayList<PackageInfo> mProfileUserPackages;
diff --git a/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbBackendTest.java b/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbBackendTest.java
index 0823fe0..567b072 100644
--- a/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbBackendTest.java
+++ b/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbBackendTest.java
@@ -18,6 +18,8 @@
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Answers.RETURNS_DEEP_STUBS;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -27,9 +29,10 @@
import android.hardware.usb.UsbPort;
import android.hardware.usb.UsbPortStatus;
import android.net.ConnectivityManager;
+import android.os.UserHandle;
+import android.os.UserManager;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settings.wrapper.UserManagerWrapper;
import org.junit.Before;
import org.junit.Test;
@@ -45,7 +48,7 @@
@Mock
private UsbManager mUsbManager;
@Mock
- private UserManagerWrapper mUserManagerWrapper;
+ private UserManager mUserManager;
@Mock
private ConnectivityManager mConnectivityManager;
@Mock
@@ -68,7 +71,7 @@
@Test
public void setDataRole_allRolesSupported_shouldSetDataRole() {
- final UsbBackend usbBackend = new UsbBackend(mContext, mUserManagerWrapper);
+ final UsbBackend usbBackend = new UsbBackend(mContext, mUserManager);
when(mUsbPortStatus
.isRoleCombinationSupported(UsbPort.POWER_ROLE_SINK, UsbPort.DATA_ROLE_DEVICE))
@@ -91,7 +94,7 @@
@Test
public void setDataRole_notAllRolesSupported_shouldSetDataAndPowerRole() {
- final UsbBackend usbBackend = new UsbBackend(mContext, mUserManagerWrapper);
+ final UsbBackend usbBackend = new UsbBackend(mContext, mUserManager);
when(mUsbPortStatus
.isRoleCombinationSupported(UsbPort.POWER_ROLE_SINK, UsbPort.DATA_ROLE_DEVICE))
@@ -109,7 +112,7 @@
@Test
public void setPowerRole_allRolesSupported_shouldSetPowerRole() {
- final UsbBackend usbBackend = new UsbBackend(mContext, mUserManagerWrapper);
+ final UsbBackend usbBackend = new UsbBackend(mContext, mUserManager);
when(mUsbPortStatus
.isRoleCombinationSupported(UsbPort.POWER_ROLE_SINK, UsbPort.DATA_ROLE_DEVICE))
@@ -133,7 +136,7 @@
@Test
public void setPowerRole_notAllRolesSupported_shouldSetDataAndPowerRole() {
- final UsbBackend usbBackend = new UsbBackend(mContext, mUserManagerWrapper);
+ final UsbBackend usbBackend = new UsbBackend(mContext, mUserManager);
when(mUsbPortStatus
.isRoleCombinationSupported(UsbPort.POWER_ROLE_SINK, UsbPort.DATA_ROLE_DEVICE))
@@ -151,20 +154,26 @@
@Test
public void areFunctionsSupported_fileTransferDisallowed_shouldReturnFalse() {
- when(mUserManagerWrapper.isUsbFileTransferRestricted()).thenReturn(true);
- when(mUserManagerWrapper.isUsbFileTransferRestrictedBySystem()).thenReturn(true);
+ when(mUserManager.hasUserRestriction(UserManager.DISALLOW_USB_FILE_TRANSFER))
+ .thenReturn(true);
+ when(mUserManager.hasBaseUserRestriction(
+ eq(UserManager.DISALLOW_USB_FILE_TRANSFER), any(UserHandle.class)))
+ .thenReturn(true);
- final UsbBackend usbBackend = new UsbBackend(mContext, mUserManagerWrapper);
+ final UsbBackend usbBackend = new UsbBackend(mContext, mUserManager);
assertThat(usbBackend.areFunctionsSupported(UsbManager.FUNCTION_MTP)).isFalse();
}
@Test
public void areFunctionsSupported_fileTransferAllowed_shouldReturnTrue() {
- when(mUserManagerWrapper.isUsbFileTransferRestricted()).thenReturn(false);
- when(mUserManagerWrapper.isUsbFileTransferRestrictedBySystem()).thenReturn(false);
+ when(mUserManager.hasUserRestriction(UserManager.DISALLOW_USB_FILE_TRANSFER))
+ .thenReturn(false);
+ when(mUserManager.hasBaseUserRestriction(
+ eq(UserManager.DISALLOW_USB_FILE_TRANSFER), any(UserHandle.class)))
+ .thenReturn(false);
- final UsbBackend usbBackend = new UsbBackend(mContext, mUserManagerWrapper);
+ final UsbBackend usbBackend = new UsbBackend(mContext, mUserManager);
assertThat(usbBackend.areFunctionsSupported(UsbManager.FUNCTION_MTP)).isTrue();
}
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/storage/SecondaryUserControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/storage/SecondaryUserControllerTest.java
index 49f0312..bbe92ad 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/storage/SecondaryUserControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/storage/SecondaryUserControllerTest.java
@@ -26,13 +26,13 @@
import android.content.Context;
import android.content.pm.UserInfo;
import android.graphics.drawable.Drawable;
+import android.os.UserManager;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceGroup;
import android.support.v7.preference.PreferenceScreen;
import android.util.SparseArray;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settings.wrapper.UserManagerWrapper;
import com.android.settingslib.applications.StorageStatsSource;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.drawable.UserIconDrawable;
@@ -54,7 +54,7 @@
private static final String TEST_NAME = "Fred";
private static final String TARGET_PREFERENCE_GROUP_KEY = "pref_secondary_users";
@Mock
- private UserManagerWrapper mUserManager;
+ private UserManager mUserManager;
@Mock
private PreferenceScreen mScreen;
@Mock
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/storage/UserProfileControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/storage/UserProfileControllerTest.java
index 84456ec..7ee6216 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/storage/UserProfileControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/storage/UserProfileControllerTest.java
@@ -35,7 +35,6 @@
import com.android.settings.SubSettings;
import com.android.settings.deviceinfo.StorageProfileFragment;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settings.wrapper.UserManagerWrapper;
import com.android.settingslib.applications.StorageStatsSource;
import com.android.settingslib.drawable.UserIconDrawable;
@@ -53,8 +52,6 @@
private static final String TEST_NAME = "Fred";
@Mock
- private UserManagerWrapper mUserManager;
- @Mock
private PreferenceScreen mScreen;
private Context mContext;
@@ -66,7 +63,7 @@
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application);
mPrimaryProfile = new UserInfo();
- mController = new UserProfileController(mContext, mPrimaryProfile, mUserManager, 0);
+ mController = new UserProfileController(mContext, mPrimaryProfile, 0);
when(mScreen.getContext()).thenReturn(mContext);
mPrimaryProfile.name = TEST_NAME;
mPrimaryProfile.id = 10;
@@ -96,7 +93,7 @@
final Intent intent = intentCaptor.getValue();
assertThat(intent.getComponent().getClassName()).isEqualTo(SubSettings.class.getName());
assertThat(intent.getStringExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT))
- .isEqualTo(StorageProfileFragment.class.getName());
+ .isEqualTo(StorageProfileFragment.class.getName());
}
@Test
diff --git a/tests/robotests/src/com/android/settings/enterprise/BackupsEnabledPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/BackupsEnabledPreferenceControllerTest.java
new file mode 100644
index 0000000..a836fa2
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/enterprise/BackupsEnabledPreferenceControllerTest.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2018 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 static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.support.v7.preference.Preference;
+
+import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RuntimeEnvironment;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+public class BackupsEnabledPreferenceControllerTest {
+
+ private static final String KEY_BACKUPS_ENABLED = "backups_enabled";
+
+ private Context mContext;
+ private FakeFeatureFactory mFeatureFactory;
+
+ private BackupsEnabledPreferenceController mController;
+
+ @Before
+ public void setUp() {
+ mContext = RuntimeEnvironment.application;
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
+ mController = new BackupsEnabledPreferenceController(mContext);
+ }
+
+ @Test
+ public void testIsAvailable() {
+ when(mFeatureFactory.enterprisePrivacyFeatureProvider.areBackupsMandatory())
+ .thenReturn(false);
+ assertThat(mController.isAvailable()).isFalse();
+
+ when(mFeatureFactory.enterprisePrivacyFeatureProvider.areBackupsMandatory())
+ .thenReturn(true);
+ assertThat(mController.isAvailable()).isTrue();
+ }
+
+ @Test
+ public void testHandlePreferenceTreeClick() {
+ assertThat(mController.handlePreferenceTreeClick(new Preference(mContext, null, 0, 0)))
+ .isFalse();
+ }
+
+ @Test
+ public void testGetPreferenceKey() {
+ assertThat(mController.getPreferenceKey()).isEqualTo(KEY_BACKUPS_ENABLED);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProviderImplTest.java b/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProviderImplTest.java
index b71a35e..40371d7 100644
--- a/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProviderImplTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacyFeatureProviderImplTest.java
@@ -28,6 +28,7 @@
import android.content.pm.PackageManager;
import android.content.pm.UserInfo;
import android.content.res.Resources;
+import android.net.ConnectivityManager;
import android.net.ProxyInfo;
import android.os.UserHandle;
import android.os.UserManager;
@@ -36,7 +37,6 @@
import com.android.settings.R;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settings.wrapper.ConnectivityManagerWrapper;
import com.android.settingslib.wrapper.PackageManagerWrapper;
import org.junit.Before;
@@ -72,7 +72,7 @@
private @Mock PackageManagerWrapper mPackageManagerWrapper;
private @Mock PackageManager mPackageManager;
private @Mock UserManager mUserManager;
- private @Mock ConnectivityManagerWrapper mConnectivityManger;
+ private @Mock ConnectivityManager mConnectivityManger;
private Resources mResources;
private EnterprisePrivacyFeatureProvider mProvider;
@@ -347,6 +347,15 @@
.isEqualTo(3);
}
+ @Test
+ public void testAreBackupsMandatory() {
+ assertThat(mProvider.areBackupsMandatory()).isFalse();
+ ComponentName transportComponent = new ComponentName("test", "test");
+ when(mDevicePolicyManager.getMandatoryBackupTransport())
+ .thenReturn(transportComponent);
+ assertThat(mProvider.areBackupsMandatory()).isTrue();
+ }
+
private void resetAndInitializePackageManagerWrapper() {
reset(mPackageManagerWrapper);
when(mPackageManagerWrapper.hasSystemFeature(PackageManager.FEATURE_DEVICE_ADMIN))
diff --git a/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacySettingsTest.java b/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacySettingsTest.java
index 5266fde..7bbe9bc 100644
--- a/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacySettingsTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacySettingsTest.java
@@ -98,7 +98,7 @@
private void verifyPreferenceControllers(List<AbstractPreferenceController> controllers) {
assertThat(controllers).isNotNull();
- assertThat(controllers.size()).isEqualTo(17);
+ assertThat(controllers.size()).isEqualTo(18);
int position = 0;
assertThat(controllers.get(position++)).isInstanceOf(NetworkLogsPreferenceController.class);
assertThat(controllers.get(position++)).isInstanceOf(BugReportsPreferenceController.class);
@@ -126,6 +126,8 @@
assertThat(controllers.get(position++)).isInstanceOf(
CaCertsManagedProfilePreferenceController.class);
assertThat(controllers.get(position++)).isInstanceOf(
+ BackupsEnabledPreferenceController.class);
+ assertThat(controllers.get(position++)).isInstanceOf(
PreferenceCategoryController.class);
assertThat(controllers.get(position++)).isInstanceOf(
FailedPasswordWipeCurrentUserPreferenceController.class);
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/detectors/HighUsageDetectorTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/detectors/HighUsageDetectorTest.java
index 14627c5..d983dfc 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/detectors/HighUsageDetectorTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/detectors/HighUsageDetectorTest.java
@@ -17,8 +17,10 @@
package com.android.settings.fuelgauge.batterytip.detectors;
import static com.google.common.truth.Truth.assertThat;
+
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
@@ -48,7 +50,8 @@
@RunWith(SettingsRobolectricTestRunner.class)
public class HighUsageDetectorTest {
- private static final int UID = 123;
+ private static final int UID_HIGH = 123;
+ private static final int UID_ZERO = 345;
private static final long SCREEN_ON_TIME_MS = DateUtils.HOUR_IN_MILLIS;
private Context mContext;
@Mock
@@ -56,7 +59,9 @@
@Mock
private BatteryUtils mBatteryUtils;
@Mock
- private BatterySipper mBatterySipper;
+ private BatterySipper mHighBatterySipper;
+ @Mock
+ private BatterySipper mZeroBatterySipper;
@Mock
private HighUsageDataParser mDataParser;
@@ -75,14 +80,25 @@
mHighUsageDetector.mBatteryUtils = mBatteryUtils;
mHighUsageDetector.mDataParser = mDataParser;
doNothing().when(mHighUsageDetector).parseBatteryData();
- doReturn(UID).when(mBatterySipper).getUid();
+ doReturn(UID_HIGH).when(mHighBatterySipper).getUid();
+ mHighBatterySipper.uidObj = mock(BatteryStats.Uid.class);
+ mZeroBatterySipper.uidObj = mock(BatteryStats.Uid.class);
+ doReturn(UID_ZERO).when(mZeroBatterySipper).getUid();
mAppInfo = new AppInfo.Builder()
- .setUid(UID)
+ .setUid(UID_HIGH)
.setScreenOnTimeMs(SCREEN_ON_TIME_MS)
.build();
+ doReturn(SCREEN_ON_TIME_MS).when(mBatteryUtils).getProcessTimeMs(
+ BatteryUtils.StatusType.FOREGROUND, mHighBatterySipper.uidObj,
+ BatteryStats.STATS_SINCE_CHARGED);
+ doReturn(0L).when(mBatteryUtils).getProcessTimeMs(
+ BatteryUtils.StatusType.FOREGROUND, mZeroBatterySipper.uidObj,
+ BatteryStats.STATS_SINCE_CHARGED);
+
mUsageList = new ArrayList<>();
- mUsageList.add(mBatterySipper);
+ mUsageList.add(mHighBatterySipper);
+ when(mBatteryStatsHelper.getUsageList()).thenReturn(mUsageList);
}
@Test
@@ -95,10 +111,16 @@
@Test
public void testDetect_containsHighUsageApp_tipVisible() {
doReturn(true).when(mDataParser).isDeviceHeavilyUsed();
- when(mBatteryStatsHelper.getUsageList()).thenReturn(mUsageList);
- doReturn(SCREEN_ON_TIME_MS).when(mBatteryUtils).getProcessTimeMs(
- BatteryUtils.StatusType.FOREGROUND, mBatterySipper.uidObj,
- BatteryStats.STATS_SINCE_CHARGED);
+
+ final HighUsageTip highUsageTip = (HighUsageTip) mHighUsageDetector.detect();
+ assertThat(highUsageTip.isVisible()).isTrue();
+ assertThat(highUsageTip.getHighUsageAppList()).containsExactly(mAppInfo);
+ }
+
+ @Test
+ public void testDetect_containsHighUsageApp_removeZeroOne() {
+ doReturn(true).when(mDataParser).isDeviceHeavilyUsed();
+ mUsageList.add(mZeroBatterySipper);
final HighUsageTip highUsageTip = (HighUsageTip) mHighUsageDetector.detect();
assertThat(highUsageTip.isVisible()).isTrue();
diff --git a/tests/robotests/src/com/android/settings/network/NetworkDashboardFragmentTest.java b/tests/robotests/src/com/android/settings/network/NetworkDashboardFragmentTest.java
index 19c9f87..51722e5 100644
--- a/tests/robotests/src/com/android/settings/network/NetworkDashboardFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/network/NetworkDashboardFragmentTest.java
@@ -76,9 +76,7 @@
public void testPrepareActionBar_networkResetShouldBeCreated() {
final NetworkResetActionMenuController resetController =
mock(NetworkResetActionMenuController.class);
- final PrivateDnsMenuController privateDnsController = mock(PrivateDnsMenuController.class);
ReflectionHelpers.setField(mFragment, "mNetworkResetController", resetController);
- ReflectionHelpers.setField(mFragment, "mPrivateDnsMenuController", privateDnsController);
mFragment.onCreateOptionsMenu(null, null);
diff --git a/tests/robotests/src/com/android/settings/network/PrivateDnsMenuControllerTest.java b/tests/robotests/src/com/android/settings/network/PrivateDnsMenuControllerTest.java
deleted file mode 100644
index fa824d6..0000000
--- a/tests/robotests/src/com/android/settings/network/PrivateDnsMenuControllerTest.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (C) 2017 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.network;
-
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyInt;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import android.app.FragmentManager;
-import android.view.Menu;
-import android.view.MenuItem;
-
-import com.android.settings.R;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-public class PrivateDnsMenuControllerTest {
- private static final int MENU_ID = 0;
-
- private PrivateDnsMenuController mController;
- @Mock
- private Menu mMenu;
- @Mock
- private MenuItem mMenuItem;
- @Mock
- private FragmentManager mFragmentManager;
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
-
- mController = new PrivateDnsMenuController(mFragmentManager, MENU_ID);
- when(mMenu.add(anyInt(), anyInt(), anyInt(), anyInt())).thenReturn(mMenuItem);
- }
-
- @Test
- public void buildMenuItem_available_shouldAddToMenu() {
- mController.buildMenuItem(mMenu);
-
- verify(mMenu).add(0 /* groupId */, MENU_ID, 0 /* order */,
- R.string.select_private_dns_configuration_title);
- verify(mMenuItem).setOnMenuItemClickListener(any(MenuItem.OnMenuItemClickListener.class));
- }
-}
diff --git a/tests/robotests/src/com/android/settings/network/PrivateDnsModeDialogFragmentTest.java b/tests/robotests/src/com/android/settings/network/PrivateDnsModeDialogFragmentTest.java
deleted file mode 100644
index d490968..0000000
--- a/tests/robotests/src/com/android/settings/network/PrivateDnsModeDialogFragmentTest.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright (C) 2017 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.network;
-
-import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_OFF;
-import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_OPPORTUNISTIC;
-import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_PROVIDER_HOSTNAME;
-import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.spy;
-
-import android.content.Context;
-import android.provider.Settings;
-import android.widget.Button;
-
-import com.android.settings.R;
-import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settings.testutils.shadow.ShadowHelpUtils;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.RuntimeEnvironment;
-import org.robolectric.annotation.Config;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-@Config(shadows = ShadowHelpUtils.class)
-public class PrivateDnsModeDialogFragmentTest {
-
- private static final String HOST_NAME = "192.168.1.1";
- private static final String INVALID_HOST_NAME = "...,";
-
- private Context mContext;
- private PrivateDnsModeDialogFragment mFragment;
- private Button mSaveButton;
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
-
- mContext = RuntimeEnvironment.application;
- mSaveButton = new Button(mContext);
-
- mFragment = spy(new PrivateDnsModeDialogFragment());
- doReturn(mContext).when(mFragment).getContext();
- mFragment.onCreateDialog(null);
- mFragment.mSaveButton = mSaveButton;
- }
-
- @Test
- public void testOnCheckedChanged_dnsModeOff_disableEditText() {
- mFragment.onCheckedChanged(null, R.id.private_dns_mode_off);
-
- assertThat(mFragment.mMode).isEqualTo(PRIVATE_DNS_MODE_OFF);
- assertThat(mFragment.mEditText.isEnabled()).isFalse();
- }
-
- @Test
- public void testOnCheckedChanged_dnsModeOpportunistic_disableEditText() {
- mFragment.onCheckedChanged(null, R.id.private_dns_mode_opportunistic);
-
- assertThat(mFragment.mMode).isEqualTo(PRIVATE_DNS_MODE_OPPORTUNISTIC);
- assertThat(mFragment.mEditText.isEnabled()).isFalse();
- }
-
- @Test
- public void testOnCheckedChanged_dnsModeProvider_enableEditText() {
- mFragment.onCheckedChanged(null, R.id.private_dns_mode_provider);
-
- assertThat(mFragment.mMode).isEqualTo(PRIVATE_DNS_MODE_PROVIDER_HOSTNAME);
- assertThat(mFragment.mEditText.isEnabled()).isTrue();
- }
-
- @Test
- public void testOnCreateDialog_containsCorrectData() {
- Settings.Global.putString(mContext.getContentResolver(),
- PrivateDnsModeDialogFragment.MODE_KEY, PRIVATE_DNS_MODE_OPPORTUNISTIC);
- Settings.Global.putString(mContext.getContentResolver(),
- PrivateDnsModeDialogFragment.HOSTNAME_KEY, HOST_NAME);
-
- mFragment.onCreateDialog(null);
-
- assertThat(mFragment.mEditText.getText().toString()).isEqualTo(HOST_NAME);
- assertThat(mFragment.mRadioGroup.getCheckedRadioButtonId()).isEqualTo(
- R.id.private_dns_mode_opportunistic);
- }
-
- @Test
- public void testOnCheckedChanged_switchMode_saveButtonHasCorrectState() {
- // Set invalid hostname
- mFragment.mEditText.setText(INVALID_HOST_NAME);
-
- mFragment.onCheckedChanged(null, R.id.private_dns_mode_opportunistic);
- assertThat(mSaveButton.isEnabled()).isTrue();
-
- mFragment.onCheckedChanged(null, R.id.private_dns_mode_provider);
- assertThat(mSaveButton.isEnabled()).isFalse();
-
- mFragment.onCheckedChanged(null, R.id.private_dns_mode_off);
- assertThat(mSaveButton.isEnabled()).isTrue();
- }
-}
diff --git a/tests/robotests/src/com/android/settings/network/PrivateDnsModeDialogPreferenceTest.java b/tests/robotests/src/com/android/settings/network/PrivateDnsModeDialogPreferenceTest.java
new file mode 100644
index 0000000..8a60cf3
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/network/PrivateDnsModeDialogPreferenceTest.java
@@ -0,0 +1,137 @@
+/*
+ * Copyright (C) 2017 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.network;
+
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_OFF;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_OPPORTUNISTIC;
+import static android.net.ConnectivityManager.PRIVATE_DNS_MODE_PROVIDER_HOSTNAME;
+import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Mockito.anyInt;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import android.app.AlertDialog;
+import android.app.Fragment;
+import android.content.Context;
+import android.provider.Settings;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.widget.Button;
+import android.widget.LinearLayout;
+
+import com.android.settings.R;
+import com.android.settingslib.CustomDialogPreference.CustomPreferenceDialogFragment;
+import com.android.settings.testutils.SettingsRobolectricTestRunner;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.util.ReflectionHelpers;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+public class PrivateDnsModeDialogPreferenceTest {
+
+ private static final String HOST_NAME = "dns.example.com";
+ private static final String INVALID_HOST_NAME = "...,";
+
+ private PrivateDnsModeDialogPreference mPreference;
+
+ private Context mContext;
+ private Button mSaveButton;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+
+ mContext = RuntimeEnvironment.application;
+ mSaveButton = new Button(mContext);
+
+ final CustomPreferenceDialogFragment fragment = mock(CustomPreferenceDialogFragment.class);
+ final AlertDialog dialog = mock(AlertDialog.class);
+ when(fragment.getDialog()).thenReturn(dialog);
+ when(dialog.getButton(anyInt())).thenReturn(mSaveButton);
+
+ mPreference = new PrivateDnsModeDialogPreference(mContext);
+ ReflectionHelpers.setField(mPreference, "mFragment", fragment);
+
+ final LayoutInflater inflater = LayoutInflater.from(mContext);
+ final View view = inflater.inflate(R.layout.private_dns_mode_dialog,
+ new LinearLayout(mContext), false);
+
+ mPreference.onBindDialogView(view);
+ }
+
+ @Test
+ public void testOnCheckedChanged_dnsModeOff_disableEditText() {
+ mPreference.onCheckedChanged(null, R.id.private_dns_mode_off);
+
+ assertThat(mPreference.mMode).isEqualTo(PRIVATE_DNS_MODE_OFF);
+ assertThat(mPreference.mEditText.isEnabled()).isFalse();
+ }
+
+ @Test
+ public void testOnCheckedChanged_dnsModeOpportunistic_disableEditText() {
+ mPreference.onCheckedChanged(null, R.id.private_dns_mode_opportunistic);
+
+ assertThat(mPreference.mMode).isEqualTo(PRIVATE_DNS_MODE_OPPORTUNISTIC);
+ assertThat(mPreference.mEditText.isEnabled()).isFalse();
+ }
+
+ @Test
+ public void testOnCheckedChanged_dnsModeProvider_enableEditText() {
+ mPreference.onCheckedChanged(null, R.id.private_dns_mode_provider);
+
+ assertThat(mPreference.mMode).isEqualTo(PRIVATE_DNS_MODE_PROVIDER_HOSTNAME);
+ assertThat(mPreference.mEditText.isEnabled()).isTrue();
+ }
+
+ @Test
+ public void testOnBindDialogView_containsCorrectData() {
+ Settings.Global.putString(mContext.getContentResolver(),
+ PrivateDnsModeDialogPreference.MODE_KEY, PRIVATE_DNS_MODE_OPPORTUNISTIC);
+ Settings.Global.putString(mContext.getContentResolver(),
+ PrivateDnsModeDialogPreference.HOSTNAME_KEY, HOST_NAME);
+
+ final LayoutInflater inflater = LayoutInflater.from(mContext);
+ final View view = inflater.inflate(R.layout.private_dns_mode_dialog,
+ new LinearLayout(mContext), false);
+ mPreference.onBindDialogView(view);
+
+ assertThat(mPreference.mEditText.getText().toString()).isEqualTo(HOST_NAME);
+ assertThat(mPreference.mRadioGroup.getCheckedRadioButtonId()).isEqualTo(
+ R.id.private_dns_mode_opportunistic);
+ }
+
+ @Test
+ public void testOnCheckedChanged_switchMode_saveButtonHasCorrectState() {
+ // Set invalid hostname
+ mPreference.mEditText.setText(INVALID_HOST_NAME);
+
+ mPreference.onCheckedChanged(null, R.id.private_dns_mode_opportunistic);
+ assertThat(mSaveButton.isEnabled()).isTrue();
+
+ mPreference.onCheckedChanged(null, R.id.private_dns_mode_provider);
+ assertThat(mSaveButton.isEnabled()).isFalse();
+
+ mPreference.onCheckedChanged(null, R.id.private_dns_mode_off);
+ assertThat(mSaveButton.isEnabled()).isTrue();
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/vpn2/VpnUtilsTest.java b/tests/robotests/src/com/android/settings/vpn2/VpnUtilsTest.java
index f354c43..fd41c36 100644
--- a/tests/robotests/src/com/android/settings/vpn2/VpnUtilsTest.java
+++ b/tests/robotests/src/com/android/settings/vpn2/VpnUtilsTest.java
@@ -20,8 +20,9 @@
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
+import android.net.ConnectivityManager;
+
import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settings.wrapper.ConnectivityManagerWrapper;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -30,7 +31,7 @@
public final class VpnUtilsTest {
@Test
public void testIsAlwaysOnVpnSet() {
- final ConnectivityManagerWrapper cm = mock(ConnectivityManagerWrapper.class);
+ final ConnectivityManager cm = mock(ConnectivityManager.class);
when(cm.getAlwaysOnVpnPackageForUser(0)).thenReturn("com.example.vpn");
assertThat(VpnUtils.isAlwaysOnVpnSet(cm, 0)).isTrue();
diff --git a/tests/robotests/src/com/android/settings/wallpaper/WallpaperSuggestionActivityTest.java b/tests/robotests/src/com/android/settings/wallpaper/WallpaperSuggestionActivityTest.java
index 6ebbef3..fc708ef 100644
--- a/tests/robotests/src/com/android/settings/wallpaper/WallpaperSuggestionActivityTest.java
+++ b/tests/robotests/src/com/android/settings/wallpaper/WallpaperSuggestionActivityTest.java
@@ -20,15 +20,15 @@
import static org.mockito.Mockito.when;
import static org.robolectric.Shadows.shadowOf;
+import android.app.WallpaperManager;
import android.content.Context;
import android.content.Intent;
-import android.content.pm.PackageManager;
import android.content.res.Resources;
import com.android.settings.SubSettings;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
-import com.android.settings.wrapper.WallpaperManagerWrapper;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -40,6 +40,7 @@
import org.robolectric.annotation.Config;
import org.robolectric.annotation.Implementation;
import org.robolectric.annotation.Implements;
+import org.robolectric.annotation.Resetter;
import org.robolectric.shadows.ShadowActivity;
import org.robolectric.shadows.ShadowPackageManager;
@@ -59,10 +60,15 @@
mController = Robolectric.buildActivity(WallpaperSuggestionActivity.class);
}
+ @After
+ public void tearDown() {
+ ShadowWallpaperManager.reset();
+ }
+
@Test
public void launch_primarySuggestionActivityDoesNotExist_shouldFallback() {
ShadowPackageManager packageManager =
- shadowOf(RuntimeEnvironment.application.getPackageManager());
+ shadowOf(RuntimeEnvironment.application.getPackageManager());
packageManager.removePackage("com.android.settings");
ShadowActivity activity = shadowOf(mController.setup().get());
@@ -74,32 +80,34 @@
}
@Test
- public void wallpaperServiceEnabled_no_shouldReturnFalse() {
+ public void wallpaperServiceEnabled_no_shouldReturnTrue() {
when(mContext.getResources()).thenReturn(mResources);
when(mResources.getBoolean(com.android.internal.R.bool.config_enableWallpaperService))
- .thenReturn(false);
-
- assertThat(WallpaperSuggestionActivity.isSuggestionComplete(mContext)).isFalse();
- }
-
- @Test
- @Config(shadows = WallpaperSuggestionActivityTest.ShadowWallpaperManagerWrapper.class)
- public void hasWallpaperSet_no_shouldReturnFalse() {
- ShadowWallpaperManagerWrapper.setWallpaperId(0);
-
- assertThat(WallpaperSuggestionActivity.isSuggestionComplete(mContext)).isFalse();
- }
-
- @Test
- @Config(shadows = WallpaperSuggestionActivityTest.ShadowWallpaperManagerWrapper.class)
- public void hasWallpaperSet_yes_shouldReturnTrue() {
- ShadowWallpaperManagerWrapper.setWallpaperId(100);
+ .thenReturn(false);
assertThat(WallpaperSuggestionActivity.isSuggestionComplete(mContext)).isTrue();
}
- @Implements(WallpaperManagerWrapper.class)
- public static class ShadowWallpaperManagerWrapper {
+ @Test
+ @Config(shadows = ShadowWallpaperManager.class)
+ public void hasWallpaperSet_no_shouldReturnFalse() {
+ ShadowWallpaperManager.setWallpaperId(0);
+
+ assertThat(WallpaperSuggestionActivity.isSuggestionComplete(RuntimeEnvironment.application))
+ .isFalse();
+ }
+
+ @Test
+ @Config(shadows = ShadowWallpaperManager.class)
+ public void hasWallpaperSet_yes_shouldReturnTrue() {
+ ShadowWallpaperManager.setWallpaperId(100);
+
+ assertThat(WallpaperSuggestionActivity.isSuggestionComplete(RuntimeEnvironment.application))
+ .isTrue();
+ }
+
+ @Implements(WallpaperManager.class)
+ public static class ShadowWallpaperManager {
private static int sWallpaperId;
@@ -107,13 +115,11 @@
sWallpaperId = id;
}
+ @Resetter
public static void reset() {
sWallpaperId = 0;
}
- public void __constructor__(Context context) {
- }
-
@Implementation
public boolean isWallpaperServiceEnabled() {
return true;
diff --git a/tests/robotests/src/com/android/settings/wifi/WifiEnablerTest.java b/tests/robotests/src/com/android/settings/wifi/WifiEnablerTest.java
index b7bc33e..66cbd30 100644
--- a/tests/robotests/src/com/android/settings/wifi/WifiEnablerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/WifiEnablerTest.java
@@ -26,7 +26,6 @@
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settings.widget.SwitchWidgetController;
-import com.android.settings.wrapper.ConnectivityManagerWrapper;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
import org.junit.Before;
@@ -43,7 +42,7 @@
@Mock
private WifiManager mWifiManager;
@Mock
- private ConnectivityManagerWrapper mConnectivityManager;
+ private ConnectivityManager mConnectivityManager;
private WifiEnabler mEnabler;
@@ -52,7 +51,7 @@
MockitoAnnotations.initMocks(this);
when(mContext.getSystemService(Context.WIFI_SERVICE)).thenReturn(mWifiManager);
mEnabler = new WifiEnabler(mContext, mock(SwitchWidgetController.class),
- mock(MetricsFeatureProvider.class), mConnectivityManager);
+ mock(MetricsFeatureProvider.class), mConnectivityManager);
}
@Test
diff --git a/tests/robotests/src/com/android/settings/wifi/details/WifiDetailPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/wifi/details/WifiDetailPreferenceControllerTest.java
index 9c20d18..d08f922 100644
--- a/tests/robotests/src/com/android/settings/wifi/details/WifiDetailPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/details/WifiDetailPreferenceControllerTest.java
@@ -51,7 +51,6 @@
import android.net.wifi.WifiManager;
import android.os.Handler;
import android.provider.Settings;
-import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceCategory;
import android.support.v7.preference.PreferenceScreen;
import android.view.View;
@@ -70,7 +69,6 @@
import com.android.settings.widget.ActionButtonPreferenceTest;
import com.android.settings.widget.EntityHeaderController;
import com.android.settings.wifi.WifiDetailPreference;
-import com.android.settings.wrapper.ConnectivityManagerWrapper;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
import com.android.settingslib.core.lifecycle.Lifecycle;
import com.android.settingslib.wifi.AccessPoint;
@@ -91,7 +89,6 @@
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Arrays;
-import java.util.List;
import java.util.stream.Collectors;
@RunWith(SettingsRobolectricTestRunner.class)
@@ -119,8 +116,6 @@
@Mock
private ConnectivityManager mockConnectivityManager;
@Mock
- private ConnectivityManagerWrapper mockConnectivityManagerWrapper;
- @Mock
private Network mockNetwork;
@Mock
private NetworkInfo mockNetworkInfo;
@@ -173,8 +168,6 @@
private ArgumentCaptor<NetworkCallback> mCallbackCaptor;
@Captor
private ArgumentCaptor<View.OnClickListener> mForgetClickListener;
- @Captor
- private ArgumentCaptor<Preference> mIpv6AddressCaptor;
private Context mContext;
private Lifecycle mLifecycle;
@@ -245,12 +238,9 @@
when(mockAccessPoint.getConfig()).thenReturn(mockWifiConfig);
when(mockAccessPoint.getLevel()).thenReturn(LEVEL);
when(mockAccessPoint.getSecurityString(false)).thenReturn(SECURITY);
-
- when(mockConnectivityManagerWrapper.getConnectivityManager())
- .thenReturn(mockConnectivityManager);
when(mockConnectivityManager.getNetworkInfo(any(Network.class)))
.thenReturn(mockNetworkInfo);
- doNothing().when(mockConnectivityManagerWrapper).registerNetworkCallback(
+ doNothing().when(mockConnectivityManager).registerNetworkCallback(
nullable(NetworkRequest.class), mCallbackCaptor.capture(), nullable(Handler.class));
mockButtonsPref = ActionButtonPreferenceTest.createMock();
when(mockButtonsPref.setButton1OnClickListener(mForgetClickListener.capture()))
@@ -281,7 +271,7 @@
private WifiDetailPreferenceController newWifiDetailPreferenceController() {
return new WifiDetailPreferenceController(
mockAccessPoint,
- mockConnectivityManagerWrapper,
+ mockConnectivityManager,
mContext,
mockFragment,
null, // Handler
@@ -362,7 +352,7 @@
public void networkCallback_shouldBeRegisteredOnResume() {
displayAndResume();
- verify(mockConnectivityManagerWrapper, times(1)).registerNetworkCallback(
+ verify(mockConnectivityManager, times(1)).registerNetworkCallback(
nullable(NetworkRequest.class), mCallbackCaptor.capture(), nullable(Handler.class));
}
@@ -779,8 +769,6 @@
displayAndResume();
- List<Preference> addrs = mIpv6AddressCaptor.getAllValues();
-
String expectedAddresses = String.join("\n",
asString(Constants.IPV6_LINKLOCAL),
asString(Constants.IPV6_GLOBAL1),
@@ -826,7 +814,7 @@
ArgumentCaptor<OnClickListener> captor = ArgumentCaptor.forClass(OnClickListener.class);
verify(mockButtonsPref).setButton2OnClickListener(captor.capture());
captor.getValue().onClick(null);
- verify(mockConnectivityManagerWrapper).startCaptivePortalApp(mockNetwork);
+ verify(mockConnectivityManager).startCaptivePortalApp(mockNetwork);
verify(mockMetricsFeatureProvider)
.action(mockActivity, MetricsProto.MetricsEvent.ACTION_WIFI_SIGNIN);
}
diff --git a/tests/unit/src/com/android/settings/deviceinfo/storage/StorageAsyncLoaderTest.java b/tests/unit/src/com/android/settings/deviceinfo/storage/StorageAsyncLoaderTest.java
index f622804..d1d2b04 100644
--- a/tests/unit/src/com/android/settings/deviceinfo/storage/StorageAsyncLoaderTest.java
+++ b/tests/unit/src/com/android/settings/deviceinfo/storage/StorageAsyncLoaderTest.java
@@ -17,7 +17,6 @@
package com.android.settings.deviceinfo.storage;
import static com.google.common.truth.Truth.assertThat;
-
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyString;
@@ -31,11 +30,11 @@
import android.content.pm.UserInfo;
import android.net.TrafficStats;
import android.os.UserHandle;
+import android.os.UserManager;
import android.support.test.filters.SmallTest;
import android.support.test.runner.AndroidJUnit4;
import android.util.SparseArray;
-import com.android.settings.wrapper.UserManagerWrapper;
import com.android.settingslib.applications.StorageStatsSource;
import com.android.settingslib.wrapper.PackageManagerWrapper;
@@ -65,7 +64,7 @@
@Mock
private PackageManagerWrapper mPackageManager;
@Mock
- private UserManagerWrapper mUserManager;
+ private UserManager mUserManager;
private List<ApplicationInfo> mInfo = new ArrayList<>();
private List<UserInfo> mUsers;