version:6.4.0

fix:
update:更换推送
This commit is contained in:
2023-06-17 09:38:37 +08:00
parent 539203e818
commit 8c948e62be
28 changed files with 1153 additions and 710 deletions

View File

@@ -81,25 +81,32 @@ android {
//酷比魔方
cube {
flavorDimensions "default"
versionCode 79
versionName "6.3.9"
versionCode 80
versionName "6.4.0"
buildConfigField "String", "platform", '"ZhanRuiCube"'
}
//MTK
MTKnewly {
flavorDimensions "default"
versionCode 54
versionName "2.4.4"
versionCode 55
versionName "2.4.5"
buildConfigField "String", "platform", '"MTK"'
}
Huaruian {
flavorDimensions "default"
versionCode 7
versionName "1.0.6"
versionCode 8
versionName "1.0.7"
buildConfigField "String", "platform", '"MTK11"'
}
Teclast {
flavorDimensions "default"
versionCode 8
versionName "1.0.7"
buildConfigField "String", "platform", '"P20S"'
}
}
sourceSets {
@@ -108,7 +115,6 @@ android {
// newly.res.srcDirs = ['src/beta/res']
}
//签名
signingConfigs {
zhanRui {
@@ -164,6 +170,14 @@ android {
v1SigningEnabled true
v2SigningEnabled true
}
P20S {
storeFile file("keystore/MTKP20S.keystore")
storePassword "123456"
keyAlias "MTKP20S"
keyPassword "123456"
v2SigningEnabled false
}
}
// Disable release builds for now
@@ -227,6 +241,18 @@ android {
signingConfig signingConfigs.G10PUserDebug
}
TeclastP20SDebug.initWith(debug)
TeclastP20SDebug {
debuggable true
versionNameSuffix "-debug"
signingConfig signingConfigs.P20S
}
TeclastP20SRelease.initWith(release)
TeclastP20SRelease {
signingConfig signingConfigs.P20S
}
zhanRuiDebug.initWith(debug)
zhanRuiDebug {
debuggable true
@@ -304,6 +330,7 @@ dependencies {
compileOnly files('libs/framework.jar')
compileOnly files('libs/cube_mdm.jar')
compileOnly files('libs/cube_sdk_v1.0.0.jar')
implementation files('libs/vendor.mediatek.hardware.nvram-V1.0-java.jar')
implementation 'androidx.recyclerview:recyclerview:1.2.1'
implementation 'androidx.cardview:cardview:1.0.0'
@@ -349,14 +376,16 @@ dependencies {
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.9.1'
//磁盘缓存
implementation 'com.jakewharton:disklrucache:2.0.2'
//fastjson
implementation 'com.alibaba:fastjson:1.2.83'
//阿里云推送
implementation 'com.aliyun.ams:alicloud-android-push:3.8.0'
// //fastjson
// implementation 'com.alibaba:fastjson:1.2.83'
//百度地图
implementation 'com.baidu.lbsyun:BaiduMapSDK_Location:9.1.8'
//MMKV
implementation 'com.tencent:mmkv-static:1.2.13'
//腾讯移动推送 TPNS
implementation 'com.tencent.tpns:tpns:1.3.2.0-release'
implementation 'com.tencent.tpns:tpns:1.4.0.1-release'
//工具类
implementation 'com.blankj:utilcodex:1.31.0'
//Aria

Binary file not shown.

Binary file not shown.

View File

@@ -309,77 +309,9 @@
android:name="org.apache.http.legacy"
android:required="false" />
<!-- 【必须】 移动推送 TPNS 默认通知 -->
<activity
android:name="com.tencent.android.tpush.TpnsActivity"
android:theme="@android:style/Theme.Translucent.NoTitleBar">
<intent-filter>
<data
android:host="com.aoleyun.sn"
android:scheme="tpns" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<!-- 【必须】 移动推送 TPNS receiver广播接收 -->
<receiver
android:name="com.tencent.android.tpush.XGPushReceiver"
android:process=":xg_vip_service">
<intent-filter android:priority="0x7fffffff">
<!-- 【必须】 移动推送 TPNS SDK的内部广播 -->
<action android:name="com.tencent.android.xg.vip.action.SDK" />
<action android:name="com.tencent.android.xg.vip.action.INTERNAL_PUSH_MESSAGE" />
<action android:name="com.tencent.android.xg.vip.action.ACTION_SDK_KEEPALIVE" />
<!-- 【可选】 系统广播:网络切换 -->
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
<!-- 【可选】 系统广播:开屏 -->
<action android:name="android.intent.action.USER_PRESENT" />
<!-- 【可选】 一些常用的系统广播,增强移动推送 TPNS service的复活机会请根据需要选择。当然您也可以添加App自定义的一些广播让启动service -->
<action android:name="android.bluetooth.adapter.action.STATE_CHANGED" />
<action android:name="android.intent.action.ACTION_POWER_CONNECTED" />
<action android:name="android.intent.action.ACTION_POWER_DISCONNECTED" />
</intent-filter>
</receiver>
<!-- 【必须】移动推送 TPNS service -->
<service
android:name="com.tencent.android.tpush.service.XGVipPushService"
android:persistent="true"
android:process=":xg_vip_service" />
<!-- 【必须】通知 service android:name 部分改为包名.XGVIP_PUSH_ACTION -->
<service
android:name="com.tencent.android.tpush.rpc.XGRemoteService"
android:exported="false">
<intent-filter>
<!-- 【必须】请修改为当前APP名包.XGVIP_PUSH_ACTION -->
<action android:name="com.aoleyun.sn.XGVIP_PUSH_ACTION" />
</intent-filter>
</service>
<!-- 【必须】【注意】authorities 修改为包名.XGVIP_PUSH_AUTH -->
<provider
android:name="com.tencent.android.tpush.XGPushProvider"
android:authorities="com.aoleyun.sn.XGVIP_PUSH_AUTH" />
<!-- 【必须】【注意】authorities 修改为包名.TPUSH_PROVIDER -->
<provider
android:name="com.tencent.android.tpush.SettingsContentProvider"
android:authorities="com.aoleyun.sn.TPUSH_PROVIDER" />
<!-- 【可选】用于增强保活能力 -->
<provider
android:name="com.tencent.android.tpush.XGVipPushKAProvider"
android:authorities="com.aoleyun.sn.AUTH_XGPUSH_KEEPALIVE"
android:exported="true"
tools:replace="android:exported" />
<!-- 【可选】APP实现的Receiver用于接收消息透传和操作结果的回调请根据需要添加 -->
<!-- YOUR_PACKAGE_PATH.CustomPushReceiver需要改为自己的Receiver -->
<receiver android:name="com.aoleyun.sn.tpush.MessageReceiver">
<receiver android:name="com.aoleyun.sn.push.tpush.MessageReceiver">
<intent-filter>
<!-- 接收消息透传 -->
<action android:name="com.tencent.android.xg.vip.action.PUSH_MESSAGE" />
@@ -388,18 +320,35 @@
</intent-filter>
</receiver>
<!-- MQTT START -->
<!-- 消息接收监听器 (用户可自主扩展) -->
<receiver
android:name=".push.alipush.AliyunMessageReceiver"
android:exported="false">
<intent-filter>
<action android:name="com.alibaba.push2.action.NOTIFICATION_OPENED" />
</intent-filter>
<intent-filter>
<action android:name="com.alibaba.push2.action.NOTIFICATION_REMOVED" />
</intent-filter>
<intent-filter>
<action android:name="com.alibaba.sdk.android.push.RECEIVE" />
</intent-filter>
</receiver>
<service
android:name="com.tencent.tpns.mqttchannel.services.MqttService"
android:exported="false"
android:process=":xg_vip_service" />
<provider
android:name="com.tencent.tpns.baseapi.base.SettingsContentProvider"
android:authorities="com.aoleyun.sn.XG_SETTINGS_PROVIDER"
android:exported="false" />
<!-- MQTT END-->
android:name=".push.alipush.AliMessageIntentService"
android:exported="false">
<intent-filter>
<action android:name="com.alibaba.push2.action.NOTIFICATION_OPENED" />
</intent-filter>
<intent-filter>
<action android:name="com.alibaba.push2.action.NOTIFICATION_REMOVED" />
</intent-filter>
<intent-filter>
<action android:name="com.alibaba.sdk.android.push.RECEIVE" />
</intent-filter>
</service>
<!-- 【必须】 请修改为 APP 的 AccessId“15”开头的10位数字中间没空格 -->
<meta-data
@@ -415,6 +364,14 @@
<meta-data
android:name="com.baidu.lbsapi.API_KEY"
android:value="bQxx6zC6AvZ6O41UUPYq6X1LsQuC36dh" />
<!-- 请填写你自己的- appKey -->
<meta-data
android:name="com.alibaba.app.appkey"
android:value="333598267" />
<!-- 请填写你自己的appSecret -->
<meta-data
android:name="com.alibaba.app.appsecret"
android:value="300dfca550f248598bc8b86c6cb9e76e" />
</application>
</manifest>

View File

@@ -85,7 +85,7 @@ public class MainAPresenter implements MainAContact.Presenter {
@Override
public void getQrCode(boolean loocked) {
String encryptString = CXAESUtil.encrypt(CommonConfig.AES_KEY, Utils.getSerial());
String encryptString = CXAESUtil.encrypt(CommonConfig.AES_KEY, Utils.getSerial(mContext));
Log.e("getQRCode", "setImageAndText: " + encryptString);
Bitmap bitmap = Utils.createQRImage(encryptString, 400, 400);
mView.setQrCode(bitmap);

View File

@@ -252,7 +252,12 @@ public class MainActivity extends BaseActivity implements MainAContact.MainView,
tv_model.setText(Build.MODEL);
String sn = Utils.getSerial(this);
Log.e(TAG, "getDevicesInfo: " + sn);
tv_serial.setText(sn);
Log.e(TAG, "getDevicesInfo: " + Utils.getMac());
if (TextUtils.isEmpty(sn)) {
tv_serial.setText(getString(R.string.no_data));
} else {
tv_serial.setText(sn);
}
getIMEI();
setMac();
checkSnError(sn);
@@ -264,7 +269,7 @@ public class MainActivity extends BaseActivity implements MainAContact.MainView,
}
private void getIMEI() {
if (!Utils.NOSN.equalsIgnoreCase(Utils.getSerial())) {
if (!Utils.NOSN.equalsIgnoreCase(Utils.getSerial(this))) {
tv_imei.setText(Utils.getIMEI(this, 1));
} else {
if (!TextUtils.isEmpty(Utils.getIMEI(this, 1))) {

View File

@@ -5,10 +5,14 @@ import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import android.os.Process;
import android.text.TextUtils;
import android.util.Log;
import androidx.multidex.MultiDexApplication;
import com.alibaba.sdk.android.push.CloudPushService;
import com.alibaba.sdk.android.push.CommonCallback;
import com.alibaba.sdk.android.push.noonesdk.PushServiceFactory;
import com.aoleyun.sn.BuildConfig;
import com.aoleyun.sn.bean.BaseResponse;
import com.aoleyun.sn.comm.CommonConfig;
@@ -17,6 +21,7 @@ import com.aoleyun.sn.manager.ConnectManager;
import com.aoleyun.sn.manager.FileManager;
import com.aoleyun.sn.network.NetInterfaceManager;
import com.aoleyun.sn.network.UrlAddress;
import com.aoleyun.sn.push.PushManager;
import com.aoleyun.sn.rlog.LogDBManager;
import com.aoleyun.sn.statistics.AppInformation;
import com.aoleyun.sn.statistics.StatisticsInfo;
@@ -73,7 +78,9 @@ public class BaseApplication extends MultiDexApplication {
String rootDir = MMKV.initialize(this);
Log.e(TAG, "mmkv root: " + rootDir);
PushManager.init(this);
tPushInit();
aliyunPushInit();
ToastUtil.init(this);
NetInterfaceManager.init(this);
JGYUtils.init(this);
@@ -126,20 +133,22 @@ public class BaseApplication extends MultiDexApplication {
Log.e("TPush", "注册成功设备token为" + data);
MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE).encode("XGPushtoken", data.toString());
List<XGPushManager.AccountInfo> accountInfoList = new ArrayList<>();
accountInfoList.add(new XGPushManager.AccountInfo(XGPushManager.AccountType.CUSTOM.getValue(), Utils.getSerial(getApplicationContext())));
if (Utils.NOSN.equalsIgnoreCase(Utils.getSerial())) {
String sn = Utils.getSerial(getApplicationContext());
Log.e("TPush", "onSuccess: " + sn);
accountInfoList.add(new XGPushManager.AccountInfo(XGPushManager.AccountType.CUSTOM.getValue(), sn));
if (Utils.NOSN.equalsIgnoreCase(sn)) {
accountInfoList.add(new XGPushManager.AccountInfo(XGPushManager.AccountType.CUSTOM.getValue(), Utils.getIMEI(getApplicationContext(), 0)));
accountInfoList.add(new XGPushManager.AccountInfo(XGPushManager.AccountType.CUSTOM.getValue(), Utils.getIMEI(getApplicationContext(), 1)));
}
XGPushManager.upsertAccounts(getApplicationContext(), accountInfoList, new XGIOperateCallback() {
@Override
public void onSuccess(Object data, int flag) {
Log.e("TPush", "onSuccess, data:" + data + ", flag:" + flag);
Log.e("TPush upsertAccounts", "onSuccess, data:" + data + ", flag:" + flag);
}
@Override
public void onFail(Object data, int errCode, String msg) {
Log.e("TPush", "onFail, data:" + data + ", code:" + errCode + ", msg:" + msg);
Log.e("TPush upsertAccounts", "onFail, data:" + data + ", code:" + errCode + ", msg:" + msg);
}
});
}
@@ -150,4 +159,51 @@ public class BaseApplication extends MultiDexApplication {
}
});
}
private void aliyunPushInit() {
PushServiceFactory.init(this);
final CloudPushService pushService = PushServiceFactory.getCloudPushService();
pushService.setLogLevel(CloudPushService.LOG_DEBUG);
pushService.register(this, new CommonCallback() {
@Override
public void onSuccess(String response) {
Log.e("AliyunPush", "init cloudchannel success");
Log.e("AliyunPush", "init cloudchannel success " + pushService.getDeviceId());
String sn = Utils.getSerial(BaseApplication.this);
if (TextUtils.isEmpty(sn)) {
return;
}
pushService.bindAccount(sn, new CommonCallback() {
@Override
public void onSuccess(String s) {
Log.e("AliyunPush", "bind account " + sn + " success\n");
}
@Override
public void onFailed(String errorCode, String errorMsg) {
Log.e("AliyunPush", "bind account " + sn + " failed." +
"errorCode: " + errorCode + ", errorMsg:" + errorMsg);
}
});
pushService.addAlias(sn, new CommonCallback() {
@Override
public void onSuccess(String s) {
Log.e("AliyunPush", "add alias " + sn + " success\n");
}
@Override
public void onFailed(String errorCode, String errorMsg) {
Log.e("AliyunPush", "add alias " + sn + " failed." +
"errorCode: " + errorCode + ", errorMsg:" + errorMsg + "\n");
}
});
}
@Override
public void onFailed(String errorCode, String errorMessage) {
Log.e("AliyunPush", "init cloudchannel failed -- errorcode:" + errorCode + " -- errorMessage:" + errorMessage);
}
});
}
}

View File

@@ -85,7 +85,7 @@ public class CommonConfig {
public final static String AOLE_ACTION_APP_POWER_ON = "aole_app_power_on";
/*禁止联网应用*/
public final static String AOLE_ACTION_NETWORK_DISALLOW = "aole_network_disallow";
/*允许联网应用*/
/*允许联网应用 G10P*/
public final static String AOLE_ACTION_NETWORK_ALLOW = "aole_network_allow";

View File

@@ -19,4 +19,6 @@ public class PackageNames {
public static final String BROWSER = "com.aoleyun.browser";
public static final String APP_STORE_BOOTRECEIVER = "com.aoleyun.appstore.receiver.BootReceiver";
public static final String LEARNING_DESKTOP = "com.aoleyunos.dop2";
public static final String YIXUEPAI_DESKTOP = "com.ygyb.yischool";
}

View File

@@ -3,6 +3,7 @@ package com.aoleyun.sn.network;
import android.annotation.SuppressLint;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.app.StatusBarManager;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
@@ -13,9 +14,9 @@ import android.util.Log;
import android.view.inputmethod.InputMethodInfo;
import android.view.inputmethod.InputMethodManager;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.sdk.android.push.CloudPushService;
import com.alibaba.sdk.android.push.CommonCallback;
import com.alibaba.sdk.android.push.noonesdk.PushServiceFactory;
import com.aoleyun.sn.BuildConfig;
import com.aoleyun.sn.bean.AppAttr;
import com.aoleyun.sn.bean.AppID;
@@ -117,6 +118,7 @@ import com.aoleyun.sn.utils.WiFiUtils;
import com.arialyy.aria.core.Aria;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.reflect.TypeToken;
@@ -149,6 +151,7 @@ import io.reactivex.rxjava3.core.Observer;
import io.reactivex.rxjava3.disposables.Disposable;
import io.reactivex.rxjava3.functions.BiFunction;
import io.reactivex.rxjava3.functions.Function5;
import io.reactivex.rxjava3.functions.Function6;
import io.reactivex.rxjava3.schedulers.Schedulers;
import io.reactivex.rxjava3.subjects.BehaviorSubject;
import okhttp3.Cache;
@@ -754,10 +757,13 @@ public class NetInterfaceManager {
.getUpdateApi().getUpdate(PackageNames.BROWSER, JGYUtils.getInstance().checkAppPlatform());
Observable<BaseResponse<AppUpdateInfo>> learningDesktopObservable = NetInterfaceManager.getInstance()
.getUpdateApi().getUpdate(PackageNames.LEARNING_DESKTOP, JGYUtils.getInstance().checkAppPlatform());
Observable.zip(infoUpdateObservable, storeUpdateObservable, desktopUpdateObservable, notifyUpdateObservable, browserUpdateObservable,
Observable.zip(infoUpdateObservable, storeUpdateObservable, desktopUpdateObservable,
notifyUpdateObservable, browserUpdateObservable,
new Function5<BaseResponse<AppUpdateInfo>, BaseResponse<AppUpdateInfo>, BaseResponse<AppUpdateInfo>, BaseResponse<AppUpdateInfo>, BaseResponse<AppUpdateInfo>, List<AppUpdateInfo>>() {
@Override
public List<AppUpdateInfo> apply(BaseResponse<AppUpdateInfo> appUpdateInfoBaseResponse, BaseResponse<AppUpdateInfo> appUpdateInfoBaseResponse2, BaseResponse<AppUpdateInfo> appUpdateInfoBaseResponse3, BaseResponse<AppUpdateInfo> appUpdateInfoBaseResponse4, BaseResponse<AppUpdateInfo> appUpdateInfoBaseResponse5) throws Throwable {
public List<AppUpdateInfo> apply
(BaseResponse<AppUpdateInfo> appUpdateInfoBaseResponse, BaseResponse<AppUpdateInfo> appUpdateInfoBaseResponse2, BaseResponse<AppUpdateInfo> appUpdateInfoBaseResponse3,
BaseResponse<AppUpdateInfo> appUpdateInfoBaseResponse4, BaseResponse<AppUpdateInfo> appUpdateInfoBaseResponse5) throws Throwable {
List<AppUpdateInfo> appUpdateInfos = new ArrayList<>();
if (appUpdateInfoBaseResponse.code == OK) {
appUpdateInfos.add(appUpdateInfoBaseResponse.data);
@@ -996,7 +1002,7 @@ public class NetInterfaceManager {
if (jsonString == null) {
getDefaultDesktop(lifecycle, callback);
} else {
JSONObject data = JSON.parseObject(jsonString);
JsonObject data = GsonUtils.getJsonObject(jsonString);
if (data != null) {
JGYUtils.getInstance().installDesktop(data);
}
@@ -1034,7 +1040,7 @@ public class NetInterfaceManager {
if (baseResponse.code == OK) {
ForceDownloadData desktopInfo = baseResponse.data;
String jsonString = GsonUtils.toJSONString(desktopInfo);
JSONObject data = JSON.parseObject(jsonString);
JsonObject data = GsonUtils.getJsonObject(jsonString);
cacheHelper.put(UrlAddress.GET_DESKTOP, jsonString);
JGYUtils.getInstance().installDesktop(data);
setDefaultDesktop(desktopInfo.getApp_package());
@@ -1772,7 +1778,7 @@ public class NetInterfaceManager {
@Override
public void onNext(BaseResponse<DefaultApp> defaultAppBaseResponse) {
Log.e("getDefaultApp", "onNext: " + JSONObject.toJSONString(defaultAppBaseResponse.data));
Log.e("getDefaultApp", "onNext: " + GsonUtils.toJSONString(defaultAppBaseResponse.data));
int code = defaultAppBaseResponse.code;
if (code == OK) {
DefaultApp defaultApp = defaultAppBaseResponse.data;
@@ -1956,9 +1962,19 @@ public class NetInterfaceManager {
// Log.e( "getLockedState", "onNext: " + "state changed , reset devices");
// Utils.doMasterClear(mContext);
// }
if (JGYUtils.getInstance().checkAppPlatform() == JGYUtils.TeclastP20sPlatform) {
JGYUtils.getInstance().showApp(PackageNames.YIXUEPAI_DESKTOP);
JGYUtils.getInstance().setYxpDefaultDesktop();
}
Settings.System.putInt(mContext.getContentResolver(), JGYActions.ACTION_QCH_UNLOCK_IPAD, JGYActions.FRAME_CODE_LOCKED);
} else if (locked == JGYActions.NET_CODE_UNLOCKED) {
// SysSettingUtils.setEnableSetting(mContext);
if (JGYUtils.getInstance().checkAppPlatform() == JGYUtils.TeclastP20sPlatform) {
JGYUtils.getInstance().hideApp(PackageNames.YIXUEPAI_DESKTOP);
JGYUtils.getInstance().setDefaultDesktop();
StatusBarManager mStatusBarManager = (StatusBarManager) mContext.getSystemService(Context.STATUS_BAR_SERVICE);
mStatusBarManager.disable(StatusBarManager.DISABLE_NONE);
}
Settings.System.putInt(mContext.getContentResolver(), JGYActions.ACTION_QCH_UNLOCK_IPAD, JGYActions.FRAME_CODE_UNLOCKED);
}
} else if (response.code == NOTFOUND) {
@@ -2141,7 +2157,7 @@ public class NetInterfaceManager {
};
}
public void clearAndAppendTags(Set tagSets) {
public void clearAndAppendTags(Set<String> tagSets) {
XGPushManager.clearAndAppendTags(mContext, "clearAndAppendTags :" + System.currentTimeMillis(), tagSets, new XGIOperateCallback() {
@Override
public void onSuccess(Object o, int i) {
@@ -2153,6 +2169,20 @@ public class NetInterfaceManager {
Log.e("setPushTags", "onFail: " + o);
}
});
String[] tag = new ArrayList<>(tagSets).toArray(new String[tagSets.size()]);
CloudPushService pushService = PushServiceFactory.getCloudPushService();
pushService.bindTag(CloudPushService.DEVICE_TARGET, tag, null, new CommonCallback() {
@Override
public void onSuccess(String s) {
Log.e("bindTag", "bind tag " + Arrays.toString(tag) + " success\n");
}
@Override
public void onFailed(String errorCode, String errorMsg) {
Log.e("bindTag", "bind tag " + Arrays.toString(tag) + " failed." +
"errorCode: " + errorCode + ", errorMsg:" + errorMsg + "\n");
}
});
}
@@ -2745,6 +2775,7 @@ public class NetInterfaceManager {
JGYUtils.getInstance().writeAppPackageList(mContext, result);
JGYUtils.getInstance().deleteOtherApp();
} else {
JGYUtils.getInstance().writeAppPackageList();
cacheHelper.put(UrlAddress.SET_WHITE_PACKAGE_LIST, "");
Log.e("getAppLimit", "onNext: " + baseResponse);
}
@@ -3411,18 +3442,18 @@ public class NetInterfaceManager {
Log.e("fht", "获取信息失败");
}
JSONObject data = new JSONObject();
JSONArray appinfo = new JSONArray();
JsonObject data = new JsonObject();
JsonArray appinfo = new JsonArray();
try {
if (localAppList.size() > 0) {
for (int i = 0; i < 5; i++) {
AppInformation information = localAppList.get(i);
JSONObject jsonObject = new JSONObject();
jsonObject.put("package", information.getPackageName());
jsonObject.put("use_time", (int) information.getUsedTimebyDay() / 1000);
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("package", information.getPackageName());
jsonObject.addProperty("use_time", (int) information.getUsedTimebyDay() / 1000);
appinfo.add(jsonObject);
}
data.put("data", appinfo);
data.add("data", appinfo);
}
} catch (Exception e) {
Log.e("sendAppUsedTime", e.getMessage());
@@ -3430,7 +3461,7 @@ public class NetInterfaceManager {
NetInterfaceManager.getInstance()
.getAppLogApi()
.getAppLog(Utils.getSerial(mContext), random, data.toJSONString())
.getAppLog(Utils.getSerial(mContext), random, data.toString())
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<BaseResponse>() {
@@ -3497,7 +3528,7 @@ public class NetInterfaceManager {
return;
}
getBatteryInfoApi()
.sendBatteryInfo(Utils.getSerial(), HTTP_KEY,
.sendBatteryInfo(Utils.getSerial(mContext), HTTP_KEY,
info.getBattery_quantity(),
info.getBattery_temperature(),
info.getBattery_voltage(),

View File

@@ -1,4 +1,4 @@
package com.aoleyun.sn.tpush;
package com.aoleyun.sn.push;
import android.annotation.SuppressLint;
import android.content.ContentResolver;
@@ -17,10 +17,7 @@ import android.os.PowerManager;
import android.provider.Settings;
import android.text.TextUtils;
import android.util.Log;
import android.widget.Toast;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.aoleyun.sn.R;
import com.aoleyun.sn.bean.BaseResponse;
import com.aoleyun.sn.bean.BatteryInfo;
@@ -37,8 +34,6 @@ import com.aoleyun.sn.network.NetInterfaceManager;
import com.aoleyun.sn.network.RetryCallback;
import com.aoleyun.sn.network.UrlAddress;
import com.aoleyun.sn.service.main.MainService;
import com.aoleyun.sn.tpush.common.NotificationService;
import com.aoleyun.sn.tpush.po.XGNotification;
import com.aoleyun.sn.utils.ApkUtils;
import com.aoleyun.sn.utils.BatteryUtils;
import com.aoleyun.sn.utils.CacheUtils;
@@ -57,21 +52,12 @@ import com.baidu.location.LocationClient;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.reflect.TypeToken;
import com.tencent.android.tpush.NotificationAction;
import com.tencent.android.tpush.XGPushBaseReceiver;
import com.tencent.android.tpush.XGPushClickedResult;
import com.tencent.android.tpush.XGPushRegisterResult;
import com.tencent.android.tpush.XGPushShowedResult;
import com.tencent.android.tpush.XGPushTextMessage;
import com.tencent.mmkv.MMKV;
import java.io.File;
import java.lang.reflect.Type;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Calendar;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
@@ -89,12 +75,40 @@ import okhttp3.RequestBody;
import retrofit2.Call;
import retrofit2.Response;
public class MessageReceiver extends XGPushBaseReceiver {
private static final String TAG = MessageReceiver.class.getSimpleName();
public class PushManager {
private static final String TAG = PushManager.class.getSimpleName();
public static final String UPDATE_LISTVIEW_ACTION = "com.qq.xgdemo.activity.UPDATE_LISTVIEW";
public static final String TEST_ACTION = "com.qq.xgdemo.activity.TEST_ACTION";
public static final String LogTag = "xg.test";
@SuppressLint("StaticFieldLeak")
private static PushManager sInstance;
private Context mContext;
private PackageManager mPackageManager;
private ContentResolver mResolver;
private CacheHelper mCacheHelper;
private MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
private PushManager(Context context) {
if (context == null) {
throw new RuntimeException("Context is NULL");
}
this.mContext = context;
this.mResolver = context.getContentResolver();
this.mCacheHelper = new CacheHelper(context);
this.mPackageManager = mContext.getPackageManager();
}
public static void init(Context context) {
if (sInstance == null) {
sInstance = new PushManager(context);
}
}
public static PushManager getInstance() {
if (sInstance == null) {
throw new IllegalStateException("You must be init PushManager first");
}
return sInstance;
}
/*删除应用*/
private static final String MSG_DELETE = "1";
@@ -189,289 +203,13 @@ public class MessageReceiver extends XGPushBaseReceiver {
/*判断是否更新桌面*/
private static final String UPDATE_DESKTOP = "56";
private Context mContext;
private ContentResolver mResolver;
private PackageManager mPackageManager;
private CacheHelper cacheHelper;
/**
* 消息透传处理
*
* @param context
* @param message 解析自定义的 JSON
*/
@Override
public void onTextMessage(Context context, XGPushTextMessage message) {
this.mContext = context;
this.mResolver = context.getContentResolver();
this.mPackageManager = context.getPackageManager();
this.cacheHelper = new CacheHelper(context);
String text = "收到消息:" + message.toString();
// 获取自定义key-value
String customContent = message.getCustomContent();
if (customContent != null && customContent.length() != 0) {
JsonObject obj = JsonParser.parseString(customContent).getAsJsonObject();
// key1为前台配置的key
if (!TextUtils.isEmpty(obj.get("key").getAsString())) {
String value = obj.get("key").getAsString();
Log.d(LogTag, "get custom value:" + value);
}
// ...
}
// APP自主处理消息的过程...
Log.e(LogTag, text);
show(context, text);
processCustomMessage(context, message);
}
/**
* 通知展示
*
* @param context
* @param notifiShowedRlt 包含通知的内容
*/
@Override
public void onNotificationShowedResult(Context context, XGPushShowedResult notifiShowedRlt) {
if (context == null || notifiShowedRlt == null) {
return;
}
XGNotification notific = new XGNotification();
notific.setMsg_id(notifiShowedRlt.getMsgId());
notific.setTitle(notifiShowedRlt.getTitle());
notific.setContent(notifiShowedRlt.getContent());
// notificationActionType==1为Activity2为url3为intent
notific.setNotificationActionType(notifiShowedRlt
.getNotificationActionType());
// Activity,url,intent都可以通过getActivity()获得
notific.setActivity(notifiShowedRlt.getActivity());
notific.setUpdate_time(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
.format(Calendar.getInstance().getTime()));
NotificationService.getInstance(context).save(notific);
Intent testIntent = new Intent(TEST_ACTION);
if (notifiShowedRlt.getTitle().equals(Constants.LOCAL_NOTIFICATION_TITLE)) {
testIntent.putExtra("step", Constants.TEST_LOCAL_NOTIFICATION);
} else {
testIntent.putExtra("step", Constants.TEST_NOTIFICATION);
}
context.sendBroadcast(testIntent);
Intent viewIntent = new Intent(UPDATE_LISTVIEW_ACTION);
context.sendBroadcast(viewIntent);
show(context, "您有1条新消息, " + "通知被展示 " + notifiShowedRlt.toString());
Log.d(LogTag, "您有1条新消息, " + "通知被展示 " + notifiShowedRlt.toString() + ", PushChannel:" + notifiShowedRlt.getPushChannel());
}
/**
* 注册回调
*
* @param context
* @param errorCode 0 为成功其它为错误码
*/
@Override
public void onRegisterResult(Context context, int errorCode, XGPushRegisterResult message) {
if (context == null || message == null) {
return;
}
String text = "";
if (errorCode == XGPushBaseReceiver.SUCCESS) {
// 在这里拿token
String token = message.getToken();
text = "注册成功1. token" + token;
} else {
text = message + "注册失败,错误码:" + errorCode;
}
Log.d(LogTag, text);
show(context, text);
}
/**
* 反注册回调
*
* @param context
* @param errorCode 0 为成功其它为错误码
*/
@Override
public void onUnregisterResult(Context context, int errorCode) {
if (context == null) {
return;
}
String text = "";
if (errorCode == XGPushBaseReceiver.SUCCESS) {
text = "反注册成功";
} else {
text = "反注册失败" + errorCode;
}
Log.d(LogTag, text);
show(context, text);
}
/**
* 设置标签回调
*
* @param context
* @param errorCode 0 为成功其它为错误码
* @param tagName 设置的 TAG
*/
@Override
public void onSetTagResult(Context context, int errorCode, String tagName) {
if (context == null) {
return;
}
String text = "";
if (errorCode == XGPushBaseReceiver.SUCCESS) {
text = "\"" + tagName + "\"设置成功";
} else {
text = "\"" + tagName + "\"设置失败,错误码:" + errorCode;
}
Log.d(LogTag, text);
show(context, text);
Intent testIntent = new Intent(TEST_ACTION);
testIntent.putExtra("step", Constants.TEST_SET_TAG);
context.sendBroadcast(testIntent);
}
/**
* 删除标签的回调
*
* @param context
* @param errorCode 0 为成功其它为错误码
* @param tagName 设置的 TAG
*/
@Override
public void onDeleteTagResult(Context context, int errorCode, String tagName) {
if (context == null) {
return;
}
String text = "";
if (errorCode == XGPushBaseReceiver.SUCCESS) {
text = "\"" + tagName + "\"删除成功";
} else {
text = "\"" + tagName + "\"删除失败,错误码:" + errorCode;
}
Log.d(LogTag, text);
show(context, text);
Intent testIntent = new Intent(TEST_ACTION);
testIntent.putExtra("step", Constants.TEST_DEL_TAG);
context.sendBroadcast(testIntent);
}
/**
* 设置账号回调
*
* @param context
* @param errorCode 0 为成功其它为错误码
* @param account 设置的账号
*/
@Override
public void onSetAccountResult(Context context, int errorCode, String account) {
Intent testIntent = new Intent(TEST_ACTION);
testIntent.putExtra("step", Constants.TEST_SET_ACCOUNT);
context.sendBroadcast(testIntent);
}
/**
* 删除账号回调
*
* @param context
* @param errorCode 0 为成功其它为错误码
* @param account 设置的账号
*/
@Override
public void onDeleteAccountResult(Context context, int errorCode, String account) {
Intent testIntent = new Intent(TEST_ACTION);
testIntent.putExtra("step", Constants.TEST_DEL_ACCOUNT);
context.sendBroadcast(testIntent);
}
@Override
public void onSetAttributeResult(Context context, int i, String s) {
}
@Override
public void onDeleteAttributeResult(Context context, int i, String s) {
}
@Override
public void onQueryTagsResult(Context context, int errorCode, String data, String operateName) {
Log.i(LogTag, "action - onQueryTagsResult, errorCode:" + errorCode + ", operateName:" + operateName + ", data: " + data);
}
/**
* 通知点击回调 actionType=1为该消息被清除actionType=0为该消息被点击
*
* @param context
* @param message 包含被点击通知的内容
*/
@Override
public void onNotificationClickedResult(Context context, XGPushClickedResult message) {
if (context == null || message == null) {
return;
}
String text = "";
if (message.getActionType() == NotificationAction.clicked.getType()) {
// 通知在通知栏被点击啦
// APP自己处理点击的相关动作
// 这个动作可以在activity的onResume也能监听请看第3点相关内容
text = "通知被打开 :" + message;
} else if (message.getActionType() == NotificationAction.delete.getType()) {
// 通知被清除啦
// APP自己处理通知被清除后的相关动作
text = "通知被清除 :" + message;
}
Toast.makeText(context, "广播接收到通知被点击:" + message.toString(),
Toast.LENGTH_SHORT).show();
// 获取自定义key-value
String customContent = message.getCustomContent();
if (customContent != null && customContent.length() != 0) {
JsonObject obj = JsonParser.parseString(customContent).getAsJsonObject();
// key1为前台配置的key
if (!TextUtils.isEmpty(obj.get("key").getAsString())) {
String value = obj.get("key").getAsString();
Log.d(LogTag, "get custom value:" + value);
}
// ...
}
// APP自主处理的过程
Log.d(LogTag, text);
show(context, text);
}
private void show(Context context, String text) {
// Toast.makeText(context, text, Toast.LENGTH_SHORT).show();
}
private int changeNum(int paramInt) {
return paramInt == 0 ? 1 : 0;
}
private void processCustomMessage(Context context, XGPushTextMessage message) {
if (context == null || message == null) {
return;
}
String title = message.getTitle();
String content = message.getContent();
JsonObject extrasJson = JsonParser.parseString(content).getAsJsonObject();
String extras = "";
if (extrasJson.get("extras") != null) {
extras = extrasJson.get("extras").toString();
}
public void setPushContent(String title, String extras) {
switch (title) {
case MSG_DELETE:
ToastUtil.betaShow("收到管控:应用删除");
if (!TextUtils.isEmpty(extras)) {
JSONObject jsonObject = JSON.parseObject(extras);
String pkg = jsonObject.getString("package_name");
JsonObject jsonObject = GsonUtils.getJsonObject(extras);
String pkg = jsonObject.get("package_name").getAsString();
if (TextUtils.isEmpty(pkg)) return;
ApkUtils.UninstallAPP(mContext, pkg);
}
@@ -511,11 +249,11 @@ public class MessageReceiver extends XGPushBaseReceiver {
ToastUtil.betaShow("收到管控:设备重置");
JGYUtils.getInstance().cleanAoleLauncher3Cache();
Utils.doMasterClear(mContext);
MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE).clearAll();
mMMKV.clearAll();
JGYUtils.getInstance().cleanAoleAppCache();
JGYUtils.getInstance().wakeUpAoleyunAPP();
NetInterfaceManager.getInstance().setPushTags();
sendRefreshBroadcast(context);
sendRefreshBroadcast(mContext);
break;
case MSG_INSTALL:
ToastUtil.betaShow("收到管控:应用安装");
@@ -543,9 +281,9 @@ public class MessageReceiver extends XGPushBaseReceiver {
break;
case GET_APP_USEDTIME:
ToastUtil.betaShow("收到管控:获取应用使用时间");
JSONObject usedTimeJson = JSON.parseObject(extras);
String random = usedTimeJson.getString("random");
String sendType = usedTimeJson.getString("type");
JsonObject usedTimeJson = GsonUtils.getJsonObject(extras);
String random = usedTimeJson.get("random").getAsString();
String sendType = usedTimeJson.get("type").getAsString();
NetInterfaceManager.getInstance().sendAppUsedTime(random, sendType);
break;
case GET_FORCEDOWNLOADURL:
@@ -558,16 +296,16 @@ public class MessageReceiver extends XGPushBaseReceiver {
Log.e(TAG, "settingNetControl extras is null");
return;
}
JSONObject extra = JSON.parseObject(extras);
String app_name = extra.getString("app_name");
String app_package = extra.getString("package");
String url = extra.getString("url");
int versionCode = extra.getInteger("version_code");
String app_id = extra.getString("app_id");
JSONObject packageObj = new JSONObject();
packageObj.put("app_name", app_name);
packageObj.put("app_package", app_package);
packageObj.put("app_id", app_id);
JsonObject extra = GsonUtils.getJsonObject(extras);
String app_name = extra.get("app_name").getAsString();
String app_package = extra.get("package").getAsString();
String url = extra.get("url").getAsString();
int versionCode = extra.get("version_code").getAsInt();
String app_id = extra.get("app_id").getAsString();
JsonObject packageObj = new JsonObject();
packageObj.addProperty("app_name", app_name);
packageObj.addProperty("app_package", app_package);
packageObj.addProperty("app_id", app_id);
Utils.ariaDownload(mContext, url, packageObj);
break;
case SET_HOMEPAG_TAG:
@@ -620,8 +358,8 @@ public class MessageReceiver extends XGPushBaseReceiver {
break;
case GET_DEVICES_INFO:
ToastUtil.betaShow("收到管控:获取设备信息");
getBatteryInfo(context);
sendRefreshBroadcast(context);
getBatteryInfo(mContext);
sendRefreshBroadcast(mContext);
LocationClient locationClient = MapManager.getInstance().getLocationClient();
locationClient.stop();
locationClient.start();
@@ -708,8 +446,8 @@ public class MessageReceiver extends XGPushBaseReceiver {
break;
case LOCK_SCREEN:
ToastUtil.betaShow("收到管控:屏幕锁定");
JSONObject lockJSONObject = JSON.parseObject(extras);
String name = lockJSONObject.getString("name");
JsonObject lockJSONObject = GsonUtils.getJsonObject(extras);
String name = lockJSONObject.get("name").getAsString();
setLock_screen(1, name);
break;
case UNLOCK_SCREEN:
@@ -718,8 +456,8 @@ public class MessageReceiver extends XGPushBaseReceiver {
break;
case KILL_SERVER:
ToastUtil.betaShow("收到管控:停止应用");
JSONObject killJSONObject = JSON.parseObject(extras);
String packages = killJSONObject.getString("package_name");
JsonObject killJSONObject = GsonUtils.getJsonObject(extras);
String packages = killJSONObject.get("package_name").getAsString();
JGYUtils.getInstance().killBackgroundProcesses(packages);
break;
case TIME_CONTROL:
@@ -775,7 +513,7 @@ public class MessageReceiver extends XGPushBaseReceiver {
e.printStackTrace();
Log.e(TAG, "setHomepagtag: " + e.getMessage());
}
sendRefreshBroadcast(context);
sendRefreshBroadcast(mContext);
break;
case UPDATE_WIFI_PW:
NetInterfaceManager.getInstance().getWiFiPasswd();
@@ -799,10 +537,10 @@ public class MessageReceiver extends XGPushBaseReceiver {
senSNLogFile(extras);
break;
case DISABLE_APP_USAGE:
disableApp(content, extras);
disableApp(extras);
break;
case INFO_BATTERY_INFO:
getBatteryInfo(context);
getBatteryInfo(mContext);
break;
case UPDATE_DESKTOP:
@@ -811,7 +549,11 @@ public class MessageReceiver extends XGPushBaseReceiver {
}
}
private void disableApp(String content, String extras) {
private int changeNum(int paramInt) {
return paramInt == 0 ? 1 : 0;
}
private void disableApp(String extras) {
JsonObject jsonObject = GsonUtils.getJsonObject(extras);
try {
String packages = jsonObject.get("package").getAsString();
@@ -832,7 +574,7 @@ public class MessageReceiver extends XGPushBaseReceiver {
ScreenLockState screenLockState = new ScreenLockState();
screenLockState.setIs_screen_lock(state);
screenLockState.setName(name);
cacheHelper.put(UrlAddress.GET_LOCK_SCREEN_STATE, GsonUtils.toJSONString(screenLockState));
mCacheHelper.put(UrlAddress.GET_LOCK_SCREEN_STATE, GsonUtils.toJSONString(screenLockState));
Intent intent = new Intent();
intent.putExtra("name", name);
if (state == 1) {
@@ -872,11 +614,11 @@ public class MessageReceiver extends XGPushBaseReceiver {
mContext.sendBroadcast(intent);
}
JSONObject packageObj = new JSONObject();
packageObj.put("app_name", app_name);
packageObj.put("app_package", app_package);
packageObj.put("app_id", app_id);
packageObj.put("MD5", MD5);
JsonObject packageObj = new JsonObject();
packageObj.addProperty("app_name", app_name);
packageObj.addProperty("app_package", app_package);
packageObj.addProperty("app_id", app_id);
packageObj.addProperty("MD5", MD5);
Log.e(TAG, "doDownloadAndInstall: app_package:" + app_package);
Log.e(TAG, "doDownloadAndInstall: app_url:" + app_url);
PackageInfo packageInfo = null;
@@ -921,10 +663,10 @@ public class MessageReceiver extends XGPushBaseReceiver {
}
private void setDisableSlideList(String jsonString) {
JSONObject jSONObject = JSON.parseObject(jsonString);
JsonObject jSONObject = GsonUtils.getJsonObject(jsonString);
Log.e("setDisableSlideList", "jSONObject::" + jSONObject.toString());
String strban = jSONObject.getString("ban");
String strnot = jSONObject.getString("not");
String strban = jSONObject.get("ban").getAsString();
String strnot = jSONObject.get("not").getAsString();
String aole_disable_slide = Settings.System.getString(mResolver, CommonConfig.AOLE_ACTION_DISABLE_SLIDE);
Log.e("fht", "aole_disable_slide: " + aole_disable_slide);
@@ -939,9 +681,9 @@ public class MessageReceiver extends XGPushBaseReceiver {
private void setDisableUpdateList(String jsonString) {
Log.e("setDisableUpdateList", jsonString);
JSONObject jsonObject = JSON.parseObject(jsonString);
String ban = jsonObject.getString("ban");
String not = jsonObject.getString("not");
JsonObject jsonObject = GsonUtils.getJsonObject(jsonString);
String ban = jsonObject.get("ban").getAsString();
String not = jsonObject.get("not").getAsString();
String[] banList = ban.split(",");
String[] notList = not.split(",");
boolean b = Utils.writeDisableUpdateList(mContext, banList, notList);
@@ -955,8 +697,8 @@ public class MessageReceiver extends XGPushBaseReceiver {
Log.e(TAG, "settingNetControl extras is null");
return;
}
JSONObject jSONObject = JSON.parseObject(s);
String s1 = jSONObject.getString("ban");
JsonObject jSONObject = GsonUtils.getJsonObject(s);
String s1 = jSONObject.get("ban").getAsString();
// String str = jSONObject.optString("not");
Log.e("settingCamera", "ban::" + s1);
// Log.e("settingCamera", "not::" + str);
@@ -976,21 +718,21 @@ public class MessageReceiver extends XGPushBaseReceiver {
Log.e(TAG, "settingNetControl extras is null");
// return;
}
JSONObject jSONObject = JSON.parseObject(s);
JsonObject jSONObject = GsonUtils.getJsonObject(s);
Log.e("settingOneNet", "jSONObject::" + jSONObject.toString());
String packages = jSONObject.getString("package");
String status = jSONObject.getString("status");
String packages = jSONObject.get("package").getAsString();
String status = jSONObject.get("status").getAsString();
}
private void settingNetControl(String s) {
if (TextUtils.isEmpty(s)) {
Log.e(TAG, "settingNetControl extras is null");
}
JSONObject jSONObject = JSON.parseObject(s);
JsonObject jSONObject = GsonUtils.getJsonObject(s);
Log.e("settingNetControl", "jSONObject::" + jSONObject.toString());
String disallow = jSONObject.getString("ban");
String allow = jSONObject.getString("not");
String disallow = jSONObject.get("ban").getAsString();
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.setAppNetwork(mContext, disallowApp, allowApp);
@@ -1001,9 +743,9 @@ public class MessageReceiver extends XGPushBaseReceiver {
Log.e(TAG, "settingPowerOn extras is null");
return;
}
JSONObject jSONObject = JSON.parseObject(s);
String ban = jSONObject.getString("ban");
String not = jSONObject.getString("not");
JsonObject jSONObject = GsonUtils.getJsonObject(s);
String ban = jSONObject.get("ban").getAsString();
String not = jSONObject.get("not").getAsString();
Log.e(TAG, "settingPowerOn aole_app_power_on = " + not);
if (TextUtils.isEmpty(not)) {
// qch_app_power_on 的值为空时会造成系统所有应用断网
@@ -1044,9 +786,8 @@ public class MessageReceiver extends XGPushBaseReceiver {
Log.e(TAG, "settingLock extras is null");
return;
}
JSONObject jSONObject = JSON.parseObject(s);
int i = changeNum(jSONObject.getIntValue("lock"));
JsonObject jSONObject = GsonUtils.getJsonObject(s);
int i = changeNum(jSONObject.get("lock").getAsInt());
Settings.System.putInt(mResolver, JGYActions.ACTION_QCH_UNLOCK_IPAD, i);
Log.e("SystemSetting", "qch_unlock_ipad---------" + i);
@@ -1058,7 +799,7 @@ public class MessageReceiver extends XGPushBaseReceiver {
}
public void screenshot(String s) {
// JSONObject jSONObject = JSON.parseObject(s);
// JsonObject jSONObject = GsonUtils.getJsonObject(s);
// long createTime = jSONObject.getLong("createTime");
long createTime = System.currentTimeMillis() / 1000;
PowerManager.WakeLock mWakeLock = JGYUtils.acquireWakeLock(mContext, 60 * 1000);
@@ -1181,27 +922,27 @@ public class MessageReceiver extends XGPushBaseReceiver {
}
private void getTopApp(String extras) {
JSONObject jsonObject = JSON.parseObject(extras);
cacheHelper.put(UrlAddress.GET_TOP_APP_CONTROL, extras);
JsonObject jsonObject = GsonUtils.getJsonObject(extras);
mCacheHelper.put(UrlAddress.GET_TOP_APP_CONTROL, extras);
String packageName = jsonObject.getString("app_package");
String packageName = jsonObject.get("app_package").getAsString();
if (TextUtils.isEmpty(packageName)) {
Settings.Global.putString(mContext.getContentResolver(), ForegroundAppUtil.TOPAPP_KEY, "");
Settings.Global.putString(mResolver, ForegroundAppUtil.TOPAPP_KEY, "");
ForegroundAppUtil.setTopAppClass(mContext, "");
} else {
Settings.Global.putString(mContext.getContentResolver(), ForegroundAppUtil.TOPAPP_KEY, packageName);
Settings.Global.putString(mResolver, ForegroundAppUtil.TOPAPP_KEY, packageName);
ForegroundAppUtil.setTopAppClass(mContext, packageName);
ForegroundAppUtil.openTopApp(mContext);
}
Log.e(TAG, "getTopApp: " + Settings.Global.getString(mContext.getContentResolver(), ForegroundAppUtil.TOPAPP_KEY));
Log.e(TAG, "getTopApp: " + Settings.Global.getString(mResolver, ForegroundAppUtil.TOPAPP_KEY));
}
private void setBootanimation(String extras) {
JSONObject jsonObject = JSONObject.parseObject(extras);
int type = jsonObject.getInteger("type");
JsonObject jsonObject = GsonUtils.getJsonObject(extras);
int type = jsonObject.get("type").getAsInt();
if (type == 1) {
String file_url = jsonObject.getString("file_url");
String file_md5 = jsonObject.getString("file_md5");
String file_url = jsonObject.get("file_url").getAsString();
String file_md5 = jsonObject.get("file_md5").getAsString();
JGYUtils.getInstance().checkBootFile(file_url, file_md5);
} else {
JGYUtils.getInstance().removeBootanimation();
@@ -1212,8 +953,8 @@ public class MessageReceiver extends XGPushBaseReceiver {
if (TextUtils.isEmpty(extras)) {
JGYUtils.getInstance().setDefaultDesktop("");
} else {
JSONObject jsonObject = JSON.parseObject(extras);
String default_launcher = jsonObject.getString("default_launcher");
JsonObject jsonObject = GsonUtils.getJsonObject(extras);
String default_launcher = jsonObject.get("default_launcher").getAsString();
if (TextUtils.isEmpty(default_launcher)) {
JGYUtils.getInstance().setDefaultDesktop("");
SPUtils.put(mContext, "default_launcher", "");
@@ -1225,7 +966,7 @@ public class MessageReceiver extends XGPushBaseReceiver {
}
private void playSound(String extras) {
JSONObject jsonObject = JSONObject.parseObject(extras);
JsonObject jsonObject = GsonUtils.getJsonObject(extras);
defaultCallMediaPlayer(mContext);
}
@@ -1295,8 +1036,8 @@ public class MessageReceiver extends XGPushBaseReceiver {
}
private void cleanCache(String extras) {
JSONObject jsonObject = JSONObject.parseObject(extras);
String packageName = jsonObject.getString("app_package");
JsonObject jsonObject = GsonUtils.getJsonObject(extras);
String packageName = jsonObject.get("app_package").getAsString();
if (TextUtils.isEmpty(packageName)) {
Log.e(TAG, "cleanCache: " + "package is empty");
} else {
@@ -1314,8 +1055,8 @@ public class MessageReceiver extends XGPushBaseReceiver {
}
private void setDeveloperoptions(String extras) {
JSONObject jsonObject = JSONObject.parseObject(extras);
int is_developer = jsonObject.getInteger("is_developer");
JsonObject jsonObject = GsonUtils.getJsonObject(extras);
int is_developer = jsonObject.get("is_developer").getAsInt();
Log.e(TAG + ":" + "getDeveloper", "onNext: " + is_developer);
Log.e(TAG, "setDeveloperoptions: " + is_developer);
JGYUtils.getInstance().setDeveloperOptions(is_developer == 0 ? 1 : 0);
@@ -1325,8 +1066,8 @@ public class MessageReceiver extends XGPushBaseReceiver {
if (TextUtils.isEmpty(jsonString)) {
throw new RuntimeException();
}
JSONObject jsonObject = JSON.parseObject(jsonString);
String platform = jsonObject.getString("platform");
JsonObject jsonObject = GsonUtils.getJsonObject(jsonString);
String platform = jsonObject.get("platform").getAsString();
if (JGYUtils.getInstance().isSamePlatform(platform)) {
checkAPPInstall(jsonObject);
} else {
@@ -1335,11 +1076,11 @@ public class MessageReceiver extends XGPushBaseReceiver {
}
@SuppressLint("NewApi")
private void checkAPPInstall(JSONObject jsonObject) {
long version_code = jsonObject.getLong("app_version_code");
private void checkAPPInstall(JsonObject jsonObject) {
long version_code = jsonObject.get("app_version_code").getAsLong();
PackageInfo packageInfo = null;
try {
packageInfo = mPackageManager.getPackageInfo(jsonObject.getString("app_package"), 0);
packageInfo = mPackageManager.getPackageInfo(jsonObject.get("app_package").getAsString(), 0);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
@@ -1351,15 +1092,15 @@ public class MessageReceiver extends XGPushBaseReceiver {
}
if (packageInfo == null || appVersionCode < version_code) {
Utils.ariaDownload(mContext, jsonObject.getString("app_url"), jsonObject);
Utils.ariaDownload(mContext, jsonObject.get("app_url").getAsString(), jsonObject);
} else {
Log.e(TAG, "checkAPPInstall: " + "已经是最新版");
}
}
private void setEbagCode(String jsonString) {
JSONObject jsonObject = JSON.parseObject(jsonString);
String ebagCode = jsonObject.getString("ebagCode");
JsonObject jsonObject = GsonUtils.getJsonObject(jsonString);
String ebagCode = jsonObject.get("ebagCode").getAsString();
if (TextUtils.isEmpty(ebagCode)) {
Log.e(TAG, "setEbagCode: " + "ebagCode is empty");
} else {
@@ -1407,9 +1148,9 @@ public class MessageReceiver extends XGPushBaseReceiver {
* "is_log_type": 1 //获取运行日志类型 0即时 1定时
*/
private void senSNLogFile(String jsonString) {
JSONObject jsonObject = JSON.parseObject(jsonString);
int is_log = jsonObject.getInteger("is_log");
int is_log_type = jsonObject.getInteger("is_log_type");
JsonObject jsonObject = GsonUtils.getJsonObject(jsonString);
int is_log = jsonObject.get("is_log").getAsInt();
int is_log_type = jsonObject.get("is_log_type").getAsInt();
if (is_log == 0) {
return;
}

View File

@@ -0,0 +1,99 @@
package com.aoleyun.sn.push.alipush;
import android.content.Context;
import android.util.Log;
import com.alibaba.sdk.android.push.AliyunMessageIntentService;
import com.alibaba.sdk.android.push.notification.CPushMessage;
import java.util.Map;
/**
* Created by liyazhou on 17/8/22.
* 为避免推送广播被系统拦截的小概率事件,我们推荐用户通过IntentService处理消息互调,接入步骤:
* 1. 创建IntentService并继承AliyunMessageIntentService
* 2. 覆写相关方法,并在Manifest的注册该Service
* 3. 调用接口CloudPushService.setPushIntentService
* 详细用户可参考:https://help.aliyun.com/document_detail/30066.html#h2-2-messagereceiver-aliyunmessageintentservice
*/
public class AliMessageIntentService extends AliyunMessageIntentService {
private static final String TAG = AliyunMessageIntentService.class.getSimpleName();
/**
* 推送通知的回调方法
*
* @param context
* @param title
* @param summary
* @param extraMap
*/
@Override
protected void onNotification(Context context, String title, String summary, Map<String, String> extraMap) {
Log.i(TAG, "收到一条推送通知 " + title + ", summary:" + summary);
}
/**
* 推送消息的回调方法
*
* @param context
* @param cPushMessage
*/
@Override
protected void onMessage(Context context, CPushMessage cPushMessage) {
Log.i(TAG, "收到一条推送消息 " + cPushMessage.getTitle() + ", content:" + cPushMessage.getContent());
}
/**
* 从通知栏打开通知的扩展处理
*
* @param context
* @param title
* @param summary
* @param extraMap
*/
@Override
protected void onNotificationOpened(Context context, String title, String summary, String extraMap) {
Log.i(TAG, "onNotificationOpened " + " : " + title + " : " + summary + " : " + extraMap);
}
/**
* 无动作通知点击回调。当在后台或阿里云控制台指定的通知动作为无逻辑跳转时,通知点击回调为onNotificationClickedWithNoAction而不是onNotificationOpened
*
* @param context
* @param title
* @param summary
* @param extraMap
*/
@Override
protected void onNotificationClickedWithNoAction(Context context, String title, String summary, String extraMap) {
Log.i(TAG, "onNotificationClickedWithNoAction " + " : " + title + " : " + summary + " : " + extraMap);
}
/**
* 通知删除回调
*
* @param context
* @param messageId
*/
@Override
protected void onNotificationRemoved(Context context, String messageId) {
Log.i(TAG, "onNotificationRemoved " + messageId);
}
/**
* 应用处于前台时通知到达回调。注意:该方法仅对自定义样式通知有效,相关详情请参考https://help.aliyun.com/document_detail/30066.html#h3-3-4-basiccustompushnotification-api
*
* @param context
* @param title
* @param summary
* @param extraMap
* @param openType
* @param openActivity
* @param openUrl
*/
@Override
protected void onNotificationReceivedInApp(Context context, String title, String summary, Map<String, String> extraMap, int openType, String openActivity, String openUrl) {
Log.i(TAG, "onNotificationReceivedInApp " + " : " + title + " : " + summary + " " + extraMap + " : " + openType + " : " + openActivity + " : " + openUrl);
}
}

View File

@@ -0,0 +1,116 @@
package com.aoleyun.sn.push.alipush;
import android.content.Context;
import android.util.Log;
import com.alibaba.sdk.android.push.MessageReceiver;
import com.alibaba.sdk.android.push.notification.CPushMessage;
import com.aoleyun.sn.push.PushManager;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import java.util.Map;
/**
* @author: 正纬
* @since: 15/4/9
* @version: 1.1
* @feature: 用于接收推送的通知和消息
*/
public class AliyunMessageReceiver extends MessageReceiver {
// 消息接收部分的LOG_TAG
public static final String TAG = AliyunMessageReceiver.class.getSimpleName();
/**
* 推送通知的回调方法
*
* @param context
* @param title
* @param summary
* @param extraMap
*/
@Override
public void onNotification(Context context, String title, String summary, Map<String, String> extraMap) {
// TODO 处理推送通知
if (null != extraMap) {
for (Map.Entry<String, String> entry : extraMap.entrySet()) {
Log.i(TAG, "@Get diy param : Key=" + entry.getKey() + " , Value=" + entry.getValue());
}
} else {
Log.i(TAG, "@收到通知 && 自定义消息为空");
}
Log.i(TAG, "收到一条推送通知 " + title + ", summary:" + summary);
}
/**
* 应用处于前台时通知到达回调。注意:该方法仅对自定义样式通知有效,相关详情请参考https://help.aliyun.com/document_detail/30066.html?spm=5176.product30047.6.620.wjcC87#h3-3-4-basiccustompushnotification-api
*
* @param context
* @param title
* @param summary
* @param extraMap
* @param openType
* @param openActivity
* @param openUrl
*/
@Override
protected void onNotificationReceivedInApp(Context context, String title, String summary, Map<String, String> extraMap, int openType, String openActivity, String openUrl) {
Log.i(TAG, "onNotificationReceivedInApp " + " : " + title + " : " + summary + " " + extraMap + " : " + openType + " : " + openActivity + " : " + openUrl);
}
/**
* 推送消息的回调方法
*
* @param context
* @param cPushMessage
*/
@Override
public void onMessage(Context context, CPushMessage cPushMessage) {
Log.e(TAG, "收到一条推送消息 " + cPushMessage.getTitle() + ", content:" + cPushMessage.getContent());
String title = cPushMessage.getTitle();
String content = cPushMessage.getContent();
JsonObject extrasJson = JsonParser.parseString(content).getAsJsonObject();
String extras = "";
if (extrasJson.get("extras") != null) {
extras = extrasJson.get("extras").toString();
}
PushManager.getInstance().setPushContent(title, extras);
}
/**
* 从通知栏打开通知的扩展处理
*
* @param context
* @param title
* @param summary
* @param extraMap
*/
@Override
public void onNotificationOpened(Context context, String title, String summary, String extraMap) {
Log.i(TAG, "onNotificationOpened " + " : " + title + " : " + summary + " : " + extraMap);
}
/**
* 通知删除回调
*
* @param context
* @param messageId
*/
@Override
public void onNotificationRemoved(Context context, String messageId) {
Log.i(TAG, "onNotificationRemoved " + messageId);
}
/**
* 无动作通知点击回调。当在后台或阿里云控制台指定的通知动作为无逻辑跳转时,通知点击回调为onNotificationClickedWithNoAction而不是onNotificationOpened
*
* @param context
* @param title
* @param summary
* @param extraMap
*/
@Override
protected void onNotificationClickedWithNoAction(Context context, String title, String summary, String extraMap) {
Log.i(TAG, "onNotificationClickedWithNoAction " + " : " + title + " : " + summary + " : " + extraMap);
}
}

View File

@@ -1,4 +1,4 @@
package com.aoleyun.sn.tpush;
package com.aoleyun.sn.push.tpush;
/**
* Created by chacewang on 2019/7/5.

View File

@@ -0,0 +1,307 @@
package com.aoleyun.sn.push.tpush;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.text.TextUtils;
import android.util.Log;
import android.widget.Toast;
import com.aoleyun.sn.disklrucache.CacheHelper;
import com.aoleyun.sn.push.PushManager;
import com.aoleyun.sn.push.tpush.common.NotificationService;
import com.aoleyun.sn.push.tpush.po.XGNotification;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.tencent.android.tpush.NotificationAction;
import com.tencent.android.tpush.XGPushBaseReceiver;
import com.tencent.android.tpush.XGPushClickedResult;
import com.tencent.android.tpush.XGPushRegisterResult;
import com.tencent.android.tpush.XGPushShowedResult;
import com.tencent.android.tpush.XGPushTextMessage;
import java.text.SimpleDateFormat;
import java.util.Calendar;
public class MessageReceiver extends XGPushBaseReceiver {
private static final String TAG = MessageReceiver.class.getSimpleName();
public static final String UPDATE_LISTVIEW_ACTION = "com.qq.xgdemo.activity.UPDATE_LISTVIEW";
public static final String TEST_ACTION = "com.qq.xgdemo.activity.TEST_ACTION";
public static final String LogTag = "xg.test";
private Context mContext;
private ContentResolver mResolver;
private PackageManager mPackageManager;
private CacheHelper cacheHelper;
/**
* 消息透传处理
*
* @param context
* @param message 解析自定义的 JSON
*/
@Override
public void onTextMessage(Context context, XGPushTextMessage message) {
this.mContext = context;
this.mResolver = context.getContentResolver();
this.mPackageManager = context.getPackageManager();
this.cacheHelper = new CacheHelper(context);
String text = "收到消息:" + message.toString();
// 获取自定义key-value
String customContent = message.getCustomContent();
if (customContent != null && customContent.length() != 0) {
JsonObject obj = JsonParser.parseString(customContent).getAsJsonObject();
// key1为前台配置的key
if (!TextUtils.isEmpty(obj.get("key").getAsString())) {
String value = obj.get("key").getAsString();
Log.d(LogTag, "get custom value:" + value);
}
// ...
}
// APP自主处理消息的过程...
Log.e(LogTag, text);
show(context, text);
processCustomMessage(context, message);
}
/**
* 通知展示
*
* @param context
* @param notifiShowedRlt 包含通知的内容
*/
@Override
public void onNotificationShowedResult(Context context, XGPushShowedResult notifiShowedRlt) {
if (context == null || notifiShowedRlt == null) {
return;
}
XGNotification notific = new XGNotification();
notific.setMsg_id(notifiShowedRlt.getMsgId());
notific.setTitle(notifiShowedRlt.getTitle());
notific.setContent(notifiShowedRlt.getContent());
// notificationActionType==1为Activity2为url3为intent
notific.setNotificationActionType(notifiShowedRlt
.getNotificationActionType());
// Activity,url,intent都可以通过getActivity()获得
notific.setActivity(notifiShowedRlt.getActivity());
notific.setUpdate_time(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
.format(Calendar.getInstance().getTime()));
NotificationService.getInstance(context).save(notific);
Intent testIntent = new Intent(TEST_ACTION);
if (notifiShowedRlt.getTitle().equals(Constants.LOCAL_NOTIFICATION_TITLE)) {
testIntent.putExtra("step", Constants.TEST_LOCAL_NOTIFICATION);
} else {
testIntent.putExtra("step", Constants.TEST_NOTIFICATION);
}
context.sendBroadcast(testIntent);
Intent viewIntent = new Intent(UPDATE_LISTVIEW_ACTION);
context.sendBroadcast(viewIntent);
show(context, "您有1条新消息, " + "通知被展示 " + notifiShowedRlt.toString());
Log.d(LogTag, "您有1条新消息, " + "通知被展示 " + notifiShowedRlt.toString() + ", PushChannel:" + notifiShowedRlt.getPushChannel());
}
/**
* 注册回调
*
* @param context
* @param errorCode 0 为成功,其它为错误码
*/
@Override
public void onRegisterResult(Context context, int errorCode, XGPushRegisterResult message) {
if (context == null || message == null) {
return;
}
String text = "";
if (errorCode == XGPushBaseReceiver.SUCCESS) {
// 在这里拿token
String token = message.getToken();
text = "注册成功1. token" + token;
} else {
text = message + "注册失败,错误码:" + errorCode;
}
Log.d(LogTag, text);
show(context, text);
}
/**
* 反注册回调
*
* @param context
* @param errorCode 0 为成功,其它为错误码
*/
@Override
public void onUnregisterResult(Context context, int errorCode) {
if (context == null) {
return;
}
String text = "";
if (errorCode == XGPushBaseReceiver.SUCCESS) {
text = "反注册成功";
} else {
text = "反注册失败" + errorCode;
}
Log.d(LogTag, text);
show(context, text);
}
/**
* 设置标签回调
*
* @param context
* @param errorCode 0 为成功,其它为错误码
* @param tagName 设置的 TAG
*/
@Override
public void onSetTagResult(Context context, int errorCode, String tagName) {
if (context == null) {
return;
}
String text = "";
if (errorCode == XGPushBaseReceiver.SUCCESS) {
text = "\"" + tagName + "\"设置成功";
} else {
text = "\"" + tagName + "\"设置失败,错误码:" + errorCode;
}
Log.d(LogTag, text);
show(context, text);
Intent testIntent = new Intent(TEST_ACTION);
testIntent.putExtra("step", Constants.TEST_SET_TAG);
context.sendBroadcast(testIntent);
}
/**
* 删除标签的回调
*
* @param context
* @param errorCode 0 为成功,其它为错误码
* @param tagName 设置的 TAG
*/
@Override
public void onDeleteTagResult(Context context, int errorCode, String tagName) {
if (context == null) {
return;
}
String text = "";
if (errorCode == XGPushBaseReceiver.SUCCESS) {
text = "\"" + tagName + "\"删除成功";
} else {
text = "\"" + tagName + "\"删除失败,错误码:" + errorCode;
}
Log.d(LogTag, text);
show(context, text);
Intent testIntent = new Intent(TEST_ACTION);
testIntent.putExtra("step", Constants.TEST_DEL_TAG);
context.sendBroadcast(testIntent);
}
/**
* 设置账号回调
*
* @param context
* @param errorCode 0 为成功,其它为错误码
* @param account 设置的账号
*/
@Override
public void onSetAccountResult(Context context, int errorCode, String account) {
Intent testIntent = new Intent(TEST_ACTION);
testIntent.putExtra("step", Constants.TEST_SET_ACCOUNT);
context.sendBroadcast(testIntent);
}
/**
* 删除账号回调
*
* @param context
* @param errorCode 0 为成功,其它为错误码
* @param account 设置的账号
*/
@Override
public void onDeleteAccountResult(Context context, int errorCode, String account) {
Intent testIntent = new Intent(TEST_ACTION);
testIntent.putExtra("step", Constants.TEST_DEL_ACCOUNT);
context.sendBroadcast(testIntent);
}
@Override
public void onSetAttributeResult(Context context, int i, String s) {
}
@Override
public void onDeleteAttributeResult(Context context, int i, String s) {
}
@Override
public void onQueryTagsResult(Context context, int errorCode, String data, String operateName) {
Log.i(LogTag, "action - onQueryTagsResult, errorCode:" + errorCode + ", operateName:" + operateName + ", data: " + data);
}
/**
* 通知点击回调 actionType=1为该消息被清除actionType=0为该消息被点击
*
* @param context
* @param message 包含被点击通知的内容
*/
@Override
public void onNotificationClickedResult(Context context, XGPushClickedResult message) {
if (context == null || message == null) {
return;
}
String text = "";
if (message.getActionType() == NotificationAction.clicked.getType()) {
// 通知在通知栏被点击啦。。。。。
// APP自己处理点击的相关动作
// 这个动作可以在activity的onResume也能监听请看第3点相关内容
text = "通知被打开 :" + message;
} else if (message.getActionType() == NotificationAction.delete.getType()) {
// 通知被清除啦。。。。
// APP自己处理通知被清除后的相关动作
text = "通知被清除 :" + message;
}
Toast.makeText(context, "广播接收到通知被点击:" + message.toString(),
Toast.LENGTH_SHORT).show();
// 获取自定义key-value
String customContent = message.getCustomContent();
if (customContent != null && customContent.length() != 0) {
JsonObject obj = JsonParser.parseString(customContent).getAsJsonObject();
// key1为前台配置的key
if (!TextUtils.isEmpty(obj.get("key").getAsString())) {
String value = obj.get("key").getAsString();
Log.d(LogTag, "get custom value:" + value);
}
// ...
}
// APP自主处理的过程。。。
Log.d(LogTag, text);
show(context, text);
}
private void show(Context context, String text) {
// Toast.makeText(context, text, Toast.LENGTH_SHORT).show();
}
private void processCustomMessage(Context context, XGPushTextMessage message) {
if (context == null || message == null) {
return;
}
String title = message.getTitle();
String content = message.getContent();
JsonObject extrasJson = JsonParser.parseString(content).getAsJsonObject();
String extras = "";
if (extrasJson.get("extras") != null) {
extras = extrasJson.get("extras").toString();
}
PushManager.getInstance().setPushContent(title, extras);
}
}

View File

@@ -1,4 +1,4 @@
package com.aoleyun.sn.tpush.common;
package com.aoleyun.sn.push.tpush.common;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;

View File

@@ -1,11 +1,11 @@
package com.aoleyun.sn.tpush.common;
package com.aoleyun.sn.push.tpush.common;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import com.aoleyun.sn.tpush.po.XGNotification;
import com.aoleyun.sn.push.tpush.po.XGNotification;
import java.util.ArrayList;
import java.util.List;

View File

@@ -1,4 +1,4 @@
package com.aoleyun.sn.tpush.po;
package com.aoleyun.sn.push.tpush.po;
public class XGNotification {
private Integer id;

View File

@@ -19,14 +19,13 @@ import android.util.Log;
import androidx.annotation.Nullable;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.aoleyun.sn.BuildConfig;
import com.aoleyun.sn.KeepAliveConnection;
import com.aoleyun.sn.R;
import com.aoleyun.sn.bean.BaseResponse;
import com.aoleyun.sn.comm.CommonConfig;
import com.aoleyun.sn.comm.PackageNames;
import com.aoleyun.sn.gson.GsonUtils;
import com.aoleyun.sn.manager.MapManager;
import com.aoleyun.sn.network.NetInterfaceManager;
import com.aoleyun.sn.network.api.post.SendScreenStatusApi;
@@ -47,6 +46,7 @@ import com.arialyy.annotations.Download;
import com.arialyy.aria.core.Aria;
import com.arialyy.aria.core.task.DownloadTask;
import com.baidu.location.LocationClient;
import com.google.gson.JsonObject;
import java.io.BufferedReader;
import java.io.File;
@@ -432,9 +432,9 @@ public class GuardService extends Service {
@Override
public void onNext(ResponseBody responseBody) {
try {
com.alibaba.fastjson.JSONObject jsonObject = JSON.parseObject(responseBody.string());
JsonObject jsonObject = GsonUtils.getJsonObject(responseBody.string());
Log.e("getLockState", "onNext: " + jsonObject);
int code = jsonObject.getInteger("code");
int code = jsonObject.get("code").getAsInt();
Log.e("getLockState", "onNext: code: " + code);
} catch (IOException e) {
e.printStackTrace();
@@ -843,9 +843,9 @@ public class GuardService extends Service {
//在这里处理任务执行中的状态,如进度进度条的刷新
@Download.onTaskRunning
protected void running(DownloadTask task) {
JSONObject jsonObject = JSON.parseObject(task.getExtendField());
String app_name = jsonObject.getString("app_name");
String app_package = jsonObject.getString("app_package");
JsonObject jsonObject = GsonUtils.getJsonObject(task.getExtendField());
String app_name = jsonObject.get("app_name").getAsString();
String app_package = jsonObject.get("app_package").getAsString();
Log.e("aria", "正在下载:" + task.getPercent() + ":" + task.getExtendField());
ToastUtil.show("正在下载:" + app_name + "-" + task.getPercent() + "%" + "\t" + Formatter.formatFileSize(GuardService.this, task.getSpeed()) + "/s");
}
@@ -859,10 +859,10 @@ public class GuardService extends Service {
Log.e("taskComplete", "extendField::" + extendField);
if (filepath.endsWith("apk")) {
JSONObject jsonObject = JSON.parseObject(extendField);
String app_name = jsonObject.getString("app_name");
String app_package = jsonObject.getString("app_package");
String app_id = jsonObject.getString("app_id");
JsonObject jsonObject = GsonUtils.getJsonObject(extendField);
String app_name = jsonObject.get("app_name").getAsString();
String app_package = jsonObject.get("app_package").getAsString();
String app_id = jsonObject.get("app_id").getAsString();
ToastUtil.show(app_name + "\t:下载完成");
if (filepath.endsWith(".xapk")) {
XAPKUtils.getInstance().installXAPK(filepath);
@@ -936,9 +936,9 @@ public class GuardService extends Service {
Aria.download(this).resumeAllTask();
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");
JsonObject jsonObject = GsonUtils.getJsonObject(task.getExtendField());
String app_name = jsonObject.get("app_name").getAsString();
String app_package = jsonObject.get("app_package").getAsString();
Log.e("aria", "taskFail: " + packageName + "filepath " + filepath + "Exception: " + e.getMessage());
// ToastUtil.show(app_name + "\t:下载失败");
} catch (Exception e1) {

View File

@@ -46,7 +46,7 @@ public class RemoteService extends Service {
@Override
public String getSerial() throws RemoteException {
return Utils.getSerial();
return Utils.getSerial(RemoteService.this);
}
@Override

View File

@@ -16,13 +16,13 @@ import android.util.Log;
import androidx.annotation.Nullable;
import com.alibaba.fastjson.JSONObject;
import com.aoleyun.sn.BuildConfig;
import com.aoleyun.sn.utils.JGYUtils;
import com.blankj.utilcode.util.NetworkUtils;
import com.aoleyun.sn.KeepAliveConnection;
import com.aoleyun.sn.utils.ServiceAliveUtils;
import com.aoleyun.sn.utils.Utils;
import com.google.gson.JsonObject;
import org.java_websocket.handshake.ServerHandshake;
@@ -231,29 +231,29 @@ public class StepService extends Service implements NetworkUtils.OnNetworkStatus
* 发送消息
*/
public void sendMsg() {
JSONObject jsonObject = new JSONObject();
jsonObject.put("sn", Utils.getSerial(this));
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("sn", Utils.getSerial(this));
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
if (!pm.isScreenOn()) {
jsonObject.put("online", 2);
jsonObject.addProperty("online", 2);
//熄屏状态
} else {
jsonObject.put("online", 1);
jsonObject.addProperty("online", 1);
}
if (null != client) {
Log.i("JWebSocketClientService", "发送的消息:" + jsonObject.toJSONString());
client.send(jsonObject.toJSONString());
Log.i("JWebSocketClientService", "发送的消息:" + jsonObject.toString());
client.send(jsonObject.toString());
}
}
public void sendMsg(int state) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("sn", Utils.getSerial(this));
jsonObject.put("online", state);
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("sn", Utils.getSerial(this));
jsonObject.addProperty("online", state);
try {
if (null != client) {
Log.i("JWebSocketClientService", "发送的消息:" + jsonObject.toJSONString());
client.send(jsonObject.toJSONString());
Log.i("JWebSocketClientService", "发送的消息:" + jsonObject.toString());
client.send(jsonObject.toString());
} else {
Log.i("JWebSocketClientService", "未连接");
}

View File

@@ -5,6 +5,7 @@ import android.app.AlarmManager;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.Service;
import android.app.StatusBarManager;
import android.app.role.OnRoleHoldersChangedListener;
import android.app.role.RoleManager;
import android.content.BroadcastReceiver;
@@ -37,8 +38,6 @@ import android.widget.TextView;
import androidx.core.app.NotificationCompat;
import androidx.core.app.NotificationManagerCompat;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.aoleyun.sn.BuildConfig;
import com.aoleyun.sn.R;
import com.aoleyun.sn.activity.main.MainActivity;
@@ -46,6 +45,7 @@ import com.aoleyun.sn.bean.PoweroffBean;
import com.aoleyun.sn.comm.CommonConfig;
import com.aoleyun.sn.comm.JGYActions;
import com.aoleyun.sn.comm.PackageNames;
import com.aoleyun.sn.gson.GsonUtils;
import com.aoleyun.sn.network.NetInterfaceManager;
import com.aoleyun.sn.rlog.LogDBManager;
import com.aoleyun.sn.utils.ApkUtils;
@@ -60,6 +60,7 @@ import com.aoleyun.sn.utils.Utils;
import com.arialyy.aria.core.Aria;
import com.blankj.utilcode.util.NetworkUtils;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.google.gson.reflect.TypeToken;
import com.tencent.android.tpush.XGIOperateCallback;
import com.tencent.android.tpush.XGPushConfig;
@@ -181,9 +182,12 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
tagSets.add(JGYUtils.CubeTag);
} else if (platform == JGYUtils.MTK11Platform) {
tagSets.add(JGYUtils.MTK11Tag);
} else if (platform == JGYUtils.TeclastP20sPlatform) {
tagSets.add(JGYUtils.TeclastP20sTag);
}
}
});
Log.e(TAG, "setPushTag: " + tagSets);
NetInterfaceManager.getInstance().clearAndAppendTags(tagSets);
}
});
@@ -429,6 +433,7 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
timeChangedStart.onstar(System.currentTimeMillis());
setStatusbar();
setFloatingWindow();
JGYUtils.getInstance().writeAppPackageList();
// notificationManager = NotificationManagerCompat.from(this);
// createNotificationChannel();
}
@@ -506,13 +511,15 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
}
private void setStatusbar() {
// StatusBarManager mStatusBarManager = (StatusBarManager) getApplicationContext().getSystemService(Context.STATUS_BAR_SERVICE);
// mStatusBarManager.disable(StatusBarManager.DISABLE_RECENT | StatusBarManager.DISABLE_HOME);
String status = (String) SPUtils.get(this, JGYActions.ACTION_STATUSBAR_STATUS, "");
Log.e(TAG, "setStatusbar: String: " + status);
if (TextUtils.isEmpty(status)) {
Log.e(TAG, "setStatusbar: " + "status is NULL");
return;
}
JSONObject jsonObject = JSON.parseObject(status);
JsonObject jsonObject = GsonUtils.getJsonObject(status);
SysSettingUtils.setStatusBar(this, jsonObject);
}
@@ -929,6 +936,7 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
} else {
ToastUtil.betaShow("设备已解锁");
// notificationManager.cancel(NotificationID);
JGYUtils.getInstance().writeAppPackageList();
SysSettingUtils.setEnableSetting(this);
}

View File

@@ -23,15 +23,15 @@ import android.util.Log;
import androidx.annotation.RequiresApi;
import androidx.core.content.FileProvider;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.aoleyun.sn.BuildConfig;
import com.aoleyun.sn.bean.UploadAppInfo;
import com.aoleyun.sn.comm.JGYActions;
import com.aoleyun.sn.comm.PackageNames;
import com.aoleyun.sn.gson.GsonUtils;
import com.arialyy.aria.core.Aria;
import com.arialyy.aria.core.download.DownloadEntity;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import java.io.BufferedReader;
import java.io.DataOutputStream;
@@ -977,6 +977,8 @@ public class ApkUtils {
this.add("com.wyt.wangkexueximvvm1");
this.add("com.android.stk");
this.add("com.shoufei.aole");
this.add("com.ygyb.yischool");
}};
public static void showAllAPP(Context context) {
@@ -1266,8 +1268,8 @@ public class ApkUtils {
for (DownloadEntity entity : list) {
long id = entity.getId();
String extendField = Aria.download(this).load(id).getExtendField();
JSONObject jsonObject = JSON.parseObject(extendField);
if (packageName.equals(jsonObject.getString("app_package"))) {
JsonObject jsonObject = GsonUtils.getJsonObject(extendField);
if (packageName.equals(jsonObject.get("app_package").getAsString())) {
Log.e("RemoveTask", "subscribe: " + "删除文件:" + entity.getFilePath());
Aria.download(this).load(id).cancel(true);
}

View File

@@ -37,8 +37,6 @@ import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.core.content.ContextCompat;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.aoleyun.sn.BuildConfig;
import com.aoleyun.sn.bean.AppListInfo;
import com.aoleyun.sn.bean.Appground;
@@ -95,7 +93,6 @@ import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.Executor;
import java.util.function.Consumer;
import java.util.function.Predicate;
@@ -118,12 +115,14 @@ public class JGYUtils {
public static final int CubePlatform = 2;
public static final int ZhanruiPlatform = 3;
public static final int MTK11Platform = 5;
public static final int TeclastP20sPlatform = 6;
public static final String Other = "其他";
public static final String MTKTag = "MTK";
public static final String CubeTag = "展锐cube";
public static final String ZhanruiTag = "展锐";
public static final String MTK11Tag = "MTK11";
public static final String TeclastP20sTag = "P20S";
private CacheHelper cacheHelper;
@@ -158,6 +157,7 @@ public class JGYUtils {
public static native String getAuthorization();
public int checkSNPlatform(String sn) {
if (TextUtils.isEmpty(sn)) return UnknowPlatform;
String secondChars = sn.substring(1, 2);
if ("N".equalsIgnoreCase(secondChars)) {//MTK平台
return MTKPlatform;
@@ -180,9 +180,12 @@ public class JGYUtils {
} else if ("ZhanRuiCube".equalsIgnoreCase(platform)) {
Log.i(TAG, "checkAppPlatform: " + "ZhanRuiCube");
return CubePlatform;
} else if ("MTK11".equalsIgnoreCase(platform)) {
} else if (MTK11Tag.equalsIgnoreCase(platform)) {
Log.i(TAG, "checkAppPlatform: " + "MTK11");
return MTK11Platform;
} else if (TeclastP20sTag.equalsIgnoreCase(platform)) {
Log.i(TAG, "checkAppPlatform: " + "P20S");
return TeclastP20sPlatform;
} else {
Log.i(TAG, "checkAppPlatform: " + "没有数据");
return UnknowPlatform;
@@ -212,6 +215,8 @@ public class JGYUtils {
getAppPlatformCallback.AppPlatform(CubePlatform);
} else if ("MTK11".equalsIgnoreCase(platform)) {
getAppPlatformCallback.AppPlatform(MTK11Platform);
} else if (TeclastP20sTag.equalsIgnoreCase(platform)) {
getAppPlatformCallback.AppPlatform(TeclastP20sPlatform);
} else {
getAppPlatformCallback.AppPlatform(UnknowPlatform);
}
@@ -227,6 +232,8 @@ public class JGYUtils {
return CubeTag;
} else if ("MTK11".equalsIgnoreCase(platform)) {
return MTK11Tag;
} else if ("P20S".equalsIgnoreCase(platform)) {
return TeclastP20sTag;
} else {
return Other;
}
@@ -490,11 +497,11 @@ public class JGYUtils {
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());
packageObj.put("app_package", info.getApp_package());
packageObj.put("app_id", info.getApp_id());
packageObj.put("MD5", info.getApp_md5());
JsonObject packageObj = new JsonObject();
packageObj.addProperty("app_name", info.getApp_name());
packageObj.addProperty("app_package", info.getApp_package());
packageObj.addProperty("app_id", info.getApp_id());
packageObj.addProperty("MD5", info.getApp_md5());
Utils.ariaDownload(mContext, info.getApp_url(), packageObj);
} else {
Log.e(TAG, "checkPackageAndVersion: " + pkg + " 版本正常");
@@ -762,8 +769,11 @@ public class JGYUtils {
synchronized public void setNewAppinsideWeb(BaseResponse response) {
Log.e(TAG, "setNewAppinsideWeb: " + "应用内部联网管控: " + response);
if (response.code == 200) {
String jsonString = JSONArray.toJSONString(response.data);
List<TTAppground> appgrounds = JSONObject.parseArray(jsonString, TTAppground.class);
String jsonString = GsonUtils.toJSONString(response.data);
Gson gson = new Gson();
Type type = new TypeToken<List<TTAppground>>() {
}.getType();
List<TTAppground> appgrounds = gson.fromJson(jsonString, type);
List<TTAppground> whiteApp = new ArrayList<>();
List<TTAppground> blackApp = new ArrayList<>();
if (appgrounds != null && appgrounds.size() > 0) {
@@ -1070,39 +1080,42 @@ public class JGYUtils {
if (TextUtils.isEmpty(data)) {
Log.e(TAG, "SettingSysData: " + "data is empty");
SysSettingUtils.setDisableSetting(mContext);
SPUtils.put(mContext, JGYActions.ACTION_STATUSBAR_STATUS, "");
} else {
SysSettingUtils.setSystemSetting(mContext, data);
}
}
HashSet<String> defaultPackages = new HashSet<String>() {{
this.add(BuildConfig.APPLICATION_ID);
this.add(PackageNames.OLD_DEVICE_INFO);//设备信息
this.add(PackageNames.OLD_APPSTORE);//教管壹
this.add(PackageNames.DEVICE_INFO);
this.add(PackageNames.APPSTORE);
this.add("com.info.sn");
this.add("com.uiuios.jgy1");
this.add("com.uiuios.jgy2");
this.add("com.tt.ttutils");
this.add("com.aoleyun.browser");
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");
this.add("com.calculator.uiui");
this.add("com.notepad.uiui");
this.add("com.calendar.uiui");
this.add("com.alarmclock.uiui");
this.add("com.uiui.videoplayer");
this.add("com.ygyb.yischool");
}};
@SuppressLint("NewApi")
public void writeAppPackageList(Context context, String packageList) {
ApkUtils.addShortcut(context);
HashSet<String> packages = new HashSet<String>() {{
this.add(BuildConfig.APPLICATION_ID);
this.add(PackageNames.OLD_DEVICE_INFO);//设备信息
this.add(PackageNames.OLD_APPSTORE);//教管壹
this.add(PackageNames.DEVICE_INFO);
this.add(PackageNames.APPSTORE);
this.add("com.info.sn");
this.add("com.uiuios.jgy1");
this.add("com.uiuios.jgy2");
this.add("com.tt.ttutils");
this.add("com.aoleyun.browser");
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");
this.add("com.calculator.uiui");
this.add("com.notepad.uiui");
this.add("com.calendar.uiui");
this.add("com.alarmclock.uiui");
this.add("com.uiui.videoplayer");
}};
HashSet<String> pkgSet = new HashSet<>(Arrays.asList(packageList.split(",")));
pkgSet.addAll(packages);
pkgSet.addAll(defaultPackages);
pkgSet.addAll(ApkUtils.desktopAPP);
pkgSet.addAll(ApkUtils.aoleyunAPP);
pkgSet.addAll(ApkUtils.aihuaApp);
@@ -1113,6 +1126,12 @@ public class JGYUtils {
Log.e("writeAppPackageList: ", "aole_app_forbid: " + b + " " + Settings.System.getString(crv, CommonConfig.AOLE_ACTION_APP_FORBID));
}
public void writeAppPackageList() {
String aole_app_forbid = String.join(",", defaultPackages);
Log.e(TAG, "writeAppPackageList: " + aole_app_forbid);
Settings.System.putString(crv, CommonConfig.AOLE_ACTION_APP_FORBID, aole_app_forbid);
}
public void checkForceDownload() {
String jsonString = cacheHelper.getAsString(UrlAddress.GET_FORCE_INSTALL_LIST);
//为 "" 是已经请求成功的
@@ -1142,11 +1161,11 @@ public class JGYUtils {
String app_url = forceDownloadData.getApp_url();
String app_id = forceDownloadData.getApp_id();
String app_md5 = forceDownloadData.getApp_md5();
JSONObject jsonObject = new JSONObject();
jsonObject.put("app_name", app_name);
jsonObject.put("app_package", app_package);
jsonObject.put("app_id", app_id);
jsonObject.put("MD5", app_md5);
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("app_name", app_name);
jsonObject.addProperty("app_package", app_package);
jsonObject.addProperty("app_id", app_id);
jsonObject.addProperty("MD5", app_md5);
long app_version_code = forceDownloadData.getApp_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())) {
@@ -1191,10 +1210,10 @@ public class JGYUtils {
String app_name = jsonObject.get("app_name").getAsString();
String app_md5 = jsonObject.get("app_md5").getAsString();
// String app_id = jsonObject.get("app_id").getAsString();
JSONObject object = new JSONObject();
object.put("app_name", app_name);
object.put("app_package", packageName);
object.put("MD5", app_md5);
JsonObject object = new JsonObject();
object.addProperty("app_name", app_name);
object.addProperty("app_package", packageName);
object.addProperty("MD5", app_md5);
// object.put("app_id", app_id);
PackageManager pm = mContext.getPackageManager();
PackageInfo packageInfo = null;
@@ -1219,9 +1238,9 @@ public class JGYUtils {
String packageName = jsonObject.get("app_package").getAsString();
String app_name = jsonObject.get("app_name").getAsString();
// String app_id = jsonObject.get("app_id").getAsString();
JSONObject object = new JSONObject();
object.put("app_name", app_name);
object.put("app_package", packageName);
JsonObject object = new JsonObject();
object.addProperty("app_name", app_name);
object.addProperty("app_package", packageName);
// object.put("app_id", app_id);
PackageManager pm = mContext.getPackageManager();
PackageInfo packageInfo = null;
@@ -1251,10 +1270,10 @@ public class JGYUtils {
String app_name = data.getApp_name();
String app_md5 = data.getApp_md5();
// String app_id = jsonObject.get("app_id").getAsString();
JSONObject object = new JSONObject();
object.put("app_name", app_name);
object.put("app_package", packageName);
object.put("MD5", app_md5);
JsonObject object = new JsonObject();
object.addProperty("app_name", app_name);
object.addProperty("app_package", packageName);
object.addProperty("MD5", app_md5);
// object.put("app_id", app_id);
PackageManager pm = mContext.getPackageManager();
PackageInfo packageInfo = null;
@@ -1271,11 +1290,11 @@ public class JGYUtils {
}
}
public void installDesktop(JSONObject jsonObject) {
String app_name = jsonObject.getString("app_name");
String app_url = jsonObject.getString("app_url");
String app_package = jsonObject.getString("app_package");
int app_version_code = jsonObject.getInteger("app_version_code");
public void installDesktop(JsonObject jsonObject) {
String app_name = jsonObject.get("app_name").getAsString();
String app_url = jsonObject.get("app_url").getAsString();
String app_package = jsonObject.get("app_package").getAsString();
int app_version_code = jsonObject.get("app_version_code").getAsInt();
if (ApkUtils.desktopAPP.get(0).equals(app_package)) {
ApkUtils.UninstallAPP(mContext, ApkUtils.desktopAPP.get(1));
} else {
@@ -1311,9 +1330,9 @@ public class JGYUtils {
public void deleteOtherApp() {
Log.e(TAG, "deleteOtherApp: " + Build.MODEL);
if ("K106".equalsIgnoreCase(Build.MODEL)
||"G10".equalsIgnoreCase(Build.MODEL)
||"G10P".equalsIgnoreCase(Build.MODEL)
||"G10R".equalsIgnoreCase(Build.MODEL)
|| "G10".equalsIgnoreCase(Build.MODEL)
|| "G10P".equalsIgnoreCase(Build.MODEL)
|| "G10R".equalsIgnoreCase(Build.MODEL)
) {
return;
}
@@ -1442,6 +1461,24 @@ public class JGYUtils {
}
}
public void hideApp(String pkg) {
PackageManager pm = mContext.getPackageManager();
try {
pm.setApplicationEnabledSetting(pkg, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 0);
} catch (Exception e) {
Log.e(TAG, "hideApp: " + e.getMessage());
}
}
public void showApp(String pkg) {
PackageManager pm = mContext.getPackageManager();
try {
pm.setApplicationEnabledSetting(pkg, PackageManager.COMPONENT_ENABLED_STATE_DEFAULT, 0);
} catch (Exception e) {
Log.e(TAG, "hideApp: " + e.getMessage());
}
}
/**
* 从Manifest中获取meta-data值
@@ -1471,15 +1508,15 @@ public class JGYUtils {
Log.e(TAG, "checkBootFile: Bootanimation file exists");
setBootanimation(bootFile.getAbsolutePath());
} else {
JSONObject jsonObject = new JSONObject();
jsonObject.put("MD5", MD5);
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("MD5", MD5);
Utils.ariaDownload(mContext, url, jsonObject);
Log.e(TAG, "checkBootFile: " + "download file");
}
} else {
JSONObject jsonObject = new JSONObject();
jsonObject.put("MD5", MD5);
jsonObject.put("app_name", urlFileName);
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("MD5", MD5);
jsonObject.addProperty("app_name", urlFileName);
Utils.ariaDownload(mContext, url, jsonObject);
}
}
@@ -2037,6 +2074,9 @@ public class JGYUtils {
setDefaultDesktop(PackageNames.DESKTOP);
}
public void setYxpDefaultDesktop() {
setDefaultDesktop(PackageNames.YIXUEPAI_DESKTOP);
}
/**
* 设置默认桌面

View File

@@ -11,12 +11,12 @@ import android.provider.Settings;
import android.text.TextUtils;
import android.util.Log;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.aoleyun.sn.BuildConfig;
import com.aoleyun.sn.comm.CommonConfig;
import com.aoleyun.sn.comm.JGYActions;
import com.aoleyun.sn.gson.GsonUtils;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import java.util.ArrayList;
import java.util.List;
@@ -41,7 +41,7 @@ public class SysSettingUtils {
if (null == context) {
throw new RuntimeException("Context it's null");
}
JSONObject jsonObject = JSON.parseObject(jsonObj);
JsonObject jsonObject = GsonUtils.getJsonObject(jsonObj);
setPhoneList(context, jsonObject);
setBluetooth(context, jsonObject);
setHotspot(context, jsonObject);
@@ -51,8 +51,8 @@ public class SysSettingUtils {
setIcon(context, jsonObject);
setCanReset(context, jsonObject);
setAutoTime(context, jsonObject);
JSONObject navJson = jsonObject.getJSONObject("setting_nav");
SPUtils.put(context, JGYActions.ACTION_STATUSBAR_STATUS, jsonObject.getJSONObject("setting_nav").toJSONString());
JsonObject navJson = jsonObject.get("setting_nav").getAsJsonObject();
SPUtils.put(context, JGYActions.ACTION_STATUSBAR_STATUS, jsonObject.get("setting_nav").toString());
setStatusBar(context, navJson);
setBrowserInput(context, jsonObject);
// TODO: 2022/4/11 不是酷比定制的会报错,无法抛出异常
@@ -123,15 +123,15 @@ public class SysSettingUtils {
}
}
private static void setPhoneList(Context context, JSONObject jsonObject) {
private static void setPhoneList(Context context, JsonObject jsonObject) {
try {
//设置电话功能,电话白名单
//电话通话开关
int setting_call = changeNum(jsonObject.getInteger("setting_call"));
int setting_call = changeNum(jsonObject.get("setting_call").getAsInt());
boolean qch_call_forbid = Settings.System.putInt(context.getContentResolver(), "qch_call_forbid", setting_call);
Log.e(TAG, "qch_call_forbid:" + qch_call_forbid);
//电话白名单开关
int setting_phone = changeNum(jsonObject.getInteger("setting_phone"));
int setting_phone = changeNum(jsonObject.get("setting_phone").getAsInt());
boolean aole_white_list_on = Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_WHITE_LIST_ON, setting_phone);
Log.e(TAG, "aole_white_list_on:" + aole_white_list_on);
//白名单列表
@@ -140,13 +140,13 @@ public class SysSettingUtils {
// ToastTool.show("qch_call_forbid::"+setting_call+"----setting_phones::"+setting_phones+"----"+aole_white_list_Array+"---"+qch_call_forbid);
Log.e(TAG, "aole_white_list_Array:" + aole_white_list_Array);
} else {
String setting_phones = jsonObject.getString("setting_phones");
String setting_phones = jsonObject.get("setting_phones").getAsString();
boolean aole_white_list_Array = Settings.System.putString(context.getContentResolver(), CommonConfig.AOLE_ACTION_WHITE_LIST_ARRAY, setting_phones);
// ToastTool.show("qch_call_forbid::"+setting_call+"----setting_phones::"+setting_phones+"----"+aole_white_list_Array+"---"+qch_call_forbid);
Log.e(TAG, "aole_white_list_Array:" + aole_white_list_Array + "---" + setting_phones);
}
//存储卡
int setting_memory = changeNum(jsonObject.getInteger("setting_memory"));
int setting_memory = changeNum(jsonObject.get("setting_memory").getAsInt());
boolean aole_sdcard_forbid_on = Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_SDCARD_FORBID_ON, setting_memory);
Log.e(TAG, "aole_sdcard_forbid_on:" + aole_sdcard_forbid_on);
} catch (Exception e) {
@@ -174,12 +174,12 @@ public class SysSettingUtils {
}
}
private static void setUSBstate(Context context, JSONObject jsonObject) {
private static void setUSBstate(Context context, JsonObject jsonObject) {
//USB数据功能管控
//仅充电usb_charge
//MTP模式usb_mtp
//Midi模式usb_midi
String setting_usb = jsonObject.getString("setting_usb");
String setting_usb = jsonObject.get("setting_usb").getAsString();
if (!BuildConfig.DEBUG) {
if (JGYUtils.isCubeDevice()) {
SuperPower mService = (SuperPower) context.getSystemService("mdm");
@@ -237,14 +237,14 @@ public class SysSettingUtils {
}
}
private static void setBluetooth(Context context, JSONObject jsonObject) {
private static void setBluetooth(Context context, JsonObject jsonObject) {
try {
//蓝牙开关
int setting_bht = changeNum(jsonObject.getInteger("setting_bht"));
int setting_bht = changeNum(jsonObject.get("setting_bht").getAsInt());
//总开关
int setting_bhtvideo = changeNum(jsonObject.getInteger("setting_bhtvideo"));
int setting_bhtvideo = changeNum(jsonObject.get("setting_bhtvideo").getAsInt());
//蓝牙音频开关
int setting_bluetooth = changeNum(jsonObject.getInteger("setting_bluetooth"));
int setting_bluetooth = changeNum(jsonObject.get("setting_bluetooth").getAsInt());
//蓝牙传输开关
boolean aole_bht_forbid_on = Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_BHT_FORBID_ON, setting_bht);
@@ -258,7 +258,7 @@ public class SysSettingUtils {
}
if (setting_bht == 0) {
//蓝牙总开关开启
String setting_context = jsonObject.getString("setting_context");
String setting_context = jsonObject.get("setting_context").getAsString();
if (setting_bhtvideo == 0) {
if (null != setting_context && !"".equals(setting_context) && !" ".equals(setting_context) && !"null".equals(setting_context)) {
Log.e(TAG, "setting_context:" + setting_context);
@@ -293,9 +293,9 @@ public class SysSettingUtils {
}
}
private static void setHotspot(Context context, JSONObject jsonObject) {
private static void setHotspot(Context context, JsonObject jsonObject) {
try {
int setting_hotspot = changeNum(jsonObject.getInteger("setting_hotspot"));//热点
int setting_hotspot = changeNum(jsonObject.get("setting_hotspot").getAsInt());//热点
if (setting_hotspot == 1) {
Intent intent = new Intent();
intent.setAction("qch_hotspot_close");
@@ -355,9 +355,9 @@ public class SysSettingUtils {
}
}
private static void setBar(Context context, JSONObject jsonObject) {
private static void setBar(Context context, JsonObject jsonObject) {
//系统导航条显示开关
int setting_navigation = changeNum(jsonObject.getInteger("setting_navigation"));
int setting_navigation = changeNum(jsonObject.get("setting_navigation").getAsInt());
//写入到系统不涉及任何管控,因为之前调用会频繁隐藏显示
boolean aole_hide_NavigationBar = Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_HIDE_NAVIGATION_BAR, setting_navigation);
Log.e(TAG, "aole_hide_NavigationBar---------" + aole_hide_NavigationBar);
@@ -378,7 +378,7 @@ public class SysSettingUtils {
//状态栏显示开关
int setting_statusbar = changeNum(jsonObject.getInteger("setting_statusbar"));
int setting_statusbar = changeNum(jsonObject.get("setting_statusbar").getAsInt());
int oldNum = Settings.System.getInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_HIDE_STATUS_BAR, 0);
if (oldNum != setting_statusbar) {
//写入到系统不涉及任何管控,因为之前调用会频繁隐藏显示
@@ -423,10 +423,10 @@ public class SysSettingUtils {
}
}
private static void setCamera(Context context, JSONObject jsonObject) {
private static void setCamera(Context context, JsonObject jsonObject) {
try {
//摄像头开关
int setting_camera = changeNum(jsonObject.getInteger("setting_camera"));
int setting_camera = changeNum(jsonObject.get("setting_camera").getAsInt());
Settings.System.putInt(context.getContentResolver(), "qch_app_camera", setting_camera);
Log.e(TAG, "qch_app_camera2:" + setting_camera);
// ApkUtils.hideSystemSettingAPP(context, "com.mediatek.camera");
@@ -479,9 +479,9 @@ public class SysSettingUtils {
* @param context
* @param jsonObject tfmedia开关
*/
private static void setTF(Context context, JSONObject jsonObject) {
private static void setTF(Context context, JsonObject jsonObject) {
try {
int setting_tfmedia = jsonObject.getInteger("setting_tfmedia");
int setting_tfmedia = jsonObject.get("setting_tfmedia").getAsInt();
// if (JGYUtils.isOfficialVersion() ) {
// setting_tfmedia = changeNum(setting_tfmedia);
// }
@@ -502,12 +502,11 @@ public class SysSettingUtils {
Intent tfmediaIntent = new Intent(tfmediaStatus).setPackage("com.android.settings");
context.sendBroadcast(tfmediaIntent);
if (setting_tfmedia == 1) {
JSONArray jSONArray = null;
jSONArray = jsonObject.getJSONArray("setting_tfmedia_format");
JsonArray jSONArray = jsonObject.get("setting_tfmedia_format").getAsJsonArray();
StringBuffer stringBuffer = new StringBuffer();
for (int i = 0; i < jSONArray.size(); i++) {
stringBuffer.append(jSONArray.getString(i));
stringBuffer.append(jSONArray.get(i).toString());
stringBuffer.append(",");
}
stringBuffer.deleteCharAt(stringBuffer.length() - 1);
@@ -561,35 +560,35 @@ public class SysSettingUtils {
}
}
private static void setIcon(Context context, JSONObject jsonObject) {
private static void setIcon(Context context, JsonObject jsonObject) {
try {
//added:2019.12.6
//设置5个app的开关
//时钟
int deskclock = changeNum(jsonObject.getInteger("setting_clock"));
int deskclock = changeNum(jsonObject.get("setting_clock").getAsInt());
Settings.System.putInt(context.getContentResolver(), "qch_app_deskclock", deskclock);
ApkUtils.hideSystemSettingAPP(context, "com.android.deskclock");
Log.e(TAG, "qch_app_deskclock" + deskclock);
//录音机
int soundrecorder = changeNum(jsonObject.getInteger("setting_recording"));
int soundrecorder = changeNum(jsonObject.get("setting_recording").getAsInt());
Settings.System.putInt(context.getContentResolver(), "qch_app_soundrecorder", soundrecorder);
ApkUtils.hideSystemSettingAPP(context, "com.android.soundrecorder");
Log.e(TAG, "qch_app_soundrecorder" + soundrecorder);
//音乐
int music = changeNum(jsonObject.getInteger("setting_music"));
int music = changeNum(jsonObject.get("setting_music").getAsInt());
Settings.System.putInt(context.getContentResolver(), "qch_app_music", music);
ApkUtils.hideSystemSettingAPP(context, "com.android.music");
Log.e(TAG, "qch_app_music" + music);
//图库
int gallery = changeNum(jsonObject.getInteger("setting_picture"));
int gallery = changeNum(jsonObject.get("setting_picture").getAsInt());
Settings.System.putInt(context.getContentResolver(), "qch_app_gallery", gallery);
ApkUtils.hideSystemSettingAPP(context, "com.android.gallery3d");
Log.e(TAG, "qch_app_gallery" + gallery);
//壁纸
int wallpaper = changeNum(jsonObject.getInteger("setting_wallpaper"));
int wallpaper = changeNum(jsonObject.get("setting_wallpaper").getAsInt());
setWallpaper(context, wallpaper);
//文件管理器
int filemanager = changeNum(jsonObject.getInteger("setting_file"));
int filemanager = changeNum(jsonObject.get("setting_file").getAsInt());
Settings.System.putInt(context.getContentResolver(), "qch_app_filemanager", filemanager);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
ApkUtils.hideSystemSettingAPP(context, "com.mediatek.filemanager");
@@ -598,11 +597,11 @@ public class SysSettingUtils {
}
Log.e(TAG, "qch_app_filemanager" + filemanager);
//浏览器
int browser = changeNum(jsonObject.getInteger("setting_browser"));
int browser = changeNum(jsonObject.get("setting_browser").getAsInt());
Settings.System.putInt(context.getContentResolver(), "qch_app_browser", browser);
Log.e(TAG, "qch_app_browser" + browser);
//短信
int setting_sms = changeNum(jsonObject.getInteger("setting_sms"));
int setting_sms = changeNum(jsonObject.get("setting_sms").getAsInt());
Settings.System.putInt(context.getContentResolver(), "qch_app_sms", setting_sms);
Log.e(TAG, "qch_app_sms" + setting_sms);
} catch (Exception e) {
@@ -625,8 +624,8 @@ public class SysSettingUtils {
//aole_restore_forbid_on=1禁止恢复出厂设置
//aole_restore_forbid_on=0允许恢复出厂设置
private static void setCanReset(Context context, JSONObject jsonObject) {
int mode = jsonObject.getInteger("qch_restore");
private static void setCanReset(Context context, JsonObject jsonObject) {
int mode = jsonObject.get("qch_restore").getAsInt();
if (mode == 1) {
boolean aole_restore_forbid_on = Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_RESTORE_FORBID_ON, 0);
Log.e(TAG, "aole_restore_forbid_on: " + aole_restore_forbid_on);
@@ -653,8 +652,8 @@ public class SysSettingUtils {
//intent34.setPackage("com.android.settings");
//sendBroadcast(intent34);
private static void setAutoTime(Context context, JSONObject jsonObject) {
String autoTime = jsonObject.getString("setting_autotime");
private static void setAutoTime(Context context, JsonObject jsonObject) {
String autoTime = jsonObject.get("setting_autotime").getAsString();
String action = "qch_autotime_network";
if (TextUtils.isEmpty(autoTime)) {
action = "qch_autotime_network";
@@ -690,23 +689,23 @@ public class SysSettingUtils {
}
@SuppressLint("NewApi")
public static void setStatusBar(Context context, JSONObject jsonObject) {
Log.e(TAG, "setStatusBar: " + jsonObject.toJSONString());
public static void setStatusBar(Context context, JsonObject jsonObject) {
Log.e(TAG, "setStatusBar: " + jsonObject.toString());
if (null != jsonObject) {
int whole = jsonObject.getInteger("whole");
int whole = jsonObject.get("whole").getAsInt();
if (whole == 1) {
setStatusBar(context, 0);
} else {
List<Integer> disableWhat = new ArrayList<>();
int home = jsonObject.getInteger("home");
int home = jsonObject.get("home").getAsInt();
if (home == 0) {
disableWhat.add(StatusBarManager.DISABLE_HOME);
}
int returnKey = jsonObject.getInteger("returnKey");
int returnKey = jsonObject.get("returnKey").getAsInt();
if (returnKey == 0) {
disableWhat.add(StatusBarManager.DISABLE_BACK);
}
int taskbar = jsonObject.getInteger("taskbar");
int taskbar = jsonObject.get("taskbar").getAsInt();
if (taskbar == 0) {
disableWhat.add(StatusBarManager.DISABLE_RECENT);
}
@@ -737,12 +736,12 @@ public class SysSettingUtils {
* @param context
* @param jsonObject
*/
private static void setBrowserInput(Context context, JSONObject jsonObject) {
private static void setBrowserInput(Context context, JsonObject jsonObject) {
int state = 1;
try {
state = jsonObject.getInteger("setting_browserInput");
state = jsonObject.get("setting_browserInput").getAsInt();
Log.e(TAG, "setBrowserInput: " + state);
String json = jsonObject.getString("setting_browserInput");
String json = jsonObject.get("setting_browserInput").getAsString();
if (TextUtils.isEmpty(json)) {
state = 1;
}

View File

@@ -48,7 +48,6 @@ import android.widget.Toast;
import androidx.annotation.RequiresApi;
import androidx.annotation.VisibleForTesting;
import com.alibaba.fastjson.JSONObject;
import com.aoleyun.sn.BuildConfig;
import com.aoleyun.sn.R;
import com.aoleyun.sn.base.BaseApplication;
@@ -63,6 +62,7 @@ import com.google.zxing.WriterException;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.qrcode.QRCodeWriter;
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
import com.squareup.moshi.Json;
import com.tencent.mmkv.MMKV;
import java.io.BufferedReader;
@@ -107,6 +107,7 @@ import io.reactivex.rxjava3.core.ObservableOnSubscribe;
import io.reactivex.rxjava3.core.Observer;
import io.reactivex.rxjava3.disposables.Disposable;
import io.reactivex.rxjava3.schedulers.Schedulers;
import vendor.mediatek.hardware.nvram.V1_0.INvram;
import static android.content.Context.WIFI_SERVICE;
@@ -177,6 +178,7 @@ public class Utils {
// } else {
// return getAndroid7MAC();
// }
return getAllMacAddress(context);
}
@@ -375,6 +377,13 @@ public class Utils {
return "未获取到设备Mac地址";
}
private static String getMacAddrApiS(Context context) {
WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
String mac = wifiInfo.getMacAddress();
return mac;
}
// MD5 设备地址标识
public static String getMD5(Context context) {
String WLANMAC = getMAC(context);
@@ -781,42 +790,86 @@ public class Utils {
return t1;
}
public static String NOSN = "012345679ABCDEF";
public static final String NOSN = "012345679ABCDEF";
public static final String TECLAST_BRAND = "Teclast";
/**
* 获取设备序列号
*
* @return
*/
@SuppressLint({"MissingPermission", "HardwareIds"})
public static String getSerial(Context context) {
String serial = "unknow";
try {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {//9.0+
serial = Build.getSerial();
} else if (Build.VERSION.SDK_INT > Build.VERSION_CODES.N) {//8.0+
serial = Build.SERIAL;
} else {//8.0-
Class<?> c = Class.forName("android.os.SystemProperties");
Method get = c.getMethod("get", String.class);
serial = (String) get.invoke(c, "ro.serialno");
if (TECLAST_BRAND.equalsIgnoreCase(Build.BRAND)) {
return getPushMac(context);
} else {
if (NOSN.equalsIgnoreCase(getSn())) {
return getIMEI(context);
} else {
return getSn();
}
} catch (Exception e) {
e.printStackTrace();
Log.e("getSerial", "读取设备序列号异常:" + e.toString());
}
if (BuildConfig.DEBUG) {
// return "LTPKD22110000051";
// serial = "012345679ABCDEF";
}
if (NOSN.equalsIgnoreCase(serial)) {
return getIMEI(context);
}
return serial;
}
public static String getPushMac(Context context) {
String macaddr = Utils.getMacAddrFromNvram();
return macaddr.replace(":", "").toUpperCase().trim();
}
//mh add start----
private static final int MAC_ADDRESS_ID = 30;
private static final int MAC_ADDRESS_OFFSET = 4;
private static final int MAC_ADDRESS_DIGITS = 6;
private static final int MAX_ADDRESS_VALUE = 0xff;
private static final int INVALID_RSSI = -200;
private static final String MAC_ADDRESS_FILENAME = "/mnt/vendor/nvdata/APCFG/APRDEB/WIFI";
private static String getMacAddrFromNvram() {
StringBuffer nvramBuf = new StringBuffer();
try {
int i = 0;
String buff = null;
INvram agent = INvram.getService();
if (agent == null) {
// mToast.setText("No support MAC address writing due to NVRAM");
// mToast.show();
Log.e("mh_mac", "NvRAMAgent is null");
return "";
}
try {
buff = agent.readFileByName(
MAC_ADDRESS_FILENAME, MAC_ADDRESS_OFFSET + MAC_ADDRESS_DIGITS);
} catch (Exception e) {
e.printStackTrace();
return "";
}
Log.i("mh_mac", "Raw data:" + buff);
if (buff.length() < 2 * (MAC_ADDRESS_OFFSET + MAC_ADDRESS_DIGITS)) {
// mToast.setText("The foramt of NVRAM is not correct");
// mToast.show();
return "";
}
// Remove the \0 special character.
int macLen = buff.length() - 1;
for (i = MAC_ADDRESS_OFFSET * 2; i < macLen; i += 2) {
if ((i + 2) < macLen) {
nvramBuf.append(buff.substring(i, i + 2));
nvramBuf.append(":");
} else {
nvramBuf.append(buff.substring(i));
}
}
Log.d("mh_mac", "buff:" + nvramBuf.toString());
} catch (Exception e) {
e.printStackTrace();
return "";
}
return nvramBuf.toString();
}
//mh add end------
@SuppressLint({"MissingPermission", "HardwareIds"})
public static String getSerial() {
public static String getSn() {
String serial = "unknow";
try {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {//9.0+
@@ -832,9 +885,6 @@ public class Utils {
e.printStackTrace();
Log.e("getSerial", "读取设备序列号异常:" + e.toString());
}
if (BuildConfig.DEBUG) {
// return "QNG2DKB00463";
}
return serial;
}
@@ -1138,9 +1188,9 @@ public class Utils {
* @param url
* @param jsonObject
*/
public static void ariaDownload(Context context, String url, JSONObject jsonObject) {
public static void ariaDownload(Context context, String url, JsonObject jsonObject) {
String fileName = getFileNamefromURL(url);
String urlMD5 = jsonObject.getString("MD5");
String urlMD5 = jsonObject.get("MD5").getAsString();
Log.e("ariaDownload", "urlMD5=" + urlMD5);
String p = JGYUtils.getInstance().getDownLoadPath();
File file = new File(JGYUtils.getInstance().getDownLoadPath() + fileName);
@@ -1158,7 +1208,7 @@ public class Utils {
.load(url) //读取下载地址
.setFilePath(JGYUtils.getInstance().getDownLoadPath() + fileName)
.ignoreFilePathOccupy()
.setExtendField(jsonObject.toJSONString())
.setExtendField(jsonObject.toString())
.create(); //启动下载}
// }
}
@@ -1167,7 +1217,7 @@ public class Utils {
.load(url) //读取下载地址
.setFilePath(JGYUtils.getInstance().getDownLoadPath() + fileName)
.ignoreFilePathOccupy()
.setExtendField(jsonObject.toJSONString())
.setExtendField(jsonObject.toString())
.create(); //启动下载}
}
}
@@ -1317,7 +1367,7 @@ public class Utils {
imei = tm.getDeviceId(slotIndex);
}
if (TextUtils.isEmpty(imei)) {
return "暂无数据";
return context.getString(R.string.no_data);
}
return imei;
}
@@ -1330,7 +1380,7 @@ public class Utils {
//8.0及以后版本获取
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
IMEI = TelephonyMgr.getDeviceId();
// } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
// try {
// Method method = TelephonyMgr.getClass().getMethod("getImei");
// IMEI = (String) method.invoke(TelephonyMgr);
@@ -1341,11 +1391,11 @@ public class Utils {
// IMEI = TelephonyMgr.getDeviceId();
// } else {//9.0到10.0获取
// IMEI = Settings.System.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
IMEI = Settings.System.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
}
Log.e("IMEI:", "IMEI: " + IMEI);
if (null == IMEI) {
return "-";
return "";
} else {
return IMEI.toUpperCase();
}
@@ -1390,18 +1440,18 @@ public class Utils {
String firmware_version = getRomVersion();
String rom = Utils.getCustomVersion();
String screen_rate = getAndroiodScreenProperty(context);
JSONObject jsonObject = new JSONObject();
jsonObject.put("device", device);
jsonObject.put("imei", imei);
jsonObject.put("system_version", system_version);
jsonObject.put("firmware_version", firmware_version);
jsonObject.put("rom", rom);
jsonObject.put("screen_rate", screen_rate);
jsonObject.put("working_time", SystemClock.elapsedRealtime() / 1000);
jsonObject.put("restart_count", SPUtils.get(context, "restart_count", 0));
jsonObject.put("storage_usable", getRemnantSize(context));
jsonObject.put("storage_total", getDataTotalSize(context));
String jsonString = jsonObject.toJSONString();
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("device", device);
jsonObject.addProperty("imei", imei);
jsonObject.addProperty("system_version", system_version);
jsonObject.addProperty("firmware_version", firmware_version);
jsonObject.addProperty("rom", rom);
jsonObject.addProperty("screen_rate", screen_rate);
jsonObject.addProperty("working_time", SystemClock.elapsedRealtime() / 1000);
jsonObject.addProperty("restart_count", (int) SPUtils.get(context, "restart_count", 0));
jsonObject.addProperty("storage_usable", getRemnantSize(context));
jsonObject.addProperty("storage_total", getDataTotalSize(context));
String jsonString = jsonObject.toString();
Log.e(TAG, "getMachine: " + jsonString);
return jsonString;
}
@@ -1414,14 +1464,14 @@ public class Utils {
Log.e("getHardware", "Memory: " + memory);
String storage = getRemnantSize(context) + "/" + getDataTotalSize(context);
int CPU = getNumCores();
JSONObject jsonObject = new JSONObject();
jsonObject.put("electric", electric);
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();
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("electric", electric);
jsonObject.addProperty("charging", charging);
jsonObject.addProperty("memory", memory);
jsonObject.addProperty("storage", storage);
jsonObject.addProperty("battery_capacity", Utils.getBatterymAh(context));
jsonObject.addProperty("CPU", CPU + "");
String jsonString = jsonObject.toString();
Log.e(TAG, "getHardware: " + jsonString);
return jsonString;
}
@@ -1704,6 +1754,7 @@ public class Utils {
|| JGYUtils.getInstance().checkAppPlatform() == JGYUtils.CubePlatform
|| JGYUtils.getInstance().checkAppPlatform() == JGYUtils.MTKPlatform
|| JGYUtils.getInstance().checkAppPlatform() == JGYUtils.MTK11Platform
|| JGYUtils.getInstance().checkAppPlatform() == JGYUtils.TeclastP20sPlatform
) {
return Utils.getProperty("ro.build.display.id", "获取失败");
} else {

View File

@@ -113,6 +113,7 @@
<string name="battery_max_charging_voltage">最大充电电压: </string>
<string name="adb_shell_help">发送命令: adb shell dumpsys battery \n</string>
<string name="upgrade_app">新版本%s已经发布,请更新应用</string>
<string name="no_data">暂无数据</string>
</resources>