version:2.0.1.5_release

update:2020.07.07
fix:修复自动更新有个app之后,另外一个无法调起来,使用广播在安装应用和锁屏之后调起另一个应用
add:
This commit is contained in:
2020-07-07 17:29:46 +08:00
parent 3f400f763d
commit d6857d576c
7 changed files with 85 additions and 17 deletions

View File

@@ -15,10 +15,10 @@ android {
minSdkVersion 20
targetSdkVersion 29
versionCode 102
versionName "3.0.7"//测试jiaoguanyi.cn
// versionCode 1004
// versionName "2.0.1.4"// 正式jiaoguanyi.com 双数正式 单数测试
// versionCode 103
// versionName "3.0.8"//测试jiaoguanyi.cn
versionCode 1005
versionName "2.0.1.5"// 正式jiaoguanyi.com 双数正式 单数测试
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

View File

@@ -105,11 +105,24 @@
<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.LOCALE_CHANGED" />
<action android:name="android.intent.action.TIME_TICK" />
<action android:name="android.intent.action.USER_PRESENT" />
<action android:name="android.intent.action.SCREEN_ON" />
<action android:name="android.intent.action.SCREEN_OFF" />
<!--测试-->
<!-- <action android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED" />-->
<!-- <action android:name="android.hardware.usb.action.USB_ACCESSORY_DETACHED" />-->
<!-- <action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />-->
<!-- <action android:name="android.hardware.usb.action.USB_DEVICE_DETACHED" />-->
<!-- <action android:name="android.intent.action.MEDIA_MOUNTED" />-->
<!-- <action android:name="android.intent.action.MEDIA_CHECKING" />-->
<!-- <action android:name="android.intent.action.MEDIA_UNMOUNTED" />-->
<!-- <action android:name="android.intent.action.MEDIA_EJECT" />-->
<!-- <action android:name="android.intent.action.MEDIA_UNMOUNTABLE" />-->
<!-- <action android:name="android.intent.action.MEDIA_REMOVED" />-->
<!-- <action android:name="android.intent.action.MEDIA_BAD_REMOVAL" />-->
<!-- 自定义广播-->
<action android:name="com.jiaoguanyi.appstore.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<receiver

View File

@@ -2,6 +2,7 @@ package com.mjsheng.myappstore;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
@@ -39,8 +40,11 @@ import com.mjsheng.myappstore.jpush.TagAliasOperatorHelper;
import com.mjsheng.myappstore.network.HTTPInterface;
import com.mjsheng.myappstore.network.Network;
import com.mjsheng.myappstore.network.api.newapi.GetLockState;
import com.mjsheng.myappstore.receiver.BootReceiver;
import com.mjsheng.myappstore.receiver.NewAppReceiver;
import com.mjsheng.myappstore.server.GuardService;
import com.mjsheng.myappstore.server.InitJpushServer;
import com.mjsheng.myappstore.server.MyDownloadService;
import com.mjsheng.myappstore.server.StepService;
import com.mjsheng.myappstore.utils.Configure;
import com.mjsheng.myappstore.utils.MySQLData;
@@ -101,6 +105,7 @@ public class MyApplication extends MultiDexApplication {
private SimpleDateFormat mDateFormat = null;
private static List<Activity> activityList = new LinkedList();
public static Context getAppContext() {
return context;
}
@@ -156,10 +161,16 @@ public class MyApplication extends MultiDexApplication {
if (!BuildConfig.DEBUG) {
catchException();
}
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
//8.0之后需要在
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
// 8.0之后需要在
registmNewAppReceiver();
startService(new Intent(this, InitJpushServer.class));
startService(new Intent(this, StepService.class));
startService(new Intent(this, GuardService.class));
startService(new Intent(this, MyDownloadService.class));
}
registerTimeReceiver();
// }
ignoreBatteryOptimization(this);
}
@@ -182,8 +193,17 @@ public class MyApplication extends MultiDexApplication {
}
}
}
private NewAppReceiver mNewAppReceiver;
private receiver receiver;
private void registmNewAppReceiver() {
mNewAppReceiver = new NewAppReceiver();
IntentFilter filter = new IntentFilter();
filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
filter.addAction(Intent.ACTION_PACKAGE_ADDED);
filter.addAction(Intent.ACTION_PACKAGE_REPLACED);
filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
registerReceiver(mNewAppReceiver, filter);
}
//监听时间和日期变化
public void registerTimeReceiver() {
@@ -197,6 +217,8 @@ public class MyApplication extends MultiDexApplication {
registerReceiver(receiver, filter);
}
private receiver receiver;
Long time1 = 0L;
Long time2 = 0L;
@@ -211,6 +233,17 @@ public class MyApplication extends MultiDexApplication {
getLockState("2", String.valueOf(time));
} else if (action.equals(Intent.ACTION_USER_PRESENT)) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
/*在8.0以上 除了开机广播其他广播基本上没有用
*当静默安装升级时app不会被唤醒只有通过显示广播唤醒
* */
Intent intent1 = new Intent(BootReceiver.BOOT_COMPLETED);
intent1.setComponent(new ComponentName("com.jiaoguanyi.store", "com.mjsheng.myappstore.receiver.BootReceiver"));
// 携带数据
// intent1.putExtra("test", "我是来测 A 应用的Android 8.0 系统静态广播的测试数据");
// 启动发送广播
sendBroadcast(intent1);
time2 = System.currentTimeMillis();
if ((time2 - time1) > 60 * 1000) {
//可能会多次触发1分钟之内不执行
@@ -224,6 +257,11 @@ public class MyApplication extends MultiDexApplication {
} else if (action.equals(Intent.ACTION_SCREEN_OFF)) {
long time = System.currentTimeMillis();
getLockState("1", String.valueOf(time));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
Intent intent1 = new Intent(BootReceiver.BOOT_COMPLETED);
intent1.setComponent(new ComponentName("com.jiaoguanyi.store", "com.mjsheng.myappstore.receiver.BootReceiver"));
sendBroadcast(intent1);
}
}
}

