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

Commit e69335f8 authored by Android (Google) Code Review's avatar Android (Google) Code Review
Browse files

Merge change 25931 into eclair

* changes:
  Add better APIs for the battery status, and other cleanup.
parents a382cb81 edd9316c
Loading
Loading
Loading
Loading
+110 −11
Original line number Diff line number Diff line
@@ -35829,17 +35829,6 @@
 visibility="public"
>
</field>
<field name="ACTION_REMOTE_INTENT"
 type="java.lang.String"
 transient="false"
 volatile="false"
 value="&quot;android.intent.action.REMOTE_INTENT&quot;"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="ACTION_RUN"
 type="java.lang.String"
 transient="false"
@@ -98763,6 +98752,116 @@
 visibility="public"
>
</field>
<field name="EXTRA_HEALTH"
 type="java.lang.String"
 transient="false"
 volatile="false"
 value="&quot;health&quot;"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="EXTRA_ICON_SMALL"
 type="java.lang.String"
 transient="false"
 volatile="false"
 value="&quot;icon-small&quot;"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="EXTRA_LEVEL"
 type="java.lang.String"
 transient="false"
 volatile="false"
 value="&quot;level&quot;"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="EXTRA_PLUGGED"
 type="java.lang.String"
 transient="false"
 volatile="false"
 value="&quot;plugged&quot;"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="EXTRA_PRESENT"
 type="java.lang.String"
 transient="false"
 volatile="false"
 value="&quot;present&quot;"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="EXTRA_SCALE"
 type="java.lang.String"
 transient="false"
 volatile="false"
 value="&quot;scale&quot;"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="EXTRA_STATUS"
 type="java.lang.String"
 transient="false"
 volatile="false"
 value="&quot;status&quot;"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="EXTRA_TECHNOLOGY"
 type="java.lang.String"
 transient="false"
 volatile="false"
 value="&quot;technology&quot;"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="EXTRA_TEMPERATURE"
 type="java.lang.String"
 transient="false"
 volatile="false"
 value="&quot;temperature&quot;"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="EXTRA_VOLTAGE"
 type="java.lang.String"
 transient="false"
 volatile="false"
 value="&quot;voltage&quot;"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
</class>
<class name="Binder"
 extends="java.lang.Object"
