version:1.9

fix:
add:
This commit is contained in:
2022-03-30 14:04:59 +08:00
parent 9b3a1c8b92
commit ed6f11b717
21 changed files with 324 additions and 144 deletions

View File

@@ -333,13 +333,11 @@ public class MainActivity extends BaseActivity implements MainAContact.MainView,
//设备已经绑定
if (code == 200) {
tv_bind.setText(getString(R.string.bind_succeed));
mPresenter.getAppletQRCode();
}
//设备没有绑定
else if (code == 300) {
tv_bind.setText(getString(R.string.scan_tips));
ControlManager.getInstance().setDisableSetting();
mPresenter.getAppletQRCode();
}
//没有授权的设备
else if (code == 400) {
@@ -348,6 +346,7 @@ public class MainActivity extends BaseActivity implements MainAContact.MainView,
Log.e(TAG, "setSnInfo: " + getString(R.string.device_unauthorized));
ControlManager.getInstance().setDisableSetting();
}
mPresenter.getAppletQRCode();
}
@Override

View File

@@ -9,7 +9,10 @@ public class CommonConfig {
public final static String ONLY_SHORTCUT_LIST = "only_jgy_shortcut_list";
/*底层白名单*/
public final static String QCH_APP_FORBID = "qch_app_forbid";
/*所有app更新*/
public final static String ALL_APP_UPDATE = "AllAppUpdate";
/*上次检查更新时间*/
public final static String LAST_CHECK_ALL_UPDATE_TIME = "lastCheckAllUpdateTime";
public static String isLogined = "isLogined";
public static String AES_KEY = "0123456789ABCDEF";

View File

@@ -782,76 +782,7 @@ public class HTTPInterface {
}
}
public static void checkUpdate(final Context context, String packageName, String versionCode) {
Log.e("checkUpdate", "packageName: " + packageName);
NewestAppUpdate newestAppUpdate = NetInterfaceManager.getInstance().getNewestAppUpdateControl();
newestAppUpdate.getAppUpdate(packageName, versionCode, JGYUtils.getInstance().checkAppPlatform())
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<BaseResponse<AppInfo>>() {
@Override
public void onSubscribe(@NonNull Disposable d) {
Log.e("checkUpdate", "onSubscribe: ");
}
@Override
public void onNext(@NonNull BaseResponse<AppInfo> appInfoBaseResponse) {
Log.e("checkUpdate", "onNext: " + appInfoBaseResponse);
int code = appInfoBaseResponse.code;
if (code == 200) {
AppInfo appInfo = appInfoBaseResponse.data;
if (null != appInfo) {
JSONObject jsonObject = (JSONObject) JSON.toJSON(appInfo);
FileUtils.ariaDownload(context, appInfo.getApp_url(), jsonObject);
}
Log.e("checkUpdate", "update now");
} else {
Log.e("checkUpdate", "not found update");
}
}
@Override
public void onError(@NonNull Throwable e) {
Log.e("checkUpdate", "onError: " + e.getMessage());
}
@Override
public void onComplete() {
Log.e("checkUpdate", "onComplete: ");
}
});
}
public static void checkUpdate(Context context) {
String packageName = BuildConfig.APPLICATION_ID;
String versionCode = String.valueOf(BuildConfig.VERSION_CODE);
checkUpdate(context, packageName, versionCode);
}
public static void checkUpdate(Context context, String packageName) {
Log.e(TAG, "checkUpdate: " + packageName);
PackageManager pm = context.getPackageManager();
PackageInfo info = null;
try {
info = pm.getPackageInfo(packageName, 0);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
if (null != info) {
long appVersionCode;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
appVersionCode = info.getLongVersionCode();
} else {
appVersionCode = info.versionCode;
}
checkUpdate(context, packageName, String.valueOf(appVersionCode));
} else {
checkUpdate(context, packageName, "0");
}
}
public static void getSystemSettings(final Context context) {
public static void getSystemSettings() {
NetInterfaceManager.getInstance().getsettingControl()
.subscribe(new Observer<BaseResponse>() {
@Override

View File

@@ -11,14 +11,19 @@ import android.provider.Settings;
import android.text.TextUtils;
import android.util.Log;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.reflect.TypeToken;
import com.tencent.android.tpush.XGIOperateCallback;
import com.tencent.android.tpush.XGPushManager;
import com.tencent.mmkv.MMKV;
import com.trello.rxlifecycle4.RxLifecycle;
import com.trello.rxlifecycle4.android.ActivityEvent;
import com.uiui.sn.BuildConfig;
import com.uiui.sn.bean.AppInfo;
import com.uiui.sn.bean.AppStart;
import com.uiui.sn.bean.AppUploadInfo;
@@ -52,6 +57,7 @@ import com.uiui.sn.network.api.TimeControl;
import com.uiui.sn.network.api.UpdateAdminSn;
import com.uiui.sn.network.api.UploadScreenshot;
import com.uiui.sn.network.api.UserInfoControl;
import com.uiui.sn.utils.FileUtils;
import com.uiui.sn.utils.JGYUtils;
import com.uiui.sn.utils.MD5Util;
import com.uiui.sn.utils.SPUtils;
@@ -61,22 +67,28 @@ import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
import io.reactivex.rxjava3.annotations.NonNull;
import io.reactivex.rxjava3.core.Flowable;
import io.reactivex.rxjava3.core.Observable;
import io.reactivex.rxjava3.core.ObservableEmitter;
import io.reactivex.rxjava3.core.ObservableOnSubscribe;
import io.reactivex.rxjava3.core.ObservableSource;
import io.reactivex.rxjava3.core.Observer;
import io.reactivex.rxjava3.disposables.Disposable;
import io.reactivex.rxjava3.functions.Consumer;
import io.reactivex.rxjava3.functions.Function;
import io.reactivex.rxjava3.functions.Function3;
import io.reactivex.rxjava3.schedulers.Schedulers;
import io.reactivex.rxjava3.subjects.BehaviorSubject;
import okhttp3.Cache;
@@ -91,11 +103,15 @@ import retrofit2.adapter.rxjava3.RxJava3CallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;
public class NetInterfaceManager {
private static final String TAG = NetInterfaceManager.class.getSimpleName();
@SuppressLint("StaticFieldLeak")
private static NetInterfaceManager INSTANCE;
private Context mContext;
private MMKV mMMKV = MMKV.defaultMMKV();
private Retrofit mRetrofit;
private OkHttpClient okHttpClient;
private final ConcurrentHashMap<String, Long> requestIdsMap = new ConcurrentHashMap<>();
//超时时间
@@ -103,7 +119,6 @@ public class NetInterfaceManager {
// 缓存文件最大限制大小20M
private static long cacheSize = 1024 * 1024 * 64;
public static final String CUSTOM_REPEAT_REQ_PROTOCOL = "MY_CUSTOM_REPEAT_REQ_PROTOCOL";
private String TAG = NetInterfaceManager.class.getSimpleName();
private NetInterfaceManager(Context context) {
mContext = context;
@@ -456,13 +471,13 @@ public class NetInterfaceManager {
.subscribe(new Observer<BaseResponse<SnInfo>>() {
@Override
public void onSubscribe(Disposable d) {
Log.e( "getSnInfo", "onSubscribe: ");
Log.e("getSnInfo", "onSubscribe: ");
callback.onSubscribe(d);
}
@Override
public void onNext(BaseResponse<SnInfo> userInfoBaseResponse) {
Log.e( "getSnInfo", "onNext: " + userInfoBaseResponse);
Log.e("getSnInfo", "onNext: " + userInfoBaseResponse);
SPUtils.put(mContext, CommonConfig.JGY_FIRST_CONNECT, 1);
callback.onNext(userInfoBaseResponse);
int code = userInfoBaseResponse.code;
@@ -490,7 +505,7 @@ public class NetInterfaceManager {
@Override
public void onError(Throwable e) {
Log.e( "getSnInfo", "onError: " + e.getMessage());
Log.e("getSnInfo", "onError: " + e.getMessage());
callback.onError(e);
onComplete();
}
@@ -525,7 +540,9 @@ public class NetInterfaceManager {
Log.e(TAG + ":" + "setPushTags", "onNext: " + response);
if (response.code == 200) {
JsonObject jsonObject = JsonParser.parseString(new Gson().toJson(response.data)).getAsJsonObject();
if (jsonObject.get("batch_id") == null) return;
if (jsonObject.get("batch_id") == null) {
return;
}
String batch = jsonObject.get("batch_id").getAsString();
Log.e(TAG + ":" + "setPushTags", "onNext: " + batch);
if (!TextUtils.isEmpty(batch)) {
@@ -644,4 +661,195 @@ public class NetInterfaceManager {
}
public void checkUpdate(String packageName) {
Log.e(TAG, "checkUpdate: " + packageName);
PackageManager pm = mContext.getPackageManager();
PackageInfo info = null;
try {
info = pm.getPackageInfo(packageName, 0);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
if (null != info) {
long appVersionCode;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
appVersionCode = info.getLongVersionCode();
} else {
appVersionCode = info.versionCode;
}
checkUpdate(packageName, String.valueOf(appVersionCode));
} else {
checkUpdate(packageName, "0");
}
}
public Observable<BaseResponse<AppInfo>> getUpdateObservable(String packageName) {
return NetInterfaceManager.getInstance()
.getNewestAppUpdateControl()
.getAppUpdate(packageName, "0", JGYUtils.getInstance().checkAppPlatform())
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread());
}
public void checkUpdate(String packageName, String versionCode) {
Log.e("checkUpdate", "packageName: " + packageName);
NetInterfaceManager.getInstance()
.getNewestAppUpdateControl()
.getAppUpdate(packageName, versionCode, JGYUtils.getInstance().checkAppPlatform())
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<BaseResponse<AppInfo>>() {
@Override
public void onSubscribe(@NonNull Disposable d) {
Log.e("checkUpdate", "onSubscribe: ");
}
@Override
public void onNext(@NonNull BaseResponse<AppInfo> appInfoBaseResponse) {
Log.e("checkUpdate", "onNext: " + appInfoBaseResponse);
int code = appInfoBaseResponse.code;
if (code == 200) {
AppInfo appInfo = appInfoBaseResponse.data;
if (appInfo != null) {
JSONObject jsonObject = (JSONObject) JSON.toJSON(appInfo);
FileUtils.ariaDownload(mContext, appInfo.getApp_url(), jsonObject);
}
Log.e("checkUpdate", "update now");
} else {
Log.e("checkUpdate", "not found update");
}
}
@Override
public void onError(@NonNull Throwable e) {
Log.e("checkUpdate", "onError: " + e.getMessage());
}
@Override
public void onComplete() {
Log.e("checkUpdate", "onComplete: ");
}
});
}
public void checkSelfUpdate() {
String packageName = BuildConfig.APPLICATION_ID;
String versionCode = String.valueOf(BuildConfig.VERSION_CODE);
checkUpdate(packageName, versionCode);
}
private static final long ONE_MINUTE = 60 * 1000;
private static final long HALF_HOUR = ONE_MINUTE * 30;
private static final long ONE_HOUR = HALF_HOUR * 2;
public void checkAllAppUpdate() {
long lastCheckAllUpdateTime = mMMKV.decodeLong(CommonConfig.LAST_CHECK_ALL_UPDATE_TIME, 0);
if (System.currentTimeMillis() - lastCheckAllUpdateTime < ONE_HOUR) {
Log.e(TAG, "checkAllAppUpdate: " + lastCheckAllUpdateTime);
String jsonString = mMMKV.decodeString(CommonConfig.ALL_APP_UPDATE, "");
getAllAppUpdate(jsonString);
return;
}
Observable.zip(getUpdateObservable(JGYUtils.PACKAGE_APPSTORE),
getUpdateObservable(JGYUtils.PACKAGE_OS),
getUpdateObservable(JGYUtils.PACKAGE_BROWSER),
new Function3<BaseResponse<AppInfo>, BaseResponse<AppInfo>, BaseResponse<AppInfo>, List<AppInfo>>() {
@Override
public List<AppInfo> apply(BaseResponse<AppInfo> appInfoBaseResponse, BaseResponse<AppInfo> appInfoBaseResponse2, BaseResponse<AppInfo> appInfoBaseResponse3) throws Throwable {
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);
}
return appInfoList;
}
})
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<List<AppInfo>>() {
@Override
public void onSubscribe(@NonNull Disposable d) {
Log.e("checkAllAppUpdate", "onSubscribe: ");
}
@Override
public void onNext(@NonNull List<AppInfo> appInfos) {
mMMKV.encode(CommonConfig.LAST_CHECK_ALL_UPDATE_TIME, System.currentTimeMillis());
getAllAppUpdate(appInfos);
String jsonString = JSON.toJSONString(appInfos);
mMMKV.encode(CommonConfig.ALL_APP_UPDATE, jsonString);
Log.e("checkAllAppUpdate", "onNext: " + jsonString);
}
@Override
public void onError(@NonNull Throwable e) {
Log.e("checkAllAppUpdate", "onError: " + e.getMessage());
}
@Override
public void onComplete() {
Log.e("checkAllAppUpdate", "onComplete: ");
}
});
}
public void getAllAppUpdate(String jsonString) {
if (TextUtils.isEmpty(jsonString)) {
return;
}
Gson gson = new Gson();
Type listType = new TypeToken<List<AppInfo>>() {
}.getType();
List<AppInfo> appInfoList = gson.fromJson(jsonString, listType);
getAllAppUpdate(appInfoList);
}
public void getAllAppUpdate(List<AppInfo> appInfos) {
if (appInfos == null || appInfos.size() == 0) {
return;
}
HashMap<String, AppInfo> appInfoHashMap = new HashMap<>();
for (AppInfo appInfo : appInfos) {
appInfoHashMap.put(appInfo.getApp_package(), appInfo);
}
PackageManager pm = mContext.getPackageManager();
for (Map.Entry<String, AppInfo> entry : appInfoHashMap.entrySet()) {
PackageInfo packageInfo = null;
try {
packageInfo = pm.getPackageInfo(entry.getKey(), 0);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
if (entry.getValue() != null) {
if (packageInfo == null) {
//未安装
FileUtils.ariaDownload(mContext, entry.getValue().getApp_url(), (JSONObject) JSON.toJSON(entry.getValue()));
} else {
long appVersionCode;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
appVersionCode = packageInfo.getLongVersionCode();
} else {
appVersionCode = packageInfo.versionCode;
}
long versionCode = entry.getValue().getApp_version_code();
//版本升级
if (appVersionCode < versionCode) {
FileUtils.ariaDownload(mContext, entry.getValue().getApp_url(), (JSONObject) JSON.toJSON(entry.getValue()));
}
}
}
}
}
}

View File

@@ -91,30 +91,28 @@ public class APKinstallReceiver extends BroadcastReceiver {
.subscribe(new Observer<String>() {
@Override
public void onSubscribe(Disposable d) {
Log.e("sendAppInfo", "onSubscribe: ");
}
@Override
public void onNext(String s) {
Log.e("sendAppInfo", "onNext: " + s);
int isLogined = (int) SPUtils.get(mContext, CommonConfig.isLogined, 2);
if (isLogined == 2) return;
NetInterfaceManager.getInstance().SendAppInstallInfo();
HTTPInterface.getForceInstall(mContext);
HTTPInterface.getAllappPackage(mContext);
HTTPInterface.getAppInside(mContext);
HTTPInterface.checkUpdate(mContext, JGYUtils.PACKAGE_APPSTORE);
HTTPInterface.checkUpdate(mContext, JGYUtils.PACKAGE_BROWSER);
HTTPInterface.checkUpdate(mContext, JGYUtils.PACKAGE_OS);
}
@Override
public void onError(Throwable e) {
Log.e("sendAppInfo", "onError: " + e.getMessage());
}
@Override
public void onComplete() {
Log.e(TAG, "onComplete: ");
Log.e("sendAppInfo", "onComplete: ");
}
});
}

View File

@@ -412,7 +412,7 @@ public class MyJPushReceiver extends BroadcastReceiver {
case JIGUANG_APP_GALLERY:
case JIGUANG_APP_MUSIC:
ToastUtil.debugShow("收到推送消息: 系统APP管控");
hideDesktopIcon(context);
hideDesktopIcon();
break;
case JIGUANG_SEARCH_TOPIC:
ToastUtil.debugShow("收到推送消息: 搜题开关");
@@ -433,7 +433,7 @@ public class MyJPushReceiver extends BroadcastReceiver {
case JIGUANG_APP_BROWSER:
ToastUtil.debugShow("收到推送消息: 系统APP管控");
Log.e(TAG, "processCustomMessage: " + extras);
hideDesktopIcon(context);
hideDesktopIcon();
break;
case JIGUANG_BIND_UNBIND:
ToastUtil.debugShow("老师授权/取消授权");
@@ -868,7 +868,7 @@ public class MyJPushReceiver extends BroadcastReceiver {
}
private void setPhone(Context context, String jsonString) {
HTTPInterface.getSystemSettings(context);
HTTPInterface.getSystemSettings();
}
@SuppressLint("NewApi")
@@ -1107,8 +1107,8 @@ public class MyJPushReceiver extends BroadcastReceiver {
}
}
private void hideDesktopIcon(Context context) {
HTTPInterface.getSystemSettings(context);
private void hideDesktopIcon() {
HTTPInterface.getSystemSettings();
}
private void searchTopic(Context context, String jsonString) {

View File

@@ -29,7 +29,7 @@ import java.io.File;
// 下载管理服务
public class DownloadService extends Service {
private static final String TAG = DownloadService.class.getSimpleName();
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
@@ -150,7 +150,12 @@ public class DownloadService extends Service {
Aria.download(this).resumeAllTask();
final String filepath = task.getFilePath();
final String packageName = task.getExtendField();
Log.e("aria", "taskFail: " + packageName + "filepath " + filepath + "Exception: " + e.getMessage());
try {
Log.e(TAG, "taskFail: " + "Exception: " + e.getMessage());
} catch (Exception ex) {
}
Log.e(TAG, "taskFail: " + packageName + "filepath " + filepath);
// Aria.download(this)
// .load(task.getDownloadEntity().getRealUrl()) //读取下载地址

View File

@@ -39,6 +39,7 @@ import com.uiui.sn.rlog.LogDBManager;
import com.uiui.sn.service.DownloadService;
import com.uiui.sn.service.GuardService;
import com.uiui.sn.service.StepService;
import com.uiui.sn.utils.ApkUtils;
import com.uiui.sn.utils.CacheUtils;
import com.uiui.sn.utils.SPUtils;
import com.uiui.sn.utils.TimeUtils;
@@ -106,7 +107,7 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
start.onstar(WiFiAlias);
}
}
NetInterfaceManager.getInstance().checkAllAppUpdate();
TimeTask task = new TimeTask();
task.execute("ntp.aliyun.com");
}
@@ -304,6 +305,9 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
TimeTask task = new TimeTask();
task.execute("ntp.aliyun.com");
ApkUtils.UninstallAPP(this, "com.joytv.live");
ApkUtils.UninstallAPP(this, "com.tencent.android.qqdownloader");
try {
getPackageManager().setApplicationEnabledSetting("com.android.email", PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 0);
} catch (Exception e) {
@@ -347,6 +351,7 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Log.e(TAG, "onStartCommand: " + System.currentTimeMillis());
NetInterfaceManager.getInstance().checkAllAppUpdate();
return START_STICKY;
}

View File

@@ -547,7 +547,7 @@ public class MessageReceiver extends XGPushBaseReceiver {
break;
case JIGUANG_PHONE:
ToastUtil.debugShow("收到推送消息: 电话管控");
setPhone(context, extras);
setPhone(extras);
break;
case JIGUANG_DISABLE_UPDATAE:
ToastUtil.debugShow("收到推送消息: 禁止升级");
@@ -647,7 +647,7 @@ public class MessageReceiver extends XGPushBaseReceiver {
case JIGUANG_APP_GALLERY:
case JIGUANG_APP_MUSIC:
ToastUtil.debugShow("收到推送消息: 系统APP管控");
hideDesktopIcon(context);
hideDesktopIcon();
break;
case JIGUANG_SEARCH_TOPIC:
ToastUtil.debugShow("收到推送消息: 搜题开关");
@@ -655,7 +655,7 @@ public class MessageReceiver extends XGPushBaseReceiver {
break;
case JIGUANG_PHONE_LIST:
ToastUtil.debugShow("收到推送消息: 电话白名单管控");
setPhone(context, extras);
setPhone(extras);
break;
case JIGUANG_CHANGE_COMBO:
ToastUtil.debugShow("更换套餐");
@@ -668,7 +668,7 @@ public class MessageReceiver extends XGPushBaseReceiver {
case JIGUANG_APP_BROWSER:
ToastUtil.debugShow("收到推送消息: 系统APP管控");
Log.e(TAG, "processCustomMessage: " + extras);
hideDesktopIcon(context);
hideDesktopIcon();
break;
case JIGUANG_BIND_UNBIND:
ToastUtil.debugShow("老师授权/取消授权");
@@ -1104,8 +1104,8 @@ public class MessageReceiver extends XGPushBaseReceiver {
context.sendBroadcast(cameraIntent);
}
private void setPhone(Context context, String jsonString) {
HTTPInterface.getSystemSettings(context);
private void setPhone(String jsonString) {
HTTPInterface.getSystemSettings();
}
@SuppressLint("NewApi")
@@ -1113,7 +1113,7 @@ public class MessageReceiver extends XGPushBaseReceiver {
JSONObject jsonObject = JSON.parseObject(jsonString);
String is_upgrade = jsonObject.getString("is_upgrade");
String packageName = jsonObject.getString("package");
String nowApplist = JGYUtils.getString(context.getContentResolver(), CommonConfig.QCH_APP_FORBID);
String nowApplist = JGYUtils.getString(context.getContentResolver(), CommonConfig.QCH_APP_FORBID);
List<String> applist = new ArrayList<>(Arrays.asList(nowApplist.split(",")));
if ("0".equals(is_upgrade)) {
if (applist.contains(packageName)) {
@@ -1126,8 +1126,8 @@ public class MessageReceiver extends XGPushBaseReceiver {
applist.add(packageName);
}
}
JGYUtils.putString(context.getContentResolver(), CommonConfig.QCH_APP_FORBID, String.join(",", applist));
Log.e("setAppUpdate", JGYUtils.getString(context.getContentResolver(), CommonConfig.QCH_APP_FORBID));
JGYUtils.putString(context.getContentResolver(), CommonConfig.QCH_APP_FORBID, String.join(",", applist));
Log.e("setAppUpdate", JGYUtils.getString(context.getContentResolver(), CommonConfig.QCH_APP_FORBID));
}
private void setLock_screen(Context context, String jsonString) {
@@ -1344,8 +1344,8 @@ public class MessageReceiver extends XGPushBaseReceiver {
}
}
private void hideDesktopIcon(Context context) {
HTTPInterface.getSystemSettings(context);
private void hideDesktopIcon() {
HTTPInterface.getSystemSettings();
}
private void searchTopic(Context context, String jsonString) {

View File

@@ -51,6 +51,14 @@ import java.util.function.Predicate;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
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;
public class ApkUtils {
private static String TAG = ApkUtils.class.getSimpleName();
@@ -510,6 +518,50 @@ public class ApkUtils {
return sessionId;
}
/**
* 静默卸载应用
*
* @param context
* @param pkg
*/
public static void UninstallAPP(Context context, String pkg) {
Observable.create(new ObservableOnSubscribe<String>() {
@Override
public void subscribe(ObservableEmitter<String> emitter) throws Exception {
Log.e("UninstallAPP", "call " + Thread.currentThread().getName());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
ApkUtils.uninstall(context, pkg);
} else {
ApkUtils.deleteApkInSilence(pkg);
}
emitter.onNext(pkg);
}
}).subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<String>() {
@Override
public void onSubscribe(Disposable d) {
Log.e("UninstallAPP", "onSubscribe: ");
}
@Override
public void onNext(String s) {
Log.e("UninstallAPP", "onNext " + Thread.currentThread().getName());
Log.e("UninstallAPP", "onNext: " + s);
}
@Override
public void onError(Throwable e) {
Log.e("UninstallAPP", "onError: " + e.getMessage());
}
@Override
public void onComplete() {
Log.e("UninstallAPP", "onComplete: ");
}
});
}
public static void uninstallApp(Context context, String packageName) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
uninstall(context, packageName);