diff --git a/app/.gitignore b/app/.gitignore
index 53e730c..52c8f66 100644
--- a/app/.gitignore
+++ b/app/.gitignore
@@ -84,3 +84,5 @@ lint/outputs/
lint/tmp/
# lint/reports/
/.idea/
+/release/
+/proguard-rules.pro
diff --git a/app/build.gradle b/app/build.gradle
index 9268411..2abc722 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -5,7 +5,7 @@ def appName() {
}
def releaseTime() {
- return new Date().format("yyyyMMdd", TimeZone.getDefault())
+ return new Date().format("yyyyMMdd-HHmmss", TimeZone.getDefault())
}
android {
@@ -15,27 +15,25 @@ android {
applicationId "com.info.sn"
minSdkVersion 24
targetSdkVersion 29
- versionCode 74
- versionName "1.7.4"
+
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
+
ndk {
//选择要添加的对应 cpu 类型的 .so 库。
abiFilters 'armeabi', 'armeabi-v7a', 'arm64-v8a', "x86"
// 还可以添加 'x86', 'x86_64', 'mips', 'mips64'
}
- manifestPlaceholders = [
- JPUSH_PKGNAME: applicationId,
- JPUSH_APPKEY : "edf9cec22731b8b2fed56ee6", //JPush 上注册的包名对应的 Appkey.
- JPUSH_CHANNEL: "developer-default", //暂时填写默认值即可.
- ]
+
javaCompileOptions {
annotationProcessorOptions {
includeCompileClasspath true
}
}
- buildConfigField "String", "SCREEN_URL", '"https://homework.uiuios.com:3018/wm/is_online"'
- buildConfigField "String", "WEBSOCKET_URL", '"wss://homework.uiuios.com:3018"'
+ }
+
+ lintOptions {
+ checkReleaseBuilds false
}
compileOptions {
@@ -43,15 +41,33 @@ android {
targetCompatibility JavaVersion.VERSION_1_8
}
- buildTypes {
- release {
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+ //多版本
+ productFlavors {
+ beta {
+ flavorDimensions "default"
+ versionCode 79
+ versionName "1.7.9"
+ manifestPlaceholders = [
+ JPUSH_PKGNAME: "com.info.sn",
+ JPUSH_APPKEY : "edf9cec22731b8b2fed56ee6", //JPush 上注册的包名对应的 Appkey.
+ JPUSH_CHANNEL: "developer-default", //暂时填写默认值即可.
+ ]
+ buildConfigField "String", "SCREEN_URL", '"https://homework.uiuios.com:3018/wm/is_online"'
+ buildConfigField "String", "WEBSOCKET_URL", '"wss://homework.uiuios.com:3018"'
}
- }
- lintOptions {
- checkReleaseBuilds false
+ official {
+ flavorDimensions "default"
+ versionCode 77
+ versionName "1.7.7"
+ manifestPlaceholders = [
+ JPUSH_PKGNAME: "com.info.sn",
+ JPUSH_APPKEY : "4a6d2d53673e958fa8beb69d", //JPush 上注册的包名对应的 Appkey.
+ JPUSH_CHANNEL: "developer-default", //暂时填写默认值即可.
+ ]
+ buildConfigField "String", "SCREEN_URL", '"https://homework.uiuios.com:3018/wm/is_online"'
+ buildConfigField "String", "WEBSOCKET_URL", '"wss://homework.uiuios.com:3018"'
+ }
}
//签名
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 530e828..ab84355 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -4,51 +4,68 @@
package="com.info.sn"
android:sharedUserId="android.uid.system">
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+ android:protectionLevel="signature" />
+
-
-
-
-
-
+ tools:ignore="ProtectedPermissions" />
+
+
+
+
+
+
+
+
+
-
+
+
-
-
+
+
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ android:screenOrientation="sensorLandscape">
@@ -96,7 +113,7 @@
android:enabled="true"
android:exported="true" />
-
+
@@ -293,7 +310,8 @@
android:value="developer-default" />
+ android:value="${JPUSH_APPKEY}" />
+
diff --git a/app/src/main/assets/aria_config.xml b/app/src/main/assets/aria_config.xml
index 3a36cd5..facc04f 100644
--- a/app/src/main/assets/aria_config.xml
+++ b/app/src/main/assets/aria_config.xml
@@ -12,7 +12,7 @@
-
+
diff --git a/app/src/main/java/com/info/sn/activity/main/MainActivity.java b/app/src/main/java/com/info/sn/activity/main/MainActivity.java
index 44f3888..e20120d 100644
--- a/app/src/main/java/com/info/sn/activity/main/MainActivity.java
+++ b/app/src/main/java/com/info/sn/activity/main/MainActivity.java
@@ -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 {
@@ -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));
}
diff --git a/app/src/main/java/com/info/sn/activity/main/MainPresenter.java b/app/src/main/java/com/info/sn/activity/main/MainPresenter.java
index e9842fa..c1e9bca 100644
--- a/app/src/main/java/com/info/sn/activity/main/MainPresenter.java
+++ b/app/src/main/java/com/info/sn/activity/main/MainPresenter.java
@@ -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() {
-// @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", " ");
}
}
diff --git a/app/src/main/java/com/info/sn/base/BaseApplication.java b/app/src/main/java/com/info/sn/base/BaseApplication.java
index a4b1b17..b372151 100644
--- a/app/src/main/java/com/info/sn/base/BaseApplication.java
+++ b/app/src/main/java/com/info/sn/base/BaseApplication.java
@@ -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() {
+ @Override
+ public void subscribe(ObservableEmitter 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() {
+ @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() {
+ @Override
+ public void subscribe(ObservableEmitter 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() {
+ @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成功");
+ }
+ });
+ }
+
}
diff --git a/app/src/main/java/com/info/sn/bean/zuoye/BaseResponse.java b/app/src/main/java/com/info/sn/bean/zuoye/BaseResponse.java
index 8c54587..37e33fe 100644
--- a/app/src/main/java/com/info/sn/bean/zuoye/BaseResponse.java
+++ b/app/src/main/java/com/info/sn/bean/zuoye/BaseResponse.java
@@ -20,8 +20,6 @@ public class BaseResponse 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();
}
}
\ No newline at end of file
diff --git a/app/src/main/java/com/info/sn/jpush/MyJPushMessageReceiver.java b/app/src/main/java/com/info/sn/jpush/MyJPushMessageReceiver.java
index ec6b01f..a842d23 100644
--- a/app/src/main/java/com/info/sn/jpush/MyJPushMessageReceiver.java
+++ b/app/src/main/java/com/info/sn/jpush/MyJPushMessageReceiver.java
@@ -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);
}
diff --git a/app/src/main/java/com/info/sn/network/HTTPInterface.java b/app/src/main/java/com/info/sn/network/HTTPInterface.java
index 7c96fa8..11f7e66 100644
--- a/app/src/main/java/com/info/sn/network/HTTPInterface.java
+++ b/app/src/main/java/com/info/sn/network/HTTPInterface.java
@@ -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() {
@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() {
+ @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);
+ }
}
diff --git a/app/src/main/java/com/info/sn/network/UrlAddress.java b/app/src/main/java/com/info/sn/network/UrlAddress.java
index a681c1a..539cdd5 100644
--- a/app/src/main/java/com/info/sn/network/UrlAddress.java
+++ b/app/src/main/java/com/info/sn/network/UrlAddress.java
@@ -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/";
}
diff --git a/app/src/main/java/com/info/sn/receiver/APKinstallReceiver.java b/app/src/main/java/com/info/sn/receiver/APKinstallReceiver.java
index b63fdcf..00b475e 100644
--- a/app/src/main/java/com/info/sn/receiver/APKinstallReceiver.java
+++ b/app/src/main/java/com/info/sn/receiver/APKinstallReceiver.java
@@ -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
diff --git a/app/src/main/java/com/info/sn/receiver/BootReceiver.java b/app/src/main/java/com/info/sn/receiver/BootReceiver.java
index b1d2a01..b210785 100644
--- a/app/src/main/java/com/info/sn/receiver/BootReceiver.java
+++ b/app/src/main/java/com/info/sn/receiver/BootReceiver.java
@@ -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));
}
}
diff --git a/app/src/main/java/com/info/sn/receiver/MyJPushReceiver.java b/app/src/main/java/com/info/sn/receiver/MyJPushReceiver.java
index feee043..4ddb8e6 100644
--- a/app/src/main/java/com/info/sn/receiver/MyJPushReceiver.java
+++ b/app/src/main/java/com/info/sn/receiver/MyJPushReceiver.java
@@ -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("收到推送消息: 应用锁管控");
diff --git a/app/src/main/java/com/info/sn/service/MyDownloadService.java b/app/src/main/java/com/info/sn/service/DownloadService.java
similarity index 93%
rename from app/src/main/java/com/info/sn/service/MyDownloadService.java
rename to app/src/main/java/com/info/sn/service/DownloadService.java
index c83eb34..187b6ef 100644
--- a/app/src/main/java/com/info/sn/service/MyDownloadService.java
+++ b/app/src/main/java/com/info/sn/service/DownloadService.java
@@ -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();
}
diff --git a/app/src/main/java/com/info/sn/service/GuardService.java b/app/src/main/java/com/info/sn/service/GuardService.java
index 4a4bf49..eadf502 100644
--- a/app/src/main/java/com/info/sn/service/GuardService.java
+++ b/app/src/main/java/com/info/sn/service/GuardService.java
@@ -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);
}
}
diff --git a/app/src/main/java/com/info/sn/service/MainService.java b/app/src/main/java/com/info/sn/service/MainService.java
index 31b14e3..0dcea8d 100644
--- a/app/src/main/java/com/info/sn/service/MainService.java
+++ b/app/src/main/java/com/info/sn/service/MainService.java
@@ -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 {
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 timeObserver = new Observer() {
-
@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
diff --git a/app/src/main/java/com/info/sn/service/ManagerService.java b/app/src/main/java/com/info/sn/service/ManagerService.java
index 1ea4206..77c8f81 100644
--- a/app/src/main/java/com/info/sn/service/ManagerService.java
+++ b/app/src/main/java/com/info/sn/service/ManagerService.java
@@ -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;
}
diff --git a/app/src/main/java/com/info/sn/service/RemoteService.java b/app/src/main/java/com/info/sn/service/RemoteService.java
index 7c7e597..35fe741 100644
--- a/app/src/main/java/com/info/sn/service/RemoteService.java
+++ b/app/src/main/java/com/info/sn/service/RemoteService.java
@@ -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);
diff --git a/app/src/main/java/com/info/sn/utils/ApkUtils.java b/app/src/main/java/com/info/sn/utils/ApkUtils.java
index 4ef4ee3..f5e7c1a 100644
--- a/app/src/main/java/com/info/sn/utils/ApkUtils.java
+++ b/app/src/main/java/com/info/sn/utils/ApkUtils.java
@@ -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 factoryAppList = new ArrayList() {{
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");
diff --git a/app/src/main/java/com/info/sn/utils/FileUtils.java b/app/src/main/java/com/info/sn/utils/FileUtils.java
index 3c9232d..a75be7c 100644
--- a/app/src/main/java/com/info/sn/utils/FileUtils.java
+++ b/app/src/main/java/com/info/sn/utils/FileUtils.java
@@ -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(); //启动下载}
}
-
}
}
diff --git a/app/src/main/java/com/info/sn/utils/JGYUtils.java b/app/src/main/java/com/info/sn/utils/JGYUtils.java
index cb873c6..0662249 100644
--- a/app/src/main/java/com/info/sn/utils/JGYUtils.java
+++ b/app/src/main/java/com/info/sn/utils/JGYUtils.java
@@ -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);
}
diff --git a/app/src/main/java/com/info/sn/utils/Utils.java b/app/src/main/java/com/info/sn/utils/Utils.java
index 487e63f..24eb8b3 100644
--- a/app/src/main/java/com/info/sn/utils/Utils.java
+++ b/app/src/main/java/com/info/sn/utils/Utils.java
@@ -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);
diff --git a/settings.gradle b/settings.gradle
index 7777f09..5162353 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1,2 +1,2 @@
include ':app'
-rootProject.name='设备信息'
+rootProject.name='作业平板设备信息'