Example usage for android.os BatteryManager BATTERY_HEALTH_OVERHEAT

List of usage examples for android.os BatteryManager BATTERY_HEALTH_OVERHEAT

Introduction

In this page you can find the example usage for android.os BatteryManager BATTERY_HEALTH_OVERHEAT.

Prototype

int BATTERY_HEALTH_OVERHEAT

To view the source code for android.os BatteryManager BATTERY_HEALTH_OVERHEAT.

Click Source Link

Usage

From source file:hmatalonga.greenhub.managers.sampling.DataEstimator.java

public String getHealthStatus() {
    String status = "";
    switch (health) {
    case BatteryManager.BATTERY_HEALTH_UNKNOWN:
        status = "Unknown";
        break;//from   ww  w  .  j a  v a 2 s.  com
    case BatteryManager.BATTERY_HEALTH_GOOD:
        status = "Good";
        break;
    case BatteryManager.BATTERY_HEALTH_OVERHEAT:
        status = "Overheat";
        break;
    case BatteryManager.BATTERY_HEALTH_DEAD:
        status = "Dead";
        break;
    case BatteryManager.BATTERY_HEALTH_OVER_VOLTAGE:
        status = "Over Voltage";
        break;
    case BatteryManager.BATTERY_HEALTH_UNSPECIFIED_FAILURE:
        status = "Unspecified Failure";
        break;
    }

    return status;
}

From source file:com.hmatalonga.greenhub.managers.sampling.DataEstimator.java

public String getHealthStatus() {
    String status = "";
    switch (mHealth) {
    case BatteryManager.BATTERY_HEALTH_UNKNOWN:
        status = "Unknown";
        break;//from w w w. j  av  a 2 s. c o  m
    case BatteryManager.BATTERY_HEALTH_GOOD:
        status = "Good";
        break;
    case BatteryManager.BATTERY_HEALTH_OVERHEAT:
        status = "Overheat";
        break;
    case BatteryManager.BATTERY_HEALTH_DEAD:
        status = "Dead";
        break;
    case BatteryManager.BATTERY_HEALTH_OVER_VOLTAGE:
        status = "Over Voltage";
        break;
    case BatteryManager.BATTERY_HEALTH_UNSPECIFIED_FAILURE:
        status = "Unspecified Failure";
        break;
    }

    return status;
}

From source file:com.hmatalonga.greenhub.managers.sampling.DataEstimator.java

public String getHealthStatus(Context context) {
    String status = "";
    switch (mHealth) {
    case BatteryManager.BATTERY_HEALTH_UNKNOWN:
        status = context.getString(R.string.battery_health_unknown);
        break;//from   w w  w .  j  a va 2s.  c  o  m
    case BatteryManager.BATTERY_HEALTH_GOOD:
        status = context.getString(R.string.battery_health_good);
        break;
    case BatteryManager.BATTERY_HEALTH_OVERHEAT:
        status = context.getString(R.string.battery_health_overheat);
        break;
    case BatteryManager.BATTERY_HEALTH_DEAD:
        status = context.getString(R.string.battery_health_dead);
        break;
    case BatteryManager.BATTERY_HEALTH_OVER_VOLTAGE:
        status = context.getString(R.string.battery_health_over_voltage);
        break;
    case BatteryManager.BATTERY_HEALTH_UNSPECIFIED_FAILURE:
        status = context.getString(R.string.battery_health_failure);
        break;
    }

    return status;
}

From source file:org.wso2.emm.agent.api.DeviceState.java

/**
 * Conversion from health condition int to String can be done through this method.
 *
 * @param health integer representing the health condition.
 * @return String representing the health condition.
 *//*  w  w  w  . j  ava 2  s . c  om*/
private String getHealth(int health) {
    String healthString = UNKNOWN;
    switch (health) {
    case BatteryManager.BATTERY_HEALTH_COLD:
        healthString = COLD;
        break;
    case BatteryManager.BATTERY_HEALTH_DEAD:
        healthString = DEAD;
        break;
    case BatteryManager.BATTERY_HEALTH_GOOD:
        healthString = GOOD_CONDITION;
        break;
    case BatteryManager.BATTERY_HEALTH_OVER_VOLTAGE:
        healthString = OVER_VOLTAGE;
        break;
    case BatteryManager.BATTERY_HEALTH_OVERHEAT:
        healthString = OVER_HEAT;
        break;
    case BatteryManager.BATTERY_HEALTH_UNSPECIFIED_FAILURE:
        healthString = FAILURE;
        break;
    }
    return healthString;
}

