Add "why?" button to low battery dialog.
This takes the user to the power usage activity.
This commit is contained in:
@@ -31851,6 +31851,17 @@
|
|||||||
visibility="public"
|
visibility="public"
|
||||||
>
|
>
|
||||||
</field>
|
</field>
|
||||||
|
<field name="ACTION_POWER_USAGE_SUMMARY"
|
||||||
|
type="java.lang.String"
|
||||||
|
transient="false"
|
||||||
|
volatile="false"
|
||||||
|
value=""android.intent.action.POWER_USAGE_SUMMARY""
|
||||||
|
static="true"
|
||||||
|
final="true"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
</field>
|
||||||
<field name="ACTION_PROVIDER_CHANGED"
|
<field name="ACTION_PROVIDER_CHANGED"
|
||||||
type="java.lang.String"
|
type="java.lang.String"
|
||||||
transient="false"
|
transient="false"
|
||||||
|
|||||||
@@ -1076,6 +1076,15 @@ public class Intent implements Parcelable {
|
|||||||
*/
|
*/
|
||||||
@SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
|
@SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
|
||||||
public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR";
|
public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Activity Action: Show power usage information to the user.
|
||||||
|
* <p>Input: Nothing.
|
||||||
|
* <p>Output: Nothing.
|
||||||
|
*/
|
||||||
|
@SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
|
||||||
|
public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY";
|
||||||
|
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
// Standard intent broadcast actions (see action variable).
|
// Standard intent broadcast actions (see action variable).
|
||||||
|
|||||||
@@ -1302,6 +1302,9 @@
|
|||||||
<string name="battery_low_percent_format">less than <xliff:g id="number">%d%%</xliff:g>
|
<string name="battery_low_percent_format">less than <xliff:g id="number">%d%%</xliff:g>
|
||||||
remaining.</string>
|
remaining.</string>
|
||||||
|
|
||||||
|
<!-- When the battery is low, this is the label of the button to go to the
|
||||||
|
power usage activity to find out what drained the battery. -->
|
||||||
|
<string name="battery_low_why">Why?</string>
|
||||||
|
|
||||||
<!-- Title of the alert when something went wrong in the factory test. -->
|
<!-- Title of the alert when something went wrong in the factory test. -->
|
||||||
<string name="factorytest_failed">Factory test failed</string>
|
<string name="factorytest_failed">Factory test failed</string>
|
||||||
|
|||||||
@@ -729,6 +729,23 @@ public class StatusBarPolicy {
|
|||||||
b.setIcon(android.R.drawable.ic_dialog_alert);
|
b.setIcon(android.R.drawable.ic_dialog_alert);
|
||||||
b.setPositiveButton(android.R.string.ok, null);
|
b.setPositiveButton(android.R.string.ok, null);
|
||||||
|
|
||||||
|
final Intent intent = new Intent(Intent.ACTION_POWER_USAGE_SUMMARY);
|
||||||
|
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
|
||||||
|
| Intent.FLAG_ACTIVITY_MULTIPLE_TASK
|
||||||
|
| Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
|
||||||
|
| Intent.FLAG_ACTIVITY_NO_HISTORY);
|
||||||
|
if (intent.resolveActivity(mContext.getPackageManager()) != null) {
|
||||||
|
b.setNegativeButton(com.android.internal.R.string.battery_low_why,
|
||||||
|
new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
mContext.startActivity(intent);
|
||||||
|
if (mLowBatteryDialog != null) {
|
||||||
|
mLowBatteryDialog.dismiss();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
AlertDialog d = b.create();
|
AlertDialog d = b.create();
|
||||||
d.setOnDismissListener(mLowBatteryListener);
|
d.setOnDismissListener(mLowBatteryListener);
|
||||||
d.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
|
d.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
|
||||||
|
|||||||
Reference in New Issue
Block a user