|
|
@ -1,6 +1,7 @@
|
|
|
|
package com.xypower.mpapp;
|
|
|
|
package com.xypower.mpapp;
|
|
|
|
|
|
|
|
|
|
|
|
import android.app.ActivityManager;
|
|
|
|
import static java.lang.System.loadLibrary;
|
|
|
|
|
|
|
|
|
|
|
|
import android.app.AlarmManager;
|
|
|
|
import android.app.AlarmManager;
|
|
|
|
import android.app.Notification;
|
|
|
|
import android.app.Notification;
|
|
|
|
import android.app.NotificationChannel;
|
|
|
|
import android.app.NotificationChannel;
|
|
|
@ -17,6 +18,7 @@ import android.location.LocationManager;
|
|
|
|
import android.location.LocationProvider;
|
|
|
|
import android.location.LocationProvider;
|
|
|
|
import android.net.ConnectivityManager;
|
|
|
|
import android.net.ConnectivityManager;
|
|
|
|
import android.net.wifi.WifiManager;
|
|
|
|
import android.net.wifi.WifiManager;
|
|
|
|
|
|
|
|
import android.os.BatteryManager;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.os.Handler;
|
|
|
|
import android.os.Handler;
|
|
|
|
import android.os.IBinder;
|
|
|
|
import android.os.IBinder;
|
|
|
@ -27,6 +29,8 @@ import android.os.SystemClock;
|
|
|
|
|
|
|
|
|
|
|
|
import androidx.core.app.NotificationCompat;
|
|
|
|
import androidx.core.app.NotificationCompat;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import android.telephony.CellSignalStrength;
|
|
|
|
|
|
|
|
import android.telephony.SignalStrength;
|
|
|
|
import android.telephony.SubscriptionManager;
|
|
|
|
import android.telephony.SubscriptionManager;
|
|
|
|
import android.telephony.TelephonyManager;
|
|
|
|
import android.telephony.TelephonyManager;
|
|
|
|
import android.text.TextUtils;
|
|
|
|
import android.text.TextUtils;
|
|
|
@ -52,7 +56,7 @@ public class MicroPhotoService extends Service {
|
|
|
|
|
|
|
|
|
|
|
|
// Used to load the 'microphoto' library on application startup.
|
|
|
|
// Used to load the 'microphoto' library on application startup.
|
|
|
|
static {
|
|
|
|
static {
|
|
|
|
System.loadLibrary("microphoto");
|
|
|
|
loadLibrary("microphoto");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private static final String ALARM_EVENT = "com.xinyingpower.mp.MicroPhotoService.AlarmReceiver";
|
|
|
|
private static final String ALARM_EVENT = "com.xinyingpower.mp.MicroPhotoService.AlarmReceiver";
|
|
|
|
public static final int NOTIFICATION_ID_FOREGROUND_SERVICE = 8466503;
|
|
|
|
public static final int NOTIFICATION_ID_FOREGROUND_SERVICE = 8466503;
|
|
|
@ -101,6 +105,8 @@ public class MicroPhotoService extends Service {
|
|
|
|
private ServiceHandler mHander = null;
|
|
|
|
private ServiceHandler mHander = null;
|
|
|
|
private Messenger mMessenger = null;
|
|
|
|
private Messenger mMessenger = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String mModelName = null;
|
|
|
|
|
|
|
|
|
|
|
|
public MicroPhotoService() {
|
|
|
|
public MicroPhotoService() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
@ -761,16 +767,69 @@ public class MicroPhotoService extends Service {
|
|
|
|
th.start();
|
|
|
|
th.start();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public String getPowerInfo() {
|
|
|
|
public String getSystemInfo() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
boolean isXyPlatform = !mModelName.startsWith("ELE-");
|
|
|
|
|
|
|
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
sb.append("CV=" + SysApi.getChargingVoltage()); // ChargeVol
|
|
|
|
if (isXyPlatform) {
|
|
|
|
sb.append("&CC=" + SysApi.getChargingCurrent()); // ChargeCurrent
|
|
|
|
sb.append("&J_CV=" + SysApi.getChargingVoltage()); // ChargeVol
|
|
|
|
sb.append("&CP="+ SysApi.getChargingPower()); // ChargePower:
|
|
|
|
sb.append("&J_CC=" + SysApi.getChargingCurrent()); // ChargeCurrent
|
|
|
|
sb.append("&CBV="+ SysApi.getChargingBusVoltage()); // ChargeBusVol
|
|
|
|
sb.append("&J_CP=" + SysApi.getChargingPower()); // ChargePower:
|
|
|
|
sb.append("&BV="+ SysApi.getBatteryVoltage()); // BatVol
|
|
|
|
sb.append("&J_CBV=" + SysApi.getChargingBusVoltage()); // ChargeBusVol
|
|
|
|
sb.append("&BC="+ SysApi.getBatteryCurrent()); // BatCurrent
|
|
|
|
sb.append("&J_BV=" + SysApi.getBatteryVoltage()); // BatVol
|
|
|
|
sb.append("&BP="+ SysApi.getBatteryPower()); // BattaryPower
|
|
|
|
sb.append("&J_BC=" + SysApi.getBatteryCurrent()); // BatCurrent
|
|
|
|
sb.append("&BBV="+ SysApi.getBatteryBusVoltage()); // BattaryBusVol
|
|
|
|
sb.append("&J_BP=" + SysApi.getBatteryPower()); // BattaryPower
|
|
|
|
|
|
|
|
sb.append("&J_BBV=" + SysApi.getBatteryBusVoltage()); // BattaryBusVol
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IntentFilter intentFilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
|
|
|
|
|
|
|
|
Intent intent = getApplicationContext().registerReceiver(null, intentFilter);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int batteryStatus = intent.getIntExtra(BatteryManager.EXTRA_STATUS, -1);
|
|
|
|
|
|
|
|
int isCahrging = ((batteryStatus == BatteryManager.BATTERY_STATUS_CHARGING) ||
|
|
|
|
|
|
|
|
(batteryStatus == BatteryManager.BATTERY_STATUS_FULL)) ? 1 : 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int level = intent.getIntExtra("level", 0); ///电池剩余电量
|
|
|
|
|
|
|
|
int scale = intent.getIntExtra("scale", 0); ///获取电池满电量数值
|
|
|
|
|
|
|
|
// intent.getStringExtra("technology"); ///获取电池技术支持
|
|
|
|
|
|
|
|
// intent.getIntExtra("status",BatteryManager.BATTERY_STATUS_UNKNOWN); ///获取电池状态
|
|
|
|
|
|
|
|
// intent.getIntExtra("plugged", 0); ///获取电源信息
|
|
|
|
|
|
|
|
// intent.getIntExtra("health",BatteryManager.BATTERY_HEALTH_UNKNOWN); ///获取电池健康度
|
|
|
|
|
|
|
|
int bv = intent.getIntExtra("voltage", 0); /// mv
|
|
|
|
|
|
|
|
int temp = intent.getIntExtra("temperature", 0); ///获取电池温度
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BatteryManager manager = (BatteryManager) getSystemService(BATTERY_SERVICE);
|
|
|
|
|
|
|
|
// manager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CHARGE_COUNTER);
|
|
|
|
|
|
|
|
int bca = manager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CURRENT_AVERAGE);
|
|
|
|
|
|
|
|
int bc = manager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CURRENT_NOW);
|
|
|
|
|
|
|
|
level = manager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float bcaVal = (bca < 0) ? ((-bca)/1000000000) : (bca / 1000000000);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sb.append("&J_BC=" + Float.toString(bcaVal));
|
|
|
|
|
|
|
|
sb.append("&J_BV=" + Float.toString(((float)bv) / 1000));
|
|
|
|
|
|
|
|
sb.append("&J_BP=" + level);
|
|
|
|
|
|
|
|
sb.append("&J_BS=" + scale);
|
|
|
|
|
|
|
|
sb.append("&J_BCS=" + isCahrging);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ConnectivityManager cm = (ConnectivityManager)getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE);
|
|
|
|
|
|
|
|
boolean isMetered = cm.isActiveNetworkMetered();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sb.append("&J_ConnState=" + (isMetered ? "1" : "0"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final TelephonyManager telephonyManager = (TelephonyManager) getApplicationContext().getSystemService(Context.TELEPHONY_SERVICE);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SignalStrength ss = telephonyManager.getSignalStrength();
|
|
|
|
|
|
|
|
List<CellSignalStrength> css = ss.getCellSignalStrengths();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int signalLevel = ss.getLevel();
|
|
|
|
|
|
|
|
sb.append("&J_Signal4G=" + signalLevel);
|
|
|
|
|
|
|
|
sb.append("&J_Signal2G=" + signalLevel);
|
|
|
|
|
|
|
|
if (css != null && css.size() > 0) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// SysApi.getCpuRate();
|
|
|
|
|
|
|
|
|
|
|
|
return sb.toString();
|
|
|
|
return sb.toString();
|
|
|
|
}
|
|
|
|
}
|
|
|
|