diff --git a/app/src/main/cpp/PhoneDevice.cpp b/app/src/main/cpp/PhoneDevice.cpp index ee8fd3f7..3ccfcca9 100644 --- a/app/src/main/cpp/PhoneDevice.cpp +++ b/app/src/main/cpp/PhoneDevice.cpp @@ -232,6 +232,7 @@ CPhoneDevice::~CPhoneDevice() if (m_pRecognizationCfg != NULL) { ncnn_uninit(); + m_pRecognizationCfg = NULL; } } @@ -350,6 +351,44 @@ bool CPhoneDevice::QuerySystemProperties(std::map& pro fs::space_info si = fs::space("/data"); it->second = std::to_string(si.capacity); } + else if (it->first == (PROP_CHARGING_VOLTAGE)) + { + double val = GpioControl::getChargingVoltage() / 200.0; // ChargeVol *5/1000 + char str[32] = { 0 }; + snprintf(str, sizeof(str), "%.0f", val); + it->second = str; + } + else if (it->first == (PROP_CHARGING_CURRENT)) + { + it->second = std::to_string(GpioControl::getChargingCurrent()); + } + else if (it->first == (PROP_CHARGING_POWER)) + { + it->second = std::to_string(GpioControl::getChargingPower()); + } + else if (it->first == (PROP_CHARGING_BUS_VOL)) + { + it->second = std::to_string(GpioControl::getChargingBusVoltage()); + } + else if (it->first == (PROP_BATTERY_VOLTAGE)) + { + double val = GpioControl::getBatteryVoltage() * 3.0 / 1000.0; // // BatVol + char str[32] = { 0 }; + snprintf(str, sizeof(str), "%.0f", val); + it->second = str; + } + else if (it->first == (PROP_BATTERY_CURRENT)) + { + it->second = std::to_string(GpioControl::getBatteryCurrent()); + } + else if (it->first == (PROP_BATTERY_POWER)) + { + it->second = std::to_string(GpioControl::getBatteryPower()); + } + else if (it->first == (PROP_BATTERY_BUS_VOL)) + { + it->second = std::to_string(GpioControl::getBatteryBusVoltage()); + } else if (startsWith(it->first, PROP_JAVA_PREFIX)) { if (powerInfo.empty()) @@ -362,6 +401,7 @@ bool CPhoneDevice::QuerySystemProperties(std::map& pro it->second = it2->second; } } + } // __system_property_get("ro.telephony.default_network", value); diff --git a/app/src/main/java/com/xypower/mpapp/MicroPhotoService.java b/app/src/main/java/com/xypower/mpapp/MicroPhotoService.java index 8a894c4a..307636f7 100644 --- a/app/src/main/java/com/xypower/mpapp/MicroPhotoService.java +++ b/app/src/main/java/com/xypower/mpapp/MicroPhotoService.java @@ -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();