version:3.5
fix:第一次开机不弹窗,修复重复请求时不抛出onerror异常,修复email意外弹出 update:
This commit is contained in:
@@ -61,8 +61,8 @@ android {
|
||||
//新平台正式
|
||||
cube {
|
||||
flavorDimensions "default"
|
||||
versionCode 24
|
||||
versionName "3.3"
|
||||
versionCode 26
|
||||
versionName "3.5"
|
||||
/*********************************极光推送************************************/
|
||||
manifestPlaceholders = [
|
||||
XG_ACCESS_ID : "1500026372",
|
||||
|
||||
@@ -25,6 +25,7 @@ import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.aoleyun.sn.BuildConfig;
|
||||
import com.aoleyun.sn.R;
|
||||
import com.aoleyun.sn.activity.checknet.CheckNetActivity;
|
||||
import com.aoleyun.sn.activity.main.MainActivity;
|
||||
import com.aoleyun.sn.base.BaseApplication;
|
||||
import com.aoleyun.sn.comm.JGYActions;
|
||||
@@ -64,8 +65,8 @@ public class SplashActivity extends AppCompatActivity {
|
||||
debugTest();
|
||||
new Handler().postDelayed(() -> {
|
||||
startActivity(new Intent(SplashActivity.this, MainActivity.class));
|
||||
// startActivity(new Intent(HomeActivity.this, CheckNetActivity.class));
|
||||
finish();
|
||||
// startActivity(new Intent(SplashActivity.this, CheckNetActivity.class));
|
||||
}, 2000);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.aoleyun.sn.activity.checknet;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.SystemClock;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
@@ -9,13 +8,14 @@ import android.widget.TextView;
|
||||
|
||||
import com.aoleyun.sn.R;
|
||||
import com.aoleyun.sn.base.BaseActivity;
|
||||
import com.aoleyun.sn.service.main.MainService;
|
||||
import com.aoleyun.sn.comm.CommonConfig;
|
||||
import com.aoleyun.sn.utils.JGYUtils;
|
||||
import com.aoleyun.sn.utils.SaveListUtils;
|
||||
import com.aoleyun.sn.utils.SysSettingUtils;
|
||||
import com.aoleyun.sn.utils.ToastUtil;
|
||||
import com.aoleyun.sn.utils.Utils;
|
||||
import com.blankj.utilcode.util.NetworkUtils;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@@ -48,6 +48,7 @@ public class CheckNetActivity extends BaseActivity implements CheckNetContact.Ma
|
||||
|
||||
private CheckNetPresenter mCheckNetPresenter;
|
||||
private boolean netWorkIsRunning = false;
|
||||
private MMKV mMMKV = MMKV.defaultMMKV();
|
||||
|
||||
@Override
|
||||
public void onDisconnected() {
|
||||
@@ -58,7 +59,7 @@ public class CheckNetActivity extends BaseActivity implements CheckNetContact.Ma
|
||||
public void onConnected(NetworkUtils.NetworkType networkType) {
|
||||
Log.e("OnNetworkStatusChanged", "onConnected: ");
|
||||
timeMillis = SystemClock.elapsedRealtime();
|
||||
giv_1.setImageResource(R.drawable.succeed);
|
||||
giv_1.setBackgroundResource(R.drawable.successful);
|
||||
//直接获取数据
|
||||
mCheckNetPresenter.getLockedState();
|
||||
}
|
||||
@@ -83,10 +84,12 @@ public class CheckNetActivity extends BaseActivity implements CheckNetContact.Ma
|
||||
public void isAvailable(boolean available) {
|
||||
runOnUiThread(() -> {
|
||||
if (available) {
|
||||
giv_1.setImageResource(R.drawable.succeed);
|
||||
giv_1.setBackgroundResource(R.drawable.successful);
|
||||
mCheckNetPresenter.getLockedState();
|
||||
} else {
|
||||
giv_1.setImageResource(R.drawable.failed);
|
||||
giv_1.setBackgroundResource(R.drawable.failed);
|
||||
giv_2.setBackgroundResource(R.drawable.failed);
|
||||
giv_3.setBackgroundResource(R.drawable.failed);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -162,7 +165,8 @@ public class CheckNetActivity extends BaseActivity implements CheckNetContact.Ma
|
||||
*/
|
||||
@Override
|
||||
public void setFirstConnect(boolean state) {
|
||||
Log.e(TAG, "isFirstConnect: " + "end request");
|
||||
Log.e(TAG, "isFirstConnect: " + "end request ");
|
||||
Log.e(TAG, "setFirstConnect: " + state);
|
||||
if (state) {
|
||||
mCheckNetPresenter.setDisableSetting();
|
||||
} else {
|
||||
@@ -257,9 +261,9 @@ public class CheckNetActivity extends BaseActivity implements CheckNetContact.Ma
|
||||
public void setTagsFinish(boolean noTag) {
|
||||
if (mCheckNetPresenter.isRequestSucceeded()) {
|
||||
Log.e(TAG, "setTagsFinish: " + mCheckNetPresenter.isRequestSucceeded());
|
||||
giv_2.setImageResource(R.drawable.succeed);
|
||||
giv_2.setBackgroundResource(R.drawable.successful);
|
||||
} else {
|
||||
giv_2.setImageResource(R.drawable.failed);
|
||||
giv_2.setBackgroundResource(R.drawable.failed);
|
||||
}
|
||||
if (noTag) {
|
||||
Log.e(TAG, "setTagsFinished: " + "not set tag");
|
||||
@@ -355,10 +359,11 @@ public class CheckNetActivity extends BaseActivity implements CheckNetContact.Ma
|
||||
public void getDefaultDesktopFinish() {
|
||||
netWorkIsRunning = false;
|
||||
if (mCheckNetPresenter.isRequestSucceeded()) {
|
||||
giv_3.setImageResource(R.drawable.succeed);
|
||||
giv_3.setBackgroundResource(R.drawable.successful);
|
||||
} else {
|
||||
giv_3.setImageResource(R.drawable.failed);
|
||||
giv_3.setBackgroundResource(R.drawable.failed);
|
||||
}
|
||||
mMMKV.encode(CommonConfig.DEVICES_FRIST_START, 0);
|
||||
Log.e(TAG, "SettingFinished: " + (SystemClock.elapsedRealtime() - timeMillis) + " ms");
|
||||
}
|
||||
|
||||
|
||||
@@ -269,7 +269,6 @@ public class CheckNetPresenter implements CheckNetContact.Presenter {
|
||||
mView.getSnTimeControlFinish();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -320,21 +319,22 @@ public class CheckNetPresenter implements CheckNetContact.Presenter {
|
||||
.getLockedState(lifecycle, new NetInterfaceManager.ObserverCallback() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
|
||||
Log.e("getLockedState", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(BaseResponse response) {
|
||||
|
||||
Log.e("getLockedState", "onNext: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.e("getLockedState", "onError: " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e(TAG, "onComplete: ");
|
||||
Log.e("getLockedState", "onComplete: ");
|
||||
int locked = Settings.System.getInt(mContext.getContentResolver(), JGYActions.ACTION_QCH_UNLOCK_IPAD, JGYActions.FRAME_CODE_LOCKED);
|
||||
Log.e(TAG + ":" + "getLockedState", "locked: " + locked);
|
||||
mView.setLockedState(locked == JGYActions.FRAME_CODE_LOCKED);
|
||||
@@ -691,9 +691,9 @@ public class CheckNetPresenter implements CheckNetContact.Presenter {
|
||||
public void onNext(@NonNull BaseResponse baseResponse) {
|
||||
requestSucceeded = true;
|
||||
Log.e(TAG + ":" + "getAppLimit", "onNext: " + baseResponse);
|
||||
JsonObject jsonObject = JsonParser.parseString(baseResponse.data.toString()).getAsJsonObject();
|
||||
int code = baseResponse.code;
|
||||
if (code == OK) {
|
||||
JsonObject jsonObject = JsonParser.parseString(new Gson().toJson(baseResponse.data)).getAsJsonObject();
|
||||
String data = jsonObject.get("result").getAsString();
|
||||
//开机图标
|
||||
boolean write = Settings.System.putString(mContext.getContentResolver(), JGYActions.ACTION_JGY_SHORTCUTLIST, data);
|
||||
@@ -1180,6 +1180,7 @@ public class CheckNetPresenter implements CheckNetContact.Presenter {
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e(TAG + ":" + "getDesktopIcon", "onComplete: ");
|
||||
JGYUtils.getInstance().hideSystemAPP();
|
||||
mView.getDesktopIconFinish();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -19,6 +19,9 @@ public class CommonConfig {
|
||||
|
||||
/*首次启动app*/
|
||||
public final static String FIRST_STARTUP = "app_first_startup";
|
||||
/**设备是否首次启动*/
|
||||
public final static String DEVICES_FRIST_START = "DEVICES_FRIST_START";
|
||||
|
||||
/*保存的应用版本号*/
|
||||
public final static String SN_VERSIONCODE = "SN_VERSIONCODE";
|
||||
/*重启标识*/
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.aoleyun.sn.comm;
|
||||
|
||||
public class JGYActions {
|
||||
|
||||
/*锁定解锁设备 后台1是锁定,底层0是锁定*/
|
||||
public final static String ACTION_QCH_UNLOCK_IPAD = "qch_unlock_ipad";
|
||||
/*后台锁定*/
|
||||
|
||||
@@ -8,7 +8,6 @@ import android.util.Log;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.aoleyun.sn.BuildConfig;
|
||||
import com.aoleyun.sn.bean.AppListInfo;
|
||||
import com.aoleyun.sn.bean.Appground;
|
||||
import com.aoleyun.sn.bean.BaseResponse;
|
||||
import com.aoleyun.sn.bean.BrowserBookmarks;
|
||||
@@ -95,10 +94,8 @@ 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.ObservableSource;
|
||||
import io.reactivex.rxjava3.core.Observer;
|
||||
import io.reactivex.rxjava3.disposables.Disposable;
|
||||
import io.reactivex.rxjava3.functions.Function;
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers;
|
||||
import io.reactivex.rxjava3.subjects.BehaviorSubject;
|
||||
import okhttp3.Cache;
|
||||
@@ -138,7 +135,7 @@ public class NetInterfaceManager {
|
||||
private static long cacheSize = 1024 * 1024 * 64;
|
||||
|
||||
public static final String HTTP_KEY = "YTM3YTAxNTJmMmZmNzkyM2E2YzIwZjlhZTc0NzNmMGI=";
|
||||
public static final String CUSTOM_REPEAT_REQ_PROTOCOL = "MY_CUSTOM_REPEAT_REQ_PROTOCOL";
|
||||
public static final String REPEAT_REQUEST_PROTOCOL = "OKHTTP_REPEAT_REQUEST_PROTOCOL";
|
||||
|
||||
private NetInterfaceManager(Context context) {
|
||||
this.mContext = context;
|
||||
@@ -154,9 +151,10 @@ public class NetInterfaceManager {
|
||||
try {
|
||||
if (requestIdsMap.size() > 0 && requestIdsMap.containsKey(requestKey)) {
|
||||
Log.e("REPEAT-REQUEST", "重复请求:" + requestKey + " Method @" + request.method() + " --- " + " URL = " + request.url());
|
||||
chain.call().cancel();
|
||||
//下面这行写了不会抛出onerror
|
||||
// chain.call().cancel();
|
||||
return new Response.Builder()
|
||||
.protocol(Protocol.get(CUSTOM_REPEAT_REQ_PROTOCOL))
|
||||
.protocol(Protocol.get(REPEAT_REQUEST_PROTOCOL))
|
||||
.request(request) //multi thread
|
||||
.build();
|
||||
}
|
||||
@@ -166,6 +164,7 @@ public class NetInterfaceManager {
|
||||
// builder.addHeader("header", jsonObject.toString());
|
||||
return chain.proceed(request);
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "intercept: " + e.getMessage());
|
||||
throw e;
|
||||
} finally {
|
||||
if (requestIdsMap.containsKey(requestKey) && requestIdsMap.containsValue(time)) {//请求任务完成删除map中的数据
|
||||
@@ -175,6 +174,7 @@ public class NetInterfaceManager {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
//如果无法生存缓存文件目录,检测权限使用已经加上,检测手机是否把文件读写权限禁止了
|
||||
OkHttpClient.Builder builder = new OkHttpClient.Builder();
|
||||
builder.connectTimeout(timeOut, TimeUnit.SECONDS); // 设置连接超时时间
|
||||
@@ -561,6 +561,7 @@ public class NetInterfaceManager {
|
||||
long lastTime = mMMKV.decodeLong(GET_LOCKED_STATE_TIME, 0);
|
||||
if (System.currentTimeMillis() - TEN_MINUTE_TIME < lastTime) {
|
||||
callback.onComplete();
|
||||
Log.e(TAG, "getLockedState: " + "return");
|
||||
return;
|
||||
}
|
||||
NetInterfaceManager.getInstance()
|
||||
|
||||
@@ -81,10 +81,10 @@ public class BootReceiver extends BroadcastReceiver {
|
||||
SPUtils.put(context, CommonConfig.FIRST_STARTUP, 1);
|
||||
} else {
|
||||
LogDBManager.getInstance().creatRebootLog("设备重启", TimeUtils.transferLongToDate(System.currentTimeMillis()));
|
||||
Intent checkNetintent = new Intent(context, CheckNetActivity.class);
|
||||
checkNetintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(checkNetintent);
|
||||
}
|
||||
Intent intent1 = new Intent(context, CheckNetActivity.class);
|
||||
intent1.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(intent1);
|
||||
JGYUtils.startServices(context);
|
||||
new BootManager(context).start();
|
||||
break;
|
||||
|
||||
@@ -36,7 +36,10 @@ import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.aoleyun.sn.BuildConfig;
|
||||
import com.aoleyun.sn.R;
|
||||
import com.aoleyun.sn.activity.SplashActivity;
|
||||
import com.aoleyun.sn.activity.checknet.CheckNetActivity;
|
||||
import com.aoleyun.sn.activity.main.MainAPresenter;
|
||||
import com.aoleyun.sn.bean.BaseResponse;
|
||||
import com.aoleyun.sn.bean.PoweroffBean;
|
||||
import com.aoleyun.sn.comm.CommonConfig;
|
||||
import com.aoleyun.sn.comm.JGYActions;
|
||||
@@ -57,6 +60,9 @@ import com.aoleyun.sn.utils.Utils;
|
||||
import com.blankj.utilcode.util.NetworkUtils;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.tencent.android.tpush.XGIOperateCallback;
|
||||
import com.tencent.android.tpush.XGPushConfig;
|
||||
import com.tencent.android.tpush.XGPushManager;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.trello.rxlifecycle4.LifecycleProvider;
|
||||
import com.trello.rxlifecycle4.LifecycleTransformer;
|
||||
@@ -66,6 +72,7 @@ import com.trello.rxlifecycle4.android.RxLifecycleAndroid;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
@@ -99,6 +106,11 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
||||
String WiFiAlias = Utils.getWifiAlias(this);
|
||||
Log.e("OnNetworkStatusChanged", "onConnected: " + WiFiAlias);
|
||||
Utils.getPublicIP(this);
|
||||
if (mMMKV.decodeInt(CommonConfig.DEVICES_FRIST_START, 1) == 1) {
|
||||
Intent intent = new Intent(this, CheckNetActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
startActivity(intent);
|
||||
}
|
||||
if (ConnectManager.getInstance().isWiFiFistConnect()) {
|
||||
start.onstar(ConnectManager.WIFI_LAST_CONNECT_TIME);
|
||||
} else {
|
||||
@@ -124,10 +136,64 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
||||
super.onPostExecute(aLong);
|
||||
AlarmManager am = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
|
||||
am.setTime(aLong);
|
||||
tPushInit();
|
||||
NetInterfaceManager.getInstance().setPushTags(lifecycleSubject, new NetInterfaceManager.ObserverCallback() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
Log.e("TimeTask", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(BaseResponse response) {
|
||||
Log.e("TimeTask", "onNext: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.e("TimeTask", "onError: " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("TimeTask", "onComplete: ");
|
||||
}
|
||||
});
|
||||
Log.e(TAG, "getTimeFromNtpServer: " + aLong);
|
||||
}
|
||||
}
|
||||
|
||||
private void tPushInit() {
|
||||
XGPushConfig.enableDebug(this, true);
|
||||
XGPushManager.registerPush(this, new XGIOperateCallback() {
|
||||
@Override
|
||||
public void onSuccess(Object data, int flag) {
|
||||
//token在设备卸载重装的时候有可能会变
|
||||
Log.e("TPush", "注册成功,设备token为:" + data);
|
||||
List<XGPushManager.AccountInfo> accountInfoList = new ArrayList<>();
|
||||
accountInfoList.add(new XGPushManager.AccountInfo(XGPushManager.AccountType.CUSTOM.getValue(), Utils.getSerial()));
|
||||
XGPushManager.upsertAccounts(MainService.this, accountInfoList, new XGIOperateCallback() {
|
||||
@Override
|
||||
public void onSuccess(Object data, int flag) {
|
||||
Log.e("TPush", "onSuccess, data:" + data + ", flag:" + flag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail(Object data, int errCode, String msg) {
|
||||
Log.e("TPush", "onFail, data:" + data + ", code:" + errCode + ", msg:" + msg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail(Object data, int errCode, String msg) {
|
||||
Log.e("TPush", "注册失败,错误码:" + errCode + ",错误信息:" + msg);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private final BehaviorSubject<ActivityEvent> lifecycleSubject = BehaviorSubject.create();
|
||||
|
||||
@Override
|
||||
@@ -265,8 +331,14 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
Log.e(TAG, "onCreate: ");
|
||||
lifecycleSubject.onNext(ActivityEvent.CREATE);
|
||||
mPresenter = new MainSPresenter(this);
|
||||
mPresenter.attachView(this);
|
||||
mPresenter.setLifecycle(lifecycleSubject);
|
||||
|
||||
TimeTask task = new TimeTask();
|
||||
task.execute("ntp.aliyun.com");
|
||||
|
||||
ApkUtils.UninstallAPP(this, "com.joytv.live");
|
||||
ApkUtils.UninstallAPP(this, "com.tencent.android.qqdownloader");
|
||||
|
||||
@@ -276,11 +348,6 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
||||
Log.e(TAG, "onCreate: " + e.getMessage());
|
||||
}
|
||||
|
||||
lifecycleSubject.onNext(ActivityEvent.CREATE);
|
||||
mPresenter = new MainSPresenter(this);
|
||||
mPresenter.attachView(this);
|
||||
mPresenter.setLifecycle(lifecycleSubject);
|
||||
|
||||
Observable.create(subscribe)
|
||||
.throttleFirst(1, TimeUnit.MINUTES)
|
||||
.subscribe(timeObserver);
|
||||
|
||||
@@ -696,14 +696,14 @@ public class ApkUtils {
|
||||
this.add("com.android.calendar");
|
||||
this.add("com.android.dreams.basic");
|
||||
this.add("com.android.musicfx");
|
||||
// this.add("com.android.email");
|
||||
this.add("com.android.email");
|
||||
this.add("com.jiaoguanyi.sysc");
|
||||
}};
|
||||
|
||||
//需要管控的系统可以卸载的应用
|
||||
public static List<String> show_canremove_systemapp = new ArrayList<String>() {{
|
||||
this.add("com.android.calendar");
|
||||
this.add("com.android.email");
|
||||
// this.add("com.android.email");
|
||||
}};
|
||||
|
||||
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 937 B |
Binary file not shown.
|
Before Width: | Height: | Size: 1.9 KiB |
BIN
app/src/main/res/drawable-hdpi/successful.png
Normal file
BIN
app/src/main/res/drawable-hdpi/successful.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 911 B |
Reference in New Issue
Block a user