update:2020.06.03
fix:修复app禁止升级出现的问题 add:增加桌面图标隐藏功能
This commit is contained in:
@@ -15,8 +15,8 @@ android {
|
||||
minSdkVersion 20
|
||||
targetSdkVersion 29
|
||||
|
||||
versionCode 140
|
||||
versionName "2.9.7"//测试jiaoguanyi.cn
|
||||
versionCode 142
|
||||
versionName "2.9.9"//测试jiaoguanyi.cn
|
||||
// versionCode 128
|
||||
// versionName "2.0.0.8"// 正式jiaoguanyi.com 双数正式 单数测试
|
||||
multiDexEnabled true
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
<uses-permission android:name="android.permission.DELETE_PACKAGES" />
|
||||
<uses-permission android:name="android.permission.MASTER_CLEAR" />
|
||||
<uses-permission android:name="android.permission.REBOOT"/>
|
||||
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS"/>
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||
<uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK"/>
|
||||
|
||||
@@ -9,6 +9,7 @@ import android.content.res.Configuration;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.provider.Settings;
|
||||
import android.support.multidex.MultiDexApplication;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
@@ -16,6 +17,7 @@ import android.util.Log;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.arialyy.aria.core.Aria;
|
||||
import com.arialyy.aria.core.download.DownloadEntity;
|
||||
import com.blankj.utilcode.util.LogUtils;
|
||||
import com.blankj.utilcode.util.PathUtils;
|
||||
import com.lzy.okgo.OkGo;
|
||||
import com.lzy.okgo.cache.CacheEntity;
|
||||
@@ -31,7 +33,6 @@ import com.mjsheng.myappstore.jpush.TagAliasOperatorHelper;
|
||||
import com.mjsheng.myappstore.network.HTTPInterface;
|
||||
import com.mjsheng.myappstore.server.GuardService;
|
||||
import com.mjsheng.myappstore.server.InitJpushServer;
|
||||
import com.mjsheng.myappstore.server.MyDownloadService;
|
||||
import com.mjsheng.myappstore.utils.Configure;
|
||||
import com.mjsheng.myappstore.utils.MySQLData;
|
||||
import com.mjsheng.myappstore.utils.ToastUtil;
|
||||
@@ -528,7 +529,7 @@ public class MyApplication extends MultiDexApplication {
|
||||
}
|
||||
|
||||
synchronized public void getWhitePackageList() {
|
||||
OkGo.post(Configure.SEND_APP_USAGE)
|
||||
OkGo.post(Configure.SET_WHITE_PACKAGE_LIST)
|
||||
.params("sn", Utils.getSerial())
|
||||
.params("key", Configure.HTTP_KEY)
|
||||
.execute(new StringCallback() {
|
||||
@@ -541,13 +542,10 @@ public class MyApplication extends MultiDexApplication {
|
||||
if (code == 200) {
|
||||
com.alibaba.fastjson.JSONObject resultJson = JSON.parseObject(data);
|
||||
String result = resultJson.getString("result");
|
||||
if (!TextUtils.isEmpty(result)) {
|
||||
String[] list = result.split(",");
|
||||
List<String> allList = new ArrayList<>(Arrays.asList(list));
|
||||
setAPPUsage(allList);
|
||||
}
|
||||
writeAppPackageList(result);
|
||||
// setAPPUsage(allList);
|
||||
} else {
|
||||
setAPPUsage();
|
||||
// setAPPUsage();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -560,6 +558,25 @@ public class MyApplication extends MultiDexApplication {
|
||||
|
||||
}
|
||||
|
||||
private void writeAppPackageList(String result) {
|
||||
String appstore = "com.jiaoguanyi.appstore";
|
||||
String store = "com.jiaoguanyi.store";
|
||||
if (!TextUtils.isEmpty(result)) {
|
||||
LogUtils.e(result);
|
||||
if (!result.contains(appstore)) {
|
||||
result = result + "," + appstore;
|
||||
}
|
||||
if (!result.contains(store)) {
|
||||
result = result + "," + store;
|
||||
}
|
||||
Settings.System.putString(context.getContentResolver(), "qch_app_forbid", result);
|
||||
Log.e("mjsheng", "qch_app_forbid :"+result);
|
||||
} else {
|
||||
Log.e("mjsheng", "writeAppPackageList is null:");
|
||||
Settings.System.putString(context.getContentResolver(), "qch_app_forbid", appstore + "," + store);
|
||||
}
|
||||
}
|
||||
|
||||
private void catchException() {
|
||||
Thread.setDefaultUncaughtExceptionHandler(
|
||||
new Thread.UncaughtExceptionHandler() {
|
||||
@@ -690,7 +707,7 @@ public class MyApplication extends MultiDexApplication {
|
||||
} else {
|
||||
MyApplication.getInstance().setDownloadState(true);
|
||||
}
|
||||
Log.e("aria", "isDownloading=" + MyApplication.getInstance().isDownloading());
|
||||
Log.e("MyApplication", "isDownloading=" + MyApplication.getInstance().isDownloading());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -68,6 +68,7 @@ import com.mjsheng.myappstore.network.api.ForceDownloadApi;
|
||||
import com.mjsheng.myappstore.network.api.NetAndLaunchApi;
|
||||
import com.mjsheng.myappstore.network.api.SystemSettingApi;
|
||||
import com.mjsheng.myappstore.network.api.UploadAppInfoApi;
|
||||
import com.mjsheng.myappstore.server.InitJpushServer;
|
||||
import com.mjsheng.myappstore.server.MyDownloadService;
|
||||
import com.mjsheng.myappstore.utils.ApkUtils;
|
||||
import com.mjsheng.myappstore.utils.Configure;
|
||||
@@ -364,7 +365,7 @@ public class MainActivity extends AppCompatActivity implements NetStateChangeObs
|
||||
private void initData() {
|
||||
Log.e("mjhsneg", "gagagag--------------------------" + Utils.getSerial());
|
||||
getLockedState();
|
||||
MyApplication.getInstance().getWhitePackageList();
|
||||
// MyApplication.getInstance().getWhitePackageList();
|
||||
initJpush();//初始化极光推送
|
||||
HTTPInterface.setJpushTags(this);
|
||||
// update();//接口更新app
|
||||
@@ -533,7 +534,6 @@ public class MainActivity extends AppCompatActivity implements NetStateChangeObs
|
||||
String registrationID = JPushInterface.getRegistrationID(MainActivity.this);
|
||||
Log.e("mjsheng", registrationID + "------------------------");
|
||||
SaveListUtils.getList();
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -571,6 +571,10 @@ public class MainActivity extends AppCompatActivity implements NetStateChangeObs
|
||||
String url = jsonObject.getString("url");
|
||||
int versionCode = jsonObject.getInteger("version_code");
|
||||
String packageName = jsonObject.getString("package");
|
||||
String app_name = jsonObject.getString("app_name");
|
||||
com.alibaba.fastjson.JSONObject object = new com.alibaba.fastjson.JSONObject();
|
||||
object.put("app_name", app_name);
|
||||
object.put("app_package", packageName);
|
||||
PackageManager pm = getPackageManager();
|
||||
PackageInfo packageInfo = null;
|
||||
try {
|
||||
@@ -582,7 +586,7 @@ public class MainActivity extends AppCompatActivity implements NetStateChangeObs
|
||||
Aria.download(this)
|
||||
.load(url) //读取下载地址
|
||||
.setFilePath(PathUtils.getExternalDownloadsPath() + "/ygj/" + EncryptUtils.encryptMD5ToString(packageName) + ".apk", true)
|
||||
.setExtendField(packageName)
|
||||
.setExtendField(object.toJSONString())
|
||||
.create(); //启动下载}
|
||||
} else {
|
||||
Log.e("fht", "无需更新");
|
||||
@@ -623,7 +627,7 @@ public class MainActivity extends AppCompatActivity implements NetStateChangeObs
|
||||
sendBroadcast(allIntent);
|
||||
loadHeadImg(Configure.HTTP_TAG_HOME_PAGE_URL);
|
||||
getLockedState();
|
||||
MyApplication.getInstance().getWhitePackageList();
|
||||
// MyApplication.getInstance().getWhitePackageList();
|
||||
|
||||
}
|
||||
|
||||
@@ -918,7 +922,7 @@ public class MainActivity extends AppCompatActivity implements NetStateChangeObs
|
||||
result = result + "," + store;
|
||||
}
|
||||
boolean b = Settings.System.putString(getContentResolver(), "qch_app_forbid", result);
|
||||
Log.e("mjsheng", "writeAppPackageList is :" + b + Settings.System.getString(getContentResolver(), "qch_app_forbid"));
|
||||
Log.e("mjsheng", "qch_app_forbid is :" + b + Settings.System.getString(getContentResolver(), "qch_app_forbid"));
|
||||
|
||||
} else {
|
||||
Log.e("mjsheng", "writeAppPackageList is null:");
|
||||
@@ -987,7 +991,7 @@ public class MainActivity extends AppCompatActivity implements NetStateChangeObs
|
||||
if (version_code > AppUtils.getAppVersionCode()) {
|
||||
Aria.download(this)
|
||||
.load(url) //读取下载地址
|
||||
.setFilePath(PathUtils.getExternalDownloadsPath() + "/ygj/" + EncryptUtils.encryptMD5ToString(url) + ".apk")
|
||||
.setFilePath(PathUtils.getExternalDownloadsPath() + "/ygj/" + EncryptUtils.encryptMD5ToString(url) + ".apk", true)
|
||||
.setExtendField(BuildConfig.APPLICATION_ID)
|
||||
.create(); //启动下载}}
|
||||
}
|
||||
@@ -1143,7 +1147,6 @@ public class MainActivity extends AppCompatActivity implements NetStateChangeObs
|
||||
// }
|
||||
// }
|
||||
private void forceDownload(List<ForceDownloadData> data) {
|
||||
MyApplication.getInstance().setDownloadState(true);
|
||||
if (data == null || data.size() <= 0) {
|
||||
return;
|
||||
}
|
||||
@@ -1151,11 +1154,15 @@ public class MainActivity extends AppCompatActivity implements NetStateChangeObs
|
||||
List<String> list = new ArrayList<>();
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
ForceDownloadData forceDownloadData = data.get(i);
|
||||
String app_name = forceDownloadData.getApp_name();
|
||||
String app_package = forceDownloadData.getApp_package();
|
||||
String app_url = forceDownloadData.getApp_url();
|
||||
com.alibaba.fastjson.JSONObject jsonObject = new com.alibaba.fastjson.JSONObject();
|
||||
jsonObject.put("app_name", app_name);
|
||||
jsonObject.put("app_package", app_package);
|
||||
int app_version_code = forceDownloadData.getApp_version_code();
|
||||
Log.e("fht ", "packageName=" + app_package + ",URL= " + app_url + ",app_version_code=" + app_version_code);
|
||||
if (data.get(i).getApp_package().equals("com.jiaoguanyi.store")) {
|
||||
if (data.get(i).getApp_package().equals("com.jiaoguanyi.appstore")) {
|
||||
continue;//为自身的跳过下载
|
||||
}
|
||||
if (!list.contains(app_package)) {
|
||||
@@ -1181,7 +1188,7 @@ public class MainActivity extends AppCompatActivity implements NetStateChangeObs
|
||||
Aria.download(this)
|
||||
.load(app_url) //读取下载地址
|
||||
.setFilePath(PathUtils.getExternalDownloadsPath() + "/ygj/" + EncryptUtils.encryptMD5ToString(app_package) + ".apk", true)
|
||||
.setExtendField(app_package)
|
||||
.setExtendField(jsonObject.toJSONString())
|
||||
.create(); //启动下载}
|
||||
}
|
||||
} else {
|
||||
@@ -1190,7 +1197,7 @@ public class MainActivity extends AppCompatActivity implements NetStateChangeObs
|
||||
Aria.download(this)
|
||||
.load(app_url) //读取下载地址
|
||||
.setFilePath(PathUtils.getExternalDownloadsPath() + "/ygj/" + EncryptUtils.encryptMD5ToString(app_package) + ".apk", true)
|
||||
.setExtendField(app_package)
|
||||
.setExtendField(jsonObject.toJSONString())
|
||||
.create(); //启动下载}
|
||||
// SaveListUtils.addDownLoadList(app_package);
|
||||
// }
|
||||
@@ -1200,14 +1207,18 @@ public class MainActivity extends AppCompatActivity implements NetStateChangeObs
|
||||
SaveListUtils.sendForceAPP(this);
|
||||
}
|
||||
|
||||
|
||||
private void getSelfDownload(List<ForceDownloadData> forceDownloadDataList) {
|
||||
for (ForceDownloadData forceDownloadData : forceDownloadDataList) {
|
||||
if ("com.jiaoguanyi.store".equals(forceDownloadData.getApp_package())) {
|
||||
if (!AppUtils.isAppInstalled("com.jiaoguanyi.store")) {
|
||||
com.alibaba.fastjson.JSONObject jsonObject = new com.alibaba.fastjson.JSONObject();
|
||||
jsonObject.put("app_name", forceDownloadData.getApp_name());
|
||||
jsonObject.put("app_package", forceDownloadData.getApp_package());
|
||||
Aria.download(this)
|
||||
.load(forceDownloadData.getApp_url()) //读取下载地址
|
||||
.setFilePath(PathUtils.getExternalDownloadsPath() + "/ygj/" + EncryptUtils.encryptMD5ToString("com.jiaoguanyi.store") + ".apk", true)
|
||||
.setExtendField("com.jiaoguanyi.store")
|
||||
.setExtendField(jsonObject.toJSONString())
|
||||
.create(); //启动下载}
|
||||
}
|
||||
} else {
|
||||
@@ -1333,7 +1344,6 @@ public class MainActivity extends AppCompatActivity implements NetStateChangeObs
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void writeDeselectBrowserIDtoSystem(String ids) {
|
||||
if (!TextUtils.isEmpty(ids)) {
|
||||
boolean deselectBrowserArray = Settings.System.putString(getContentResolver(), "DeselectBrowserArray", ids);
|
||||
|
||||
@@ -12,6 +12,7 @@ import java.util.List;
|
||||
public class ForceDownloadData {
|
||||
|
||||
|
||||
private String app_name;
|
||||
private String app_package;
|
||||
private String app_url;
|
||||
private int app_version_code;
|
||||
@@ -40,6 +41,14 @@ public class ForceDownloadData {
|
||||
this.app_version_code = app_version_code;
|
||||
}
|
||||
|
||||
public String getApp_name() {
|
||||
return app_name;
|
||||
}
|
||||
|
||||
public void setApp_name(String app_name) {
|
||||
this.app_name = app_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ForceDownloadData{" +
|
||||
|
||||
@@ -15,6 +15,8 @@ public class NetAndLaunchData {
|
||||
private int is_auto;
|
||||
private int is_network;
|
||||
private int is_camera;
|
||||
private int is_slide;
|
||||
private int is_upgrade;
|
||||
|
||||
public int getIs_slide() {
|
||||
return is_slide;
|
||||
@@ -24,7 +26,6 @@ public class NetAndLaunchData {
|
||||
this.is_slide = is_slide;
|
||||
}
|
||||
|
||||
private int is_slide;
|
||||
|
||||
|
||||
public int getIs_upgrade() {
|
||||
@@ -35,7 +36,6 @@ public class NetAndLaunchData {
|
||||
this.is_upgrade = is_upgrade;
|
||||
}
|
||||
|
||||
private int is_upgrade;
|
||||
|
||||
public String getApp_package() {
|
||||
return app_package;
|
||||
@@ -75,6 +75,8 @@ public class NetAndLaunchData {
|
||||
"app_package='" + app_package + '\'' +
|
||||
", is_auto=" + is_auto +
|
||||
", is_network=" + is_network +
|
||||
", is_slide=" + is_slide +
|
||||
", is_upgrade=" + is_upgrade +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.mjsheng.myappstore.network;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.icu.text.SimpleDateFormat;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
@@ -9,6 +10,7 @@ import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.provider.Settings;
|
||||
import android.support.annotation.RequiresApi;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
|
||||
@@ -21,14 +23,18 @@ import com.lzy.okgo.OkGo;
|
||||
import com.lzy.okgo.callback.StringCallback;
|
||||
import com.mjsheng.myappstore.MyApplication;
|
||||
import com.mjsheng.myappstore.bean.Appground;
|
||||
import com.mjsheng.myappstore.bean.NetAndLaunchBean;
|
||||
import com.mjsheng.myappstore.bean.NetAndLaunchData;
|
||||
import com.mjsheng.myappstore.bean.UserInfo;
|
||||
import com.mjsheng.myappstore.jpush.TagAliasOperatorHelper;
|
||||
import com.mjsheng.myappstore.utils.ApkUtils;
|
||||
import com.mjsheng.myappstore.utils.Configure;
|
||||
import com.mjsheng.myappstore.utils.SPUtils;
|
||||
import com.mjsheng.myappstore.utils.ToastUtil;
|
||||
import com.mjsheng.myappstore.utils.Utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@@ -556,24 +562,18 @@ public class HTTPInterface {
|
||||
int code = jsonObject.getInteger("code");
|
||||
String msg = jsonObject.getString("msg");
|
||||
String data = jsonObject.getString("data");
|
||||
// 不判断code,根据写入数据库的值比较
|
||||
boolean write = false;
|
||||
if (data != null && !"".equals(data)) {
|
||||
String olddata = Settings.System.getString(context.getContentResolver(), "hide_desktop_icon");
|
||||
if (!olddata.equalsIgnoreCase(data)) {
|
||||
write = Settings.System.putString(context.getContentResolver(), "hide_desktop_icon", data);
|
||||
} else {
|
||||
Log.e("SystemSetting", "setHideDesktopIcon-equally");
|
||||
ApkUtils.showAllAPP(context);
|
||||
if (code == 200) {
|
||||
if (data != null && !"".equals(data)) {
|
||||
List<String> newList = Arrays.asList(data.split(","));//新的list
|
||||
PackageManager pm = context.getPackageManager();
|
||||
for (String pack : newList) {
|
||||
pm.setApplicationEnabledSetting(pack, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 0);
|
||||
}
|
||||
}
|
||||
Log.e("SystemSetting", "setHideDesktopIcon---------" + write + ":" + data);
|
||||
}
|
||||
if (write) {
|
||||
Utils.rebootDevices(context);
|
||||
Log.e("fht", "reboot");
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
} catch (Exception e) {
|
||||
Log.e("fht", "setHideDesktopIcon" + e.getMessage());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -582,7 +582,141 @@ public class HTTPInterface {
|
||||
super.onError(call, response, e);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
synchronized public static void getNetAndLaunchSetting(final Context context) {
|
||||
OkGo.post(Configure.NET_AND_LAUNCH_API)
|
||||
.params("key", Configure.HTTP_KEY)
|
||||
.params("sn", Utils.getSerial())
|
||||
.execute(new StringCallback() {
|
||||
@Override
|
||||
public void onSuccess(String s, Call call, Response response) {
|
||||
NetAndLaunchBean netAndLaunchBeanList = JSON.parseObject(s, NetAndLaunchBean.class);
|
||||
LogUtils.e(s);
|
||||
setNetAndlaunch(netAndLaunchBeanList, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Call call, Response response, Exception e) {
|
||||
super.onError(call, response, e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void setNetAndlaunch(NetAndLaunchBean netAndLaunchBean, Context context) {
|
||||
LogUtils.e("联网和自启管控:" + netAndLaunchBean.toString());
|
||||
String net_ok = "";
|
||||
String net_not = "";
|
||||
String launch = "";
|
||||
String camera_ok = "";
|
||||
String camera_not = "";
|
||||
String upgrade_ok = "";
|
||||
String upgrade_not = "";
|
||||
String slide_ok = "";
|
||||
String slide_not = "";
|
||||
|
||||
List<NetAndLaunchData> data = netAndLaunchBean.getData();
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
NetAndLaunchData netAndLaunchData = data.get(i);
|
||||
String app_package = netAndLaunchData.getApp_package();
|
||||
int is_auto = netAndLaunchData.getIs_auto();
|
||||
int is_network = netAndLaunchData.getIs_network();
|
||||
int is_camera = netAndLaunchData.getIs_camera();
|
||||
int is_upgrade = netAndLaunchData.getIs_upgrade();
|
||||
int is_slide = netAndLaunchData.getIs_slide();
|
||||
|
||||
|
||||
if (is_auto == 1) {
|
||||
launch += app_package + ",";
|
||||
}
|
||||
if (is_network == 1) {
|
||||
net_ok += app_package + ",";
|
||||
} else {
|
||||
net_not += app_package + ",";
|
||||
}
|
||||
|
||||
if (is_camera == 1) {
|
||||
camera_ok += app_package + ",";
|
||||
} else {
|
||||
camera_not += app_package + ",";
|
||||
}
|
||||
if (is_upgrade == 1) {
|
||||
upgrade_ok += app_package + ",";
|
||||
} else {
|
||||
upgrade_not += app_package + ",";
|
||||
}
|
||||
if (is_slide == 1) {
|
||||
slide_ok += app_package + ",";
|
||||
} else {
|
||||
slide_not += app_package + ",";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!TextUtils.isEmpty(launch)) {
|
||||
launch = launch.substring(0, launch.length() - 1);
|
||||
}
|
||||
if (!TextUtils.isEmpty(net_ok)) {
|
||||
net_ok = net_ok.substring(0, net_ok.length() - 1);
|
||||
}
|
||||
if (!TextUtils.isEmpty(net_not)) {
|
||||
net_not = net_not.substring(0, net_not.length() - 1);
|
||||
}
|
||||
if (!TextUtils.isEmpty(camera_ok)) {
|
||||
camera_ok = camera_ok.substring(0, camera_ok.length() - 1);
|
||||
}
|
||||
if (!TextUtils.isEmpty(camera_not)) {
|
||||
camera_not = camera_not.substring(0, camera_not.length() - 1);
|
||||
}
|
||||
if (!TextUtils.isEmpty(upgrade_ok)) {
|
||||
upgrade_ok = upgrade_ok.substring(0, upgrade_ok.length() - 1);
|
||||
}
|
||||
if (!TextUtils.isEmpty(upgrade_not)) {
|
||||
upgrade_not = upgrade_not.substring(0, upgrade_not.length() - 1);
|
||||
}
|
||||
if (!TextUtils.isEmpty(slide_ok)) {
|
||||
slide_ok = slide_ok.substring(0, slide_ok.length() - 1);
|
||||
}
|
||||
if (!TextUtils.isEmpty(slide_not)) {
|
||||
slide_not = slide_not.substring(0, slide_not.length() - 1);
|
||||
boolean writeSucceed = Settings.System.putString(context.getContentResolver(), "qch_disable_slide", slide_not);
|
||||
Log.e("fht", "qch_disable_slide=" + writeSucceed + ":" + slide_not);
|
||||
} else {
|
||||
boolean writeSucceed = Settings.System.putString(context.getContentResolver(), "qch_disable_slide", "Invalid");
|
||||
Log.e("fht", "qch_disable_slide ok=" + writeSucceed + ":" + slide_ok);
|
||||
}
|
||||
|
||||
Utils.writeDisableUpdateList(context, upgrade_not.split(","), upgrade_ok.split(","));
|
||||
|
||||
LogUtils.e("launch:" + launch + "-----------net_ok:" + net_ok + "-----------net_not:" + net_not);
|
||||
boolean qch_app_power_on = Settings.System.putString(context.getContentResolver(), "qch_app_power_on", launch);
|
||||
|
||||
// Intent netControlIntent = new Intent(CommonDatas.ACTION_HrReceiver_JGY_DIS);
|
||||
// netControlIntent.putExtra("package_name", net_not);
|
||||
// sendBroadcast(netControlIntent);
|
||||
//
|
||||
// Intent netControlNotIntent = new Intent(CommonDatas.ACTION_HrReceiver_JGY);
|
||||
// netControlNotIntent.putExtra("package_name", net_ok);
|
||||
// sendBroadcast(netControlNotIntent);
|
||||
if (!net_not.equals("")) {
|
||||
String[] bans = net_not.split(",");
|
||||
Settings.System.putString(context.getContentResolver(), "qch_jgy_network_disallow", net_not);
|
||||
Log.e("fht", "ban::" + net_not);
|
||||
|
||||
}
|
||||
MyApplication.getInstance().setFinished(true);
|
||||
if (!net_ok.equals("")) {
|
||||
String[] nots = net_ok.split(",");
|
||||
Log.e("fht", "not::" + net_ok);
|
||||
}
|
||||
|
||||
|
||||
Intent intent2 = new Intent("qch_camera_forbid");
|
||||
intent2.putExtra("camera_package_name", camera_not).setPackage("com.android.settings");
|
||||
context.sendBroadcast(intent2);
|
||||
Intent intent1 = new Intent("qch_camera_open");
|
||||
intent1.putExtra("camera_package_name", camera_ok).setPackage("com.android.settings");
|
||||
context.sendBroadcast(intent1);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -29,6 +29,7 @@ import com.mjsheng.myappstore.network.HTTPInterface;
|
||||
import com.mjsheng.myappstore.network.Network;
|
||||
import com.mjsheng.myappstore.server.InitJpushServer;
|
||||
import com.mjsheng.myappstore.utils.ApkUtils;
|
||||
import com.mjsheng.myappstore.utils.Configure;
|
||||
import com.mjsheng.myappstore.utils.MySQLData;
|
||||
import com.mjsheng.myappstore.utils.SaveListUtils;
|
||||
import com.mjsheng.myappstore.utils.ToastUtil;
|
||||
@@ -90,7 +91,7 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
||||
|
||||
private final String HIDE_DESKTOP_ICON = "18";//隐藏桌面图标
|
||||
|
||||
private final String DISABLE_APP_SLIDE = "19";//隐藏桌面图标
|
||||
private final String DISABLE_APP_SLIDE = "19";//禁止滑动
|
||||
|
||||
|
||||
private Context mContext;
|
||||
@@ -300,9 +301,13 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
||||
}
|
||||
try {
|
||||
JSONObject jSONObject = new JSONObject(s);
|
||||
String app_name = jSONObject.optString("app_name");
|
||||
String app_package = jSONObject.optString("app_package");
|
||||
String app_url = jSONObject.optString("app_url");
|
||||
int app_version_code = jSONObject.optInt("app_version_code");
|
||||
com.alibaba.fastjson.JSONObject packageObj = new com.alibaba.fastjson.JSONObject();
|
||||
packageObj.put("app_name", app_name);
|
||||
packageObj.put("app_package", app_package);
|
||||
Log.e("mymjsheng", "app_package::" + app_package);
|
||||
Log.e("mymjsheng", "app_url::" + app_url);
|
||||
SaveListUtils.addList(app_package);
|
||||
@@ -318,8 +323,8 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
||||
if (!SaveListUtils.isDownLoading(app_url)) {
|
||||
Aria.download(this)
|
||||
.load(app_url)
|
||||
.setFilePath(PathUtils.getExternalDownloadsPath() + "/ygj/" + EncryptUtils.encryptMD5ToString(s) + ".apk")
|
||||
.setExtendField(app_package)
|
||||
.setFilePath(PathUtils.getExternalDownloadsPath() + "/ygj/" + EncryptUtils.encryptMD5ToString(s) + ".apk", true)
|
||||
.setExtendField(packageObj.toJSONString())
|
||||
.create();
|
||||
}
|
||||
} else {
|
||||
@@ -333,8 +338,8 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
||||
if (!SaveListUtils.isDownLoading(app_url)) {
|
||||
Aria.download(this)
|
||||
.load(app_url)
|
||||
.setFilePath(PathUtils.getExternalDownloadsPath() + "/ygj/" + EncryptUtils.encryptMD5ToString(s) + ".apk")
|
||||
.setExtendField(app_package)
|
||||
.setFilePath(PathUtils.getExternalDownloadsPath() + "/ygj/" + EncryptUtils.encryptMD5ToString(s) + ".apk", true)
|
||||
.setExtendField(packageObj.toJSONString())
|
||||
.create();
|
||||
}
|
||||
}
|
||||
@@ -346,14 +351,17 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
||||
}
|
||||
|
||||
private void getAppLimitApi() {
|
||||
Network.getAppLimitApi().getAppLimitApi("YTM3YTAxNTJmMmZmNzkyM2E2YzIwZjlhZTc0NzNmMGI=", Utils.getSerial()).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer<ResponseBody>() {
|
||||
Network.getAppLimitApi().getAppLimitApi(Configure.HTTP_KEY, Utils.getSerial()).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer<ResponseBody>() {
|
||||
@Override
|
||||
public void onComplete() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable param1Throwable) {
|
||||
Log.e("mjsheng", "getAppLimitApi=onError:");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(ResponseBody param1ResponseBody) {
|
||||
try {
|
||||
String str1;
|
||||
@@ -375,6 +383,7 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable param1Disposable) {
|
||||
}
|
||||
});
|
||||
@@ -530,6 +539,8 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
||||
ApkUtils.deleteApkInSilence(title);
|
||||
}
|
||||
}
|
||||
getAppLimitApi();
|
||||
HTTPInterface.getNetAndLaunchSetting(mContext);
|
||||
break;
|
||||
case MSG_SETTING:
|
||||
if (!TextUtils.isEmpty(extras)) {
|
||||
@@ -557,6 +568,7 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
||||
// mContext.sendBroadcast(new Intent("android.intent.action.MASTER_CLEAR"));
|
||||
getAppLimitApi();
|
||||
doDownloadAndInstall(extras);
|
||||
HTTPInterface.setHideDesktopIcon(mContext);
|
||||
break;
|
||||
case MSG_LOCK:
|
||||
settingLock(extras);
|
||||
@@ -579,10 +591,13 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
||||
com.alibaba.fastjson.JSONObject URI = JSON.parseObject(extras);
|
||||
String versionCode = URI.getString("version_code");
|
||||
String url = URI.getString("url");
|
||||
com.alibaba.fastjson.JSONObject packageObj = new com.alibaba.fastjson.JSONObject();
|
||||
packageObj.put("app_name", "教管易");
|
||||
packageObj.put("app_package", "com.jiaoguanyi.store");
|
||||
Aria.download(this)
|
||||
.load(url) //读取下载地址
|
||||
.setFilePath(PathUtils.getExternalDownloadsPath() + "/ygj/" + EncryptUtils.encryptMD5ToString("com.jiaoguanyi.store") + ".apk", true)
|
||||
.setExtendField("com.jiaoguanyi.store")
|
||||
.setExtendField(packageObj.toJSONString())
|
||||
.create(); //启动下载}
|
||||
|
||||
break;
|
||||
@@ -767,6 +782,8 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
||||
result = result + "," + store;
|
||||
}
|
||||
Settings.System.putString(mContext.getContentResolver(), "qch_app_forbid", result);
|
||||
Log.e("mjsheng", "qch_app_forbid " + result);
|
||||
|
||||
} else {
|
||||
Log.e("mjsheng", "writeAppPackageList is null:");
|
||||
|
||||
@@ -840,7 +857,7 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
||||
}
|
||||
Settings.System.putString(this.mContext.getContentResolver(), "qch_app_forbid", result);
|
||||
Settings.System.putString(this.mContext.getContentResolver(), "DeselectViewArray", s1);
|
||||
Log.e("SystemSetting", "qch_app_forbid---------" + result);
|
||||
Log.e("qch_app_forbid", "qch_app_forbid---------" + result);
|
||||
Log.e("SystemSetting", "deselectViewArray---------" + s1);
|
||||
return;
|
||||
} else {
|
||||
|
||||
@@ -13,6 +13,7 @@ import com.lzy.okgo.callback.StringCallback;
|
||||
import com.mjsheng.myappstore.MyApplication;
|
||||
import com.mjsheng.myappstore.bean.AppData;
|
||||
import com.mjsheng.myappstore.bean.UploadAppInfo;
|
||||
import com.mjsheng.myappstore.network.HTTPInterface;
|
||||
import com.mjsheng.myappstore.network.Network;
|
||||
import com.mjsheng.myappstore.network.api.UploadAppInfoApi;
|
||||
import com.mjsheng.myappstore.utils.ApkUtils;
|
||||
@@ -94,6 +95,9 @@ public class NewAppReceiver extends BroadcastReceiver {
|
||||
context.sendBroadcast(intent1);
|
||||
getAppInfo(context);
|
||||
}
|
||||
// MyApplication.getInstance().getWhitePackageList();
|
||||
HTTPInterface.getNetAndLaunchSetting(context);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -18,6 +18,8 @@ import android.support.annotation.Nullable;
|
||||
import android.text.format.Formatter;
|
||||
import android.util.Log;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.arialyy.annotations.Download;
|
||||
import com.arialyy.aria.core.Aria;
|
||||
import com.arialyy.aria.core.download.DownloadEntity;
|
||||
@@ -89,15 +91,14 @@ public class GuardService extends Service implements NetStateChangeObserver {
|
||||
}
|
||||
|
||||
|
||||
|
||||
//在这里处理任务执行中的状态,如进度进度条的刷新
|
||||
@Download.onTaskRunning
|
||||
protected void running(DownloadTask task) {
|
||||
Log.e("aria", "正在下载=--------------::" + task.getState() + "-------" + task.getPercent() + "-------" + task.getExtendField());
|
||||
|
||||
|
||||
ToastUtil.show("正在下载:" + task.getExtendField() + "--" + task.getPercent() + "%" + "\t" + Formatter.formatFileSize(GuardService.this, task.getSpeed()) + "/s");
|
||||
|
||||
JSONObject jsonObject = JSON.parseObject(task.getExtendField());
|
||||
String app_name = jsonObject.getString("app_name");
|
||||
String app_package = jsonObject.getString("app_package");
|
||||
Log.e("aria", "正在下载---:" + task.getPercent() + ":" + task.getExtendField());
|
||||
ToastUtil.show("正在下载:" + app_name + "-" + task.getPercent() + "%" + "\t" + Formatter.formatFileSize(GuardService.this, task.getSpeed()) + "/s");
|
||||
}
|
||||
|
||||
@Download.onTaskComplete
|
||||
@@ -107,6 +108,10 @@ public class GuardService extends Service implements NetStateChangeObserver {
|
||||
final String packageName = task.getExtendField();
|
||||
Log.e("aria", "downloadPath::" + filepath);
|
||||
Log.e("aria", "extendField::" + packageName);
|
||||
JSONObject jsonObject = JSON.parseObject(task.getExtendField());
|
||||
String app_name = jsonObject.getString("app_name");
|
||||
String app_package = jsonObject.getString("app_package");
|
||||
ToastUtil.show(app_name + "\t:下载完成");
|
||||
// ApkUtils.installApp(filepath);
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
@@ -115,7 +120,7 @@ public class GuardService extends Service implements NetStateChangeObserver {
|
||||
}
|
||||
}).start();
|
||||
try {
|
||||
Aria.download(this).load(Aria.download(this).getFirstDownloadEntity(task.getDownloadUrl()).getId()).cancel();
|
||||
Aria.download(this).load(Aria.download(this).getFirstDownloadEntity(task.getKey()).getId()).cancel();
|
||||
} catch (Exception e) {
|
||||
Log.e("aria", e.getMessage());
|
||||
}
|
||||
@@ -131,8 +136,11 @@ public class GuardService extends Service implements NetStateChangeObserver {
|
||||
try {
|
||||
final String filepath = task.getFilePath();
|
||||
final String packageName = task.getExtendField();
|
||||
JSONObject jsonObject = JSON.parseObject(task.getExtendField());
|
||||
String app_name = jsonObject.getString("app_name");
|
||||
String app_package = jsonObject.getString("app_package");
|
||||
Log.e("aria", "下载失败:" + filepath);
|
||||
ToastUtil.show("下载失败:" + packageName);
|
||||
ToastUtil.show(app_name + "\t:下载失败");
|
||||
} catch (Exception e) {
|
||||
Log.e("fht", "taskFail");
|
||||
}
|
||||
|
||||
@@ -95,6 +95,8 @@ public class InitJpushServer extends Service {
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
// 初始化 JPush
|
||||
JPushInterface.init(this);
|
||||
getAppLimitApi();//获取可以写入的app包名
|
||||
HTTPInterface.getNetAndLaunchSetting(this);
|
||||
timerImitate();
|
||||
// getNetworkState();
|
||||
Log.e("InitJpushServer", "onStartCommand");
|
||||
@@ -320,6 +322,7 @@ public class InitJpushServer extends Service {
|
||||
result = result + "," + store;
|
||||
}
|
||||
Settings.System.putString(getContentResolver(), "qch_app_forbid", result);
|
||||
Log.e("mjsheng", "qch_app_forbid :"+result);
|
||||
} else {
|
||||
Log.e("mjsheng", "writeAppPackageList is null:");
|
||||
|
||||
@@ -416,8 +419,12 @@ public class InitJpushServer extends Service {
|
||||
List<String> list = new ArrayList<>();
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
ForceDownloadData forceDownloadData = data.get(i);
|
||||
String app_name = forceDownloadData.getApp_name();
|
||||
String app_package = forceDownloadData.getApp_package();
|
||||
String app_url = forceDownloadData.getApp_url();
|
||||
com.alibaba.fastjson.JSONObject jsonObject = new com.alibaba.fastjson.JSONObject();
|
||||
jsonObject.put("app_name", app_name);
|
||||
jsonObject.put("app_package", app_package);
|
||||
int app_version_code = forceDownloadData.getApp_version_code();
|
||||
Log.e("fht ", "packageName=" + app_package + ",URL= " + app_url + ",app_version_code=" + app_version_code);
|
||||
if (data.get(i).getApp_package().equals("com.jiaoguanyi.appstore")) {
|
||||
@@ -446,7 +453,7 @@ public class InitJpushServer extends Service {
|
||||
Aria.download(this)
|
||||
.load(app_url) //读取下载地址
|
||||
.setFilePath(PathUtils.getExternalDownloadsPath() + "/ygj/" + EncryptUtils.encryptMD5ToString(app_package) + ".apk", true)
|
||||
.setExtendField(app_package)
|
||||
.setExtendField(jsonObject.toJSONString())
|
||||
.create(); //启动下载}
|
||||
}
|
||||
} else {
|
||||
@@ -455,7 +462,7 @@ public class InitJpushServer extends Service {
|
||||
Aria.download(this)
|
||||
.load(app_url) //读取下载地址
|
||||
.setFilePath(PathUtils.getExternalDownloadsPath() + "/ygj/" + EncryptUtils.encryptMD5ToString(app_package) + ".apk", true)
|
||||
.setExtendField(app_package)
|
||||
.setExtendField(jsonObject.toJSONString())
|
||||
.create(); //启动下载}
|
||||
// SaveListUtils.addDownLoadList(app_package);
|
||||
// }
|
||||
@@ -468,10 +475,13 @@ public class InitJpushServer extends Service {
|
||||
private void getSelfDownload(List<ForceDownloadData> forceDownloadDataList) {
|
||||
for (ForceDownloadData forceDownloadData : forceDownloadDataList) {
|
||||
if ("com.jiaoguanyi.appstore".equals(forceDownloadData.getApp_package())) {
|
||||
com.alibaba.fastjson.JSONObject packageObj = new com.alibaba.fastjson.JSONObject();
|
||||
packageObj.put("app_name", forceDownloadData.getApp_name());
|
||||
packageObj.put("app_package",forceDownloadData.getApp_package());
|
||||
Aria.download(this)
|
||||
.load(forceDownloadData.getApp_url()) //读取下载地址
|
||||
.setFilePath(PathUtils.getExternalDownloadsPath() + "/ygj/" + EncryptUtils.encryptMD5ToString("com.jiaoguanyi.appstore") + ".apk")
|
||||
.setExtendField("com.mjsheng.myappstore")
|
||||
.setFilePath(PathUtils.getExternalDownloadsPath() + "/ygj/" + EncryptUtils.encryptMD5ToString("com.jiaoguanyi.appstore") + ".apk", true)
|
||||
.setExtendField(packageObj.toJSONString())
|
||||
.create(); //启动下载}
|
||||
} else {
|
||||
Log.e("fht", "未上传应用");
|
||||
@@ -732,7 +742,7 @@ public class InitJpushServer extends Service {
|
||||
// Settings.System.putString(getApplicationContext().getContentResolver(), "DeselectBrowserArray", "http://www.baidu.com");
|
||||
String ss = Settings.System.getString(getApplicationContext().getContentResolver(), "DeselectBrowserArray");
|
||||
Log.e("jpttlocked2", "DeselectBrowserArray---------" + ss);
|
||||
getAppLimitApi();//获取可以写入的app包名
|
||||
// getAppLimitApi();//获取可以写入的app包名
|
||||
getDeselectID();
|
||||
// getDeselectBrowerID();
|
||||
getNetAndLaunchSetting();
|
||||
@@ -744,7 +754,7 @@ public class InitJpushServer extends Service {
|
||||
HTTPInterface.setAppinsideWeb(InitJpushServer.this);//app内部网页管控
|
||||
HTTPInterface.setHomepagtag(InitJpushServer.this);//设置主页和标签
|
||||
HTTPInterface.setHideDesktopIcon(InitJpushServer.this);//设置桌面图标隐藏
|
||||
MyApplication.getInstance().getWhitePackageList();
|
||||
// MyApplication.getInstance().getWhitePackageList();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -996,6 +1006,10 @@ public class InitJpushServer extends Service {
|
||||
String url = jsonObject.getString("url");
|
||||
int versionCode = jsonObject.getInteger("version_code");
|
||||
String packageName = jsonObject.getString("package");
|
||||
String app_name = jsonObject.getString("app_name");
|
||||
com.alibaba.fastjson.JSONObject object = new com.alibaba.fastjson.JSONObject();
|
||||
object.put("app_name", app_name);
|
||||
object.put("app_package", packageName);
|
||||
PackageManager pm = getPackageManager();
|
||||
PackageInfo packageInfo = null;
|
||||
try {
|
||||
@@ -1007,7 +1021,7 @@ public class InitJpushServer extends Service {
|
||||
Aria.download(this)
|
||||
.load(url) //读取下载地址
|
||||
.setFilePath(PathUtils.getExternalDownloadsPath() + "/ygj/" + EncryptUtils.encryptMD5ToString(packageName) + ".apk", true)
|
||||
.setExtendField(packageName)
|
||||
.setExtendField(object.toJSONString())
|
||||
.create(); //启动下载}
|
||||
} else {
|
||||
Log.e("fht", "无需更新");
|
||||
|
||||
@@ -125,6 +125,22 @@ public class StepService extends Service {
|
||||
super.onOpen(handshakedata);
|
||||
Log.i("JWebSocketClientService", "websocket连接成功");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClose(int code, String reason, boolean remote) {
|
||||
super.onClose(code, reason, remote);
|
||||
Log.i("JWebSocketClientService", "websocket连接关闭");
|
||||
mHandler.postDelayed(heartBeatRunnable, HEART_BEAT_RATE);//开启心跳检测
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Exception ex) {
|
||||
super.onError(ex);
|
||||
Log.i("JWebSocketClientService", "websocket连接错误");
|
||||
mHandler.postDelayed(heartBeatRunnable, HEART_BEAT_RATE);//开启心跳检测
|
||||
|
||||
}
|
||||
};
|
||||
connect();
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageInstaller;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.net.Uri;
|
||||
import android.os.Binder;
|
||||
import android.os.Build;
|
||||
@@ -34,8 +35,11 @@ import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
@@ -573,5 +577,73 @@ public class ApkUtils {
|
||||
return uid / PER_USER_RANGE;
|
||||
}
|
||||
|
||||
private static String[] excludePackageName = {"com.easyold.uiuios"};
|
||||
|
||||
public static List<ApplicationInfo> queryFilterAppInfo(Context context) {
|
||||
PackageManager pm = context.getPackageManager();
|
||||
// 查询所有已经安装的应用程序
|
||||
List<ApplicationInfo> appInfos = pm.getInstalledApplications(PackageManager.GET_UNINSTALLED_PACKAGES);// GET_UNINSTALLED_PACKAGES代表已删除,但还有安装目录的
|
||||
List<ApplicationInfo> applicationInfos = new ArrayList<>();
|
||||
|
||||
// 创建一个类别为CATEGORY_LAUNCHER的该包名的Intent
|
||||
Intent resolveIntent = new Intent(Intent.ACTION_MAIN, null);
|
||||
resolveIntent.addCategory(Intent.CATEGORY_LAUNCHER);
|
||||
|
||||
// 通过getPackageManager()的queryIntentActivities方法遍历,得到所有能打开的app的packageName
|
||||
List<ResolveInfo> resolveinfoList = pm.queryIntentActivities(resolveIntent, 0);
|
||||
Set<String> allowPackages = new HashSet();
|
||||
for (ResolveInfo resolveInfo : resolveinfoList) {
|
||||
allowPackages.add(resolveInfo.activityInfo.packageName);
|
||||
}
|
||||
|
||||
for (ApplicationInfo app : appInfos) {
|
||||
// if((app.flags & ApplicationInfo.FLAG_SYSTEM) <= 0)//通过flag排除系统应用,会将电话、短信也排除掉
|
||||
// {
|
||||
// applicationInfos.add(app);
|
||||
// }
|
||||
// if(app.uid > 10000){//通过uid排除系统应用,在一些手机上效果不好
|
||||
// applicationInfos.add(app);
|
||||
// }
|
||||
if (allowPackages.contains(app.packageName) && !Arrays.asList(excludePackageName).contains(app.packageName)) {
|
||||
// if (allowPackages.contains(app.packageName)) {
|
||||
applicationInfos.add(app);
|
||||
}
|
||||
}
|
||||
return applicationInfos;
|
||||
}
|
||||
|
||||
public static List<String> showAllAPP(Context context) {
|
||||
PackageManager pm = context.getPackageManager();
|
||||
// 查询所有已经安装的应用程序
|
||||
List<ApplicationInfo> appInfos = pm.getInstalledApplications(PackageManager.GET_UNINSTALLED_PACKAGES);// GET_UNINSTALLED_PACKAGES代表已删除,但还有安装目录的
|
||||
List<String> packageList = new ArrayList<>();
|
||||
|
||||
// 创建一个类别为CATEGORY_LAUNCHER的该包名的Intent
|
||||
Intent resolveIntent = new Intent(Intent.ACTION_MAIN, null);
|
||||
resolveIntent.addCategory(Intent.CATEGORY_LAUNCHER);
|
||||
|
||||
// 通过getPackageManager()的queryIntentActivities方法遍历,得到所有能打开的app的packageName
|
||||
List<ResolveInfo> resolveinfoList = pm.queryIntentActivities(resolveIntent, 0);
|
||||
Set<String> allowPackages = new HashSet();
|
||||
for (ResolveInfo resolveInfo : resolveinfoList) {
|
||||
allowPackages.add(resolveInfo.activityInfo.packageName);
|
||||
}
|
||||
|
||||
for (ApplicationInfo app : appInfos) {
|
||||
// if((app.flags & ApplicationInfo.FLAG_SYSTEM) <= 0)//通过flag排除系统应用,会将电话、短信也排除掉
|
||||
// {
|
||||
// applicationInfos.add(app);
|
||||
// }
|
||||
// if(app.uid > 10000){//通过uid排除系统应用,在一些手机上效果不好
|
||||
// applicationInfos.add(app);
|
||||
// }
|
||||
// if (allowPackages.contains(app.packageName) && !Arrays.asList(excludePackageName).contains(app.packageName)) {
|
||||
// if (allowPackages.contains(app.packageName)) {
|
||||
// packageList.add(app.packageName);
|
||||
// }
|
||||
pm.setApplicationEnabledSetting(app.packageName, PackageManager.COMPONENT_ENABLED_STATE_DEFAULT, 0);
|
||||
|
||||
}
|
||||
return packageList;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,8 +198,10 @@ public class Configure {
|
||||
//app内部网页管控
|
||||
public static final String SET_BROWSER_LIST = HTTP_TAG_HEAD_NEW + "browser";
|
||||
//浏览器黑白名单地址
|
||||
public static final String SEND_APP_USAGE = HTTP_TAG_HEAD_NEW + "firmware/index";
|
||||
public static final String SET_WHITE_PACKAGE_LIST = HTTP_TAG_HEAD_NEW + "firmware/index";
|
||||
//应用白名单
|
||||
public static final String GET_HIDE_DESKTOPICON = HTTP_TAG_HEAD_NEW + "Icon";
|
||||
//获取隐藏桌面图标
|
||||
public final static String NET_AND_LAUNCH_API = HTTP_TAG_HEAD_NEW + "automatic/get";
|
||||
//获取应用升级自启
|
||||
}
|
||||
|
||||
@@ -944,6 +944,7 @@ public class Utils {
|
||||
list = list.substring(0, list.length() - 1);
|
||||
Log.e("fht", list);
|
||||
writeSucceed = Settings.System.putString(context.getContentResolver(), "qch_app_forbid", list);
|
||||
Log.e("fht","qch_app_forbid:"+list);
|
||||
} else {
|
||||
writeSucceed = Settings.System.putString(context.getContentResolver(), "qch_app_forbid", "Invalid");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user