version:1.7.9

date:2021-11-01 14:02:44
fix:修复唤醒
add:
This commit is contained in:
2021-11-01 14:04:00 +08:00
parent e1c6d69428
commit c04d66726b
24 changed files with 658 additions and 246 deletions

View File

@@ -4,51 +4,68 @@
package="com.info.sn"
android:sharedUserId="android.uid.system">
<!-- 系统权限,有系统签名可以使用 -->
<uses-permission android:name="android.permission.ACTION_SCREEN_ON" />
<uses-permission android:name="android.permission.ACTION_SCREEN_OFF" />
<uses-permission android:name="android.permission.BROADCAST_STICKY" />
<uses-permission android:name="android.permission.INSTALL_PACKAGES" />
<uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" />
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
<uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />
<uses-permission android:name="android.permission.DELETE_PACKAGES" />
<uses-permission android:name="android.permission.MASTER_CLEAR" />
<uses-permission android:name="android.permission.CHANGE_COMPONENT_ENABLED_STATE" />
<uses-permission android:name="android.permission.READ_PRIVILEGED_PHONE_STATE" />
<uses-permission android:name="android.permission.CHANGE_CONFIGURATION" />
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<uses-permission android:name="android.permission.ACTION_SCREEN_ON" />
<uses-permission android:name="android.permission.ACTION_SCREEN_OFF" />
<uses-permission android:name="android.permission.BROADCAST_STICKY" />
<uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" />
<uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<!-- Required -->
<permission
android:name="com.info.sn.permission.JPUSH_MESSAGE"
android:protectionLevel="signature" /> <!-- Required 一些系统要求的权限,如访问网络等 -->
android:protectionLevel="signature" />
<!-- Required 一些系统要求的权限,如访问网络等 -->
<uses-permission android:name="${JPUSH_PKGNAME}.permission.JPUSH_MESSAGE" />
<uses-permission android:name="android.permission.RECEIVE_USER_PRESENT" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission
android:name="android.permission.PACKAGE_USAGE_STATS"
tools:ignore="ProtectedPermissions" /> <!-- Optional for location -->
<uses-permission android:name="android.permission.VIBRATE" /> <!-- 用于开启 debug 版本的应用在6.0 系统上 层叠窗口权限 -->
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" /> <!-- 获取运营商信息,用于支持提供运营商信息相关的接口 -->
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" /> <!-- 用于访问wifi网络信息wifi信息会用于进行网络定位 -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <!-- 这个权限用于获取wifi的获取权限wifi信息会用来进行网络定位 -->
tools:ignore="ProtectedPermissions" />
<!-- Optional for location -->
<uses-permission android:name="android.permission.VIBRATE" />
<!-- 用于开启 debug 版本的应用在6.0 系统上 层叠窗口权限 -->
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<!-- 获取运营商信息,用于支持提供运营商信息相关的接口 -->
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<!-- 用于访问wifi网络信息wifi信息会用于进行网络定位 -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!-- 这个权限用于获取wifi的获取权限wifi信息会用来进行网络定位 -->
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /> <!-- 请求网络 -->
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<!-- 请求网络 -->
<!-- Normal Permissions 不需要运行时注册 -->
<uses-permission android:name="android.permission.INTERNET" /> <!-- 不是SDK需要的权限是示例中的后台唤醒定位需要的权限 -->
<uses-permission android:name="android.permission.WAKE_LOCK" /> <!-- 需要运行时注册的权限 -->
<uses-permission android:name="android.permission.INTERNET" />
<!-- 不是SDK需要的权限是示例中的后台唤醒定位需要的权限 -->
<uses-permission android:name="android.permission.WAKE_LOCK" />
<!-- 需要运行时注册的权限 -->
<!-- 用于进行网络定位 -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <!-- 用于访问GPS定位 -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <!-- 用于提高GPS定位速度 -->
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" /> <!-- 写入扩展存储,向扩展卡写入数据,用于写入缓存定位数据 -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <!-- 读取缓存数据 -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <!-- 用于读取手机当前的状态 -->
<uses-permission android:name="android.permission.READ_PHONE_STATE" /> <!-- 更改设置 -->
<uses-permission android:name="android.permission.WRITE_SETTINGS" /> <!-- 如果设置了target >= 28 如果需要启动后台定位则必须声明这个权限 -->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> <!-- 如果您的应用需要后台定位权限且有可能运行在Android Q设备上,并且设置了target>28必须增加这个权限声明 -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<!-- 用于访问GPS定位 -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<!-- 用于提高GPS定位速度 -->
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<!-- 写入扩展存储,向扩展卡写入数据,用于写入缓存定位数据 -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!-- 读取缓存数据 -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<!-- 用于读取手机当前的状态 -->
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<!-- 更改设置 -->
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<!-- 如果设置了target >= 28 如果需要启动后台定位则必须声明这个权限 -->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<!-- 如果您的应用需要后台定位权限且有可能运行在Android Q设备上,并且设置了target>28必须增加这个权限声明 -->
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
<application
@@ -83,7 +100,7 @@
<activity
android:name=".activity.main.MainActivity"
android:launchMode="singleTask"
android:screenOrientation="sensor">
android:screenOrientation="sensorLandscape">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
@@ -96,7 +113,7 @@
android:enabled="true"
android:exported="true" />
<service android:name=".service.GuardService" />
<service android:name=".service.MyDownloadService" />
<service android:name=".service.DownloadService" />
<service
android:name=".service.StepService"
android:exported="true">
@@ -293,7 +310,8 @@
android:value="developer-default" />
<meta-data
android:name="JPUSH_APPKEY"
android:value="${JPUSH_APPKEY}" /> <!-- 设置key -->
android:value="${JPUSH_APPKEY}" />
<!-- 设置key -->
<meta-data
android:name="com.amap.api.v2.apikey"
android:value="${AMAP_KEY}" />

View File

@@ -12,7 +12,7 @@
<netCheck value="true"/>
<!--除非无法使用注解否则不建议使用广播来接受任务状态true使用广播接收任务状态false不适用广播接收状态 -->
<!-- http://aria.laoyuyu.me/aria_doc/api/use_broadcast.html -->
<useBroadcast value="true"/>
<useBroadcast value="false"/>
<!--断网的时候是否重试true断网也重试false断网不重试直接走失败的回调-->
<notNetRetry value="true"/>
</app>

View File

