version:2.0.1.5_release
update:2020.07.07 fix:修复自动更新有个app之后,另外一个无法调起来,使用广播在安装应用和锁屏之后调起另一个应用 add:
This commit is contained in:
@@ -15,10 +15,10 @@ android {
|
|||||||
minSdkVersion 20
|
minSdkVersion 20
|
||||||
targetSdkVersion 29
|
targetSdkVersion 29
|
||||||
|
|
||||||
versionCode 102
|
// versionCode 103
|
||||||
versionName "3.0.7"//测试jiaoguanyi.cn
|
// versionName "3.0.8"//测试jiaoguanyi.cn
|
||||||
// versionCode 1004
|
versionCode 1005
|
||||||
// versionName "2.0.1.4"// 正式jiaoguanyi.com 双数正式 单数测试
|
versionName "2.0.1.5"// 正式jiaoguanyi.com 双数正式 单数测试
|
||||||
multiDexEnabled true
|
multiDexEnabled true
|
||||||
|
|
||||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||||
|
|||||||
@@ -105,11 +105,24 @@
|
|||||||
<action android:name="android.intent.action.BATTERY_OKAY" />
|
<action android:name="android.intent.action.BATTERY_OKAY" />
|
||||||
<action android:name="android.intent.action.ACTION_POWER_CONNECTED" />
|
<action android:name="android.intent.action.ACTION_POWER_CONNECTED" />
|
||||||
<action android:name="android.intent.action.DATE_CHANGED" />
|
<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.TIME_TICK" />
|
||||||
<action android:name="android.intent.action.USER_PRESENT" />
|
<action android:name="android.intent.action.USER_PRESENT" />
|
||||||
<action android:name="android.intent.action.SCREEN_ON" />
|
<action android:name="android.intent.action.SCREEN_ON" />
|
||||||
<action android:name="android.intent.action.SCREEN_OFF" />
|
<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>
|
</intent-filter>
|
||||||
</receiver>
|
</receiver>
|
||||||
<receiver
|
<receiver
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.mjsheng.myappstore;
|
|||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
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.HTTPInterface;
|
||||||
import com.mjsheng.myappstore.network.Network;
|
import com.mjsheng.myappstore.network.Network;
|
||||||
import com.mjsheng.myappstore.network.api.newapi.GetLockState;
|
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.GuardService;
|
||||||
import com.mjsheng.myappstore.server.InitJpushServer;
|
import com.mjsheng.myappstore.server.InitJpushServer;
|
||||||
|
import com.mjsheng.myappstore.server.MyDownloadService;
|
||||||
import com.mjsheng.myappstore.server.StepService;
|
import com.mjsheng.myappstore.server.StepService;
|
||||||
import com.mjsheng.myappstore.utils.Configure;
|
import com.mjsheng.myappstore.utils.Configure;
|
||||||
import com.mjsheng.myappstore.utils.MySQLData;
|
import com.mjsheng.myappstore.utils.MySQLData;
|
||||||
@@ -101,6 +105,7 @@ public class MyApplication extends MultiDexApplication {
|
|||||||
private SimpleDateFormat mDateFormat = null;
|
private SimpleDateFormat mDateFormat = null;
|
||||||
private static List<Activity> activityList = new LinkedList();
|
private static List<Activity> activityList = new LinkedList();
|
||||||
|
|
||||||
|
|
||||||
public static Context getAppContext() {
|
public static Context getAppContext() {
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
@@ -156,10 +161,16 @@ public class MyApplication extends MultiDexApplication {
|
|||||||
if (!BuildConfig.DEBUG) {
|
if (!BuildConfig.DEBUG) {
|
||||||
catchException();
|
catchException();
|
||||||
}
|
}
|
||||||
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
//8.0之后需要在
|
// 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();
|
registerTimeReceiver();
|
||||||
// }
|
|
||||||
ignoreBatteryOptimization(this);
|
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() {
|
public void registerTimeReceiver() {
|
||||||
@@ -197,6 +217,8 @@ public class MyApplication extends MultiDexApplication {
|
|||||||
registerReceiver(receiver, filter);
|
registerReceiver(receiver, filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private receiver receiver;
|
||||||
|
|
||||||
Long time1 = 0L;
|
Long time1 = 0L;
|
||||||
Long time2 = 0L;
|
Long time2 = 0L;
|
||||||
|
|
||||||
@@ -211,6 +233,17 @@ public class MyApplication extends MultiDexApplication {
|
|||||||
getLockState("2", String.valueOf(time));
|
getLockState("2", String.valueOf(time));
|
||||||
} else if (action.equals(Intent.ACTION_USER_PRESENT)) {
|
} else if (action.equals(Intent.ACTION_USER_PRESENT)) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
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();
|
time2 = System.currentTimeMillis();
|
||||||
if ((time2 - time1) > 60 * 1000) {
|
if ((time2 - time1) > 60 * 1000) {
|
||||||
//可能会多次触发,1分钟之内不执行
|
//可能会多次触发,1分钟之内不执行
|
||||||
@@ -224,6 +257,11 @@ public class MyApplication extends MultiDexApplication {
|
|||||||
} else if (action.equals(Intent.ACTION_SCREEN_OFF)) {
|
} else if (action.equals(Intent.ACTION_SCREEN_OFF)) {
|
||||||
long time = System.currentTimeMillis();
|
long time = System.currentTimeMillis();
|
||||||
getLockState("1", String.valueOf(time));
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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 = "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://www.jiaoguanyi.com/api/";//正式 弃用
|
||||||
|
|
||||||
// public static final String ROOT_URL = "https://partner.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 WebsocketURL = "ws://47.107.133.19:1234";
|
||||||
public static final String ROOT_URL = "http://www.jiaoguanyi.cn/api/";//测试
|
// 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 WebsocketURL = "ws://47.107.133.19:2345";
|
||||||
|
|
||||||
private static UploadAppInfoApi uploadAppInfoApi;
|
private static UploadAppInfoApi uploadAppInfoApi;
|
||||||
private static DeselectIDApi deselectIDApi;
|
private static DeselectIDApi deselectIDApi;
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import com.mjsheng.myappstore.server.MyDownloadService;
|
|||||||
import com.mjsheng.myappstore.server.StepService;
|
import com.mjsheng.myappstore.server.StepService;
|
||||||
|
|
||||||
public class BootReceiver extends BroadcastReceiver {
|
public class BootReceiver extends BroadcastReceiver {
|
||||||
|
public static final String BOOT_COMPLETED = "com.jiaoguanyi.appstore.intent.action.BOOT_COMPLETED";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
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.BATTERY_OKAY")
|
||||||
|| intent.getAction().equals("android.intent.action.ACTION_POWER_CONNECTED")
|
|| intent.getAction().equals("android.intent.action.ACTION_POWER_CONNECTED")
|
||||||
|| intent.getAction().equals("android.intent.action.DATE_CHANGED")
|
|| 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.TIME_TICK")
|
||||||
|| intent.getAction().equals("android.intent.action.USER_PRESENT")
|
|| intent.getAction().equals("android.intent.action.USER_PRESENT")
|
||||||
|| intent.getAction().equals("android.intent.action.SCREEN_ON")
|
|| intent.getAction().equals("android.intent.action.SCREEN_ON")
|
||||||
|| intent.getAction().equals("android.intent.action.SCREEN_OFF")
|
|| 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应该都收不到
|
//除了USER_PRESENT应该都收不到
|
||||||
@@ -38,7 +49,6 @@ public class BootReceiver extends BroadcastReceiver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startService(Context context) {
|
private void startService(Context context) {
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
package com.mjsheng.myappstore.receiver;
|
package com.mjsheng.myappstore.receiver;
|
||||||
|
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.ApplicationInfo;
|
import android.content.pm.ApplicationInfo;
|
||||||
import android.content.pm.PackageInfo;
|
import android.content.pm.PackageInfo;
|
||||||
|
import android.os.Build;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
@@ -43,6 +45,11 @@ public class NewAppReceiver extends BroadcastReceiver {
|
|||||||
action = intent.getAction();
|
action = intent.getAction();
|
||||||
//接收安装广播
|
//接收安装广播
|
||||||
if (action.equals(Intent.ACTION_PACKAGE_ADDED) || action.equals(Intent.ACTION_PACKAGE_REPLACED)) {
|
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();
|
Intent allIntent = new Intent();
|
||||||
allIntent.setAction(Utils.DOWNLOAD_ALLTASK_ACTION);
|
allIntent.setAction(Utils.DOWNLOAD_ALLTASK_ACTION);
|
||||||
context.sendBroadcast(allIntent);
|
context.sendBroadcast(allIntent);
|
||||||
|
|||||||
@@ -243,7 +243,7 @@ public class GuardService extends Service {
|
|||||||
String app_name = jsonObject.getString("app_name");
|
String app_name = jsonObject.getString("app_name");
|
||||||
String app_package = jsonObject.getString("app_package");
|
String app_package = jsonObject.getString("app_package");
|
||||||
Log.e("aria", "下载失败:" + filepath);
|
Log.e("aria", "下载失败:" + filepath);
|
||||||
ToastUtil.show(app_name + "\t:下载失败");
|
// ToastUtil.show(app_name + "\t:下载失败");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e("fht", "taskFail");
|
Log.e("fht", "taskFail");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user