Merge "Mainline remove hide api SubscriptionInfo.getCardString"
diff --git a/TEST_MAPPING b/TEST_MAPPING
index 8061cb4..3e32512 100644
--- a/TEST_MAPPING
+++ b/TEST_MAPPING
@@ -7,6 +7,14 @@
"exclude-annotation": "androidx.test.filters.FlakyTest"
}
]
+ },
+ {
+ "name": "SettingsPrefTests",
+ "options": [
+ {
+ "exclude-annotation": "androidx.test.filters.FlakyTest"
+ }
+ ]
}
]
}
diff --git a/src/com/android/settings/datetime/timezone/model/FilteredCountryTimeZones.java b/src/com/android/settings/datetime/timezone/model/FilteredCountryTimeZones.java
index d7fcb2f..92e9e96 100644
--- a/src/com/android/settings/datetime/timezone/model/FilteredCountryTimeZones.java
+++ b/src/com/android/settings/datetime/timezone/model/FilteredCountryTimeZones.java
@@ -48,9 +48,10 @@
mCountryTimeZones = countryTimeZones;
List<String> timeZoneIds = countryTimeZones.getTimeZoneMappings().stream()
.filter(timeZoneMapping ->
- timeZoneMapping.showInPicker && (timeZoneMapping.notUsedAfter == null
- || timeZoneMapping.notUsedAfter >= MIN_USE_DATE_OF_TIMEZONE))
- .map(timeZoneMapping -> timeZoneMapping.timeZoneId)
+ timeZoneMapping.isShownInPicker()
+ && (timeZoneMapping.getNotUsedAfter() == null
+ || timeZoneMapping.getNotUsedAfter() >= MIN_USE_DATE_OF_TIMEZONE))
+ .map(timeZoneMapping -> timeZoneMapping.getTimeZoneId())
.collect(Collectors.toList());
mTimeZoneIds = Collections.unmodifiableList(timeZoneIds);
}
diff --git a/src/com/android/settings/location/LocationForWorkPreferenceController.java b/src/com/android/settings/location/LocationForWorkPreferenceController.java
index 8163934..41d26ef 100644
--- a/src/com/android/settings/location/LocationForWorkPreferenceController.java
+++ b/src/com/android/settings/location/LocationForWorkPreferenceController.java
@@ -67,21 +67,22 @@
final RestrictedLockUtils.EnforcedAdmin admin =
mLocationEnabler.getShareLocationEnforcedAdmin(
Utils.getManagedProfile(mUserManager).getIdentifier());
- final boolean isRestrictedByBase = mLocationEnabler.isManagedProfileRestrictedByBase();
- if (!isRestrictedByBase && admin != null) {
+ if (admin != null) {
mPreference.setDisabledByAdmin(admin);
- mPreference.setChecked(false);
} else {
final boolean enabled = mLocationEnabler.isEnabled(mode);
mPreference.setEnabled(enabled);
+ int summaryResId;
- int summaryResId = R.string.switch_off_text;
- if (!enabled) {
+ final boolean isRestrictedByBase =
+ mLocationEnabler.isManagedProfileRestrictedByBase();
+ if (isRestrictedByBase || !enabled) {
mPreference.setChecked(false);
+ summaryResId = enabled ? R.string.switch_off_text
+ : R.string.location_app_permission_summary_location_off;
} else {
- mPreference.setChecked(!isRestrictedByBase);
- summaryResId = (isRestrictedByBase ?
- R.string.switch_off_text : R.string.switch_on_text);
+ mPreference.setChecked(true);
+ summaryResId = R.string.switch_on_text;
}
mPreference.setSummary(summaryResId);
}
diff --git a/src/com/android/settings/network/ims/ImsDirectQuery.java b/src/com/android/settings/network/ims/ImsDirectQuery.java
deleted file mode 100644
index 4c6a932..0000000
--- a/src/com/android/settings/network/ims/ImsDirectQuery.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (C) 2020 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.ims;
-
-
-/**
- * An interface for direct querying IMS, and return {@code boolean}
- */
-public interface ImsDirectQuery {
-
- /**
- * Interface for performing IMS status/configuration query through public APIs
- *
- * @return result of query in boolean
- */
- boolean directQuery();
-
-}
diff --git a/src/com/android/settings/network/ims/ImsDirectQueryImpl.java b/src/com/android/settings/network/ims/ImsDirectQueryImpl.java
deleted file mode 100644
index cff8461..0000000
--- a/src/com/android/settings/network/ims/ImsDirectQueryImpl.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (C) 2020 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.ims;
-
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Future;
-import java.util.concurrent.RejectedExecutionException;
-
-
-/**
- * An implementation of {@code ImsQuery} and {@code ImsDirectQuery}.
- */
-abstract class ImsDirectQueryImpl implements ImsQuery, ImsDirectQuery, Callable<Boolean> {
-
- /**
- * Implementation of interface {@code ImsQuery}
- *
- * @param executors {@code ExecutorService} which allows to submit {@code ImsQuery} when
- * required
- * @return result of query in format of {@code Future<Boolean>}
- */
- public Future<Boolean> query(ExecutorService executors) throws RejectedExecutionException {
- return executors.submit(this);
- }
-
- /**
- * Implementation of interface {@code ImsDirectQuery}
- *
- * @return result of query
- */
- public boolean directQuery() {
- return call();
- }
-
- /**
- * Query running within a {@code Callable}
- *
- * @return result of query
- */
- public abstract Boolean call();
-}
diff --git a/src/com/android/settings/network/ims/ImsQuery.java b/src/com/android/settings/network/ims/ImsQuery.java
index 1462718..dcb6eee 100644
--- a/src/com/android/settings/network/ims/ImsQuery.java
+++ b/src/com/android/settings/network/ims/ImsQuery.java
@@ -16,23 +16,17 @@
package com.android.settings.network.ims;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Future;
-import java.util.concurrent.RejectedExecutionException;
-
/**
- * An interface for querying IMS, and return {@code Future<Boolean>}
+ * An interface for direct querying IMS, and return {@link boolean}
*/
public interface ImsQuery {
/**
- * Interface for performing IMS status/configuration query through ExecutorService
+ * Interface for performing IMS status/configuration query through public APIs
*
- * @param executors {@code ExecutorService} which allows to submit {@code ImsQuery} when
- * required
- * @return result of query in format of {@code Future<Boolean>}
+ * @return result of query in boolean
*/
- Future<Boolean> query(ExecutorService executors) throws RejectedExecutionException;
+ boolean query();
}
diff --git a/src/com/android/settings/network/ims/ImsQueryController.java b/src/com/android/settings/network/ims/ImsQueryController.java
index 651c422..83d6578 100644
--- a/src/com/android/settings/network/ims/ImsQueryController.java
+++ b/src/com/android/settings/network/ims/ImsQueryController.java
@@ -16,8 +16,6 @@
package com.android.settings.network.ims;
-import android.content.Context;
-
import androidx.annotation.VisibleForTesting;
/**
@@ -26,12 +24,7 @@
abstract class ImsQueryController {
@VisibleForTesting
- ImsDirectQuery isSystemTtyEnabled(Context context) {
- return new ImsQuerySystemTtyStat(context);
- }
-
- @VisibleForTesting
- ImsDirectQuery isTtyOnVolteEnabled(int subId) {
+ ImsQuery isTtyOnVolteEnabled(int subId) {
return new ImsQueryTtyOnVolteStat(subId);
}
}
diff --git a/src/com/android/settings/network/ims/ImsQuerySystemTtyStat.java b/src/com/android/settings/network/ims/ImsQuerySystemTtyStat.java
deleted file mode 100644
index 4239b16..0000000
--- a/src/com/android/settings/network/ims/ImsQuerySystemTtyStat.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2020 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.ims;
-
-import android.content.Context;
-import android.telecom.TelecomManager;
-
-
-/**
- * An {@code ImsQuery} for accessing system TTY stat
- */
-public class ImsQuerySystemTtyStat extends ImsDirectQueryImpl {
-
- /**
- * Constructor
- * @param context context of activity
- */
- public ImsQuerySystemTtyStat(Context context) {
- mContext = context;
- }
-
- private volatile Context mContext;
-
- /**
- * Query running within a {@code Callable}
- *
- * @return result of query
- */
- public Boolean call() {
- final TelecomManager telecomManager = mContext.getSystemService(TelecomManager.class);
- return (telecomManager.getCurrentTtyMode() != TelecomManager.TTY_MODE_OFF);
- }
-}
diff --git a/src/com/android/settings/network/ims/ImsQueryTtyOnVolteStat.java b/src/com/android/settings/network/ims/ImsQueryTtyOnVolteStat.java
index a371ce7..c2d655f 100644
--- a/src/com/android/settings/network/ims/ImsQueryTtyOnVolteStat.java
+++ b/src/com/android/settings/network/ims/ImsQueryTtyOnVolteStat.java
@@ -20,9 +20,9 @@
/**
- * An {@code ImsQuery} for accessing IMS tty on VoLte stat
+ * An {@link ImsQuery} for accessing IMS tty on VoLte stat
*/
-public class ImsQueryTtyOnVolteStat extends ImsDirectQueryImpl {
+public class ImsQueryTtyOnVolteStat implements ImsQuery {
/**
* Constructor
@@ -35,11 +35,11 @@
private volatile int mSubId;
/**
- * Query running within a {@code Callable}
+ * Implementation of interface {@link ImsQuery#query()}
*
* @return result of query
*/
- public Boolean call() {
+ public boolean query() {
final ImsMmTelManager imsMmTelManager = ImsMmTelManager.createForSubscriptionId(mSubId);
return imsMmTelManager.isTtyOverVolteEnabled();
}
diff --git a/src/com/android/settings/network/ims/ImsQueryVtUserSetting.java b/src/com/android/settings/network/ims/ImsQueryVtUserSetting.java
index 20e8c05..6d699e3 100644
--- a/src/com/android/settings/network/ims/ImsQueryVtUserSetting.java
+++ b/src/com/android/settings/network/ims/ImsQueryVtUserSetting.java
@@ -20,9 +20,9 @@
/**
- * An {@code ImsQuery} for accessing IMS VT enabled settings from user
+ * An {@link ImsQuery} for accessing IMS VT enabled settings from user
*/
-public class ImsQueryVtUserSetting extends ImsDirectQueryImpl {
+public class ImsQueryVtUserSetting implements ImsQuery {
/**
* Constructor
@@ -35,11 +35,11 @@
private volatile int mSubId;
/**
- * Query running within a {@code Callable}
+ * Implementation of interface {@link ImsQuery#query()}
*
* @return result of query
*/
- public Boolean call() {
+ public boolean query() {
final ImsMmTelManager imsMmTelManager = ImsMmTelManager.createForSubscriptionId(mSubId);
return imsMmTelManager.isVtSettingEnabled();
}
diff --git a/src/com/android/settings/network/ims/ImsQueryWfcUserSetting.java b/src/com/android/settings/network/ims/ImsQueryWfcUserSetting.java
index 86e25e6..22d2c67 100644
--- a/src/com/android/settings/network/ims/ImsQueryWfcUserSetting.java
+++ b/src/com/android/settings/network/ims/ImsQueryWfcUserSetting.java
@@ -20,9 +20,9 @@
/**
- * An {@code ImsQuery} for accessing IMS WFC enabled settings from user
+ * An {@link ImsQuery} for accessing IMS WFC enabled settings from user
*/
-public class ImsQueryWfcUserSetting extends ImsDirectQueryImpl {
+public class ImsQueryWfcUserSetting implements ImsQuery {
/**
* Constructor
@@ -35,11 +35,11 @@
private volatile int mSubId;
/**
- * Query running within a {@code Callable}
+ * Implementation of interface {@link ImsQuery#query()}
*
* @return result of query
*/
- public Boolean call() {
+ public boolean query() {
final ImsMmTelManager imsMmTelManager = ImsMmTelManager.createForSubscriptionId(mSubId);
return imsMmTelManager.isVoWiFiSettingEnabled();
}
diff --git a/src/com/android/settings/network/ims/VolteQueryImsState.java b/src/com/android/settings/network/ims/VolteQueryImsState.java
index b999cda..320aa26 100644
--- a/src/com/android/settings/network/ims/VolteQueryImsState.java
+++ b/src/com/android/settings/network/ims/VolteQueryImsState.java
@@ -17,8 +17,11 @@
package com.android.settings.network.ims;
import android.content.Context;
+import android.telecom.TelecomManager;
import android.telephony.SubscriptionManager;
+import androidx.annotation.VisibleForTesting;
+
import com.android.ims.ImsManager;
import com.android.settings.network.SubscriptionUtil;
@@ -34,7 +37,7 @@
/**
* Constructor
*
- * @param context {@code Context}
+ * @param context {@link Context}
* @param subId subscription's id
*/
public VolteQueryImsState(Context context, int subId) {
@@ -52,8 +55,14 @@
return false;
}
- return ((!isSystemTtyEnabled(mContext).directQuery())
- || (isTtyOnVolteEnabled(mSubId).directQuery()));
+ return ((!isTtyEnabled(mContext))
+ || (isTtyOnVolteEnabled(mSubId).query()));
+ }
+
+ @VisibleForTesting
+ boolean isTtyEnabled(Context context) {
+ final TelecomManager telecomManager = context.getSystemService(TelecomManager.class);
+ return (telecomManager.getCurrentTtyMode() != TelecomManager.TTY_MODE_OFF);
}
/**
diff --git a/src/com/android/settings/network/ims/VtQueryImsState.java b/src/com/android/settings/network/ims/VtQueryImsState.java
index ca8deea..5ac07a3 100644
--- a/src/com/android/settings/network/ims/VtQueryImsState.java
+++ b/src/com/android/settings/network/ims/VtQueryImsState.java
@@ -17,6 +17,7 @@
package com.android.settings.network.ims;
import android.content.Context;
+import android.telecom.TelecomManager;
import android.telephony.SubscriptionManager;
import androidx.annotation.VisibleForTesting;
@@ -32,7 +33,7 @@
/**
* Constructor
*
- * @param context {@code Context}
+ * @param context {@link Context}
* @param subId subscription's id
*/
public VtQueryImsState(Context context, int subId) {
@@ -44,7 +45,7 @@
* Implementation of ImsQueryController#isEnabledByUser(int subId)
*/
@VisibleForTesting
- ImsDirectQuery isEnabledByUser(int subId) {
+ ImsQuery isEnabledByUser(int subId) {
return new ImsQueryVtUserSetting(subId);
}
@@ -57,8 +58,14 @@
if (!SubscriptionManager.isValidSubscriptionId(mSubId)) {
return false;
}
- return ((!isSystemTtyEnabled(mContext).directQuery())
- || (isTtyOnVolteEnabled(mSubId).directQuery()));
+ return ((!isTtyEnabled(mContext))
+ || (isTtyOnVolteEnabled(mSubId).query()));
+ }
+
+ @VisibleForTesting
+ boolean isTtyEnabled(Context context) {
+ final TelecomManager telecomManager = context.getSystemService(TelecomManager.class);
+ return (telecomManager.getCurrentTtyMode() != TelecomManager.TTY_MODE_OFF);
}
/**
@@ -70,6 +77,6 @@
if (!SubscriptionManager.isValidSubscriptionId(mSubId)) {
return false;
}
- return isEnabledByUser(mSubId).directQuery();
+ return isEnabledByUser(mSubId).query();
}
}
diff --git a/src/com/android/settings/network/ims/WifiCallingQueryImsState.java b/src/com/android/settings/network/ims/WifiCallingQueryImsState.java
index f8b0767..e1b3bbf 100644
--- a/src/com/android/settings/network/ims/WifiCallingQueryImsState.java
+++ b/src/com/android/settings/network/ims/WifiCallingQueryImsState.java
@@ -17,6 +17,7 @@
package com.android.settings.network.ims;
import android.content.Context;
+import android.telecom.TelecomManager;
import android.telephony.SubscriptionManager;
import androidx.annotation.VisibleForTesting;
@@ -32,7 +33,7 @@
/**
* Constructor
*
- * @param context {@code Context}
+ * @param context {@link Context}
* @param subId subscription's id
*/
public WifiCallingQueryImsState(Context context, int subId) {
@@ -44,7 +45,7 @@
* Implementation of ImsQueryController#isEnabledByUser(int subId)
*/
@VisibleForTesting
- ImsDirectQuery isEnabledByUser(int subId) {
+ ImsQuery isEnabledByUser(int subId) {
return new ImsQueryWfcUserSetting(subId);
}
@@ -58,8 +59,14 @@
return false;
}
- return ((!isSystemTtyEnabled(mContext).directQuery())
- || (isTtyOnVolteEnabled(mSubId).directQuery()));
+ return ((!isTtyEnabled(mContext))
+ || (isTtyOnVolteEnabled(mSubId).query()));
+ }
+
+ @VisibleForTesting
+ boolean isTtyEnabled(Context context) {
+ final TelecomManager telecomManager = context.getSystemService(TelecomManager.class);
+ return (telecomManager.getCurrentTtyMode() != TelecomManager.TTY_MODE_OFF);
}
/**
@@ -71,6 +78,6 @@
if (!SubscriptionManager.isValidSubscriptionId(mSubId)) {
return false;
}
- return isEnabledByUser(mSubId).directQuery();
+ return isEnabledByUser(mSubId).query();
}
}
diff --git a/src/com/android/settings/network/telephony/MobileNetworkActivity.java b/src/com/android/settings/network/telephony/MobileNetworkActivity.java
index 9dd6ddd..0f3d289 100644
--- a/src/com/android/settings/network/telephony/MobileNetworkActivity.java
+++ b/src/com/android/settings/network/telephony/MobileNetworkActivity.java
@@ -118,6 +118,9 @@
@Override
protected void onDestroy() {
super.onDestroy();
+ if (mProxySubscriptionMgr == null) {
+ return;
+ }
mProxySubscriptionMgr.removeActiveSubscriptionsListener(this);
}
diff --git a/src/com/android/settings/wifi/WifiEntryShell.java b/src/com/android/settings/wifi/WifiEntryShell.java
index 7c6fc48..385cca1 100644
--- a/src/com/android/settings/wifi/WifiEntryShell.java
+++ b/src/com/android/settings/wifi/WifiEntryShell.java
@@ -23,7 +23,6 @@
* all the unavalable {@link AccessPoint} methods & constants.
*
* TODO(b/143326832): Replace all methods & constants with WifiEntry version when it's available.
- * TODO(b/143326832): How about AccessPoint#getSettingsSummary(boolean convertSavedAsDisconnected)?
*/
public class WifiEntryShell {
public WifiEntryShell(){};
@@ -47,41 +46,4 @@
* Upper bound on the 5.0 GHz (802.11a/h/j/n/ac) WLAN channels
*/
public static final int HIGHER_FREQ_5GHZ = 5900;
-
- // Passpoint methods
-
- /**
- * Mapping of the corresponding {@link AccessPoint} method
- */
- public static boolean isExpired(WifiEntry wifiEntry) {
- return false;
- }
-
- /**
- * Mapping of the corresponding {@link AccessPoint} method
- */
- public static boolean isPasspointConfigurationR1(WifiEntry wifiEntry) {
- return false;
- }
-
- /**
- * Mapping of the corresponding {@link AccessPoint} method
- */
- public static boolean isPasspointConfigurationOsuProvisioned(WifiEntry wifiEntry) {
- return false;
- }
-
- /**
- * Mapping of the corresponding {@link AccessPoint} method
- */
- public static boolean isOsuProvider(WifiEntry wifiEntry) {
- return false;
- }
-
- /**
- * Mapping of the corresponding {@link AccessPoint} method
- */
- public static String getPasspointFqdn(WifiEntry wifiEntry) {
- return "Fake passpoint FQDN";
- }
}
diff --git a/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2.java b/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2.java
index b5813cf..b9e39bc 100644
--- a/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2.java
+++ b/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2.java
@@ -537,7 +537,7 @@
}
private void refreshSsid() {
- if (mWifiEntry.isSubscription() || WifiEntryShell.isOsuProvider(mWifiEntry)) {
+ if (mWifiEntry.isSubscription()) {
mSsidPref.setVisible(true);
mSsidPref.setSummary(mWifiEntry.getTitle());
} else {
@@ -596,7 +596,17 @@
mButtonsPref.setButton1Visible(canForgetNetwork);
mButtonsPref.setButton2Visible(canSignIntoNetwork);
- mButtonsPref.setButton3Visible(mWifiEntry.getLevel() != WifiEntry.WIFI_LEVEL_UNREACHABLE);
+ // If it's expired and connected, shows Disconnect button for users to disconnect it.
+ // If it's expired and not connected, hides the button and users are not able to connect it.
+ //
+ // expired connected visibility
+ // false false true show (Connect) button
+ // false true true show (Disconnect) button
+ // true false false hide button
+ // true true true show (Disconnect) button
+ mButtonsPref.setButton3Visible(mWifiEntry.getLevel() != WifiEntry.WIFI_LEVEL_UNREACHABLE
+ && (!mWifiEntry.isExpired()
+ || mWifiEntry.getConnectedState() == WifiEntry.CONNECTED_STATE_CONNECTED));
mButtonsPref.setButton3Enabled(canConnectDisconnectNetwork);
mButtonsPref.setButton3Text(getConnectDisconnectButtonTextResource());
mButtonsPref.setButton3Icon(getConnectDisconnectButtonIconResource());
@@ -743,8 +753,7 @@
try {
mWifiEntry.forget(this);
} catch (RuntimeException e) {
- Log.e(TAG, "Failed to remove Passpoint configuration for "
- + WifiEntryShell.getPasspointFqdn(mWifiEntry));
+ Log.e(TAG, "Failed to remove Passpoint configuration: " + e);
}
mMetricsFeatureProvider.action(
mFragment.getActivity(), SettingsEnums.ACTION_WIFI_FORGET);
diff --git a/tests/perftests/Android.bp b/tests/perftests/Android.bp
new file mode 100644
index 0000000..961acb2
--- /dev/null
+++ b/tests/perftests/Android.bp
@@ -0,0 +1,22 @@
+android_test {
+ name: "SettingsPrefTests",
+
+ certificate: "platform",
+
+ libs: [
+ "android.test.runner",
+ ],
+
+ static_libs: [
+ "androidx.test.rules",
+ "ub-uiautomator",
+ ],
+
+ // Include all test java files.
+ srcs: ["src/**/*.java"],
+
+ platform_apis: true,
+ test_suites: ["device-tests"],
+
+ instrumentation_for: "Settings",
+}
diff --git a/tests/perftests/AndroidManifest.xml b/tests/perftests/AndroidManifest.xml
new file mode 100644
index 0000000..902090a
--- /dev/null
+++ b/tests/perftests/AndroidManifest.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2020 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.
+-->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.settings.tests.pref">
+
+ <application>
+ <uses-library android:name="android.test.runner" />
+ </application>
+
+ <instrumentation android:name="androidx.test.runner.AndroidJUnitRunner"
+ android:targetPackage="com.android.settings"
+ android:label="Settings Performance Test Cases">
+ </instrumentation>
+
+</manifest>
diff --git a/tests/perftests/src/com/android/settings/tests/pref/LaunchSettingsTest.java b/tests/perftests/src/com/android/settings/tests/pref/LaunchSettingsTest.java
new file mode 100644
index 0000000..9e035cd
--- /dev/null
+++ b/tests/perftests/src/com/android/settings/tests/pref/LaunchSettingsTest.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2020 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.tests.pref;
+
+import android.app.Instrumentation;
+import android.os.Bundle;
+
+import androidx.test.InstrumentationRegistry;
+import androidx.test.runner.AndroidJUnit4;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(AndroidJUnit4.class)
+public class LaunchSettingsTest {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testReportMetrics() throws Exception {
+ Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation();
+ final Bundle result = new Bundle();
+ result.putString("LaunchSettingsTest_metric_key1", "1000");
+ result.putString("LaunchSettingsTest_metric_key2", "5000");
+ instrumentation.sendStatus(0, result);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/wifi/details2/WifiMeteredPreferenceController2Test.java b/tests/robotests/src/com/android/settings/wifi/details2/WifiMeteredPreferenceController2Test.java
index c453db3..9c31d44 100644
--- a/tests/robotests/src/com/android/settings/wifi/details2/WifiMeteredPreferenceController2Test.java
+++ b/tests/robotests/src/com/android/settings/wifi/details2/WifiMeteredPreferenceController2Test.java
@@ -28,7 +28,6 @@
import com.android.wifitrackerlib.WifiEntry;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
@@ -86,13 +85,4 @@
assertThat(mDropDownPreference.getEntry()).isEqualTo("Detect automatically");
}
-
- @Test
- @Ignore
- public void testController_resilientToNullConfig() {
- mPreferenceController = spy(new WifiMeteredPreferenceController2(mContext, null));
-
- mPreferenceController.getMeteredOverride();
- mPreferenceController.onPreferenceChange(mDropDownPreference, 1);
- }
}
diff --git a/tests/robotests/src/com/android/settings/wifi/details2/WifiPrivacyPreferenceController2Test.java b/tests/robotests/src/com/android/settings/wifi/details2/WifiPrivacyPreferenceController2Test.java
index 3403e0c..0414b1c 100644
--- a/tests/robotests/src/com/android/settings/wifi/details2/WifiPrivacyPreferenceController2Test.java
+++ b/tests/robotests/src/com/android/settings/wifi/details2/WifiPrivacyPreferenceController2Test.java
@@ -19,6 +19,7 @@
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
@@ -30,7 +31,6 @@
import com.android.wifitrackerlib.WifiEntry;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
@@ -38,14 +38,12 @@
import org.robolectric.RuntimeEnvironment;
@RunWith(RobolectricTestRunner.class)
-@Ignore
public class WifiPrivacyPreferenceController2Test {
private static final int PRIVACY_RANDOMIZED = WifiEntry.PRIVACY_RANDOMIZED_MAC;
private static final int PRIVACY_TRUSTED = WifiEntry.PRIVACY_DEVICE_MAC;
- @Mock
- private WifiEntry mWifiEntry;
+ @Mock private WifiEntry mMockWifiEntry;
private WifiPrivacyPreferenceController2 mPreferenceController;
private Context mContext;
@@ -56,9 +54,10 @@
public void setUp() {
mContext = RuntimeEnvironment.application;
+ mMockWifiEntry = mock(WifiEntry.class);
WifiPrivacyPreferenceController2 preferenceController =
new WifiPrivacyPreferenceController2(mContext);
- preferenceController.setWifiEntry(mWifiEntry);
+ preferenceController.setWifiEntry(mMockWifiEntry);
mPreferenceController = spy(preferenceController);
mDropDownPreference = new DropDownPreference(mContext);
mDropDownPreference.setEntries(R.array.wifi_privacy_entries);
@@ -90,17 +89,9 @@
}
@Test
- public void testController_resilientToNullConfig() {
- mPreferenceController = spy(new WifiPrivacyPreferenceController2(mContext));
- mPreferenceController.setWifiEntry(mWifiEntry);
-
- mPreferenceController.getRandomizationValue();
- mPreferenceController.onPreferenceChange(mDropDownPreference, "1");
- }
-
- @Test
public void testUpdateState_canSetPrivacy_shouldBeSelectable() {
- when(mWifiEntry.canSetPrivacy()).thenReturn(true);
+ when(mMockWifiEntry.canSetPrivacy()).thenReturn(true);
+
mPreferenceController.updateState(mDropDownPreference);
assertThat(mDropDownPreference.isSelectable()).isTrue();
@@ -108,7 +99,8 @@
@Test
public void testUpdateState_canNotSetPrivacy_shouldNotSelectable() {
- when(mWifiEntry.canSetPrivacy()).thenReturn(false);
+ when(mMockWifiEntry.canSetPrivacy()).thenReturn(false);
+
mPreferenceController.updateState(mDropDownPreference);
assertThat(mDropDownPreference.isSelectable()).isFalse();