diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index 310701e..e0aedd8 100755
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -5397,5 +5397,10 @@
<!-- ChooserActivity - Alphabetically sorted apps list label. [CHAR LIMIT=NONE] -->
<string name="chooser_all_apps_button_label">Apps list</string>
-
+ <!--add by jzhen for [ID1004437]add battery temp warning dialog-->
+ <string name="warningLowBatteryTemperature">"Battery temperature is too low, in order to protect battery life, please wait until the battery temperature is normal before using."</string>
+ <string name="warningHightBatteryTemperature">"Battery temperature is too high, in order to protect battery life, please wait until the battery temperature is normal before using."</string>
+ <string name="shutdownBatteryTemperatureMsg">"Battery temperature is too high. For safety reasons, the phone will shut down automatically later."</string>
+ <string name="batteryTemperatureWarning">Warning</string>
+ <string name="batteryTemperatureOk">"OK"</string>
</resources>
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index ad65be9..f8b3d56 100755
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -2071,6 +2071,14 @@
<java-symbol type="integer" name="config_screenBrightnessDoze" />
<java-symbol type="integer" name="config_autoBrightnessShortTermModelTimeout" />
<java-symbol type="integer" name="config_shutdownBatteryTemperature" />
+ <!--add by jzhen for [ID1004437]add battery temp warning dialog-->
+ <java-symbol type="integer" name="config_warningHightBatteryTemperature" />
+ <java-symbol type="integer" name="config_warningLowBatteryTemperature" />
+ <java-symbol type="string" name="warningLowBatteryTemperature" />
+ <java-symbol type="string" name="warningHightBatteryTemperature" />
+ <java-symbol type="string" name="shutdownBatteryTemperatureMsg" />
+ <java-symbol type="string" name="batteryTemperatureWarning" />
+ <java-symbol type="string" name="batteryTemperatureOk" />
<java-symbol type="integer" name="config_undockedHdmiRotation" />
<java-symbol type="integer" name="config_virtualKeyQuietTimeMillis" />
<java-symbol type="integer" name="config_brightness_ramp_rate_fast" />
diff --git a/services/core/java/com/android/server/BatteryService.java b/services/core/java/com/android/server/BatteryService.java
index eda6124..c35d011 100644
--- a/services/core/java/com/android/server/BatteryService.java
+++ b/services/core/java/com/android/server/BatteryService.java
@@ -81,6 +81,10 @@ import java.util.List;
import java.util.NoSuchElementException;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicReference;
+//add by jzhen [ID1004437]add battery temp warning
+import android.app.AlertDialog;
+import android.view.WindowManager;
+import android.content.DialogInterface;
/**
* <p>BatteryService monitors the charging status, and charge level of the device
@@ -191,6 +195,13 @@ public final class BatteryService extends SystemService {
private long mLastBatteryLevelChangedSentMs;
private MetricsLogger mMetricsLogger;
+ //add by jzhen [ID1004437]add battery temp warning
+ private int mConfigWarningLowBatteryTemperature;
+ private int mConfigWarningHightBatteryTemperature;
+ private String mWarningLowBatteryTemperature;
+ private String mWarningHightBatteryTemperature;
+ private String mShutdownBatteryTemperatureMsg;
+ private AlertDialog mbatteryTemperatureDialog = null;
public BatteryService(Context context) {
super(context);
@@ -200,7 +211,17 @@ public final class BatteryService extends SystemService {
mLed = new Led(context, getLocalService(LightsManager.class));
mBatteryStats = BatteryStatsService.getService();
mActivityManagerInternal = LocalServices.getService(ActivityManagerInternal.class);
-
+ //add by jzhen [ID1004437]add battery temp warning
+ mConfigWarningLowBatteryTemperature= mContext.getResources().getInteger(
+ com.android.internal.R.integer.config_warningLowBatteryTemperature);
+ mConfigWarningHightBatteryTemperature= mContext.getResources().getInteger(
+ com.android.internal.R.integer.config_warningHightBatteryTemperature);
+ mWarningHightBatteryTemperature = mContext.getResources().getString(
+ com.android.internal.R.string.warningHightBatteryTemperature);
+ mShutdownBatteryTemperatureMsg = mContext.getResources().getString(
+ com.android.internal.R.string.shutdownBatteryTemperatureMsg);
+ mWarningLowBatteryTemperature = mContext.getResources().getString(
+ com.android.internal.R.string.warningLowBatteryTemperature);
mCriticalBatteryLevel = mContext.getResources().getInteger(
com.android.internal.R.integer.config_criticalBatteryWarningLevel);
mLowBatteryWarningLevel = mContext.getResources().getInteger(
@@ -415,7 +436,52 @@ public final class BatteryService extends SystemService {
});
}
}
+ //add by jzhen for[ID1004437] add battery temp warning begin
+ private void warningBatteryTemperature(){
+ if(mHealthInfo!=null && mbatteryTemperatureDialog == null){
+ if (mHealthInfo.batteryTemperature >= mConfigWarningHightBatteryTemperature) {
+ mHandler.post(new Runnable() {
+ public void run() {
+ if(mHealthInfo.batteryTemperature >= (mShutdownBatteryTemperature-10)){
+ batteryTemperatureDialog(mShutdownBatteryTemperatureMsg);
+ }else{
+ batteryTemperatureDialog(mWarningHightBatteryTemperature);
+ }
+ }
+ });
+ }
+ if (mHealthInfo.batteryTemperature < mConfigWarningLowBatteryTemperature) {
+ mHandler.post(new Runnable() {
+ public void run() {
+ batteryTemperatureDialog(mWarningLowBatteryTemperature);
+ }
+ });
+ }
+ }
+ }
+ private void batteryTemperatureDialog(String batteryTemperature) {
+ AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
+ builder.setTitle(mContext.getResources().getString(
+ com.android.internal.R.string.batteryTemperatureWarning));
+ builder.setCancelable(false);
+ builder.setMessage(batteryTemperature);
+ builder.setIconAttribute(android.R.attr.alertDialogIcon);
+ builder.setPositiveButton(com.android.internal.R.string.batteryTemperatureOk,
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int id) {
+ dialog.cancel();
+ mbatteryTemperatureDialog = null;
+ }
+ });
+ mbatteryTemperatureDialog = builder.create();
+ mbatteryTemperatureDialog.getWindow().setType(
+ WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY);
+ if (mbatteryTemperatureDialog != null&& !mbatteryTemperatureDialog.isShowing()) {
+ mbatteryTemperatureDialog.show();
+ }
+ }
+ //add by jzhen for[ID1004437] add battery temp warning end
private void update(android.hardware.health.V2_0.HealthInfo info) {
traceBegin("HealthInfoUpdate");
@@ -492,7 +558,8 @@ public final class BatteryService extends SystemService {
shutdownIfNoPowerLocked();
shutdownIfOverTempLocked();
-
+ //add by jzhen [ID1004437]add battery temp warning
+ warningBatteryTemperature();
if (force || (mHealthInfo.batteryStatus != mLastBatteryStatus ||
mHealthInfo.batteryHealth != mLastBatteryHealth ||
mHealthInfo.batteryPresent != mLastBatteryPresent ||
高通添加电池高温低温提醒
最新推荐文章于 2024-05-12 13:30:58 发布