version:2.0.1.9

update:2020.08.1
fix:修复强制安装应用重复下载,禁止升级应用卸载后无法安装
add:增加测试图标,多版本打包
This commit is contained in:
2020-08-01 17:16:29 +08:00
parent f4cb8b96a4
commit c5478df95c
15 changed files with 136 additions and 38 deletions

View File

@@ -15,10 +15,10 @@ android {
minSdkVersion 20
targetSdkVersion 29
// versionCode 104
// versionName "3.0.9"//测试jiaoguanyi.cn
versionCode 1006
versionName "2.0.1.6"// 正式jiaoguanyi.com 双数正式 单数测试
// versionCode 105
// versionName "3.1.0"//测试jiaoguanyi.cn
// versionCode 1008
// versionName "2.0.1.8"// 正式jiaoguanyi.com 双数正式 单数测试
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
@@ -26,14 +26,7 @@ android {
exclude 'META-INF/rxjava.properties'
}
/*********************************极光推送************************************/
manifestPlaceholders = [
JPUSH_PKGNAME: "com.jiaoguanyi.appstore",
JPUSH_APPKEY : "20f70bbeb78bad23eddd08d0", //JPush上注册的包名对应的appkey.
JPUSH_CHANNEL: "developer-default", //暂时填写默认值即可.
]
/*********************************极光推送end************************************/
}
lintOptions {
checkReleaseBuilds false
@@ -41,6 +34,46 @@ android {
dexOptions {
jumboMode true
}
//多版本
productFlavors {
official {
flavorDimensions "default"
versionCode 1009
versionName "2.0.1.9"// 正式jiaoguanyi.com 双数正式 单数测试
/*********************************极光推送************************************/
manifestPlaceholders = [
JPUSH_PKGNAME: "com.jiaoguanyi.appstore",
JPUSH_APPKEY : "20f70bbeb78bad23eddd08d0", //JPush上注册的包名对应的appkey.
JPUSH_CHANNEL: "developer-default", //暂时填写默认值即可.
]
signingConfig signingConfigs.debug
/*********************************极光推送end************************************/
buildConfigField "String", "ROOT_URL", '"https://partner.jiaoguanyi.com/api/"'
buildConfigField "String", "WebsocketURL", '"ws://47.107.133.19:1234"'
}
beta {
flavorDimensions "default"
versionCode 105
versionName "3.1.0"//测试jiaoguanyi.cn
/*********************************极光推送************************************/
manifestPlaceholders = [
JPUSH_PKGNAME: "com.jiaoguanyi.appstore",
JPUSH_APPKEY : "52d81643665bb2cadacf0e9e", //JPush上注册的包名对应的appkey.
JPUSH_CHANNEL: "developer-default", //暂时填写默认值即可.
]
signingConfig signingConfigs.debug
/*********************************极光推送end************************************/
buildConfigField "String", "ROOT_URL", '"http://www.jiaoguanyi.cn/api/"'
buildConfigField "String", "WebsocketURL", '"ws://47.107.133.19:2345"'
}
}
sourceSets {
beta.res.srcDirs = ['src/beta/res']
}
//签名
signingConfigs {
debug {
@@ -72,7 +105,7 @@ android {
variant.outputs.each { output ->
def outputFile = output.outputFile
if (outputFile != null) {
def fileName = "${appName()}-V${defaultConfig.versionName}-${releaseTime()}.apk"
def fileName = "${appName()}-${variant.versionCode}-V${variant.versionName}-${releaseTime()}-${buildType.name}.apk"
output.outputFileName = new File(outputFile.parent, fileName)
}
}
@@ -94,7 +127,7 @@ android {
variant.outputs.each { output ->
def outputFile = ""
if (outputFile != null) {
def fileName = "${appName()}-${defaultConfig.versionCode}-V${defaultConfig.versionName}-${releaseTime()}.apk"
def fileName = "${appName()}-${variant.versionCode}-V${variant.versionName}-${releaseTime()}-${buildType.name}.apk"
output.outputFileName = new File(outputFile, fileName)
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools" xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_name">设备信息测试</string>
</resources>

View File

@@ -28,7 +28,8 @@
<!-- Required -->
<permission
android:name="${JPUSH_PKGNAME}.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.INTERNET" />
@@ -109,7 +110,7 @@
<action android:name="android.intent.action.BATTERY_OKAY" />
<action android:name="android.intent.action.ACTION_POWER_CONNECTED" />
<action android:name="android.intent.action.DATE_CHANGED" />
<action android:name="android.intent.action.TIME_TICK" />
<action android:name="android.intent.action.ACTION_TIMEZONE_CHANGED" />
<action android:name="android.intent.action.USER_PRESENT" />
<action android:name="android.intent.action.SCREEN_ON" />
<action android:name="android.intent.action.SCREEN_OFF" />
@@ -291,7 +292,7 @@
android:value="developer-default" /> <!-- Required. AppKey copied from Portal -->
<meta-data
android:name="JPUSH_APPKEY"
android:value="20f70bbeb78bad23eddd08d0" />
android:value="${JPUSH_APPKEY}" />
</application>
</manifest>

View File

@@ -171,7 +171,7 @@ public class MyApplication extends MultiDexApplication {
startService(new Intent(this, MyDownloadService.class));
}
registerTimeReceiver();
ignoreBatteryOptimization(this);
// ignoreBatteryOptimization(this);
}

View File

@@ -206,7 +206,7 @@ public class MainActivity extends AppCompatActivity {
// setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
// }
requestPermission();
acquireWakeLock();
// acquireWakeLock();//加入后锁屏解锁有延迟
registerMessageReceiver(); // used for receive msg
// HTTPInterface.checkDevicesInfo(handler);
startService(new Intent(MainActivity.this, MyDownloadService.class));
@@ -508,7 +508,7 @@ public class MainActivity extends AppCompatActivity {
lazyLoading();
}
} else if (code == -300) {
ApkUtils.uninstallAllApp(MainActivity.this);
// ApkUtils.uninstallAllApp(MainActivity.this);
}
}
@@ -1049,6 +1049,7 @@ public class MainActivity extends AppCompatActivity {
private void writeAppPackageList(String result) {
String appstore = "com.jiaoguanyi.appstore";
String store = "com.jiaoguanyi.store";
String iflytek = "iflytek.eface2sdk";
if (!TextUtils.isEmpty(result)) {
LogUtils.e(result);
if (!result.contains(appstore)) {
@@ -1057,6 +1058,10 @@ public class MainActivity extends AppCompatActivity {
if (!result.contains(store)) {
result = result + "," + store;
}
if (!result.contains(iflytek)) {
result = result + "," + iflytek;
}
//人脸识别
boolean b = Settings.System.putString(getContentResolver(), "qch_app_forbid", result);
Log.e("mjsheng", "qch_app_forbid is :" + b + Settings.System.getString(getContentResolver(), "qch_app_forbid"));

View File

@@ -1,9 +1,11 @@
package com.mjsheng.myappstore.network;
import android.os.Build;
import android.os.Environment;
import android.util.Log;
import com.mjsheng.myappstore.BuildConfig;
import com.mjsheng.myappstore.network.api.AppLimitApi;
import com.mjsheng.myappstore.network.api.BrankPicApi;
import com.mjsheng.myappstore.network.api.CategoryPicApi;
@@ -41,10 +43,12 @@ public class Network {
// public static final String ROOT_URL = "http://www.as.xueshibao.com.cn/api/"; 弃用
// public static final String ROOT_URL = "https://www.jiaoguanyi.com/api/";//正式 弃用
public static final String ROOT_URL = "https://partner.jiaoguanyi.com/api/";//正式
public static final String WebsocketURL = "ws://47.107.133.19:1234";
// public static final String ROOT_URL = "https://partner.jiaoguanyi.com/api/";//正式
// public static final String WebsocketURL = "ws://47.107.133.19:1234";
// public static final String ROOT_URL = "http://www.jiaoguanyi.cn/api/";//测试
// public static final String WebsocketURL = "ws://47.107.133.19:2345";
public static final String ROOT_URL = BuildConfig.ROOT_URL;
public static final String WebsocketURL = BuildConfig.WebsocketURL;
private static UploadAppInfoApi uploadAppInfoApi;
private static DeselectIDApi deselectIDApi;
@@ -250,6 +254,7 @@ public class Network {
Log.e("mjsheng", "forceDownloadApi");
return forceDownloadApi;
}
public static GetLockState getLockState() {
if (getLockState == null) {
Retrofit retrofit = new Retrofit.Builder()

View File

@@ -2,9 +2,12 @@ package com.mjsheng.myappstore.server;
import android.app.Service;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.BatteryManager;
import android.os.Build;
import android.os.Handler;
import android.os.IBinder;
@@ -23,6 +26,7 @@ import com.lzy.okgo.OkGo;
import com.lzy.okgo.callback.StringCallback;
import com.mjsheng.myappstore.BuildConfig;
import com.mjsheng.myappstore.MyApplication;
import com.mjsheng.myappstore.activity.MainActivity;
import com.mjsheng.myappstore.bean.ForceDownloadBean;
import com.mjsheng.myappstore.bean.ForceDownloadData;
import com.mjsheng.myappstore.bean.NetAndLaunchBean;
@@ -299,7 +303,7 @@ public class InitJpushServer extends Service {
}
private void writeAppPackageList(String result) {
ApkUtils. addShortcut(this, result);//开机之后添加图标到桌面
ApkUtils.addShortcut(this, result);//开机之后添加图标到桌面
String appstore = "com.jiaoguanyi.appstore";
String store = "com.jiaoguanyi.store";
if (!TextUtils.isEmpty(result)) {
@@ -315,12 +319,13 @@ public class InitJpushServer extends Service {
} else {
Log.e("mjsheng", "writeAppPackageList is null:");
}
deleteOtherApp(result);
int locked = Settings.System.getInt(InitJpushServer.this.getContentResolver(), "qch_unlock_ipad", 1);
if (locked == 0) {
deleteOtherApp(result);
}
}
private void deleteOtherApp(String packageList) {
Log.e("deleteOtherApp", "packageList:" + packageList);
String[] result = packageList.split(",");
@@ -812,7 +817,7 @@ public class InitJpushServer extends Service {
}
} else if (code == -300) {
ApkUtils.uninstallAllApp(InitJpushServer.this);
// ApkUtils.uninstallAllApp(InitJpushServer.this);
}
}
@@ -826,13 +831,27 @@ public class InitJpushServer extends Service {
}
synchronized private void resetDevice() {
private void resetDevice() {
boolean isReset = MySQLData.GetBooleanData(this, CommonDatas.IS_RESET);
if (isReset) {
int batteryLevel = getBatteryLevel();
LogUtils.e(batteryLevel + "------------------" + isReset);
if (isReset && batteryLevel >= CommonDatas.MIN_POWER) {
Utils.doMasterClear(this);
}
}
private int getBatteryLevel() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
BatteryManager batteryManager = (BatteryManager) getSystemService(BATTERY_SERVICE);
return batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY);
} else {
Intent intent = new ContextWrapper(InitJpushServer.this).
registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
return (intent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1) * 100) /
intent.getIntExtra(BatteryManager.EXTRA_SCALE, -1);
}
}
private void checkUpdate() {
HTTPInterface.checkUpdate(mHandler, "com.jiaoguanyi.store");
}

View File

@@ -42,6 +42,7 @@ import android.widget.Toast;
import com.alibaba.fastjson.JSONObject;
import com.arialyy.aria.core.Aria;
import com.blankj.utilcode.util.EncryptUtils;
import com.blankj.utilcode.util.FileUtils;
import com.blankj.utilcode.util.PathUtils;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType;
@@ -53,6 +54,7 @@ import com.mjsheng.myappstore.R;
import com.mjsheng.myappstore.MyApplication;
import com.mjsheng.myappstore.comm.CommonDatas;
import java.io.File;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
@@ -937,6 +939,12 @@ public class Utils {
if (ApkUtils.isAvailable(context, s)) {
allList.remove(s);
//去掉已经安装的
} else {
if (allList.indexOf(s) == -1) {
allList.add(s);
}
//没有安装就加入进去
//没有加入会导致安装后卸载不能再安装的情况
}
}
}
@@ -978,21 +986,44 @@ public class Utils {
return url.substring(position + 1);
}
private String getMD5fromFileName(String fileName) {
private static String getMD5fromFileName(String fileName) {
int position = fileName.lastIndexOf("/");
return fileName.substring(position + 9);
return fileName.substring(position + 9, fileName.length() - 4);
}
public static void ariaDownload(Context context, String url, JSONObject jsonObject) {
String fileName = getFileNamefromURL(url);
Aria.download(context)
.load(url) //读取下载地址
.setFilePath(PathUtils.getExternalDownloadsPath() + "/jgy/" + fileName, true)
.setExtendField(jsonObject.toJSONString())
.create(); //启动下载}
String urlMD5 = jsonObject.getString("MD5");
Log.e("ariaDownload", "urlMD5=" + urlMD5);
File file = new File(PathUtils.getExternalDownloadsPath() + "/jgy/" + fileName);
if (file.exists() && !file.isDirectory()) {
String filenameMD5 = getMD5fromFileName(url);
String fileMD5 = FileUtils.getFileMD5ToString(file);
Log.e("ariaDownload", "filenameMD5=" + filenameMD5);
Log.e("ariaDownload", "fileMD5=" + fileMD5);
//后端还没有完成json字段的MD5暂时用文件名获取
if (fileMD5.equalsIgnoreCase(filenameMD5)) {
ApkUtils.installApp(context, file.getAbsolutePath());
} else {
Aria.download(context)
.load(url) //读取下载地址
.setFilePath(PathUtils.getExternalDownloadsPath() + "/jgy/" + fileName, true)
.setExtendField(jsonObject.toJSONString())
.create(); //启动下载}
// SaveListUtils.addDownLoadList(app_package);
// }
}
} else {
Aria.download(context)
.load(url) //读取下载地址
.setFilePath(PathUtils.getExternalDownloadsPath() + "/jgy/" + fileName, true)
.setExtendField(jsonObject.toJSONString())
.create(); //启动下载}
}
}
}

View File

@@ -13,7 +13,7 @@
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
</content>
<orderEntry type="jdk" jdkName="JDK" jdkType="JavaSDK" />
<orderEntry type="jdk" jdkName="1.8" jdkType="JavaSDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@@ -4,5 +4,5 @@
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
#Mon Feb 24 11:04:00 CST 2020
sdk.dir=C\:\\Users\\Administrator\\AppData\\Local\\Android\\Sdk
#Mon Jul 20 16:54:17 CST 2020
sdk.dir=G\:\\Sdk