Snap for 4656203 from eb029cffaf to pi-release
Change-Id: Ic8b6b9ba9a3250425f27a285513e9d2876dc2f21
This commit is contained in:
45
res/drawable/data_usage_progress.xml
Normal file
45
res/drawable/data_usage_progress.xml
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
<?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.
|
||||||
|
-->
|
||||||
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:id="@android:id/background">
|
||||||
|
<shape android:shape="rectangle"
|
||||||
|
android:tint="?android:attr/colorControlActivated">
|
||||||
|
<corners android:radius="5dp" />
|
||||||
|
<size android:height="10dp" />
|
||||||
|
<solid android:color="@color/white_disabled" />
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
<item android:id="@android:id/secondaryProgress">
|
||||||
|
<scale android:scaleWidth="100%">
|
||||||
|
<shape android:shape="rectangle"
|
||||||
|
android:tint="?android:attr/colorControlActivated">
|
||||||
|
<corners android:radius="5dp" />
|
||||||
|
<size android:height="10dp" />
|
||||||
|
<solid android:color="@color/white_disabled" />
|
||||||
|
</shape>
|
||||||
|
</scale>
|
||||||
|
</item>
|
||||||
|
<item android:id="@android:id/progress">
|
||||||
|
<scale android:scaleWidth="100%">
|
||||||
|
<shape android:shape="rectangle"
|
||||||
|
android:tint="?android:attr/colorControlActivated">
|
||||||
|
<corners android:radius="5dp" />
|
||||||
|
<size android:height="10dp" />
|
||||||
|
<solid android:color="@android:color/black" />
|
||||||
|
</shape>
|
||||||
|
</scale>
|
||||||
|
</item>
|
||||||
|
</layer-list>
|
||||||
@@ -18,6 +18,8 @@
|
|||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingTop="24dp"
|
||||||
|
android:paddingBottom="32dp"
|
||||||
android:paddingStart="@dimen/preference_no_icon_padding_start"
|
android:paddingStart="@dimen/preference_no_icon_padding_start"
|
||||||
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
|
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
@@ -31,36 +33,31 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textAppearance="?android:attr/textAppearanceListItemSecondary"
|
android:textAppearance="?android:attr/textAppearanceListItemSecondary"
|
||||||
android:textColor="?android:attr/textColorSecondary"
|
android:textColor="?android:attr/textColorSecondary"
|
||||||
android:paddingBottom="5dp"
|
|
||||||
android:text="@string/data_usage_title" />
|
android:text="@string/data_usage_title" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@android:id/title"
|
android:id="@android:id/title"
|
||||||
|
android:paddingTop="12dp"
|
||||||
|
android:paddingBottom="4dp"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="5dp"
|
|
||||||
android:fontFamily="@*android:string/config_headlineFontFamily"
|
android:fontFamily="@*android:string/config_headlineFontFamily"
|
||||||
android:textColor="?android:attr/colorAccent"
|
android:textColor="?android:attr/colorAccent"
|
||||||
android:textAppearance="@android:style/TextAppearance.Material.Large" />
|
android:textAppearance="@android:style/TextAppearance.Material.Large" />
|
||||||
|
|
||||||
<TextView
|
<android.widget.ProgressBar
|
||||||
android:id="@android:id/summary"
|
android:id="@+id/determinateBar"
|
||||||
|
style="?android:attr/progressBarStyleHorizontal"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="10dp"
|
||||||
android:textAppearance="?android:attr/textAppearanceListItemSecondary"
|
android:progressDrawable="@drawable/data_usage_progress"/>
|
||||||
android:textColor="?android:attr/textColorSecondary"
|
|
||||||
android:paddingBottom="5dp" />
|
|
||||||
|
|
||||||
<com.android.settings.widget.LinearColorBar
|
|
||||||
android:id="@+id/color_bar"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="28dp" />
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/label_bar"
|
android:id="@+id/label_bar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingTop="2dp"
|
android:paddingTop="4dp"
|
||||||
|
android:paddingBottom="8dp"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<TextView android:id="@android:id/text1"
|
<TextView android:id="@android:id/text1"
|
||||||
@@ -84,18 +81,18 @@
|
|||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/cycle_left_time"
|
android:id="@+id/cycle_left_time"
|
||||||
|
android:paddingTop="4dp"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content" />
|
||||||
android:paddingBottom="5dp" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/carrier_and_update"
|
android:id="@+id/carrier_and_update"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content" />
|
||||||
android:paddingBottom="5dp" />
|
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/launch_mdp_app_button"
|
android:id="@+id/launch_mdp_app_button"
|
||||||
|
android:paddingTop="12dp"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="left"
|
android:layout_gravity="left"
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
android:scrollIndicators="top|bottom">
|
android:scrollIndicators="top|bottom">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
android:id="@+id/l_wifidialog"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
|
|||||||
@@ -8657,6 +8657,9 @@
|
|||||||
<!-- Label for cellular data usage in data usage screen [CHAR LIMIT=60] -->
|
<!-- Label for cellular data usage in data usage screen [CHAR LIMIT=60] -->
|
||||||
<string name="cellular_data_usage">Mobile data usage</string>
|
<string name="cellular_data_usage">Mobile data usage</string>
|
||||||
|
|
||||||
|
<!-- App data usage, as seen from the platform, in data usage screen [CHAR LIMIT=60] -->
|
||||||
|
<string name="app_cellular_data_usage">App data usage</string>
|
||||||
|
|
||||||
<!-- Label for wifi data usage in data usage screen [CHAR LIMIT=60] -->
|
<!-- Label for wifi data usage in data usage screen [CHAR LIMIT=60] -->
|
||||||
<string name="wifi_data_usage">Wi-Fi data usage</string>
|
<string name="wifi_data_usage">Wi-Fi data usage</string>
|
||||||
|
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ import android.graphics.Bitmap;
|
|||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.drawable.BitmapDrawable;
|
import android.graphics.drawable.BitmapDrawable;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.graphics.drawable.VectorDrawable;
|
||||||
import android.hardware.fingerprint.FingerprintManager;
|
import android.hardware.fingerprint.FingerprintManager;
|
||||||
import android.net.ConnectivityManager;
|
import android.net.ConnectivityManager;
|
||||||
import android.net.LinkProperties;
|
import android.net.LinkProperties;
|
||||||
@@ -929,7 +930,7 @@ public final class Utils extends com.android.settingslib.Utils {
|
|||||||
*/
|
*/
|
||||||
public static void setSafeIcon(Preference pref, Drawable icon) {
|
public static void setSafeIcon(Preference pref, Drawable icon) {
|
||||||
Drawable safeIcon = icon;
|
Drawable safeIcon = icon;
|
||||||
if (icon != null) {
|
if ((icon != null) && !(icon instanceof VectorDrawable)) {
|
||||||
safeIcon = getSafeDrawable(icon, 500, 500);
|
safeIcon = getSafeDrawable(icon, 500, 500);
|
||||||
}
|
}
|
||||||
pref.setIcon(safeIcon);
|
pref.setIcon(safeIcon);
|
||||||
|
|||||||
@@ -26,7 +26,9 @@ import android.app.Fragment;
|
|||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
|
import android.content.pm.ApplicationInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
|
import android.content.pm.ResolveInfo;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Binder;
|
import android.os.Binder;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@@ -34,7 +36,6 @@ import android.os.IBinder;
|
|||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.IconDrawableFactory;
|
|
||||||
import android.view.accessibility.AccessibilityManager;
|
import android.view.accessibility.AccessibilityManager;
|
||||||
|
|
||||||
import com.android.internal.accessibility.AccessibilityShortcutController;
|
import com.android.internal.accessibility.AccessibilityShortcutController;
|
||||||
@@ -45,7 +46,6 @@ import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
|
|||||||
import com.android.settings.widget.RadioButtonPickerFragment;
|
import com.android.settings.widget.RadioButtonPickerFragment;
|
||||||
import com.android.settings.widget.RadioButtonPreference;
|
import com.android.settings.widget.RadioButtonPreference;
|
||||||
import com.android.settingslib.accessibility.AccessibilityUtils;
|
import com.android.settingslib.accessibility.AccessibilityUtils;
|
||||||
import com.android.settingslib.applications.DefaultAppInfo;
|
|
||||||
import com.android.settingslib.widget.CandidateInfo;
|
import com.android.settingslib.widget.CandidateInfo;
|
||||||
import com.android.settingslib.wrapper.PackageManagerWrapper;
|
import com.android.settingslib.wrapper.PackageManagerWrapper;
|
||||||
|
|
||||||
@@ -71,13 +71,11 @@ public class ShortcutServicePickerFragment extends RadioButtonPickerFragment {
|
|||||||
@Override
|
@Override
|
||||||
protected List<? extends CandidateInfo> getCandidates() {
|
protected List<? extends CandidateInfo> getCandidates() {
|
||||||
final Context context = getContext();
|
final Context context = getContext();
|
||||||
final PackageManager pm = context.getPackageManager();
|
|
||||||
final AccessibilityManager accessibilityManager = context
|
final AccessibilityManager accessibilityManager = context
|
||||||
.getSystemService(AccessibilityManager.class);
|
.getSystemService(AccessibilityManager.class);
|
||||||
final List<AccessibilityServiceInfo> installedServices =
|
final List<AccessibilityServiceInfo> installedServices =
|
||||||
accessibilityManager.getInstalledAccessibilityServiceList();
|
accessibilityManager.getInstalledAccessibilityServiceList();
|
||||||
final int numInstalledServices = installedServices.size();
|
final int numInstalledServices = installedServices.size();
|
||||||
final PackageManagerWrapper pmw = new PackageManagerWrapper(context.getPackageManager());
|
|
||||||
|
|
||||||
final List<CandidateInfo> candidates = new ArrayList<>(numInstalledServices);
|
final List<CandidateInfo> candidates = new ArrayList<>(numInstalledServices);
|
||||||
Map<ComponentName, ToggleableFrameworkFeatureInfo> frameworkFeatureInfoMap =
|
Map<ComponentName, ToggleableFrameworkFeatureInfo> frameworkFeatureInfoMap =
|
||||||
@@ -95,10 +93,7 @@ public class ShortcutServicePickerFragment extends RadioButtonPickerFragment {
|
|||||||
iconId, componentName.flattenToString()));
|
iconId, componentName.flattenToString()));
|
||||||
}
|
}
|
||||||
for (int i = 0; i < numInstalledServices; i++) {
|
for (int i = 0; i < numInstalledServices; i++) {
|
||||||
final AccessibilityServiceInfo installedServiceInfo = installedServices.get(i);
|
candidates.add(new ServiceCandidateInfo(installedServices.get(i)));
|
||||||
candidates.add(new DefaultAppInfo(context, pmw, UserHandle.myUserId(),
|
|
||||||
installedServiceInfo.getComponentName(),
|
|
||||||
(String) installedServiceInfo.loadSummary(pm), true /* enabled */));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return candidates;
|
return candidates;
|
||||||
@@ -196,9 +191,9 @@ public class ShortcutServicePickerFragment extends RadioButtonPickerFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class FrameworkCandidateInfo extends CandidateInfo {
|
private class FrameworkCandidateInfo extends CandidateInfo {
|
||||||
ToggleableFrameworkFeatureInfo mToggleableFrameworkFeatureInfo;
|
final ToggleableFrameworkFeatureInfo mToggleableFrameworkFeatureInfo;
|
||||||
int mIconResId;
|
final int mIconResId;
|
||||||
String mKey;
|
final String mKey;
|
||||||
|
|
||||||
public FrameworkCandidateInfo(
|
public FrameworkCandidateInfo(
|
||||||
ToggleableFrameworkFeatureInfo frameworkFeatureInfo, int iconResId, String key) {
|
ToggleableFrameworkFeatureInfo frameworkFeatureInfo, int iconResId, String key) {
|
||||||
@@ -223,4 +218,49 @@ public class ShortcutServicePickerFragment extends RadioButtonPickerFragment {
|
|||||||
return mKey;
|
return mKey;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class ServiceCandidateInfo extends CandidateInfo {
|
||||||
|
final AccessibilityServiceInfo mServiceInfo;
|
||||||
|
|
||||||
|
public ServiceCandidateInfo(AccessibilityServiceInfo serviceInfo) {
|
||||||
|
super(true /* enabled */);
|
||||||
|
mServiceInfo = serviceInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CharSequence loadLabel() {
|
||||||
|
final PackageManagerWrapper pmw =
|
||||||
|
new PackageManagerWrapper(getContext().getPackageManager());
|
||||||
|
final CharSequence label =
|
||||||
|
mServiceInfo.getResolveInfo().serviceInfo.loadLabel(pmw.getPackageManager());
|
||||||
|
if (label != null) {
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
|
||||||
|
final ComponentName componentName = mServiceInfo.getComponentName();
|
||||||
|
if (componentName != null) {
|
||||||
|
try {
|
||||||
|
final ApplicationInfo appInfo = pmw.getApplicationInfoAsUser(
|
||||||
|
componentName.getPackageName(), 0, UserHandle.myUserId());
|
||||||
|
return appInfo.loadLabel(pmw.getPackageManager());
|
||||||
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Drawable loadIcon() {
|
||||||
|
final ResolveInfo resolveInfo = mServiceInfo.getResolveInfo();
|
||||||
|
return (resolveInfo.getIconResource() == 0)
|
||||||
|
? getContext().getDrawable(R.mipmap.ic_accessibility_generic)
|
||||||
|
: resolveInfo.loadIcon(getContext().getPackageManager());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getKey() {
|
||||||
|
return mServiceInfo.getComponentName().flattenToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,9 +23,11 @@ import android.support.v4.content.res.TypedArrayUtils;
|
|||||||
import android.support.v7.preference.Preference;
|
import android.support.v7.preference.Preference;
|
||||||
import android.text.format.Formatter;
|
import android.text.format.Formatter;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
import android.util.FeatureFlagUtils;
|
||||||
|
|
||||||
import com.android.internal.logging.nano.MetricsProto;
|
import com.android.internal.logging.nano.MetricsProto;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.core.FeatureFlags;
|
||||||
import com.android.settings.core.SubSettingLauncher;
|
import com.android.settings.core.SubSettingLauncher;
|
||||||
import com.android.settingslib.net.DataUsageController;
|
import com.android.settingslib.net.DataUsageController;
|
||||||
|
|
||||||
@@ -53,8 +55,13 @@ public class DataUsagePreference extends Preference implements TemplatePreferenc
|
|||||||
mSubId = subId;
|
mSubId = subId;
|
||||||
DataUsageController controller = new DataUsageController(getContext());
|
DataUsageController controller = new DataUsageController(getContext());
|
||||||
DataUsageController.DataUsageInfo usageInfo = controller.getDataUsageInfo(mTemplate);
|
DataUsageController.DataUsageInfo usageInfo = controller.getDataUsageInfo(mTemplate);
|
||||||
setSummary(getContext().getString(R.string.data_usage_template,
|
if (FeatureFlagUtils.isEnabled(getContext(), FeatureFlags.DATA_USAGE_SETTINGS_V2)) {
|
||||||
Formatter.formatFileSize(getContext(), usageInfo.usageLevel), usageInfo.period));
|
setTitle(getContext().getString(R.string.app_cellular_data_usage));
|
||||||
|
} else {
|
||||||
|
setTitle(getContext().getString(R.string.cellular_data_usage));
|
||||||
|
setSummary(getContext().getString(R.string.data_usage_template,
|
||||||
|
Formatter.formatFileSize(getContext(), usageInfo.usageLevel), usageInfo.period));
|
||||||
|
}
|
||||||
setIntent(getIntent());
|
setIntent(getIntent());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,10 +74,14 @@ public class DataUsagePreference extends Preference implements TemplatePreferenc
|
|||||||
.setArguments(args)
|
.setArguments(args)
|
||||||
.setDestination(DataUsageList.class.getName())
|
.setDestination(DataUsageList.class.getName())
|
||||||
.setSourceMetricsCategory(MetricsProto.MetricsEvent.VIEW_UNKNOWN);
|
.setSourceMetricsCategory(MetricsProto.MetricsEvent.VIEW_UNKNOWN);
|
||||||
if (mTitleRes > 0) {
|
if (FeatureFlagUtils.isEnabled(getContext(), FeatureFlags.DATA_USAGE_SETTINGS_V2)) {
|
||||||
launcher.setTitle(mTitleRes);
|
launcher.setTitle(getContext().getString(R.string.app_cellular_data_usage));
|
||||||
} else {
|
} else {
|
||||||
|
if (mTitleRes > 0) {
|
||||||
|
launcher.setTitle(mTitleRes);
|
||||||
|
} else {
|
||||||
launcher.setTitle(getTitle());
|
launcher.setTitle(getTitle());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return launcher.toIntent();
|
return launcher.toIntent();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,14 +18,16 @@ package com.android.settings.datausage;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.support.v7.preference.Preference;
|
||||||
import android.support.v7.preference.PreferenceViewHolder;
|
import android.support.v7.preference.PreferenceViewHolder;
|
||||||
|
import android.text.TextUtils;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.SummaryPreference;
|
|
||||||
import com.android.settingslib.utils.StringUtil;
|
import com.android.settingslib.utils.StringUtil;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@@ -33,7 +35,11 @@ import java.util.Objects;
|
|||||||
/**
|
/**
|
||||||
* Provides a summary of data usage.
|
* Provides a summary of data usage.
|
||||||
*/
|
*/
|
||||||
public class DataUsageSummaryPreference extends SummaryPreference {
|
public class DataUsageSummaryPreference extends Preference {
|
||||||
|
|
||||||
|
private boolean mChartEnabled = true;
|
||||||
|
private String mStartLabel;
|
||||||
|
private String mEndLabel;
|
||||||
|
|
||||||
private int mNumPlans;
|
private int mNumPlans;
|
||||||
/** The ending time of the billing cycle in milliseconds since epoch. */
|
/** The ending time of the billing cycle in milliseconds since epoch. */
|
||||||
@@ -45,6 +51,9 @@ public class DataUsageSummaryPreference extends SummaryPreference {
|
|||||||
private String mLimitInfoText;
|
private String mLimitInfoText;
|
||||||
private Intent mLaunchIntent;
|
private Intent mLaunchIntent;
|
||||||
|
|
||||||
|
/** Progress to display on ProgressBar */
|
||||||
|
private float mProgress;
|
||||||
|
|
||||||
public DataUsageSummaryPreference(Context context, AttributeSet attrs) {
|
public DataUsageSummaryPreference(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
setLayoutResource(R.layout.data_usage_summary_preference);
|
setLayoutResource(R.layout.data_usage_summary_preference);
|
||||||
@@ -57,6 +66,11 @@ public class DataUsageSummaryPreference extends SummaryPreference {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setProgress(float progress) {
|
||||||
|
mProgress = progress;
|
||||||
|
notifyChanged();
|
||||||
|
}
|
||||||
|
|
||||||
public void setUsageInfo(long cycleEnd, long snapshotTime, CharSequence carrierName,
|
public void setUsageInfo(long cycleEnd, long snapshotTime, CharSequence carrierName,
|
||||||
int numPlans, Intent launchIntent) {
|
int numPlans, Intent launchIntent) {
|
||||||
mCycleEndTimeMs = cycleEnd;
|
mCycleEndTimeMs = cycleEnd;
|
||||||
@@ -67,10 +81,33 @@ public class DataUsageSummaryPreference extends SummaryPreference {
|
|||||||
notifyChanged();
|
notifyChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setChartEnabled(boolean enabled) {
|
||||||
|
if (mChartEnabled != enabled) {
|
||||||
|
mChartEnabled = enabled;
|
||||||
|
notifyChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLabels(String start, String end) {
|
||||||
|
mStartLabel = start;
|
||||||
|
mEndLabel = end;
|
||||||
|
notifyChanged();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(PreferenceViewHolder holder) {
|
public void onBindViewHolder(PreferenceViewHolder holder) {
|
||||||
super.onBindViewHolder(holder);
|
super.onBindViewHolder(holder);
|
||||||
|
|
||||||
|
if (mChartEnabled && (!TextUtils.isEmpty(mStartLabel) || !TextUtils.isEmpty(mEndLabel))) {
|
||||||
|
holder.findViewById(R.id.label_bar).setVisibility(View.VISIBLE);
|
||||||
|
ProgressBar bar = (ProgressBar) holder.findViewById(R.id.determinateBar);
|
||||||
|
bar.setProgress((int) (mProgress * 100));
|
||||||
|
((TextView) holder.findViewById(android.R.id.text1)).setText(mStartLabel);
|
||||||
|
((TextView) holder.findViewById(android.R.id.text2)).setText(mEndLabel);
|
||||||
|
} else {
|
||||||
|
holder.findViewById(R.id.label_bar).setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
TextView usageTitle = (TextView) holder.findViewById(R.id.usage_title);
|
TextView usageTitle = (TextView) holder.findViewById(R.id.usage_title);
|
||||||
usageTitle.setVisibility(mNumPlans > 1 ? View.VISIBLE : View.GONE);
|
usageTitle.setVisibility(mNumPlans > 1 ? View.VISIBLE : View.GONE);
|
||||||
|
|
||||||
|
|||||||
@@ -194,8 +194,7 @@ public class DataUsageSummaryPreferenceController extends BasePreferenceControll
|
|||||||
summaryPreference.setChartEnabled(true);
|
summaryPreference.setChartEnabled(true);
|
||||||
summaryPreference.setLabels(Formatter.formatFileSize(mContext, 0 /* sizeBytes */),
|
summaryPreference.setLabels(Formatter.formatFileSize(mContext, 0 /* sizeBytes */),
|
||||||
Formatter.formatFileSize(mContext, mDataplanSize));
|
Formatter.formatFileSize(mContext, mDataplanSize));
|
||||||
summaryPreference.setRatios(mDataplanUse / (float) mDataplanSize, 0 /* middle */,
|
summaryPreference.setProgress(mDataplanUse / (float) mDataplanSize);
|
||||||
(mDataplanSize - mDataplanUse) / (float) mDataplanSize);
|
|
||||||
}
|
}
|
||||||
summaryPreference.setUsageInfo(mCycleEnd, mSnapshotTime, mCarrierName,
|
summaryPreference.setUsageInfo(mCycleEnd, mSnapshotTime, mCarrierName,
|
||||||
mDataplanCount, mManageSubscriptionIntent);
|
mDataplanCount, mManageSubscriptionIntent);
|
||||||
|
|||||||
@@ -31,8 +31,9 @@ import android.content.ContentResolver;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Process;
|
||||||
import android.os.StatsDimensionsValue;
|
import android.os.StatsDimensionsValue;
|
||||||
import android.os.SystemPropertiesProto;
|
import android.os.UserHandle;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.support.annotation.VisibleForTesting;
|
import android.support.annotation.VisibleForTesting;
|
||||||
@@ -122,7 +123,8 @@ public class AnomalyDetectionJobService extends JobService {
|
|||||||
final boolean smartBatteryOn = Settings.Global.getInt(contentResolver,
|
final boolean smartBatteryOn = Settings.Global.getInt(contentResolver,
|
||||||
Settings.Global.APP_STANDBY_ENABLED, ON) == ON;
|
Settings.Global.APP_STANDBY_ENABLED, ON) == ON;
|
||||||
final String packageName = batteryUtils.getPackageName(uid);
|
final String packageName = batteryUtils.getPackageName(uid);
|
||||||
if (!powerWhitelistBackend.isSysWhitelisted(packageName)) {
|
if (!powerWhitelistBackend.isSysWhitelistedExceptIdle(packageName)
|
||||||
|
&& !isSystemUid(uid)) {
|
||||||
if (anomalyType == StatsManagerConfig.AnomalyType.EXCESSIVE_BG) {
|
if (anomalyType == StatsManagerConfig.AnomalyType.EXCESSIVE_BG) {
|
||||||
// TODO(b/72385333): check battery percentage draining in batterystats
|
// TODO(b/72385333): check battery percentage draining in batterystats
|
||||||
if (batteryUtils.isLegacyApp(packageName) && batteryUtils.isAppHeavilyUsed(
|
if (batteryUtils.isLegacyApp(packageName) && batteryUtils.isAppHeavilyUsed(
|
||||||
@@ -156,7 +158,7 @@ public class AnomalyDetectionJobService extends JobService {
|
|||||||
* 3. Bluetooth anomaly: 3:{1:{1:{1:10140|}|}|}
|
* 3. Bluetooth anomaly: 3:{1:{1:{1:10140|}|}|}
|
||||||
*/
|
*/
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
final int extractUidFromStatsDimensionsValue(StatsDimensionsValue statsDimensionsValue) {
|
int extractUidFromStatsDimensionsValue(StatsDimensionsValue statsDimensionsValue) {
|
||||||
//TODO(b/73172999): Add robo test for this method
|
//TODO(b/73172999): Add robo test for this method
|
||||||
if (statsDimensionsValue == null) {
|
if (statsDimensionsValue == null) {
|
||||||
return UID_NULL;
|
return UID_NULL;
|
||||||
@@ -178,4 +180,9 @@ public class AnomalyDetectionJobService extends JobService {
|
|||||||
|
|
||||||
return UID_NULL;
|
return UID_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isSystemUid(int uid) {
|
||||||
|
final int appUid = UserHandle.getAppId(uid);
|
||||||
|
return appUid >= Process.ROOT_UID && appUid < Process.FIRST_APPLICATION_UID;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,9 @@ import android.widget.LinearLayout;
|
|||||||
|
|
||||||
import com.android.settings.Utils;
|
import com.android.settings.Utils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Deprecated Use {@link android.widget.ProgressBar} instead.
|
||||||
|
*/
|
||||||
public class LinearColorBar extends LinearLayout {
|
public class LinearColorBar extends LinearLayout {
|
||||||
|
|
||||||
static final int RIGHT_COLOR = 0xffced7db;
|
static final int RIGHT_COLOR = 0xffced7db;
|
||||||
|
|||||||
@@ -363,6 +363,9 @@ public class WifiConfigController implements TextWatcher,
|
|||||||
if (mConfigUi.getSubmitButton() != null) {
|
if (mConfigUi.getSubmitButton() != null) {
|
||||||
enableSubmitIfAppropriate();
|
enableSubmitIfAppropriate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// After done view show and hide, request focus from parent view
|
||||||
|
mView.findViewById(R.id.l_wifidialog).requestFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
@@ -1216,6 +1219,11 @@ public class WifiConfigController implements TextWatcher,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
KeyStore getKeyStore() {
|
||||||
|
return KeyStore.getInstance();
|
||||||
|
}
|
||||||
|
|
||||||
private void loadCertificates(
|
private void loadCertificates(
|
||||||
Spinner spinner,
|
Spinner spinner,
|
||||||
String prefix,
|
String prefix,
|
||||||
@@ -1232,8 +1240,12 @@ public class WifiConfigController implements TextWatcher,
|
|||||||
if (showUsePreinstalledCertOption) {
|
if (showUsePreinstalledCertOption) {
|
||||||
certs.add(mUseSystemCertsString);
|
certs.add(mUseSystemCertsString);
|
||||||
}
|
}
|
||||||
certs.addAll(
|
try {
|
||||||
Arrays.asList(KeyStore.getInstance().list(prefix, android.os.Process.WIFI_UID)));
|
certs.addAll(
|
||||||
|
Arrays.asList(getKeyStore().list(prefix, android.os.Process.WIFI_UID)));
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.e(TAG, "can't get the certificate list from KeyStore");
|
||||||
|
}
|
||||||
certs.add(noCertificateString);
|
certs.add(noCertificateString);
|
||||||
|
|
||||||
final ArrayAdapter<String> adapter = new ArrayAdapter<String>(
|
final ArrayAdapter<String> adapter = new ArrayAdapter<String>(
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ import android.support.v7.preference.PreferenceViewHolder;
|
|||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
@@ -54,6 +56,10 @@ public class DataUsageSummaryPreferenceTest {
|
|||||||
private TextView mCarrierInfo;
|
private TextView mCarrierInfo;
|
||||||
private TextView mDataLimits;
|
private TextView mDataLimits;
|
||||||
private Button mLaunchButton;
|
private Button mLaunchButton;
|
||||||
|
private LinearLayout mLabelBar;
|
||||||
|
private TextView mLabel1;
|
||||||
|
private TextView mLabel2;
|
||||||
|
private ProgressBar mProgressBar;
|
||||||
|
|
||||||
private long mCycleEnd;
|
private long mCycleEnd;
|
||||||
private long mUpdateTime;
|
private long mUpdateTime;
|
||||||
@@ -159,6 +165,46 @@ public class DataUsageSummaryPreferenceTest {
|
|||||||
assertThat(mDataLimits.getVisibility()).isEqualTo(View.GONE);
|
assertThat(mDataLimits.getVisibility()).isEqualTo(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSetChartEnabledFalse_hidesLabelBar() {
|
||||||
|
setValidLabels();
|
||||||
|
mSummaryPreference.setChartEnabled(false);
|
||||||
|
|
||||||
|
bindViewHolder();
|
||||||
|
assertThat(mLabelBar.getVisibility()).isEqualTo(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSetEmptyLabels_hidesLabelBar() {
|
||||||
|
mSummaryPreference.setLabels("", "");
|
||||||
|
|
||||||
|
bindViewHolder();
|
||||||
|
assertThat(mLabelBar.getVisibility()).isEqualTo(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testLabelBar_isVisible_whenLabelsSet() {
|
||||||
|
setValidLabels();
|
||||||
|
//mChartEnabled defaults to true
|
||||||
|
|
||||||
|
bindViewHolder();
|
||||||
|
assertThat(mLabelBar.getVisibility()).isEqualTo(View.VISIBLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSetProgress_updatesProgressBar() {
|
||||||
|
setValidLabels();
|
||||||
|
mSummaryPreference.setProgress(.5f);
|
||||||
|
|
||||||
|
bindViewHolder();
|
||||||
|
assertThat(mProgressBar.getProgress()).isEqualTo(50);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setValidLabels() {
|
||||||
|
mSummaryPreference.setLabels("0.0 GB", "5.0 GB");
|
||||||
|
}
|
||||||
|
|
||||||
private void bindViewHolder() {
|
private void bindViewHolder() {
|
||||||
mSummaryPreference.onBindViewHolder(mHolder);
|
mSummaryPreference.onBindViewHolder(mHolder);
|
||||||
mUsageTitle = (TextView) mHolder.findViewById(R.id.usage_title);
|
mUsageTitle = (TextView) mHolder.findViewById(R.id.usage_title);
|
||||||
@@ -166,5 +212,9 @@ public class DataUsageSummaryPreferenceTest {
|
|||||||
mCarrierInfo = (TextView) mHolder.findViewById(R.id.carrier_and_update);
|
mCarrierInfo = (TextView) mHolder.findViewById(R.id.carrier_and_update);
|
||||||
mDataLimits = (TextView) mHolder.findViewById(R.id.data_limits);
|
mDataLimits = (TextView) mHolder.findViewById(R.id.data_limits);
|
||||||
mLaunchButton = (Button) mHolder.findViewById(R.id.launch_mdp_app_button);
|
mLaunchButton = (Button) mHolder.findViewById(R.id.launch_mdp_app_button);
|
||||||
|
mLabelBar = (LinearLayout) mHolder.findViewById(R.id.label_bar);
|
||||||
|
mLabel1 = (TextView) mHolder.findViewById(R.id.text1);
|
||||||
|
mLabel2 = (TextView) mHolder.findViewById(R.id.text2);
|
||||||
|
mProgressBar = (ProgressBar) mHolder.findViewById(R.id.determinateBar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -18,11 +18,13 @@ package com.android.settings.fuelgauge.batterytip;
|
|||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
|
import static org.mockito.Matchers.any;
|
||||||
import static org.mockito.Matchers.anyInt;
|
import static org.mockito.Matchers.anyInt;
|
||||||
import static org.mockito.Matchers.anyLong;
|
import static org.mockito.Matchers.anyLong;
|
||||||
import static org.mockito.Matchers.anyString;
|
import static org.mockito.Matchers.anyString;
|
||||||
import static org.mockito.Mockito.doReturn;
|
import static org.mockito.Mockito.doReturn;
|
||||||
import static org.mockito.Mockito.never;
|
import static org.mockito.Mockito.never;
|
||||||
|
import static org.mockito.Mockito.spy;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.robolectric.RuntimeEnvironment.application;
|
import static org.robolectric.RuntimeEnvironment.application;
|
||||||
|
|
||||||
@@ -32,6 +34,7 @@ import android.app.job.JobScheduler;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Process;
|
||||||
import android.os.StatsDimensionsValue;
|
import android.os.StatsDimensionsValue;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
|
|
||||||
@@ -84,7 +87,7 @@ public class AnomalyDetectionJobServiceTest {
|
|||||||
mBundle = new Bundle();
|
mBundle = new Bundle();
|
||||||
mBundle.putParcelable(StatsManager.EXTRA_STATS_DIMENSIONS_VALUE, mStatsDimensionsValue);
|
mBundle.putParcelable(StatsManager.EXTRA_STATS_DIMENSIONS_VALUE, mStatsDimensionsValue);
|
||||||
|
|
||||||
mAnomalyDetectionJobService = new AnomalyDetectionJobService();
|
mAnomalyDetectionJobService = spy(new AnomalyDetectionJobService());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -92,13 +95,14 @@ public class AnomalyDetectionJobServiceTest {
|
|||||||
AnomalyDetectionJobService.scheduleAnomalyDetection(application, new Intent());
|
AnomalyDetectionJobService.scheduleAnomalyDetection(application, new Intent());
|
||||||
|
|
||||||
ShadowJobScheduler shadowJobScheduler =
|
ShadowJobScheduler shadowJobScheduler =
|
||||||
Shadows.shadowOf(application.getSystemService(JobScheduler.class));
|
Shadows.shadowOf(application.getSystemService(JobScheduler.class));
|
||||||
List<JobInfo> pendingJobs = shadowJobScheduler.getAllPendingJobs();
|
List<JobInfo> pendingJobs = shadowJobScheduler.getAllPendingJobs();
|
||||||
assertThat(pendingJobs).hasSize(1);
|
assertThat(pendingJobs).hasSize(1);
|
||||||
|
|
||||||
JobInfo pendingJob = pendingJobs.get(0);
|
JobInfo pendingJob = pendingJobs.get(0);
|
||||||
assertThat(pendingJob.getId()).isEqualTo(R.id.job_anomaly_detection);
|
assertThat(pendingJob.getId()).isEqualTo(R.id.job_anomaly_detection);
|
||||||
assertThat(pendingJob.getMaxExecutionDelayMillis())
|
assertThat(pendingJob.getMaxExecutionDelayMillis())
|
||||||
.isEqualTo(TimeUnit.MINUTES.toMillis(30));
|
.isEqualTo(TimeUnit.MINUTES.toMillis(30));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -114,10 +118,25 @@ public class AnomalyDetectionJobServiceTest {
|
|||||||
anyInt(), anyLong());
|
anyInt(), anyLong());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSaveAnomalyToDatabase_systemUid_doNotSave() {
|
||||||
|
doReturn(Process.SYSTEM_UID).when(
|
||||||
|
mAnomalyDetectionJobService).extractUidFromStatsDimensionsValue(any());
|
||||||
|
|
||||||
|
mAnomalyDetectionJobService.saveAnomalyToDatabase(mBatteryStatsHelper, mUserManager,
|
||||||
|
mBatteryDatabaseManager, mBatteryUtils, mPolicy, mPowerWhitelistBackend,
|
||||||
|
mContext.getContentResolver(), mBundle);
|
||||||
|
|
||||||
|
verify(mBatteryDatabaseManager, never()).insertAnomaly(anyInt(), anyString(), anyInt(),
|
||||||
|
anyInt(), anyLong());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSaveAnomalyToDatabase_normalApp_save() {
|
public void testSaveAnomalyToDatabase_normalApp_save() {
|
||||||
doReturn(SYSTEM_PACKAGE).when(mBatteryUtils).getPackageName(anyInt());
|
doReturn(SYSTEM_PACKAGE).when(mBatteryUtils).getPackageName(anyInt());
|
||||||
doReturn(false).when(mPowerWhitelistBackend).isSysWhitelisted(SYSTEM_PACKAGE);
|
doReturn(false).when(mPowerWhitelistBackend).isSysWhitelisted(SYSTEM_PACKAGE);
|
||||||
|
doReturn(Process.FIRST_APPLICATION_UID).when(
|
||||||
|
mAnomalyDetectionJobService).extractUidFromStatsDimensionsValue(any());
|
||||||
|
|
||||||
mAnomalyDetectionJobService.saveAnomalyToDatabase(mBatteryStatsHelper, mUserManager,
|
mAnomalyDetectionJobService.saveAnomalyToDatabase(mBatteryStatsHelper, mUserManager,
|
||||||
mBatteryDatabaseManager, mBatteryUtils, mPolicy, mPowerWhitelistBackend,
|
mBatteryDatabaseManager, mBatteryUtils, mPolicy, mPowerWhitelistBackend,
|
||||||
|
|||||||
@@ -20,11 +20,14 @@ import static com.google.common.truth.Truth.assertThat;
|
|||||||
import static org.mockito.Mockito.any;
|
import static org.mockito.Mockito.any;
|
||||||
import static org.mockito.Mockito.anyBoolean;
|
import static org.mockito.Mockito.anyBoolean;
|
||||||
import static org.mockito.Mockito.anyInt;
|
import static org.mockito.Mockito.anyInt;
|
||||||
|
import static org.mockito.Mockito.anyString;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.os.ServiceSpecificException;
|
||||||
|
import android.security.KeyStore;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@@ -56,6 +59,8 @@ public class WifiConfigControllerTest {
|
|||||||
private View mView;
|
private View mView;
|
||||||
@Mock
|
@Mock
|
||||||
private AccessPoint mAccessPoint;
|
private AccessPoint mAccessPoint;
|
||||||
|
@Mock
|
||||||
|
private KeyStore mKeyStore;
|
||||||
|
|
||||||
public WifiConfigController mController;
|
public WifiConfigController mController;
|
||||||
private static final String HEX_PSK = "01234567012345670123456701234567012345670123456701234567"
|
private static final String HEX_PSK = "01234567012345670123456701234567012345670123456701234567"
|
||||||
@@ -210,6 +215,37 @@ public class WifiConfigControllerTest {
|
|||||||
assertThat(mView.findViewById(R.id.eap).getVisibility()).isEqualTo(View.GONE);
|
assertThat(mView.findViewById(R.id.eap).getVisibility()).isEqualTo(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void loadCertificates_keyStoreListFail_shouldNotCrash() {
|
||||||
|
// Set up
|
||||||
|
when(mAccessPoint.getSecurity()).thenReturn(AccessPoint.SECURITY_EAP);
|
||||||
|
when(mKeyStore.list(anyString()))
|
||||||
|
.thenThrow(new ServiceSpecificException(-1, "permission error"));
|
||||||
|
|
||||||
|
mController = new TestWifiConfigController(mConfigUiBase, mView, mAccessPoint,
|
||||||
|
WifiConfigUiBase.MODE_CONNECT);
|
||||||
|
|
||||||
|
// Verify that the EAP method menu is visible.
|
||||||
|
assertThat(mView.findViewById(R.id.eap).getVisibility()).isEqualTo(View.VISIBLE);
|
||||||
|
// No Crash
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void ssidGetFocus_addNewNetwork_shouldReturnTrue() {
|
||||||
|
mController = new TestWifiConfigController(mConfigUiBase, mView, null /* accessPoint */,
|
||||||
|
WifiConfigUiBase.MODE_CONNECT);
|
||||||
|
final TextView ssid = mView.findViewById(R.id.ssid);
|
||||||
|
// Verify ssid text get focus when add new network (accesspoint is null)
|
||||||
|
assertThat(ssid.isFocused()).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void passwordGetFocus_connectSecureWifi_shouldReturnTrue() {
|
||||||
|
final TextView password = mView.findViewById(R.id.password);
|
||||||
|
// Verify password get focus when connect to secure wifi without eap type
|
||||||
|
assertThat(password.isFocused()).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
public class TestWifiConfigController extends WifiConfigController {
|
public class TestWifiConfigController extends WifiConfigController {
|
||||||
|
|
||||||
private TestWifiConfigController(
|
private TestWifiConfigController(
|
||||||
@@ -221,5 +257,8 @@ public class WifiConfigControllerTest {
|
|||||||
boolean isSplitSystemUser() {
|
boolean isSplitSystemUser() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
KeyStore getKeyStore() { return mKeyStore; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user