version:6.4.7
fix: update:增加绑定手机和绑定状态,增加扫码绑定
This commit is contained in:
@@ -19,8 +19,11 @@ import android.os.PowerManager;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import com.aoleyun.sn.R;
|
||||
import com.aoleyun.sn.activity.main.MainActivity;
|
||||
import com.aoleyun.sn.bean.BaseResponse;
|
||||
import com.aoleyun.sn.bean.BatteryInfo;
|
||||
import com.aoleyun.sn.bean.DownloadInfo;
|
||||
@@ -28,6 +31,7 @@ import com.aoleyun.sn.bean.RemoteDebug;
|
||||
import com.aoleyun.sn.bean.ScreenLockState;
|
||||
import com.aoleyun.sn.comm.CommonConfig;
|
||||
import com.aoleyun.sn.comm.JGYActions;
|
||||
import com.aoleyun.sn.dialog.CustomDialog;
|
||||
import com.aoleyun.sn.disklrucache.CacheHelper;
|
||||
import com.aoleyun.sn.gson.GsonUtils;
|
||||
import com.aoleyun.sn.gson.NullStringToEmptyAdapterFactory;
|
||||
@@ -67,13 +71,16 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
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.functions.Consumer;
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers;
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.MultipartBody;
|
||||
@@ -84,6 +91,8 @@ import retrofit2.Response;
|
||||
public class PushManager {
|
||||
private static final String TAG = PushManager.class.getSimpleName();
|
||||
|
||||
public static final String ACTION_REFRESH_BINDING_STATUS = "RefreshBindingStatus";
|
||||
|
||||
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
private static PushManager sInstance;
|
||||
@@ -212,10 +221,30 @@ public class PushManager {
|
||||
private static final String TAKE_FRONT_PICTURE = "58";
|
||||
/*时间管控*/
|
||||
private static final String TIME_CONTROL2 = "59";
|
||||
/*应用安装总开关*/
|
||||
private static final String INSTALL_CONTROL = "60";
|
||||
/*usb传输*/
|
||||
private static final String USB_CONTROL = "61";
|
||||
/*专注模式*/
|
||||
private static final String FOCUS_MODE = "62";
|
||||
/*修改锁屏密码*/
|
||||
private static final String CHANGE_LOCKED_PASSWD = "63";
|
||||
/*蓝牙传输管控*/
|
||||
private static final String BLUETOOTH_CONTROL = "64";
|
||||
/*开发者选项*/
|
||||
private static final String DEVELOPER_CONTROL = "65";
|
||||
/*恢复出厂模式*/
|
||||
private static final String FACTORY_CONTROL = "66";
|
||||
/*通知栏开关*/
|
||||
private static final String SETTING_STATUSBAR = "67";
|
||||
/*导航栏管控*/
|
||||
private static final String SETTING_NAVIGATION = "68";
|
||||
/*存储卡管控*/
|
||||
private static final String SETTING_TF_CARD = "69";
|
||||
|
||||
/*绑定设备*/
|
||||
private static final String BIND_DEVICE = "71";
|
||||
|
||||
|
||||
public void setPushContent(String title, String extras) {
|
||||
switch (title) {
|
||||
@@ -597,6 +626,18 @@ public class PushManager {
|
||||
case FOCUS_MODE:
|
||||
refreshFocusMode();
|
||||
break;
|
||||
case INSTALL_CONTROL:
|
||||
case BLUETOOTH_CONTROL:
|
||||
case DEVELOPER_CONTROL:
|
||||
case FACTORY_CONTROL:
|
||||
case SETTING_STATUSBAR:
|
||||
case SETTING_NAVIGATION:
|
||||
case SETTING_TF_CARD:
|
||||
NetInterfaceManager.getInstance().setSystemSetting();
|
||||
break;
|
||||
case BIND_DEVICE:
|
||||
bindService(extras);
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
@@ -1269,4 +1310,130 @@ public class PushManager {
|
||||
context.sendBroadcast(intent);
|
||||
}
|
||||
|
||||
private Disposable subscribe;
|
||||
private long cutdownTime = 30;
|
||||
private CustomDialog dialog;
|
||||
|
||||
void bindService(final String jsonString) {
|
||||
ToastUtil.betaShow("收到绑定设备请求");
|
||||
JsonObject object = GsonUtils.getJsonObject(jsonString);
|
||||
// String userName = object.get("member_name").getAsString();
|
||||
final String id = object.get("userId").getAsString();
|
||||
String phoneNum = object.get("mobile").getAsString();
|
||||
if (dialog == null) {
|
||||
dialog = new CustomDialog(mContext);
|
||||
subscribe = Observable.interval(1, TimeUnit.SECONDS)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Consumer<Long>() {
|
||||
@Override
|
||||
public void accept(Long aLong) throws Exception {
|
||||
// Log.e("TAG", "倒计时:" + aLong);
|
||||
if (aLong < cutdownTime && !subscribe.isDisposed()) {
|
||||
dialog.setNegtiveText("拒绝" + "(" + (cutdownTime - aLong) + ")");
|
||||
} else {
|
||||
bind(id, 0);
|
||||
dialog.dismiss();
|
||||
dialog = null;
|
||||
subscribe.dispose();
|
||||
subscribe = null;
|
||||
}
|
||||
}
|
||||
});
|
||||
dialog.setMessage(phoneNum + "请求绑定你的设备")
|
||||
.setTitle("设备绑定请求")
|
||||
.setPositive("允许")
|
||||
.setNegtive("拒绝")
|
||||
// .setSingle(true)
|
||||
.setOnClickBottomListener(new CustomDialog.OnClickBottomListener() {
|
||||
@Override
|
||||
public void onPositiveClick() {
|
||||
bind(id, 1);
|
||||
dialog.dismiss();
|
||||
dialog = null;
|
||||
subscribe.dispose();
|
||||
subscribe = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNegtiveClick() {
|
||||
bind(id, 2);
|
||||
ToastUtil.show("设备取消绑定");
|
||||
dialog.dismiss();
|
||||
dialog = null;
|
||||
subscribe.dispose();
|
||||
subscribe = null;
|
||||
}
|
||||
});
|
||||
dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
|
||||
dialog.show();
|
||||
dialog.getWindow().setGravity(Gravity.CENTER);
|
||||
dialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
|
||||
dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
|
||||
}
|
||||
|
||||
// new CountDownTimer(30000, 1000) {
|
||||
// @Override
|
||||
// public void onTick(long l) {
|
||||
// String value = String.valueOf((int) (l / 1000));
|
||||
// dialog_info.setNegtiveText("拒绝" + "(" + value + ")");
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onFinish() {
|
||||
// bind(context, id, 0);
|
||||
// dialog_info.dismiss();
|
||||
// }
|
||||
// }.start();
|
||||
}
|
||||
|
||||
private void bind(final String id, int type) {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getSnConfirmBindApi()
|
||||
.snConfirmBind(Utils.getSerial(mContext), id, type)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("bind", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse baseResponse) {
|
||||
int code = baseResponse.code;
|
||||
Log.e("bind", "onNext: " + baseResponse);
|
||||
String msg = baseResponse.msg;
|
||||
// Log.e("bind", baseResponse.toString());
|
||||
if (code == 200) {
|
||||
ToastUtil.show("绑定成功");
|
||||
sendRefreshIntent();
|
||||
} else if (code == 301) {
|
||||
ToastUtil.show(msg);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("bind", "onError: " + e.getMessage());
|
||||
onComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("bind", "onComplete: ");
|
||||
// NetInterfaceManager.getInstance().getSnInfo();
|
||||
Intent serviceIntent = new Intent(MainService.RefreshReceiver.REFRESH_RECEIVER_ACTION);
|
||||
mContext.sendBroadcast(serviceIntent);
|
||||
Intent activityIntent = new Intent(MainActivity.REFRESHACTION);
|
||||
mContext.sendBroadcast(activityIntent);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void sendRefreshIntent() {
|
||||
Intent intent = new Intent(ACTION_REFRESH_BINDING_STATUS);
|
||||
intent.setPackage("com.teclast.zyos");
|
||||
mContext.sendBroadcast(intent);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user