@@ -47,10 +47,11 @@ import com.info.sn.jpush.ExampleUtil;
import com.info.sn.jpush.LocalBroadcastManager;
import com.info.sn.jpush.TagAliasOperatorHelper;
import com.info.sn.network.HTTPInterface;
import com.info.sn.receiver.BootReceiver;
import com.info.sn.service.DownloadService;
import com.info.sn.service.GuardService;
import com.info.sn.service.MainService;
import com.info.sn.service.ManagerService;
import com.info.sn.service.MyDownloadService;
import com.info.sn.service.StepService;
import com.info.sn.manager.ControlManager;
import com.info.sn.manager.DeviceManager;
@@ -63,9 +64,7 @@ import com.info.sn.utils.Utils;
import org.jetbrains.annotations.NotNull;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -76,7 +75,6 @@ import butterknife.ButterKnife;
import cn.jpush.android.api.JPushInterface;
import static com.info.sn.jpush.TagAliasOperatorHelper.ACTION_SET;
import static com.info.sn.jpush.TagAliasOperatorHelper.TagAliasBean;
public class MainActivity extends BaseActivity implements MainContact.MainView, NetworkUtils.OnNetworkStatusChangedListener {
private final String TAG = MainActivity.class.getSimpleName();
@@ -190,6 +188,10 @@ public class MainActivity extends BaseActivity implements MainContact.MainView,
JGYUtils.getInstance().killBackgroundProcesses(this, "com.gankao.gkwxhd");
SPUtils.put(this, "versionCode", BuildConfig.VERSION_CODE);
}
//启动应用市场
Intent bootIntent = new Intent(BootReceiver.BOOT_COMPLETED);
bootIntent.setComponent(new ComponentName("com.jgyapp.market", "com.jgyapp.market.receiver.BootReceiver"));
sendBroadcast(bootIntent);
}
private class TimeTask extends AsyncTask<String, Long, Long> {
@@ -619,7 +621,12 @@ public class MainActivity extends BaseActivity implements MainContact.MainView,
public void setBatch(String batch) {
HashSet hashSet = new HashSet();
hashSet.add(batch);
setTag(hashSet);
hashSet.removeIf(o -> TextUtils.isEmpty(o.toString()));
if (hashSet.size() != 0) {
setTag(hashSet);
} else {
Log.e(TAG, "setBatch: " + "hashSet size is 0");
}
}
private void toGankaoApp() {
@@ -689,7 +696,7 @@ public class MainActivity extends BaseActivity implements MainContact.MainView,
startService(new Intent(this, MainService.class));
startService(new Intent(this, GuardService.class));
startService(new Intent(this, StepService.class));
startService(new Intent(this, MyDownloadService.class));
startService(new Intent(this, DownloadService.class));
startService(new Intent(this, ManagerService.class));
}

View File

@@ -409,48 +409,6 @@ public class MainPresenter implements MainContact.Presenter {
});
}
private void setTag(Set set) {
TagAliasOperatorHelper.TagAliasBean tagAliasBean = new TagAliasOperatorHelper.TagAliasBean();
tagAliasBean.action = ACTION_SET;
TagAliasOperatorHelper.sequence++;
tagAliasBean.tags = set;
tagAliasBean.isAliasAction = false;
TagAliasOperatorHelper.getInstance().handleAction(mContext, TagAliasOperatorHelper.sequence, tagAliasBean);
}
// private void sendUid(AvailableProduct product, String gankaoUID) {
// NetInterfaceManager.getInstance()
// .getSaveSnUidApiControl()
// .saveSnUid(Utils.getSerial(), gankaoUID, System.currentTimeMillis() / 1000, product.getDuration())
// .subscribeOn(Schedulers.io())
// .observeOn(AndroidSchedulers.mainThread())
// .compose(getProvider().bindUntilEvent(ActivityEvent.DESTROY))
// .subscribe(new Observer<Response>() {
// @Override
// public void onSubscribe(Disposable d) {
// Log.e(TAG + "sendUid", "onSubscribe: ");
// }
//
// @Override
// public void onNext(Response response) {
// Log.e(TAG + "sendUid", "onNext: " + JSONObject.toJSONString(response));
// if (response.code == 200) {
// Log.e(TAG + "sendUid", "onNext: " + response.msg);
// }
// }
//
// @Override
// public void onError(Throwable e) {
// Log.e(TAG + "sendUid", "onError: " + e.getMessage());
// }
//
// @Override
// public void onComplete() {
// Log.e(TAG + "sendUid", "onComplete: ");
// }
// });
// }
@Override
public void getQRCode() {
String encryptString = CXAESUtil.encrypt(Configs.AES_KEY, Utils.getSerial());
@@ -759,6 +717,8 @@ public class MainPresenter implements MainContact.Presenter {
JGYUtils.getInstance().writeDeselectIDtoSystem(ids, packages);
} else {
Log.e("getAppInside", "onNext: " + baseResponse.msg);
JGYUtils.putString(mContext.getContentResolver(), "qch_app_forbid_id", " ");
JGYUtils.putString(mContext.getContentResolver(), "DeselectViewArray", " ");
}
}

View File

