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

Loading
+1 −0
Original line number Diff line number Diff line
@@ -63,6 +63,7 @@ LOCAL_SRC_FILES += \
	core/java/android/app/IActivityPendingResult.aidl \
	core/java/android/app/IAlarmManager.aidl \
	core/java/android/app/IBackupAgent.aidl \
	core/java/android/app/IBatteryService.aidl \
	core/java/android/app/IInstrumentationWatcher.aidl \
	core/java/android/app/INotificationManager.aidl \
	core/java/android/app/IProfileManager.aidl \
+8 −0
Original line number Diff line number Diff line
@@ -80,6 +80,7 @@ import android.net.wifi.p2p.WifiP2pManager;
import android.net.wimax.WimaxHelper;
import android.net.wimax.WimaxManagerConstants;
import android.nfc.NfcManager;
import android.os.BatteryManager;
import android.os.Binder;
import android.os.Bundle;
import android.os.Debug;
@@ -604,6 +605,13 @@ class ContextImpl extends Context {
                public Object createService(ContextImpl ctx) {
                    return WimaxHelper.createWimaxService(ctx, ctx.mMainThread.getHandler());
                }});

        registerService(BATTERY_SERVICE, new ServiceFetcher() {
                public Object createService(ContextImpl ctx) {
                    IBinder b = ServiceManager.getService(BATTERY_SERVICE);
                    IBatteryService service = IBatteryService.Stub.asInterface(b);
                    return new BatteryManager(service, ctx);
                }});
    }

    static ContextImpl getImpl(Context context) {
+28 −0
Original line number Diff line number Diff line
/* //device/java/android/android/app/IBatteryService.aidl
**
** Copyright 2013, The CyanogenMod 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 android.app;

/**
 * System private API for talking with the battery service.
 *
 * {@hide}
 */
interface IBatteryService {
    boolean isDockBatterySupported();
}

+10 −0
Original line number Diff line number Diff line
@@ -2466,6 +2466,16 @@ public abstract class Context {
     */
    public static final String CONSUMER_IR_SERVICE = "consumer_ir";

    /**
     * Use with {@link #getSystemService} to retrieve a
     * {@link android.os.BatteryManager} for access battery information.
     *
     * @see #getSystemService
     * @see android.os.BatteryManager
     * @hide
     */
    public static final String BATTERY_SERVICE = "battery";

    /**
     * Determine whether the given permission is allowed for a particular
     * process and user ID running in the system.
+120 −9
Original line number Diff line number Diff line
@@ -16,6 +16,9 @@

package android.os;

import android.app.IBatteryService;
import android.content.Context;

/**
 * The BatteryManager class contains strings and constants used for values
 * in the {@link android.content.Intent#ACTION_BATTERY_CHANGED} Intent.
@@ -85,6 +88,79 @@ public class BatteryManager {
     */
    public static final String EXTRA_TECHNOLOGY = "technology";

    /**
     * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
     * integer containing the current dock status constant.
     * @hide
     */
    public static final String EXTRA_DOCK_STATUS = "dock_status";

    /**
     * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
     * integer containing the current dock health constant.
     * @hide
     */
    public static final String EXTRA_DOCK_HEALTH = "dock_health";

    /**
     * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
     * boolean indicating whether a dock battery is present.
     * @hide
     */
    public static final String EXTRA_DOCK_PRESENT = "dock_present";

    /**
     * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
     * integer field containing the current dock battery level, from 0 to
     * {@link #EXTRA_SCALE}.
     * @hide
     */
    public static final String EXTRA_DOCK_LEVEL = "dock_level";

    /**
     * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
     * integer containing the maximum dock battery level.
     * @hide
     */
    public static final String EXTRA_DOCK_SCALE = "dock_scale";

    /**
     * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
     * integer containing the resource ID of a small status bar icon
     * indicating the current dock battery state.
     * @hide
     */
    public static final String EXTRA_DOCK_ICON_SMALL = "dock_icon-small";

    /**
     * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
     * integer indicating whether the device is plugged in to a dock power
     * source.
     * @hide
     */
    public static final String EXTRA_DOCK_PLUGGED = "dock_plugged";

    /**
     * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
     * integer containing the current dock battery voltage level.
     * @hide
     */
    public static final String EXTRA_DOCK_VOLTAGE = "dock_voltage";

    /**
     * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
     * integer containing the current dock battery temperature.
     * @hide
     */
    public static final String EXTRA_DOCK_TEMPERATURE = "dock_temperature";

    /**
     * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
     * String describing the technology of the current dock battery.
     * @hide
     */
    public static final String EXTRA_DOCK_TECHNOLOGY = "dock_technology";

    /**
     * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
     * Int value set to nonzero if an unsupported charger is attached
@@ -118,7 +194,42 @@ public class BatteryManager {
    /** Power source is wireless. */
    public static final int BATTERY_PLUGGED_WIRELESS = 4;

    // values of the "dock_plugged" field in the ACTION_BATTERY_CHANGED intent.
    // These must be powers of 2.
    /** Power source is an DockAC charger.
     * @hide*/
    public static final int BATTERY_DOCK_PLUGGED_AC = 1;
    /** Power source is an DockUSB charger.
     * @hide*/
    public static final int BATTERY_DOCK_PLUGGED_USB = 2;

    /** @hide */
    public static final int BATTERY_PLUGGED_ANY =
            BATTERY_PLUGGED_AC | BATTERY_PLUGGED_USB | BATTERY_PLUGGED_WIRELESS;

    /** @hide */
    public static final int BATTERY_DOCK_PLUGGED_ANY =
            BATTERY_DOCK_PLUGGED_AC | BATTERY_DOCK_PLUGGED_USB;

    private final IBatteryService mService;

    /**
     * @hide
     */
    public BatteryManager(IBatteryService service, Context context) {
        super();
        mService = service;
    }

    /**
     * @hide
     */
    public boolean isDockBatterySupported() {
        try {
            return mService.isDockBatterySupported();
        } catch (RemoteException ex) {
            // Ignore
        }
        return false;
    }
}
Loading