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

Commit 3d74bb4a authored by Dianne Hackborn's avatar Dianne Hackborn
Browse files

Add "why?" button to low battery dialog.

This takes the user to the power usage activity.
parent 03255de3
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -31851,6 +31851,17 @@
 visibility="public"
>
</field>
<field name="ACTION_POWER_USAGE_SUMMARY"
 type="java.lang.String"
 transient="false"
 volatile="false"
 value="&quot;android.intent.action.POWER_USAGE_SUMMARY&quot;"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="ACTION_PROVIDER_CHANGED"
 type="java.lang.String"
 transient="false"
+9 −0
Original line number Diff line number Diff line
@@ -1076,6 +1076,15 @@ public class Intent implements Parcelable {
     */
    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
    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).
+3 −0
Original line number Diff line number Diff line
@@ -1302,6 +1302,9 @@
    <string name="battery_low_percent_format">less than <xliff:g id="number">%d%%</xliff:g>
    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. -->
    <string name="factorytest_failed">Factory test failed</string>
+17 −0
Original line number Diff line number Diff line
@@ -729,6 +729,23 @@ public class StatusBarPolicy {
                b.setIcon(android.R.drawable.ic_dialog_alert);
                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();
            d.setOnDismissListener(mLowBatteryListener);
            d.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);