@@ -1,6 +1,8 @@
package com.info.sn.base;
import android.annotation.SuppressLint;
import android.app.Application;
import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import android.os.Process;
@@ -9,22 +11,63 @@ import android.util.Log;
import com.arialyy.aria.core.Aria;
import com.blankj.utilcode.util.ProcessUtils;
import com.info.sn.BuildConfig;
import com.info.sn.jpush.TagAliasOperatorHelper;
import com.info.sn.manager.AmapManager;
import com.info.sn.manager.NetInterfaceManager;
import com.info.sn.manager.ControlManager;
import com.info.sn.manager.DeviceManager;
import com.info.sn.network.HTTPInterface;
import com.info.sn.network.UrlAddress;
import com.info.sn.utils.JGYUtils;
import com.info.sn.utils.SystemUtils;
import com.info.sn.utils.ToastUtil;
import com.info.sn.utils.Utils;
import org.jetbrains.annotations.NotNull;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import cn.jpush.android.api.JPushInterface;
import cn.jpush.android.api.JPushMessage;
import io.reactivex.Observable;
import io.reactivex.ObservableEmitter;
import io.reactivex.ObservableOnSubscribe;
import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
public class BaseApplication extends Application {
private static final String TAG = BaseApplication.class.getSimpleName();
@SuppressLint("StaticFieldLeak")
public static Context context;
@SuppressLint("StaticFieldLeak")
private static BaseApplication instance;
public static Context getAppContext() {
return context;
}
// 单例模式中获取唯一的ExitApplication实例
public static BaseApplication getInstance() {
if (null == instance) {
instance = new BaseApplication();
}
return instance;
}
@Override
public void onCreate() {
super.onCreate();
// if (!getPackageName().equals(ProcessUtils.getCurrentProcessName())) {
// return;
// }
context = this;
instance = this;
if (SystemUtils.isMainProcessName(this, Process.myPid())) {
//非主进程不初始化
utilsInint();
@@ -48,6 +91,8 @@ public class BaseApplication extends Application {
AmapManager.getInstance().initAmap();
NetInterfaceManager.init(this);
JGYUtils.hookWebView();
initAliasObservable();
initTagObservable();
}
private void catchException() {
@@ -68,7 +113,8 @@ public class BaseApplication extends Application {
try {
Looper.loop(); //会先执行这个方法,然后在执行下面的异常捕获方法!
} catch (Exception e) {
Log.e("捕获异常主线程:", Thread.currentThread().getName() + "在:" + e.getStackTrace()[0].getClassName());
Log.e("捕获异常主线程:", Thread.currentThread().getName() +
"在:" + e.getStackTrace()[0].getClassName());
e.printStackTrace();
}
}
@@ -76,4 +122,266 @@ public class BaseApplication extends Application {
});
}
public void onAliasOperatorResult(JPushMessage jPushMessage) {
if (jPushMessage == null) {
return;
}
int errorCode = jPushMessage.getErrorCode();
onAliasResult.onResult(errorCode);
}
public static void setJpushAlias() {
Log.e("jiguangInterface", "30s后重新设置alias");
JPushInterface.setAlias(context, TagAliasOperatorHelper.sequence++, Utils.getSerial());
}
public void onTagOperatorResult(JPushMessage jPushMessage) {
if (jPushMessage == null) {
return;
}
int errorCode = jPushMessage.getErrorCode();
onTagResult.onResult(errorCode);
}
public static void setJpushTags() {
Log.e(TAG, "30s后重新设置tags");
HTTPInterface.setJpushTags(context);
}
private static OnAliasResult onAliasResult;
interface OnAliasResult {
void onResult(int code);
}
private static OnTagResult onTagResult;
interface OnTagResult {
void onResult(int code);
}
private static void initTagObservable() {
Log.e(TAG, "initTagObservable: ");
Observable.create(new ObservableOnSubscribe<Integer>() {
@Override
public void subscribe(ObservableEmitter<Integer> emitter) {
onTagResult = new OnTagResult() {
@Override
public void onResult(int code) {
Log.e("initTagObservable", "onResult: " + code);
emitter.onNext(code);
}
};
}
}).throttleLast(1, TimeUnit.MINUTES)
.subscribe(new Observer<Integer>() {
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onNext(Integer integer) {
Log.e("initTagObservable", "onNext: " + integer);
String s = "tags:\t";
switch (integer) {
case 0:
Log.e("jiguangInterface", s + "Tag绑定成功");
break;
case 6001:
Log.e("jiguangInterface", s + "无效的设置");
break;
case 6005:
Log.e("jiguangInterface", s + "某一个 tag 字符串不合法");
ToastUtil.show("设备标签不合法,联系管理员修改\t" + "code:6005");
break;
case 6006:
Log.e("jiguangInterface", s + "某一个 tag 超长");
ToastUtil.show("设备标签过长,联系管理员修改\t" + "code:6006");
break;
case 6007:
Log.e("jiguangInterface", s + "tags 数量超出限制");
ToastUtil.show("设备标签数量超出限制,联系管理员修改\t" + "code:6007");
break;
case 6008:
Log.e("jiguangInterface", s + "tag 超出总长度限制");
ToastUtil.show("设备标签超出总长度限制,联系管理员修改\t" + "code:6008");
break;
case 6011:
Log.e("jiguangInterface", s + "短时间内操作过于频繁");
break;
case 6013:
Log.e("jiguangInterface", s + "用户设备时间轴异常");
ToastUtil.show("用户设备时间轴异常,修改后重新登陆\t" + "code:6013");
break;
case 6018:
Log.e("jiguangInterface", s + "Tags 过多");
cleanJpushTag();
ToastUtil.show("设备标签数量超出限制,联系管理员修改\t" + "code:6018");
break;
case 6021:
Log.e("jiguangInterface", s + "tags 操作正在进行中");
break;
//需要重新设置
case 6002:
Log.e("jiguangInterface", s + "设置超时,请重试");
setJpushTags();
break;
case 6014:
Log.e("jiguangInterface", s + "服务器繁忙,建议重试");
setJpushTags();
break;
case 6020:
Log.e("jiguangInterface", s + "建议过一段时间再设置");
setJpushTags();
break;
case 6024:
Log.e("jiguangInterface", s + "服务器内部错误");
setJpushTags();
break;
default:
break;
}
}
@Override
public void onError(Throwable e) {
}
@Override
public void onComplete() {
}
});
}
private static void initAliasObservable() {
Log.e(TAG, "initAliasObservable: ");
Observable.create(new ObservableOnSubscribe<Integer>() {
@Override
public void subscribe(ObservableEmitter<Integer> emitter) throws Exception {
onAliasResult = new OnAliasResult() {
@Override
public void onResult(int code) {
Log.e("initAliasObservable", "onResult: " + code);
emitter.onNext(code);
}
};
}
}).throttleLast(1, TimeUnit.MINUTES)
.subscribe(new Observer<Integer>() {
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onNext(Integer integer) {
Log.e("initAliasObservable", "onNext: " + integer);
String s = "alias:\t";
switch (integer) {
case 0:
Log.e("jiguangInterface", s + "Alias绑定成功");
break;
case 6001:
Log.e("jiguangInterface", s + "无效的设置");
break;
case 6011:
Log.e("jiguangInterface", s + "短时间内操作过于频繁");
break;
case 6013:
Log.e("jiguangInterface", s + "用户设备时间轴异常");
ToastUtil.show("用户设备时间轴异常,修改后重新登陆\t" + s + "code:6013");
break;
case 6022:
Log.e("jiguangInterface", s + "alias 操作正在进行中");
break;
//需要重新设置
case 6002:
Log.e("jiguangInterface", s + "设置超时,请重试");
setJpushAlias();
break;
case 6014:
Log.e("jiguangInterface", s + "服务器繁忙,建议重试");
setJpushAlias();
break;
case 6020:
Log.e("jiguangInterface", s + "建议过一段时间再设置");
setJpushAlias();
break;
case 6024:
Log.e("jiguangInterface", s + "服务器内部错误");
setJpushAlias();
break;
case 6017:
case 6027:
Log.e("jiguangInterface", s + "别名绑定的设备数超过限制");
cleanJpushAlias();
setJpushAlias();
break;
default:
break;
}
}
@Override
public void onError(Throwable e) {
}
@Override
public void onComplete() {
}
});
}
synchronized public static void cleanJpushAlias() {
//alias的绑定的设备超过10个但是alias应该是一个设备对应一个在重置设备后jpush的regid会变动所以需要清除
//https://docs.jiguang.cn/jpush/server/push/rest_api_v3_device/#_5
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url(UrlAddress.DELETE_JPUSH_ALIAS + Utils.getSerial())
.header("Authorization", JGYUtils.getAuthorization())
.delete()
.build();
Call call = client.newCall(request);
call.enqueue(new Callback() {
@Override
public void onFailure(@NotNull Call call, @NotNull IOException e) {
Log.e("cleanJpushAlias", "onFailure: " + e.getMessage());
}
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
Log.e("cleanJpushAlias", "onResponse: " + response.toString());
Log.e(TAG, "onResponse: " + "清除Alias成功");
}
});
}
synchronized public static void cleanJpushTag() {
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url(UrlAddress.DELETE_JPUSH_TAG + Utils.getSerial())
.header("Authorization", JGYUtils.getAuthorization())
.delete()
.build();
Call call = client.newCall(request);
call.enqueue(new Callback() {
@Override
public void onFailure(@NotNull Call call, @NotNull IOException e) {
Log.e("cleanJpushTag", "onFailure: " + e.getMessage());
}
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
Log.e("cleanJpushTag", "onResponse: " + response.toString());
Log.e(TAG, "onResponse: " + "清除Tag成功");
}
});
}
}

