Merge "Correct typo for "Redirect vibration"" into pi-dev
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 3b74473..e2accdd 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -1166,6 +1166,17 @@
</intent-filter>
</activity-alias>
+ <activity android:name=".applications.InstalledAppOpenByDefaultPage"
+ android:label="@string/application_info_label"
+ android:permission="android.permission.OPEN_APPLICATION_DETAILS_OPEN_BY_DEFAULT_PAGE"
+ android:exported="true">
+ <intent-filter android:priority="1">
+ <action android:name="android.settings.APPLICATION_DETAILS_SETTINGS_OPEN_BY_DEFAULT_PAGE" />
+ <category android:name="android.intent.category.DEFAULT" />
+ <data android:scheme="package" />
+ </intent-filter>
+ </activity>
+
<!-- Provide direct entry into manage apps showing running services. -->
<activity android:name="Settings$RunningServicesActivity"
android:label="@string/runningservices_settings_title"
diff --git a/res/drawable-nodpi/fp_enrollment_header.png b/res/drawable-nodpi/fp_enrollment_header.png
deleted file mode 100644
index 4e7b931..0000000
--- a/res/drawable-nodpi/fp_enrollment_header.png
+++ /dev/null
Binary files differ
diff --git a/res/values-land/colors.xml b/res/values-land/colors.xml
deleted file mode 100644
index 5bab9d1..0000000
--- a/res/values-land/colors.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- ~ Copyright (C) 2015 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
- -->
-
-<resources>
- <drawable name="fp_enrollment_header">#009688</drawable>
-</resources>
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 38ab893..2fb96ec 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -54,13 +54,11 @@
<color name="running_processes_free_ram">#ffced7db</color>
<color name="wifi_divider">#ffe0e0e0</color>
- <color name="sim_noitification">@*android:color/material_deep_teal_500</color>
+ <color name="sim_noitification">@*android:color/accent_device_default_light</color>
<color name="confirm_device_credential_transparent_black">#60000000</color>
<color name="voice_interaction_highlight">#33b5e5</color>
- <drawable name="fp_enrollment_header_landscape">#009688</drawable>
-
<color name="memory_normal">#ff009587</color>
<color name="memory_moderate">#ffF3B300</color>
<color name="memory_low">#ffff9700</color>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 1a0ab36..f0d41b5 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1584,7 +1584,7 @@
<!-- Bluetooth settings: The sub heading for devices which have already been paired with this device. [CHAR LIMIT=40] -->
<string name="bluetooth_preference_paired_devices">Paired devices</string>
<!-- Bluetooth settings: The sub heading for available devices during and after scanning. [CHAR LIMIT=40] -->
- <string name="bluetooth_preference_found_devices">Available devices</string>
+ <string name="bluetooth_preference_found_media_devices">Available media devices</string>
<!-- Bluetooth settings: The message displayed if no Bluetooth devices were found. [CHAR LIMIT=40] -->
<string name="bluetooth_preference_no_found_devices">No devices available</string>
<!-- Bluetooth settings. Context menu item for a device. Action will connect to all profiles on the device. -->
@@ -4699,6 +4699,9 @@
<!-- Template for the summary of a print job. [CHAR LIMIT=25] -->
<string name="print_job_summary"><xliff:g id="printer">%1$s</xliff:g>\n<xliff:g id="time">%2$s</xliff:g></string>
+ <!-- Template for the label for a configuring print job (i.e. the user is currently selecting the paper size and printer to use). [CHAR LIMIT=25] -->
+ <string name="print_configuring_state_title_template" >Configuring <xliff:g id="print_job_name" example="foo.jpg">%1$s</xliff:g></string>
+
<!-- Template for the label of the state for a ongoing print job. [CHAR LIMIT=25] -->
<string name="print_printing_state_title_template">Printing <xliff:g id="print_job_name" example="foo.jpg">%1$s</xliff:g></string>
@@ -9561,4 +9564,7 @@
<!-- Summary for battery Suggestion. [CHAR LIMIT=55] -->
<string name="battery_suggestion_summary"></string>
+ <!-- Title for detail page of wifi network [CHAR LIMIT=30] -->
+ <string name="pref_title_network_details">Network details</string>
+
</resources>
diff --git a/res/xml/security_lockscreen_settings.xml b/res/xml/security_lockscreen_settings.xml
index 5b313b3..7cad34a 100644
--- a/res/xml/security_lockscreen_settings.xml
+++ b/res/xml/security_lockscreen_settings.xml
@@ -40,9 +40,12 @@
android:summary="@string/lockdown_settings_summary"
settings:controller="com.android.settings.security.LockdownButtonPreferenceController"/>
+ <!-- Work profile settings are at the bottom with high order value to avoid users thinking that
+ any of the above settings (including dynamic) are specific to the work profile. -->
<PreferenceCategory
android:key="security_setting_lock_screen_notif_work_header"
- android:title="@string/profile_section_header">
+ android:title="@string/profile_section_header"
+ android:order="1000">
<com.android.settings.RestrictedListPreference
android:key="security_setting_lock_screen_notif_work"
diff --git a/src/com/android/settings/applications/InstalledAppOpenByDefaultPage.java b/src/com/android/settings/applications/InstalledAppOpenByDefaultPage.java
new file mode 100644
index 0000000..40eef25
--- /dev/null
+++ b/src/com/android/settings/applications/InstalledAppOpenByDefaultPage.java
@@ -0,0 +1,36 @@
+/*
+ * 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.applications;
+
+import android.content.Intent;
+
+import com.android.settings.SettingsActivity;
+
+public class InstalledAppOpenByDefaultPage extends SettingsActivity {
+
+ @Override
+ public Intent getIntent() {
+ Intent modIntent = new Intent(super.getIntent());
+ modIntent.putExtra(EXTRA_SHOW_FRAGMENT, AppLaunchSettings.class.getName());
+ return modIntent;
+ }
+
+ @Override
+ protected boolean isValidFragment(String fragmentName) {
+ return AppLaunchSettings.class.getName().equals(fragmentName);
+ }
+}
diff --git a/src/com/android/settings/bluetooth/BluetoothPairingDetail.java b/src/com/android/settings/bluetooth/BluetoothPairingDetail.java
index 1a64f26..b31d4c8 100644
--- a/src/com/android/settings/bluetooth/BluetoothPairingDetail.java
+++ b/src/com/android/settings/bluetooth/BluetoothPairingDetail.java
@@ -148,7 +148,7 @@
mLocalAdapter.setBluetoothEnabled(true);
addDeviceCategory(mAvailableDevicesCategory,
- R.string.bluetooth_preference_found_devices,
+ R.string.bluetooth_preference_found_media_devices,
BluetoothDeviceFilter.UNBONDED_DEVICE_FILTER, mInitialScanStarted);
updateFooterPreference(mFooterPreference);
mAlwaysDiscoverable.start();
diff --git a/src/com/android/settings/datausage/DataUsageSummary.java b/src/com/android/settings/datausage/DataUsageSummary.java
index dbc3e59..81def7a 100644
--- a/src/com/android/settings/datausage/DataUsageSummary.java
+++ b/src/com/android/settings/datausage/DataUsageSummary.java
@@ -104,18 +104,10 @@
removePreference(KEY_RESTRICT_BACKGROUND);
}
if (hasMobileData) {
- List<SubscriptionInfo> subscriptions =
- services.mSubscriptionManager.getActiveSubscriptionInfoList();
- if (subscriptions == null || subscriptions.size() == 0) {
- addMobileSection(defaultSubId);
- }
- for (int i = 0; subscriptions != null && i < subscriptions.size(); i++) {
- SubscriptionInfo subInfo = subscriptions.get(i);
- if (subscriptions.size() > 1) {
- addMobileSection(subInfo.getSubscriptionId(), subInfo);
- } else {
- addMobileSection(subInfo.getSubscriptionId());
- }
+ SubscriptionInfo subInfo
+ = services.mSubscriptionManager.getDefaultDataSubscriptionInfo();
+ if (subInfo != null) {
+ addMobileSection(subInfo.getSubscriptionId());
}
}
boolean hasWifiRadio = DataUsageUtils.hasWifiRadio(context);
diff --git a/src/com/android/settings/datausage/DataUsageSummaryPreferenceController.java b/src/com/android/settings/datausage/DataUsageSummaryPreferenceController.java
index 6deced7..c33371b 100644
--- a/src/com/android/settings/datausage/DataUsageSummaryPreferenceController.java
+++ b/src/com/android/settings/datausage/DataUsageSummaryPreferenceController.java
@@ -37,7 +37,6 @@
import com.android.internal.util.CollectionUtils;
import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;
-import com.android.settings.core.FeatureFlags;
import com.android.settingslib.NetworkPolicyEditor;
import com.android.settingslib.net.DataUsageController;
@@ -150,7 +149,8 @@
@Override
public int getAvailabilityStatus() {
- return AVAILABLE;
+ return mSubscriptionManager.getDefaultDataSubscriptionInfo() != null
+ ? AVAILABLE : DISABLED_UNSUPPORTED;
}
@Override
diff --git a/src/com/android/settings/fingerprint/FingerprintEnrollEnrolling.java b/src/com/android/settings/fingerprint/FingerprintEnrollEnrolling.java
index 756f826..d89226c 100644
--- a/src/com/android/settings/fingerprint/FingerprintEnrollEnrolling.java
+++ b/src/com/android/settings/fingerprint/FingerprintEnrollEnrolling.java
@@ -30,6 +30,7 @@
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import android.hardware.fingerprint.FingerprintManager;
+import android.media.AudioAttributes;
import android.os.Bundle;
import android.os.UserHandle;
import android.os.VibrationEffect;
@@ -78,6 +79,11 @@
private static final VibrationEffect VIBRATE_EFFECT_ERROR =
VibrationEffect.createWaveform(new long[] {0, 5, 55, 60}, -1);
+ private static final AudioAttributes FINGERPRINT_ENROLLING_SONFICATION_ATTRIBUTES =
+ new AudioAttributes.Builder()
+ .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
+ .setUsage(AudioAttributes.USAGE_ASSISTANCE_SONIFICATION)
+ .build();
private ProgressBar mProgressBar;
private ObjectAnimator mProgressAnim;
@@ -376,7 +382,7 @@
mErrorText.setTranslationY(0f);
}
if (isResumed()) {
- mVibrator.vibrate(VIBRATE_EFFECT_ERROR);
+ mVibrator.vibrate(VIBRATE_EFFECT_ERROR, FINGERPRINT_ENROLLING_SONFICATION_ATTRIBUTES);
}
}
diff --git a/src/com/android/settings/fuelgauge/BatteryHistoryChart.java b/src/com/android/settings/fuelgauge/BatteryHistoryChart.java
index d44f9f8..5003254 100644
--- a/src/com/android/settings/fuelgauge/BatteryHistoryChart.java
+++ b/src/com/android/settings/fuelgauge/BatteryHistoryChart.java
@@ -363,7 +363,8 @@
mThinLineWidth = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
2, getResources().getDisplayMetrics());
- mBatteryBackgroundPaint.setColor(0xFF009688);
+ int accentColor = Utils.getColorAccent(mContext);
+ mBatteryBackgroundPaint.setColor(accentColor);
mBatteryBackgroundPaint.setStyle(Paint.Style.FILL);
mBatteryGoodPaint.setARGB(128, 0, 128, 0);
mBatteryGoodPaint.setStyle(Paint.Style.STROKE);
@@ -383,13 +384,13 @@
mPhoneSignalChart.setColors(com.android.settings.Utils.BADNESS_COLORS);
mDebugRectPaint.setARGB(255, 255, 0, 0);
mDebugRectPaint.setStyle(Paint.Style.STROKE);
- mScreenOnPaint.setColor(0xFF009688);
- mGpsOnPaint.setColor(0xFF009688);
- mCameraOnPaint.setColor(0xFF009688);
- mFlashlightOnPaint.setColor(0xFF009688);
- mWifiRunningPaint.setColor(0xFF009688);
- mCpuRunningPaint.setColor(0xFF009688);
- mChargingPaint.setColor(0xFF009688);
+ mScreenOnPaint.setColor(accentColor);
+ mGpsOnPaint.setColor(accentColor);
+ mCameraOnPaint.setColor(accentColor);
+ mFlashlightOnPaint.setColor(accentColor);
+ mWifiRunningPaint.setColor(accentColor);
+ mCpuRunningPaint.setColor(accentColor);
+ mChargingPaint.setColor(accentColor);
TypedArray a =
context.obtainStyledAttributes(
diff --git a/src/com/android/settings/fuelgauge/batterytip/AnomalyDetectionJobService.java b/src/com/android/settings/fuelgauge/batterytip/AnomalyDetectionJobService.java
index c2af02a..619913d 100644
--- a/src/com/android/settings/fuelgauge/batterytip/AnomalyDetectionJobService.java
+++ b/src/com/android/settings/fuelgauge/batterytip/AnomalyDetectionJobService.java
@@ -40,8 +40,11 @@
import android.util.Log;
import com.android.internal.os.BatteryStatsHelper;
+import com.android.internal.util.ArrayUtils;
import com.android.settings.R;
import com.android.settings.fuelgauge.BatteryUtils;
+import com.android.settings.fuelgauge.PowerUsageFeatureProvider;
+import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.fuelgauge.PowerWhitelistBackend;
import com.android.settingslib.utils.ThreadUtils;
@@ -84,11 +87,14 @@
true /* collectBatteryBroadcast */);
final UserManager userManager = getSystemService(UserManager.class);
final PowerWhitelistBackend powerWhitelistBackend = PowerWhitelistBackend.getInstance();
+ final PowerUsageFeatureProvider powerUsageFeatureProvider = FeatureFactory
+ .getFactory(this).getPowerUsageFeatureProvider(this);
for (JobWorkItem item = params.dequeueWork(); item != null;
item = params.dequeueWork()) {
saveAnomalyToDatabase(batteryStatsHelper, userManager, batteryDatabaseManager,
batteryUtils, policy, powerWhitelistBackend, contentResolver,
+ powerUsageFeatureProvider,
item.getIntent().getExtras());
}
jobFinished(params, false /* wantsReschedule */);
@@ -106,42 +112,52 @@
void saveAnomalyToDatabase(BatteryStatsHelper batteryStatsHelper, UserManager userManager,
BatteryDatabaseManager databaseManager, BatteryUtils batteryUtils,
BatteryTipPolicy policy, PowerWhitelistBackend powerWhitelistBackend,
- ContentResolver contentResolver, Bundle bundle) {
+ ContentResolver contentResolver, PowerUsageFeatureProvider powerUsageFeatureProvider,
+ Bundle bundle) {
// The Example of intentDimsValue is: 35:{1:{1:{1:10013|}|}|}
final StatsDimensionsValue intentDimsValue =
bundle.getParcelable(StatsManager.EXTRA_STATS_DIMENSIONS_VALUE);
- final long subscriptionId = bundle.getLong(StatsManager.EXTRA_STATS_SUBSCRIPTION_ID,
- -1);
final long timeMs = bundle.getLong(AnomalyDetectionReceiver.KEY_ANOMALY_TIMESTAMP,
System.currentTimeMillis());
+ final String[] cookies = bundle.getStringArray(
+ StatsManager.EXTRA_STATS_BROADCAST_SUBSCRIBER_COOKIES);
+ final AnomalyInfo anomalyInfo = new AnomalyInfo(
+ !ArrayUtils.isEmpty(cookies) ? cookies[0] : "");
Log.i(TAG, "Extra stats value: " + intentDimsValue.toString());
try {
final int uid = extractUidFromStatsDimensionsValue(intentDimsValue);
- final int anomalyType = StatsManagerConfig.getAnomalyTypeFromSubscriptionId(
- subscriptionId);
- final boolean smartBatteryOn = Settings.Global.getInt(contentResolver,
- Settings.Global.APP_STANDBY_ENABLED, ON) == ON;
+ final boolean autoFeatureOn = powerUsageFeatureProvider.isSmartBatterySupported()
+ ? Settings.Global.getInt(contentResolver,
+ Settings.Global.APP_STANDBY_ENABLED, ON) == ON
+ : Settings.Global.getInt(contentResolver,
+ Settings.Global.APP_AUTO_RESTRICTION_ENABLED, ON) == ON;
final String packageName = batteryUtils.getPackageName(uid);
if (!powerWhitelistBackend.isSysWhitelistedExceptIdle(packageName)
&& !isSystemUid(uid)) {
- if (anomalyType == StatsManagerConfig.AnomalyType.EXCESSIVE_BG) {
- // TODO(b/72385333): check battery percentage draining in batterystats
- if (batteryUtils.isPreOApp(packageName) && batteryUtils.isAppHeavilyUsed(
- batteryStatsHelper, userManager, uid,
+ boolean anomalyDetected = true;
+ if (anomalyInfo.anomalyType == StatsManagerConfig.AnomalyType.EXCESSIVE_BG) {
+ if (!batteryUtils.isPreOApp(packageName)
+ || !batteryUtils.isAppHeavilyUsed(batteryStatsHelper, userManager, uid,
policy.excessiveBgDrainPercentage)) {
- Log.e(TAG, "Excessive detected uid=" + uid);
+ // Don't report if it is not legacy app or haven't used much battery
+ anomalyDetected = false;
+ }
+ }
+
+ if (anomalyDetected) {
+ if (autoFeatureOn && anomalyInfo.autoRestriction) {
+ // Auto restrict this app
batteryUtils.setForceAppStandby(uid, packageName,
AppOpsManager.MODE_IGNORED);
- databaseManager.insertAnomaly(uid, packageName, anomalyType,
- smartBatteryOn
- ? AnomalyDatabaseHelper.State.AUTO_HANDLED
- : AnomalyDatabaseHelper.State.NEW,
+ databaseManager.insertAnomaly(uid, packageName, anomalyInfo.anomalyType,
+ AnomalyDatabaseHelper.State.AUTO_HANDLED,
+ timeMs);
+ } else {
+ databaseManager.insertAnomaly(uid, packageName, anomalyInfo.anomalyType,
+ AnomalyDatabaseHelper.State.NEW,
timeMs);
}
- } else {
- databaseManager.insertAnomaly(uid, packageName, anomalyType,
- AnomalyDatabaseHelper.State.NEW, timeMs);
}
}
} catch (NullPointerException | IndexOutOfBoundsException e) {
diff --git a/src/com/android/settings/fuelgauge/batterytip/AnomalyInfo.java b/src/com/android/settings/fuelgauge/batterytip/AnomalyInfo.java
new file mode 100644
index 0000000..a4077be
--- /dev/null
+++ b/src/com/android/settings/fuelgauge/batterytip/AnomalyInfo.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.fuelgauge.batterytip;
+
+import android.util.KeyValueListParser;
+
+/**
+ * Model class to parse and store anomaly info from westworld
+ */
+public class AnomalyInfo {
+ private static final String KEY_ANOMALY_TYPE = "anomaly_type";
+ private static final String KEY_AUTO_RESTRICTION = "auto_restriction";
+ public final Integer anomalyType;
+ public final boolean autoRestriction;
+
+ public AnomalyInfo(String info) {
+ KeyValueListParser parser = new KeyValueListParser(',');
+ parser.setString(info);
+ anomalyType = parser.getInt(KEY_ANOMALY_TYPE, -1);
+ autoRestriction = parser.getBoolean(KEY_AUTO_RESTRICTION, false);
+ }
+
+}
\ No newline at end of file
diff --git a/src/com/android/settings/fuelgauge/batterytip/StatsManagerConfig.java b/src/com/android/settings/fuelgauge/batterytip/StatsManagerConfig.java
index 62eb7ee..4ae3f10 100644
--- a/src/com/android/settings/fuelgauge/batterytip/StatsManagerConfig.java
+++ b/src/com/android/settings/fuelgauge/batterytip/StatsManagerConfig.java
@@ -41,22 +41,6 @@
*/
public static final long SUBSCRIBER_ID = 1;
- private static final Map<Long, Integer> ANOMALY_TYPE;
-
- private static final HashFunction HASH_FUNCTION = Hashing.sha256();
-
- static {
- ANOMALY_TYPE = new HashMap<>();
- ANOMALY_TYPE.put(hash("SUBSCRIPTION:SETTINGS_EXCESSIVE_BACKGROUND_SERVICE"),
- AnomalyType.EXCESSIVE_BG);
- ANOMALY_TYPE.put(hash("SUBSCRIPTION:SETTINGS_LONG_UNOPTIMIZED_BLE_SCAN"),
- AnomalyType.BLUETOOTH_SCAN);
- ANOMALY_TYPE.put(hash("SUBSCRIPTION:SETTINGS_EXCESSIVE_WAKEUPS_IN_BACKGROUND"),
- AnomalyType.WAKEUP_ALARM);
- ANOMALY_TYPE.put(hash("SUBSCRIPTION:SETTINGS_EXCESSIVE_WAKELOCK_ALL_SCREEN_OFF"),
- AnomalyType.WAKE_LOCK);
- }
-
@Retention(RetentionPolicy.SOURCE)
@IntDef({AnomalyType.NULL,
AnomalyType.WAKE_LOCK,
@@ -71,11 +55,4 @@
int EXCESSIVE_BG = 3;
}
- public static int getAnomalyTypeFromSubscriptionId(long subscriptionId) {
- return ANOMALY_TYPE.getOrDefault(subscriptionId, AnomalyType.NULL);
- }
-
- private static long hash(CharSequence value) {
- return HASH_FUNCTION.hashUnencodedChars(value).asLong();
- }
}
diff --git a/src/com/android/settings/inputmethod/KeyboardLayoutDialogFragment.java b/src/com/android/settings/inputmethod/KeyboardLayoutDialogFragment.java
index 3a62d0e..e100dd2 100644
--- a/src/com/android/settings/inputmethod/KeyboardLayoutDialogFragment.java
+++ b/src/com/android/settings/inputmethod/KeyboardLayoutDialogFragment.java
@@ -55,7 +55,6 @@
private int mInputDeviceId = -1;
private InputManager mIm;
private KeyboardLayoutAdapter mAdapter;
- private boolean mHasShownLayoutSelectionScreen;
public KeyboardLayoutDialogFragment() {
}
@@ -187,7 +186,6 @@
dialog.getListView().setItemChecked(data.current, true);
}
updateSwitchHintVisibility();
- showSetupKeyboardLayoutsIfNecessary();
}
@Override
@@ -222,17 +220,6 @@
}
}
- private void showSetupKeyboardLayoutsIfNecessary() {
- AlertDialog dialog = (AlertDialog)getDialog();
- if (dialog != null
- && mAdapter.getCount() == 1 && mAdapter.getItem(0) == null
- && !mHasShownLayoutSelectionScreen) {
- mHasShownLayoutSelectionScreen = true;
- ((OnSetupKeyboardLayoutsListener)getTargetFragment()).onSetupKeyboardLayouts(
- mInputDeviceIdentifier);
- }
- }
-
private static final class KeyboardLayoutAdapter extends ArrayAdapter<KeyboardLayout> {
private final LayoutInflater mInflater;
private int mCheckedItem = -1;
diff --git a/src/com/android/settings/inputmethod/PhysicalKeyboardFragment.java b/src/com/android/settings/inputmethod/PhysicalKeyboardFragment.java
index a02a6d0..36f4e92 100644
--- a/src/com/android/settings/inputmethod/PhysicalKeyboardFragment.java
+++ b/src/com/android/settings/inputmethod/PhysicalKeyboardFragment.java
@@ -187,13 +187,10 @@
}
private void showKeyboardLayoutDialog(InputDeviceIdentifier inputDeviceIdentifier) {
- KeyboardLayoutDialogFragment fragment = (KeyboardLayoutDialogFragment)
- getFragmentManager().findFragmentByTag("keyboardLayout");
- if (fragment == null) {
- fragment = new KeyboardLayoutDialogFragment(inputDeviceIdentifier);
- fragment.setTargetFragment(this, 0);
- fragment.show(getActivity().getFragmentManager(), "keyboardLayout");
- }
+ KeyboardLayoutDialogFragment fragment = new KeyboardLayoutDialogFragment(
+ inputDeviceIdentifier);
+ fragment.setTargetFragment(this, 0);
+ fragment.show(getActivity().getFragmentManager(), "keyboardLayout");
}
private void registerShowVirtualKeyboardSettingsObserver() {
diff --git a/src/com/android/settings/print/PrintJobSettingsFragment.java b/src/com/android/settings/print/PrintJobSettingsFragment.java
index 7142e49..c16642a 100644
--- a/src/com/android/settings/print/PrintJobSettingsFragment.java
+++ b/src/com/android/settings/print/PrintJobSettingsFragment.java
@@ -28,6 +28,7 @@
import android.support.v7.preference.Preference;
import android.text.TextUtils;
import android.text.format.DateUtils;
+import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
@@ -45,6 +46,8 @@
* Fragment for management of a print job.
*/
public class PrintJobSettingsFragment extends SettingsPreferenceFragment {
+ private static final String LOG_TAG = PrintJobSettingsFragment.class.getSimpleName();
+
private static final int MENU_ITEM_ID_CANCEL = 1;
private static final int MENU_ITEM_ID_RESTART = 2;
@@ -164,10 +167,17 @@
private void processArguments() {
String printJobId = getArguments().getString(EXTRA_PRINT_JOB_ID);
if (printJobId == null) {
- finish();
- } else {
- mPrintJobId = PrintJobId.unflattenFromString(printJobId);
+ printJobId = getIntent().getStringExtra(EXTRA_PRINT_JOB_ID);
+
+ if (printJobId == null) {
+ Log.w(LOG_TAG, EXTRA_PRINT_JOB_ID + " not set");
+ finish();
+ return;
+ }
}
+
+
+ mPrintJobId = PrintJobId.unflattenFromString(printJobId);
}
private PrintJob getPrintJob() {
@@ -190,6 +200,10 @@
PrintJobInfo info = printJob.getInfo();
switch (info.getState()) {
+ case PrintJobInfo.STATE_CREATED: {
+ mPrintJobPreference.setTitle(getString(
+ R.string.print_configuring_state_title_template, info.getLabel()));
+ } break;
case PrintJobInfo.STATE_QUEUED:
case PrintJobInfo.STATE_STARTED: {
if (!printJob.getInfo().isCancelling()) {
diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java
index 4f67012..7c1b725 100644
--- a/src/com/android/settings/wifi/WifiSettings.java
+++ b/src/com/android/settings/wifi/WifiSettings.java
@@ -876,7 +876,7 @@
private void launchNetworkDetailsFragment(ConnectedAccessPointPreference pref) {
new SubSettingLauncher(getContext())
- .setTitle(pref.getTitle())
+ .setTitle(getContext().getString(R.string.pref_title_network_details))
.setDestination(WifiNetworkDetailsFragment.class.getName())
.setArguments(pref.getExtras())
.setSourceMetricsCategory(getMetricsCategory())
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothPairingDetailTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothPairingDetailTest.java
index 1364c63..ece706d 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothPairingDetailTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothPairingDetailTest.java
@@ -114,7 +114,7 @@
mFragment.updateContent(BluetoothAdapter.STATE_ON);
verify(mFragment).addDeviceCategory(mAvailableDevicesCategory,
- R.string.bluetooth_preference_found_devices,
+ R.string.bluetooth_preference_found_media_devices,
BluetoothDeviceFilter.UNBONDED_DEVICE_FILTER, false);
verify(mLocalAdapter).setScanMode(BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE);
}
diff --git a/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryPreferenceControllerTest.java
index 1914250..634fe65 100644
--- a/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryPreferenceControllerTest.java
@@ -16,6 +16,9 @@
package com.android.settings.datausage;
+import static com.android.settings.core.BasePreferenceController.AVAILABLE;
+import static com.android.settings.core.BasePreferenceController.DISABLED_UNSUPPORTED;
+import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;
@@ -25,6 +28,8 @@
import android.content.Context;
import android.content.Intent;
import android.net.NetworkTemplate;
+import android.telephony.SubscriptionInfo;
+import android.telephony.SubscriptionManager;
import com.android.settings.R;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
@@ -61,6 +66,8 @@
private NetworkPolicyEditor mPolicyEditor;
@Mock
private NetworkTemplate mNetworkTemplate;
+ @Mock
+ private SubscriptionManager mSubscriptionManager;
private Context mContext;
private DataUsageSummaryPreferenceController mController;
@@ -230,6 +237,40 @@
verify(mSummaryPreference).setLimitInfo("1.00 MB data warning / 1.00 MB data limit");
}
+ @Test
+ public void testMobileData_preferenceAvailable() {
+ mController = new DataUsageSummaryPreferenceController(
+ mContext,
+ mDataUsageController,
+ mDataInfoController,
+ mNetworkTemplate,
+ mPolicyEditor,
+ R.string.cell_data_template,
+ true,
+ mSubscriptionManager);
+
+ final SubscriptionInfo subInfo = new SubscriptionInfo(0, "123456", 0, "name", "carrier",
+ 0, 0, "number", 0, null, 123, 456, "ZX");
+ when(mSubscriptionManager.getDefaultDataSubscriptionInfo()).thenReturn(subInfo);
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
+ }
+
+ @Test
+ public void testMobileData_preferenceDisabled() {
+ mController = new DataUsageSummaryPreferenceController(
+ mContext,
+ mDataUsageController,
+ mDataInfoController,
+ mNetworkTemplate,
+ mPolicyEditor,
+ R.string.cell_data_template,
+ true,
+ mSubscriptionManager);
+
+ when(mSubscriptionManager.getDefaultDataSubscriptionInfo()).thenReturn(null);
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(DISABLED_UNSUPPORTED);
+ }
+
private DataUsageController.DataUsageInfo createTestDataUsageInfo(long now) {
DataUsageController.DataUsageInfo info = new DataUsageController.DataUsageInfo();
info.carrier = CARRIER_NAME;
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/AnomalyDetectionJobServiceTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/AnomalyDetectionJobServiceTest.java
index 499ab9d..d2b11fd 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batterytip/AnomalyDetectionJobServiceTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterytip/AnomalyDetectionJobServiceTest.java
@@ -22,6 +22,7 @@
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyLong;
import static org.mockito.Matchers.anyString;
+import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
@@ -41,6 +42,8 @@
import com.android.internal.os.BatteryStatsHelper;
import com.android.settings.R;
import com.android.settings.fuelgauge.BatteryUtils;
+import com.android.settings.overlay.FeatureFactory;
+import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settingslib.fuelgauge.PowerWhitelistBackend;
@@ -60,6 +63,10 @@
public class AnomalyDetectionJobServiceTest {
private static final int UID = 123;
private static final String SYSTEM_PACKAGE = "com.android.system";
+ private static final String SUBSCRIBER_COOKIES_AUTO_RESTRICTION =
+ "anomaly_type=6,auto_restriction=true";
+ private static final String SUBSCRIBER_COOKIES_NOT_AUTO_RESTRICTION =
+ "anomaly_type=6,auto_restriction=false";
@Mock
private BatteryStatsHelper mBatteryStatsHelper;
@Mock
@@ -76,6 +83,7 @@
private BatteryTipPolicy mPolicy;
private Bundle mBundle;
private AnomalyDetectionJobService mAnomalyDetectionJobService;
+ private FakeFeatureFactory mFeatureFactory;
private Context mContext;
@Before
@@ -86,6 +94,7 @@
mPolicy = new BatteryTipPolicy(mContext);
mBundle = new Bundle();
mBundle.putParcelable(StatsManager.EXTRA_STATS_DIMENSIONS_VALUE, mStatsDimensionsValue);
+ mFeatureFactory = FakeFeatureFactory.setupForTest();
mAnomalyDetectionJobService = spy(new AnomalyDetectionJobService());
}
@@ -112,7 +121,7 @@
mAnomalyDetectionJobService.saveAnomalyToDatabase(mBatteryStatsHelper, mUserManager,
mBatteryDatabaseManager, mBatteryUtils, mPolicy, mPowerWhitelistBackend,
- mContext.getContentResolver(), mBundle);
+ mContext.getContentResolver(), mFeatureFactory.powerUsageFeatureProvider, mBundle);
verify(mBatteryDatabaseManager, never()).insertAnomaly(anyInt(), anyString(), anyInt(),
anyInt(), anyLong());
@@ -125,14 +134,16 @@
mAnomalyDetectionJobService.saveAnomalyToDatabase(mBatteryStatsHelper, mUserManager,
mBatteryDatabaseManager, mBatteryUtils, mPolicy, mPowerWhitelistBackend,
- mContext.getContentResolver(), mBundle);
+ mContext.getContentResolver(), mFeatureFactory.powerUsageFeatureProvider, mBundle);
verify(mBatteryDatabaseManager, never()).insertAnomaly(anyInt(), anyString(), anyInt(),
anyInt(), anyLong());
}
@Test
- public void testSaveAnomalyToDatabase_normalApp_save() {
+ public void testSaveAnomalyToDatabase_normalAppWithAutoRestriction_save() {
+ mBundle.putStringArray(StatsManager.EXTRA_STATS_BROADCAST_SUBSCRIBER_COOKIES,
+ new String[]{SUBSCRIBER_COOKIES_AUTO_RESTRICTION});
doReturn(SYSTEM_PACKAGE).when(mBatteryUtils).getPackageName(anyInt());
doReturn(false).when(mPowerWhitelistBackend).isSysWhitelisted(SYSTEM_PACKAGE);
doReturn(Process.FIRST_APPLICATION_UID).when(
@@ -140,9 +151,27 @@
mAnomalyDetectionJobService.saveAnomalyToDatabase(mBatteryStatsHelper, mUserManager,
mBatteryDatabaseManager, mBatteryUtils, mPolicy, mPowerWhitelistBackend,
- mContext.getContentResolver(), mBundle);
+ mContext.getContentResolver(), mFeatureFactory.powerUsageFeatureProvider, mBundle);
- verify(mBatteryDatabaseManager).insertAnomaly(anyInt(), anyString(), anyInt(), anyInt(),
- anyLong());
+ verify(mBatteryDatabaseManager).insertAnomaly(anyInt(), anyString(), eq(6),
+ eq(AnomalyDatabaseHelper.State.AUTO_HANDLED), anyLong());
+ }
+
+
+ @Test
+ public void testSaveAnomalyToDatabase_normalAppWithoutAutoRestriction_save() {
+ mBundle.putStringArray(StatsManager.EXTRA_STATS_BROADCAST_SUBSCRIBER_COOKIES,
+ new String[]{SUBSCRIBER_COOKIES_NOT_AUTO_RESTRICTION});
+ doReturn(SYSTEM_PACKAGE).when(mBatteryUtils).getPackageName(anyInt());
+ doReturn(false).when(mPowerWhitelistBackend).isSysWhitelisted(SYSTEM_PACKAGE);
+ doReturn(Process.FIRST_APPLICATION_UID).when(
+ mAnomalyDetectionJobService).extractUidFromStatsDimensionsValue(any());
+
+ mAnomalyDetectionJobService.saveAnomalyToDatabase(mBatteryStatsHelper, mUserManager,
+ mBatteryDatabaseManager, mBatteryUtils, mPolicy, mPowerWhitelistBackend,
+ mContext.getContentResolver(), mFeatureFactory.powerUsageFeatureProvider, mBundle);
+
+ verify(mBatteryDatabaseManager).insertAnomaly(anyInt(), anyString(), eq(6),
+ eq(AnomalyDatabaseHelper.State.NEW), anyLong());
}
}
diff --git a/tests/unit/AndroidManifest.xml b/tests/unit/AndroidManifest.xml
index 0563753..3eacab8 100644
--- a/tests/unit/AndroidManifest.xml
+++ b/tests/unit/AndroidManifest.xml
@@ -70,9 +70,4 @@
android:label="Settings Test Cases">
</instrumentation>
- <instrumentation android:name="com.android.settings.tests.SettingsLaunchPerformance"
- android:targetPackage="com.android.settings"
- android:label="Settings Launch Performance">
- </instrumentation>
-
</manifest>
diff --git a/tests/unit/src/com/android/settings/print/PrintJobSettingsActivityTest.java b/tests/unit/src/com/android/settings/print/PrintJobSettingsActivityTest.java
new file mode 100644
index 0000000..da351e7
--- /dev/null
+++ b/tests/unit/src/com/android/settings/print/PrintJobSettingsActivityTest.java
@@ -0,0 +1,142 @@
+/*
+ * 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.print;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assume.assumeTrue;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.net.Uri;
+import android.os.Bundle;
+import android.os.CancellationSignal;
+import android.os.ParcelFileDescriptor;
+import android.print.PageRange;
+import android.print.PrintAttributes;
+import android.print.PrintDocumentAdapter;
+import android.print.PrintDocumentInfo;
+import android.print.PrintJob;
+import android.print.PrintManager;
+import android.support.annotation.NonNull;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.filters.LargeTest;
+import android.support.test.rule.ActivityTestRule;
+import android.support.test.runner.AndroidJUnit4;
+import android.support.test.uiautomator.By;
+import android.support.test.uiautomator.UiDevice;
+import android.support.test.uiautomator.UiObject2;
+import android.support.test.uiautomator.Until;
+import android.util.Log;
+
+import com.android.settings.Settings;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.UUID;
+
+@RunWith(AndroidJUnit4.class)
+public class PrintJobSettingsActivityTest {
+ private static final String EXTRA_PRINT_JOB_ID = "EXTRA_PRINT_JOB_ID";
+ private static final String LOG_TAG = PrintJobSettingsActivityTest.class.getSimpleName();
+
+ // Any activity is fine
+ @Rule
+ public final ActivityTestRule<Settings.PrintSettingsActivity> mActivityRule =
+ new ActivityTestRule<>(Settings.PrintSettingsActivity.class, true);
+
+ public static void runShellCommand(@NonNull String cmd) throws IOException {
+ ParcelFileDescriptor stdOut =
+ InstrumentationRegistry.getInstrumentation().getUiAutomation().executeShellCommand(
+ cmd);
+
+ try (FileInputStream fis = new ParcelFileDescriptor.AutoCloseInputStream(stdOut)) {
+ byte[] buf = new byte[512];
+ while (fis.read(buf) != -1) {
+ // keep reading
+ }
+ }
+ }
+
+ @Before
+ public void requirePrintFeature() {
+ assumeTrue(InstrumentationRegistry.getTargetContext().getPackageManager().hasSystemFeature(
+ PackageManager.FEATURE_PRINTING));
+ }
+
+ @Before
+ public void wakeUpScreen() throws Exception {
+ runShellCommand("input keyevent KEYCODE_WAKEUP");
+ }
+
+ @Test
+ @LargeTest
+ public void viewPrintJobSettings() throws Exception {
+ UUID uuid = UUID.randomUUID();
+ Object isWriteCalled = new Object();
+
+ // Create adapter that is good enough to start a print preview
+ PrintDocumentAdapter adapter = new PrintDocumentAdapter() {
+ @Override
+ public void onLayout(PrintAttributes oldAttributes, PrintAttributes newAttributes,
+ CancellationSignal cancellationSignal,
+ LayoutResultCallback callback, Bundle extras) {
+ callback.onLayoutFinished(new PrintDocumentInfo.Builder(uuid.toString()).build(),
+ true);
+ }
+
+ @Override
+ public void onWrite(PageRange[] pages, ParcelFileDescriptor destination,
+ CancellationSignal cancellationSignal,
+ WriteResultCallback callback) {
+ synchronized (isWriteCalled) {
+ isWriteCalled.notify();
+ }
+ callback.onWriteFailed(null);
+ }
+ };
+
+ Activity activity = mActivityRule.getActivity();
+ PrintManager pm = mActivityRule.getActivity().getSystemService(PrintManager.class);
+
+ // Start printing
+ PrintJob printJob = pm.print(uuid.toString(), adapter, null);
+
+ // Wait until print preview is up
+ synchronized (isWriteCalled) {
+ isWriteCalled.wait();
+ }
+
+ // Start print job settings
+ Intent intent = new Intent(android.provider.Settings.ACTION_PRINT_SETTINGS);
+ intent.putExtra(EXTRA_PRINT_JOB_ID, printJob.getId().flattenToString());
+ intent.setData(Uri.fromParts("printjob", printJob.getId().flattenToString(), null));
+ activity.startActivity(intent);
+
+ UiDevice uiDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
+ UiObject2 printPrefTitle = uiDevice.wait(Until.findObject(By.text("Configuring "
+ + uuid.toString())), 5000);
+ assertNotNull(printPrefTitle);
+
+ Log.i(LOG_TAG, "Found " + printPrefTitle.getText());
+ }
+}
diff --git a/tests/unit/src/com/android/settings/tests/SettingsLaunchPerformance.java b/tests/unit/src/com/android/settings/tests/SettingsLaunchPerformance.java
deleted file mode 100644
index 225a60b..0000000
--- a/tests/unit/src/com/android/settings/tests/SettingsLaunchPerformance.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (C) 2007 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;
-
-import android.app.Activity;
-import android.test.LaunchPerformanceBase;
-import android.os.Bundle;
-
-import java.util.Map;
-
-/**
- * Instrumentation class for Settings launch performance testing.
- */
-public class SettingsLaunchPerformance extends LaunchPerformanceBase {
-
- public static final String LOG_TAG = "SettingsLaunchPerformance";
-
- public SettingsLaunchPerformance() {
- super();
- }
-
- @Override
- public void onCreate(Bundle arguments) {
- super.onCreate(arguments);
-
- mIntent.setClassName(getTargetContext(), "com.android.settings.Settings");
- start();
- }
-
- /**
- * Calls LaunchApp and finish.
- */
- @Override
- public void onStart() {
- super.onStart();
- LaunchApp();
- finish(Activity.RESULT_OK, mResults);
- }
-}