Merge "Allows IndicatorView to have a different size than Settings Activity" into rvc-dev am: b50512b69a am: eab293354a am: 4d896e3da8
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/11835166
Change-Id: Ic9b70cd934b937a2c45efac6f637ec53f8188753
diff --git a/MODULE_LICENSE_APACHE2 b/MODULE_LICENSE_APACHE2
deleted file mode 100644
index e69de29..0000000
--- a/MODULE_LICENSE_APACHE2
+++ /dev/null
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 8473357..a4dd28e 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -11608,6 +11608,9 @@
<string name="mobile_data_settings_summary_auto_switch">
Phone will automatically switch to this carrier when in range
</string>
+ <!-- Mobile network setting screen, summary of Mobile data switch preference when the network
+ is unavailable, the preference selection will be disabled. [CHAR LIMIT=NONE] -->
+ <string name="mobile_data_settings_summary_unavailable">No SIM card available</string>
<!-- Mobile network settings screen, title of item showing the name of the default subscription
that will be used for calls. This only appears in multi-SIM mode. [CHAR LIMIT=NONE] -->
diff --git a/src/com/android/settings/applications/AppStorageSettings.java b/src/com/android/settings/applications/AppStorageSettings.java
index 8a54c73..d095e37 100644
--- a/src/com/android/settings/applications/AppStorageSettings.java
+++ b/src/com/android/settings/applications/AppStorageSettings.java
@@ -312,13 +312,9 @@
if (appHasSpaceManagementUI) {
mButtonsPref.setButton1Text(R.string.manage_space_text);
} else {
- mButtonsPref
- .setButton1Text(R.string.clear_user_data_text)
- .setButton1Icon(R.drawable.ic_settings_delete);
+ mButtonsPref.setButton1Text(R.string.clear_user_data_text);
}
- mButtonsPref
- .setButton1Text(R.string.clear_user_data_text)
- .setButton1Icon(R.drawable.ic_settings_delete)
+ mButtonsPref.setButton1Icon(R.drawable.ic_settings_delete)
.setButton1OnClickListener(v -> handleClearDataClick());
}
diff --git a/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminAdd.java b/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminAdd.java
index 9afb2b4..7c8b96f 100644
--- a/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminAdd.java
+++ b/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminAdd.java
@@ -288,7 +288,7 @@
// setup.
final String supervisor = getString(
com.android.internal.R.string.config_defaultSupervisionProfileOwnerComponent);
- if (supervisor == null) {
+ if (TextUtils.isEmpty(supervisor)) {
Log.w(TAG, "Unable to set profile owner post-setup, no default supervisor"
+ "profile owner defined");
finish();
@@ -297,7 +297,7 @@
final ComponentName supervisorComponent = ComponentName.unflattenFromString(
supervisor);
- if (who.compareTo(supervisorComponent) != 0) {
+ if (supervisorComponent == null || who.compareTo(supervisorComponent) != 0) {
Log.w(TAG, "Unable to set non-default profile owner post-setup " + who);
finish();
return;
diff --git a/src/com/android/settings/connecteddevice/usb/ConnectedUsbDeviceUpdater.java b/src/com/android/settings/connecteddevice/usb/ConnectedUsbDeviceUpdater.java
index 1078a21..6a13a96 100644
--- a/src/com/android/settings/connecteddevice/usb/ConnectedUsbDeviceUpdater.java
+++ b/src/com/android/settings/connecteddevice/usb/ConnectedUsbDeviceUpdater.java
@@ -97,7 +97,7 @@
// New version - uses a separate screen.
new SubSettingLauncher(mFragment.getContext())
.setDestination(UsbDetailsFragment.class.getName())
- .setTitleRes(R.string.device_details_title)
+ .setTitleRes(R.string.usb_preference)
.setSourceMetricsCategory(mFragment.getMetricsCategory())
.launch();
return true;
diff --git a/src/com/android/settings/datetime/timezone/OWNERS b/src/com/android/settings/datetime/timezone/OWNERS
index 02cf23c..7ad770a 100644
--- a/src/com/android/settings/datetime/timezone/OWNERS
+++ b/src/com/android/settings/datetime/timezone/OWNERS
@@ -1,6 +1,5 @@
# Default reviewers for this and subdirectories.
vichang@google.com
-tobiast@google.com
nfuller@google.com
# Emergency approvers in case the above are not available
diff --git a/src/com/android/settings/network/telephony/CarrierSettingsVersionPreferenceController.java b/src/com/android/settings/network/telephony/CarrierSettingsVersionPreferenceController.java
index a6db773..aec3648 100644
--- a/src/com/android/settings/network/telephony/CarrierSettingsVersionPreferenceController.java
+++ b/src/com/android/settings/network/telephony/CarrierSettingsVersionPreferenceController.java
@@ -20,6 +20,7 @@
import android.os.PersistableBundle;
import android.telephony.CarrierConfigManager;
import android.telephony.SubscriptionManager;
+import android.text.TextUtils;
import com.android.settings.core.BasePreferenceController;
@@ -49,6 +50,6 @@
@Override
public int getAvailabilityStatus() {
- return AVAILABLE;
+ return TextUtils.isEmpty(getSummary()) ? UNSUPPORTED_ON_DEVICE : AVAILABLE;
}
}
diff --git a/src/com/android/settings/network/telephony/MobileDataPreferenceController.java b/src/com/android/settings/network/telephony/MobileDataPreferenceController.java
index c35eef6..91c46df 100644
--- a/src/com/android/settings/network/telephony/MobileDataPreferenceController.java
+++ b/src/com/android/settings/network/telephony/MobileDataPreferenceController.java
@@ -128,6 +128,13 @@
preference.setEnabled(true);
preference.setSummary(R.string.mobile_data_settings_summary);
}
+
+ if (mSubId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
+ preference.setSelectable(false);
+ preference.setSummary(R.string.mobile_data_settings_summary_unavailable);
+ } else {
+ preference.setSelectable(true);
+ }
}
private boolean isOpportunistic() {
diff --git a/src/com/android/settings/panel/PanelFragment.java b/src/com/android/settings/panel/PanelFragment.java
index 1224e1f..6f5cf90 100644
--- a/src/com/android/settings/panel/PanelFragment.java
+++ b/src/com/android/settings/panel/PanelFragment.java
@@ -172,8 +172,13 @@
private void createPanelContent() {
final FragmentActivity activity = getActivity();
+ if (activity == null) {
+ return;
+ }
+
if (mLayoutView == null) {
activity.finish();
+ return;
}
final ViewGroup.LayoutParams params = mLayoutView.getLayoutParams();
params.height = ViewGroup.LayoutParams.WRAP_CONTENT;
@@ -202,6 +207,7 @@
if (mPanel == null) {
activity.finish();
+ return;
}
mPanel.registerCallback(new LocalPanelCallback());
diff --git a/src/com/android/settings/users/EditUserInfoController.java b/src/com/android/settings/users/EditUserInfoController.java
index d205968..6b5e670 100644
--- a/src/com/android/settings/users/EditUserInfoController.java
+++ b/src/com/android/settings/users/EditUserInfoController.java
@@ -99,8 +99,7 @@
}
public void onSaveInstanceState(Bundle outState) {
- if (mEditUserInfoDialog != null && mEditUserInfoDialog.isShowing()
- && mEditUserPhotoController != null) {
+ if (mEditUserInfoDialog != null && mEditUserPhotoController != null) {
// Bitmap cannot be stored into bundle because it may exceed parcel limit
// Store it in a temporary file instead
File file = mEditUserPhotoController.saveNewUserPhotoBitmap();
diff --git a/src/com/android/settings/vpn2/ConfigDialog.java b/src/com/android/settings/vpn2/ConfigDialog.java
index 12d91ec..26c1565 100644
--- a/src/com/android/settings/vpn2/ConfigDialog.java
+++ b/src/com/android/settings/vpn2/ConfigDialog.java
@@ -348,14 +348,14 @@
mView.findViewById(R.id.vpn_proxy_fields).setVisibility(visible);
}
- private boolean hasAdvancedOptionsEnabled() {
+ private boolean isAdvancedOptionsEnabled() {
return mSearchDomains.getText().length() > 0 || mDnsServers.getText().length() > 0 ||
mRoutes.getText().length() > 0 || mProxyHost.getText().length() > 0
|| mProxyPort.getText().length() > 0;
}
private void configureAdvancedOptionsVisibility() {
- if (mShowOptions.isChecked() || hasAdvancedOptionsEnabled()) {
+ if (mShowOptions.isChecked() || isAdvancedOptionsEnabled()) {
mView.findViewById(R.id.options).setVisibility(View.VISIBLE);
mShowOptions.setVisibility(View.GONE);
diff --git a/tests/perftests/Android.bp b/tests/perftests/Android.bp
index 7708bbe..1ba5d9c 100644
--- a/tests/perftests/Android.bp
+++ b/tests/perftests/Android.bp
@@ -19,4 +19,4 @@
test_suites: ["device-tests"],
instrumentation_for: "Settings",
-}
\ No newline at end of file
+}
diff --git a/tests/perftests/AndroidManifest.xml b/tests/perftests/AndroidManifest.xml
index 972467f..8aae24a 100644
--- a/tests/perftests/AndroidManifest.xml
+++ b/tests/perftests/AndroidManifest.xml
@@ -15,15 +15,15 @@
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.android.settings.tests.perf">
+ package="com.android.settings.tests.perf">
<application>
- <uses-library android:name="android.test.runner"/>
+ <uses-library android:name="android.test.runner" />
</application>
<instrumentation android:name="androidx.test.runner.AndroidJUnitRunner"
- android:targetPackage="com.android.settings.tests.perf"
- android:label="Settings Performance Test Cases">
+ android:targetPackage="com.android.settings.tests.perf"
+ android:label="Settings Performance Test Cases">
</instrumentation>
</manifest>
diff --git a/tests/perftests/src/com/android/settings/tests/perf/LaunchSettingsTest.java b/tests/perftests/src/com/android/settings/tests/perf/LaunchSettingsTest.java
index f55598c..a8c5230 100644
--- a/tests/perftests/src/com/android/settings/tests/perf/LaunchSettingsTest.java
+++ b/tests/perftests/src/com/android/settings/tests/perf/LaunchSettingsTest.java
@@ -21,8 +21,10 @@
import android.app.Instrumentation;
import android.os.Bundle;
+import android.util.Log;
import android.support.test.uiautomator.By;
import android.support.test.uiautomator.UiDevice;
+import android.support.test.uiautomator.UiSelector;
import android.support.test.uiautomator.Until;
import androidx.test.InstrumentationRegistry;
@@ -34,9 +36,9 @@
import org.junit.runner.RunWith;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
+import java.util.Collections;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -54,10 +56,13 @@
}
}
+ private static final String SCREEN_TIME_OUT = "7200000";
+ private static final String DEFAULT_SCREEN_TIMEOUT = "15000";
private static final int TIME_OUT = 5000;
private static final int TEST_TIME = 10;
private static final Pattern PATTERN = Pattern.compile("TotalTime:\\s[0-9]*");
private static final Page[] PAGES;
+ private static final String TAG = "SettingsPerfTests";
static {
PAGES = new Page[]{
@@ -65,7 +70,8 @@
new Page("android.settings.WIFI_SETTINGS", "Use Wi‑Fi", "Wi-Fi"),
new Page("android.settings.BLUETOOTH_SETTINGS", "Connected devices", "BlueTooth"),
new Page("android.settings.APPLICATION_SETTINGS", "App info", "Application"),
- new Page("android.intent.action.POWER_USAGE_SUMMARY", "Battery", "Battery")
+ new Page("android.intent.action.POWER_USAGE_SUMMARY", "Battery", "Battery"),
+ new Page("android.settings.INTERNAL_STORAGE_SETTINGS", "Storage", "Storage")
};
}
@@ -73,6 +79,8 @@
private UiDevice mDevice;
private Instrumentation mInstrumentation;
private Map<String, ArrayList<Integer>> mResult;
+ private String mDefaultScreenTimeout;
+ private String mDefaultAirplaneModeStatus;
@Before
public void setUp() throws Exception {
@@ -80,6 +88,11 @@
mDevice = UiDevice.getInstance(getInstrumentation());
mInstrumentation = InstrumentationRegistry.getInstrumentation();
mResult = new LinkedHashMap<>();
+ mDefaultScreenTimeout = mDevice.executeShellCommand(
+ "settings get system screen_off_timeout");
+ mDefaultAirplaneModeStatus = getAirplaneModeStatus();
+ setScreenTimeOut(SCREEN_TIME_OUT);
+ setAirplaneMode();
mDevice.pressHome();
mDevice.waitForIdle(TIME_OUT);
@@ -92,6 +105,9 @@
public void tearDown() throws Exception {
putResultToBundle();
mInstrumentation.sendStatus(0, mBundle);
+ resetScreenTimeout();
+ resetAirplaneMode();
+ closeApp();
}
@Test
@@ -105,19 +121,19 @@
private void executePreformanceTest(String action, String displayName, String title)
throws Exception {
+ closeApp();
+ mDevice.waitForIdle(TIME_OUT);
final String mString = mDevice.executeShellCommand("am start -W -a" + action);
mDevice.wait(Until.findObject(By.text(displayName)), TIME_OUT);
handleLaunchResult(title, mString);
- closeApp();
- mDevice.waitForIdle(TIME_OUT);
}
- private void handleLaunchResult(String title, String s) {
- Matcher mMatcher = PATTERN.matcher(s);
+ private void handleLaunchResult(String title, String shellCommandResult) {
+ Matcher mMatcher = PATTERN.matcher(shellCommandResult);
if (mMatcher.find()) {
mResult.get(title).add(Integer.valueOf(mMatcher.group().split("\\s")[1]));
} else {
- fail("Some pages can't be found");
+ fail(String.format("Not found %s.\n %s", title, shellCommandResult));
}
}
@@ -129,23 +145,92 @@
private void putResultToBundle() {
for (String string : mResult.keySet()) {
mBundle.putString(String.format("LaunchSettingsTest_%s_%s", string, "max"),
- getMax(mResult.get(string)));
+ getMax(string));
mBundle.putString(String.format("LaunchSettingsTest_%s_%s", string, "min"),
- getMin(mResult.get(string)));
+ getMin(string));
mBundle.putString(String.format("LaunchSettingsTest_%s_%s", string, "avg"),
- getAvg(mResult.get(string)));
+ getAvg(string));
+ mBundle.putString(String.format("LaunchSettingsTest_%s_%s", string, "25 Percentile"),
+ getPercentile(string, 25));
+ mBundle.putString(String.format("LaunchSettingsTest_%s_%s", string, "50 Percentile"),
+ getPercentile(string, 50));
+ mBundle.putString(String.format("LaunchSettingsTest_%s_%s", string, "75 Percentile"),
+ getPercentile(string, 75));
+ mBundle.putString(String.format("LaunchSettingsTest_%s_%s", string, "all_results"),
+ mResult.get(string).toString());
+ mBundle.putString(String.format("LaunchSettingsTest_%s_%s", string, "results_count"),
+ String.valueOf(mResult.get(string).size()));
}
}
- private String getMax(ArrayList<Integer> launchResult) {
- return String.format("%s", launchResult.isEmpty() ? "null" : Collections.max(launchResult));
+ private String getMax(String page) {
+ if (mResult.get(page).size() == TEST_TIME) {
+ return String.format("%s", Collections.max(mResult.get(page)));
+ }
+ Log.e(TAG, String.format("Fail to get max of %s.", page));
+ return "0";
+
}
- private String getMin(ArrayList<Integer> launchResult) {
- return String.format("%s", launchResult.isEmpty() ? "null" : Collections.min(launchResult));
+ private String getMin(String page) {
+ if (mResult.get(page).size() == TEST_TIME) {
+ return String.format("%s", Collections.min(mResult.get(page)));
+ }
+ Log.e(TAG, String.format("Fail to get min of %s.", page));
+ return "0";
}
- private String getAvg(ArrayList<Integer> launchResult) {
- return String.valueOf((int) launchResult.stream().mapToInt(i -> i).average().orElse(0));
+ private String getAvg(String page) {
+ if (mResult.get(page).size() == TEST_TIME) {
+ return String.valueOf((int) mResult.get(page).stream().mapToInt(
+ i -> i).average().orElse(0));
+ }
+ Log.e(TAG, String.format("Fail to get avg of %s.", page));
+ return "0";
+ }
+
+ private void setScreenTimeOut(String timeout) throws Exception {
+ mDevice.executeShellCommand("settings put system screen_off_timeout " + timeout);
+ }
+
+ private void resetScreenTimeout() throws Exception {
+ String timeout = DEFAULT_SCREEN_TIMEOUT;
+ if (!mDefaultScreenTimeout.isEmpty()) {
+ timeout = mDefaultScreenTimeout;
+ }
+ setScreenTimeOut(timeout);
+ }
+
+ private void setAirplaneMode() throws Exception {
+ if (mDefaultAirplaneModeStatus.equals("0\n")) {
+ clickAirplaneMode();
+ }
+ }
+
+ private void resetAirplaneMode() throws Exception {
+ if (!getAirplaneModeStatus().equals(mDefaultAirplaneModeStatus)) {
+ clickAirplaneMode();
+ }
+ }
+
+ private void clickAirplaneMode() throws Exception {
+ mDevice.executeShellCommand("am start -W -a android.settings.AIRPLANE_MODE_SETTINGS");
+ mDevice.waitForIdle(TIME_OUT);
+ mDevice.findObject(By.textContains("Airplane")).click();
+ mDevice.waitForIdle(TIME_OUT);
+ }
+
+ private String getAirplaneModeStatus() throws Exception {
+ return mDevice.executeShellCommand("settings get global airplane_mode_on");
+ }
+
+ private String getPercentile(String page, double position) {
+ Collections.sort(mResult.get(page));
+ if (mResult.get(page).size() == TEST_TIME) {
+ return String.valueOf(
+ mResult.get(page).get((int) (Math.ceil(TEST_TIME * position / 100)) - 1));
+ }
+ Log.e(TAG, String.format("Fail to get percentile of %s.", page));
+ return "0";
}
}
\ No newline at end of file