feat: 优化管控
This commit is contained in:
@@ -15,7 +15,7 @@ android {
|
||||
buildToolsVersion "29.0.3"
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 24
|
||||
minSdkVersion 26
|
||||
targetSdkVersion 29
|
||||
|
||||
multiDexEnabled true
|
||||
@@ -63,8 +63,8 @@ android {
|
||||
|
||||
official {
|
||||
flavorDimensions "default"
|
||||
versionCode 88
|
||||
versionName "3.4.8"
|
||||
versionCode 89
|
||||
versionName "3.4.9"
|
||||
applicationId "com.fuying.sn"
|
||||
|
||||
buildConfigField "String", "ROOT_URL", '"https://as.fuyingy.com/android/"'
|
||||
@@ -570,6 +570,22 @@ project.afterEvaluate {
|
||||
}
|
||||
}
|
||||
|
||||
tasks.register('deleteAppSourceWhiteList', Exec) {
|
||||
// Windows 系统使用 cmd /c, Mac/Linux 使用 sh -c
|
||||
if (System.properties['os.name'].toLowerCase().contains('windows')) {
|
||||
commandLine 'cmd', '/c', 'adb', 'shell', 'settings', 'delete', 'system', 'app_source_white_list'
|
||||
} else {
|
||||
commandLine 'adb', 'shell', 'settings', 'delete', 'system', 'app_source_white_list'
|
||||
}
|
||||
|
||||
// 即使命令执行失败也不中断构建(可选,防止因为没连手机导致编译失败)
|
||||
ignoreExitValue = true
|
||||
|
||||
doLast {
|
||||
println "ADB command executed: settings delete system app_source_white_list"
|
||||
}
|
||||
}
|
||||
|
||||
//preBuild {
|
||||
// doLast {
|
||||
// def imlFile = file(project.name + ".iml")
|
||||
|
||||
@@ -214,7 +214,7 @@
|
||||
|
||||
<provider
|
||||
android:name="androidx.core.content.FileProvider"
|
||||
android:authorities="com.fuying.sn.fileprovider"
|
||||
android:authorities="${applicationId}.fileprovider"
|
||||
android:exported="false"
|
||||
android:grantUriPermissions="true">
|
||||
<meta-data
|
||||
|
||||
@@ -449,13 +449,30 @@ public class RunningAppManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* 如果界面正在最近任务列表,有些app可能不会被清理
|
||||
* 强行返回主桌面,优化跳转逻辑以确保回到系统默认桌面。
|
||||
*/
|
||||
private void gotoLauncher() {
|
||||
Intent i = new Intent(Intent.ACTION_MAIN);
|
||||
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); //android123提示如果是服务里调用,必须加入new task标识
|
||||
i.addCategory(Intent.CATEGORY_HOME);
|
||||
mContext.startActivity(i);
|
||||
Intent intent = new Intent(Intent.ACTION_MAIN);
|
||||
intent.addCategory(Intent.CATEGORY_HOME);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
|
||||
|
||||
// 优先定位到当前的默认桌面应用,避免在存在多个桌面时弹出系统选择框
|
||||
PackageManager pm = mContext.getPackageManager();
|
||||
ResolveInfo resolveInfo = pm.resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY);
|
||||
if (resolveInfo != null && resolveInfo.activityInfo != null && !resolveInfo.activityInfo.packageName.equals("android")) {
|
||||
intent.setComponent(new ComponentName(resolveInfo.activityInfo.packageName, resolveInfo.activityInfo.name));
|
||||
}
|
||||
|
||||
try {
|
||||
mContext.startActivity(intent);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "gotoLauncher failed: " + e.getMessage());
|
||||
// 如果精准跳转失败,则使用基础的 Home Intent
|
||||
Intent fallback = new Intent(Intent.ACTION_MAIN);
|
||||
fallback.addCategory(Intent.CATEGORY_HOME);
|
||||
fallback.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
mContext.startActivity(fallback);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -813,54 +813,54 @@ public class NetInterfaceManager {
|
||||
*/
|
||||
public void SendAppInstallInfo() {
|
||||
Observable.create(new ObservableOnSubscribe<String>() {
|
||||
@Override
|
||||
public void subscribe(@NonNull ObservableEmitter<String> emitter) throws Throwable {
|
||||
PackageManager pm = mContext.getPackageManager();
|
||||
List<PackageInfo> list = pm.getInstalledPackages(0);
|
||||
List<AppUploadInfo> uploadInfos = new ArrayList<>();
|
||||
Intent intent = new Intent(Intent.ACTION_MAIN);
|
||||
intent.addCategory(Intent.CATEGORY_LAUNCHER);
|
||||
List<ResolveInfo> appsWithLauncher = pm.queryIntentActivities(intent, 0);
|
||||
List<String> pkgs = new ArrayList<>();
|
||||
for (ResolveInfo info : appsWithLauncher) {
|
||||
pkgs.add(info.activityInfo.packageName);
|
||||
}
|
||||
Log.e("SendAppInstallInfo", "pkgs: " + pkgs);
|
||||
Set<String> showPkg = getShowPackages();
|
||||
Log.e("SendAppInstallInfo", "showPkg: " + showPkg);
|
||||
for (PackageInfo info : list) {
|
||||
//排除掉部分系统应用
|
||||
if (ApkUtils.isSystemApp(mContext, info.packageName)) {
|
||||
if (!showPkg.contains(info.packageName)) {
|
||||
continue;
|
||||
@Override
|
||||
public void subscribe(@NonNull ObservableEmitter<String> emitter) throws Throwable {
|
||||
PackageManager pm = mContext.getPackageManager();
|
||||
List<PackageInfo> list = pm.getInstalledPackages(0);
|
||||
List<AppUploadInfo> uploadInfos = new ArrayList<>();
|
||||
Intent intent = new Intent(Intent.ACTION_MAIN);
|
||||
intent.addCategory(Intent.CATEGORY_LAUNCHER);
|
||||
List<ResolveInfo> appsWithLauncher = pm.queryIntentActivities(intent, 0);
|
||||
List<String> pkgs = new ArrayList<>();
|
||||
for (ResolveInfo info : appsWithLauncher) {
|
||||
pkgs.add(info.activityInfo.packageName);
|
||||
}
|
||||
} else {
|
||||
if (!showPkg.contains(info.packageName)) {
|
||||
//排除掉没有图标的应用
|
||||
if (!pkgs.contains(info.packageName)) {
|
||||
continue;
|
||||
Log.e("SendAppInstallInfo", "pkgs: " + pkgs);
|
||||
Set<String> showPkg = getShowPackages();
|
||||
Log.e("SendAppInstallInfo", "showPkg: " + showPkg);
|
||||
for (PackageInfo info : list) {
|
||||
//排除掉部分系统应用
|
||||
if (ApkUtils.isSystemApp(mContext, info.packageName)) {
|
||||
if (!showPkg.contains(info.packageName)) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
if (!showPkg.contains(info.packageName)) {
|
||||
//排除掉没有图标的应用
|
||||
if (!pkgs.contains(info.packageName)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
AppUploadInfo uploadInfo = new AppUploadInfo();
|
||||
uploadInfo.setApp_name(info.applicationInfo.loadLabel(pm).toString());
|
||||
uploadInfo.setApp_package(info.packageName);
|
||||
uploadInfo.setApp_version_name(info.versionName);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||
uploadInfo.setApp_version_code(info.getLongVersionCode());
|
||||
} else {
|
||||
uploadInfo.setApp_version_code(info.versionCode);
|
||||
}
|
||||
uploadInfo.setFirstInstallTime(info.firstInstallTime / 1000);
|
||||
uploadInfo.setLastUpdateTime(info.lastUpdateTime / 1000);
|
||||
uploadInfo.setApp_size(getPackageSize(mContext, info.applicationInfo.publicSourceDir));
|
||||
uploadInfos.add(uploadInfo);
|
||||
}
|
||||
String json = GsonUtils.toJSONString(uploadInfos);
|
||||
Log.e("SendAppInstallInfo", "subscribe: json = " + json);
|
||||
emitter.onNext(json);
|
||||
}
|
||||
AppUploadInfo uploadInfo = new AppUploadInfo();
|
||||
uploadInfo.setApp_name(info.applicationInfo.loadLabel(pm).toString());
|
||||
uploadInfo.setApp_package(info.packageName);
|
||||
uploadInfo.setApp_version_name(info.versionName);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||
uploadInfo.setApp_version_code(info.getLongVersionCode());
|
||||
} else {
|
||||
uploadInfo.setApp_version_code(info.versionCode);
|
||||
}
|
||||
uploadInfo.setFirstInstallTime(info.firstInstallTime / 1000);
|
||||
uploadInfo.setLastUpdateTime(info.lastUpdateTime / 1000);
|
||||
uploadInfo.setApp_size(getPackageSize(mContext, info.applicationInfo.publicSourceDir));
|
||||
uploadInfos.add(uploadInfo);
|
||||
}
|
||||
String json = GsonUtils.toJSONString(uploadInfos);
|
||||
Log.e("SendAppInstallInfo", "subscribe: json = " + json);
|
||||
emitter.onNext(json);
|
||||
}
|
||||
})
|
||||
})
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.concatMap(new Function<String, ObservableSource<BaseResponse>>() {
|
||||
@@ -909,20 +909,20 @@ public class NetInterfaceManager {
|
||||
|
||||
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;
|
||||
}
|
||||
})
|
||||
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>>() {
|
||||
@@ -1017,19 +1017,19 @@ public class NetInterfaceManager {
|
||||
|
||||
public void checkAllAppUpdate(BehaviorSubject<ActivityEvent> lifecycle, CompleteCallback callback) {
|
||||
Observable.zip(
|
||||
getUpdateObservable(BuildConfig.APPLICATION_ID),
|
||||
getUpdateObservable(JgyUtils.PACKAGE_APPSTORE),
|
||||
getUpdateObservable(BuildConfig.APPLICATION_ID),
|
||||
getUpdateObservable(JgyUtils.PACKAGE_APPSTORE),
|
||||
// getUpdateObservable(JGYUtils.PACKAGE_OS),
|
||||
// getUpdateObservable(JGYUtils.PACKAGE_BROWSER),
|
||||
// getUpdateObservable(JGYUtils.Notifications),
|
||||
(appInfoBaseResponse, appInfoBaseResponse2) -> {
|
||||
List<AppInfo> appInfoList = new ArrayList<>();
|
||||
if (appInfoBaseResponse.code == 200) {
|
||||
appInfoList.add(appInfoBaseResponse.data);
|
||||
}
|
||||
if (appInfoBaseResponse2.code == 200) {
|
||||
appInfoList.add(appInfoBaseResponse2.data);
|
||||
}
|
||||
(appInfoBaseResponse, appInfoBaseResponse2) -> {
|
||||
List<AppInfo> appInfoList = new ArrayList<>();
|
||||
if (appInfoBaseResponse.code == 200) {
|
||||
appInfoList.add(appInfoBaseResponse.data);
|
||||
}
|
||||
if (appInfoBaseResponse2.code == 200) {
|
||||
appInfoList.add(appInfoBaseResponse2.data);
|
||||
}
|
||||
// if (appInfoBaseResponse3.code == 200) {
|
||||
// appInfoList.add(appInfoBaseResponse3.data);
|
||||
// }
|
||||
@@ -1039,8 +1039,8 @@ public class NetInterfaceManager {
|
||||
// if (appInfoBaseResponse5.code == 200) {
|
||||
// appInfoList.add(appInfoBaseResponse5.data);
|
||||
// }
|
||||
return appInfoList;
|
||||
})
|
||||
return appInfoList;
|
||||
})
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
@@ -1098,46 +1098,46 @@ public class NetInterfaceManager {
|
||||
|
||||
public void checkFXYAppUpdate(BehaviorSubject<ActivityEvent> lifecycle, CompleteCallback callback) {
|
||||
Observable.zip(
|
||||
getUpdateObservable(JgyUtils.gkwxhd),
|
||||
getUpdateObservable(JgyUtils.fuxiaoying),
|
||||
getUpdateObservable(JgyUtils.moshujia),
|
||||
getUpdateObservable(JgyUtils.english),
|
||||
getUpdateObservable(JgyUtils.zhiduoke),
|
||||
getUpdateObservable(JgyUtils.aobama),
|
||||
getUpdateObservable(JgyUtils.growthspace),
|
||||
getUpdateObservable(JgyUtils.pandaabc),
|
||||
getUpdateObservable(JgyUtils.qibenyi),
|
||||
(appInfoBaseResponse, appInfoBaseResponse2, appInfoBaseResponse3, appInfoBaseResponse4, appInfoBaseResponse5, appInfoBaseResponse6, appInfoBaseResponse7, appInfoBaseResponse8, appInfoBaseResponse9) -> {
|
||||
List<AppInfo> appInfoList = new ArrayList<>();
|
||||
if (appInfoBaseResponse.code == 200) {
|
||||
appInfoList.add(appInfoBaseResponse.data);
|
||||
}
|
||||
if (appInfoBaseResponse2.code == 200) {
|
||||
appInfoList.add(appInfoBaseResponse2.data);
|
||||
}
|
||||
if (appInfoBaseResponse3.code == 200) {
|
||||
appInfoList.add(appInfoBaseResponse3.data);
|
||||
}
|
||||
if (appInfoBaseResponse4.code == 200) {
|
||||
appInfoList.add(appInfoBaseResponse4.data);
|
||||
}
|
||||
if (appInfoBaseResponse5.code == 200) {
|
||||
appInfoList.add(appInfoBaseResponse5.data);
|
||||
}
|
||||
if (appInfoBaseResponse6.code == 200) {
|
||||
appInfoList.add(appInfoBaseResponse6.data);
|
||||
}
|
||||
if (appInfoBaseResponse7.code == 200) {
|
||||
appInfoList.add(appInfoBaseResponse7.data);
|
||||
}
|
||||
if (appInfoBaseResponse8.code == 200) {
|
||||
appInfoList.add(appInfoBaseResponse7.data);
|
||||
}
|
||||
if (appInfoBaseResponse9.code == 200) {
|
||||
appInfoList.add(appInfoBaseResponse7.data);
|
||||
}
|
||||
return appInfoList;
|
||||
})
|
||||
getUpdateObservable(JgyUtils.gkwxhd),
|
||||
getUpdateObservable(JgyUtils.fuxiaoying),
|
||||
getUpdateObservable(JgyUtils.moshujia),
|
||||
getUpdateObservable(JgyUtils.english),
|
||||
getUpdateObservable(JgyUtils.zhiduoke),
|
||||
getUpdateObservable(JgyUtils.aobama),
|
||||
getUpdateObservable(JgyUtils.growthspace),
|
||||
getUpdateObservable(JgyUtils.pandaabc),
|
||||
getUpdateObservable(JgyUtils.qibenyi),
|
||||
(appInfoBaseResponse, appInfoBaseResponse2, appInfoBaseResponse3, appInfoBaseResponse4, appInfoBaseResponse5, appInfoBaseResponse6, appInfoBaseResponse7, appInfoBaseResponse8, appInfoBaseResponse9) -> {
|
||||
List<AppInfo> appInfoList = new ArrayList<>();
|
||||
if (appInfoBaseResponse.code == 200) {
|
||||
appInfoList.add(appInfoBaseResponse.data);
|
||||
}
|
||||
if (appInfoBaseResponse2.code == 200) {
|
||||
appInfoList.add(appInfoBaseResponse2.data);
|
||||
}
|
||||
if (appInfoBaseResponse3.code == 200) {
|
||||
appInfoList.add(appInfoBaseResponse3.data);
|
||||
}
|
||||
if (appInfoBaseResponse4.code == 200) {
|
||||
appInfoList.add(appInfoBaseResponse4.data);
|
||||
}
|
||||
if (appInfoBaseResponse5.code == 200) {
|
||||
appInfoList.add(appInfoBaseResponse5.data);
|
||||
}
|
||||
if (appInfoBaseResponse6.code == 200) {
|
||||
appInfoList.add(appInfoBaseResponse6.data);
|
||||
}
|
||||
if (appInfoBaseResponse7.code == 200) {
|
||||
appInfoList.add(appInfoBaseResponse7.data);
|
||||
}
|
||||
if (appInfoBaseResponse8.code == 200) {
|
||||
appInfoList.add(appInfoBaseResponse7.data);
|
||||
}
|
||||
if (appInfoBaseResponse9.code == 200) {
|
||||
appInfoList.add(appInfoBaseResponse7.data);
|
||||
}
|
||||
return appInfoList;
|
||||
})
|
||||
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
@@ -1339,27 +1339,27 @@ public class NetInterfaceManager {
|
||||
|
||||
public void setBrowserWhiteList() {
|
||||
Observable.zip(getLabelControl(), getBrowserControl(), new BiFunction<BaseResponse<Label>, BaseResponse<BrowserApiData>, HashSet<String>>() {
|
||||
@Override
|
||||
public HashSet<String> apply(BaseResponse<Label> baseResponse, BaseResponse<BrowserApiData> baseResponse2) throws Exception {
|
||||
HashSet<String> hashSet = new HashSet<>();
|
||||
setLabelResponse(baseResponse);
|
||||
if (baseResponse.code == 200) {
|
||||
if (!TextUtils.isEmpty(baseResponse.data.getHome_page())) {
|
||||
hashSet.add(baseResponse.data.getHome_page());
|
||||
}
|
||||
}
|
||||
setBrowserResponse(baseResponse2);
|
||||
if (baseResponse2.code == 200) {
|
||||
List<BrowserBean> beanList = baseResponse2.data.getWhiteList();
|
||||
if (beanList != null && beanList.size() != 0) {
|
||||
for (BrowserBean browserBean : beanList) {
|
||||
hashSet.add(browserBean.getAddress());
|
||||
@Override
|
||||
public HashSet<String> apply(BaseResponse<Label> baseResponse, BaseResponse<BrowserApiData> baseResponse2) throws Exception {
|
||||
HashSet<String> hashSet = new HashSet<>();
|
||||
setLabelResponse(baseResponse);
|
||||
if (baseResponse.code == 200) {
|
||||
if (!TextUtils.isEmpty(baseResponse.data.getHome_page())) {
|
||||
hashSet.add(baseResponse.data.getHome_page());
|
||||
}
|
||||
}
|
||||
setBrowserResponse(baseResponse2);
|
||||
if (baseResponse2.code == 200) {
|
||||
List<BrowserBean> beanList = baseResponse2.data.getWhiteList();
|
||||
if (beanList != null && beanList.size() != 0) {
|
||||
for (BrowserBean browserBean : beanList) {
|
||||
hashSet.add(browserBean.getAddress());
|
||||
}
|
||||
}
|
||||
}
|
||||
return hashSet;
|
||||
}
|
||||
}
|
||||
return hashSet;
|
||||
}
|
||||
})
|
||||
})
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<HashSet<String>>() {
|
||||
@@ -1892,12 +1892,12 @@ public class NetInterfaceManager {
|
||||
return;
|
||||
}
|
||||
getSnInfoApi().sendAdminSn(
|
||||
Utils.getSerial(),
|
||||
addr,
|
||||
machine,
|
||||
hardware,
|
||||
software
|
||||
).subscribeOn(Schedulers.io())
|
||||
Utils.getSerial(),
|
||||
addr,
|
||||
machine,
|
||||
hardware,
|
||||
software
|
||||
).subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
@@ -2293,13 +2293,13 @@ public class NetInterfaceManager {
|
||||
|
||||
private Observable<Integer> getScreenshot(String filePath) {
|
||||
Observable<Integer> screenshotObservable = Observable.create(new ObservableOnSubscribe<Integer>() {
|
||||
@Override
|
||||
public void subscribe(ObservableEmitter<Integer> e) {
|
||||
int code = CmdUtil.execute("screencap -p " + filePath).code;
|
||||
e.onNext(code);
|
||||
e.onComplete();
|
||||
}
|
||||
}).subscribeOn(Schedulers.io())
|
||||
@Override
|
||||
public void subscribe(ObservableEmitter<Integer> e) {
|
||||
int code = CmdUtil.execute("screencap -p " + filePath).code;
|
||||
e.onNext(code);
|
||||
e.onComplete();
|
||||
}
|
||||
}).subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
return screenshotObservable;
|
||||
}
|
||||
@@ -2316,15 +2316,15 @@ public class NetInterfaceManager {
|
||||
String path = ContextCompat.getExternalFilesDirs(mContext, Environment.DIRECTORY_DOWNLOADS)[0].getAbsolutePath();
|
||||
String filePath = path + File.separator + Utils.getSerial() + ".png";
|
||||
getScreenshot(filePath).concatMap(new Function<Integer, ObservableSource<BaseResponse>>() {
|
||||
@Override
|
||||
public ObservableSource<BaseResponse> apply(Integer integer) throws Exception {
|
||||
if (integer != 0) {
|
||||
throw new FileNotFoundException();
|
||||
}
|
||||
File file = new File(filePath);
|
||||
if (!file.exists()) {
|
||||
throw new FileNotFoundException(filePath);
|
||||
}
|
||||
@Override
|
||||
public ObservableSource<BaseResponse> apply(Integer integer) throws Exception {
|
||||
if (integer != 0) {
|
||||
throw new FileNotFoundException();
|
||||
}
|
||||
File file = new File(filePath);
|
||||
if (!file.exists()) {
|
||||
throw new FileNotFoundException(filePath);
|
||||
}
|
||||
// Bitmap bitmap = BitmapFactory.decodeFile(filePath);
|
||||
// if (bitmap.getWidth() < bitmap.getHeight()) {
|
||||
// bitmap = ImageUtils.rotate(bitmap, -90, bitmap.getWidth(), bitmap.getHeight());
|
||||
@@ -2340,12 +2340,12 @@ public class NetInterfaceManager {
|
||||
// fos.write(b, 0, x);
|
||||
// }
|
||||
// fos.close();
|
||||
MediaType mediaType = MediaType.Companion.parse("image/png");
|
||||
RequestBody requestBody = RequestBody.Companion.create(file, mediaType);
|
||||
MultipartBody.Part body = MultipartBody.Part.createFormData("file", file.getName(), requestBody);
|
||||
return getSendFile(filePath, body);
|
||||
}
|
||||
}).subscribeOn(Schedulers.io())
|
||||
MediaType mediaType = MediaType.Companion.parse("image/png");
|
||||
RequestBody requestBody = RequestBody.Companion.create(file, mediaType);
|
||||
MultipartBody.Part body = MultipartBody.Part.createFormData("file", file.getName(), requestBody);
|
||||
return getSendFile(filePath, body);
|
||||
}
|
||||
}).subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
@@ -3004,30 +3004,30 @@ public class NetInterfaceManager {
|
||||
|
||||
public void getAppWhiteList(WhiteListCallback callback) {
|
||||
Observable.zip(getQueryAllAppControl(), getAdminAppObservable(), new BiFunction<BaseResponse<List<AppInfo>>, BaseResponse<List<AppInfo>>, HashSet<AppInfo>>() {
|
||||
@Override
|
||||
public HashSet<AppInfo> apply(BaseResponse<List<AppInfo>> listBaseResponse1, BaseResponse<List<AppInfo>> listBaseResponse2) throws Throwable {
|
||||
Log.e("getAppWhiteList", "listBaseResponse1: " + listBaseResponse1);
|
||||
Log.e("getAppWhiteList", "listBaseResponse2: " + listBaseResponse2);
|
||||
HashSet<AppInfo> appInfos = new HashSet<>();
|
||||
if (listBaseResponse1.code == 200) {
|
||||
List<AppInfo> appInfos1 = listBaseResponse1.data;
|
||||
if (appInfos1 != null && appInfos1.size() != 0) {
|
||||
appInfos.addAll(appInfos1);
|
||||
List<String> allPkgSet = appInfos1.stream().map(AppInfo::getApp_package).collect(Collectors.toList());
|
||||
String allPkgString = String.join(",", allPkgSet);
|
||||
Settings.System.putString(mContext.getContentResolver(), CommonConfig.ONLY_SHORTCUT_LIST, allPkgString);
|
||||
Log.e("getAppWhiteList", "onNext: " + allPkgString);
|
||||
@Override
|
||||
public HashSet<AppInfo> apply(BaseResponse<List<AppInfo>> listBaseResponse1, BaseResponse<List<AppInfo>> listBaseResponse2) throws Throwable {
|
||||
Log.e("getAppWhiteList", "listBaseResponse1: " + listBaseResponse1);
|
||||
Log.e("getAppWhiteList", "listBaseResponse2: " + listBaseResponse2);
|
||||
HashSet<AppInfo> appInfos = new HashSet<>();
|
||||
if (listBaseResponse1.code == 200) {
|
||||
List<AppInfo> appInfos1 = listBaseResponse1.data;
|
||||
if (appInfos1 != null && appInfos1.size() != 0) {
|
||||
appInfos.addAll(appInfos1);
|
||||
List<String> allPkgSet = appInfos1.stream().map(AppInfo::getApp_package).collect(Collectors.toList());
|
||||
String allPkgString = String.join(",", allPkgSet);
|
||||
Settings.System.putString(mContext.getContentResolver(), CommonConfig.ONLY_SHORTCUT_LIST, allPkgString);
|
||||
Log.e("getAppWhiteList", "onNext: " + allPkgString);
|
||||
}
|
||||
}
|
||||
if (listBaseResponse2.code == 200) {
|
||||
List<AppInfo> appInfos2 = listBaseResponse2.data;
|
||||
if (appInfos2 != null) {
|
||||
appInfos.addAll(appInfos2);
|
||||
}
|
||||
}
|
||||
return appInfos;
|
||||
}
|
||||
}
|
||||
if (listBaseResponse2.code == 200) {
|
||||
List<AppInfo> appInfos2 = listBaseResponse2.data;
|
||||
if (appInfos2 != null) {
|
||||
appInfos.addAll(appInfos2);
|
||||
}
|
||||
}
|
||||
return appInfos;
|
||||
}
|
||||
}).subscribeOn(Schedulers.io())
|
||||
}).subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<HashSet<AppInfo>>() {
|
||||
@Override
|
||||
@@ -3339,11 +3339,13 @@ public class NetInterfaceManager {
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<SnTimeControlInfo> snTimeControlInfoBaseResponse) {
|
||||
Log.e("getSnTimeControlObserver", "onNext: ");
|
||||
Log.e("getSnTimeControl", "onNext: " + snTimeControlInfoBaseResponse);
|
||||
if (snTimeControlInfoBaseResponse.code == 200) {
|
||||
SnTimeControlInfo snTimeControlInfo = snTimeControlInfoBaseResponse.data;
|
||||
TimeManager.getInstance().setSnTimeControlInfo(snTimeControlInfo);
|
||||
mMMKV.encode(TimeManager.SN_TIME_CONTROL_INFO, GsonUtils.toJSONString(snTimeControlInfo));
|
||||
} else if (snTimeControlInfoBaseResponse.code == 400) {
|
||||
Log.e("getSnTimeControl", "onNext: Too frequent");
|
||||
} else {
|
||||
TimeManager.getInstance().setSnTimeControlInfo(null);
|
||||
}
|
||||
@@ -3352,7 +3354,7 @@ public class NetInterfaceManager {
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("getSnTimeControlObserver", "onError: ");
|
||||
Log.e("getSnTimeControl", "onError: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -570,6 +570,7 @@ public class PushManager {
|
||||
}
|
||||
|
||||
private void updateUserSettings() {
|
||||
Log.e(TAG, "updateUserSettings: " );
|
||||
new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
@@ -15,7 +15,8 @@ import com.fuying.sn.service.main.MainService;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
|
||||
|
||||
public class BootReceiver extends BroadcastReceiver {
|
||||
public class
|
||||
BootReceiver extends BroadcastReceiver {
|
||||
private static final String TAG = "BootReceiver";
|
||||
public static final String BOOT_COMPLETED = "zuoyeos.action.BOOT_COMPLETED";
|
||||
private MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
|
||||
|
||||
@@ -722,13 +722,30 @@ public class JgyUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* 如果界面正在最近任务列表,有些app可能不会被清理
|
||||
* 强行返回主桌面,优化跳转逻辑以确保回到系统默认桌面。
|
||||
*/
|
||||
public void gotoLauncher() {
|
||||
Intent i = new Intent(Intent.ACTION_MAIN);
|
||||
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); //android123提示如果是服务里调用,必须加入new task标识
|
||||
i.addCategory(Intent.CATEGORY_HOME);
|
||||
mContext.startActivity(i);
|
||||
Intent intent = new Intent(Intent.ACTION_MAIN);
|
||||
intent.addCategory(Intent.CATEGORY_HOME);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
|
||||
|
||||
// 优先定位到当前的默认桌面应用,避免在存在多个桌面时弹出系统选择框
|
||||
PackageManager pm = mContext.getPackageManager();
|
||||
ResolveInfo resolveInfo = pm.resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY);
|
||||
if (resolveInfo != null && resolveInfo.activityInfo != null && !resolveInfo.activityInfo.packageName.equals("android")) {
|
||||
intent.setComponent(new ComponentName(resolveInfo.activityInfo.packageName, resolveInfo.activityInfo.name));
|
||||
}
|
||||
|
||||
try {
|
||||
mContext.startActivity(intent);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "gotoLauncher failed: " + e.getMessage());
|
||||
// 如果精准跳转失败,则使用基础的 Home Intent
|
||||
Intent fallback = new Intent(Intent.ACTION_MAIN);
|
||||
fallback.addCategory(Intent.CATEGORY_HOME);
|
||||
fallback.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
mContext.startActivity(fallback);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user