View File

@@ -20,8 +20,6 @@ public class BaseResponse<T> implements Serializable {
@NonNull
@Override
public String toString() {
Gson gson = new Gson();
JsonObject jsonObject = JsonParser.parseString(gson.toJson(this)).getAsJsonObject();
return jsonObject.toString();
return JsonParser.parseString(new Gson().toJson(this)).getAsJsonObject().toString();
}
}

View File

@@ -2,6 +2,8 @@ package com.info.sn.jpush;
import android.content.Context;
import com.info.sn.base.BaseApplication;
import cn.jpush.android.api.CustomMessage;
import cn.jpush.android.api.JPushMessage;
import cn.jpush.android.service.JPushMessageReceiver;
@@ -14,6 +16,7 @@ public class MyJPushMessageReceiver extends JPushMessageReceiver {
@Override
public void onTagOperatorResult(Context context, JPushMessage jPushMessage) {
TagAliasOperatorHelper.getInstance().onTagOperatorResult(context, jPushMessage);
BaseApplication.getInstance().onTagOperatorResult(jPushMessage);
super.onTagOperatorResult(context, jPushMessage);
}
@@ -26,6 +29,7 @@ public class MyJPushMessageReceiver extends JPushMessageReceiver {
@Override
public void onAliasOperatorResult(Context context, JPushMessage jPushMessage) {
TagAliasOperatorHelper.getInstance().onAliasOperatorResult(context, jPushMessage);
BaseApplication.getInstance().onAliasOperatorResult(jPushMessage);
super.onAliasOperatorResult(context, jPushMessage);
}

View File

@@ -16,6 +16,7 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.info.sn.BuildConfig;
import com.info.sn.Statistics.AppInformation;
import com.info.sn.Statistics.StatisticsInfo;
@@ -24,6 +25,7 @@ import com.info.sn.bean.zuoye.AppStart;
import com.info.sn.bean.zuoye.AppUploadInfo;
import com.info.sn.bean.zuoye.BaseResponse;
import com.info.sn.bean.zuoye.BrowserBean;
import com.info.sn.jpush.TagAliasOperatorHelper;
import com.info.sn.manager.ControlManager;
import com.info.sn.manager.NetInterfaceManager;
import com.info.sn.network.api.NewestAppUpdate;
@@ -41,6 +43,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import cn.jpush.android.api.JPushInterface;
import io.reactivex.Observable;
@@ -51,6 +54,8 @@ import io.reactivex.annotations.NonNull;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
import static com.info.sn.jpush.TagAliasOperatorHelper.ACTION_SET;
public class HTTPInterface {
private static String TAG = HTTPInterface.class.getSimpleName();
@@ -558,11 +563,11 @@ public class HTTPInterface {
String hardware = Utils.getHardware(context);
Log.e(TAG, "updateAdminInfo: getHardware = " + hardware);
JSONObject softwareJson = new JSONObject();
softwareJson.put("appstore_version", ApkUtils.getAPPVersionName(context, "com.appstore.uiui"));
softwareJson.put("appstore_version", ApkUtils.getAPPVersionName(context, "com.jgyapp.market"));
softwareJson.put("updatetools_version", ApkUtils.getAPPVersionName(context, "com.uiuios.updatetools"));
softwareJson.put("info_version", ApkUtils.getAPPVersionName(context, "com.info.sn"));
softwareJson.put("jiaoguanyi_version", ApkUtils.getAPPVersionName(context, "com.gankao.gkwxhd"));
softwareJson.put("gankao_version", ApkUtils.getAPPVersionName(context, "com.jiaoguanyi.os"));
softwareJson.put("jiaoguanyi_version", ApkUtils.getAPPVersionName(context, "com.jiaoguanyi.os"));
softwareJson.put("gankao_version", ApkUtils.getAPPVersionName(context, "com.gankao.gkwxhd"));
softwareJson.put("learning_version", ApkUtils.getAPPVersionName(context, "com.info.learning"));
softwareJson.put("chat_version", ApkUtils.getAPPVersionName(context, "com.info.chat"));
softwareJson.put("jpush_id", JPushInterface.getRegistrationID(context));
@@ -943,7 +948,7 @@ public class HTTPInterface {
});
}
public static void getAppInside() {
public static void getAppInside(Context context) {
NetInterfaceManager.getInstance().getAppInsideControl()
.subscribe(new Observer<BaseResponse>() {
@Override
@@ -962,6 +967,8 @@ public class HTTPInterface {
JGYUtils.getInstance().writeDeselectIDtoSystem(ids, packages);
} else {
Log.e("getAppInside", "onNext: " + baseResponse.msg);
JGYUtils.putString(context.getContentResolver(), "qch_app_forbid_id", " ");
JGYUtils.putString(context.getContentResolver(), "DeselectViewArray", " ");
}
}
@@ -1042,4 +1049,50 @@ public class HTTPInterface {
});
}
public static void setJpushTags(Context context) {
NetInterfaceManager.getInstance()
.getBatchApiControl()
.subscribe(new Observer<BaseResponse>() {
@Override
public void onSubscribe(Disposable d) {
Log.e("getBatch", "onSubscribe: ");
}
@Override
public void onNext(BaseResponse baseResponse) {
Log.e("getBatch", "onNext: " + baseResponse);
if (baseResponse.code == 200) {
Gson gson = new Gson();
JsonObject jsonObject = JsonParser.parseString(gson.toJson(baseResponse.data)).getAsJsonObject();
int batch_id = jsonObject.get("batch_id").getAsInt();
Log.e("getBatch", "onNext: " + batch_id);
Set set = new HashSet();
set.add(batch_id);
setTag(context, set);
} else {
Log.e("getBatch", "onNext: " + baseResponse.msg);
}
}
@Override
public void onError(Throwable e) {
Log.e("getBatch", "onError: " + e.getMessage());
onComplete();
}
@Override
public void onComplete() {
Log.e("getBatch", "onComplete: ");
}
});
}
private static void setTag(Context context, Set set) {
TagAliasOperatorHelper.TagAliasBean tagAliasBean = new TagAliasOperatorHelper.TagAliasBean();
tagAliasBean.action = ACTION_SET;
TagAliasOperatorHelper.sequence++;
tagAliasBean.tags = set;
tagAliasBean.isAliasAction = false;
TagAliasOperatorHelper.getInstance().handleAction(context, TagAliasOperatorHelper.sequence, tagAliasBean);
}
}

View File

@@ -77,4 +77,13 @@ public class UrlAddress {
public static final String UPGRADE_USER_POWER = "upgradeUserPower";
//撤销指定的用户授权记录
public static final String CANCEL_USER_POWER = "cancelUserPower";
/*
* 极光
* */
//删除alias
public static final String DELETE_JPUSH_ALIAS = "https://device.jpush.cn/v3/aliases/";
//删除tags
public static final String DELETE_JPUSH_TAG = "https://device.jpush.cn/v3/tags/";
}

View File

@@ -2,6 +2,7 @@ package com.info.sn.receiver;
import android.annotation.SuppressLint;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
@@ -73,7 +74,21 @@ public class APKinstallReceiver extends BroadcastReceiver {
}
Log.e(TAG, "sendAppInfo: " + state + packageName);
newAppListener.setNewAppListener(packageName);
//启动应用市场
if ("com.jgyapp.market".equals(packageName)) {
Intent bootIntent = new Intent(BootReceiver.BOOT_COMPLETED);
bootIntent.setComponent(new ComponentName("com.jgyapp.market", "com.jgyapp.market.receiver.BootReceiver"));
context.sendBroadcast(bootIntent);
} else if ("com.uiuios.updatetools".equals(packageName)) {
//启动升级组件
Intent bootIntent = new Intent(BootReceiver.BOOT_COMPLETED);
bootIntent.setComponent(new ComponentName("com.uiuios.updatetools", "com.uiuios.updatetools.receiver.BootReceiver"));
context.sendBroadcast(bootIntent);
}
Intent bootIntent = new Intent(BootReceiver.BOOT_COMPLETED);
bootIntent.setComponent(new ComponentName("com.appstore.uiui", "com.appstore.uiui.receiver.BootReceiver"));
context.sendBroadcast(bootIntent);
newAppListener.setNewAppListener(packageName);
}
private void cleanLauncher3Cache() {
@@ -104,6 +119,7 @@ public class APKinstallReceiver extends BroadcastReceiver {
HTTPInterface.getAPPinfo(mContext);
HTTPInterface.getForceInstall(mContext);
HTTPInterface.getAllappPackage(mContext);
HTTPInterface.getAppInside(mContext);
}
@Override

View File

@@ -8,34 +8,37 @@ import android.util.Log;
import com.info.sn.service.GuardService;
import com.info.sn.service.MainService;
import com.info.sn.service.ManagerService;
import com.info.sn.service.MyDownloadService;
import com.info.sn.service.DownloadService;
import com.info.sn.service.StepService;
public class BootReceiver extends BroadcastReceiver {
public static final String BOOT_COMPLETED = "zuoyeos.action.BOOT_COMPLETED";
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
Log.e("SNBootReceiver", action);
if (action.equals(Intent.ACTION_BOOT_COMPLETED)
|| action.equals(Intent.ACTION_BATTERY_CHANGED)
|| action.equals(Intent.ACTION_BATTERY_LOW)
|| action.equals(Intent.ACTION_BATTERY_OKAY)
|| action.equals(Intent.ACTION_POWER_CONNECTED)
|| action.equals(Intent.ACTION_POWER_DISCONNECTED)
|| action.equals(Intent.ACTION_DATE_CHANGED)
|| action.equals(Intent.ACTION_TIME_TICK)
|| action.equals(Intent.ACTION_USER_PRESENT)
|| action.equals(Intent.ACTION_SCREEN_ON)
|| action.equals(Intent.ACTION_SCREEN_OFF)
|| action.equals("android.intent.action.BATTERY_LEVEL_CHANGED")
if (Intent.ACTION_BOOT_COMPLETED.equals(action)
|| Intent.ACTION_BATTERY_CHANGED.equals(action)
|| Intent.ACTION_BATTERY_LOW.equals(action)
|| Intent.ACTION_BATTERY_OKAY.equals(action)
|| Intent.ACTION_POWER_CONNECTED.equals(action)
|| Intent.ACTION_POWER_DISCONNECTED.equals(action)
|| Intent.ACTION_DATE_CHANGED.equals(action)
|| Intent.ACTION_TIME_TICK.equals(action)
|| Intent.ACTION_USER_PRESENT.equals(action)
|| Intent.ACTION_SCREEN_ON.equals(action)
|| Intent.ACTION_SCREEN_OFF.equals(action)
|| BOOT_COMPLETED.equals(action)
|| "android.intent.action.BATTERY_LEVEL_CHANGED".equals(action)
) {
// Intent i = new Intent(context, InitJpushServer.class);
// context.startService(i);
context.startService(new Intent(context, MainService.class));
context.startService(new Intent(context, GuardService.class));
context.startService(new Intent(context, StepService.class));
context.startService(new Intent(context, MyDownloadService.class));
context.startService(new Intent(context, DownloadService.class));
context.startService(new Intent(context, ManagerService.class));
}
}

View File

@@ -261,7 +261,12 @@ public class MyJPushReceiver extends BroadcastReceiver {
case JIGUANG_APP_NETWORKSTATE:
ToastUtil.debugShow("收到推送消息: 应用联网管控");
setAppNetworkstate(context, extras);
Handler.getMain().postDelayed(HTTPInterface::getAppInside, 2000);
Handler.getMain().postDelayed(new Runnable() {
@Override
public void run() {
HTTPInterface.getAppInside(context);
}
}, 2000);
break;
case JIGUANG_APP_LOCKEDSTATE:
ToastUtil.debugShow("收到推送消息: 应用锁管控");

View File

@@ -11,7 +11,6 @@ import android.os.Environment;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.provider.Settings;
import android.text.TextUtils;
import android.util.Log;
import android.view.WindowManager;
@@ -27,15 +26,13 @@ import com.arialyy.aria.core.task.DownloadTask;
import com.blankj.utilcode.util.ToastUtils;
import com.info.sn.KeepAliveConnection;
import com.info.sn.R;
import com.info.sn.activity.main.MainActivity;
import com.info.sn.utils.ApkUtils;
import com.info.sn.utils.JGYUtils;
import com.info.sn.utils.ToastUtil;
import java.io.File;
// 下载管理服务
public class MyDownloadService extends Service {
public class DownloadService extends Service {
@Override
@@ -45,9 +42,9 @@ public class MyDownloadService extends Service {
startService(new Intent(this, MainService.class));
startService(new Intent(this, ManagerService.class));
CheckUpdate();
CheckUpdateByPackageName("com.appstore.uiui", handler);
CheckUpdateByPackageName("com.jgyapp.market", handler);
//静默升级应用市场
CheckUpdateByPackageName("com.android.uiuios", handler);
// CheckUpdateByPackageName("com.android.uiuios", handler);
//静默升级桌面
CheckUpdateByPackageName("com.uiuios.updatetools", handler);
//静默升级更新工具
@@ -111,7 +108,7 @@ public class MyDownloadService extends Service {
String apppackage = (String) msg.obj;
Log.e("handler", JGYUtils.getString(getContentResolver(), "qch_app_forbid") + "?");
try {
JGYUtils.putString(getContentResolver(), "qch_app_forbid", apppackage + "com.info.sn,com.android.uiuios,com.appstore.uiui,com.uiuios.updatetools");
JGYUtils.putString(getContentResolver(), "qch_app_forbid", apppackage + "com.info.sn,com.android.uiuios,com.appstore.uiui,com.jgyapp.market,com.uiuios.updatetools");
} catch (Exception e) {
Log.e("fht", e.getMessage());
}
@@ -142,7 +139,7 @@ public class MyDownloadService extends Service {
// .setPositiveButton("确定", new DialogInterface.OnClickListener() {
// @Override
// public void onClick(DialogInterface dialogInterface, int i) {
ApkUtils.installApp(MyDownloadService.this, file.getAbsolutePath());
ApkUtils.installApp(DownloadService.this, file.getAbsolutePath());
// dialogInterface.dismiss();
// }
// });
@@ -171,7 +168,7 @@ public class MyDownloadService extends Service {
.setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
ApkUtils.installApk(MyDownloadService.this, file);
ApkUtils.installApk(DownloadService.this, file);
dialogInterface.dismiss();
}
});
@@ -204,7 +201,7 @@ public class MyDownloadService extends Service {
@Download.onTaskComplete
void taskComplete(DownloadTask task) {
//在这里处理任务完成的状态
ApkUtils.installApp(MyDownloadService.this, task.getFilePath());
ApkUtils.installApp(DownloadService.this, task.getFilePath());
Log.e("taskComplete", task.getExtendField());
Aria.download(this).load(task.getDownloadEntity().getId()).cancel();
}

View File

@@ -35,7 +35,7 @@ public class GuardService extends Service {
Log.e(TAG, "GuardService:建立链接");
boolean isServiceRunning = ServiceAliveUtils.isServiceAlice(GuardService.this, getClass().getName());
if (!isServiceRunning) {
Intent i = new Intent(GuardService.this, MyDownloadService.class);
Intent i = new Intent(GuardService.this, DownloadService.class);
startService(i);
}
}

View File

@@ -33,8 +33,6 @@ import com.trello.rxlifecycle2.android.RxLifecycleAndroid;
import org.jetbrains.annotations.NotNull;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -49,14 +47,13 @@ import io.reactivex.disposables.Disposable;
import io.reactivex.subjects.BehaviorSubject;
import static com.info.sn.jpush.TagAliasOperatorHelper.ACTION_SET;
import static com.info.sn.jpush.TagAliasOperatorHelper.sequence;
/**
* @author jgy02
*/
public class MainService extends Service implements MainContact.MainView, NetworkUtils.OnNetworkStatusChangedListener, LifecycleProvider<ActivityEvent> {
private String TAG = MainService.class.getSimpleName();
private static MainPresenter mPresenter ;
public static MainPresenter mPresenter;
//执行所有请求的时间
long runningTime = 0;
@@ -84,6 +81,23 @@ public class MainService extends Service implements MainContact.MainView, Networ
return RxLifecycleAndroid.bindActivity(lifecycleSubject);
}
@Override
public void onDisconnected() {
Log.e(TAG, "网络未连接");
ToastUtil.show("网络未连接");
}
@Override
public void onConnected(NetworkUtils.NetworkType networkType) {
mPresenter.getUserInfo();
HTTPInterface.checkUpdate(this);
Log.e(TAG, "网络已连接");
ToastUtil.show("网络已连接");
Log.e(TAG, "onConnected: wifi ssid = " + Utils.getWifiSSID(this));
SPUtils.put(this, "wifi_last_connect_time", System.currentTimeMillis());
mPresenter.checkUpdate();
}
private interface Start {
void onstar(long time);
}
@@ -103,7 +117,6 @@ public class MainService extends Service implements MainContact.MainView, Networ
};
private Observer<Long> timeObserver = new Observer<Long>() {
@Override
public void onSubscribe(Disposable d) {
@@ -183,32 +196,16 @@ public class MainService extends Service implements MainContact.MainView, Networ
mPresenter.detachView();
}
@Override
public void onDisconnected() {
Log.e(TAG, "网络未连接");
ToastUtil.show("网络未连接");
}
@Override
public void onConnected(NetworkUtils.NetworkType networkType) {
Log.e(TAG, "网络已连接");
ToastUtil.show("网络已连接");
Log.e(TAG, "onConnected: wifi ssid = " + Utils.getWifiSSID(this));
SPUtils.put(this, "wifi_last_connect_time", System.currentTimeMillis());
mPresenter.checkUpdate();
}
private void startService() {
private void startService() {
startService(new Intent(this, GuardService.class));
startService(new Intent(this, StepService.class));
startService(new Intent(this, MyDownloadService.class));
startService(new Intent(this, DownloadService.class));
}
public static MainPresenter getPresenter(){
public static MainPresenter getPresenter() {
return mPresenter;
}
@Override
public void setPowerUserList(String date) {
@@ -264,7 +261,12 @@ public class MainService extends Service implements MainContact.MainView, Networ
public void setBatch(String batch) {
HashSet hashSet = new HashSet();
hashSet.add(batch);
setTag(hashSet);
hashSet.removeIf(o -> TextUtils.isEmpty(o.toString()));
if (hashSet.size() != 0) {
setTag(hashSet);
} else {
Log.e(TAG, "setBatch: " + "hashSet size is 0");
}
}
@Override

View File

@@ -72,7 +72,8 @@ public class ManagerService extends Service {
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
HTTPInterface.checkUpdate(this);
HTTPInterface.checkUpdate(this, "com.appstore.uiui");
HTTPInterface.checkUpdate(this, "com.jgyapp.market");
HTTPInterface.checkUpdate(this, "com.uiuios.updatetools");
return START_STICKY;
}

View File

@@ -52,10 +52,13 @@ public class RemoteService extends Service {
@Override
public String getUserInfo() throws RemoteException {
if (MainService.mPresenter != null) {
MainService.mPresenter.getUserInfo();
}
String username = Settings.System.getString(getContentResolver(), "UserInfo_username");
String avatar = Settings.System.getString(getContentResolver(), "UserInfo_avatar");
// String gread = Settings.System.getString(getContentResolver(), "UserInfo_grade");
int gread = (int) SPUtils.get(RemoteService.this,"int_grade",0);
int gread = (int) SPUtils.get(RemoteService.this, "int_grade", 0);
String gankaoUID = Settings.System.getString(getContentResolver(), "gankaoUID");
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("username", username);

View File

@@ -126,8 +126,7 @@ public class ApkUtils {
/**
* 根据包名卸载应用
*
* @param packageName
* @param packageName 包名
*/
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public static void uninstall(Context context, String packageName) {
@@ -351,6 +350,11 @@ public class ApkUtils {
}
}
/**
* 通过路径安装APK兼容Android 9以上
* @param context 上下文
* @param filePath apk文件路径
*/
public static void installApp(Context context, String filePath) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
installAppatPie(context, filePath);
@@ -360,7 +364,7 @@ public class ApkUtils {
}
public static boolean installApps(String apkPath) {
ToastUtil.show("正在安装应用...");
ToastUtil.show("正在安装应用");
Process process = null;
BufferedReader successResult = null;
BufferedReader errorResult = null;
@@ -398,7 +402,7 @@ public class ApkUtils {
//如果含有“success”认为安装成功
Log.e("installApp", successMsg.toString());
// if (!successMsg.toString().equalsIgnoreCase("success")) {
// ApkUtils.install(context, new File(apkPath));
// install(context, new File(apkPath));
// }
return successMsg.toString().equalsIgnoreCase("success");
}
@@ -414,40 +418,11 @@ public class ApkUtils {
if (sessionId != -1) {
boolean copySuccess = copyApkFile(packageInstaller, sessionId, apkFilePath);
if (copySuccess) {
ToastUtil.show("正在安装应用");
install(packageInstaller, sessionId, context);
}
}
}
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
private static void install(PackageInstaller packageInstaller, int sessionId, Context context) {
try {
PackageInstaller.Session session = packageInstaller.openSession(sessionId);
Intent intent = new Intent(context, InstallResultReceiver.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(
context,
1, intent,
PendingIntent.FLAG_UPDATE_CURRENT
);
session.commit(pendingIntent.getIntentSender());
} catch (IOException e) {
e.printStackTrace();
}
}
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
private static int createSession(PackageInstaller packageInstaller, PackageInstaller.SessionParams sessionParams) {
int sessionId = -1;
try {
sessionId = packageInstaller.createSession(sessionParams);
} catch (IOException e) {
e.printStackTrace();
}
return sessionId;
}
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
private static boolean copyApkFile(PackageInstaller pi, int sessionId, String apkFilePath) {
boolean success = false;
@@ -481,11 +456,38 @@ public class ApkUtils {
return success;
}
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
private static void install(PackageInstaller packageInstaller, int sessionId, Context context) {
try {
PackageInstaller.Session session = packageInstaller.openSession(sessionId);
Intent intent = new Intent(context, InstallResultReceiver.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(
context,
1, intent,
PendingIntent.FLAG_UPDATE_CURRENT
);
session.commit(pendingIntent.getIntentSender());
} catch (IOException e) {
e.printStackTrace();
}
}
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
private static int createSession(PackageInstaller packageInstaller, PackageInstaller.SessionParams sessionParams) {
int sessionId = -1;
try {
sessionId = packageInstaller.createSession(sessionParams);
} catch (IOException e) {
e.printStackTrace();
}
return sessionId;
}
public static void uninstallApp(Context context, String packageName) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
ApkUtils.uninstall(context, packageName);
uninstall(context, packageName);
} else {
ApkUtils.deleteApkInSilence(packageName);
deleteApkInSilence(packageName);
}
}
@@ -501,7 +503,8 @@ public class ApkUtils {
pmService = PackageManagerService.getClass();
Class<?> paramTypes1[] = getParamTypes(pmService, "deletePackageAsUser");
method = pmService.getMethod("deletePackageAsUser", paramTypes1);
method.invoke(PackageManagerService, packageName, null, getUserId(Binder.getCallingUid()), 0x00000040);//getUserId
//getUserId
method.invoke(PackageManagerService, packageName, null, getUserId(Binder.getCallingUid()), 0x00000040);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
@@ -513,7 +516,6 @@ public class ApkUtils {
}
}
private static Class<?>[] getParamTypes(Class<?> cls, String mName) {
Class<?> cs[] = null;
Method[] mtd = cls.getMethods();
@@ -521,7 +523,6 @@ public class ApkUtils {
if (!mtd[i].getName().equals(mName)) {
continue;
}
cs = mtd[i].getParameterTypes();
}
return cs;
@@ -702,10 +703,10 @@ public class ApkUtils {
continue;
}
}
if (!ApkUtils.isAvailable(context, s)) {
if (!isAvailable(context, s)) {
continue;
}
// ApkUtils.getStartActivityName(context, s);
// getStartActivityName(context, s);
if (installedListBuilder.length() > 0) {
installedListBuilder.append(",");
}
@@ -722,13 +723,14 @@ public class ApkUtils {
@SuppressLint("NewApi")
public static void writeAppPackageList(Context context, String result) {
ApkUtils.addShortcut(context);//开机之后添加图标到桌面
addShortcut(context);//开机之后添加图标到桌面
List<String> factoryAppList = new ArrayList<String>() {{
this.add("com.jiaoguanyi.appstore");
this.add("com.jiaoguanyi.store");
this.add("com.info.sn");
this.add("com.appstore.uiui");
this.add("com.jgyapp.market");
this.add("com.android.uiuios");
this.add("com.uiuios.jgy1");
this.add("com.uiuios.jgy2");

View File

@@ -6,6 +6,7 @@ import android.util.Log;
import com.alibaba.fastjson.JSONObject;
import com.arialyy.aria.core.Aria;
import com.blankj.utilcode.util.PathUtils;
import java.io.File;
import java.io.FileInputStream;
@@ -70,19 +71,19 @@ public class FileUtils {
} else {
Aria.download(context)
.load(url) //读取下载地址
.setFilePath(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS) + "/jgy/" + fileName, true)
.setFilePath(PathUtils.getExternalDownloadsPath() + "/jgy/" + fileName)
.ignoreFilePathOccupy()
.setExtendField(jsonObject.toJSONString())
.create(); //启动下载}
// SaveListUtils.addDownLoadList(app_package);
// }
}
} else {
Aria.download(context)
.load(url) //读取下载地址
.setFilePath(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS) + "/jgy/" + fileName, true)
.setFilePath(PathUtils.getExternalDownloadsPath() + "/jgy/" + fileName)
.ignoreFilePathOccupy()
.setExtendField(jsonObject.toJSONString())
.create(); //启动下载}
}
}
}

View File

@@ -73,6 +73,12 @@ public class JGYUtils {
return sInstance;
}
public static String getAuthorization() {
// TODO: 2021/10/19 ndk代码待实现
return "Basic ZWRmOWNlYzIyNzMxYjhiMmZlZDU2ZWU2OmIzYWRlZDRmODk5N2E0ODM5ZTI5MjRjYg==";
}
public static boolean isOfficialVersion() {
String channelValue = JGYUtils.getInstance().getStringMetaData();
return "official".equals(channelValue);
@@ -88,6 +94,22 @@ public class JGYUtils {
return "beta".equals(channelValue);
}
/**
* 从Manifest中获取meta-data值
* https://blog.csdn.net/yue_233/article/details/91453451
*
* @return
*/
public String getStringMetaData() {
ApplicationInfo appInfo = null;
try {
appInfo = mContext.getPackageManager().getApplicationInfo(mContext.getPackageName(), PackageManager.GET_META_DATA);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
String value = appInfo.metaData.getString("CHANNEL_VALUE");
return value;
}
private int getBatteryLevel() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
@@ -189,24 +211,6 @@ public class JGYUtils {
context.sendBroadcast(intent);
}
/**
* 从Manifest中获取meta-data值
* https://blog.csdn.net/yue_233/article/details/91453451
*
* @return
*/
public String getStringMetaData() {
ApplicationInfo appInfo = null;
try {
appInfo = mContext.getPackageManager().getApplicationInfo(mContext.getPackageName(), PackageManager.GET_META_DATA);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
String value = appInfo.metaData.getString("CHANNEL_VALUE");
return value;
}
/**
* 系统应用hook使用webview
*/
@@ -384,17 +388,38 @@ public class JGYUtils {
public static String getCustomVersion() {
if (JGYUtils.getInstance().checkAppPlatform() == JGYUtils.ZhanruiPlatform) {
return Utils.getProperty("ro.build.display.id", "获取失败");
return getProperty("ro.build.display.id", "获取失败");
} else {
return Utils.getProperty("ro.custom.build.version", "获取失败");
return getProperty("ro.custom.build.version", "获取失败");
}
}
public static String getRomVersion() {
if (JGYUtils.getInstance().checkAppPlatform() == JGYUtils.ZhanruiPlatform) {
return Utils.getProperty("ro.build.id", "获取失败");
return getProperty("ro.build.id", "获取失败");
} else {
return Utils.getProperty("ro.build.display.id", "获取失败");
return getProperty("ro.build.display.id", "获取失败");
}
}
/**
* 获取系统配置信息
*
* @param key
* @param defaultValue
* @return
*/
public static String getProperty(String key, String defaultValue) {
String value = defaultValue;
try {
Class<?> c = Class.forName("android.os.SystemProperties");
Method get = c.getMethod("get", String.class, String.class);
value = (String) (get.invoke(c, key, "unknown"));
} catch (Exception e) {
e.printStackTrace();
} finally {
return value;
}
}
@@ -601,8 +626,9 @@ public class JGYUtils {
Intent intent = new Intent(UPDATE_FORBID_APP);
intent.putStringArrayListExtra("forbid_app_list", getForbidList(context));
Log.e(TAG, "updateForbidList: " + getForbidList(context));
// intent.setComponent(new ComponentName("com.jiaoguanyi.os","com.jiaoguanyi.os.view.MainActivity"));
intent.setPackage("com.jiaoguanyi.os");
intent.setPackage("com.tt.ttutils");
// intent.setPackage("com.tt.ttutils");
context.sendBroadcast(intent);
}
@@ -621,8 +647,9 @@ public class JGYUtils {
public static void updateHideList(Context context) {
Intent intent = new Intent(UPDATE_HIDE_APP);
intent.putStringArrayListExtra("hide_app_list", getHideList(context));
// intent.setComponent(new ComponentName("com.jiaoguanyi.os","com.jiaoguanyi.os.view.MainActivity"));
intent.setPackage("com.jiaoguanyi.os");
intent.setPackage("com.tt.ttutils");
// intent.setPackage("com.tt.ttutils");
context.sendBroadcast(intent);
}

View File

@@ -1155,26 +1155,6 @@ public class Utils {
}
}
/**
* 获取系统配置信息
*
* @param key
* @param defaultValue
* @return
*/
public static String getProperty(String key, String defaultValue) {
String value = defaultValue;
try {
Class<?> c = Class.forName("android.os.SystemProperties");
Method get = c.getMethod("get", String.class, String.class);
value = (String) (get.invoke(c, key, "unknown"));
} catch (Exception e) {
e.printStackTrace();
} finally {
return value;
}
}
public static String getMachine(Context context) {
String device = Build.MODEL;//机型
String imei = getIMEI(context);