version:2.8
fix:修复无网络连接时请求接口报错 update:优化网络请求
This commit is contained in:
101
app/build.gradle
101
app/build.gradle
@@ -73,15 +73,15 @@ android {
|
|||||||
|
|
||||||
official {
|
official {
|
||||||
flavorDimensions "default"
|
flavorDimensions "default"
|
||||||
versionCode 14
|
versionCode 28
|
||||||
versionName "2.3"
|
versionName "2.8"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//签名
|
//签名
|
||||||
signingConfigs {
|
signingConfigs {
|
||||||
zhanRui {
|
zhanRui {
|
||||||
storeFile file("src/keys/zhanxun.keystore")
|
storeFile file("keystore/zhanxun.keystore")
|
||||||
storePassword "123456"
|
storePassword "123456"
|
||||||
keyAlias "zhanxun"
|
keyAlias "zhanxun"
|
||||||
keyPassword "123456"
|
keyPassword "123456"
|
||||||
@@ -89,8 +89,17 @@ android {
|
|||||||
v2SigningEnabled true
|
v2SigningEnabled true
|
||||||
}
|
}
|
||||||
|
|
||||||
teclastuserdebug {
|
teclastUnisoc {
|
||||||
storeFile file("src/keys/TeclastUserDebug.jks")
|
storeFile file("keystore/TeclastUnisoc.keystore")
|
||||||
|
storePassword "123456"
|
||||||
|
keyAlias "TeclastUnisoc"
|
||||||
|
keyPassword "123456"
|
||||||
|
v1SigningEnabled true
|
||||||
|
v2SigningEnabled true
|
||||||
|
}
|
||||||
|
|
||||||
|
teclastUnisocUserdebug {
|
||||||
|
storeFile file("keystore/TeclastUnisocUserDebug.jks")
|
||||||
storePassword "123456"
|
storePassword "123456"
|
||||||
keyAlias "teclast"
|
keyAlias "teclast"
|
||||||
keyPassword "123456"
|
keyPassword "123456"
|
||||||
@@ -98,8 +107,17 @@ android {
|
|||||||
v2SigningEnabled true
|
v2SigningEnabled true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
teclastMTK {
|
||||||
|
storeFile file("keystore/TeclastMTK.jks")
|
||||||
|
storePassword "123456"
|
||||||
|
keyAlias "TeclastMTK"
|
||||||
|
keyPassword "123456"
|
||||||
|
v1SigningEnabled true
|
||||||
|
v2SigningEnabled true
|
||||||
|
}
|
||||||
|
|
||||||
mtk {
|
mtk {
|
||||||
storeFile file("src/keys/xueshibaoos.jks")
|
storeFile file("keystore/xueshibaoos.jks")
|
||||||
storePassword "123456"
|
storePassword "123456"
|
||||||
keyAlias "xueshibaoos"
|
keyAlias "xueshibaoos"
|
||||||
keyPassword "123456"
|
keyPassword "123456"
|
||||||
@@ -108,7 +126,7 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mtkAndroid11 {
|
mtkAndroid11 {
|
||||||
storeFile file("src/keys/mtkAndroid11.jks")
|
storeFile file("keystore/mtkAndroid11.jks")
|
||||||
storePassword "123456"
|
storePassword "123456"
|
||||||
keyAlias "mtk11"
|
keyAlias "mtk11"
|
||||||
keyPassword "123456"
|
keyPassword "123456"
|
||||||
@@ -117,7 +135,7 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
unisoc {
|
unisoc {
|
||||||
storeFile file("src/keys/Unisoc.jks")
|
storeFile file("keystore/Unisoc.jks")
|
||||||
storePassword "123456"
|
storePassword "123456"
|
||||||
keyAlias "unisoc"
|
keyAlias "unisoc"
|
||||||
keyPassword "123456"
|
keyPassword "123456"
|
||||||
@@ -156,8 +174,61 @@ android {
|
|||||||
signingConfig signingConfigs.mtkAndroid11
|
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.initWith(debug)
|
||||||
zhanRuiDebug {
|
zhanRuiDebug {
|
||||||
|
manifestPlaceholders = [
|
||||||
|
AK: "EiqcGW9LWDvfMKl7mZxUtt1UkNKpdQI5"
|
||||||
|
]
|
||||||
buildConfigField "String", "platform", '"ZhanRui"'
|
buildConfigField "String", "platform", '"ZhanRui"'
|
||||||
versionNameSuffix "-debug"
|
versionNameSuffix "-debug"
|
||||||
debuggable true
|
debuggable true
|
||||||
@@ -166,19 +237,13 @@ android {
|
|||||||
|
|
||||||
zhanRuiRelease.initWith(release)
|
zhanRuiRelease.initWith(release)
|
||||||
zhanRuiRelease {
|
zhanRuiRelease {
|
||||||
|
manifestPlaceholders = [
|
||||||
|
AK: "EiqcGW9LWDvfMKl7mZxUtt1UkNKpdQI5"
|
||||||
|
]
|
||||||
buildConfigField "String", "platform", '"ZhanRui"'
|
buildConfigField "String", "platform", '"ZhanRui"'
|
||||||
signingConfig signingConfigs.zhanRui
|
signingConfig signingConfigs.zhanRui
|
||||||
}
|
}
|
||||||
|
|
||||||
//userdebug rom使用这个版本
|
|
||||||
zhanRuiUserdebug.initWith(zhanRuiDebug)
|
|
||||||
zhanRuiUserdebug {
|
|
||||||
buildConfigField "String", "platform", '"ZhanRui"'
|
|
||||||
versionNameSuffix "-debug"
|
|
||||||
debuggable true
|
|
||||||
signingConfig signingConfigs.teclastuserdebug
|
|
||||||
}
|
|
||||||
|
|
||||||
debug {
|
debug {
|
||||||
buildConfigField "String", "platform", '"MTK"'
|
buildConfigField "String", "platform", '"MTK"'
|
||||||
versionNameSuffix "-debug"
|
versionNameSuffix "-debug"
|
||||||
@@ -248,7 +313,7 @@ dependencies {
|
|||||||
annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.3'
|
annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.3'
|
||||||
|
|
||||||
//okhttp
|
//okhttp
|
||||||
implementation 'com.squareup.okhttp3:okhttp:4.9.3'
|
implementation 'com.squareup.okhttp3:okhttp:4.10.0'
|
||||||
//Retrofit
|
//Retrofit
|
||||||
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
|
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
|
||||||
implementation 'com.squareup.retrofit2:converter-gson: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:label="@string/app_name"
|
||||||
android:networkSecurityConfig="@xml/network"
|
android:networkSecurityConfig="@xml/network"
|
||||||
android:requestLegacyExternalStorage="true"
|
android:requestLegacyExternalStorage="true"
|
||||||
|
android:usesCleartextTraffic="true"
|
||||||
android:roundIcon="@mipmap/ic_launcher"
|
android:roundIcon="@mipmap/ic_launcher"
|
||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/ImmerseTheme"
|
android:theme="@style/ImmerseTheme"
|
||||||
@@ -339,7 +340,7 @@
|
|||||||
|
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="com.baidu.lbsapi.API_KEY"
|
android:name="com.baidu.lbsapi.API_KEY"
|
||||||
android:value="EiqcGW9LWDvfMKl7mZxUtt1UkNKpdQI5" >
|
android:value="${AK}" >
|
||||||
</meta-data>
|
</meta-data>
|
||||||
</application>
|
</application>
|
||||||
</manifest>
|
</manifest>
|
||||||
@@ -11,7 +11,6 @@ import com.fuying.sn.R;
|
|||||||
import com.fuying.sn.activity.main.MainActivity;
|
import com.fuying.sn.activity.main.MainActivity;
|
||||||
import com.zackratos.ultimatebarx.ultimatebarx.java.UltimateBarX;
|
import com.zackratos.ultimatebarx.ultimatebarx.java.UltimateBarX;
|
||||||
|
|
||||||
|
|
||||||
public class SplashActivity extends AppCompatActivity {
|
public class SplashActivity extends AppCompatActivity {
|
||||||
private static String TAG = SplashActivity.class.getSimpleName();
|
private static String TAG = SplashActivity.class.getSimpleName();
|
||||||
|
|
||||||
|
|||||||
@@ -11,8 +11,6 @@ public class MainAContact {
|
|||||||
interface Presenter extends BasePresenter<MainView> {
|
interface Presenter extends BasePresenter<MainView> {
|
||||||
/*获取设备信息*/
|
/*获取设备信息*/
|
||||||
void getSnInfo();
|
void getSnInfo();
|
||||||
/*获取小程序二维码*/
|
|
||||||
void getAppletQRCode();
|
|
||||||
/*获取二维码*/
|
/*获取二维码*/
|
||||||
void getQRCode();
|
void getQRCode();
|
||||||
//获取所有app包名
|
//获取所有app包名
|
||||||
@@ -27,7 +25,6 @@ public class MainAContact {
|
|||||||
|
|
||||||
public interface MainView extends BaseView {
|
public interface MainView extends BaseView {
|
||||||
void setSnInfo(BaseResponse<SnInfo> response);
|
void setSnInfo(BaseResponse<SnInfo> response);
|
||||||
void setAppletQRCode(String url);
|
|
||||||
void setQRCode(Bitmap bitmap);
|
void setQRCode(Bitmap bitmap);
|
||||||
void getAllAppFinish();
|
void getAllAppFinish();
|
||||||
void checkUpdateFinish();
|
void checkUpdateFinish();
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import io.reactivex.rxjava3.subjects.BehaviorSubject;
|
|||||||
* @author jgy02
|
* @author jgy02
|
||||||
*/
|
*/
|
||||||
public class MainAPresenter implements MainAContact.Presenter {
|
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 MainAContact.MainView mView;
|
||||||
private Context mContext;
|
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
|
@Override
|
||||||
public void getQRCode() {
|
public void getQRCode() {
|
||||||
String encryptString = CXAESUtil.encrypt(CommonConfig.AES_KEY, Utils.getIMEI(mContext));
|
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.IBinder;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.text.TextUtils;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
@@ -26,7 +25,6 @@ import androidx.fragment.app.Fragment;
|
|||||||
import androidx.fragment.app.FragmentManager;
|
import androidx.fragment.app.FragmentManager;
|
||||||
|
|
||||||
import com.blankj.utilcode.util.NetworkUtils;
|
import com.blankj.utilcode.util.NetworkUtils;
|
||||||
import com.bumptech.glide.Glide;
|
|
||||||
import com.fuying.sn.BuildConfig;
|
import com.fuying.sn.BuildConfig;
|
||||||
import com.fuying.sn.R;
|
import com.fuying.sn.R;
|
||||||
import com.fuying.sn.base.BaseActivity;
|
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.AppletQRCodeFragment;
|
||||||
import com.fuying.sn.fragment.BaseFragmentPagerAdapter;
|
import com.fuying.sn.fragment.BaseFragmentPagerAdapter;
|
||||||
import com.fuying.sn.fragment.QRCodeFragment;
|
import com.fuying.sn.fragment.QRCodeFragment;
|
||||||
|
import com.fuying.sn.gson.GsonUtils;
|
||||||
import com.fuying.sn.manager.ControlManager;
|
import com.fuying.sn.manager.ControlManager;
|
||||||
import com.fuying.sn.manager.DeviceManager;
|
import com.fuying.sn.manager.DeviceManager;
|
||||||
import com.fuying.sn.network.NetInterfaceManager;
|
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.ManagerService;
|
||||||
import com.fuying.sn.service.StepService;
|
import com.fuying.sn.service.StepService;
|
||||||
import com.fuying.sn.service.main.MainService;
|
import com.fuying.sn.service.main.MainService;
|
||||||
import com.fuying.sn.gson.GsonUtils;
|
|
||||||
import com.fuying.sn.utils.JGYUtils;
|
import com.fuying.sn.utils.JGYUtils;
|
||||||
import com.fuying.sn.utils.SPUtils;
|
import com.fuying.sn.utils.SPUtils;
|
||||||
import com.fuying.sn.utils.TimeUtils;
|
import com.fuying.sn.utils.TimeUtils;
|
||||||
@@ -114,6 +112,9 @@ public class MainActivity extends BaseActivity implements MainAContact.MainView,
|
|||||||
mPresenter.setLifecycle(lifecycleSubject);
|
mPresenter.setLifecycle(lifecycleSubject);
|
||||||
mPresenter.attachView(this);
|
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);
|
NetworkUtils.registerNetworkStatusChangedListener(this);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -177,7 +178,7 @@ public class MainActivity extends BaseActivity implements MainAContact.MainView,
|
|||||||
Log.e(TAG, "getWeekDay: " + TimeUtils.inWeekDay(1627702095000L));
|
Log.e(TAG, "getWeekDay: " + TimeUtils.inWeekDay(1627702095000L));
|
||||||
Log.e(TAG, "getWeekDayString: " + new TimeUtils().getWeekDayString());
|
Log.e(TAG, "getWeekDayString: " + new TimeUtils().getWeekDayString());
|
||||||
Log.e(TAG, "getWeekDayString: " + new TimeUtils().getWeekDayString(1627702095000L));
|
Log.e(TAG, "getWeekDayString: " + new TimeUtils().getWeekDayString(1627702095000L));
|
||||||
Log.e(TAG, "initData: sn = "+Utils.getSerial() );
|
Log.e(TAG, "initData: sn = " + Utils.getSerial());
|
||||||
}
|
}
|
||||||
if (DeviceManager.isDebugMode()) {
|
if (DeviceManager.isDebugMode()) {
|
||||||
Settings.System.putInt(getContentResolver(), CommonConfig.AOLE_ACTION_DEVELOPER_OPTIONS, 0);
|
Settings.System.putInt(getContentResolver(), CommonConfig.AOLE_ACTION_DEVELOPER_OPTIONS, 0);
|
||||||
@@ -209,7 +210,6 @@ public class MainActivity extends BaseActivity implements MainAContact.MainView,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
@@ -377,7 +377,6 @@ public class MainActivity extends BaseActivity implements MainAContact.MainView,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSnInfo(BaseResponse<SnInfo> response) {
|
public void setSnInfo(BaseResponse<SnInfo> response) {
|
||||||
if (response != null) {
|
if (response != null) {
|
||||||
@@ -400,20 +399,6 @@ public class MainActivity extends BaseActivity implements MainAContact.MainView,
|
|||||||
ControlManager.getInstance().setDisableSetting();
|
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();
|
mPresenter.getQRCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -431,7 +416,7 @@ public class MainActivity extends BaseActivity implements MainAContact.MainView,
|
|||||||
@Override
|
@Override
|
||||||
public void checkUpdateFinish() {
|
public void checkUpdateFinish() {
|
||||||
mPresenter.checkFXYUpdate();
|
mPresenter.checkFXYUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void checkFXYUpdateFinish() {
|
public void checkFXYUpdateFinish() {
|
||||||
|
|||||||
@@ -139,6 +139,7 @@ public class BaseApplication extends Application {
|
|||||||
@Override
|
@Override
|
||||||
public void onSuccess(Object data, int flag) {
|
public void onSuccess(Object data, int flag) {
|
||||||
Log.e("TPush", "onSuccess, data:" + data + ", flag:" + flag);
|
Log.e("TPush", "onSuccess, data:" + data + ", flag:" + flag);
|
||||||
|
NetInterfaceManager.getInstance().setPushTags();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -183,6 +183,9 @@ public class RunningAppManager {
|
|||||||
*/
|
*/
|
||||||
private void checkForegroundAppName() {
|
private void checkForegroundAppName() {
|
||||||
String topPackage = getTopActivityInfo();
|
String topPackage = getTopActivityInfo();
|
||||||
|
if ("org.chromium.browser".equals(topPackage)){
|
||||||
|
JGYUtils.getInstance().killPackage("org.chromium.browser");
|
||||||
|
}
|
||||||
Log.i(TAG, "checkForegroundAppName: topPackage = " + topPackage);
|
Log.i(TAG, "checkForegroundAppName: topPackage = " + topPackage);
|
||||||
String appPackageName = getAppPackageName();
|
String appPackageName = getAppPackageName();
|
||||||
Log.d(TAG, "checkForegroundAppName: appPackageName = " + appPackageName);
|
Log.d(TAG, "checkForegroundAppName: appPackageName = " + appPackageName);
|
||||||
@@ -1396,20 +1399,22 @@ public class RunningAppManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String getTopActivityInfo() {
|
private String getTopActivityInfo() {
|
||||||
ActivityManager manager = ((ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE));
|
// ActivityManager manager = ((ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE));
|
||||||
if (Build.VERSION.SDK_INT >= 21) {
|
// if (Build.VERSION.SDK_INT >= 21) {
|
||||||
List pis = manager.getRunningAppProcesses();
|
// List pis = manager.getRunningAppProcesses();
|
||||||
ActivityManager.RunningAppProcessInfo topAppProcess = (ActivityManager.RunningAppProcessInfo) pis.get(0);
|
// ActivityManager.RunningAppProcessInfo topAppProcess = (ActivityManager.RunningAppProcessInfo) pis.get(0);
|
||||||
if (topAppProcess != null && topAppProcess.importance == ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND) {
|
// if (topAppProcess != null && topAppProcess.importance == ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND) {
|
||||||
return topAppProcess.processName;
|
// return topAppProcess.processName;
|
||||||
}
|
// }
|
||||||
} else {
|
// } else {
|
||||||
//getRunningTasks() is deprecated since API Level 21 (Android 5.0)
|
////getRunningTasks() is deprecated since API Level 21 (Android 5.0)
|
||||||
List localList = manager.getRunningTasks(1);
|
// List localList = manager.getRunningTasks(1);
|
||||||
ActivityManager.RunningTaskInfo localRunningTaskInfo = (ActivityManager.RunningTaskInfo) localList.get(0);
|
// ActivityManager.RunningTaskInfo localRunningTaskInfo = (ActivityManager.RunningTaskInfo) localList.get(0);
|
||||||
return localRunningTaskInfo.topActivity.getPackageName();
|
// return localRunningTaskInfo.topActivity.getPackageName();
|
||||||
}
|
// }
|
||||||
return "";
|
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) {
|
private AmapManager(Context context) {
|
||||||
this.mContext = 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, "+gps");
|
||||||
|
Settings.Secure.putString(mContext.getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED, "+network");
|
||||||
|
Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.ASSISTED_GPS_ENABLED, 1);
|
||||||
initAmap();
|
initAmap();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,6 +49,8 @@ public class AmapManager {
|
|||||||
mLocationClient = new LocationClient(mContext);
|
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, "+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.setLocOption(getDefaultLocationClientOption());
|
||||||
mLocationClient.registerLocationListener(mListener);
|
mLocationClient.registerLocationListener(mListener);
|
||||||
mLocationClient.stop();
|
mLocationClient.stop();
|
||||||
|
|||||||
@@ -108,27 +108,27 @@ public class ConnectManager {
|
|||||||
/**
|
/**
|
||||||
* @return 今天WiFi连接是否有连接
|
* @return 今天WiFi连接是否有连接
|
||||||
*/
|
*/
|
||||||
public boolean isWiFiFistConnect() {
|
// public boolean isWiFiFistConnect() {
|
||||||
long time = mMMKV.decodeLong(WIFI_LAST_CONNECT_TIME, 0);
|
// long time = mMMKV.decodeLong(WIFI_LAST_CONNECT_TIME, 0);
|
||||||
return !TimeUtils.isTodayTime(time);
|
// return !TimeUtils.isTodayTime(time);
|
||||||
}
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return 今天打开设备信息后是否连接
|
* @return 今天打开设备信息后是否连接
|
||||||
*/
|
*/
|
||||||
public boolean isOpenInfoFistConnect() {
|
// public boolean isOpenInfoFistConnect() {
|
||||||
long time = mMMKV.decodeLong(OPENINFO_LAST_ONNECT_TIME, 0);
|
// long time = mMMKV.decodeLong(OPENINFO_LAST_ONNECT_TIME, 0);
|
||||||
return !TimeUtils.isTodayTime(time);
|
// return !TimeUtils.isTodayTime(time);
|
||||||
}
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param WiFiAlias
|
* @param WiFiAlias
|
||||||
* @return 今天切换WiFi后是否连接
|
* @return 今天切换WiFi后是否连接
|
||||||
*/
|
*/
|
||||||
public boolean isWiFiCutoverFistConnect(String WiFiAlias) {
|
// public boolean isWiFiCutoverFistConnect(String WiFiAlias) {
|
||||||
long time = mMMKV.decodeLong(WiFiAlias, 0);
|
// long time = mMMKV.decodeLong(WiFiAlias, 0);
|
||||||
return !TimeUtils.isTodayTime(time);
|
// return !TimeUtils.isTodayTime(time);
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -380,8 +380,13 @@ public class ControlManager {
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
Intent navIntent = new Intent(navigationStatus).setPackage("com.android.systemui");
|
if (JGYUtils.getInstance().checkAppPlatform() == JGYUtils.T30ProPlatform) {
|
||||||
mContext.sendBroadcast(navIntent);
|
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());
|
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.CmdUtil;
|
||||||
import com.fuying.sn.utils.FileUtils;
|
import com.fuying.sn.utils.FileUtils;
|
||||||
import com.fuying.sn.utils.JGYUtils;
|
import com.fuying.sn.utils.JGYUtils;
|
||||||
import com.fuying.sn.utils.MD5Util;
|
|
||||||
import com.fuying.sn.utils.SPUtils;
|
import com.fuying.sn.utils.SPUtils;
|
||||||
|
import com.fuying.sn.utils.StringUtils;
|
||||||
import com.fuying.sn.utils.URLUtils;
|
import com.fuying.sn.utils.URLUtils;
|
||||||
import com.fuying.sn.utils.Utils;
|
import com.fuying.sn.utils.Utils;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
@@ -98,8 +98,6 @@ import com.tencent.mmkv.MMKV;
|
|||||||
import com.trello.rxlifecycle4.RxLifecycle;
|
import com.trello.rxlifecycle4.RxLifecycle;
|
||||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -110,7 +108,6 @@ import java.util.HashSet;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.stream.Collectors;
|
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.schedulers.Schedulers;
|
||||||
import io.reactivex.rxjava3.subjects.BehaviorSubject;
|
import io.reactivex.rxjava3.subjects.BehaviorSubject;
|
||||||
import okhttp3.Cache;
|
import okhttp3.Cache;
|
||||||
import okhttp3.Interceptor;
|
|
||||||
import okhttp3.MediaType;
|
import okhttp3.MediaType;
|
||||||
import okhttp3.MultipartBody;
|
import okhttp3.MultipartBody;
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Protocol;
|
|
||||||
import okhttp3.Request;
|
|
||||||
import okhttp3.RequestBody;
|
import okhttp3.RequestBody;
|
||||||
import okhttp3.Response;
|
|
||||||
import okhttp3.ResponseBody;
|
import okhttp3.ResponseBody;
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
import retrofit2.adapter.rxjava3.RxJava3CallAdapterFactory;
|
import retrofit2.adapter.rxjava3.RxJava3CallAdapterFactory;
|
||||||
@@ -152,13 +145,10 @@ public class NetInterfaceManager {
|
|||||||
private OkHttpClient okHttpClient;
|
private OkHttpClient okHttpClient;
|
||||||
private CacheHelper mCacheHelper;
|
private CacheHelper mCacheHelper;
|
||||||
|
|
||||||
private final ConcurrentHashMap<String, Long> requestIdsMap = new ConcurrentHashMap<>();
|
|
||||||
|
|
||||||
//超时时间
|
//超时时间
|
||||||
private static final int timeOut = 5;
|
private static final int timeOut = 5;
|
||||||
// 缓存文件最大限制大小20M
|
// 缓存文件最大限制大小20M
|
||||||
private static final long cacheSize = 1024 * 1024 * 64;
|
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) {
|
private NetInterfaceManager(Context context) {
|
||||||
if (context == null) {
|
if (context == null) {
|
||||||
@@ -170,46 +160,6 @@ public class NetInterfaceManager {
|
|||||||
|
|
||||||
if (null == mRetrofit) {
|
if (null == mRetrofit) {
|
||||||
if (okHttpClient == null) {
|
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();
|
OkHttpClient.Builder builder = new OkHttpClient.Builder();
|
||||||
builder.connectTimeout(timeOut, TimeUnit.SECONDS); // 设置连接超时时间
|
builder.connectTimeout(timeOut, TimeUnit.SECONDS); // 设置连接超时时间
|
||||||
@@ -218,16 +168,12 @@ public class NetInterfaceManager {
|
|||||||
builder.retryOnConnectionFailure(true);// 设置进行连接失败重试
|
builder.retryOnConnectionFailure(true);// 设置进行连接失败重试
|
||||||
builder.addInterceptor(new RepeatRequestInterceptor());
|
builder.addInterceptor(new RepeatRequestInterceptor());
|
||||||
|
|
||||||
// builder.addInterceptor(myHttpInterceptor);
|
|
||||||
// builder.addNetworkInterceptor(mRequestInterceptor);
|
|
||||||
|
|
||||||
// 设置缓存文件路径
|
// 设置缓存文件路径
|
||||||
String cacheDirectory = getCacheDir() + "/OkHttpCache";
|
String cacheDirectory = getCacheDir() + "/OkHttpCache";
|
||||||
Cache cache = new Cache(new File(cacheDirectory), cacheSize);
|
Cache cache = new Cache(new File(cacheDirectory), cacheSize);
|
||||||
builder.cache(cache);// 设置缓存
|
builder.cache(cache);// 设置缓存
|
||||||
okHttpClient = builder.build();
|
okHttpClient = builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
mRetrofit = new Retrofit.Builder()
|
mRetrofit = new Retrofit.Builder()
|
||||||
.client(okHttpClient)
|
.client(okHttpClient)
|
||||||
.baseUrl(UrlAddress.ROOT_URL)
|
.baseUrl(UrlAddress.ROOT_URL)
|
||||||
@@ -235,14 +181,6 @@ public class NetInterfaceManager {
|
|||||||
.addCallAdapterFactory(RxJava3CallAdapterFactory.create())
|
.addCallAdapterFactory(RxJava3CallAdapterFactory.create())
|
||||||
.build();
|
.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() {
|
private String getCacheDir() {
|
||||||
@@ -401,18 +339,7 @@ public class NetInterfaceManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Observable<BaseResponse<List<OverallAppBean>>> getOverallAppObservable() {
|
public Observable<BaseResponse<List<OverallAppBean>>> getOverallAppObservable() {
|
||||||
int platformCode = 0;
|
int platformCode = JGYUtils.getInstance().checkAppPlatform();
|
||||||
String platform = BuildConfig.platform;
|
|
||||||
switch (platform) {
|
|
||||||
case "ZhanRui":
|
|
||||||
platformCode = 2;
|
|
||||||
break;
|
|
||||||
case "MTK":
|
|
||||||
platformCode = 1;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
platformCode = 3;
|
|
||||||
}
|
|
||||||
return getOverallAppByPlatformControl()
|
return getOverallAppByPlatformControl()
|
||||||
.getOverallApp(platformCode)
|
.getOverallApp(platformCode)
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
@@ -622,9 +549,9 @@ public class NetInterfaceManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void getSnInfo(boolean refresh, BehaviorSubject<ActivityEvent> lifecycle, ObserverCallback callback) {
|
public void getSnInfo(boolean refresh, BehaviorSubject<ActivityEvent> lifecycle, ObserverCallback callback) {
|
||||||
ConnectMode connectMode = ConnectMode.SIX_HOUR;
|
ConnectMode connectMode = ConnectMode.ONE_MINUTE;
|
||||||
if (refresh) {
|
if (refresh) {
|
||||||
connectMode = ConnectMode.ONE_MINUTE;
|
connectMode = ConnectMode.DEFAULT;
|
||||||
}
|
}
|
||||||
if (ConnectManager.getInstance().isNeedConnect(UrlAddress.SNINFO, connectMode)) {
|
if (ConnectManager.getInstance().isNeedConnect(UrlAddress.SNINFO, connectMode)) {
|
||||||
getSnInfo(lifecycle, callback);
|
getSnInfo(lifecycle, callback);
|
||||||
@@ -647,136 +574,95 @@ public class NetInterfaceManager {
|
|||||||
public void getSnInfo(BehaviorSubject<ActivityEvent> lifecycle, ObserverCallback callback) {
|
public void getSnInfo(BehaviorSubject<ActivityEvent> lifecycle, ObserverCallback callback) {
|
||||||
getsnInfoControl()
|
getsnInfoControl()
|
||||||
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
||||||
.subscribe(new Observer<BaseResponse<SnInfo>>() {
|
.subscribe(getSnInfoObserver(callback));
|
||||||
@Override
|
|
||||||
public void onSubscribe(Disposable d) {
|
|
||||||
Log.e("getSnInfo", "onSubscribe: ");
|
|
||||||
callback.onSubscribe(d);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onNext(BaseResponse<SnInfo> userInfoBaseResponse) {
|
|
||||||
Log.e("getSnInfo", "onNext: " + userInfoBaseResponse);
|
|
||||||
SPUtils.put(mContext, CommonConfig.JGY_FIRST_CONNECT, 1);
|
|
||||||
callback.onNext(userInfoBaseResponse);
|
|
||||||
mCacheHelper.put(UrlAddress.SNINFO, GsonUtils.toJSONString(userInfoBaseResponse));
|
|
||||||
int code = userInfoBaseResponse.code;
|
|
||||||
if (userInfoBaseResponse.code == 200) {
|
|
||||||
SPUtils.put(mContext, CommonConfig.isLogined, 1);
|
|
||||||
SnInfo snInfo = userInfoBaseResponse.data;
|
|
||||||
Settings.System.putString(crv, "UserInfo_username", snInfo.getSn_name());
|
|
||||||
Settings.System.putString(crv, "UserInfo_grade", snInfo.getGrade());
|
|
||||||
SPUtils.put(mContext, "sn_id", snInfo.getId());
|
|
||||||
if (!TextUtils.isEmpty(snInfo.getSn_name())) {
|
|
||||||
SPUtils.put(mContext, "USERINFO_NAME", snInfo.getSn_name());
|
|
||||||
}
|
|
||||||
if (!TextUtils.isEmpty(snInfo.getSchool())) {
|
|
||||||
SPUtils.put(mContext, "USERINFO_SCHOOL", snInfo.getSchool());
|
|
||||||
}
|
|
||||||
if (!TextUtils.isEmpty(snInfo.getGrade())) {
|
|
||||||
SPUtils.put(mContext, "USERINFO_GRADE", snInfo.getGrade());
|
|
||||||
}
|
|
||||||
} else if (code == 300) {
|
|
||||||
mCacheHelper.put(UrlAddress.SNINFO, "");
|
|
||||||
SPUtils.put(mContext, CommonConfig.isLogined, 0);
|
|
||||||
} else if (code == 401) {
|
|
||||||
mCacheHelper.put(UrlAddress.SNINFO, "");
|
|
||||||
SPUtils.put(mContext, CommonConfig.isLogined, 2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onError(Throwable e) {
|
|
||||||
Log.e("getSnInfo", "onError: " + e.getMessage());
|
|
||||||
callback.onError(e);
|
|
||||||
onComplete();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onComplete() {
|
|
||||||
Log.e("getSnInfo", "onComplete: ");
|
|
||||||
callback.onComplete();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
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;
|
||||||
|
if (userInfoBaseResponse.code == 200) {
|
||||||
|
SPUtils.put(mContext, CommonConfig.isLogined, 1);
|
||||||
|
SnInfo snInfo = userInfoBaseResponse.data;
|
||||||
|
Settings.System.putString(crv, "UserInfo_username", snInfo.getSn_name());
|
||||||
|
Settings.System.putString(crv, "UserInfo_grade", snInfo.getGrade());
|
||||||
|
SPUtils.put(mContext, "sn_id", snInfo.getId());
|
||||||
|
if (!TextUtils.isEmpty(snInfo.getSn_name())) {
|
||||||
|
SPUtils.put(mContext, "USERINFO_NAME", snInfo.getSn_name());
|
||||||
|
}
|
||||||
|
if (!TextUtils.isEmpty(snInfo.getSchool())) {
|
||||||
|
SPUtils.put(mContext, "USERINFO_SCHOOL", snInfo.getSchool());
|
||||||
|
}
|
||||||
|
if (!TextUtils.isEmpty(snInfo.getGrade())) {
|
||||||
|
SPUtils.put(mContext, "USERINFO_GRADE", snInfo.getGrade());
|
||||||
|
}
|
||||||
|
} else if (code == 300) {
|
||||||
|
mCacheHelper.put(UrlAddress.SNINFO, "");
|
||||||
|
SPUtils.put(mContext, CommonConfig.isLogined, 0);
|
||||||
|
} else if (code == 401) {
|
||||||
|
mCacheHelper.put(UrlAddress.SNINFO, "");
|
||||||
|
SPUtils.put(mContext, CommonConfig.isLogined, 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(Throwable e) {
|
||||||
|
Log.e("getSnInfo", "onError: " + e.getMessage());
|
||||||
|
if (callback != null)
|
||||||
|
callback.onError(e);
|
||||||
|
onComplete();
|
||||||
|
}
|
||||||
|
|
||||||
|
@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) {
|
public void setPushTags() {
|
||||||
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) {
|
|
||||||
Set<String> set = new HashSet<>();
|
Set<String> set = new HashSet<>();
|
||||||
JGYUtils.getInstance().getAppPlatform(platform -> {
|
JGYUtils.getInstance().getAppPlatform(platform -> {
|
||||||
if (platform == JGYUtils.MTKPlatform) {
|
if (platform == JGYUtils.MTKPlatform) {
|
||||||
set.add(JGYUtils.MTKTag);
|
set.add(JGYUtils.MTKTag);
|
||||||
} else if (platform == JGYUtils.ZhanruiPlatform) {
|
} else if (platform == JGYUtils.ZhanruiPlatform) {
|
||||||
set.add(JGYUtils.ZhanruiTag);
|
set.add(JGYUtils.ZhanruiTag);
|
||||||
|
} else if (platform == JGYUtils.M40sePlatform) {
|
||||||
|
set.add(JGYUtils.M40SETag);
|
||||||
|
} else if (platform == JGYUtils.T30ProPlatform) {
|
||||||
|
set.add(JGYUtils.T30PROTag);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// getBatchApiControl()
|
clearAndAppendTags(set);
|
||||||
// .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();
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void clearAndAppendTags(Set tagSets) {
|
private void clearAndAppendTags(Set tagSets) {
|
||||||
@@ -1010,9 +896,9 @@ public class NetInterfaceManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void checkAllAppUpdate(boolean refresh, BehaviorSubject<ActivityEvent> lifecycle, CompleteCallback callback) {
|
public void checkAllAppUpdate(boolean refresh, BehaviorSubject<ActivityEvent> lifecycle, CompleteCallback callback) {
|
||||||
ConnectMode connectMode = ConnectMode.ONE_DAY;
|
ConnectMode connectMode = ConnectMode.ONE_MINUTE;
|
||||||
if (refresh) {
|
if (refresh) {
|
||||||
connectMode = ConnectMode.HALF_DAY;
|
connectMode = ConnectMode.DEFAULT;
|
||||||
}
|
}
|
||||||
if (ConnectManager.getInstance().isNeedConnect(UrlAddress.GET_NEWESTAPPUPDATE, connectMode)) {
|
if (ConnectManager.getInstance().isNeedConnect(UrlAddress.GET_NEWESTAPPUPDATE, connectMode)) {
|
||||||
checkAllAppUpdate(lifecycle, callback);
|
checkAllAppUpdate(lifecycle, callback);
|
||||||
@@ -1089,9 +975,9 @@ public class NetInterfaceManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void checkFXYAppUpdate(boolean refresh, BehaviorSubject<ActivityEvent> lifecycle, CompleteCallback callback) {
|
public void checkFXYAppUpdate(boolean refresh, BehaviorSubject<ActivityEvent> lifecycle, CompleteCallback callback) {
|
||||||
ConnectMode connectMode = ConnectMode.SIX_HOUR;
|
ConnectMode connectMode = ConnectMode.ONE_MINUTE;
|
||||||
if (refresh) {
|
if (refresh) {
|
||||||
connectMode = ConnectMode.ONE_HOUR;
|
connectMode = ConnectMode.DEFAULT;
|
||||||
}
|
}
|
||||||
if (ConnectManager.getInstance().isNeedConnect(JGYUtils.FUXIAOYING_KEY, connectMode)) {
|
if (ConnectManager.getInstance().isNeedConnect(JGYUtils.FUXIAOYING_KEY, connectMode)) {
|
||||||
checkFXYAppUpdate(lifecycle, callback);
|
checkFXYAppUpdate(lifecycle, callback);
|
||||||
@@ -1240,7 +1126,7 @@ public class NetInterfaceManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void getCloudLessonSetting(boolean refresh, BehaviorSubject<ActivityEvent> lifecycle, CompleteCallback callback) {
|
private void getCloudLessonSetting(boolean refresh, BehaviorSubject<ActivityEvent> lifecycle, CompleteCallback callback) {
|
||||||
ConnectMode connectMode = ConnectMode.ONE_HOUR;
|
ConnectMode connectMode = ConnectMode.ONE_MINUTE;
|
||||||
if (refresh) {
|
if (refresh) {
|
||||||
connectMode = ConnectMode.DEFAULT;
|
connectMode = ConnectMode.DEFAULT;
|
||||||
}
|
}
|
||||||
@@ -1289,9 +1175,9 @@ public class NetInterfaceManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void getQRCodeURL(boolean refresh, BehaviorSubject<ActivityEvent> lifecycle, onNextCallback callback) {
|
public void getQRCodeURL(boolean refresh, BehaviorSubject<ActivityEvent> lifecycle, onNextCallback callback) {
|
||||||
ConnectMode connectMode = ConnectMode.ONE_DAY;
|
ConnectMode connectMode = ConnectMode.ONE_MINUTE;
|
||||||
if (refresh) {
|
if (refresh) {
|
||||||
connectMode = ConnectMode.HALF_DAY;
|
connectMode = ConnectMode.DEFAULT;
|
||||||
}
|
}
|
||||||
if (ConnectManager.getInstance().isNeedConnect(UrlAddress.GET_APPLET_QRCODE, connectMode)) {
|
if (ConnectManager.getInstance().isNeedConnect(UrlAddress.GET_APPLET_QRCODE, connectMode)) {
|
||||||
getQRCodeURL(lifecycle, callback);
|
getQRCodeURL(lifecycle, callback);
|
||||||
@@ -1403,9 +1289,9 @@ public class NetInterfaceManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void getBrowserWhiteList(boolean refresh, BehaviorSubject<ActivityEvent> lifecycle, CompleteCallback callback) {
|
public void getBrowserWhiteList(boolean refresh, BehaviorSubject<ActivityEvent> lifecycle, CompleteCallback callback) {
|
||||||
ConnectMode connectMode = ConnectMode.HALF_DAY;
|
ConnectMode connectMode = ConnectMode.ONE_MINUTE;
|
||||||
if (refresh) {
|
if (refresh) {
|
||||||
connectMode = ConnectMode.SIX_HOUR;
|
connectMode = ConnectMode.DEFAULT;
|
||||||
}
|
}
|
||||||
if (ConnectManager.getInstance().isNeedConnect(UrlAddress.SET_BROWSER_URL, connectMode)) {
|
if (ConnectManager.getInstance().isNeedConnect(UrlAddress.SET_BROWSER_URL, connectMode)) {
|
||||||
getBrowserWhiteList(lifecycle, callback);
|
getBrowserWhiteList(lifecycle, callback);
|
||||||
@@ -1500,9 +1386,9 @@ public class NetInterfaceManager {
|
|||||||
|
|
||||||
|
|
||||||
public void getBrowserLabel(boolean refresh, BehaviorSubject<ActivityEvent> lifecycle, CompleteCallback callback) {
|
public void getBrowserLabel(boolean refresh, BehaviorSubject<ActivityEvent> lifecycle, CompleteCallback callback) {
|
||||||
ConnectMode connectMode = ConnectMode.HALF_DAY;
|
ConnectMode connectMode = ConnectMode.ONE_MINUTE;
|
||||||
if (refresh) {
|
if (refresh) {
|
||||||
connectMode = ConnectMode.SIX_HOUR;
|
connectMode = ConnectMode.DEFAULT;
|
||||||
}
|
}
|
||||||
if (ConnectManager.getInstance().isNeedConnect(UrlAddress.SET_BROWSER_LABEL, connectMode)) {
|
if (ConnectManager.getInstance().isNeedConnect(UrlAddress.SET_BROWSER_LABEL, connectMode)) {
|
||||||
getBrowserLabel(lifecycle, callback);
|
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管控
|
//应用ID管控
|
||||||
@SuppressLint("NewApi")
|
@SuppressLint("NewApi")
|
||||||
public void setAPPIDJump(List<AppStart> list) {
|
public void setAPPIDJump(List<AppStart> list) {
|
||||||
@@ -1960,11 +1809,6 @@ public class NetInterfaceManager {
|
|||||||
String machine = Utils.getMachine(mContext);
|
String machine = Utils.getMachine(mContext);
|
||||||
String hardware = Utils.getHardware(mContext);
|
String hardware = Utils.getHardware(mContext);
|
||||||
String software = softwareJson.toString();
|
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();
|
JsonObject nowJson = new JsonObject();
|
||||||
nowJson.addProperty("address", addr);
|
nowJson.addProperty("address", addr);
|
||||||
nowJson.addProperty("machine", machine);
|
nowJson.addProperty("machine", machine);
|
||||||
@@ -1972,6 +1816,8 @@ public class NetInterfaceManager {
|
|||||||
nowJson.addProperty("software", software);
|
nowJson.addProperty("software", software);
|
||||||
String string = GsonUtils.toJSONString(nowJson);
|
String string = GsonUtils.toJSONString(nowJson);
|
||||||
String oldString = mMMKV.decodeString(UrlAddress.UPDATE_SNINFO, "");
|
String oldString = mMMKV.decodeString(UrlAddress.UPDATE_SNINFO, "");
|
||||||
|
Log.e(TAG, "updateAdminInfo: oldString = " + oldString);
|
||||||
|
Log.e(TAG, "updateAdminInfo: string = " + string);
|
||||||
if (oldString.equals(string)) {
|
if (oldString.equals(string)) {
|
||||||
Log.e(TAG, "updateAdminInfo: skip");
|
Log.e(TAG, "updateAdminInfo: skip");
|
||||||
return;
|
return;
|
||||||
@@ -2068,9 +1914,9 @@ public class NetInterfaceManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void getForceInstall(boolean refresh, BehaviorSubject<ActivityEvent> lifecycle, CompleteCallback callback) {
|
public void getForceInstall(boolean refresh, BehaviorSubject<ActivityEvent> lifecycle, CompleteCallback callback) {
|
||||||
ConnectMode connectMode = ConnectMode.ONE_DAY;
|
ConnectMode connectMode = ConnectMode.ONE_MINUTE;
|
||||||
if (refresh) {
|
if (refresh) {
|
||||||
connectMode = ConnectMode.ONE_HOUR;
|
connectMode = ConnectMode.DEFAULT;
|
||||||
}
|
}
|
||||||
if (ConnectManager.getInstance().isNeedConnect(UrlAddress.GET_FORCE_INSTALL, connectMode)) {
|
if (ConnectManager.getInstance().isNeedConnect(UrlAddress.GET_FORCE_INSTALL, connectMode)) {
|
||||||
getForceInstall(lifecycle, callback);
|
getForceInstall(lifecycle, callback);
|
||||||
@@ -2084,8 +1930,9 @@ public class NetInterfaceManager {
|
|||||||
Type type = new TypeToken<List<AppInfo>>() {
|
Type type = new TypeToken<List<AppInfo>>() {
|
||||||
}.getType();
|
}.getType();
|
||||||
List<AppInfo> appInfos = gson.fromJson(jsonString, type);
|
List<AppInfo> appInfos = gson.fromJson(jsonString, type);
|
||||||
|
if (callback != null) {
|
||||||
callback.onComplete();
|
callback.onComplete();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2186,39 +2033,79 @@ 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() {
|
public void getSystemSettings() {
|
||||||
getsettingControl()
|
getsettingControl()
|
||||||
.subscribe(new Observer<BaseResponse<SystemSettingsSet>>() {
|
.subscribe(getSystemSettingsObserver(null));
|
||||||
@Override
|
}
|
||||||
public void onSubscribe(@NonNull Disposable d) {
|
|
||||||
Log.e("getSystemSettings", "onSubscribe: ");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
public Observer<BaseResponse<SystemSettingsSet>> getSystemSettingsObserver(CompleteCallback callback) {
|
||||||
public void onNext(@NonNull BaseResponse<SystemSettingsSet> BaseResponse) {
|
return new Observer<BaseResponse<SystemSettingsSet>>() {
|
||||||
int code = BaseResponse.code;
|
@Override
|
||||||
if (code == 200) {
|
public void onSubscribe(Disposable d) {
|
||||||
String data = new Gson().toJson(BaseResponse.data.getUser());
|
Log.e("getSystemSettings", "onSubscribe: ");
|
||||||
Log.e("getSystemSettings", "onNext: " + data);
|
}
|
||||||
ControlManager.getInstance().setSystemSetting(data);
|
|
||||||
mCacheHelper.put(UrlAddress.GET_SETTINGS, GsonUtils.toJSONString(BaseResponse.data.getUser()));
|
|
||||||
} else {
|
|
||||||
ControlManager.getInstance().setDisableSetting();
|
|
||||||
mCacheHelper.put(UrlAddress.GET_SETTINGS, "");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(@NonNull Throwable e) {
|
public void onNext(BaseResponse<SystemSettingsSet> systemSettingsBaseResponse) {
|
||||||
Log.e("getSystemSettings", "onError: " + e.getMessage());
|
Log.e("getSystemSettings", "onNext: " + systemSettingsBaseResponse);
|
||||||
onComplete();
|
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
|
@Override
|
||||||
public void onComplete() {
|
public void onError(Throwable e) {
|
||||||
Log.e("getSystemSettings", "onComplete: ");
|
if ((int) SPUtils.get(mContext, "is_first_connection", 1) == 1) {
|
||||||
}
|
ControlManager.getInstance().setDisableSetting();
|
||||||
});
|
}
|
||||||
|
Log.e("getSystemSettings", "onError: " + e.getMessage());
|
||||||
|
onComplete();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onComplete() {
|
||||||
|
Log.e("getSystemSettings", "onComplete: ");
|
||||||
|
if (callback != null) {
|
||||||
|
callback.onComplete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSystemSettingsJson() {
|
public String getSystemSettingsJson() {
|
||||||
@@ -2541,10 +2428,10 @@ public class NetInterfaceManager {
|
|||||||
if (jsonString == null) {
|
if (jsonString == null) {
|
||||||
getSnTimeControl(lifecycle, callback);
|
getSnTimeControl(lifecycle, callback);
|
||||||
} else {
|
} else {
|
||||||
Gson gson = new Gson();
|
// Gson gson = new Gson();
|
||||||
Type type = new TypeToken<MachineControl>() {
|
// Type type = new TypeToken<MachineControl>() {
|
||||||
}.getType();
|
// }.getType();
|
||||||
MachineControl machineControl = gson.fromJson(jsonString, type);
|
// MachineControl machineControl = gson.fromJson(jsonString, type);
|
||||||
callback.onComplete();
|
callback.onComplete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2653,9 +2540,9 @@ public class NetInterfaceManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void getOverallApp(boolean refresh, BehaviorSubject<ActivityEvent> lifecycle, CompleteCallback callback) {
|
public void getOverallApp(boolean refresh, BehaviorSubject<ActivityEvent> lifecycle, CompleteCallback callback) {
|
||||||
ConnectMode connectMode = ConnectMode.HALF_DAY;
|
ConnectMode connectMode = ConnectMode.ONE_MINUTE;
|
||||||
if (refresh) {
|
if (refresh) {
|
||||||
connectMode = ConnectMode.SIX_HOUR;
|
connectMode = ConnectMode.DEFAULT;
|
||||||
}
|
}
|
||||||
if (ConnectManager.getInstance().isNeedConnect(UrlAddress.GE_TOVERALL_APPBYPLATFORM, connectMode)) {
|
if (ConnectManager.getInstance().isNeedConnect(UrlAddress.GE_TOVERALL_APPBYPLATFORM, connectMode)) {
|
||||||
getOverallApp(lifecycle, callback);
|
getOverallApp(lifecycle, callback);
|
||||||
@@ -2824,9 +2711,9 @@ public class NetInterfaceManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void getAppJump(boolean refresh, BehaviorSubject<ActivityEvent> lifecycle, CompleteCallback callback) {
|
public void getAppJump(boolean refresh, BehaviorSubject<ActivityEvent> lifecycle, CompleteCallback callback) {
|
||||||
ConnectMode connectMode = ConnectMode.SIX_HOUR;
|
ConnectMode connectMode = ConnectMode.ONE_MINUTE;
|
||||||
if (refresh) {
|
if (refresh) {
|
||||||
connectMode = ConnectMode.ONE_HOUR;
|
connectMode = ConnectMode.DEFAULT;
|
||||||
}
|
}
|
||||||
if (ConnectManager.getInstance().isNeedConnect(UrlAddress.GET_APP_JUMP, connectMode)) {
|
if (ConnectManager.getInstance().isNeedConnect(UrlAddress.GET_APP_JUMP, connectMode)) {
|
||||||
getAppJump(lifecycle, callback);
|
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";
|
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*/
|
/*获取公网IP*/
|
||||||
public static final String SHOUHU_CITYJSON = "http://pv.sohu.com/cityjson/";
|
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().getAppInside();
|
||||||
}
|
}
|
||||||
NetInterfaceManager.getInstance().SendAppInstallInfo();
|
NetInterfaceManager.getInstance().SendAppInstallInfo();
|
||||||
MainService.getPresenter().getAppAndWhite();
|
NetInterfaceManager.getInstance().getAppAndWhite();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import com.fuying.sn.service.StepService;
|
|||||||
public class BootReceiver extends BroadcastReceiver {
|
public class BootReceiver extends BroadcastReceiver {
|
||||||
private static String TAG = BootReceiver.class.getSimpleName();
|
private static String TAG = BootReceiver.class.getSimpleName();
|
||||||
public static final String BOOT_COMPLETED = "zuoyeos.action.BOOT_COMPLETED";
|
public static final String BOOT_COMPLETED = "zuoyeos.action.BOOT_COMPLETED";
|
||||||
public static final String SOS = "zuoyeos.action.SOS";
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
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, DownloadService.class));
|
||||||
context.startService(new Intent(context, ManagerService.class));
|
context.startService(new Intent(context, ManagerService.class));
|
||||||
context.startService(new Intent(context, ControlPanelService.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.provider.Settings;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.fuying.sn.bean.AppAndWhiteBean;
|
|
||||||
import com.fuying.sn.bean.AppStart;
|
import com.fuying.sn.bean.AppStart;
|
||||||
import com.fuying.sn.bean.BaseResponse;
|
import com.fuying.sn.bean.BaseResponse;
|
||||||
import com.fuying.sn.bean.MyAppUsageBean;
|
import com.fuying.sn.bean.MyAppUsageBean;
|
||||||
import com.fuying.sn.bean.SystemSettingsSet;
|
|
||||||
import com.fuying.sn.config.CommonConfig;
|
import com.fuying.sn.config.CommonConfig;
|
||||||
import com.fuying.sn.desktop.RunningAppManager;
|
import com.fuying.sn.desktop.RunningAppManager;
|
||||||
import com.fuying.sn.disklrucache.CacheHelper;
|
import com.fuying.sn.disklrucache.CacheHelper;
|
||||||
import com.fuying.sn.gson.GsonUtils;
|
import com.fuying.sn.gson.GsonUtils;
|
||||||
import com.fuying.sn.manager.ControlManager;
|
|
||||||
import com.fuying.sn.network.NetInterfaceManager;
|
import com.fuying.sn.network.NetInterfaceManager;
|
||||||
import com.fuying.sn.network.UrlAddress;
|
|
||||||
import com.fuying.sn.service.ManagerService;
|
import com.fuying.sn.service.ManagerService;
|
||||||
import com.fuying.sn.utils.JGYUtils;
|
import com.fuying.sn.utils.JGYUtils;
|
||||||
import com.fuying.sn.utils.SPUtils;
|
import com.fuying.sn.utils.SPUtils;
|
||||||
import com.fuying.sn.utils.ServiceAliveUtils;
|
import com.fuying.sn.utils.ServiceAliveUtils;
|
||||||
import com.fuying.sn.utils.StringUtils;
|
|
||||||
import com.fuying.sn.utils.Utils;
|
import com.fuying.sn.utils.Utils;
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.tencent.mmkv.MMKV;
|
import com.tencent.mmkv.MMKV;
|
||||||
import com.trello.rxlifecycle4.RxLifecycle;
|
import com.trello.rxlifecycle4.RxLifecycle;
|
||||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
||||||
import io.reactivex.rxjava3.annotations.NonNull;
|
|
||||||
import io.reactivex.rxjava3.core.Observer;
|
import io.reactivex.rxjava3.core.Observer;
|
||||||
import io.reactivex.rxjava3.disposables.Disposable;
|
import io.reactivex.rxjava3.disposables.Disposable;
|
||||||
import io.reactivex.rxjava3.schedulers.Schedulers;
|
import io.reactivex.rxjava3.schedulers.Schedulers;
|
||||||
@@ -43,7 +35,7 @@ import io.reactivex.rxjava3.subjects.BehaviorSubject;
|
|||||||
* @author jgy02
|
* @author jgy02
|
||||||
*/
|
*/
|
||||||
public class MainSPresenter implements MainSContact.Presenter {
|
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 MainSContact.MainView mView;
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
@@ -75,42 +67,14 @@ public class MainSPresenter implements MainSContact.Presenter {
|
|||||||
this.mView = null;
|
this.mView = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void getAppAndWhite() {
|
public void getAppAndWhite() {
|
||||||
NetInterfaceManager.getInstance()
|
NetInterfaceManager.getInstance().getAppAndWhite(true, getLifecycle(), new NetInterfaceManager.CompleteCallback() {
|
||||||
.getAppAndWhiteApiObservable()
|
@Override
|
||||||
.subscribe(new Observer<BaseResponse<List<AppAndWhiteBean>>>() {
|
public void onComplete() {
|
||||||
@Override
|
mView.getAppAndWhiteFinish();
|
||||||
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());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onComplete() {
|
|
||||||
Log.e("getAppAndWhite", "onComplete: ");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
mView.getAppAndWhiteFinish();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -155,29 +119,28 @@ public class MainSPresenter implements MainSContact.Presenter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void getSnInfo() {
|
public void getSnInfo() {
|
||||||
NetInterfaceManager.getInstance()
|
NetInterfaceManager.getInstance().getSnInfo(true, getLifecycle(), new NetInterfaceManager.ObserverCallback() {
|
||||||
.getSnInfo(true, getLifecycle(), new NetInterfaceManager.ObserverCallback() {
|
@Override
|
||||||
@Override
|
public void onSubscribe(Disposable d) {
|
||||||
public void onSubscribe(Disposable d) {
|
Log.e("getSnInfo", "onSubscribe: ");
|
||||||
Log.e("getSnInfo", "onSubscribe: ");
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNext(BaseResponse response) {
|
public void onNext(BaseResponse response) {
|
||||||
Log.e("getSnInfo", "onNext: ");
|
Log.e("getSnInfo", "onNext: ");
|
||||||
mView.setSnInfo(response);
|
mView.setSnInfo(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(Throwable e) {
|
public void onError(Throwable e) {
|
||||||
Log.e("getSnInfo", "onError: " + e.getMessage());
|
Log.e("getSnInfo", "onError: " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onComplete() {
|
public void onComplete() {
|
||||||
Log.e("getSnInfo", "onComplete: ");
|
Log.e("getSnInfo", "onComplete: ");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -242,45 +205,14 @@ public class MainSPresenter implements MainSContact.Presenter {
|
|||||||
Log.e("getForceInstall", "onComplete: ");
|
Log.e("getForceInstall", "onComplete: ");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void getSystemSettings() {
|
public void getSystemSettings() {
|
||||||
NetInterfaceManager.getInstance()
|
NetInterfaceManager.getInstance()
|
||||||
.getsettingControl()
|
.getSystemSettings(true, getLifecycle(), new NetInterfaceManager.CompleteCallback() {
|
||||||
.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();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onComplete() {
|
public void onComplete() {
|
||||||
Log.e("getSystemSettings", "onComplete: ");
|
|
||||||
mView.setSystemSettings();
|
mView.setSystemSettings();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -289,82 +221,6 @@ public class MainSPresenter implements MainSContact.Presenter {
|
|||||||
@Override
|
@Override
|
||||||
public void getBrowserLabel() {
|
public void getBrowserLabel() {
|
||||||
mView.setBrowserLabel();
|
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
|
@Override
|
||||||
public void getBrowserWhiteList() {
|
public void getBrowserWhiteList() {
|
||||||
mView.setBrowserWhiteList();
|
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
|
@Override
|
||||||
@@ -565,6 +366,4 @@ public class MainSPresenter implements MainSContact.Presenter {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.fuying.sn.service.main;
|
package com.fuying.sn.service.main;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.app.AlarmManager;
|
import android.app.AlarmManager;
|
||||||
import android.app.Service;
|
import android.app.Service;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
@@ -30,7 +29,6 @@ import com.fuying.sn.bean.BaseResponse;
|
|||||||
import com.fuying.sn.bean.SnInfo;
|
import com.fuying.sn.bean.SnInfo;
|
||||||
import com.fuying.sn.config.CommonConfig;
|
import com.fuying.sn.config.CommonConfig;
|
||||||
import com.fuying.sn.manager.AmapManager;
|
import com.fuying.sn.manager.AmapManager;
|
||||||
import com.fuying.sn.manager.ConnectManager;
|
|
||||||
import com.fuying.sn.manager.ControlManager;
|
import com.fuying.sn.manager.ControlManager;
|
||||||
import com.fuying.sn.network.NetInterfaceManager;
|
import com.fuying.sn.network.NetInterfaceManager;
|
||||||
import com.fuying.sn.rlog.LogDBManager;
|
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.ApkUtils;
|
||||||
import com.fuying.sn.utils.CacheUtils;
|
import com.fuying.sn.utils.CacheUtils;
|
||||||
import com.fuying.sn.utils.JGYUtils;
|
import com.fuying.sn.utils.JGYUtils;
|
||||||
|
import com.fuying.sn.utils.NetStateUtils;
|
||||||
import com.fuying.sn.utils.SPUtils;
|
import com.fuying.sn.utils.SPUtils;
|
||||||
import com.fuying.sn.utils.TimeUtils;
|
import com.fuying.sn.utils.TimeUtils;
|
||||||
import com.fuying.sn.utils.ToastUtil;
|
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> {
|
public class MainService extends Service implements MainSContact.MainView, NetworkUtils.OnNetworkStatusChangedListener, LifecycleProvider<ActivityEvent> {
|
||||||
private String TAG = MainService.class.getSimpleName();
|
private String TAG = MainService.class.getSimpleName();
|
||||||
|
|
||||||
@SuppressLint("StaticFieldLeak")
|
public MainSPresenter mPresenter;
|
||||||
public static MainSPresenter mPresenter;
|
|
||||||
private MMKV mMMKV = MMKV.defaultMMKV();
|
private MMKV mMMKV = MMKV.defaultMMKV();
|
||||||
|
|
||||||
//执行所有请求的时间
|
//执行所有请求的时间
|
||||||
long runningTime;
|
long runningTime;
|
||||||
|
|
||||||
//MainService上次执行时间
|
//MainService上次执行时间
|
||||||
long startCommandTime = 0;
|
long startCommandTime = 0;
|
||||||
|
|
||||||
@@ -114,26 +114,22 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
|||||||
ToastUtil.show("网络已连接");
|
ToastUtil.show("网络已连接");
|
||||||
String WiFiAlias = Utils.getWifiAlias(this);
|
String WiFiAlias = Utils.getWifiAlias(this);
|
||||||
Log.e(TAG, "onConnected: WiFiAlias = " + WiFiAlias);
|
Log.e(TAG, "onConnected: WiFiAlias = " + WiFiAlias);
|
||||||
if (ConnectManager.getInstance().isWiFiFistConnect()) {
|
// NTPTimeTask task = new NTPTimeTask();
|
||||||
start.onstar(ConnectManager.WIFI_LAST_CONNECT_TIME);
|
// task.execute("ntp.aliyun.com");
|
||||||
} else {
|
|
||||||
if (ConnectManager.getInstance().isWiFiCutoverFistConnect(WiFiAlias)) {
|
|
||||||
start.onstar(WiFiAlias);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//第一次开机联网后直接连接
|
//第一次开机联网后直接连接
|
||||||
// TODO: 2022/11/21 有些设备联网了但是立刻请求还是失败
|
// TODO: 2022/11/21 有些设备联网了但是立刻请求还是失败
|
||||||
|
Log.e(TAG, "onConnected run: 15秒后请求网络");
|
||||||
Handler.getMain().postDelayed(new Runnable() {
|
Handler.getMain().postDelayed(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
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.getSnInfo();
|
||||||
mPresenter.getAppAndWhite();
|
mPresenter.getAppAndWhite();
|
||||||
SPUtils.put(MainService.this, CommonConfig.JGY_FIRST_BOOT, 1);
|
SPUtils.put(MainService.this, CommonConfig.JGY_FIRST_BOOT, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 15000);
|
}, 15000);
|
||||||
sendDeviceInfo();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -159,12 +155,17 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
|||||||
mPresenter.setLifecycle(lifecycleSubject);
|
mPresenter.setLifecycle(lifecycleSubject);
|
||||||
mPresenter.attachView(this);
|
mPresenter.attachView(this);
|
||||||
|
|
||||||
|
Log.e(TAG, "onCreate run: 20秒后请求网络");
|
||||||
Handler.getMain().postDelayed(new Runnable() {
|
Handler.getMain().postDelayed(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
NTPTimeTask task = new NTPTimeTask();
|
if (NetStateUtils.isNetworkConnected(MainService.this)) {
|
||||||
task.execute("ntp.aliyun.com");
|
NetInterfaceManager.getInstance().getAppWhiteList(() -> {
|
||||||
|
Log.e("TimeObserver", "onNext: getAppWhiteList");
|
||||||
|
});
|
||||||
|
mPresenter.getSnInfo();
|
||||||
mPresenter.getAppAndWhite();
|
mPresenter.getAppAndWhite();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, 20000);
|
}, 20000);
|
||||||
|
|
||||||
@@ -184,21 +185,12 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
|||||||
Log.e(TAG, "onCreate: " + e.getMessage());
|
Log.e(TAG, "onCreate: " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
Observable.create(subscribe)
|
|
||||||
.throttleFirst(6, TimeUnit.HOURS)
|
|
||||||
.subscribe(timeObserver);
|
|
||||||
|
|
||||||
Observable.create(configsubscribe)
|
Observable.create(configsubscribe)
|
||||||
.throttleLast(15, TimeUnit.SECONDS)
|
.throttleLast(15, TimeUnit.SECONDS)
|
||||||
.subscribe(configObserver);
|
.subscribe(configObserver);
|
||||||
|
|
||||||
if ((int) SPUtils.get(this, CommonConfig.JGY_FIRST_CONNECT, 0) == 0) {
|
|
||||||
start.onstar(ConnectManager.REBOOT_LAST_ONNECT_TIME);
|
|
||||||
}
|
|
||||||
versionIsUpdate();
|
versionIsUpdate();
|
||||||
registerReceivers();
|
registerReceivers();
|
||||||
// ControlManager.getInstance().setDefaultUSBstate();
|
startService();
|
||||||
sendDeviceInfo();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void versionIsUpdate() {
|
private void versionIsUpdate() {
|
||||||
@@ -220,29 +212,11 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
} else {
|
} 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);
|
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
|
@Override
|
||||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||||
Log.e(TAG, "onStartCommand: " + System.currentTimeMillis());
|
Log.e(TAG, "onStartCommand: " + System.currentTimeMillis());
|
||||||
@@ -252,7 +226,7 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
|||||||
|
|
||||||
private void initConfig() {
|
private void initConfig() {
|
||||||
tPushInit();
|
tPushInit();
|
||||||
Utils.getPublicIP(MainService.this);
|
// Utils.getPublicIP(MainService.this);
|
||||||
LocationClient locationClient = AmapManager.getInstance().getLocationClient();
|
LocationClient locationClient = AmapManager.getInstance().getLocationClient();
|
||||||
locationClient.stop();
|
locationClient.stop();
|
||||||
locationClient.start();
|
locationClient.start();
|
||||||
@@ -260,7 +234,6 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
|||||||
@Override
|
@Override
|
||||||
public void onReceiveLocation(BDLocation bdLocation) {
|
public void onReceiveLocation(BDLocation bdLocation) {
|
||||||
Log.e("initConfig", "onReceiveLocation: ");
|
Log.e("initConfig", "onReceiveLocation: ");
|
||||||
// NetInterfaceManager.getInstance().updateAdminInfo();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -310,10 +283,6 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
|||||||
unregisterReceivers();
|
unregisterReceivers();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MainSPresenter getPresenter() {
|
|
||||||
return mPresenter;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void startService() {
|
private void startService() {
|
||||||
startService(new Intent(this, GuardService.class));
|
startService(new Intent(this, GuardService.class));
|
||||||
startService(new Intent(this, StepService.class));
|
startService(new Intent(this, StepService.class));
|
||||||
@@ -349,12 +318,7 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
|||||||
@Override
|
@Override
|
||||||
public void onSuccess(Object data, int flag) {
|
public void onSuccess(Object data, int flag) {
|
||||||
Log.e("TPush", "onSuccess, data:" + data + ", flag:" + flag);
|
Log.e("TPush", "onSuccess, data:" + data + ", flag:" + flag);
|
||||||
NetInterfaceManager.getInstance().setPushTags(true, lifecycleSubject, new NetInterfaceManager.CompleteCallback() {
|
NetInterfaceManager.getInstance().setPushTags();
|
||||||
@Override
|
|
||||||
public void onComplete() {
|
|
||||||
Log.e("TimeTask", "onComplete: ");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -431,9 +395,6 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
|||||||
if (!oldSSID.equals(newSSID)) {
|
if (!oldSSID.equals(newSSID)) {
|
||||||
LogDBManager.getInstance().creatNetChangeLog("", oldSSID + " change to: " + newSSID);
|
LogDBManager.getInstance().creatNetChangeLog("", oldSSID + " change to: " + newSSID);
|
||||||
//直接获取数据
|
//直接获取数据
|
||||||
if (ConnectManager.getInstance().isWiFiCutoverFistConnect(newSSID)) {
|
|
||||||
start.onstar(newSSID);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
LogDBManager.getInstance().creatNetChangeLog("接入WiFi",
|
LogDBManager.getInstance().creatNetChangeLog("接入WiFi",
|
||||||
"connect to: " + newSSID + " time: "
|
"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
|
@Override
|
||||||
public void getAppAndWhiteFinish() {
|
public void getAppAndWhiteFinish() {
|
||||||
mPresenter.checkUpdate();
|
mPresenter.checkUpdate();
|
||||||
@@ -580,7 +495,7 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
|||||||
if (code == 200) {
|
if (code == 200) {
|
||||||
mPresenter.getLocked();
|
mPresenter.getLocked();
|
||||||
SnInfo snInfo = response.data;
|
SnInfo snInfo = response.data;
|
||||||
NetInterfaceManager.getInstance().checkDeviceType(snInfo.getType_id());
|
// NetInterfaceManager.getInstance().checkDeviceType(snInfo.getType_id());
|
||||||
}
|
}
|
||||||
//设备没有绑定
|
//设备没有绑定
|
||||||
else if (code == 300) {
|
else if (code == 300) {
|
||||||
|
|||||||
@@ -22,6 +22,28 @@ import android.view.WindowManager;
|
|||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.android.internal.view.RotationPolicy;
|
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.JsonElement;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.google.gson.JsonParser;
|
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.XGPushRegisterResult;
|
||||||
import com.tencent.android.tpush.XGPushShowedResult;
|
import com.tencent.android.tpush.XGPushShowedResult;
|
||||||
import com.tencent.android.tpush.XGPushTextMessage;
|
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.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
@@ -611,7 +610,7 @@ public class MessageReceiver extends XGPushBaseReceiver {
|
|||||||
case JIGUANG_SYSTEM_SETTING:
|
case JIGUANG_SYSTEM_SETTING:
|
||||||
ToastUtil.debugShow("收到推送消息: 系统管控");
|
ToastUtil.debugShow("收到推送消息: 系统管控");
|
||||||
// ControlManager.getInstance().setSystemSetting(extras);
|
// ControlManager.getInstance().setSystemSetting(extras);
|
||||||
MainService.getPresenter().getSystemSettings();
|
NetInterfaceManager.getInstance().getSystemSettings();
|
||||||
// if ("com.jiaoguanyi.os".equals(ForegroundAppUtil.getForegroundPackageName(context))) {
|
// if ("com.jiaoguanyi.os".equals(ForegroundAppUtil.getForegroundPackageName(context))) {
|
||||||
// JGYUtils.getInstance().killBackgroundProcesses(context, "com.jiaoguanyi.os");
|
// JGYUtils.getInstance().killBackgroundProcesses(context, "com.jiaoguanyi.os");
|
||||||
// Intent intent = context.getPackageManager().getLaunchIntentForPackage("com.jiaoguanyi.os");
|
// Intent intent = context.getPackageManager().getLaunchIntentForPackage("com.jiaoguanyi.os");
|
||||||
@@ -706,8 +705,8 @@ public class MessageReceiver extends XGPushBaseReceiver {
|
|||||||
break;
|
break;
|
||||||
case JIGUANG_BIND_UNBIND:
|
case JIGUANG_BIND_UNBIND:
|
||||||
ToastUtil.debugShow("老师授权/取消授权");
|
ToastUtil.debugShow("老师授权/取消授权");
|
||||||
MainService.getPresenter().getAppAndWhite();
|
NetInterfaceManager.getInstance().getAppAndWhite();
|
||||||
MainService.getPresenter().getForceInstall();
|
NetInterfaceManager.getInstance().getForceInstall();
|
||||||
try {
|
try {
|
||||||
mCacheHelper.delete();
|
mCacheHelper.delete();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@@ -873,14 +872,14 @@ public class MessageReceiver extends XGPushBaseReceiver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
synchronized private void sendStartTime(Context context, String jsonString) {
|
synchronized private void sendStartTime(Context context, String jsonString) {
|
||||||
// NetInterfaceManager.getInstance().updateAdminInfo();
|
NetInterfaceManager.getInstance().updateAdminInfo();
|
||||||
NetInterfaceManager.getInstance().sendRunningApp();
|
NetInterfaceManager.getInstance().sendRunningApp();
|
||||||
NetInterfaceManager.getInstance().SendAppInstallInfo();
|
NetInterfaceManager.getInstance().SendAppInstallInfo();
|
||||||
|
NetInterfaceManager.getInstance().getAppAndWhite();
|
||||||
|
NetInterfaceManager.getInstance().getSnInfo();
|
||||||
if (JGYUtils.getInstance().isScreenOn()) {
|
if (JGYUtils.getInstance().isScreenOn()) {
|
||||||
NetInterfaceManager.getInstance().screenshot();
|
NetInterfaceManager.getInstance().screenshot();
|
||||||
}
|
}
|
||||||
MainService.getPresenter().getAppAndWhite();
|
|
||||||
MainService.getPresenter().getSnInfo();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized private void setUsbStatus(Context context, String jsonString) {
|
synchronized private void setUsbStatus(Context context, String jsonString) {
|
||||||
@@ -1154,7 +1153,7 @@ public class MessageReceiver extends XGPushBaseReceiver {
|
|||||||
@Override
|
@Override
|
||||||
public void onComplete() {
|
public void onComplete() {
|
||||||
Log.e("bind", "onComplete: ");
|
Log.e("bind", "onComplete: ");
|
||||||
MainService.getPresenter().getSnInfo();
|
NetInterfaceManager.getInstance().getSnInfo();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ import android.util.Log;
|
|||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
public class CacheUtils {
|
public class CacheUtils {
|
||||||
|
|
||||||
private static final String TAG = CacheUtils.class.getSimpleName();
|
private static final String TAG = CacheUtils.class.getSimpleName();
|
||||||
|
|
||||||
private final long MAX_WAIT_TIME = 60 * 1000;
|
private final long MAX_WAIT_TIME = 60 * 1000;
|
||||||
private final long WAIT_TIME_INCR = 10 * 1000;
|
private final long WAIT_TIME_INCR = 10 * 1000;
|
||||||
|
|
||||||
@@ -100,6 +100,7 @@ public class CacheUtils {
|
|||||||
public boolean retValue = false;
|
public boolean retValue = false;
|
||||||
private boolean doneFlag = false;
|
private boolean doneFlag = false;
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onRemoveCompleted(String packageName, boolean succeeded) throws RemoteException {
|
public void onRemoveCompleted(String packageName, boolean succeeded) throws RemoteException {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
retValue = succeeded;
|
retValue = succeeded;
|
||||||
@@ -118,6 +119,7 @@ public class CacheUtils {
|
|||||||
public PackageStats stats;
|
public PackageStats stats;
|
||||||
private boolean doneFlag = false;
|
private boolean doneFlag = false;
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onGetStatsCompleted(PackageStats pStats, boolean succeeded) throws RemoteException {
|
public void onGetStatsCompleted(PackageStats pStats, boolean succeeded) throws RemoteException {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
retValue = succeeded;
|
retValue = succeeded;
|
||||||
|
|||||||
@@ -90,12 +90,16 @@ public class JGYUtils {
|
|||||||
private ContentResolver resolver;
|
private ContentResolver resolver;
|
||||||
private MMKV mMMKV = MMKV.defaultMMKV();
|
private MMKV mMMKV = MMKV.defaultMMKV();
|
||||||
|
|
||||||
public static int MTKPlatform = 1;
|
public static final int MTKPlatform = 1;
|
||||||
public static int ZhanruiPlatform = 2;
|
public static final int ZhanruiPlatform = 2;
|
||||||
public static int UnknowPlatform = 0;
|
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 MTKTag = "MTK";
|
||||||
public static String ZhanruiTag = "展锐";
|
public static String ZhanruiTag = "展锐";
|
||||||
|
public static String M40SETag = "M40SE";
|
||||||
|
public static String T30PROTag = "T30PRO";
|
||||||
|
|
||||||
private HashSet<String> ownApp = new HashSet<String>() {{
|
private HashSet<String> ownApp = new HashSet<String>() {{
|
||||||
this.add("com.android.settings");
|
this.add("com.android.settings");
|
||||||
@@ -164,9 +168,9 @@ public class JGYUtils {
|
|||||||
|
|
||||||
public HashSet<String> getAppAndWhite() {
|
public HashSet<String> getAppAndWhite() {
|
||||||
String pkgString = mMMKV.decodeString(UrlAddress.GET_APP_AND_WHITE, "");
|
String pkgString = mMMKV.decodeString(UrlAddress.GET_APP_AND_WHITE, "");
|
||||||
if(TextUtils.isEmpty(pkgString)){
|
if (TextUtils.isEmpty(pkgString)) {
|
||||||
return new HashSet<>();
|
return new HashSet<>();
|
||||||
}else {
|
} else {
|
||||||
return new HashSet<>(Arrays.asList(pkgString.split(",")));
|
return new HashSet<>(Arrays.asList(pkgString.split(",")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -478,6 +482,12 @@ public class JGYUtils {
|
|||||||
} else if ("ZhanRui".equalsIgnoreCase(platform)) {
|
} else if ("ZhanRui".equalsIgnoreCase(platform)) {
|
||||||
Log.i(TAG, "checkAppPlatform: " + "展锐平台");
|
Log.i(TAG, "checkAppPlatform: " + "展锐平台");
|
||||||
return ZhanruiPlatform;
|
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 {
|
} else {
|
||||||
Log.i(TAG, "checkAppPlatform: " + "没有数据");
|
Log.i(TAG, "checkAppPlatform: " + "没有数据");
|
||||||
return UnknowPlatform;
|
return UnknowPlatform;
|
||||||
@@ -503,7 +513,11 @@ public class JGYUtils {
|
|||||||
getAppPlatformCallback.AppPlatform(MTKPlatform);
|
getAppPlatformCallback.AppPlatform(MTKPlatform);
|
||||||
} else if ("ZhanRui".equalsIgnoreCase(platform)) {
|
} else if ("ZhanRui".equalsIgnoreCase(platform)) {
|
||||||
getAppPlatformCallback.AppPlatform(ZhanruiPlatform);
|
getAppPlatformCallback.AppPlatform(ZhanruiPlatform);
|
||||||
} else {
|
}else if ("M40SE".equalsIgnoreCase(platform)) {
|
||||||
|
getAppPlatformCallback.AppPlatform(M40sePlatform);
|
||||||
|
} else if ("T30PRO".equalsIgnoreCase(platform)) {
|
||||||
|
getAppPlatformCallback.AppPlatform(T30ProPlatform);
|
||||||
|
} else {
|
||||||
getAppPlatformCallback.AppPlatform(UnknowPlatform);
|
getAppPlatformCallback.AppPlatform(UnknowPlatform);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -591,18 +605,20 @@ public class JGYUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void removeTask(String packageName) {
|
public void removeTask(String packageName) {
|
||||||
List<ActivityManager.RecentTaskInfo> list = getRecentTasks(ActivityManager.getMaxRecentTasksStatic(), getCurrentUserId());
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||||
HashMap<String, Integer> taskMap = new HashMap<>();
|
List<ActivityManager.RecentTaskInfo> list = getRecentTasks(ActivityManager.getMaxRecentTasksStatic(), getCurrentUserId());
|
||||||
for (ActivityManager.RecentTaskInfo info : list) {
|
HashMap<String, Integer> taskMap = new HashMap<>();
|
||||||
taskMap.put(info.realActivity.getPackageName(), info.id);
|
for (ActivityManager.RecentTaskInfo info : list) {
|
||||||
}
|
taskMap.put(info.realActivity.getPackageName(), info.id);
|
||||||
try {
|
}
|
||||||
ActivityManagerNative.getDefault().removeTask(taskMap.get(packageName));
|
try {
|
||||||
} catch (RemoteException e) {
|
ActivityManagerNative.getDefault().removeTask(taskMap.get(packageName));
|
||||||
e.printStackTrace();
|
} catch (RemoteException e) {
|
||||||
Log.e(TAG, "removeTask: " + e.getMessage());
|
e.printStackTrace();
|
||||||
} catch (NullPointerException e) {
|
Log.e(TAG, "removeTask: " + e.getMessage());
|
||||||
Log.e(TAG, "removeTask: " + e.getMessage());
|
} catch (NullPointerException e) {
|
||||||
|
Log.e(TAG, "removeTask: " + e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
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) {
|
if (mNtpClient == null) {
|
||||||
mNtpClient = new SntpClient();
|
mNtpClient = new SntpClient();
|
||||||
}
|
}
|
||||||
boolean isSuccessful = mNtpClient.requestTime(hostAddress, 20000);
|
try {
|
||||||
Log.e(TAG, "requestTime:" + isSuccessful);
|
boolean isSuccessful = mNtpClient.requestTime(hostAddress, 20000);
|
||||||
if (isSuccessful) {
|
Log.e(TAG, "requestTime:" + isSuccessful);
|
||||||
long now = mNtpClient.getNtpTime();//now就是获取的时间
|
if (isSuccessful) {
|
||||||
return now;
|
long now = mNtpClient.getNtpTime();//now就是获取的时间
|
||||||
} else {
|
return now;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.e(TAG, "getTimeFromNtpServer: " + e.getMessage());
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1250,9 +1250,11 @@ public class Utils {
|
|||||||
jsonObject.addProperty("use_ram", use_ram);
|
jsonObject.addProperty("use_ram", use_ram);
|
||||||
jsonObject.addProperty("wifi_ssid", getWifiSSID(context));
|
jsonObject.addProperty("wifi_ssid", getWifiSSID(context));
|
||||||
jsonObject.addProperty("wifi_time", wifi_time);
|
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("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());
|
jsonObject.addProperty("bluetooth", getBluetoothList());
|
||||||
Log.e(TAG, "getHardware: " + jsonObject.toString());
|
Log.e(TAG, "getHardware: " + jsonObject.toString());
|
||||||
return jsonObject.toString();
|
return jsonObject.toString();
|
||||||
|
|||||||
Reference in New Issue
Block a user