Snap for 4716599 from 17a463130e to pi-release
Change-Id: I0ef338cf3b7eb4f2cbeacca2873e706ba3cfb9ab
This commit is contained in:
@@ -207,6 +207,8 @@
|
||||
android:value="com.android.settings.category.ia.homepage"/>
|
||||
<meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
|
||||
android:value="true" />
|
||||
<meta-data android:name="android.metadata.SLICE_URI"
|
||||
android:value="content://android.settings.slices/action/toggle_bluetooth_switch" />
|
||||
</activity>
|
||||
|
||||
<activity android:name="AirplaneModeVoiceActivity"
|
||||
@@ -2235,6 +2237,8 @@
|
||||
android:value="com.android.settings.category.ia.homepage" />
|
||||
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
||||
android:value="com.android.settings.fuelgauge.PowerUsageSummary" />
|
||||
<meta-data android:name="android.metadata.SLICE_URI"
|
||||
android:value="content://android.settings.slices/action/auto_brightness" />
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
@@ -2251,6 +2255,8 @@
|
||||
android:value="com.android.settings.fuelgauge.batterysaver.BatterySaverSettings" />
|
||||
<meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
|
||||
android:value="true" />
|
||||
<meta-data android:name="android.metadata.SLICE_URI"
|
||||
android:value="content://android.settings.slices/action/battery_saver_summary" />
|
||||
</activity>
|
||||
|
||||
<activity android:name=".fuelgauge.BatterySaverModeVoiceActivity"
|
||||
@@ -2670,6 +2676,8 @@
|
||||
android:value="true" />
|
||||
<meta-data android:name="com.android.settings.summary"
|
||||
android:resource="@string/sound_dashboard_summary"/>
|
||||
<meta-data android:name="android.metadata.SLICE_URI"
|
||||
android:value="content://android.settings.slices/action/alarm_volume" />
|
||||
</activity>
|
||||
|
||||
<!-- Show apps for which application-level notification settings are applicable -->
|
||||
|
||||
BIN
res/drawable-nodpi/gesture_swipe_up.png
Normal file
BIN
res/drawable-nodpi/gesture_swipe_up.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 25 KiB |
@@ -120,6 +120,14 @@
|
||||
android:clipToPadding="false"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<!-- left : skip -->
|
||||
<Button android:id="@+id/skip_button"
|
||||
style="@style/SuwGlifButton.Secondary"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/skip_label"
|
||||
android:visibility="gone" />
|
||||
|
||||
<!-- left / top button: skip, or re-try -->
|
||||
<Button android:id="@+id/footerLeftButton"
|
||||
style="@style/SetupWizardButton.Negative"
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
-->
|
||||
|
||||
<!-- TODO: Use aapt:attr when it is fixed (b/36809755) -->
|
||||
<LinearLayout
|
||||
<com.android.setupwizardlib.view.ButtonBarLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
style="@style/SuwGlifButtonBar"
|
||||
style="@style/SuwGlifButtonBar.Stackable"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
@@ -49,4 +49,4 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/lockpattern_tutorial_continue_label" />
|
||||
|
||||
</LinearLayout>
|
||||
</com.android.setupwizardlib.view.ButtonBarLayout>
|
||||
|
||||
BIN
res/raw/gesture_swipe_up.mp4
Normal file
BIN
res/raw/gesture_swipe_up.mp4
Normal file
Binary file not shown.
@@ -4899,10 +4899,6 @@
|
||||
<string name="background_activity_title">Background restriction</string>
|
||||
<!-- Summary for the background activity [CHAR_LIMIT=120] -->
|
||||
<string name="background_activity_summary">Allow the app to run in the background</string>
|
||||
<!-- Summary for the background activity when it is on [CHAR_LIMIT=120] -->
|
||||
<string name="background_activity_summary_on">App can run in the background when not in use</string>
|
||||
<!-- Summary for the background activity when it is off [CHAR_LIMIT=120] -->
|
||||
<string name="background_activity_summary_off">App\'s background activity is limited when not in use</string>
|
||||
<!-- Summary for the background activity when it is disabled [CHAR_LIMIT=120] -->
|
||||
<string name="background_activity_summary_disabled">App not allowed to run in background</string>
|
||||
<!-- TODO: Pending UX review. Summary for the background activity when it is whitlisted [CHAR_LIMIT=120] -->
|
||||
@@ -5023,11 +5019,11 @@
|
||||
<!-- Summary for the battery high usage tip, which presents battery may run out soon [CHAR LIMIT=NONE] -->
|
||||
<string name="battery_tip_high_usage_summary">Battery may run out soon</string>
|
||||
<!-- Message for battery tip dialog to show the status about the battery [CHAR LIMIT=NONE] -->
|
||||
<string name="battery_tip_dialog_message" product="default">Your phone has been used more than usual. Your battery may run out sooner than expected.\n\nTop <xliff:g id="number">%1$d</xliff:g> apps since last charge:</string>
|
||||
<string name="battery_tip_dialog_message" product="default">Your phone has been used more than usual. Your battery may run out sooner than expected.\n\nTop <xliff:g id="number">%1$d</xliff:g> apps since last full charge(<xliff:g id="time_period_ago" example="1 hr ago">%2$s</xliff:g>):</string>
|
||||
<!-- Message for battery tip dialog to show the status about the battery [CHAR LIMIT=NONE] -->
|
||||
<string name="battery_tip_dialog_message" product="tablet">Your tablet has been used more than usual. Your battery may run out sooner than expected.\n\nTop <xliff:g id="number">%1$d</xliff:g> apps since last charge:</string>
|
||||
<string name="battery_tip_dialog_message" product="tablet">Your tablet has been used more than usual. Your battery may run out sooner than expected.\n\nTop <xliff:g id="number">%1$d</xliff:g> apps since last full charge(<xliff:g id="time_period_ago" example="1 hr ago">%2$s</xliff:g>):</string>
|
||||
<!-- Message for battery tip dialog to show the status about the battery [CHAR LIMIT=NONE] -->
|
||||
<string name="battery_tip_dialog_message" product="device">Your device has been used more than usual. Your battery may run out sooner than expected.\n\nTop <xliff:g id="number">%1$d</xliff:g> apps since last charge:</string>
|
||||
<string name="battery_tip_dialog_message" product="device">Your device has been used more than usual. Your battery may run out sooner than expected.\n\nTop <xliff:g id="number">%1$d</xliff:g> apps since last full charge(<xliff:g id="time_period_ago" example="1 hr ago">%2$s</xliff:g>):</string>
|
||||
<!-- Title for restricted app preference, showing how many app need to be restricted [CHAR LIMIT=NONE] -->
|
||||
<plurals name="battery_tip_restrict_title">
|
||||
<item quantity="one">Restrict %1$d app</item>
|
||||
@@ -5097,7 +5093,7 @@
|
||||
</plurals>
|
||||
|
||||
<!-- Footer message for restrict app details page -->
|
||||
<string name="restricted_app_detail_footer">Apps shown here aren\'t behaving properly and have been using battery in the background.\n\nThese apps are now blocked from using battery in the background. As a result, some app notifications may be delayed.</string>
|
||||
<string name="restricted_app_detail_footer">These apps have been using battery in the background. Restricted apps may not work properly and notifications may be delayed.</string>
|
||||
|
||||
<!-- Title for auto restriction toggle -->
|
||||
<string name="battery_auto_restriction_title">Use Battery Manager</string>
|
||||
@@ -7236,7 +7232,7 @@
|
||||
<!-- Do not disturb: what to block option [CHAR LIMIT=NONE] -->
|
||||
<string name="zen_mode_block_effect_badge">Hide notification dots</string>
|
||||
<!-- Do not disturb: what to block option [CHAR LIMIT=NONE] -->
|
||||
<string name="zen_mode_block_effect_ambient">Hide from ambient display</string>
|
||||
<string name="zen_mode_block_effect_ambient">Don\'t wake for notifications</string>
|
||||
<!-- Do not disturb: what to block option [CHAR LIMIT=NONE] -->
|
||||
<string name="zen_mode_block_effect_list">Hide from notification list</string>
|
||||
|
||||
@@ -7330,7 +7326,7 @@
|
||||
<string name="zen_onboarding_screen_off_title">Block when the screen is off</string>
|
||||
<string name="zen_onboarding_dnd_visual_disturbances_description">Do Not Disturb can do more than block unwanted sounds - it can block visuals too. This may be helpful if you\'re trying to sleep, focus, or limit time spent on your phone.</string>
|
||||
<string name="zen_onboarding_dnd_visual_disturbances_header">Block sounds and visuals</string>
|
||||
<string name="zen_onboarding_screen_off_summary">Don\'t turn on the screen or show notifications in the ambient display</string>
|
||||
<string name="zen_onboarding_screen_off_summary">Don\'t turn on the screen or wake for notifications</string>
|
||||
<string name="zen_onboarding_screen_on_summary">Don\'t show notifications at all, except for basic phone activity and status</string>
|
||||
|
||||
<!-- Work Sounds: Work sound settings section header. [CHAR LIMIT=50] -->
|
||||
@@ -8022,7 +8018,7 @@
|
||||
<string name="encryption_interstitial_no">No</string>
|
||||
|
||||
<!-- Label to say yes to the question of whether app is restricted. [CHAR LIMIT=20] -->
|
||||
<string name="restricted_true_label">App can\u2019t use battery in background</string>
|
||||
<string name="restricted_true_label">Restricted</string>
|
||||
<!-- Label to say no to the question of whether app is restricted. [CHAR LIMIT=20] -->
|
||||
<string name="restricted_false_label">App can use battery in background</string>
|
||||
|
||||
|
||||
@@ -45,6 +45,12 @@
|
||||
android:fragment="com.android.settings.gestures.DoubleTwistGestureSettings"
|
||||
settings:controller="com.android.settings.gestures.DoubleTwistPreferenceController" />
|
||||
|
||||
<Preference
|
||||
android:key="gesture_swipe_up_input_summary"
|
||||
android:title="@string/swipe_up_to_switch_apps_title"
|
||||
android:fragment="com.android.settings.gestures.SwipeUpGestureSettings"
|
||||
settings:controller="com.android.settings.gestures.SwipeUpPreferenceController" />
|
||||
|
||||
<Preference
|
||||
android:key="gesture_double_tap_screen_input_summary"
|
||||
android:title="@string/ambient_display_title"
|
||||
|
||||
36
res/xml/swipe_up_gesture_settings.xml
Normal file
36
res/xml/swipe_up_gesture_settings.xml
Normal file
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
|
||||
<PreferenceScreen
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:key="gesture_swipe_up_screen"
|
||||
android:title="@string/swipe_up_to_switch_apps_title">
|
||||
|
||||
<com.android.settings.widget.VideoPreference
|
||||
android:key="gesture_swipe_up_video"
|
||||
app:animation="@raw/gesture_swipe_up"
|
||||
app:preview="@drawable/gesture_swipe_up" />
|
||||
|
||||
<SwitchPreference
|
||||
android:key="gesture_swipe_up"
|
||||
android:title="@string/swipe_up_to_switch_apps_title"
|
||||
android:summary="@string/swipe_up_to_switch_apps_summary"
|
||||
app:keywords="@string/keywords_gesture"
|
||||
app:controller="com.android.settings.gestures.SwipeUpPreferenceController" />
|
||||
|
||||
</PreferenceScreen>
|
||||
@@ -23,10 +23,9 @@
|
||||
settings:keywords="@string/keywords_zen_mode_settings">
|
||||
|
||||
<!-- sound vibration -->
|
||||
<CheckBoxPreference
|
||||
<com.android.settings.widget.DisabledCheckBoxPreference
|
||||
android:key="zen_effect_sound"
|
||||
android:title="@string/zen_mode_block_effect_sound"
|
||||
android:enabled="false" />
|
||||
android:title="@string/zen_mode_block_effect_sound" />
|
||||
|
||||
<!-- What to block (effects) -->
|
||||
<Preference
|
||||
|
||||
@@ -176,7 +176,8 @@ public class ManageApplications extends InstrumentedFragment
|
||||
private static final int NO_USER_SPECIFIED = -1;
|
||||
|
||||
// sort order
|
||||
private int mSortOrder = R.id.sort_order_alpha;
|
||||
@VisibleForTesting
|
||||
int mSortOrder = R.id.sort_order_alpha;
|
||||
|
||||
// whether showing system apps.
|
||||
private boolean mShowSystem;
|
||||
@@ -649,9 +650,8 @@ public class ManageApplications extends InstrumentedFragment
|
||||
switch (item.getItemId()) {
|
||||
case R.id.sort_order_alpha:
|
||||
case R.id.sort_order_size:
|
||||
mSortOrder = menuId;
|
||||
if (mApplications != null) {
|
||||
mApplications.rebuild(mSortOrder);
|
||||
mApplications.rebuild(menuId);
|
||||
}
|
||||
break;
|
||||
case R.id.show_system:
|
||||
@@ -712,6 +712,7 @@ public class ManageApplications extends InstrumentedFragment
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
mFilter = mFilterAdapter.getFilter(position);
|
||||
mApplications.setFilter(mFilter);
|
||||
|
||||
if (DEBUG) Log.d(TAG, "Selecting filter " + mFilter);
|
||||
}
|
||||
|
||||
@@ -986,6 +987,7 @@ public class ManageApplications extends InstrumentedFragment
|
||||
if (sort == mLastSortMode) {
|
||||
return;
|
||||
}
|
||||
mManageApplications.mSortOrder = sort;
|
||||
mLastSortMode = sort;
|
||||
rebuild();
|
||||
}
|
||||
|
||||
@@ -167,7 +167,7 @@ public abstract class BluetoothDeviceUpdater implements BluetoothCallback {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProfileAudioStateChanged(int bluetoothProfile, int state) {
|
||||
public void onAudioModeChanged() {
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -81,7 +81,7 @@ public final class BluetoothSummaryUpdater extends SummaryUpdater implements Blu
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProfileAudioStateChanged(int bluetoothProfile, int state) {
|
||||
public void onAudioModeChanged() {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -276,7 +276,7 @@ public abstract class DeviceListPreferenceFragment extends
|
||||
public void onActiveDeviceChanged(CachedBluetoothDevice activeDevice, int bluetoothProfile) { }
|
||||
|
||||
@Override
|
||||
public void onProfileAudioStateChanged(int bluetoothProfile, int state) { }
|
||||
public void onAudioModeChanged() { }
|
||||
|
||||
/**
|
||||
* Return the key of the {@link PreferenceGroup} that contains the bluetooth devices
|
||||
|
||||
@@ -78,6 +78,7 @@ import com.android.settings.gestures.AssistGestureSettings;
|
||||
import com.android.settings.gestures.DoubleTapPowerSettings;
|
||||
import com.android.settings.gestures.DoubleTapScreenSettings;
|
||||
import com.android.settings.gestures.DoubleTwistGestureSettings;
|
||||
import com.android.settings.gestures.SwipeUpGestureSettings;
|
||||
import com.android.settings.gestures.PickupGestureSettings;
|
||||
import com.android.settings.gestures.SwipeToNotificationSettings;
|
||||
import com.android.settings.inputmethod.AvailableVirtualKeyboardFragment;
|
||||
@@ -188,6 +189,7 @@ public class SettingsGateway {
|
||||
DoubleTapScreenSettings.class.getName(),
|
||||
PickupGestureSettings.class.getName(),
|
||||
DoubleTwistGestureSettings.class.getName(),
|
||||
SwipeUpGestureSettings.class.getName(),
|
||||
CryptKeeperSettings.class.getName(),
|
||||
DataUsageSummary.class.getName(),
|
||||
DataUsageSummaryLegacy.class.getName(),
|
||||
|
||||
@@ -18,19 +18,16 @@ package com.android.settings.enterprise;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.AppGlobals;
|
||||
import android.app.admin.DevicePolicyManager;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Process;
|
||||
import android.os.RemoteException;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
import android.support.annotation.VisibleForTesting;
|
||||
import android.util.Log;
|
||||
import android.util.IconDrawableFactory;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -40,6 +37,7 @@ import android.widget.TextView;
|
||||
import com.android.settings.DeviceAdminAdd;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Settings;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settingslib.RestrictedLockUtils;
|
||||
import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
|
||||
|
||||
@@ -99,20 +97,12 @@ public class ActionDisabledByAdminDialogHelper {
|
||||
|| !RestrictedLockUtils.isCurrentUserOrProfile(mActivity, userId)) {
|
||||
admin = null;
|
||||
} else {
|
||||
ActivityInfo ai = null;
|
||||
try {
|
||||
ai = AppGlobals.getPackageManager().getReceiverInfo(admin, 0 /* flags */,
|
||||
userId);
|
||||
} catch (RemoteException e) {
|
||||
Log.w(TAG, "Missing reciever info", e);
|
||||
}
|
||||
if (ai != null) {
|
||||
final Drawable icon = ai.loadIcon(mActivity.getPackageManager());
|
||||
final Drawable badgedIcon = mActivity.getPackageManager().getUserBadgedIcon(
|
||||
icon, new UserHandle(userId));
|
||||
((ImageView) root.findViewById(R.id.admin_support_icon)).setImageDrawable(
|
||||
badgedIcon);
|
||||
}
|
||||
final Drawable badgedIcon = Utils.getBadgedIcon(
|
||||
IconDrawableFactory.newInstance(mActivity),
|
||||
mActivity.getPackageManager(),
|
||||
admin.getPackageName(),
|
||||
userId);
|
||||
((ImageView) root.findViewById(R.id.admin_support_icon)).setImageDrawable(badgedIcon);
|
||||
}
|
||||
|
||||
setAdminSupportTitle(root, restriction);
|
||||
|
||||
@@ -71,7 +71,11 @@ public class AnomalyConfigJobService extends JobService {
|
||||
ThreadUtils.postOnBackgroundThread(() -> {
|
||||
final StatsManager statsManager = getSystemService(StatsManager.class);
|
||||
checkAnomalyConfig(statsManager);
|
||||
BatteryTipUtils.uploadAnomalyPendingIntent(this, statsManager);
|
||||
try {
|
||||
BatteryTipUtils.uploadAnomalyPendingIntent(this, statsManager);
|
||||
} catch (StatsManager.StatsUnavailableException e) {
|
||||
Log.w(TAG, "Failed to uploadAnomalyPendingIntent.", e);
|
||||
}
|
||||
jobFinished(params, false /* wantsReschedule */);
|
||||
});
|
||||
|
||||
@@ -96,23 +100,26 @@ public class AnomalyConfigJobService extends JobService {
|
||||
Log.i(TAG, "CurrentVersion: " + currentVersion + " new version: " + newVersion);
|
||||
|
||||
if (newVersion > currentVersion) {
|
||||
statsManager.removeConfiguration(StatsManagerConfig.ANOMALY_CONFIG_KEY);
|
||||
try {
|
||||
statsManager.removeConfig(StatsManagerConfig.ANOMALY_CONFIG_KEY);
|
||||
} catch (StatsManager.StatsUnavailableException e) {
|
||||
Log.i(TAG, "When updating anomaly config, failed to first remove the old config "
|
||||
+ StatsManagerConfig.ANOMALY_CONFIG_KEY, e);
|
||||
}
|
||||
if (!TextUtils.isEmpty(rawConfig)) {
|
||||
try {
|
||||
final byte[] config = Base64.decode(rawConfig, Base64.DEFAULT);
|
||||
if (statsManager.addConfiguration(StatsManagerConfig.ANOMALY_CONFIG_KEY,
|
||||
config)) {
|
||||
Log.i(TAG, "Upload the anomaly config. configKey: "
|
||||
+ StatsManagerConfig.ANOMALY_CONFIG_KEY);
|
||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
editor.putInt(KEY_ANOMALY_CONFIG_VERSION, newVersion);
|
||||
editor.commit();
|
||||
} else {
|
||||
Log.i(TAG, "Upload the anomaly config failed. configKey: "
|
||||
+ StatsManagerConfig.ANOMALY_CONFIG_KEY);
|
||||
}
|
||||
statsManager.addConfig(StatsManagerConfig.ANOMALY_CONFIG_KEY, config);
|
||||
Log.i(TAG, "Upload the anomaly config. configKey: "
|
||||
+ StatsManagerConfig.ANOMALY_CONFIG_KEY);
|
||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
editor.putInt(KEY_ANOMALY_CONFIG_VERSION, newVersion);
|
||||
editor.commit();
|
||||
} catch (IllegalArgumentException e) {
|
||||
Log.e(TAG, "Anomaly raw config is in wrong format", e);
|
||||
} catch (StatsManager.StatsUnavailableException e) {
|
||||
Log.i(TAG, "Upload of anomaly config failed for configKey "
|
||||
+ StatsManagerConfig.ANOMALY_CONFIG_KEY, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,11 @@ public class AnomalyConfigReceiver extends BroadcastReceiver {
|
||||
// Check whether to update the config
|
||||
AnomalyConfigJobService.scheduleConfigUpdate(context);
|
||||
|
||||
BatteryTipUtils.uploadAnomalyPendingIntent(context, statsManager);
|
||||
try {
|
||||
BatteryTipUtils.uploadAnomalyPendingIntent(context, statsManager);
|
||||
} catch (StatsManager.StatsUnavailableException e) {
|
||||
Log.w(TAG, "Failed to uploadAnomalyPendingIntent.", e);
|
||||
}
|
||||
|
||||
if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
|
||||
AnomalyCleanupJobService.scheduleCleanUp(context);
|
||||
|
||||
@@ -102,7 +102,10 @@ public class BatteryTipDialogFragment extends InstrumentedDialogFragment impleme
|
||||
|
||||
return new AlertDialog.Builder(context)
|
||||
.setMessage(getString(R.string.battery_tip_dialog_message,
|
||||
highUsageTip.getHighUsageAppList().size()))
|
||||
highUsageTip.getHighUsageAppList().size(),
|
||||
StringUtil.formatRelativeTime(context,
|
||||
highUsageTip.getLastFullChargeTimeMs(),
|
||||
false /* withSeconds */)))
|
||||
.setView(view)
|
||||
.setPositiveButton(android.R.string.ok, null)
|
||||
.create();
|
||||
|
||||
@@ -110,12 +110,14 @@ public class BatteryTipUtils {
|
||||
|
||||
/**
|
||||
* Upload the {@link PendingIntent} to {@link StatsManager} for anomaly detection
|
||||
* @throws StatsManager.StatsUnavailableException if failed to communicate with stats service
|
||||
*/
|
||||
public static void uploadAnomalyPendingIntent(Context context, StatsManager statsManager) {
|
||||
public static void uploadAnomalyPendingIntent(Context context, StatsManager statsManager)
|
||||
throws StatsManager.StatsUnavailableException {
|
||||
final Intent extraIntent = new Intent(context, AnomalyDetectionReceiver.class);
|
||||
final PendingIntent pendingIntent = PendingIntent.getBroadcast(context, REQUEST_CODE,
|
||||
extraIntent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
statsManager.setBroadcastSubscriber(StatsManagerConfig.ANOMALY_CONFIG_KEY,
|
||||
StatsManagerConfig.SUBSCRIBER_ID, pendingIntent);
|
||||
statsManager.setBroadcastSubscriber(pendingIntent,
|
||||
StatsManagerConfig.ANOMALY_CONFIG_KEY, StatsManagerConfig.SUBSCRIBER_ID);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,7 +63,8 @@ public class HighUsageDetector implements BatteryTipDetector {
|
||||
|
||||
@Override
|
||||
public BatteryTip detect() {
|
||||
final long screenUsageTimeMs = mBatteryUtils.calculateScreenUsageTime(mBatteryStatsHelper);
|
||||
final long lastFullChargeTimeMs = mBatteryUtils.calculateLastFullChargeTime(
|
||||
mBatteryStatsHelper, System.currentTimeMillis());
|
||||
if (mPolicy.highUsageEnabled) {
|
||||
parseBatteryData();
|
||||
if (mDataParser.isDeviceHeavilyUsed() || mPolicy.testHighUsageTip) {
|
||||
@@ -99,7 +100,7 @@ public class HighUsageDetector implements BatteryTipDetector {
|
||||
}
|
||||
}
|
||||
|
||||
return new HighUsageTip(screenUsageTimeMs, mHighUsageAppList);
|
||||
return new HighUsageTip(lastFullChargeTimeMs, mHighUsageAppList);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
|
||||
@@ -26,7 +26,7 @@ import com.android.settings.R;
|
||||
import com.android.settings.fuelgauge.batterytip.AppInfo;
|
||||
|
||||
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
||||
import com.android.settingslib.utils.StringUtil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -34,28 +34,28 @@ import java.util.List;
|
||||
*/
|
||||
public class HighUsageTip extends BatteryTip {
|
||||
|
||||
private final long mScreenTimeMs;
|
||||
private final long mLastFullChargeTimeMs;
|
||||
@VisibleForTesting
|
||||
final List<AppInfo> mHighUsageAppList;
|
||||
|
||||
public HighUsageTip(long screenTimeMs, List<AppInfo> appList) {
|
||||
public HighUsageTip(long lastFullChargeTimeMs, List<AppInfo> appList) {
|
||||
super(TipType.HIGH_DEVICE_USAGE, appList.isEmpty() ? StateType.INVISIBLE : StateType.NEW,
|
||||
true /* showDialog */);
|
||||
mScreenTimeMs = screenTimeMs;
|
||||
mLastFullChargeTimeMs = lastFullChargeTimeMs;
|
||||
mHighUsageAppList = appList;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
HighUsageTip(Parcel in) {
|
||||
super(in);
|
||||
mScreenTimeMs = in.readLong();
|
||||
mLastFullChargeTimeMs = in.readLong();
|
||||
mHighUsageAppList = in.createTypedArrayList(AppInfo.CREATOR);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
super.writeToParcel(dest, flags);
|
||||
dest.writeLong(mScreenTimeMs);
|
||||
dest.writeLong(mLastFullChargeTimeMs);
|
||||
dest.writeTypedList(mHighUsageAppList);
|
||||
}
|
||||
|
||||
@@ -91,8 +91,8 @@ public class HighUsageTip extends BatteryTip {
|
||||
}
|
||||
}
|
||||
|
||||
public long getScreenTimeMs() {
|
||||
return mScreenTimeMs;
|
||||
public long getLastFullChargeTimeMs() {
|
||||
return mLastFullChargeTimeMs;
|
||||
}
|
||||
|
||||
public List<AppInfo> getHighUsageAppList() {
|
||||
|
||||
@@ -45,6 +45,7 @@ public class GestureSettings extends DashboardFragment {
|
||||
private static final String KEY_DOUBLE_TAP_SCREEN = "gesture_double_tap_screen_input_summary";
|
||||
private static final String KEY_PICK_UP = "gesture_pick_up_input_summary";
|
||||
private static final String KEY_PREVENT_RINGING = "gesture_prevent_ringing_summary";
|
||||
private static final String KEY_SWIPE_UP = "gesture_swipe_up_input_summary";
|
||||
|
||||
private AmbientDisplayConfiguration mAmbientDisplayConfig;
|
||||
|
||||
@@ -96,6 +97,7 @@ public class GestureSettings extends DashboardFragment {
|
||||
keys.add(KEY_SWIPE_DOWN);
|
||||
keys.add(KEY_DOUBLE_TAP_POWER);
|
||||
keys.add(KEY_DOUBLE_TWIST);
|
||||
keys.add(KEY_SWIPE_UP);
|
||||
keys.add(KEY_DOUBLE_TAP_SCREEN);
|
||||
keys.add(KEY_PICK_UP);
|
||||
keys.add(KEY_PREVENT_RINGING);
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* 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.gestures;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.provider.SearchIndexableResource;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.dashboard.suggestions.SuggestionFeatureProvider;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class SwipeUpGestureSettings extends DashboardFragment {
|
||||
|
||||
private static final String TAG = "SwipeUpGesture";
|
||||
|
||||
public static final String PREF_KEY_SUGGESTION_COMPLETE =
|
||||
"pref_swipe_up_suggestion_complete";
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
SuggestionFeatureProvider suggestionFeatureProvider = FeatureFactory.getFactory(context)
|
||||
.getSuggestionFeatureProvider(context);
|
||||
SharedPreferences prefs = suggestionFeatureProvider.getSharedPrefs(context);
|
||||
prefs.edit().putBoolean(PREF_KEY_SUGGESTION_COMPLETE, true).apply();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return MetricsProto.MetricsEvent.SETTINGS_GESTURE_SWIPE_UP;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getLogTag() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getPreferenceScreenResId() {
|
||||
return R.xml.swipe_up_gesture_settings;
|
||||
}
|
||||
|
||||
public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||
new BaseSearchIndexProvider() {
|
||||
@Override
|
||||
public List<SearchIndexableResource> getXmlResourcesToIndex(
|
||||
Context context, boolean enabled) {
|
||||
final SearchIndexableResource sir = new SearchIndexableResource(context);
|
||||
sir.xmlResId = R.xml.swipe_up_gesture_settings;
|
||||
return Arrays.asList(sir);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isPageSearchEnabled(Context context) {
|
||||
return SwipeUpPreferenceController.isGestureAvailable(context);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* 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.gestures;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Resources;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
import android.provider.Settings;
|
||||
import android.support.annotation.VisibleForTesting;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
|
||||
public class SwipeUpPreferenceController extends GesturePreferenceController {
|
||||
|
||||
private final int ON = 1;
|
||||
private final int OFF = 0;
|
||||
|
||||
private static final String PREF_KEY_VIDEO = "gesture_swipe_up_video";
|
||||
private final UserManager mUserManager;
|
||||
|
||||
public SwipeUpPreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
mUserManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
|
||||
}
|
||||
|
||||
static boolean isGestureAvailable(Context context) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return isGestureAvailable(mContext) ? AVAILABLE : DISABLED_UNSUPPORTED;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getVideoPrefKey() {
|
||||
return PREF_KEY_VIDEO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setChecked(boolean isChecked) {
|
||||
setSwipeUpPreference(mContext, mUserManager, isChecked ? ON : OFF);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void setSwipeUpPreference(Context context, UserManager userManager,
|
||||
int enabled) {
|
||||
Settings.Secure.putInt(context.getContentResolver(),
|
||||
Settings.Secure.SWIPE_UP_TO_SWITCH_APPS_ENABLED, enabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChecked() {
|
||||
final int swipeUpEnabled = Settings.Secure.getInt(mContext.getContentResolver(),
|
||||
Settings.Secure.SWIPE_UP_TO_SWITCH_APPS_ENABLED, OFF);
|
||||
return swipeUpEnabled != OFF;
|
||||
}
|
||||
}
|
||||
@@ -654,7 +654,6 @@ public class ChooseLockGeneric extends SettingsActivity {
|
||||
}
|
||||
|
||||
if (quality == DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED) {
|
||||
mLockPatternUtils.setSeparateProfileChallengeEnabled(mUserId, true, mUserPassword);
|
||||
mChooseLockSettingsHelper.utils().clearLock(mUserPassword, mUserId);
|
||||
mChooseLockSettingsHelper.utils().setLockScreenDisabled(disabled, mUserId);
|
||||
getActivity().setResult(Activity.RESULT_OK);
|
||||
|
||||
@@ -33,6 +33,10 @@ public interface DeviceIndexFeatureProvider {
|
||||
// TODO: Remove this and index all action and intent slices through search index.
|
||||
String[] ACTIONS_TO_INDEX = new String[]{
|
||||
Settings.ACTION_WIFI_SETTINGS,
|
||||
Settings.ACTION_BATTERY_SAVER_SETTINGS,
|
||||
Settings.ACTION_BLUETOOTH_SETTINGS,
|
||||
"android.intent.action.POWER_USAGE_SUMMARY",
|
||||
Settings.ACTION_SOUND_SETTINGS,
|
||||
};
|
||||
|
||||
String TAG = "DeviceIndex";
|
||||
@@ -40,7 +44,7 @@ public interface DeviceIndexFeatureProvider {
|
||||
String INDEX_VERSION = "settings:index_version";
|
||||
|
||||
// Increment when new items are added to ensure they get pushed to the device index.
|
||||
int VERSION = 1;
|
||||
int VERSION = 2;
|
||||
|
||||
boolean isIndexingEnabled();
|
||||
|
||||
|
||||
@@ -57,6 +57,7 @@ import com.android.settings.gestures.AssistGestureSettings;
|
||||
import com.android.settings.gestures.DoubleTapPowerSettings;
|
||||
import com.android.settings.gestures.DoubleTapScreenSettings;
|
||||
import com.android.settings.gestures.DoubleTwistGestureSettings;
|
||||
import com.android.settings.gestures.SwipeUpGestureSettings;
|
||||
import com.android.settings.gestures.GestureSettings;
|
||||
import com.android.settings.gestures.PickupGestureSettings;
|
||||
import com.android.settings.gestures.SwipeToNotificationSettings;
|
||||
@@ -132,6 +133,7 @@ public class SearchIndexableResourcesImpl implements SearchIndexableResources {
|
||||
addIndex(DoubleTapScreenSettings.class);
|
||||
addIndex(DoubleTapPowerSettings.class);
|
||||
addIndex(DoubleTwistGestureSettings.class);
|
||||
addIndex(SwipeUpGestureSettings.class);
|
||||
addIndex(SwipeToNotificationSettings.class);
|
||||
addIndex(GestureSettings.class);
|
||||
addIndex(LanguageAndInputSettings.class);
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* 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.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
|
||||
import android.support.v7.preference.CheckBoxPreference;
|
||||
import android.support.v7.preference.PreferenceViewHolder;
|
||||
|
||||
/**
|
||||
* A CheckboxPreference with a disabled checkbox. Differs from CheckboxPreference.setDisabled()
|
||||
* in that the text is not dimmed.
|
||||
*/
|
||||
public class DisabledCheckBoxPreference extends CheckBoxPreference {
|
||||
|
||||
public DisabledCheckBoxPreference(Context context, AttributeSet attrs,
|
||||
int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
}
|
||||
|
||||
public DisabledCheckBoxPreference(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
public DisabledCheckBoxPreference(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public DisabledCheckBoxPreference(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(PreferenceViewHolder holder) {
|
||||
super.onBindViewHolder(holder);
|
||||
|
||||
View view = holder.findViewById(android.R.id.checkbox);
|
||||
view.setEnabled(false);
|
||||
holder.itemView.setEnabled(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void performClick(View view) {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,6 @@ import android.net.wifi.WifiConfiguration;
|
||||
import android.support.v7.preference.EditTextPreference;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.widget.ValidatedEditTextPreference;
|
||||
@@ -52,7 +51,6 @@ public class WifiTetherPasswordPreferenceController extends WifiTetherBasePrefer
|
||||
final WifiConfiguration config = mWifiManager.getWifiApConfiguration();
|
||||
if (config != null) {
|
||||
mPassword = config.preSharedKey;
|
||||
Log.d(TAG, "Updating password in Preference, " + mPassword);
|
||||
} else {
|
||||
mPassword = generateRandomPassword();
|
||||
}
|
||||
|
||||
@@ -23,6 +23,8 @@ import static com.android.settings.applications.manageapplications.ManageApplica
|
||||
import static com.android.settings.applications.manageapplications.ManageApplications.LIST_TYPE_NOTIFICATION;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.anyInt;
|
||||
@@ -303,6 +305,23 @@ public class ManageApplicationsTest {
|
||||
verify(holder, never()).updateSwitch(any(), anyBoolean(), anyBoolean());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sortOrderSavedOnRebuild() {
|
||||
ManageApplications manageApplications = mock(ManageApplications.class);
|
||||
manageApplications.mListType = LIST_TYPE_NOTIFICATION;
|
||||
manageApplications.mSortOrder = -1;
|
||||
ManageApplications.ApplicationsAdapter adapter =
|
||||
new ManageApplications.ApplicationsAdapter(mState,
|
||||
manageApplications, mock(AppFilterItem.class),
|
||||
mock(Bundle.class));
|
||||
|
||||
adapter.rebuild(mSortRecent.getItemId());
|
||||
assertThat(manageApplications.mSortOrder).isEqualTo(mSortRecent.getItemId());
|
||||
|
||||
adapter.rebuild(mSortFrequent.getItemId());
|
||||
assertThat(manageApplications.mSortOrder).isEqualTo(mSortFrequent.getItemId());
|
||||
}
|
||||
|
||||
private void setUpOptionMenus() {
|
||||
when(mMenu.findItem(anyInt())).thenAnswer(invocation -> {
|
||||
final Object[] args = invocation.getArguments();
|
||||
|
||||
@@ -183,7 +183,7 @@ public class BackgroundActivityPreferenceControllerTest {
|
||||
|
||||
mController.updateSummary(mPreference);
|
||||
|
||||
assertThat(mPreference.getSummary()).isEqualTo("App can\u2019t use battery in background");
|
||||
assertThat(mPreference.getSummary()).isEqualTo("Restricted");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -104,7 +104,8 @@ public class AnomalyConfigJobServiceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkAnomalyConfig_newConfigExist_removeOldConfig() {
|
||||
public void checkAnomalyConfig_newConfigExist_removeOldConfig()
|
||||
throws StatsManager.StatsUnavailableException{
|
||||
Settings.Global.putInt(application.getContentResolver(),
|
||||
Settings.Global.ANOMALY_CONFIG_VERSION, ANOMALY_CONFIG_VERSION);
|
||||
Settings.Global.putString(application.getContentResolver(), Settings.Global.ANOMALY_CONFIG,
|
||||
@@ -112,11 +113,12 @@ public class AnomalyConfigJobServiceTest {
|
||||
|
||||
mJobService.checkAnomalyConfig(mStatsManager);
|
||||
|
||||
verify(mStatsManager).removeConfiguration(StatsManagerConfig.ANOMALY_CONFIG_KEY);
|
||||
verify(mStatsManager).removeConfig(StatsManagerConfig.ANOMALY_CONFIG_KEY);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkAnomalyConfig_newConfigExist_uploadNewConfig() {
|
||||
public void checkAnomalyConfig_newConfigExist_uploadNewConfig()
|
||||
throws StatsManager.StatsUnavailableException{
|
||||
Settings.Global.putInt(application.getContentResolver(),
|
||||
Settings.Global.ANOMALY_CONFIG_VERSION, ANOMALY_CONFIG_VERSION);
|
||||
Settings.Global.putString(application.getContentResolver(), Settings.Global.ANOMALY_CONFIG,
|
||||
@@ -124,7 +126,7 @@ public class AnomalyConfigJobServiceTest {
|
||||
|
||||
mJobService.checkAnomalyConfig(mStatsManager);
|
||||
|
||||
verify(mStatsManager).addConfiguration(eq(StatsManagerConfig.ANOMALY_CONFIG_KEY), any());
|
||||
verify(mStatsManager).addConfig(eq(StatsManagerConfig.ANOMALY_CONFIG_KEY), any());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -112,8 +112,8 @@ public class BatteryTipDialogFragmentTest {
|
||||
final AlertDialog dialog = (AlertDialog) ShadowDialog.getLatestDialog();
|
||||
ShadowAlertDialog shadowDialog = shadowOf(dialog);
|
||||
|
||||
assertThat(shadowDialog.getMessage())
|
||||
.isEqualTo(mContext.getString(R.string.battery_tip_dialog_message, 1));
|
||||
assertThat(shadowDialog.getMessage()).isEqualTo(
|
||||
mContext.getString(R.string.battery_tip_dialog_message, 1, "60 minutes ago"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -43,6 +43,7 @@ public class HighUsageTipTest {
|
||||
|
||||
private static final String PACKAGE_NAME = "com.android.app";
|
||||
private static final long SCREEN_TIME = 30 * DateUtils.MINUTE_IN_MILLIS;
|
||||
private static final long LAST_FULL_CHARGE_TIME = 20 * DateUtils.MINUTE_IN_MILLIS;
|
||||
|
||||
@Mock
|
||||
private MetricsFeatureProvider mMetricsFeatureProvider;
|
||||
@@ -60,7 +61,7 @@ public class HighUsageTipTest {
|
||||
.setPackageName(PACKAGE_NAME)
|
||||
.setScreenOnTimeMs(SCREEN_TIME)
|
||||
.build());
|
||||
mBatteryTip = new HighUsageTip(SCREEN_TIME, mUsageAppList);
|
||||
mBatteryTip = new HighUsageTip(LAST_FULL_CHARGE_TIME, mUsageAppList);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -75,7 +76,7 @@ public class HighUsageTipTest {
|
||||
assertThat(parcelTip.getTitle(mContext)).isEqualTo("Phone used more than usual");
|
||||
assertThat(parcelTip.getType()).isEqualTo(BatteryTip.TipType.HIGH_DEVICE_USAGE);
|
||||
assertThat(parcelTip.getState()).isEqualTo(BatteryTip.StateType.NEW);
|
||||
assertThat(parcelTip.getScreenTimeMs()).isEqualTo(SCREEN_TIME);
|
||||
assertThat(parcelTip.getLastFullChargeTimeMs()).isEqualTo(LAST_FULL_CHARGE_TIME);
|
||||
assertThat(parcelTip.mHighUsageAppList).isNotNull();
|
||||
assertThat(parcelTip.mHighUsageAppList.size()).isEqualTo(1);
|
||||
final AppInfo app = parcelTip.mHighUsageAppList.get(0);
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* 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.gestures;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.mockito.Matchers.anyInt;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.Context;
|
||||
import android.hardware.Sensor;
|
||||
import android.hardware.SensorManager;
|
||||
import android.os.UserManager;
|
||||
import android.provider.Settings;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Answers;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.annotation.Config;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
public class SwipeUpPreferenceControllerTest {
|
||||
|
||||
private Context mContext;
|
||||
private SwipeUpPreferenceController mController;
|
||||
private static final String KEY_SWIPE_UP = "gesture_swipe_up";
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
mContext = RuntimeEnvironment.application;
|
||||
mController = new SwipeUpPreferenceController(mContext, KEY_SWIPE_UP);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsChecked_configIsSet_shouldReturnTrue() {
|
||||
// Set the setting to be enabled.
|
||||
mController.setChecked(true);
|
||||
assertThat(mController.isChecked()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsChecked_configIsNotSet_shouldReturnFalse() {
|
||||
// Set the setting to be disabled.
|
||||
mController.setChecked(false);
|
||||
assertThat(mController.isChecked()).isFalse();
|
||||
}
|
||||
}
|
||||
@@ -101,9 +101,7 @@ public class SetupChooseLockPatternTest {
|
||||
ReflectionHelpers.callInstanceMethod(lockPatternView, "notifyPatternDetected");
|
||||
}
|
||||
|
||||
@Config(qualifiers = "sw400dp")
|
||||
@Test
|
||||
public void sw400dp_shouldShowScreenLockOptions() {
|
||||
private void verifyScreenLockOptionsShown() {
|
||||
Button button = mActivity.findViewById(R.id.screen_lock_options);
|
||||
assertThat(button).isNotNull();
|
||||
assertThat(button.getVisibility()).isEqualTo(View.VISIBLE);
|
||||
@@ -115,14 +113,36 @@ public class SetupChooseLockPatternTest {
|
||||
assertThat(count).named("List items shown").isEqualTo(3);
|
||||
}
|
||||
|
||||
@Config(qualifiers = "sw300dp")
|
||||
@Config(qualifiers = "sw400dp")
|
||||
@Test
|
||||
public void smallScreens_shouldHideScreenLockOptions() {
|
||||
public void sw400dp_shouldShowScreenLockOptions() {
|
||||
verifyScreenLockOptionsShown();
|
||||
}
|
||||
|
||||
@Config(qualifiers = "sw400dp-land")
|
||||
@Test
|
||||
public void sw400dpLandscape_shouldShowScreenLockOptions() {
|
||||
verifyScreenLockOptionsShown();
|
||||
}
|
||||
|
||||
private void verifyScreenLockOptionsHidden() {
|
||||
Button button = mActivity.findViewById(R.id.screen_lock_options);
|
||||
assertThat(button).isNotNull();
|
||||
assertThat(button.getVisibility()).isEqualTo(View.GONE);
|
||||
}
|
||||
|
||||
@Config(qualifiers = "sw300dp")
|
||||
@Test
|
||||
public void smallScreens_shouldHideScreenLockOptions() {
|
||||
verifyScreenLockOptionsHidden();
|
||||
}
|
||||
|
||||
@Config(qualifiers = "sw300dp-land")
|
||||
@Test
|
||||
public void smallScreensLandscape_shouldHideScreenLockOptions() {
|
||||
verifyScreenLockOptionsHidden();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void skipButton_shouldBeVisible_duringNonFingerprintFlow() {
|
||||
Button skipButton = mActivity.findViewById(R.id.skip_button);
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* 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.widget;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
|
||||
import android.support.v7.preference.R;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceViewHolder;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
public class DisabledCheckBoxPreferenceTest {
|
||||
|
||||
private Context mContext;
|
||||
private View mRootView;
|
||||
private DisabledCheckBoxPreference mPref;
|
||||
private PreferenceViewHolder mHolder;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
mContext = RuntimeEnvironment.application;
|
||||
mRootView = View.inflate(mContext, R.layout.preference, null /* parent */);
|
||||
mHolder = PreferenceViewHolder.createInstanceForTests(mRootView);
|
||||
mPref = new DisabledCheckBoxPreference(mContext);
|
||||
}
|
||||
|
||||
private void inflatePreference() {
|
||||
final LayoutInflater inflater = LayoutInflater.from(mContext);
|
||||
final LinearLayout widgetView = mHolder.itemView.findViewById(android.R.id.widget_frame);
|
||||
assertThat(widgetView).isNotNull();
|
||||
inflater.inflate(R.layout.preference_widget_checkbox, widgetView, true);
|
||||
mPref.onBindViewHolder(mHolder);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onBindViewHolder_checkboxDisabled() {
|
||||
inflatePreference();
|
||||
assertThat(mRootView.findViewById(android.R.id.checkbox).isEnabled()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkboxOnClick_doesNothing() {
|
||||
Preference.OnPreferenceClickListener onClick =
|
||||
mock(Preference.OnPreferenceClickListener.class);
|
||||
mPref.setOnPreferenceClickListener(onClick);
|
||||
inflatePreference();
|
||||
|
||||
mPref.performClick(mRootView);
|
||||
|
||||
verify(onClick, never()).onPreferenceClick(any());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* 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 static android.support.test.espresso.Espresso.onView;
|
||||
import static android.support.test.espresso.assertion.ViewAssertions.matches;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.withText;
|
||||
|
||||
import android.app.Instrumentation;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.support.test.InstrumentationRegistry;
|
||||
import android.support.test.filters.SmallTest;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
@SmallTest
|
||||
public class RestrictAppTest {
|
||||
private static final String BATTERY_INTENT = "android.intent.action.POWER_USAGE_SUMMARY";
|
||||
private static final String PACKAGE_SETTINGS = "com.android.settings";
|
||||
private static final String PACKAGE_SYSTEM_UI = "com.android.systemui";
|
||||
|
||||
private BatteryDatabaseManager mBatteryDatabaseManager;
|
||||
private PackageManager mPackageManager;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
final Context context = InstrumentationRegistry.getTargetContext();
|
||||
mPackageManager = context.getPackageManager();
|
||||
mBatteryDatabaseManager = BatteryDatabaseManager.getInstance(context);
|
||||
mBatteryDatabaseManager.deleteAllAnomaliesBeforeTimeStamp(System.currentTimeMillis() +
|
||||
TimeUnit.DAYS.toMillis(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBatterySettings_hasOneAnomaly_showAnomaly() throws
|
||||
PackageManager.NameNotFoundException {
|
||||
mBatteryDatabaseManager.insertAnomaly(mPackageManager.getPackageUid(PACKAGE_SETTINGS, 0),
|
||||
PACKAGE_SETTINGS, 1,
|
||||
AnomalyDatabaseHelper.State.NEW, System.currentTimeMillis());
|
||||
|
||||
Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation();
|
||||
instrumentation.startActivitySync(new Intent(BATTERY_INTENT));
|
||||
onView(withText("Restrict 1 app")).check(matches(isDisplayed()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBatterySettings_hasTwoAnomalies_showAnomalies() throws
|
||||
PackageManager.NameNotFoundException {
|
||||
mBatteryDatabaseManager.insertAnomaly(mPackageManager.getPackageUid(PACKAGE_SETTINGS, 0),
|
||||
PACKAGE_SETTINGS, 1,
|
||||
AnomalyDatabaseHelper.State.NEW, System.currentTimeMillis());
|
||||
mBatteryDatabaseManager.insertAnomaly(mPackageManager.getPackageUid(PACKAGE_SYSTEM_UI, 0),
|
||||
PACKAGE_SYSTEM_UI, 1,
|
||||
AnomalyDatabaseHelper.State.NEW, System.currentTimeMillis());
|
||||
|
||||
Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation();
|
||||
instrumentation.startActivitySync(new Intent(BATTERY_INTENT));
|
||||
onView(withText("Restrict 2 apps")).check(matches(isDisplayed()));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user