version:4.5beta
fix: update:增加获取手机号码,获取运营商类型,获取wifi网络运营商,获取手机号码
This commit is contained in:
@@ -61,8 +61,8 @@ android {
|
|||||||
//新平台正式
|
//新平台正式
|
||||||
cube {
|
cube {
|
||||||
flavorDimensions "default"
|
flavorDimensions "default"
|
||||||
versionCode 35
|
versionCode 36
|
||||||
versionName "4.4"
|
versionName "4.5"
|
||||||
/*********************************极光推送************************************/
|
/*********************************极光推送************************************/
|
||||||
manifestPlaceholders = [
|
manifestPlaceholders = [
|
||||||
XG_ACCESS_ID : "1500026372",
|
XG_ACCESS_ID : "1500026372",
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ import com.aoleyun.sn.service.LogcatService;
|
|||||||
import com.aoleyun.sn.utils.ApkUtils;
|
import com.aoleyun.sn.utils.ApkUtils;
|
||||||
import com.aoleyun.sn.utils.ForegroundAppUtil;
|
import com.aoleyun.sn.utils.ForegroundAppUtil;
|
||||||
import com.aoleyun.sn.utils.JGYUtils;
|
import com.aoleyun.sn.utils.JGYUtils;
|
||||||
|
import com.aoleyun.sn.utils.NetworkUtils;
|
||||||
import com.aoleyun.sn.utils.SPUtils;
|
import com.aoleyun.sn.utils.SPUtils;
|
||||||
import com.aoleyun.sn.utils.ServiceAliveUtils;
|
import com.aoleyun.sn.utils.ServiceAliveUtils;
|
||||||
import com.aoleyun.sn.utils.TimeUtils;
|
import com.aoleyun.sn.utils.TimeUtils;
|
||||||
@@ -88,10 +89,13 @@ public class SplashActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
private void initView() {
|
private void initView() {
|
||||||
if (BuildConfig.DEBUG) {
|
if (BuildConfig.DEBUG) {
|
||||||
Log.e(TAG, "initView: " + Utils.getIMEI(this));
|
// Log.e(TAG, "initView: " + Utils.getIMEI(this));
|
||||||
Log.e(TAG, "initView: " + Utils.getIMEI(this, 0));
|
// Log.e(TAG, "initView: " + Utils.getIMEI(this, 0));
|
||||||
Log.e(TAG, "initView: " + Utils.getIMEI(this, 1));
|
// Log.e(TAG, "initView: " + Utils.getIMEI(this, 1));
|
||||||
|
Log.e(TAG, "getOperators: " + NetworkUtils.getOperators(this));
|
||||||
|
Log.e(TAG, "PublicIP: " + MMKV.defaultMMKV().decodeString(NetInterfaceManager.PublicIP, ""));
|
||||||
|
NetInterfaceManager.GetWhois();
|
||||||
|
Log.e(TAG, "initView: " + NetworkUtils.getPhoneNumber(this));
|
||||||
// String jsonString = ApkUtils.getRunningAppInfo(this);
|
// String jsonString = ApkUtils.getRunningAppInfo(this);
|
||||||
// Log.e(TAG, "initView: " + jsonString);
|
// Log.e(TAG, "initView: " + jsonString);
|
||||||
ApkUtils.showAllAPP(this);
|
ApkUtils.showAllAPP(this);
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ public class CheckNetPresenter implements CheckNetContact.Presenter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendMACAddress() {
|
public void sendMACAddress() {
|
||||||
mNetInterfaceManager.sendMACAddress(getLifecycle(), new NetInterfaceManager.onCompleteCallback() {
|
mNetInterfaceManager.sendMACAddress(true, getLifecycle(), new NetInterfaceManager.onCompleteCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onComplete() {
|
public void onComplete() {
|
||||||
mView.sendMACFinish();
|
mView.sendMACFinish();
|
||||||
|
|||||||
@@ -153,6 +153,7 @@ public class BaseApplication extends MultiDexApplication {
|
|||||||
public void onSuccess(Object data, int flag) {
|
public void onSuccess(Object data, int flag) {
|
||||||
//token在设备卸载重装的时候有可能会变
|
//token在设备卸载重装的时候有可能会变
|
||||||
Log.e("TPush", "注册成功,设备token为:" + data);
|
Log.e("TPush", "注册成功,设备token为:" + data);
|
||||||
|
MMKV.defaultMMKV().encode("XGPushtoken", data.toString());
|
||||||
List<XGPushManager.AccountInfo> accountInfoList = new ArrayList<>();
|
List<XGPushManager.AccountInfo> accountInfoList = new ArrayList<>();
|
||||||
accountInfoList.add(new XGPushManager.AccountInfo(XGPushManager.AccountType.CUSTOM.getValue(), Utils.getSerial(getApplicationContext())));
|
accountInfoList.add(new XGPushManager.AccountInfo(XGPushManager.AccountType.CUSTOM.getValue(), Utils.getSerial(getApplicationContext())));
|
||||||
if (Utils.NOSN.equalsIgnoreCase(Utils.getSerial())) {
|
if (Utils.NOSN.equalsIgnoreCase(Utils.getSerial())) {
|
||||||
|
|||||||
109
app/src/main/java/com/aoleyun/sn/bean/WhoisBean.java
Normal file
109
app/src/main/java/com/aoleyun/sn/bean/WhoisBean.java
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
package com.aoleyun.sn.bean;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.JsonParser;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
public class WhoisBean implements Serializable {
|
||||||
|
private static final long serialVersionUID = -6537021620041268080L;
|
||||||
|
|
||||||
|
String ip;
|
||||||
|
String pro;
|
||||||
|
String proCode;
|
||||||
|
String city;
|
||||||
|
String cityCode;
|
||||||
|
String region;
|
||||||
|
String regionCode;
|
||||||
|
String addr;
|
||||||
|
String regionNames;
|
||||||
|
String err;
|
||||||
|
|
||||||
|
public String getIp() {
|
||||||
|
return ip;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIp(String ip) {
|
||||||
|
this.ip = ip;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPro() {
|
||||||
|
return pro;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPro(String pro) {
|
||||||
|
this.pro = pro;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getProCode() {
|
||||||
|
return proCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProCode(String proCode) {
|
||||||
|
this.proCode = proCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCity() {
|
||||||
|
return city;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCity(String city) {
|
||||||
|
this.city = city;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCityCode() {
|
||||||
|
return cityCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCityCode(String cityCode) {
|
||||||
|
this.cityCode = cityCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRegion() {
|
||||||
|
return region;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRegion(String region) {
|
||||||
|
this.region = region;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRegionCode() {
|
||||||
|
return regionCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRegionCode(String regionCode) {
|
||||||
|
this.regionCode = regionCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAddr() {
|
||||||
|
return addr;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAddr(String addr) {
|
||||||
|
this.addr = addr;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRegionNames() {
|
||||||
|
return regionNames;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRegionNames(String regionNames) {
|
||||||
|
this.regionNames = regionNames;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getErr() {
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setErr(String err) {
|
||||||
|
this.err = err;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return JsonParser.parseString(new Gson().toJson(this)).getAsJsonObject().toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -36,6 +36,7 @@ import com.aoleyun.sn.bean.SnRunLog;
|
|||||||
import com.aoleyun.sn.bean.SnTimeControl;
|
import com.aoleyun.sn.bean.SnTimeControl;
|
||||||
import com.aoleyun.sn.bean.StudentsInfo;
|
import com.aoleyun.sn.bean.StudentsInfo;
|
||||||
import com.aoleyun.sn.bean.TopApp;
|
import com.aoleyun.sn.bean.TopApp;
|
||||||
|
import com.aoleyun.sn.bean.WhoisBean;
|
||||||
import com.aoleyun.sn.bean.WiFiAlias;
|
import com.aoleyun.sn.bean.WiFiAlias;
|
||||||
import com.aoleyun.sn.comm.CommonConfig;
|
import com.aoleyun.sn.comm.CommonConfig;
|
||||||
import com.aoleyun.sn.comm.JGYActions;
|
import com.aoleyun.sn.comm.JGYActions;
|
||||||
@@ -44,12 +45,13 @@ import com.aoleyun.sn.disklrucache.CacheHelper;
|
|||||||
import com.aoleyun.sn.gson.NullStringToEmptyAdapterFactory;
|
import com.aoleyun.sn.gson.NullStringToEmptyAdapterFactory;
|
||||||
import com.aoleyun.sn.manager.ConnectManager;
|
import com.aoleyun.sn.manager.ConnectManager;
|
||||||
import com.aoleyun.sn.manager.ConnectMode;
|
import com.aoleyun.sn.manager.ConnectMode;
|
||||||
|
import com.aoleyun.sn.network.api.GetWhoisApi;
|
||||||
import com.aoleyun.sn.network.api.get.CheckTestUpdateApi;
|
import com.aoleyun.sn.network.api.get.CheckTestUpdateApi;
|
||||||
import com.aoleyun.sn.network.api.get.DefaultAppApi;
|
import com.aoleyun.sn.network.api.get.DefaultAppApi;
|
||||||
import com.aoleyun.sn.network.api.get.GetDesktopApi;
|
import com.aoleyun.sn.network.api.get.GetDesktopApi;
|
||||||
import com.aoleyun.sn.network.api.get.GetDeveloperApi;
|
import com.aoleyun.sn.network.api.get.GetDeveloperApi;
|
||||||
import com.aoleyun.sn.network.api.get.GetJpushTagsApi;
|
import com.aoleyun.sn.network.api.get.GetJpushTagsApi;
|
||||||
import com.aoleyun.sn.network.api.get.GetPublicIPApi;
|
import com.aoleyun.sn.network.api.GetPublicIPApi;
|
||||||
import com.aoleyun.sn.network.api.get.GetSnRunLogApi;
|
import com.aoleyun.sn.network.api.get.GetSnRunLogApi;
|
||||||
import com.aoleyun.sn.network.api.get.GetWiFiAliasApi;
|
import com.aoleyun.sn.network.api.get.GetWiFiAliasApi;
|
||||||
import com.aoleyun.sn.network.api.get.LogoImgApi;
|
import com.aoleyun.sn.network.api.get.LogoImgApi;
|
||||||
@@ -95,6 +97,7 @@ import com.aoleyun.sn.utils.CacheUtils;
|
|||||||
import com.aoleyun.sn.utils.ForegroundAppUtil;
|
import com.aoleyun.sn.utils.ForegroundAppUtil;
|
||||||
import com.aoleyun.sn.utils.GsonUtils;
|
import com.aoleyun.sn.utils.GsonUtils;
|
||||||
import com.aoleyun.sn.utils.JGYUtils;
|
import com.aoleyun.sn.utils.JGYUtils;
|
||||||
|
import com.aoleyun.sn.utils.NetworkUtils;
|
||||||
import com.aoleyun.sn.utils.SPUtils;
|
import com.aoleyun.sn.utils.SPUtils;
|
||||||
import com.aoleyun.sn.utils.TimeUtils;
|
import com.aoleyun.sn.utils.TimeUtils;
|
||||||
import com.aoleyun.sn.utils.ToastUtil;
|
import com.aoleyun.sn.utils.ToastUtil;
|
||||||
@@ -294,7 +297,7 @@ public class NetInterfaceManager {
|
|||||||
return mRetrofit.create(MACAddressApi.class)
|
return mRetrofit.create(MACAddressApi.class)
|
||||||
.sendMACaddress(Utils.getSerial(mContext),
|
.sendMACaddress(Utils.getSerial(mContext),
|
||||||
Utils.getAndroid10MAC(mContext),
|
Utils.getAndroid10MAC(mContext),
|
||||||
"0000",
|
MMKV.defaultMMKV().decodeString("XGPushtoken", "未知"),
|
||||||
// JPushInterface.getRegistrationID(mContext),
|
// JPushInterface.getRegistrationID(mContext),
|
||||||
Utils.getCustomVersion(),
|
Utils.getCustomVersion(),
|
||||||
BuildConfig.VERSION_NAME,
|
BuildConfig.VERSION_NAME,
|
||||||
@@ -302,13 +305,17 @@ public class NetInterfaceManager {
|
|||||||
Utils.getAPPVersionName(PackageNames.DESKTOP, mContext),
|
Utils.getAPPVersionName(PackageNames.DESKTOP, mContext),
|
||||||
Utils.getAndroid7MAC(),
|
Utils.getAndroid7MAC(),
|
||||||
Utils.obtainWifiInfo(mContext),
|
Utils.obtainWifiInfo(mContext),
|
||||||
(String) SPUtils.get(mContext, "PublicIP", ""),
|
mMMKV.decodeString(NetInterfaceManager.PublicIP, ""),
|
||||||
Utils.getIPAddress(mContext),
|
Utils.getIPAddress(mContext),
|
||||||
Utils.getBluetoothList(),
|
Utils.getBluetoothList(),
|
||||||
Utils.getWifiAlias(mContext),
|
Utils.getWifiAlias(mContext),
|
||||||
Utils.getAPPVersionName(PackageNames.BROWSER, mContext),
|
Utils.getAPPVersionName(PackageNames.BROWSER, mContext),
|
||||||
Utils.getAPPVersionName(PackageNames.NOTIFICATIONS, mContext),
|
Utils.getAPPVersionName(PackageNames.NOTIFICATIONS, mContext),
|
||||||
JGYUtils.getInstance().getAppPlatform()
|
JGYUtils.getInstance().getAppPlatform(),
|
||||||
|
mMMKV.decodeString(WHOIS_ADDR, "未知"),
|
||||||
|
NetworkUtils.getNetworkType(mContext),
|
||||||
|
NetworkUtils.getOperators(mContext),
|
||||||
|
NetworkUtils.getPhoneNumber(mContext)
|
||||||
)
|
)
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread());
|
.observeOn(AndroidSchedulers.mainThread());
|
||||||
@@ -1724,21 +1731,41 @@ public class NetInterfaceManager {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String macJson;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发送mac地址本机信息
|
* 发送mac地址本机信息
|
||||||
*
|
*
|
||||||
* @param lifecycle
|
* @param lifecycle
|
||||||
* @param callback
|
* @param callback
|
||||||
*/
|
*/
|
||||||
public void sendMACAddress(BehaviorSubject<ActivityEvent> lifecycle, onCompleteCallback callback) {
|
public void sendMACAddress(boolean refresh, BehaviorSubject<ActivityEvent> lifecycle, onCompleteCallback callback) {
|
||||||
String macJson = (String) SPUtils.get(mContext, "macJson", "");
|
macJson = (String) SPUtils.get(mContext, "macJson", "");
|
||||||
String jsonString = JGYUtils.getInstance().getMacJson(mContext);
|
String macJsonString = JGYUtils.getInstance().getMacJson(mContext);
|
||||||
// Log.e(TAG, "sendMACAddress: macJson = " + macJson);
|
|
||||||
// Log.e(TAG, "sendMACAddress: jsonString = " + jsonString);
|
ConnectMode connectMode = ConnectMode.ONE_HOUR;
|
||||||
if (macJson.equals(jsonString)) {
|
if (refresh) {
|
||||||
callback.onComplete();
|
connectMode = ConnectMode.DEFAULT;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
if (ConnectManager.getInstance().isNeedConnect(UrlAddress.SEND_DEVICES, connectMode)) {
|
||||||
|
if (macJson.equals(macJsonString)) {
|
||||||
|
callback.onComplete();
|
||||||
|
} else {
|
||||||
|
sendMACAddress(lifecycle, callback);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String jsonString = cacheHelper.getAsString(UrlAddress.SEND_DEVICES);
|
||||||
|
//为 "" 是已经请求成功的
|
||||||
|
if (jsonString == null) {
|
||||||
|
sendMACAddress(lifecycle, callback);
|
||||||
|
} else {
|
||||||
|
callback.onComplete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendMACAddress(BehaviorSubject<ActivityEvent> lifecycle, onCompleteCallback callback) {
|
||||||
sendMACAddressObservable()
|
sendMACAddressObservable()
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(Schedulers.io())
|
||||||
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
||||||
@@ -1751,8 +1778,9 @@ public class NetInterfaceManager {
|
|||||||
@Override
|
@Override
|
||||||
public void onNext(@NonNull BaseResponse response) {
|
public void onNext(@NonNull BaseResponse response) {
|
||||||
if (response.code == OK) {
|
if (response.code == OK) {
|
||||||
|
cacheHelper.put(UrlAddress.SEND_DEVICES, macJson);
|
||||||
Log.e("sendMACAddress", response.msg);
|
Log.e("sendMACAddress", response.msg);
|
||||||
SPUtils.put(mContext, "macJson", JGYUtils.getInstance().getMacJson(mContext));
|
SPUtils.put(mContext, "macJson", macJson);
|
||||||
} else {
|
} else {
|
||||||
Log.e("sendMACAddress", response.toString());
|
Log.e("sendMACAddress", response.toString());
|
||||||
}
|
}
|
||||||
@@ -1774,6 +1802,7 @@ public class NetInterfaceManager {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
synchronized public void setPushTags(boolean refresh, BehaviorSubject<ActivityEvent> lifecycle, onCompleteCallback callback) {
|
synchronized public void setPushTags(boolean refresh, BehaviorSubject<ActivityEvent> lifecycle, onCompleteCallback callback) {
|
||||||
ConnectMode connectMode = ConnectMode.ONE_HOUR;
|
ConnectMode connectMode = ConnectMode.ONE_HOUR;
|
||||||
if (refresh) {
|
if (refresh) {
|
||||||
@@ -3064,9 +3093,10 @@ public class NetInterfaceManager {
|
|||||||
|
|
||||||
public interface PublicIP {
|
public interface PublicIP {
|
||||||
void set(String ip);
|
void set(String ip);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static final String PublicIP = "PublicIP";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取设备公网IP
|
* 获取设备公网IP
|
||||||
*
|
*
|
||||||
@@ -3121,8 +3151,48 @@ public class NetInterfaceManager {
|
|||||||
@Override
|
@Override
|
||||||
public void onComplete() {
|
public void onComplete() {
|
||||||
Log.e("getPublicIP", "onComplete: ");
|
Log.e("getPublicIP", "onComplete: ");
|
||||||
|
MMKV.defaultMMKV().encode(NetInterfaceManager.PublicIP, IpAddr);
|
||||||
publicIP.set(IpAddr);
|
publicIP.set(IpAddr);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static final String WHOIS_ADDR = "whois_ip_addr";
|
||||||
|
|
||||||
|
public static void GetWhois() {
|
||||||
|
Retrofit retrofit = new Retrofit.Builder()
|
||||||
|
.client(NetInterfaceManager.getInstance().getOkHttpClient())
|
||||||
|
.baseUrl(UrlAddress.PCONLINE_WHOIS)
|
||||||
|
.addConverterFactory(GsonConverterFactory.create())
|
||||||
|
.addCallAdapterFactory(RxJava3CallAdapterFactory.create())
|
||||||
|
.build();
|
||||||
|
retrofit.create(GetWhoisApi.class)
|
||||||
|
.getWhois(true)
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(new Observer<WhoisBean>() {
|
||||||
|
@Override
|
||||||
|
public void onSubscribe(@NonNull Disposable d) {
|
||||||
|
Log.e("GetWhois", "onSubscribe: ");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNext(@NonNull WhoisBean whoisBean) {
|
||||||
|
Log.e("GetWhois", "onNext: " + whoisBean);
|
||||||
|
if (whoisBean != null && !TextUtils.isEmpty(whoisBean.getAddr())) {
|
||||||
|
MMKV.defaultMMKV().encode(WHOIS_ADDR, whoisBean.getAddr());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(@NonNull Throwable e) {
|
||||||
|
Log.e("GetWhois", "onError: ");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onComplete() {
|
||||||
|
Log.e("GetWhois", "onComplete: ");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -118,6 +118,10 @@ public class UrlAddress {
|
|||||||
|
|
||||||
/*获取公网IP*/
|
/*获取公网IP*/
|
||||||
public static final String SHOUHU_CITYJSON = "http://pv.sohu.com/cityjson/";
|
public static final String SHOUHU_CITYJSON = "http://pv.sohu.com/cityjson/";
|
||||||
|
/*通过ip获取信息*/
|
||||||
|
public static final String PCONLINE_WHOIS = "http://whois.pconline.com.cn/";
|
||||||
|
public static final String WHOIS = "ipJson.jsp";
|
||||||
|
|
||||||
|
|
||||||
/*删除alias*/
|
/*删除alias*/
|
||||||
public static final String DELETE_JPUSH_ALIAS = "https://device.jpush.cn/v3/aliases/";
|
public static final String DELETE_JPUSH_ALIAS = "https://device.jpush.cn/v3/aliases/";
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
package com.aoleyun.sn.network.api.get;
|
package com.aoleyun.sn.network.api;
|
||||||
|
|
||||||
import com.aoleyun.sn.bean.BaseResponse;
|
|
||||||
import com.aoleyun.sn.network.UrlAddress;
|
import com.aoleyun.sn.network.UrlAddress;
|
||||||
|
|
||||||
import io.reactivex.rxjava3.core.Observable;
|
import io.reactivex.rxjava3.core.Observable;
|
||||||
import okhttp3.ResponseBody;
|
import okhttp3.ResponseBody;
|
||||||
import retrofit2.http.GET;
|
import retrofit2.http.GET;
|
||||||
import retrofit2.http.Query;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author : fanhuitong
|
* @author : fanhuitong
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package com.aoleyun.sn.network.api;
|
||||||
|
|
||||||
|
import com.aoleyun.sn.bean.WhoisBean;
|
||||||
|
import com.aoleyun.sn.network.UrlAddress;
|
||||||
|
|
||||||
|
import io.reactivex.rxjava3.core.Observable;
|
||||||
|
import okhttp3.ResponseBody;
|
||||||
|
import retrofit2.http.GET;
|
||||||
|
import retrofit2.http.Query;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author : fanhuitong
|
||||||
|
* e-mail :
|
||||||
|
* @date : 2021/10/1814:39
|
||||||
|
* desc :
|
||||||
|
* version: 1.0
|
||||||
|
*/
|
||||||
|
public interface GetWhoisApi {
|
||||||
|
@GET(UrlAddress.WHOIS)
|
||||||
|
Observable<WhoisBean> getWhois(
|
||||||
|
@Query("json") boolean json
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -29,6 +29,10 @@ public interface MACAddressApi {
|
|||||||
@Field("wifi_name") String wifi_name,
|
@Field("wifi_name") String wifi_name,
|
||||||
@Field("browser_version") String browser_version,
|
@Field("browser_version") String browser_version,
|
||||||
@Field("notice_version") String notice_version,
|
@Field("notice_version") String notice_version,
|
||||||
@Field("platform") String platform
|
@Field("platform") String platform,
|
||||||
|
@Field("wifi_operator") String wifi_operator,
|
||||||
|
@Field("network_type") String network_type,
|
||||||
|
@Field("network_operator") String network_operator,
|
||||||
|
@Field("sn_phone") String sn_phone
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.aoleyun.sn.network.interceptor;
|
|||||||
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import com.aoleyun.sn.BuildConfig;
|
||||||
import com.aoleyun.sn.utils.MD5Util;
|
import com.aoleyun.sn.utils.MD5Util;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@@ -30,7 +31,7 @@ public class RepeatRequestInterceptor implements Interceptor {
|
|||||||
long time = System.currentTimeMillis();//请求时间
|
long time = System.currentTimeMillis();//请求时间
|
||||||
try {
|
try {
|
||||||
if (requestIdsMap.size() > 0 && requestIdsMap.containsKey(requestKey)) {
|
if (requestIdsMap.size() > 0 && requestIdsMap.containsKey(requestKey)) {
|
||||||
Log.e("REPEAT-REQUEST", "重复请求:" + requestKey + " Method @" + request.method() + " --- " + " URL = " + request.url() + "\t" + bodyToString(request));
|
log(requestKey, request);
|
||||||
//下面这行写了不会抛出onerror
|
//下面这行写了不会抛出onerror
|
||||||
// chain.call().cancel();
|
// chain.call().cancel();
|
||||||
return new Response.Builder()
|
return new Response.Builder()
|
||||||
@@ -39,7 +40,7 @@ public class RepeatRequestInterceptor implements Interceptor {
|
|||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
requestIdsMap.put(requestKey, time);
|
requestIdsMap.put(requestKey, time);
|
||||||
Log.e("REPEAT-REQUEST", "注册请求:" + requestKey + " Method @" + request.method() + " --- " + " URL = " + request.url() + "\t" + bodyToString(request));
|
log(requestKey, request);
|
||||||
// RepeatRequestInterceptor.Builder builder = request.newBuilder();
|
// RepeatRequestInterceptor.Builder builder = request.newBuilder();
|
||||||
// builder.addHeader("header", jsonObject.toString());
|
// builder.addHeader("header", jsonObject.toString());
|
||||||
return chain.proceed(request);
|
return chain.proceed(request);
|
||||||
@@ -49,18 +50,26 @@ public class RepeatRequestInterceptor implements Interceptor {
|
|||||||
} finally {
|
} finally {
|
||||||
if (requestIdsMap.containsKey(requestKey) && requestIdsMap.containsValue(time)) {//请求任务完成删除map中的数据
|
if (requestIdsMap.containsKey(requestKey) && requestIdsMap.containsValue(time)) {//请求任务完成删除map中的数据
|
||||||
requestIdsMap.remove(requestKey);
|
requestIdsMap.remove(requestKey);
|
||||||
Log.e("REPEAT-REQUEST", "移除请求:" + requestKey + " Method @" + request.method() + " --- " + " URL = " + request.url() + "\t" + bodyToString(request));
|
log(requestKey, request);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String bodyToString(final Request request){
|
private void log(String requestKey, Request request) {
|
||||||
|
if (BuildConfig.DEBUG) {
|
||||||
|
Log.e("REPEAT-REQUEST", "移除请求:" + requestKey + " Method @" + request.method() + " --- " + " URL = " + request.url() + "\t" + bodyToString(request));
|
||||||
|
} else {
|
||||||
|
Log.e("REPEAT-REQUEST", "移除请求:" + requestKey + " Method @" + request.method());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String bodyToString(final Request request) {
|
||||||
try {
|
try {
|
||||||
final Request copy = request.newBuilder().build();
|
final Request copy = request.newBuilder().build();
|
||||||
final Buffer buffer = new Buffer();
|
final Buffer buffer = new Buffer();
|
||||||
copy.body().writeTo(buffer);
|
copy.body().writeTo(buffer);
|
||||||
return buffer.readUtf8();
|
return buffer.readUtf8();
|
||||||
} catch ( Exception e) {
|
} catch (Exception e) {
|
||||||
return "-";
|
return "-";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ public class MainSPresenter implements MainSContact.Presenter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendMACAddress() {
|
public void sendMACAddress() {
|
||||||
NetInterfaceManager.getInstance().sendMACAddress(getLifecycle(), new NetInterfaceManager.onCompleteCallback() {
|
NetInterfaceManager.getInstance().sendMACAddress(true, getLifecycle(), new NetInterfaceManager.onCompleteCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onComplete() {
|
public void onComplete() {
|
||||||
mView.sendMACFinish();
|
mView.sendMACFinish();
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ import com.aoleyun.sn.service.GuardService;
|
|||||||
import com.aoleyun.sn.service.LogcatService;
|
import com.aoleyun.sn.service.LogcatService;
|
||||||
import com.aoleyun.sn.service.main.MainService;
|
import com.aoleyun.sn.service.main.MainService;
|
||||||
import com.aoleyun.sn.service.StepService;
|
import com.aoleyun.sn.service.StepService;
|
||||||
|
import com.tencent.mmkv.MMKV;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
@@ -1965,7 +1966,7 @@ public class JGYUtils {
|
|||||||
jsonObject.addProperty("desktop_version", Utils.getAPPVersionName("com.aoleyun.os", mContext));
|
jsonObject.addProperty("desktop_version", Utils.getAPPVersionName("com.aoleyun.os", mContext));
|
||||||
jsonObject.addProperty("local_mac", Utils.getAndroid7MAC());
|
jsonObject.addProperty("local_mac", Utils.getAndroid7MAC());
|
||||||
// jsonObject.addProperty("wifi_status", Utils.obtainWifiInfo(mContext));
|
// 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("LAN_ip", Utils.getIPAddress(mContext));
|
||||||
jsonObject.addProperty("bluetooth", Utils.getBluetoothList());
|
jsonObject.addProperty("bluetooth", Utils.getBluetoothList());
|
||||||
jsonObject.addProperty("wifi_name", Utils.getWifiAlias(mContext));
|
jsonObject.addProperty("wifi_name", Utils.getWifiAlias(mContext));
|
||||||
|
|||||||
@@ -1,15 +1,31 @@
|
|||||||
package com.aoleyun.sn.utils;
|
package com.aoleyun.sn.utils;
|
||||||
|
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.net.ConnectivityManager;
|
import android.net.ConnectivityManager;
|
||||||
import android.net.NetworkCapabilities;
|
import android.net.NetworkCapabilities;
|
||||||
import android.net.NetworkInfo;
|
import android.net.NetworkInfo;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
import android.telephony.CellInfo;
|
||||||
import android.telephony.TelephonyManager;
|
import android.telephony.TelephonyManager;
|
||||||
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author fanhuitong
|
||||||
|
*/
|
||||||
public class NetworkUtils {
|
public class NetworkUtils {
|
||||||
|
private static String TAG = NetworkUtils.class.getSimpleName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 网络是否连接
|
||||||
|
*
|
||||||
|
* @param context
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public static boolean isConnected(Context context) {
|
public static boolean isConnected(Context context) {
|
||||||
ConnectivityManager mConnectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
ConnectivityManager mConnectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
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";
|
String strNetworkType = "UnKnown";
|
||||||
final NetworkInfo activeNetworkInfo = ((ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE)).getActiveNetworkInfo();
|
final NetworkInfo activeNetworkInfo = ((ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE)).getActiveNetworkInfo();
|
||||||
if (activeNetworkInfo != null && activeNetworkInfo.getType() == 1) {
|
if (activeNetworkInfo != null && activeNetworkInfo.getType() == 1) {
|
||||||
@@ -67,7 +89,49 @@ public class NetworkUtils {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Log.e(TAG, "getNetworkType: " + strNetworkType);
|
||||||
return 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.common.BitMatrix;
|
||||||
import com.google.zxing.qrcode.QRCodeWriter;
|
import com.google.zxing.qrcode.QRCodeWriter;
|
||||||
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
|
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
|
||||||
|
import com.tencent.mmkv.MMKV;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
@@ -1649,7 +1650,6 @@ public class Utils {
|
|||||||
NetInterfaceManager.getPublicIP(new NetInterfaceManager.PublicIP() {
|
NetInterfaceManager.getPublicIP(new NetInterfaceManager.PublicIP() {
|
||||||
@Override
|
@Override
|
||||||
public void set(String ip) {
|
public void set(String ip) {
|
||||||
SPUtils.put(context, "PublicIP", ip);
|
|
||||||
Log.e("getPublicIP", "set: " + ip);
|
Log.e("getPublicIP", "set: " + ip);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user