feat: 优化管控
This commit is contained in:
@@ -15,7 +15,7 @@ android {
|
|||||||
buildToolsVersion "29.0.3"
|
buildToolsVersion "29.0.3"
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdkVersion 24
|
minSdkVersion 26
|
||||||
targetSdkVersion 29
|
targetSdkVersion 29
|
||||||
|
|
||||||
multiDexEnabled true
|
multiDexEnabled true
|
||||||
@@ -63,8 +63,8 @@ android {
|
|||||||
|
|
||||||
official {
|
official {
|
||||||
flavorDimensions "default"
|
flavorDimensions "default"
|
||||||
versionCode 88
|
versionCode 89
|
||||||
versionName "3.4.8"
|
versionName "3.4.9"
|
||||||
applicationId "com.fuying.sn"
|
applicationId "com.fuying.sn"
|
||||||
|
|
||||||
buildConfigField "String", "ROOT_URL", '"https://as.fuyingy.com/android/"'
|
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 {
|
//preBuild {
|
||||||
// doLast {
|
// doLast {
|
||||||
// def imlFile = file(project.name + ".iml")
|
// def imlFile = file(project.name + ".iml")
|
||||||
|
|||||||
@@ -214,7 +214,7 @@
|
|||||||
|
|
||||||
<provider
|
<provider
|
||||||
android:name="androidx.core.content.FileProvider"
|
android:name="androidx.core.content.FileProvider"
|
||||||
android:authorities="com.fuying.sn.fileprovider"
|
android:authorities="${applicationId}.fileprovider"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:grantUriPermissions="true">
|
android:grantUriPermissions="true">
|
||||||
<meta-data
|
<meta-data
|
||||||
|
|||||||
@@ -449,13 +449,30 @@ public class RunningAppManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 如果界面正在最近任务列表,有些app可能不会被清理
|
* 强行返回主桌面,优化跳转逻辑以确保回到系统默认桌面。
|
||||||
*/
|
*/
|
||||||
private void gotoLauncher() {
|
private void gotoLauncher() {
|
||||||
Intent i = new Intent(Intent.ACTION_MAIN);
|
Intent intent = new Intent(Intent.ACTION_MAIN);
|
||||||
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); //android123提示如果是服务里调用,必须加入new task标识
|
intent.addCategory(Intent.CATEGORY_HOME);
|
||||||
i.addCategory(Intent.CATEGORY_HOME);
|
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
|
||||||
mContext.startActivity(i);
|
|
||||||
|
// 优先定位到当前的默认桌面应用,避免在存在多个桌面时弹出系统选择框
|
||||||
|
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() {
|
public void SendAppInstallInfo() {
|
||||||
Observable.create(new ObservableOnSubscribe<String>() {
|
Observable.create(new ObservableOnSubscribe<String>() {
|
||||||
@Override
|
@Override
|
||||||
public void subscribe(@NonNull ObservableEmitter<String> emitter) throws Throwable {
|
public void subscribe(@NonNull ObservableEmitter<String> emitter) throws Throwable {
|
||||||
PackageManager pm = mContext.getPackageManager();
|
PackageManager pm = mContext.getPackageManager();
|
||||||
List<PackageInfo> list = pm.getInstalledPackages(0);
|
List<PackageInfo> list = pm.getInstalledPackages(0);
|
||||||
List<AppUploadInfo> uploadInfos = new ArrayList<>();
|
List<AppUploadInfo> uploadInfos = new ArrayList<>();
|
||||||
Intent intent = new Intent(Intent.ACTION_MAIN);
|
Intent intent = new Intent(Intent.ACTION_MAIN);
|
||||||
intent.addCategory(Intent.CATEGORY_LAUNCHER);
|
intent.addCategory(Intent.CATEGORY_LAUNCHER);
|
||||||
List<ResolveInfo> appsWithLauncher = pm.queryIntentActivities(intent, 0);
|
List<ResolveInfo> appsWithLauncher = pm.queryIntentActivities(intent, 0);
|
||||||
List<String> pkgs = new ArrayList<>();
|
List<String> pkgs = new ArrayList<>();
|
||||||
for (ResolveInfo info : appsWithLauncher) {
|
for (ResolveInfo info : appsWithLauncher) {
|
||||||
pkgs.add(info.activityInfo.packageName);
|
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;
|
|
||||||
}
|
}
|
||||||
} else {
|
Log.e("SendAppInstallInfo", "pkgs: " + pkgs);
|
||||||
if (!showPkg.contains(info.packageName)) {
|
Set<String> showPkg = getShowPackages();
|
||||||
//排除掉没有图标的应用
|
Log.e("SendAppInstallInfo", "showPkg: " + showPkg);
|
||||||
if (!pkgs.contains(info.packageName)) {
|
for (PackageInfo info : list) {
|
||||||
continue;
|
//排除掉部分系统应用
|
||||||
|
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())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.concatMap(new Function<String, ObservableSource<BaseResponse>>() {
|
.concatMap(new Function<String, ObservableSource<BaseResponse>>() {
|
||||||
@@ -909,20 +909,20 @@ public class NetInterfaceManager {
|
|||||||
|
|
||||||
public void getElderlyUsersApp() {
|
public void getElderlyUsersApp() {
|
||||||
Observable.zip(getUpdateObservable(JgyUtils.AIHealth),
|
Observable.zip(getUpdateObservable(JgyUtils.AIHealth),
|
||||||
getUpdateObservable(JgyUtils.ElderlyDesktop),
|
getUpdateObservable(JgyUtils.ElderlyDesktop),
|
||||||
new BiFunction<BaseResponse<AppInfo>, BaseResponse<AppInfo>, List<AppInfo>>() {
|
new BiFunction<BaseResponse<AppInfo>, BaseResponse<AppInfo>, List<AppInfo>>() {
|
||||||
@Override
|
@Override
|
||||||
public List<AppInfo> apply(BaseResponse<AppInfo> appInfoBaseResponse, BaseResponse<AppInfo> appInfoBaseResponse2) throws Throwable {
|
public List<AppInfo> apply(BaseResponse<AppInfo> appInfoBaseResponse, BaseResponse<AppInfo> appInfoBaseResponse2) throws Throwable {
|
||||||
List<AppInfo> appInfoList = new ArrayList<>();
|
List<AppInfo> appInfoList = new ArrayList<>();
|
||||||
if (appInfoBaseResponse.code == 200) {
|
if (appInfoBaseResponse.code == 200) {
|
||||||
appInfoList.add(appInfoBaseResponse.data);
|
appInfoList.add(appInfoBaseResponse.data);
|
||||||
}
|
}
|
||||||
if (appInfoBaseResponse2.code == 200) {
|
if (appInfoBaseResponse2.code == 200) {
|
||||||
appInfoList.add(appInfoBaseResponse2.data);
|
appInfoList.add(appInfoBaseResponse2.data);
|
||||||
}
|
}
|
||||||
return appInfoList;
|
return appInfoList;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(new Observer<List<AppInfo>>() {
|
.subscribe(new Observer<List<AppInfo>>() {
|
||||||
@@ -1017,19 +1017,19 @@ public class NetInterfaceManager {
|
|||||||
|
|
||||||
public void checkAllAppUpdate(BehaviorSubject<ActivityEvent> lifecycle, CompleteCallback callback) {
|
public void checkAllAppUpdate(BehaviorSubject<ActivityEvent> lifecycle, CompleteCallback callback) {
|
||||||
Observable.zip(
|
Observable.zip(
|
||||||
getUpdateObservable(BuildConfig.APPLICATION_ID),
|
getUpdateObservable(BuildConfig.APPLICATION_ID),
|
||||||
getUpdateObservable(JgyUtils.PACKAGE_APPSTORE),
|
getUpdateObservable(JgyUtils.PACKAGE_APPSTORE),
|
||||||
// getUpdateObservable(JGYUtils.PACKAGE_OS),
|
// getUpdateObservable(JGYUtils.PACKAGE_OS),
|
||||||
// getUpdateObservable(JGYUtils.PACKAGE_BROWSER),
|
// getUpdateObservable(JGYUtils.PACKAGE_BROWSER),
|
||||||
// getUpdateObservable(JGYUtils.Notifications),
|
// getUpdateObservable(JGYUtils.Notifications),
|
||||||
(appInfoBaseResponse, appInfoBaseResponse2) -> {
|
(appInfoBaseResponse, appInfoBaseResponse2) -> {
|
||||||
List<AppInfo> appInfoList = new ArrayList<>();
|
List<AppInfo> appInfoList = new ArrayList<>();
|
||||||
if (appInfoBaseResponse.code == 200) {
|
if (appInfoBaseResponse.code == 200) {
|
||||||
appInfoList.add(appInfoBaseResponse.data);
|
appInfoList.add(appInfoBaseResponse.data);
|
||||||
}
|
}
|
||||||
if (appInfoBaseResponse2.code == 200) {
|
if (appInfoBaseResponse2.code == 200) {
|
||||||
appInfoList.add(appInfoBaseResponse2.data);
|
appInfoList.add(appInfoBaseResponse2.data);
|
||||||
}
|
}
|
||||||
// if (appInfoBaseResponse3.code == 200) {
|
// if (appInfoBaseResponse3.code == 200) {
|
||||||
// appInfoList.add(appInfoBaseResponse3.data);
|
// appInfoList.add(appInfoBaseResponse3.data);
|
||||||
// }
|
// }
|
||||||
@@ -1039,8 +1039,8 @@ public class NetInterfaceManager {
|
|||||||
// if (appInfoBaseResponse5.code == 200) {
|
// if (appInfoBaseResponse5.code == 200) {
|
||||||
// appInfoList.add(appInfoBaseResponse5.data);
|
// appInfoList.add(appInfoBaseResponse5.data);
|
||||||
// }
|
// }
|
||||||
return appInfoList;
|
return appInfoList;
|
||||||
})
|
})
|
||||||
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
@@ -1098,46 +1098,46 @@ public class NetInterfaceManager {
|
|||||||
|
|
||||||
public void checkFXYAppUpdate(BehaviorSubject<ActivityEvent> lifecycle, CompleteCallback callback) {
|
public void checkFXYAppUpdate(BehaviorSubject<ActivityEvent> lifecycle, CompleteCallback callback) {
|
||||||
Observable.zip(
|
Observable.zip(
|
||||||
getUpdateObservable(JgyUtils.gkwxhd),
|
getUpdateObservable(JgyUtils.gkwxhd),
|
||||||
getUpdateObservable(JgyUtils.fuxiaoying),
|
getUpdateObservable(JgyUtils.fuxiaoying),
|
||||||
getUpdateObservable(JgyUtils.moshujia),
|
getUpdateObservable(JgyUtils.moshujia),
|
||||||
getUpdateObservable(JgyUtils.english),
|
getUpdateObservable(JgyUtils.english),
|
||||||
getUpdateObservable(JgyUtils.zhiduoke),
|
getUpdateObservable(JgyUtils.zhiduoke),
|
||||||
getUpdateObservable(JgyUtils.aobama),
|
getUpdateObservable(JgyUtils.aobama),
|
||||||
getUpdateObservable(JgyUtils.growthspace),
|
getUpdateObservable(JgyUtils.growthspace),
|
||||||
getUpdateObservable(JgyUtils.pandaabc),
|
getUpdateObservable(JgyUtils.pandaabc),
|
||||||
getUpdateObservable(JgyUtils.qibenyi),
|
getUpdateObservable(JgyUtils.qibenyi),
|
||||||
(appInfoBaseResponse, appInfoBaseResponse2, appInfoBaseResponse3, appInfoBaseResponse4, appInfoBaseResponse5, appInfoBaseResponse6, appInfoBaseResponse7, appInfoBaseResponse8, appInfoBaseResponse9) -> {
|
(appInfoBaseResponse, appInfoBaseResponse2, appInfoBaseResponse3, appInfoBaseResponse4, appInfoBaseResponse5, appInfoBaseResponse6, appInfoBaseResponse7, appInfoBaseResponse8, appInfoBaseResponse9) -> {
|
||||||
List<AppInfo> appInfoList = new ArrayList<>();
|
List<AppInfo> appInfoList = new ArrayList<>();
|
||||||
if (appInfoBaseResponse.code == 200) {
|
if (appInfoBaseResponse.code == 200) {
|
||||||
appInfoList.add(appInfoBaseResponse.data);
|
appInfoList.add(appInfoBaseResponse.data);
|
||||||
}
|
}
|
||||||
if (appInfoBaseResponse2.code == 200) {
|
if (appInfoBaseResponse2.code == 200) {
|
||||||
appInfoList.add(appInfoBaseResponse2.data);
|
appInfoList.add(appInfoBaseResponse2.data);
|
||||||
}
|
}
|
||||||
if (appInfoBaseResponse3.code == 200) {
|
if (appInfoBaseResponse3.code == 200) {
|
||||||
appInfoList.add(appInfoBaseResponse3.data);
|
appInfoList.add(appInfoBaseResponse3.data);
|
||||||
}
|
}
|
||||||
if (appInfoBaseResponse4.code == 200) {
|
if (appInfoBaseResponse4.code == 200) {
|
||||||
appInfoList.add(appInfoBaseResponse4.data);
|
appInfoList.add(appInfoBaseResponse4.data);
|
||||||
}
|
}
|
||||||
if (appInfoBaseResponse5.code == 200) {
|
if (appInfoBaseResponse5.code == 200) {
|
||||||
appInfoList.add(appInfoBaseResponse5.data);
|
appInfoList.add(appInfoBaseResponse5.data);
|
||||||
}
|
}
|
||||||
if (appInfoBaseResponse6.code == 200) {
|
if (appInfoBaseResponse6.code == 200) {
|
||||||
appInfoList.add(appInfoBaseResponse6.data);
|
appInfoList.add(appInfoBaseResponse6.data);
|
||||||
}
|
}
|
||||||
if (appInfoBaseResponse7.code == 200) {
|
if (appInfoBaseResponse7.code == 200) {
|
||||||
appInfoList.add(appInfoBaseResponse7.data);
|
appInfoList.add(appInfoBaseResponse7.data);
|
||||||
}
|
}
|
||||||
if (appInfoBaseResponse8.code == 200) {
|
if (appInfoBaseResponse8.code == 200) {
|
||||||
appInfoList.add(appInfoBaseResponse7.data);
|
appInfoList.add(appInfoBaseResponse7.data);
|
||||||
}
|
}
|
||||||
if (appInfoBaseResponse9.code == 200) {
|
if (appInfoBaseResponse9.code == 200) {
|
||||||
appInfoList.add(appInfoBaseResponse7.data);
|
appInfoList.add(appInfoBaseResponse7.data);
|
||||||
}
|
}
|
||||||
return appInfoList;
|
return appInfoList;
|
||||||
})
|
})
|
||||||
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
@@ -1339,27 +1339,27 @@ public class NetInterfaceManager {
|
|||||||
|
|
||||||
public void setBrowserWhiteList() {
|
public void setBrowserWhiteList() {
|
||||||
Observable.zip(getLabelControl(), getBrowserControl(), new BiFunction<BaseResponse<Label>, BaseResponse<BrowserApiData>, HashSet<String>>() {
|
Observable.zip(getLabelControl(), getBrowserControl(), new BiFunction<BaseResponse<Label>, BaseResponse<BrowserApiData>, HashSet<String>>() {
|
||||||
@Override
|
@Override
|
||||||
public HashSet<String> apply(BaseResponse<Label> baseResponse, BaseResponse<BrowserApiData> baseResponse2) throws Exception {
|
public HashSet<String> apply(BaseResponse<Label> baseResponse, BaseResponse<BrowserApiData> baseResponse2) throws Exception {
|
||||||
HashSet<String> hashSet = new HashSet<>();
|
HashSet<String> hashSet = new HashSet<>();
|
||||||
setLabelResponse(baseResponse);
|
setLabelResponse(baseResponse);
|
||||||
if (baseResponse.code == 200) {
|
if (baseResponse.code == 200) {
|
||||||
if (!TextUtils.isEmpty(baseResponse.data.getHome_page())) {
|
if (!TextUtils.isEmpty(baseResponse.data.getHome_page())) {
|
||||||
hashSet.add(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());
|
|
||||||
}
|
}
|
||||||
|
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())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(new Observer<HashSet<String>>() {
|
.subscribe(new Observer<HashSet<String>>() {
|
||||||
@@ -1892,12 +1892,12 @@ public class NetInterfaceManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
getSnInfoApi().sendAdminSn(
|
getSnInfoApi().sendAdminSn(
|
||||||
Utils.getSerial(),
|
Utils.getSerial(),
|
||||||
addr,
|
addr,
|
||||||
machine,
|
machine,
|
||||||
hardware,
|
hardware,
|
||||||
software
|
software
|
||||||
).subscribeOn(Schedulers.io())
|
).subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(new Observer<BaseResponse>() {
|
.subscribe(new Observer<BaseResponse>() {
|
||||||
@Override
|
@Override
|
||||||
@@ -2293,13 +2293,13 @@ public class NetInterfaceManager {
|
|||||||
|
|
||||||
private Observable<Integer> getScreenshot(String filePath) {
|
private Observable<Integer> getScreenshot(String filePath) {
|
||||||
Observable<Integer> screenshotObservable = Observable.create(new ObservableOnSubscribe<Integer>() {
|
Observable<Integer> screenshotObservable = Observable.create(new ObservableOnSubscribe<Integer>() {
|
||||||
@Override
|
@Override
|
||||||
public void subscribe(ObservableEmitter<Integer> e) {
|
public void subscribe(ObservableEmitter<Integer> e) {
|
||||||
int code = CmdUtil.execute("screencap -p " + filePath).code;
|
int code = CmdUtil.execute("screencap -p " + filePath).code;
|
||||||
e.onNext(code);
|
e.onNext(code);
|
||||||
e.onComplete();
|
e.onComplete();
|
||||||
}
|
}
|
||||||
}).subscribeOn(Schedulers.io())
|
}).subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread());
|
.observeOn(AndroidSchedulers.mainThread());
|
||||||
return screenshotObservable;
|
return screenshotObservable;
|
||||||
}
|
}
|
||||||
@@ -2316,15 +2316,15 @@ public class NetInterfaceManager {
|
|||||||
String path = ContextCompat.getExternalFilesDirs(mContext, Environment.DIRECTORY_DOWNLOADS)[0].getAbsolutePath();
|
String path = ContextCompat.getExternalFilesDirs(mContext, Environment.DIRECTORY_DOWNLOADS)[0].getAbsolutePath();
|
||||||
String filePath = path + File.separator + Utils.getSerial() + ".png";
|
String filePath = path + File.separator + Utils.getSerial() + ".png";
|
||||||
getScreenshot(filePath).concatMap(new Function<Integer, ObservableSource<BaseResponse>>() {
|
getScreenshot(filePath).concatMap(new Function<Integer, ObservableSource<BaseResponse>>() {
|
||||||
@Override
|
@Override
|
||||||
public ObservableSource<BaseResponse> apply(Integer integer) throws Exception {
|
public ObservableSource<BaseResponse> apply(Integer integer) throws Exception {
|
||||||
if (integer != 0) {
|
if (integer != 0) {
|
||||||
throw new FileNotFoundException();
|
throw new FileNotFoundException();
|
||||||
}
|
}
|
||||||
File file = new File(filePath);
|
File file = new File(filePath);
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
throw new FileNotFoundException(filePath);
|
throw new FileNotFoundException(filePath);
|
||||||
}
|
}
|
||||||
// Bitmap bitmap = BitmapFactory.decodeFile(filePath);
|
// Bitmap bitmap = BitmapFactory.decodeFile(filePath);
|
||||||
// if (bitmap.getWidth() < bitmap.getHeight()) {
|
// if (bitmap.getWidth() < bitmap.getHeight()) {
|
||||||
// bitmap = ImageUtils.rotate(bitmap, -90, 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.write(b, 0, x);
|
||||||
// }
|
// }
|
||||||
// fos.close();
|
// fos.close();
|
||||||
MediaType mediaType = MediaType.Companion.parse("image/png");
|
MediaType mediaType = MediaType.Companion.parse("image/png");
|
||||||
RequestBody requestBody = RequestBody.Companion.create(file, mediaType);
|
RequestBody requestBody = RequestBody.Companion.create(file, mediaType);
|
||||||
MultipartBody.Part body = MultipartBody.Part.createFormData("file", file.getName(), requestBody);
|
MultipartBody.Part body = MultipartBody.Part.createFormData("file", file.getName(), requestBody);
|
||||||
return getSendFile(filePath, body);
|
return getSendFile(filePath, body);
|
||||||
}
|
}
|
||||||
}).subscribeOn(Schedulers.io())
|
}).subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(new Observer<BaseResponse>() {
|
.subscribe(new Observer<BaseResponse>() {
|
||||||
@Override
|
@Override
|
||||||
@@ -3004,30 +3004,30 @@ public class NetInterfaceManager {
|
|||||||
|
|
||||||
public void getAppWhiteList(WhiteListCallback callback) {
|
public void getAppWhiteList(WhiteListCallback callback) {
|
||||||
Observable.zip(getQueryAllAppControl(), getAdminAppObservable(), new BiFunction<BaseResponse<List<AppInfo>>, BaseResponse<List<AppInfo>>, HashSet<AppInfo>>() {
|
Observable.zip(getQueryAllAppControl(), getAdminAppObservable(), new BiFunction<BaseResponse<List<AppInfo>>, BaseResponse<List<AppInfo>>, HashSet<AppInfo>>() {
|
||||||
@Override
|
@Override
|
||||||
public HashSet<AppInfo> apply(BaseResponse<List<AppInfo>> listBaseResponse1, BaseResponse<List<AppInfo>> listBaseResponse2) throws Throwable {
|
public HashSet<AppInfo> apply(BaseResponse<List<AppInfo>> listBaseResponse1, BaseResponse<List<AppInfo>> listBaseResponse2) throws Throwable {
|
||||||
Log.e("getAppWhiteList", "listBaseResponse1: " + listBaseResponse1);
|
Log.e("getAppWhiteList", "listBaseResponse1: " + listBaseResponse1);
|
||||||
Log.e("getAppWhiteList", "listBaseResponse2: " + listBaseResponse2);
|
Log.e("getAppWhiteList", "listBaseResponse2: " + listBaseResponse2);
|
||||||
HashSet<AppInfo> appInfos = new HashSet<>();
|
HashSet<AppInfo> appInfos = new HashSet<>();
|
||||||
if (listBaseResponse1.code == 200) {
|
if (listBaseResponse1.code == 200) {
|
||||||
List<AppInfo> appInfos1 = listBaseResponse1.data;
|
List<AppInfo> appInfos1 = listBaseResponse1.data;
|
||||||
if (appInfos1 != null && appInfos1.size() != 0) {
|
if (appInfos1 != null && appInfos1.size() != 0) {
|
||||||
appInfos.addAll(appInfos1);
|
appInfos.addAll(appInfos1);
|
||||||
List<String> allPkgSet = appInfos1.stream().map(AppInfo::getApp_package).collect(Collectors.toList());
|
List<String> allPkgSet = appInfos1.stream().map(AppInfo::getApp_package).collect(Collectors.toList());
|
||||||
String allPkgString = String.join(",", allPkgSet);
|
String allPkgString = String.join(",", allPkgSet);
|
||||||
Settings.System.putString(mContext.getContentResolver(), CommonConfig.ONLY_SHORTCUT_LIST, allPkgString);
|
Settings.System.putString(mContext.getContentResolver(), CommonConfig.ONLY_SHORTCUT_LIST, allPkgString);
|
||||||
Log.e("getAppWhiteList", "onNext: " + allPkgString);
|
Log.e("getAppWhiteList", "onNext: " + allPkgString);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (listBaseResponse2.code == 200) {
|
||||||
|
List<AppInfo> appInfos2 = listBaseResponse2.data;
|
||||||
|
if (appInfos2 != null) {
|
||||||
|
appInfos.addAll(appInfos2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return appInfos;
|
||||||
}
|
}
|
||||||
}
|
}).subscribeOn(Schedulers.io())
|
||||||
if (listBaseResponse2.code == 200) {
|
|
||||||
List<AppInfo> appInfos2 = listBaseResponse2.data;
|
|
||||||
if (appInfos2 != null) {
|
|
||||||
appInfos.addAll(appInfos2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return appInfos;
|
|
||||||
}
|
|
||||||
}).subscribeOn(Schedulers.io())
|
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(new Observer<HashSet<AppInfo>>() {
|
.subscribe(new Observer<HashSet<AppInfo>>() {
|
||||||
@Override
|
@Override
|
||||||
@@ -3339,11 +3339,13 @@ public class NetInterfaceManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNext(@NonNull BaseResponse<SnTimeControlInfo> snTimeControlInfoBaseResponse) {
|
public void onNext(@NonNull BaseResponse<SnTimeControlInfo> snTimeControlInfoBaseResponse) {
|
||||||
Log.e("getSnTimeControlObserver", "onNext: ");
|
Log.e("getSnTimeControl", "onNext: " + snTimeControlInfoBaseResponse);
|
||||||
if (snTimeControlInfoBaseResponse.code == 200) {
|
if (snTimeControlInfoBaseResponse.code == 200) {
|
||||||
SnTimeControlInfo snTimeControlInfo = snTimeControlInfoBaseResponse.data;
|
SnTimeControlInfo snTimeControlInfo = snTimeControlInfoBaseResponse.data;
|
||||||
TimeManager.getInstance().setSnTimeControlInfo(snTimeControlInfo);
|
TimeManager.getInstance().setSnTimeControlInfo(snTimeControlInfo);
|
||||||
mMMKV.encode(TimeManager.SN_TIME_CONTROL_INFO, GsonUtils.toJSONString(snTimeControlInfo));
|
mMMKV.encode(TimeManager.SN_TIME_CONTROL_INFO, GsonUtils.toJSONString(snTimeControlInfo));
|
||||||
|
} else if (snTimeControlInfoBaseResponse.code == 400) {
|
||||||
|
Log.e("getSnTimeControl", "onNext: Too frequent");
|
||||||
} else {
|
} else {
|
||||||
TimeManager.getInstance().setSnTimeControlInfo(null);
|
TimeManager.getInstance().setSnTimeControlInfo(null);
|
||||||
}
|
}
|
||||||
@@ -3352,7 +3354,7 @@ public class NetInterfaceManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(@NonNull Throwable e) {
|
public void onError(@NonNull Throwable e) {
|
||||||
Log.e("getSnTimeControlObserver", "onError: ");
|
Log.e("getSnTimeControl", "onError: ");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -570,6 +570,7 @@ public class PushManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateUserSettings() {
|
private void updateUserSettings() {
|
||||||
|
Log.e(TAG, "updateUserSettings: " );
|
||||||
new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
|
new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ import com.fuying.sn.service.main.MainService;
|
|||||||
import com.tencent.mmkv.MMKV;
|
import com.tencent.mmkv.MMKV;
|
||||||
|
|
||||||
|
|
||||||
public class BootReceiver extends BroadcastReceiver {
|
public class
|
||||||
|
BootReceiver extends BroadcastReceiver {
|
||||||
private static final String TAG = "BootReceiver";
|
private static final String TAG = "BootReceiver";
|
||||||
public static final String BOOT_COMPLETED = "zuoyeos.action.BOOT_COMPLETED";
|
public static final String BOOT_COMPLETED = "zuoyeos.action.BOOT_COMPLETED";
|
||||||
private MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
|
private MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
|
||||||
|
|||||||
@@ -722,13 +722,30 @@ public class JgyUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 如果界面正在最近任务列表,有些app可能不会被清理
|
* 强行返回主桌面,优化跳转逻辑以确保回到系统默认桌面。
|
||||||
*/
|
*/
|
||||||
public void gotoLauncher() {
|
public void gotoLauncher() {
|
||||||
Intent i = new Intent(Intent.ACTION_MAIN);
|
Intent intent = new Intent(Intent.ACTION_MAIN);
|
||||||
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); //android123提示如果是服务里调用,必须加入new task标识
|
intent.addCategory(Intent.CATEGORY_HOME);
|
||||||
i.addCategory(Intent.CATEGORY_HOME);
|
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
|
||||||
mContext.startActivity(i);
|
|
||||||
|
// 优先定位到当前的默认桌面应用,避免在存在多个桌面时弹出系统选择框
|
||||||
|
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