View File

@@ -41,10 +41,10 @@ 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 = "http://www.jiaoguanyi.cn/api/";//测试
public static final String WebsocketURL = "ws://47.107.133.19:2345";
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";
private static UploadAppInfoApi uploadAppInfoApi;
private static DeselectIDApi deselectIDApi;

View File

@@ -11,7 +11,7 @@ import com.mjsheng.myappstore.server.MyDownloadService;
import com.mjsheng.myappstore.server.StepService;
public class BootReceiver extends BroadcastReceiver {
public static final String BOOT_COMPLETED = "com.jiaoguanyi.appstore.intent.action.BOOT_COMPLETED";
@Override
public void onReceive(Context context, Intent intent) {
@@ -25,11 +25,22 @@ public class BootReceiver extends BroadcastReceiver {
|| intent.getAction().equals("android.intent.action.BATTERY_OKAY")
|| intent.getAction().equals("android.intent.action.ACTION_POWER_CONNECTED")
|| intent.getAction().equals("android.intent.action.DATE_CHANGED")
|| intent.getAction().equals("android.intent.action.LOCALE_CHANGED")
|| intent.getAction().equals("android.intent.action.TIME_TICK")
|| intent.getAction().equals("android.intent.action.USER_PRESENT")
|| intent.getAction().equals("android.intent.action.SCREEN_ON")
|| intent.getAction().equals("android.intent.action.SCREEN_OFF")
//测试
// || intent.getAction().equals("android.hardware.usb.action.USB_ACCESSORY_ATTACHED")
// || intent.getAction().equals("android.hardware.usb.action.USB_ACCESSORY_DETACHED")
// || intent.getAction().equals("android.hardware.usb.action.USB_DEVICE_ATTACHED")
// || intent.getAction().equals("android.hardware.usb.action.USB_DEVICE_DETACHED")
// || intent.getAction().equals("android.intent.action.MEDIA_MOUNTED")
// || intent.getAction().equals("android.intent.action.MEDIA_CHECKING")
// || intent.getAction().equals("android.intent.action.MEDIA_UNMOUNTED")
// || intent.getAction().equals("android.intent.action.MEDIA_EJECT")
// || intent.getAction().equals("android.intent.action.MEDIA_UNMOUNTABLE")
// || intent.getAction().equals("android.intent.action.MEDIA_REMOVED")
// || intent.getAction().equals("android.intent.action.MEDIA_BAD_REMOVAL")
) {
//除了USER_PRESENT应该都收不到
@@ -38,7 +49,6 @@ public class BootReceiver extends BroadcastReceiver {
}
}
private void startService(Context context) {

View File

@@ -1,10 +1,12 @@
package com.mjsheng.myappstore.receiver;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.os.Build;
import android.util.Log;
import com.google.gson.Gson;
@@ -43,6 +45,11 @@ public class NewAppReceiver extends BroadcastReceiver {
action = intent.getAction();
//接收安装广播
if (action.equals(Intent.ACTION_PACKAGE_ADDED) || action.equals(Intent.ACTION_PACKAGE_REPLACED)) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
Intent intent1 = new Intent(BootReceiver.BOOT_COMPLETED);
intent1.setComponent(new ComponentName("com.jiaoguanyi.store", "com.mjsheng.myappstore.receiver.BootReceiver"));
context.sendBroadcast(intent1);
}
Intent allIntent = new Intent();
allIntent.setAction(Utils.DOWNLOAD_ALLTASK_ACTION);
context.sendBroadcast(allIntent);

View File

@@ -243,7 +243,7 @@ public class GuardService extends Service {
String app_name = jsonObject.getString("app_name");
String app_package = jsonObject.getString("app_package");
Log.e("aria", "下载失败:" + filepath);
ToastUtil.show(app_name + "\t:下载失败");
// ToastUtil.show(app_name + "\t:下载失败");
} catch (Exception e) {
Log.e("fht", "taskFail");
}