diff --git a/app/build.gradle b/app/build.gradle
index 86cb100..46332a6 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -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"
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 97a6b54..03df107 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -105,11 +105,24 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
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);
+ }
}
}
diff --git a/app/src/main/java/com/mjsheng/myappstore/network/Network.java b/app/src/main/java/com/mjsheng/myappstore/network/Network.java
index 1d6bf4d..45315fe 100644
--- a/app/src/main/java/com/mjsheng/myappstore/network/Network.java
+++ b/app/src/main/java/com/mjsheng/myappstore/network/Network.java
@@ -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;
diff --git a/app/src/main/java/com/mjsheng/myappstore/receiver/BootReceiver.java b/app/src/main/java/com/mjsheng/myappstore/receiver/BootReceiver.java
index 140dd02..8c93478 100644
--- a/app/src/main/java/com/mjsheng/myappstore/receiver/BootReceiver.java
+++ b/app/src/main/java/com/mjsheng/myappstore/receiver/BootReceiver.java
@@ -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) {
diff --git a/app/src/main/java/com/mjsheng/myappstore/receiver/NewAppReceiver.java b/app/src/main/java/com/mjsheng/myappstore/receiver/NewAppReceiver.java
index ece5e6a..c540945 100644
--- a/app/src/main/java/com/mjsheng/myappstore/receiver/NewAppReceiver.java
+++ b/app/src/main/java/com/mjsheng/myappstore/receiver/NewAppReceiver.java
@@ -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);
diff --git a/app/src/main/java/com/mjsheng/myappstore/server/GuardService.java b/app/src/main/java/com/mjsheng/myappstore/server/GuardService.java
index 6c7a71b..32ba18b 100644
--- a/app/src/main/java/com/mjsheng/myappstore/server/GuardService.java
+++ b/app/src/main/java/com/mjsheng/myappstore/server/GuardService.java
@@ -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");
}