diff --git a/app/build.gradle b/app/build.gradle index f1e41991..852dca67 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -5,7 +5,7 @@ plugins { // 10,00,000 major-minor-build def AppMajorVersion = 1 def AppMinorVersion = 3 -def AppBuildNumber = 62 +def AppBuildNumber = 63 def AppVersionName = AppMajorVersion + "." + AppMinorVersion + "." + AppBuildNumber def AppVersionCode = AppMajorVersion * 100000 + AppMinorVersion * 1000 + AppBuildNumber diff --git a/app/src/main/cpp/GPIOControl.h b/app/src/main/cpp/GPIOControl.h index 52261117..5d740a0a 100644 --- a/app/src/main/cpp/GPIOControl.h +++ b/app/src/main/cpp/GPIOControl.h @@ -66,8 +66,8 @@ #define CMD_SET_SYSTEM_RESET 202 #define CMD_GET_LIGHT_ADC 101 #define CMD_SET_LIGHT_ADC 102 - #define CMD_GET_CHARGING_BUS_VOLTAGE_STATE 112 - #define CMD_GET_BAT_BUS_VOLTAGE_STATE 117 +#define CMD_GET_CHARGING_BUS_VOLTAGE_STATE 112 +#define CMD_GET_BAT_BUS_VOLTAGE_STATE 117 //#define CMD_GET_CHARGING_BUS_VOLTAGE_STATE 117 //#define CMD_GET_BAT_BUS_VOLTAGE_STATE 112 #define CMD_SET_SPI_MODE 0 // TO BE ADDED @@ -349,11 +349,7 @@ public: #endif static int getChargingBusVoltage() { -#ifndef USING_N938 return getInt(CMD_GET_CHARGING_BUS_VOLTAGE_STATE); -#else - return -1; -#endif } #if 0 diff --git a/common/src/main/java/com/xypower/common/NetworkUtils.java b/common/src/main/java/com/xypower/common/NetworkUtils.java index 58065629..97ba3971 100644 --- a/common/src/main/java/com/xypower/common/NetworkUtils.java +++ b/common/src/main/java/com/xypower/common/NetworkUtils.java @@ -6,14 +6,20 @@ import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.net.ConnectivityManager; +import android.net.LinkProperties; +import android.net.Network; +import android.net.NetworkCapabilities; import android.net.NetworkInfo; import android.net.Uri; +import android.net.wifi.WifiManager; import android.telephony.TelephonyManager; import android.text.TextUtils; +import android.text.format.Formatter; import java.net.Inet4Address; import java.net.InetAddress; import java.net.NetworkInterface; +import java.net.SocketException; import java.net.URI; import java.util.Enumeration; import java.util.regex.Pattern; @@ -55,7 +61,7 @@ public class NetworkUtils { } public static String getMobileNetworkIp(Context context) { - ConnectivityManager connectivityManager = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE); + ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); @SuppressLint("MissingPermission") NetworkInfo[] networkInfos = connectivityManager.getAllNetworkInfo(); if (networkInfos == null || networkInfos.length == 0) { @@ -89,6 +95,29 @@ public class NetworkUtils { } + public static String getMobileIPAddress() { + try { + Enumeration interfaces = NetworkInterface.getNetworkInterfaces(); + while (interfaces.hasMoreElements()) { + NetworkInterface networkInterface = interfaces.nextElement(); + if (networkInterface.isUp() && !networkInterface.isLoopback()) { + if (networkInterface.getName() != null && !networkInterface.getName().contains("ap")) { + Enumeration addresses = networkInterface.getInetAddresses(); + while (addresses.hasMoreElements()) { + InetAddress address = addresses.nextElement(); + if (!address.isLoopbackAddress() && address.getAddress().length == 4) { // IPv4 + return address.getHostAddress(); + } + } + } + } + } + } catch (SocketException e) { + e.printStackTrace(); + } + return null; + } + public static int addAPN(Context context, String name, String desc, String numeric, String user, String pwd) { int id = -1; String NUMERIC = getSIMInfo(context); diff --git a/mpmaster/src/main/java/com/xypower/mpmaster/sms/SimUtil.java b/mpmaster/src/main/java/com/xypower/mpmaster/sms/SimUtil.java index 801a19fe..63d6ea51 100644 --- a/mpmaster/src/main/java/com/xypower/mpmaster/sms/SimUtil.java +++ b/mpmaster/src/main/java/com/xypower/mpmaster/sms/SimUtil.java @@ -687,7 +687,7 @@ public class SimUtil { result.append(isActiveSlot ? ",默认" : ""); if (isActiveSlot) { - result.append(",IP=" + NetworkUtils.getMobileNetworkIp(context)); + result.append(",IP=" + NetworkUtils.getMobileIPAddress()); } result.append(" ");