version:1.4

update:2021-10-21 10:14:40
fix:
add:增加浏览器桌面检测升级,修复重复请求
This commit is contained in:
2021-12-03 14:33:03 +08:00
parent 768519e14e
commit 34fa9fcdb7
70 changed files with 3189 additions and 1503 deletions

View File

@@ -18,14 +18,18 @@ import android.graphics.Bitmap;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
import android.net.wifi.WifiManager;
import android.os.BatteryManager;
import android.os.Build;
import android.os.Environment;
import android.os.PowerManager;
import android.os.RemoteException;
import android.provider.Settings;
import android.text.TextUtils;
import android.util.Log;
import androidx.core.content.ContextCompat;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.aoleyun.sn.comm.PackageNames;
@@ -113,7 +117,7 @@ public class JGYUtils {
public static void init(Context context) {
if (sInstance == null) {
Logutils.e(TAG, "init: ");
Log.e(TAG, "init: ");
sInstance = new JGYUtils(context);
}
}
@@ -133,7 +137,7 @@ public class JGYUtils {
}
public static boolean isOfficialVersion(Context context) {
Logutils.e(TAG, "isOfficialVersion: " + ProcessUtil.getCurrentProcessName(context));
Log.e(TAG, "isOfficialVersion: " + ProcessUtil.getCurrentProcessName(context));
String channelValue = JGYUtils.getInstance().getStringMetaData();
return "official".equals(channelValue);
}
@@ -155,12 +159,16 @@ public class JGYUtils {
public void resetDevice() {
boolean isReset = MySQLData.GetBooleanData(mContext, CommonDatas.IS_RESET);
int batteryLevel = getBatteryLevel();
Logutils.e(TAG, "batteryLevel:" + batteryLevel + " isReset" + isReset);
Log.e(TAG, "batteryLevel:" + batteryLevel + " isReset" + isReset);
if (isReset && batteryLevel >= CommonDatas.MIN_POWER) {
Utils.doMasterClear(mContext);
}
}
public String getDownLoadPath() {
String path = ContextCompat.getExternalFilesDirs(mContext, Environment.DIRECTORY_DOWNLOADS)[0].getAbsolutePath();
return path + File.separator;
}
private int getBatteryLevel() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
@@ -187,7 +195,7 @@ public class JGYUtils {
wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK
| PowerManager.ON_AFTER_RELEASE, mWakeLockName);
if (null != wakeLock) {
Logutils.e("fht", "acquireWakeLock!");
Log.e("fht", "acquireWakeLock!");
wakeLock.acquire();
}
}
@@ -198,7 +206,7 @@ public class JGYUtils {
*/
private synchronized void releaseWakeLock() {
if (null != wakeLock) {
Logutils.e("fht", "releaseWakeLock!");
Log.e("fht", "releaseWakeLock!");
wakeLock.release();
wakeLock = null;
}
@@ -211,8 +219,8 @@ public class JGYUtils {
*/
@SuppressLint("NewApi")
synchronized public void setNetAndlaunch(NetAndLaunchBean netAndLaunchBean, List<AppListInfo> appListInfos) {
Logutils.e(TAG, "setNetAndlaunch: " + "应用联网管控: " + netAndLaunchBean.getData().toString());
Logutils.e(TAG, "setNetAndlaunch: ");
Log.e(TAG, "setNetAndlaunch: " + "应用联网管控: " + netAndLaunchBean.getData().toString());
Log.e(TAG, "setNetAndlaunch: ");
HashSet<String> autoLaunchApp = new HashSet<>();//开机自启app
HashSet<String> allowNetApp = new HashSet<>();//允许联网
HashSet<String> disallowNetApp = new HashSet<>();//禁止联网
@@ -244,11 +252,11 @@ public class JGYUtils {
if (disallowSlide.size() != 0) {
String slide_not = String.join(",", disallowSlide);
boolean writeSucceed = Settings.System.putString(mContext.getContentResolver(), "qch_disable_slide", slide_not);
Logutils.e("fht", "qch_disable_slide=" + writeSucceed + ":" + slide_not);
Log.e("fht", "qch_disable_slide=" + writeSucceed + ":" + slide_not);
} else {
String slide_ok = String.join(",", allowSlide);
boolean writeSucceed = Settings.System.putString(mContext.getContentResolver(), "qch_disable_slide", "Invalid");
Logutils.e("fht", "qch_disable_slide ok=" + writeSucceed + ":" + slide_ok);
Log.e("fht", "qch_disable_slide ok=" + writeSucceed + ":" + slide_ok);
}
String[] upgrade_ok = new String[allowUpgrade.size()];
@@ -258,26 +266,26 @@ public class JGYUtils {
disallowUpgrade.toArray(upgrade_not);
Utils.writeDisableUpdateList(mContext, upgrade_not, upgrade_ok);
String qch_app_power_on = String.join(",", autoLaunchApp);
Logutils.e(TAG, "setNetAndlaunch: qch_app_power_on: " + qch_app_power_on);
Log.e(TAG, "setNetAndlaunch: qch_app_power_on: " + qch_app_power_on);
if (TextUtils.isEmpty(qch_app_power_on)) {
//当 qch_app_power_on 的值为空时,会造成系统所有应用断网
Settings.System.putString(mContext.getContentResolver(), "qch_app_power_on", "Invalid");
Logutils.e(TAG, "setNetAndlaunch: qch_app_power_on: " + "Invalid");
Log.e(TAG, "setNetAndlaunch: qch_app_power_on: " + "Invalid");
} else {
Settings.System.putString(mContext.getContentResolver(), "qch_app_power_on", qch_app_power_on);
Logutils.e(TAG, "setNetAndlaunch: qch_app_power_on: " + qch_app_power_on);
Log.e(TAG, "setNetAndlaunch: qch_app_power_on: " + qch_app_power_on);
}
// if (BuildConfig.DEBUG) {
// TODO: 2021/7/2 测试写入为空是否断网
// boolean w = Settings.System.putString(mContext.getContentResolver(), "qch_app_power_on", "");
// Logutils.e(TAG, "setNetAndlaunch: 测试写入: " + w);
// Log.e(TAG, "setNetAndlaunch: 测试写入: " + w);
// }
setAppNetwork(mContext, disallowNetApp);
BaseApplication.getInstance().setFinished(true);
}
private void checkPackageAndVersion(HashSet<String> disallowUpgrade, List<AppListInfo> appListInfos) {
Logutils.e(TAG, "checkPackageAndVersion: " + disallowUpgrade);
Log.e(TAG, "checkPackageAndVersion: " + disallowUpgrade);
PackageManager pm = mContext.getPackageManager();
HashMap<String, AppListInfo> listInfoHashMap = new HashMap<>();
for (AppListInfo appListInfo : appListInfos) {
@@ -296,8 +304,8 @@ public class JGYUtils {
appVersionCode = packageInfo.versionCode;
}
if (appVersionCode > info.getApp_version_code() && info.getApp_version_code() != 0) {
Logutils.e(TAG, "checkPackageAndVersion: appVersionCode: " + appVersionCode + " getApp_version_code: " + info.getApp_version_code());
Logutils.e(TAG, "checkPackageAndVersion: " + pkg + " 卸载");
Log.e(TAG, "checkPackageAndVersion: appVersionCode: " + appVersionCode + " getApp_version_code: " + info.getApp_version_code());
Log.e(TAG, "checkPackageAndVersion: " + pkg + " 卸载");
ApkUtils.UninstallAPP(mContext, pkg);
JSONObject packageObj = new JSONObject();
packageObj.put("app_name", info.getApp_name());
@@ -306,7 +314,7 @@ public class JGYUtils {
packageObj.put("MD5", info.getApp_md5());
Utils.ariaDownload(mContext, info.getApp_url(), packageObj);
} else {
Logutils.e(TAG, "checkPackageAndVersion: " + pkg + " 版本正常");
Log.e(TAG, "checkPackageAndVersion: " + pkg + " 版本正常");
}
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
@@ -320,8 +328,8 @@ public class JGYUtils {
@SuppressLint("NewApi")
synchronized public void setNetAndlaunch(NetAndLaunchBean netAndLaunchBean) {
Logutils.e(TAG, "setNetAndlaunch: " + "应用联网管控: " + netAndLaunchBean.getData().toString());
Logutils.e(TAG, "setNetAndlaunch: ");
Log.e(TAG, "setNetAndlaunch: " + "应用联网管控: " + netAndLaunchBean.getData().toString());
Log.e(TAG, "setNetAndlaunch: ");
HashSet<String> autoLaunchApp = new HashSet<>();//开机自启app
HashSet<String> allowNetApp = new HashSet<>();//允许联网
HashSet<String> disallowNetApp = new HashSet<>();//禁止联网
@@ -353,11 +361,11 @@ public class JGYUtils {
if (disallowSlide.size() != 0) {
String slide_not = String.join(",", disallowSlide);
boolean writeSucceed = Settings.System.putString(mContext.getContentResolver(), "qch_disable_slide", slide_not);
Logutils.e("fht", "qch_disable_slide=" + writeSucceed + ":" + slide_not);
Log.e("fht", "qch_disable_slide=" + writeSucceed + ":" + slide_not);
} else {
String slide_ok = String.join(",", allowSlide);
boolean writeSucceed = Settings.System.putString(mContext.getContentResolver(), "qch_disable_slide", "Invalid");
Logutils.e("fht", "qch_disable_slide ok=" + writeSucceed + ":" + slide_ok);
Log.e("fht", "qch_disable_slide ok=" + writeSucceed + ":" + slide_ok);
}
String[] upgrade_ok = new String[allowUpgrade.size()];
@@ -366,19 +374,19 @@ public class JGYUtils {
disallowUpgrade.toArray(upgrade_not);
Utils.writeDisableUpdateList(mContext, upgrade_not, upgrade_ok);
String qch_app_power_on = String.join(",", autoLaunchApp);
Logutils.e(TAG, "setNetAndlaunch: qch_app_power_on: " + qch_app_power_on);
Log.e(TAG, "setNetAndlaunch: qch_app_power_on: " + qch_app_power_on);
if (TextUtils.isEmpty(qch_app_power_on)) {
//当 qch_app_power_on 的值为空时,会造成系统所有应用断网
Settings.System.putString(mContext.getContentResolver(), "qch_app_power_on", "Invalid");
Logutils.e(TAG, "setNetAndlaunch: qch_app_power_on: " + "Invalid");
Log.e(TAG, "setNetAndlaunch: qch_app_power_on: " + "Invalid");
} else {
Settings.System.putString(mContext.getContentResolver(), "qch_app_power_on", qch_app_power_on);
Logutils.e(TAG, "setNetAndlaunch: qch_app_power_on: " + qch_app_power_on);
Log.e(TAG, "setNetAndlaunch: qch_app_power_on: " + qch_app_power_on);
}
// if (BuildConfig.DEBUG) {
// TODO: 2021/7/2 测试写入为空是否断网
// boolean w = Settings.System.putString(mContext.getContentResolver(), "qch_app_power_on", "");
// Logutils.e(TAG, "setNetAndlaunch: 测试写入: " + w);
// Log.e(TAG, "setNetAndlaunch: 测试写入: " + w);
// }
setAppNetwork(mContext, disallowNetApp);
BaseApplication.getInstance().setFinished(true);
@@ -386,16 +394,16 @@ public class JGYUtils {
@SuppressLint("NewApi")
synchronized public static void setAppNetwork(Context context, HashSet<String> blackList) {
Logutils.e(TAG, "setAppNetwork: " + "设置应用联网管控" + blackList);
Log.e(TAG, "setAppNetwork: " + "设置应用联网管控" + blackList);
String dis = Settings.System.getString(context.getContentResolver(), JGYActions.ACTION_HR_RECEIVER_JGY_DIS);
String not = Settings.System.getString(context.getContentResolver(), JGYActions.ACTION_HR_RECEIVER_JGY);
//清除旧数据
if (!TextUtils.isEmpty(dis)) {
Logutils.e(TAG, "setAppNetwork: dis = " + dis);
Log.e(TAG, "setAppNetwork: dis = " + dis);
Settings.System.putString(context.getContentResolver(), JGYActions.ACTION_HR_RECEIVER_JGY_DIS, "Invalid");
}
if (!TextUtils.isEmpty(not)) {
Logutils.e(TAG, "setAppNetwork: not = " + not);
Log.e(TAG, "setAppNetwork: not = " + not);
Settings.System.putString(context.getContentResolver(), JGYActions.ACTION_HR_RECEIVER_JGY, "Invalid");
}
@@ -403,14 +411,15 @@ public class JGYUtils {
HashSet<String> oldBlackListSet = new HashSet<>(Arrays.asList(oldBlackList.split(",")));
oldBlackListSet.removeIf(s -> TextUtils.isEmpty(s.trim()));
//之前禁止上网得列表
Logutils.e(TAG, "setAppNetwork: oldBlackListSet: " + oldBlackListSet);
Log.e(TAG, "setAppNetwork: oldBlackListSet: " + oldBlackListSet);
if (oldBlackListSet.size() == 0) {
Logutils.e(TAG, "setAppNetwork: blackList: " + blackList);
for (String pkg : blackList) {
Log.e(TAG, "setAppNetwork: blackList: " + blackList);
for (String pkg : new HashSet<>(blackList)) {
if (TextUtils.isEmpty(pkg)) continue;
//发送没有安装的
if (!ApkUtils.isAvailable(context, pkg)) {
Log.e(TAG, "setAppNetwork: skip: " + pkg);
blackList.remove(pkg);
continue;
} else {
Log.e(TAG, "setAppNetwork: " + pkg + " 已安装");
@@ -434,8 +443,8 @@ public class JGYUtils {
}
}
Logutils.e(TAG, "setAppNetwork: removedNet: " + removedNet);
Logutils.e(TAG, "setAppNetwork: addedNet: " + addedNet);
Log.e(TAG, "setAppNetwork: removedNet: " + removedNet);
Log.e(TAG, "setAppNetwork: addedNet: " + addedNet);
for (String pkg : removedNet) {
if (TextUtils.isEmpty(pkg)) continue;
Intent netControlNotIntent = new Intent(JGYActions.ACTION_HR_RECEIVER_JGY);
@@ -447,6 +456,7 @@ public class JGYUtils {
if (TextUtils.isEmpty(pkg)) continue;
if (!ApkUtils.isAvailable(context, pkg)) {
Log.e(TAG, "setAppNetwork: skip: " + pkg);
blackList.remove(pkg);
continue;
} else {
Log.e(TAG, "setAppNetwork: " + pkg + " 已安装");
@@ -461,7 +471,7 @@ public class JGYUtils {
String net_not = String.join(",", blackList);
SPUtils.put(context, JGYActions.ACTION_HR_RECEIVER_JGY_DIS, net_not);
//Settings.System.putString(mContext.getContentResolver(), JGYActions.ACTION_HrReceiver_JGY_DIS, net_not);
Logutils.e("fht", "not::" + net_not);
Log.e("fht", "not::" + net_not);
//Intent netControlIntent = new Intent(CommonDatas.ACTION_HrReceiver_JGY_DIS);
//netControlIntent.putExtra("package_name", net_not);
@@ -476,7 +486,7 @@ public class JGYUtils {
synchronized public void onBootSendNetwork() {
String oldBlackListString = (String) SPUtils.get(mContext, JGYActions.ACTION_HR_RECEIVER_JGY_DIS, "");
HashSet<String> oldBlackListSet = new HashSet<>(Arrays.asList(oldBlackListString.split(",")));
Logutils.e(TAG, "setAppNetwork: oldBlackListSet: " + oldBlackListSet);
Log.e(TAG, "setAppNetwork: oldBlackListSet: " + oldBlackListSet);
oldBlackListSet.removeIf(new Predicate<String>() {
@Override
public boolean test(String s) {
@@ -525,14 +535,14 @@ public class JGYUtils {
String olddeselectViewArray = Settings.System.getString(mContext.getContentResolver(), "qch_app_forbid_id");
Logutils.e("writeDeselectIDtoSystem", "olddeselectViewArray: " + olddeselectViewArray);
Log.e("writeDeselectIDtoSystem", "olddeselectViewArray: " + olddeselectViewArray);
Settings.System.putString(mContext.getContentResolver(), "qch_app_forbid_id", packageStringBuilder.toString());
Settings.System.putString(mContext.getContentResolver(), "DeselectViewArray", idStringBuilder.toString());
Logutils.e("writeDeselectIDtoSystem", "qch_app_forbid_id: " + packageStringBuilder.toString());
Logutils.e("writeDeselectIDtoSystem", "deselectViewArray: " + idStringBuilder.toString());
Log.e("writeDeselectIDtoSystem", "qch_app_forbid_id: " + packageStringBuilder.toString());
Log.e("writeDeselectIDtoSystem", "deselectViewArray: " + idStringBuilder.toString());
} else {
Logutils.e("writeDeselectIDtoSystem", "writeDeselectIDtoSystem is null:");
Log.e("writeDeselectIDtoSystem", "writeDeselectIDtoSystem is null:");
Settings.System.putString(mContext.getContentResolver(), "qch_app_forbid_id", "");
Settings.System.putString(mContext.getContentResolver(), "DeselectViewArray", "");
}
@@ -561,7 +571,7 @@ public class JGYUtils {
if (packageList.length() > 0) {
//app内所有的网页禁止
Logutils.e("setAppinsideWeb ", "packageList:" + packageList.toString());
Log.e("setAppinsideWeb ", "packageList:" + packageList.toString());
Intent qch_app_website = new Intent("qch_app_website")
.setPackage("com.android.settings");
qch_app_website.putExtra("package_name", packageList.toString());
@@ -572,7 +582,7 @@ public class JGYUtils {
if (strings.length() > 0) {
//app内单个网页地址禁止打开
Logutils.e("setAppinsideWeb ", "strings:" + strings.toString());
Log.e("setAppinsideWeb ", "strings:" + strings.toString());
Intent intent = new Intent("qch_app_inside_website")
.setPackage("com.android.settings");
intent.putExtra("websitelist", strings.toString());
@@ -586,7 +596,7 @@ public class JGYUtils {
sendAllweb(mContext);
sendwebUrl(mContext);
//ToastUtil.show(msg);
Logutils.e("setAppinsideWeb", "setAppinsideWeb: " + response.msg);
Log.e("setAppinsideWeb", "setAppinsideWeb: " + response.msg);
}
}
@@ -594,7 +604,7 @@ public class JGYUtils {
* @param response 黑白名单都可以管控
*/
synchronized public void setNewAppinsideWeb(BaseResponse response) {
Logutils.e(TAG, "setNewAppinsideWeb: " + "应用内部联网管控: " + response);
Log.e(TAG, "setNewAppinsideWeb: " + "应用内部联网管控: " + response);
if (response.code == 200) {
String jsonString = JSONArray.toJSONString(response.data);
List<TTAppground> appgrounds = JSONObject.parseArray(jsonString, TTAppground.class);
@@ -608,8 +618,8 @@ public class JGYUtils {
blackApp.add(appground);
}
}
Logutils.e(TAG, "setAppinsideWeb: whiteApp: " + whiteApp);
Logutils.e(TAG, "setAppinsideWeb: blackApp: " + blackApp);
Log.e(TAG, "setAppinsideWeb: whiteApp: " + whiteApp);
Log.e(TAG, "setAppinsideWeb: blackApp: " + blackApp);
setWhiteApp(whiteApp);
setBlackApp(blackApp);
}
@@ -620,7 +630,7 @@ public class JGYUtils {
sendAllweb(mContext);
sendwebUrl(mContext);
//ToastUtil.show(msg);
Logutils.e("setAppinsideWeb", "setAppinsideWeb: " + response.msg);
Log.e("setAppinsideWeb", "setAppinsideWeb: " + response.msg);
}
}
@@ -667,9 +677,9 @@ public class JGYUtils {
addAppgrounds.add(entry.getValue());
}
Logutils.e(TAG, "comparedAppground: addAppgrounds.size():" + addAppgrounds.size());
Logutils.e(TAG, "comparedAppground: deleteAppgrounds.size():" + deleteAppgrounds.size());
Logutils.e(TAG, "comparedAppground: changedAppgrounds.size():" + changedAppgrounds.size());
Log.e(TAG, "comparedAppground: addAppgrounds.size():" + addAppgrounds.size());
Log.e(TAG, "comparedAppground: deleteAppgrounds.size():" + deleteAppgrounds.size());
Log.e(TAG, "comparedAppground: changedAppgrounds.size():" + changedAppgrounds.size());
addAppground(addAppgrounds);
deleteAppground(deleteAppgrounds);
@@ -683,7 +693,7 @@ public class JGYUtils {
//删除空的,旧版本使用这个清除
deleteWhitelistUrl(appground.getPackages(), "Invalid");
addToWhitelist(appground.getPackages(), appground.getAddress());
Logutils.e("comparedAppground", "addAppground: " + appground.getAddress());
Log.e("comparedAppground", "addAppground: " + appground.getAddress());
}
}
@@ -691,7 +701,7 @@ public class JGYUtils {
for (TTAppground appground : appgroundList) {
deleteWhitelistUrl(appground.getPackages(), appground.getAddress());
deleteOtherAppWhitelist(appground.getPackages());
Logutils.e("comparedAppground", "deleteAppground: " + appground.getAddress());
Log.e("comparedAppground", "deleteAppground: " + appground.getAddress());
}
}
@@ -705,12 +715,12 @@ public class JGYUtils {
oldURL.remove(url);
} else {
addToWhitelist(appground.getPackages(), url);
Logutils.e("comparedAppground", "addToWhitelist: " + url);
Log.e("comparedAppground", "addToWhitelist: " + url);
}
}
for (String url : oldURL) {
deleteWhitelistUrl(appground.getPackages(), url);
Logutils.e("comparedAppground", "deleteWhitelistUrl: " + url);
Log.e("comparedAppground", "deleteWhitelistUrl: " + url);
}
}
}
@@ -718,7 +728,7 @@ public class JGYUtils {
private List<TTAppground> getOldWhitelist() {
String whiteListString = (String) SPUtils.get(mContext, JGY_APPINSIDE_WHITELIST, "");
Logutils.e(TAG, "getOldWhitelist: " + whiteListString);
Log.e(TAG, "getOldWhitelist: " + whiteListString);
Gson gson = new Gson();
Type listType = new TypeToken<List<TTAppground>>() {
}.getType();
@@ -753,10 +763,10 @@ public class JGYUtils {
public void onBootSetAppInsideWeb() {
List<TTAppground> old = getOldWhitelist();
Logutils.e(TAG, "onBootSetAppInsideWeb: " + old);
Log.e(TAG, "onBootSetAppInsideWeb: " + old);
for (TTAppground appground : old) {
if (TextUtils.isEmpty(appground.getAddress())) {
Logutils.e(TAG, "setWhiteApp: " + "skip: " + appground.getAddress());
Log.e(TAG, "setWhiteApp: " + "skip: " + appground.getAddress());
} else {
addPackage(appground.getPackages());
//删除空的,旧版本使用这个清除
@@ -771,7 +781,7 @@ public class JGYUtils {
* @param pkg 开启app白名单
*/
synchronized private void addPackage(String pkg) {
Logutils.e(TAG, "addPackage: " + pkg);
Log.e(TAG, "addPackage: " + pkg);
Intent intent26 = new Intent();
intent26.setAction("qch_app_inside_website");
intent26.putExtra("WEBURLforbidapp", pkg);
@@ -785,7 +795,7 @@ public class JGYUtils {
*/
synchronized private void addToWhitelist(String pkg, String urls) {
if (TextUtils.isEmpty(urls)) {
Logutils.e(TAG, "addToWhitelist: " + "urls is NULL");
Log.e(TAG, "addToWhitelist: " + "urls is NULL");
return;
}
HashSet<String> urlSet = new HashSet<>(Arrays.asList(urls.trim().split(",")));
@@ -794,7 +804,7 @@ public class JGYUtils {
continue;
}
deleteOtherAppWhitelist(pkg);
Logutils.e(TAG, "addToWhitelist: pkg:" + pkg + " url: " + url);
Log.e(TAG, "addToWhitelist: pkg:" + pkg + " url: " + url);
Intent intent25 = new Intent();
intent25.setAction("qch_app_setAddAppWhitWebUid");
intent25.putExtra("AddAppWhitWebUidPackage", pkg);
@@ -810,7 +820,7 @@ public class JGYUtils {
*/
synchronized private void deleteWhitelistUrl(String pkg, String urls) {
if (TextUtils.isEmpty(urls)) {
Logutils.e(TAG, "addToWhitelist: " + "urls is NULL");
Log.e(TAG, "addToWhitelist: " + "urls is NULL");
return;
}
HashSet<String> urlSet = new HashSet<>(Arrays.asList(urls.trim().split(",")));
@@ -818,7 +828,7 @@ public class JGYUtils {
if (TextUtils.isEmpty(url)) {
continue;
}
Logutils.e(TAG, "deleteWhitelistUrl: qch_app_setDelAppWhitWebUid" + "pkg: " + pkg + " url: " + url);
Log.e(TAG, "deleteWhitelistUrl: qch_app_setDelAppWhitWebUid" + "pkg: " + pkg + " url: " + url);
Intent intent25 = new Intent();
intent25.setAction("qch_app_setDelAppWhitWebUid");
intent25.putExtra("DelAppWhitWebUidPackage", pkg);
@@ -832,7 +842,7 @@ public class JGYUtils {
* @param pkg 开启和关闭白名单管控都需要发送
*/
synchronized private void deleteOtherAppWhitelist(String pkg) {
Logutils.e(TAG, "disableAppWhitelist: " + pkg);
Log.e(TAG, "disableAppWhitelist: " + pkg);
Intent intent24 = new Intent();
intent24.setAction("qch_app_setDelAppWhitUid");
intent24.putExtra("DelAppWhitUidPackage", pkg);
@@ -844,7 +854,7 @@ public class JGYUtils {
* @param appgrounds 设置黑名单管控
*/
synchronized private void setBlackApp(List<TTAppground> appgrounds) {
Logutils.e(TAG, "setBlackApp: " + appgrounds);
Log.e(TAG, "setBlackApp: " + appgrounds);
StringBuilder blackList = new StringBuilder();
StringBuilder packageList = new StringBuilder();//单条管控名单
for (TTAppground appground : appgrounds) {
@@ -863,7 +873,7 @@ public class JGYUtils {
//old
if (packageList.length() > 0) {
//app内所有的网页禁止
Logutils.e("setAppinsideWeb ", "packageList:" + packageList.toString());
Log.e("setAppinsideWeb ", "packageList:" + packageList.toString());
Intent qch_app_website = new Intent("qch_app_website")
.setPackage("com.android.settings");
qch_app_website.putExtra("package_name", packageList.toString());
@@ -873,7 +883,7 @@ public class JGYUtils {
}
if (blackList.length() > 0) {
//app内单个网页地址禁止打开
Logutils.e("setAppinsideWeb ", "blackList:" + blackList.toString());
Log.e("setAppinsideWeb ", "blackList:" + blackList.toString());
Intent intent = new Intent("qch_app_inside_website")
.setPackage("com.android.settings");
intent.putExtra("websitelist", blackList.toString());
@@ -884,7 +894,7 @@ public class JGYUtils {
}
synchronized private static void sendAllweb(Context context) {
Logutils.e(TAG, "sendAllweb: ");
Log.e(TAG, "sendAllweb: ");
Intent intent = new Intent("qch_app_website")
.setPackage("com.android.settings");
intent.putExtra("package_name", "Invalid");
@@ -892,7 +902,7 @@ public class JGYUtils {
}
synchronized private static void sendwebUrl(Context context) {
Logutils.e(TAG, "sendwebUrl: ");
Log.e(TAG, "sendwebUrl: ");
Intent intent = new Intent("qch_app_inside_website")
.setPackage("com.android.settings");
intent.putExtra("websitelist", "Invalid");
@@ -902,7 +912,7 @@ public class JGYUtils {
synchronized public void SettingSysData(String data) {
SPUtils.put(mContext, "SystemSettingData", data);
if (TextUtils.isEmpty(data)) {
Logutils.e(TAG, "SettingSysData: " + "data is empty");
Log.e(TAG, "SettingSysData: " + "data is empty");
SysSettingUtils.setDisableSetting(mContext);
} else {
SysSettingUtils.setSystemSetting(mContext, data);
@@ -921,15 +931,20 @@ public class JGYUtils {
this.add("com.uiuios.jgy1");
this.add("com.uiuios.jgy2");
this.add("com.tt.ttutils");
this.add("com.uiui.browser");
this.add("com.android.uiuios");
this.add("com.aoleyun.os");
this.add("com.aoleyunos.dop1");
this.add("com.aoleyunos.dop2");
this.add("com.aoleyun.info");
}};
HashSet<String> pkgSet = new HashSet<>(Arrays.asList(packageList.split(",")));
pkgSet.addAll(packages);
pkgSet.removeIf(TextUtils::isEmpty);
String qch_app_forbid = String.join(",", pkgSet);
Logutils.e(TAG, "writeAppPackageList: " + qch_app_forbid);
Log.e(TAG, "writeAppPackageList: " + qch_app_forbid);
boolean b = Settings.System.putString(mContext.getContentResolver(), "qch_app_forbid", qch_app_forbid);
Logutils.e("writeAppPackageList: ", "qch_app_forbid is :" + b + " " + Settings.System.getString(mContext.getContentResolver(), "qch_app_forbid"));
Log.e("writeAppPackageList: ", "qch_app_forbid is :" + b + " " + Settings.System.getString(mContext.getContentResolver(), "qch_app_forbid"));
}
public void forceDownload(List<ForceDownloadData> data) {
@@ -951,7 +966,7 @@ public class JGYUtils {
jsonObject.put("app_id", app_id);
jsonObject.put("MD5", app_md5);
long app_version_code = forceDownloadData.getApp_version_code();
Logutils.e("fht ", "packageName=" + app_package + ",URL= " + app_url + ",app_version_code=" + app_version_code);
Log.e("fht ", "packageName=" + app_package + ",URL= " + app_url + ",app_version_code=" + app_version_code);
if (BuildConfig.APPLICATION_ID.equals(data.get(i).getApp_package())) {
continue;//为自身的跳过下载
}
@@ -964,7 +979,7 @@ public class JGYUtils {
packageInfo = pm.getPackageInfo(app_package, 0);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
Logutils.e("fht", "forceDownload=" + e.getMessage());
Log.e("fht", "forceDownload=" + e.getMessage());
}
if (packageInfo != null) {
long appVersionCode;
@@ -974,11 +989,11 @@ public class JGYUtils {
appVersionCode = packageInfo.versionCode;
}
if (app_version_code > appVersionCode) {
Logutils.e("fht ", "download URL " + app_url);
Log.e("fht ", "download URL " + app_url);
Utils.ariaDownload(mContext, app_url, jsonObject);
}
} else {
Logutils.e("fht ", "download URL " + app_url);
Log.e("fht ", "download URL " + app_url);
Utils.ariaDownload(mContext, app_url, jsonObject);
}
}
@@ -1001,7 +1016,7 @@ public class JGYUtils {
Utils.ariaDownload(mContext, forceDownloadData.getApp_url(), jsonObject);
}
} else {
// Logutils.e("fht", "未上传应用");
// Log.e("fht", "未上传应用");
}
}
}
@@ -1032,7 +1047,7 @@ public class JGYUtils {
if (packageInfo == null || packageInfo.versionCode < versionCode) {
Utils.ariaDownload(mContext, url, object);
} else {
Logutils.e("installAPK", "已是最新版本");
Log.e("installAPK", "已是最新版本");
}
}
@@ -1059,7 +1074,7 @@ public class JGYUtils {
if (packageInfo == null || packageInfo.versionCode < versionCode) {
Utils.ariaDownload(mContext, url, object);
} else {
Logutils.e("installTestAPK", "TestAPK: " + "无更新");
Log.e("installTestAPK", "TestAPK: " + "无更新");
}
}
@@ -1092,7 +1107,7 @@ public class JGYUtils {
if (packageInfo == null || packageInfo.versionCode < versionCode) {
Utils.ariaDownload(mContext, url, object);
} else {
Logutils.e("installTestAPK", "TestAPK: " + packageName + "\t无更新");
Log.e("installTestAPK", "TestAPK: " + packageName + "\t无更新");
}
}
}
@@ -1114,7 +1129,7 @@ public class JGYUtils {
info = packageManager.getPackageInfo(app_package, 0);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
Logutils.e("fht", "installDesktop: " + e.getMessage());
Log.e("fht", "installDesktop: " + e.getMessage());
}
if (null != info) {
long versionCode;
@@ -1143,26 +1158,33 @@ public class JGYUtils {
if (locked == 1) {
return;
}
Logutils.e(TAG, "deleteOtherApp: " + "start");
Log.e(TAG, "deleteOtherApp: " + "start");
String[] result_white = new String[]{};
String[] result_forbid = new String[]{};
//获取后台应用白名单
String only_jgy_shortcut_list = Settings.System.getString(mContext.getContentResolver(), JGYActions.ACTION_JGY_SHORTCUTLIST);
if (!TextUtils.isEmpty(only_jgy_shortcut_list)) {
result_white = only_jgy_shortcut_list.split(",");
}
//获取可以被安装的包名
String qch_app_forbid = Settings.System.getString(mContext.getContentResolver(), "qch_app_forbid");
Logutils.e("deleteOtherApp", "only_jgy_shortcut_list:" + only_jgy_shortcut_list);
Logutils.e("deleteOtherApp", "qch_app_forbid:" + qch_app_forbid);
String[] result_white = only_jgy_shortcut_list.split(",");
String[] result_forbid = qch_app_forbid.split(",");
if (!TextUtils.isEmpty(qch_app_forbid)) {
result_forbid = qch_app_forbid.split(",");
}
Log.e("deleteOtherApp", "only_jgy_shortcut_list:" + only_jgy_shortcut_list);
Log.e("deleteOtherApp", "qch_app_forbid:" + qch_app_forbid);
List<String> resulWhitetList = new ArrayList<>(Arrays.asList(result_white));
List<String> resulForbidtList = new ArrayList<>(Arrays.asList(result_forbid));
resulWhitetList.addAll(resulForbidtList);
HashSet<String> allWhitePkg = new HashSet<>(resulWhitetList);
List<String> installedPackageList = ApkUtils.queryFilterAppInfo(mContext);
Logutils.e("deleteOtherApp", "installedPackageList:" + installedPackageList.toString());
Log.e("deleteOtherApp", "installedPackageList:" + installedPackageList.toString());
if (allWhitePkg.size() > 0) {
for (final String packageName : installedPackageList) {
if (ApkUtils.isSystemApp(mContext, packageName)) {
Logutils.e("deleteOtherApp", "is systemApp:" + packageName);
Log.e("deleteOtherApp", "is systemApp:" + packageName);
continue;
}
if (ApkUtils.desktopAPP.contains(packageName)) {
@@ -1177,11 +1199,11 @@ public class JGYUtils {
}
if (!allWhitePkg.contains(packageName)) {
ApkUtils.UninstallAPP(mContext, packageName);
Logutils.e("deleteOtherApp", "uninstall apkName:" + packageName);
Log.e("deleteOtherApp", "uninstall apkName:" + packageName);
}
}
}
Logutils.e(TAG, "deleteOtherApp: " + "end");
Log.e(TAG, "deleteOtherApp: " + "end");
}
@@ -1204,19 +1226,19 @@ public class JGYUtils {
public void checkBootFile(String url, String MD5) {
String urlFileName = Utils.getFileNamefromURL(url);
File bootFile = new File(PathUtils.getExternalDownloadsPath() + File.separator + "jgy" + File.separator + urlFileName);
Logutils.e(TAG, "checkBootFile: bootFile file path=" + bootFile.getAbsolutePath());
Logutils.e(TAG, "checkBootFile: bootFile exists=" + bootFile.exists() + " isFile=" + bootFile.isFile());
File bootFile = new File(JGYUtils.getInstance().getDownLoadPath() + urlFileName);
Log.e(TAG, "checkBootFile: bootFile file path=" + bootFile.getAbsolutePath());
Log.e(TAG, "checkBootFile: bootFile exists=" + bootFile.exists() + " isFile=" + bootFile.isFile());
if (bootFile.exists() && bootFile.isFile()) {
String oldMd5 = FileUtils.getFileMD5ToString(bootFile);
if (!TextUtils.isEmpty(oldMd5) && oldMd5.equalsIgnoreCase(MD5)) {
Logutils.e(TAG, "checkBootFile: Bootanimation file exists");
Log.e(TAG, "checkBootFile: Bootanimation file exists");
setBootanimation(bootFile.getAbsolutePath());
} else {
JSONObject jsonObject = new JSONObject();
jsonObject.put("MD5", MD5);
Utils.ariaDownload(mContext, url, jsonObject);
Logutils.e(TAG, "checkBootFile: " + "download file");
Log.e(TAG, "checkBootFile: " + "download file");
}
} else {
JSONObject jsonObject = new JSONObject();
@@ -1234,12 +1256,12 @@ public class JGYUtils {
if (!systemFile.exists()) {
systemFile.getParentFile().mkdirs();
File file = systemFile.getParentFile();
Logutils.e(TAG, "setBootanimation: " + file.getAbsolutePath());
Log.e(TAG, "setBootanimation: " + file.getAbsolutePath());
try {
systemFile.createNewFile();
} catch (IOException e) {
e.printStackTrace();
Logutils.e("setBootanimation: ", "createNewFile: " + e.getMessage());
Log.e("setBootanimation: ", "createNewFile: " + e.getMessage());
}
}
File newFile = new File(filePath);
@@ -1247,31 +1269,31 @@ public class JGYUtils {
String systemMD5 = FileUtils.getFileMD5ToString(systemFile);
String newMD5 = FileUtils.getFileMD5ToString(newFile);
if (systemMD5.equals(newMD5)) {
Logutils.e(TAG, "setBootanimation: 文件一致");
Log.e(TAG, "setBootanimation: 文件一致");
} else {
Path path = Paths.get(newFile.getAbsolutePath());
try {
Files.copy(path, new FileOutputStream(systemFile));
Logutils.e(TAG, "setBootanimation: 设置新开机动画");
Log.e(TAG, "setBootanimation: 设置新开机动画");
} catch (IOException e) {
Logutils.e(TAG, "setBootanimation: IOException: " + e.getMessage());
Log.e(TAG, "setBootanimation: IOException: " + e.getMessage());
e.printStackTrace();
}
}
} else {
File file = new File(BOOTANIMATION_PATH);
Logutils.e(TAG, "setBootanimation: " + file.getParentFile().getAbsolutePath());
Logutils.e(TAG, "setBootanimation: " + "Is a directory = " + file.isDirectory());
Log.e(TAG, "setBootanimation: " + file.getParentFile().getAbsolutePath());
Log.e(TAG, "setBootanimation: " + "Is a directory = " + file.isDirectory());
if (!file.getParentFile().delete()) {
Logutils.e(TAG, "setBootanimation: " + "系统动画删除失败");
Log.e(TAG, "setBootanimation: " + "系统动画删除失败");
}
Path path = Paths.get(newFile.getAbsolutePath());
try {
Files.copy(path, new FileOutputStream(systemFile));
copy(systemFile.getAbsolutePath(), newFile.getAbsolutePath());
Logutils.e(TAG, "setBootanimation: 设置新开机动画");
Log.e(TAG, "setBootanimation: 设置新开机动画");
} catch (IOException e) {
Logutils.e(TAG, "setBootanimation: IOException: " + e.getMessage());
Log.e(TAG, "setBootanimation: IOException: " + e.getMessage());
e.printStackTrace();
}
}
@@ -1281,9 +1303,9 @@ public class JGYUtils {
File systemFile = new File(BOOTANIMATION_PATH);
if (systemFile.exists()) {
if (systemFile.delete()) {
Logutils.e(TAG, "removeBootanimation: delete: " + "ture");
Log.e(TAG, "removeBootanimation: delete: " + "ture");
} else {
Logutils.e(TAG, "removeBootanimation: delete: " + "false");
Log.e(TAG, "removeBootanimation: delete: " + "false");
}
}
}
@@ -1306,7 +1328,7 @@ public class JGYUtils {
inStream.close();
}
} catch (Exception e) {
Logutils.e(TAG, "setBootanimation: " + e.getMessage());
Log.e(TAG, "setBootanimation: " + e.getMessage());
e.printStackTrace();
}
}
@@ -1336,7 +1358,7 @@ public class JGYUtils {
field.setAccessible(true);
Object sProviderInstance = field.get(null);
if (sProviderInstance != null) {
Logutils.i(TAG, "sProviderInstance isn't null");
Log.i(TAG, "sProviderInstance isn't null");
return;
}
@@ -1346,7 +1368,7 @@ public class JGYUtils {
} else if (sdkInt == 22) {
getProviderClassMethod = factoryClass.getDeclaredMethod("getFactoryClass");
} else {
Logutils.i(TAG, "Don't need to Hook WebView");
Log.i(TAG, "Don't need to Hook WebView");
return;
}
getProviderClassMethod.setAccessible(true);
@@ -1375,23 +1397,23 @@ public class JGYUtils {
if (sProviderInstance != null) {
field.set("sProviderInstance", sProviderInstance);
Logutils.i(TAG, "Hook success!");
Log.i(TAG, "Hook success!");
} else {
Logutils.i(TAG, "Hook failed!");
Log.i(TAG, "Hook failed!");
}
} catch (Throwable e) {
Logutils.w(TAG, e.getMessage());
Log.w(TAG, e.getMessage());
}
}
public void deleteScreenshots() {
Logutils.e("File", "deleteScreenshots");
Log.e("File", "deleteScreenshots");
String path = mContext.getExternalFilesDir("db").getAbsolutePath();
File file = new File(path);
File[] files = file.listFiles();
for (File f : files) {
if (f.isFile()) {
Logutils.e("File", f.getAbsolutePath());
Log.e("File", f.getAbsolutePath());
f.delete();
}
}
@@ -1437,7 +1459,7 @@ public class JGYUtils {
}
public void openLauncher() {
Logutils.e(TAG, "openLauncher: ");
Log.e(TAG, "openLauncher: ");
killPackage("com.android.launcher3");
Intent intent = new Intent();
// 为Intent设置Action、Category属性
@@ -1448,16 +1470,16 @@ public class JGYUtils {
}
public void cleanLauncherCache() {
Logutils.e(TAG, "cleanLauncherCache: Start");
Log.e(TAG, "cleanLauncherCache: Start");
int cleaned = (int) SPUtils.get(mContext, "fristcleanLauncherCache", 0);
if (cleaned == 0) {
try {
new CacheUtils().cleanApplicationUserData(mContext, "com.android.launcher3");
SPUtils.put(mContext, "fristcleanLauncherCache", 1);
Logutils.e(TAG, "cleanLauncherCache: end");
Log.e(TAG, "cleanLauncherCache: end");
} catch (Exception e) {
e.printStackTrace();
Logutils.e(TAG, "cleanLauncherCache: " + e.getMessage());
Log.e(TAG, "cleanLauncherCache: " + e.getMessage());
}
}
}
@@ -1469,7 +1491,7 @@ public class JGYUtils {
} else if ("R".equalsIgnoreCase(secondChars)) {//展锐平台
return ZhanruiPlatform;
} else {
Logutils.e(TAG, "checkSNPlatform: " + "sn: " + sn + "没有对应平台");
Log.e(TAG, "checkSNPlatform: " + "sn: " + sn + "没有对应平台");
return UnknowPlatform;
}
}
@@ -1477,13 +1499,13 @@ public class JGYUtils {
public int checkAppPlatform() {
String platform = BuildConfig.platform;
if ("MTK".equalsIgnoreCase(platform)) {
Logutils.i(TAG, "checkAppPlatform: " + "MTK平台");
Log.i(TAG, "checkAppPlatform: " + "MTK平台");
return MTKPlatform;
} else if ("ZhanRui".equalsIgnoreCase(platform)) {
Logutils.i(TAG, "checkAppPlatform: " + "展锐平台");
Log.i(TAG, "checkAppPlatform: " + "展锐平台");
return ZhanruiPlatform;
} else {
Logutils.i(TAG, "checkAppPlatform: " + "没有数据");
Log.i(TAG, "checkAppPlatform: " + "没有数据");
return UnknowPlatform;
}
}
@@ -1554,7 +1576,7 @@ public class JGYUtils {
for (ActivityManager.RecentTaskInfo info : list) {
if (info.realActivity != null) {
Logutils.e(TAG, "removeAllTask: " + info.realActivity.getPackageName());
Log.e(TAG, "removeAllTask: " + info.realActivity.getPackageName());
//排除自身
if (BuildConfig.APPLICATION_ID.equals(info.realActivity.getPackageName())) {
continue;
@@ -1564,7 +1586,7 @@ public class JGYUtils {
ActivityManagerNative.getDefault().removeTask(info.id);
} catch (RemoteException e) {
e.printStackTrace();
Logutils.e(TAG, "removeAllTask: " + e.getMessage());
Log.e(TAG, "removeAllTask: " + e.getMessage());
}
}
}
@@ -1579,9 +1601,9 @@ public class JGYUtils {
ActivityManagerNative.getDefault().removeTask(taskMap.get(packageName));
} catch (RemoteException e) {
e.printStackTrace();
Logutils.e(TAG, "removeTask: " + e.getMessage());
Log.e(TAG, "removeTask: " + e.getMessage());
} catch (NullPointerException e) {
Logutils.e(TAG, "removeTask: " + e.getMessage());
Log.e(TAG, "removeTask: " + e.getMessage());
}
}
@@ -1605,7 +1627,7 @@ public class JGYUtils {
return ActivityTaskManager.getService().getRecentTasks(numTasks,
RECENT_IGNORE_UNAVAILABLE, userId).getList();
} catch (RemoteException e) {
Logutils.e(TAG, "Failed to get recent tasks " + e);
Log.e(TAG, "Failed to get recent tasks " + e);
return new ArrayList<>();
}
}
@@ -1757,7 +1779,7 @@ public class JGYUtils {
private void openLauncher3() {
setDefaultDesktop(Launcher3, Launcher3Class);
ApkUtils.openApp(mContext, Launcher3);
ApkUtils.openPackage(mContext, Launcher3);
}
public String getStartClassName(String pkg) {
@@ -1806,7 +1828,7 @@ public class JGYUtils {
intent.putExtra("className", className);
intent.setPackage("com.android.settings");
mContext.sendBroadcast(intent);
ApkUtils.openApp(mContext, pkg);
ApkUtils.openPackage(mContext, pkg);
Log.e(TAG, "setDefaultDesktop: " + pkg + ":" + className);
}
@@ -1817,8 +1839,25 @@ public class JGYUtils {
jsonObject.addProperty("jpush_id", JPushInterface.getRegistrationID(mContext));
jsonObject.addProperty("devices_version", Utils.getCustomVersion());
jsonObject.addProperty("appstore_version", BuildConfig.VERSION_NAME);
jsonObject.addProperty("store_version", Utils.getAPPVersionName(mContext));
jsonObject.addProperty("store_version", Utils.getAPPVersionName(PackageNames.APPSTORE, mContext));
jsonObject.addProperty("desktop_version", Utils.getAPPVersionName("com.aoleyun.os", mContext));
jsonObject.addProperty("local_mac", Utils.getAndroid7MAC());
jsonObject.addProperty("wifi_status", Utils.obtainWifiInfo(mContext));
jsonObject.addProperty("PN_ip", (String) SPUtils.get(mContext, "PublicIP", ""));
jsonObject.addProperty("LAN_ip", Utils.getIPAddress(mContext));
jsonObject.addProperty("bluetooth", Utils.getBluetoothList());
jsonObject.addProperty("wifi_name", Utils.getWifiAlias(mContext));
return jsonObject.toString();
}
public void shutdown() {
if (ActivityManagerNative.isSystemReady()) {
Intent intent = new Intent(Intent.ACTION_REQUEST_SHUTDOWN);
intent.putExtra(Intent.EXTRA_KEY_CONFIRM, false);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mContext.startActivity(intent);
}
}
}