version:2.0

fix:
add:根据设备类型自动下载应用
This commit is contained in:
2022-06-11 18:21:56 +08:00
parent 688e48bd97
commit 0d324c17a4
6 changed files with 104 additions and 26 deletions

View File

@@ -34,6 +34,7 @@ import com.uiui.sn.fragment.BaseFragmentPagerAdapter;
import com.uiui.sn.fragment.QRCodeFragment;
import com.uiui.sn.manager.ControlManager;
import com.uiui.sn.manager.DeviceManager;
import com.uiui.sn.network.NetInterfaceManager;
import com.uiui.sn.service.ControlPanelService;
import com.uiui.sn.service.DownloadService;
import com.uiui.sn.service.GuardService;
@@ -327,31 +328,28 @@ public class MainActivity extends BaseActivity implements MainAContact.MainView,
@Override
public void setSnInfo(BaseResponse<SnInfo> response) {
if (response != null) {
int code = response.code;
setDeviceBindStatu(code);
//设备已经绑定
if (response.code == 200) {
tv_bind.setText(getString(R.string.bind_succeed));
SnInfo snInfo = response.data;
NetInterfaceManager.getInstance().checkDeviceType(snInfo.getType_id());
}
//设备没有绑定
else if (response.code == 300) {
tv_bind.setText(getString(R.string.scan_tips));
ControlManager.getInstance().setDisableSetting();
}
//没有授权的设备
else if (response.code == 400) {
tv_bind.setText(getString(R.string.device_unauthorized));
ToastUtil.show(getString(R.string.device_unauthorized));
Log.e(TAG, "setSnInfo: " + getString(R.string.device_unauthorized));
ControlManager.getInstance().setDisableSetting();
}
mPresenter.getAppletQRCode();
}
}
private void setDeviceBindStatu(int code) {
//设备已经绑定
if (code == 200) {
tv_bind.setText(getString(R.string.bind_succeed));
}
//设备没有绑定
else if (code == 300) {
tv_bind.setText(getString(R.string.scan_tips));
ControlManager.getInstance().setDisableSetting();
}
//没有授权的设备
else if (code == 400) {
tv_bind.setText(getString(R.string.device_unauthorized));
ToastUtil.show(getString(R.string.device_unauthorized));
Log.e(TAG, "setSnInfo: " + getString(R.string.device_unauthorized));
ControlManager.getInstance().setDisableSetting();
}
mPresenter.getAppletQRCode();
}
@Override
public void setAppletQRCode(String url) {
if (!TextUtils.isEmpty(url)) {

View File

@@ -23,9 +23,19 @@ public class SnInfo implements Serializable {
String school;
String is_lock;
String is_reset;
String grade;
String name;
int admin_id;
String grade;
/*
*3 商用——企业用户
4 C端——老人用户
5 教育——机构用户
6 C端——学生用户
7 C端——DIY用户
8 C端——经销商
*
* */
int type_id;
public int getId() {
return id;
@@ -155,6 +165,14 @@ public class SnInfo implements Serializable {
this.grade = grade;
}
public int getType_id() {
return type_id;
}
public void setType_id(int type_id) {
this.type_id = type_id;
}
@NonNull
@Override
public String toString() {

View File

@@ -746,6 +746,60 @@ public class NetInterfaceManager {
}
private static final int cElderlyUsers = 4;
public void checkDeviceType(int type) {
switch (type) {
case cElderlyUsers:
getElderlyUsersApp();
break;
default:
}
}
public void getElderlyUsersApp() {
Observable.zip(getUpdateObservable(JGYUtils.AIHealth),
getUpdateObservable(JGYUtils.ElderlyDesktop),
new BiFunction<BaseResponse<AppInfo>, BaseResponse<AppInfo>, List<AppInfo>>() {
@Override
public List<AppInfo> apply(BaseResponse<AppInfo> appInfoBaseResponse, BaseResponse<AppInfo> appInfoBaseResponse2) throws Throwable {
List<AppInfo> appInfoList = new ArrayList<>();
if (appInfoBaseResponse.code == 200) {
appInfoList.add(appInfoBaseResponse.data);
}
if (appInfoBaseResponse2.code == 200) {
appInfoList.add(appInfoBaseResponse2.data);
}
return appInfoList;
}
})
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<List<AppInfo>>() {
@Override
public void onSubscribe(@NonNull Disposable d) {
Log.e("getElderlyUsersApp", "onSubscribe: ");
}
@Override
public void onNext(@NonNull List<AppInfo> appInfos) {
cacheHelper.put(UrlAddress.GET_NEWESTAPPUPDATE, GsonUtils.toJsonString(appInfos));
getAllAppUpdate(appInfos);
Log.e("getElderlyUsersApp", "onNext: " + appInfos);
}
@Override
public void onError(@NonNull Throwable e) {
Log.e("getElderlyUsersApp", "onError: " + e.getMessage());
onComplete();
}
@Override
public void onComplete() {
Log.e("getElderlyUsersApp", "onComplete: ");
}
});
}
public void checkUpdate(String packageName, String versionCode) {
Log.e("checkUpdate", "packageName: " + packageName);
@@ -1588,7 +1642,7 @@ public class NetInterfaceManager {
String machine = Utils.getMachine(mContext);
String hardware = Utils.getHardware(mContext);
String software = softwareJson.toString();
if (BuildConfig.DEBUG){
if (BuildConfig.DEBUG) {
Log.e(TAG, "updateAdminInfo: machine = " + machine);
Log.e(TAG, "updateAdminInfo: getHardware = " + hardware);
Log.e(TAG, "updateAdminInfo: software = " + software);

View File

@@ -361,6 +361,8 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
//设备已经绑定
if (code == 200) {
mPresenter.getLocked();
SnInfo snInfo = response.data;
NetInterfaceManager.getInstance().checkDeviceType(snInfo.getType_id());
}
//设备没有绑定
else if (code == 300) {

View File

@@ -79,6 +79,7 @@ public class JGYUtils {
this.add("com.uiui.appstore");
this.add("com.uiui.browser");
this.add("com.uiui.os");
this.add("com.uiui.aios");
this.add("com.uiui.sn");
this.add("com.uiui.videoplayer");
this.add("com.uiuios.jgy1");
@@ -447,7 +448,6 @@ public class JGYUtils {
}
}
/**
* 获取系统配置信息
*
@@ -824,7 +824,7 @@ public class JGYUtils {
only_jgy_shortcut_list = "";
}
//获取可以被安装的包名
String qch_app_forbid = Settings.System.getString(resolver, CommonConfig.QCH_APP_FORBID);
String qch_app_forbid = Settings.System.getString(resolver, CommonConfig.QCH_APP_FORBID);
if (qch_app_forbid == null) {
qch_app_forbid = "";
}
@@ -933,6 +933,11 @@ public class JGYUtils {
mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, currentVolume, 0);
}
/*AI健康*/
public static final String AIHealth = "com.uiui.health";
/*老人桌面*/
public static final String ElderlyDesktop = "com.uiui.aios";
public static final String PACKAGE_BROWSER = "com.uiui.browser";
public static final String PACKAGE_VIDEOPLAYER = "com.uiui.videoplayer";

View File

@@ -1279,6 +1279,7 @@ public class Utils {
this.add(BuildConfig.APPLICATION_ID);
this.add("com.uiui.appstore");
this.add("com.uiui.os");
this.add("com.uiui.aios");
this.add("com.uiui.browser");
}};