Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dbc5db63 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 7017347 from 2a1c2a7a to rvc-qpr2-release

Change-Id: I94dec9ed0f3b4c529d03db23519301bd194b1930
parents 0e2b7ea3 2a1c2a7a
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.settingslib.fuelgauge;

import static android.os.BatteryManager.BATTERY_HEALTH_OVERHEAT;
import static android.os.BatteryManager.BATTERY_HEALTH_UNKNOWN;
import static android.os.BatteryManager.BATTERY_STATUS_FULL;
import static android.os.BatteryManager.BATTERY_STATUS_UNKNOWN;
@@ -123,6 +124,15 @@ public class BatteryStatus {
        return level < LOW_BATTERY_THRESHOLD;
    }

    /**
     * Whether battery is overheated.
     *
     * @return true if battery is overheated
     */
    public boolean isOverheated() {
        return health == BATTERY_HEALTH_OVERHEAT;
    }

    /**
     * Return current chargin speed is fast, slow or normal.
     *
+5 −5
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.settingslib.media;
import android.bluetooth.BluetoothClass;
import android.bluetooth.BluetoothDevice;
import android.content.Context;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.media.MediaRoute2Info;
import android.media.MediaRouter2Manager;
@@ -56,8 +57,9 @@ public class BluetoothMediaDevice extends MediaDevice {

    @Override
    public Drawable getIcon() {
        final Drawable drawable = getIconWithoutBackground();
        if (!isFastPairDevice()) {
        final Drawable drawable =
                BluetoothUtils.getBtDrawableWithDescription(mContext, mCachedDevice).first;
        if (!(drawable instanceof BitmapDrawable)) {
            setColorFilter(drawable);
        }
        return BluetoothUtils.buildAdvancedDrawable(mContext, drawable);
@@ -65,9 +67,7 @@ public class BluetoothMediaDevice extends MediaDevice {

    @Override
    public Drawable getIconWithoutBackground() {
        return isFastPairDevice()
                ? BluetoothUtils.getBtDrawableWithDescription(mContext, mCachedDevice).first
                : mContext.getDrawable(R.drawable.ic_headphone);
        return BluetoothUtils.getBtClassDrawableWithDescription(mContext, mCachedDevice).first;
    }

    @Override
+14 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import static org.mockito.Mockito.when;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothProfile;
import android.content.Context;
import android.graphics.drawable.BitmapDrawable;

import com.android.settingslib.bluetooth.CachedBluetoothDevice;

@@ -96,4 +97,17 @@ public class BluetoothMediaDeviceTest {

        assertThat(mBluetoothMediaDevice.isFastPairDevice()).isFalse();
    }

    @Test
    public void getIcon_isNotFastPairDevice_drawableTypeIsNotBitmapDrawable() {
        final BluetoothDevice bluetoothDevice = mock(BluetoothDevice.class);
        when(mDevice.getDevice()).thenReturn(bluetoothDevice);

        final String value = "False";
        final byte[] bytes = value.getBytes();
        when(bluetoothDevice.getMetadata(BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET))
                .thenReturn(bytes);

        assertThat(mBluetoothMediaDevice.getIcon() instanceof BitmapDrawable).isFalse();
    }
}
+5 −0
Original line number Diff line number Diff line
@@ -2579,6 +2579,11 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
            return true;
        }

        // change in battery overheat
        if (current.health != old.health) {
            return true;
        }

        return false;
    }

+15 −6
Original line number Diff line number Diff line
@@ -118,6 +118,8 @@ public class KeyguardIndicationController implements StateListener,
    private boolean mPowerPluggedIn;
    private boolean mPowerPluggedInWired;
    private boolean mPowerCharged;
    private boolean mBatteryOverheated;
    private boolean mEnableBatteryDefender;
    private int mChargingSpeed;
    private int mChargingWattage;
    private int mBatteryLevel;
@@ -401,7 +403,7 @@ public class KeyguardIndicationController implements StateListener,
                } else if (!TextUtils.isEmpty(mAlignmentIndication)) {
                    mTextView.switchIndication(mAlignmentIndication);
                    mTextView.setTextColor(mContext.getColor(R.color.misalignment_text_color));
                } else if (mPowerPluggedIn) {
                } else if (mPowerPluggedIn || mEnableBatteryDefender) {
                    String indication = computePowerIndication();
                    if (animate) {
                        animateText(mTextView, indication);
@@ -421,7 +423,7 @@ public class KeyguardIndicationController implements StateListener,
            String trustManagedIndication = getTrustManagedIndication();

            String powerIndication = null;
            if (mPowerPluggedIn) {
            if (mPowerPluggedIn || mEnableBatteryDefender) {
                powerIndication = computePowerIndication();
            }

@@ -451,7 +453,7 @@ public class KeyguardIndicationController implements StateListener,
            } else if (!TextUtils.isEmpty(mAlignmentIndication)) {
                mTextView.switchIndication(mAlignmentIndication);
                isError = true;
            } else if (mPowerPluggedIn) {
            } else if (mPowerPluggedIn || mEnableBatteryDefender) {
                if (DEBUG_CHARGING_SPEED) {
                    powerIndication += ",  " + (mChargingWattage / 1000) + " mW";
                }
@@ -528,8 +530,15 @@ public class KeyguardIndicationController implements StateListener,
            return mContext.getResources().getString(R.string.keyguard_charged);
        }

        final boolean hasChargingTime = mChargingTimeRemaining > 0;
        int chargingId;
        String percentage = NumberFormat.getPercentInstance().format(mBatteryLevel / 100f);

        if (mBatteryOverheated) {
            chargingId = R.string.keyguard_plugged_in_charging_limited;
            return mContext.getResources().getString(chargingId, percentage);
        }

        final boolean hasChargingTime = mChargingTimeRemaining > 0;
        if (mPowerPluggedInWired) {
            switch (mChargingSpeed) {
                case BatteryStatus.CHARGING_FAST:
@@ -554,8 +563,6 @@ public class KeyguardIndicationController implements StateListener,
                    : R.string.keyguard_plugged_in_wireless;
        }

        String percentage = NumberFormat.getPercentInstance()
                .format(mBatteryLevel / 100f);
        if (hasChargingTime) {
            // We now have battery percentage in these strings and it's expected that all
            // locales will also have it in the future. For now, we still have to support the old
@@ -685,6 +692,8 @@ public class KeyguardIndicationController implements StateListener,
            mChargingWattage = status.maxChargingWattage;
            mChargingSpeed = status.getChargingSpeed(mContext);
            mBatteryLevel = status.level;
            mBatteryOverheated = status.isOverheated();
            mEnableBatteryDefender = mBatteryOverheated && status.isPluggedIn();
            try {
                mChargingTimeRemaining = mPowerPluggedIn
                        ? mBatteryInfo.computeChargeTimeRemaining() : -1;
Loading