From 16322a027142db6eaae885dea06b825382bb76b8 Mon Sep 17 00:00:00 2001 From: Anton Hansson Date: Mon, 10 Dec 2018 17:03:29 +0000 Subject: [PATCH 01/14] Make the Settings permission a required module This will include the Settings permission file whenever the Settings app is installed. Bug: 110072687 Test: make Change-Id: Ia2548355282498bceeffddb564de32a6cb857c66 --- Android.mk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Android.mk b/Android.mk index 7eb9b6ac071..0fbaacfa157 100644 --- a/Android.mk +++ b/Android.mk @@ -15,6 +15,7 @@ LOCAL_PACKAGE_NAME := Settings LOCAL_PRIVATE_PLATFORM_APIS := true LOCAL_CERTIFICATE := platform LOCAL_PRIVILEGED_MODULE := true +LOCAL_REQUIRED_MODULES := privapp_whitelist_com.android.settings LOCAL_MODULE_TAGS := optional LOCAL_USE_AAPT2 := true @@ -70,4 +71,4 @@ include $(BUILD_MULTI_PREBUILT) # Use the following include to make our test apk. ifeq (,$(ONE_SHOT_MAKEFILE)) include $(call all-makefiles-under,$(LOCAL_PATH)) -endif \ No newline at end of file +endif From 8ff2852f74aaa3f716a58519be60bf20c6db2a9d Mon Sep 17 00:00:00 2001 From: Arc Wang Date: Thu, 13 Dec 2018 17:02:19 +0800 Subject: [PATCH 02/14] Implement receiver flow of WiFi sharing feature II Bug: 120630683 Test: atest RunSettingsRoboTests Change-Id: Iabe56205ff9274382adbe5bba59a60d833a57214 --- res/values/strings.xml | 2 ++ src/com/android/settings/wifi/AddNetworkFragment.java | 2 +- src/com/android/settings/wifi/WifiDialog.java | 6 +++++- src/com/android/settings/wifi/WifiSettings.java | 2 +- .../wifi/details/WifiDetailPreferenceController.java | 5 +---- .../settings/wifi/dpp/WifiDppEnrolleeActivity.java | 2 +- .../settings/wifi/dpp/WifiDppQrCodeBaseFragment.java | 2 +- .../wifi/dpp/WifiDppQrCodeScannerFragment.java | 10 +++++++++- src/com/android/settings/wifi/dpp/WifiDppUtils.java | 9 +++++---- 9 files changed, 26 insertions(+), 14 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 188ba6e78f7..3a538c6b520 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -2071,6 +2071,8 @@ Scan QR code Join \u201c%1$s\u201d by scanning a QR code + + Join Wi\u2011Fi by scanning a QR code Share Wi\u2011Fi diff --git a/src/com/android/settings/wifi/AddNetworkFragment.java b/src/com/android/settings/wifi/AddNetworkFragment.java index 72d878b3109..cd8f76e624a 100644 --- a/src/com/android/settings/wifi/AddNetworkFragment.java +++ b/src/com/android/settings/wifi/AddNetworkFragment.java @@ -73,7 +73,7 @@ public class AddNetworkFragment extends InstrumentedFragment implements WifiConf scannerButton.setOnClickListener((View v) -> { // Launch QR code scanner to join a network. getContext().startActivity( - WifiDppUtils.getConfiguratorQRCodeScannerIntent(/* ssid */ null)); + WifiDppUtils.getEnrolleeQrCodeScannerIntent(/* ssid */ null)); }); } } diff --git a/src/com/android/settings/wifi/WifiDialog.java b/src/com/android/settings/wifi/WifiDialog.java index 0e2ca608b5b..0bee671e2e0 100644 --- a/src/com/android/settings/wifi/WifiDialog.java +++ b/src/com/android/settings/wifi/WifiDialog.java @@ -86,9 +86,13 @@ public class WifiDialog extends AlertDialog implements WifiConfigUiBase, if (scannerButton != null) { scannerButton.setVisibility(View.VISIBLE); scannerButton.setOnClickListener((View v) -> { + String ssid = null; + if (mAccessPoint != null) { + ssid = mAccessPoint.getSsidStr(); + } // Launch QR code scanner to join a network. getContext().startActivity( - WifiDppUtils.getConfiguratorQRCodeScannerIntent(/* ssid */ null)); + WifiDppUtils.getEnrolleeQrCodeScannerIntent(ssid)); }); } } diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java index 54de28d9de4..95e912db684 100644 --- a/src/com/android/settings/wifi/WifiSettings.java +++ b/src/com/android/settings/wifi/WifiSettings.java @@ -244,7 +244,7 @@ public class WifiSettings extends RestrictedSettingsFragment mAddPreference.setButtonOnClickListener((View v) -> { // Launch QR code scanner to join a network. getContext().startActivity( - WifiDppUtils.getConfiguratorQRCodeScannerIntent(/* ssid */ null)); + WifiDppUtils.getEnrolleeQrCodeScannerIntent(/* ssid */ null)); }); } mStatusMessagePreference = (LinkablePreference) findPreference(PREF_KEY_STATUS_MESSAGE); diff --git a/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java b/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java index e1179f820fa..f3e8fc194e5 100644 --- a/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java +++ b/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java @@ -549,11 +549,8 @@ public class WifiDetailPreferenceController extends AbstractPreferenceController * Show QR code to share the network represented by this preference. */ public void launchQRCodeGenerator() { - final Intent intent = new Intent( - WifiDppConfiguratorActivity.ACTION_CONFIGURATOR_QR_CODE_GENERATOR); - intent.putExtra(WifiDppUtils.EXTRA_WIFI_SECURITY, + Intent intent = WifiDppUtils.getConfiguratorQrCodeGeneratorIntent(mAccessPoint.getSsidStr(), mAccessPoint.getSecurityString(/* concise */ false)); - intent.putExtra(WifiDppUtils.EXTRA_WIFI_SSID, mAccessPoint.getSsidStr()); mContext.startActivity(intent); } diff --git a/src/com/android/settings/wifi/dpp/WifiDppEnrolleeActivity.java b/src/com/android/settings/wifi/dpp/WifiDppEnrolleeActivity.java index 7c58fd577be..39d993f03f9 100644 --- a/src/com/android/settings/wifi/dpp/WifiDppEnrolleeActivity.java +++ b/src/com/android/settings/wifi/dpp/WifiDppEnrolleeActivity.java @@ -35,7 +35,7 @@ import com.android.settings.R; * To provision "this" device with specified Wi-Fi network. * * To use intent action {@code ACTION_ENROLLEE_QR_CODE_SCANNER}, specify the SSID string of the - * Wi-Fi network to be provisioned in {@code WifiDppUtils.EXTRA_QR_CODE}. + * Wi-Fi network to be provisioned in {@code WifiDppUtils.EXTRA_WIFI_SSID}. */ public class WifiDppEnrolleeActivity extends InstrumentedActivity { private static final String TAG = "WifiDppEnrolleeActivity"; diff --git a/src/com/android/settings/wifi/dpp/WifiDppQrCodeBaseFragment.java b/src/com/android/settings/wifi/dpp/WifiDppQrCodeBaseFragment.java index cddd55cdd40..e6427d9e644 100644 --- a/src/com/android/settings/wifi/dpp/WifiDppQrCodeBaseFragment.java +++ b/src/com/android/settings/wifi/dpp/WifiDppQrCodeBaseFragment.java @@ -34,7 +34,7 @@ import com.android.settings.wifi.qrcode.QrDecorateView; import com.android.settings.R; /** - * TODO: Should refine code to only initiate UI component in each child fragment. + * TODO: b/120645817 should refine code to only initiate UI component in each child fragment. */ /** diff --git a/src/com/android/settings/wifi/dpp/WifiDppQrCodeScannerFragment.java b/src/com/android/settings/wifi/dpp/WifiDppQrCodeScannerFragment.java index 5689c56ddad..342e693371b 100644 --- a/src/com/android/settings/wifi/dpp/WifiDppQrCodeScannerFragment.java +++ b/src/com/android/settings/wifi/dpp/WifiDppQrCodeScannerFragment.java @@ -23,6 +23,7 @@ import android.content.Context; import android.content.Intent; import android.graphics.Rect; import android.os.Bundle; +import android.text.TextUtils; import android.util.Size; import android.view.Menu; import android.view.MenuInflater; @@ -87,7 +88,14 @@ public class WifiDppQrCodeScannerFragment extends WifiDppQrCodeBaseFragment impl setDescription(getString(R.string.wifi_dpp_center_qr_code, wifiNetworkConfig.getSsid())); } else { setTitle(getString(R.string.wifi_dpp_scan_qr_code)); - setDescription(getString(R.string.wifi_dpp_scan_qr_code_join_network, mSsid)); + + String description; + if (TextUtils.isEmpty(mSsid)) { + description = getString(R.string.wifi_dpp_scan_qr_code_join_unknown_network, mSsid); + } else { + description = getString(R.string.wifi_dpp_scan_qr_code_join_network, mSsid); + } + setDescription(description); } ActionBar actionBar = getActivity().getActionBar(); diff --git a/src/com/android/settings/wifi/dpp/WifiDppUtils.java b/src/com/android/settings/wifi/dpp/WifiDppUtils.java index dc0ff849eaf..3275695c307 100644 --- a/src/com/android/settings/wifi/dpp/WifiDppUtils.java +++ b/src/com/android/settings/wifi/dpp/WifiDppUtils.java @@ -88,14 +88,14 @@ public class WifiDppUtils { } /** - * Returns an intent to launch QR code scanner. + * Returns an intent to launch QR code scanner for Wi-Fi DPP enrollee. * * @param ssid The data corresponding to {@code WifiConfiguration} SSID * @return Intent for launching QR code scanner */ - public static Intent getConfiguratorQRCodeScannerIntent(String ssid) { + public static Intent getEnrolleeQrCodeScannerIntent(String ssid) { final Intent intent = new Intent( - WifiDppConfiguratorActivity.ACTION_CONFIGURATOR_QR_CODE_SCANNER); + WifiDppEnrolleeActivity.ACTION_ENROLLEE_QR_CODE_SCANNER); if (!TextUtils.isEmpty(ssid)) { intent.putExtra(EXTRA_WIFI_SSID, ssid); } @@ -109,7 +109,8 @@ public class WifiDppUtils { * @param Security The data is from {@code AccessPoint.securityToString} * @return Intent for launching QR code generator */ - public static Intent getConfiguratorQRCodeGeneratorIntent(String ssid, String Security) { + public static Intent getConfiguratorQrCodeGeneratorIntent(String ssid, String Security) { + //TODO: b/118794858#comment6 should put password & hideSsid in intent extra final Intent intent = new Intent( WifiDppConfiguratorActivity.ACTION_CONFIGURATOR_QR_CODE_GENERATOR); if (!TextUtils.isEmpty(ssid)) { From ec84a9367ff3ed4478e8ec2b24c34ff6f6632dfb Mon Sep 17 00:00:00 2001 From: Julia Reynolds Date: Fri, 14 Dec 2018 09:27:53 -0500 Subject: [PATCH 03/14] Link to the appropriate config activity for dnd rules Test: atest, manual Bug: 111474881 Change-Id: I0c1d7b14abe3cf65762167f3c412fa8f2be1d842 --- ...ModeAutomaticRulePreferenceController.java | 44 +++++++++---- .../ZenModeAutomationSettings.java | 2 + .../settings/notification/ZenRuleInfo.java | 3 + .../notification/ZenRulePreference.java | 17 ++--- .../notification/ZenRuleSelectionDialog.java | 12 ++-- .../utils/ManagedServiceSettings.java | 17 +++-- .../settings/utils/ZenServiceListing.java | 66 ++++++++++++------- ...utomaticRulesPreferenceControllerTest.java | 24 +++---- .../notification/ZenModeBackendTest.java | 14 ++-- 9 files changed, 121 insertions(+), 78 deletions(-) diff --git a/src/com/android/settings/notification/AbstractZenModeAutomaticRulePreferenceController.java b/src/com/android/settings/notification/AbstractZenModeAutomaticRulePreferenceController.java index d0f1ee69efa..1499656eacf 100644 --- a/src/com/android/settings/notification/AbstractZenModeAutomaticRulePreferenceController.java +++ b/src/com/android/settings/notification/AbstractZenModeAutomaticRulePreferenceController.java @@ -21,6 +21,8 @@ import android.app.NotificationManager; import android.content.ComponentName; import android.content.Context; import android.content.Intent; +import android.content.pm.ActivityInfo; +import android.content.pm.ComponentInfo; import android.content.pm.PackageManager; import android.content.pm.ServiceInfo; import android.provider.Settings; @@ -82,33 +84,47 @@ abstract public class AbstractZenModeAutomaticRulePreferenceController extends return intent; } - public static ZenRuleInfo getRuleInfo(PackageManager pm, ServiceInfo si) { - if (si == null || si.metaData == null) { + public static ZenRuleInfo getRuleInfo(PackageManager pm, ComponentInfo ci) { + if (ci == null || ci.metaData == null) { return null; } - final String ruleType = si.metaData.getString(ConditionProviderService.META_DATA_RULE_TYPE); - final ComponentName configurationActivity = getSettingsActivity(si); + final String ruleType = (ci instanceof ServiceInfo) + ? ci.metaData.getString(ConditionProviderService.META_DATA_RULE_TYPE) + : ci.metaData.getString(NotificationManager.META_DATA_AUTOMATIC_RULE_TYPE); + + final ComponentName configurationActivity = getSettingsActivity(null, ci); if (ruleType != null && !ruleType.trim().isEmpty() && configurationActivity != null) { final ZenRuleInfo ri = new ZenRuleInfo(); - ri.serviceComponent = new ComponentName(si.packageName, si.name); + ri.serviceComponent = + (ci instanceof ServiceInfo) ? new ComponentName(ci.packageName, ci.name) : null; ri.settingsAction = Settings.ACTION_ZEN_MODE_EXTERNAL_RULE_SETTINGS; ri.title = ruleType; - ri.packageName = si.packageName; - ri.configurationActivity = getSettingsActivity(si); - ri.packageLabel = si.applicationInfo.loadLabel(pm); - ri.ruleInstanceLimit = - si.metaData.getInt(ConditionProviderService.META_DATA_RULE_INSTANCE_LIMIT, -1); + ri.packageName = ci.packageName; + ri.configurationActivity = configurationActivity; + ri.packageLabel = ci.applicationInfo.loadLabel(pm); + ri.ruleInstanceLimit = (ci instanceof ServiceInfo) + ? ci.metaData.getInt(ConditionProviderService.META_DATA_RULE_INSTANCE_LIMIT, -1) + : ci.metaData.getInt(NotificationManager.META_DATA_RULE_INSTANCE_LIMIT, -1); return ri; } return null; } - protected static ComponentName getSettingsActivity(ServiceInfo si) { - if (si == null || si.metaData == null) { + protected static ComponentName getSettingsActivity(AutomaticZenRule rule, ComponentInfo ci) { + // prefer config activity on the rule itself; fallback to manifest definition + if (rule != null && rule.getConfigurationActivity() != null) { + return rule.getConfigurationActivity(); + } + if (ci == null) { return null; } + // new activity backed rule + if (ci instanceof ActivityInfo) { + return new ComponentName(ci.packageName, ci.name); + } + // old service backed rule final String configurationActivity = - si.metaData.getString(ConditionProviderService.META_DATA_CONFIGURATION_ACTIVITY); + ci.metaData.getString(ConditionProviderService.META_DATA_CONFIGURATION_ACTIVITY); if (configurationActivity != null) { return ComponentName.unflattenFromString(configurationActivity); } @@ -127,7 +143,7 @@ abstract public class AbstractZenModeAutomaticRulePreferenceController extends mMetricsFeatureProvider.action(mContext, MetricsProto.MetricsEvent.ACTION_ZEN_MODE_RULE_NAME_CHANGE_OK); AutomaticZenRule rule = new AutomaticZenRule(ruleName, mRuleInfo.serviceComponent, - mRuleInfo.defaultConditionId, + mRuleInfo.configurationActivity, mRuleInfo.defaultConditionId, null, NotificationManager.INTERRUPTION_FILTER_PRIORITY, true); String savedRuleId = mBackend.addZenRule(rule); if (savedRuleId != null) { diff --git a/src/com/android/settings/notification/ZenModeAutomationSettings.java b/src/com/android/settings/notification/ZenModeAutomationSettings.java index d6a7d72e0cb..57ee545292b 100644 --- a/src/com/android/settings/notification/ZenModeAutomationSettings.java +++ b/src/com/android/settings/notification/ZenModeAutomationSettings.java @@ -18,6 +18,7 @@ package com.android.settings.notification; import android.app.AlertDialog; import android.app.AutomaticZenRule; +import android.app.NotificationManager; import android.content.Context; import android.content.DialogInterface; import android.os.Bundle; @@ -92,6 +93,7 @@ public class ZenModeAutomationSettings extends ZenModeSettingsBase { return new ManagedServiceSettings.Config.Builder() .setTag(TAG) .setIntentAction(ConditionProviderService.SERVICE_INTERFACE) + .setConfigurationIntentAction(NotificationManager.ACTION_AUTOMATIC_ZEN_RULE) .setPermission(android.Manifest.permission.BIND_CONDITION_PROVIDER_SERVICE) .setNoun("condition provider") .build(); diff --git a/src/com/android/settings/notification/ZenRuleInfo.java b/src/com/android/settings/notification/ZenRuleInfo.java index 2d7abf81bce..1a1539b6a3d 100644 --- a/src/com/android/settings/notification/ZenRuleInfo.java +++ b/src/com/android/settings/notification/ZenRuleInfo.java @@ -24,6 +24,8 @@ public class ZenRuleInfo { that.defaultConditionId) : that.defaultConditionId != null) return false; if (serviceComponent != null ? !serviceComponent.equals( that.serviceComponent) : that.serviceComponent != null) return false; + if (id != null ? !id.equals(that.id) : that.id != null) + return false; return packageLabel != null ? packageLabel.equals( that.packageLabel) : that.packageLabel == null; @@ -38,4 +40,5 @@ public class ZenRuleInfo { public boolean isSystem; public CharSequence packageLabel; public int ruleInstanceLimit = -1; + public String id; } diff --git a/src/com/android/settings/notification/ZenRulePreference.java b/src/com/android/settings/notification/ZenRulePreference.java index 10b49eb73dd..91f68e824a7 100644 --- a/src/com/android/settings/notification/ZenRulePreference.java +++ b/src/com/android/settings/notification/ZenRulePreference.java @@ -21,6 +21,7 @@ import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.pm.ApplicationInfo; +import android.content.pm.ComponentInfo; import android.content.pm.PackageManager; import android.content.pm.ServiceInfo; import android.service.notification.ZenModeConfig; @@ -45,7 +46,6 @@ public class ZenRulePreference extends TwoTargetPreference { private static final ManagedServiceSettings.Config CONFIG = ZenModeAutomationSettings.getConditionProviderConfig(); final String mId; - boolean appExists; final Fragment mParent; final Preference mPref; final Context mContext; @@ -56,7 +56,6 @@ public class ZenRulePreference extends TwoTargetPreference { final AutomaticZenRule mRule; CharSequence mName; - private boolean mIsSystemRule; private Intent mIntent; private boolean mChecked; private CheckBox mCheckBox; @@ -163,25 +162,17 @@ public class ZenRulePreference extends TwoTargetPreference { final boolean isSchedule = ZenModeConfig.isValidScheduleConditionId( rule.getConditionId(), true); final boolean isEvent = ZenModeConfig.isValidEventConditionId(rule.getConditionId()); - mIsSystemRule = isSchedule || isEvent; - try { - ApplicationInfo info = mPm.getApplicationInfo(rule.getOwner().getPackageName(), 0); - setSummary(computeRuleSummary(rule)); - } catch (PackageManager.NameNotFoundException e) { - appExists = false; - return; - } + setSummary(computeRuleSummary(rule)); - appExists = true; setTitle(mName); setPersistent(false); final String action = isSchedule ? ZenModeScheduleRuleSettings.ACTION : isEvent ? ZenModeEventRuleSettings.ACTION : ""; - ServiceInfo si = mServiceListing.findService(rule.getOwner()); + ComponentInfo si = mServiceListing.findService(rule.getOwner()); ComponentName settingsActivity = AbstractZenModeAutomaticRulePreferenceController. - getSettingsActivity(si); + getSettingsActivity(rule, si); mIntent = AbstractZenModeAutomaticRulePreferenceController.getRuleIntent(action, settingsActivity, mId); setKey(mId); diff --git a/src/com/android/settings/notification/ZenRuleSelectionDialog.java b/src/com/android/settings/notification/ZenRuleSelectionDialog.java index abda3769be8..7f0b4c2dff6 100644 --- a/src/com/android/settings/notification/ZenRuleSelectionDialog.java +++ b/src/com/android/settings/notification/ZenRuleSelectionDialog.java @@ -23,6 +23,7 @@ import android.app.NotificationManager; import android.content.Context; import android.content.DialogInterface; import android.content.pm.ApplicationInfo; +import android.content.pm.ComponentInfo; import android.content.pm.PackageManager; import android.content.pm.ServiceInfo; import android.graphics.drawable.Drawable; @@ -192,16 +193,17 @@ public class ZenRuleSelectionDialog extends InstrumentedDialogFragment { private final ZenServiceListing.Callback mServiceListingCallback = new ZenServiceListing.Callback() { @Override - public void onServicesReloaded(Set services) { - if (DEBUG) Log.d(TAG, "Services reloaded: count=" + services.size()); + public void onComponentsReloaded(Set componentInfos) { + if (DEBUG) Log.d(TAG, "Reloaded: count=" + componentInfos.size()); + Set externalRuleTypes = new TreeSet<>(RULE_TYPE_COMPARATOR); - for (ServiceInfo serviceInfo : services) { + for (ComponentInfo ci : componentInfos) { final ZenRuleInfo ri = AbstractZenModeAutomaticRulePreferenceController. - getRuleInfo(mPm, serviceInfo); + getRuleInfo(mPm, ci); if (ri != null && ri.configurationActivity != null && mNm.isNotificationPolicyAccessGrantedForPackage(ri.packageName) && (ri.ruleInstanceLimit <= 0 || ri.ruleInstanceLimit - >= (mNm.getRuleInstanceCount(serviceInfo.getComponentName()) + 1))) { + >= (mNm.getRuleInstanceCount(ci.getComponentName()) + 1))) { externalRuleTypes.add(ri); } } diff --git a/src/com/android/settings/utils/ManagedServiceSettings.java b/src/com/android/settings/utils/ManagedServiceSettings.java index e5dfb066e3e..16f79c2aebe 100644 --- a/src/com/android/settings/utils/ManagedServiceSettings.java +++ b/src/com/android/settings/utils/ManagedServiceSettings.java @@ -240,9 +240,11 @@ public abstract class ManagedServiceSettings extends EmptyTextSettings { public final int warningDialogTitle; public final int warningDialogSummary; public final int emptyText; + public final String configIntentAction; - private Config(String tag, String setting, String intentAction, String permission, - String noun, int warningDialogTitle, int warningDialogSummary, int emptyText) { + private Config(String tag, String setting, String intentAction, String configIntentAction, + String permission, String noun, int warningDialogTitle, int warningDialogSummary, + int emptyText) { this.tag = tag; this.setting = setting; this.intentAction = intentAction; @@ -251,6 +253,7 @@ public abstract class ManagedServiceSettings extends EmptyTextSettings { this.warningDialogTitle = warningDialogTitle; this.warningDialogSummary = warningDialogSummary; this.emptyText = emptyText; + this.configIntentAction = configIntentAction; } public static class Builder{ @@ -262,6 +265,7 @@ public abstract class ManagedServiceSettings extends EmptyTextSettings { private int mWarningDialogTitle; private int mWarningDialogSummary; private int mEmptyText; + private String mConfigIntentAction; public Builder setTag(String tag) { mTag = tag; @@ -278,6 +282,11 @@ public abstract class ManagedServiceSettings extends EmptyTextSettings { return this; } + public Builder setConfigurationIntentAction(String action) { + mConfigIntentAction = action; + return this; + } + public Builder setPermission(String permission) { mPermission = permission; return this; @@ -304,8 +313,8 @@ public abstract class ManagedServiceSettings extends EmptyTextSettings { } public Config build() { - return new Config(mTag, mSetting, mIntentAction, mPermission, mNoun, - mWarningDialogTitle, mWarningDialogSummary, mEmptyText); + return new Config(mTag, mSetting, mIntentAction, mConfigIntentAction, mPermission, + mNoun, mWarningDialogTitle, mWarningDialogSummary, mEmptyText); } } } diff --git a/src/com/android/settings/utils/ZenServiceListing.java b/src/com/android/settings/utils/ZenServiceListing.java index e87cc51f2c2..99f56f621c8 100644 --- a/src/com/android/settings/utils/ZenServiceListing.java +++ b/src/com/android/settings/utils/ZenServiceListing.java @@ -20,6 +20,8 @@ import android.app.NotificationManager; import android.content.ComponentName; import android.content.Context; import android.content.Intent; +import android.content.pm.ActivityInfo; +import android.content.pm.ComponentInfo; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.content.pm.ServiceInfo; @@ -34,7 +36,7 @@ public class ZenServiceListing { private final Context mContext; private final ManagedServiceSettings.Config mConfig; - private final Set mApprovedServices = new ArraySet(); + private final Set mApprovedComponents = new ArraySet<>(); private final List mZenCallbacks = new ArrayList<>(); private final NotificationManager mNm; @@ -44,11 +46,14 @@ public class ZenServiceListing { mNm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); } - public ServiceInfo findService(final ComponentName cn) { - for (ServiceInfo service : mApprovedServices) { - final ComponentName serviceCN = new ComponentName(service.packageName, service.name); - if (serviceCN.equals(cn)) { - return service; + public ComponentInfo findService(final ComponentName cn) { + if (cn == null) { + return null; + } + for (ComponentInfo component : mApprovedComponents) { + final ComponentName ci = new ComponentName(component.packageName, component.name); + if (ci.equals(cn)) { + return component; } } return null; @@ -63,32 +68,29 @@ public class ZenServiceListing { } public void reloadApprovedServices() { - mApprovedServices.clear(); + mApprovedComponents.clear(); List enabledNotificationListenerPkgs = mNm.getEnabledNotificationListenerPackages(); - List services = new ArrayList<>(); - getServices(mConfig, services, mContext.getPackageManager()); - for (ServiceInfo service : services) { - final String servicePackage = service.getComponentName().getPackageName(); - if (mNm.isNotificationPolicyAccessGrantedForPackage(servicePackage) - || enabledNotificationListenerPkgs.contains(servicePackage)) { - mApprovedServices.add(service); + List components = new ArrayList<>(); + getServices(mConfig, components, mContext.getPackageManager()); + getActivities(mConfig, components, mContext.getPackageManager()); + for (ComponentInfo componentInfo : components) { + final String pkg = componentInfo.getComponentName().getPackageName(); + if (mNm.isNotificationPolicyAccessGrantedForPackage(pkg) + || enabledNotificationListenerPkgs.contains(pkg)) { + mApprovedComponents.add(componentInfo); } } - if (!mApprovedServices.isEmpty()) { + if (!mApprovedComponents.isEmpty()) { for (Callback callback : mZenCallbacks) { - callback.onServicesReloaded(mApprovedServices); + callback.onComponentsReloaded(mApprovedComponents); } } } - private static int getServices(ManagedServiceSettings.Config c, List list, + private static void getServices(ManagedServiceSettings.Config c, List list, PackageManager pm) { - int services = 0; - if (list != null) { - list.clear(); - } final int user = ActivityManager.getCurrentUser(); List installedServices = pm.queryIntentServicesAsUser( @@ -110,12 +112,28 @@ public class ZenServiceListing { if (list != null) { list.add(info); } - services++; } - return services; + } + + private static void getActivities(ManagedServiceSettings.Config c, List list, + PackageManager pm) { + final int user = ActivityManager.getCurrentUser(); + + List resolveInfos = pm.queryIntentActivitiesAsUser( + new Intent(c.configIntentAction), + PackageManager.GET_ACTIVITIES | PackageManager.GET_META_DATA, + user); + + for (int i = 0, count = resolveInfos.size(); i < count; i++) { + ResolveInfo resolveInfo = resolveInfos.get(i); + ActivityInfo info = resolveInfo.activityInfo; + if (list != null) { + list.add(info); + } + } } public interface Callback { - void onServicesReloaded(Set services); + void onComponentsReloaded(Set components); } } diff --git a/tests/robotests/src/com/android/settings/notification/ZenModeAutomaticRulesPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/ZenModeAutomaticRulesPreferenceControllerTest.java index 5e3d6e9888c..41227c5349e 100644 --- a/tests/robotests/src/com/android/settings/notification/ZenModeAutomaticRulesPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/notification/ZenModeAutomaticRulesPreferenceControllerTest.java @@ -83,12 +83,12 @@ public class ZenModeAutomaticRulesPreferenceControllerTest { String ruleId2 = "test2_id"; String ruleId3 = "test3_id"; - AutomaticZenRule autoRule1 = new AutomaticZenRule("test_rule_1", null, - null, Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS, true, 10); - AutomaticZenRule autoRule2 = new AutomaticZenRule("test_rule_2", null, - null, Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS, true, 20); - AutomaticZenRule autoRule3 = new AutomaticZenRule("test_rule_3", null, - null, Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS, true, 30); + AutomaticZenRule autoRule1 = new AutomaticZenRule("test_rule_1", null, null, + null, null, Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS, true, 10); + AutomaticZenRule autoRule2 = new AutomaticZenRule("test_rule_2", null, null, + null, null, Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS, true, 20); + AutomaticZenRule autoRule3 = new AutomaticZenRule("test_rule_3", null, null, + null, null, Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS, true, 30); rMap.put(ruleId1, autoRule1); rMap.put(ruleId2, autoRule2); @@ -109,10 +109,10 @@ public class ZenModeAutomaticRulesPreferenceControllerTest { String ruleId1 = "test1_id"; String ruleId2 = "test2_id"; - AutomaticZenRule autoRule1 = new AutomaticZenRule("test_rule_1", null, - null, Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS, true, 10); - AutomaticZenRule autoRule2 = new AutomaticZenRule("test_rule_2", null, - null, Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS, true, 20); + AutomaticZenRule autoRule1 = new AutomaticZenRule("test_rule_1", null, null, + null, null, Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS, true, 10); + AutomaticZenRule autoRule2 = new AutomaticZenRule("test_rule_2", null, null, + null, null, Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS, true, 20); rMap.put(ruleId1, autoRule1); rMap.put(ruleId2, autoRule2); @@ -130,8 +130,8 @@ public class ZenModeAutomaticRulesPreferenceControllerTest { final int NUM_RULES = 1; Map rMap = new HashMap<>(); String testId = "test1_id"; - AutomaticZenRule rule = new AutomaticZenRule("rule_name", null, - null, Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS, true, 10); + AutomaticZenRule rule = new AutomaticZenRule("rule_name", null, null, + null, null, Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS, true, 10); rMap.put(testId, rule); when(mockPref.getPreferenceCount()).thenReturn(NUM_RULES); diff --git a/tests/robotests/src/com/android/settings/notification/ZenModeBackendTest.java b/tests/robotests/src/com/android/settings/notification/ZenModeBackendTest.java index 3feff0d28b2..6169f92ddc9 100644 --- a/tests/robotests/src/com/android/settings/notification/ZenModeBackendTest.java +++ b/tests/robotests/src/com/android/settings/notification/ZenModeBackendTest.java @@ -69,13 +69,14 @@ public class ZenModeBackendTest { for (int i = 0; i < numRules; i++) { ruleMap.put(GENERIC_RULE_NAME + i, new AutomaticZenRule(GENERIC_RULE_NAME + i, null, - null, Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS, true, i * 2)); + null, null, null, Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS, true, + i * 2)); } if (addDefaultRules) { - ruleMap.put(DEFAULT_ID_1, new AutomaticZenRule("DEFAULT_1_NAME", null, + ruleMap.put(DEFAULT_ID_1, new AutomaticZenRule("DEFAULT_1_NAME", null, null, null, null, Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS, true, 20)); - ruleMap.put(DEFAULT_ID_2, new AutomaticZenRule("DEFAULT_2_NAME", null, + ruleMap.put(DEFAULT_ID_2, new AutomaticZenRule("DEFAULT_2_NAME", null, null, null, null, Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS, true, 10)); } @@ -90,13 +91,14 @@ public class ZenModeBackendTest { for (int i = 0; i < numRules; i++) { ruleMap.put(GENERIC_RULE_NAME + i, new AutomaticZenRule(GENERIC_RULE_NAME + i, null, - null, Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS, true, numRules - i)); + null, null, null, Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS, true, + numRules - i)); } if (addDefaultRules) { - ruleMap.put(DEFAULT_ID_1, new AutomaticZenRule("DEFAULT_1_NAME", null, + ruleMap.put(DEFAULT_ID_1, new AutomaticZenRule("DEFAULT_1_NAME", null, null, null, null, Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS, true, 10)); - ruleMap.put(DEFAULT_ID_2, new AutomaticZenRule("DEFAULT_2_NAME", null, + ruleMap.put(DEFAULT_ID_2, new AutomaticZenRule("DEFAULT_2_NAME", null, null, null, null, Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS, true, 20)); } From 11f698ba220daa11e5b432c9562d437d24c6a0c6 Mon Sep 17 00:00:00 2001 From: Ben Lin Date: Fri, 14 Dec 2018 16:00:21 -0800 Subject: [PATCH 04/14] Add boolean flags to show/hide top-most settings. Bug: None Test: RunSettingsRoboTests Change-Id: Ib576f5979feda0fa7f573915acffc5065d40095c --- res/values/bools.xml | 9 +++++++++ ...velConnectedDevicesPreferenceController.java | 5 ++++- .../TopLevelDisplayPreferenceController.java | 4 +++- .../TopLevelBatteryPreferenceController.java | 4 +++- tests/robotests/res/values-mcc999/config.xml | 3 +++ ...onnectedDevicesPreferenceControllerTest.java | 14 ++++++++++++++ ...TopLevelDisplayPreferenceControllerTest.java | 15 +++++++++++++-- ...TopLevelBatteryPreferenceControllerTest.java | 17 ++++++++++++++++- 8 files changed, 65 insertions(+), 6 deletions(-) diff --git a/res/values/bools.xml b/res/values/bools.xml index 8bd11c78d53..a5043a2949e 100644 --- a/res/values/bools.xml +++ b/res/values/bools.xml @@ -168,6 +168,15 @@ true + + true + + + true + + + true + true diff --git a/src/com/android/settings/connecteddevice/TopLevelConnectedDevicesPreferenceController.java b/src/com/android/settings/connecteddevice/TopLevelConnectedDevicesPreferenceController.java index 6f16db6e368..4b2bdc05d80 100644 --- a/src/com/android/settings/connecteddevice/TopLevelConnectedDevicesPreferenceController.java +++ b/src/com/android/settings/connecteddevice/TopLevelConnectedDevicesPreferenceController.java @@ -19,6 +19,7 @@ package com.android.settings.connecteddevice; import android.content.Context; import com.android.settings.core.BasePreferenceController; +import com.android.settings.R; public class TopLevelConnectedDevicesPreferenceController extends BasePreferenceController { @@ -29,7 +30,9 @@ public class TopLevelConnectedDevicesPreferenceController extends BasePreference @Override public int getAvailabilityStatus() { - return AVAILABLE_UNSEARCHABLE; + return mContext.getResources().getBoolean(R.bool.config_show_top_level_connected_devices) + ? AVAILABLE_UNSEARCHABLE + : UNSUPPORTED_ON_DEVICE; } @Override diff --git a/src/com/android/settings/display/TopLevelDisplayPreferenceController.java b/src/com/android/settings/display/TopLevelDisplayPreferenceController.java index 88b87e0ba0b..ed85a4ab10a 100644 --- a/src/com/android/settings/display/TopLevelDisplayPreferenceController.java +++ b/src/com/android/settings/display/TopLevelDisplayPreferenceController.java @@ -29,7 +29,9 @@ public class TopLevelDisplayPreferenceController extends BasePreferenceControlle @Override public int getAvailabilityStatus() { - return AVAILABLE; + return mContext.getResources().getBoolean(R.bool.config_show_top_level_display) + ? AVAILABLE + : UNSUPPORTED_ON_DEVICE; } @Override diff --git a/src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceController.java b/src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceController.java index 82058183e53..ce85be8daf6 100644 --- a/src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceController.java +++ b/src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceController.java @@ -48,7 +48,9 @@ public class TopLevelBatteryPreferenceController extends BasePreferenceControlle @Override public int getAvailabilityStatus() { - return AVAILABLE_UNSEARCHABLE; + return mContext.getResources().getBoolean(R.bool.config_show_top_level_battery) + ? AVAILABLE_UNSEARCHABLE + : UNSUPPORTED_ON_DEVICE; } @Override diff --git a/tests/robotests/res/values-mcc999/config.xml b/tests/robotests/res/values-mcc999/config.xml index c5c552e54e1..101a6b813f4 100644 --- a/tests/robotests/res/values-mcc999/config.xml +++ b/tests/robotests/res/values-mcc999/config.xml @@ -58,6 +58,9 @@ false false false + false + false + false false false true diff --git a/tests/robotests/src/com/android/settings/connecteddevice/TopLevelConnectedDevicesPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/connecteddevice/TopLevelConnectedDevicesPreferenceControllerTest.java index f6b18a31810..ab733701cdf 100644 --- a/tests/robotests/src/com/android/settings/connecteddevice/TopLevelConnectedDevicesPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/connecteddevice/TopLevelConnectedDevicesPreferenceControllerTest.java @@ -16,6 +16,9 @@ package com.android.settings.connecteddevice; +import static com.android.settings.core.BasePreferenceController.AVAILABLE_UNSEARCHABLE; +import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE; + import static com.google.common.truth.Truth.assertThat; import android.content.Context; @@ -43,6 +46,17 @@ public class TopLevelConnectedDevicesPreferenceControllerTest { mController = new TopLevelConnectedDevicesPreferenceController(mContext, "test_key"); } + @Test + public void getAvailibilityStatus_availableByDefault() { + assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE_UNSEARCHABLE); + } + + @Test + @Config(qualifiers = "mcc999") + public void getAvailabilityStatus_unsupportedWhenSet() { + assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE); + } + @Test @Config(shadows = ShadowAdvancedConnectedDeviceController.class) public void getSummary_shouldCallAdvancedConnectedDeviceController() { diff --git a/tests/robotests/src/com/android/settings/display/TopLevelDisplayPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/TopLevelDisplayPreferenceControllerTest.java index 9ad05ce56e2..23d794c93c3 100644 --- a/tests/robotests/src/com/android/settings/display/TopLevelDisplayPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/display/TopLevelDisplayPreferenceControllerTest.java @@ -17,12 +17,14 @@ package com.android.settings.display; import static com.android.settings.core.BasePreferenceController.AVAILABLE; +import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE; import static com.google.common.truth.Truth.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when; import android.content.Context; @@ -40,11 +42,13 @@ import org.mockito.MockitoAnnotations; import java.util.ArrayList; import java.util.List; + +import org.robolectric.annotation.Config; import org.robolectric.RobolectricTestRunner; +import org.robolectric.RuntimeEnvironment; @RunWith(RobolectricTestRunner.class) public class TopLevelDisplayPreferenceControllerTest { - @Mock private Context mContext; @Mock private PackageManager mPackageManager; @@ -54,6 +58,7 @@ public class TopLevelDisplayPreferenceControllerTest { @Before public void setUp() { MockitoAnnotations.initMocks(this); + mContext = spy(RuntimeEnvironment.application); when(mContext.getPackageManager()).thenReturn(mPackageManager); when(mContext.getString(R.string.config_wallpaper_picker_package)).thenReturn("pkg"); when(mContext.getString(R.string.config_wallpaper_picker_class)).thenReturn("cls"); @@ -62,10 +67,16 @@ public class TopLevelDisplayPreferenceControllerTest { } @Test - public void getAvailability_alwaysAvailable() { + public void getAvailibilityStatus_availableByDefault() { assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE); } + @Test + @Config(qualifiers = "mcc999") + public void getAvailabilityStatus_unsupportedWhenSet() { + assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE); + } + @Test public void getSummary_hasWallpaper_shouldReturnWallpaperSummary() { final List resolveInfos = new ArrayList<>(); diff --git a/tests/robotests/src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceControllerTest.java index e6efef7cc12..7568987da3a 100644 --- a/tests/robotests/src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceControllerTest.java @@ -16,6 +16,8 @@ package com.android.settings.fuelgauge; +import static com.android.settings.core.BasePreferenceController.AVAILABLE_UNSEARCHABLE; +import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE; import static com.android.settings.fuelgauge.TopLevelBatteryPreferenceController.getDashboardLabel; import static com.google.common.truth.Truth.assertThat; @@ -25,17 +27,30 @@ import android.content.Context; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; +import org.robolectric.annotation.Config; import org.robolectric.RobolectricTestRunner; import org.robolectric.RuntimeEnvironment; @RunWith(RobolectricTestRunner.class) public class TopLevelBatteryPreferenceControllerTest { - private Context mContext; + private TopLevelBatteryPreferenceController mController; @Before public void setUp() { mContext = RuntimeEnvironment.application; + mController = new TopLevelBatteryPreferenceController(mContext, "test_key"); + } + + @Test + public void getAvailibilityStatus_availableByDefault() { + assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE_UNSEARCHABLE); + } + + @Test + @Config(qualifiers = "mcc999") + public void getAvailabilityStatus_unsupportedWhenSet() { + assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE); } @Test From 9ed7cb40cb72d4f646e2d1ef7cd80ed5a80bfdde Mon Sep 17 00:00:00 2001 From: Kevin Chyn Date: Mon, 19 Nov 2018 12:22:25 -0800 Subject: [PATCH 05/14] Get enrollment animation from overlay Bug: 111548033 Test: Able to get animation from overlay Test: atest RunSettingsRoboTests Change-Id: Ib02f484474b306ba8d61f9be541acb12dd1ecd90 --- .../face/FaceEnrollAnimationDrawable.java | 25 +++++------ .../biometrics/face/FaceEnrollEnrolling.java | 2 +- .../face/FaceEnrollPreviewFragment.java | 8 ++-- .../biometrics/face/FaceFeatureProvider.java | 42 +++++++++++++++++++ .../face/FaceFeatureProviderImpl.java | 28 +++++++++++++ .../biometrics/face/ParticleCollection.java | 13 +++--- .../settings/overlay/FeatureFactory.java | 3 ++ .../settings/overlay/FeatureFactoryImpl.java | 12 ++++++ .../testutils/FakeFeatureFactory.java | 9 ++++ 9 files changed, 118 insertions(+), 24 deletions(-) create mode 100644 src/com/android/settings/biometrics/face/FaceFeatureProvider.java create mode 100644 src/com/android/settings/biometrics/face/FaceFeatureProviderImpl.java diff --git a/src/com/android/settings/biometrics/face/FaceEnrollAnimationDrawable.java b/src/com/android/settings/biometrics/face/FaceEnrollAnimationDrawable.java index 5be7c5331d3..b6ad565bad2 100644 --- a/src/com/android/settings/biometrics/face/FaceEnrollAnimationDrawable.java +++ b/src/com/android/settings/biometrics/face/FaceEnrollAnimationDrawable.java @@ -29,6 +29,7 @@ import android.graphics.Rect; import android.graphics.drawable.Drawable; import com.android.settings.biometrics.BiometricEnrollSidecar; +import com.android.settings.overlay.FeatureFactory; /** * A drawable containing the circle cutout as well as the animations. @@ -41,17 +42,17 @@ public class FaceEnrollAnimationDrawable extends Drawable private static final int BORDER_BOUNDS = 20; private final Context mContext; - private final ParticleCollection.Listener mListener; + private final FaceFeatureProvider.Listener mListener; private Rect mBounds; private final Paint mSquarePaint; private final Paint mCircleCutoutPaint; - private ParticleCollection mParticleCollection; + private FaceFeatureProvider.EnrollingAnimation mEnrollingAnimation; private TimeAnimator mTimeAnimator; - private final ParticleCollection.Listener mAnimationListener - = new ParticleCollection.Listener() { + private final FaceFeatureProvider.Listener mAnimationListener + = new FaceFeatureProvider.Listener() { @Override public void onEnrolled() { if (mTimeAnimator != null && mTimeAnimator.isStarted()) { @@ -61,7 +62,7 @@ public class FaceEnrollAnimationDrawable extends Drawable } }; - public FaceEnrollAnimationDrawable(Context context, ParticleCollection.Listener listener) { + public FaceEnrollAnimationDrawable(Context context, FaceFeatureProvider.Listener listener) { mContext = context; mListener = listener; @@ -77,29 +78,29 @@ public class FaceEnrollAnimationDrawable extends Drawable @Override public void onEnrollmentHelp(int helpMsgId, CharSequence helpString) { - mParticleCollection.onEnrollmentHelp(helpMsgId, helpString); + mEnrollingAnimation.onEnrollmentHelp(helpMsgId, helpString); } @Override public void onEnrollmentError(int errMsgId, CharSequence errString) { - mParticleCollection.onEnrollmentError(errMsgId, errString); + mEnrollingAnimation.onEnrollmentError(errMsgId, errString); } @Override public void onEnrollmentProgressChange(int steps, int remaining) { - mParticleCollection.onEnrollmentProgressChange(steps, remaining); + mEnrollingAnimation.onEnrollmentProgressChange(steps, remaining); } @Override protected void onBoundsChange(Rect bounds) { mBounds = bounds; - mParticleCollection = - new ParticleCollection(mContext, mAnimationListener, bounds, BORDER_BOUNDS); + mEnrollingAnimation = FeatureFactory.getFactory(mContext).getFaceFeatureProvider() + .getEnrollingAnimation(mContext, mAnimationListener, bounds, BORDER_BOUNDS); if (mTimeAnimator == null) { mTimeAnimator = new TimeAnimator(); mTimeAnimator.setTimeListener((animation, totalTimeMs, deltaTimeMs) -> { - mParticleCollection.update(totalTimeMs, deltaTimeMs); + mEnrollingAnimation.update(totalTimeMs, deltaTimeMs); FaceEnrollAnimationDrawable.this.invalidateSelf(); }); mTimeAnimator.start(); @@ -121,7 +122,7 @@ public class FaceEnrollAnimationDrawable extends Drawable mBounds.height() / 2 - BORDER_BOUNDS, mCircleCutoutPaint); // Draw the animation - mParticleCollection.draw(canvas); + mEnrollingAnimation.draw(canvas); canvas.restore(); } diff --git a/src/com/android/settings/biometrics/face/FaceEnrollEnrolling.java b/src/com/android/settings/biometrics/face/FaceEnrollEnrolling.java index 37b949c7709..727d74ac93b 100644 --- a/src/com/android/settings/biometrics/face/FaceEnrollEnrolling.java +++ b/src/com/android/settings/biometrics/face/FaceEnrollEnrolling.java @@ -47,7 +47,7 @@ public class FaceEnrollEnrolling extends BiometricsEnrollEnrolling { private boolean mShouldFinishOnStop = true; private FaceEnrollPreviewFragment mPreviewFragment; - private ParticleCollection.Listener mListener = new ParticleCollection.Listener() { + private FaceFeatureProvider.Listener mListener = new FaceFeatureProvider.Listener() { @Override public void onEnrolled() { FaceEnrollEnrolling.this.launchFinish(mToken); diff --git a/src/com/android/settings/biometrics/face/FaceEnrollPreviewFragment.java b/src/com/android/settings/biometrics/face/FaceEnrollPreviewFragment.java index a5435845c06..a3708751cf4 100644 --- a/src/com/android/settings/biometrics/face/FaceEnrollPreviewFragment.java +++ b/src/com/android/settings/biometrics/face/FaceEnrollPreviewFragment.java @@ -63,7 +63,7 @@ public class FaceEnrollPreviewFragment extends InstrumentedPreferenceFragment private CameraCaptureSession mCaptureSession; private CaptureRequest mPreviewRequest; private Size mPreviewSize; - private ParticleCollection.Listener mListener; + private FaceFeatureProvider.Listener mListener; // View used to contain the circular cutout and enrollment animation drawable private ImageView mCircleView; @@ -75,8 +75,8 @@ public class FaceEnrollPreviewFragment extends InstrumentedPreferenceFragment private FaceSquareTextureView mTextureView; // Listener sent to the animation drawable - private final ParticleCollection.Listener mAnimationListener - = new ParticleCollection.Listener() { + private final FaceFeatureProvider.Listener mAnimationListener + = new FaceFeatureProvider.Listener() { @Override public void onEnrolled() { mListener.onEnrolled(); @@ -234,7 +234,7 @@ public class FaceEnrollPreviewFragment extends InstrumentedPreferenceFragment mAnimationDrawable.onEnrollmentProgressChange(steps, remaining); } - public void setListener(ParticleCollection.Listener listener) { + public void setListener(FaceFeatureProvider.Listener listener) { mListener = listener; } diff --git a/src/com/android/settings/biometrics/face/FaceFeatureProvider.java b/src/com/android/settings/biometrics/face/FaceFeatureProvider.java new file mode 100644 index 00000000000..e2f62d3a9af --- /dev/null +++ b/src/com/android/settings/biometrics/face/FaceFeatureProvider.java @@ -0,0 +1,42 @@ +/* + * 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.biometrics.face; + +import android.content.Context; +import android.graphics.Canvas; +import android.graphics.Rect; + +/** + * Feature provider for face authentication. + */ +public interface FaceFeatureProvider { + + interface EnrollingAnimation { + void onEnrollmentHelp(int helpMsgId, CharSequence helpString); + void onEnrollmentError(int errMsgId, CharSequence errString); + void onEnrollmentProgressChange(int steps, int remaining); + void draw(Canvas canvas); + void update(long t, long dt); + } + + interface Listener { + void onEnrolled(); + } + + EnrollingAnimation getEnrollingAnimation(Context context, Listener listener, Rect bounds, + int borderWidth); +} diff --git a/src/com/android/settings/biometrics/face/FaceFeatureProviderImpl.java b/src/com/android/settings/biometrics/face/FaceFeatureProviderImpl.java new file mode 100644 index 00000000000..3f656696afa --- /dev/null +++ b/src/com/android/settings/biometrics/face/FaceFeatureProviderImpl.java @@ -0,0 +1,28 @@ +/* + * 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.biometrics.face; + +import android.content.Context; +import android.graphics.Rect; + +public class FaceFeatureProviderImpl implements FaceFeatureProvider { + @Override + public EnrollingAnimation getEnrollingAnimation(Context context, Listener listener, Rect bounds, + int borderWidth) { + return new ParticleCollection(context, listener, bounds, borderWidth); + } +} diff --git a/src/com/android/settings/biometrics/face/ParticleCollection.java b/src/com/android/settings/biometrics/face/ParticleCollection.java index 399beec3abd..b345ab5f945 100644 --- a/src/com/android/settings/biometrics/face/ParticleCollection.java +++ b/src/com/android/settings/biometrics/face/ParticleCollection.java @@ -35,7 +35,7 @@ import java.util.List; * are updated/drawn in a special order so that the overlap is correct during the final completion * effect. */ -public class ParticleCollection implements BiometricEnrollSidecar.Listener { +public class ParticleCollection implements FaceFeatureProviderImpl.EnrollingAnimation { private static final String TAG = "AnimationController"; @@ -49,11 +49,7 @@ public class ParticleCollection implements BiometricEnrollSidecar.Listener { private final List mParticleList; private final List mPrimariesInProgress; // primary particles not done animating yet private int mState; - private Listener mListener; - - public interface Listener { - void onEnrolled(); - } + private FaceFeatureProvider.Listener mListener; private final AnimationParticle.Listener mParticleListener = new AnimationParticle.Listener() { @Override @@ -72,7 +68,8 @@ public class ParticleCollection implements BiometricEnrollSidecar.Listener { } }; - public ParticleCollection(Context context, Listener listener, Rect bounds, int borderWidth) { + public ParticleCollection(Context context, FaceFeatureProvider.Listener listener, Rect bounds, + int borderWidth) { mParticleList = new ArrayList<>(); mListener = listener; @@ -103,12 +100,14 @@ public class ParticleCollection implements BiometricEnrollSidecar.Listener { updateState(STATE_STARTED); } + @Override public void update(long t, long dt) { for (int i = 0; i < mParticleList.size(); i++) { mParticleList.get(i).update(t, dt); } } + @Override public void draw(Canvas canvas) { for (int i = 0; i < mParticleList.size(); i++) { mParticleList.get(i).draw(canvas); diff --git a/src/com/android/settings/overlay/FeatureFactory.java b/src/com/android/settings/overlay/FeatureFactory.java index a52619b3a6f..184ccc8b7ab 100644 --- a/src/com/android/settings/overlay/FeatureFactory.java +++ b/src/com/android/settings/overlay/FeatureFactory.java @@ -23,6 +23,7 @@ import android.util.Log; import com.android.settings.R; import com.android.settings.accounts.AccountFeatureProvider; import com.android.settings.applications.ApplicationFeatureProvider; +import com.android.settings.biometrics.face.FaceFeatureProvider; import com.android.settings.dashboard.DashboardFeatureProvider; import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider; import com.android.settings.enterprise.EnterprisePrivacyFeatureProvider; @@ -111,6 +112,8 @@ public abstract class FeatureFactory { public abstract ContextualCardFeatureProvider getContextualCardFeatureProvider(); + public abstract FaceFeatureProvider getFaceFeatureProvider(); + public static final class FactoryNotFoundException extends RuntimeException { public FactoryNotFoundException(Throwable throwable) { super("Unable to create factory. Did you misconfigure Proguard?", throwable); diff --git a/src/com/android/settings/overlay/FeatureFactoryImpl.java b/src/com/android/settings/overlay/FeatureFactoryImpl.java index 3515ac06a48..88c09d036a2 100644 --- a/src/com/android/settings/overlay/FeatureFactoryImpl.java +++ b/src/com/android/settings/overlay/FeatureFactoryImpl.java @@ -28,6 +28,8 @@ import com.android.settings.accounts.AccountFeatureProvider; import com.android.settings.accounts.AccountFeatureProviderImpl; import com.android.settings.applications.ApplicationFeatureProvider; import com.android.settings.applications.ApplicationFeatureProviderImpl; +import com.android.settings.biometrics.face.FaceFeatureProvider; +import com.android.settings.biometrics.face.FaceFeatureProviderImpl; import com.android.settings.connecteddevice.dock.DockUpdaterFeatureProviderImpl; import com.android.settings.core.instrumentation.SettingsMetricsFeatureProvider; import com.android.settings.dashboard.DashboardFeatureProvider; @@ -78,6 +80,7 @@ public class FeatureFactoryImpl extends FeatureFactory { private AccountFeatureProvider mAccountFeatureProvider; private PanelFeatureProvider mPanelFeatureProvider; private ContextualCardFeatureProvider mContextualCardFeatureProvider; + private FaceFeatureProvider mFaceFeatureProvider; @Override public SupportFeatureProvider getSupportFeatureProvider(Context context) { @@ -224,10 +227,19 @@ public class FeatureFactoryImpl extends FeatureFactory { return mPanelFeatureProvider; } + @Override public ContextualCardFeatureProvider getContextualCardFeatureProvider() { if (mContextualCardFeatureProvider == null) { mContextualCardFeatureProvider = new ContextualCardFeatureProviderImpl(); } return mContextualCardFeatureProvider; } + + @Override + public FaceFeatureProvider getFaceFeatureProvider() { + if (mFaceFeatureProvider == null) { + mFaceFeatureProvider = new FaceFeatureProviderImpl(); + } + return mFaceFeatureProvider; + } } diff --git a/tests/robotests/src/com/android/settings/testutils/FakeFeatureFactory.java b/tests/robotests/src/com/android/settings/testutils/FakeFeatureFactory.java index ef07fd4a880..e0b8646df25 100644 --- a/tests/robotests/src/com/android/settings/testutils/FakeFeatureFactory.java +++ b/tests/robotests/src/com/android/settings/testutils/FakeFeatureFactory.java @@ -23,6 +23,7 @@ import android.content.Context; import com.android.settings.accounts.AccountFeatureProvider; import com.android.settings.applications.ApplicationFeatureProvider; +import com.android.settings.biometrics.face.FaceFeatureProvider; import com.android.settings.dashboard.DashboardFeatureProvider; import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider; import com.android.settings.enterprise.EnterprisePrivacyFeatureProvider; @@ -64,6 +65,7 @@ public class FakeFeatureFactory extends FeatureFactory { public final AssistGestureFeatureProvider assistGestureFeatureProvider; public final AccountFeatureProvider mAccountFeatureProvider; public final ContextualCardFeatureProvider mContextualCardFeatureProvider; + public final FaceFeatureProvider mFaceFeatureProvider; public PanelFeatureProvider panelFeatureProvider; public SlicesFeatureProvider slicesFeatureProvider; @@ -108,6 +110,7 @@ public class FakeFeatureFactory extends FeatureFactory { mAccountFeatureProvider = mock(AccountFeatureProvider.class); mContextualCardFeatureProvider = mock(ContextualCardFeatureProvider.class); panelFeatureProvider = mock(PanelFeatureProvider.class); + mFaceFeatureProvider = mock(FaceFeatureProvider.class); } @Override @@ -195,7 +198,13 @@ public class FakeFeatureFactory extends FeatureFactory { return panelFeatureProvider; } + @Override public ContextualCardFeatureProvider getContextualCardFeatureProvider() { return mContextualCardFeatureProvider; } + + @Override + public FaceFeatureProvider getFaceFeatureProvider() { + return mFaceFeatureProvider; + } } From ebbb0bc56355abbeff26fa6ef1305d8e4d6957a8 Mon Sep 17 00:00:00 2001 From: Johnson Lu Date: Sat, 15 Dec 2018 11:50:46 +0800 Subject: [PATCH 06/14] Adjust camera preview area to square 1.Choose the smaller size of both dimensions as its size. 2.Set transform matrix to crop and center the preview picture. Bug: 118797380 Test: make RunSettingsRoboTests Change-Id: Ic65fb1fe0c5082995d6903f50dda48eec16c3fb1 --- .../wifi_dpp_qrcode_scanner_fragment.xml | 19 +++--- .../wifi_dpp_qrcode_scanner_fragment.xml | 16 ++--- .../wifi/dpp/WifiDppQrCodeBaseFragment.java | 13 ---- .../dpp/WifiDppQrCodeScannerFragment.java | 49 ++++++++------- .../settings/wifi/qrcode/QrCamera.java | 63 +++++++++++++++---- .../settings/wifi/qrcode/QrPreviewLayout.java | 50 +++++++++++++++ .../settings/wifi/qrcode/QrCameraTest.java | 15 +++-- 7 files changed, 155 insertions(+), 70 deletions(-) create mode 100644 src/com/android/settings/wifi/qrcode/QrPreviewLayout.java diff --git a/res/layout-land/wifi_dpp_qrcode_scanner_fragment.xml b/res/layout-land/wifi_dpp_qrcode_scanner_fragment.xml index 0c938f82ede..fb50def7649 100644 --- a/res/layout-land/wifi_dpp_qrcode_scanner_fragment.xml +++ b/res/layout-land/wifi_dpp_qrcode_scanner_fragment.xml @@ -24,20 +24,19 @@ - - + + android:layout_width="wrap_content" + android:layout_height="match_parent"/> - + android:layout_width="wrap_content" + android:layout_height="match_parent"/> + - - + - + { private QrYuvLuminanceSource mImage; - private SurfaceHolder mSurfaceHolder; + private SurfaceTexture mSurface; - private DecodingTask(SurfaceHolder surfaceHolder) { - mSurfaceHolder = surfaceHolder; + private DecodingTask(SurfaceTexture surface) { + mSurface = surface; } @Override protected String doInBackground(Void... tmp) { - if (!initCamera(mSurfaceHolder)) { + if (!initCamera(mSurface)) { return null; } @@ -253,7 +261,7 @@ public class QrCamera extends Handler { } } - private boolean initCamera(SurfaceHolder surfaceHolder) { + private boolean initCamera(SurfaceTexture surface) { final int numberOfCameras = Camera.getNumberOfCameras(); Camera.CameraInfo cameraInfo = new Camera.CameraInfo(); try { @@ -261,7 +269,7 @@ public class QrCamera extends Handler { Camera.getCameraInfo(i, cameraInfo); if (cameraInfo.facing == CameraInfo.CAMERA_FACING_BACK) { mCamera = Camera.open(i); - mCamera.setPreviewDisplay(surfaceHolder); + mCamera.setPreviewTexture(surface); mCameraOrientation = cameraInfo.orientation; break; } @@ -272,6 +280,7 @@ public class QrCamera extends Handler { return false; } setCameraParameter(); + setTransformationMatrix(mScannerCallback.getViewSize()); if (!startPreview()) { Log.e(TAG, "Error to init Camera"); mCamera = null; @@ -288,6 +297,36 @@ public class QrCamera extends Handler { } } + /** Set transfom matrix to crop and center the preview picture */ + private void setTransformationMatrix(Size viewSize) { + // Check aspect ratio, can only handle square view. + final int viewRatio = (int)getRatio(viewSize.getWidth(), viewSize.getHeight()); + if (viewRatio != 1) { + throw new IllegalArgumentException("Preview area should be square"); + } + + final boolean isPortrait = mContext.get().getResources().getConfiguration().orientation + == Configuration.ORIENTATION_PORTRAIT ? true : false; + + final int previewWidth = isPortrait ? mPreviewSize.getWidth() : mPreviewSize.getHeight(); + final int previewHeight = isPortrait ? mPreviewSize.getHeight() : mPreviewSize.getWidth(); + final float ratioPreview = (float) getRatio(previewWidth, previewHeight); + + // Calculate transformation matrix. + float scaleX = 1.0f; + float scaleY = 1.0f; + if (previewWidth > previewHeight) { + scaleY = scaleX / ratioPreview; + } else { + scaleX = scaleY / ratioPreview; + } + + // Set the transform matrix. + final Matrix matrix = new Matrix(); + matrix.setScale(scaleX, scaleY); + mScannerCallback.setTransform(matrix); + } + private QrYuvLuminanceSource getFrameImage(byte[] imageData) { final Rect frame = mScannerCallback.getFramePosition(mPreviewSize, mCameraOrientation); final Camera.Size size = mParameters.getPictureSize(); diff --git a/src/com/android/settings/wifi/qrcode/QrPreviewLayout.java b/src/com/android/settings/wifi/qrcode/QrPreviewLayout.java new file mode 100644 index 00000000000..56566aeefb6 --- /dev/null +++ b/src/com/android/settings/wifi/qrcode/QrPreviewLayout.java @@ -0,0 +1,50 @@ +/* + * 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.wifi.qrcode; + +import android.content.Context; +import android.util.AttributeSet; +import android.util.Log; +import android.widget.FrameLayout; + +/** + * A customize square {@link FrameLayout}. + * This is used for camera preview. Choose the smaller size of both dimensions as length and width. + */ +public class QrPreviewLayout extends FrameLayout { + public QrPreviewLayout(Context context) { + super(context); + } + + public QrPreviewLayout(Context context, AttributeSet attrs) { + super(context, attrs); + } + + public QrPreviewLayout(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + } + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + // Choose the smaller size of the two dimensions. + if (MeasureSpec.getSize(widthMeasureSpec) > MeasureSpec.getSize(heightMeasureSpec)) { + super.onMeasure(heightMeasureSpec, heightMeasureSpec); + } else { + super.onMeasure(widthMeasureSpec, widthMeasureSpec); + } + } +} diff --git a/tests/robotests/src/com/android/settings/wifi/qrcode/QrCameraTest.java b/tests/robotests/src/com/android/settings/wifi/qrcode/QrCameraTest.java index e32ac6b5a8b..0ef02737007 100644 --- a/tests/robotests/src/com/android/settings/wifi/qrcode/QrCameraTest.java +++ b/tests/robotests/src/com/android/settings/wifi/qrcode/QrCameraTest.java @@ -22,9 +22,11 @@ import static org.mockito.Mockito.mock; import android.content.Context; import android.graphics.Bitmap; +import android.graphics.Color; +import android.graphics.Matrix; import android.graphics.Rect; +import android.graphics.SurfaceTexture; import android.util.Size; -import android.view.SurfaceHolder; import com.android.settings.R; @@ -48,7 +50,7 @@ import org.robolectric.RuntimeEnvironment; public class QrCameraTest { @Mock - private SurfaceHolder mSurfaceHolder; + private SurfaceTexture mSurfaceTexture; private QrCamera mCamera; private Context mContext; @@ -78,6 +80,11 @@ public class QrCameraTest { mCameraCallbacked = true; mCallbackSignal.countDown(); } + + @Override + public void setTransform(Matrix transform) { + // Do nothing + } } private ScannerTestCallback mScannerCallback; @@ -87,7 +94,7 @@ public class QrCameraTest { mContext = RuntimeEnvironment.application; mScannerCallback = new ScannerTestCallback(); mCamera = new QrCamera(mContext, mScannerCallback); - mSurfaceHolder = mock(SurfaceHolder.class); + mSurfaceTexture = mock(SurfaceTexture.class); mQrCode = ""; mCameraCallbacked = false; mCallbackSignal = null; @@ -96,7 +103,7 @@ public class QrCameraTest { @Test public void testCamera_Init_Callback() throws InterruptedException { mCallbackSignal = new CountDownLatch(1); - mCamera.start(mSurfaceHolder); + mCamera.start(mSurfaceTexture); mCallbackSignal.await(5000, TimeUnit.MILLISECONDS); assertThat(mCameraCallbacked).isTrue(); } From 6c403a876dd2051081143a1c866bc1d0eb53ade9 Mon Sep 17 00:00:00 2001 From: Sunny Shao Date: Fri, 14 Dec 2018 11:17:07 +0800 Subject: [PATCH 07/14] Add the contentDescription on avatar icon Add the talkback saying wordings on avatar icon of the search bar. Change-Id: I7e41d8bf842c0efae5440520586e88dd746802e7 Fixes: 120097338 Test: manual --- res/layout/search_bar.xml | 3 ++- res/values/strings.xml | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/res/layout/search_bar.xml b/res/layout/search_bar.xml index be8aa3b8819..fe2f270d109 100644 --- a/res/layout/search_bar.xml +++ b/res/layout/search_bar.xml @@ -43,5 +43,6 @@ android:layout_marginEnd="@dimen/search_bar_avatar_end_margin" android:layout_width="@dimen/search_bar_avatar_size" android:layout_height="@dimen/search_bar_avatar_size" - android:layout_gravity="end|center_vertical"/> + android:layout_gravity="end|center_vertical" + android:contentDescription="@string/search_bar_account_avatar_content_description"/> diff --git a/res/values/strings.xml b/res/values/strings.xml index 23adc768536..d042ebcb5ba 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -10346,4 +10346,8 @@ %1$s copied to clipboard. + + + + From e519cd6e681cbdddec8a6aed248d876e9afaf08d Mon Sep 17 00:00:00 2001 From: Josh Hou Date: Fri, 23 Nov 2018 09:57:20 +0800 Subject: [PATCH 08/14] Refine APN fetching logic APN fetching logic has been encapsulated in URL_SIM_APN_LIST API in TelephonyProvider Bug: 115709816 Test: Live network test Change-Id: I735bc50e912dfbec0903fbcafdc4d6eaa6ccfc7b Merged-In: I735bc50e912dfbec0903fbcafdc4d6eaa6ccfc7b --- .../android/settings/network/ApnSettings.java | 71 +++++-------------- 1 file changed, 19 insertions(+), 52 deletions(-) diff --git a/src/com/android/settings/network/ApnSettings.java b/src/com/android/settings/network/ApnSettings.java index 3b39e383ddc..1c02b0eb2cc 100755 --- a/src/com/android/settings/network/ApnSettings.java +++ b/src/com/android/settings/network/ApnSettings.java @@ -42,7 +42,6 @@ import android.telephony.CarrierConfigManager; import android.telephony.SubscriptionInfo; import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; -import android.telephony.data.ApnSetting; import android.text.TextUtils; import android.util.Log; import android.view.Menu; @@ -54,8 +53,6 @@ import android.widget.Toast; import com.android.internal.logging.nano.MetricsProto.MetricsEvent; import com.android.internal.telephony.PhoneConstants; import com.android.internal.telephony.TelephonyIntents; -import com.android.internal.telephony.dataconnection.ApnSettingUtils; -import com.android.internal.telephony.uicc.IccRecords; import com.android.internal.telephony.uicc.UiccController; import com.android.settings.R; import com.android.settings.RestrictedSettingsFragment; @@ -277,34 +274,27 @@ public class ApnSettings extends RestrictedSettingsFragment { } private void fillList() { - final TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); final int subId = mSubscriptionInfo != null ? mSubscriptionInfo.getSubscriptionId() : SubscriptionManager.INVALID_SUBSCRIPTION_ID; - final String mccmnc = mSubscriptionInfo == null ? "" : tm.getSimOperator(subId); - Log.d(TAG, "mccmnc = " + mccmnc); - StringBuilder where = new StringBuilder("numeric=\"" + mccmnc + - "\" AND NOT (type='ia' AND (apn=\"\" OR apn IS NULL)) AND user_visible!=0"); + final Uri simApnUri = Uri.withAppendedPath(Telephony.Carriers.SIM_APN_LIST, + String.valueOf(subId)); + StringBuilder where = new StringBuilder("NOT (type='ia' AND (apn=\"\" OR apn IS NULL)) AND " + + "user_visible!=0"); if (mHideImsApn) { where.append(" AND NOT (type='ims')"); } - Cursor cursor = getContentResolver().query(Telephony.Carriers.CONTENT_URI, - CARRIERS_PROJECTION, where.toString(), null, Telephony.Carriers.DEFAULT_SORT_ORDER); + Cursor cursor = getContentResolver().query(simApnUri, + CARRIERS_PROJECTION, where.toString(), null, + Telephony.Carriers.DEFAULT_SORT_ORDER); if (cursor != null) { - IccRecords r = null; - if (mUiccController != null && mSubscriptionInfo != null) { - r = mUiccController.getIccRecords( - SubscriptionManager.getPhoneId(subId), UiccController.APP_FAM_3GPP); - } - PreferenceGroup apnList = (PreferenceGroup) findPreference("apn_list"); - apnList.removeAll(); + PreferenceGroup apnPrefList = (PreferenceGroup) findPreference("apn_list"); + apnPrefList.removeAll(); - ArrayList mnoApnList = new ArrayList(); - ArrayList mvnoApnList = new ArrayList(); - ArrayList mnoMmsApnList = new ArrayList(); - ArrayList mvnoMmsApnList = new ArrayList(); + ArrayList apnList = new ArrayList(); + ArrayList mmsApnList = new ArrayList(); mSelectedKey = getSelectedApnKey(); cursor.moveToFirst(); @@ -313,9 +303,9 @@ public class ApnSettings extends RestrictedSettingsFragment { String apn = cursor.getString(APN_INDEX); String key = cursor.getString(ID_INDEX); String type = cursor.getString(TYPES_INDEX); - String mvnoType = cursor.getString(MVNO_TYPE_INDEX); - String mvnoMatchData = cursor.getString(MVNO_MATCH_DATA_INDEX); int edited = cursor.getInt(EDITED_INDEX); + mMvnoType = cursor.getString(MVNO_TYPE_INDEX); + mMvnoMatchData = cursor.getString(MVNO_MATCH_DATA_INDEX); ApnPreference pref = new ApnPreference(getPrefContext()); @@ -335,43 +325,20 @@ public class ApnSettings extends RestrictedSettingsFragment { if ((mSelectedKey != null) && mSelectedKey.equals(key)) { pref.setChecked(); } - addApnToList(pref, mnoApnList, mvnoApnList, r, mvnoType, mvnoMatchData); + apnList.add(pref); } else { - addApnToList(pref, mnoMmsApnList, mvnoMmsApnList, r, mvnoType, mvnoMatchData); + mmsApnList.add(pref); } cursor.moveToNext(); } cursor.close(); - if (!mvnoApnList.isEmpty()) { - mnoApnList = mvnoApnList; - mnoMmsApnList = mvnoMmsApnList; - - // Also save the mvno info + for (Preference preference : apnList) { + apnPrefList.addPreference(preference); } - - for (Preference preference : mnoApnList) { - apnList.addPreference(preference); + for (Preference preference : mmsApnList) { + apnPrefList.addPreference(preference); } - for (Preference preference : mnoMmsApnList) { - apnList.addPreference(preference); - } - } - } - - private void addApnToList(ApnPreference pref, ArrayList mnoList, - ArrayList mvnoList, IccRecords r, String mvnoType, - String mvnoMatchData) { - if (r != null && !TextUtils.isEmpty(mvnoType) && !TextUtils.isEmpty(mvnoMatchData)) { - if (ApnSettingUtils.mvnoMatches(r, ApnSetting.getMvnoTypeIntFromString(mvnoType), - mvnoMatchData)) { - mvnoList.add(pref); - // Since adding to mvno list, save mvno info - mMvnoType = mvnoType; - mMvnoMatchData = mvnoMatchData; - } - } else { - mnoList.add(pref); } } From 7aa7ece7a2a98dec63c76f8c501b221c42eb8034 Mon Sep 17 00:00:00 2001 From: Jason Chiu Date: Mon, 17 Dec 2018 15:56:56 +0800 Subject: [PATCH 09/14] Fix build failed of Settings test cases while importing AndroidX - API change in AndroidX Preference causes a build breakage - Apply explicit casting for the new API interface Test: robotest Fixes: 121109361 Change-Id: If3e7be9e53c7860252523700d6721ae4956db68a --- .../AvailableMediaDeviceGroupControllerTest.java | 3 ++- .../ConnectedDeviceGroupControllerTest.java | 3 ++- .../usb/UsbDetailsPowerRoleControllerTest.java | 8 +++++--- .../deviceinfo/BuildNumberPreferenceControllerTest.java | 2 +- .../notification/WorkSoundPreferenceControllerTest.java | 9 +++++---- 5 files changed, 15 insertions(+), 10 deletions(-) diff --git a/tests/robotests/src/com/android/settings/connecteddevice/AvailableMediaDeviceGroupControllerTest.java b/tests/robotests/src/com/android/settings/connecteddevice/AvailableMediaDeviceGroupControllerTest.java index 8470ef9c252..c4b5901d97c 100644 --- a/tests/robotests/src/com/android/settings/connecteddevice/AvailableMediaDeviceGroupControllerTest.java +++ b/tests/robotests/src/com/android/settings/connecteddevice/AvailableMediaDeviceGroupControllerTest.java @@ -119,7 +119,8 @@ public class AvailableMediaDeviceGroupControllerTest { mAvailableMediaDeviceGroupController.onDeviceAdded(mPreference); assertThat(mPreferenceGroup.isVisible()).isTrue(); - assertThat(mPreferenceGroup.findPreference(PREFERENCE_KEY_1)).isEqualTo(mPreference); + assertThat((Preference) mPreferenceGroup.findPreference(PREFERENCE_KEY_1)) + .isEqualTo(mPreference); } @Test diff --git a/tests/robotests/src/com/android/settings/connecteddevice/ConnectedDeviceGroupControllerTest.java b/tests/robotests/src/com/android/settings/connecteddevice/ConnectedDeviceGroupControllerTest.java index c9e2644b1b3..23754a05d36 100644 --- a/tests/robotests/src/com/android/settings/connecteddevice/ConnectedDeviceGroupControllerTest.java +++ b/tests/robotests/src/com/android/settings/connecteddevice/ConnectedDeviceGroupControllerTest.java @@ -100,7 +100,8 @@ public class ConnectedDeviceGroupControllerTest { mConnectedDeviceGroupController.onDeviceAdded(mPreference); assertThat(mPreferenceGroup.isVisible()).isTrue(); - assertThat(mPreferenceGroup.findPreference(PREFERENCE_KEY_1)).isEqualTo(mPreference); + assertThat((Preference) mPreferenceGroup.findPreference(PREFERENCE_KEY_1)) + .isEqualTo(mPreference); } @Test diff --git a/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbDetailsPowerRoleControllerTest.java b/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbDetailsPowerRoleControllerTest.java index 38c92c3a2d9..b16a4536321 100644 --- a/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbDetailsPowerRoleControllerTest.java +++ b/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbDetailsPowerRoleControllerTest.java @@ -29,6 +29,7 @@ import android.hardware.usb.UsbPort; import android.os.Handler; import androidx.fragment.app.FragmentActivity; +import androidx.preference.Preference; import androidx.preference.PreferenceCategory; import androidx.preference.PreferenceManager; import androidx.preference.PreferenceScreen; @@ -122,8 +123,8 @@ public class UsbDetailsPowerRoleControllerTest { UsbPort.POWER_ROLE_SINK, UsbPort.DATA_ROLE_DEVICE); assertThat(mPreference.isEnabled()).isFalse(); - assertThat(mScreen.findPreference(mDetailsPowerRoleController.getPreferenceKey())) - .isEqualTo(mPreference); + assertThat((Preference) mScreen.findPreference( + mDetailsPowerRoleController.getPreferenceKey())).isEqualTo(mPreference); } @Test @@ -134,7 +135,8 @@ public class UsbDetailsPowerRoleControllerTest { mDetailsPowerRoleController.refresh(true, UsbManager.FUNCTION_NONE, UsbPort.POWER_ROLE_SINK, UsbPort.DATA_ROLE_DEVICE); - assertThat(mScreen.findPreference(mDetailsPowerRoleController.getPreferenceKey())).isNull(); + assertThat((Preference) mScreen.findPreference( + mDetailsPowerRoleController.getPreferenceKey())).isNull(); } @Test diff --git a/tests/robotests/src/com/android/settings/deviceinfo/BuildNumberPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/BuildNumberPreferenceControllerTest.java index fb674abb0a0..5fb17470c6e 100644 --- a/tests/robotests/src/com/android/settings/deviceinfo/BuildNumberPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/deviceinfo/BuildNumberPreferenceControllerTest.java @@ -105,7 +105,7 @@ public class BuildNumberPreferenceControllerTest { public void displayPref_shouldAlwaysDisplay() { mController.displayPreference(mScreen); - verify(mScreen.findPreference(mController.getPreferenceKey())) + verify((Preference) mScreen.findPreference(mController.getPreferenceKey())) .setSummary(BidiFormatter.getInstance().unicodeWrap(Build.DISPLAY)); verify(mScreen, never()).removePreference(any(Preference.class)); } diff --git a/tests/robotests/src/com/android/settings/notification/WorkSoundPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/WorkSoundPreferenceControllerTest.java index d6a594a72b8..fb4747c7fe7 100644 --- a/tests/robotests/src/com/android/settings/notification/WorkSoundPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/notification/WorkSoundPreferenceControllerTest.java @@ -218,7 +218,8 @@ public class WorkSoundPreferenceControllerTest { mController.displayPreference(mScreen); mController.onResume(); - verify(mWorkCategory.findPreference(KEY_WORK_PHONE_RINGTONE)).setVisible(false); + verify((Preference) mWorkCategory.findPreference(KEY_WORK_PHONE_RINGTONE)) + .setVisible(false); } @Test @@ -242,11 +243,11 @@ public class WorkSoundPreferenceControllerTest { verify(mWorkCategory, times(2)).setVisible(true); // Sound preferences should explain that the profile isn't available yet. - verify(mWorkCategory.findPreference(KEY_WORK_PHONE_RINGTONE)) + verify((Preference) mWorkCategory.findPreference(KEY_WORK_PHONE_RINGTONE)) .setSummary(eq(notAvailable)); - verify(mWorkCategory.findPreference(KEY_WORK_NOTIFICATION_RINGTONE)) + verify((Preference) mWorkCategory.findPreference(KEY_WORK_NOTIFICATION_RINGTONE)) .setSummary(eq(notAvailable)); - verify(mWorkCategory.findPreference(KEY_WORK_ALARM_RINGTONE)) + verify((Preference) mWorkCategory.findPreference(KEY_WORK_ALARM_RINGTONE)) .setSummary(eq(notAvailable)); } From 93d4993556ef0a25b17e75cbcb34e7b23964e34e Mon Sep 17 00:00:00 2001 From: Jason Chiu Date: Fri, 14 Dec 2018 18:43:47 +0800 Subject: [PATCH 10/14] Micro cleanup and refactoring - organize import - remove unused code in ContextualCardLoaderTest - refactor CardDatabaseHelper Test: robotest Change-Id: I1a5a49bee1c4edb34f1c59f3dbe37cb22f01b0d4 --- src/com/android/settings/DateTimeSettings.java | 1 - .../contextualcards/CardDatabaseHelper.java | 5 ++--- .../ContextualCardLoaderTest.java | 16 +++++----------- 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/src/com/android/settings/DateTimeSettings.java b/src/com/android/settings/DateTimeSettings.java index 149deb15282..05dd265891e 100644 --- a/src/com/android/settings/DateTimeSettings.java +++ b/src/com/android/settings/DateTimeSettings.java @@ -20,7 +20,6 @@ import android.app.Activity; import android.app.Dialog; import android.content.Context; import android.content.Intent; -import android.os.UserManager; import android.provider.SearchIndexableResource; import com.android.internal.logging.nano.MetricsProto.MetricsEvent; diff --git a/src/com/android/settings/homepage/contextualcards/CardDatabaseHelper.java b/src/com/android/settings/homepage/contextualcards/CardDatabaseHelper.java index 164afdd7d68..b9bab21386b 100644 --- a/src/com/android/settings/homepage/contextualcards/CardDatabaseHelper.java +++ b/src/com/android/settings/homepage/contextualcards/CardDatabaseHelper.java @@ -197,12 +197,11 @@ public class CardDatabaseHelper extends SQLiteOpenHelper { } Cursor getContextualCards() { - final SQLiteDatabase db = this.getReadableDatabase(); + final SQLiteDatabase db = getReadableDatabase(); final String selection = CardColumns.CARD_DISMISSED + "=0"; - Cursor cursor = db.query(CARD_TABLE, null /* columns */, selection, + return db.query(CARD_TABLE, null /* columns */, selection, null /* selectionArgs */, null /* groupBy */, null /* having */, CardColumns.SCORE + " DESC" /* orderBy */); - return cursor; } /** diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardLoaderTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardLoaderTest.java index d86b9a31800..101ca75ec2d 100644 --- a/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardLoaderTest.java +++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardLoaderTest.java @@ -28,33 +28,27 @@ import android.content.Context; import android.net.Uri; import com.android.settings.slices.CustomSliceRegistry; -import com.android.settings.slices.SettingsSliceProvider; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.RobolectricTestRunner; import org.robolectric.RuntimeEnvironment; -import org.robolectric.shadows.ShadowContentResolver; - -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Collectors; @RunWith(RobolectricTestRunner.class) public class ContextualCardLoaderTest { private Context mContext; private ContextualCardLoader mContextualCardLoader; - private SettingsSliceProvider mProvider; @Before public void setUp() { mContext = RuntimeEnvironment.application; mContextualCardLoader = spy(new ContextualCardLoader(mContext)); - mProvider = new SettingsSliceProvider(); - ShadowContentResolver.registerProviderInternal(SettingsSliceProvider.SLICE_AUTHORITY, - mProvider); } @Test @@ -210,4 +204,4 @@ public class ContextualCardLoaderTest { .build()); return cards; } -} \ No newline at end of file +} From 031dcf5019d31dfaf0569c931cbfdcffaa206329 Mon Sep 17 00:00:00 2001 From: Brett Chabot Date: Thu, 13 Dec 2018 19:06:32 -0800 Subject: [PATCH 11/14] Migrate packages/apps/Settings to androidx.test See go/jetpack-test-android-migration Test: make checkbuild Change-Id: If67b124188fd4e303154eb11263d03abfb3718c6 --- tests/anomaly-tester/Android.mk | 2 +- tests/anomaly-tester/AndroidManifest.xml | 2 +- .../anomaly/tests/BluetoothAnomalyTest.java | 5 +-- .../anomaly/tests/WakelockAnomalyTest.java | 5 +-- tests/uitests/Android.mk | 2 +- tests/uitests/AndroidManifest.xml | 2 +- tests/uitests/AndroidTest.xml | 2 +- .../settings/ui/AboutPhoneSettingsTests.java | 7 ++-- .../ui/AppsSettingsRetainFilterTests.java | 5 +-- .../settings/ui/BatterySettingsUITest.java | 7 ++-- .../settings/ui/ConnectedDeviceTests.java | 7 ++-- .../settings/ui/HomepageDisplayTests.java | 7 ++-- .../ui/SecuritySettingsLaunchTest.java | 7 ++-- .../settings/ui/StorageSettingsUITest.java | 5 +-- .../settings/ui/StorageWizardTest.java | 5 +-- .../android/settings/ui/SyncSettingsTest.java | 7 ++-- .../ui/WirelessNetworkSettingsTests.java | 5 +-- .../settings/ui/ZonePickerSettingsTest.java | 8 +++-- .../inputmethods/DataSaverSummaryUITest.java | 5 +-- .../SpellCheckerSettingsUITest.java | 5 +-- .../SettingsSearchResultRegressionTest.java | 7 ++-- tests/unit/Android.mk | 8 ++--- tests/unit/AndroidManifest.xml | 2 +- tests/unit/AndroidTest.xml | 2 +- tests/unit/README | 6 ++-- .../android/settings/DisplaySettingsTest.java | 13 +++---- .../settings/EncryptionInterstitialTest.java | 14 ++++---- .../ManagedAccessSettingsLowRamTest.java | 19 ++++++----- .../RegulatoryInfoDisplayActivityTest.java | 18 +++++----- .../android/settings/UserCredentialsTest.java | 2 +- ...ibilityShortcutPreferenceFragmentTest.java | 22 ++++++------ .../ToggleFeaturePreferenceFragmentTest.java | 15 ++++---- .../accounts/AccountsSettingsTest.java | 7 ++-- .../applications/AppOpsSettingsTest.java | 7 ++-- .../applications/DefaultAppSettingsTest.java | 3 +- .../applications/DrawOverlaySettingsTest.java | 5 +-- .../ExternalSourcesSettingsTest.java | 5 +-- .../ManageApplicationsLaunchTest.java | 16 +++++---- .../SpecialAppAccessSettingsTest.java | 3 +- .../ManageApplicationsUnitTest.java | 6 ++-- .../settings/backup/BackupIntentTest.java | 7 ++-- .../FingerprintEnrollFinishTest.java | 22 ++++++------ .../BluetoothDeviceDetailsRotationTest.java | 7 ++-- .../bluetooth/DevicePickerActivityTest.java | 7 ++-- .../ConnectedDeviceActivityTest.java | 7 ++-- .../core/LifecycleEventHandlingTest.java | 8 +++-- .../PreferenceControllerContractTest.java | 7 ++-- .../settings/core/SettingsGatewayTest.java | 10 ++++-- .../settings/core/UniquePreferenceTest.java | 7 ++-- .../settings/core/UserRestrictionTest.java | 7 ++-- .../dashboard/PreferenceThemeTest.java | 23 +++++++------ .../MobileDataUsageActivityTest.java | 7 ++-- .../timezone/model/TimeZoneDataTest.java | 4 +-- ...eferenceControllerInstrumentationTest.java | 7 ++-- .../deviceinfo/PrivateVolumeForgetTest.java | 10 +++--- .../deviceinfo/PublicVolumeSettingsTest.java | 10 +++--- .../StorageDashboardFragmentTest.java | 15 ++++---- .../storage/StorageAsyncLoaderTest.java | 6 ++-- .../NightDisplaySettingsActivityTest.java | 7 ++-- .../ThemePreferenceControllerTest.java | 11 +++--- .../dream/DreamSettingsLaunchTest.java | 7 ++-- .../fuelgauge/PowerUsageSummaryTest.java | 13 +++---- .../fuelgauge/batterytip/RestrictAppTest.java | 16 +++++---- .../ContextualCardLoaderTest.java | 5 +-- .../AppNotificationSettingsTest.java | 34 +++++++++++-------- .../ChannelNotificationSettingsTest.java | 17 ++++++---- .../ZenModeSettingsIntegrationTest.java | 15 ++++---- .../password/ChooseLockGenericTest.java | 19 ++++++----- .../password/ChooseLockPasswordTest.java | 24 +++++++------ .../password/ConfirmLockPasswordTest.java | 17 +++++----- .../password/SetupChooseLockGenericTest.java | 14 ++++---- .../SetupChooseLockPasswordAppTest.java | 31 +++++++++-------- .../print/PrintJobSettingsActivityTest.java | 12 +++---- .../search/SearchIndexablesContractTest.java | 5 +-- .../search/SearchResultTrampolineTest.java | 7 ++-- .../SettingsSearchIndexablesProviderTest.java | 7 ++-- .../slices/SliceDataContractTest.java | 7 ++-- .../slices/SliceDeepLinkSpringBoardTest.java | 7 ++-- .../tests/DrawOverlayDetailsTest.java | 20 ++++++----- .../settings/tests/KeepOnScreenTest.java | 14 ++++---- .../tests/PrivateVolumeSettingsTest.java | 13 +++---- .../tests/SettingsRestoreAfterCloseTest.java | 7 ++-- .../settings/users/UserSettingsTest.java | 7 ++-- .../settings/utils/FileSizeFormatterTest.java | 7 ++-- .../wifi/SavedNetworkSettingsTest.java | 18 +++++----- .../wifi/WifiCallingSettingUiTest.java | 26 +++++++------- .../settings/wifi/WifiSettingsUiTest.java | 30 ++++++++-------- .../dpp/WifiDppConfiguratorActivityTest.java | 7 ++-- .../WifiDppQrCodeGeneratorFragmentTest.java | 6 ++-- .../dpp/WifiDppQrCodeScannerFragmentTest.java | 6 ++-- .../wifi/tether/WifiTetherSettingsTest.java | 15 ++++---- 91 files changed, 500 insertions(+), 402 deletions(-) diff --git a/tests/anomaly-tester/Android.mk b/tests/anomaly-tester/Android.mk index 9a0a8755163..4dffeab0500 100644 --- a/tests/anomaly-tester/Android.mk +++ b/tests/anomaly-tester/Android.mk @@ -7,7 +7,7 @@ LOCAL_CERTIFICATE := platform LOCAL_JAVA_LIBRARIES := android.test.runner LOCAL_STATIC_JAVA_LIBRARIES := \ - android-support-test \ + androidx.test.rules \ mockito-target \ ub-uiautomator \ truth-prebuilt \ diff --git a/tests/anomaly-tester/AndroidManifest.xml b/tests/anomaly-tester/AndroidManifest.xml index 7893b866bfa..d6f68a892c1 100644 --- a/tests/anomaly-tester/AndroidManifest.xml +++ b/tests/anomaly-tester/AndroidManifest.xml @@ -44,7 +44,7 @@ diff --git a/tests/anomaly-tester/src/com/android/settings/anomaly/tests/BluetoothAnomalyTest.java b/tests/anomaly-tester/src/com/android/settings/anomaly/tests/BluetoothAnomalyTest.java index 3630ce420dd..0477e094228 100644 --- a/tests/anomaly-tester/src/com/android/settings/anomaly/tests/BluetoothAnomalyTest.java +++ b/tests/anomaly-tester/src/com/android/settings/anomaly/tests/BluetoothAnomalyTest.java @@ -19,13 +19,14 @@ import static com.google.common.truth.Truth.assertWithMessage; import android.app.Instrumentation; import android.content.Context; import android.content.Intent; -import android.support.test.InstrumentationRegistry; -import android.support.test.runner.AndroidJUnit4; import android.support.test.uiautomator.By; import android.support.test.uiautomator.UiDevice; import android.support.test.uiautomator.Until; import android.text.format.DateUtils; +import androidx.test.InstrumentationRegistry; +import androidx.test.runner.AndroidJUnit4; + import org.junit.After; import org.junit.Before; import org.junit.Test; diff --git a/tests/anomaly-tester/src/com/android/settings/anomaly/tests/WakelockAnomalyTest.java b/tests/anomaly-tester/src/com/android/settings/anomaly/tests/WakelockAnomalyTest.java index a2f38048977..c44e2eaf712 100644 --- a/tests/anomaly-tester/src/com/android/settings/anomaly/tests/WakelockAnomalyTest.java +++ b/tests/anomaly-tester/src/com/android/settings/anomaly/tests/WakelockAnomalyTest.java @@ -19,13 +19,14 @@ import static com.google.common.truth.Truth.assertWithMessage; import android.app.Instrumentation; import android.content.Context; import android.content.Intent; -import android.support.test.InstrumentationRegistry; -import android.support.test.runner.AndroidJUnit4; import android.support.test.uiautomator.By; import android.support.test.uiautomator.UiDevice; import android.support.test.uiautomator.Until; import android.text.format.DateUtils; +import androidx.test.InstrumentationRegistry; +import androidx.test.runner.AndroidJUnit4; + import org.junit.After; import org.junit.Before; import org.junit.Test; diff --git a/tests/uitests/Android.mk b/tests/uitests/Android.mk index 89f9133cd69..fb7258ce792 100644 --- a/tests/uitests/Android.mk +++ b/tests/uitests/Android.mk @@ -27,7 +27,7 @@ LOCAL_JAVA_LIBRARIES := \ android.test.base LOCAL_STATIC_JAVA_LIBRARIES := \ - android-support-test \ + androidx.test.rules \ app-helpers-core \ launcher-helper-lib \ metrics-helper-lib \ diff --git a/tests/uitests/AndroidManifest.xml b/tests/uitests/AndroidManifest.xml index 49a2fd110aa..dc6fc15d1cd 100644 --- a/tests/uitests/AndroidManifest.xml +++ b/tests/uitests/AndroidManifest.xml @@ -31,7 +31,7 @@ diff --git a/tests/uitests/AndroidTest.xml b/tests/uitests/AndroidTest.xml index 4162207fa80..50c6a758010 100644 --- a/tests/uitests/AndroidTest.xml +++ b/tests/uitests/AndroidTest.xml @@ -24,7 +24,7 @@