version:1.3.4

update:
fix:
add:开发人员选项管控推送
This commit is contained in:
2021-05-07 17:32:15 +08:00
parent c0dc7acca8
commit e780b3ff44
9 changed files with 145 additions and 123 deletions

View File

@@ -15,10 +15,10 @@ android {
minSdkVersion 24
targetSdkVersion 29
// versionCode 105
// versionName "3.1.0"//测试jiaoguanyi.cn
// versionCode 1008
// versionName "2.0.1.8"// 正式jiaoguanyi.com 双数正式 单数测试
//versionCode 105
//versionName "3.1.0"//测试jiaoguanyi.cn
//versionCode 1008
//versionName "2.0.1.8"// 正式jiaoguanyi.com 双数正式 单数测试
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
@@ -37,9 +37,9 @@ android {
jumboMode true
}
// dataBinding {
// enabled = true
// }
//dataBinding {
//enabled = true
//}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
@@ -50,8 +50,8 @@ android {
productFlavors {
official {
flavorDimensions "default"
versionCode 1037
versionName "2.0.3.7"
versionCode 1038
versionName "2.0.3.8"
/*********************************极光推送************************************/
manifestPlaceholders = [
JPUSH_PKGNAME: "com.jiaoguanyi.appstore",
@@ -69,7 +69,7 @@ android {
beta {
flavorDimensions "default"
versionCode 109
// versionCode 160//出厂版本太高
//versionCode 160//出厂版本太高
versionName "3.1.4"//测试jiaoguanyi.cn
/*********************************极光推送************************************/
manifestPlaceholders = [
@@ -106,7 +106,7 @@ android {
newly {
flavorDimensions "default"
versionCode 174
// versionCode 1037
//versionCode 1037
versionName "1.3.4"
/*********************************极光推送************************************/
manifestPlaceholders = [
@@ -136,7 +136,7 @@ android {
v2SigningEnabled false
}
release {// 签名文件
release {
storeFile file("src/main/doc/xueshibaoos.jks")
storePassword "123456"
keyAlias "xueshibaoos"
@@ -147,10 +147,12 @@ android {
buildTypes {
debug {
// 显示Log
buildConfigField "boolean", "LOG_DEBUG", "true"
versionNameSuffix "-debug"
// 显示Log
//buildConfigField "boolean", "LOG_DEBUG", "false"
//
//versionNameSuffix "-debug"
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
//Zipalign优化
zipAlignEnabled true
signingConfig signingConfigs.debug
@@ -165,17 +167,15 @@ android {
}
}
release {
// 不显示Log
buildConfigField "boolean", "LOG_DEBUG", "false"
//混淆
minifyEnabled false
//Zipalign优化
zipAlignEnabled true
//前一部分代表系统默认的android程序的混淆文件该文件已经包含了基本的混淆声明后一个文件是自己的定义混淆文件
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
//Zipalign优化
zipAlignEnabled true
//签名
signingConfig signingConfigs.release
// 将release版本的包名重命名加上版本及日期
//将release版本的包名重命名加上版本及日期
applicationVariants.all { variant ->
variant.outputs.each { output ->
def outputFile = ""
@@ -190,7 +190,7 @@ android {
}
dependencies {
// implementation fileTree(include: ['*.jar'], dir: 'libs')
//implementation fileTree(include: ['*.jar'], dir: 'libs')
compileOnly files('src/main/libs/classes.jar')
implementation 'androidx.appcompat:appcompat:1.2.0'
@@ -212,8 +212,8 @@ dependencies {
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.4.0'
implementation 'io.reactivex.rxjava2:rxjava:2.2.5'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
// implementation "com.uber.autodispose:autodispose:1.3.0"
// implementation "com.uber.autodispose:autodispose-android-archcomponents:1.3.0"
//implementation "com.uber.autodispose:autodispose:1.3.0"
//implementation "com.uber.autodispose:autodispose-android-archcomponents:1.3.0"
implementation 'com.google.code.gson:gson:2.8.6'
implementation 'com.google.zxing:core:3.3.0'
implementation 'cn.jiguang.sdk:jpush:3.8.6' // 此处以JPush 3.5.6 版本为例。
@@ -221,14 +221,14 @@ dependencies {
implementation 'com.alibaba:fastjson:1.2.70'
implementation 'com.lzy.net:okgo:2.1.4'
implementation 'com.lzy.net:okrx:0.1.2'
// implementation 'com.lzy.net:okserver:1.1.3'
//implementation 'com.lzy.net:okserver:1.1.3'
implementation 'com.blankj:utilcode:1.23.7'
implementation 'com.arialyy.aria:core:3.8.15'
annotationProcessor 'com.arialyy.aria:compiler:3.8.15'
implementation 'com.amap.api:location:5.1.0'
//高德地图定位
implementation 'org.zeroturnaround:zt-zip:1.13'
implementation 'com.amap.api:location:5.1.0'
//压缩文件解压
implementation 'org.zeroturnaround:zt-zip:1.13'
}
preBuild {

View File

@@ -1283,6 +1283,10 @@ public class MainPresenter implements MainContact.Presenter {
@Override
public void setTopApp() {
if (JGYUtils.isOfficialVersion()) {
mView.setTopAppFinished();
return;
}
NetInterfaceManager.getInstance().getTopAppControl()
.subscribe(new Observer<BaseResponse>() {
@Override
@@ -1333,9 +1337,9 @@ public class MainPresenter implements MainContact.Presenter {
JSONObject jsonObject = (JSONObject) JSON.toJSON(baseResponse.data);
int is_developer = jsonObject.getInteger("is_developer");
//后台1是0否 底层0是1否
setDeveloper(is_developer == 0 ? 1 : 0);
JGYUtils.getInstance().setDeveloper(is_developer == 0 ? 1 : 0);
} else {
setDeveloper(1);
JGYUtils.getInstance().setDeveloper(1);
}
}
@@ -1354,16 +1358,6 @@ public class MainPresenter implements MainContact.Presenter {
}
private void setDeveloper(int state) {
Settings.System.putInt(mContext.getContentResolver(), "qch_Developeroptions", state);
if (state == 1) {
Intent intent = new Intent();
intent.setAction("qch_developeroptions_close");
intent.setPackage("com.android.settings");
mContext.sendBroadcast(intent);
}
}
@Override
public void getScreenLockState() {
int locked = Settings.System.getInt(mContext.getContentResolver(), "qch_unlock_ipad", 1);

View File

@@ -115,7 +115,7 @@ public class BaseApplication extends MultiDexApplication {
JGYUtils.init(this);
XAPKUtils.init(this);
FileManager.init(this);
hookWebView();
JGYUtils.getInstance().hookWebView();
Configuration config = getResources().getConfiguration();
int smallestScreenWidthDp = config.smallestScreenWidthDp;
Log.e("mjsheng", "smallestScreenWidthDp=" + smallestScreenWidthDp);
@@ -162,63 +162,6 @@ public class BaseApplication extends MultiDexApplication {
AmapManager.init(this);
}
public void hookWebView() {
int sdkInt = Build.VERSION.SDK_INT;
try {
Class<?> factoryClass = Class.forName("android.webkit.WebViewFactory");
Field field = factoryClass.getDeclaredField("sProviderInstance");
field.setAccessible(true);
Object sProviderInstance = field.get(null);
if (sProviderInstance != null) {
Log.i(TAG, "sProviderInstance isn't null");
return;
}
Method getProviderClassMethod;
if (sdkInt > 22) {
getProviderClassMethod = factoryClass.getDeclaredMethod("getProviderClass");
} else if (sdkInt == 22) {
getProviderClassMethod = factoryClass.getDeclaredMethod("getFactoryClass");
} else {
Log.i(TAG, "Don't need to Hook WebView");
return;
}
getProviderClassMethod.setAccessible(true);
Class<?> factoryProviderClass = (Class<?>) getProviderClassMethod.invoke(factoryClass);
Class<?> delegateClass = Class.forName("android.webkit.WebViewDelegate");
Constructor<?> delegateConstructor = delegateClass.getDeclaredConstructor();
delegateConstructor.setAccessible(true);
if (sdkInt < 26) {//低于Android O版本
Constructor<?> providerConstructor = factoryProviderClass.getConstructor(delegateClass);
if (providerConstructor != null) {
providerConstructor.setAccessible(true);
sProviderInstance = providerConstructor.newInstance(delegateConstructor.newInstance());
}
} else {
Field chromiumMethodName = factoryClass.getDeclaredField("CHROMIUM_WEBVIEW_FACTORY_METHOD");
chromiumMethodName.setAccessible(true);
String chromiumMethodNameStr = (String) chromiumMethodName.get(null);
if (chromiumMethodNameStr == null) {
chromiumMethodNameStr = "create";
}
Method staticFactory = factoryProviderClass.getMethod(chromiumMethodNameStr, delegateClass);
if (staticFactory != null) {
sProviderInstance = staticFactory.invoke(null, delegateConstructor.newInstance());
}
}
if (sProviderInstance != null) {
field.set("sProviderInstance", sProviderInstance);
Log.i(TAG, "Hook success!");
} else {
Log.i(TAG, "Hook failed!");
}
} catch (Throwable e) {
Log.w(TAG, e);
}
}
/**
* 忽略电池优化

View File

@@ -6,54 +6,57 @@ import com.mjsheng.myappstore.manager.NetInterfaceManager;
* @author Administrator
*/
public class URLAddress {
//根网址
private static final String HTTP_TAG_HEAD_NEW = NetInterfaceManager.ROOT_URL;
public static final String HTTP_TAG_DOWNLOAD_URL = HTTP_TAG_HEAD_NEW + "count/index";
// 下载接口 根据包名匹配 请求后更新下载次数
public static final String HTTP_TAG_DOWNLOAD_URL = HTTP_TAG_HEAD_NEW + "count/index";
//app下载完成发送下载次数
public static final String SEND_DOWNLOAD_FILE_INFO = HTTP_TAG_HEAD_NEW + "app/downloadApp";
//获取设备锁定状态
public static final String GET_DEVICES_LOCKED = HTTP_TAG_HEAD_NEW + "lock/index";
//发送设备信息
public static final String SEND_DEVICES = HTTP_TAG_HEAD_NEW + "Mac/getMac";
//发送app使用情况
public static final String SEND_USEDTIME = HTTP_TAG_HEAD_NEW + "Applog/getAppLog";
public static final String CHECK_UPDATE = HTTP_TAG_HEAD_NEW + "Silent/silent";
//更新接口
public static final String GET_DEVICES_TAGS = HTTP_TAG_HEAD_NEW + "Sn/getSnTag";
public static final String CHECK_UPDATE = HTTP_TAG_HEAD_NEW + "Silent/silent";
//获取设备标签
public static final String DELETE_GEDEVICE_ALIAS = HTTP_TAG_HEAD_NEW + "Sn/deleteAliases";
public static final String GET_DEVICES_TAGS = HTTP_TAG_HEAD_NEW + "Sn/getSnTag";
//删除Aliases
public static final String SET_HOMEPAG_TAG = HTTP_TAG_HEAD_NEW + "Label";
public static final String DELETE_GEDEVICE_ALIAS = HTTP_TAG_HEAD_NEW + "Sn/deleteAliases";
//浏览器书签主页设置
public static final String SET_APPINSIDEWEB = HTTP_TAG_HEAD_NEW + "Appground";
public static final String SET_HOMEPAG_TAG = HTTP_TAG_HEAD_NEW + "Label";
//app内部网页管控
public static final String SET_BROWSER_LIST = HTTP_TAG_HEAD_NEW + "browser";
public static final String SET_APPINSIDEWEB = HTTP_TAG_HEAD_NEW + "Appground";
//浏览器黑白名单地址
public static final String SET_WHITE_PACKAGE_LIST = HTTP_TAG_HEAD_NEW + "firmware/index";
public static final String SET_BROWSER_LIST = HTTP_TAG_HEAD_NEW + "browser";
//应用白名单
public static final String GET_HIDE_DESKTOPICON = HTTP_TAG_HEAD_NEW + "Icon";
public static final String SET_WHITE_PACKAGE_LIST = HTTP_TAG_HEAD_NEW + "firmware/index";
//获取隐藏桌面图标
public final static String NET_AND_LAUNCH_API = HTTP_TAG_HEAD_NEW + "automatic/get";
public static final String GET_HIDE_DESKTOPICON = HTTP_TAG_HEAD_NEW + "Icon";
//获取应用升级自启
public static final String GET_STUDENTS_INFO = HTTP_TAG_HEAD_NEW + "Sn/getStudent";
public final static String NET_AND_LAUNCH_API = HTTP_TAG_HEAD_NEW + "automatic/get";
//通过sn获取信息
public static final String SEND_SCREENSHOT = HTTP_TAG_HEAD_NEW + "Screenshot/addImg";
public static final String GET_STUDENTS_INFO = HTTP_TAG_HEAD_NEW + "Sn/getStudent";
//上传截图
//public static final String UPDATE_DEVICEINFO = HTTP_TAG_HEAD_NEW + "Mac/getInfo";
public static final String SEND_SCREENSHOT = HTTP_TAG_HEAD_NEW + "Screenshot/addImg";
//上传我的设备
public final static String GET_LOCK_SCREEN_STATE = HTTP_TAG_HEAD_NEW + "Sn/getSnScreen";
//public static final String UPDATE_DEVICEINFO = HTTP_TAG_HEAD_NEW + "Mac/getInfo";
//获取霸屏状态
public final static String GET_DESKTOP = HTTP_TAG_HEAD_NEW + "Sn/getSnDesktop";
public final static String GET_LOCK_SCREEN_STATE = HTTP_TAG_HEAD_NEW + "Sn/getSnScreen";
//获取默认桌面升级
public final static String GET_SN_TIME_CONTROL = HTTP_TAG_HEAD_NEW + "Sn/getSnTimeControl";
public final static String GET_DESKTOP = HTTP_TAG_HEAD_NEW + "Sn/getSnDesktop";
//获取时间管控
public final static String GET_TOP_APP_CONTROL = HTTP_TAG_HEAD_NEW + "Sn/getSnAppControl";
public final static String GET_SN_TIME_CONTROL = HTTP_TAG_HEAD_NEW + "Sn/getSnTimeControl";
//获取顶部app管控
public final static String GET_SN_APP_TEST = HTTP_TAG_HEAD_NEW + "Sn/getSnAppTest";
public final static String GET_TOP_APP_CONTROL = HTTP_TAG_HEAD_NEW + "Sn/getSnAppControl";
//获取测试app
public final static String GET_LOGO_IMG = HTTP_TAG_HEAD_NEW + "Sn/getLogoImg";
public final static String GET_SN_APP_TEST = HTTP_TAG_HEAD_NEW + "Sn/getSnAppTest";
//开机动画
public final static String GET_DEVELOPER = HTTP_TAG_HEAD_NEW + "Sn/getDeveloper";
public final static String GET_LOGO_IMG = HTTP_TAG_HEAD_NEW + "Sn/getLogoImg";
//开发人员选项开关
public final static String GET_DEVELOPER = HTTP_TAG_HEAD_NEW + "Sn/getDeveloper";
}

View File

@@ -131,6 +131,8 @@ public class MyJPushReceiver extends BroadcastReceiver {
private final String CLEAN_APP_CACHE = "32";//清除app数据
private final String DEVELOPER_OPTIONS = "33";//开发人员选项
private Context mContext;
@@ -365,6 +367,9 @@ public class MyJPushReceiver extends BroadcastReceiver {
case CLEAN_APP_CACHE:
cleanCache(context, extras);
break;
case DEVELOPER_OPTIONS:
setDeveloperoptions(extras);
break;
}
}
@@ -1432,4 +1437,11 @@ public class MyJPushReceiver extends BroadcastReceiver {
}
}
}
private void setDeveloperoptions(String extras) {
com.alibaba.fastjson.JSONObject jsonObject = com.alibaba.fastjson.JSONObject.parseObject(extras);
int is_developer = jsonObject.getInteger("is_developer");
Log.e(TAG, "setDeveloperoptions: " + is_developer);
JGYUtils.getInstance().setDeveloper(is_developer == 0 ? 1 : 0);
}
}

View File

@@ -1140,7 +1140,7 @@ public class ApkUtils {
@Override
public void onError(Throwable e) {
Log.e("RemoveTask", "onError: ");
Log.e("RemoveTask", "onError: " + e.getMessage());
}
@Override

View File

@@ -32,6 +32,9 @@ import com.mjsheng.myappstore.comm.CommonDatas;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
@@ -764,4 +767,71 @@ public class JGYUtils {
}
}
}
public void setDeveloper(int state) {
Settings.System.putInt(mContext.getContentResolver(), "qch_Developeroptions", state);
if (state == 1) {
Intent intent = new Intent();
intent.setAction("qch_developeroptions_close");
intent.setPackage("com.android.settings");
mContext.sendBroadcast(intent);
}
}
public void hookWebView() {
int sdkInt = Build.VERSION.SDK_INT;
try {
Class<?> factoryClass = Class.forName("android.webkit.WebViewFactory");
Field field = factoryClass.getDeclaredField("sProviderInstance");
field.setAccessible(true);
Object sProviderInstance = field.get(null);
if (sProviderInstance != null) {
Log.i(TAG, "sProviderInstance isn't null");
return;
}
Method getProviderClassMethod;
if (sdkInt > 22) {
getProviderClassMethod = factoryClass.getDeclaredMethod("getProviderClass");
} else if (sdkInt == 22) {
getProviderClassMethod = factoryClass.getDeclaredMethod("getFactoryClass");
} else {
Log.i(TAG, "Don't need to Hook WebView");
return;
}
getProviderClassMethod.setAccessible(true);
Class<?> factoryProviderClass = (Class<?>) getProviderClassMethod.invoke(factoryClass);
Class<?> delegateClass = Class.forName("android.webkit.WebViewDelegate");
Constructor<?> delegateConstructor = delegateClass.getDeclaredConstructor();
delegateConstructor.setAccessible(true);
if (sdkInt < 26) {//低于Android O版本
Constructor<?> providerConstructor = factoryProviderClass.getConstructor(delegateClass);
if (providerConstructor != null) {
providerConstructor.setAccessible(true);
sProviderInstance = providerConstructor.newInstance(delegateConstructor.newInstance());
}
} else {
Field chromiumMethodName = factoryClass.getDeclaredField("CHROMIUM_WEBVIEW_FACTORY_METHOD");
chromiumMethodName.setAccessible(true);
String chromiumMethodNameStr = (String) chromiumMethodName.get(null);
if (chromiumMethodNameStr == null) {
chromiumMethodNameStr = "create";
}
Method staticFactory = factoryProviderClass.getMethod(chromiumMethodNameStr, delegateClass);
if (staticFactory != null) {
sProviderInstance = staticFactory.invoke(null, delegateConstructor.newInstance());
}
}
if (sProviderInstance != null) {
field.set("sProviderInstance", sProviderInstance);
Log.i(TAG, "Hook success!");
} else {
Log.i(TAG, "Hook failed!");
}
} catch (Throwable e) {
Log.w(TAG, e);
}
}
}

View File

@@ -11,7 +11,7 @@ import com.mjsheng.myappstore.BuildConfig;
public class Logger {
//设为false关闭日志
private static final boolean LOG_ENABLE = BuildConfig.LOG_DEBUG;
private static final boolean LOG_ENABLE = BuildConfig.DEBUG;
public static void i(String tag, String msg){
if (LOG_ENABLE){

View File

@@ -88,7 +88,7 @@ public class ToastUtil {
mainHandler.post(new Runnable() {
@Override
public void run() {
if (BuildConfig.LOG_DEBUG) {
if (BuildConfig.DEBUG) {
if (toast != null) {
toast.setText(msg);
toast.show();