AOD: Show charging status on AOD1
- Change PowerManager to not turn on display when on AOD - Add charging icon to AOD1 - Add transient charging indication when plugged in Bug: 30876804 Bug: 35850304 Test: runtest systemui; enable AOD, plug in phone, verify charging indicator shows, verify charging text shows and goes away after a few seconds Change-Id: Icb80843a12c56c7e2abeca78115a366b4d508d4f
This commit is contained in:
@@ -28,25 +28,42 @@
|
||||
androidprv:layout_maxWidth="@dimen/keyguard_security_width"
|
||||
androidprv:layout_maxHeight="@dimen/keyguard_security_height"
|
||||
android:gravity="center_horizontal|top">
|
||||
<LinearLayout
|
||||
<RelativeLayout
|
||||
android:id="@+id/keyguard_clock_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal|top"
|
||||
android:orientation="vertical" >
|
||||
android:layout_gravity="center_horizontal|top">
|
||||
<TextClock
|
||||
android:id="@+id/clock_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:textColor="@color/clock_white"
|
||||
android:singleLine="true"
|
||||
style="@style/widget_big_thin"
|
||||
android:format12Hour="@string/keyguard_widget_12_hours_format"
|
||||
android:format24Hour="@string/keyguard_widget_24_hours_format"
|
||||
android:layout_marginBottom="@dimen/bottom_text_spacing_digital" />
|
||||
<com.android.systemui.ChargingView
|
||||
android:id="@+id/battery_doze"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignTop="@id/clock_view"
|
||||
android:layout_alignBottom="@id/clock_view"
|
||||
android:layout_toEndOf="@id/clock_view"
|
||||
android:visibility="invisible"
|
||||
android:src="@drawable/ic_aod_charging_24dp"
|
||||
android:contentDescription="@string/accessibility_ambient_display_charging"
|
||||
/>
|
||||
|
||||
<include layout="@layout/keyguard_status_area"
|
||||
android:id="@+id/keyguard_status_area"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/clock_view" />
|
||||
|
||||
<include layout="@layout/keyguard_status_area" />
|
||||
<TextView
|
||||
android:id="@+id/owner_info"
|
||||
android:layout_marginLeft="16dp"
|
||||
@@ -54,12 +71,13 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/date_owner_info_margin"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_below="@id/keyguard_status_area"
|
||||
android:textColor="@color/clock_gray"
|
||||
android:textSize="@dimen/widget_label_font_size"
|
||||
android:letterSpacing="0.05"
|
||||
android:ellipsize="marquee"
|
||||
android:singleLine="true" />
|
||||
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
||||
</com.android.keyguard.KeyguardStatusView>
|
||||
|
||||
24
packages/SystemUI/res/drawable/ic_aod_charging_24dp.xml
Normal file
24
packages/SystemUI/res/drawable/ic_aod_charging_24dp.xml
Normal file
@@ -0,0 +1,24 @@
|
||||
<!--
|
||||
Copyright (C) 2014 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.
|
||||
-->
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24.0dp"
|
||||
android:height="24.0dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:pathData="M11.0,22.98l0.0,-8.98 -4.0,0.0 6.0,-13.0 0.0,9.0 4.0,0.0z"
|
||||
android:fillColor="#ffffff"/>
|
||||
</vector>
|
||||
@@ -565,6 +565,9 @@
|
||||
<!-- Content description of the display brightness slider (not shown on the screen). [CHAR LIMIT=NONE] -->
|
||||
<string name="accessibility_brightness">Display brightness</string>
|
||||
|
||||
<!-- Content description of the charging indicator on Ambient Display (lower-power version of the lock screen). [CHAR LIMIT=NONE] -->
|
||||
<string name="accessibility_ambient_display_charging">Charging</string>
|
||||
|
||||
<!-- Title of dialog shown when 2G-3G data usage has exceeded limit and has been disabled. [CHAR LIMIT=48] -->
|
||||
<string name="data_usage_disabled_dialog_3g_title">2G-3G data is paused</string>
|
||||
<!-- Title of dialog shown when 4G data usage has exceeded limit and has been disabled. [CHAR LIMIT=48] -->
|
||||
|
||||
@@ -35,6 +35,7 @@ import android.widget.TextClock;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.android.internal.widget.LockPatternUtils;
|
||||
import com.android.systemui.ChargingView;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
@@ -50,6 +51,7 @@ public class KeyguardStatusView extends GridLayout {
|
||||
private TextClock mClockView;
|
||||
private TextView mOwnerInfo;
|
||||
private ViewGroup mClockContainer;
|
||||
private ChargingView mBatteryDoze;
|
||||
|
||||
private KeyguardUpdateMonitorCallback mInfoCallback = new KeyguardUpdateMonitorCallback() {
|
||||
|
||||
@@ -114,6 +116,7 @@ public class KeyguardStatusView extends GridLayout {
|
||||
mDateView.setShowCurrentUserTime(true);
|
||||
mClockView.setShowCurrentUserTime(true);
|
||||
mOwnerInfo = (TextView) findViewById(R.id.owner_info);
|
||||
mBatteryDoze = (ChargingView) findViewById(R.id.battery_doze);
|
||||
|
||||
boolean shouldMarquee = KeyguardUpdateMonitor.getInstance(mContext).isDeviceInteractive();
|
||||
setEnableMarquee(shouldMarquee);
|
||||
@@ -273,10 +276,11 @@ public class KeyguardStatusView extends GridLayout {
|
||||
final int N = mClockContainer.getChildCount();
|
||||
for (int i = 0; i < N; i++) {
|
||||
View child = mClockContainer.getChildAt(i);
|
||||
if (child == mClockView) {
|
||||
if (child == mClockView || child == mBatteryDoze) {
|
||||
continue;
|
||||
}
|
||||
child.setAlpha(dark ? 0 : 1);
|
||||
}
|
||||
mBatteryDoze.setDark(dark);
|
||||
}
|
||||
}
|
||||
|
||||
91
packages/SystemUI/src/com/android/systemui/ChargingView.java
Normal file
91
packages/SystemUI/src/com/android/systemui/ChargingView.java
Normal file
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* Copyright (C) 2017 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.systemui;
|
||||
|
||||
import android.annotation.Nullable;
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.android.systemui.statusbar.policy.BatteryController;
|
||||
import com.android.systemui.statusbar.policy.ConfigurationController;
|
||||
|
||||
/**
|
||||
* A view that only shows its drawable while the phone is charging.
|
||||
*
|
||||
* Also reloads its drawable upon density changes.
|
||||
*/
|
||||
public class ChargingView extends ImageView implements
|
||||
BatteryController.BatteryStateChangeCallback,
|
||||
ConfigurationController.ConfigurationListener {
|
||||
|
||||
private BatteryController mBatteryController;
|
||||
private int mImageResource;
|
||||
private boolean mCharging;
|
||||
private boolean mDark;
|
||||
|
||||
public ChargingView(Context context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
|
||||
TypedArray a = context.obtainStyledAttributes(attrs, new int[]{android.R.attr.src});
|
||||
int srcResId = a.getResourceId(0, 0);
|
||||
|
||||
if (srcResId != 0) {
|
||||
mImageResource = srcResId;
|
||||
}
|
||||
|
||||
a.recycle();
|
||||
|
||||
updateVisibility();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
mBatteryController = Dependency.get(BatteryController.class);
|
||||
mBatteryController.addCallback(this);
|
||||
Dependency.get(ConfigurationController.class).addCallback(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
mBatteryController.removeCallback(this);
|
||||
Dependency.get(ConfigurationController.class).removeCallback(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBatteryLevelChanged(int level, boolean pluggedIn, boolean charging) {
|
||||
mCharging = charging;
|
||||
updateVisibility();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDensityOrFontScaleChanged() {
|
||||
setImageResource(mImageResource);
|
||||
}
|
||||
|
||||
public void setDark(boolean dark) {
|
||||
mDark = dark;
|
||||
updateVisibility();
|
||||
}
|
||||
|
||||
private void updateVisibility() {
|
||||
setVisibility(mCharging && mDark ? VISIBLE : INVISIBLE);
|
||||
}
|
||||
}
|
||||
@@ -340,17 +340,23 @@ public class KeyguardIndicationController {
|
||||
}
|
||||
|
||||
protected class BaseKeyguardCallback extends KeyguardUpdateMonitorCallback {
|
||||
public static final int HIDE_DELAY_MS = 5000;
|
||||
private int mLastSuccessiveErrorMessage = -1;
|
||||
|
||||
@Override
|
||||
public void onRefreshBatteryInfo(KeyguardUpdateMonitor.BatteryStatus status) {
|
||||
boolean isChargingOrFull = status.status == BatteryManager.BATTERY_STATUS_CHARGING
|
||||
|| status.status == BatteryManager.BATTERY_STATUS_FULL;
|
||||
boolean wasPluggedIn = mPowerPluggedIn;
|
||||
mPowerPluggedIn = status.isPluggedIn() && isChargingOrFull;
|
||||
mPowerCharged = status.isCharged();
|
||||
mChargingWattage = status.maxChargingWattage;
|
||||
mChargingSpeed = status.getChargingSpeed(mSlowThreshold, mFastThreshold);
|
||||
updateIndication();
|
||||
if (!wasPluggedIn && mPowerPluggedIn && mDozing) {
|
||||
showTransientIndication(computePowerIndication());
|
||||
hideTransientIndicationDelayed(HIDE_DELAY_MS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -402,7 +408,7 @@ public class KeyguardIndicationController {
|
||||
showTransientIndication(errString, errorColor);
|
||||
// We want to keep this message around in case the screen was off
|
||||
mHandler.removeMessages(MSG_HIDE_TRANSIENT);
|
||||
hideTransientIndicationDelayed(5000);
|
||||
hideTransientIndicationDelayed(HIDE_DELAY_MS);
|
||||
} else {
|
||||
mMessageToShowOnScreenOn = errString;
|
||||
}
|
||||
@@ -416,7 +422,7 @@ public class KeyguardIndicationController {
|
||||
showTransientIndication(mMessageToShowOnScreenOn, errorColor);
|
||||
// We want to keep this message around in case the screen was off
|
||||
mHandler.removeMessages(MSG_HIDE_TRANSIENT);
|
||||
hideTransientIndicationDelayed(5000);
|
||||
hideTransientIndicationDelayed(HIDE_DELAY_MS);
|
||||
mMessageToShowOnScreenOn = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ public interface BatteryController extends DemoMode, Dumpable,
|
||||
* has occurred.
|
||||
*/
|
||||
interface BatteryStateChangeCallback {
|
||||
void onBatteryLevelChanged(int level, boolean pluggedIn, boolean charging);
|
||||
void onPowerSaveChanged(boolean isPowerSave);
|
||||
default void onBatteryLevelChanged(int level, boolean pluggedIn, boolean charging) {}
|
||||
default void onPowerSaveChanged(boolean isPowerSave) {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,6 +72,7 @@ import android.view.WindowManagerPolicy;
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.internal.app.IAppOpsService;
|
||||
import com.android.internal.app.IBatteryStats;
|
||||
import com.android.internal.hardware.AmbientDisplayConfiguration;
|
||||
import com.android.internal.os.BackgroundThread;
|
||||
import com.android.internal.util.ArrayUtils;
|
||||
import com.android.server.EventLogTags;
|
||||
@@ -194,6 +195,7 @@ public final class PowerManagerService extends SystemService
|
||||
private final Context mContext;
|
||||
private final ServiceThread mHandlerThread;
|
||||
private final PowerManagerHandler mHandler;
|
||||
private final AmbientDisplayConfiguration mAmbientDisplayConfiguration;
|
||||
private final BatterySaverPolicy mBatterySaverPolicy;
|
||||
|
||||
private LightsManager mLightsManager;
|
||||
@@ -516,6 +518,9 @@ public final class PowerManagerService extends SystemService
|
||||
// True if theater mode is enabled
|
||||
private boolean mTheaterModeEnabled;
|
||||
|
||||
// True if always on display is enabled
|
||||
private boolean mAlwaysOnEnabled;
|
||||
|
||||
// True if double tap to wake is enabled
|
||||
private boolean mDoubleTapWakeEnabled;
|
||||
|
||||
@@ -608,6 +613,7 @@ public final class PowerManagerService extends SystemService
|
||||
mHandlerThread.start();
|
||||
mHandler = new PowerManagerHandler(mHandlerThread.getLooper());
|
||||
mConstants = new Constants(mHandler);
|
||||
mAmbientDisplayConfiguration = new AmbientDisplayConfiguration(mContext);
|
||||
mBatterySaverPolicy = new BatterySaverPolicy(mHandler);
|
||||
|
||||
synchronized (mLock) {
|
||||
@@ -640,6 +646,7 @@ public final class PowerManagerService extends SystemService
|
||||
mHandlerThread.start();
|
||||
mHandler = new PowerManagerHandler(mHandlerThread.getLooper());
|
||||
mConstants = new Constants(mHandler);
|
||||
mAmbientDisplayConfiguration = new AmbientDisplayConfiguration(mContext);
|
||||
mDisplaySuspendBlocker = null;
|
||||
mWakeLockSuspendBlocker = null;
|
||||
}
|
||||
@@ -765,6 +772,9 @@ public final class PowerManagerService extends SystemService
|
||||
resolver.registerContentObserver(Settings.Global.getUriFor(
|
||||
Settings.Global.THEATER_MODE_ON),
|
||||
false, mSettingsObserver, UserHandle.USER_ALL);
|
||||
resolver.registerContentObserver(Settings.Secure.getUriFor(
|
||||
Settings.Secure.DOZE_ALWAYS_ON),
|
||||
false, mSettingsObserver, UserHandle.USER_ALL);
|
||||
resolver.registerContentObserver(Settings.Secure.getUriFor(
|
||||
Settings.Secure.DOUBLE_TAP_TO_WAKE),
|
||||
false, mSettingsObserver, UserHandle.USER_ALL);
|
||||
@@ -863,6 +873,7 @@ public final class PowerManagerService extends SystemService
|
||||
Settings.Global.STAY_ON_WHILE_PLUGGED_IN, BatteryManager.BATTERY_PLUGGED_AC);
|
||||
mTheaterModeEnabled = Settings.Global.getInt(mContext.getContentResolver(),
|
||||
Settings.Global.THEATER_MODE_ON, 0) == 1;
|
||||
mAlwaysOnEnabled = mAmbientDisplayConfiguration.alwaysOnEnabled(UserHandle.USER_CURRENT);
|
||||
|
||||
if (mSupportsDoubleTapWakeConfig) {
|
||||
boolean doubleTapWakeEnabled = Settings.Secure.getIntForUser(resolver,
|
||||
@@ -1702,6 +1713,11 @@ public final class PowerManagerService extends SystemService
|
||||
return false;
|
||||
}
|
||||
|
||||
// On Always On Display, SystemUI shows the charging indicator
|
||||
if (mAlwaysOnEnabled && mWakefulness == WAKEFULNESS_DOZING) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Otherwise wake up!
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user