version:2.1
fix:完善推送 update:
@@ -1,4 +1,5 @@
|
|||||||
apply plugin: 'com.android.application'
|
apply plugin: 'com.android.application'
|
||||||
|
apply plugin: "com.tencent.android.tpns"
|
||||||
|
|
||||||
static def appName() {
|
static def appName() {
|
||||||
return "AoleyunDeviceInfo"
|
return "AoleyunDeviceInfo"
|
||||||
@@ -60,14 +61,18 @@ android {
|
|||||||
//新平台正式
|
//新平台正式
|
||||||
newly {
|
newly {
|
||||||
flavorDimensions "default"
|
flavorDimensions "default"
|
||||||
versionCode 10
|
versionCode 12
|
||||||
versionName "1.9"
|
versionName "2.1"
|
||||||
/*********************************极光推送************************************/
|
/*********************************极光推送************************************/
|
||||||
manifestPlaceholders = [
|
manifestPlaceholders = [
|
||||||
JPUSH_PKGNAME: "com.aoleyun.sn",
|
XG_ACCESS_ID : "1500026372",
|
||||||
JPUSH_APPKEY : "79c64ef41b8728ad6aa29af1", //JPush上注册的包名对应的appkey.
|
XG_ACCESS_KEY: "AR7A1L5M0LPH",
|
||||||
JPUSH_CHANNEL: "developer-default", //暂时填写默认值即可.
|
|
||||||
channel_value: "newly",
|
// JPUSH_PKGNAME: "com.aoleyun.sn",
|
||||||
|
// JPUSH_APPKEY : "79c64ef41b8728ad6aa29af1", //JPush上注册的包名对应的appkey.
|
||||||
|
// JPUSH_CHANNEL: "developer-default", //暂时填写默认值即可.
|
||||||
|
// channel_value: "newly",
|
||||||
|
|
||||||
]
|
]
|
||||||
/*********************************极光推送end************************************/
|
/*********************************极光推送end************************************/
|
||||||
buildConfigField "String", "ROOT_URL", '"https://led.aoleyun.cn/api/"'
|
buildConfigField "String", "ROOT_URL", '"https://led.aoleyun.cn/api/"'
|
||||||
@@ -78,14 +83,16 @@ android {
|
|||||||
|
|
||||||
MTKnewly {
|
MTKnewly {
|
||||||
flavorDimensions "default"
|
flavorDimensions "default"
|
||||||
versionCode 1
|
versionCode 4
|
||||||
versionName "1.0"
|
versionName "1.3"
|
||||||
/*********************************极光推送************************************/
|
/*********************************极光推送************************************/
|
||||||
manifestPlaceholders = [
|
manifestPlaceholders = [
|
||||||
JPUSH_PKGNAME: "com.aoleyun.sn",
|
XG_ACCESS_ID : "1500026372",
|
||||||
JPUSH_APPKEY : "79c64ef41b8728ad6aa29af1", //JPush上注册的包名对应的appkey.
|
XG_ACCESS_KEY: "AR7A1L5M0LPH",
|
||||||
JPUSH_CHANNEL: "developer-default", //暂时填写默认值即可.
|
// JPUSH_PKGNAME: "com.aoleyun.sn",
|
||||||
channel_value: "newly",
|
// JPUSH_APPKEY : "79c64ef41b8728ad6aa29af1", //JPush上注册的包名对应的appkey.
|
||||||
|
// JPUSH_CHANNEL: "developer-default", //暂时填写默认值即可.
|
||||||
|
// channel_value: "newly",
|
||||||
]
|
]
|
||||||
/*********************************极光推送end************************************/
|
/*********************************极光推送end************************************/
|
||||||
buildConfigField "String", "ROOT_URL", '"https://led.aoleyun.cn/api/"'
|
buildConfigField "String", "ROOT_URL", '"https://led.aoleyun.cn/api/"'
|
||||||
@@ -102,10 +109,12 @@ android {
|
|||||||
versionName "1.0"
|
versionName "1.0"
|
||||||
/*********************************极光推送************************************/
|
/*********************************极光推送************************************/
|
||||||
manifestPlaceholders = [
|
manifestPlaceholders = [
|
||||||
JPUSH_PKGNAME: "com.aoleyun.sn",
|
XG_ACCESS_ID : "1500026372",
|
||||||
JPUSH_APPKEY : "79c64ef41b8728ad6aa29af1", //JPush上注册的包名对应的appkey.
|
XG_ACCESS_KEY: "AR7A1L5M0LPH",
|
||||||
JPUSH_CHANNEL: "developer-default", //暂时填写默认值即可.
|
// JPUSH_PKGNAME: "com.aoleyun.sn",
|
||||||
channel_value: "beta",
|
// JPUSH_APPKEY : "79c64ef41b8728ad6aa29af1", //JPush上注册的包名对应的appkey.
|
||||||
|
// JPUSH_CHANNEL: "developer-default", //暂时填写默认值即可.
|
||||||
|
// channel_value: "beta",
|
||||||
]
|
]
|
||||||
/*********************************极光推送end************************************/
|
/*********************************极光推送end************************************/
|
||||||
buildConfigField "String", "ROOT_URL", '"https://led.aoleyun.cn/api/"'
|
buildConfigField "String", "ROOT_URL", '"https://led.aoleyun.cn/api/"'
|
||||||
@@ -320,15 +329,16 @@ dependencies {
|
|||||||
implementation 'com.github.bumptech.glide:glide:4.11.0'
|
implementation 'com.github.bumptech.glide:glide:4.11.0'
|
||||||
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
|
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
|
||||||
//fastjson
|
//fastjson
|
||||||
implementation 'com.alibaba:fastjson:1.2.76'
|
implementation 'com.alibaba:fastjson:1.2.79'
|
||||||
//极光推送
|
//极光推送
|
||||||
implementation 'cn.jiguang.sdk:jpush:4.3.0' // 此处以JPush 3.5.6 版本为例。
|
// implementation 'cn.jiguang.sdk:jpush:4.3.0' // 此处以JPush 3.5.6 版本为例。
|
||||||
implementation 'cn.jiguang.sdk:jcore:2.9.0' // 此处以JCore 2.2.8 版本为例。
|
// implementation 'cn.jiguang.sdk:jcore:2.9.0' // 此处以JCore 2.2.8 版本为例。
|
||||||
//高德地图定位
|
//高德地图定位
|
||||||
implementation 'com.amap.api:location:5.1.0'
|
implementation 'com.amap.api:location:5.1.0'
|
||||||
//MMKV
|
//MMKV
|
||||||
implementation 'com.tencent:mmkv-static:1.2.10'
|
implementation 'com.tencent:mmkv-static:1.2.11'
|
||||||
|
//腾讯移动推送 TPNS
|
||||||
|
implementation 'com.tencent.tpns:tpns:1.3.1.1-release'
|
||||||
//RxHttp
|
//RxHttp
|
||||||
implementation 'com.github.liujingxing.rxhttp:rxhttp:2.6.5'
|
implementation 'com.github.liujingxing.rxhttp:rxhttp:2.6.5'
|
||||||
//implementation 'com.squareup.okhttp3:okhttp:4.9.1' //rxhttp v2.2.2版本起,需要手动依赖okhttp
|
//implementation 'com.squareup.okhttp3:okhttp:4.9.1' //rxhttp v2.2.2版本起,需要手动依赖okhttp
|
||||||
|
|||||||
@@ -5,87 +5,108 @@
|
|||||||
coreApp="true"
|
coreApp="true"
|
||||||
android:sharedUserId="android.uid.system">
|
android:sharedUserId="android.uid.system">
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
|
|
||||||
<uses-permission android:name="android.permission.SYSTEM_OVERLAY_WINDOW" />
|
|
||||||
<uses-permission android:name="android.permission.BROADCAST_STICKY" />
|
<uses-permission android:name="android.permission.BROADCAST_STICKY" />
|
||||||
<uses-permission android:name="android.permission.INSTALL_PACKAGES" />
|
|
||||||
<uses-permission android:name="android.permission.DELETE_PACKAGES" />
|
|
||||||
<uses-permission android:name="android.permission.GET_PACKAGE_SIZE" />
|
|
||||||
<uses-permission android:name="android.permission.MASTER_CLEAR" />
|
|
||||||
<uses-permission android:name="android.permission.REBOOT" />
|
|
||||||
<uses-permission android:name="android.permission.DUMP" />
|
|
||||||
<uses-permission android:name="android.permission.READ_LOGS" />
|
|
||||||
<uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" />
|
|
||||||
<uses-permission android:name="android.permission.GET_TASKS" />
|
|
||||||
<uses-permission android:name="android.permission.REAL_GET_TASKS" />
|
|
||||||
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
|
|
||||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
|
||||||
<uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />
|
|
||||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
|
||||||
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
|
|
||||||
<uses-permission android:name="android.permission.BLUETOOTH" />
|
<uses-permission android:name="android.permission.BLUETOOTH" />
|
||||||
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
|
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
|
||||||
<uses-permission android:name="android.permission.SHUTDOWN" />
|
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
|
||||||
<uses-permission android:name="android.permission.GET_PACKAGE_SIZE" />
|
<uses-permission android:name="android.permission.GET_PACKAGE_SIZE" />
|
||||||
<uses-permission android:name="android.permission.DELETE_CACHE_FILES" />
|
<uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" />
|
||||||
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
|
<uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />
|
||||||
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
||||||
<!-- 静默安装权限 -->
|
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||||
<uses-permission
|
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
|
||||||
android:name="android.permission.INSTALL_PACKAGES"
|
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
|
||||||
tools:ignore="ProtectedPermissions" />
|
<uses-permission android:name="android.permission.SYSTEM_OVERLAY_WINDOW" />
|
||||||
<!-- 应用卸载权限 -->
|
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
|
||||||
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
|
|
||||||
<uses-permission
|
|
||||||
android:name="android.permission.DELETE_PACKAGES"
|
|
||||||
tools:ignore="ProtectedPermissions" />
|
|
||||||
<!-- ##############################极光推送############################## -->
|
|
||||||
<!-- Required -->
|
|
||||||
<permission
|
|
||||||
android:name="${JPUSH_PKGNAME}.permission.JPUSH_MESSAGE"
|
|
||||||
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" />
|
|
||||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
|
||||||
<uses-permission android:name="android.permission.READ_PRIVILEGED_PHONE_STATE" />
|
|
||||||
<uses-permission android:name="android.permission.BATTERY_STATS" />
|
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||||
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
|
|
||||||
|
<uses-permission android:name="android.permission.BATTERY_STATS" />
|
||||||
|
<uses-permission android:name="android.permission.DELETE_CACHE_FILES" />
|
||||||
|
<uses-permission android:name="android.permission.DUMP" />
|
||||||
|
<uses-permission android:name="android.permission.MASTER_CLEAR" />
|
||||||
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
|
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
|
||||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
<uses-permission android:name="android.permission.REBOOT" />
|
||||||
|
<uses-permission android:name="android.permission.READ_LOGS" />
|
||||||
|
<uses-permission android:name="android.permission.REAL_GET_TASKS" />
|
||||||
|
<uses-permission android:name="android.permission.READ_PRIVILEGED_PHONE_STATE" />
|
||||||
|
<uses-permission android:name="android.permission.SHUTDOWN" />
|
||||||
|
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
|
||||||
|
|
||||||
|
<uses-permission android:name="android.permission.GET_TASKS" />
|
||||||
|
|
||||||
<uses-permission
|
<uses-permission
|
||||||
android:name="com.android.browser.permission.WRITE_HISTORY_BOOKMARKS"
|
android:name="com.android.browser.permission.WRITE_HISTORY_BOOKMARKS"
|
||||||
android:maxSdkVersion="22" />
|
android:maxSdkVersion="22" />
|
||||||
<uses-permission
|
<uses-permission
|
||||||
android:name="com.android.browser.permission.READ_HISTORY_BOOKMARKS"
|
android:name="com.android.browser.permission.READ_HISTORY_BOOKMARKS"
|
||||||
android:maxSdkVersion="23" /> <!-- 高德地图 -->
|
android:maxSdkVersion="23" />
|
||||||
|
|
||||||
|
<!-- 静默安装权限 -->
|
||||||
|
<uses-permission android:name="android.permission.INSTALL_PACKAGES" />
|
||||||
|
<uses-permission
|
||||||
|
android:name="android.permission.INSTALL_PACKAGES"
|
||||||
|
tools:ignore="ProtectedPermissions" />
|
||||||
|
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
|
||||||
|
<!-- 应用卸载权限 -->
|
||||||
|
<uses-permission android:name="android.permission.DELETE_PACKAGES" />
|
||||||
|
<uses-permission
|
||||||
|
android:name="android.permission.DELETE_PACKAGES"
|
||||||
|
tools:ignore="ProtectedPermissions" />
|
||||||
|
|
||||||
|
<!-- 【必须】 移动推送 TPNS SDK VIP版本所需权限 -->
|
||||||
|
<permission
|
||||||
|
android:name="com.aoleyun.sn.permission.XGPUSH_RECEIVE"
|
||||||
|
android:protectionLevel="signature" />
|
||||||
|
<uses-permission android:name="com.aoleyun.sn.permission.XGPUSH_RECEIVE" />
|
||||||
|
|
||||||
|
<!-- 【必须】 移动推送 TPNS SDK 所需权限 -->
|
||||||
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||||
|
|
||||||
|
<!-- 【常用】 移动推送 TPNS SDK所需权限 -->
|
||||||
|
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||||
|
<uses-permission android:name="android.permission.VIBRATE" />
|
||||||
|
<uses-permission android:name="android.permission.RECEIVE_USER_PRESENT" />
|
||||||
|
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||||
|
<uses-permission android:name="android.permission.GET_TASKS" />
|
||||||
|
|
||||||
|
<!-- ##############################极光推送############################## -->
|
||||||
|
<!-- Required -->
|
||||||
|
<!-- <permission-->
|
||||||
|
<!-- android:name="${JPUSH_PKGNAME}.permission.JPUSH_MESSAGE"-->
|
||||||
|
<!-- android:protectionLevel="signature" />-->
|
||||||
|
<!-- Required -->
|
||||||
|
<!-- <uses-permission android:name="${JPUSH_PKGNAME}.permission.JPUSH_MESSAGE" />-->
|
||||||
|
|
||||||
|
<!-- 高德地图 -->
|
||||||
<!-- 用于进行网络定位 -->
|
<!-- 用于进行网络定位 -->
|
||||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||||
<!-- 用于访问GPS定位 -->
|
<!-- 用于访问GPS定位 -->
|
||||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||||
<!-- 用于获取运营商信息,用于支持提供运营商信息相关的接口 -->
|
<!-- 用于获取运营商信息,用于支持提供运营商信息相关的接口 -->
|
||||||
<!-- <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> -->
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||||
<!-- 用于访问wifi网络信息,wifi信息会用于进行网络定位 -->
|
<!-- 用于访问wifi网络信息,wifi信息会用于进行网络定位 -->
|
||||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||||
<!-- 用于获取wifi的获取权限,wifi信息会用来进行网络定位 -->
|
<!-- 用于获取wifi的获取权限,wifi信息会用来进行网络定位 -->
|
||||||
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
|
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
|
||||||
<!-- 用于访问网络,网络定位需要上网 -->
|
<!-- 用于访问网络,网络定位需要上网 -->
|
||||||
<!-- <uses-permission android:name="android.permission.INTERNET" /> -->
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
<!-- 用于读取手机当前的状态 -->
|
<!-- 用于读取手机当前的状态 -->
|
||||||
<!-- <uses-permission android:name="android.permission.READ_PHONE_STATE" /> -->
|
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||||
<!-- 用于写入缓存数据到扩展存储卡 -->
|
<!-- 用于写入缓存数据到扩展存储卡 -->
|
||||||
<!-- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> -->
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||||
<!-- 用于申请调用A-GPS模块 -->
|
<!-- 用于申请调用A-GPS模块 -->
|
||||||
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
|
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
|
||||||
<!-- 如果设置了target >= 28 如果需要启动后台定位则必须声明这个权限 -->
|
<!-- 如果设置了target >= 28 如果需要启动后台定位则必须声明这个权限 -->
|
||||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||||
<!-- 如果您的应用需要后台定位权限,且有可能运行在Android Q设备上,并且设置了target>28,必须增加这个权限声明 -->
|
<!-- 如果您的应用需要后台定位权限,且有可能运行在Android Q设备上,并且设置了target>28,必须增加这个权限声明 -->
|
||||||
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
|
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
|
||||||
<uses-permission android:name="com.aoleyun.sn.permissions.INSTALL_APK" />
|
|
||||||
|
|
||||||
|
<!--自定义安装应用权限-->
|
||||||
|
<uses-permission android:name="com.aoleyun.sn.permissions.INSTALL_APK" />
|
||||||
<permission android:name="com.aoleyun.sn.permissions.INSTALL_APK" />
|
<permission android:name="com.aoleyun.sn.permissions.INSTALL_APK" />
|
||||||
|
|
||||||
<application
|
<application
|
||||||
@@ -105,7 +126,7 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
android:name=".activity.MainActivity"
|
android:name=".activity.main.MainActivity"
|
||||||
android:excludeFromRecents="true"
|
android:excludeFromRecents="true"
|
||||||
android:launchMode="singleTop" />
|
android:launchMode="singleTop" />
|
||||||
<activity android:name=".activity.TopActivity" />
|
<activity android:name=".activity.TopActivity" />
|
||||||
@@ -216,7 +237,8 @@
|
|||||||
<!-- 自定义广播 -->
|
<!-- 自定义广播 -->
|
||||||
<action android:name="com.aoleyun.sn.intent.action.BOOT_COMPLETED" />
|
<action android:name="com.aoleyun.sn.intent.action.BOOT_COMPLETED" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</receiver> <!-- <receiver android:name=".log.LogReceiver" -->
|
</receiver>
|
||||||
|
<!-- <receiver android:name=".log.LogReceiver" -->
|
||||||
<!-- android:permission="android.permission.DUMP" > -->
|
<!-- android:permission="android.permission.DUMP" > -->
|
||||||
<!-- <intent-filter> -->
|
<!-- <intent-filter> -->
|
||||||
<!-- <action android:name="android.intent.action.BOOT_COMPLETED" /> -->
|
<!-- <action android:name="android.intent.action.BOOT_COMPLETED" /> -->
|
||||||
@@ -228,7 +250,7 @@
|
|||||||
<!-- </intent-filter> -->
|
<!-- </intent-filter> -->
|
||||||
<!-- </receiver> -->
|
<!-- </receiver> -->
|
||||||
<receiver
|
<receiver
|
||||||
android:name=".receiver.MyJPushReceiver"
|
android:name=".jpush.MyJPushReceiver"
|
||||||
android:enabled="true">
|
android:enabled="true">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
|
|
||||||
@@ -243,9 +265,10 @@
|
|||||||
<!-- 接收网络变化 连接/断开 since 1.6.3 -->
|
<!-- 接收网络变化 连接/断开 since 1.6.3 -->
|
||||||
<action android:name="cn.jpush.android.intent.CONNECTION" />
|
<action android:name="cn.jpush.android.intent.CONNECTION" />
|
||||||
|
|
||||||
<category android:name="${JPUSH_PKGNAME}" />
|
<!-- <category android:name="${JPUSH_PKGNAME}" />-->
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</receiver> <!-- Required. For publish channel feature -->
|
</receiver>
|
||||||
|
<!-- Required. For publish channel feature -->
|
||||||
<!-- JPUSH_CHANNEL 是为了方便开发者统计APK分发渠道。 -->
|
<!-- JPUSH_CHANNEL 是为了方便开发者统计APK分发渠道。 -->
|
||||||
<!-- 例如: -->
|
<!-- 例如: -->
|
||||||
<!-- 发到 Google Play 的APK可以设置为 google-play; -->
|
<!-- 发到 Google Play 的APK可以设置为 google-play; -->
|
||||||
@@ -268,147 +291,252 @@
|
|||||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||||
android:resource="@xml/file_paths" />
|
android:resource="@xml/file_paths" />
|
||||||
</provider>
|
</provider>
|
||||||
|
|
||||||
<!-- ##############################极光推送############################## -->
|
<!-- ##############################极光推送############################## -->
|
||||||
<!-- Rich push 核心功能 since 2.0.6 -->
|
<!-- Rich push 核心功能 since 2.0.6 -->
|
||||||
<activity
|
<!-- <activity-->
|
||||||
android:name="cn.jpush.android.ui.PopWinActivity"
|
<!-- android:name="cn.jpush.android.ui.PopWinActivity"-->
|
||||||
android:exported="false"
|
<!-- android:exported="false"-->
|
||||||
android:theme="@style/MyDialogStyle"
|
<!-- android:theme="@style/MyDialogStyle"-->
|
||||||
tools:replace="android:exported" />
|
<!-- tools:replace="android:exported" />-->
|
||||||
<!-- Required SDK核心功能 -->
|
<!-- Required SDK核心功能 -->
|
||||||
<activity
|
<!-- <activity-->
|
||||||
android:name="cn.jpush.android.ui.PushActivity"
|
<!-- android:name="cn.jpush.android.ui.PushActivity"-->
|
||||||
android:configChanges="orientation|keyboardHidden"
|
<!-- android:configChanges="orientation|keyboardHidden"-->
|
||||||
android:exported="false"
|
<!-- android:exported="false"-->
|
||||||
android:theme="@android:style/Theme.NoTitleBar"
|
<!-- android:theme="@android:style/Theme.NoTitleBar"-->
|
||||||
tools:replace="android:exported">
|
<!-- tools:replace="android:exported">-->
|
||||||
<intent-filter>
|
<!-- <intent-filter>-->
|
||||||
<action android:name="cn.jpush.android.ui.PushActivity" />
|
<!-- <action android:name="cn.jpush.android.ui.PushActivity" />-->
|
||||||
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<!-- <category android:name="android.intent.category.DEFAULT" />-->
|
||||||
<category android:name="com.aoleyun.sn" />
|
<!-- <category android:name="com.aoleyun.sn" />-->
|
||||||
</intent-filter>
|
<!-- </intent-filter>-->
|
||||||
</activity>
|
<!-- </activity>-->
|
||||||
<!-- Required SDK 核心功能 -->
|
<!-- Required SDK 核心功能 -->
|
||||||
<!-- 可配置android:process参数将PushService放在其他进程中 -->
|
<!-- 可配置android:process参数将PushService放在其他进程中 -->
|
||||||
<service
|
<!-- <service-->
|
||||||
android:name="cn.jpush.android.service.PushService"
|
<!-- android:name="cn.jpush.android.service.PushService"-->
|
||||||
android:exported="false"
|
<!-- android:exported="false"-->
|
||||||
android:process=":pushcore">
|
<!-- android:process=":pushcore">-->
|
||||||
<intent-filter>
|
<!-- <intent-filter>-->
|
||||||
<action android:name="cn.jpush.android.intent.REGISTER" />
|
<!-- <action android:name="cn.jpush.android.intent.REGISTER" />-->
|
||||||
<action android:name="cn.jpush.android.intent.REPORT" />
|
<!-- <action android:name="cn.jpush.android.intent.REPORT" />-->
|
||||||
<action android:name="cn.jpush.android.intent.PushService" />
|
<!-- <action android:name="cn.jpush.android.intent.PushService" />-->
|
||||||
<action android:name="cn.jpush.android.intent.PUSH_TIME" />
|
<!-- <action android:name="cn.jpush.android.intent.PUSH_TIME" />-->
|
||||||
</intent-filter>
|
<!-- </intent-filter>-->
|
||||||
</service>
|
<!-- </service>-->
|
||||||
<!-- since 3.0.9 Required SDK 核心功能 -->
|
<!-- since 3.0.9 Required SDK 核心功能 -->
|
||||||
<provider
|
<!-- <provider-->
|
||||||
android:name="cn.jpush.android.service.DataProvider"
|
<!-- android:name="cn.jpush.android.service.DataProvider"-->
|
||||||
android:authorities="com.aoleyun.sn.DataProvider"
|
<!-- android:authorities="com.aoleyun.sn.DataProvider"-->
|
||||||
android:exported="false"
|
<!-- android:exported="false"-->
|
||||||
android:process=":pushcore"
|
<!-- android:process=":pushcore"-->
|
||||||
tools:replace="android:authorities" />
|
<!-- tools:replace="android:authorities" />-->
|
||||||
<!-- since 1.8.0 option 可选项。用于同一设备中不同应用的JPush服务相互拉起的功能。 -->
|
<!-- since 1.8.0 option 可选项。用于同一设备中不同应用的JPush服务相互拉起的功能。 -->
|
||||||
<!-- 若不启用该功能可删除该组件,将不拉起其他应用也不能被其他应用拉起 -->
|
<!-- 若不启用该功能可删除该组件,将不拉起其他应用也不能被其他应用拉起 -->
|
||||||
<service
|
<!-- <service-->
|
||||||
android:name="cn.jpush.android.service.DaemonService"
|
<!-- android:name="cn.jpush.android.service.DaemonService"-->
|
||||||
android:enabled="true"
|
<!-- android:enabled="true"-->
|
||||||
android:exported="true">
|
<!-- android:exported="true">-->
|
||||||
<intent-filter>
|
<!-- <intent-filter>-->
|
||||||
<action android:name="cn.jpush.android.intent.DaemonService" />
|
<!-- <action android:name="cn.jpush.android.intent.DaemonService" />-->
|
||||||
|
|
||||||
<category android:name="com.aoleyun.sn" />
|
<!-- <category android:name="com.aoleyun.sn" />-->
|
||||||
</intent-filter>
|
<!-- </intent-filter>-->
|
||||||
</service>
|
<!-- </service>-->
|
||||||
<!-- since 3.1.0 Required SDK 核心功能 -->
|
<!-- since 3.1.0 Required SDK 核心功能 -->
|
||||||
<provider
|
<!-- <provider-->
|
||||||
android:name="cn.jpush.android.service.DownloadProvider"
|
<!-- android:name="cn.jpush.android.service.DownloadProvider"-->
|
||||||
android:authorities="com.aoleyun.sn.DownloadProvider"
|
<!-- android:authorities="com.aoleyun.sn.DownloadProvider"-->
|
||||||
android:exported="true"
|
<!-- android:exported="true"-->
|
||||||
tools:replace="android:authorities" />
|
<!-- tools:replace="android:authorities" />-->
|
||||||
<!-- Required SDK核心功能 -->
|
<!-- Required SDK核心功能 -->
|
||||||
<receiver
|
<!-- <receiver-->
|
||||||
android:name="cn.jpush.android.service.PushReceiver"
|
<!-- android:name="cn.jpush.android.service.PushReceiver"-->
|
||||||
android:enabled="true"
|
<!-- android:enabled="true"-->
|
||||||
android:exported="false"
|
<!-- android:exported="false"-->
|
||||||
tools:replace="android:exported">
|
<!-- tools:replace="android:exported">-->
|
||||||
<intent-filter android:priority="1000">
|
<!-- <intent-filter android:priority="1000">-->
|
||||||
<action android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED_PROXY" />
|
<!-- <action android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED_PROXY" />-->
|
||||||
<!-- Required 显示通知栏 -->
|
<!-- <!– Required 显示通知栏 –>-->
|
||||||
<category android:name="com.aoleyun.sn" />
|
<!-- <category android:name="com.aoleyun.sn" />-->
|
||||||
</intent-filter>
|
<!-- </intent-filter>-->
|
||||||
<intent-filter>
|
<!-- <intent-filter>-->
|
||||||
<action android:name="android.intent.action.USER_PRESENT" />
|
<!-- <action android:name="android.intent.action.USER_PRESENT" />-->
|
||||||
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
|
<!-- <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />-->
|
||||||
</intent-filter>
|
<!-- </intent-filter>-->
|
||||||
<!-- Optional -->
|
<!-- <!– Optional –>-->
|
||||||
<intent-filter>
|
<!-- <intent-filter>-->
|
||||||
<action android:name="android.intent.action.PACKAGE_ADDED" />
|
<!-- <action android:name="android.intent.action.PACKAGE_ADDED" />-->
|
||||||
<action android:name="android.intent.action.PACKAGE_REMOVED" />
|
<!-- <action android:name="android.intent.action.PACKAGE_REMOVED" />-->
|
||||||
|
|
||||||
<data android:scheme="package" />
|
<!-- <data android:scheme="package" />-->
|
||||||
</intent-filter>
|
<!-- </intent-filter>-->
|
||||||
</receiver> <!-- Required SDK核心功能 -->
|
<!-- </receiver>-->
|
||||||
<receiver
|
<!-- Required SDK核心功能 -->
|
||||||
android:name="cn.jpush.android.service.AlarmReceiver"
|
<!-- <receiver-->
|
||||||
android:exported="false" />
|
<!-- android:name="cn.jpush.android.service.AlarmReceiver"-->
|
||||||
|
<!-- android:exported="false" />-->
|
||||||
<!-- since 3.3.0 Required SDK核心功能 -->
|
<!-- since 3.3.0 Required SDK核心功能 -->
|
||||||
<activity
|
<!-- <activity-->
|
||||||
android:name="cn.jpush.android.service.JNotifyActivity"
|
<!-- android:name="cn.jpush.android.service.JNotifyActivity"-->
|
||||||
android:exported="true"
|
<!-- android:exported="true"-->
|
||||||
android:taskAffinity="jpush.custom"
|
<!-- android:taskAffinity="jpush.custom"-->
|
||||||
android:theme="@android:style/Theme.Translucent.NoTitleBar">
|
<!-- android:theme="@android:style/Theme.Translucent.NoTitleBar">-->
|
||||||
<intent-filter>
|
<!-- <intent-filter>-->
|
||||||
<action android:name="cn.jpush.android.intent.JNotifyActivity" />
|
<!-- <action android:name="cn.jpush.android.intent.JNotifyActivity" />-->
|
||||||
|
|
||||||
<category android:name="com.aoleyun.sn" />
|
<!-- <category android:name="com.aoleyun.sn" />-->
|
||||||
</intent-filter>
|
<!-- </intent-filter>-->
|
||||||
</activity>
|
<!-- </activity>-->
|
||||||
<!-- Since JCore2.0.0 Required SDK核心功能 -->
|
<!-- Since JCore2.0.0 Required SDK核心功能 -->
|
||||||
<!-- 这个Service要继承JCommonService -->
|
<!-- 这个Service要继承JCommonService -->
|
||||||
<service
|
<!-- <service-->
|
||||||
android:name=".jpush.PushService"
|
<!-- android:name=".jpush.PushService"-->
|
||||||
android:process=":pushcore">
|
<!-- android:process=":pushcore">-->
|
||||||
<intent-filter>
|
<!-- <intent-filter>-->
|
||||||
<action android:name="cn.jiguang.user.service.action" />
|
<!-- <action android:name="cn.jiguang.user.service.action" />-->
|
||||||
</intent-filter>
|
<!-- </intent-filter>-->
|
||||||
</service>
|
<!-- </service>-->
|
||||||
<!-- User defined. For test only 用户自定义的广播接收器 -->
|
<!-- User defined. For test only 用户自定义的广播接收器 -->
|
||||||
|
<!-- <receiver-->
|
||||||
|
<!-- android:name=".jpush.MyReceiver"-->
|
||||||
|
<!-- android:enabled="true"-->
|
||||||
|
<!-- android:exported="false">-->
|
||||||
|
<!-- <intent-filter>-->
|
||||||
|
<!-- <action android:name="cn.jpush.android.intent.REGISTRATION" />-->
|
||||||
|
<!-- <!– Required 用户注册SDK的intent –>-->
|
||||||
|
<!-- <action android:name="cn.jpush.android.intent.MESSAGE_RECEIVED" />-->
|
||||||
|
<!-- <!– Required 用户接收SDK消息的intent –>-->
|
||||||
|
<!-- <action android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED" />-->
|
||||||
|
<!-- <!– Required 用户接收SDK通知栏信息的intent –>-->
|
||||||
|
<!-- <action android:name="cn.jpush.android.intent.NOTIFICATION_OPENED" />-->
|
||||||
|
<!-- <!– Required 用户打开自定义通知栏的intent –>-->
|
||||||
|
<!-- <action android:name="cn.jpush.android.intent.CONNECTION" />-->
|
||||||
|
<!-- <!– 接收网络变化 连接/断开 since 1.6.3 –>-->
|
||||||
|
<!-- <category android:name="com.aoleyun.sn" />-->
|
||||||
|
<!-- </intent-filter>-->
|
||||||
|
<!-- </receiver>-->
|
||||||
|
<!-- User defined. For test only 用户自定义接收消息器,3.0.7开始支持,目前新tag/alias接口设置结果会在该广播接收器对应的方法中回调 -->
|
||||||
|
<!-- <receiver android:name=".jpush.MyJPushMessageReceiver">-->
|
||||||
|
<!-- <intent-filter>-->
|
||||||
|
<!-- <action android:name="cn.jpush.android.intent.RECEIVE_MESSAGE" />-->
|
||||||
|
|
||||||
|
<!-- <category android:name="com.aoleyun.sn" />-->
|
||||||
|
<!-- </intent-filter>-->
|
||||||
|
<!-- </receiver>-->
|
||||||
|
|
||||||
|
<!-- <meta-data-->
|
||||||
|
<!-- android:name="JPUSH_CHANNEL"-->
|
||||||
|
<!-- android:value="developer-default" />-->
|
||||||
|
<!-- Required. AppKey copied from Portal -->
|
||||||
|
<!-- <meta-data-->
|
||||||
|
<!-- android:name="JPUSH_APPKEY"-->
|
||||||
|
<!-- android:value="${JPUSH_APPKEY}" />-->
|
||||||
|
<!-- <meta-data-->
|
||||||
|
<!-- android:name="CHANNEL_VALUE"-->
|
||||||
|
<!-- android:value="${channel_value}" />-->
|
||||||
|
|
||||||
|
<!-- 应用的其它配置 -->
|
||||||
|
<uses-library android:name="org.apache.http.legacy" android:required="false"/>
|
||||||
|
<!-- 【必须】 移动推送 TPNS 默认通知 -->
|
||||||
|
<activity android:name="com.tencent.android.tpush.TpnsActivity"
|
||||||
|
android:theme="@android:style/Theme.Translucent.NoTitleBar">
|
||||||
|
<intent-filter>
|
||||||
|
<data
|
||||||
|
android:scheme="tpns"
|
||||||
|
android:host="com.aoleyun.sn"/>
|
||||||
|
<action android:name="android.intent.action.VIEW" />
|
||||||
|
<category android:name="android.intent.category.BROWSABLE" />
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
|
||||||
|
<!-- 【必须】 移动推送 TPNS receiver广播接收 -->
|
||||||
<receiver
|
<receiver
|
||||||
android:name=".jpush.MyReceiver"
|
android:name="com.tencent.android.tpush.XGPushReceiver"
|
||||||
android:enabled="true"
|
android:process=":xg_vip_service">
|
||||||
|
<intent-filter android:priority="0x7fffffff">
|
||||||
|
<!-- 【必须】 移动推送 TPNS SDK的内部广播 -->
|
||||||
|
<action android:name="com.tencent.android.xg.vip.action.SDK" />
|
||||||
|
<action android:name="com.tencent.android.xg.vip.action.INTERNAL_PUSH_MESSAGE" />
|
||||||
|
<action android:name="com.tencent.android.xg.vip.action.ACTION_SDK_KEEPALIVE" />
|
||||||
|
<!-- 【可选】 系统广播:网络切换 -->
|
||||||
|
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
|
||||||
|
<!-- 【可选】 系统广播:开屏 -->
|
||||||
|
<action android:name="android.intent.action.USER_PRESENT" />
|
||||||
|
<!-- 【可选】 一些常用的系统广播,增强移动推送 TPNS service的复活机会,请根据需要选择。当然,您也可以添加App自定义的一些广播让启动service -->
|
||||||
|
<action android:name="android.bluetooth.adapter.action.STATE_CHANGED" />
|
||||||
|
<action android:name="android.intent.action.ACTION_POWER_CONNECTED" />
|
||||||
|
<action android:name="android.intent.action.ACTION_POWER_DISCONNECTED" />
|
||||||
|
</intent-filter>
|
||||||
|
</receiver>
|
||||||
|
|
||||||
|
<!-- 【必须】移动推送 TPNS service -->
|
||||||
|
<service
|
||||||
|
android:name="com.tencent.android.tpush.service.XGVipPushService"
|
||||||
|
android:persistent="true"
|
||||||
|
android:process=":xg_vip_service" />
|
||||||
|
|
||||||
|
<!-- 【必须】通知 service ,android:name 部分改为包名.XGVIP_PUSH_ACTION -->
|
||||||
|
<service android:name="com.tencent.android.tpush.rpc.XGRemoteService"
|
||||||
android:exported="false">
|
android:exported="false">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="cn.jpush.android.intent.REGISTRATION" />
|
<!-- 【必须】请修改为当前APP名包.XGVIP_PUSH_ACTION -->
|
||||||
<!-- Required 用户注册SDK的intent -->
|
<action android:name="com.aoleyun.sn.XGVIP_PUSH_ACTION" />
|
||||||
<action android:name="cn.jpush.android.intent.MESSAGE_RECEIVED" />
|
|
||||||
<!-- Required 用户接收SDK消息的intent -->
|
|
||||||
<action android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED" />
|
|
||||||
<!-- Required 用户接收SDK通知栏信息的intent -->
|
|
||||||
<action android:name="cn.jpush.android.intent.NOTIFICATION_OPENED" />
|
|
||||||
<!-- Required 用户打开自定义通知栏的intent -->
|
|
||||||
<action android:name="cn.jpush.android.intent.CONNECTION" />
|
|
||||||
<!-- 接收网络变化 连接/断开 since 1.6.3 -->
|
|
||||||
<category android:name="com.aoleyun.sn" />
|
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</receiver>
|
</service>
|
||||||
<!-- User defined. For test only 用户自定义接收消息器,3.0.7开始支持,目前新tag/alias接口设置结果会在该广播接收器对应的方法中回调 -->
|
|
||||||
<receiver android:name=".jpush.MyJPushMessageReceiver">
|
<!-- 【必须】【注意】authorities 修改为包名.XGVIP_PUSH_AUTH -->
|
||||||
|
<provider
|
||||||
|
android:name="com.tencent.android.tpush.XGPushProvider"
|
||||||
|
android:authorities="com.aoleyun.sn.XGVIP_PUSH_AUTH" />
|
||||||
|
|
||||||
|
<!-- 【必须】【注意】authorities 修改为包名.TPUSH_PROVIDER -->
|
||||||
|
<provider
|
||||||
|
android:name="com.tencent.android.tpush.SettingsContentProvider"
|
||||||
|
android:authorities="com.aoleyun.sn.TPUSH_PROVIDER" />
|
||||||
|
|
||||||
|
<!-- 【可选】用于增强保活能力 -->
|
||||||
|
<provider
|
||||||
|
android:name="com.tencent.android.tpush.XGVipPushKAProvider"
|
||||||
|
android:authorities="com.aoleyun.sn.AUTH_XGPUSH_KEEPALIVE"
|
||||||
|
android:exported="true"
|
||||||
|
tools:replace="android:exported" />
|
||||||
|
|
||||||
|
<!-- 【可选】APP实现的Receiver,用于接收消息透传和操作结果的回调,请根据需要添加 -->
|
||||||
|
<!-- YOUR_PACKAGE_PATH.CustomPushReceiver需要改为自己的Receiver: -->
|
||||||
|
<receiver android:name="com.aoleyun.sn.tpush.MessageReceiver">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="cn.jpush.android.intent.RECEIVE_MESSAGE" />
|
<!-- 接收消息透传 -->
|
||||||
|
<action android:name="com.tencent.android.xg.vip.action.PUSH_MESSAGE" />
|
||||||
<category android:name="com.aoleyun.sn" />
|
<!-- 监听注册、反注册、设置/删除标签、通知被点击等处理结果 -->
|
||||||
|
<action android:name="com.tencent.android.xg.vip.action.FEEDBACK" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</receiver>
|
</receiver>
|
||||||
|
|
||||||
|
<!-- MQTT START -->
|
||||||
|
<service android:exported="false"
|
||||||
|
android:process=":xg_vip_service"
|
||||||
|
android:name="com.tencent.tpns.mqttchannel.services.MqttService" />
|
||||||
|
|
||||||
|
<provider
|
||||||
|
android:exported="false"
|
||||||
|
android:name="com.tencent.tpns.baseapi.base.SettingsContentProvider"
|
||||||
|
android:authorities="com.aoleyun.sn.XG_SETTINGS_PROVIDER" />
|
||||||
|
|
||||||
|
<!-- MQTT END-->
|
||||||
|
|
||||||
|
<!-- 【必须】 请修改为 APP 的 AccessId,“15”开头的10位数字,中间没空格 -->
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="JPUSH_CHANNEL"
|
android:name="XG_V2_ACCESS_ID"
|
||||||
android:value="developer-default" />
|
android:value="1500026372" />
|
||||||
<!-- Required. AppKey copied from Portal -->
|
<!-- 【必须】 请修改为APP的AccessKey,“A”开头的12位字符串,中间没空格 -->
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="JPUSH_APPKEY"
|
android:name="XG_V2_ACCESS_KEY"
|
||||||
android:value="${JPUSH_APPKEY}" />
|
android:value="AR7A1L5M0LPH" />
|
||||||
|
|
||||||
<!-- 高德地图 -->
|
<!-- 高德地图 -->
|
||||||
<!-- 设置key -->
|
<!-- 设置key -->
|
||||||
<meta-data
|
<meta-data
|
||||||
@@ -418,10 +546,6 @@
|
|||||||
<service
|
<service
|
||||||
android:name="com.amap.api.location.APSService"
|
android:name="com.amap.api.location.APSService"
|
||||||
android:foregroundServiceType="location" />
|
android:foregroundServiceType="location" />
|
||||||
|
|
||||||
<meta-data
|
|
||||||
android:name="CHANNEL_VALUE"
|
|
||||||
android:value="${channel_value}" />
|
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="com.aoleyun.sn.base.CustomGlideModule"
|
android:name="com.aoleyun.sn.base.CustomGlideModule"
|
||||||
android:value="AppGlideModule" />
|
android:value="AppGlideModule" />
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ import android.widget.Button;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.aoleyun.sn.R;
|
import com.aoleyun.sn.R;
|
||||||
|
import com.aoleyun.sn.activity.main.MainContact;
|
||||||
|
import com.aoleyun.sn.activity.main.MainPresenter;
|
||||||
import com.aoleyun.sn.base.BaseActivity;
|
import com.aoleyun.sn.base.BaseActivity;
|
||||||
import com.aoleyun.sn.service.MainService;
|
import com.aoleyun.sn.service.MainService;
|
||||||
import com.aoleyun.sn.utils.ApkUtils;
|
import com.aoleyun.sn.utils.ApkUtils;
|
||||||
@@ -33,7 +35,6 @@ import com.google.gson.JsonObject;
|
|||||||
|
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
import cn.jpush.android.api.JPushInterface;
|
|
||||||
import pl.droidsonroids.gif.GifImageView;
|
import pl.droidsonroids.gif.GifImageView;
|
||||||
|
|
||||||
public class CheckNetActivity extends BaseActivity implements MainContact.MainView, NetworkUtils.OnNetworkStatusChangedListener {
|
public class CheckNetActivity extends BaseActivity implements MainContact.MainView, NetworkUtils.OnNetworkStatusChangedListener {
|
||||||
@@ -69,12 +70,12 @@ public class CheckNetActivity extends BaseActivity implements MainContact.MainVi
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisconnected() {
|
public void onDisconnected() {
|
||||||
Log.e("OnNetworkStatusChangedListener", "onDisconnected: ");
|
Log.e("OnNetworkStatusChanged", "onDisconnected: ");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConnected(NetworkUtils.NetworkType networkType) {
|
public void onConnected(NetworkUtils.NetworkType networkType) {
|
||||||
Log.e("OnNetworkStatusChangedListener", "onConnected: ");
|
Log.e("OnNetworkStatusChanged", "onConnected: ");
|
||||||
timeMillis = SystemClock.elapsedRealtime();
|
timeMillis = SystemClock.elapsedRealtime();
|
||||||
//直接获取数据
|
//直接获取数据
|
||||||
mPresenter.getLockedState();
|
mPresenter.getLockedState();
|
||||||
@@ -167,7 +168,7 @@ public class CheckNetActivity extends BaseActivity implements MainContact.MainVi
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initData() {
|
public void initData() {
|
||||||
JPushInterface.init(this);
|
// JPushInterface.init(this);
|
||||||
registerMessageReceiver();
|
registerMessageReceiver();
|
||||||
Log.e("getMacAddress", Utils.getAndroid10MAC(this));
|
Log.e("getMacAddress", Utils.getAndroid10MAC(this));
|
||||||
timeMillis = SystemClock.elapsedRealtime();
|
timeMillis = SystemClock.elapsedRealtime();
|
||||||
@@ -219,7 +220,7 @@ public class CheckNetActivity extends BaseActivity implements MainContact.MainVi
|
|||||||
}
|
}
|
||||||
SaveListUtils.getList();
|
SaveListUtils.getList();
|
||||||
//获取系统管控
|
//获取系统管控
|
||||||
mPresenter.setJpushTags();
|
mPresenter.setPushTags();
|
||||||
netWorkIsRunning = true;
|
netWorkIsRunning = true;
|
||||||
} else {
|
} else {
|
||||||
netWorkIsRunning = false;
|
netWorkIsRunning = false;
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import android.os.Build;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.PowerManager;
|
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@@ -25,6 +24,7 @@ import androidx.core.content.ContextCompat;
|
|||||||
import com.aoleyun.sn.BuildConfig;
|
import com.aoleyun.sn.BuildConfig;
|
||||||
import com.aoleyun.sn.R;
|
import com.aoleyun.sn.R;
|
||||||
import com.aoleyun.sn.action.JGYActions;
|
import com.aoleyun.sn.action.JGYActions;
|
||||||
|
import com.aoleyun.sn.activity.main.MainActivity;
|
||||||
import com.aoleyun.sn.base.BaseApplication;
|
import com.aoleyun.sn.base.BaseApplication;
|
||||||
import com.aoleyun.sn.comm.PackageNames;
|
import com.aoleyun.sn.comm.PackageNames;
|
||||||
import com.aoleyun.sn.service.LogcatService;
|
import com.aoleyun.sn.service.LogcatService;
|
||||||
@@ -42,7 +42,6 @@ import java.nio.file.Files;
|
|||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
|
|
||||||
import cn.jpush.android.api.JPushInterface;
|
|
||||||
|
|
||||||
|
|
||||||
public class SplashActivity extends AppCompatActivity {
|
public class SplashActivity extends AppCompatActivity {
|
||||||
@@ -131,7 +130,7 @@ public class SplashActivity extends AppCompatActivity {
|
|||||||
// Log.i(TAG, "debugTest: iptables = " + CmdUtil.execute("iptables -L -n" ).toString());
|
// Log.i(TAG, "debugTest: iptables = " + CmdUtil.execute("iptables -L -n" ).toString());
|
||||||
|
|
||||||
Log.i(TAG, "debugTest: " + Utils.getAndroid10MAC(this));
|
Log.i(TAG, "debugTest: " + Utils.getAndroid10MAC(this));
|
||||||
Log.i(TAG, "debugTest: " + JPushInterface.getRegistrationID(this));
|
// Log.i(TAG, "debugTest: " + JPushInterface.getRegistrationID(this));
|
||||||
Log.i(TAG, "debugTest: " + Utils.getCustomVersion());
|
Log.i(TAG, "debugTest: " + Utils.getCustomVersion());
|
||||||
Log.i(TAG, "debugTest: " + BuildConfig.VERSION_NAME);
|
Log.i(TAG, "debugTest: " + BuildConfig.VERSION_NAME);
|
||||||
Log.i(TAG, "debugTest: " + Utils.getAPPVersionName(PackageNames.APPSTORE, this));
|
Log.i(TAG, "debugTest: " + Utils.getAPPVersionName(PackageNames.APPSTORE, this));
|
||||||
@@ -145,8 +144,8 @@ public class SplashActivity extends AppCompatActivity {
|
|||||||
// }
|
// }
|
||||||
// ActivityManager mAm = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
|
// ActivityManager mAm = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
|
||||||
// mAm.killBackgroundProcesses("com.android.documentsui");
|
// mAm.killBackgroundProcesses("com.android.documentsui");
|
||||||
BaseApplication.cleanJpushAlias();
|
// BaseApplication.cleanJpushAlias();
|
||||||
BaseApplication.cleanJpushTag();
|
// BaseApplication.cleanJpushTag();
|
||||||
Log.e(TAG, "debugTest: SPUtils all " + SPUtils.getAll(this));
|
Log.e(TAG, "debugTest: SPUtils all " + SPUtils.getAll(this));
|
||||||
try {
|
try {
|
||||||
PackageManager packageManager = getPackageManager();
|
PackageManager packageManager = getPackageManager();
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.aoleyun.sn.activity;
|
package com.aoleyun.sn.activity.main;
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
@@ -33,13 +33,13 @@ import com.aoleyun.sn.utils.SaveListUtils;
|
|||||||
import com.aoleyun.sn.utils.SysSettingUtils;
|
import com.aoleyun.sn.utils.SysSettingUtils;
|
||||||
import com.aoleyun.sn.utils.ToastUtil;
|
import com.aoleyun.sn.utils.ToastUtil;
|
||||||
import com.aoleyun.sn.utils.Utils;
|
import com.aoleyun.sn.utils.Utils;
|
||||||
|
import com.tencent.mmkv.MMKV;
|
||||||
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
import butterknife.OnClick;
|
import butterknife.OnClick;
|
||||||
import cn.jpush.android.api.JPushInterface;
|
|
||||||
import io.reactivex.Observable;
|
import io.reactivex.Observable;
|
||||||
import io.reactivex.ObservableEmitter;
|
import io.reactivex.ObservableEmitter;
|
||||||
import io.reactivex.ObservableOnSubscribe;
|
import io.reactivex.ObservableOnSubscribe;
|
||||||
@@ -171,7 +171,7 @@ public class MainActivity extends BaseActivity implements MainContact.MainView,
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initData() {
|
public void initData() {
|
||||||
JPushInterface.init(this);
|
// JPushInterface.init(this);
|
||||||
registerMessageReceiver();
|
registerMessageReceiver();
|
||||||
Log.e("getMacAddress", Utils.getAndroid10MAC(this));
|
Log.e("getMacAddress", Utils.getAndroid10MAC(this));
|
||||||
timeMillis = SystemClock.elapsedRealtime();
|
timeMillis = SystemClock.elapsedRealtime();
|
||||||
@@ -229,7 +229,7 @@ public class MainActivity extends BaseActivity implements MainContact.MainView,
|
|||||||
//设置极光推送别名
|
//设置极光推送别名
|
||||||
mPresenter.setJpushAlias();
|
mPresenter.setJpushAlias();
|
||||||
//设置极光推送标签
|
//设置极光推送标签
|
||||||
mPresenter.setJpushTags();
|
mPresenter.setPushTags();
|
||||||
Log.e(TAG, "netWorkIsRunning: " + netWorkIsRunning);
|
Log.e(TAG, "netWorkIsRunning: " + netWorkIsRunning);
|
||||||
Log.e(TAG, "MainService.netWorkIsRunning: " + MainService.netWorkIsRunning);
|
Log.e(TAG, "MainService.netWorkIsRunning: " + MainService.netWorkIsRunning);
|
||||||
if (loocked) {
|
if (loocked) {
|
||||||
@@ -461,8 +461,6 @@ public class MainActivity extends BaseActivity implements MainContact.MainView,
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void getDefaultDesktopFinish() {
|
public void getDefaultDesktopFinish() {
|
||||||
netWorkIsRunning = false;
|
|
||||||
Log.e(TAG, "SettingFinished: " + (SystemClock.elapsedRealtime() - timeMillis) + " ms");
|
|
||||||
mPresenter.getPoweroffTime();
|
mPresenter.getPoweroffTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -473,7 +471,9 @@ public class MainActivity extends BaseActivity implements MainContact.MainView,
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setWiFiPasswd() {
|
public void setWiFiPasswd() {
|
||||||
|
MMKV.defaultMMKV().encode(MainPresenter.GET_SETTING_FINISH_TIME, System.currentTimeMillis());
|
||||||
|
netWorkIsRunning = false;
|
||||||
|
Log.e(TAG, "SettingFinished: " + (SystemClock.elapsedRealtime() - timeMillis) + " ms");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -595,12 +595,12 @@ public class MainActivity extends BaseActivity implements MainContact.MainView,
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisconnected() {
|
public void onDisconnected() {
|
||||||
Log.e("OnNetworkStatusChangedListener", "onDisconnected: ");
|
Log.e("OnNetworkStatusChanged", "onDisconnected: ");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConnected(NetworkUtils.NetworkType networkType) {
|
public void onConnected(NetworkUtils.NetworkType networkType) {
|
||||||
Log.e("OnNetworkStatusChangedListener", "onConnected: ");
|
Log.e("OnNetworkStatusChanged", "onConnected: ");
|
||||||
timeMillis = SystemClock.elapsedRealtime();
|
timeMillis = SystemClock.elapsedRealtime();
|
||||||
//直接获取数据
|
//直接获取数据
|
||||||
mPresenter.getLockedState();
|
mPresenter.getLockedState();
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.aoleyun.sn.activity;
|
package com.aoleyun.sn.activity.main;
|
||||||
|
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@@ -47,7 +47,7 @@ public class MainContact {
|
|||||||
void checkTestUpdate();
|
void checkTestUpdate();
|
||||||
//开始
|
//开始
|
||||||
//设置极光推送标签
|
//设置极光推送标签
|
||||||
void setJpushTags();
|
void setPushTags();
|
||||||
//获取开发者选项
|
//获取开发者选项
|
||||||
void getDeveloper();
|
void getDeveloper();
|
||||||
//获取设备后台设置
|
//获取设备后台设置
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.aoleyun.sn.activity;
|
package com.aoleyun.sn.activity.main;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@@ -32,7 +32,6 @@ import com.aoleyun.sn.bean.ForceDownloadData;
|
|||||||
import com.aoleyun.sn.bean.LogoImg;
|
import com.aoleyun.sn.bean.LogoImg;
|
||||||
import com.aoleyun.sn.bean.NetAndLaunchBean;
|
import com.aoleyun.sn.bean.NetAndLaunchBean;
|
||||||
import com.aoleyun.sn.bean.StudentsInfo;
|
import com.aoleyun.sn.bean.StudentsInfo;
|
||||||
import com.aoleyun.sn.jpush.TagAliasOperatorHelper;
|
|
||||||
import com.aoleyun.sn.network.NetInterfaceManager;
|
import com.aoleyun.sn.network.NetInterfaceManager;
|
||||||
import com.aoleyun.sn.network.HTTPInterface;
|
import com.aoleyun.sn.network.HTTPInterface;
|
||||||
import com.aoleyun.sn.service.MainService;
|
import com.aoleyun.sn.service.MainService;
|
||||||
@@ -46,6 +45,8 @@ import com.aoleyun.sn.utils.TimeUtils;
|
|||||||
import com.aoleyun.sn.utils.ToastUtil;
|
import com.aoleyun.sn.utils.ToastUtil;
|
||||||
import com.aoleyun.sn.utils.URLUtils;
|
import com.aoleyun.sn.utils.URLUtils;
|
||||||
import com.aoleyun.sn.utils.Utils;
|
import com.aoleyun.sn.utils.Utils;
|
||||||
|
import com.tencent.android.tpush.XGIOperateCallback;
|
||||||
|
import com.tencent.android.tpush.XGPushManager;
|
||||||
import com.tencent.mmkv.MMKV;
|
import com.tencent.mmkv.MMKV;
|
||||||
import com.trello.rxlifecycle2.LifecycleProvider;
|
import com.trello.rxlifecycle2.LifecycleProvider;
|
||||||
import com.trello.rxlifecycle2.android.ActivityEvent;
|
import com.trello.rxlifecycle2.android.ActivityEvent;
|
||||||
@@ -55,10 +56,8 @@ import java.lang.reflect.Type;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import cn.jpush.android.api.JPushInterface;
|
|
||||||
import io.reactivex.Observer;
|
import io.reactivex.Observer;
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
import io.reactivex.annotations.NonNull;
|
import io.reactivex.annotations.NonNull;
|
||||||
@@ -66,8 +65,8 @@ import io.reactivex.disposables.Disposable;
|
|||||||
import io.reactivex.schedulers.Schedulers;
|
import io.reactivex.schedulers.Schedulers;
|
||||||
import okhttp3.ResponseBody;
|
import okhttp3.ResponseBody;
|
||||||
|
|
||||||
import static com.aoleyun.sn.jpush.TagAliasOperatorHelper.ACTION_SET;
|
//import static com.aoleyun.sn.jpush.TagAliasOperatorHelper.ACTION_SET;
|
||||||
import static com.aoleyun.sn.jpush.TagAliasOperatorHelper.sequence;
|
//import static com.aoleyun.sn.jpush.TagAliasOperatorHelper.sequence;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MainActivity和MainService 的 Presenter
|
* MainActivity和MainService 的 Presenter
|
||||||
@@ -79,6 +78,8 @@ public class MainPresenter implements MainContact.Presenter {
|
|||||||
private MainContact.MainView mView;
|
private MainContact.MainView mView;
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
|
|
||||||
|
public static final String GET_SETTING_FINISH_TIME = "GET_SETTING_FINISH_TIME";
|
||||||
|
|
||||||
//是否有接口请求成功
|
//是否有接口请求成功
|
||||||
public boolean requestSucceeded = false;
|
public boolean requestSucceeded = false;
|
||||||
private final String DEFAULT_INFO = "暂无信息";
|
private final String DEFAULT_INFO = "暂无信息";
|
||||||
@@ -260,12 +261,18 @@ public class MainPresenter implements MainContact.Presenter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private long lastgetLockedTime;
|
private long lastgetLockedTime;
|
||||||
|
private long one_minute = 1000 * 60;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void getLockedState() {
|
public void getLockedState() {
|
||||||
// if (System.currentTimeMillis() - lastgetLockedTime < 600 * 1000) {
|
MMKV mmkv = MMKV.defaultMMKV();
|
||||||
// return;
|
lastgetLockedTime = mmkv.decodeLong(MainPresenter.GET_SETTING_FINISH_TIME);
|
||||||
// }
|
Log.e(TAG, "getLockedState: " + lastgetLockedTime);
|
||||||
|
if (System.currentTimeMillis() - lastgetLockedTime < one_minute) {
|
||||||
|
Log.e(TAG, "getLockedState: lastgetLockedTime = " + lastgetLockedTime);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// lastgetLockedTime = System.currentTimeMillis();
|
// lastgetLockedTime = System.currentTimeMillis();
|
||||||
NetInterfaceManager.getInstance()
|
NetInterfaceManager.getInstance()
|
||||||
.getDevicesLockedStateObservable()
|
.getDevicesLockedStateObservable()
|
||||||
@@ -553,34 +560,34 @@ public class MainPresenter implements MainContact.Presenter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setJpushAlias() {
|
public void setJpushAlias() {
|
||||||
JPushInterface.init(mContext);
|
// JPushInterface.init(mContext);
|
||||||
SetAlias();
|
// SetAlias();
|
||||||
String rid = JPushInterface.getRegistrationID(mContext);
|
// String rid = JPushInterface.getRegistrationID(mContext);
|
||||||
if (!TextUtils.isEmpty(rid)) {
|
// if (!TextUtils.isEmpty(rid)) {
|
||||||
Log.e(TAG + ":" + "setJpushAlias", "RegId:" + rid);
|
// Log.e(TAG + ":" + "setJpushAlias", "RegId:" + rid);
|
||||||
}
|
// }
|
||||||
JPushInterface.getAlias(mContext, new Random().nextInt(100));
|
// JPushInterface.getAlias(mContext, new Random().nextInt(100));
|
||||||
mView.setAliasFinish();
|
mView.setAliasFinish();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetAlias() {
|
// private void SetAlias() {
|
||||||
TagAliasOperatorHelper.TagAliasBean tagAliasBean = new TagAliasOperatorHelper.TagAliasBean();
|
// TagAliasOperatorHelper.TagAliasBean tagAliasBean = new TagAliasOperatorHelper.TagAliasBean();
|
||||||
tagAliasBean.action = ACTION_SET;
|
// tagAliasBean.action = ACTION_SET;
|
||||||
sequence++;
|
// sequence++;
|
||||||
tagAliasBean.alias = Utils.getSerial();
|
// tagAliasBean.alias = Utils.getSerial();
|
||||||
tagAliasBean.isAliasAction = true;
|
// tagAliasBean.isAliasAction = true;
|
||||||
TagAliasOperatorHelper.getInstance().handleAction(mContext, sequence, tagAliasBean);
|
// TagAliasOperatorHelper.getInstance().handleAction(mContext, sequence, tagAliasBean);
|
||||||
}
|
// }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setJpushTags() {
|
public void setPushTags() {
|
||||||
NetInterfaceManager.getInstance()
|
NetInterfaceManager.getInstance()
|
||||||
.getJpushTagsObservable()
|
.getJpushTagsObservable()
|
||||||
.compose(getProvider().bindUntilEvent(ActivityEvent.DESTROY))
|
.compose(getProvider().bindUntilEvent(ActivityEvent.DESTROY))
|
||||||
.subscribe(new Observer<BaseResponse>() {
|
.subscribe(new Observer<BaseResponse>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSubscribe(@NonNull Disposable d) {
|
public void onSubscribe(@NonNull Disposable d) {
|
||||||
Log.e(TAG + ":" + "setJpushTags", "onSubscribe: ");
|
Log.e(TAG + ":" + "setPushTags", "onSubscribe: ");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -589,7 +596,7 @@ public class MainPresenter implements MainContact.Presenter {
|
|||||||
if (response.code == OK) {
|
if (response.code == OK) {
|
||||||
JsonObject jsonObject = JsonParser.parseString(new Gson().toJson(response.data)).getAsJsonObject();
|
JsonObject jsonObject = JsonParser.parseString(new Gson().toJson(response.data)).getAsJsonObject();
|
||||||
String batch = jsonObject.get("batch").getAsString();
|
String batch = jsonObject.get("batch").getAsString();
|
||||||
Log.e(TAG + ":" + "setJpushTags", "onNext: " + batch);
|
Log.e(TAG + ":" + "setPushTags", "onNext: " + batch);
|
||||||
if (!TextUtils.isEmpty(batch)) {
|
if (!TextUtils.isEmpty(batch)) {
|
||||||
mView.setTagsFinish(false);
|
mView.setTagsFinish(false);
|
||||||
Set set = new HashSet();
|
Set set = new HashSet();
|
||||||
@@ -604,27 +611,39 @@ public class MainPresenter implements MainContact.Presenter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
setTag(set);
|
Set<String> tagsSet = new HashSet<>(set);
|
||||||
|
XGPushManager.clearAndAppendTags(mContext, "clearAndAppendTags :" + System.currentTimeMillis(), tagsSet, new XGIOperateCallback() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(Object o, int i) {
|
||||||
|
Log.e("setPushTags", "onSuccess: " + o);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFail(Object o, int i, String s) {
|
||||||
|
Log.e("setPushTags", "onFail: " + o);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// setTag(set);
|
||||||
} else {
|
} else {
|
||||||
mView.setTagsFinish(true);
|
mView.setTagsFinish(true);
|
||||||
Log.e(TAG + ":" + "setJpushTags", "onNext: " + "batch empty");
|
Log.e(TAG + ":" + "setPushTags", "onNext: " + "batch empty");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mView.setTagsFinish(true);
|
mView.setTagsFinish(true);
|
||||||
Log.e(TAG + ":" + "setJpushTags", "onNext: " + response.toString());
|
Log.e(TAG + ":" + "setPushTags", "onNext: " + response.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(@NonNull Throwable e) {
|
public void onError(@NonNull Throwable e) {
|
||||||
Log.e(TAG + ":" + "setJpushTags", "onError: " + e.getMessage());
|
Log.e(TAG + ":" + "setPushTags", "onError: " + e.getMessage());
|
||||||
mView.setTagsFinish(true);
|
mView.setTagsFinish(true);
|
||||||
onComplete();
|
onComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onComplete() {
|
public void onComplete() {
|
||||||
Log.e(TAG + ":" + "setJpushTags", "onComplete: ");
|
Log.e(TAG + ":" + "setPushTags", "onComplete: ");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -634,14 +653,14 @@ public class MainPresenter implements MainContact.Presenter {
|
|||||||
mView.setJpushPlatformTagsFinish();
|
mView.setJpushPlatformTagsFinish();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setTag(Set set) {
|
// private void setTag(Set set) {
|
||||||
TagAliasOperatorHelper.TagAliasBean tagAliasBean = new TagAliasOperatorHelper.TagAliasBean();
|
// TagAliasOperatorHelper.TagAliasBean tagAliasBean = new TagAliasOperatorHelper.TagAliasBean();
|
||||||
tagAliasBean.action = ACTION_SET;
|
// tagAliasBean.action = ACTION_SET;
|
||||||
sequence++;
|
// sequence++;
|
||||||
tagAliasBean.tags = set;
|
// tagAliasBean.tags = set;
|
||||||
tagAliasBean.isAliasAction = false;
|
// tagAliasBean.isAliasAction = false;
|
||||||
TagAliasOperatorHelper.getInstance().handleAction(mContext, sequence, tagAliasBean);
|
// TagAliasOperatorHelper.getInstance().handleAction(mContext, sequence, tagAliasBean);
|
||||||
}
|
// }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void checkStoreUpdate() {
|
public void checkStoreUpdate() {
|
||||||
@@ -2043,6 +2062,7 @@ public class MainPresenter implements MainContact.Presenter {
|
|||||||
public void getPoweroffTime() {
|
public void getPoweroffTime() {
|
||||||
NetInterfaceManager.getInstance()
|
NetInterfaceManager.getInstance()
|
||||||
.getPoweroffTimeControl()
|
.getPoweroffTimeControl()
|
||||||
|
.compose(getProvider().bindUntilEvent(ActivityEvent.DESTROY))
|
||||||
.subscribe(new Observer<BaseResponse<List<PoweroffBean>>>() {
|
.subscribe(new Observer<BaseResponse<List<PoweroffBean>>>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSubscribe(Disposable d) {
|
public void onSubscribe(Disposable d) {
|
||||||
@@ -2079,6 +2099,7 @@ public class MainPresenter implements MainContact.Presenter {
|
|||||||
@Override
|
@Override
|
||||||
public void getWiFiPasswd() {
|
public void getWiFiPasswd() {
|
||||||
NetInterfaceManager.getInstance().getWiFiControl()
|
NetInterfaceManager.getInstance().getWiFiControl()
|
||||||
|
.compose(getProvider().bindUntilEvent(ActivityEvent.DESTROY))
|
||||||
.subscribe(new Observer<BaseResponse<List<WiFiAlias>>>() {
|
.subscribe(new Observer<BaseResponse<List<WiFiAlias>>>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSubscribe(Disposable d) {
|
public void onSubscribe(Disposable d) {
|
||||||
@@ -2101,11 +2122,13 @@ public class MainPresenter implements MainContact.Presenter {
|
|||||||
@Override
|
@Override
|
||||||
public void onError(Throwable e) {
|
public void onError(Throwable e) {
|
||||||
Log.e("getWiFiPasswd", "onError: " + e.getMessage());
|
Log.e("getWiFiPasswd", "onError: " + e.getMessage());
|
||||||
|
onComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onComplete() {
|
public void onComplete() {
|
||||||
Log.e("getWiFiPasswd", "onComplete: ");
|
Log.e("getWiFiPasswd", "onComplete: ");
|
||||||
|
mView.setWiFiPasswd();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -16,7 +16,6 @@ import com.aoleyun.sn.utils.WiFiUtils;
|
|||||||
import com.arialyy.aria.core.Aria;
|
import com.arialyy.aria.core.Aria;
|
||||||
import com.arialyy.aria.core.download.DownloadEntity;
|
import com.arialyy.aria.core.download.DownloadEntity;
|
||||||
import com.aoleyun.sn.BuildConfig;
|
import com.aoleyun.sn.BuildConfig;
|
||||||
import com.aoleyun.sn.jpush.TagAliasOperatorHelper;
|
|
||||||
import com.aoleyun.sn.manager.AmapManager;
|
import com.aoleyun.sn.manager.AmapManager;
|
||||||
import com.aoleyun.sn.manager.FileManager;
|
import com.aoleyun.sn.manager.FileManager;
|
||||||
import com.aoleyun.sn.network.NetInterfaceManager;
|
import com.aoleyun.sn.network.NetInterfaceManager;
|
||||||
@@ -30,6 +29,9 @@ import com.aoleyun.sn.utils.SystemUtils;
|
|||||||
import com.aoleyun.sn.utils.ToastUtil;
|
import com.aoleyun.sn.utils.ToastUtil;
|
||||||
import com.aoleyun.sn.utils.Utils;
|
import com.aoleyun.sn.utils.Utils;
|
||||||
import com.aoleyun.sn.utils.XAPKUtils;
|
import com.aoleyun.sn.utils.XAPKUtils;
|
||||||
|
import com.tencent.android.tpush.XGIOperateCallback;
|
||||||
|
import com.tencent.android.tpush.XGPushConfig;
|
||||||
|
import com.tencent.android.tpush.XGPushManager;
|
||||||
import com.tencent.mmkv.MMKV;
|
import com.tencent.mmkv.MMKV;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@@ -39,8 +41,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import cn.jpush.android.api.JPushInterface;
|
|
||||||
import cn.jpush.android.api.JPushMessage;
|
|
||||||
import io.reactivex.Observable;
|
import io.reactivex.Observable;
|
||||||
import io.reactivex.ObservableEmitter;
|
import io.reactivex.ObservableEmitter;
|
||||||
import io.reactivex.ObservableOnSubscribe;
|
import io.reactivex.ObservableOnSubscribe;
|
||||||
@@ -87,6 +87,8 @@ public class BaseApplication extends MultiDexApplication {
|
|||||||
private void init() {
|
private void init() {
|
||||||
String rootDir = MMKV.initialize(this);
|
String rootDir = MMKV.initialize(this);
|
||||||
Log.e(TAG, "mmkv root: " + rootDir);
|
Log.e(TAG, "mmkv root: " + rootDir);
|
||||||
|
|
||||||
|
tPushInit();
|
||||||
ToastUtil.init(this);
|
ToastUtil.init(this);
|
||||||
NetInterfaceManager.init(this);
|
NetInterfaceManager.init(this);
|
||||||
JGYUtils.init(this);
|
JGYUtils.init(this);
|
||||||
@@ -99,8 +101,8 @@ public class BaseApplication extends MultiDexApplication {
|
|||||||
JGYUtils.getInstance().hookWebView();
|
JGYUtils.getInstance().hookWebView();
|
||||||
|
|
||||||
// 设置开启日志,发布时请关闭日志
|
// 设置开启日志,发布时请关闭日志
|
||||||
JPushInterface.setDebugMode(true);
|
// JPushInterface.setDebugMode(true);
|
||||||
JPushInterface.requestPermission(this);
|
// JPushInterface.requestPermission(this);
|
||||||
//解锁设备不需要初始化
|
//解锁设备不需要初始化
|
||||||
// 初始化 JPush
|
// 初始化 JPush
|
||||||
//JPushInterface.init(this);
|
//JPushInterface.init(this);
|
||||||
@@ -150,6 +152,37 @@ public class BaseApplication extends MultiDexApplication {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void tPushInit() {
|
||||||
|
XGPushConfig.enableDebug(this, true);
|
||||||
|
XGPushManager.registerPush(this, new XGIOperateCallback() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(Object data, int flag) {
|
||||||
|
//token在设备卸载重装的时候有可能会变
|
||||||
|
Log.e("TPush", "注册成功,设备token为:" + data);
|
||||||
|
List<XGPushManager.AccountInfo> accountInfoList = new ArrayList<>();
|
||||||
|
accountInfoList.add(new XGPushManager.AccountInfo(XGPushManager.AccountType.CUSTOM.getValue(), Utils.getSerial()));
|
||||||
|
XGPushManager.upsertAccounts(getAppContext(), accountInfoList, new XGIOperateCallback() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(Object data, int flag) {
|
||||||
|
Log.e("TPush", "onSuccess, data:" + data + ", flag:" + flag);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFail(Object data, int errCode, String msg) {
|
||||||
|
Log.e("TPush", "onFail, data:" + data + ", code:" + errCode + ", msg:" + msg);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFail(Object data, int errCode, String msg) {
|
||||||
|
Log.e("TPush", "注册失败,错误码:" + errCode + ",错误信息:" + msg);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private static void initAliasObservable() {
|
private static void initAliasObservable() {
|
||||||
Log.e(TAG, "initAliasObservable: ");
|
Log.e(TAG, "initAliasObservable: ");
|
||||||
Observable.create(new ObservableOnSubscribe<Integer>() {
|
Observable.create(new ObservableOnSubscribe<Integer>() {
|
||||||
@@ -232,17 +265,17 @@ public class BaseApplication extends MultiDexApplication {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onAliasOperatorResult(JPushMessage jPushMessage) {
|
// public void onAliasOperatorResult(JPushMessage jPushMessage) {
|
||||||
if (jPushMessage == null) {
|
// if (jPushMessage == null) {
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
int errorCode = jPushMessage.getErrorCode();
|
// int errorCode = jPushMessage.getErrorCode();
|
||||||
onAliasResult.onResult(errorCode);
|
// onAliasResult.onResult(errorCode);
|
||||||
}
|
// }
|
||||||
|
|
||||||
public static void setJpushAlias() {
|
public static void setJpushAlias() {
|
||||||
Log.e("jiguangInterface", "30s后重新设置alias");
|
Log.e("jiguangInterface", "30s后重新设置alias");
|
||||||
JPushInterface.setAlias(context, TagAliasOperatorHelper.sequence++, Utils.getSerial());
|
// JPushInterface.setAlias(context, TagAliasOperatorHelper.sequence++, Utils.getSerial());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void initTagObservable() {
|
private static void initTagObservable() {
|
||||||
@@ -341,17 +374,17 @@ public class BaseApplication extends MultiDexApplication {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onTagOperatorResult(JPushMessage jPushMessage) {
|
// public void onTagOperatorResult(JPushMessage jPushMessage) {
|
||||||
if (jPushMessage == null) {
|
// if (jPushMessage == null) {
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
int errorCode = jPushMessage.getErrorCode();
|
// int errorCode = jPushMessage.getErrorCode();
|
||||||
onTagResult.onResult(errorCode);
|
// onTagResult.onResult(errorCode);
|
||||||
}
|
// }
|
||||||
|
|
||||||
public static void setJpushTags() {
|
public static void setJpushTags() {
|
||||||
Log.e(TAG, "30s后重新设置tags");
|
Log.e(TAG, "30s后重新设置tags");
|
||||||
HTTPInterface.setJpushTags(context);
|
HTTPInterface.setPushTags(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static OnAliasResult onAliasResult;
|
private static OnAliasResult onAliasResult;
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ import android.text.TextUtils;
|
|||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import cn.jpush.android.api.JPushInterface;
|
|
||||||
|
|
||||||
public class ExampleUtil {
|
public class ExampleUtil {
|
||||||
public static final String PREFS_NAME = "JPUSH_EXAMPLE";
|
public static final String PREFS_NAME = "JPUSH_EXAMPLE";
|
||||||
@@ -126,7 +125,7 @@ public class ExampleUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getDeviceId(Context context) {
|
// public static String getDeviceId(Context context) {
|
||||||
return JPushInterface.getUdid(context);
|
// return JPushInterface.getUdid(context);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,43 +4,40 @@ import android.content.Context;
|
|||||||
|
|
||||||
import com.aoleyun.sn.base.BaseApplication;
|
import com.aoleyun.sn.base.BaseApplication;
|
||||||
|
|
||||||
import cn.jpush.android.api.CustomMessage;
|
|
||||||
import cn.jpush.android.api.JPushMessage;
|
|
||||||
import cn.jpush.android.service.JPushMessageReceiver;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 自定义JPush message 接收器,包括操作tag/alias的结果返回(仅仅包含tag/alias新接口部分)
|
* 自定义JPush message 接收器,包括操作tag/alias的结果返回(仅仅包含tag/alias新接口部分)
|
||||||
* */
|
* */
|
||||||
public class MyJPushMessageReceiver extends JPushMessageReceiver {
|
//public class MyJPushMessageReceiver extends JPushMessageReceiver {
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void onTagOperatorResult(Context context, JPushMessage jPushMessage) {
|
// public void onTagOperatorResult(Context context, JPushMessage jPushMessage) {
|
||||||
TagAliasOperatorHelper.getInstance().onTagOperatorResult(context,jPushMessage);
|
// TagAliasOperatorHelper.getInstance().onTagOperatorResult(context,jPushMessage);
|
||||||
super.onTagOperatorResult(context, jPushMessage);
|
// super.onTagOperatorResult(context, jPushMessage);
|
||||||
BaseApplication.getInstance().onTagOperatorResult(jPushMessage);
|
// BaseApplication.getInstance().onTagOperatorResult(jPushMessage);
|
||||||
}
|
// }
|
||||||
@Override
|
// @Override
|
||||||
public void onCheckTagOperatorResult(Context context, JPushMessage jPushMessage){
|
// public void onCheckTagOperatorResult(Context context, JPushMessage jPushMessage){
|
||||||
TagAliasOperatorHelper.getInstance().onCheckTagOperatorResult(context,jPushMessage);
|
// TagAliasOperatorHelper.getInstance().onCheckTagOperatorResult(context,jPushMessage);
|
||||||
super.onCheckTagOperatorResult(context, jPushMessage);
|
// super.onCheckTagOperatorResult(context, jPushMessage);
|
||||||
}
|
// }
|
||||||
@Override
|
// @Override
|
||||||
public void onAliasOperatorResult(Context context, JPushMessage jPushMessage) {
|
// public void onAliasOperatorResult(Context context, JPushMessage jPushMessage) {
|
||||||
TagAliasOperatorHelper.getInstance().onAliasOperatorResult(context,jPushMessage);
|
// TagAliasOperatorHelper.getInstance().onAliasOperatorResult(context,jPushMessage);
|
||||||
super.onAliasOperatorResult(context, jPushMessage);
|
// super.onAliasOperatorResult(context, jPushMessage);
|
||||||
BaseApplication.getInstance().onAliasOperatorResult(jPushMessage);
|
// BaseApplication.getInstance().onAliasOperatorResult(jPushMessage);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void onMobileNumberOperatorResult(Context context, JPushMessage jPushMessage) {
|
// public void onMobileNumberOperatorResult(Context context, JPushMessage jPushMessage) {
|
||||||
TagAliasOperatorHelper.getInstance().onMobileNumberOperatorResult(context,jPushMessage);
|
// TagAliasOperatorHelper.getInstance().onMobileNumberOperatorResult(context,jPushMessage);
|
||||||
super.onMobileNumberOperatorResult(context, jPushMessage);
|
// super.onMobileNumberOperatorResult(context, jPushMessage);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void onMessage(Context context, CustomMessage customMessage) {
|
// public void onMessage(Context context, CustomMessage customMessage) {
|
||||||
super.onMessage(context, customMessage);
|
// super.onMessage(context, customMessage);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
|||||||
1042
app/src/main/java/com/aoleyun/sn/jpush/MyJPushReceiver.java
Normal file
@@ -1,19 +1,5 @@
|
|||||||
package com.aoleyun.sn.jpush;
|
package com.aoleyun.sn.jpush;
|
||||||
|
|
||||||
import android.content.BroadcastReceiver;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.text.TextUtils;
|
|
||||||
|
|
||||||
import com.aoleyun.sn.activity.MainActivity;
|
|
||||||
|
|
||||||
import org.json.JSONException;
|
|
||||||
import org.json.JSONObject;
|
|
||||||
|
|
||||||
import java.util.Iterator;
|
|
||||||
|
|
||||||
import cn.jpush.android.api.JPushInterface;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 自定义接收器
|
* 自定义接收器
|
||||||
@@ -22,108 +8,108 @@ import cn.jpush.android.api.JPushInterface;
|
|||||||
* 1) 默认用户会打开主界面
|
* 1) 默认用户会打开主界面
|
||||||
* 2) 接收不到自定义消息
|
* 2) 接收不到自定义消息
|
||||||
*/
|
*/
|
||||||
public class MyReceiver extends BroadcastReceiver {
|
//public class MyReceiver extends BroadcastReceiver {
|
||||||
private static final String TAG = "JIGUANG-Example";
|
// private static final String TAG = "JIGUANG-Example";
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
// public void onReceive(Context context, Intent intent) {
|
||||||
try {
|
// try {
|
||||||
Bundle bundle = intent.getExtras();
|
// Bundle bundle = intent.getExtras();
|
||||||
Logger.d(TAG, "[MyReceiver] onReceive - " + intent.getAction() + ", extras: " + printBundle(bundle));
|
// Logger.d(TAG, "[MyReceiver] onReceive - " + intent.getAction() + ", extras: " + printBundle(bundle));
|
||||||
|
//
|
||||||
if (JPushInterface.ACTION_REGISTRATION_ID.equals(intent.getAction())) {
|
// if (JPushInterface.ACTION_REGISTRATION_ID.equals(intent.getAction())) {
|
||||||
String regId = bundle.getString(JPushInterface.EXTRA_REGISTRATION_ID);
|
// String regId = bundle.getString(JPushInterface.EXTRA_REGISTRATION_ID);
|
||||||
Logger.d(TAG, "[MyReceiver] 接收Registration Id : " + regId);
|
// Logger.d(TAG, "[MyReceiver] 接收Registration Id : " + regId);
|
||||||
//send the Registration Id to your server...
|
// //send the Registration Id to your server...
|
||||||
|
//
|
||||||
} else if (JPushInterface.ACTION_MESSAGE_RECEIVED.equals(intent.getAction())) {
|
// } else if (JPushInterface.ACTION_MESSAGE_RECEIVED.equals(intent.getAction())) {
|
||||||
Logger.d(TAG, "[MyReceiver] 接收到推送下来的自定义消息: " + bundle.getString(JPushInterface.EXTRA_MESSAGE));
|
// Logger.d(TAG, "[MyReceiver] 接收到推送下来的自定义消息: " + bundle.getString(JPushInterface.EXTRA_MESSAGE));
|
||||||
processCustomMessage(context, bundle);
|
// processCustomMessage(context, bundle);
|
||||||
|
//
|
||||||
} else if (JPushInterface.ACTION_NOTIFICATION_RECEIVED.equals(intent.getAction())) {
|
// } else if (JPushInterface.ACTION_NOTIFICATION_RECEIVED.equals(intent.getAction())) {
|
||||||
Logger.d(TAG, "[MyReceiver] 接收到推送下来的通知");
|
// Logger.d(TAG, "[MyReceiver] 接收到推送下来的通知");
|
||||||
int notifactionId = bundle.getInt(JPushInterface.EXTRA_NOTIFICATION_ID);
|
// int notifactionId = bundle.getInt(JPushInterface.EXTRA_NOTIFICATION_ID);
|
||||||
Logger.d(TAG, "[MyReceiver] 接收到推送下来的通知的ID: " + notifactionId);
|
// Logger.d(TAG, "[MyReceiver] 接收到推送下来的通知的ID: " + notifactionId);
|
||||||
|
//
|
||||||
} else if (JPushInterface.ACTION_NOTIFICATION_OPENED.equals(intent.getAction())) {
|
// } else if (JPushInterface.ACTION_NOTIFICATION_OPENED.equals(intent.getAction())) {
|
||||||
Logger.d(TAG, "[MyReceiver] 用户点击打开了通知");
|
// Logger.d(TAG, "[MyReceiver] 用户点击打开了通知");
|
||||||
|
//
|
||||||
//打开自定义的Activity
|
// //打开自定义的Activity
|
||||||
// Intent i = new Intent(context, TestActivity.class);
|
//// Intent i = new Intent(context, TestActivity.class);
|
||||||
// i.putExtras(bundle);
|
//// i.putExtras(bundle);
|
||||||
//i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
// //i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
// i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP );
|
//// i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP );
|
||||||
// context.startActivity(i);
|
//// context.startActivity(i);
|
||||||
|
//
|
||||||
} else if (JPushInterface.ACTION_RICHPUSH_CALLBACK.equals(intent.getAction())) {
|
// } else if (JPushInterface.ACTION_RICHPUSH_CALLBACK.equals(intent.getAction())) {
|
||||||
Logger.d(TAG, "[MyReceiver] 用户收到到RICH PUSH CALLBACK: " + bundle.getString(JPushInterface.EXTRA_EXTRA));
|
// Logger.d(TAG, "[MyReceiver] 用户收到到RICH PUSH CALLBACK: " + bundle.getString(JPushInterface.EXTRA_EXTRA));
|
||||||
//在这里根据 JPushInterface.EXTRA_EXTRA 的内容处理代码,比如打开新的Activity, 打开一个网页等..
|
// //在这里根据 JPushInterface.EXTRA_EXTRA 的内容处理代码,比如打开新的Activity, 打开一个网页等..
|
||||||
|
//
|
||||||
} else if(JPushInterface.ACTION_CONNECTION_CHANGE.equals(intent.getAction())) {
|
// } else if(JPushInterface.ACTION_CONNECTION_CHANGE.equals(intent.getAction())) {
|
||||||
boolean connected = intent.getBooleanExtra(JPushInterface.EXTRA_CONNECTION_CHANGE, false);
|
// boolean connected = intent.getBooleanExtra(JPushInterface.EXTRA_CONNECTION_CHANGE, false);
|
||||||
Logger.w(TAG, "[MyReceiver]" + intent.getAction() +" connected state change to "+connected);
|
// Logger.w(TAG, "[MyReceiver]" + intent.getAction() +" connected state change to "+connected);
|
||||||
} else {
|
// } else {
|
||||||
Logger.d(TAG, "[MyReceiver] Unhandled intent - " + intent.getAction());
|
// Logger.d(TAG, "[MyReceiver] Unhandled intent - " + intent.getAction());
|
||||||
}
|
// }
|
||||||
} catch (Exception e){
|
// } catch (Exception e){
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// 打印所有的 intent extra 数据
|
// // 打印所有的 intent extra 数据
|
||||||
private static String printBundle(Bundle bundle) {
|
// private static String printBundle(Bundle bundle) {
|
||||||
StringBuilder sb = new StringBuilder();
|
// StringBuilder sb = new StringBuilder();
|
||||||
for (String key : bundle.keySet()) {
|
// for (String key : bundle.keySet()) {
|
||||||
if (key.equals(JPushInterface.EXTRA_NOTIFICATION_ID)) {
|
// if (key.equals(JPushInterface.EXTRA_NOTIFICATION_ID)) {
|
||||||
sb.append("\nkey:" + key + ", value:" + bundle.getInt(key));
|
// sb.append("\nkey:" + key + ", value:" + bundle.getInt(key));
|
||||||
}else if(key.equals(JPushInterface.EXTRA_CONNECTION_CHANGE)){
|
// }else if(key.equals(JPushInterface.EXTRA_CONNECTION_CHANGE)){
|
||||||
sb.append("\nkey:" + key + ", value:" + bundle.getBoolean(key));
|
// sb.append("\nkey:" + key + ", value:" + bundle.getBoolean(key));
|
||||||
} else if (key.equals(JPushInterface.EXTRA_EXTRA)) {
|
// } else if (key.equals(JPushInterface.EXTRA_EXTRA)) {
|
||||||
if (TextUtils.isEmpty(bundle.getString(JPushInterface.EXTRA_EXTRA))) {
|
// if (TextUtils.isEmpty(bundle.getString(JPushInterface.EXTRA_EXTRA))) {
|
||||||
Logger.i(TAG, "This message has no Extra data");
|
// Logger.i(TAG, "This message has no Extra data");
|
||||||
continue;
|
// continue;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
try {
|
// try {
|
||||||
JSONObject json = new JSONObject(bundle.getString(JPushInterface.EXTRA_EXTRA));
|
// JSONObject json = new JSONObject(bundle.getString(JPushInterface.EXTRA_EXTRA));
|
||||||
Iterator<String> it = json.keys();
|
// Iterator<String> it = json.keys();
|
||||||
|
//
|
||||||
while (it.hasNext()) {
|
// while (it.hasNext()) {
|
||||||
String myKey = it.next();
|
// String myKey = it.next();
|
||||||
sb.append("\nkey:" + key + ", value: [" +
|
// sb.append("\nkey:" + key + ", value: [" +
|
||||||
myKey + " - " +json.optString(myKey) + "]");
|
// myKey + " - " +json.optString(myKey) + "]");
|
||||||
}
|
// }
|
||||||
} catch (JSONException e) {
|
// } catch (JSONException e) {
|
||||||
Logger.e(TAG, "Get message extra JSON error!");
|
// Logger.e(TAG, "Get message extra JSON error!");
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
} else {
|
// } else {
|
||||||
sb.append("\nkey:" + key + ", value:" + bundle.get(key));
|
// sb.append("\nkey:" + key + ", value:" + bundle.get(key));
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return sb.toString();
|
// return sb.toString();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
//send msg to MainActivity
|
// //send msg to MainActivity
|
||||||
private void processCustomMessage(Context context, Bundle bundle) {
|
// private void processCustomMessage(Context context, Bundle bundle) {
|
||||||
if (MainActivity.isForeground) {
|
// if (MainActivity.isForeground) {
|
||||||
String message = bundle.getString(JPushInterface.EXTRA_MESSAGE);
|
// String message = bundle.getString(JPushInterface.EXTRA_MESSAGE);
|
||||||
String extras = bundle.getString(JPushInterface.EXTRA_EXTRA);
|
// String extras = bundle.getString(JPushInterface.EXTRA_EXTRA);
|
||||||
Intent msgIntent = new Intent(MainActivity.MESSAGE_RECEIVED_ACTION);
|
// Intent msgIntent = new Intent(MainActivity.MESSAGE_RECEIVED_ACTION);
|
||||||
msgIntent.putExtra(MainActivity.KEY_MESSAGE, message);
|
// msgIntent.putExtra(MainActivity.KEY_MESSAGE, message);
|
||||||
if (!ExampleUtil.isEmpty(extras)) {
|
// if (!ExampleUtil.isEmpty(extras)) {
|
||||||
try {
|
// try {
|
||||||
JSONObject extraJson = new JSONObject(extras);
|
// JSONObject extraJson = new JSONObject(extras);
|
||||||
if (extraJson.length() > 0) {
|
// if (extraJson.length() > 0) {
|
||||||
msgIntent.putExtra(MainActivity.KEY_EXTRAS, extras);
|
// msgIntent.putExtra(MainActivity.KEY_EXTRAS, extras);
|
||||||
}
|
// }
|
||||||
} catch (JSONException e) {
|
// } catch (JSONException e) {
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
LocalBroadcastManager.getInstance(context).sendBroadcast(msgIntent);
|
// LocalBroadcastManager.getInstance(context).sendBroadcast(msgIntent);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
package com.aoleyun.sn.jpush;
|
package com.aoleyun.sn.jpush;
|
||||||
|
|
||||||
import cn.jpush.android.service.JCommonService;
|
//import cn.jpush.android.service.JCommonService;
|
||||||
|
|
||||||
public class PushService extends JCommonService {
|
public class PushService {
|
||||||
|
// extends JCommonService {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,335 +11,333 @@ import com.aoleyun.sn.utils.ToastUtil;
|
|||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import cn.jpush.android.api.JPushInterface;
|
|
||||||
import cn.jpush.android.api.JPushMessage;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理tagalias相关的逻辑
|
* 处理tagalias相关的逻辑
|
||||||
* */
|
* */
|
||||||
public class TagAliasOperatorHelper {
|
public class TagAliasOperatorHelper {
|
||||||
private static final String TAG = "JIGUANG-TagAliasHelper";
|
// private static final String TAG = "JIGUANG-TagAliasHelper";
|
||||||
public static int sequence = 1;
|
// public static int sequence = 1;
|
||||||
/**增加*/
|
// /**增加*/
|
||||||
public static final int ACTION_ADD = 1;
|
// public static final int ACTION_ADD = 1;
|
||||||
/**覆盖*/
|
// /**覆盖*/
|
||||||
public static final int ACTION_SET = 2;
|
// public static final int ACTION_SET = 2;
|
||||||
/**删除部分*/
|
// /**删除部分*/
|
||||||
public static final int ACTION_DELETE = 3;
|
// public static final int ACTION_DELETE = 3;
|
||||||
/**删除所有*/
|
// /**删除所有*/
|
||||||
public static final int ACTION_CLEAN = 4;
|
// public static final int ACTION_CLEAN = 4;
|
||||||
/**查询*/
|
// /**查询*/
|
||||||
public static final int ACTION_GET = 5;
|
// public static final int ACTION_GET = 5;
|
||||||
|
//
|
||||||
public static final int ACTION_CHECK = 6;
|
// public static final int ACTION_CHECK = 6;
|
||||||
|
//
|
||||||
public static final int DELAY_SEND_ACTION = 1;
|
// public static final int DELAY_SEND_ACTION = 1;
|
||||||
|
//
|
||||||
public static final int DELAY_SET_MOBILE_NUMBER_ACTION = 2;
|
// public static final int DELAY_SET_MOBILE_NUMBER_ACTION = 2;
|
||||||
|
//
|
||||||
private Context context;
|
// private Context context;
|
||||||
|
//
|
||||||
private static TagAliasOperatorHelper mInstance;
|
// private static TagAliasOperatorHelper mInstance;
|
||||||
private TagAliasOperatorHelper(){
|
// private TagAliasOperatorHelper(){
|
||||||
}
|
// }
|
||||||
public static TagAliasOperatorHelper getInstance(){
|
// public static TagAliasOperatorHelper getInstance(){
|
||||||
if(mInstance == null){
|
// if(mInstance == null){
|
||||||
synchronized (TagAliasOperatorHelper.class){
|
// synchronized (TagAliasOperatorHelper.class){
|
||||||
if(mInstance == null){
|
// if(mInstance == null){
|
||||||
mInstance = new TagAliasOperatorHelper();
|
// mInstance = new TagAliasOperatorHelper();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return mInstance;
|
// return mInstance;
|
||||||
}
|
// }
|
||||||
public void init(Context context){
|
// public void init(Context context){
|
||||||
if(context != null) {
|
// if(context != null) {
|
||||||
this.context = context.getApplicationContext();
|
// this.context = context.getApplicationContext();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
private SparseArray<Object> setActionCache = new SparseArray<Object>();
|
// private SparseArray<Object> setActionCache = new SparseArray<Object>();
|
||||||
|
//
|
||||||
public Object get(int sequence){
|
// public Object get(int sequence){
|
||||||
return setActionCache.get(sequence);
|
// return setActionCache.get(sequence);
|
||||||
}
|
// }
|
||||||
public Object remove(int sequence){
|
// public Object remove(int sequence){
|
||||||
return setActionCache.get(sequence);
|
// return setActionCache.get(sequence);
|
||||||
}
|
// }
|
||||||
public void put(int sequence, Object tagAliasBean){
|
// public void put(int sequence, Object tagAliasBean){
|
||||||
setActionCache.put(sequence,tagAliasBean);
|
// setActionCache.put(sequence,tagAliasBean);
|
||||||
}
|
// }
|
||||||
private Handler delaySendHandler = new Handler(){
|
// private Handler delaySendHandler = new Handler(){
|
||||||
@Override
|
// @Override
|
||||||
public void handleMessage(Message msg) {
|
// public void handleMessage(Message msg) {
|
||||||
switch (msg.what){
|
// switch (msg.what){
|
||||||
case DELAY_SEND_ACTION:
|
// case DELAY_SEND_ACTION:
|
||||||
if(msg.obj !=null && msg.obj instanceof TagAliasBean){
|
// if(msg.obj !=null && msg.obj instanceof TagAliasBean){
|
||||||
Logger.i(TAG,"on delay time");
|
// Logger.i(TAG,"on delay time");
|
||||||
sequence++;
|
// sequence++;
|
||||||
TagAliasBean tagAliasBean = (TagAliasBean) msg.obj;
|
// TagAliasBean tagAliasBean = (TagAliasBean) msg.obj;
|
||||||
setActionCache.put(sequence, tagAliasBean);
|
// setActionCache.put(sequence, tagAliasBean);
|
||||||
if(context!=null) {
|
// if(context!=null) {
|
||||||
handleAction(context, sequence, tagAliasBean);
|
// handleAction(context, sequence, tagAliasBean);
|
||||||
}else{
|
// }else{
|
||||||
Logger.e(TAG,"#unexcepted - context was null");
|
// Logger.e(TAG,"#unexcepted - context was null");
|
||||||
}
|
// }
|
||||||
}else{
|
// }else{
|
||||||
Logger.w(TAG,"#unexcepted - msg obj was incorrect");
|
// Logger.w(TAG,"#unexcepted - msg obj was incorrect");
|
||||||
}
|
// }
|
||||||
break;
|
// break;
|
||||||
case DELAY_SET_MOBILE_NUMBER_ACTION:
|
// case DELAY_SET_MOBILE_NUMBER_ACTION:
|
||||||
if(msg.obj !=null && msg.obj instanceof String) {
|
// if(msg.obj !=null && msg.obj instanceof String) {
|
||||||
Logger.i(TAG, "retry set mobile number");
|
// Logger.i(TAG, "retry set mobile number");
|
||||||
sequence++;
|
// sequence++;
|
||||||
String mobileNumber = (String) msg.obj;
|
// String mobileNumber = (String) msg.obj;
|
||||||
setActionCache.put(sequence, mobileNumber);
|
// setActionCache.put(sequence, mobileNumber);
|
||||||
if(context !=null) {
|
// if(context !=null) {
|
||||||
handleAction(context, sequence, mobileNumber);
|
// handleAction(context, sequence, mobileNumber);
|
||||||
}else {
|
// }else {
|
||||||
Logger.e(TAG, "#unexcepted - context was null");
|
// Logger.e(TAG, "#unexcepted - context was null");
|
||||||
}
|
// }
|
||||||
}else{
|
// }else{
|
||||||
Logger.w(TAG,"#unexcepted - msg obj was incorrect");
|
// Logger.w(TAG,"#unexcepted - msg obj was incorrect");
|
||||||
}
|
// }
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
};
|
// };
|
||||||
public void handleAction(Context context, int sequence, String mobileNumber){
|
// public void handleAction(Context context, int sequence, String mobileNumber){
|
||||||
put(sequence,mobileNumber);
|
// put(sequence,mobileNumber);
|
||||||
Logger.d(TAG,"sequence:"+sequence+",mobileNumber:"+mobileNumber);
|
// Logger.d(TAG,"sequence:"+sequence+",mobileNumber:"+mobileNumber);
|
||||||
JPushInterface.setMobileNumber(context,sequence,mobileNumber);
|
// JPushInterface.setMobileNumber(context,sequence,mobileNumber);
|
||||||
}
|
// }
|
||||||
/**
|
// /**
|
||||||
* 处理设置tag
|
// * 处理设置tag
|
||||||
* */
|
// * */
|
||||||
public void handleAction(Context context, int sequence, TagAliasBean tagAliasBean){
|
// public void handleAction(Context context, int sequence, TagAliasBean tagAliasBean){
|
||||||
init(context);
|
// init(context);
|
||||||
if(tagAliasBean == null){
|
// if(tagAliasBean == null){
|
||||||
Logger.w(TAG,"tagAliasBean was null");
|
// Logger.w(TAG,"tagAliasBean was null");
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
put(sequence,tagAliasBean);
|
// put(sequence,tagAliasBean);
|
||||||
if(tagAliasBean.isAliasAction){
|
// if(tagAliasBean.isAliasAction){
|
||||||
switch (tagAliasBean.action){
|
// switch (tagAliasBean.action){
|
||||||
case ACTION_GET:
|
// case ACTION_GET:
|
||||||
JPushInterface.getAlias(context,sequence);
|
// JPushInterface.getAlias(context,sequence);
|
||||||
break;
|
// break;
|
||||||
case ACTION_DELETE:
|
// case ACTION_DELETE:
|
||||||
JPushInterface.deleteAlias(context,sequence);
|
// JPushInterface.deleteAlias(context,sequence);
|
||||||
break;
|
// break;
|
||||||
case ACTION_SET:
|
// case ACTION_SET:
|
||||||
JPushInterface.setAlias(context,sequence,tagAliasBean.alias);
|
// JPushInterface.setAlias(context,sequence,tagAliasBean.alias);
|
||||||
break;
|
// break;
|
||||||
default:
|
// default:
|
||||||
Logger.w(TAG,"unsupport alias action type");
|
// Logger.w(TAG,"unsupport alias action type");
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
}else {
|
// }else {
|
||||||
switch (tagAliasBean.action) {
|
// switch (tagAliasBean.action) {
|
||||||
case ACTION_ADD:
|
// case ACTION_ADD:
|
||||||
JPushInterface.addTags(context, sequence, tagAliasBean.tags);
|
// JPushInterface.addTags(context, sequence, tagAliasBean.tags);
|
||||||
break;
|
// break;
|
||||||
case ACTION_SET:
|
// case ACTION_SET:
|
||||||
JPushInterface.setTags(context, sequence, tagAliasBean.tags);
|
// JPushInterface.setTags(context, sequence, tagAliasBean.tags);
|
||||||
break;
|
// break;
|
||||||
case ACTION_DELETE:
|
// case ACTION_DELETE:
|
||||||
JPushInterface.deleteTags(context, sequence, tagAliasBean.tags);
|
// JPushInterface.deleteTags(context, sequence, tagAliasBean.tags);
|
||||||
break;
|
// break;
|
||||||
case ACTION_CHECK:
|
// case ACTION_CHECK:
|
||||||
//一次只能check一个tag
|
// //一次只能check一个tag
|
||||||
String tag = (String)tagAliasBean.tags.toArray()[0];
|
// String tag = (String)tagAliasBean.tags.toArray()[0];
|
||||||
JPushInterface.checkTagBindState(context,sequence,tag);
|
// JPushInterface.checkTagBindState(context,sequence,tag);
|
||||||
break;
|
// break;
|
||||||
case ACTION_GET:
|
// case ACTION_GET:
|
||||||
JPushInterface.getAllTags(context, sequence);
|
// JPushInterface.getAllTags(context, sequence);
|
||||||
break;
|
// break;
|
||||||
case ACTION_CLEAN:
|
// case ACTION_CLEAN:
|
||||||
JPushInterface.cleanTags(context, sequence);
|
// JPushInterface.cleanTags(context, sequence);
|
||||||
break;
|
// break;
|
||||||
default:
|
// default:
|
||||||
Logger.w(TAG,"unsupport tag action type");
|
// Logger.w(TAG,"unsupport tag action type");
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
private boolean RetryActionIfNeeded(int errorCode,TagAliasBean tagAliasBean){
|
// private boolean RetryActionIfNeeded(int errorCode,TagAliasBean tagAliasBean){
|
||||||
if(!ExampleUtil.isConnected(context)){
|
// if(!ExampleUtil.isConnected(context)){
|
||||||
Logger.w(TAG,"no network");
|
// Logger.w(TAG,"no network");
|
||||||
return false;
|
// return false;
|
||||||
}
|
// }
|
||||||
//返回的错误码为6002 超时,6014 服务器繁忙,都建议延迟重试
|
// //返回的错误码为6002 超时,6014 服务器繁忙,都建议延迟重试
|
||||||
if(errorCode == 6002 || errorCode == 6014){
|
// if(errorCode == 6002 || errorCode == 6014){
|
||||||
Logger.d(TAG,"need retry");
|
// Logger.d(TAG,"need retry");
|
||||||
if(tagAliasBean!=null){
|
// if(tagAliasBean!=null){
|
||||||
Message message = new Message();
|
// Message message = new Message();
|
||||||
message.what = DELAY_SEND_ACTION;
|
// message.what = DELAY_SEND_ACTION;
|
||||||
message.obj = tagAliasBean;
|
// message.obj = tagAliasBean;
|
||||||
delaySendHandler.sendMessageDelayed(message,1000*60);
|
// delaySendHandler.sendMessageDelayed(message,1000*60);
|
||||||
String logs =getRetryStr(tagAliasBean.isAliasAction, tagAliasBean.action,errorCode);
|
// String logs =getRetryStr(tagAliasBean.isAliasAction, tagAliasBean.action,errorCode);
|
||||||
ExampleUtil.showToast(logs, context);
|
// ExampleUtil.showToast(logs, context);
|
||||||
return true;
|
// return true;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return false;
|
// return false;
|
||||||
}
|
// }
|
||||||
private boolean RetrySetMObileNumberActionIfNeeded(int errorCode, String mobileNumber){
|
// private boolean RetrySetMObileNumberActionIfNeeded(int errorCode, String mobileNumber){
|
||||||
if(!ExampleUtil.isConnected(context)){
|
// if(!ExampleUtil.isConnected(context)){
|
||||||
Logger.w(TAG,"no network");
|
// Logger.w(TAG,"no network");
|
||||||
return false;
|
// return false;
|
||||||
}
|
// }
|
||||||
//返回的错误码为6002 超时,6024 服务器内部错误,建议稍后重试
|
// //返回的错误码为6002 超时,6024 服务器内部错误,建议稍后重试
|
||||||
if(errorCode == 6002 || errorCode == 6024){
|
// if(errorCode == 6002 || errorCode == 6024){
|
||||||
Logger.d(TAG,"need retry");
|
// Logger.d(TAG,"need retry");
|
||||||
Message message = new Message();
|
// Message message = new Message();
|
||||||
message.what = DELAY_SET_MOBILE_NUMBER_ACTION;
|
// message.what = DELAY_SET_MOBILE_NUMBER_ACTION;
|
||||||
message.obj = mobileNumber;
|
// message.obj = mobileNumber;
|
||||||
delaySendHandler.sendMessageDelayed(message,1000*60);
|
// delaySendHandler.sendMessageDelayed(message,1000*60);
|
||||||
String str = "Failed to set mobile number due to %s. Try again after 60s.";
|
// String str = "Failed to set mobile number due to %s. Try again after 60s.";
|
||||||
str = String.format(Locale.ENGLISH,str,(errorCode == 6002 ? "timeout" : "server internal error”"));
|
// str = String.format(Locale.ENGLISH,str,(errorCode == 6002 ? "timeout" : "server internal error”"));
|
||||||
ExampleUtil.showToast(str, context);
|
// ExampleUtil.showToast(str, context);
|
||||||
return true;
|
// return true;
|
||||||
}
|
// }
|
||||||
return false;
|
// return false;
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
private String getRetryStr(boolean isAliasAction, int actionType, int errorCode){
|
// private String getRetryStr(boolean isAliasAction, int actionType, int errorCode){
|
||||||
String str = "Failed to %s %s due to %s. Try again after 60s.";
|
// String str = "Failed to %s %s due to %s. Try again after 60s.";
|
||||||
str = String.format(Locale.ENGLISH,str,getActionStr(actionType),(isAliasAction? "alias" : " tags") ,(errorCode == 6002 ? "timeout" : "server too busy"));
|
// str = String.format(Locale.ENGLISH,str,getActionStr(actionType),(isAliasAction? "alias" : " tags") ,(errorCode == 6002 ? "timeout" : "server too busy"));
|
||||||
return str;
|
// return str;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private String getActionStr(int actionType){
|
// private String getActionStr(int actionType){
|
||||||
switch (actionType){
|
// switch (actionType){
|
||||||
case ACTION_ADD:
|
// case ACTION_ADD:
|
||||||
return "add";
|
// return "add";
|
||||||
case ACTION_SET:
|
// case ACTION_SET:
|
||||||
return "set";
|
// return "set";
|
||||||
case ACTION_DELETE:
|
// case ACTION_DELETE:
|
||||||
return "delete";
|
// return "delete";
|
||||||
case ACTION_GET:
|
// case ACTION_GET:
|
||||||
return "get";
|
// return "get";
|
||||||
case ACTION_CLEAN:
|
// case ACTION_CLEAN:
|
||||||
return "clean";
|
// return "clean";
|
||||||
case ACTION_CHECK:
|
// case ACTION_CHECK:
|
||||||
return "check";
|
// return "check";
|
||||||
}
|
// }
|
||||||
return "unkonw operation";
|
// return "unkonw operation";
|
||||||
}
|
// }
|
||||||
public void onTagOperatorResult(Context context, JPushMessage jPushMessage) {
|
// public void onTagOperatorResult(Context context, JPushMessage jPushMessage) {
|
||||||
int sequence = jPushMessage.getSequence();
|
// int sequence = jPushMessage.getSequence();
|
||||||
Logger.i(TAG,"action - onTagOperatorResult, sequence:"+sequence+",tags:"+jPushMessage.getTags());
|
// Logger.i(TAG,"action - onTagOperatorResult, sequence:"+sequence+",tags:"+jPushMessage.getTags());
|
||||||
Logger.i(TAG,"tags size:"+jPushMessage.getTags().size());
|
// Logger.i(TAG,"tags size:"+jPushMessage.getTags().size());
|
||||||
init(context);
|
// init(context);
|
||||||
//根据sequence从之前操作缓存中获取缓存记录
|
// //根据sequence从之前操作缓存中获取缓存记录
|
||||||
TagAliasBean tagAliasBean = (TagAliasBean)setActionCache.get(sequence);
|
// TagAliasBean tagAliasBean = (TagAliasBean)setActionCache.get(sequence);
|
||||||
if(tagAliasBean == null){
|
// if(tagAliasBean == null){
|
||||||
ExampleUtil.showToast("获取缓存记录失败", context);
|
// ExampleUtil.showToast("获取缓存记录失败", context);
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
if(jPushMessage.getErrorCode() == 0){
|
// if(jPushMessage.getErrorCode() == 0){
|
||||||
Logger.i(TAG,"action - modify tag Success,sequence:"+sequence);
|
// Logger.i(TAG,"action - modify tag Success,sequence:"+sequence);
|
||||||
setActionCache.remove(sequence);
|
// setActionCache.remove(sequence);
|
||||||
String logs = getActionStr(tagAliasBean.action)+" tags success";
|
// String logs = getActionStr(tagAliasBean.action)+" tags success";
|
||||||
Logger.i(TAG,logs);
|
// Logger.i(TAG,logs);
|
||||||
Log.e(TAG,"Tag绑定成功: " + jPushMessage.getTags());
|
// Log.e(TAG,"Tag绑定成功: " + jPushMessage.getTags());
|
||||||
ToastUtil.betaShow("Tag绑定成功: " + jPushMessage.getTags());
|
// ToastUtil.betaShow("Tag绑定成功: " + jPushMessage.getTags());
|
||||||
ExampleUtil.showToast(logs, context);
|
// ExampleUtil.showToast(logs, context);
|
||||||
}else{
|
// }else{
|
||||||
String logs = "Failed to " + getActionStr(tagAliasBean.action)+" tags";
|
// String logs = "Failed to " + getActionStr(tagAliasBean.action)+" tags";
|
||||||
if(jPushMessage.getErrorCode() == 6018){
|
// if(jPushMessage.getErrorCode() == 6018){
|
||||||
//tag数量超过限制,需要先清除一部分再add
|
// //tag数量超过限制,需要先清除一部分再add
|
||||||
logs += ", tags is exceed limit need to clean";
|
// logs += ", tags is exceed limit need to clean";
|
||||||
}
|
// }
|
||||||
logs += ", errorCode:" + jPushMessage.getErrorCode();
|
// logs += ", errorCode:" + jPushMessage.getErrorCode();
|
||||||
Logger.e(TAG, logs);
|
// Logger.e(TAG, logs);
|
||||||
if(!RetryActionIfNeeded(jPushMessage.getErrorCode(),tagAliasBean)) {
|
// if(!RetryActionIfNeeded(jPushMessage.getErrorCode(),tagAliasBean)) {
|
||||||
ExampleUtil.showToast(logs, context);
|
// ExampleUtil.showToast(logs, context);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
public void onCheckTagOperatorResult(Context context, JPushMessage jPushMessage){
|
//
|
||||||
int sequence = jPushMessage.getSequence();
|
// public void onCheckTagOperatorResult(Context context, JPushMessage jPushMessage){
|
||||||
Logger.i(TAG,"action - onCheckTagOperatorResult, sequence:"+sequence+",checktag:"+jPushMessage.getCheckTag());
|
// int sequence = jPushMessage.getSequence();
|
||||||
init(context);
|
// Logger.i(TAG,"action - onCheckTagOperatorResult, sequence:"+sequence+",checktag:"+jPushMessage.getCheckTag());
|
||||||
//根据sequence从之前操作缓存中获取缓存记录
|
// init(context);
|
||||||
TagAliasBean tagAliasBean = (TagAliasBean)setActionCache.get(sequence);
|
// //根据sequence从之前操作缓存中获取缓存记录
|
||||||
if(tagAliasBean == null){
|
// TagAliasBean tagAliasBean = (TagAliasBean)setActionCache.get(sequence);
|
||||||
ExampleUtil.showToast("获取缓存记录失败", context);
|
// if(tagAliasBean == null){
|
||||||
return;
|
// ExampleUtil.showToast("获取缓存记录失败", context);
|
||||||
}
|
// return;
|
||||||
if(jPushMessage.getErrorCode() == 0){
|
// }
|
||||||
Logger.i(TAG,"tagBean:"+tagAliasBean);
|
// if(jPushMessage.getErrorCode() == 0){
|
||||||
setActionCache.remove(sequence);
|
// Logger.i(TAG,"tagBean:"+tagAliasBean);
|
||||||
String logs = getActionStr(tagAliasBean.action)+" tag "+jPushMessage.getCheckTag() + " bind state success,state:"+jPushMessage.getTagCheckStateResult();
|
// setActionCache.remove(sequence);
|
||||||
Logger.i(TAG,logs);
|
// String logs = getActionStr(tagAliasBean.action)+" tag "+jPushMessage.getCheckTag() + " bind state success,state:"+jPushMessage.getTagCheckStateResult();
|
||||||
ExampleUtil.showToast(logs, context);
|
// Logger.i(TAG,logs);
|
||||||
}else{
|
// ExampleUtil.showToast(logs, context);
|
||||||
String logs = "Failed to " + getActionStr(tagAliasBean.action)+" tags, errorCode:" + jPushMessage.getErrorCode();
|
// }else{
|
||||||
Logger.e(TAG, logs);
|
// String logs = "Failed to " + getActionStr(tagAliasBean.action)+" tags, errorCode:" + jPushMessage.getErrorCode();
|
||||||
if(!RetryActionIfNeeded(jPushMessage.getErrorCode(),tagAliasBean)) {
|
// Logger.e(TAG, logs);
|
||||||
ExampleUtil.showToast(logs, context);
|
// if(!RetryActionIfNeeded(jPushMessage.getErrorCode(),tagAliasBean)) {
|
||||||
}
|
// ExampleUtil.showToast(logs, context);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
public void onAliasOperatorResult(Context context, JPushMessage jPushMessage) {
|
// }
|
||||||
int sequence = jPushMessage.getSequence();
|
//
|
||||||
Logger.i(TAG,"action - onAliasOperatorResult, sequence:"+sequence+",alias:"+jPushMessage.getAlias());
|
// public void onAliasOperatorResult(Context context, JPushMessage jPushMessage) {
|
||||||
init(context);
|
// int sequence = jPushMessage.getSequence();
|
||||||
//根据sequence从之前操作缓存中获取缓存记录
|
// Logger.i(TAG,"action - onAliasOperatorResult, sequence:"+sequence+",alias:"+jPushMessage.getAlias());
|
||||||
TagAliasBean tagAliasBean = (TagAliasBean)setActionCache.get(sequence);
|
// init(context);
|
||||||
if(tagAliasBean == null){
|
// //根据sequence从之前操作缓存中获取缓存记录
|
||||||
ExampleUtil.showToast("获取缓存记录失败", context);
|
// TagAliasBean tagAliasBean = (TagAliasBean)setActionCache.get(sequence);
|
||||||
return;
|
// if(tagAliasBean == null){
|
||||||
}
|
// ExampleUtil.showToast("获取缓存记录失败", context);
|
||||||
if(jPushMessage.getErrorCode() == 0){
|
// return;
|
||||||
Logger.i(TAG,"action - modify alias Success,sequence:"+sequence);
|
// }
|
||||||
setActionCache.remove(sequence);
|
// if(jPushMessage.getErrorCode() == 0){
|
||||||
String logs = getActionStr(tagAliasBean.action)+" alias success";
|
// Logger.i(TAG,"action - modify alias Success,sequence:"+sequence);
|
||||||
Logger.i(TAG,logs);
|
// setActionCache.remove(sequence);
|
||||||
Log.e(TAG,"Alias绑定成功: "+jPushMessage.getAlias());
|
// String logs = getActionStr(tagAliasBean.action)+" alias success";
|
||||||
ToastUtil.betaShow("Alias绑定成功: "+jPushMessage.getAlias());
|
// Logger.i(TAG,logs);
|
||||||
ExampleUtil.showToast(logs, context);
|
// Log.e(TAG,"Alias绑定成功: "+jPushMessage.getAlias());
|
||||||
}else{
|
// ToastUtil.betaShow("Alias绑定成功: "+jPushMessage.getAlias());
|
||||||
String logs = "Failed to " + getActionStr(tagAliasBean.action)+" alias, errorCode:" + jPushMessage.getErrorCode();
|
// ExampleUtil.showToast(logs, context);
|
||||||
Logger.e(TAG, logs);
|
// }else{
|
||||||
if(!RetryActionIfNeeded(jPushMessage.getErrorCode(),tagAliasBean)) {
|
// String logs = "Failed to " + getActionStr(tagAliasBean.action)+" alias, errorCode:" + jPushMessage.getErrorCode();
|
||||||
ExampleUtil.showToast(logs, context);
|
// Logger.e(TAG, logs);
|
||||||
}
|
// if(!RetryActionIfNeeded(jPushMessage.getErrorCode(),tagAliasBean)) {
|
||||||
}
|
// ExampleUtil.showToast(logs, context);
|
||||||
}
|
// }
|
||||||
//设置手机号码回调
|
// }
|
||||||
public void onMobileNumberOperatorResult(Context context, JPushMessage jPushMessage) {
|
// }
|
||||||
int sequence = jPushMessage.getSequence();
|
// //设置手机号码回调
|
||||||
Logger.i(TAG,"action - onMobileNumberOperatorResult, sequence:"+sequence+",mobileNumber:"+jPushMessage.getMobileNumber());
|
// public void onMobileNumberOperatorResult(Context context, JPushMessage jPushMessage) {
|
||||||
init(context);
|
// int sequence = jPushMessage.getSequence();
|
||||||
if(jPushMessage.getErrorCode() == 0){
|
// Logger.i(TAG,"action - onMobileNumberOperatorResult, sequence:"+sequence+",mobileNumber:"+jPushMessage.getMobileNumber());
|
||||||
Logger.i(TAG,"action - set mobile number Success,sequence:"+sequence);
|
// init(context);
|
||||||
setActionCache.remove(sequence);
|
// if(jPushMessage.getErrorCode() == 0){
|
||||||
}else{
|
// Logger.i(TAG,"action - set mobile number Success,sequence:"+sequence);
|
||||||
String logs = "Failed to set mobile number, errorCode:" + jPushMessage.getErrorCode();
|
// setActionCache.remove(sequence);
|
||||||
Logger.e(TAG, logs);
|
// }else{
|
||||||
if(!RetrySetMObileNumberActionIfNeeded(jPushMessage.getErrorCode(),jPushMessage.getMobileNumber())){
|
// String logs = "Failed to set mobile number, errorCode:" + jPushMessage.getErrorCode();
|
||||||
ExampleUtil.showToast(logs, context);
|
// Logger.e(TAG, logs);
|
||||||
}
|
// if(!RetrySetMObileNumberActionIfNeeded(jPushMessage.getErrorCode(),jPushMessage.getMobileNumber())){
|
||||||
}
|
// ExampleUtil.showToast(logs, context);
|
||||||
}
|
// }
|
||||||
public static class TagAliasBean{
|
// }
|
||||||
public int action;
|
// }
|
||||||
public Set<String> tags;
|
// public static class TagAliasBean{
|
||||||
public String alias;
|
// public int action;
|
||||||
public boolean isAliasAction;
|
// public Set<String> tags;
|
||||||
|
// public String alias;
|
||||||
@Override
|
// public boolean isAliasAction;
|
||||||
public String toString() {
|
//
|
||||||
return "TagAliasBean{" +
|
// @Override
|
||||||
"action=" + action +
|
// public String toString() {
|
||||||
", tags=" + tags +
|
// return "TagAliasBean{" +
|
||||||
", alias='" + alias + '\'' +
|
// "action=" + action +
|
||||||
", isAliasAction=" + isAliasAction +
|
// ", tags=" + tags +
|
||||||
'}';
|
// ", alias='" + alias + '\'' +
|
||||||
}
|
// ", isAliasAction=" + isAliasAction +
|
||||||
}
|
// '}';
|
||||||
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import android.app.Application;
|
|||||||
|
|
||||||
import com.aoleyun.sn.jpush.Logger;
|
import com.aoleyun.sn.jpush.Logger;
|
||||||
|
|
||||||
import cn.jpush.android.api.JPushInterface;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For developer startup JPush SDK
|
* For developer startup JPush SDK
|
||||||
@@ -19,7 +18,7 @@ public class ExampleApplication extends Application {
|
|||||||
Logger.d(TAG, "[ExampleApplication] onCreate");
|
Logger.d(TAG, "[ExampleApplication] onCreate");
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
|
|
||||||
JPushInterface.setDebugMode(true); // 设置开启日志,发布时请关闭日志
|
// JPushInterface.setDebugMode(true); // 设置开启日志,发布时请关闭日志
|
||||||
JPushInterface.init(this); // 初始化 JPush
|
// JPushInterface.init(this); // 初始化 JPush
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import android.os.Bundle;
|
|||||||
import android.view.ViewGroup.LayoutParams;
|
import android.view.ViewGroup.LayoutParams;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import cn.jpush.android.api.JPushInterface;
|
|
||||||
|
|
||||||
public class TestActivity extends Activity {
|
public class TestActivity extends Activity {
|
||||||
|
|
||||||
@@ -21,8 +20,8 @@ public class TestActivity extends Activity {
|
|||||||
String title = null;
|
String title = null;
|
||||||
String content = null;
|
String content = null;
|
||||||
if(bundle!=null){
|
if(bundle!=null){
|
||||||
title = bundle.getString(JPushInterface.EXTRA_NOTIFICATION_TITLE);
|
// title = bundle.getString(JPushInterface.EXTRA_NOTIFICATION_TITLE);
|
||||||
content = bundle.getString(JPushInterface.EXTRA_ALERT);
|
// content = bundle.getString(JPushInterface.EXTRA_ALERT);
|
||||||
}
|
}
|
||||||
tv.setText("Title : " + title + " " + "Content : " + content);
|
tv.setText("Title : " + title + " " + "Content : " + content);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,6 +49,8 @@ import com.aoleyun.sn.utils.ForegroundAppUtil;
|
|||||||
import com.aoleyun.sn.utils.SPUtils;
|
import com.aoleyun.sn.utils.SPUtils;
|
||||||
import com.aoleyun.sn.utils.TimeUtils;
|
import com.aoleyun.sn.utils.TimeUtils;
|
||||||
import com.aoleyun.sn.utils.Utils;
|
import com.aoleyun.sn.utils.Utils;
|
||||||
|
import com.tencent.android.tpush.XGIOperateCallback;
|
||||||
|
import com.tencent.android.tpush.XGPushManager;
|
||||||
import com.tencent.mmkv.MMKV;
|
import com.tencent.mmkv.MMKV;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -69,8 +71,8 @@ import retrofit2.Retrofit;
|
|||||||
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
|
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
|
||||||
import retrofit2.converter.gson.GsonConverterFactory;
|
import retrofit2.converter.gson.GsonConverterFactory;
|
||||||
|
|
||||||
import static com.aoleyun.sn.jpush.TagAliasOperatorHelper.ACTION_SET;
|
//import static com.aoleyun.sn.jpush.TagAliasOperatorHelper.ACTION_SET;
|
||||||
import static com.aoleyun.sn.jpush.TagAliasOperatorHelper.sequence;
|
//import static com.aoleyun.sn.jpush.TagAliasOperatorHelper.sequence;
|
||||||
|
|
||||||
public class HTTPInterface {
|
public class HTTPInterface {
|
||||||
private static final String TAG = HTTPInterface.class.getSimpleName();
|
private static final String TAG = HTTPInterface.class.getSimpleName();
|
||||||
@@ -100,13 +102,13 @@ public class HTTPInterface {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized public static void setJpushTags(final Context context) {
|
synchronized public static void setPushTags(final Context context) {
|
||||||
NetInterfaceManager.getInstance()
|
NetInterfaceManager.getInstance()
|
||||||
.getJpushTagsObservable()
|
.getJpushTagsObservable()
|
||||||
.subscribe(new Observer<BaseResponse>() {
|
.subscribe(new Observer<BaseResponse>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSubscribe(@NonNull Disposable d) {
|
public void onSubscribe(@NonNull Disposable d) {
|
||||||
Log.e(TAG + ":" + "setJpushTags", "onSubscribe: ");
|
Log.e(TAG + ":" + "setPushTags", "onSubscribe: ");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -114,7 +116,7 @@ public class HTTPInterface {
|
|||||||
if (response.code == 200) {
|
if (response.code == 200) {
|
||||||
JsonObject jsonObject = JsonParser.parseString(new Gson().toJson(response.data)).getAsJsonObject();
|
JsonObject jsonObject = JsonParser.parseString(new Gson().toJson(response.data)).getAsJsonObject();
|
||||||
String batch = jsonObject.get("batch").getAsString();
|
String batch = jsonObject.get("batch").getAsString();
|
||||||
Log.e(TAG + ":" + "setJpushTags", "onNext: " + batch);
|
Log.e(TAG + ":" + "setPushTags", "onNext: " + batch);
|
||||||
if (!TextUtils.isEmpty(batch)) {
|
if (!TextUtils.isEmpty(batch)) {
|
||||||
Set set = new HashSet();
|
Set set = new HashSet();
|
||||||
set.add(batch);
|
set.add(batch);
|
||||||
@@ -128,36 +130,48 @@ public class HTTPInterface {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
setTag(context, set);
|
Set<String> tagsSet = new HashSet<>(set);
|
||||||
|
XGPushManager.clearAndAppendTags(context, "clearAndAppendTags :" + System.currentTimeMillis(), tagsSet, new XGIOperateCallback() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(Object o, int i) {
|
||||||
|
Log.e("setPushTags", "onSuccess: " + o);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFail(Object o, int i, String s) {
|
||||||
|
Log.e("setPushTags", "onFail: " + o);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// setTag(context, set);
|
||||||
} else {
|
} else {
|
||||||
Log.e(TAG + ":" + "setJpushTags", "onNext: " + "batch empty");
|
Log.e(TAG + ":" + "setPushTags", "onNext: " + "batch empty");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.e(TAG + ":" + "setJpushTags", "onNext: " + response.toString());
|
Log.e(TAG + ":" + "setPushTags", "onNext: " + response.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(@NonNull Throwable e) {
|
public void onError(@NonNull Throwable e) {
|
||||||
Log.e(TAG + ":" + "setJpushTags", "onError: " + e.getMessage());
|
Log.e(TAG + ":" + "setPushTags", "onError: " + e.getMessage());
|
||||||
onComplete();
|
onComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onComplete() {
|
public void onComplete() {
|
||||||
Log.e(TAG + ":" + "setJpushTags", "onComplete: ");
|
Log.e(TAG + ":" + "setPushTags", "onComplete: ");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void setTag(Context context, Set set) {
|
// private static void setTag(Context context, Set set) {
|
||||||
TagAliasOperatorHelper.TagAliasBean tagAliasBean = new TagAliasOperatorHelper.TagAliasBean();
|
// TagAliasOperatorHelper.TagAliasBean tagAliasBean = new TagAliasOperatorHelper.TagAliasBean();
|
||||||
tagAliasBean.action = ACTION_SET;
|
// tagAliasBean.action = ACTION_SET;
|
||||||
sequence++;
|
// sequence++;
|
||||||
tagAliasBean.tags = set;
|
// tagAliasBean.tags = set;
|
||||||
tagAliasBean.isAliasAction = false;
|
// tagAliasBean.isAliasAction = false;
|
||||||
TagAliasOperatorHelper.getInstance().handleAction(context, sequence, tagAliasBean);
|
// TagAliasOperatorHelper.getInstance().handleAction(context, sequence, tagAliasBean);
|
||||||
}
|
// }
|
||||||
|
|
||||||
public interface GetAppinsideWebCallback {
|
public interface GetAppinsideWebCallback {
|
||||||
void onComplete();
|
void onComplete();
|
||||||
@@ -802,28 +816,28 @@ public class HTTPInterface {
|
|||||||
.subscribe(new Observer<NetAndLaunchBean>() {
|
.subscribe(new Observer<NetAndLaunchBean>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSubscribe(@NonNull Disposable d) {
|
public void onSubscribe(@NonNull Disposable d) {
|
||||||
Log.e("getAppAutoStartUpdateAndNet", "onSubscribe: ");
|
Log.e("getAutoUpdateAndNet", "onSubscribe: ");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNext(@NonNull NetAndLaunchBean netAndLaunchBean) {
|
public void onNext(@NonNull NetAndLaunchBean netAndLaunchBean) {
|
||||||
Log.e("getAppAutoStartUpdateAndNet", "onNext: " + netAndLaunchBean.toString());
|
Log.e("getAutoUpdateAndNet", "onNext: " + netAndLaunchBean.toString());
|
||||||
if (netAndLaunchBean.getCode() == 200) {
|
if (netAndLaunchBean.getCode() == 200) {
|
||||||
JGYUtils.getInstance().setNetAndlaunch(netAndLaunchBean, appListInfos);
|
JGYUtils.getInstance().setNetAndlaunch(netAndLaunchBean, appListInfos);
|
||||||
} else {
|
} else {
|
||||||
Log.e("getAppAutoStartUpdateAndNet", "onNext: " + netAndLaunchBean.toString());
|
Log.e("getAutoUpdateAndNet", "onNext: " + netAndLaunchBean.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(@NonNull Throwable e) {
|
public void onError(@NonNull Throwable e) {
|
||||||
Log.e("getAppAutoStartUpdateAndNet", "onError: " + e.getMessage());
|
Log.e("getAutoUpdateAndNet", "onError: " + e.getMessage());
|
||||||
onComplete();
|
onComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onComplete() {
|
public void onComplete() {
|
||||||
Log.e("getAppAutoStartUpdateAndNet", "onComplete: ");
|
Log.e("getAutoUpdateAndNet", "onComplete: ");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ import com.aoleyun.sn.network.api.newapi.SnTimeControlApi;
|
|||||||
import com.aoleyun.sn.network.api.newapi.StudentsInfosApi;
|
import com.aoleyun.sn.network.api.newapi.StudentsInfosApi;
|
||||||
import com.aoleyun.sn.network.api.newapi.TopAppControlApi;
|
import com.aoleyun.sn.network.api.newapi.TopAppControlApi;
|
||||||
import com.aoleyun.sn.network.api.newapi.UpdateDeviceInfoApi;
|
import com.aoleyun.sn.network.api.newapi.UpdateDeviceInfoApi;
|
||||||
|
import com.aoleyun.sn.utils.JGYUtils;
|
||||||
import com.aoleyun.sn.utils.MD5Util;
|
import com.aoleyun.sn.utils.MD5Util;
|
||||||
import com.aoleyun.sn.utils.SPUtils;
|
import com.aoleyun.sn.utils.SPUtils;
|
||||||
import com.aoleyun.sn.utils.Utils;
|
import com.aoleyun.sn.utils.Utils;
|
||||||
@@ -70,7 +71,6 @@ import java.util.List;
|
|||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import cn.jpush.android.api.JPushInterface;
|
|
||||||
import io.reactivex.Observable;
|
import io.reactivex.Observable;
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
import io.reactivex.schedulers.Schedulers;
|
import io.reactivex.schedulers.Schedulers;
|
||||||
@@ -265,7 +265,8 @@ public class NetInterfaceManager {
|
|||||||
return mRetrofit.create(MACAddressApi.class)
|
return mRetrofit.create(MACAddressApi.class)
|
||||||
.sendMACaddress(Utils.getSerial(),
|
.sendMACaddress(Utils.getSerial(),
|
||||||
Utils.getAndroid10MAC(mContext),
|
Utils.getAndroid10MAC(mContext),
|
||||||
JPushInterface.getRegistrationID(mContext),
|
"0000",
|
||||||
|
// JPushInterface.getRegistrationID(mContext),
|
||||||
Utils.getCustomVersion(),
|
Utils.getCustomVersion(),
|
||||||
BuildConfig.VERSION_NAME,
|
BuildConfig.VERSION_NAME,
|
||||||
Utils.getAPPVersionName(PackageNames.APPSTORE, mContext),
|
Utils.getAPPVersionName(PackageNames.APPSTORE, mContext),
|
||||||
@@ -277,7 +278,8 @@ public class NetInterfaceManager {
|
|||||||
Utils.getBluetoothList(),
|
Utils.getBluetoothList(),
|
||||||
Utils.getWifiAlias(mContext),
|
Utils.getWifiAlias(mContext),
|
||||||
Utils.getAPPVersionName(PackageNames.BROWSER, mContext),
|
Utils.getAPPVersionName(PackageNames.BROWSER, mContext),
|
||||||
Utils.getAPPVersionName(PackageNames.NOTIFICATIONS, mContext)
|
Utils.getAPPVersionName(PackageNames.NOTIFICATIONS, mContext),
|
||||||
|
JGYUtils.getInstance().getAppPlatform()
|
||||||
)
|
)
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread());
|
.observeOn(AndroidSchedulers.mainThread());
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ package com.aoleyun.sn.network.api.newapi;
|
|||||||
import com.aoleyun.sn.bean.BaseResponse;
|
import com.aoleyun.sn.bean.BaseResponse;
|
||||||
import com.aoleyun.sn.network.UrlAddress;
|
import com.aoleyun.sn.network.UrlAddress;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
import io.reactivex.Observable;
|
import io.reactivex.Observable;
|
||||||
import retrofit2.http.Field;
|
import retrofit2.http.Field;
|
||||||
import retrofit2.http.FormUrlEncoded;
|
import retrofit2.http.FormUrlEncoded;
|
||||||
@@ -26,6 +28,7 @@ public interface MACAddressApi {
|
|||||||
@Field("bluetooth") String bluetooth,
|
@Field("bluetooth") String bluetooth,
|
||||||
@Field("wifi_name") String wifi_name,
|
@Field("wifi_name") String wifi_name,
|
||||||
@Field("browser_version") String browser_version,
|
@Field("browser_version") String browser_version,
|
||||||
@Field("notice_version") String notice_version
|
@Field("notice_version") String notice_version,
|
||||||
|
@Field("platform") String platform
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,9 +32,9 @@ import com.alibaba.fastjson.JSON;
|
|||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.aoleyun.sn.R;
|
import com.aoleyun.sn.R;
|
||||||
import com.aoleyun.sn.action.JGYActions;
|
import com.aoleyun.sn.action.JGYActions;
|
||||||
import com.aoleyun.sn.activity.MainActivity;
|
import com.aoleyun.sn.activity.main.MainActivity;
|
||||||
import com.aoleyun.sn.activity.MainContact;
|
import com.aoleyun.sn.activity.main.MainContact;
|
||||||
import com.aoleyun.sn.activity.MainPresenter;
|
import com.aoleyun.sn.activity.main.MainPresenter;
|
||||||
import com.aoleyun.sn.bean.PoweroffBean;
|
import com.aoleyun.sn.bean.PoweroffBean;
|
||||||
import com.aoleyun.sn.comm.PackageNames;
|
import com.aoleyun.sn.comm.PackageNames;
|
||||||
import com.aoleyun.sn.receiver.BootReceiver;
|
import com.aoleyun.sn.receiver.BootReceiver;
|
||||||
@@ -64,7 +64,6 @@ import java.util.HashSet;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import cn.jpush.android.api.JPushInterface;
|
|
||||||
import io.reactivex.Observable;
|
import io.reactivex.Observable;
|
||||||
import io.reactivex.ObservableEmitter;
|
import io.reactivex.ObservableEmitter;
|
||||||
import io.reactivex.ObservableOnSubscribe;
|
import io.reactivex.ObservableOnSubscribe;
|
||||||
@@ -210,7 +209,7 @@ public class MainService extends Service implements MainContact.MainView, Networ
|
|||||||
Intent bootIntent = new Intent(BootReceiver.BOOT_COMPLETED);
|
Intent bootIntent = new Intent(BootReceiver.BOOT_COMPLETED);
|
||||||
bootIntent.setComponent(new ComponentName(PackageNames.APPSTORE, PackageNames.APP_STORE_BOOTRECEIVER));
|
bootIntent.setComponent(new ComponentName(PackageNames.APPSTORE, PackageNames.APP_STORE_BOOTRECEIVER));
|
||||||
sendBroadcast(bootIntent);
|
sendBroadcast(bootIntent);
|
||||||
JPushInterface.init(this);
|
// JPushInterface.init(this);
|
||||||
if (MainActivity.isForeground) {
|
if (MainActivity.isForeground) {
|
||||||
Log.e(TAG, "onStartCommand: MainService: isForeground: " + MainActivity.isForeground);
|
Log.e(TAG, "onStartCommand: MainService: isForeground: " + MainActivity.isForeground);
|
||||||
} else {
|
} else {
|
||||||
@@ -649,7 +648,7 @@ public class MainService extends Service implements MainContact.MainView, Networ
|
|||||||
//设置极光推送别名
|
//设置极光推送别名
|
||||||
mPresenter.setJpushAlias();
|
mPresenter.setJpushAlias();
|
||||||
//设置极光推送标签
|
//设置极光推送标签
|
||||||
mPresenter.setJpushTags();
|
mPresenter.setPushTags();
|
||||||
if (loocked) {
|
if (loocked) {
|
||||||
ToastUtil.betaShow("设备已上锁");
|
ToastUtil.betaShow("设备已上锁");
|
||||||
//上传APP信息
|
//上传APP信息
|
||||||
@@ -842,8 +841,6 @@ public class MainService extends Service implements MainContact.MainView, Networ
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void getDefaultDesktopFinish() {
|
public void getDefaultDesktopFinish() {
|
||||||
netWorkIsRunning = false;
|
|
||||||
Log.e(TAG, "SettingFinished: " + (SystemClock.elapsedRealtime() - runningTime) + " ms");
|
|
||||||
mPresenter.getPoweroffTime();
|
mPresenter.getPoweroffTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -854,7 +851,9 @@ public class MainService extends Service implements MainContact.MainView, Networ
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setWiFiPasswd() {
|
public void setWiFiPasswd() {
|
||||||
|
MMKV.defaultMMKV().encode(MainPresenter.GET_SETTING_FINISH_TIME, System.currentTimeMillis());
|
||||||
|
netWorkIsRunning = false;
|
||||||
|
Log.e(TAG, "SettingFinished: " + (SystemClock.elapsedRealtime() - runningTime) + " ms");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
17
app/src/main/java/com/aoleyun/sn/tpush/Constants.java
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
package com.aoleyun.sn.tpush;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by chacewang on 2019/7/5.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class Constants {
|
||||||
|
public static final int TEST_LOCAL_NOTIFICATION = 1;
|
||||||
|
public static final int TEST_NOTIFICATION = 2;
|
||||||
|
public static final int TEST_SET_TAG = 3;
|
||||||
|
public static final int TEST_DEL_TAG = 4;
|
||||||
|
public static final int TEST_SET_ACCOUNT = 5;
|
||||||
|
public static final int TEST_DEL_ACCOUNT = 6;
|
||||||
|
|
||||||
|
public static final String LOCAL_NOTIFICATION_TITLE = "localtest";
|
||||||
|
public static final String TEST_TAG_NAME = "DiagnosisTag";
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package com.aoleyun.sn.receiver;
|
package com.aoleyun.sn.tpush;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.ContentResolver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.ContextWrapper;
|
import android.content.ContextWrapper;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@@ -17,49 +17,57 @@ import android.os.Handler;
|
|||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.amap.api.location.AMapLocation;
|
import com.amap.api.location.AMapLocation;
|
||||||
import com.amap.api.location.AMapLocationClient;
|
import com.amap.api.location.AMapLocationClient;
|
||||||
import com.amap.api.location.AMapLocationListener;
|
import com.amap.api.location.AMapLocationListener;
|
||||||
|
import com.aoleyun.sn.R;
|
||||||
import com.aoleyun.sn.action.JGYActions;
|
import com.aoleyun.sn.action.JGYActions;
|
||||||
|
import com.aoleyun.sn.base.BaseApplication;
|
||||||
import com.aoleyun.sn.bean.BaseResponse;
|
import com.aoleyun.sn.bean.BaseResponse;
|
||||||
import com.aoleyun.sn.bean.RemoteDebug;
|
import com.aoleyun.sn.bean.RemoteDebug;
|
||||||
import com.aoleyun.sn.bean.TTAppground;
|
|
||||||
import com.arialyy.aria.core.Aria;
|
|
||||||
import com.blankj.utilcode.util.PathUtils;
|
|
||||||
import com.aoleyun.sn.R;
|
|
||||||
import com.aoleyun.sn.utils.CacheUtils;
|
|
||||||
import com.aoleyun.sn.utils.JGYUtils;
|
|
||||||
import com.aoleyun.sn.base.BaseApplication;
|
|
||||||
import com.aoleyun.sn.comm.CommonDatas;
|
import com.aoleyun.sn.comm.CommonDatas;
|
||||||
import com.aoleyun.sn.manager.AmapManager;
|
import com.aoleyun.sn.manager.AmapManager;
|
||||||
import com.aoleyun.sn.network.NetInterfaceManager;
|
|
||||||
import com.aoleyun.sn.network.HTTPInterface;
|
import com.aoleyun.sn.network.HTTPInterface;
|
||||||
|
import com.aoleyun.sn.network.NetInterfaceManager;
|
||||||
import com.aoleyun.sn.service.MainService;
|
import com.aoleyun.sn.service.MainService;
|
||||||
|
import com.aoleyun.sn.tpush.common.NotificationService;
|
||||||
|
import com.aoleyun.sn.tpush.po.XGNotification;
|
||||||
import com.aoleyun.sn.utils.ApkUtils;
|
import com.aoleyun.sn.utils.ApkUtils;
|
||||||
|
import com.aoleyun.sn.utils.CacheUtils;
|
||||||
import com.aoleyun.sn.utils.CmdUtil;
|
import com.aoleyun.sn.utils.CmdUtil;
|
||||||
import com.aoleyun.sn.utils.ForegroundAppUtil;
|
import com.aoleyun.sn.utils.ForegroundAppUtil;
|
||||||
|
import com.aoleyun.sn.utils.JGYUtils;
|
||||||
import com.aoleyun.sn.utils.MySQLData;
|
import com.aoleyun.sn.utils.MySQLData;
|
||||||
import com.aoleyun.sn.utils.SPUtils;
|
import com.aoleyun.sn.utils.SPUtils;
|
||||||
import com.aoleyun.sn.utils.SaveListUtils;
|
import com.aoleyun.sn.utils.SaveListUtils;
|
||||||
import com.aoleyun.sn.utils.ServiceAliveUtils;
|
import com.aoleyun.sn.utils.ServiceAliveUtils;
|
||||||
import com.aoleyun.sn.utils.ToastUtil;
|
import com.aoleyun.sn.utils.ToastUtil;
|
||||||
import com.aoleyun.sn.utils.Utils;
|
import com.aoleyun.sn.utils.Utils;
|
||||||
|
import com.arialyy.aria.core.Aria;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import com.google.gson.JsonParser;
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
import com.tencent.android.tpush.NotificationAction;
|
||||||
|
import com.tencent.android.tpush.XGPushBaseReceiver;
|
||||||
|
import com.tencent.android.tpush.XGPushClickedResult;
|
||||||
|
import com.tencent.android.tpush.XGPushRegisterResult;
|
||||||
|
import com.tencent.android.tpush.XGPushShowedResult;
|
||||||
|
import com.tencent.android.tpush.XGPushTextMessage;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.util.ArrayList;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Calendar;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import cn.jpush.android.api.JPushInterface;
|
|
||||||
import io.reactivex.Observable;
|
import io.reactivex.Observable;
|
||||||
import io.reactivex.ObservableEmitter;
|
import io.reactivex.ObservableEmitter;
|
||||||
import io.reactivex.ObservableOnSubscribe;
|
import io.reactivex.ObservableOnSubscribe;
|
||||||
@@ -72,8 +80,12 @@ import okhttp3.MultipartBody;
|
|||||||
import okhttp3.RequestBody;
|
import okhttp3.RequestBody;
|
||||||
import okhttp3.ResponseBody;
|
import okhttp3.ResponseBody;
|
||||||
|
|
||||||
public class MyJPushReceiver extends BroadcastReceiver {
|
public class MessageReceiver extends XGPushBaseReceiver {
|
||||||
private static final String TAG = MyJPushReceiver.class.getSimpleName();
|
public static final String UPDATE_LISTVIEW_ACTION = "com.qq.xgdemo.activity.UPDATE_LISTVIEW";
|
||||||
|
public static final String TEST_ACTION = "com.qq.xgdemo.activity.TEST_ACTION";
|
||||||
|
public static final String LogTag = "xg.test";
|
||||||
|
|
||||||
|
private static final String TAG = MessageReceiver.class.getSimpleName();
|
||||||
|
|
||||||
//删除应用
|
//删除应用
|
||||||
private final String MSG_DELETE = "1";
|
private final String MSG_DELETE = "1";
|
||||||
@@ -156,57 +168,281 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
|||||||
//自定义指令
|
//自定义指令
|
||||||
private final String CUSTOM_ORDER = "44";
|
private final String CUSTOM_ORDER = "44";
|
||||||
|
|
||||||
|
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
|
private ContentResolver mResolver;
|
||||||
|
private PackageManager mPackageManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消息透传处理
|
||||||
|
*
|
||||||
|
* @param context
|
||||||
|
* @param message 解析自定义的 JSON
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void onTextMessage(Context context, XGPushTextMessage message) {
|
||||||
|
this.mContext = context;
|
||||||
|
this.mResolver = context.getContentResolver();
|
||||||
|
this.mPackageManager = context.getPackageManager();
|
||||||
|
String text = "收到消息:" + message.toString();
|
||||||
|
// 获取自定义key-value
|
||||||
|
String customContent = message.getCustomContent();
|
||||||
|
if (customContent != null && customContent.length() != 0) {
|
||||||
|
JsonObject obj = JsonParser.parseString(customContent).getAsJsonObject();
|
||||||
|
// key1为前台配置的key
|
||||||
|
if (!TextUtils.isEmpty(obj.get("key").getAsString())) {
|
||||||
|
String value = obj.get("key").getAsString();
|
||||||
|
Log.d(LogTag, "get custom value:" + value);
|
||||||
|
}
|
||||||
|
// ...
|
||||||
|
}
|
||||||
|
// APP自主处理消息的过程...
|
||||||
|
Log.e(LogTag, text);
|
||||||
|
show(context, text);
|
||||||
|
processCustomMessage(context, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通知展示
|
||||||
|
*
|
||||||
|
* @param context
|
||||||
|
* @param notifiShowedRlt 包含通知的内容
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void onNotificationShowedResult(Context context, XGPushShowedResult notifiShowedRlt) {
|
||||||
|
if (context == null || notifiShowedRlt == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
XGNotification notific = new XGNotification();
|
||||||
|
notific.setMsg_id(notifiShowedRlt.getMsgId());
|
||||||
|
notific.setTitle(notifiShowedRlt.getTitle());
|
||||||
|
notific.setContent(notifiShowedRlt.getContent());
|
||||||
|
// notificationActionType==1为Activity,2为url,3为intent
|
||||||
|
notific.setNotificationActionType(notifiShowedRlt
|
||||||
|
.getNotificationActionType());
|
||||||
|
// Activity,url,intent都可以通过getActivity()获得
|
||||||
|
notific.setActivity(notifiShowedRlt.getActivity());
|
||||||
|
notific.setUpdate_time(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
|
||||||
|
.format(Calendar.getInstance().getTime()));
|
||||||
|
NotificationService.getInstance(context).save(notific);
|
||||||
|
|
||||||
|
Intent testIntent = new Intent(TEST_ACTION);
|
||||||
|
if (notifiShowedRlt.getTitle().equals(Constants.LOCAL_NOTIFICATION_TITLE)) {
|
||||||
|
testIntent.putExtra("step", Constants.TEST_LOCAL_NOTIFICATION);
|
||||||
|
} else {
|
||||||
|
testIntent.putExtra("step", Constants.TEST_NOTIFICATION);
|
||||||
|
}
|
||||||
|
context.sendBroadcast(testIntent);
|
||||||
|
|
||||||
|
Intent viewIntent = new Intent(UPDATE_LISTVIEW_ACTION);
|
||||||
|
context.sendBroadcast(viewIntent);
|
||||||
|
show(context, "您有1条新消息, " + "通知被展示 , " + notifiShowedRlt.toString());
|
||||||
|
Log.d(LogTag, "您有1条新消息, " + "通知被展示 , " + notifiShowedRlt.toString() + ", PushChannel:" + notifiShowedRlt.getPushChannel());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 注册回调
|
||||||
|
*
|
||||||
|
* @param context
|
||||||
|
* @param errorCode 0 为成功,其它为错误码
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void onRegisterResult(Context context, int errorCode, XGPushRegisterResult message) {
|
||||||
|
if (context == null || message == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String text = "";
|
||||||
|
if (errorCode == XGPushBaseReceiver.SUCCESS) {
|
||||||
|
// 在这里拿token
|
||||||
|
String token = message.getToken();
|
||||||
|
text = "注册成功1. token:" + token;
|
||||||
|
} else {
|
||||||
|
text = message + "注册失败,错误码:" + errorCode;
|
||||||
|
}
|
||||||
|
Log.d(LogTag, text);
|
||||||
|
show(context, text);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 反注册回调
|
||||||
|
*
|
||||||
|
* @param context
|
||||||
|
* @param errorCode 0 为成功,其它为错误码
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void onUnregisterResult(Context context, int errorCode) {
|
||||||
|
if (context == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String text = "";
|
||||||
|
if (errorCode == XGPushBaseReceiver.SUCCESS) {
|
||||||
|
text = "反注册成功";
|
||||||
|
} else {
|
||||||
|
text = "反注册失败" + errorCode;
|
||||||
|
}
|
||||||
|
Log.d(LogTag, text);
|
||||||
|
show(context, text);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置标签回调
|
||||||
|
*
|
||||||
|
* @param context
|
||||||
|
* @param errorCode 0 为成功,其它为错误码
|
||||||
|
* @param tagName 设置的 TAG
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void onSetTagResult(Context context, int errorCode, String tagName) {
|
||||||
|
if (context == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String text = "";
|
||||||
|
if (errorCode == XGPushBaseReceiver.SUCCESS) {
|
||||||
|
text = "\"" + tagName + "\"设置成功";
|
||||||
|
} else {
|
||||||
|
text = "\"" + tagName + "\"设置失败,错误码:" + errorCode;
|
||||||
|
}
|
||||||
|
Log.d(LogTag, text);
|
||||||
|
show(context, text);
|
||||||
|
|
||||||
|
Intent testIntent = new Intent(TEST_ACTION);
|
||||||
|
testIntent.putExtra("step", Constants.TEST_SET_TAG);
|
||||||
|
context.sendBroadcast(testIntent);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除标签的回调
|
||||||
|
*
|
||||||
|
* @param context
|
||||||
|
* @param errorCode 0 为成功,其它为错误码
|
||||||
|
* @param tagName 设置的 TAG
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void onDeleteTagResult(Context context, int errorCode, String tagName) {
|
||||||
|
if (context == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String text = "";
|
||||||
|
if (errorCode == XGPushBaseReceiver.SUCCESS) {
|
||||||
|
text = "\"" + tagName + "\"删除成功";
|
||||||
|
} else {
|
||||||
|
text = "\"" + tagName + "\"删除失败,错误码:" + errorCode;
|
||||||
|
}
|
||||||
|
Log.d(LogTag, text);
|
||||||
|
show(context, text);
|
||||||
|
|
||||||
|
Intent testIntent = new Intent(TEST_ACTION);
|
||||||
|
testIntent.putExtra("step", Constants.TEST_DEL_TAG);
|
||||||
|
context.sendBroadcast(testIntent);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置账号回调
|
||||||
|
*
|
||||||
|
* @param context
|
||||||
|
* @param errorCode 0 为成功,其它为错误码
|
||||||
|
* @param account 设置的账号
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void onSetAccountResult(Context context, int errorCode, String account) {
|
||||||
|
Intent testIntent = new Intent(TEST_ACTION);
|
||||||
|
testIntent.putExtra("step", Constants.TEST_SET_ACCOUNT);
|
||||||
|
context.sendBroadcast(testIntent);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除账号回调
|
||||||
|
*
|
||||||
|
* @param context
|
||||||
|
* @param errorCode 0 为成功,其它为错误码
|
||||||
|
* @param account 设置的账号
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void onDeleteAccountResult(Context context, int errorCode, String account) {
|
||||||
|
Intent testIntent = new Intent(TEST_ACTION);
|
||||||
|
testIntent.putExtra("step", Constants.TEST_DEL_ACCOUNT);
|
||||||
|
context.sendBroadcast(testIntent);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSetAttributeResult(Context context, int i, String s) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDeleteAttributeResult(Context context, int i, String s) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onQueryTagsResult(Context context, int errorCode, String data, String operateName) {
|
||||||
|
Log.i(LogTag, "action - onQueryTagsResult, errorCode:" + errorCode + ", operateName:" + operateName + ", data: " + data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通知点击回调 actionType=1为该消息被清除,actionType=0为该消息被点击
|
||||||
|
*
|
||||||
|
* @param context
|
||||||
|
* @param message 包含被点击通知的内容
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void onNotificationClickedResult(Context context, XGPushClickedResult message) {
|
||||||
|
if (context == null || message == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String text = "";
|
||||||
|
if (message.getActionType() == NotificationAction.clicked.getType()) {
|
||||||
|
// 通知在通知栏被点击啦。。。。。
|
||||||
|
// APP自己处理点击的相关动作
|
||||||
|
// 这个动作可以在activity的onResume也能监听,请看第3点相关内容
|
||||||
|
text = "通知被打开 :" + message;
|
||||||
|
} else if (message.getActionType() == NotificationAction.delete.getType()) {
|
||||||
|
// 通知被清除啦。。。。
|
||||||
|
// APP自己处理通知被清除后的相关动作
|
||||||
|
text = "通知被清除 :" + message;
|
||||||
|
}
|
||||||
|
Toast.makeText(context, "广播接收到通知被点击:" + message.toString(),
|
||||||
|
Toast.LENGTH_SHORT).show();
|
||||||
|
// 获取自定义key-value
|
||||||
|
String customContent = message.getCustomContent();
|
||||||
|
if (customContent != null && customContent.length() != 0) {
|
||||||
|
JsonObject obj = JsonParser.parseString(customContent).getAsJsonObject();
|
||||||
|
// key1为前台配置的key
|
||||||
|
if (!TextUtils.isEmpty(obj.get("key").getAsString())) {
|
||||||
|
String value = obj.get("key").getAsString();
|
||||||
|
Log.d(LogTag, "get custom value:" + value);
|
||||||
|
}
|
||||||
|
// ...
|
||||||
|
}
|
||||||
|
// APP自主处理的过程。。。
|
||||||
|
Log.d(LogTag, text);
|
||||||
|
show(context, text);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void show(Context context, String text) {
|
||||||
|
Toast.makeText(context, text, Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
|
||||||
private int changeNum(int paramInt) {
|
private int changeNum(int paramInt) {
|
||||||
return paramInt == 0 ? 1 : 0;
|
return paramInt == 0 ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private void processCustomMessage(Context context, XGPushTextMessage message) {
|
||||||
public void onReceive(Context context, Intent intent) {
|
if (context == null || message == null) {
|
||||||
mContext = context;
|
return;
|
||||||
Bundle bundle = intent.getExtras();
|
|
||||||
|
|
||||||
if (JPushInterface.ACTION_REGISTRATION_ID.equals(intent.getAction())) {
|
|
||||||
String regId = bundle.getString(JPushInterface.EXTRA_REGISTRATION_ID);
|
|
||||||
Log.e(TAG, "[MyReceiver] 接收Registration Id : " + regId);
|
|
||||||
//send the Registration Id to your server...
|
|
||||||
} else if (JPushInterface.ACTION_MESSAGE_RECEIVED.equals(intent.getAction())) {
|
|
||||||
// ToastTool.show("[MyReceiver] 接收到推送下来的自定义消息: " + bundle.getString(JPushInterface.EXTRA_MESSAGE)
|
|
||||||
// + "---" + bundle.getString(JPushInterface.EXTRA_TITLE) + "---" + bundle.getString(JPushInterface.EXTRA_CONTENT_TYPE)
|
|
||||||
// + "---" + bundle.getString(JPushInterface.EXTRA_EXTRA) + "----" + bundle.getString("package_name"));
|
|
||||||
// Log.e(TAG, "[MyReceiver] 接收到推送下来的自定义消息: " + bundle.getString(JPushInterface.EXTRA_MESSAGE)
|
|
||||||
// + "---" + bundle.getString(JPushInterface.EXTRA_TITLE) + "---" + bundle.getString(JPushInterface.EXTRA_CONTENT_TYPE)
|
|
||||||
// + "---" + bundle.getString(JPushInterface.EXTRA_EXTRA) + "----" + bundle.getString("package_name"));
|
|
||||||
processCustomMessage(context, bundle);//屏蔽推送
|
|
||||||
} else if (JPushInterface.ACTION_NOTIFICATION_RECEIVED.equals(intent.getAction())) {
|
|
||||||
Log.e(TAG, "[MyReceiver] 接收到推送下来的通知" + bundle.getString(JPushInterface.EXTRA_EXTRA));
|
|
||||||
// doDownloadAndInstall(bundle.getString(JPushInterface.EXTRA_EXTRA));
|
|
||||||
// Log.e(getBatteryLevel()+"-0-iweroiwerewefeerer-----------");
|
|
||||||
int notifactionId = bundle.getInt(JPushInterface.EXTRA_NOTIFICATION_ID);
|
|
||||||
Log.e(TAG, "[MyReceiver] 接收到推送下来的通知的ID: " + notifactionId);
|
|
||||||
} else if (JPushInterface.ACTION_NOTIFICATION_OPENED.equals(intent.getAction())) {
|
|
||||||
Log.e(TAG, "[MyReceiver] 用户点击打开了通知");
|
|
||||||
} else if (JPushInterface.ACTION_RICHPUSH_CALLBACK.equals(intent.getAction())) {
|
|
||||||
Log.e(TAG, "[MyReceiver] 用户收到到RICH PUSH CALLBACK: " + bundle.getString(JPushInterface.EXTRA_EXTRA));
|
|
||||||
//在这里根据 JPushInterface.EXTRA_EXTRA 的内容处理代码,比如打开新的Activity, 打开一个网页等..
|
|
||||||
} else if (JPushInterface.ACTION_CONNECTION_CHANGE.equals(intent.getAction())) {
|
|
||||||
boolean connected = intent.getBooleanExtra(JPushInterface.EXTRA_CONNECTION_CHANGE, false);
|
|
||||||
Log.i(TAG, "[MyReceiver]" + intent.getAction() + " connected state change to " + connected);
|
|
||||||
} else {
|
|
||||||
Log.e(TAG, "[MyReceiver] Unhandled intent - " + intent.getAction());
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void processCustomMessage(final Context context, Bundle bundle) {
|
String title = message.getTitle();
|
||||||
String message = bundle.getString(JPushInterface.EXTRA_MESSAGE);
|
String content = message.getContent();
|
||||||
String title = bundle.getString(JPushInterface.EXTRA_TITLE);
|
JsonObject extrasJson = JsonParser.parseString(content).getAsJsonObject();
|
||||||
String type = bundle.getString(JPushInterface.EXTRA_CONTENT_TYPE);
|
|
||||||
String extras = bundle.getString(JPushInterface.EXTRA_EXTRA);
|
String extras = "";
|
||||||
String package_name = bundle.getString("package_name");
|
if (extrasJson.get("extras") != null) {
|
||||||
Log.e(TAG, "message::" + message + "--type::" + type + "--title::" + title + "--extras::" + extras);
|
extras = extrasJson.get("extras").toString();
|
||||||
switch (message) {
|
}
|
||||||
|
|
||||||
|
switch (title) {
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
case MSG_DELETE:
|
case MSG_DELETE:
|
||||||
@@ -218,7 +454,7 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
|||||||
SaveListUtils.sendForceAPP(mContext);
|
SaveListUtils.sendForceAPP(mContext);
|
||||||
ApkUtils.UninstallAPP(mContext, title);
|
ApkUtils.UninstallAPP(mContext, title);
|
||||||
}
|
}
|
||||||
HTTPInterface.getAppLimit(context);
|
HTTPInterface.getAppLimit(mContext);
|
||||||
HTTPInterface.getNetAndLaunchSetting(mContext);
|
HTTPInterface.getNetAndLaunchSetting(mContext);
|
||||||
break;
|
break;
|
||||||
case MSG_SETTING:
|
case MSG_SETTING:
|
||||||
@@ -249,7 +485,7 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
|||||||
break;
|
break;
|
||||||
case MSG_INSTALL:
|
case MSG_INSTALL:
|
||||||
ToastUtil.betaShow("收到管控:应用安装");
|
ToastUtil.betaShow("收到管控:应用安装");
|
||||||
HTTPInterface.getAppLimit(context);
|
HTTPInterface.getAppLimit(mContext);
|
||||||
doDownloadAndInstall(extras);
|
doDownloadAndInstall(extras);
|
||||||
HTTPInterface.setHideDesktopIcon(mContext);
|
HTTPInterface.setHideDesktopIcon(mContext);
|
||||||
break;
|
break;
|
||||||
@@ -269,9 +505,9 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
|||||||
break;
|
break;
|
||||||
case GET_APP_USEDTIME:
|
case GET_APP_USEDTIME:
|
||||||
ToastUtil.betaShow("收到管控:获取应用使用时间");
|
ToastUtil.betaShow("收到管控:获取应用使用时间");
|
||||||
JSONObject jsonObject = JSON.parseObject(extras);
|
JSONObject usedTimeJson = JSON.parseObject(extras);
|
||||||
String random = jsonObject.getString("random");
|
String random = usedTimeJson.getString("random");
|
||||||
String sendType = jsonObject.getString("type");
|
String sendType = usedTimeJson.getString("type");
|
||||||
BaseApplication.sendAppUsedTime(random, sendType);
|
BaseApplication.sendAppUsedTime(random, sendType);
|
||||||
break;
|
break;
|
||||||
case GET_FORCEDOWNLOADURL:
|
case GET_FORCEDOWNLOADURL:
|
||||||
@@ -306,7 +542,7 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
Log.e(TAG, "setHomepagtag: " + e.getMessage());
|
Log.e(TAG, "setHomepagtag: " + e.getMessage());
|
||||||
}
|
}
|
||||||
setHomepagtag(extras);
|
setHomepagtag();
|
||||||
ToastUtil.betaShow("收到管控:浏览器主页书签设置");
|
ToastUtil.betaShow("收到管控:浏览器主页书签设置");
|
||||||
}
|
}
|
||||||
}, 2000);
|
}, 2000);
|
||||||
@@ -325,7 +561,7 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
|||||||
Handler.getMain().postDelayed(() -> {
|
Handler.getMain().postDelayed(() -> {
|
||||||
//后台发送时数据库未改变,有时候可能获取到的数据时上一次的
|
//后台发送时数据库未改变,有时候可能获取到的数据时上一次的
|
||||||
Log.e(TAG, "run: HIDE_DESKTOP_ICON ");
|
Log.e(TAG, "run: HIDE_DESKTOP_ICON ");
|
||||||
HTTPInterface.setHideDesktopIcon(context);
|
HTTPInterface.setHideDesktopIcon(mContext);
|
||||||
}, 2000);
|
}, 2000);
|
||||||
break;
|
break;
|
||||||
case DISABLE_APP_SLIDE:
|
case DISABLE_APP_SLIDE:
|
||||||
@@ -334,7 +570,7 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
|||||||
break;
|
break;
|
||||||
case UPDATE_INFO:
|
case UPDATE_INFO:
|
||||||
ToastUtil.betaShow("收到管控:更新白名单");
|
ToastUtil.betaShow("收到管控:更新白名单");
|
||||||
HTTPInterface.getAppLimit(context);
|
HTTPInterface.getAppLimit(mContext);
|
||||||
break;
|
break;
|
||||||
case SN_SCREENSHOT:
|
case SN_SCREENSHOT:
|
||||||
ToastUtil.betaShow("收到管控:设备截图");
|
ToastUtil.betaShow("收到管控:设备截图");
|
||||||
@@ -384,42 +620,42 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
|||||||
ToastUtil.betaShow("收到管控:屏幕锁定");
|
ToastUtil.betaShow("收到管控:屏幕锁定");
|
||||||
JSONObject lockJSONObject = JSON.parseObject(extras);
|
JSONObject lockJSONObject = JSON.parseObject(extras);
|
||||||
String name = lockJSONObject.getString("name");
|
String name = lockJSONObject.getString("name");
|
||||||
setLock_screen(1, context, name);
|
setLock_screen(1, name);
|
||||||
break;
|
break;
|
||||||
case UNLOCK_SCREEN:
|
case UNLOCK_SCREEN:
|
||||||
ToastUtil.betaShow("收到管控:屏幕解锁");
|
ToastUtil.betaShow("收到管控:屏幕解锁");
|
||||||
setLock_screen(0, context, "");
|
setLock_screen(0, "");
|
||||||
break;
|
break;
|
||||||
case KILL_SERVER:
|
case KILL_SERVER:
|
||||||
ToastUtil.betaShow("收到管控:停止应用");
|
ToastUtil.betaShow("收到管控:停止应用");
|
||||||
JSONObject killJSONObject = JSON.parseObject(extras);
|
JSONObject killJSONObject = JSON.parseObject(extras);
|
||||||
String packages = killJSONObject.getString("package_name");
|
String packages = killJSONObject.getString("package_name");
|
||||||
JGYUtils.getInstance().killBackgroundProcesses(context, packages);
|
JGYUtils.getInstance().killBackgroundProcesses(mContext, packages);
|
||||||
break;
|
break;
|
||||||
case TIME_CONTROL:
|
case TIME_CONTROL:
|
||||||
ToastUtil.betaShow("收到管控:使用时间管控");
|
ToastUtil.betaShow("收到管控:使用时间管控");
|
||||||
getTimeControl(context, extras);
|
getTimeControl(extras);
|
||||||
break;
|
break;
|
||||||
case TOP_APP:
|
case TOP_APP:
|
||||||
ToastUtil.betaShow("收到管控:应用霸屏");
|
ToastUtil.betaShow("收到管控:应用霸屏");
|
||||||
getTopApp(context, extras);
|
getTopApp(extras);
|
||||||
break;
|
break;
|
||||||
case LOGO_IMG:
|
case LOGO_IMG:
|
||||||
ToastUtil.betaShow("收到管控:开机动画设置");
|
ToastUtil.betaShow("收到管控:开机动画设置");
|
||||||
setBootanimation(context, extras);
|
setBootanimation(extras);
|
||||||
Log.e(TAG, "processCustomMessage: " + extras);
|
Log.e(TAG, "processCustomMessage: " + extras);
|
||||||
break;
|
break;
|
||||||
case DEFAULTP_APP:
|
case DEFAULTP_APP:
|
||||||
ToastUtil.betaShow("收到管控:");
|
ToastUtil.betaShow("收到管控:");
|
||||||
setDefalutApp(context, extras);
|
setDefalutApp(extras);
|
||||||
break;
|
break;
|
||||||
case PLAY_SOUND:
|
case PLAY_SOUND:
|
||||||
ToastUtil.betaShow("收到管控:查找设备");
|
ToastUtil.betaShow("收到管控:查找设备");
|
||||||
playSound(context, extras);
|
playSound(extras);
|
||||||
break;
|
break;
|
||||||
case CLEAN_APP_CACHE:
|
case CLEAN_APP_CACHE:
|
||||||
ToastUtil.betaShow("收到管控:应用缓存清除");
|
ToastUtil.betaShow("收到管控:应用缓存清除");
|
||||||
cleanCache(context, extras);
|
cleanCache(extras);
|
||||||
break;
|
break;
|
||||||
case DEVELOPER_OPTIONS:
|
case DEVELOPER_OPTIONS:
|
||||||
ToastUtil.betaShow("收到管控:开发人员选项管控");
|
ToastUtil.betaShow("收到管控:开发人员选项管控");
|
||||||
@@ -432,7 +668,7 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
|||||||
case EBAG_CODE:
|
case EBAG_CODE:
|
||||||
ToastUtil.betaShow("收到管控:电子书包激活码");
|
ToastUtil.betaShow("收到管控:电子书包激活码");
|
||||||
setEbagCode(extras);
|
setEbagCode(extras);
|
||||||
JGYUtils.getInstance().killBackgroundProcesses(context, "com.jxw.launcher");
|
JGYUtils.getInstance().killBackgroundProcesses(mContext, "com.jxw.launcher");
|
||||||
break;
|
break;
|
||||||
case UPDATE_WHITELIST:
|
case UPDATE_WHITELIST:
|
||||||
ToastUtil.betaShow("收到管控:更新白名单");
|
ToastUtil.betaShow("收到管控:更新白名单");
|
||||||
@@ -455,24 +691,23 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case UPDATE_WIFI_PW:
|
case UPDATE_WIFI_PW:
|
||||||
HTTPInterface.getWiFiPasswd(context);
|
HTTPInterface.getWiFiPasswd(mContext);
|
||||||
break;
|
break;
|
||||||
case DEVICES_POWEROFF:
|
case DEVICES_POWEROFF:
|
||||||
HTTPInterface.getPoweroffTime();
|
HTTPInterface.getPoweroffTime();
|
||||||
break;
|
break;
|
||||||
case SN_RUN_LOG:
|
case SN_RUN_LOG:
|
||||||
recordLog(context, extras);
|
recordLog(extras);
|
||||||
break;
|
break;
|
||||||
case CUSTOM_ORDER:
|
case CUSTOM_ORDER:
|
||||||
customOrder(context, extras);
|
customOrder(extras);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setLock_screen(int state, Context context, String name) {
|
private void setLock_screen(int state, String name) {
|
||||||
if (ServiceAliveUtils.isServiceAlive(context)) {
|
if (ServiceAliveUtils.isServiceAlive(mContext)) {
|
||||||
context.startService(new Intent(context, MainService.class));
|
mContext.startService(new Intent(mContext, MainService.class));
|
||||||
}
|
}
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
intent.putExtra("name", name);
|
intent.putExtra("name", name);
|
||||||
@@ -481,7 +716,7 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
|||||||
} else if (state == 0) {
|
} else if (state == 0) {
|
||||||
intent.setAction(MainService.LockScreenReceiver.action_unlock);
|
intent.setAction(MainService.LockScreenReceiver.action_unlock);
|
||||||
}
|
}
|
||||||
context.sendBroadcast(intent);
|
mContext.sendBroadcast(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doDownloadAndInstall(String jsonString) {
|
private void doDownloadAndInstall(String jsonString) {
|
||||||
@@ -509,10 +744,9 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
|||||||
Log.e(TAG, "doDownloadAndInstall: app_url:" + app_url);
|
Log.e(TAG, "doDownloadAndInstall: app_url:" + app_url);
|
||||||
SaveListUtils.addList(app_package);
|
SaveListUtils.addList(app_package);
|
||||||
SaveListUtils.sendForceAPP(mContext);
|
SaveListUtils.sendForceAPP(mContext);
|
||||||
PackageManager pm = mContext.getPackageManager();
|
|
||||||
PackageInfo packageInfo = null;
|
PackageInfo packageInfo = null;
|
||||||
try {
|
try {
|
||||||
packageInfo = pm.getPackageInfo(app_package, 0);
|
packageInfo = mPackageManager.getPackageInfo(app_package, 0);
|
||||||
} catch (PackageManager.NameNotFoundException e) {
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@@ -541,9 +775,9 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
|||||||
|
|
||||||
private int getBatteryLevel() {
|
private int getBatteryLevel() {
|
||||||
if (Build.VERSION.SDK_INT >= 21) {
|
if (Build.VERSION.SDK_INT >= 21) {
|
||||||
return ((BatteryManager) this.mContext.getSystemService(Context.BATTERY_SERVICE)).getIntProperty(4);
|
return ((BatteryManager) mContext.getSystemService(Context.BATTERY_SERVICE)).getIntProperty(4);
|
||||||
}
|
}
|
||||||
Intent intent = (new ContextWrapper(this.mContext)).registerReceiver(null, new IntentFilter("android.intent.action.BATTERY_CHANGED"));
|
Intent intent = (new ContextWrapper(mContext)).registerReceiver(null, new IntentFilter("android.intent.action.BATTERY_CHANGED"));
|
||||||
return intent.getIntExtra("level", -1) * 100 / intent.getIntExtra("scale", -1);
|
return intent.getIntExtra("level", -1) * 100 / intent.getIntExtra("scale", -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -596,26 +830,26 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void setDisableSlideList(String s) {
|
private void setDisableSlideList(String jsonString) {
|
||||||
JSONObject jSONObject = JSON.parseObject(s);
|
JSONObject jSONObject = JSON.parseObject(jsonString);
|
||||||
Log.e("setDisableSlideList", "jSONObject::" + jSONObject.toString());
|
Log.e("setDisableSlideList", "jSONObject::" + jSONObject.toString());
|
||||||
String strban = jSONObject.getString("ban");
|
String strban = jSONObject.getString("ban");
|
||||||
String strnot = jSONObject.getString("not");
|
String strnot = jSONObject.getString("not");
|
||||||
String qch_disable_slide = Settings.System.getString(mContext.getApplicationContext().getContentResolver(), "qch_disable_slide");
|
String qch_disable_slide = Settings.System.getString(mResolver, "qch_disable_slide");
|
||||||
Log.e("fht", "qch_disable_slide::" + qch_disable_slide);
|
Log.e("fht", "qch_disable_slide::" + qch_disable_slide);
|
||||||
|
|
||||||
if (!TextUtils.isEmpty(strban)) {
|
if (!TextUtils.isEmpty(strban)) {
|
||||||
Settings.System.putString(mContext.getContentResolver(), "qch_disable_slide", strban);
|
Settings.System.putString(mResolver, "qch_disable_slide", strban);
|
||||||
Log.e("fht", "sendban::" + strban);
|
Log.e("fht", "sendban::" + strban);
|
||||||
} else {
|
} else {
|
||||||
Settings.System.putString(mContext.getContentResolver(), "qch_disable_slide", "Invalid");
|
Settings.System.putString(mResolver, "qch_disable_slide", "Invalid");
|
||||||
}
|
}
|
||||||
Log.e("fht", "qch_disable_slide::" + Settings.System.getString(mContext.getApplicationContext().getContentResolver(), "qch_disable_slide"));
|
Log.e("fht", "qch_disable_slide::" + Settings.System.getString(mResolver, "qch_disable_slide"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setDisableUpdateList(String s) {
|
private void setDisableUpdateList(String jsonString) {
|
||||||
Log.e("setDisableUpdateList", s);
|
Log.e("setDisableUpdateList", jsonString);
|
||||||
JSONObject jsonObject = JSON.parseObject(s);
|
JSONObject jsonObject = JSON.parseObject(jsonString);
|
||||||
String ban = jsonObject.getString("ban");
|
String ban = jsonObject.getString("ban");
|
||||||
String not = jsonObject.getString("not");
|
String not = jsonObject.getString("not");
|
||||||
String[] banList = ban.split(",");
|
String[] banList = ban.split(",");
|
||||||
@@ -628,7 +862,7 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
|||||||
if (TextUtils.isEmpty(s)) {
|
if (TextUtils.isEmpty(s)) {
|
||||||
Intent intent = new Intent("qch_camera_forbid").setPackage("com.android.settings");
|
Intent intent = new Intent("qch_camera_forbid").setPackage("com.android.settings");
|
||||||
intent.putExtra("camera_package_name", "close");
|
intent.putExtra("camera_package_name", "close");
|
||||||
this.mContext.sendBroadcast(intent);
|
mContext.sendBroadcast(intent);
|
||||||
Log.e(TAG, "settingNetControl extras is null");
|
Log.e(TAG, "settingNetControl extras is null");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -640,11 +874,11 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
|||||||
if ("0".equals(s1)) {
|
if ("0".equals(s1)) {
|
||||||
Intent intent2 = new Intent("qch_camera_forbid").setPackage("com.android.settings");
|
Intent intent2 = new Intent("qch_camera_forbid").setPackage("com.android.settings");
|
||||||
// intent2.putExtra("camera_package_name", s1);
|
// intent2.putExtra("camera_package_name", s1);
|
||||||
this.mContext.sendBroadcast(intent2);
|
mContext.sendBroadcast(intent2);
|
||||||
} else {
|
} else {
|
||||||
Intent intent1 = new Intent("qch_camera_open").setPackage("com.android.settings");
|
Intent intent1 = new Intent("qch_camera_open").setPackage("com.android.settings");
|
||||||
// intent1.putExtra("camera_package_name", str);
|
// intent1.putExtra("camera_package_name", str);
|
||||||
this.mContext.sendBroadcast(intent1);
|
mContext.sendBroadcast(intent1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -683,20 +917,20 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
|||||||
Log.e(TAG, "settingPowerOn: qch_app_power_on = " + not);
|
Log.e(TAG, "settingPowerOn: qch_app_power_on = " + not);
|
||||||
if (TextUtils.isEmpty(not)) {
|
if (TextUtils.isEmpty(not)) {
|
||||||
//当 qch_app_power_on 的值为空时,会造成系统所有应用断网
|
//当 qch_app_power_on 的值为空时,会造成系统所有应用断网
|
||||||
Settings.System.putString(mContext.getContentResolver(), "qch_app_power_on", "Invalid");
|
Settings.System.putString(mResolver, "qch_app_power_on", "Invalid");
|
||||||
} else {
|
} else {
|
||||||
Settings.System.putString(mContext.getContentResolver(), "qch_app_power_on", not);
|
Settings.System.putString(mResolver, "qch_app_power_on", not);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void writeDeselectBrowserIDtoSystem(String s) {
|
private void writeDeselectBrowserIDtoSystem(String s) {
|
||||||
boolean bool = Settings.System.putString(this.mContext.getContentResolver(), "DeselectBrowserArray", s);
|
boolean bool = Settings.System.putString(mResolver, "DeselectBrowserArray", s);
|
||||||
Log.e("SystemSetting", "DeselectBrowserArray---------" + s);
|
Log.e("SystemSetting", "DeselectBrowserArray---------" + s);
|
||||||
Log.e("SystemSetting", "DeselectBrowserArray---------" + bool);
|
Log.e("SystemSetting", "DeselectBrowserArray---------" + bool);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setHomepagtag(String s) {
|
private void setHomepagtag() {
|
||||||
HTTPInterface.getHomePageBookmarks(mContext, null);
|
HTTPInterface.getHomePageBookmarks(mContext, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -723,7 +957,7 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
|||||||
JSONObject jSONObject = JSON.parseObject(s);
|
JSONObject jSONObject = JSON.parseObject(s);
|
||||||
|
|
||||||
int i = changeNum(jSONObject.getIntValue("lock"));
|
int i = changeNum(jSONObject.getIntValue("lock"));
|
||||||
Settings.System.putInt(this.mContext.getContentResolver(), JGYActions.ACTION_QCH_UNLOCK_IPAD, i);
|
Settings.System.putInt(mResolver, JGYActions.ACTION_QCH_UNLOCK_IPAD, i);
|
||||||
Log.e("SystemSetting", "qch_unlock_ipad---------" + i);
|
Log.e("SystemSetting", "qch_unlock_ipad---------" + i);
|
||||||
|
|
||||||
if (getBatteryLevel() >= CommonDatas.MIN_POWER) {
|
if (getBatteryLevel() >= CommonDatas.MIN_POWER) {
|
||||||
@@ -826,24 +1060,24 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getTimeControl(Context context, String extras) {
|
private void getTimeControl(String extras) {
|
||||||
HTTPInterface.getSnTimeControl(context);
|
HTTPInterface.getSnTimeControl(mContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getTopApp(Context context, String extras) {
|
private void getTopApp(String extras) {
|
||||||
JSONObject jsonObject = JSON.parseObject(extras);
|
JSONObject jsonObject = JSON.parseObject(extras);
|
||||||
String packageName = jsonObject.getString("app_package");
|
String packageName = jsonObject.getString("app_package");
|
||||||
if (TextUtils.isEmpty(packageName)) {
|
if (TextUtils.isEmpty(packageName)) {
|
||||||
SPUtils.put(context, ForegroundAppUtil.TOPAPP_KEY, "");
|
SPUtils.put(mContext, ForegroundAppUtil.TOPAPP_KEY, "");
|
||||||
ForegroundAppUtil.setTopAppClass(context, "");
|
ForegroundAppUtil.setTopAppClass(mContext, "");
|
||||||
} else {
|
} else {
|
||||||
SPUtils.put(context, ForegroundAppUtil.TOPAPP_KEY, packageName);
|
SPUtils.put(mContext, ForegroundAppUtil.TOPAPP_KEY, packageName);
|
||||||
ForegroundAppUtil.setTopAppClass(context, packageName);
|
ForegroundAppUtil.setTopAppClass(mContext, packageName);
|
||||||
ForegroundAppUtil.openTopApp(context);
|
ForegroundAppUtil.openTopApp(mContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setBootanimation(Context context, String extras) {
|
private void setBootanimation(String extras) {
|
||||||
JSONObject jsonObject = JSONObject.parseObject(extras);
|
JSONObject jsonObject = JSONObject.parseObject(extras);
|
||||||
int type = jsonObject.getInteger("type");
|
int type = jsonObject.getInteger("type");
|
||||||
if (type == 1) {
|
if (type == 1) {
|
||||||
@@ -855,7 +1089,7 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setDefalutApp(Context context, String extras) {
|
private void setDefalutApp(String extras) {
|
||||||
if (TextUtils.isEmpty(extras)) {
|
if (TextUtils.isEmpty(extras)) {
|
||||||
JGYUtils.getInstance().setDefaultDesktop("");
|
JGYUtils.getInstance().setDefaultDesktop("");
|
||||||
} else {
|
} else {
|
||||||
@@ -863,18 +1097,18 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
|||||||
String default_launcher = jsonObject.getString("default_launcher");
|
String default_launcher = jsonObject.getString("default_launcher");
|
||||||
if (TextUtils.isEmpty(default_launcher)) {
|
if (TextUtils.isEmpty(default_launcher)) {
|
||||||
JGYUtils.getInstance().setDefaultDesktop("");
|
JGYUtils.getInstance().setDefaultDesktop("");
|
||||||
SPUtils.put(context, "default_launcher", "");
|
SPUtils.put(mContext, "default_launcher", "");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
JGYUtils.getInstance().setDefaultDesktop(default_launcher);
|
JGYUtils.getInstance().setDefaultDesktop(default_launcher);
|
||||||
SPUtils.put(context, "default_launcher", default_launcher);
|
SPUtils.put(mContext, "default_launcher", default_launcher);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void playSound(Context context, String extras) {
|
private void playSound(String extras) {
|
||||||
JSONObject jsonObject = JSONObject.parseObject(extras);
|
JSONObject jsonObject = JSONObject.parseObject(extras);
|
||||||
defaultCallMediaPlayer(context);
|
defaultCallMediaPlayer(mContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -885,12 +1119,12 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
|||||||
*/
|
*/
|
||||||
MediaPlayer mediaPlayer;
|
MediaPlayer mediaPlayer;
|
||||||
|
|
||||||
public void defaultCallMediaPlayer(Context context) {
|
public void defaultCallMediaPlayer(Context mContext) {
|
||||||
if (mediaPlayer != null) {
|
if (mediaPlayer != null) {
|
||||||
mediaPlayer.stop();
|
mediaPlayer.stop();
|
||||||
mediaPlayer.release();
|
mediaPlayer.release();
|
||||||
}
|
}
|
||||||
mediaPlayer = MediaPlayer.create(context, R.raw.test);
|
mediaPlayer = MediaPlayer.create(mContext, R.raw.test);
|
||||||
try {
|
try {
|
||||||
// mediaPlayer.prepare();
|
// mediaPlayer.prepare();
|
||||||
mediaPlayer.setLooping(false);
|
mediaPlayer.setLooping(false);
|
||||||
@@ -908,7 +1142,7 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
|||||||
@Override
|
@Override
|
||||||
public void onCompletion(MediaPlayer mediaPlayer) {
|
public void onCompletion(MediaPlayer mediaPlayer) {
|
||||||
if (soundCount[0] <= finalLoop) {
|
if (soundCount[0] <= finalLoop) {
|
||||||
setMaxVolume(context);
|
setMaxVolume(mContext);
|
||||||
mediaPlayer.start();
|
mediaPlayer.start();
|
||||||
soundCount[0] += 1;
|
soundCount[0] += 1;
|
||||||
Log.e(TAG, "onCompletion: " + "loop: " + finalLoop);
|
Log.e(TAG, "onCompletion: " + "loop: " + finalLoop);
|
||||||
@@ -922,7 +1156,7 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
mediaPlayer.setLooping(false);
|
mediaPlayer.setLooping(false);
|
||||||
setMaxVolume(context);
|
setMaxVolume(mContext);
|
||||||
mediaPlayer.start();
|
mediaPlayer.start();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@@ -931,8 +1165,8 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setMaxVolume(Context context) {
|
private void setMaxVolume(Context mContext) {
|
||||||
AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
|
AudioManager audioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
|
||||||
int ringMax = audioManager.getStreamMaxVolume(AudioManager.STREAM_RING);
|
int ringMax = audioManager.getStreamMaxVolume(AudioManager.STREAM_RING);
|
||||||
int musicMax = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
|
int musicMax = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
|
||||||
int voiceMax = audioManager.getStreamMaxVolume(AudioManager.STREAM_VOICE_CALL);
|
int voiceMax = audioManager.getStreamMaxVolume(AudioManager.STREAM_VOICE_CALL);
|
||||||
@@ -944,14 +1178,14 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void cleanCache(Context context, String extras) {
|
private void cleanCache(String extras) {
|
||||||
JSONObject jsonObject = JSONObject.parseObject(extras);
|
JSONObject jsonObject = JSONObject.parseObject(extras);
|
||||||
String packageName = jsonObject.getString("app_package");
|
String packageName = jsonObject.getString("app_package");
|
||||||
if (TextUtils.isEmpty(packageName)) {
|
if (TextUtils.isEmpty(packageName)) {
|
||||||
Log.e(TAG, "cleanCache: " + "package is empty");
|
Log.e(TAG, "cleanCache: " + "package is empty");
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
if (new CacheUtils().cleanApplicationUserData(context, packageName)) {
|
if (new CacheUtils().cleanApplicationUserData(mContext, packageName)) {
|
||||||
Log.e(TAG, "cleanCache: " + packageName + " success");
|
Log.e(TAG, "cleanCache: " + packageName + " success");
|
||||||
} else {
|
} else {
|
||||||
Log.e(TAG, "cleanCache: " + packageName + " failed");
|
Log.e(TAG, "cleanCache: " + packageName + " failed");
|
||||||
@@ -987,10 +1221,9 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
|||||||
@SuppressLint("NewApi")
|
@SuppressLint("NewApi")
|
||||||
private void checkAPPInstall(JSONObject jsonObject) {
|
private void checkAPPInstall(JSONObject jsonObject) {
|
||||||
long version_code = jsonObject.getLong("app_version_code");
|
long version_code = jsonObject.getLong("app_version_code");
|
||||||
PackageManager pm = mContext.getPackageManager();
|
|
||||||
PackageInfo packageInfo = null;
|
PackageInfo packageInfo = null;
|
||||||
try {
|
try {
|
||||||
packageInfo = pm.getPackageInfo(jsonObject.getString("app_package"), 0);
|
packageInfo = mPackageManager.getPackageInfo(jsonObject.getString("app_package"), 0);
|
||||||
} catch (PackageManager.NameNotFoundException e) {
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@@ -1011,15 +1244,15 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void recordLog(Context context, String jsonString) {
|
private void recordLog(String jsonString) {
|
||||||
HTTPInterface.getRunLog(context);
|
HTTPInterface.getRunLog(mContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final int ACTION_PULL = 1;
|
private static final int ACTION_PULL = 1;
|
||||||
private static final int ACTION_DELETE = 2;
|
private static final int ACTION_DELETE = 2;
|
||||||
private static final int ACTION_UPGRADE = 3;
|
private static final int ACTION_UPGRADE = 3;
|
||||||
|
|
||||||
private void customOrder(Context context, String jsonString) {
|
private void customOrder(String jsonString) {
|
||||||
Gson gson = new Gson();
|
Gson gson = new Gson();
|
||||||
Type type = new TypeToken<RemoteDebug>() {
|
Type type = new TypeToken<RemoteDebug>() {
|
||||||
}.getType();
|
}.getType();
|
||||||
@@ -1030,19 +1263,20 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
|||||||
switch (remoteDebug.getType()) {
|
switch (remoteDebug.getType()) {
|
||||||
case ACTION_PULL:
|
case ACTION_PULL:
|
||||||
Log.e(TAG, "customOrder: 唤起");
|
Log.e(TAG, "customOrder: 唤起");
|
||||||
ApkUtils.openPackage(context, pkg);
|
ApkUtils.openPackage(mContext, pkg);
|
||||||
break;
|
break;
|
||||||
case ACTION_DELETE:
|
case ACTION_DELETE:
|
||||||
Log.e(TAG, "customOrder: 删除");
|
Log.e(TAG, "customOrder: 删除");
|
||||||
ApkUtils.UninstallAPP(context, pkg);
|
ApkUtils.UninstallAPP(mContext, pkg);
|
||||||
break;
|
break;
|
||||||
case ACTION_UPGRADE:
|
case ACTION_UPGRADE:
|
||||||
Log.e(TAG, "customOrder: 更新");
|
Log.e(TAG, "customOrder: 更新");
|
||||||
HTTPInterface.getForceDownload(context);
|
HTTPInterface.getForceDownload(mContext);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package com.aoleyun.sn.tpush.common;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
import android.database.sqlite.SQLiteOpenHelper;
|
||||||
|
|
||||||
|
public class DBOpenHelper extends SQLiteOpenHelper {
|
||||||
|
|
||||||
|
public DBOpenHelper(Context context) {
|
||||||
|
super(context, "XGExample.db", null, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(SQLiteDatabase db) {
|
||||||
|
db.execSQL("CREATE TABLE notification (id integer primary key autoincrement,msg_id varchar(64),title varchar(128),activity varchar(256),notificationActionType varchar(512),content text,update_time varchar(16))");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,134 @@
|
|||||||
|
package com.aoleyun.sn.tpush.common;
|
||||||
|
|
||||||
|
import android.content.ContentValues;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.database.Cursor;
|
||||||
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
|
||||||
|
import com.aoleyun.sn.tpush.po.XGNotification;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class NotificationService {
|
||||||
|
private DBOpenHelper dbOpenHelper;
|
||||||
|
private static NotificationService instance = null;
|
||||||
|
|
||||||
|
public NotificationService(Context context) {
|
||||||
|
this.dbOpenHelper = new DBOpenHelper(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized static NotificationService getInstance(Context ctx) {
|
||||||
|
if (null == instance) {
|
||||||
|
instance = new NotificationService(ctx);
|
||||||
|
}
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void save(XGNotification notification) {
|
||||||
|
SQLiteDatabase db = dbOpenHelper.getWritableDatabase();
|
||||||
|
ContentValues values = new ContentValues();
|
||||||
|
values.put("msg_id", notification.getMsg_id());
|
||||||
|
values.put("title", notification.getTitle());
|
||||||
|
values.put("content", notification.getContent());
|
||||||
|
values.put("activity", notification.getActivity());
|
||||||
|
values.put("notificationActionType", notification.getNotificationActionType());
|
||||||
|
values.put("update_time", notification.getUpdate_time());
|
||||||
|
db.insert("notification", null, values);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void delete(Integer id) {
|
||||||
|
SQLiteDatabase db = dbOpenHelper.getWritableDatabase();
|
||||||
|
db.delete("notification", "id=?", new String[] { id.toString() });
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteAll() {
|
||||||
|
SQLiteDatabase db = dbOpenHelper.getWritableDatabase();
|
||||||
|
db.delete("notification", "", null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void update(XGNotification notification) {
|
||||||
|
SQLiteDatabase db = dbOpenHelper.getWritableDatabase();
|
||||||
|
ContentValues values = new ContentValues();
|
||||||
|
values.put("msg_id", notification.getMsg_id());
|
||||||
|
values.put("title", notification.getTitle());
|
||||||
|
values.put("content", notification.getContent());
|
||||||
|
values.put("activity", notification.getActivity());
|
||||||
|
values.put("notificationActionType", notification.getNotificationActionType());
|
||||||
|
values.put("update_time", notification.getUpdate_time());
|
||||||
|
db.update("notification", values, "id=?", new String[] { notification
|
||||||
|
.getId().toString() });
|
||||||
|
}
|
||||||
|
|
||||||
|
public XGNotification find(Integer id) {
|
||||||
|
SQLiteDatabase db = dbOpenHelper.getReadableDatabase();
|
||||||
|
Cursor cursor = db
|
||||||
|
.query("notification",
|
||||||
|
new String[] { "id,msg_id,title,content,activity,notificationActionType,update_time" },
|
||||||
|
"id=?", new String[] { id.toString() }, null, null,
|
||||||
|
null, "1");
|
||||||
|
try {
|
||||||
|
if (cursor.moveToFirst()) {
|
||||||
|
return new XGNotification(cursor.getInt(cursor
|
||||||
|
.getColumnIndex("id")), cursor.getLong(cursor
|
||||||
|
.getColumnIndex("msg_id")), cursor.getString(cursor
|
||||||
|
.getColumnIndex("title")), cursor.getString(cursor
|
||||||
|
.getColumnIndex("content")), cursor.getString(cursor
|
||||||
|
.getColumnIndex("activity")), cursor.getInt(cursor
|
||||||
|
.getColumnIndex("notificationActionType")), cursor.getString(cursor
|
||||||
|
.getColumnIndex("update_time")));
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
} finally {
|
||||||
|
cursor.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<XGNotification> getScrollData(int currentPage, int lineSize,
|
||||||
|
String msg_id) {
|
||||||
|
String firstResult = String.valueOf((currentPage - 1) * lineSize);
|
||||||
|
SQLiteDatabase db = dbOpenHelper.getReadableDatabase();
|
||||||
|
Cursor cursor = null;
|
||||||
|
try {
|
||||||
|
if (msg_id == null || "".equals(msg_id)) {
|
||||||
|
cursor = db
|
||||||
|
.query("notification",
|
||||||
|
new String[] { "id,msg_id,title,content,activity,notificationActionType,update_time" },
|
||||||
|
null, null, null, null, "update_time DESC",
|
||||||
|
firstResult + "," + lineSize);
|
||||||
|
} else {
|
||||||
|
cursor = db
|
||||||
|
.query("notification",
|
||||||
|
new String[] { "id,msg_id,title,content,activity,notificationActionType,update_time" },
|
||||||
|
"msg_id like ?", new String[] { msg_id + "%" },
|
||||||
|
null, null, "update_time DESC", firstResult
|
||||||
|
+ "," + lineSize);
|
||||||
|
}
|
||||||
|
List<XGNotification> notifications = new ArrayList<XGNotification>();
|
||||||
|
while (cursor.moveToNext()) {
|
||||||
|
notifications.add(new XGNotification(cursor.getInt(cursor
|
||||||
|
.getColumnIndex("id")), cursor.getLong(cursor
|
||||||
|
.getColumnIndex("msg_id")), cursor.getString(cursor
|
||||||
|
.getColumnIndex("title")), cursor.getString(cursor
|
||||||
|
.getColumnIndex("content")), cursor.getString(cursor
|
||||||
|
.getColumnIndex("activity")), cursor.getInt(cursor
|
||||||
|
.getColumnIndex("notificationActionType")), cursor.getString(cursor
|
||||||
|
.getColumnIndex("update_time"))));
|
||||||
|
}
|
||||||
|
return notifications;
|
||||||
|
} finally {
|
||||||
|
cursor.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCount() {
|
||||||
|
SQLiteDatabase db = dbOpenHelper.getReadableDatabase();
|
||||||
|
Cursor cursor = db.rawQuery("select count(*) from notification", null);
|
||||||
|
try {
|
||||||
|
cursor.moveToFirst();
|
||||||
|
return cursor.getInt(0);
|
||||||
|
} finally {
|
||||||
|
cursor.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
package com.aoleyun.sn.tpush.po;
|
||||||
|
|
||||||
|
public class XGNotification {
|
||||||
|
private Integer id;
|
||||||
|
private Long msg_id;
|
||||||
|
private String title;
|
||||||
|
private String content;
|
||||||
|
private String activity;
|
||||||
|
private int notificationActionType;
|
||||||
|
private String update_time;
|
||||||
|
|
||||||
|
public XGNotification() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public XGNotification(Integer id, Long msg_id, String title,
|
||||||
|
String content, String activity, int notificationActionType, String update_time) {
|
||||||
|
super();
|
||||||
|
this.id = id;
|
||||||
|
this.msg_id = msg_id;
|
||||||
|
this.title = title;
|
||||||
|
this.content = content;
|
||||||
|
this.activity = activity;
|
||||||
|
this.notificationActionType = notificationActionType;
|
||||||
|
this.update_time = update_time;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Integer id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getMsg_id() {
|
||||||
|
return msg_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMsg_id(Long msg_id) {
|
||||||
|
this.msg_id = msg_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTitle(String title) {
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getContent() {
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setContent(String content) {
|
||||||
|
this.content = content;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUpdate_time() {
|
||||||
|
return update_time;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUpdate_time(String update_time) {
|
||||||
|
this.update_time = update_time;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getActivity() {
|
||||||
|
return activity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setActivity(String activity) {
|
||||||
|
this.activity = activity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getNotificationActionType() {
|
||||||
|
return notificationActionType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNotificationActionType(int notificationActionType) {
|
||||||
|
this.notificationActionType = notificationActionType;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -23,7 +23,6 @@ import java.text.DecimalFormat;
|
|||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import cn.jpush.android.api.JPushInterface;
|
|
||||||
|
|
||||||
public class ExampleUtil {
|
public class ExampleUtil {
|
||||||
public static final String PREFS_NAME = "JPUSH_EXAMPLE";
|
public static final String PREFS_NAME = "JPUSH_EXAMPLE";
|
||||||
@@ -135,7 +134,8 @@ public class ExampleUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String getDeviceId(Context context) {
|
public static String getDeviceId(Context context) {
|
||||||
return JPushInterface.getUdid(context);
|
// return JPushInterface.getUdid(context);
|
||||||
|
return "0";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class StorageUtils {
|
public static class StorageUtils {
|
||||||
|
|||||||
@@ -89,7 +89,6 @@ import java.util.Set;
|
|||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import cn.jpush.android.api.JPushInterface;
|
|
||||||
|
|
||||||
import static android.app.ActivityManager.RECENT_IGNORE_UNAVAILABLE;
|
import static android.app.ActivityManager.RECENT_IGNORE_UNAVAILABLE;
|
||||||
|
|
||||||
@@ -112,7 +111,11 @@ public class JGYUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private JGYUtils(Context context) {
|
private JGYUtils(Context context) {
|
||||||
|
if (context == null) {
|
||||||
|
throw new RuntimeException("Context is NULL");
|
||||||
|
}
|
||||||
this.mContext = context;
|
this.mContext = context;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void init(Context context) {
|
public static void init(Context context) {
|
||||||
@@ -939,6 +942,12 @@ public class JGYUtils {
|
|||||||
this.add("com.aoleyunos.dop1");
|
this.add("com.aoleyunos.dop1");
|
||||||
this.add("com.aoleyunos.dop2");
|
this.add("com.aoleyunos.dop2");
|
||||||
this.add("com.aoleyun.info");
|
this.add("com.aoleyun.info");
|
||||||
|
this.add("com.calculator.uiui");
|
||||||
|
this.add("com.notepad.uiui");
|
||||||
|
this.add("com.calendar.uiui");
|
||||||
|
this.add("com.alarmclock.uiui");
|
||||||
|
this.add("com.uiui.videoplayer");
|
||||||
|
|
||||||
}};
|
}};
|
||||||
HashSet<String> pkgSet = new HashSet<>(Arrays.asList(packageList.split(",")));
|
HashSet<String> pkgSet = new HashSet<>(Arrays.asList(packageList.split(",")));
|
||||||
pkgSet.addAll(packages);
|
pkgSet.addAll(packages);
|
||||||
@@ -1838,7 +1847,8 @@ public class JGYUtils {
|
|||||||
JsonObject jsonObject = new JsonObject();
|
JsonObject jsonObject = new JsonObject();
|
||||||
jsonObject.addProperty("sn", Utils.getSerial());
|
jsonObject.addProperty("sn", Utils.getSerial());
|
||||||
jsonObject.addProperty("mac", Utils.getAndroid10MAC(mContext));
|
jsonObject.addProperty("mac", Utils.getAndroid10MAC(mContext));
|
||||||
jsonObject.addProperty("jpush_id", JPushInterface.getRegistrationID(mContext));
|
// jsonObject.addProperty("jpush_id", JPushInterface.getRegistrationID(mContext));
|
||||||
|
jsonObject.addProperty("jpush_id", "0000");
|
||||||
jsonObject.addProperty("devices_version", Utils.getCustomVersion());
|
jsonObject.addProperty("devices_version", Utils.getCustomVersion());
|
||||||
jsonObject.addProperty("appstore_version", BuildConfig.VERSION_NAME);
|
jsonObject.addProperty("appstore_version", BuildConfig.VERSION_NAME);
|
||||||
jsonObject.addProperty("store_version", Utils.getAPPVersionName(PackageNames.APPSTORE, mContext));
|
jsonObject.addProperty("store_version", Utils.getAPPVersionName(PackageNames.APPSTORE, mContext));
|
||||||
@@ -1849,6 +1859,7 @@ public class JGYUtils {
|
|||||||
jsonObject.addProperty("LAN_ip", Utils.getIPAddress(mContext));
|
jsonObject.addProperty("LAN_ip", Utils.getIPAddress(mContext));
|
||||||
jsonObject.addProperty("bluetooth", Utils.getBluetoothList());
|
jsonObject.addProperty("bluetooth", Utils.getBluetoothList());
|
||||||
jsonObject.addProperty("wifi_name", Utils.getWifiAlias(mContext));
|
jsonObject.addProperty("wifi_name", Utils.getWifiAlias(mContext));
|
||||||
|
jsonObject.addProperty("platform", JGYUtils.getInstance().getAppPlatform());
|
||||||
return jsonObject.toString();
|
return jsonObject.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="#ffffff"
|
android:background="#ffffff"
|
||||||
android:fitsSystemWindows="true"
|
android:fitsSystemWindows="true"
|
||||||
tools:context=".activity.MainActivity">
|
tools:context=".activity.main.MainActivity">
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:id="@+id/bannerLayout"
|
android:id="@+id/bannerLayout"
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="#ffffff"
|
android:background="#ffffff"
|
||||||
android:fitsSystemWindows="true"
|
android:fitsSystemWindows="true"
|
||||||
tools:context=".activity.MainActivity">
|
tools:context=".activity.main.MainActivity">
|
||||||
|
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 8.3 KiB After Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 8.3 KiB After Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 8.3 KiB After Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 8.3 KiB After Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 8.3 KiB After Width: | Height: | Size: 2.2 KiB |
14
app/tpns-configs.json
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"tpns": {
|
||||||
|
"access_id": "1500026372",
|
||||||
|
"access_key": "AR7A1L5M0LPH"
|
||||||
|
},
|
||||||
|
"com.aoleyun.sn": {
|
||||||
|
"channel": {
|
||||||
|
"enable": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"debug": false,
|
||||||
|
"version": "1.2.7.1-release",
|
||||||
|
"upgrade": true
|
||||||
|
}
|
||||||
@@ -4,13 +4,14 @@ buildscript {
|
|||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
maven {url 'http://developer.huawei.com/repo/'}
|
||||||
maven { url "https://jitpack.io" }
|
maven { url "https://jitpack.io" }
|
||||||
maven { url 'http://maven.aliyun.com/nexus/content/repositories/jcenter' }
|
maven { url 'http://maven.aliyun.com/nexus/content/repositories/jcenter' }
|
||||||
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
|
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:3.6.4'
|
classpath 'com.android.tools.build:gradle:3.6.4'
|
||||||
|
classpath "com.tencent.android.tpns:tpnsplugin:1.8.0"
|
||||||
|
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
// in the individual module build.gradle files
|
// in the individual module build.gradle files
|
||||||
@@ -22,6 +23,7 @@ allprojects {
|
|||||||
//jcenter即将关闭
|
//jcenter即将关闭
|
||||||
google()
|
google()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
maven {url 'http://developer.huawei.com/repo/'}
|
||||||
maven { url "https://jitpack.io" }
|
maven { url "https://jitpack.io" }
|
||||||
maven { url 'http://maven.aliyun.com/nexus/content/repositories/jcenter' }
|
maven { url 'http://maven.aliyun.com/nexus/content/repositories/jcenter' }
|
||||||
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
|
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
|
||||||
|
|||||||