From source file:com.google.code.twisty.Twisty.java

private void appendBatteryState(StringBuffer sb) {
    IntentFilter battFilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
    Intent intent = registerReceiver(null, battFilter);

    int rawlevel = intent.getIntExtra("level", -1);
    int scale = intent.getIntExtra("scale", -1);
    int status = intent.getIntExtra("status", -1);
    int health = intent.getIntExtra("health", -1);
    int level = -1; // percentage, or -1 for unknown
    if (rawlevel >= 0 && scale > 0) {
        level = (rawlevel * 100) / scale;
    }/*  w w  w.j  a  v  a2s  . c om*/
    sb.append("The device");
    if (BatteryManager.BATTERY_HEALTH_OVERHEAT == health) {
        sb.append("'s battery feels very hot!");
    } else {
        switch (status) {
        case BatteryManager.BATTERY_STATUS_UNKNOWN:
            // old emulator; maybe also when plugged in with no battery
            sb.append(" has no battery.");
            break;
        case BatteryManager.BATTERY_STATUS_CHARGING:
            sb.append("'s battery");
            if (level <= 33)
                sb.append(" is charging, and really ought to " + "remain that way for the time being.");
            else if (level <= 84)
                sb.append(" charges merrily.");
            else
                sb.append(" will soon be fully charged.");
            break;
        case BatteryManager.BATTERY_STATUS_DISCHARGING:
        case BatteryManager.BATTERY_STATUS_NOT_CHARGING:
            if (level == 0)
                sb.append(" needs charging right away.");
            else if (level > 0 && level <= 33)
                sb.append(" is about ready to be recharged.");
            else
                sb.append("'s battery discharges merrily.");
            break;
        case BatteryManager.BATTERY_STATUS_FULL:
            sb.append(" is fully charged up and ready to go on " + "an adventure of some sort.");
            break;
        default:
            sb.append("'s battery is indescribable!");
            break;
        }
    }
    sb.append(" ");
}

From source file:com.mozilla.SUTAgentAndroid.SUTAgentAndroid.java

private void monitorBatteryState() {
    battReceiver = new BroadcastReceiver() {
        public void onReceive(Context context, Intent intent) {
            StringBuilder sb = new StringBuilder();

            int rawlevel = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1); // charge level from 0 to scale inclusive
            int scale = intent.getIntExtra(BatteryManager.EXTRA_SCALE, -1); // Max value for charge level
            int status = intent.getIntExtra(BatteryManager.EXTRA_STATUS, -1);
            int health = intent.getIntExtra(BatteryManager.EXTRA_HEALTH, -1);
            boolean present = intent.getBooleanExtra(BatteryManager.EXTRA_PRESENT, false);
            int plugged = intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1); //0 if the device is not plugged in; 1 if plugged into an AC power adapter; 2 if plugged in via USB.
            //                int voltage = intent.getIntExtra(BatteryManager.EXTRA_VOLTAGE, -1); // voltage in millivolts
            nBatteryTemp = intent.getIntExtra(BatteryManager.EXTRA_TEMPERATURE, -1); // current battery temperature in tenths of a degree Centigrade
            //                String technology = intent.getStringExtra(BatteryManager.EXTRA_TECHNOLOGY);

            nChargeLevel = -1; // percentage, or -1 for unknown
            if (rawlevel >= 0 && scale > 0) {
                nChargeLevel = (rawlevel * 100) / scale;
            }//w  w w .ja va 2 s.  c  o m

            if (plugged > 0)
                sACStatus = "ONLINE";
            else
                sACStatus = "OFFLINE";

            if (present == false)
                sb.append("NO BATTERY");
            else {
                if (nChargeLevel < 10)
                    sb.append("Critical");
                else if (nChargeLevel < 33)
                    sb.append("LOW");
                else if (nChargeLevel > 80)
                    sb.append("HIGH");
            }

            if (BatteryManager.BATTERY_HEALTH_OVERHEAT == health) {
                sb.append("Overheated ");
                sb.append((((float) (nBatteryTemp)) / 10));
                sb.append("(C)");
            } else {
                switch (status) {
                case BatteryManager.BATTERY_STATUS_UNKNOWN:
                    // old emulator; maybe also when plugged in with no battery
                    if (present == true)
                        sb.append(" UNKNOWN");
                    break;
                case BatteryManager.BATTERY_STATUS_CHARGING:
                    sb.append(" CHARGING");
                    break;
                case BatteryManager.BATTERY_STATUS_DISCHARGING:
                    sb.append(" DISCHARGING");
                    break;
                case BatteryManager.BATTERY_STATUS_NOT_CHARGING:
                    sb.append(" NOTCHARGING");
                    break;
                case BatteryManager.BATTERY_STATUS_FULL:
                    sb.append(" FULL");
                    break;
                default:
                    if (present == true)
                        sb.append("Unknown");
                    break;
                }
            }

            sPowerStatus = sb.toString();
        }
    };

    IntentFilter battFilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
    registerReceiver(battReceiver, battFilter);
}

