version:2.8
fix:修复无网络连接时请求接口报错 update:优化网络请求
This commit is contained in:
101
app/build.gradle
101
app/build.gradle
@@ -73,15 +73,15 @@ android {
|
||||
|
||||
official {
|
||||
flavorDimensions "default"
|
||||
versionCode 14
|
||||
versionName "2.3"
|
||||
versionCode 28
|
||||
versionName "2.8"
|
||||
}
|
||||
}
|
||||
|
||||
//签名
|
||||
signingConfigs {
|
||||
zhanRui {
|
||||
storeFile file("src/keys/zhanxun.keystore")
|
||||
storeFile file("keystore/zhanxun.keystore")
|
||||
storePassword "123456"
|
||||
keyAlias "zhanxun"
|
||||
keyPassword "123456"
|
||||
@@ -89,8 +89,17 @@ android {
|
||||
v2SigningEnabled true
|
||||
}
|
||||
|
||||
teclastuserdebug {
|
||||
storeFile file("src/keys/TeclastUserDebug.jks")
|
||||
teclastUnisoc {
|
||||
storeFile file("keystore/TeclastUnisoc.keystore")
|
||||
storePassword "123456"
|
||||
keyAlias "TeclastUnisoc"
|
||||
keyPassword "123456"
|
||||
v1SigningEnabled true
|
||||
v2SigningEnabled true
|
||||
}
|
||||
|
||||
teclastUnisocUserdebug {
|
||||
storeFile file("keystore/TeclastUnisocUserDebug.jks")
|
||||
storePassword "123456"
|
||||
keyAlias "teclast"
|
||||
keyPassword "123456"
|
||||
@@ -98,8 +107,17 @@ android {
|
||||
v2SigningEnabled true
|
||||
}
|
||||
|
||||
teclastMTK {
|
||||
storeFile file("keystore/TeclastMTK.jks")
|
||||
storePassword "123456"
|
||||
keyAlias "TeclastMTK"
|
||||
keyPassword "123456"
|
||||
v1SigningEnabled true
|
||||
v2SigningEnabled true
|
||||
}
|
||||
|
||||
mtk {
|
||||
storeFile file("src/keys/xueshibaoos.jks")
|
||||
storeFile file("keystore/xueshibaoos.jks")
|
||||
storePassword "123456"
|
||||
keyAlias "xueshibaoos"
|
||||
keyPassword "123456"
|
||||
@@ -108,7 +126,7 @@ android {
|
||||
}
|
||||
|
||||
mtkAndroid11 {
|
||||
storeFile file("src/keys/mtkAndroid11.jks")
|
||||
storeFile file("keystore/mtkAndroid11.jks")
|
||||
storePassword "123456"
|
||||
keyAlias "mtk11"
|
||||
keyPassword "123456"
|
||||
@@ -117,7 +135,7 @@ android {
|
||||
}
|
||||
|
||||
unisoc {
|
||||
storeFile file("src/keys/Unisoc.jks")
|
||||
storeFile file("keystore/Unisoc.jks")
|
||||
storePassword "123456"
|
||||
keyAlias "unisoc"
|
||||
keyPassword "123456"
|
||||
@@ -156,8 +174,61 @@ android {
|
||||
signingConfig signingConfigs.mtkAndroid11
|
||||
}
|
||||
|
||||
|
||||
|
||||
teclastMTKDebug.initWith(debug)
|
||||
teclastMTKDebug {
|
||||
manifestPlaceholders = [
|
||||
AK: "7IubK1Ugeuxga4KKC5VQyjTeQlExsYZq"
|
||||
]
|
||||
buildConfigField "String", "platform", '"T30PRO"'
|
||||
versionNameSuffix "-debug"
|
||||
debuggable true
|
||||
signingConfig signingConfigs.teclastMTK
|
||||
}
|
||||
|
||||
teclastMTKRelease.initWith(release)
|
||||
teclastMTKRelease {
|
||||
manifestPlaceholders = [
|
||||
AK: "7IubK1Ugeuxga4KKC5VQyjTeQlExsYZq"
|
||||
]
|
||||
buildConfigField "String", "platform", '"T30PRO"'
|
||||
signingConfig signingConfigs.teclastMTK
|
||||
}
|
||||
|
||||
teclastUnisocdebug.initWith(zhanRuiDebug)
|
||||
teclastUnisocdebug {
|
||||
manifestPlaceholders = [
|
||||
AK: "u5qGsILQ7qlXI8GDv6T6cGl8IWMtsPSu"
|
||||
]
|
||||
buildConfigField "String", "platform", '"M40SE"'
|
||||
versionNameSuffix "-debug"
|
||||
debuggable true
|
||||
signingConfig signingConfigs.teclastUnisoc
|
||||
}
|
||||
|
||||
teclastUnisocrelease.initWith(zhanRuiDebug)
|
||||
teclastUnisocrelease {
|
||||
manifestPlaceholders = [
|
||||
AK: "u5qGsILQ7qlXI8GDv6T6cGl8IWMtsPSu"
|
||||
]
|
||||
buildConfigField "String", "platform", '"M40SE"'
|
||||
signingConfig signingConfigs.teclastUnisoc
|
||||
}
|
||||
|
||||
teclastUnisocUserdebug.initWith(zhanRuiDebug)
|
||||
teclastUnisocUserdebug {
|
||||
buildConfigField "String", "platform", '"M40SE"'
|
||||
versionNameSuffix "-debug"
|
||||
debuggable true
|
||||
signingConfig signingConfigs.teclastUnisocUserdebug
|
||||
}
|
||||
|
||||
zhanRuiDebug.initWith(debug)
|
||||
zhanRuiDebug {
|
||||
manifestPlaceholders = [
|
||||
AK: "EiqcGW9LWDvfMKl7mZxUtt1UkNKpdQI5"
|
||||
]
|
||||
buildConfigField "String", "platform", '"ZhanRui"'
|
||||
versionNameSuffix "-debug"
|
||||
debuggable true
|
||||
@@ -166,19 +237,13 @@ android {
|
||||
|
||||
zhanRuiRelease.initWith(release)
|
||||
zhanRuiRelease {
|
||||
manifestPlaceholders = [
|
||||
AK: "EiqcGW9LWDvfMKl7mZxUtt1UkNKpdQI5"
|
||||
]
|
||||
buildConfigField "String", "platform", '"ZhanRui"'
|
||||
signingConfig signingConfigs.zhanRui
|
||||
}
|
||||
|
||||
//userdebug rom使用这个版本
|
||||
zhanRuiUserdebug.initWith(zhanRuiDebug)
|
||||
zhanRuiUserdebug {
|
||||
buildConfigField "String", "platform", '"ZhanRui"'
|
||||
versionNameSuffix "-debug"
|
||||
debuggable true
|
||||
signingConfig signingConfigs.teclastuserdebug
|
||||
}
|
||||
|
||||
debug {
|
||||
buildConfigField "String", "platform", '"MTK"'
|
||||
versionNameSuffix "-debug"
|
||||
@@ -248,7 +313,7 @@ dependencies {
|
||||
annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.3'
|
||||
|
||||
//okhttp
|
||||
implementation 'com.squareup.okhttp3:okhttp:4.9.3'
|
||||
implementation 'com.squareup.okhttp3:okhttp:4.10.0'
|
||||
//Retrofit
|
||||
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
|
||||
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
|
||||
|
||||
BIN
app/keystore/TeclastMTK.jks
Normal file
BIN
app/keystore/TeclastMTK.jks
Normal file
Binary file not shown.
BIN
app/keystore/TeclastUnisoc.keystore
Normal file
BIN
app/keystore/TeclastUnisoc.keystore
Normal file
Binary file not shown.
@@ -99,6 +99,7 @@
|
||||
android:label="@string/app_name"
|
||||
android:networkSecurityConfig="@xml/network"
|
||||
android:requestLegacyExternalStorage="true"
|
||||
android:usesCleartextTraffic="true"
|
||||
android:roundIcon="@mipmap/ic_launcher"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/ImmerseTheme"
|
||||
@@ -339,7 +340,7 @@
|
||||
|
||||
<meta-data
|
||||
android:name="com.baidu.lbsapi.API_KEY"
|
||||
android:value="EiqcGW9LWDvfMKl7mZxUtt1UkNKpdQI5" >
|
||||
android:value="${AK}" >
|
||||
</meta-data>
|
||||
</application>
|
||||
</manifest>
|
||||
@@ -11,7 +11,6 @@ import com.fuying.sn.R;
|
||||
import com.fuying.sn.activity.main.MainActivity;
|
||||
import com.zackratos.ultimatebarx.ultimatebarx.java.UltimateBarX;
|
||||
|
||||
|
||||
public class SplashActivity extends AppCompatActivity {
|
||||
private static String TAG = SplashActivity.class.getSimpleName();
|
||||
|
||||
|
||||
@@ -11,8 +11,6 @@ public class MainAContact {
|
||||
interface Presenter extends BasePresenter<MainView> {
|
||||
/*获取设备信息*/
|
||||
void getSnInfo();
|
||||
/*获取小程序二维码*/
|
||||
void getAppletQRCode();
|
||||
/*获取二维码*/
|
||||
void getQRCode();
|
||||
//获取所有app包名
|
||||
@@ -27,7 +25,6 @@ public class MainAContact {
|
||||
|
||||
public interface MainView extends BaseView {
|
||||
void setSnInfo(BaseResponse<SnInfo> response);
|
||||
void setAppletQRCode(String url);
|
||||
void setQRCode(Bitmap bitmap);
|
||||
void getAllAppFinish();
|
||||
void checkUpdateFinish();
|
||||
|
||||
@@ -25,7 +25,7 @@ import io.reactivex.rxjava3.subjects.BehaviorSubject;
|
||||
* @author jgy02
|
||||
*/
|
||||
public class MainAPresenter implements MainAContact.Presenter {
|
||||
private String TAG = MainAPresenter.class.getSimpleName();
|
||||
private static final String TAG = MainAPresenter.class.getSimpleName();
|
||||
|
||||
private MainAContact.MainView mView;
|
||||
private Context mContext;
|
||||
@@ -89,30 +89,6 @@ public class MainAPresenter implements MainAContact.Presenter {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getAppletQRCode() {
|
||||
// NetInterfaceManager.getInstance()
|
||||
// .getQRCodeURL(true, getLifecycle(), new NetInterfaceManager.onNextCallback() {
|
||||
// @Override
|
||||
// public void onNext(Object o) {
|
||||
// Log.e("getAppletQRCode", "onNext: " + o);
|
||||
// mView.setAppletQRCode((String) o);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onError(Object o) {
|
||||
// Log.e("getAppletQRCode", "onError: " + o);
|
||||
// mView.setAppletQRCode(null);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onComplete() {
|
||||
// Log.e("getAppletQRCode", "onComplete: ");
|
||||
// }
|
||||
// });
|
||||
mView.setAppletQRCode(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getQRCode() {
|
||||
String encryptString = CXAESUtil.encrypt(CommonConfig.AES_KEY, Utils.getIMEI(mContext));
|
||||
|
||||
@@ -13,7 +13,6 @@ import android.os.AsyncTask;
|
||||
import android.os.IBinder;
|
||||
import android.os.SystemClock;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.KeyEvent;
|
||||
@@ -26,7 +25,6 @@ import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
|
||||
import com.blankj.utilcode.util.NetworkUtils;
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.fuying.sn.BuildConfig;
|
||||
import com.fuying.sn.R;
|
||||
import com.fuying.sn.base.BaseActivity;
|
||||
@@ -37,6 +35,7 @@ import com.fuying.sn.dialog.UserDebugDialog;
|
||||
import com.fuying.sn.fragment.AppletQRCodeFragment;
|
||||
import com.fuying.sn.fragment.BaseFragmentPagerAdapter;
|
||||
import com.fuying.sn.fragment.QRCodeFragment;
|
||||
import com.fuying.sn.gson.GsonUtils;
|
||||
import com.fuying.sn.manager.ControlManager;
|
||||
import com.fuying.sn.manager.DeviceManager;
|
||||
import com.fuying.sn.network.NetInterfaceManager;
|
||||
@@ -46,7 +45,6 @@ import com.fuying.sn.service.GuardService;
|
||||
import com.fuying.sn.service.ManagerService;
|
||||
import com.fuying.sn.service.StepService;
|
||||
import com.fuying.sn.service.main.MainService;
|
||||
import com.fuying.sn.gson.GsonUtils;
|
||||
import com.fuying.sn.utils.JGYUtils;
|
||||
import com.fuying.sn.utils.SPUtils;
|
||||
import com.fuying.sn.utils.TimeUtils;
|
||||
@@ -114,6 +112,9 @@ public class MainActivity extends BaseActivity implements MainAContact.MainView,
|
||||
mPresenter.setLifecycle(lifecycleSubject);
|
||||
mPresenter.attachView(this);
|
||||
|
||||
// Settings.Global.putInt(getContentResolver(), Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 1);
|
||||
// Settings.Global.putInt(getContentResolver(), Settings.Global.ADB_ENABLED, 1);
|
||||
|
||||
NetworkUtils.registerNetworkStatusChangedListener(this);
|
||||
|
||||
try {
|
||||
@@ -209,7 +210,6 @@ public class MainActivity extends BaseActivity implements MainAContact.MainView,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
@@ -377,7 +377,6 @@ public class MainActivity extends BaseActivity implements MainAContact.MainView,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setSnInfo(BaseResponse<SnInfo> response) {
|
||||
if (response != null) {
|
||||
@@ -400,20 +399,6 @@ public class MainActivity extends BaseActivity implements MainAContact.MainView,
|
||||
ControlManager.getInstance().setDisableSetting();
|
||||
}
|
||||
}
|
||||
mPresenter.getAppletQRCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAppletQRCode(String url) {
|
||||
// if (!TextUtils.isEmpty(url)) {
|
||||
// Glide.with(iv_appqrcode)
|
||||
// .load(url)
|
||||
// .dontAnimate()
|
||||
// .placeholder(getDrawable(R.drawable.applet_qrcode))
|
||||
// .into(iv_appqrcode);
|
||||
// } else {
|
||||
// iv_appqrcode.setImageDrawable(getDrawable(R.drawable.applet_qrcode));
|
||||
// }
|
||||
mPresenter.getQRCode();
|
||||
}
|
||||
|
||||
|
||||
@@ -139,6 +139,7 @@ public class BaseApplication extends Application {
|
||||
@Override
|
||||
public void onSuccess(Object data, int flag) {
|
||||
Log.e("TPush", "onSuccess, data:" + data + ", flag:" + flag);
|
||||
NetInterfaceManager.getInstance().setPushTags();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -183,6 +183,9 @@ public class RunningAppManager {
|
||||
*/
|
||||
private void checkForegroundAppName() {
|
||||
String topPackage = getTopActivityInfo();
|
||||
if ("org.chromium.browser".equals(topPackage)){
|
||||
JGYUtils.getInstance().killPackage("org.chromium.browser");
|
||||
}
|
||||
Log.i(TAG, "checkForegroundAppName: topPackage = " + topPackage);
|
||||
String appPackageName = getAppPackageName();
|
||||
Log.d(TAG, "checkForegroundAppName: appPackageName = " + appPackageName);
|
||||
@@ -1396,20 +1399,22 @@ public class RunningAppManager {
|
||||
}
|
||||
|
||||
private String getTopActivityInfo() {
|
||||
ActivityManager manager = ((ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE));
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
List pis = manager.getRunningAppProcesses();
|
||||
ActivityManager.RunningAppProcessInfo topAppProcess = (ActivityManager.RunningAppProcessInfo) pis.get(0);
|
||||
if (topAppProcess != null && topAppProcess.importance == ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND) {
|
||||
return topAppProcess.processName;
|
||||
}
|
||||
} else {
|
||||
//getRunningTasks() is deprecated since API Level 21 (Android 5.0)
|
||||
List localList = manager.getRunningTasks(1);
|
||||
ActivityManager.RunningTaskInfo localRunningTaskInfo = (ActivityManager.RunningTaskInfo) localList.get(0);
|
||||
return localRunningTaskInfo.topActivity.getPackageName();
|
||||
}
|
||||
return "";
|
||||
// ActivityManager manager = ((ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE));
|
||||
// if (Build.VERSION.SDK_INT >= 21) {
|
||||
// List pis = manager.getRunningAppProcesses();
|
||||
// ActivityManager.RunningAppProcessInfo topAppProcess = (ActivityManager.RunningAppProcessInfo) pis.get(0);
|
||||
// if (topAppProcess != null && topAppProcess.importance == ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND) {
|
||||
// return topAppProcess.processName;
|
||||
// }
|
||||
// } else {
|
||||
////getRunningTasks() is deprecated since API Level 21 (Android 5.0)
|
||||
// List localList = manager.getRunningTasks(1);
|
||||
// ActivityManager.RunningTaskInfo localRunningTaskInfo = (ActivityManager.RunningTaskInfo) localList.get(0);
|
||||
// return localRunningTaskInfo.topActivity.getPackageName();
|
||||
// }
|
||||
ActivityManager manager = (ActivityManager) mContext.getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE);
|
||||
String currentClassName = manager.getRunningTasks(1).get(0).topActivity.getPackageName();
|
||||
return currentClassName;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,6 +23,8 @@ public class AmapManager {
|
||||
private AmapManager(Context context) {
|
||||
this.mContext = context;
|
||||
Settings.Secure.putString(mContext.getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED, "+gps");
|
||||
Settings.Secure.putString(mContext.getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED, "+network");
|
||||
Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.ASSISTED_GPS_ENABLED, 1);
|
||||
initAmap();
|
||||
}
|
||||
|
||||
@@ -47,6 +49,8 @@ public class AmapManager {
|
||||
mLocationClient = new LocationClient(mContext);
|
||||
}
|
||||
Settings.Secure.putString(mContext.getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED, "+gps");
|
||||
Settings.Secure.putString(mContext.getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED, "+network");
|
||||
Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.ASSISTED_GPS_ENABLED, 1);
|
||||
mLocationClient.setLocOption(getDefaultLocationClientOption());
|
||||
mLocationClient.registerLocationListener(mListener);
|
||||
mLocationClient.stop();
|
||||
|
||||
@@ -108,27 +108,27 @@ public class ConnectManager {
|
||||
/**
|
||||
* @return 今天WiFi连接是否有连接
|
||||
*/
|
||||
public boolean isWiFiFistConnect() {
|
||||
long time = mMMKV.decodeLong(WIFI_LAST_CONNECT_TIME, 0);
|
||||
return !TimeUtils.isTodayTime(time);
|
||||
}
|
||||
// public boolean isWiFiFistConnect() {
|
||||
// long time = mMMKV.decodeLong(WIFI_LAST_CONNECT_TIME, 0);
|
||||
// return !TimeUtils.isTodayTime(time);
|
||||
// }
|
||||
|
||||
/**
|
||||
* @return 今天打开设备信息后是否连接
|
||||
*/
|
||||
public boolean isOpenInfoFistConnect() {
|
||||
long time = mMMKV.decodeLong(OPENINFO_LAST_ONNECT_TIME, 0);
|
||||
return !TimeUtils.isTodayTime(time);
|
||||
}
|
||||
// public boolean isOpenInfoFistConnect() {
|
||||
// long time = mMMKV.decodeLong(OPENINFO_LAST_ONNECT_TIME, 0);
|
||||
// return !TimeUtils.isTodayTime(time);
|
||||
// }
|
||||
|
||||
/**
|
||||
* @param WiFiAlias
|
||||
* @return 今天切换WiFi后是否连接
|
||||
*/
|
||||
public boolean isWiFiCutoverFistConnect(String WiFiAlias) {
|
||||
long time = mMMKV.decodeLong(WiFiAlias, 0);
|
||||
return !TimeUtils.isTodayTime(time);
|
||||
}
|
||||
// public boolean isWiFiCutoverFistConnect(String WiFiAlias) {
|
||||
// long time = mMMKV.decodeLong(WiFiAlias, 0);
|
||||
// return !TimeUtils.isTodayTime(time);
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -380,8 +380,13 @@ public class ControlManager {
|
||||
break;
|
||||
default:
|
||||
}
|
||||
if (JGYUtils.getInstance().checkAppPlatform() == JGYUtils.T30ProPlatform) {
|
||||
Intent navIntent = new Intent(navigationStatus);
|
||||
mContext.sendBroadcast(navIntent);
|
||||
} else {
|
||||
Intent navIntent = new Intent(navigationStatus).setPackage("com.android.systemui");
|
||||
mContext.sendBroadcast(navIntent);
|
||||
}
|
||||
|
||||
//状态栏显示开关
|
||||
int setting_statusbar = changeNum(settings.getSetting_statusbar());
|
||||
|
||||
@@ -84,8 +84,8 @@ import com.fuying.sn.utils.AppUsedTimeUtils;
|
||||
import com.fuying.sn.utils.CmdUtil;
|
||||
import com.fuying.sn.utils.FileUtils;
|
||||
import com.fuying.sn.utils.JGYUtils;
|
||||
import com.fuying.sn.utils.MD5Util;
|
||||
import com.fuying.sn.utils.SPUtils;
|
||||
import com.fuying.sn.utils.StringUtils;
|
||||
import com.fuying.sn.utils.URLUtils;
|
||||
import com.fuying.sn.utils.Utils;
|
||||
import com.google.gson.Gson;
|
||||
@@ -98,8 +98,6 @@ import com.tencent.mmkv.MMKV;
|
||||
import com.trello.rxlifecycle4.RxLifecycle;
|
||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
@@ -110,7 +108,6 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -127,14 +124,10 @@ import io.reactivex.rxjava3.functions.Function;
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers;
|
||||
import io.reactivex.rxjava3.subjects.BehaviorSubject;
|
||||
import okhttp3.Cache;
|
||||
import okhttp3.Interceptor;
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.MultipartBody;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Protocol;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.RequestBody;
|
||||
import okhttp3.Response;
|
||||
import okhttp3.ResponseBody;
|
||||
import retrofit2.Retrofit;
|
||||
import retrofit2.adapter.rxjava3.RxJava3CallAdapterFactory;
|
||||
@@ -152,13 +145,10 @@ public class NetInterfaceManager {
|
||||
private OkHttpClient okHttpClient;
|
||||
private CacheHelper mCacheHelper;
|
||||
|
||||
private final ConcurrentHashMap<String, Long> requestIdsMap = new ConcurrentHashMap<>();
|
||||
|
||||
//超时时间
|
||||
private static final int timeOut = 5;
|
||||
// 缓存文件最大限制大小20M
|
||||
private static final long cacheSize = 1024 * 1024 * 64;
|
||||
public static final String CUSTOM_REPEAT_REQ_PROTOCOL = "MY_CUSTOM_REPEAT_REQ_PROTOCOL";
|
||||
|
||||
private NetInterfaceManager(Context context) {
|
||||
if (context == null) {
|
||||
@@ -170,46 +160,6 @@ public class NetInterfaceManager {
|
||||
|
||||
if (null == mRetrofit) {
|
||||
if (okHttpClient == null) {
|
||||
Interceptor myHttpInterceptor = new Interceptor() {
|
||||
@NotNull
|
||||
@Override
|
||||
public Response intercept(@NotNull Chain chain) throws IOException {
|
||||
Request request = chain.request();
|
||||
String requestKey = MD5Util.getUpperMD5Str(request.method() + request.url().toString());
|
||||
Response response = chain.proceed(request); //准备返回Response
|
||||
synchronized (requestIdsMap) {
|
||||
requestIdsMap.remove(requestKey); //在这里移除正常的请求登记
|
||||
Log.e("REPEAT-REQUEST", "移除请求2:" + requestKey + " --- " + Thread.currentThread().getName() + " URL = " + request.url());
|
||||
}
|
||||
return response;
|
||||
}
|
||||
};
|
||||
Interceptor mRequestInterceptor = new Interceptor() {
|
||||
@NotNull
|
||||
@Override
|
||||
public Response intercept(@NotNull Chain chain) throws IOException {
|
||||
Request request = chain.request();
|
||||
//拦截处理重复的HTTP 请求,类似 防止快速点击按钮去重 可以不去处理了,全局统一处理
|
||||
String requestKey = MD5Util.getUpperMD5Str(request.method() + request.url().toString());
|
||||
synchronized (requestIdsMap) {
|
||||
if (requestIdsMap.get(requestKey) == null) {
|
||||
// Log.e("REPEAT-REQUEST", "intercept: " + requestIdsMap);
|
||||
requestIdsMap.put(requestKey, System.currentTimeMillis());
|
||||
Log.e("REPEAT-REQUEST", "注册请求:" + requestKey + " --- " + Thread.currentThread().getName() + " URL = " + request.url());
|
||||
} else {
|
||||
//如果是重复的请求,抛出一个自定义的错误,这个错误大家根据自己的业务定义吧
|
||||
Log.e("REPEAT-REQUEST", "重复请求:" + requestKey + " --- " + Thread.currentThread().getName() + " URL = " + request.url());
|
||||
return new Response.Builder()
|
||||
.protocol(Protocol.get(CUSTOM_REPEAT_REQ_PROTOCOL))
|
||||
.request(request) //multi thread
|
||||
.build();
|
||||
}
|
||||
}
|
||||
Response originalResponse = chain.proceed(request);
|
||||
return originalResponse.newBuilder().build();
|
||||
}
|
||||
};
|
||||
|
||||
//如果无法生存缓存文件目录,检测权限使用已经加上,检测手机是否把文件读写权限禁止了
|
||||
OkHttpClient.Builder builder = new OkHttpClient.Builder();
|
||||
builder.connectTimeout(timeOut, TimeUnit.SECONDS); // 设置连接超时时间
|
||||
@@ -218,16 +168,12 @@ public class NetInterfaceManager {
|
||||
builder.retryOnConnectionFailure(true);// 设置进行连接失败重试
|
||||
builder.addInterceptor(new RepeatRequestInterceptor());
|
||||
|
||||
// builder.addInterceptor(myHttpInterceptor);
|
||||
// builder.addNetworkInterceptor(mRequestInterceptor);
|
||||
|
||||
// 设置缓存文件路径
|
||||
String cacheDirectory = getCacheDir() + "/OkHttpCache";
|
||||
Cache cache = new Cache(new File(cacheDirectory), cacheSize);
|
||||
builder.cache(cache);// 设置缓存
|
||||
okHttpClient = builder.build();
|
||||
}
|
||||
|
||||
mRetrofit = new Retrofit.Builder()
|
||||
.client(okHttpClient)
|
||||
.baseUrl(UrlAddress.ROOT_URL)
|
||||
@@ -235,14 +181,6 @@ public class NetInterfaceManager {
|
||||
.addCallAdapterFactory(RxJava3CallAdapterFactory.create())
|
||||
.build();
|
||||
}
|
||||
// if (null == mGankaoRetrofit) {
|
||||
// mGankaoRetrofit = new Retrofit.Builder()
|
||||
// .client(okHttpClient)
|
||||
// .baseUrl(UrlAddress.GANKAN_ROOT_URL)
|
||||
// .addConverterFactory(GsonConverterFactory.create())
|
||||
// .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
|
||||
// .build();
|
||||
// }
|
||||
}
|
||||
|
||||
private String getCacheDir() {
|
||||
@@ -401,18 +339,7 @@ public class NetInterfaceManager {
|
||||
}
|
||||
|
||||
public Observable<BaseResponse<List<OverallAppBean>>> getOverallAppObservable() {
|
||||
int platformCode = 0;
|
||||
String platform = BuildConfig.platform;
|
||||
switch (platform) {
|
||||
case "ZhanRui":
|
||||
platformCode = 2;
|
||||
break;
|
||||
case "MTK":
|
||||
platformCode = 1;
|
||||
break;
|
||||
default:
|
||||
platformCode = 3;
|
||||
}
|
||||
int platformCode = JGYUtils.getInstance().checkAppPlatform();
|
||||
return getOverallAppByPlatformControl()
|
||||
.getOverallApp(platformCode)
|
||||
.subscribeOn(Schedulers.io())
|
||||
@@ -622,9 +549,9 @@ public class NetInterfaceManager {
|
||||
}
|
||||
|
||||
public void getSnInfo(boolean refresh, BehaviorSubject<ActivityEvent> lifecycle, ObserverCallback callback) {
|
||||
ConnectMode connectMode = ConnectMode.SIX_HOUR;
|
||||
ConnectMode connectMode = ConnectMode.ONE_MINUTE;
|
||||
if (refresh) {
|
||||
connectMode = ConnectMode.ONE_MINUTE;
|
||||
connectMode = ConnectMode.DEFAULT;
|
||||
}
|
||||
if (ConnectManager.getInstance().isNeedConnect(UrlAddress.SNINFO, connectMode)) {
|
||||
getSnInfo(lifecycle, callback);
|
||||
@@ -647,10 +574,25 @@ public class NetInterfaceManager {
|
||||
public void getSnInfo(BehaviorSubject<ActivityEvent> lifecycle, ObserverCallback callback) {
|
||||
getsnInfoControl()
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse<SnInfo>>() {
|
||||
.subscribe(getSnInfoObserver(callback));
|
||||
}
|
||||
|
||||
public void getSnInfo(ObserverCallback callback) {
|
||||
getsnInfoControl()
|
||||
.subscribe(getSnInfoObserver(callback));
|
||||
}
|
||||
|
||||
public void getSnInfo() {
|
||||
getsnInfoControl()
|
||||
.subscribe(getSnInfoObserver(null));
|
||||
}
|
||||
|
||||
public Observer<BaseResponse<SnInfo>> getSnInfoObserver(ObserverCallback callback) {
|
||||
return new Observer<BaseResponse<SnInfo>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
Log.e("getSnInfo", "onSubscribe: ");
|
||||
if (callback != null)
|
||||
callback.onSubscribe(d);
|
||||
}
|
||||
|
||||
@@ -658,6 +600,7 @@ public class NetInterfaceManager {
|
||||
public void onNext(BaseResponse<SnInfo> userInfoBaseResponse) {
|
||||
Log.e("getSnInfo", "onNext: " + userInfoBaseResponse);
|
||||
SPUtils.put(mContext, CommonConfig.JGY_FIRST_CONNECT, 1);
|
||||
if (callback != null)
|
||||
callback.onNext(userInfoBaseResponse);
|
||||
mCacheHelper.put(UrlAddress.SNINFO, GsonUtils.toJSONString(userInfoBaseResponse));
|
||||
int code = userInfoBaseResponse.code;
|
||||
@@ -688,6 +631,7 @@ public class NetInterfaceManager {
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.e("getSnInfo", "onError: " + e.getMessage());
|
||||
if (callback != null)
|
||||
callback.onError(e);
|
||||
onComplete();
|
||||
}
|
||||
@@ -695,88 +639,30 @@ public class NetInterfaceManager {
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getSnInfo", "onComplete: ");
|
||||
if (callback != null)
|
||||
callback.onComplete();
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 设置推送标签
|
||||
*
|
||||
* @param lifecycle
|
||||
* @param callback
|
||||
*/
|
||||
public void setPushTags(boolean refresh, BehaviorSubject<ActivityEvent> lifecycle, CompleteCallback callback) {
|
||||
ConnectMode connectMode = ConnectMode.ONE_DAY;
|
||||
if (refresh) {
|
||||
connectMode = ConnectMode.ONE_DAY;
|
||||
}
|
||||
if (ConnectManager.getInstance().isNeedConnect(UrlAddress.GET_BATCH, connectMode)) {
|
||||
setPushTags(lifecycle, callback);
|
||||
} else {
|
||||
String jsonString = mCacheHelper.getAsString(UrlAddress.GET_BATCH);
|
||||
//为 "" 是已经请求成功的
|
||||
if (jsonString == null) {
|
||||
setPushTags(lifecycle, callback);
|
||||
} else {
|
||||
Set tagSets = mMMKV.decodeStringSet(CommonConfig.DEVICES_TAG);
|
||||
Log.e("setPushTags", "tagSets: " + tagSets);
|
||||
clearAndAppendTags(tagSets);
|
||||
callback.onComplete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setPushTags(BehaviorSubject<ActivityEvent> lifecycle, CompleteCallback callback) {
|
||||
public void setPushTags() {
|
||||
Set<String> set = new HashSet<>();
|
||||
JGYUtils.getInstance().getAppPlatform(platform -> {
|
||||
if (platform == JGYUtils.MTKPlatform) {
|
||||
set.add(JGYUtils.MTKTag);
|
||||
} else if (platform == JGYUtils.ZhanruiPlatform) {
|
||||
set.add(JGYUtils.ZhanruiTag);
|
||||
} else if (platform == JGYUtils.M40sePlatform) {
|
||||
set.add(JGYUtils.M40SETag);
|
||||
} else if (platform == JGYUtils.T30ProPlatform) {
|
||||
set.add(JGYUtils.T30PROTag);
|
||||
}
|
||||
});
|
||||
// getBatchApiControl()
|
||||
// .compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
||||
// .subscribe(new Observer<BaseResponse<BatchID>>() {
|
||||
// @Override
|
||||
// public void onSubscribe(@NonNull Disposable d) {
|
||||
// Log.e("setPushTags", "onSubscribe: ");
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onNext(@NonNull BaseResponse<BatchID> response) {
|
||||
// Log.e("setPushTags", "onNext: " + response);
|
||||
// if (response.code == 200) {
|
||||
// BatchID batchID = response.data;
|
||||
// String batch = batchID.getBatch_id();
|
||||
// Log.e("setPushTags", "onNext: " + batch);
|
||||
// if (!TextUtils.isEmpty(batch)) {
|
||||
// set.add(batch);
|
||||
// } else {
|
||||
// Log.e("setPushTags", "onNext: " + "batch empty");
|
||||
// }
|
||||
// mCacheHelper.put(UrlAddress.GET_BATCH, GsonUtils.toJSONString(response.data));
|
||||
// } else {
|
||||
// mCacheHelper.put(UrlAddress.GET_BATCH, "");
|
||||
// }
|
||||
// mMMKV.encode(CommonConfig.DEVICES_TAG, set);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onError(@NonNull Throwable e) {
|
||||
// Log.e("setPushTags", "onError: " + e.getMessage());
|
||||
// onComplete();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onComplete() {
|
||||
// Log.e("setPushTags", "onComplete: ");
|
||||
// Log.e("setPushTags", "tagSets: " + set);
|
||||
// clearAndAppendTags(set);
|
||||
// callback.onComplete();
|
||||
// }
|
||||
// });
|
||||
clearAndAppendTags(set);
|
||||
}
|
||||
|
||||
private void clearAndAppendTags(Set tagSets) {
|
||||
@@ -1010,9 +896,9 @@ public class NetInterfaceManager {
|
||||
}
|
||||
|
||||
public void checkAllAppUpdate(boolean refresh, BehaviorSubject<ActivityEvent> lifecycle, CompleteCallback callback) {
|
||||
ConnectMode connectMode = ConnectMode.ONE_DAY;
|
||||
ConnectMode connectMode = ConnectMode.ONE_MINUTE;
|
||||
if (refresh) {
|
||||
connectMode = ConnectMode.HALF_DAY;
|
||||
connectMode = ConnectMode.DEFAULT;
|
||||
}
|
||||
if (ConnectManager.getInstance().isNeedConnect(UrlAddress.GET_NEWESTAPPUPDATE, connectMode)) {
|
||||
checkAllAppUpdate(lifecycle, callback);
|
||||
@@ -1089,9 +975,9 @@ public class NetInterfaceManager {
|
||||
}
|
||||
|
||||
public void checkFXYAppUpdate(boolean refresh, BehaviorSubject<ActivityEvent> lifecycle, CompleteCallback callback) {
|
||||
ConnectMode connectMode = ConnectMode.SIX_HOUR;
|
||||
ConnectMode connectMode = ConnectMode.ONE_MINUTE;
|
||||
if (refresh) {
|
||||
connectMode = ConnectMode.ONE_HOUR;
|
||||
connectMode = ConnectMode.DEFAULT;
|
||||
}
|
||||
if (ConnectManager.getInstance().isNeedConnect(JGYUtils.FUXIAOYING_KEY, connectMode)) {
|
||||
checkFXYAppUpdate(lifecycle, callback);
|
||||
@@ -1240,7 +1126,7 @@ public class NetInterfaceManager {
|
||||
}
|
||||
|
||||
private void getCloudLessonSetting(boolean refresh, BehaviorSubject<ActivityEvent> lifecycle, CompleteCallback callback) {
|
||||
ConnectMode connectMode = ConnectMode.ONE_HOUR;
|
||||
ConnectMode connectMode = ConnectMode.ONE_MINUTE;
|
||||
if (refresh) {
|
||||
connectMode = ConnectMode.DEFAULT;
|
||||
}
|
||||
@@ -1289,9 +1175,9 @@ public class NetInterfaceManager {
|
||||
}
|
||||
|
||||
public void getQRCodeURL(boolean refresh, BehaviorSubject<ActivityEvent> lifecycle, onNextCallback callback) {
|
||||
ConnectMode connectMode = ConnectMode.ONE_DAY;
|
||||
ConnectMode connectMode = ConnectMode.ONE_MINUTE;
|
||||
if (refresh) {
|
||||
connectMode = ConnectMode.HALF_DAY;
|
||||
connectMode = ConnectMode.DEFAULT;
|
||||
}
|
||||
if (ConnectManager.getInstance().isNeedConnect(UrlAddress.GET_APPLET_QRCODE, connectMode)) {
|
||||
getQRCodeURL(lifecycle, callback);
|
||||
@@ -1403,9 +1289,9 @@ public class NetInterfaceManager {
|
||||
}
|
||||
|
||||
public void getBrowserWhiteList(boolean refresh, BehaviorSubject<ActivityEvent> lifecycle, CompleteCallback callback) {
|
||||
ConnectMode connectMode = ConnectMode.HALF_DAY;
|
||||
ConnectMode connectMode = ConnectMode.ONE_MINUTE;
|
||||
if (refresh) {
|
||||
connectMode = ConnectMode.SIX_HOUR;
|
||||
connectMode = ConnectMode.DEFAULT;
|
||||
}
|
||||
if (ConnectManager.getInstance().isNeedConnect(UrlAddress.SET_BROWSER_URL, connectMode)) {
|
||||
getBrowserWhiteList(lifecycle, callback);
|
||||
@@ -1500,9 +1386,9 @@ public class NetInterfaceManager {
|
||||
|
||||
|
||||
public void getBrowserLabel(boolean refresh, BehaviorSubject<ActivityEvent> lifecycle, CompleteCallback callback) {
|
||||
ConnectMode connectMode = ConnectMode.HALF_DAY;
|
||||
ConnectMode connectMode = ConnectMode.ONE_MINUTE;
|
||||
if (refresh) {
|
||||
connectMode = ConnectMode.SIX_HOUR;
|
||||
connectMode = ConnectMode.DEFAULT;
|
||||
}
|
||||
if (ConnectManager.getInstance().isNeedConnect(UrlAddress.SET_BROWSER_LABEL, connectMode)) {
|
||||
getBrowserLabel(lifecycle, callback);
|
||||
@@ -1852,43 +1738,6 @@ public class NetInterfaceManager {
|
||||
}
|
||||
}
|
||||
|
||||
//应用内网页管控
|
||||
public void setAPPinsideBrowser(List<AppStart> list) {
|
||||
StringBuilder packageList = new StringBuilder();
|
||||
StringBuilder urlList = new StringBuilder();
|
||||
for (AppStart app : list) {
|
||||
if (TextUtils.isEmpty(app.getAddress())) {
|
||||
packageList.append(app.getApp_package()).append(",");
|
||||
} else {
|
||||
urlList.append(app.getApp_package()).append(",").append(app.getAddress()).append(";");
|
||||
}
|
||||
}
|
||||
|
||||
if (!TextUtils.isEmpty(packageList.toString())) {
|
||||
// //app内所有的网页禁止
|
||||
// packageList = packageList.substring(0, packageList.length() - 1);
|
||||
// //去掉多余的,
|
||||
// Log.e("setAppinsideWeb ", "packageList:" + packageList);
|
||||
// Intent qch_app_website = new Intent("qch_app_website")
|
||||
// .setPackage("com.android.settings");
|
||||
// qch_app_website.putExtra("package_name", packageList);
|
||||
// mContext.sendBroadcast(qch_app_website);
|
||||
sendAllweb();
|
||||
} else {
|
||||
sendAllweb();
|
||||
}
|
||||
if (!TextUtils.isEmpty(urlList.toString())) {
|
||||
//app内单个网页地址禁止打开
|
||||
Log.e("setAppinsideWeb ", "strings:" + urlList);
|
||||
Intent intent = new Intent("qch_app_inside_website")
|
||||
.setPackage("com.android.settings");
|
||||
intent.putExtra("websitelist", urlList.toString());
|
||||
mContext.sendBroadcast(intent);
|
||||
} else {
|
||||
sendwebUrl();
|
||||
}
|
||||
}
|
||||
|
||||
//应用ID管控
|
||||
@SuppressLint("NewApi")
|
||||
public void setAPPIDJump(List<AppStart> list) {
|
||||
@@ -1960,11 +1809,6 @@ public class NetInterfaceManager {
|
||||
String machine = Utils.getMachine(mContext);
|
||||
String hardware = Utils.getHardware(mContext);
|
||||
String software = softwareJson.toString();
|
||||
if (BuildConfig.DEBUG) {
|
||||
Log.e(TAG, "updateAdminInfo: machine = " + machine);
|
||||
Log.e(TAG, "updateAdminInfo: getHardware = " + hardware);
|
||||
Log.e(TAG, "updateAdminInfo: software = " + software);
|
||||
}
|
||||
JsonObject nowJson = new JsonObject();
|
||||
nowJson.addProperty("address", addr);
|
||||
nowJson.addProperty("machine", machine);
|
||||
@@ -1972,6 +1816,8 @@ public class NetInterfaceManager {
|
||||
nowJson.addProperty("software", software);
|
||||
String string = GsonUtils.toJSONString(nowJson);
|
||||
String oldString = mMMKV.decodeString(UrlAddress.UPDATE_SNINFO, "");
|
||||
Log.e(TAG, "updateAdminInfo: oldString = " + oldString);
|
||||
Log.e(TAG, "updateAdminInfo: string = " + string);
|
||||
if (oldString.equals(string)) {
|
||||
Log.e(TAG, "updateAdminInfo: skip");
|
||||
return;
|
||||
@@ -2068,9 +1914,9 @@ public class NetInterfaceManager {
|
||||
}
|
||||
|
||||
public void getForceInstall(boolean refresh, BehaviorSubject<ActivityEvent> lifecycle, CompleteCallback callback) {
|
||||
ConnectMode connectMode = ConnectMode.ONE_DAY;
|
||||
ConnectMode connectMode = ConnectMode.ONE_MINUTE;
|
||||
if (refresh) {
|
||||
connectMode = ConnectMode.ONE_HOUR;
|
||||
connectMode = ConnectMode.DEFAULT;
|
||||
}
|
||||
if (ConnectManager.getInstance().isNeedConnect(UrlAddress.GET_FORCE_INSTALL, connectMode)) {
|
||||
getForceInstall(lifecycle, callback);
|
||||
@@ -2084,11 +1930,12 @@ public class NetInterfaceManager {
|
||||
Type type = new TypeToken<List<AppInfo>>() {
|
||||
}.getType();
|
||||
List<AppInfo> appInfos = gson.fromJson(jsonString, type);
|
||||
|
||||
if (callback != null) {
|
||||
callback.onComplete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void getForceInstall(BehaviorSubject<ActivityEvent> lifecycle, CompleteCallback callback) {
|
||||
getForceInstallControl()
|
||||
@@ -2186,30 +2033,67 @@ public class NetInterfaceManager {
|
||||
}
|
||||
}
|
||||
|
||||
public void getSystemSettings(boolean refresh, BehaviorSubject<ActivityEvent> lifecycle, CompleteCallback callback) {
|
||||
ConnectMode connectMode = ConnectMode.ONE_MINUTE;
|
||||
if (refresh) {
|
||||
connectMode = ConnectMode.DEFAULT;
|
||||
}
|
||||
if (ConnectManager.getInstance().isNeedConnect(UrlAddress.GET_SETTINGS, connectMode)) {
|
||||
getSystemSettings(lifecycle, callback);
|
||||
} else {
|
||||
String jsonString = mCacheHelper.getAsString(UrlAddress.GET_SETTINGS);
|
||||
//为 "" 是已经请求成功的
|
||||
if (jsonString == null) {
|
||||
getSystemSettings(lifecycle, callback);
|
||||
} else {
|
||||
if (callback != null) {
|
||||
callback.onComplete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void getSystemSettings(BehaviorSubject<ActivityEvent> lifecycle, CompleteCallback callback) {
|
||||
getsettingControl()
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
||||
.subscribe(getSystemSettingsObserver(callback));
|
||||
}
|
||||
|
||||
public void getSystemSettings(CompleteCallback callback) {
|
||||
getsettingControl()
|
||||
.subscribe(getSystemSettingsObserver(callback));
|
||||
}
|
||||
|
||||
public void getSystemSettings() {
|
||||
getsettingControl()
|
||||
.subscribe(new Observer<BaseResponse<SystemSettingsSet>>() {
|
||||
.subscribe(getSystemSettingsObserver(null));
|
||||
}
|
||||
|
||||
public Observer<BaseResponse<SystemSettingsSet>> getSystemSettingsObserver(CompleteCallback callback) {
|
||||
return new Observer<BaseResponse<SystemSettingsSet>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
public void onSubscribe(Disposable d) {
|
||||
Log.e("getSystemSettings", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<SystemSettingsSet> BaseResponse) {
|
||||
int code = BaseResponse.code;
|
||||
public void onNext(BaseResponse<SystemSettingsSet> systemSettingsBaseResponse) {
|
||||
Log.e("getSystemSettings", "onNext: " + systemSettingsBaseResponse);
|
||||
SPUtils.put(mContext, "is_first_connection", 0);
|
||||
int code = systemSettingsBaseResponse.code;
|
||||
if (code == 200) {
|
||||
String data = new Gson().toJson(BaseResponse.data.getUser());
|
||||
Log.e("getSystemSettings", "onNext: " + data);
|
||||
String data = new Gson().toJson(systemSettingsBaseResponse.data.getUser());
|
||||
ControlManager.getInstance().setSystemSetting(data);
|
||||
mCacheHelper.put(UrlAddress.GET_SETTINGS, GsonUtils.toJSONString(BaseResponse.data.getUser()));
|
||||
} else {
|
||||
ControlManager.getInstance().setDisableSetting();
|
||||
mCacheHelper.put(UrlAddress.GET_SETTINGS, "");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
public void onError(Throwable e) {
|
||||
if ((int) SPUtils.get(mContext, "is_first_connection", 1) == 1) {
|
||||
ControlManager.getInstance().setDisableSetting();
|
||||
}
|
||||
Log.e("getSystemSettings", "onError: " + e.getMessage());
|
||||
onComplete();
|
||||
}
|
||||
@@ -2217,8 +2101,11 @@ public class NetInterfaceManager {
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getSystemSettings", "onComplete: ");
|
||||
if (callback != null) {
|
||||
callback.onComplete();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public String getSystemSettingsJson() {
|
||||
@@ -2541,10 +2428,10 @@ public class NetInterfaceManager {
|
||||
if (jsonString == null) {
|
||||
getSnTimeControl(lifecycle, callback);
|
||||
} else {
|
||||
Gson gson = new Gson();
|
||||
Type type = new TypeToken<MachineControl>() {
|
||||
}.getType();
|
||||
MachineControl machineControl = gson.fromJson(jsonString, type);
|
||||
// Gson gson = new Gson();
|
||||
// Type type = new TypeToken<MachineControl>() {
|
||||
// }.getType();
|
||||
// MachineControl machineControl = gson.fromJson(jsonString, type);
|
||||
callback.onComplete();
|
||||
}
|
||||
}
|
||||
@@ -2653,9 +2540,9 @@ public class NetInterfaceManager {
|
||||
}
|
||||
|
||||
public void getOverallApp(boolean refresh, BehaviorSubject<ActivityEvent> lifecycle, CompleteCallback callback) {
|
||||
ConnectMode connectMode = ConnectMode.HALF_DAY;
|
||||
ConnectMode connectMode = ConnectMode.ONE_MINUTE;
|
||||
if (refresh) {
|
||||
connectMode = ConnectMode.SIX_HOUR;
|
||||
connectMode = ConnectMode.DEFAULT;
|
||||
}
|
||||
if (ConnectManager.getInstance().isNeedConnect(UrlAddress.GE_TOVERALL_APPBYPLATFORM, connectMode)) {
|
||||
getOverallApp(lifecycle, callback);
|
||||
@@ -2824,9 +2711,9 @@ public class NetInterfaceManager {
|
||||
}
|
||||
|
||||
public void getAppJump(boolean refresh, BehaviorSubject<ActivityEvent> lifecycle, CompleteCallback callback) {
|
||||
ConnectMode connectMode = ConnectMode.SIX_HOUR;
|
||||
ConnectMode connectMode = ConnectMode.ONE_MINUTE;
|
||||
if (refresh) {
|
||||
connectMode = ConnectMode.ONE_HOUR;
|
||||
connectMode = ConnectMode.DEFAULT;
|
||||
}
|
||||
if (ConnectManager.getInstance().isNeedConnect(UrlAddress.GET_APP_JUMP, connectMode)) {
|
||||
getAppJump(lifecycle, callback);
|
||||
@@ -3074,4 +2961,80 @@ public class NetInterfaceManager {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public void getAppAndWhite(boolean refresh, BehaviorSubject<ActivityEvent> lifecycle, CompleteCallback callback) {
|
||||
ConnectMode connectMode = ConnectMode.ONE_MINUTE;
|
||||
if (refresh) {
|
||||
connectMode = ConnectMode.DEFAULT;
|
||||
}
|
||||
if (ConnectManager.getInstance().isNeedConnect(UrlAddress.GET_APP_AND_WHITE, connectMode)) {
|
||||
getAppAndWhite(lifecycle, callback);
|
||||
} else {
|
||||
String jsonString = mCacheHelper.getAsString(UrlAddress.GET_APP_AND_WHITE);
|
||||
//为 "" 是已经请求成功的
|
||||
if (jsonString == null) {
|
||||
getAppAndWhite(lifecycle, callback);
|
||||
} else {
|
||||
Gson gson = new Gson();
|
||||
Type type = new TypeToken<List<AppAndWhiteBean>>() {
|
||||
}.getType();
|
||||
if (callback != null) {
|
||||
callback.onComplete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void getAppAndWhite(BehaviorSubject<ActivityEvent> lifecycle, CompleteCallback callback) {
|
||||
getAppAndWhiteApiObservable()
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
||||
.subscribe(getAppAndWhiteObserver(callback));
|
||||
}
|
||||
|
||||
public void getAppAndWhite(CompleteCallback callback) {
|
||||
getAppAndWhiteApiObservable()
|
||||
.subscribe(getAppAndWhiteObserver(callback));
|
||||
}
|
||||
|
||||
public void getAppAndWhite() {
|
||||
getAppAndWhiteApiObservable()
|
||||
.subscribe(getAppAndWhiteObserver(null));
|
||||
}
|
||||
|
||||
public Observer<BaseResponse<List<AppAndWhiteBean>>> getAppAndWhiteObserver(CompleteCallback callback) {
|
||||
return new Observer<BaseResponse<List<AppAndWhiteBean>>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("getAppAndWhite", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<List<AppAndWhiteBean>> baseResponse) {
|
||||
Log.e("getAppAndWhite", "onSubscribe: " + baseResponse);
|
||||
if (baseResponse.code == 200) {
|
||||
List<AppAndWhiteBean> appAndWhiteList = baseResponse.data;
|
||||
if (appAndWhiteList != null) {
|
||||
List<String> pkgList = appAndWhiteList.stream().map(AppAndWhiteBean::getApp_package).collect(Collectors.toList());
|
||||
String pkgString = StringUtils.join(",", pkgList);
|
||||
mMMKV.encode(UrlAddress.GET_APP_AND_WHITE, pkgString);
|
||||
Log.e("getAppAndWhite", "onNext: " + pkgString);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("getAppAndWhite", "onError: " + e.getMessage());
|
||||
onComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getAppAndWhite", "onComplete: ");
|
||||
if (callback != null) {
|
||||
callback.onComplete();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,21 +80,7 @@ public class UrlAddress {
|
||||
public static final String UPDATE_LOCK_SCREEN = "sn/updateLockScreen";
|
||||
|
||||
|
||||
/*发送app信息*/
|
||||
@Deprecated
|
||||
public static final String APPLOG = "App/getApplog";
|
||||
/*根据包名获取更新*/
|
||||
@Deprecated
|
||||
public final static String GET_APP_UPDATE = "Update/update";
|
||||
/*获取当前最顶层应用和电量*/
|
||||
@Deprecated
|
||||
public final static String SEND_RUNINGAPPINFO = "Monitoring/getAppNow";
|
||||
/*在线状态*/
|
||||
@Deprecated
|
||||
public final static String SEND_DRIVE_STATE = "Online/online";
|
||||
|
||||
|
||||
/*获取公网IP*/
|
||||
public static final String SHOUHU_CITYJSON = "http://pv.sohu.com/cityjson/";
|
||||
|
||||
}
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.fuying.sn.network.api;
|
||||
|
||||
import com.fuying.sn.bean.BaseResponse;
|
||||
import com.fuying.sn.network.UrlAddress;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface Applog {
|
||||
@GET(UrlAddress.APPLOG)
|
||||
Observable<BaseResponse> getApplog(
|
||||
@Query("sn") String sn,
|
||||
@Query("app_name") String app_name,
|
||||
@Query("use_time") String use_time,
|
||||
@Query("status") String status,
|
||||
@Query("createtime") String createtime
|
||||
);
|
||||
}
|
||||
@@ -106,7 +106,7 @@ public class APKinstallReceiver extends BroadcastReceiver {
|
||||
NetInterfaceManager.getInstance().getAppInside();
|
||||
}
|
||||
NetInterfaceManager.getInstance().SendAppInstallInfo();
|
||||
MainService.getPresenter().getAppAndWhite();
|
||||
NetInterfaceManager.getInstance().getAppAndWhite();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -21,7 +21,6 @@ import com.fuying.sn.service.StepService;
|
||||
public class BootReceiver extends BroadcastReceiver {
|
||||
private static String TAG = BootReceiver.class.getSimpleName();
|
||||
public static final String BOOT_COMPLETED = "zuoyeos.action.BOOT_COMPLETED";
|
||||
public static final String SOS = "zuoyeos.action.SOS";
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
@@ -47,17 +46,6 @@ public class BootReceiver extends BroadcastReceiver {
|
||||
context.startService(new Intent(context, DownloadService.class));
|
||||
context.startService(new Intent(context, ManagerService.class));
|
||||
context.startService(new Intent(context, ControlPanelService.class));
|
||||
} else if (SOS.equals(action)) {
|
||||
LocationClient locationClient = AmapManager.getInstance().getLocationClient();
|
||||
locationClient.stop();
|
||||
locationClient.start();
|
||||
locationClient.registerLocationListener(new BDAbstractLocationListener() {
|
||||
@Override
|
||||
public void onReceiveLocation(BDLocation bdLocation) {
|
||||
Log.e(TAG, "onReceiveLocation: ");
|
||||
NetInterfaceManager.getInstance().updateAdminInfo();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,35 +5,27 @@ import android.content.Intent;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
|
||||
import com.fuying.sn.bean.AppAndWhiteBean;
|
||||
import com.fuying.sn.bean.AppStart;
|
||||
import com.fuying.sn.bean.BaseResponse;
|
||||
import com.fuying.sn.bean.MyAppUsageBean;
|
||||
import com.fuying.sn.bean.SystemSettingsSet;
|
||||
import com.fuying.sn.config.CommonConfig;
|
||||
import com.fuying.sn.desktop.RunningAppManager;
|
||||
import com.fuying.sn.disklrucache.CacheHelper;
|
||||
import com.fuying.sn.gson.GsonUtils;
|
||||
import com.fuying.sn.manager.ControlManager;
|
||||
import com.fuying.sn.network.NetInterfaceManager;
|
||||
import com.fuying.sn.network.UrlAddress;
|
||||
import com.fuying.sn.service.ManagerService;
|
||||
import com.fuying.sn.utils.JGYUtils;
|
||||
import com.fuying.sn.utils.SPUtils;
|
||||
import com.fuying.sn.utils.ServiceAliveUtils;
|
||||
import com.fuying.sn.utils.StringUtils;
|
||||
import com.fuying.sn.utils.Utils;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.trello.rxlifecycle4.RxLifecycle;
|
||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.rxjava3.annotations.NonNull;
|
||||
import io.reactivex.rxjava3.core.Observer;
|
||||
import io.reactivex.rxjava3.disposables.Disposable;
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers;
|
||||
@@ -43,7 +35,7 @@ import io.reactivex.rxjava3.subjects.BehaviorSubject;
|
||||
* @author jgy02
|
||||
*/
|
||||
public class MainSPresenter implements MainSContact.Presenter {
|
||||
private String TAG = MainSPresenter.class.getSimpleName();
|
||||
private static final String TAG = MainSPresenter.class.getSimpleName();
|
||||
|
||||
private MainSContact.MainView mView;
|
||||
private Context mContext;
|
||||
@@ -75,42 +67,14 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
this.mView = null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void getAppAndWhite() {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getAppAndWhiteApiObservable()
|
||||
.subscribe(new Observer<BaseResponse<List<AppAndWhiteBean>>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("getAppAndWhite", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<List<AppAndWhiteBean>> baseResponse) {
|
||||
Log.e("getAppAndWhite", "onSubscribe: " + baseResponse);
|
||||
if (baseResponse.code == 200) {
|
||||
List<AppAndWhiteBean> appAndWhiteList = baseResponse.data;
|
||||
if (appAndWhiteList != null) {
|
||||
List<String> pkgList = appAndWhiteList.stream().map(AppAndWhiteBean::getApp_package).collect(Collectors.toList());
|
||||
String pkgString = StringUtils.join(",", pkgList);
|
||||
mMMKV.encode(UrlAddress.GET_APP_AND_WHITE, pkgString);
|
||||
Log.e("getAppAndWhite", "onNext: " + pkgString);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("getAppAndWhite", "onError: " + e.getMessage());
|
||||
}
|
||||
|
||||
NetInterfaceManager.getInstance().getAppAndWhite(true, getLifecycle(), new NetInterfaceManager.CompleteCallback() {
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getAppAndWhite", "onComplete: ");
|
||||
mView.getAppAndWhiteFinish();
|
||||
}
|
||||
});
|
||||
mView.getAppAndWhiteFinish();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -155,8 +119,7 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
|
||||
@Override
|
||||
public void getSnInfo() {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getSnInfo(true, getLifecycle(), new NetInterfaceManager.ObserverCallback() {
|
||||
NetInterfaceManager.getInstance().getSnInfo(true, getLifecycle(), new NetInterfaceManager.ObserverCallback() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
Log.e("getSnInfo", "onSubscribe: ");
|
||||
@@ -242,45 +205,14 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
Log.e("getForceInstall", "onComplete: ");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSystemSettings() {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getsettingControl()
|
||||
.compose(RxLifecycle.bindUntilEvent(getLifecycle(), ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse<SystemSettingsSet>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
Log.e("getSystemSettings", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(BaseResponse<SystemSettingsSet> systemSettingsBaseResponse) {
|
||||
Log.e("getSystemSettings", "onNext: " + systemSettingsBaseResponse);
|
||||
SPUtils.put(mContext, "is_first_connection", 0);
|
||||
int code = systemSettingsBaseResponse.code;
|
||||
if (code == 200) {
|
||||
String data = new Gson().toJson(systemSettingsBaseResponse.data.getUser());
|
||||
ControlManager.getInstance().setSystemSetting(data);
|
||||
} else {
|
||||
ControlManager.getInstance().setDisableSetting();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
if ((int) SPUtils.get(mContext, "is_first_connection", 1) == 1) {
|
||||
ControlManager.getInstance().setDisableSetting();
|
||||
}
|
||||
Log.e("getSystemSettings", "onError: " + e.getMessage());
|
||||
onComplete();
|
||||
}
|
||||
|
||||
.getSystemSettings(true, getLifecycle(), new NetInterfaceManager.CompleteCallback() {
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getSystemSettings", "onComplete: ");
|
||||
mView.setSystemSettings();
|
||||
}
|
||||
});
|
||||
@@ -289,82 +221,6 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
@Override
|
||||
public void getBrowserLabel() {
|
||||
mView.setBrowserLabel();
|
||||
// NetInterfaceManager.getInstance().getBrowserLabel(true, getLifecycle(), new NetInterfaceManager.CompleteCallback() {
|
||||
// @Override
|
||||
// public void onComplete() {
|
||||
// mView.setBrowserLabel();
|
||||
// }
|
||||
// });
|
||||
// NetInterfaceManager.getInstance().getLabelControl()
|
||||
// .compose(RxLifecycle.bindUntilEvent(getLifecycle(), ActivityEvent.DESTROY))
|
||||
// .subscribe(new Observer<BaseResponse<Label>>() {
|
||||
// @Override
|
||||
// public void onSubscribe(Disposable d) {
|
||||
// Log.e("getBrowserLabel", "onSubscribe: ");
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onNext(BaseResponse<Label> labelBaseResponse) {
|
||||
// Log.e("getBrowserLabel", "onNext: " + labelBaseResponse);
|
||||
// if (labelBaseResponse.code == 200) {
|
||||
// String home_page = labelBaseResponse.data.getHome_page();
|
||||
// Settings.System.putString(mContext.getContentResolver(), "homepagURL", home_page);
|
||||
// //主页
|
||||
// Intent homepag = new Intent("qch_app_brower_homepage");
|
||||
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
// homepag.setPackage("com.android.settings")
|
||||
// .setPackage("com.android.browser");
|
||||
// }
|
||||
// if (!TextUtils.isEmpty(home_page)) {
|
||||
// homepag.putExtra("homepage", home_page);
|
||||
// } else {
|
||||
// homepag.putExtra("homepage", "");
|
||||
// }
|
||||
// mContext.sendBroadcast(homepag);
|
||||
//
|
||||
// //书签
|
||||
// String label_page = labelBaseResponse.data.getLabel_page();
|
||||
// Intent websiteBookMark = new Intent("qch_app_brower_website");
|
||||
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
// websiteBookMark.setPackage("com.android.settings")
|
||||
// .setPackage("com.android.browser");
|
||||
// }
|
||||
// if (!TextUtils.isEmpty(label_page)) {
|
||||
// websiteBookMark.putExtra("websiteBookMark", label_page);
|
||||
// } else {
|
||||
// websiteBookMark.putExtra("websiteBookMark", "");
|
||||
// }
|
||||
// mContext.sendBroadcast(websiteBookMark);
|
||||
// } else {
|
||||
// Intent intent1 = new Intent("qch_app_brower_homepage");
|
||||
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
// intent1.setPackage("com.android.settings")
|
||||
// .setPackage("com.android.browser");
|
||||
// }
|
||||
// intent1.putExtra("homepage", "");
|
||||
// mContext.sendBroadcast(intent1);
|
||||
// Intent intent2 = new Intent("qch_app_brower_website");
|
||||
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
// intent2.setPackage("com.android.settings")
|
||||
// .setPackage("com.android.browser");
|
||||
// }
|
||||
// intent2.putExtra("websiteBookMark", "");
|
||||
// mContext.sendBroadcast(intent2);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onError(Throwable e) {
|
||||
// Log.e("getBrowserLabel", "onError: " + e.getMessage());
|
||||
// onComplete();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onComplete() {
|
||||
// Log.e("getBrowserLabel", "onComplete: ");
|
||||
// mView.setBrowserLabel();
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -373,61 +229,6 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
@Override
|
||||
public void getBrowserWhiteList() {
|
||||
mView.setBrowserWhiteList();
|
||||
// NetInterfaceManager.getInstance().getBrowserWhiteList(true, getLifecycle(), new NetInterfaceManager.CompleteCallback() {
|
||||
// @Override
|
||||
// public void onComplete() {
|
||||
// mView.setBrowserWhiteList();
|
||||
// }
|
||||
// });
|
||||
// NetInterfaceManager.getInstance().getBrowserControl()
|
||||
// .compose(RxLifecycle.bindUntilEvent(getLifecycle(), ActivityEvent.DESTROY))
|
||||
// .subscribe(new Observer<BaseResponse<BrowserApiData>>() {
|
||||
// @Override
|
||||
// public void onSubscribe(Disposable d) {
|
||||
// Log.e("getBrowserWhiteList", "onSubscribe: ");
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onNext(BaseResponse<BrowserApiData> response) {
|
||||
// Log.e("getBrowserWhiteList", "onNext: " + response);
|
||||
// if (response.code == 200) {
|
||||
// //白名单
|
||||
// List<BrowserBean> white = response.data.getWhiteList();
|
||||
// if (null != white && white.size() != 0) {
|
||||
// boolean whiteList = Settings.System.putString(mContext.getContentResolver(), "DeselectBrowserArray",
|
||||
// white.stream().map(BrowserBean::getAddress).collect(Collectors.joining(",")));
|
||||
// Log.e("getBrowserWhiteList", "setBrowserList_white:" + white + ":" + whiteList);
|
||||
// } else {
|
||||
// Settings.System.putString(mContext.getContentResolver(), "DeselectBrowserArray", " ");
|
||||
// }
|
||||
// //黑名单
|
||||
// List<BrowserBean> black = response.data.getBlackList();
|
||||
// if (null != black && black.size() != 0) {
|
||||
// boolean blackList = Settings.System.putString(mContext.getContentResolver(), "qch_webblack_url",
|
||||
// black.stream().map(BrowserBean::getAddress).collect(Collectors.joining(",")));
|
||||
// Log.e("getBrowserWhiteList", "setBrowserList_black:" + black + ":" + blackList);
|
||||
// } else {
|
||||
// Settings.System.putString(mContext.getContentResolver(), "qch_webblack_url", " ");
|
||||
// }
|
||||
// } else {
|
||||
// Settings.System.putString(mContext.getContentResolver(), "DeselectBrowserArray", " ");
|
||||
// Settings.System.putString(mContext.getContentResolver(), "qch_webblack_url", " ");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onError(Throwable e) {
|
||||
// Log.e("getBrowserWhiteList", "onError: " + e.getMessage());
|
||||
// onComplete();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onComplete() {
|
||||
// new URLUtils(mContext).setBrowserList();
|
||||
// mView.setBrowserWhiteList();
|
||||
// Log.e("getBrowserWhiteList", "onComplete: ");
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -565,6 +366,4 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.fuying.sn.service.main;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.AlarmManager;
|
||||
import android.app.Service;
|
||||
import android.content.BroadcastReceiver;
|
||||
@@ -30,7 +29,6 @@ import com.fuying.sn.bean.BaseResponse;
|
||||
import com.fuying.sn.bean.SnInfo;
|
||||
import com.fuying.sn.config.CommonConfig;
|
||||
import com.fuying.sn.manager.AmapManager;
|
||||
import com.fuying.sn.manager.ConnectManager;
|
||||
import com.fuying.sn.manager.ControlManager;
|
||||
import com.fuying.sn.network.NetInterfaceManager;
|
||||
import com.fuying.sn.rlog.LogDBManager;
|
||||
@@ -40,6 +38,7 @@ import com.fuying.sn.service.StepService;
|
||||
import com.fuying.sn.utils.ApkUtils;
|
||||
import com.fuying.sn.utils.CacheUtils;
|
||||
import com.fuying.sn.utils.JGYUtils;
|
||||
import com.fuying.sn.utils.NetStateUtils;
|
||||
import com.fuying.sn.utils.SPUtils;
|
||||
import com.fuying.sn.utils.TimeUtils;
|
||||
import com.fuying.sn.utils.ToastUtil;
|
||||
@@ -74,11 +73,12 @@ import io.reactivex.rxjava3.subjects.BehaviorSubject;
|
||||
public class MainService extends Service implements MainSContact.MainView, NetworkUtils.OnNetworkStatusChangedListener, LifecycleProvider<ActivityEvent> {
|
||||
private String TAG = MainService.class.getSimpleName();
|
||||
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
public static MainSPresenter mPresenter;
|
||||
public MainSPresenter mPresenter;
|
||||
private MMKV mMMKV = MMKV.defaultMMKV();
|
||||
|
||||
//执行所有请求的时间
|
||||
long runningTime;
|
||||
|
||||
//MainService上次执行时间
|
||||
long startCommandTime = 0;
|
||||
|
||||
@@ -114,26 +114,22 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
||||
ToastUtil.show("网络已连接");
|
||||
String WiFiAlias = Utils.getWifiAlias(this);
|
||||
Log.e(TAG, "onConnected: WiFiAlias = " + WiFiAlias);
|
||||
if (ConnectManager.getInstance().isWiFiFistConnect()) {
|
||||
start.onstar(ConnectManager.WIFI_LAST_CONNECT_TIME);
|
||||
} else {
|
||||
if (ConnectManager.getInstance().isWiFiCutoverFistConnect(WiFiAlias)) {
|
||||
start.onstar(WiFiAlias);
|
||||
}
|
||||
}
|
||||
// NTPTimeTask task = new NTPTimeTask();
|
||||
// task.execute("ntp.aliyun.com");
|
||||
//第一次开机联网后直接连接
|
||||
// TODO: 2022/11/21 有些设备联网了但是立刻请求还是失败
|
||||
Log.e(TAG, "onConnected run: 15秒后请求网络");
|
||||
Handler.getMain().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if ((int) SPUtils.get(MainService.this, CommonConfig.JGY_FIRST_BOOT, 0) == 0) {
|
||||
NetInterfaceManager.getInstance().updateAdminInfo();
|
||||
if (JGYUtils.getInstance().isScreenOn()) {
|
||||
mPresenter.getSnInfo();
|
||||
mPresenter.getAppAndWhite();
|
||||
SPUtils.put(MainService.this, CommonConfig.JGY_FIRST_BOOT, 1);
|
||||
}
|
||||
}
|
||||
}, 15000);
|
||||
sendDeviceInfo();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -159,13 +155,18 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
||||
mPresenter.setLifecycle(lifecycleSubject);
|
||||
mPresenter.attachView(this);
|
||||
|
||||
Log.e(TAG, "onCreate run: 20秒后请求网络");
|
||||
Handler.getMain().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
NTPTimeTask task = new NTPTimeTask();
|
||||
task.execute("ntp.aliyun.com");
|
||||
if (NetStateUtils.isNetworkConnected(MainService.this)) {
|
||||
NetInterfaceManager.getInstance().getAppWhiteList(() -> {
|
||||
Log.e("TimeObserver", "onNext: getAppWhiteList");
|
||||
});
|
||||
mPresenter.getSnInfo();
|
||||
mPresenter.getAppAndWhite();
|
||||
}
|
||||
}
|
||||
}, 20000);
|
||||
|
||||
Log.e(TAG, "onCreate: IMEI = " + Utils.getIMEI(MainService.this));
|
||||
@@ -184,21 +185,12 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
||||
Log.e(TAG, "onCreate: " + e.getMessage());
|
||||
}
|
||||
|
||||
Observable.create(subscribe)
|
||||
.throttleFirst(6, TimeUnit.HOURS)
|
||||
.subscribe(timeObserver);
|
||||
|
||||
Observable.create(configsubscribe)
|
||||
.throttleLast(15, TimeUnit.SECONDS)
|
||||
.subscribe(configObserver);
|
||||
|
||||
if ((int) SPUtils.get(this, CommonConfig.JGY_FIRST_CONNECT, 0) == 0) {
|
||||
start.onstar(ConnectManager.REBOOT_LAST_ONNECT_TIME);
|
||||
}
|
||||
versionIsUpdate();
|
||||
registerReceivers();
|
||||
// ControlManager.getInstance().setDefaultUSBstate();
|
||||
sendDeviceInfo();
|
||||
startService();
|
||||
}
|
||||
|
||||
private void versionIsUpdate() {
|
||||
@@ -220,29 +212,11 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
if (ConnectManager.getInstance().isRebootFistConnect()) {
|
||||
start.onstar(ConnectManager.REBOOT_LAST_ONNECT_TIME);
|
||||
runningTime = SystemClock.elapsedRealtime();
|
||||
} else {
|
||||
Log.e(TAG, "onCreate: " + "Service Reboot");
|
||||
// mPresenter.getLockedState();
|
||||
}
|
||||
|
||||
}
|
||||
SPUtils.put(this, CommonConfig.SN_VERSIONCODE, BuildConfig.VERSION_CODE);
|
||||
}
|
||||
|
||||
private void sendDeviceInfo() {
|
||||
Handler.getMain().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
initConfig();
|
||||
NetInterfaceManager.getInstance().SendAppInstallInfo();
|
||||
NetInterfaceManager.getInstance().updateAdminInfo();
|
||||
}
|
||||
}, 15000);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
Log.e(TAG, "onStartCommand: " + System.currentTimeMillis());
|
||||
@@ -252,7 +226,7 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
||||
|
||||
private void initConfig() {
|
||||
tPushInit();
|
||||
Utils.getPublicIP(MainService.this);
|
||||
// Utils.getPublicIP(MainService.this);
|
||||
LocationClient locationClient = AmapManager.getInstance().getLocationClient();
|
||||
locationClient.stop();
|
||||
locationClient.start();
|
||||
@@ -260,7 +234,6 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
||||
@Override
|
||||
public void onReceiveLocation(BDLocation bdLocation) {
|
||||
Log.e("initConfig", "onReceiveLocation: ");
|
||||
// NetInterfaceManager.getInstance().updateAdminInfo();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -310,10 +283,6 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
||||
unregisterReceivers();
|
||||
}
|
||||
|
||||
public static MainSPresenter getPresenter() {
|
||||
return mPresenter;
|
||||
}
|
||||
|
||||
private void startService() {
|
||||
startService(new Intent(this, GuardService.class));
|
||||
startService(new Intent(this, StepService.class));
|
||||
@@ -349,12 +318,7 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
||||
@Override
|
||||
public void onSuccess(Object data, int flag) {
|
||||
Log.e("TPush", "onSuccess, data:" + data + ", flag:" + flag);
|
||||
NetInterfaceManager.getInstance().setPushTags(true, lifecycleSubject, new NetInterfaceManager.CompleteCallback() {
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("TimeTask", "onComplete: ");
|
||||
}
|
||||
});
|
||||
NetInterfaceManager.getInstance().setPushTags();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -431,9 +395,6 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
||||
if (!oldSSID.equals(newSSID)) {
|
||||
LogDBManager.getInstance().creatNetChangeLog("", oldSSID + " change to: " + newSSID);
|
||||
//直接获取数据
|
||||
if (ConnectManager.getInstance().isWiFiCutoverFistConnect(newSSID)) {
|
||||
start.onstar(newSSID);
|
||||
}
|
||||
} else {
|
||||
LogDBManager.getInstance().creatNetChangeLog("接入WiFi",
|
||||
"connect to: " + newSSID + " time: "
|
||||
@@ -500,52 +461,6 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
||||
}
|
||||
}
|
||||
|
||||
private interface Start {
|
||||
void onstar(String key);
|
||||
}
|
||||
|
||||
private Start start;
|
||||
|
||||
private ObservableOnSubscribe<String> subscribe = new ObservableOnSubscribe<String>() {
|
||||
@Override
|
||||
public void subscribe(ObservableEmitter<String> emitter) throws Exception {
|
||||
start = emitter::onNext;
|
||||
}
|
||||
};
|
||||
|
||||
private Observer<String> timeObserver = new Observer<String>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String string) {
|
||||
Log.e("TimeObserver", "onNext: " + string);
|
||||
mMMKV.encode(string, System.currentTimeMillis());
|
||||
startCommandTime = runningTime = SystemClock.elapsedRealtime();
|
||||
NTPTimeTask task = new NTPTimeTask();
|
||||
task.execute("ntp.aliyun.com");
|
||||
NetInterfaceManager.getInstance().getAppWhiteList(() -> {
|
||||
Log.e("TimeObserver", "onNext: getAppWhiteList");
|
||||
});
|
||||
mPresenter.getSnInfo();
|
||||
NetInterfaceManager.getInstance().SendAppInstallInfo();
|
||||
// NetInterfaceManager.getInstance().updateAdminInfo();
|
||||
startService();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void getAppAndWhiteFinish() {
|
||||
mPresenter.checkUpdate();
|
||||
@@ -580,7 +495,7 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
||||
if (code == 200) {
|
||||
mPresenter.getLocked();
|
||||
SnInfo snInfo = response.data;
|
||||
NetInterfaceManager.getInstance().checkDeviceType(snInfo.getType_id());
|
||||
// NetInterfaceManager.getInstance().checkDeviceType(snInfo.getType_id());
|
||||
}
|
||||
//设备没有绑定
|
||||
else if (code == 300) {
|
||||
|
||||
@@ -22,6 +22,28 @@ import android.view.WindowManager;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.android.internal.view.RotationPolicy;
|
||||
import com.fuying.sn.R;
|
||||
import com.fuying.sn.bean.BaseResponse;
|
||||
import com.fuying.sn.config.CommonConfig;
|
||||
import com.fuying.sn.dialog.CustomDialog;
|
||||
import com.fuying.sn.disklrucache.CacheHelper;
|
||||
import com.fuying.sn.gson.GsonUtils;
|
||||
import com.fuying.sn.manager.ControlManager;
|
||||
import com.fuying.sn.manager.DeviceManager;
|
||||
import com.fuying.sn.network.NetInterfaceManager;
|
||||
import com.fuying.sn.receiver.BootReceiver;
|
||||
import com.fuying.sn.service.ManagerService;
|
||||
import com.fuying.sn.tpush.common.NotificationService;
|
||||
import com.fuying.sn.tpush.po.XGNotification;
|
||||
import com.fuying.sn.utils.ApkUtils;
|
||||
import com.fuying.sn.utils.CacheUtils;
|
||||
import com.fuying.sn.utils.CmdUtil;
|
||||
import com.fuying.sn.utils.FileUtils;
|
||||
import com.fuying.sn.utils.JGYUtils;
|
||||
import com.fuying.sn.utils.SPUtils;
|
||||
import com.fuying.sn.utils.ServiceAliveUtils;
|
||||
import com.fuying.sn.utils.ToastUtil;
|
||||
import com.fuying.sn.utils.Utils;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
@@ -31,29 +53,6 @@ import com.tencent.android.tpush.XGPushClickedResult;
|
||||
import com.tencent.android.tpush.XGPushRegisterResult;
|
||||
import com.tencent.android.tpush.XGPushShowedResult;
|
||||
import com.tencent.android.tpush.XGPushTextMessage;
|
||||
import com.fuying.sn.R;
|
||||
import com.fuying.sn.bean.BaseResponse;
|
||||
import com.fuying.sn.config.CommonConfig;
|
||||
import com.fuying.sn.dialog.CustomDialog;
|
||||
import com.fuying.sn.disklrucache.CacheHelper;
|
||||
import com.fuying.sn.manager.ControlManager;
|
||||
import com.fuying.sn.manager.DeviceManager;
|
||||
import com.fuying.sn.network.NetInterfaceManager;
|
||||
import com.fuying.sn.receiver.BootReceiver;
|
||||
import com.fuying.sn.service.ManagerService;
|
||||
import com.fuying.sn.service.main.MainService;
|
||||
import com.fuying.sn.tpush.common.NotificationService;
|
||||
import com.fuying.sn.tpush.po.XGNotification;
|
||||
import com.fuying.sn.utils.ApkUtils;
|
||||
import com.fuying.sn.utils.CacheUtils;
|
||||
import com.fuying.sn.utils.CmdUtil;
|
||||
import com.fuying.sn.gson.GsonUtils;
|
||||
import com.fuying.sn.utils.FileUtils;
|
||||
import com.fuying.sn.utils.JGYUtils;
|
||||
import com.fuying.sn.utils.SPUtils;
|
||||
import com.fuying.sn.utils.ServiceAliveUtils;
|
||||
import com.fuying.sn.utils.ToastUtil;
|
||||
import com.fuying.sn.utils.Utils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
@@ -611,7 +610,7 @@ public class MessageReceiver extends XGPushBaseReceiver {
|
||||
case JIGUANG_SYSTEM_SETTING:
|
||||
ToastUtil.debugShow("收到推送消息: 系统管控");
|
||||
// ControlManager.getInstance().setSystemSetting(extras);
|
||||
MainService.getPresenter().getSystemSettings();
|
||||
NetInterfaceManager.getInstance().getSystemSettings();
|
||||
// if ("com.jiaoguanyi.os".equals(ForegroundAppUtil.getForegroundPackageName(context))) {
|
||||
// JGYUtils.getInstance().killBackgroundProcesses(context, "com.jiaoguanyi.os");
|
||||
// Intent intent = context.getPackageManager().getLaunchIntentForPackage("com.jiaoguanyi.os");
|
||||
@@ -706,8 +705,8 @@ public class MessageReceiver extends XGPushBaseReceiver {
|
||||
break;
|
||||
case JIGUANG_BIND_UNBIND:
|
||||
ToastUtil.debugShow("老师授权/取消授权");
|
||||
MainService.getPresenter().getAppAndWhite();
|
||||
MainService.getPresenter().getForceInstall();
|
||||
NetInterfaceManager.getInstance().getAppAndWhite();
|
||||
NetInterfaceManager.getInstance().getForceInstall();
|
||||
try {
|
||||
mCacheHelper.delete();
|
||||
} catch (IOException e) {
|
||||
@@ -873,14 +872,14 @@ public class MessageReceiver extends XGPushBaseReceiver {
|
||||
}
|
||||
|
||||
synchronized private void sendStartTime(Context context, String jsonString) {
|
||||
// NetInterfaceManager.getInstance().updateAdminInfo();
|
||||
NetInterfaceManager.getInstance().updateAdminInfo();
|
||||
NetInterfaceManager.getInstance().sendRunningApp();
|
||||
NetInterfaceManager.getInstance().SendAppInstallInfo();
|
||||
NetInterfaceManager.getInstance().getAppAndWhite();
|
||||
NetInterfaceManager.getInstance().getSnInfo();
|
||||
if (JGYUtils.getInstance().isScreenOn()) {
|
||||
NetInterfaceManager.getInstance().screenshot();
|
||||
}
|
||||
MainService.getPresenter().getAppAndWhite();
|
||||
MainService.getPresenter().getSnInfo();
|
||||
}
|
||||
|
||||
synchronized private void setUsbStatus(Context context, String jsonString) {
|
||||
@@ -1154,7 +1153,7 @@ public class MessageReceiver extends XGPushBaseReceiver {
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("bind", "onComplete: ");
|
||||
MainService.getPresenter().getSnInfo();
|
||||
NetInterfaceManager.getInstance().getSnInfo();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -14,8 +14,8 @@ import android.util.Log;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class CacheUtils {
|
||||
|
||||
private static final String TAG = CacheUtils.class.getSimpleName();
|
||||
|
||||
private final long MAX_WAIT_TIME = 60 * 1000;
|
||||
private final long WAIT_TIME_INCR = 10 * 1000;
|
||||
|
||||
@@ -100,6 +100,7 @@ public class CacheUtils {
|
||||
public boolean retValue = false;
|
||||
private boolean doneFlag = false;
|
||||
|
||||
@Override
|
||||
public void onRemoveCompleted(String packageName, boolean succeeded) throws RemoteException {
|
||||
synchronized (this) {
|
||||
retValue = succeeded;
|
||||
@@ -118,6 +119,7 @@ public class CacheUtils {
|
||||
public PackageStats stats;
|
||||
private boolean doneFlag = false;
|
||||
|
||||
@Override
|
||||
public void onGetStatsCompleted(PackageStats pStats, boolean succeeded) throws RemoteException {
|
||||
synchronized (this) {
|
||||
retValue = succeeded;
|
||||
|
||||
@@ -90,12 +90,16 @@ public class JGYUtils {
|
||||
private ContentResolver resolver;
|
||||
private MMKV mMMKV = MMKV.defaultMMKV();
|
||||
|
||||
public static int MTKPlatform = 1;
|
||||
public static int ZhanruiPlatform = 2;
|
||||
public static int UnknowPlatform = 0;
|
||||
public static final int MTKPlatform = 1;
|
||||
public static final int ZhanruiPlatform = 2;
|
||||
public static final int M40sePlatform = 4;
|
||||
public static final int T30ProPlatform = 5;
|
||||
public static final int UnknowPlatform = 0;
|
||||
|
||||
public static String MTKTag = "MTK";
|
||||
public static String ZhanruiTag = "展锐";
|
||||
public static String M40SETag = "M40SE";
|
||||
public static String T30PROTag = "T30PRO";
|
||||
|
||||
private HashSet<String> ownApp = new HashSet<String>() {{
|
||||
this.add("com.android.settings");
|
||||
@@ -478,6 +482,12 @@ public class JGYUtils {
|
||||
} else if ("ZhanRui".equalsIgnoreCase(platform)) {
|
||||
Log.i(TAG, "checkAppPlatform: " + "展锐平台");
|
||||
return ZhanruiPlatform;
|
||||
} else if ("M40SE".equalsIgnoreCase(platform)) {
|
||||
Log.i(TAG, "checkAppPlatform: " + "M40SE");
|
||||
return M40sePlatform;
|
||||
} else if ("T30PRO".equalsIgnoreCase(platform)) {
|
||||
Log.i(TAG, "checkAppPlatform: " + "T30PRO");
|
||||
return T30ProPlatform;
|
||||
} else {
|
||||
Log.i(TAG, "checkAppPlatform: " + "没有数据");
|
||||
return UnknowPlatform;
|
||||
@@ -503,6 +513,10 @@ public class JGYUtils {
|
||||
getAppPlatformCallback.AppPlatform(MTKPlatform);
|
||||
} else if ("ZhanRui".equalsIgnoreCase(platform)) {
|
||||
getAppPlatformCallback.AppPlatform(ZhanruiPlatform);
|
||||
}else if ("M40SE".equalsIgnoreCase(platform)) {
|
||||
getAppPlatformCallback.AppPlatform(M40sePlatform);
|
||||
} else if ("T30PRO".equalsIgnoreCase(platform)) {
|
||||
getAppPlatformCallback.AppPlatform(T30ProPlatform);
|
||||
} else {
|
||||
getAppPlatformCallback.AppPlatform(UnknowPlatform);
|
||||
}
|
||||
@@ -591,6 +605,7 @@ public class JGYUtils {
|
||||
}
|
||||
|
||||
public void removeTask(String packageName) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
List<ActivityManager.RecentTaskInfo> list = getRecentTasks(ActivityManager.getMaxRecentTasksStatic(), getCurrentUserId());
|
||||
HashMap<String, Integer> taskMap = new HashMap<>();
|
||||
for (ActivityManager.RecentTaskInfo info : list) {
|
||||
@@ -605,6 +620,7 @@ public class JGYUtils {
|
||||
Log.e(TAG, "removeTask: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 如果界面正在最近任务列表,有些app可能不会被清理
|
||||
|
||||
84
app/src/main/java/com/fuying/sn/utils/NetStateUtils.java
Normal file
84
app/src/main/java/com/fuying/sn/utils/NetStateUtils.java
Normal file
@@ -0,0 +1,84 @@
|
||||
package com.fuying.sn.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
|
||||
public class NetStateUtils {
|
||||
|
||||
/**
|
||||
* 判断网络连接状态
|
||||
*
|
||||
* @param context
|
||||
* @return true:网络已链接, false:网络已断开连接
|
||||
*/
|
||||
public static boolean isNetworkConnected(Context context) {
|
||||
if (context != null) {
|
||||
ConnectivityManager mConnectivityManager = (ConnectivityManager) context
|
||||
.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
NetworkInfo mNetworkInfo = mConnectivityManager
|
||||
.getActiveNetworkInfo();
|
||||
if (mNetworkInfo != null) {
|
||||
return mNetworkInfo.isAvailable();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断wifi状态
|
||||
*
|
||||
* @param context
|
||||
* @return true:是wifi情况 ,false:非wifi情况
|
||||
*/
|
||||
public static boolean isWifiConnected(Context context) {
|
||||
if (context != null) {
|
||||
ConnectivityManager mConnectivityManager = (ConnectivityManager) context
|
||||
.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
NetworkInfo mWiFiNetworkInfo = mConnectivityManager
|
||||
.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
|
||||
if (mWiFiNetworkInfo != null) {
|
||||
return mWiFiNetworkInfo.isAvailable();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断移动网络
|
||||
*
|
||||
* @param context
|
||||
* @return true:是移动网络情况, false:非移动网络情况
|
||||
*/
|
||||
public static boolean isMobileConnected(Context context) {
|
||||
if (context != null) {
|
||||
ConnectivityManager mConnectivityManager = (ConnectivityManager) context
|
||||
.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
NetworkInfo mMobileNetworkInfo = mConnectivityManager
|
||||
.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
|
||||
if (mMobileNetworkInfo != null) {
|
||||
return mMobileNetworkInfo.isAvailable();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取连接类型
|
||||
*
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
public static int getConnectedType(Context context) {
|
||||
if (context != null) {
|
||||
ConnectivityManager mConnectivityManager = (ConnectivityManager) context
|
||||
.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
NetworkInfo mNetworkInfo = mConnectivityManager
|
||||
.getActiveNetworkInfo();
|
||||
if (mNetworkInfo != null && mNetworkInfo.isAvailable()) {
|
||||
return mNetworkInfo.getType();
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -385,13 +385,15 @@ public class TimeUtils {
|
||||
if (mNtpClient == null) {
|
||||
mNtpClient = new SntpClient();
|
||||
}
|
||||
try {
|
||||
boolean isSuccessful = mNtpClient.requestTime(hostAddress, 20000);
|
||||
Log.e(TAG, "requestTime:" + isSuccessful);
|
||||
if (isSuccessful) {
|
||||
long now = mNtpClient.getNtpTime();//now就是获取的时间
|
||||
return now;
|
||||
} else {
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "getTimeFromNtpServer: " + e.getMessage());
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -1250,9 +1250,11 @@ public class Utils {
|
||||
jsonObject.addProperty("use_ram", use_ram);
|
||||
jsonObject.addProperty("wifi_ssid", getWifiSSID(context));
|
||||
jsonObject.addProperty("wifi_time", wifi_time);
|
||||
jsonObject.addProperty("boot_time", SystemClock.elapsedRealtime());
|
||||
// jsonObject.addProperty("boot_time", SystemClock.elapsedRealtime());
|
||||
jsonObject.addProperty("boot_time", 0);
|
||||
jsonObject.addProperty("battery_capacity", getBatterymAh(context));
|
||||
jsonObject.addProperty("wifi_signal", info.getRssi());
|
||||
// jsonObject.addProperty("wifi_signal", info.getRssi());
|
||||
jsonObject.addProperty("wifi_signal", 0);
|
||||
jsonObject.addProperty("bluetooth", getBluetoothList());
|
||||
Log.e(TAG, "getHardware: " + jsonObject.toString());
|
||||
return jsonObject.toString();
|
||||
|
||||
Reference in New Issue
Block a user