|
|
|
@ -14,6 +14,10 @@ import android.content.ComponentName;
|
|
|
|
|
import android.content.Context;
|
|
|
|
|
import android.content.Intent;
|
|
|
|
|
import android.content.IntentFilter;
|
|
|
|
|
import android.graphics.Bitmap;
|
|
|
|
|
import android.graphics.Canvas;
|
|
|
|
|
import android.graphics.Color;
|
|
|
|
|
import android.graphics.Paint;
|
|
|
|
|
import android.location.Location;
|
|
|
|
|
import android.location.LocationListener;
|
|
|
|
|
import android.location.LocationManager;
|
|
|
|
@ -43,6 +47,7 @@ import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
|
|
|
|
import android.telephony.SignalStrength;
|
|
|
|
|
import android.telephony.SubscriptionManager;
|
|
|
|
|
import android.telephony.TelephonyManager;
|
|
|
|
|
import android.text.TextPaint;
|
|
|
|
|
import android.text.TextUtils;
|
|
|
|
|
import android.text.format.DateFormat;
|
|
|
|
|
import android.util.Log;
|
|
|
|
@ -55,6 +60,7 @@ import com.xypower.common.InetAddressUtils;
|
|
|
|
|
import com.xypower.common.MicroPhotoContext;
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.io.FileOutputStream;
|
|
|
|
|
import java.lang.reflect.Method;
|
|
|
|
|
import java.net.InetAddress;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
@ -230,6 +236,56 @@ public class MicroPhotoService extends Service {
|
|
|
|
|
super.onDestroy();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean drawText(Bitmap bitmap, String[] osds, float[] x, float[] y, int fontSize, int strokeWidth, int quality, String path) {
|
|
|
|
|
Canvas canvas = new Canvas(bitmap);
|
|
|
|
|
|
|
|
|
|
TextPaint paint = new TextPaint();
|
|
|
|
|
paint.setStyle(Paint.Style.FILL_AND_STROKE);
|
|
|
|
|
paint.setColor(Color.WHITE);
|
|
|
|
|
paint.setStrokeWidth(0);
|
|
|
|
|
paint.setTextSize(fontSize);
|
|
|
|
|
paint.setAntiAlias(true);
|
|
|
|
|
|
|
|
|
|
for (int idx = 0; idx < osds.length; idx++) {
|
|
|
|
|
canvas.drawText(osds[idx], x[idx], y[idx], paint);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TextPaint paint2 = new TextPaint();
|
|
|
|
|
|
|
|
|
|
paint2.setColor(Color.BLACK);
|
|
|
|
|
paint2.setStyle(Paint.Style.STROKE);
|
|
|
|
|
paint2.setStrokeWidth(strokeWidth);
|
|
|
|
|
paint2.setTextSize(fontSize);
|
|
|
|
|
paint2.setAntiAlias(true);
|
|
|
|
|
|
|
|
|
|
for (int idx = 0; idx < osds.length; idx++) {
|
|
|
|
|
canvas.drawText(osds[idx], x[idx], y[idx], paint2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FileOutputStream fileOutputStream = null;
|
|
|
|
|
try {
|
|
|
|
|
File file = new File(path);
|
|
|
|
|
if (file.exists()) {
|
|
|
|
|
file.delete();
|
|
|
|
|
}
|
|
|
|
|
fileOutputStream = new FileOutputStream(file);
|
|
|
|
|
|
|
|
|
|
return bitmap.compress(Bitmap.CompressFormat.JPEG, quality, fileOutputStream);
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
if (fileOutputStream != null) {
|
|
|
|
|
try {
|
|
|
|
|
fileOutputStream.close();
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static class ServiceHandler extends Handler {
|
|
|
|
|
@Override
|
|
|
|
|
public void dispatchMessage(Message msg) {
|
|
|
|
@ -954,21 +1010,6 @@ public class MicroPhotoService extends Service {
|
|
|
|
|
sb.append("&SL=" + signalLevel);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isXyPlatform) {
|
|
|
|
|
java.text.DecimalFormat fmt=new java.text.DecimalFormat("0.0");
|
|
|
|
|
|
|
|
|
|
double val = SysApi.getChargingVoltage() / 200.0;
|
|
|
|
|
sb.append("&CV=" + fmt.format(val)); // ChargeVol *5/1000
|
|
|
|
|
sb.append("&CC=" + SysApi.getChargingCurrent()); // ChargeCurrent
|
|
|
|
|
sb.append("&CP=" + SysApi.getChargingPower()); // ChargePower:
|
|
|
|
|
sb.append("&CBV=" + SysApi.getChargingBusVoltage()); // ChargeBusVol
|
|
|
|
|
val = SysApi.getBatteryVoltage() * 3.0 / 1000.0;
|
|
|
|
|
sb.append("&BV=" + fmt.format(val)); // BatVol
|
|
|
|
|
sb.append("&BC=" + SysApi.getBatteryCurrent()); // BatCurrent
|
|
|
|
|
sb.append("&BP=" + SysApi.getBatteryPower()); // BattaryPower
|
|
|
|
|
sb.append("&BBV=" + SysApi.getBatteryBusVoltage()); // BattaryBusVol
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// SysApi.getCpuRate();
|
|
|
|
|
|
|
|
|
|
return sb.toString();
|
|
|
|
|