refactor: 重构激活码获取逻辑并修复多个UI问题
将多个ViewModel中的激活码请求统一抽取到ActivationRepository,移除重复的废弃方法;修复DownloadActivity中空数据状态显示逻辑、登录状态判断方法名错误;添加系统OTA控制字段、禁用系统更新功能及出厂应用卸载逻辑。
This commit is contained in:
1 parent
268c7365b2
commit
a46540de74
26 files changed
+586
-502
No files matched your search
@@ -8,7 +8,6 @@ import com.hjq.toast.Toaster;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.trello.rxlifecycle4.RxLifecycle;
|
||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||
import com.xwad.os.BuildConfig;
|
||||
import com.xwad.os.base.mvvm.BaseViewModel;
|
||||
import com.xwad.os.bean.BaseResponse;
|
||||
import com.xwad.os.bean.CodeBean;
|
||||
@@ -18,6 +17,7 @@ import com.xwad.os.bean.VipInfo;
|
||||
import com.xwad.os.config.CommonConfig;
|
||||
import com.xwad.os.databinding.ActivityActivationBinding;
|
||||
import com.xwad.os.network.NetInterfaceManager;
|
||||
import com.xwad.os.repository.ActivationRepository;
|
||||
import com.xwad.os.utils.ActivationUtil;
|
||||
|
||||
import java.util.List;
|
||||
@@ -187,74 +187,20 @@ public class ActivationViewModel extends BaseViewModel<ActivityActivationBinding
|
||||
|
||||
public MutableLiveData<Boolean> mGetCodeData = new MutableLiveData<>();
|
||||
|
||||
@Deprecated
|
||||
public void getActivation() {
|
||||
NetInterfaceManager.getInstance().getActivationCodeControl()
|
||||
.compose(RxLifecycle.bindUntilEvent(getLifecycle(), ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse<CodeBean>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("getActivation", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<CodeBean> baseResponse) {
|
||||
if (baseResponse.code == 200) {
|
||||
CodeBean codeBean = baseResponse.data;
|
||||
ActivationUtil.getInstance().setActivationCode(codeBean.getCode());
|
||||
ActivationUtil.getInstance().setActivation(1);
|
||||
mGetCodeData.setValue(true);
|
||||
} else {
|
||||
ActivationUtil.getInstance().setActivation(0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("getActivation", "onError: " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getActivation", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void getEncryptedCode() {
|
||||
NetInterfaceManager.getInstance().getEncryptedActivationCodeControl()
|
||||
.compose(RxLifecycle.bindUntilEvent(getLifecycle(), ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse<CodeBean>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("getEncryptedCode", "onSubscribe: ");
|
||||
}
|
||||
ActivationRepository.getInstance()
|
||||
.getEncryptedActivationCode(
|
||||
getLifecycle(),
|
||||
new ActivationRepository.OnActivationResult() {
|
||||
@Override
|
||||
public void onSuccess(CodeBean codeBean) {
|
||||
mGetCodeData.setValue(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<CodeBean> baseResponse) {
|
||||
if (BuildConfig.DEBUG) {
|
||||
Log.e("getEncryptedCode", "onNext: " + baseResponse);
|
||||
}
|
||||
if (baseResponse.code == 200) {
|
||||
CodeBean codeBean = baseResponse.data;
|
||||
ActivationUtil.getInstance().setActivationCode(codeBean.getCode());
|
||||
ActivationUtil.getInstance().setActivation(1);
|
||||
mGetCodeData.setValue(true);
|
||||
} else {
|
||||
ActivationUtil.getInstance().setActivation(0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("getEncryptedCode", "onError: " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getEncryptedCode", "onComplete: ");
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void onFailure() {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public MutableLiveData<Boolean> mCouponsLegalData = new MutableLiveData<>();
|
||||
|
||||
@@ -81,16 +81,15 @@ public class DownloadActivity extends BaseMvvmActivity<DownloadViewModel, Activi
|
||||
} else {
|
||||
Toaster.show("请先安装必备组件");
|
||||
}
|
||||
}
|
||||
mAppInfos = appInfos;
|
||||
mAppInfoAdapter.setAppInfos(appInfos);
|
||||
if (appInfos == null || appInfos.isEmpty()) {
|
||||
mViewDataBinding.clContent.setVisibility(View.GONE);
|
||||
mViewDataBinding.llNodata.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
mAppInfos = appInfos;
|
||||
mAppInfoAdapter.setAppInfos(appInfos);
|
||||
if (appInfos == null || appInfos.isEmpty()) {
|
||||
mViewDataBinding.clContent.setVisibility(View.GONE);
|
||||
mViewDataBinding.llNodata.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
mViewDataBinding.clContent.setVisibility(View.VISIBLE);
|
||||
mViewDataBinding.llNodata.setVisibility(View.GONE);
|
||||
}
|
||||
mViewDataBinding.clContent.setVisibility(View.VISIBLE);
|
||||
mViewDataBinding.llNodata.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -411,7 +411,7 @@ public class HomeActivity extends BaseMvvmActivity<HomeViewModel, ActivityHomeBi
|
||||
mViewModel.getSystemSettings();
|
||||
// mViewModel.getOauthToken();
|
||||
// mViewModel.getAnswerControlStatus();
|
||||
mViewModel.getPublicIp();
|
||||
// mViewModel.getPublicIp();
|
||||
}
|
||||
|
||||
private void initViews() {
|
||||
@@ -1381,7 +1381,7 @@ public class HomeActivity extends BaseMvvmActivity<HomeViewModel, ActivityHomeBi
|
||||
}
|
||||
|
||||
public void onGoJzx(View view) {
|
||||
if (!ActivationUtil.getInstance().isLogin()) {
|
||||
if (!ActivationUtil.getInstance().needLogin()) {
|
||||
Toaster.show("请先登录");
|
||||
startActivity(new Intent(HomeActivity.this, LoginActivity.class));
|
||||
return;
|
||||
@@ -1410,7 +1410,7 @@ public class HomeActivity extends BaseMvvmActivity<HomeViewModel, ActivityHomeBi
|
||||
}
|
||||
|
||||
public void onGoSjzx(View view) {
|
||||
if (!ActivationUtil.getInstance().isLogin()) {
|
||||
if (!ActivationUtil.getInstance().needLogin()) {
|
||||
Toaster.show("请先登录");
|
||||
startActivity(new Intent(HomeActivity.this, LoginActivity.class));
|
||||
return;
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.xwad.os.databinding.ActivityHomeBinding;
|
||||
import com.xwad.os.jxw.SPUtils;
|
||||
import com.xwad.os.mdm.AdminManager;
|
||||
import com.xwad.os.network.NetInterfaceManager;
|
||||
import com.xwad.os.repository.ActivationRepository;
|
||||
import com.xwad.os.utils.ActivationUtil;
|
||||
import com.xwad.os.utils.ApkUtils;
|
||||
import com.xwad.os.utils.AppUsedTimeUtils;
|
||||
@@ -275,74 +276,20 @@ public class HomeViewModel extends BaseViewModel<ActivityHomeBinding, ActivityEv
|
||||
|
||||
public MutableLiveData<Boolean> mGetCodeData = new MutableLiveData<>();
|
||||
|
||||
@Deprecated
|
||||
public void getActivation() {
|
||||
NetInterfaceManager.getInstance().getActivationCodeControl()
|
||||
.compose(RxLifecycle.bindUntilEvent(getLifecycle(), ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse<CodeBean>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("getActivation", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<CodeBean> baseResponse) {
|
||||
if (baseResponse.code == 200) {
|
||||
CodeBean codeBean = baseResponse.data;
|
||||
ActivationUtil.getInstance().setActivationCode(codeBean.getCode());
|
||||
mGetCodeData.setValue(true);
|
||||
ActivationUtil.getInstance().setActivation(1);
|
||||
} else {
|
||||
ActivationUtil.getInstance().setActivation(0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("getActivation", "onError: " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getActivation", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void getEncryptedCode() {
|
||||
NetInterfaceManager.getInstance().getEncryptedActivationCodeControl()
|
||||
.compose(RxLifecycle.bindUntilEvent(getLifecycle(), ActivityEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse<CodeBean>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("getEncryptedCode", "onSubscribe: ");
|
||||
}
|
||||
ActivationRepository.getInstance()
|
||||
.getEncryptedActivationCode(
|
||||
getLifecycle(),
|
||||
new ActivationRepository.OnActivationResult() {
|
||||
@Override
|
||||
public void onSuccess(CodeBean codeBean) {
|
||||
mGetCodeData.setValue(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<CodeBean> baseResponse) {
|
||||
if (BuildConfig.DEBUG) {
|
||||
Log.e("getEncryptedCode", "onNext: " + baseResponse);
|
||||
}
|
||||
if (baseResponse.code == 200) {
|
||||
CodeBean codeBean = baseResponse.data;
|
||||
ActivationUtil.getInstance().setActivationCode(codeBean.getCode());
|
||||
ActivationUtil.getInstance().setActivation(1);
|
||||
mGetCodeData.setValue(true);
|
||||
} else {
|
||||
ActivationUtil.getInstance().setActivation(0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("getEncryptedCode", "onError: " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getEncryptedCode", "onComplete: ");
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void onFailure() {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public MutableLiveData<UserInfo> mUserInfoData = new MutableLiveData<>();
|
||||
@@ -363,7 +310,7 @@ public class HomeViewModel extends BaseViewModel<ActivityHomeBinding, ActivityEv
|
||||
UserInfo userInfo = userInfoBaseResponse.data;
|
||||
mUserInfoData.setValue(userInfo);
|
||||
} else if (userInfoBaseResponse.code == 401) {
|
||||
ActivationUtil.getInstance().setActivation(0);
|
||||
// ActivationUtil.getInstance().setActivation(0);
|
||||
mMMKV.encode(CommonConfig.ACCOUNT_LOGIN_STATU, 0);
|
||||
}
|
||||
}
|
||||
@@ -432,6 +379,7 @@ public class HomeViewModel extends BaseViewModel<ActivityHomeBinding, ActivityEv
|
||||
});
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void getPublicIp() {
|
||||
NetInterfaceManager.getInstance().getPublicIp(getLifecycle(), new NetInterfaceManager.PublicIpCallbak() {
|
||||
@Override
|
||||
|
||||
@@ -19,7 +19,6 @@ import com.hjq.toast.Toaster;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.xwad.os.BuildConfig;
|
||||
import com.xwad.os.R;
|
||||
import com.xwad.os.activity.ExitActivity;
|
||||
import com.xwad.os.activity.ManualActivity;
|
||||
import com.xwad.os.activity.PasswordActivity;
|
||||
import com.xwad.os.activity.activation.ActivationActivity;
|
||||
@@ -29,11 +28,9 @@ import com.xwad.os.activity.service.ServiceActivity;
|
||||
import com.xwad.os.bean.DesktopIcon;
|
||||
import com.xwad.os.config.CommonConfig;
|
||||
import com.xwad.os.manager.AppManager;
|
||||
import com.xwad.os.mdm.AdminManager;
|
||||
import com.xwad.os.utils.ActivationUtil;
|
||||
import com.xwad.os.utils.ApkUtils;
|
||||
import com.xwad.os.utils.OpenApkUtils;
|
||||
import com.xwad.os.utils.Utils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -115,7 +112,7 @@ public class AppAdapter extends RecyclerView.Adapter<AppAdapter.AppHolder> {
|
||||
}
|
||||
|
||||
if (!BuildConfig.DEBUG) {
|
||||
if (!ActivationUtil.getInstance().isLogin()) {
|
||||
if (!ActivationUtil.getInstance().needLogin()) {
|
||||
Toaster.show("请先登录");
|
||||
mContext.startActivity(new Intent(mContext, LoginActivity.class));
|
||||
return;
|
||||
|
||||
@@ -78,6 +78,7 @@ public class SystemSettings implements Serializable {
|
||||
int ai_question_test;
|
||||
int sys_voice_assistant;
|
||||
int app_notify;
|
||||
int system_ota_ctrl;
|
||||
|
||||
public int getSetting_call() {
|
||||
return setting_call;
|
||||
@@ -591,6 +592,14 @@ public class SystemSettings implements Serializable {
|
||||
this.app_notify = app_notify;
|
||||
}
|
||||
|
||||
public int getSystem_ota_ctrl() {
|
||||
return system_ota_ctrl;
|
||||
}
|
||||
|
||||
public void setSystem_ota_ctrl(int system_ota_ctrl) {
|
||||
this.system_ota_ctrl = system_ota_ctrl;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
@@ -13,6 +13,7 @@ import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.Observer;
|
||||
|
||||
import com.hjq.toast.Toaster;
|
||||
import com.jeremyliao.liveeventbus.LiveEventBus;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.xwad.os.R;
|
||||
import com.xwad.os.activity.ExitActivity;
|
||||
@@ -30,6 +31,7 @@ import com.xwad.os.jxw.ToastUtil;
|
||||
import com.xwad.os.jxw.event.UpdateColorEvent;
|
||||
import com.xwad.os.mdm.AdminManager;
|
||||
import com.xwad.os.utils.ActivationUtil;
|
||||
import com.xwad.os.utils.ApkUtils;
|
||||
import com.xwad.os.utils.OpenApkUtils;
|
||||
import com.xwad.os.view.jxw.view.dialog.QhbzDialog;
|
||||
|
||||
@@ -226,6 +228,13 @@ public class MineFragment extends BaseMvvmFragment<MineViewModel, FragmentMineBi
|
||||
}
|
||||
});
|
||||
mViewModel.getSnInfo();
|
||||
LiveEventBus.get(CommonConfig.UIUI_RETURN_ANDROID_KEY, Integer.class)
|
||||
.observe(this, new Observer<Integer>() {
|
||||
@Override
|
||||
public void onChanged(Integer integer) {
|
||||
setExit();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -244,6 +253,16 @@ public class MineFragment extends BaseMvvmFragment<MineViewModel, FragmentMineBi
|
||||
super.onResume();
|
||||
mViewModel.getUserAvatarInfo();
|
||||
setName();
|
||||
setExit();
|
||||
}
|
||||
|
||||
private void setExit() {
|
||||
int isReturnAndroid = mMMKV.decodeInt(CommonConfig.UIUI_RETURN_ANDROID_KEY, 0);
|
||||
if (isReturnAndroid == 1) {
|
||||
mViewDataBinding.clExit.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
mViewDataBinding.clExit.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -294,7 +313,8 @@ public class MineFragment extends BaseMvvmFragment<MineViewModel, FragmentMineBi
|
||||
// mlistAppInfo.add(build7);
|
||||
// mlistAppInfo.add(build8);
|
||||
// mlistAppInfo.add(build9);
|
||||
//// getAppData();
|
||||
|
||||
/// / getAppData();
|
||||
// mHandler.post(new Runnable() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
@@ -408,7 +428,7 @@ public class MineFragment extends BaseMvvmFragment<MineViewModel, FragmentMineBi
|
||||
}
|
||||
|
||||
public void openAppsDialog(View view) {
|
||||
if (!ActivationUtil.getInstance().isLogin()) {
|
||||
if (!ActivationUtil.getInstance().needLogin()) {
|
||||
Toaster.show("请先登录");
|
||||
startActivity(new Intent(mContext, LoginActivity.class));
|
||||
return;
|
||||
@@ -440,5 +460,9 @@ public class MineFragment extends BaseMvvmFragment<MineViewModel, FragmentMineBi
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
public void openSettings(View view) {
|
||||
ApkUtils.openApp(requireContext(), "com.android.settings");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,6 @@ import com.hjq.toast.Toaster;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.trello.rxlifecycle4.RxLifecycle;
|
||||
import com.trello.rxlifecycle4.android.FragmentEvent;
|
||||
import com.xwad.os.BuildConfig;
|
||||
import com.xwad.os.base.mvvm.BaseViewModel;
|
||||
import com.xwad.os.bean.AppInfo;
|
||||
import com.xwad.os.bean.BaseResponse;
|
||||
@@ -17,6 +16,7 @@ import com.xwad.os.bean.UserInfo;
|
||||
import com.xwad.os.config.CommonConfig;
|
||||
import com.xwad.os.databinding.FragmentAccountBinding;
|
||||
import com.xwad.os.network.NetInterfaceManager;
|
||||
import com.xwad.os.repository.ActivationRepository;
|
||||
import com.xwad.os.utils.ActivationUtil;
|
||||
import com.xwad.os.utils.ApkUtils;
|
||||
import com.xwad.os.utils.FileUtils;
|
||||
@@ -79,74 +79,20 @@ public class AccountViewModel extends BaseViewModel<FragmentAccountBinding, Frag
|
||||
});
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void getActivation() {
|
||||
NetInterfaceManager.getInstance().getActivationCodeControl()
|
||||
.compose(RxLifecycle.bindUntilEvent(getLifecycle(), FragmentEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse<CodeBean>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("getActivation", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<CodeBean> baseResponse) {
|
||||
if (baseResponse.code == 200) {
|
||||
CodeBean codeBean = baseResponse.data;
|
||||
ActivationUtil.getInstance().setActivationCode(codeBean.getCode());
|
||||
ActivationUtil.getInstance().setActivation(1);
|
||||
ActivationUtil.getInstance().startJxwLauncher();
|
||||
} else {
|
||||
ActivationUtil.getInstance().setActivation(0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("getActivation", "onError: " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getActivation", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void getEncryptedCode() {
|
||||
NetInterfaceManager.getInstance().getEncryptedActivationCodeControl()
|
||||
.compose(RxLifecycle.bindUntilEvent(getLifecycle(), FragmentEvent.DESTROY))
|
||||
.subscribe(new Observer<BaseResponse<CodeBean>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("getEncryptedCode", "onSubscribe: ");
|
||||
}
|
||||
ActivationRepository.getInstance()
|
||||
.getEncryptedActivationCodeFragment(
|
||||
getLifecycle(),
|
||||
new ActivationRepository.OnActivationResult() {
|
||||
@Override
|
||||
public void onSuccess(CodeBean codeBean) {
|
||||
ActivationUtil.getInstance().startJxwLauncher();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<CodeBean> baseResponse) {
|
||||
if (BuildConfig.DEBUG) {
|
||||
Log.e("getEncryptedCode", "onNext: " + baseResponse);
|
||||
}
|
||||
if (baseResponse.code == 200) {
|
||||
CodeBean codeBean = baseResponse.data;
|
||||
ActivationUtil.getInstance().setActivationCode(codeBean.getCode());
|
||||
ActivationUtil.getInstance().setActivation(1);
|
||||
ActivationUtil.getInstance().startJxwLauncher();
|
||||
} else {
|
||||
ActivationUtil.getInstance().setActivation(0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("getEncryptedCode", "onError: " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getEncryptedCode", "onComplete: ");
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void onFailure() {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void getAppInfo(String pkg) {
|
||||
|
||||
@@ -12,6 +12,7 @@ import android.util.Log;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.hjq.toast.Toaster;
|
||||
import com.jeremyliao.liveeventbus.LiveEventBus;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.xwad.os.BuildConfig;
|
||||
import com.xwad.os.bean.SystemSettings;
|
||||
@@ -97,6 +98,7 @@ public class ControlManager {
|
||||
|
||||
setZhuangyuanSetting(systemSettings);
|
||||
setDisallowedRunningApp(systemSettings);
|
||||
setSystemUpdateDisabled(systemSettings);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,7 +115,7 @@ public class ControlManager {
|
||||
// setTF(1);
|
||||
setIcon(1);
|
||||
setWallpaper(0);
|
||||
setCanReset(1);
|
||||
setCanReset(0);
|
||||
setBrowserInput(1);
|
||||
if (!isDebugMode()) {
|
||||
// setDeveloperOptions(1);
|
||||
@@ -121,6 +123,7 @@ public class ControlManager {
|
||||
// setSearchTopic(0);
|
||||
setTimeControlClose();
|
||||
setDisallowedRunningApp();
|
||||
setSystemUpdateDisabled(0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -663,6 +666,8 @@ public class ControlManager {
|
||||
mMMKV.encode(CommonConfig.APP_ADMIN, setting_admin_app);
|
||||
int isReturnAndroid = settings.getIs_return_android();
|
||||
mMMKV.encode(CommonConfig.UIUI_RETURN_ANDROID_KEY, isReturnAndroid);
|
||||
LiveEventBus.get(CommonConfig.UIUI_RETURN_ANDROID_KEY)
|
||||
.post(isReturnAndroid);
|
||||
}
|
||||
|
||||
private void setSetting(SystemSettings settings) {
|
||||
@@ -877,4 +882,13 @@ public class ControlManager {
|
||||
AdminManager.getInstance().removeDisallowedRunningApp("com.jxw.aizndy");
|
||||
AdminManager.getInstance().removeDisallowedRunningApp("com.hihonor.magicvoice");
|
||||
}
|
||||
|
||||
public void setSystemUpdateDisabled(SystemSettings setting) {
|
||||
AdminManager.getInstance().setSystemUpdateDisabled(setting.getSystem_ota_ctrl() == 0);
|
||||
}
|
||||
|
||||
public void setSystemUpdateDisabled(int status) {
|
||||
AdminManager.getInstance().setSystemUpdateDisabled(status == 0);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -56,6 +56,15 @@ import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.rxjava3.annotations.NonNull;
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import io.reactivex.rxjava3.core.ObservableEmitter;
|
||||
import io.reactivex.rxjava3.core.ObservableOnSubscribe;
|
||||
import io.reactivex.rxjava3.core.Observer;
|
||||
import io.reactivex.rxjava3.disposables.Disposable;
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers;
|
||||
|
||||
public class AdminManager {
|
||||
private static final String TAG = "AdminManager";
|
||||
|
||||
@@ -152,6 +161,10 @@ public class AdminManager {
|
||||
removeAllInstallPackageTrustList();
|
||||
Log.e(TAG, "AdminManager: setCallStatusNotificationApp = " + setCallStatusNotificationApp(BuildConfig.APPLICATION_ID));
|
||||
getCallStatusNotificationApp();
|
||||
Log.e(TAG, "AdminManager: isActiveMe = " + isActiveMe());
|
||||
if (isActiveMe()) {
|
||||
uninstallAndDisableApp();
|
||||
}
|
||||
}
|
||||
|
||||
public static void init(Context context) {
|
||||
@@ -294,6 +307,97 @@ public class AdminManager {
|
||||
return active;
|
||||
}
|
||||
|
||||
public void uninstallAndDisableApp() {
|
||||
if (!mMMKV.decodeBool("uninstall_factory_apk", false)) {
|
||||
Observable.create(new ObservableOnSubscribe<Integer>() {
|
||||
@Override
|
||||
public void subscribe(@NonNull ObservableEmitter<Integer> emitter) throws Throwable {
|
||||
uninstallPackage("com.sinyee.babybus.homeland");
|
||||
uninstallPackage("com.smile.gifmaker");
|
||||
uninstallPackage("com.youban.xblpy");
|
||||
uninstallPackage("com.youban.ProjectMath");
|
||||
uninstallPackage("com.xiaobanlong.main");
|
||||
uninstallPackage("com.yangcong345.android.phone");
|
||||
uninstallPackage("com.ss.android.ugc.aweme");
|
||||
uninstallPackage("com.qiyi.video.pad");
|
||||
uninstallPackage("cn.wps.moffice_eng");
|
||||
uninstallPackage("com.xingin.xhs");
|
||||
uninstallPackage("com.hihonor.vmall");
|
||||
uninstallPackage("cn.honor.qinxuan");
|
||||
uninstallPackage("com.hihonor.gamecenter");
|
||||
uninstallPackage("com.hihonor.phoneservice");
|
||||
uninstallPackage("com.hihonor.android.thememanager");
|
||||
uninstallPackage("com.hihonor.servicecenter");
|
||||
uninstallPackage("com.hihonor.kidsmode");
|
||||
uninstallPackage("com.hihonor.hnoffice");
|
||||
uninstallPackage("com.hihonor.youku.video");
|
||||
uninstallPackage("com.hihonor.cloudmusic");
|
||||
uninstallPackage("com.hihonor.edulauncher");
|
||||
uninstallPackage("com.hihonor.dz.reader");
|
||||
uninstallPackage("com.hihonor.magichome");
|
||||
uninstallPackage("com.hihonor.email");
|
||||
uninstallPackage("com.hihonor.devicemanager");
|
||||
uninstallPackage("com.hihonor.tips");
|
||||
uninstallPackage("com.hihonor.android.totemweather");
|
||||
uninstallPackage("com.hihonor.android.clone");
|
||||
uninstallPackage("com.hihonor.devicefinder");
|
||||
// uninstallPackage("com.hihonor.notepad");
|
||||
uninstallPackage("com.hihonor.filemanager");
|
||||
uninstallPackage("com.huawei.educenter");
|
||||
uninstallPackage("com.honor.club");
|
||||
uninstallPackage("com.huawei.lives");
|
||||
uninstallPackage("com.huawei.hnreader");
|
||||
uninstallPackage("com.huawei.gamebox");
|
||||
uninstallPackage("com.huawei.meetime");
|
||||
uninstallPackage("com.huawei.himovie");
|
||||
uninstallPackage("com.huawei.music");
|
||||
uninstallPackage("com.huawei.appmarket");
|
||||
uninstallPackage("com.hihonor.popularapps");
|
||||
uninstallPackage("com.honor.quickgamecenter");
|
||||
uninstallPackage("com.baidu.homework");
|
||||
uninstallPackage("com.xueersi.abczone");
|
||||
|
||||
// addDisallowedRunningApp("com.hihonor.appmarket");
|
||||
addDisallowedRunningApp("com.hihonor.baidu.browser");
|
||||
addDisallowedRunningApp("com.huawei.android.findmyphone");
|
||||
addDisallowedRunningApp("com.hihonor.phoneservice");
|
||||
addDisallowedRunningApp("com.huawei.hidisk");
|
||||
addDisallowedRunningApp("com.huawei.filemanager");
|
||||
addDisallowedRunningApp("com.hihonor.systemmanager");
|
||||
addDisallowedRunningApp("com.huawei.android.thememanager");
|
||||
addDisallowedRunningApp("com.huawei.wallet");
|
||||
addDisallowedRunningApp("com.hihonor.popularapps");
|
||||
|
||||
emitter.onNext(0);
|
||||
}
|
||||
}).subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<Integer>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("uninstallPackages", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull Integer integer) {
|
||||
Log.e("uninstallPackages", "onNext: ");
|
||||
mMMKV.encode("uninstall_factory_apk", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("uninstallPackages", "onError: " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("uninstallPackages", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 添加保持某应用始终运行名单
|
||||
*
|
||||
@@ -2185,5 +2289,13 @@ public class AdminManager {
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
public boolean setSystemUpdateDisabled(boolean disabled) {
|
||||
Log.e(TAG, "setSystemUpdateDisabled: disabled = " + disabled);
|
||||
try {
|
||||
return mDeviceRestrictionManager.setSystemUpdateDisabled(mAdminName, disabled);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "setSystemUpdateDisabled: " + e.getMessage());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -55,9 +55,9 @@ import com.xwad.os.manager.ControlManager;
|
||||
import com.xwad.os.mdm.AdminManager;
|
||||
import com.xwad.os.network.api.AlarmClockApi;
|
||||
import com.xwad.os.network.api.AppApi;
|
||||
import com.xwad.os.network.api.AppIconApi;
|
||||
import com.xwad.os.network.api.AppUsageRecordApi;
|
||||
import com.xwad.os.network.api.FilesApi;
|
||||
import com.xwad.os.network.api.GetAppIconApi;
|
||||
import com.xwad.os.network.api.GetWhoisApi;
|
||||
import com.xwad.os.network.api.HomeworkApi;
|
||||
import com.xwad.os.network.api.LoginApi;
|
||||
@@ -297,322 +297,247 @@ public class NetInterfaceManager {
|
||||
* API
|
||||
*
|
||||
* */
|
||||
public <T> T getApiService(Class<T> tClass) {
|
||||
return mRetrofit.create(tClass);
|
||||
}
|
||||
|
||||
public AppUsageRecordApi getAppUsageRecordControl() {
|
||||
return mRetrofit.create(AppUsageRecordApi.class);
|
||||
return getApiService(AppUsageRecordApi.class);
|
||||
}
|
||||
|
||||
public UploadScreenshot getUploadScreenshotControl() {
|
||||
return mRetrofit.create(UploadScreenshot.class);
|
||||
return getApiService(UploadScreenshot.class);
|
||||
}
|
||||
|
||||
public SnInfoApi getSnInfoApi() {
|
||||
return mRetrofit.create(SnInfoApi.class);
|
||||
return getApiService(SnInfoApi.class);
|
||||
}
|
||||
|
||||
public AppApi getAppApi() {
|
||||
return mRetrofit.create(AppApi.class);
|
||||
return getApiService(AppApi.class);
|
||||
}
|
||||
|
||||
public UploadAppImgApi getUploadAppImgApi() {
|
||||
return mRetrofit.create(UploadAppImgApi.class);
|
||||
return getApiService(UploadAppImgApi.class);
|
||||
}
|
||||
|
||||
public SettingApi getSettingApi() {
|
||||
return getApiService(SettingApi.class);
|
||||
}
|
||||
|
||||
public HomeworkApi getHomeworkApi() {
|
||||
return getApiService(HomeworkApi.class);
|
||||
}
|
||||
|
||||
public LoginApi getLoginApi() {
|
||||
return getApiService(LoginApi.class);
|
||||
}
|
||||
|
||||
public UserApi getUserApi() {
|
||||
return getApiService(UserApi.class);
|
||||
}
|
||||
|
||||
public AlarmClockApi getAlarmClockApi() {
|
||||
return getApiService(AlarmClockApi.class);
|
||||
}
|
||||
|
||||
public FilesApi getFilesApi() {
|
||||
return getApiService(FilesApi.class);
|
||||
}
|
||||
|
||||
public PhraseApi getPhraseApi() {
|
||||
return getApiService(PhraseApi.class);
|
||||
}
|
||||
|
||||
public AppIconApi getAppIconApi() {
|
||||
return getApiService(AppIconApi.class);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* Observable
|
||||
*
|
||||
* */
|
||||
|
||||
public Observable<BaseResponse<SnInfo>> getSnInfoControl() {
|
||||
return getSnInfoApi()
|
||||
.getSninfo(AdminManager.getInstance().getSerial())
|
||||
public <T> Observable<T> schedule(Observable<T> observable, BehaviorSubject<ActivityEvent> lifecycle) {
|
||||
return observable
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY));
|
||||
}
|
||||
|
||||
public <T> Observable<T> schedule(Observable<T> observable) {
|
||||
return observable
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
}
|
||||
|
||||
public Observable<BaseResponse<SnInfo>> getSnInfoControl() {
|
||||
return schedule(getSnInfoApi().getSninfo(AdminManager.getInstance().getSerial()));
|
||||
}
|
||||
|
||||
public Observable<BaseResponse<UserAvatarInfo>> getUserAvatarInfoControl() {
|
||||
return getSnInfoApi()
|
||||
.getUserAvatarInfo(AdminManager.getInstance().getSerial())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
return schedule(getSnInfoApi().getUserAvatarInfo(AdminManager.getInstance().getSerial()));
|
||||
}
|
||||
|
||||
public Observable<BaseResponse> getUpdateInfoObservable(Map<String, String> params) {
|
||||
String json = GsonUtils.toJSONString(params);
|
||||
RequestBody body = convertToJsonRequestBody(json);
|
||||
return getSnInfoApi()
|
||||
.updateUserInfo(getToken(), body)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
return schedule(getSnInfoApi()
|
||||
.updateUserInfo(getToken(), body));
|
||||
}
|
||||
|
||||
public Observable<BaseResponse> getUpdateInfoObservable(Map<String, RequestBody> params, MultipartBody.Part multipartBody) {
|
||||
return getSnInfoApi()
|
||||
.updateUserInfo(getToken(), params, multipartBody)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
return schedule(getSnInfoApi()
|
||||
.updateUserInfo(getToken(), params, multipartBody));
|
||||
}
|
||||
|
||||
public Observable<BaseResponse> getupdateAvatarObservable(Map<String, RequestBody> params, MultipartBody.Part multipartBody) {
|
||||
return getSnInfoApi()
|
||||
.updateAvatar(getToken(), params, multipartBody)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
return schedule(getSnInfoApi()
|
||||
.updateAvatar(getToken(), params, multipartBody));
|
||||
}
|
||||
|
||||
public Observable<BaseResponse> getRunningAppObservable(String json) {
|
||||
return mRetrofit.create(AppUsageRecordApi.class)
|
||||
.sendRunningInfo(AdminManager.getInstance().getSerial(), json)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
return schedule(getAppUsageRecordControl()
|
||||
.sendRunningInfo(AdminManager.getInstance().getSerial(), json));
|
||||
}
|
||||
|
||||
public Observable<BaseResponse<LessonSetting>> getCloudLessonObservable() {
|
||||
return mRetrofit.create(SettingApi.class)
|
||||
.getCloudLessonSetting(AdminManager.getInstance().getSerial())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
return schedule(getSettingApi().getCloudLessonSetting(AdminManager.getInstance().getSerial()));
|
||||
}
|
||||
|
||||
public Observable<BaseResponse<LessonApp>> getCloudLessonAppObservable() {
|
||||
return mRetrofit.create(SettingApi.class)
|
||||
.getCloudLessonApp(AdminManager.getInstance().getSerial())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
return schedule(getSettingApi().getCloudLessonApp(AdminManager.getInstance().getSerial()));
|
||||
}
|
||||
|
||||
public Observable<BaseResponse<List<AlarmClockData>>> getAlarmClockObservable() {
|
||||
return mRetrofit
|
||||
.create(AlarmClockApi.class)
|
||||
.getAlarmClock(AdminManager.getInstance().getSerial())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
return schedule(getAlarmClockApi().getAlarmClock(AdminManager.getInstance().getSerial()));
|
||||
}
|
||||
|
||||
public Observable<BaseResponse> getUpdateAlarmObservable(int id) {
|
||||
return mRetrofit.create(AlarmClockApi.class)
|
||||
.updateAlarm(AdminManager.getInstance().getSerial(), id)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
return schedule(getAlarmClockApi().updateAlarm(AdminManager.getInstance().getSerial(), id));
|
||||
}
|
||||
|
||||
public Observable<BaseResponse<StudyStatBean>> getStudyStatObservable() {
|
||||
return getSnInfoApi()
|
||||
.getStudyStat(AdminManager.getInstance().getSerial())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
return schedule(getSnInfoApi().getStudyStat(AdminManager.getInstance().getSerial()));
|
||||
}
|
||||
|
||||
public Observable<BaseResponse> getUpdateAddressObservable(String address, double longitude, double latitude) {
|
||||
return getSnInfoApi()
|
||||
.updateAddress(getToken(), AdminManager.getInstance().getSerial(), address, longitude, latitude)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
return schedule(getSnInfoApi().updateAddress(getToken(), AdminManager.getInstance().getSerial(), address, longitude, latitude));
|
||||
}
|
||||
|
||||
public Observable<BaseResponse<GuideBean>> getFilesObservable(int type) {
|
||||
return mRetrofit.create(FilesApi.class)
|
||||
.getFiles(type)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
return schedule(getFilesApi().getFiles(type));
|
||||
}
|
||||
|
||||
public Observable<BaseResponse<ArrayList<HomeworkBean>>> getHomeworkObservable() {
|
||||
return mRetrofit.create(HomeworkApi.class)
|
||||
.getHomeworks(AdminManager.getInstance().getSerial())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
return schedule(getHomeworkApi().getHomeworks(AdminManager.getInstance().getSerial()));
|
||||
}
|
||||
|
||||
public Observable<BaseResponse<HomeworkBean>> getHomeworkDetailObservable(int id) {
|
||||
return mRetrofit.create(HomeworkApi.class)
|
||||
.getHomeworkDetail(AdminManager.getInstance().getSerial(), id)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
return schedule(getHomeworkApi().getHomeworkDetail(AdminManager.getInstance().getSerial(), id));
|
||||
}
|
||||
|
||||
public Observable<BaseResponse> getHomeworkUpdateObservable(int id) {
|
||||
return mRetrofit.create(HomeworkApi.class)
|
||||
.updateHomework(AdminManager.getInstance().getSerial(), id)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
return schedule(getHomeworkApi().updateHomework(AdminManager.getInstance().getSerial(), id));
|
||||
}
|
||||
|
||||
public Observable<BaseResponse<PhraseContent>> getPhraseObservable() {
|
||||
return mRetrofit.create(PhraseApi.class)
|
||||
.getPhrase(AdminManager.getInstance().getSerial())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
return schedule(getPhraseApi().getPhrase(AdminManager.getInstance().getSerial()));
|
||||
}
|
||||
|
||||
public Observable<BaseResponse<SystemSettings>> getSettingControl() {
|
||||
return mRetrofit.create(SettingApi.class)
|
||||
.getSetting(AdminManager.getInstance().getSerial())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
return schedule(getSettingApi().getSetting(AdminManager.getInstance().getSerial()));
|
||||
}
|
||||
|
||||
public Observable<BaseResponse<AppInfo>> getAdminAppObservable(String app_package) {
|
||||
return getAppApi()
|
||||
.getAdminApp(BuildConfig.APPLICATION_ID, app_package)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
return schedule(getAppApi().getAdminApp(BuildConfig.APPLICATION_ID, app_package));
|
||||
}
|
||||
|
||||
public Observable<BaseResponse<AppInfo>> getUpdateObservable(String packageName) {
|
||||
return getAppApi()
|
||||
.getAppUpdate(packageName, "0", JgyUtils.getInstance().checkAppPlatform())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
return schedule(getAppApi().getAppUpdate(packageName, "0", JgyUtils.getInstance().checkAppPlatform()));
|
||||
}
|
||||
|
||||
public Observable<BaseResponse<List<AppInfo>>> getTestAppObservable() {
|
||||
return getAppApi()
|
||||
.getTestApp(Utils.getSerial())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
return schedule(getAppApi().getTestApp(Utils.getSerial()));
|
||||
}
|
||||
|
||||
public Observable<BaseResponse> getPhoneCodeObservable(String mobile) {
|
||||
return mRetrofit.create(LoginApi.class)
|
||||
.getCode(mobile)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
return schedule(getLoginApi().getCode(mobile));
|
||||
}
|
||||
|
||||
public Observable<BaseResponse<LoginInfo>> getCodeLoginObservable(String mobile, String code) {
|
||||
return mRetrofit.create(LoginApi.class)
|
||||
.codeLogin(mobile, code, AdminManager.getInstance().getSerial())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
return schedule(getLoginApi().codeLogin(mobile, code, AdminManager.getInstance().getSerial()));
|
||||
}
|
||||
|
||||
public Observable<BaseResponse<LoginInfo>> getNewCodeLoginObservable(String mobile, String code) {
|
||||
return mRetrofit.create(LoginApi.class)
|
||||
.newCodeLogin(mobile, code, AdminManager.getInstance().getSerial(), BuildConfig.APPLICATION_ID)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
return schedule(getLoginApi().newCodeLogin(mobile, code, AdminManager.getInstance().getSerial(), BuildConfig.APPLICATION_ID));
|
||||
}
|
||||
|
||||
public Observable<BaseResponse> getUserLoginObservable(String mobile, String password) {
|
||||
return mRetrofit.create(LoginApi.class)
|
||||
.userLogin(mobile, password, AdminManager.getInstance().getSerial())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
return schedule(getLoginApi().userLogin(mobile, password, AdminManager.getInstance().getSerial()));
|
||||
}
|
||||
|
||||
public Observable<BaseResponse<UserInfo>> getUserInfoControl() {
|
||||
return mRetrofit.create(UserApi.class)
|
||||
.getUserInfo(getToken())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
return schedule(getUserApi().getUserInfo(getToken()));
|
||||
}
|
||||
|
||||
public Observable<BaseResponse<UserExpireInfo>> getUserExpireInfoControl() {
|
||||
return mRetrofit.create(UserApi.class)
|
||||
.getUserExpireInfo(getToken())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
return schedule(getUserApi().getUserExpireInfo(getToken()));
|
||||
}
|
||||
|
||||
public Observable<BaseResponse<List<VipInfo>>> getVipListControl() {
|
||||
return mRetrofit.create(UserApi.class)
|
||||
.getVipList(getToken(), BuildConfig.APPLICATION_ID)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
return schedule(getUserApi().getVipList(getToken(), BuildConfig.APPLICATION_ID));
|
||||
}
|
||||
|
||||
public Observable<BaseResponse<OrderInfo>> getBuyVipControl(String vipId) {
|
||||
return mRetrofit.create(UserApi.class)
|
||||
.buyVip(getToken(), AdminManager.getInstance().getSerial(), vipId)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
return schedule(getUserApi().buyVip(getToken(), AdminManager.getInstance().getSerial(), vipId));
|
||||
}
|
||||
|
||||
public Observable<BaseResponse<OrderInfo>> getBuyVipControl(String vipId, String coupons) {
|
||||
return mRetrofit.create(UserApi.class)
|
||||
.buyVip(getToken(), AdminManager.getInstance().getSerial(), vipId, coupons)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
return schedule(getUserApi().buyVip(getToken(), AdminManager.getInstance().getSerial(), vipId, coupons));
|
||||
}
|
||||
|
||||
public Observable<BaseResponse> getCheckCouponsControl(String coupons) {
|
||||
return mRetrofit.create(UserApi.class)
|
||||
.checkCoupons(getToken(), coupons)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
return schedule(getUserApi().checkCoupons(getToken(), coupons));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Observable<BaseResponse<CodeBean>> getCodeActivationControl(String code) {
|
||||
return mRetrofit.create(UserApi.class)
|
||||
.codeActivation(getToken(), AdminManager.getInstance().getSerial(), code)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
return schedule(getUserApi().codeActivation(getToken(), AdminManager.getInstance().getSerial(), code));
|
||||
}
|
||||
|
||||
public Observable<BaseResponse<CodeBean>> getActivationExchangeControl(String exchangeCode) {
|
||||
return mRetrofit.create(UserApi.class)
|
||||
.activationExchange(getToken(), AdminManager.getInstance().getSerial(), exchangeCode)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Observable<BaseResponse<CodeBean>> getActivationCodeControl() {
|
||||
return mRetrofit.create(UserApi.class)
|
||||
.getActivationCode(getToken(), AdminManager.getInstance().getSerial())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
return schedule(getUserApi().activationExchange(getToken(), AdminManager.getInstance().getSerial(), exchangeCode));
|
||||
}
|
||||
|
||||
public Observable<BaseResponse<CodeBean>> getEncryptedActivationCodeControl() {
|
||||
return mRetrofit.create(UserApi.class)
|
||||
.getEncryptedActivationCode(getToken(), AdminManager.getInstance().getSerial())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
return schedule(getUserApi().getEncryptedActivationCode(getToken(), AdminManager.getInstance().getSerial()));
|
||||
}
|
||||
|
||||
public Observable<BaseResponse<PayInfo>> getPayQrcodeControl(String orderSn) {
|
||||
return mRetrofit.create(UserApi.class)
|
||||
.payQrcode(getToken(), AdminManager.getInstance().getSerial(), orderSn)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
return schedule(getUserApi().payQrcode(getToken(), AdminManager.getInstance().getSerial(), orderSn));
|
||||
}
|
||||
|
||||
public Observable<BaseResponse<ScreenPassword>> getLockScreenPwdObservable() {
|
||||
return getSnInfoApi()
|
||||
.getLockScreenPwd(Utils.getSerial())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
return schedule(getSnInfoApi().getLockScreenPwd(Utils.getSerial()));
|
||||
}
|
||||
|
||||
public Observable<BaseResponse> getUpdateLockScreenObservable() {
|
||||
return mRetrofit.create(SnInfoApi.class)
|
||||
.updateLockScreen(Utils.getSerial())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
return schedule(getSnInfoApi().updateLockScreen(Utils.getSerial()));
|
||||
}
|
||||
|
||||
public Observable<BaseResponse<List<AppInfo>>> getAdminAppObservable() {
|
||||
return mRetrofit.create(AppApi.class)
|
||||
.getAdminApp(Utils.getSerial())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
return schedule(getAppApi().getAdminApp(Utils.getSerial()));
|
||||
}
|
||||
|
||||
public Observable<BaseResponse<List<AppInfo>>> get365AdminAppObservable() {
|
||||
return mRetrofit.create(AppApi.class)
|
||||
.getAdminApp(Utils.getSerial(), "11", BuildConfig.APPLICATION_ID)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
return schedule(getAppApi().getAdminApp(Utils.getSerial(), "11", BuildConfig.APPLICATION_ID));
|
||||
}
|
||||
|
||||
public Observable<BaseResponse<List<AppIcon>>> getAppIconObservable() {
|
||||
return mRetrofit.create(GetAppIconApi.class)
|
||||
.getAppIcon(Utils.getSerial())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
return schedule(getAppIconApi().getAppIcon(Utils.getSerial()));
|
||||
}
|
||||
|
||||
public Observable<BaseResponse> getOauthTokenObservable() {
|
||||
@@ -1127,12 +1052,12 @@ public class NetInterfaceManager {
|
||||
Log.e(TAG, "updateAdminInfo: software = " + software);
|
||||
}
|
||||
getSnInfoApi().sendAdminSn(
|
||||
Utils.getSerial(),
|
||||
"",
|
||||
machine,
|
||||
hardware,
|
||||
software
|
||||
).subscribeOn(Schedulers.io())
|
||||
Utils.getSerial(),
|
||||
"",
|
||||
machine,
|
||||
hardware,
|
||||
software
|
||||
).subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
@@ -1214,7 +1139,7 @@ public class NetInterfaceManager {
|
||||
this.add("com.hihonor.quickgamecenter");
|
||||
this.add("com.hihonor.edulauncher");
|
||||
this.add("com.hihonor.cloudmusic");
|
||||
this.add("com.hihonor.appmarket");
|
||||
// this.add("com.hihonor.appmarket");
|
||||
this.add("com.hihonor.gamecenter");
|
||||
this.add("com.hihonor.dz.reader");
|
||||
this.add("com.hihonor.magichome");
|
||||
@@ -1230,62 +1155,62 @@ public class NetInterfaceManager {
|
||||
*/
|
||||
public void SendAppInstallInfo() {
|
||||
Observable.create(new ObservableOnSubscribe<String>() {
|
||||
@Override
|
||||
public void subscribe(@NonNull ObservableEmitter<String> emitter) throws Throwable {
|
||||
Set<String> adminAppSet = mMMKV.decodeStringSet(CommonConfig.ADMIN_APP_LIST, new HashSet<>());
|
||||
PackageManager pm = mContext.getPackageManager();
|
||||
List<PackageInfo> installedPackages = pm.getInstalledPackages(PackageManager.GET_UNINSTALLED_PACKAGES);
|
||||
List<AppUploadInfo> uploadInfos = new ArrayList<>();
|
||||
Intent intent = new Intent(Intent.ACTION_MAIN, null);
|
||||
intent.addCategory(Intent.CATEGORY_LAUNCHER);
|
||||
List<ResolveInfo> appsWithLauncher = pm.queryIntentActivities(intent, 0);
|
||||
Log.e("SendAppInstallInfo", "appsWithLauncher: " + appsWithLauncher);
|
||||
List<String> pkgs = new ArrayList<>();
|
||||
@Override
|
||||
public void subscribe(@NonNull ObservableEmitter<String> emitter) throws Throwable {
|
||||
Set<String> adminAppSet = mMMKV.decodeStringSet(CommonConfig.ADMIN_APP_LIST, new HashSet<>());
|
||||
PackageManager pm = mContext.getPackageManager();
|
||||
List<PackageInfo> installedPackages = pm.getInstalledPackages(PackageManager.GET_UNINSTALLED_PACKAGES);
|
||||
List<AppUploadInfo> uploadInfos = new ArrayList<>();
|
||||
Intent intent = new Intent(Intent.ACTION_MAIN, null);
|
||||
intent.addCategory(Intent.CATEGORY_LAUNCHER);
|
||||
List<ResolveInfo> appsWithLauncher = pm.queryIntentActivities(intent, 0);
|
||||
Log.e("SendAppInstallInfo", "appsWithLauncher: " + appsWithLauncher);
|
||||
List<String> pkgs = new ArrayList<>();
|
||||
// for (PackageInfo packageInfo : installedPackages) {
|
||||
// if (pm.getApplicationEnabledSetting(packageInfo.packageName) == PackageManager.COMPONENT_ENABLED_STATE_DISABLED) {
|
||||
// pkgs.add(packageInfo.packageName);
|
||||
// }
|
||||
// }
|
||||
for (ResolveInfo info : appsWithLauncher) {
|
||||
pkgs.add(info.activityInfo.packageName);
|
||||
}
|
||||
Log.e("SendAppInstallInfo", "pkgs: " + pkgs);
|
||||
|
||||
for (PackageInfo info : installedPackages) {
|
||||
Log.i("SendAppInstallInfo", "info: " + info.packageName);
|
||||
//排除掉部分系统应用
|
||||
if (ApkUtils.isSystemApp(mContext, info.packageName)) {
|
||||
if (!showSystemApps.contains(info.packageName)) {
|
||||
continue;
|
||||
for (ResolveInfo info : appsWithLauncher) {
|
||||
pkgs.add(info.activityInfo.packageName);
|
||||
}
|
||||
Log.e("SendAppInstallInfo", "pkgs: " + pkgs);
|
||||
|
||||
for (PackageInfo info : installedPackages) {
|
||||
Log.i("SendAppInstallInfo", "info: " + info.packageName);
|
||||
//排除掉部分系统应用
|
||||
if (ApkUtils.isSystemApp(mContext, info.packageName)) {
|
||||
if (!showSystemApps.contains(info.packageName)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
//排除掉没有图标的应用
|
||||
if (!pkgs.contains(info.packageName) && !showPackages.contains(info.packageName)) {
|
||||
continue;
|
||||
}
|
||||
if (hidePackages.contains(info.packageName)) {
|
||||
continue;
|
||||
}
|
||||
Log.e("SendAppInstallInfo", "info: " + info.packageName);
|
||||
AppUploadInfo uploadInfo = new AppUploadInfo();
|
||||
uploadInfo.setApp_name(info.applicationInfo.loadLabel(pm).toString());
|
||||
uploadInfo.setApp_package(info.packageName);
|
||||
uploadInfo.setApp_version_name(info.versionName);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||
uploadInfo.setApp_version_code(info.getLongVersionCode());
|
||||
} else {
|
||||
uploadInfo.setApp_version_code(info.versionCode);
|
||||
}
|
||||
uploadInfo.setFirstInstallTime(info.firstInstallTime / 1000);
|
||||
uploadInfo.setLastUpdateTime(info.lastUpdateTime / 1000);
|
||||
uploadInfo.setApp_size(getPackageSize(mContext, info.applicationInfo.publicSourceDir));
|
||||
uploadInfo.setSource(adminAppSet.contains(info.packageName) ? 1 : 0);
|
||||
uploadInfos.add(uploadInfo);
|
||||
}
|
||||
String json = GsonUtils.toJSONString(uploadInfos);
|
||||
emitter.onNext(json);
|
||||
}
|
||||
//排除掉没有图标的应用
|
||||
if (!pkgs.contains(info.packageName) && !showPackages.contains(info.packageName)) {
|
||||
continue;
|
||||
}
|
||||
if (hidePackages.contains(info.packageName)) {
|
||||
continue;
|
||||
}
|
||||
Log.e("SendAppInstallInfo", "info: " + info.packageName);
|
||||
AppUploadInfo uploadInfo = new AppUploadInfo();
|
||||
uploadInfo.setApp_name(info.applicationInfo.loadLabel(pm).toString());
|
||||
uploadInfo.setApp_package(info.packageName);
|
||||
uploadInfo.setApp_version_name(info.versionName);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||
uploadInfo.setApp_version_code(info.getLongVersionCode());
|
||||
} else {
|
||||
uploadInfo.setApp_version_code(info.versionCode);
|
||||
}
|
||||
uploadInfo.setFirstInstallTime(info.firstInstallTime / 1000);
|
||||
uploadInfo.setLastUpdateTime(info.lastUpdateTime / 1000);
|
||||
uploadInfo.setApp_size(getPackageSize(mContext, info.applicationInfo.publicSourceDir));
|
||||
uploadInfo.setSource(adminAppSet.contains(info.packageName) ? 1 : 0);
|
||||
uploadInfos.add(uploadInfo);
|
||||
}
|
||||
String json = GsonUtils.toJSONString(uploadInfos);
|
||||
emitter.onNext(json);
|
||||
}
|
||||
})
|
||||
})
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.concatMap(new Function<String, ObservableSource<BaseResponse>>() {
|
||||
@@ -1388,15 +1313,15 @@ public class NetInterfaceManager {
|
||||
String path = ContextCompat.getExternalFilesDirs(mContext, Environment.DIRECTORY_DOWNLOADS)[0].getAbsolutePath();
|
||||
String filePath = path + File.separator + Utils.getSerial() + ".png";
|
||||
getScreenshot(filePath).concatMap(new Function<Integer, ObservableSource<BaseResponse>>() {
|
||||
@Override
|
||||
public ObservableSource<BaseResponse> apply(Integer integer) throws Exception {
|
||||
if (integer != 0) {
|
||||
throw new FileNotFoundException();
|
||||
}
|
||||
File file = new File(filePath);
|
||||
if (!file.exists()) {
|
||||
throw new FileNotFoundException(filePath);
|
||||
}
|
||||
@Override
|
||||
public ObservableSource<BaseResponse> apply(Integer integer) throws Exception {
|
||||
if (integer != 0) {
|
||||
throw new FileNotFoundException();
|
||||
}
|
||||
File file = new File(filePath);
|
||||
if (!file.exists()) {
|
||||
throw new FileNotFoundException(filePath);
|
||||
}
|
||||
// Bitmap bitmap = BitmapFactory.decodeFile(filePath);
|
||||
// if (bitmap.getWidth() < bitmap.getHeight()) {
|
||||
// bitmap = ImageUtils.rotate(bitmap, -90, bitmap.getWidth(), bitmap.getHeight());
|
||||
@@ -1412,12 +1337,12 @@ public class NetInterfaceManager {
|
||||
// fos.write(b, 0, x);
|
||||
// }
|
||||
// fos.close();
|
||||
MediaType mediaType = MediaType.Companion.parse("image/png");
|
||||
RequestBody requestBody = RequestBody.Companion.create(file, mediaType);
|
||||
MultipartBody.Part body = MultipartBody.Part.createFormData("file", file.getName(), requestBody);
|
||||
return getSendFile(filePath, body);
|
||||
}
|
||||
}).subscribeOn(Schedulers.io())
|
||||
MediaType mediaType = MediaType.Companion.parse("image/png");
|
||||
RequestBody requestBody = RequestBody.Companion.create(file, mediaType);
|
||||
MultipartBody.Part body = MultipartBody.Part.createFormData("file", file.getName(), requestBody);
|
||||
return getSendFile(filePath, body);
|
||||
}
|
||||
}).subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
@@ -1445,22 +1370,19 @@ public class NetInterfaceManager {
|
||||
|
||||
private Observable<Integer> getScreenshot(String filePath) {
|
||||
Observable<Integer> screenshotObservable = Observable.create(new ObservableOnSubscribe<Integer>() {
|
||||
@Override
|
||||
public void subscribe(ObservableEmitter<Integer> e) {
|
||||
int code = CmdUtil.execute("screencap -p " + filePath).code;
|
||||
e.onNext(code);
|
||||
e.onComplete();
|
||||
}
|
||||
}).subscribeOn(Schedulers.io())
|
||||
@Override
|
||||
public void subscribe(ObservableEmitter<Integer> e) {
|
||||
int code = CmdUtil.execute("screencap -p " + filePath).code;
|
||||
e.onNext(code);
|
||||
e.onComplete();
|
||||
}
|
||||
}).subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
return screenshotObservable;
|
||||
}
|
||||
|
||||
private Observable<BaseResponse> getSendFile(String path, MultipartBody.Part body) {
|
||||
return getUploadScreenshotControl()
|
||||
.getControlScreenshot(Utils.getSerial(), body)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
return schedule(getUploadScreenshotControl().getControlScreenshot(Utils.getSerial(), body));
|
||||
}
|
||||
|
||||
public static final String WHOIS_IP = "whois_ip_addr";
|
||||
@@ -1469,6 +1391,7 @@ public class NetInterfaceManager {
|
||||
void getPublicIp(String ip);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void getPublicIp(BehaviorSubject<ActivityEvent> lifecycle, PublicIpCallbak callbak) {
|
||||
Retrofit retrofit = new Retrofit.Builder()
|
||||
.client(NetInterfaceManager.getInstance().getOkHttpClient())
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface GetAppIconApi {
|
||||
public interface AppIconApi {
|
||||
@GET(UrlAddress.GET_APP_ICON)
|
||||
Observable<BaseResponse<List<AppIcon>>> getAppIcon(
|
||||
@Query("sn") String sn
|
||||
@@ -19,6 +19,7 @@ import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.hjq.toast.Toaster;
|
||||
import com.jeremyliao.liveeventbus.LiveEventBus;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.xwad.os.BuildConfig;
|
||||
import com.xwad.os.activity.home.HomeActivity;
|
||||
@@ -294,6 +295,9 @@ public class PushManager {
|
||||
/*APP应用通知管控*/
|
||||
private static final String APP_NOTIFY_SETTING = "127";
|
||||
|
||||
private static final String SYSTEM_OTA_CTRL = "129";
|
||||
|
||||
|
||||
public void setPushContent(String title, String extras) {
|
||||
switch (title) {
|
||||
case GET_DRIVELINE:
|
||||
@@ -421,10 +425,24 @@ public class PushManager {
|
||||
case APP_NOTIFY_SETTING:
|
||||
setAppNotify(extras);
|
||||
break;
|
||||
case SYSTEM_OTA_CTRL:
|
||||
setSystemOtaCtrl(extras);
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
private void setSystemOtaCtrl(String extras) {
|
||||
JsonObject jsonObject = GsonUtils.getJsonObject(extras);
|
||||
JsonElement jsonElement = jsonObject.get("system_ota_ctrl");
|
||||
if (jsonElement == null || jsonElement.isJsonNull()) {
|
||||
Log.e(TAG, "setSystemOtaCtrl: jsonElement is null");
|
||||
return;
|
||||
}
|
||||
int system_ota_ctrl = jsonElement.getAsInt();
|
||||
ControlManager.getInstance().setSystemUpdateDisabled(system_ota_ctrl);
|
||||
}
|
||||
|
||||
private void setAppNotify(String extras) {
|
||||
JsonObject jsonObject = GsonUtils.getJsonObject(extras);
|
||||
JsonElement jsonElement = jsonObject.get("app_notify");
|
||||
@@ -765,14 +783,14 @@ public class PushManager {
|
||||
|
||||
public void doscreenshot(long time) {
|
||||
Observable.create(new ObservableOnSubscribe<File>() {
|
||||
@Override
|
||||
public void subscribe(ObservableEmitter<File> e) throws Exception {
|
||||
String filepath = mContext.getExternalFilesDir("db").getAbsolutePath() + File.separator + time + ".db";
|
||||
Bitmap bitmap = AdminManager.getInstance().captureScreen();
|
||||
File file = BitmapUtils.saveBitmap(bitmap, filepath);
|
||||
e.onNext(file);
|
||||
}
|
||||
}).subscribeOn(Schedulers.io())
|
||||
@Override
|
||||
public void subscribe(ObservableEmitter<File> e) throws Exception {
|
||||
String filepath = mContext.getExternalFilesDir("db").getAbsolutePath() + File.separator + time + ".db";
|
||||
Bitmap bitmap = AdminManager.getInstance().captureScreen();
|
||||
File file = BitmapUtils.saveBitmap(bitmap, filepath);
|
||||
e.onNext(file);
|
||||
}
|
||||
}).subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<File>() {
|
||||
@Override
|
||||
@@ -875,6 +893,8 @@ public class PushManager {
|
||||
int isReturnAndroid = jsonObject.get("is_return_android").getAsInt();
|
||||
mMMKV.encode(CommonConfig.UIUI_RETURN_ANDROID_KEY, isReturnAndroid);
|
||||
sendZyosRefreshIntent();
|
||||
LiveEventBus.get(CommonConfig.UIUI_RETURN_ANDROID_KEY)
|
||||
.post(isReturnAndroid);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
package com.xwad.os.repository;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.trello.rxlifecycle4.RxLifecycle;
|
||||
import com.trello.rxlifecycle4.android.ActivityEvent;
|
||||
import com.trello.rxlifecycle4.android.FragmentEvent;
|
||||
import com.xwad.os.BuildConfig;
|
||||
import com.xwad.os.bean.BaseResponse;
|
||||
import com.xwad.os.bean.CodeBean;
|
||||
import com.xwad.os.network.NetInterfaceManager;
|
||||
import com.xwad.os.utils.ActivationUtil;
|
||||
|
||||
import io.reactivex.rxjava3.annotations.NonNull;
|
||||
import io.reactivex.rxjava3.core.Observer;
|
||||
import io.reactivex.rxjava3.disposables.Disposable;
|
||||
import io.reactivex.rxjava3.subjects.BehaviorSubject;
|
||||
|
||||
/**
|
||||
* 激活相关网络请求与本地状态写入的仓储层。
|
||||
* 统一封装 getEncryptedActivationCodeControl 的请求与激活状态处理,
|
||||
* ViewModel 通过回调获取结果后处理各自的差异化逻辑。
|
||||
*/
|
||||
public class ActivationRepository {
|
||||
|
||||
private static final String TAG = "ActivationRepository";
|
||||
|
||||
/**
|
||||
* 获取加密激活码的处理结果回调。
|
||||
*/
|
||||
public interface OnActivationResult {
|
||||
/**
|
||||
* 请求成功且 code == 200。
|
||||
*
|
||||
* @param codeBean 服务端返回的激活码信息
|
||||
*/
|
||||
void onSuccess(CodeBean codeBean);
|
||||
|
||||
/**
|
||||
* 请求失败或服务端返回非 200。
|
||||
*/
|
||||
void onFailure();
|
||||
}
|
||||
|
||||
private static class Holder {
|
||||
static final ActivationRepository INSTANCE = new ActivationRepository();
|
||||
}
|
||||
|
||||
public static ActivationRepository getInstance() {
|
||||
return Holder.INSTANCE;
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求加密激活码(绑定 Activity 生命周期),并将激活信息写入本地。
|
||||
* 成功后交由回调处理差异化逻辑(如跳转 launcher、通知 UI 等),
|
||||
* 失败统一将本地激活状态置为 0。
|
||||
*
|
||||
* @param lifecycle Activity 生命周期
|
||||
* @param result 结果回调,不可为 null
|
||||
*/
|
||||
public void getEncryptedActivationCode(BehaviorSubject<ActivityEvent> lifecycle, OnActivationResult result) {
|
||||
NetInterfaceManager.getInstance().getEncryptedActivationCodeControl()
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
||||
.subscribe(getActivationObserver(result));
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求加密激活码(绑定 Fragment 生命周期),并将激活信息写入本地。
|
||||
* 成功后交由回调处理差异化逻辑(如跳转 launcher、通知 UI 等),
|
||||
* 失败统一将本地激活状态置为 0。
|
||||
*
|
||||
* @param lifecycle Fragment 生命周期
|
||||
* @param result 结果回调,不可为 null
|
||||
*/
|
||||
public void getEncryptedActivationCodeFragment(BehaviorSubject<FragmentEvent> lifecycle, OnActivationResult result) {
|
||||
NetInterfaceManager.getInstance().getEncryptedActivationCodeControl()
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycle, FragmentEvent.DESTROY))
|
||||
.subscribe(getActivationObserver(result));
|
||||
}
|
||||
|
||||
private Observer<BaseResponse<CodeBean>> getActivationObserver(OnActivationResult result) {
|
||||
return new Observer<BaseResponse<CodeBean>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("getEncryptedCode", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<CodeBean> baseResponse) {
|
||||
if (BuildConfig.DEBUG) {
|
||||
Log.e("getEncryptedCode", "onNext: " + baseResponse);
|
||||
}
|
||||
if (baseResponse.code == 200) {
|
||||
CodeBean codeBean = baseResponse.data;
|
||||
ActivationUtil.getInstance().setActivationCode(codeBean.getCode());
|
||||
ActivationUtil.getInstance().setActivation(1);
|
||||
if (result != null) {
|
||||
result.onSuccess(codeBean);
|
||||
}
|
||||
} else {
|
||||
ActivationUtil.getInstance().setActivation(0);
|
||||
if (result != null) {
|
||||
result.onFailure();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("getEncryptedCode", "onError: " + e.getMessage());
|
||||
if (result != null) {
|
||||
result.onFailure();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getEncryptedCode", "onComplete: ");
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,6 @@ import com.xwad.os.config.CommonConfig;
|
||||
import com.xwad.os.gson.GsonUtils;
|
||||
import com.xwad.os.network.NetInterfaceManager;
|
||||
import com.xwad.os.service.ManagerService;
|
||||
import com.xwad.os.utils.ActivationUtil;
|
||||
import com.xwad.os.utils.ApkUtils;
|
||||
import com.xwad.os.utils.FileUtils;
|
||||
import com.xwad.os.utils.ServiceAliveUtils;
|
||||
@@ -135,7 +134,7 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
}
|
||||
|
||||
} else if (userInfoBaseResponse.code == 401) {
|
||||
ActivationUtil.getInstance().setActivation(0);
|
||||
// ActivationUtil.getInstance().setActivation(0);
|
||||
mMMKV.encode(CommonConfig.ACCOUNT_LOGIN_STATU, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,6 +127,11 @@ public class ActivationUtil {
|
||||
return mMMKV.decodeInt(CommonConfig.ACCOUNT_LOGIN_STATU, 0) == 1;
|
||||
}
|
||||
|
||||
public boolean needLogin() {
|
||||
return ActivationUtil.getInstance().isActivation() || isLogin();
|
||||
}
|
||||
|
||||
|
||||
public void startJxwLauncher() {
|
||||
if (!ApkUtils.isAvailable(mContext, JxwPackageConfig.JXW_LAUNCHER_PACKAGE_NAME)) {
|
||||
Log.e(TAG, "startJxwLauncher: jxw app not install");
|
||||
|
||||
@@ -689,7 +689,7 @@ public class OpenApkUtils {
|
||||
}
|
||||
|
||||
public void openJxwAppWithParam(Activity activity, String paramStr, boolean checkInstall) {
|
||||
if (!ActivationUtil.getInstance().isLogin()) {
|
||||
if (!ActivationUtil.getInstance().needLogin()) {
|
||||
Toaster.show("请先登录");
|
||||
activity.startActivity(new Intent(activity, LoginActivity.class));
|
||||
return;
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 38 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 208 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 142 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 150 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 848 KiB After Width: | Height: | Size: 1.1 MiB |
@@ -18,10 +18,23 @@
|
||||
android:background="@drawable/mine_wallpaper"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_aidxxt"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="80dp"
|
||||
android:adjustViewBounds="true"
|
||||
android:onClick="onClick"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/icon_aidxxt"
|
||||
android:tag="@string/tag_args_dxxt"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/home"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="24dp"
|
||||
android:orientation="horizontal"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
@@ -35,6 +48,7 @@
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/xuewang_logo_ai"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
@@ -43,7 +57,6 @@
|
||||
android:id="@+id/tv_notification"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:ellipsize="marquee"
|
||||
android:focusable="true"
|
||||
@@ -53,6 +66,7 @@
|
||||
android:text="@string/tips"
|
||||
android:textColor="@color/lightGray"
|
||||
android:textSize="8sp"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/tv_time"
|
||||
app:layout_constraintStart_toEndOf="@+id/iv_logo"
|
||||
@@ -178,6 +192,8 @@
|
||||
android:id="@+id/subject_viewPager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_marginEnd="20dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
|
||||
@@ -213,8 +213,8 @@
|
||||
android:adjustViewBounds="true"
|
||||
android:onClick="onClick"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/icon_xwcd"
|
||||
android:tag="@string/tag_args_new_xwcd_online"
|
||||
android:src="@drawable/icon_dxxt"
|
||||
android:tag="@string/tag_args_dxxt"
|
||||
app:layout_constraintStart_toEndOf="@+id/rl_grxx"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
@@ -226,8 +226,8 @@
|
||||
android:adjustViewBounds="true"
|
||||
android:onClick="onClick"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/icon_sjzx"
|
||||
android:tag="@string/tag_args_new_hemo"
|
||||
android:src="@drawable/icon_aikyls"
|
||||
android:tag="@string/tag_args_new_kyls"
|
||||
app:layout_constraintStart_toEndOf="@+id/iv_xwcd"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
@@ -239,8 +239,8 @@
|
||||
android:adjustViewBounds="true"
|
||||
android:onClick="onClick"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/icon_szzs"
|
||||
android:tag="@string/tag_args_new_msfc"
|
||||
android:src="@drawable/icon_cjcd"
|
||||
android:tag="@string/tag_args_new_xwcd_online"
|
||||
app:layout_constraintStart_toEndOf="@+id/iv_sjzx"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
@@ -649,8 +649,10 @@
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/cl_exit"
|
||||
android:layout_width="@dimen/mine_icon_width"
|
||||
android:layout_height="match_parent"
|
||||
android:visibility="gone"
|
||||
android:onClick="@{click::exit}"
|
||||
android:tag="@string/tag_args_launcher">
|
||||
|
||||
@@ -693,7 +695,7 @@
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="@dimen/mine_icon_width"
|
||||
android:layout_height="match_parent"
|
||||
android:onClick="onClick"
|
||||
android:onClick="@{click::openSettings}"
|
||||
android:tag="@string/tag_args_new_settings">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<resources>
|
||||
<string name="app_name">学习超人365</string>
|
||||
<string name="app_name">学习中心</string>
|
||||
<string name="privacy_agreement"><u>隐私协议</u></string>
|
||||
<string name="privacy_agreement_title">服务协议和隐私政策</string>
|
||||
<string name="privacy_agreement_content">\t\t\t\t请你务必审慎阅读、充分理解“服务协议”和“隐私政策”各条款,包括但不限于:为了向你提供即时通讯,内容分享等服务,
|
||||
@@ -71,4 +71,6 @@
|
||||
<string name="sample_device_admin_description">开启我吧</string>
|
||||
<string name="bibeizujian_permission">1、必备组件维持系统基本运行,请优先安装,并【允许】所有权限弹窗请求;</string>
|
||||
|
||||
<string name="tag_args_dxxt">com.xiaoyeoo.launcher,,,,督学系统</string>
|
||||
|
||||
</resources>
|
||||
Reference in new issue
Block a user