Java Code Examples for android.os.BatteryManager#BATTERY_HEALTH_OVER_VOLTAGE

The following examples show how to use android.os.BatteryManager#BATTERY_HEALTH_OVER_VOLTAGE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TypeTranslators.java    From under-the-hood with Apache License 2.0 6 votes vote down vote up
public static String translateBatteryHealth(int batteryHealth) {
    switch (batteryHealth) {
        case BatteryManager.BATTERY_HEALTH_UNKNOWN:
            return "UNKNOWN HEALTH";
        case BatteryManager.BATTERY_HEALTH_GOOD:
            return "GOOD";
        case BatteryManager.BATTERY_HEALTH_OVERHEAT:
            return "OVERHEAT";
        case BatteryManager.BATTERY_HEALTH_DEAD:
            return "DEAD";
        case BatteryManager.BATTERY_HEALTH_OVER_VOLTAGE:
            return "OVER VOLTAGE";
        case BatteryManager.BATTERY_HEALTH_UNSPECIFIED_FAILURE:
            return "UNSPECIFIED FAILURE";
        case BatteryManager.BATTERY_HEALTH_COLD:
            return "COLD";
        default:
            return "UNKNOWN (" + batteryHealth + ")";
    }
}
 
Example 2
Source File: DataEstimator.java    From batteryhub with Apache License 2.0 6 votes vote down vote up
public String getHealthStatus() {
    String status = "";
    switch (mHealth) {
        case BatteryManager.BATTERY_HEALTH_UNKNOWN:
            status = "Unknown";
            break;
        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;
}
 
Example 3
Source File: DataEstimator.java    From batteryhub with Apache License 2.0 6 votes vote down vote up
public String getHealthStatus(final Context context) {
    String status = "";
    switch (mHealth) {
        case BatteryManager.BATTERY_HEALTH_UNKNOWN:
            status = context.getString(R.string.battery_health_unknown);
            break;
        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;
}
 
Example 4
Source File: DeviceState.java    From product-emm with Apache License 2.0 6 votes vote down vote up
/**
 * 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.
 */
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;
}
 
Example 5
Source File: BatteryInfo.java    From MobileInfo with Apache License 2.0 5 votes vote down vote up
private static String batteryHealth(int health) {
    String healthBat = BaseData.UNKNOWN_PARAM;
    switch (health) {
        case BatteryManager.BATTERY_HEALTH_COLD:
            healthBat = "cold";
            break;
        case BatteryManager.BATTERY_HEALTH_DEAD:
            healthBat = "dead";
            break;
        case BatteryManager.BATTERY_HEALTH_GOOD:
            healthBat = "good";
            break;
        case BatteryManager.BATTERY_HEALTH_OVER_VOLTAGE:
            healthBat = "overVoltage";
            break;
        case BatteryManager.BATTERY_HEALTH_OVERHEAT:
            healthBat = "overheat";
            break;
        case BatteryManager.BATTERY_HEALTH_UNKNOWN:
            healthBat = "unknown";
            break;
        case BatteryManager.BATTERY_HEALTH_UNSPECIFIED_FAILURE:
            healthBat = "unspecified";
            break;
        default:
            break;
    }
    return healthBat;
}
 
Example 6
Source File: SKBatteryData.java    From SensingKit-Android with GNU Lesser General Public License v3.0 5 votes vote down vote up
private String getBatteryHealthString(int health) {

        switch (health) {

            case BatteryManager.BATTERY_HEALTH_COLD:
                return "cold";

            case BatteryManager.BATTERY_HEALTH_DEAD:
                return "dead";

            case BatteryManager.BATTERY_HEALTH_GOOD:
                return "good";

            case BatteryManager.BATTERY_HEALTH_OVERHEAT:
                return "over heat";

            case BatteryManager.BATTERY_HEALTH_OVER_VOLTAGE:
                return "over voltage";

            case BatteryManager.BATTERY_HEALTH_UNKNOWN:
                return "unknown";

            case BatteryManager.BATTERY_HEALTH_UNSPECIFIED_FAILURE:
                return "failure";

            default:
                return "unsupported";
        }
    }
 
Example 7
Source File: BatteryInformation.java    From Saiy-PS with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * Method to resolve the battery health
 */
private void getHealth() {
    if (DEBUG) {
        MyLog.i(CLS_NAME, "getHealth");
    }

    if (batteryIntent != null) {

        final SaiyResources sr = new SaiyResources(mContext, sl);

        final int health = batteryIntent.getIntExtra(BatteryManager.EXTRA_HEALTH,
                BatteryManager.BATTERY_HEALTH_UNKNOWN);

        switch (health) {

            case BatteryManager.BATTERY_HEALTH_COLD:
                setHealthResponse(sr.getString(ai.saiy.android.R.string.cold));
                break;
            case BatteryManager.BATTERY_HEALTH_DEAD:
                setHealthResponse(sr.getString(ai.saiy.android.R.string.dead));
                break;
            case BatteryManager.BATTERY_HEALTH_GOOD:
                setHealthResponse(sr.getString(ai.saiy.android.R.string.good));
                break;
            case BatteryManager.BATTERY_HEALTH_OVERHEAT:
                setHealthResponse(sr.getString(ai.saiy.android.R.string.over_heating));
                break;
            case BatteryManager.BATTERY_HEALTH_OVER_VOLTAGE:
                setHealthResponse(sr.getString(ai.saiy.android.R.string.over_voltage));
                break;
            case BatteryManager.BATTERY_HEALTH_UNKNOWN:
                setHealthResponse(sr.getString(ai.saiy.android.R.string.currently_indeterminable));
                break;
            case BatteryManager.BATTERY_HEALTH_UNSPECIFIED_FAILURE:
                setHealthResponse(sr.getString(ai.saiy.android.R.string.currently_indeterminable));
                break;
            default:
                setHealthResponse(sr.getString(ai.saiy.android.R.string.currently_indeterminable));
                break;
        }

        sr.reset();

    } else {
        if (DEBUG) {
            MyLog.w(CLS_NAME, "batteryIntent: null");
        }
        setAccessFailure();
    }
}
 
Example 8
Source File: Inspector.java    From batteryhub with Apache License 2.0 4 votes vote down vote up
static BatteryUsage getBatteryUsage(final Context context, Intent intent) {
    BatteryUsage usage = new BatteryUsage();
    BatteryDetails details = new BatteryDetails();

    // Battery details
    int health = intent.getIntExtra(BatteryManager.EXTRA_HEALTH, 0);
    int status = intent.getIntExtra(BatteryManager.EXTRA_STATUS, 0);
    int plugged = intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, 0);
    String batteryTechnology = intent.getExtras().getString(BatteryManager.EXTRA_TECHNOLOGY);
    String batteryHealth = "Unknown";
    String batteryCharger = "unplugged";
    String batteryStatus;

    usage.timestamp = System.currentTimeMillis();
    usage.id = String.valueOf(usage.timestamp).hashCode();

    switch (health) {
        case BatteryManager.BATTERY_HEALTH_DEAD:
            batteryHealth = "Dead";
            break;
        case BatteryManager.BATTERY_HEALTH_GOOD:
            batteryHealth = "Good";
            break;
        case BatteryManager.BATTERY_HEALTH_OVER_VOLTAGE:
            batteryHealth = "Over voltage";
            break;
        case BatteryManager.BATTERY_HEALTH_OVERHEAT:
            batteryHealth = "Overheat";
            break;
        case BatteryManager.BATTERY_HEALTH_UNKNOWN:
            batteryHealth = "Unknown";
            break;
        case BatteryManager.BATTERY_HEALTH_UNSPECIFIED_FAILURE:
            batteryHealth = "Unspecified failure";
            break;
    }

    switch (status) {
        case BatteryManager.BATTERY_STATUS_CHARGING:
            batteryStatus = "Charging";
            break;
        case BatteryManager.BATTERY_STATUS_DISCHARGING:
            batteryStatus = "Discharging";
            break;
        case BatteryManager.BATTERY_STATUS_FULL:
            batteryStatus = "Full";
            break;
        case BatteryManager.BATTERY_STATUS_NOT_CHARGING:
            batteryStatus = "Not charging";
            break;
        case BatteryManager.BATTERY_STATUS_UNKNOWN:
            batteryStatus = "Unknown";
            break;
        default:
            batteryStatus = "Unknown";
    }

    switch (plugged) {
        case BatteryManager.BATTERY_PLUGGED_AC:
            batteryCharger = "ac";
            break;
        case BatteryManager.BATTERY_PLUGGED_USB:
            batteryCharger = "usb";
            break;
        case BatteryManager.BATTERY_PLUGGED_WIRELESS:
            batteryCharger = "wireless";
    }

    details.temperature =
            ((float) intent.getIntExtra(BatteryManager.EXTRA_TEMPERATURE, 0)) / 10;

    // current battery voltage in VOLTS
    // (the unit of the returned value by BatteryManager is millivolts)
    details.voltage =
            ((float) intent.getIntExtra(BatteryManager.EXTRA_VOLTAGE, 0)) / 1000;

    details.charger = batteryCharger;
    details.health = batteryHealth;
    details.technology = batteryTechnology;

    // Battery other values with API level limitations
    details.capacity = Battery.getBatteryDesignCapacity(context);
    details.chargeCounter = Battery.getBatteryChargeCounter(context);
    details.currentAverage = Battery.getBatteryCurrentAverage(context);
    details.currentNow = (int) Battery.getBatteryCurrentNow(context);
    details.energyCounter = Battery.getBatteryEnergyCounter(context);
    details.remainingCapacity = Battery.getBatteryRemainingCapacity(context);

    usage.level = (float) sCurrentBatteryLevel;
    usage.state = batteryStatus;
    usage.screenOn = Screen.isOn(context);
    usage.triggeredBy = intent.getAction();
    usage.details = details;

    return usage;
}