From source file:saphion.services.ForegroundService.java

public int readbattery() {
    Intent batteryIntent = getApplicationContext().registerReceiver(null,
            new IntentFilter(Intent.ACTION_BATTERY_CHANGED));

    int rawlevel = batteryIntent.getIntExtra("level", -1);
    double scale = batteryIntent.getIntExtra("scale", -1);
    int plugged = batteryIntent.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1);
    isconnected = (plugged == BatteryManager.BATTERY_PLUGGED_AC || plugged == BatteryManager.BATTERY_PLUGGED_USB
            || plugged == BatteryManager.BATTERY_PLUGGED_WIRELESS);
    level = -1;/* ww  w.j a  v a2 s. c o m*/
    if (rawlevel >= 0 && scale > 0) {
        level = (int) ((rawlevel * 100) / scale);
        Log.d("rawLevel: " + rawlevel);
        Log.d("scale: " + scale);
    }

    temperature = Functions.updateTemperature(
            (float) ((float) (batteryIntent.getIntExtra("temperature", 0)) / 10),
            mPref.getBoolean(PreferenceHelper.MAIN_TEMP, true), true);

    int inthealth = batteryIntent.getIntExtra(BatteryManager.EXTRA_HEALTH, 0);
    health = "";
    switch (inthealth) {
    case BatteryManager.BATTERY_HEALTH_COLD:
        health = "Cold";
        break;
    case BatteryManager.BATTERY_HEALTH_DEAD:
        health = "Dead";
        break;
    case BatteryManager.BATTERY_HEALTH_GOOD:
        health = "Good";
        break;
    case BatteryManager.BATTERY_HEALTH_OVER_VOLTAGE:
        health = "Over Voltage";
        break;
    case BatteryManager.BATTERY_HEALTH_OVERHEAT:
        health = "Overheat";
        break;
    case BatteryManager.BATTERY_HEALTH_UNKNOWN:
        health = "Unknown";
        break;
    case BatteryManager.BATTERY_HEALTH_UNSPECIFIED_FAILURE:
        health = "Unspecified failure";
        break;
    }

    if (mPref.getBoolean(PreferenceHelper.KEY_ONE_PERCENT_HACK, false)) {
        try {
            java.io.FileReader fReader = new java.io.FileReader(
                    "/sys/class/power_supply/battery/charge_counter");
            java.io.BufferedReader bReader = new java.io.BufferedReader(fReader);
            int charge_counter = Integer.valueOf(bReader.readLine());
            bReader.close();

            if (charge_counter > PreferenceHelper.CHARGE_COUNTER_LEGIT_MAX) {
                disableOnePercentHack("charge_counter is too big to be actual charge");
            } else {
                if (charge_counter > 100)
                    charge_counter = 100;

                level = charge_counter;
            }
        } catch (java.io.FileNotFoundException e) {
            /*
             * These error messages are only really useful to me and might
             * as well be left hardwired here in English.
             */
            disableOnePercentHack("charge_counter file doesn't exist");
        } catch (java.io.IOException e) {
            disableOnePercentHack("Error reading charge_counter file");
        }
    }

    return level;
}