update:2021.01.23
fix:用户信息缓存,更换ui,更换公司名称
add:
This commit is contained in:
2021-01-23 13:52:47 +08:00
parent 85505851ab
commit ea2c9676b4
19 changed files with 367 additions and 146 deletions

View File

@@ -24,6 +24,10 @@ import android.util.Log;
import android.view.View;
import android.widget.Toast;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.arialyy.aria.core.Aria;
import com.arialyy.aria.core.download.DownloadEntity;
import com.google.gson.Gson;
import com.mjsheng.myappstore.BuildConfig;
import com.mjsheng.myappstore.R;
@@ -32,6 +36,8 @@ import com.mjsheng.myappstore.network.Network;
import com.mjsheng.myappstore.network.api.UploadAppInfoApi;
import com.mjsheng.myappstore.server.InitJpushServer;
import org.w3c.dom.Text;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.File;
@@ -48,6 +54,8 @@ import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import io.reactivex.ObservableEmitter;
import io.reactivex.ObservableOnSubscribe;
import io.reactivex.disposables.Disposable;
import okhttp3.ResponseBody;
import rx.Observable;
@@ -633,6 +641,9 @@ public class ApkUtils {
this.add("com.android.fmradio");//FM电台
this.add("com.android.dialer");//电话
this.add("com.android.contacts");//通讯录
//根据需求内置
this.add("com.easyclient.activity");//移动课堂
this.add("com.jiandan.mobilelesson");//简单课堂
}};
@@ -653,12 +664,13 @@ public class ApkUtils {
//10.0上日历和电子邮件是可卸载的
//7.0是系统应用
if (show_canremove_systemapp.contains(packageInfo.packageName)) {
Log.e("showAllAPP2", "packageName:" + packageInfo.packageName);
Logger.e("showAllAPP2", "packageName:" + packageInfo.packageName);
pm.setApplicationEnabledSetting(packageInfo.packageName, PackageManager.COMPONENT_ENABLED_STATE_DEFAULT, 0);
}
}
} else {
Log.e("showAllAPP", "packageName:" + packageInfo.packageName);
Logger.e("showAllAPP", "packageName:" + packageInfo.packageName);
pm.setApplicationEnabledSetting(packageInfo.packageName, PackageManager.COMPONENT_ENABLED_STATE_DEFAULT, 0);
hideSystemSettingAPP(context, packageInfo.packageName);
}
}
@@ -676,35 +688,35 @@ public class ApkUtils {
}
} else if (pkage.equalsIgnoreCase("com.android.deskclock")) {
if (Settings.System.getInt(context.getContentResolver(), "qch_app_deskclock") == 1) {
hide = 1;
hide = 0;
}
} else if (pkage.equalsIgnoreCase("com.android.soundrecorder")) {
if (Settings.System.getInt(context.getContentResolver(), "qch_app_soundrecorder") == 1) {
hide = 1;
hide = 0;
}
} else if (pkage.equalsIgnoreCase("com.android.music")) {
if (Settings.System.getInt(context.getContentResolver(), "qch_app_music") == 1) {
hide = 1;
hide = 0;
}
} else if (pkage.equalsIgnoreCase("com.android.gallery3d")) {
if (Settings.System.getInt(context.getContentResolver(), "qch_app_gallery") == 1) {
hide = 1;
hide = 0;
}
} else if (pkage.equalsIgnoreCase("com.android.documentsui")
|| pkage.equalsIgnoreCase("com.mediatek.filemanager")) {
if (Settings.System.getInt(context.getContentResolver(), "qch_app_filemanager") == 1) {
hide = 1;
hide = 0;
}
}
} catch (Settings.SettingNotFoundException e) {
e.printStackTrace();
}
PackageManager pm = context.getPackageManager();
if (hide == 0) {
pm.setApplicationEnabledSetting(pkage, PackageManager.COMPONENT_ENABLED_STATE_DEFAULT, 0);
} else {
pm.setApplicationEnabledSetting(pkage, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 0);
}
// PackageManager pm = context.getPackageManager();
// if (hide == 0) {
// pm.setApplicationEnabledSetting(pkage, PackageManager.COMPONENT_ENABLED_STATE_DEFAULT, 0);
// } else {
// pm.setApplicationEnabledSetting(pkage, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 0);
// }
}
@@ -826,13 +838,14 @@ public class ApkUtils {
boolean qch_force_app = Settings.System.putString(context.getContentResolver(), "qch_launcher_icon_app", installedList);
// String old = Settings.System.getString(context.getContentResolver(), "qch_launcher_icon_app");
// Log.e("addShortcut", old);
Log.e("addShortcut", "installedList:" + installedList);
Log.e("addShortcut", "putstring:" + qch_force_app);
}
public static void getAppInfo(Context context) {
ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
List<ActivityManager.RunningServiceInfo> infoList = activityManager.getRunningServices(Integer.MAX_VALUE);
for (ActivityManager.RunningServiceInfo info:infoList){
for (ActivityManager.RunningServiceInfo info : infoList) {
// Log.e("fht", "getAppInfo1: "+info.process);
// Log.e("fht", "getAppInfo2: "+info.service.getPackageName());
// Log.e("fht", "getAppInfo3: "+info.service.getClassName());
@@ -843,8 +856,8 @@ public class ApkUtils {
for (int i = 0; i < packages.size(); i++) {
PackageInfo packageInfo = packages.get(i);
if (ApkUtils.systemapp.contains(packageInfo.packageName)
||ApkUtils.show_canremove_systemapp.contains(packageInfo.packageName)
||ApkUtils.canremove_systemapp.contains(packageInfo.packageName)
|| ApkUtils.show_canremove_systemapp.contains(packageInfo.packageName)
|| ApkUtils.canremove_systemapp.contains(packageInfo.packageName)
) {
continue;
}
@@ -858,13 +871,14 @@ public class ApkUtils {
uploadAppInfo.setInstall_time(firstInstallTime);
uploadAppInfo.setVersionCode(String.valueOf(packageInfo.versionCode));
uploadAppInfo.setState(0);
uploadAppInfo.setVersionName(packageInfo.versionName);
if ((packageInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 1) {
} else {
for (ActivityManager.RunningServiceInfo info:infoList){
if (info.process.contains(packageInfo.packageName)){
for (ActivityManager.RunningServiceInfo info : infoList) {
if (info.process.contains(packageInfo.packageName)) {
uploadAppInfo.setState(1);
Log.e("fht", "getAppInfo running: "+packageInfo.packageName);
Log.e("fht", "getAppInfo running: " + packageInfo.packageName);
}
}
appList.add(uploadAppInfo);
@@ -910,5 +924,54 @@ public class ApkUtils {
});
}
public static void RemoveTask(final Context context, final String packageName) {
if (TextUtils.isEmpty(packageName)) {
return;
}
io.reactivex.Observable.create(new ObservableOnSubscribe<String>() {
@Override
public void subscribe(ObservableEmitter<String> e) throws Exception {
List<DownloadEntity> list = Aria.download(context).getTaskList();
for (DownloadEntity entity : list) {
long id = entity.getId();
String extendField = Aria.download(this).load(id).getExtendField();
JSONObject jsonObject = JSON.parseObject(extendField);
if (packageName.equals(jsonObject.getString("app_package"))) {
Log.e("RemoveTask", "subscribe: " + "删除文件:" + entity.getFilePath());
Aria.download(this).load(id).cancel(true);
}
}
e.onComplete();
}
}).subscribeOn(io.reactivex.schedulers.Schedulers.io())
.observeOn(io.reactivex.android.schedulers.AndroidSchedulers.mainThread())
.subscribe(new io.reactivex.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: ");
}
@Override
public void onComplete() {
Log.e("RemoveTask", "onComplete: ");
}
});
}
}

View File

@@ -2,6 +2,8 @@ package com.mjsheng.myappstore.utils;
import android.util.Log;
import com.mjsheng.myappstore.BuildConfig;
/**
* Created by efan on 2017/4/13.
*/
@@ -9,7 +11,7 @@ import android.util.Log;
public class Logger {
//设为false关闭日志
private static final boolean LOG_ENABLE = true;
private static final boolean LOG_ENABLE = BuildConfig.LOG_DEBUG;
public static void i(String tag, String msg){
if (LOG_ENABLE){

View File

@@ -5,6 +5,7 @@ import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.provider.Settings;
import android.text.TextUtils;
import android.util.Log;
import com.alibaba.fastjson.JSON;
@@ -41,7 +42,8 @@ public class SysSettingUtils {
setCamera(mContext, jsonObject);
setTF(mContext, jsonObject);
setIcon(mContext, jsonObject);
setCanReset(mContext, jsonObject);
setAutoTime(mContext, jsonObject);
//otg开关
// int setting_otg = changeNum(jsonObject.getInteger("setting_otg"));
// Log.e("SystemSetting", "setting_otg---------" + setting_otg);
@@ -58,31 +60,46 @@ public class SysSettingUtils {
// sendBroadcast(otgIntent);
}
public static void setDefaultSetting(Context mContext) {
setPhoneList(mContext);
setUSBstate(mContext);
setBluetooth(mContext);
setHotspot(mContext);
setBar(mContext);
setCamera(mContext);
setTF(mContext);
setIcon(mContext);
public static void setDisableSetting(Context mContext) {
setPhoneList(mContext,1);
setUSBstate(mContext,1);
setBluetooth(mContext,1);
setHotspot(mContext,1);
setBar(mContext,1);
setCamera(mContext,1);
setTF(mContext,1);
setIcon(mContext,1);
setCanReset(mContext,1);
setAutoTime(mContext,1);
}
private static void setPhoneList(Context mContext) {
public static void setEnableSetting(Context mContext) {
setPhoneList(mContext,0);
setUSBstate(mContext,0);
setBluetooth(mContext,0);
setHotspot(mContext,0);
setBar(mContext,0);
setCamera(mContext,0);
setTF(mContext,0);
setIcon(mContext,0);
setCanReset(mContext,0);
setAutoTime(mContext,0);
}
private static void setPhoneList(Context mContext,int state) {
try {
//设置电话功能,电话白名单
boolean qch_call_forbid = Settings.System.putInt(mContext.getContentResolver(), "qch_call_forbid", 1);
boolean qch_call_forbid = Settings.System.putInt(mContext.getContentResolver(), "qch_call_forbid", state);
Log.e("SystemSetting", "qch_call_forbid:" + qch_call_forbid);
boolean qch_white_list_on = Settings.System.putInt(mContext.getContentResolver(), "qch_white_list_on", 1);
boolean qch_white_list_on = Settings.System.putInt(mContext.getContentResolver(), "qch_white_list_on", state);
Log.e("SystemSetting", "qch_white_list_on:" + qch_white_list_on);
boolean qch_white_list_Array = Settings.System.putString(mContext.getContentResolver(), "qch_white_list_Array", "");
// ToastTool.show("qch_call_forbid::"+setting_call+"----setting_phones::"+setting_phones+"----"+qch_white_list_Array+"---"+qch_call_forbid);
Log.e("SystemSetting", "qch_white_list_Array:" + qch_white_list_Array + "---" + qch_white_list_Array);
boolean qch_sdcard_forbid_on = Settings.System.putInt(mContext.getContentResolver(), "qch_sdcard_forbid_on", 1);
boolean qch_sdcard_forbid_on = Settings.System.putInt(mContext.getContentResolver(), "qch_sdcard_forbid_on", state);
Log.e("SystemSetting", "qch_sdcard_forbid_on:" + qch_sdcard_forbid_on);
} catch (Exception e) {
Log.e(TAG, "setPhoneList: " + e.getMessage());
@@ -113,7 +130,7 @@ public class SysSettingUtils {
}
}
private static void setUSBstate(Context mContext) {
private static void setUSBstate(Context mContext,int state) {
//USB数据功能管控
//仅充电usb_charge
//MTP模式usb_mtp
@@ -162,9 +179,9 @@ public class SysSettingUtils {
}
}
private static void setBluetooth(Context mContext) {
private static void setBluetooth(Context mContext,int state) {
try {
boolean qch_bht_forbid_on = Settings.System.putInt(mContext.getContentResolver(), "qch_bht_forbid_on", 1);
boolean qch_bht_forbid_on = Settings.System.putInt(mContext.getContentResolver(), "qch_bht_forbid_on", state);
//写入系统数据库
Log.e("SystemSetting", "qch_bht_forbid_on:" + qch_bht_forbid_on);
BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
@@ -176,7 +193,7 @@ public class SysSettingUtils {
}
//蓝牙总开关开启
Settings.System.putString(mContext.getContentResolver(), "qch_bhtvideo_forbid_on", "Empty");
Settings.System.putInt(mContext.getContentResolver(), "qch_bt_forbid_on", 1);
Settings.System.putInt(mContext.getContentResolver(), "qch_bt_forbid_on", state);
mBluetoothAdapter.disable();
//设置关闭时关闭蓝牙
}
@@ -228,13 +245,13 @@ public class SysSettingUtils {
}
}
private static void setHotspot(Context mContext) {
private static void setHotspot(Context mContext,int state) {
try {
Intent intent = new Intent();
intent.setAction("qch_hotspot_close");
intent.setPackage("com.android.settings");
mContext.sendStickyBroadcast(intent);
boolean qch_hotspot_forbid_on = Settings.System.putInt(mContext.getContentResolver(), "qch_hotspot_forbid_on", 1);//写入系统数据库
boolean qch_hotspot_forbid_on = Settings.System.putInt(mContext.getContentResolver(), "qch_hotspot_forbid_on", state);//写入系统数据库
Log.e("SystemSetting", "qch_hotspot_forbid_on:" + qch_hotspot_forbid_on);
} catch (Exception e) {
Log.e(TAG, "setHotspot: " + e.getMessage());
@@ -258,7 +275,7 @@ public class SysSettingUtils {
}
}
private static void setBar(Context mContext) {
private static void setBar(Context mContext,int state) {
//系统导航条显示开关
int setting_navigation = 0;
boolean qch_hide_navigationBar = Settings.System.putInt(mContext.getContentResolver(), "qch_hide_NavigationBar", setting_navigation);
@@ -338,13 +355,22 @@ public class SysSettingUtils {
}
}
private static void setCamera(Context mContext) {
private static void setCamera(Context mContext,int state) {
try {
//摄像头开关
boolean qch_app_camera = Settings.System.putInt(mContext.getContentResolver(), "qch_app_camera", 1);
boolean qch_app_camera = Settings.System.putInt(mContext.getContentResolver(), "qch_app_camera", state);
Log.e("SystemSetting", "qch_app_camera1:" + state);
// ApkUtils.hideSystemSettingAPP(mContext, "com.mediatek.camera");
Log.e("SystemSetting", "setting_camera---------" + qch_app_camera);
String cameraStatus = "qch_camera_forbid";
switch (state) {
case 0:
cameraStatus = "qch_camera_open";
break;
case 1:
cameraStatus = "qch_camera_forbid";
break;
}
Intent cameraIntent = new Intent(cameraStatus).setPackage("com.android.settings");
mContext.sendBroadcast(cameraIntent);
} catch (Exception e) {
@@ -357,6 +383,7 @@ public class SysSettingUtils {
//摄像头开关
int setting_camera = changeNum(jsonObject.getInteger("setting_camera"));
Settings.System.putInt(mContext.getContentResolver(), "qch_app_camera", setting_camera);
Log.e("SystemSetting", "qch_app_camera2:" + setting_camera);
// ApkUtils.hideSystemSettingAPP(mContext, "com.mediatek.camera");
Log.e("SystemSetting", "setting_camera---------" + setting_camera);
String cameraStatus = "";
@@ -375,14 +402,14 @@ public class SysSettingUtils {
}
}
private static void setTF(Context mContext) {
private static void setTF(Context mContext,int state) {
try {
//tfmedia开关
int setting_tfmedia = 1;
boolean qch_tfmedia_forbid = Settings.System.putInt(mContext.getContentResolver(), "qch_tfmedia_forbid", setting_tfmedia);
// int setting_tfmedia = 1;
boolean qch_tfmedia_forbid = Settings.System.putInt(mContext.getContentResolver(), "qch_tfmedia_forbid", state);
Log.e("SystemSetting", "setting_tfmedia---------" + qch_tfmedia_forbid);
String tfmediaStatus = "";
switch (setting_tfmedia) {
switch (state) {
case 0:
tfmediaStatus = "qch_tfmedia_open";
break;
@@ -392,7 +419,7 @@ public class SysSettingUtils {
}
Intent tfmediaIntent = new Intent(tfmediaStatus).setPackage("com.android.settings");
mContext.sendBroadcast(tfmediaIntent);
if (setting_tfmedia == 1) {
if (state == 1) {
boolean qch_tfmedia_filetypes = Settings.System.putString(mContext.getContentResolver(), "qch_tfmedia_filetypes", "Empty");//影音管控
Log.e("SystemSetting", "qch_tfmedia_filetypes:" + qch_tfmedia_filetypes);
} else {
@@ -425,63 +452,59 @@ public class SysSettingUtils {
JSONArray jSONArray = null;
jSONArray = jsonObject.getJSONArray("setting_tfmedia_format");
int i = 0;
StringBuffer stringBuffer = new StringBuffer();
while (!jSONArray.isEmpty()) {
for (int i = 0; i < jSONArray.size(); i++) {
stringBuffer.append(jSONArray.getString(i));
stringBuffer.append(",");
i++;
}
stringBuffer.deleteCharAt(stringBuffer.length() - 1);
Settings.System.putString(mContext.getContentResolver(), "qch_tfmedia_filetypes", stringBuffer.toString());//影音管控
Log.e("SystemSetting", "qch_tfmedia_filetypes---------" + stringBuffer.toString());
} else {
Settings.System.putInt(mContext.getContentResolver(), "qch_tfmedia_forbid", 0);
}
} catch (Exception e) {
Log.e(TAG, "setTF: " + e.getMessage());
Log.e("SystemSetting", "setTF: " + e.getMessage());
}
}
private static void setIcon(Context mContext) {
private static void setIcon(Context mContext,int state) {
try {
//added:2019.12.6
//设置5个app的开关
//时钟
int deskclock = 1;
Settings.System.putInt(mContext.getContentResolver(), "qch_app_deskclock", deskclock);
// int deskclock = 1;
Settings.System.putInt(mContext.getContentResolver(), "qch_app_deskclock", state);
ApkUtils.hideSystemSettingAPP(mContext, "com.android.deskclock");
Log.e("SystemSetting", "qch_app_deskclock" + deskclock);
Log.e("SystemSetting", "qch_app_deskclock" + state);
//录音机
int soundrecorder = 1;
Settings.System.putInt(mContext.getContentResolver(), "qch_app_soundrecorder", soundrecorder);
// int soundrecorder = 1;
Settings.System.putInt(mContext.getContentResolver(), "qch_app_soundrecorder", state);
ApkUtils.hideSystemSettingAPP(mContext, "com.android.soundrecorder");
Log.e("SystemSetting", "qch_app_soundrecorder" + soundrecorder);
Log.e("SystemSetting", "qch_app_soundrecorder" + state);
//音乐
int music = 1;
Settings.System.putInt(mContext.getContentResolver(), "qch_app_music", music);
// int music = 1;
Settings.System.putInt(mContext.getContentResolver(), "qch_app_music", state);
ApkUtils.hideSystemSettingAPP(mContext, "com.android.music");
Log.e("SystemSetting", "qch_app_music" + music);
Log.e("SystemSetting", "qch_app_music" + state);
//图库
int gallery = 1;
Settings.System.putInt(mContext.getContentResolver(), "qch_app_gallery", gallery);
// int gallery = 1;
Settings.System.putInt(mContext.getContentResolver(), "qch_app_gallery", state);
ApkUtils.hideSystemSettingAPP(mContext, "com.android.gallery3d");
Log.e("SystemSetting", "qch_app_gallery" + gallery);
Log.e("SystemSetting", "qch_app_gallery" + state);
//壁纸
int wallpaper = 1;
Settings.System.putInt(mContext.getContentResolver(), "qch_app_wallpaper", wallpaper);
Log.e("SystemSetting", "qch_app_wallpaper" + wallpaper);
// int wallpaper = 1;
Settings.System.putInt(mContext.getContentResolver(), "qch_app_wallpaper", state);
Log.e("SystemSetting", "qch_app_wallpaper" + state);
//文件管理器
int filemanager = 1;
Settings.System.putInt(mContext.getContentResolver(), "qch_app_filemanager", filemanager);
// int filemanager = 1;
Settings.System.putInt(mContext.getContentResolver(), "qch_app_filemanager", state);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
ApkUtils.hideSystemSettingAPP(mContext, "com.mediatek.filemanager");
} else {
ApkUtils.hideSystemSettingAPP(mContext, "com.android.documentsui");
}
Log.e("SystemSetting", "qch_app_filemanager" + filemanager);
Log.e("SystemSetting", "qch_app_filemanager" + state);
} catch (Exception e) {
Log.e(TAG, "setIcon: " + e.getMessage());
}
@@ -529,4 +552,76 @@ public class SysSettingUtils {
}
}
private static void setCanReset(Context mContext,int state) {
boolean qch_restore_forbid_on = Settings.System.putInt(mContext.getContentResolver(), "qch_restore_forbid_on", 0);
Log.e("SystemSetting", "qch_restore_forbid_on:" + qch_restore_forbid_on);
//默认打开
}
//qch_restore_forbid_on=1禁止恢复出厂设置
//qch_restore_forbid_on=0允许恢复出厂设置
private static void setCanReset(Context mContext, JSONObject jsonObject) {
int mode = jsonObject.getInteger("qch_restore");
if (mode == 1) {
boolean qch_restore_forbid_on = Settings.System.putInt(mContext.getContentResolver(), "qch_restore_forbid_on", 0);
Log.e("SystemSetting", "qch_restore_forbid_on:" + qch_restore_forbid_on);
} else {
boolean qch_restore_forbid_on = Settings.System.putInt(mContext.getContentResolver(), "qch_restore_forbid_on", 1);
Log.e("SystemSetting", "qch_restore_forbid_on:" + qch_restore_forbid_on);
}
}
//系统默认“使用网络提供时间”且不可点击
//后台设置“使用网络提供时间”:
//Intent intent32 = new Intent();
//intent32.setAction("qch_autotime_network");
//intent32.setPackage("com.android.settings");
//sendBroadcast(intent32);
//后台设置“使用GPS提供时间”
//Intent intent33 = new Intent();
//intent33.setAction("qch_autotime_gps");
//intent33.setPackage("com.android.settings");
//sendBroadcast(intent33);
//后台设置“关闭”(可以手动修改日期和时间)
//Intent intent34 = new Intent();
//intent34.setAction("qch_autotime_off");
//intent34.setPackage("com.android.settings");
//sendBroadcast(intent34);
private static void setAutoTime(Context mContext, JSONObject jsonObject) {
String autoTime = jsonObject.getString("setting_autotime");
String action = "qch_autotime_network";
if (TextUtils.isEmpty(autoTime)) {
action = "qch_autotime_network";
} else {
switch (autoTime) {
case "autotime_network":
action = "qch_autotime_network";
break;
case "autotime_gps":
action = "qch_autotime_gps";
break;
case "autotime_off":
action = "qch_autotime_off";
break;
default:
action = "qch_autotime_network";
break;
}
}
Log.e("SystemSetting", "setAutoTime: " + "action=" + action);
Intent intent = new Intent();
intent.setAction(action);
intent.setPackage("com.android.settings");
mContext.sendBroadcast(intent);
}
private static void setAutoTime(Context mContext,int state) {
Log.e("SystemSetting", "setAutoTime: " + "default");
Intent intent = new Intent();
intent.setAction("qch_autotime_network");
intent.setPackage("com.android.settings");
mContext.sendBroadcast(intent);
}
}