fix: 修复应用安装,升级之后无法获取配置,增加MainService获取应用时间配置
This commit is contained in:
@@ -269,12 +269,12 @@
|
||||
<!-- 请填写你自己的- appKey -->
|
||||
<meta-data
|
||||
android:name="com.alibaba.app.appkey"
|
||||
android:value="335685739" />
|
||||
android:value="${ALIYUN_PUSH_KEY}" />
|
||||
|
||||
<!-- 请填写你自己的appSecret -->
|
||||
<meta-data
|
||||
android:name="com.alibaba.app.appsecret"
|
||||
android:value="713e04b35a6249fc979e3d1f74ad59fd" />
|
||||
android:value="${ALIYUN_PUSH_SECRET}" />
|
||||
|
||||
</application>
|
||||
</manifest>
|
||||
@@ -292,7 +292,7 @@ public class TimeManager {
|
||||
AppTimeControlInfo appInfo = mAppTimeControlMap.get(pkg);
|
||||
if (appInfo == null) {
|
||||
Log.w(TAG, "appCanRun: Application [" + pkg + "] is not in the controlled list. Blocking by default.");
|
||||
Toaster.show("应用已被禁用");
|
||||
Toaster.show("获取应用设置失败");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -543,6 +543,7 @@ public class TimeManager {
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<List<AppTimeControlInfo>> response) {
|
||||
Log.e(TAG, "getAppTimeControlInfo onNext: " + response);
|
||||
if (response.code == 200 && response.data != null) {
|
||||
List<AppTimeControlInfo> list = response.data;
|
||||
mAppTimeControlMap = list.stream().collect(Collectors.toMap(AppTimeControlInfo::getApp_package, Function.identity(), (v1, v2) -> v1));
|
||||
@@ -604,4 +605,22 @@ public class TimeManager {
|
||||
public void setGetSnTimeControlInfoSuccessful(boolean successful) {
|
||||
this.mGetSnTimeControlInfoSuccessful = successful;
|
||||
}
|
||||
|
||||
public Map<String, AppTimeControlInfo> getAppTimeControlMap() {
|
||||
return mAppTimeControlMap;
|
||||
}
|
||||
|
||||
public void setAppTimeControlMap(Map<String, AppTimeControlInfo> appTimeControlMap) {
|
||||
mAppTimeControlMap = appTimeControlMap;
|
||||
}
|
||||
|
||||
public Map<String, Long> getRemainingTimeMap() {
|
||||
return mRemainingTimeMap;
|
||||
}
|
||||
|
||||
public void setRemainingTimeMap(Map<String, Long> remainingTimeMap) {
|
||||
mRemainingTimeMap = remainingTimeMap;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ public class NetInterfaceManager {
|
||||
private CacheHelper mCacheHelper;
|
||||
|
||||
//超时时间
|
||||
private static final int timeOut = 5;
|
||||
private static final int timeOut = 15;
|
||||
// 缓存文件最大限制大小20M
|
||||
private static final long cacheSize = 1024 * 1024 * 64;
|
||||
|
||||
@@ -391,6 +391,7 @@ public class NetInterfaceManager {
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Observable<BaseResponse<MachineControl>> getMachineTimeControlObservable() {
|
||||
return getSettingsApi()
|
||||
.getSnTimeControl(Utils.getSerial())
|
||||
@@ -2487,17 +2488,20 @@ public class NetInterfaceManager {
|
||||
return mCacheHelper.getAsString(UrlAddress.GET_SN_TIME_CONTROL);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void getMachineTimeControl(BehaviorSubject<ActivityEvent> lifecycle, CompleteCallback callback) {
|
||||
getMachineTimeControlObservable()
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
||||
.subscribe(getMachineTimeControlObserver(callback));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void getMachineTimeControl(CompleteCallback callback) {
|
||||
getMachineTimeControlObservable()
|
||||
.subscribe(getMachineTimeControlObserver(callback));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void getMachineTimeControl() {
|
||||
getMachineTimeControlObservable()
|
||||
.subscribe(getMachineTimeControlObserver(null));
|
||||
@@ -3350,18 +3354,77 @@ public class NetInterfaceManager {
|
||||
TimeManager.getInstance().setSnTimeControlInfo(null);
|
||||
}
|
||||
TimeManager.getInstance().setGetSnTimeControlInfoSuccessful(true);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("getSnTimeControl", "onError: ");
|
||||
onComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getSnTimeControlObserver", "onComplete: ");
|
||||
if (callback != null) {
|
||||
callback.onComplete();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public void getAppTimeControlInfo(BehaviorSubject<ActivityEvent> lifecycle, CompleteCallback callback) {
|
||||
getAppTimeControlInfoObservable()
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
||||
.subscribe(getAppTimeControlInfoObserver(callback));
|
||||
}
|
||||
|
||||
public void getAppTimeControlInfo(CompleteCallback callback) {
|
||||
getAppTimeControlInfoObservable()
|
||||
.subscribe(getAppTimeControlInfoObserver(callback));
|
||||
}
|
||||
|
||||
public void getAppTimeControlInfo() {
|
||||
getAppTimeControlInfoObservable()
|
||||
.subscribe(getAppTimeControlInfoObserver(null));
|
||||
}
|
||||
|
||||
private Observer<BaseResponse<List<AppTimeControlInfo>>> getAppTimeControlInfoObserver(CompleteCallback callback) {
|
||||
return new Observer<BaseResponse<List<AppTimeControlInfo>>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("getAppTimeControlInfo", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<List<AppTimeControlInfo>> response) {
|
||||
Log.e("getAppTimeControlInfo", "onNext: " + response);
|
||||
if (response.code == 200) {
|
||||
List<AppTimeControlInfo> list = response.data;
|
||||
Map<String, AppTimeControlInfo> appTimeControlMap = list.stream().collect(Collectors.toMap(AppTimeControlInfo::getApp_package, java.util.function.Function.identity(), (v1, v2) -> v1));
|
||||
Map<String, Long> remainingTimeMap = list.stream().collect(Collectors.toMap(AppTimeControlInfo::getApp_package, AppTimeControlInfo::getToday_time, (v1, v2) -> v1));
|
||||
TimeManager.getInstance().setAppTimeControlMap(appTimeControlMap);
|
||||
TimeManager.getInstance().setRemainingTimeMap(remainingTimeMap);
|
||||
}else if (response.code == 400) {
|
||||
Log.e("getSnTimeControl", "onNext: Too frequent");
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("getAppTimeControlInfo", "onError: ");
|
||||
onComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getAppTimeControlInfo", "onComplete: ");
|
||||
if (callback != null) {
|
||||
callback.onComplete();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import android.util.Log;
|
||||
|
||||
import com.fuying.sn.config.CommonConfig;
|
||||
import com.fuying.sn.manager.ControlManager;
|
||||
import com.fuying.sn.manager.time.TimeManager;
|
||||
import com.fuying.sn.network.NetInterfaceManager;
|
||||
import com.fuying.sn.utils.CacheUtils;
|
||||
import com.fuying.sn.utils.JgyUtils;
|
||||
@@ -107,6 +108,7 @@ public class APKinstallReceiver extends BroadcastReceiver {
|
||||
}
|
||||
NetInterfaceManager.getInstance().SendAppInstallInfo();
|
||||
// NetInterfaceManager.getInstance().getAppAndWhite();
|
||||
TimeManager.getInstance().getTimeControl();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -208,10 +208,10 @@ public class ManagerService extends Service implements NetworkUtils.OnNetworkSta
|
||||
public static final String LOCK_STATE = "SCRENN_LOOCKED_STATE";
|
||||
|
||||
private void showFloatingWindow(String name) {
|
||||
if (BuildConfig.DEBUG) {
|
||||
Log.e(TAG, "showFloatingWindow: debug mode skip");
|
||||
return;
|
||||
}
|
||||
// if (BuildConfig.DEBUG) {
|
||||
// Log.e(TAG, "showFloatingWindow: debug mode skip");
|
||||
// return;
|
||||
// }
|
||||
if (Settings.canDrawOverlays(this)) {
|
||||
// 获取WindowManager服务
|
||||
if (null == windowManager) {
|
||||
|
||||
@@ -326,6 +326,13 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
mView.setAppTimeControl();
|
||||
}
|
||||
});
|
||||
NetInterfaceManager.getInstance().getAppTimeControlInfo(getLifecycle(), new NetInterfaceManager.CompleteCallback() {
|
||||
@Override
|
||||
public void onComplete() {
|
||||
mView.setAppTimeControl();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -336,6 +343,12 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
mView.setSnTimeControl();
|
||||
}
|
||||
});
|
||||
NetInterfaceManager.getInstance().getSnTimeControl(getLifecycle(), new NetInterfaceManager.CompleteCallback() {
|
||||
@Override
|
||||
public void onComplete() {
|
||||
mView.setSnTimeControl();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -28,6 +28,7 @@ import com.fuying.sn.config.CommonConfig;
|
||||
import com.fuying.sn.desktop.RunningAppManager;
|
||||
import com.fuying.sn.manager.AmapManager;
|
||||
import com.fuying.sn.manager.ControlManager;
|
||||
import com.fuying.sn.manager.time.TimeManager;
|
||||
import com.fuying.sn.network.NetInterfaceManager;
|
||||
import com.fuying.sn.network.UrlAddress;
|
||||
import com.fuying.sn.rlog.LogDBManager;
|
||||
@@ -96,6 +97,7 @@ public class MainService extends BaseRxService implements MainSContact.MainView,
|
||||
NetInterfaceManager.getInstance().getAppWhiteList(() -> {
|
||||
Log.e("onConnected", "onNext: getAppWhiteList");
|
||||
});
|
||||
TimeManager.getInstance().getTimeControl();
|
||||
mPresenter.getSnInfo();
|
||||
mPresenter.getAppAndWhite();
|
||||
NetInterfaceManager.getInstance().updateAdminInfo();
|
||||
|
||||
Reference in New Issue
Block a user