version:4.5beta
fix: update:增加获取手机号码,获取运营商类型,获取wifi网络运营商,获取手机号码
This commit is contained in:
@@ -65,6 +65,7 @@ import com.aoleyun.sn.service.GuardService;
|
||||
import com.aoleyun.sn.service.LogcatService;
|
||||
import com.aoleyun.sn.service.main.MainService;
|
||||
import com.aoleyun.sn.service.StepService;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
@@ -1965,7 +1966,7 @@ public class JGYUtils {
|
||||
jsonObject.addProperty("desktop_version", Utils.getAPPVersionName("com.aoleyun.os", mContext));
|
||||
jsonObject.addProperty("local_mac", Utils.getAndroid7MAC());
|
||||
// jsonObject.addProperty("wifi_status", Utils.obtainWifiInfo(mContext));
|
||||
jsonObject.addProperty("PN_ip", (String) SPUtils.get(mContext, "PublicIP", ""));
|
||||
jsonObject.addProperty("PN_ip", MMKV.defaultMMKV().decodeString(NetInterfaceManager.PublicIP, ""));
|
||||
jsonObject.addProperty("LAN_ip", Utils.getIPAddress(mContext));
|
||||
jsonObject.addProperty("bluetooth", Utils.getBluetoothList());
|
||||
jsonObject.addProperty("wifi_name", Utils.getWifiAlias(mContext));
|
||||
|
||||
@@ -1,15 +1,31 @@
|
||||
package com.aoleyun.sn.utils;
|
||||
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkCapabilities;
|
||||
import android.net.NetworkInfo;
|
||||
import android.os.Build;
|
||||
import android.telephony.CellInfo;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author fanhuitong
|
||||
*/
|
||||
public class NetworkUtils {
|
||||
private static String TAG = NetworkUtils.class.getSimpleName();
|
||||
|
||||
/**
|
||||
* 网络是否连接
|
||||
*
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
public static boolean isConnected(Context context) {
|
||||
ConnectivityManager mConnectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
@@ -29,7 +45,13 @@ public class NetworkUtils {
|
||||
}
|
||||
|
||||
|
||||
public String getNetworkType(Context context) {
|
||||
/**
|
||||
* 获取网络类型
|
||||
*
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
public static String getNetworkType(Context context) {
|
||||
String strNetworkType = "UnKnown";
|
||||
final NetworkInfo activeNetworkInfo = ((ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE)).getActiveNetworkInfo();
|
||||
if (activeNetworkInfo != null && activeNetworkInfo.getType() == 1) {
|
||||
@@ -67,7 +89,49 @@ public class NetworkUtils {
|
||||
break;
|
||||
}
|
||||
}
|
||||
Log.e(TAG, "getNetworkType: " + strNetworkType);
|
||||
return strNetworkType;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取SIM卡运营商
|
||||
*
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
public static String getOperators(Context context) {
|
||||
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 1; i <= tm.getPhoneCount(); i++) {
|
||||
if (sb.length() > 0) {
|
||||
sb.append(",");
|
||||
}
|
||||
sb.append("SIM卡").append(i).append(":");
|
||||
String operatorName = tm.getSimOperatorName(i);
|
||||
sb.append(TextUtils.isEmpty(operatorName) ? "未知" : operatorName);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取电话号码
|
||||
*
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
@SuppressLint("HardwareIds")
|
||||
public static String getPhoneNumber(Context context) {
|
||||
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 1; i <= tm.getPhoneCount(); i++) {
|
||||
if (sb.length() > 0) {
|
||||
sb.append(",");
|
||||
}
|
||||
// sb.append("电话").append(i).append(":");
|
||||
String operatorName = tm.getLine1Number(i);
|
||||
sb.append(TextUtils.isEmpty(operatorName) ? "未知" : operatorName);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,6 +63,7 @@ import com.google.zxing.WriterException;
|
||||
import com.google.zxing.common.BitMatrix;
|
||||
import com.google.zxing.qrcode.QRCodeWriter;
|
||||
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.DataOutputStream;
|
||||
@@ -1649,7 +1650,6 @@ public class Utils {
|
||||
NetInterfaceManager.getPublicIP(new NetInterfaceManager.PublicIP() {
|
||||
@Override
|
||||
public void set(String ip) {
|
||||
SPUtils.put(context, "PublicIP", ip);
|
||||
Log.e("getPublicIP", "set: " + ip);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user