Snap for 10527654 from 8cdbeab57c to udc-qpr1-release
Change-Id: Ifa23d2b664d6ad9ac08b37bf7aa16106139bc77e
This commit is contained in:
@@ -14,13 +14,18 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
-->
|
-->
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:id="@+id/color_selector_root_view"
|
android:id="@+id/color_selector_root_view"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="20dp"
|
||||||
|
android:clipToPadding="false"
|
||||||
|
android:scrollbarStyle="outsideOverlay">
|
||||||
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:minHeight="?android:attr/listPreferredItemHeight"
|
android:minHeight="?android:attr/listPreferredItemHeight"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@@ -171,4 +176,5 @@
|
|||||||
android:contentDescription="@string/screen_flash_color_violet" />
|
android:contentDescription="@string/screen_flash_color_violet" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
</ScrollView>
|
||||||
|
|||||||
@@ -17,16 +17,12 @@
|
|||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical"
|
android:gravity="center_horizontal"
|
||||||
android:paddingBottom="24dp">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<com.android.settings.accessibility.ColorSelectorLayout
|
<com.android.settings.accessibility.ColorSelectorLayout
|
||||||
android:id="@+id/color_selector_preference"
|
android:id="@+id/color_selector_preference"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"/>
|
||||||
android:layout_marginBottom="2dp"
|
|
||||||
android:layout_marginHorizontal="25dp"
|
|
||||||
android:layout_marginTop="21dp"
|
|
||||||
android:orientation="vertical" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
@@ -124,7 +124,7 @@ public class StylusDevicesController extends AbstractPreferenceController implem
|
|||||||
try {
|
try {
|
||||||
ApplicationInfo ai = pm.getApplicationInfo(packageName,
|
ApplicationInfo ai = pm.getApplicationInfo(packageName,
|
||||||
PackageManager.ApplicationInfoFlags.of(0));
|
PackageManager.ApplicationInfoFlags.of(0));
|
||||||
appName = ai == null ? packageName : pm.getApplicationLabel(ai).toString();
|
appName = ai == null ? "" : pm.getApplicationLabel(ai).toString();
|
||||||
} catch (PackageManager.NameNotFoundException e) {
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
Log.e(TAG, "Notes role package not found.");
|
Log.e(TAG, "Notes role package not found.");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -369,6 +369,12 @@ public class ScreenResolutionFragment extends RadioButtonPickerFragment {
|
|||||||
|
|
||||||
private void restoreDensity() {
|
private void restoreDensity() {
|
||||||
final DisplayDensityUtils density = new DisplayDensityUtils(mContext);
|
final DisplayDensityUtils density = new DisplayDensityUtils(mContext);
|
||||||
|
/* If current density is the same as a default density of other resolutions,
|
||||||
|
* then mCurrentIndex may be out of boundary.
|
||||||
|
*/
|
||||||
|
if (density.getDefaultDisplayDensityValues().length <= mCurrentIndex) {
|
||||||
|
mCurrentIndex = density.getCurrentIndexForDefaultDisplay();
|
||||||
|
}
|
||||||
if (density.getDefaultDisplayDensityValues()[mCurrentIndex]
|
if (density.getDefaultDisplayDensityValues()[mCurrentIndex]
|
||||||
!= density.getDefaultDensityForDefaultDisplay()) {
|
!= density.getDefaultDensityForDefaultDisplay()) {
|
||||||
density.setForcedDisplayDensity(mCurrentIndex);
|
density.setForcedDisplayDensity(mCurrentIndex);
|
||||||
|
|||||||
@@ -128,6 +128,11 @@ public interface PowerUsageFeatureProvider {
|
|||||||
*/
|
*/
|
||||||
boolean delayHourlyJobWhenBooting();
|
boolean delayHourlyJobWhenBooting();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Insert device usage data for anomaly detection
|
||||||
|
*/
|
||||||
|
void insertSettingsData(Context context);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets an intent for one time bypass charge limited to resume charging.
|
* Gets an intent for one time bypass charge limited to resume charging.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -160,6 +160,9 @@ public class PowerUsageFeatureProviderImpl implements PowerUsageFeatureProvider
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void insertSettingsData(Context context) {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<Integer> getOthersSystemComponentSet() {
|
public Set<Integer> getOthersSystemComponentSet() {
|
||||||
return new ArraySet<>();
|
return new ArraySet<>();
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ package com.android.settings.fuelgauge.batteryusage;
|
|||||||
import static com.android.settings.Utils.formatPercentage;
|
import static com.android.settings.Utils.formatPercentage;
|
||||||
import static com.android.settings.fuelgauge.batteryusage.BatteryChartViewModel.AxisLabelPosition.BETWEEN_TRAPEZOIDS;
|
import static com.android.settings.fuelgauge.batteryusage.BatteryChartViewModel.AxisLabelPosition.BETWEEN_TRAPEZOIDS;
|
||||||
|
|
||||||
|
import static java.lang.Math.abs;
|
||||||
import static java.lang.Math.round;
|
import static java.lang.Math.round;
|
||||||
import static java.util.Objects.requireNonNull;
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
@@ -74,6 +75,8 @@ public class BatteryChartView extends AppCompatImageView implements View.OnClick
|
|||||||
private final Rect[] mPercentageBounds = new Rect[]{new Rect(), new Rect(), new Rect()};
|
private final Rect[] mPercentageBounds = new Rect[]{new Rect(), new Rect(), new Rect()};
|
||||||
private final List<Rect> mAxisLabelsBounds = new ArrayList<>();
|
private final List<Rect> mAxisLabelsBounds = new ArrayList<>();
|
||||||
private final Set<Integer> mLabelDrawnIndexes = new ArraySet<>();
|
private final Set<Integer> mLabelDrawnIndexes = new ArraySet<>();
|
||||||
|
private final int mLayoutDirection =
|
||||||
|
getContext().getResources().getConfiguration().getLayoutDirection();
|
||||||
|
|
||||||
private BatteryChartViewModel mViewModel;
|
private BatteryChartViewModel mViewModel;
|
||||||
private int mHoveredIndex = BatteryChartViewModel.SELECTED_INDEX_INVALID;
|
private int mHoveredIndex = BatteryChartViewModel.SELECTED_INDEX_INVALID;
|
||||||
@@ -159,7 +162,12 @@ public class BatteryChartView extends AppCompatImageView implements View.OnClick
|
|||||||
}
|
}
|
||||||
// Updates the indent configurations.
|
// Updates the indent configurations.
|
||||||
mIndent.top = mPercentageBounds[0].height();
|
mIndent.top = mPercentageBounds[0].height();
|
||||||
mIndent.right = mPercentageBounds[0].width() + mTextPadding;
|
final int textWidth = mPercentageBounds[0].width() + mTextPadding;
|
||||||
|
if (isRTL()) {
|
||||||
|
mIndent.left = textWidth;
|
||||||
|
} else {
|
||||||
|
mIndent.right = textWidth;
|
||||||
|
}
|
||||||
|
|
||||||
if (mViewModel != null) {
|
if (mViewModel != null) {
|
||||||
int maxTop = 0;
|
int maxTop = 0;
|
||||||
@@ -334,7 +342,7 @@ public class BatteryChartView extends AppCompatImageView implements View.OnClick
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void drawHorizontalDividers(Canvas canvas) {
|
private void drawHorizontalDividers(Canvas canvas) {
|
||||||
final int width = getWidth() - mIndent.right;
|
final int width = getWidth() - abs(mIndent.width());
|
||||||
final int height = getHeight() - mIndent.top - mIndent.bottom;
|
final int height = getHeight() - mIndent.top - mIndent.bottom;
|
||||||
final float topOffsetY = mIndent.top + mDividerWidth * .5f;
|
final float topOffsetY = mIndent.top + mDividerWidth * .5f;
|
||||||
final float bottomOffsetY = mIndent.top + (height - mDividerHeight - mDividerWidth * .5f);
|
final float bottomOffsetY = mIndent.top + (height - mDividerHeight - mDividerWidth * .5f);
|
||||||
@@ -347,7 +355,8 @@ public class BatteryChartView extends AppCompatImageView implements View.OnClick
|
|||||||
// Draws 5 divider lines.
|
// Draws 5 divider lines.
|
||||||
for (int index = 0; index < HORIZONTAL_DIVIDER_COUNT; index++) {
|
for (int index = 0; index < HORIZONTAL_DIVIDER_COUNT; index++) {
|
||||||
float offsetY = topOffsetY + dividerOffsetUnit * index;
|
float offsetY = topOffsetY + dividerOffsetUnit * index;
|
||||||
canvas.drawLine(0, offsetY, width, offsetY, mDividerPaint);
|
canvas.drawLine(mIndent.left, offsetY,
|
||||||
|
mIndent.left + width, offsetY, mDividerPaint);
|
||||||
|
|
||||||
// Draws percentage text only for 100% / 50% / 0%
|
// Draws percentage text only for 100% / 50% / 0%
|
||||||
if (index % 2 == 0) {
|
if (index % 2 == 0) {
|
||||||
@@ -362,14 +371,14 @@ public class BatteryChartView extends AppCompatImageView implements View.OnClick
|
|||||||
mTextPaint.setColor(mDefaultTextColor);
|
mTextPaint.setColor(mDefaultTextColor);
|
||||||
canvas.drawText(
|
canvas.drawText(
|
||||||
mPercentages[index],
|
mPercentages[index],
|
||||||
getWidth(),
|
isRTL() ? mIndent.left - mTextPadding : getWidth(),
|
||||||
offsetY + mPercentageBounds[index].height() * .5f,
|
offsetY + mPercentageBounds[index].height() * .5f,
|
||||||
mTextPaint);
|
mTextPaint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void drawVerticalDividers(Canvas canvas) {
|
private void drawVerticalDividers(Canvas canvas) {
|
||||||
final int width = getWidth() - mIndent.right;
|
final int width = getWidth() - abs(mIndent.width());
|
||||||
final int dividerCount = mTrapezoidSlots.length + 1;
|
final int dividerCount = mTrapezoidSlots.length + 1;
|
||||||
final float dividerSpace = dividerCount * mDividerWidth;
|
final float dividerSpace = dividerCount * mDividerWidth;
|
||||||
final float unitWidth = (width - dividerSpace) / (float) mTrapezoidSlots.length;
|
final float unitWidth = (width - dividerSpace) / (float) mTrapezoidSlots.length;
|
||||||
@@ -384,7 +393,7 @@ public class BatteryChartView extends AppCompatImageView implements View.OnClick
|
|||||||
case CENTER_OF_TRAPEZOIDS:
|
case CENTER_OF_TRAPEZOIDS:
|
||||||
axisLabelDisplayAreas = getAxisLabelDisplayAreas(
|
axisLabelDisplayAreas = getAxisLabelDisplayAreas(
|
||||||
/* size= */ mViewModel.size() - 1,
|
/* size= */ mViewModel.size() - 1,
|
||||||
/* baselineX= */ mDividerWidth + unitWidth * .5f,
|
/* baselineX= */ mIndent.left + mDividerWidth + unitWidth * .5f,
|
||||||
/* offsetX= */ mDividerWidth + unitWidth,
|
/* offsetX= */ mDividerWidth + unitWidth,
|
||||||
baselineY,
|
baselineY,
|
||||||
/* shiftFirstAndLast= */ false);
|
/* shiftFirstAndLast= */ false);
|
||||||
@@ -393,7 +402,7 @@ public class BatteryChartView extends AppCompatImageView implements View.OnClick
|
|||||||
default:
|
default:
|
||||||
axisLabelDisplayAreas = getAxisLabelDisplayAreas(
|
axisLabelDisplayAreas = getAxisLabelDisplayAreas(
|
||||||
/* size= */ mViewModel.size(),
|
/* size= */ mViewModel.size(),
|
||||||
/* baselineX= */ mDividerWidth * .5f,
|
/* baselineX= */ mIndent.left + mDividerWidth * .5f,
|
||||||
/* offsetX= */ mDividerWidth + unitWidth,
|
/* offsetX= */ mDividerWidth + unitWidth,
|
||||||
baselineY,
|
baselineY,
|
||||||
/* shiftFirstAndLast= */ true);
|
/* shiftFirstAndLast= */ true);
|
||||||
@@ -402,7 +411,7 @@ public class BatteryChartView extends AppCompatImageView implements View.OnClick
|
|||||||
drawAxisLabels(canvas, axisLabelDisplayAreas, baselineY);
|
drawAxisLabels(canvas, axisLabelDisplayAreas, baselineY);
|
||||||
}
|
}
|
||||||
// Draws each vertical dividers.
|
// Draws each vertical dividers.
|
||||||
float startX = mDividerWidth * .5f;
|
float startX = mDividerWidth * .5f + mIndent.left;
|
||||||
for (int index = 0; index < dividerCount; index++) {
|
for (int index = 0; index < dividerCount; index++) {
|
||||||
float dividerY = bottomY;
|
float dividerY = bottomY;
|
||||||
if (mViewModel.axisLabelPosition() == BETWEEN_TRAPEZOIDS
|
if (mViewModel.axisLabelPosition() == BETWEEN_TRAPEZOIDS
|
||||||
@@ -416,8 +425,9 @@ public class BatteryChartView extends AppCompatImageView implements View.OnClick
|
|||||||
final float nextX = startX + mDividerWidth + unitWidth;
|
final float nextX = startX + mDividerWidth + unitWidth;
|
||||||
// Updates the trapezoid slots for drawing.
|
// Updates the trapezoid slots for drawing.
|
||||||
if (index < mTrapezoidSlots.length) {
|
if (index < mTrapezoidSlots.length) {
|
||||||
mTrapezoidSlots[index].mLeft = round(startX + trapezoidSlotOffset);
|
final int trapezoidIndex = isRTL() ? mTrapezoidSlots.length - index - 1 : index;
|
||||||
mTrapezoidSlots[index].mRight = round(nextX - trapezoidSlotOffset);
|
mTrapezoidSlots[trapezoidIndex].mLeft = round(startX + trapezoidSlotOffset);
|
||||||
|
mTrapezoidSlots[trapezoidIndex].mRight = round(nextX - trapezoidSlotOffset);
|
||||||
}
|
}
|
||||||
startX = nextX;
|
startX = nextX;
|
||||||
}
|
}
|
||||||
@@ -509,10 +519,20 @@ public class BatteryChartView extends AppCompatImageView implements View.OnClick
|
|||||||
return displayAreas[leftIndex].right + mTextPadding * 2.3f > displayAreas[rightIndex].left;
|
return displayAreas[leftIndex].right + mTextPadding * 2.3f > displayAreas[rightIndex].left;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isRTL() {
|
||||||
|
return mLayoutDirection == View.LAYOUT_DIRECTION_RTL;
|
||||||
|
}
|
||||||
|
|
||||||
private void drawAxisLabelText(
|
private void drawAxisLabelText(
|
||||||
Canvas canvas, final int index, final Rect displayArea, final float baselineY) {
|
Canvas canvas, int index, final Rect displayArea, final float baselineY) {
|
||||||
mTextPaint.setColor(mTrapezoidSolidColor);
|
mTextPaint.setColor(mTrapezoidSolidColor);
|
||||||
mTextPaint.setTextAlign(Paint.Align.CENTER);
|
mTextPaint.setTextAlign(Paint.Align.CENTER);
|
||||||
|
// Reverse the sort of axis labels for RTL
|
||||||
|
if (isRTL()) {
|
||||||
|
index = mViewModel.axisLabelPosition() == BETWEEN_TRAPEZOIDS
|
||||||
|
? mViewModel.size() - index - 1 // for hourly
|
||||||
|
: mViewModel.size() - index - 2; // for daily
|
||||||
|
}
|
||||||
canvas.drawText(
|
canvas.drawText(
|
||||||
mViewModel.getText(index),
|
mViewModel.getText(index),
|
||||||
displayArea.centerX(),
|
displayArea.centerX(),
|
||||||
@@ -548,10 +568,16 @@ public class BatteryChartView extends AppCompatImageView implements View.OnClick
|
|||||||
mHoveredIndex);
|
mHoveredIndex);
|
||||||
mTrapezoidPaint.setColor(isHoverState ? mTrapezoidHoverColor : trapezoidColor);
|
mTrapezoidPaint.setColor(isHoverState ? mTrapezoidHoverColor : trapezoidColor);
|
||||||
|
|
||||||
final float leftTop = round(
|
float leftTop = round(
|
||||||
trapezoidBottom - requireNonNull(mViewModel.getLevel(index)) * unitHeight);
|
trapezoidBottom - requireNonNull(mViewModel.getLevel(index)) * unitHeight);
|
||||||
final float rightTop = round(trapezoidBottom
|
float rightTop = round(trapezoidBottom
|
||||||
- requireNonNull(mViewModel.getLevel(index + 1)) * unitHeight);
|
- requireNonNull(mViewModel.getLevel(index + 1)) * unitHeight);
|
||||||
|
// Mirror the shape of the trapezoid for RTL
|
||||||
|
if (isRTL()) {
|
||||||
|
float temp = leftTop;
|
||||||
|
leftTop = rightTop;
|
||||||
|
rightTop = temp;
|
||||||
|
}
|
||||||
trapezoidPath.reset();
|
trapezoidPath.reset();
|
||||||
trapezoidPath.moveTo(mTrapezoidSlots[index].mLeft, trapezoidBottom);
|
trapezoidPath.moveTo(mTrapezoidSlots[index].mLeft, trapezoidBottom);
|
||||||
trapezoidPath.lineTo(mTrapezoidSlots[index].mLeft, leftTop);
|
trapezoidPath.lineTo(mTrapezoidSlots[index].mLeft, leftTop);
|
||||||
|
|||||||
@@ -15,6 +15,8 @@
|
|||||||
*/
|
*/
|
||||||
package com.android.settings.wifi;
|
package com.android.settings.wifi;
|
||||||
|
|
||||||
|
import static com.android.settingslib.wifi.WifiUtils.getHotspotIconResource;
|
||||||
|
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
@@ -37,6 +39,7 @@ import com.android.settingslib.RestrictedPreference;
|
|||||||
import com.android.settingslib.Utils;
|
import com.android.settingslib.Utils;
|
||||||
import com.android.settingslib.wifi.WifiUtils;
|
import com.android.settingslib.wifi.WifiUtils;
|
||||||
import com.android.wifitrackerlib.BaseWifiTracker;
|
import com.android.wifitrackerlib.BaseWifiTracker;
|
||||||
|
import com.android.wifitrackerlib.HotspotNetworkEntry;
|
||||||
import com.android.wifitrackerlib.WifiEntry;
|
import com.android.wifitrackerlib.WifiEntry;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -145,13 +148,17 @@ public class WifiEntryPreference extends RestrictedPreference implements
|
|||||||
*/
|
*/
|
||||||
public void refresh() {
|
public void refresh() {
|
||||||
setTitle(mWifiEntry.getTitle());
|
setTitle(mWifiEntry.getTitle());
|
||||||
final int level = mWifiEntry.getLevel();
|
if (mWifiEntry instanceof HotspotNetworkEntry) {
|
||||||
final boolean showX = mWifiEntry.shouldShowXLevelIcon();
|
updateHotspotIcon(((HotspotNetworkEntry) mWifiEntry).getDeviceType());
|
||||||
|
} else {
|
||||||
|
int level = mWifiEntry.getLevel();
|
||||||
|
boolean showX = mWifiEntry.shouldShowXLevelIcon();
|
||||||
|
|
||||||
if (level != mLevel || showX != mShowX) {
|
if (level != mLevel || showX != mShowX) {
|
||||||
mLevel = level;
|
mLevel = level;
|
||||||
mShowX = showX;
|
mShowX = showX;
|
||||||
updateIcon(mShowX, mLevel);
|
updateIcon(mShowX, mLevel);
|
||||||
notifyChanged();
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setSummary(mWifiEntry.getSummary(false /* concise */));
|
setSummary(mWifiEntry.getSummary(false /* concise */));
|
||||||
@@ -201,14 +208,7 @@ public class WifiEntryPreference extends RestrictedPreference implements
|
|||||||
return accent ? android.R.attr.colorAccent : android.R.attr.colorControlNormal;
|
return accent ? android.R.attr.colorAccent : android.R.attr.colorControlNormal;
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
private void setIconWithTint(Drawable drawable) {
|
||||||
void updateIcon(boolean showX, int level) {
|
|
||||||
if (level == -1) {
|
|
||||||
setIcon(null);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final Drawable drawable = mIconInjector.getIcon(showX, level);
|
|
||||||
if (drawable != null) {
|
if (drawable != null) {
|
||||||
// Must use Drawable#setTintList() instead of Drawable#setTint() to show the grey
|
// Must use Drawable#setTintList() instead of Drawable#setTint() to show the grey
|
||||||
// icon when the preference is disabled.
|
// icon when the preference is disabled.
|
||||||
@@ -219,6 +219,20 @@ public class WifiEntryPreference extends RestrictedPreference implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
void updateIcon(boolean showX, int level) {
|
||||||
|
if (level == -1) {
|
||||||
|
setIcon(null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setIconWithTint(mIconInjector.getIcon(showX, level));
|
||||||
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
void updateHotspotIcon(int deviceType) {
|
||||||
|
setIconWithTint(getContext().getDrawable(getHotspotIconResource(deviceType)));
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private StateListDrawable getFrictionStateListDrawable() {
|
private StateListDrawable getFrictionStateListDrawable() {
|
||||||
TypedArray frictionSld;
|
TypedArray frictionSld;
|
||||||
|
|||||||
@@ -272,6 +272,20 @@ public class StylusDevicesControllerTest {
|
|||||||
NOTES_APP_LABEL.toString()));
|
NOTES_APP_LABEL.toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void defaultNotesPreference_noApplicationInfo_showsBlankSummary()
|
||||||
|
throws PackageManager.NameNotFoundException {
|
||||||
|
when(mPm.getApplicationInfo(eq(NOTES_PACKAGE_NAME),
|
||||||
|
any(PackageManager.ApplicationInfoFlags.class))).thenReturn(null);
|
||||||
|
|
||||||
|
showScreen(mController);
|
||||||
|
|
||||||
|
Preference defaultNotesPref = mPreferenceContainer.getPreference(0);
|
||||||
|
assertThat(defaultNotesPref.getTitle().toString()).isEqualTo(
|
||||||
|
mContext.getString(R.string.stylus_default_notes_app));
|
||||||
|
assertThat(defaultNotesPref.getSummary().toString()).isEqualTo("");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void defaultNotesPreference_roleHolderChanges_updatesPreference() {
|
public void defaultNotesPreference_roleHolderChanges_updatesPreference() {
|
||||||
showScreen(mController);
|
showScreen(mController);
|
||||||
|
|||||||
@@ -18,11 +18,15 @@ package com.android.settings.wifi;
|
|||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
|
import static org.mockito.ArgumentMatchers.anyInt;
|
||||||
|
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.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.net.wifi.sharedconnectivity.app.NetworkProviderInfo;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
@@ -31,6 +35,7 @@ import androidx.preference.PreferenceViewHolder;
|
|||||||
|
|
||||||
import com.android.settingslib.R;
|
import com.android.settingslib.R;
|
||||||
import com.android.settingslib.wifi.WifiUtils;
|
import com.android.settingslib.wifi.WifiUtils;
|
||||||
|
import com.android.wifitrackerlib.HotspotNetworkEntry;
|
||||||
import com.android.wifitrackerlib.WifiEntry;
|
import com.android.wifitrackerlib.WifiEntry;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
@@ -52,6 +57,8 @@ public class WifiEntryPreferenceTest {
|
|||||||
@Mock
|
@Mock
|
||||||
private WifiEntry mMockWifiEntry;
|
private WifiEntry mMockWifiEntry;
|
||||||
@Mock
|
@Mock
|
||||||
|
private HotspotNetworkEntry mHotspotNetworkEntry;
|
||||||
|
@Mock
|
||||||
private WifiUtils.InternetIconInjector mMockIconInjector;
|
private WifiUtils.InternetIconInjector mMockIconInjector;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
@@ -256,4 +263,26 @@ public class WifiEntryPreferenceTest {
|
|||||||
public void getSecondTargetResId_shouldNotReturnZero() {
|
public void getSecondTargetResId_shouldNotReturnZero() {
|
||||||
assertThat(mPref.getSecondTargetResId()).isNotEqualTo(0);
|
assertThat(mPref.getSecondTargetResId()).isNotEqualTo(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void refresh_itsHotspotNetworkEntry_shouldUpdateHotspotIcon() {
|
||||||
|
int deviceType = NetworkProviderInfo.DEVICE_TYPE_PHONE;
|
||||||
|
when(mHotspotNetworkEntry.getDeviceType()).thenReturn(deviceType);
|
||||||
|
WifiEntryPreference pref = spy(
|
||||||
|
new WifiEntryPreference(mContext, mHotspotNetworkEntry, mMockIconInjector));
|
||||||
|
|
||||||
|
pref.refresh();
|
||||||
|
|
||||||
|
verify(pref).updateHotspotIcon(deviceType);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void refresh_notHotspotNetworkEntry_shouldNotUpdateHotspotIcon() {
|
||||||
|
WifiEntryPreference pref = spy(
|
||||||
|
new WifiEntryPreference(mContext, mMockWifiEntry, mMockIconInjector));
|
||||||
|
|
||||||
|
pref.refresh();
|
||||||
|
|
||||||
|
verify(pref, never()).updateHotspotIcon(anyInt());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user