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

Commit 042159d9 authored by Jorge Ruesga's avatar Jorge Ruesga
Browse files

SystemUI: Add dock battery icon styles

Support for dock battery icon styles. This changes does a refactor of DockBatteryController to
extend BatteryController and create a new CircleDockBattery that extends CircleBattery (that listen
for dock battery events)

Patchset 2: Fully functional.
Patchset 3: Fixed min icons. Rebased.
Patchset 4: Create full device specific service in frameworks
            Move dock battery stuff from the framework to a device handler.
            Register/unregister DockBatteryController receivers
            Remove battery views if device doesn't support dock battery
            Refresh status on dock and screen on events
            Rebased
Patchset 5: Transformers backwards compatibility
            Better main battery status detection (use status instead of plugged type)
            Fixed battery cluster space in status bar
            Rebased
Patchset 6: Fix dock icons in ligths out mode
Patchset 7: Fix code style
            Fix lockscreen status
            Fix lights out mode (typo)
            Fix images size
            Rebased
Patchset 8: Fix icon images
            Fix status on full charge
            Rebased

TF700T implementation: http://review.cyanogenmod.org/#/c/31298/



Change-Id: I9a576d1b279f1883f736ac3bcd2435c4b95a73de
Signed-off-by: default avatarJorge Ruesga <jorge@ruesga.com>
parent eeb11165
Loading
Loading
Loading
Loading
+22 −25
Original line number Diff line number Diff line
@@ -27,12 +27,6 @@ public class BatteryManager {
     */
    public static final String EXTRA_STATUS = "status";

    /**
     * Integer containing the current status constant for the dock battery.
     * @hide
     */
    public static final String EXTRA_DOCK_STATUS = "dock_status";
    
    /**
     * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
     * integer containing the current health constant.
@@ -45,12 +39,6 @@ public class BatteryManager {
     */
    public static final String EXTRA_PRESENT = "present";

    /**
     * Integer containing the current status constant for the dock battery.
     * @hide
     */
    public static final String EXTRA_DOCK_PRESENT = "dock_present";

    /**
     * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
     * integer field containing the current battery level, from 0 to
@@ -58,12 +46,6 @@ public class BatteryManager {
     */
    public static final String EXTRA_LEVEL = "level";

    /**
     * Integer field containing the current dock battery level.
     * @hide
     */
    public static final String EXTRA_DOCK_LEVEL = "dock_level";

    /**
     * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
     * integer containing the maximum battery level.
@@ -111,6 +93,28 @@ public class BatteryManager {
     */
    public static final String EXTRA_INVALID_CHARGER = "invalid_charger";

    // Dock intents
    /** @hide **/
    public static final String EXTRA_DOCK_STATUS = "dock_status";
    /** @hide **/
    public static final String EXTRA_DOCK_HEALTH = "dock_health";
    /** @hide **/
    public static final String EXTRA_DOCK_PRESENT = "dock_present";
    /** @hide **/
    public static final String EXTRA_DOCK_LEVEL = "dock_level";
    /** @hide **/
    public static final String EXTRA_DOCK_SCALE = "dock_scale";
    /** @hide **/
    public static final String EXTRA_DOCK_ICON_SMALL = "dock_icon-small";
    /** @hide **/
    public static final String EXTRA_DOCK_PLUGGED = "dock_plugged";
    /** @hide **/
    public static final String EXTRA_DOCK_VOLTAGE = "dock_voltage";
    /** @hide **/
    public static final String EXTRA_DOCK_TEMPERATURE = "dock_temperature";
    /** @hide **/
    public static final String EXTRA_DOCK_TECHNOLOGY = "dock_technology";

    // values for "status" field in the ACTION_BATTERY_CHANGED Intent
    public static final int BATTERY_STATUS_UNKNOWN = 1;
    public static final int BATTERY_STATUS_CHARGING = 2;
@@ -127,13 +131,6 @@ public class BatteryManager {
    public static final int BATTERY_HEALTH_UNSPECIFIED_FAILURE = 6;
    public static final int BATTERY_HEALTH_COLD = 7;

    /** @hide */
    public static final int DOCK_BATTERY_STATUS_UNKNOWN = 1;
    /** @hide */
    public static final int DOCK_BATTERY_STATUS_CHARGING = 2;
    /** @hide */
    public static final int DOCK_BATTERY_STATUS_NOT_CHARGING = 4;

    // values of the "plugged" field in the ACTION_BATTERY_CHANGED intent.
    // These must be powers of 2.
    /** Power source is an AC charger. */
+53 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 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 com.android.internal.os;

import android.content.Intent;
import android.os.Bundle;

public interface DeviceDockBatteryHandler {

    /**
     * Invoked when the system request an update of the dock battery status. Device should
     * access specific sysfs and read status, present and level of the device dock battery.
     */
    public void update();

    /**
     * Invoked after {@link #update()} for processing the values prior to notify them.
     */
    public void process();

    /**
     * Method that returns the data to notify to {@link Intent#ACTION_BATTERY_CHANGED} action.
     */
    public Bundle getNotifyData();

    /**
     * Method that returns if this handler has new battery data to notify
     *
     * @return If this handler has new battery data to notify.
     */
    public boolean hasNewData();

    /**
     * Method that returns if the dock battery is plugged (is powering device main battery)
     *
     * @return If the dock battery is plugged
     */
    public boolean isPlugged();
}
+25 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 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 com.android.internal.os;

/**
 * @hide
 */
public interface IDeviceHandler {
    public DeviceKeyHandler getDeviceKeyHandler();
    public DeviceDockBatteryHandler getDeviceDockBatteryHandler();
}
+3 −1
Original line number Diff line number Diff line
@@ -22,6 +22,8 @@ import android.view.LayoutInflater;
import android.view.Window;
import android.view.WindowManagerPolicy;

import com.android.internal.os.IDeviceHandler;

/**
 * {@hide}
 */
@@ -33,7 +35,7 @@ public interface IPolicy {

    public LayoutInflater makeNewLayoutInflater(Context context);

    public WindowManagerPolicy makeNewWindowManager();
    public WindowManagerPolicy makeNewWindowManager(IDeviceHandler device);

    public FallbackEventHandler makeNewFallbackEventHandler(Context context);
}
+3 −2
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.view.LayoutInflater;
import android.view.Window;
import android.view.WindowManagerPolicy;

import com.android.internal.os.IDeviceHandler;
import com.android.internal.policy.IPolicy;

/**
@@ -63,8 +64,8 @@ public final class PolicyManager {
        return sPolicy.makeNewLayoutInflater(context);
    }

    public static WindowManagerPolicy makeNewWindowManager() {
        return sPolicy.makeNewWindowManager();
    public static WindowManagerPolicy makeNewWindowManager(IDeviceHandler device) {
        return sPolicy.makeNewWindowManager(device);
    }

    public static FallbackEventHandler makeNewFallbackEventHandler(Context context) {
Loading