version:1.9
fix: update:增加安装完成后删除文件,修复设备信息上传失败
This commit is contained in:
@@ -73,8 +73,8 @@ android {
|
||||
|
||||
official {
|
||||
flavorDimensions "default"
|
||||
versionCode 9
|
||||
versionName "1.8"
|
||||
versionCode 10
|
||||
versionName "1.9"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.fuying.sn.base;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.media.AudioManager;
|
||||
import android.os.Environment;
|
||||
import android.os.Handler;
|
||||
@@ -9,6 +10,12 @@ import android.os.Looper;
|
||||
import android.util.Log;
|
||||
|
||||
import com.arialyy.aria.core.Aria;
|
||||
import com.fuying.sn.service.ControlPanelService;
|
||||
import com.fuying.sn.service.DownloadService;
|
||||
import com.fuying.sn.service.GuardService;
|
||||
import com.fuying.sn.service.ManagerService;
|
||||
import com.fuying.sn.service.StepService;
|
||||
import com.fuying.sn.service.main.MainService;
|
||||
import com.tencent.android.tpush.XGIOperateCallback;
|
||||
import com.tencent.android.tpush.XGPushConfig;
|
||||
import com.tencent.android.tpush.XGPushManager;
|
||||
@@ -79,6 +86,16 @@ public class BaseApplication extends Application {
|
||||
NetInterfaceManager.init(this);
|
||||
AppUsedTimeUtils.init(this);
|
||||
JGYUtils.hookWebView();
|
||||
startService();
|
||||
}
|
||||
|
||||
private void startService() {
|
||||
startService(new Intent(this, MainService.class));
|
||||
startService(new Intent(this, GuardService.class));
|
||||
startService(new Intent(this, StepService.class));
|
||||
startService(new Intent(this, DownloadService.class));
|
||||
startService(new Intent(this, ManagerService.class));
|
||||
startService(new Intent(this, ControlPanelService.class));
|
||||
}
|
||||
|
||||
private void catchException() {
|
||||
|
||||
@@ -879,6 +879,9 @@ public class NetInterfaceManager {
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse baseResponse) {
|
||||
Log.e("SendAppInstallInfo", "onNext: " + baseResponse);
|
||||
if (baseResponse.code != 200) {
|
||||
mCacheHelper.put(UrlAddress.SEND_INSTALLEDORREMOVED, "");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -51,6 +51,7 @@ public class APKinstallReceiver extends BroadcastReceiver {
|
||||
switch (action) {
|
||||
case Intent.ACTION_PACKAGE_ADDED:
|
||||
state = "安装了:";
|
||||
JGYUtils.RemoveTask(context, packageName);
|
||||
break;
|
||||
case Intent.ACTION_PACKAGE_REPLACED:
|
||||
cleanLauncher3Cache();
|
||||
|
||||
@@ -141,7 +141,7 @@ public class DownloadService extends Service {
|
||||
//在这里处理任务完成的状态
|
||||
ApkUtils.installApp(DownloadService.this, task.getFilePath());
|
||||
Log.e("taskComplete", task.getExtendField());
|
||||
Aria.download(this).load(task.getDownloadEntity().getId()).cancel();
|
||||
// Aria.download(this).load(task.getDownloadEntity().getId()).cancel();
|
||||
}
|
||||
|
||||
@Download.onTaskFail
|
||||
|
||||
@@ -14,6 +14,7 @@ import android.net.wifi.WifiInfo;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Binder;
|
||||
import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
import android.os.SystemClock;
|
||||
import android.provider.Settings;
|
||||
@@ -34,6 +35,7 @@ import com.fuying.sn.service.GuardService;
|
||||
import com.fuying.sn.service.StepService;
|
||||
import com.fuying.sn.utils.ApkUtils;
|
||||
import com.fuying.sn.utils.CacheUtils;
|
||||
import com.fuying.sn.utils.JGYUtils;
|
||||
import com.fuying.sn.utils.SPUtils;
|
||||
import com.fuying.sn.utils.TimeUtils;
|
||||
import com.fuying.sn.utils.ToastUtil;
|
||||
@@ -50,6 +52,7 @@ import com.trello.rxlifecycle4.android.RxLifecycleAndroid;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -121,7 +124,7 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
||||
mPresenter.getAllApp();
|
||||
SPUtils.put(this, CommonConfig.JGY_FIRST_BOOT, 1);
|
||||
}
|
||||
NetInterfaceManager.getInstance().updateAdminInfo();
|
||||
sendDeviceInfo();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -140,6 +143,8 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
NetworkUtils.registerNetworkStatusChangedListener(this);
|
||||
|
||||
lifecycleSubject.onNext(ActivityEvent.CREATE);
|
||||
mPresenter = new MainSPresenter(this);
|
||||
mPresenter.setLifecycle(lifecycleSubject);
|
||||
@@ -155,7 +160,6 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
||||
ApkUtils.writeAppPackageList(MainService.this, "");
|
||||
}
|
||||
mPresenter.getAllApp();
|
||||
NetInterfaceManager.getInstance().updateAdminInfo();
|
||||
|
||||
ApkUtils.UninstallAPP(this, "com.joytv.live");
|
||||
ApkUtils.UninstallAPP(this, "com.tencent.android.qqdownloader");
|
||||
@@ -175,9 +179,8 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
||||
}
|
||||
versionIsUpdate();
|
||||
registerReceivers();
|
||||
NetworkUtils.registerNetworkStatusChangedListener(this);
|
||||
// ControlManager.getInstance().setDefaultUSBstate();
|
||||
NetInterfaceManager.getInstance().SendAppInstallInfo();
|
||||
sendDeviceInfo();
|
||||
}
|
||||
|
||||
private void versionIsUpdate() {
|
||||
@@ -186,6 +189,14 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
||||
Log.e(TAG, "onCreate: " + "upgrade successful");
|
||||
try {
|
||||
new CacheUtils().cleanApplicationUserData(this, "com.aoleyun.os");
|
||||
File file = new File(JGYUtils.getInstance().getDownLoadPath());
|
||||
Log.e(TAG, "versionIsUpdate: " + file.getAbsolutePath());
|
||||
String[] fileList = file.list();
|
||||
if (fileList != null) {
|
||||
for (String path : fileList) {
|
||||
Log.e(TAG, "versionIsUpdate: delete file " + path + " = " + new File(file.getAbsolutePath() + File.separator + path).delete());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "onReceive: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
@@ -202,6 +213,17 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
||||
SPUtils.put(this, CommonConfig.SN_VERSIONCODE, BuildConfig.VERSION_CODE);
|
||||
}
|
||||
|
||||
private void sendDeviceInfo() {
|
||||
Handler.getMain().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
NetInterfaceManager.getInstance().SendAppInstallInfo();
|
||||
NetInterfaceManager.getInstance().updateAdminInfo();
|
||||
}
|
||||
},10000);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
Log.e(TAG, "onStartCommand: " + System.currentTimeMillis());
|
||||
@@ -434,10 +456,11 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
||||
NTPTimeTask task = new NTPTimeTask();
|
||||
task.execute("ntp.aliyun.com");
|
||||
NetInterfaceManager.getInstance().getAppWhiteList(() -> {
|
||||
Log.e("TimeObserver", "onNext: getAppWhiteList" );
|
||||
Log.e("TimeObserver", "onNext: getAppWhiteList");
|
||||
});
|
||||
mPresenter.getSnInfo();
|
||||
NetInterfaceManager.getInstance().SendAppInstallInfo();
|
||||
NetInterfaceManager.getInstance().updateAdminInfo();
|
||||
startService();
|
||||
}
|
||||
|
||||
|
||||
@@ -40,13 +40,16 @@ import android.view.inputmethod.InputMethodManager;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.android.internal.view.RotationPolicy;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.arialyy.aria.core.Aria;
|
||||
import com.arialyy.aria.core.download.DownloadEntity;
|
||||
import com.fuying.sn.BuildConfig;
|
||||
import com.fuying.sn.R;
|
||||
import com.fuying.sn.config.CommonConfig;
|
||||
import com.fuying.sn.gson.GsonUtils;
|
||||
import com.fuying.sn.network.NetInterfaceManager;
|
||||
import com.fuying.sn.receiver.BootReceiver;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Constructor;
|
||||
@@ -65,6 +68,14 @@ import java.util.function.Consumer;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
||||
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;
|
||||
|
||||
import static android.app.ActivityManager.RECENT_IGNORE_UNAVAILABLE;
|
||||
|
||||
|
||||
@@ -1295,4 +1306,54 @@ public class JGYUtils {
|
||||
NetInterfaceManager.getInstance().getAllappPackage();
|
||||
}
|
||||
|
||||
public static void RemoveTask(final Context context, final String packageName) {
|
||||
if (TextUtils.isEmpty(packageName)) {
|
||||
return;
|
||||
}
|
||||
Observable.create(new ObservableOnSubscribe<String>() {
|
||||
@Override
|
||||
public void subscribe(ObservableEmitter<String> e) throws Exception {
|
||||
Log.e("RemoveTask", "subscribe: " + packageName);
|
||||
List<DownloadEntity> list = Aria.download(context).getTaskList();
|
||||
for (DownloadEntity entity : list) {
|
||||
long id = entity.getId();
|
||||
String extendField = Aria.download(this).load(id).getExtendField();
|
||||
try {
|
||||
JsonObject jsonObject = JsonParser.parseString(extendField).getAsJsonObject();
|
||||
if (packageName.equals(jsonObject.get("app_package").getAsString())) {
|
||||
Log.e("RemoveTask", "subscribe: " + "删除文件:" + entity.getFilePath());
|
||||
Aria.download(this).load(id).cancel(true);
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
Log.e("RemoveTask", "subscribe: " + exception.getMessage());
|
||||
}
|
||||
}
|
||||
e.onComplete();
|
||||
}
|
||||
}).subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<String>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
Log.e("RemoveTask", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(String s) {
|
||||
Log.e("RemoveTask", "onNext: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.e("RemoveTask", "onError: " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("RemoveTask", "onComplete: ");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user