+24 −14
Original line number Diff line number Diff line
@@ -1352,14 +1352,20 @@ public class Intent implements Parcelable {
    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
    public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
    /**
     * Broadcast Action:  The charging state, or charge level of the battery has
     * changed.
     * Broadcast Action:  This is a <em>sticky broadcast</em> containing the
     * charging state, level, and other information about the battery.
     * See {@link android.os.BatteryManager} for documentation on the
     * contents of the Intent.
     *
     * <p class="note">
     * You can <em>not</em> receive this through components declared
     * in manifests, only by explicitly registering for it with
     * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
     * Context.registerReceiver()}.
     * Context.registerReceiver()}.  See {@link #ACTION_BATTERY_LOW},
     * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
     * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
     * broadcasts that are sent and can be received through manifest
     * receivers.
     * 
     * <p class="note">This is a protected intent that can only be sent
     * by the system.
@@ -1434,7 +1440,8 @@ public class Intent implements Parcelable {
     */
    public static final String ACTION_REQUEST_SHUTDOWN = "android.intent.action.ACTION_REQUEST_SHUTDOWN";
    /**
     * Broadcast Action:  Indicates low memory condition on the device
     * Broadcast Action:  A sticky broadcast that indicates low memory
     * condition on the device
     * 
     * <p class="note">This is a protected intent that can only be sent
     * by the system.
@@ -1710,6 +1717,18 @@ public class Intent implements Parcelable {
    public static final String ACTION_REBOOT =
            "android.intent.action.REBOOT";

    /**
     * Broadcast Action:  A sticky broadcast indicating the phone was docked
     * or undocked.  Includes the extra
     * field {@link #EXTRA_DOCK_STATE}, containing the current dock state.
     * This is intended for monitoring the current dock state.
     * To launch an activity from a dock state change, use {@link #CATEGORY_CAR_DOCK}
     * or {@link #CATEGORY_DESK_DOCK} instead.
     */
    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
    public static final String ACTION_DOCK_EVENT =
            "android.intent.action.DOCK_EVENT";

    /**
     * Broadcast Action: a remote intent is to be broadcasted.
     *
@@ -1720,6 +1739,7 @@ public class Intent implements Parcelable {
     * does not trust intent broadcasts from arbitrary intent senders, it should require
     * the sender to hold certain permissions so only trusted sender's broadcast will be
     * let through.
     * @hide
     */
    public static final String ACTION_REMOTE_INTENT =
            "android.intent.action.REMOTE_INTENT";
@@ -1878,16 +1898,6 @@ public class Intent implements Parcelable {
    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
    public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";

    /**
     * Broadcast Action:  The phone was docked or undocked.  Includes the extra
     * field {@link #EXTRA_DOCK_STATE}, containing the current dock state.
     * This is intended for monitoring the current dock state.
     * To launch an activity from a dock state change, use {@link #CATEGORY_CAR_DOCK}
     * or {@link #CATEGORY_DESK_DOCK} instead.
     */
    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
    public static final String ACTION_DOCK_EVENT = "android.intent.action.DOCK_EVENT";

    // ---------------------------------------------------------------------
    // ---------------------------------------------------------------------
    // Standard extra data keys.
+65 −2
Original line number Diff line number Diff line
@@ -18,9 +18,72 @@ package android.os;

/**
 * The BatteryManager class contains strings and constants used for values
 * in the ACTION_BATTERY_CHANGED Intent.
 * in the {@link android.content.Intent#ACTION_BATTERY_CHANGED} Intent.
 */
public class BatteryManager {
    /**
     * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
     * integer containing the current status constant.
     */
    public static final String EXTRA_STATUS = "status";
    
    /**
     * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
     * integer containing the current health constant.
     */
    public static final String EXTRA_HEALTH = "health";
    
    /**
     * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
     * boolean indicating whether a battery is present.
     */
    public static final String EXTRA_PRESENT = "present";
    
    /**
     * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
     * integer field containing the current battery level, from 0 to
     * {@link #EXTRA_SCALE}.
     */
    public static final String EXTRA_LEVEL = "level";
    
    /**
     * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
     * integer containing the maximum battery level.
     */
    public static final String EXTRA_SCALE = "scale";
    
    /**
     * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
     * integer containing the resource ID of a small status bar icon
     * indicating the current battery state.
     */
    public static final String EXTRA_ICON_SMALL = "icon-small";
    
    /**
     * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
     * integer indicating whether the device is plugged in to a power
     * source; 0 means it is on battery, other constants are different
     * types of power sources.
     */
    public static final String EXTRA_PLUGGED = "plugged";
    
    /**
     * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
     * integer containing the current battery voltage level.
     */
    public static final String EXTRA_VOLTAGE = "voltage";
    
    /**
     * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
     * integer containing the current battery temperature.
     */
    public static final String EXTRA_TEMPERATURE = "temperature";
    
    /**
     * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
     * String describing the technology of the current battery.
     */
    public static final String EXTRA_TECHNOLOGY = "technology";
    
    // values for "status" field in the ACTION_BATTERY_CHANGED Intent
    public static final int BATTERY_STATUS_UNKNOWN = 1;
+8 −0
Original line number Diff line number Diff line
@@ -78,6 +78,14 @@
         A value of -1 means no change in orientation by default. -->
    <integer name="config_carDockRotation">-1</integer>

    <!-- Control whether being in the desk dock (and powered) always
         keeps the screen on.  By default it doesn't.  Set to true to make it. -->
    <bool name="config_deskDockKeepsScreenOn">false</bool>

    <!-- Control whether being in the car dock (and powered) always
         keeps the screen on.  By default it does.  Set to false to not keep on. -->
    <bool name="config_carDockKeepsScreenOn">true</bool>

    <!-- Indicate whether the lid state impacts the accessibility of
         the physical keyboard.  0 means it doesn't, 1 means it is accessible
         when the lid is open, 2 means it is accessible when the lid is
+10 −11
Original line number Diff line number Diff line
@@ -26,7 +26,6 @@ import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.BatteryManager;
import android.os.Binder;
import android.os.Debug;
import android.os.IBinder;
import android.os.RemoteException;
import android.os.ServiceManager;
@@ -333,16 +332,16 @@ class BatteryService extends Binder {
        
        int icon = getIcon(mBatteryLevel);

        intent.putExtra("status", mBatteryStatus);
        intent.putExtra("health", mBatteryHealth);
        intent.putExtra("present", mBatteryPresent);
        intent.putExtra("level", mBatteryLevel);
        intent.putExtra("scale", BATTERY_SCALE);
        intent.putExtra("icon-small", icon);
        intent.putExtra("plugged", mPlugType);
        intent.putExtra("voltage", mBatteryVoltage);
        intent.putExtra("temperature", mBatteryTemperature);
        intent.putExtra("technology", mBatteryTechnology);
        intent.putExtra(BatteryManager.EXTRA_STATUS, mBatteryStatus);
        intent.putExtra(BatteryManager.EXTRA_HEALTH, mBatteryHealth);
        intent.putExtra(BatteryManager.EXTRA_PRESENT, mBatteryPresent);
        intent.putExtra(BatteryManager.EXTRA_LEVEL, mBatteryLevel);
        intent.putExtra(BatteryManager.EXTRA_SCALE, BATTERY_SCALE);
        intent.putExtra(BatteryManager.EXTRA_ICON_SMALL, icon);
        intent.putExtra(BatteryManager.EXTRA_PLUGGED, mPlugType);
        intent.putExtra(BatteryManager.EXTRA_VOLTAGE, mBatteryVoltage);
        intent.putExtra(BatteryManager.EXTRA_TEMPERATURE, mBatteryTemperature);
        intent.putExtra(BatteryManager.EXTRA_TECHNOLOGY, mBatteryTechnology);

        if (false) {
            Log.d(TAG, "updateBattery level:" + mBatteryLevel +