bugfixes:修复应用安装开关问题,修改打开之后不会删除应用,id管控默认写入一条无效数据,修复应用安装之后不能联网的问题
This commit is contained in:
2024-10-15 09:30:58 +08:00
parent c6bec5cd43
commit c360344acc
12 changed files with 158 additions and 53 deletions

View File

@@ -138,7 +138,7 @@ public class MainActivity extends BaseMvvmActivity<MainViewModel, ActivityMainBi
Settings.System.putString(getContentResolver(), CommonConfig.ACTIVATIONBEAN_CODE_KEY, Utils.getSerial(this));
}
Log.e(TAG, "initView: " + Build.MODEL);
Log.e(TAG, "initView: Build.MODEL = " + Build.MODEL);
if ("YX-T01".equalsIgnoreCase(Build.MODEL)) {
mViewDataBinding.clBind.setVisibility(View.GONE);
mViewDataBinding.clQrcode.setVisibility(View.VISIBLE);

View File

@@ -15,6 +15,11 @@ public class AoleyunActivityController extends IActivityController.Stub {
@Override
public boolean activityStarting(Intent intent, String pkg) {
Log.e(TAG, "activityStarting: " + pkg + ", intent= " + intent);
// if (JGYUtils.getInstance().isHidedApp(pkg)) {
// return false;
// }
//false 则不会启动,直接返回。
if (JGYUtils.getInstance().isCloudLessonMod(pkg)) {
return true;

View File

@@ -1854,13 +1854,15 @@ public class NetInterfaceManager {
@Override
public void onNext(@NonNull BaseResponse<List<AppID>> baseResponse) {
Log.e("getAppIDControl", "onNext: " + baseResponse);
Settings.System.putString(mContext.getContentResolver(), CommonConfig.APP_VIEW_CLICK_DISABLED, "com.ttstd.utils:12345");
if (baseResponse.code == OK) {
List<AppID> appIDList = baseResponse.data;
cacheHelper.put(UrlAddress.GET_APPID, GsonUtils.toJSONString(appIDList));
JGYUtils.getInstance().writeDeselectIDtoSystem(appIDList);
// JGYUtils.getInstance().writeDeselectIDtoSystem(appIDList);
} else {
cacheHelper.put(UrlAddress.GET_APPID, "");
JGYUtils.getInstance().writeDeselectIDtoSystem(null);
// JGYUtils.getInstance().writeDeselectIDtoSystem(null);
}
}
@@ -1908,19 +1910,9 @@ public class NetInterfaceManager {
Log.e("getSnAppAttr", "onNext: " + baseResponse);
if (baseResponse.code == 200) {
List<AppAttr> appAttrList = baseResponse.data;
if (appAttrList == null || appAttrList.size() == 0) {
Log.e("getSnAppAttr", "onNext: appAttrList is empty");
Settings.Global.putString(mContext.getContentResolver(), CommonConfig.AOLE_ACTION_DISABLE_APP, "null");
} else {
String disableApp = appAttrList.stream()
.filter(appAttr -> appAttr.getIs_open() == 0)
.map(AppAttr::getApp_package)
.collect(Collectors.joining(","));
Log.e("getSnAppAttr", "onNext: disableApp = " + disableApp);
Settings.Global.putString(mContext.getContentResolver(), CommonConfig.AOLE_ACTION_DISABLE_APP, disableApp);
}
setAppDisAble(appAttrList);
} else {
Settings.Global.putString(mContext.getContentResolver(), CommonConfig.AOLE_ACTION_DISABLE_APP, "null");
setAppDisAble(null);
}
}
@@ -1940,6 +1932,32 @@ public class NetInterfaceManager {
};
}
private void setAppDisAble(List<AppAttr> appAttrList) {
String appString = Settings.Global.getString(mContext.getContentResolver(), CommonConfig.AOLE_ACTION_DISABLE_APP);
if (!TextUtils.isEmpty(appString)) {
List<String> pkgs = new ArrayList<>(Arrays.asList(appString.split(",")));
for (String pkg : pkgs) {
JGYUtils.getInstance().showApp(pkg);
}
}
if (appAttrList == null || appAttrList.size() == 0) {
Log.e("getSnAppAttr", "onNext: appAttrList is empty");
Settings.Global.putString(mContext.getContentResolver(), CommonConfig.AOLE_ACTION_DISABLE_APP, "null");
} else {
for (AppAttr appAttr : appAttrList) {
if (appAttr.getIs_open() == 0) {
JGYUtils.getInstance().hideApp(appAttr.getApp_package());
}
}
String disableApp = appAttrList.stream()
.filter(appAttr -> appAttr.getIs_open() == 0)
.map(AppAttr::getApp_package)
.collect(Collectors.joining(","));
Log.e("getSnAppAttr", "onNext: disableApp = " + disableApp);
Settings.Global.putString(mContext.getContentResolver(), CommonConfig.AOLE_ACTION_DISABLE_APP, disableApp);
}
}
public void setSystemSetting(boolean refresh, BehaviorSubject<ActivityEvent> lifecycle, onCompleteCallback callback) {
ConnectMode connectMode = ConnectMode.ONE_HOUR;
@@ -2378,7 +2396,7 @@ public class NetInterfaceManager {
JGYUtils.getInstance().setYxpDefaultDesktop();
}
Settings.System.putInt(mContext.getContentResolver(), JGYActions.ACTION_QCH_UNLOCK_IPAD, JGYActions.FRAME_CODE_LOCKED);
Settings.System.putInt(mContext.getContentResolver(), CommonConfig.AOLE_APP_ALLOW_INSTALL, 0);
// Settings.System.putInt(mContext.getContentResolver(), CommonConfig.AOLE_APP_ALLOW_INSTALL, 0);
} else if (locked == JGYActions.NET_CODE_UNLOCKED) {
// SysSettingUtils.setEnableSetting(mContext);
JGYUtils.getInstance().writeAppPackageList();
@@ -2626,6 +2644,8 @@ public class NetInterfaceManager {
tagSets.add(JGYUtils.MT8768Tag);
} else if (platform == JGYUtils.AUDG104Platform) {
tagSets.add(JGYUtils.AUDG104Tag);
}else if (platform == JGYUtils.HL500Platform) {
tagSets.add(JGYUtils.HL500Tag);
}
});
Log.e(TAG, "clearAndAppendTags: " + tagSets);

View File

@@ -34,7 +34,7 @@ public class RepeatRequestInterceptor implements Interceptor {
Response response = chain.proceed(request);
ResponseBody responseBody = response.body();
//消费请求,导致请求多次
//responseBody.string()消费请求,就会导致多次请求。
String content = responseBody.string();
// Response copy = response.newBuilder().body(responseBody).build();
ResponseBody copy = ResponseBody.create(responseBody.contentType(), content);

View File

@@ -899,7 +899,7 @@ public class PushManager {
String allow = jSONObject.get("not").getAsString();
HashSet<String> disallowApp = new HashSet<>(Arrays.asList(disallow.split(",")));
HashSet<String> allowApp = new HashSet<>(Arrays.asList(allow.split(",")));
JGYUtils.getInstance().setAppNetwork(mContext, disallowApp, allowApp);
JGYUtils.getInstance().setAppNetwork(disallowApp, allowApp);
}
private void settingPowerOn(String s) {

View File

@@ -105,7 +105,6 @@ public class NewAppReceiver extends BroadcastReceiver {
Log.e("sendAppInfo", "onNext: " + s);
// JGYUtils.getInstance().checkForceDownload();
NetInterfaceManager.getInstance().getForceDownload();
JGYUtils.getInstance().updateNetworkWhiteList();
NetInterfaceManager.getInstance().getAppLimit();
NetInterfaceManager.getInstance().getDefaultDesktop();
NetInterfaceManager.getInstance().sendInstalledAppInfo(new NetInterfaceManager.onCompleteCallback() {
@@ -147,7 +146,7 @@ public class NewAppReceiver extends BroadcastReceiver {
@Override
public void onNext(@NonNull String pkg) {
Log.e("setLauncher", "onNext: " + pkg);
JGYUtils.getInstance().setAllowPermissionsPackage(mContext);
JGYUtils.getInstance().setAllowPermissionsPackage();
JGYUtils.getInstance().checkDefaultDesktop(pkg);
String oldDesktop = JGYUtils.getInstance().getDefaultDesktop();
// String oldDesktop = (String) SPUtils.get(mContext, "default_launcher", "");
@@ -155,6 +154,7 @@ public class NewAppReceiver extends BroadcastReceiver {
if (pkg.equals(oldDesktop)) {
ApkUtils.openPackage(mContext, pkg);
}
JGYUtils.getInstance().updateNetworkWhiteList();
}
@Override

View File

@@ -33,9 +33,10 @@ import okhttp3.MultipartBody;
import okhttp3.RequestBody;
public class LogcatService extends Service {
private static final String TAG = "LogcatService";
public final static String LOGCAT_START_ACTION = "START";
public final static String LOGCAT_STOP_ACTION = "STOP";
private String TAG = "LogcatService";
public LogcatService() {

View File

@@ -91,7 +91,6 @@ import java.util.Arrays;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -147,6 +146,7 @@ public class JGYUtils {
public static final int G11Platform = 16;
public static final int MT8768Platform = 17;
public static final int AUDG104Platform = 18;
public static final int HL500Platform = 20;
public static final String Other = "其他";
@@ -165,6 +165,7 @@ public class JGYUtils {
public static final String G11TAG = "MTKG11";
public static final String MT8768Tag = "MT8768";
public static final String AUDG104Tag = "AUDG104";
public static final String HL500Tag = "HL500";
private CacheHelper cacheHelper;
@@ -295,6 +296,9 @@ public class JGYUtils {
} else if (AUDG104Tag.equalsIgnoreCase(platform)) {
Log.i(TAG, "checkAppPlatform: " + "AUDG104");
return AUDG104Platform;
} else if (HL500Tag.equalsIgnoreCase(platform)) {
Log.i(TAG, "checkAppPlatform: " + "HL500");
return HL500Platform;
} else {
Log.i(TAG, "checkAppPlatform: " + "没有数据");
return UnknowPlatform;
@@ -347,6 +351,8 @@ public class JGYUtils {
getAppPlatformCallback.AppPlatform(MT8768Platform);
} else if (AUDG104Tag.equalsIgnoreCase(platform)) {
getAppPlatformCallback.AppPlatform(AUDG104Platform);
} else if (HL500Tag.equalsIgnoreCase(platform)) {
getAppPlatformCallback.AppPlatform(HL500Platform);
} else {
getAppPlatformCallback.AppPlatform(UnknowPlatform);
}
@@ -600,7 +606,7 @@ public class JGYUtils {
// boolean w = Settings.System.putString(crv, "aole_app_power_on", "");
// Log.e(TAG, "setNetAndlaunch: 测试写入: " + w);
// }
setAppNetwork(mContext, disallowNetApp, allowNetApp);
setAppNetwork(disallowNetApp, allowNetApp);
}
public void onBootOpenApp() {
@@ -740,10 +746,10 @@ public class JGYUtils {
// boolean w = Settings.System.putString(crv, "aole_app_power_on", "");
// Log.e(TAG, "setNetAndlaunch: 测试写入: " + w);
// }
setAppNetwork(mContext, disallowNetApp, allowNetApp);
setAppNetwork(disallowNetApp, allowNetApp);
setDisallowNotificationPackage(mContext, disallowNotification);
mMMKV.encode("aole_app_privilege", allowPermissions);
setAllowPermissionsPackage(mContext);
setAllowPermissionsPackage();
}
private void setDisallowNotificationPackage(Context context, HashSet<String> pkgSet) {
@@ -755,62 +761,86 @@ public class JGYUtils {
}
}
public void setAllowPermissionsPackage(Context context) {
public void setAllowPermissionsPackage() {
Set<String> privilegeApp = mMMKV.decodeStringSet("aole_app_privilege", new HashSet<>());
Log.e(TAG, "setAllowPermissionsPackage: " + privilegeApp);
Set<String> pkgSet = privilegeApp.stream().filter(s -> ApkUtils.isAvailable(mContext, s)).collect(Collectors.toSet());
Log.e(TAG, "setAllowPermissionsPackage: " + pkgSet);
if (pkgSet.size() == 0) {
Settings.System.putString(context.getContentResolver(), "aole_app_privilege", "");
Settings.System.putString(crv, "aole_app_privilege", "");
} else {
Settings.System.putString(context.getContentResolver(), "aole_app_privilege", String.join(",", pkgSet));
Settings.System.putString(crv, "aole_app_privilege", String.join(",", pkgSet));
}
}
public void setAppNetwork(Context context, HashSet<String> blackList, HashSet<String> whiteList) {
ContentResolver contentResolver = context.getContentResolver();
public void setAppNetwork(HashSet<String> blackList, HashSet<String> whiteList) {
Log.e(TAG, "setAppNetwork: " + "设置应用联网管控 blackList =" + blackList);
Log.e(TAG, "setAppNetwork: " + "设置应用联网管控 whiteList =" + whiteList);
if (!MTK11Tag.equals(JGYUtils.getInstance().getAppPlatform())) {
if (blackList == null || blackList.size() == 0) {
Settings.System.putString(contentResolver, CommonConfig.AOLE_ACTION_NETWORK_DISALLOW, "");
Settings.System.putString(crv, CommonConfig.AOLE_ACTION_NETWORK_DISALLOW, "");
} else {
String net_not = String.join(",", blackList);
Settings.System.putString(contentResolver, CommonConfig.AOLE_ACTION_NETWORK_DISALLOW, net_not);
Settings.System.putString(crv, CommonConfig.AOLE_ACTION_NETWORK_DISALLOW, net_not);
Log.e(TAG, "setAppNetwork: " + net_not);
}
}
mMMKV.encode(CommonConfig.AOLE_ACTION_NETWORK_ALLOW, whiteList);
if (whiteList == null) {
whiteList = new HashSet<>();
Set<String> pkgs;
int is_app_install = Settings.System.getInt(crv, CommonConfig.AOLE_APP_ALLOW_INSTALL, 0);
if (is_app_install == 1) {
Log.e(TAG, "setAppNetwork: is_app_install = 1");
pkgs = new HashSet<>(ApkUtils.queryFilterAppList(mContext));
} else {
pkgs = new HashSet<>(whiteList);
}
whiteList.add(BuildConfig.APPLICATION_ID);
whiteList.add("com.aoleyun.appstore");
pkgs.add(BuildConfig.APPLICATION_ID);
pkgs.add("com.aoleyun.appstore");
pkgs.add("com.aoleyun.camera");
pkgs.add("com.aoleyun.calculator");
pkgs.add("com.aoleyun.gallery3d");
pkgs.addAll(ApkUtils.mJxwApp);
List<String> filterList = whiteList.stream().filter(s -> ApkUtils.isAvailable(context, s)).collect(Collectors.toList());
List<String> filterList = pkgs.stream().filter(s -> ApkUtils.isAvailable(mContext, s)).collect(Collectors.toList());
Log.e(TAG, "setAppNetwork: filterList = " + filterList);
if (filterList.size() == 0) {
Settings.System.putString(contentResolver, CommonConfig.AOLE_ACTION_NETWORK_ALLOW, "");
Settings.System.putString(crv, CommonConfig.AOLE_ACTION_NETWORK_ALLOW, "");
} else {
Settings.System.putString(contentResolver, CommonConfig.AOLE_ACTION_NETWORK_ALLOW, String.join(",", filterList));
Settings.System.putString(crv, CommonConfig.AOLE_ACTION_NETWORK_ALLOW, String.join(",", filterList));
}
}
/**
* 应用安装之后添加到白名单
*/
public void updateNetworkWhiteList() {
Set<String> pkgs = mMMKV.decodeStringSet(CommonConfig.AOLE_ACTION_NETWORK_ALLOW, new HashSet<>());
if (pkgs.isEmpty()) {
Log.e(TAG, "updateNetworkWhiteList: allow content is empty");
return;
}
List<String> whiteList = new ArrayList<>(pkgs);
List<String> filterList = whiteList.stream().filter(s -> ApkUtils.isAvailable(mContext, s)).collect(Collectors.toList());
if (filterList.size() == 0) {
Set<String> pkgs;
int is_app_install = Settings.System.getInt(crv, CommonConfig.AOLE_APP_ALLOW_INSTALL, 0);
if (is_app_install == 1) {
Log.e(TAG, "updateNetworkWhiteList: is_app_install = 1");
pkgs = new HashSet<>(ApkUtils.queryFilterAppList(mContext));
} else {
pkgs = mMMKV.decodeStringSet(CommonConfig.AOLE_ACTION_NETWORK_ALLOW, new HashSet<>());
}
pkgs.add(BuildConfig.APPLICATION_ID);
pkgs.add("com.aoleyun.appstore");
pkgs.add("com.aoleyun.camera");
pkgs.add("com.aoleyun.calculator");
pkgs.add("com.aoleyun.gallery3d");
pkgs.addAll(ApkUtils.mJxwApp);
List<String> whiteList = new ArrayList<>(pkgs);
List<String> filterList = whiteList.stream().filter(s -> ApkUtils.isAvailable(mContext, s)).collect(Collectors.toList());
Log.e(TAG, "updateNetworkWhiteList: filterList = " + filterList);
if (filterList.size() == 0) {
Settings.System.putString(crv, CommonConfig.AOLE_ACTION_NETWORK_ALLOW, "");
} else {
Settings.System.putString(crv, CommonConfig.AOLE_ACTION_NETWORK_ALLOW, String.join(",", filterList));
}
Log.e(TAG, "updateNetworkWhiteList: " + filterList);
}
@@ -1551,8 +1581,15 @@ public class JGYUtils {
}
int aihuaUnlock = Settings.System.getInt(crv, CommonConfig.AIHUA_UNLOCK, 0);
if (aihuaUnlock == 1) {
Log.e(TAG, "deleteOtherApp: aihuaUnlock");
return;
}
int is_app_install = Settings.System.getInt(crv, CommonConfig.AOLE_APP_ALLOW_INSTALL, 0);
if (is_app_install == 1) {
Log.e(TAG, "deleteOtherApp: is_app_install = 1");
return;
}
Log.e(TAG, "deleteOtherApp: " + "start");
String[] result_white = new String[]{};
String[] result_forbid = new String[]{};
@@ -3309,4 +3346,18 @@ public class JGYUtils {
return info.applicationInfo.loadLabel(pm).toString();
}
}
/**
* @param pkg
* @return
*/
public boolean isHidedApp(String pkg) {
String appString = Settings.Global.getString(mContext.getContentResolver(), CommonConfig.AOLE_ACTION_DISABLE_APP);
if (TextUtils.isEmpty(appString)) {
return true;
} else {
List<String> pkgs = new ArrayList<>(Arrays.asList(appString.split(",")));
return pkgs.contains(pkg);
}
}
}

View File

@@ -986,7 +986,8 @@ public class SysSettingUtils {
}
}
int is_storeinstall = snSetting.getIs_storeinstall();
Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_APP_ALLOW_INSTALL, is_storeinstall);
// TODO: 2024/10/12 待更换为 AOLEYUN_APPSTORE_INSTALL
Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLEYUN_APPSTORE_INSTALL, is_storeinstall);
int is_usb = snSetting.getIs_usb();
setUsb(context, is_usb);
int is_bluetooth_file = snSetting.getIs_bluetooth_file();
@@ -1008,7 +1009,7 @@ public class SysSettingUtils {
if (null != c) {
Log.e("getTimeControl", c.toString());
}
Settings.Global.putInt(context.getContentResolver(), CommonConfig.AOLE_APP_ALLOW_INSTALL, 1);
Settings.Global.putInt(context.getContentResolver(), CommonConfig.AOLEYUN_APPSTORE_INSTALL, 1);
setUsb(context, 0);
setBluetoothTransmission(context, 0);
// JGYUtils.getInstance().setDeveloperOptions(0);

View File

@@ -795,6 +795,9 @@ public class Utils {
* @return
*/
public static String getSerial(Context context) {
if ("HL500".equals(Build.MODEL)){
return getIMEI(context);
}
if (TECLAST_BRAND.equalsIgnoreCase(Build.BRAND)) {
return getPushMac(context);
} else {
@@ -1782,6 +1785,7 @@ public class Utils {
|| JGYUtils.getInstance().checkAppPlatform() == JGYUtils.G11Platform
|| JGYUtils.getInstance().checkAppPlatform() == JGYUtils.MT8768Platform
|| JGYUtils.getInstance().checkAppPlatform() == JGYUtils.AUDG104Platform
|| JGYUtils.getInstance().checkAppPlatform() == JGYUtils.HL500Platform
) {
return Utils.getProperty("ro.build.display.id", "获取失败");
} else {