From 9341b8659db2572d9d262c75f1c355c83b56944d Mon Sep 17 00:00:00 2001 From: BlueMatthew Date: Fri, 2 Feb 2024 17:44:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A6=82=E6=9E=9C=E5=BD=93=E5=89=8D=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E8=AE=BE=E5=AE=9Acmdid=EF=BC=8C=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E8=AE=BE=E5=A4=87=E5=BA=8F=E5=88=97=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/cpp/MicroPhoto.cpp | 10 ++++++++++ app/src/main/java/com/xypower/mpapp/MainActivity.java | 6 +++++- .../main/java/com/xypower/mpapp/MicroPhotoService.java | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/app/src/main/cpp/MicroPhoto.cpp b/app/src/main/cpp/MicroPhoto.cpp index 1793cdc2..84a1ff20 100644 --- a/app/src/main/cpp/MicroPhoto.cpp +++ b/app/src/main/cpp/MicroPhoto.cpp @@ -646,3 +646,13 @@ Java_com_xypower_mpapp_MicroPhotoService_setCam3V3Enable( GpioControl::setCam3V3Enable(enabled != JNI_FALSE); } +extern "C" JNIEXPORT jstring JNICALL +Java_com_xypower_mpapp_MicroPhotoService_getSerialNumber( + JNIEnv* env, + jclass cls) { + + char value[PROP_VALUE_MAX] = { 0 }; + __system_property_get("ro.serialno", value); + return env->NewStringUTF(value); +} + diff --git a/app/src/main/java/com/xypower/mpapp/MainActivity.java b/app/src/main/java/com/xypower/mpapp/MainActivity.java index 692d4a16..d9294268 100644 --- a/app/src/main/java/com/xypower/mpapp/MainActivity.java +++ b/app/src/main/java/com/xypower/mpapp/MainActivity.java @@ -184,7 +184,11 @@ public class MainActivity extends AppCompatActivity { Log.d(TAG, "MainActivity: reboot=" + rebootFlag + " noDelay=" + noDelay); MicroPhotoContext.AppConfig appConfig = getAppConfig(); - binding.cmdid.setText(appConfig.cmdid); + if (TextUtils.isEmpty(appConfig.cmdid)) { + binding.cmdid.setText(MicroPhotoService.getSerialNumber()); + } else { + binding.cmdid.setText(appConfig.cmdid); + } binding.server.setText(appConfig.server); binding.port.setText(appConfig.port != 0 ? Integer.toString(appConfig.port) : ""); String protocolStr = appConfig.protocol + "-"; diff --git a/app/src/main/java/com/xypower/mpapp/MicroPhotoService.java b/app/src/main/java/com/xypower/mpapp/MicroPhotoService.java index d27f4752..5f628a7e 100644 --- a/app/src/main/java/com/xypower/mpapp/MicroPhotoService.java +++ b/app/src/main/java/com/xypower/mpapp/MicroPhotoService.java @@ -1034,6 +1034,7 @@ cellSignalStrengthGsm.getDbm(); protected native void recordingFinished(long handler, boolean result, String path, long videoId); public static native void setOtgState(boolean enabled); public static native void setCam3V3Enable(boolean enabled); + public static native String getSerialNumber(); ////////////////////////GPS//////////////////// private static final String GPS_LOCATION_NAME = android.location.LocationManager.GPS_PROVIDER;