version:3.9
fix:修复系统设置管控失败 update:
This commit is contained in:
@@ -175,12 +175,8 @@ public class NetInterfaceManager {
|
||||
private NetInterfaceManager(Context context) {
|
||||
this.mContext = context;
|
||||
this.cacheHelper = new CacheHelper(mContext);
|
||||
|
||||
if (okHttpClient == null) {
|
||||
try {
|
||||
mDiskLruCacheHelper = new DiskLruCacheHelper(mContext);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
/**
|
||||
* 有网时候的缓存
|
||||
*/
|
||||
@@ -518,6 +514,7 @@ public class NetInterfaceManager {
|
||||
* API
|
||||
*
|
||||
* */
|
||||
|
||||
public UploadAppInfoApi getUploadAppInfoApi() {
|
||||
return mRetrofit.create(UploadAppInfoApi.class);
|
||||
}
|
||||
@@ -1792,7 +1789,7 @@ public class NetInterfaceManager {
|
||||
Set<String> set = new HashSet<>();
|
||||
JGYUtils.getInstance().getAppPlatform(new JGYUtils.GetAppPlatformCallback() {
|
||||
@Override
|
||||
public void getAppPlatform(int platform) {
|
||||
public void AppPlatform(int platform) {
|
||||
if (platform == JGYUtils.MTKPlatform) {
|
||||
set.add(JGYUtils.MTKTag);
|
||||
} else if (platform == JGYUtils.ZhanruiPlatform) {
|
||||
|
||||
@@ -76,10 +76,11 @@ public class MainSContact {
|
||||
void getSnTimeControl();
|
||||
/*获取电子书包激活码*/
|
||||
void getEBagCode();
|
||||
/*获取屏幕锁状态*/
|
||||
void getScreenLockState();
|
||||
/*获取wifi密码*/
|
||||
void getWiFiPasswd();
|
||||
|
||||
/*获取屏幕锁状态*/
|
||||
void getScreenLockState();
|
||||
}
|
||||
|
||||
public interface MainView extends BaseView {
|
||||
@@ -149,9 +150,10 @@ public class MainSContact {
|
||||
void getSnTimeControlFinish();
|
||||
/*获取电子书包激活码*/
|
||||
void getEBagCodeFinish();
|
||||
/*设置屏幕锁状态结束*/
|
||||
void setScreenLockStateFinish(boolean locked, String tips);
|
||||
/*获取wifi密码结束*/
|
||||
void setWiFiPasswd();
|
||||
|
||||
/*设置屏幕锁状态结束*/
|
||||
void setScreenLockStateFinish(boolean locked, String tips);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -444,16 +444,6 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void getScreenLockState() {
|
||||
NetInterfaceManager.getInstance().getScreenLockState(true, getLifecycle(), new NetInterfaceManager.ScreenLockStateListener() {
|
||||
@Override
|
||||
public void setScreenLockState(boolean locked, String tips) {
|
||||
mView.setScreenLockStateFinish(locked, tips);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getWiFiPasswd() {
|
||||
NetInterfaceManager.getInstance()
|
||||
@@ -464,4 +454,15 @@ public class MainSPresenter implements MainSContact.Presenter {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getScreenLockState() {
|
||||
NetInterfaceManager.getInstance().getScreenLockState(true, getLifecycle(), new NetInterfaceManager.ScreenLockStateListener() {
|
||||
@Override
|
||||
public void setScreenLockState(boolean locked, String tips) {
|
||||
mView.setScreenLockStateFinish(locked, tips);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -986,7 +986,12 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
||||
|
||||
@Override
|
||||
public void getEBagCodeFinish() {
|
||||
mPresenter.getScreenLockState();
|
||||
mPresenter.getWiFiPasswd();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWiFiPasswd() {
|
||||
Log.e(TAG, "setWiFiPasswd: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1009,8 +1014,5 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
||||
mPresenter.getWiFiPasswd();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWiFiPasswd() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ public class CacheUtils {
|
||||
PackageStatsObserver observer = new PackageStatsObserver();
|
||||
// wait on observer
|
||||
synchronized (observer) {
|
||||
Method method = PackageManager.class.getMethod("getPackageSizeInfo", new Class[] { String.class, IPackageStatsObserver.class });
|
||||
Method method = PackageManager.class.getMethod("getPackageSizeInfo", new Class[]{String.class, IPackageStatsObserver.class});
|
||||
method.invoke(context.getPackageManager(), packageName, observer);
|
||||
// getPm().getPackageSizeInfo(packageName, UserHandle.myUserId(), observer);
|
||||
long waitTime = 0;
|
||||
@@ -65,11 +65,12 @@ public class CacheUtils {
|
||||
* @throws Exception
|
||||
*/
|
||||
public boolean cleanApplicationUserData(Context context, String packageName) throws Exception {
|
||||
Log.e(TAG, "cleanApplicationUserData: " + packageName);
|
||||
try {
|
||||
PackageDataObserver observer = new PackageDataObserver();
|
||||
// wait on observer
|
||||
synchronized (observer) {
|
||||
Method method = PackageManager.class.getMethod("clearApplicationUserData", new Class[] { String.class, IPackageDataObserver.class });
|
||||
Method method = PackageManager.class.getMethod("clearApplicationUserData", new Class[]{String.class, IPackageDataObserver.class});
|
||||
method.invoke(context.getPackageManager(), packageName, observer);
|
||||
// getPm().deleteApplicationCacheFiles(appid, observer);
|
||||
long waitTime = 0;
|
||||
@@ -133,6 +134,5 @@ public class CacheUtils {
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -2,16 +2,16 @@ package com.aoleyun.sn.utils;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
import static com.google.gson.JsonParser.parseString;
|
||||
|
||||
public class GsonUtils {
|
||||
public static JsonObject getJsonObject(String jsonString) {
|
||||
JsonObject jsonObject = parseString(new Gson().toJson(jsonString)).getAsJsonObject();
|
||||
JsonObject jsonObject = JsonParser.parseString(jsonString).getAsJsonObject();
|
||||
return jsonObject;
|
||||
}
|
||||
|
||||
|
||||
@@ -1584,17 +1584,17 @@ public class JGYUtils {
|
||||
}
|
||||
|
||||
public interface GetAppPlatformCallback {
|
||||
void getAppPlatform(int platform);
|
||||
void AppPlatform(int platform);
|
||||
}
|
||||
|
||||
public void getAppPlatform(GetAppPlatformCallback getAppPlatformCallback) {
|
||||
String platform = BuildConfig.platform;
|
||||
if ("MTK".equalsIgnoreCase(platform)) {
|
||||
getAppPlatformCallback.getAppPlatform(MTKPlatform);
|
||||
getAppPlatformCallback.AppPlatform(MTKPlatform);
|
||||
} else if ("ZhanRui".equalsIgnoreCase(platform)) {
|
||||
getAppPlatformCallback.getAppPlatform(ZhanruiPlatform);
|
||||
getAppPlatformCallback.AppPlatform(ZhanruiPlatform);
|
||||
} else {
|
||||
getAppPlatformCallback.getAppPlatform(UnknowPlatform);
|
||||
getAppPlatformCallback.AppPlatform(UnknowPlatform);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,6 @@ public class SysSettingUtils {
|
||||
}
|
||||
JSONObject jsonObject = JSON.parseObject(jsonObj);
|
||||
setPhoneList(context, jsonObject);
|
||||
setUSBstate(context, jsonObject);
|
||||
setBluetooth(context, jsonObject);
|
||||
setHotspot(context, jsonObject);
|
||||
setBar(context, jsonObject);
|
||||
@@ -55,20 +54,8 @@ public class SysSettingUtils {
|
||||
SPUtils.put(context, JGYActions.ACTION_STATUSBAR_STATUS, jsonObject.getJSONObject("setting_nav").toJSONString());
|
||||
setStatusBar(context, navJson);
|
||||
setBrowserInput(context, jsonObject);
|
||||
//otg开关
|
||||
// int setting_otg = changeNum(jsonObject.getInteger("setting_otg"));
|
||||
// Log.e(TAG, "setting_otg---------" + setting_otg);
|
||||
// String otgStatus = "";
|
||||
// switch (setting_otg) {
|
||||
// case 0:
|
||||
// otgStatus = "qch_otg_open";
|
||||
// break;
|
||||
// case 1:
|
||||
// otgStatus = "qch_otg_forbid";
|
||||
// break;
|
||||
// }
|
||||
// Intent otgIntent = new Intent(otgStatus);
|
||||
// sendBroadcast(otgIntent);
|
||||
// TODO: 2022/4/11 不是酷比定制的会报错,无法抛出异常
|
||||
setUSBstate(context, jsonObject);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -194,29 +181,25 @@ public class SysSettingUtils {
|
||||
String setting_usb = jsonObject.getString("setting_usb");
|
||||
if (!BuildConfig.DEBUG) {
|
||||
SuperPower mService = (SuperPower) context.getSystemService("mdm");
|
||||
try {
|
||||
boolean aole_usb_choose = Settings.System.putString(context.getContentResolver(), "aole_usb_choose", setting_usb);
|
||||
Log.e("setUSBstate", "aole_usb_choose---------" + aole_usb_choose);
|
||||
String usbStatus = "";
|
||||
switch (setting_usb) {
|
||||
case "usb_charge":
|
||||
mService.setUSBDataDisabled(true);
|
||||
usbStatus = "aole_action_usb_usb_charge";
|
||||
break;
|
||||
case "usb_mtp":
|
||||
mService.setUSBDataDisabled(false);
|
||||
usbStatus = "aole_action_usb_usb_mtp";
|
||||
break;
|
||||
case "usb_midi":
|
||||
usbStatus = "aole_action_usb_usb_midi";
|
||||
break;
|
||||
boolean aole_usb_choose = Settings.System.putString(context.getContentResolver(), "aole_usb_choose", setting_usb);
|
||||
Log.e("setUSBstate", "aole_usb_choose---------" + aole_usb_choose);
|
||||
String usbStatus = "";
|
||||
switch (setting_usb) {
|
||||
case "usb_charge":
|
||||
mService.setUSBDataDisabled(true);
|
||||
usbStatus = "aole_action_usb_usb_charge";
|
||||
break;
|
||||
case "usb_mtp":
|
||||
mService.setUSBDataDisabled(false);
|
||||
usbStatus = "aole_action_usb_usb_mtp";
|
||||
break;
|
||||
case "usb_midi":
|
||||
usbStatus = "aole_action_usb_usb_midi";
|
||||
break;
|
||||
|
||||
}
|
||||
Intent usbIntent = new Intent(usbStatus).setPackage("com.android.settings");
|
||||
context.sendBroadcast(usbIntent);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "setUSBstate: " + e.getMessage());
|
||||
}
|
||||
Intent usbIntent = new Intent(usbStatus).setPackage("com.android.settings");
|
||||
context.sendBroadcast(usbIntent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -928,23 +928,7 @@ public class Utils {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取电量
|
||||
*
|
||||
* @param mContext
|
||||
* @return
|
||||
*/
|
||||
synchronized private static int getBatteryLevel(Context mContext) {
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
return ((BatteryManager) mContext.getSystemService(Context.BATTERY_SERVICE)).getIntProperty(4);
|
||||
} else {
|
||||
Intent intent = (new ContextWrapper(mContext)).registerReceiver(null, new IntentFilter("android.intent.action.BATTERY_CHANGED"));
|
||||
return intent.getIntExtra("level", -1) * 100 / intent.getIntExtra("scale", -1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
* 更新应用白名单禁止升级
|
||||
*
|
||||
* @param context
|
||||
@@ -1269,6 +1253,7 @@ public class Utils {
|
||||
jsonObject.put("charging", charging);
|
||||
jsonObject.put("memory", memory);
|
||||
jsonObject.put("storage", storage);
|
||||
jsonObject.put("battery_capacity", Utils.getBatterymAh(context));
|
||||
jsonObject.put("CPU", CPU + "核");
|
||||
String jsonString = jsonObject.toJSONString();
|
||||
Log.e(TAG, "getHardware: " + jsonString);
|
||||
@@ -1312,6 +1297,36 @@ public class Utils {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static double getBatterymAh(Context context) {
|
||||
Object mPowerProfile;
|
||||
double batteryCapacity = 0; //电池的容量mAh
|
||||
final String POWER_PROFILE_CLASS = "com.android.internal.os.PowerProfile";
|
||||
try {
|
||||
mPowerProfile = Class.forName(POWER_PROFILE_CLASS).getConstructor(Context.class).newInstance(context);
|
||||
batteryCapacity = (double) Class.forName(POWER_PROFILE_CLASS).getMethod("getBatteryCapacity").invoke(mPowerProfile);
|
||||
Log.e("getBattery", "battery mAh: " + batteryCapacity);
|
||||
} catch (Exception e) {
|
||||
Log.e("getBattery", "get batteryCapacity mAh error:" + batteryCapacity);
|
||||
e.printStackTrace();
|
||||
}
|
||||
return batteryCapacity;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取电量
|
||||
*
|
||||
* @param mContext
|
||||
* @return
|
||||
*/
|
||||
synchronized private static int getBatteryLevel(Context mContext) {
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
return ((BatteryManager) mContext.getSystemService(Context.BATTERY_SERVICE)).getIntProperty(4);
|
||||
} else {
|
||||
Intent intent = (new ContextWrapper(mContext)).registerReceiver(null, new IntentFilter("android.intent.action.BATTERY_CHANGED"));
|
||||
return intent.getIntExtra("level", -1) * 100 / intent.getIntExtra("scale", -1);
|
||||
}
|
||||
}
|
||||
|
||||
public static int getBatteryPercentage(Context context) {
|
||||
|
||||
IntentFilter iFilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
|
||||
|
||||
Reference in New Issue
Block a user