medic / cht-gateway

Android SMS gateway app for CHT Applications
GNU Affero General Public License v3.0
84 stars 41 forks source link

Feature request - Battery power level monitoring and alert system #18

Open bishwasBhatta opened 8 years ago

bishwasBhatta commented 8 years ago

If the battery level goes below a certain value (make this a user selectable value as well?), an alert SMS (pre defined, editable content) should go to a user saved number. This feature will be useful for PMs and/or Tech Leads in cases of power outages, battery failures etc.

mandric commented 8 years ago

Related https://github.com/ushahidi/SMSSync/issues/160

bishwasBhatta commented 8 years ago

Great list there @mandric . Can we have all that? 😄

On serious note, alert for Scenario 3 If data connection is lost for extended time (either WiFi, or GSM) will be a great feature to have.

alxndrsn commented 7 years ago

Get battery level:

import android.content.Intent;
import android.content.IntentFilter;
import android.os.BatteryManager;

import static android.content.Intent.ACTION_BATTERY_CHANGED;

---

Intent i = ctx.registerReceiver(null, new IntentFilter(ACTION_BATTERY_CHANGED));

Object val;

int level = i.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);
int scale = i.getIntExtra(BatteryManager.EXTRA_SCALE, -1);

if(level < 0 || scale <= 0) {
        val = "unknown";
} else {
        val = Math.round(level * 100.0f / scale);
}
alxndrsn commented 6 years ago

This information could also easily be added to each request to medic-api, e.g.

{
  "messages": ...
  "updates": ...
  "device": {
    "power": 72
  }
}
mukesh2006 commented 6 years ago

@alxndrsn Along with the information about the battery, can we please incorporate the details we can get from adb commands. Such as:

  1. adb dumpsys meminfo
  2. adb dumpsys cpuinfo,
  3. adb shell dumpsys | grep gateway | grep -i error
  4. adb bugreport
  5. adb shell dumpsys connectivity

Further any hardware diagnostic information would be helpful to keep track of the health of the gateway phone.

alxndrsn commented 6 years ago

@mukesh2006 if you have an example of the outputs of these commands, that would be helpful. I doubt we can run the commands directly from java, but we may be able to get some of the same data. However, when implementing this feature we'll also be concerned with how quick it is to collect these data, and how much they might increase the size of a request to webapp.

mukesh2006 commented 5 years ago

@alxndrsn The output of these commands are:

  1. adb dumpsys meminfo: memeinfo_medic_gateway.txt

  2. adb dumpsys cpuinfo: cpuinfo_medic_gateway.txt

  3. adb shell dumpsys | grep gateway: medic_error.txt

  4. adb bugreport: bugreport-LDN-L22A-HUAWEILDN-LX2-2018-11-27-16-07-09.zip

  5. adb shell dumpsys connectivity: medic_connectivity.txt

These are elaborate logs, we only need snippet of logs which are related with the medic gateway app, network, cpu and memory of the phone.