version:2.4
fix:更换图标,修改桌面隐藏其他应用 add:
@@ -214,96 +214,96 @@
|
|||||||
|
|
||||||
|
|
||||||
<!-- 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"></activity>
|
<!-- tools:replace="android:exported"></activity>-->
|
||||||
|
|
||||||
<!-- 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="${applicationId}" />
|
<!-- <category android:name="${applicationId}" />-->
|
||||||
</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="${applicationId}.DataProvider"
|
<!-- android:authorities="${applicationId}.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="${applicationId}" />
|
<!-- <category android:name="${applicationId}" />-->
|
||||||
</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="${applicationId}.DownloadProvider"
|
<!-- android:authorities="${applicationId}.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" /> <!--Required 显示通知栏 -->
|
<!-- <action android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED_PROXY" /> <!–Required 显示通知栏 –>-->
|
||||||
<category android:name="${applicationId}" />
|
<!-- <category android:name="${applicationId}" />-->
|
||||||
</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>
|
<!-- </receiver>-->
|
||||||
|
|
||||||
<!-- Required SDK核心功能-->
|
<!-- Required SDK核心功能-->
|
||||||
<receiver
|
<!-- <receiver-->
|
||||||
android:name="cn.jpush.android.service.AlarmReceiver"
|
<!-- android:name="cn.jpush.android.service.AlarmReceiver"-->
|
||||||
android:exported="false" />
|
<!-- android:exported="false" />-->
|
||||||
|
|
||||||
|
|
||||||
<!-- User defined. For test only 用户自定义的广播接收器-->
|
<!-- User defined. For test only 用户自定义的广播接收器-->
|
||||||
@@ -336,16 +336,16 @@
|
|||||||
android:exported="true" />
|
android:exported="true" />
|
||||||
|
|
||||||
<!--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="${applicationId}" />
|
<!-- <category android:name="${applicationId}" />-->
|
||||||
</intent-filter>
|
<!-- </intent-filter>-->
|
||||||
</activity>
|
<!-- </activity>-->
|
||||||
|
|
||||||
<!-- since 3.3.0 Required SDK 核心功能-->
|
<!-- since 3.3.0 Required SDK 核心功能-->
|
||||||
<!-- 可配置android:process参数将PushService放在其他进程中 -->
|
<!-- 可配置android:process参数将PushService放在其他进程中 -->
|
||||||
@@ -359,11 +359,12 @@
|
|||||||
</service>
|
</service>
|
||||||
|
|
||||||
<!-- Required . Enable it you can get statistics data with channel -->
|
<!-- Required . Enable it you can get statistics data with channel -->
|
||||||
<meta-data
|
<!-- <meta-data-->
|
||||||
android:name="JPUSH_CHANNEL"
|
<!-- android:name="JPUSH_CHANNEL"-->
|
||||||
android:value="${JPUSH_CHANNEL}" />
|
<!-- android:value="${JPUSH_CHANNEL}" />-->
|
||||||
<meta-data
|
<!-- <meta-data-->
|
||||||
android:name="JPUSH_APPKEY"
|
<!-- android:name="JPUSH_APPKEY"-->
|
||||||
android:value="${JPUSH_APPKEY}" /> <!-- </>值来自开发者平台取得的AppKey-->
|
<!-- android:value="${JPUSH_APPKEY}" /> -->
|
||||||
|
<!-- <!– </>值来自开发者平台取得的AppKey–>-->
|
||||||
</application>
|
</application>
|
||||||
</manifest>
|
</manifest>
|
||||||
|
|||||||
29
build.gradle
@@ -1,11 +1,18 @@
|
|||||||
buildscript {
|
buildscript {
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
|
||||||
google()
|
google()
|
||||||
|
mavenCentral()
|
||||||
|
maven {url 'http://developer.huawei.com/repo/'}
|
||||||
|
maven { url "https://jitpack.io" }
|
||||||
|
maven { url 'http://maven.aliyun.com/nexus/content/repositories/jcenter' }
|
||||||
|
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath GRADLE_CLASS_PATH
|
classpath GRADLE_CLASS_PATH
|
||||||
classpath PROTOBUF_CLASS_PATH
|
classpath PROTOBUF_CLASS_PATH
|
||||||
|
classpath "com.tencent.android.tpns:tpnsplugin:1.8.0"
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,6 +37,8 @@ final String FRAMEWORK_PREBUILTS_DIR = "${ANDROID_TOP}/prebuilts/framework_inter
|
|||||||
|
|
||||||
apply plugin: 'com.android.application'
|
apply plugin: 'com.android.application'
|
||||||
apply plugin: 'com.google.protobuf'
|
apply plugin: 'com.google.protobuf'
|
||||||
|
//apply plugin: "com.tencent.android.tpns"
|
||||||
|
|
||||||
|
|
||||||
android {
|
android {
|
||||||
gradle.projectsEvaluated {
|
gradle.projectsEvaluated {
|
||||||
@@ -57,17 +66,19 @@ android {
|
|||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdkVersion 26
|
minSdkVersion 26
|
||||||
targetSdkVersion 28
|
targetSdkVersion 28
|
||||||
versionCode 13
|
versionCode 15
|
||||||
versionName "2.2"
|
versionName "2.4"
|
||||||
ndk {
|
ndk {
|
||||||
//选择要添加的对应 cpu 类型的 .so 库。
|
//选择要添加的对应 cpu 类型的 .so 库。
|
||||||
abiFilters 'armeabi', 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
|
abiFilters 'armeabi', 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
|
||||||
// 还可以添加 'x86', 'x86_64', 'mips', 'mips64'
|
// 还可以添加 'x86', 'x86_64', 'mips', 'mips64'
|
||||||
}
|
}
|
||||||
manifestPlaceholders = [
|
manifestPlaceholders = [
|
||||||
JPUSH_PKGNAME: "com.aoleyun.os",
|
XG_ACCESS_ID : "1500026378",
|
||||||
JPUSH_APPKEY : "0c7ba5a1622dba78d5bd00cc", //JPush 上注册的包名对应的 Appkey.
|
XG_ACCESS_KEY: "AH5QD9ZMBJ6R",
|
||||||
JPUSH_CHANNEL: "developer-default", //暂时填写默认值即可.
|
// JPUSH_PKGNAME: "com.aoleyun.os",
|
||||||
|
// JPUSH_APPKEY : "0c7ba5a1622dba78d5bd00cc", //JPush 上注册的包名对应的 Appkey.
|
||||||
|
// JPUSH_CHANNEL: "developer-default", //暂时填写默认值即可.
|
||||||
]
|
]
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
@@ -314,9 +325,11 @@ dependencies {
|
|||||||
implementation 'com.google.code.gson:gson:2.8.7'
|
implementation 'com.google.code.gson:gson:2.8.7'
|
||||||
//mmkv
|
//mmkv
|
||||||
implementation 'com.tencent:mmkv-static:1.2.10'
|
implementation 'com.tencent:mmkv-static:1.2.10'
|
||||||
|
//腾讯移动推送 TPNS
|
||||||
|
implementation 'com.tencent.tpns:tpns:1.2.2.0-release'
|
||||||
//极光推送
|
//极光推送
|
||||||
implementation 'cn.jiguang.sdk:jpush:3.8.6' // 此处以JPush 3.8.6 版本为例。
|
// implementation 'cn.jiguang.sdk:jpush:3.8.6' // 此处以JPush 3.8.6 版本为例。
|
||||||
implementation 'cn.jiguang.sdk:jcore:2.6.0' // 此处以JCore 2.6.0 版本为例。
|
// implementation 'cn.jiguang.sdk:jcore:2.6.0' // 此处以JCore 2.6.0 版本为例。
|
||||||
//下载
|
//下载
|
||||||
implementation 'me.laoyuyu.aria:core:3.8.16'
|
implementation 'me.laoyuyu.aria:core:3.8.16'
|
||||||
annotationProcessor 'me.laoyuyu.aria:compiler:3.8.16'
|
annotationProcessor 'me.laoyuyu.aria:compiler:3.8.16'
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 7.7 KiB |
|
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 3.4 KiB |
|
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 4.0 KiB |
|
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 4.4 KiB |
|
Before Width: | Height: | Size: 4.1 KiB After Width: | Height: | Size: 4.0 KiB |
|
Before Width: | Height: | Size: 4.1 KiB After Width: | Height: | Size: 4.0 KiB |
|
Before Width: | Height: | Size: 4.1 KiB After Width: | Height: | Size: 4.0 KiB |
|
Before Width: | Height: | Size: 4.1 KiB After Width: | Height: | Size: 4.0 KiB |
@@ -169,7 +169,6 @@ import java.util.Random;
|
|||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
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;
|
||||||
@@ -342,6 +341,8 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
|||||||
Observable.create(updateSubscribe)
|
Observable.create(updateSubscribe)
|
||||||
.throttleFirst(6, TimeUnit.HOURS)
|
.throttleFirst(6, TimeUnit.HOURS)
|
||||||
.subscribe(updateObserver);
|
.subscribe(updateObserver);
|
||||||
|
JGYUtils.getInstance().wakeUpAppstore();
|
||||||
|
JGYUtils.getInstance().wakeUpDeviceInfo();
|
||||||
startService(new Intent(Launcher.this, MainService.class));
|
startService(new Intent(Launcher.this, MainService.class));
|
||||||
if (DEBUG_STRICT_MODE) {
|
if (DEBUG_STRICT_MODE) {
|
||||||
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
|
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
|
||||||
@@ -471,12 +472,12 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
registerMessageReceiver(); // used for receive msg
|
registerMessageReceiver(); // used for receive msg
|
||||||
JPushInterface.init(this);
|
// JPushInterface.init(this);
|
||||||
String rid = JPushInterface.getRegistrationID(this);
|
// String rid = JPushInterface.getRegistrationID(this);
|
||||||
if (!TextUtils.isEmpty(rid)) {
|
// if (!TextUtils.isEmpty(rid)) {
|
||||||
Log.e("setJpushAlias", "RegId:" + rid);
|
// Log.e("setJpushAlias", "RegId:" + rid);
|
||||||
}
|
// }
|
||||||
JPushInterface.getAlias(this, new Random().nextInt(100));
|
// JPushInterface.getAlias(this, new Random().nextInt(100));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1115,8 +1116,11 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
|||||||
String app_name = APKUtils.getAppNameByPackage(Launcher.this, packageName);
|
String app_name = APKUtils.getAppNameByPackage(Launcher.this, packageName);
|
||||||
long openTime = TimeUtils.getInstance().getStartTime() / 1000;
|
long openTime = TimeUtils.getInstance().getStartTime() / 1000;
|
||||||
long closeTime = TimeUtils.getInstance().getEndTime() / 1000;
|
long closeTime = TimeUtils.getInstance().getEndTime() / 1000;
|
||||||
NetworkManager.getInstance().getAppUsageRecordControl()
|
NetworkManager.getInstance()
|
||||||
|
.getAppUsageRecordControl()
|
||||||
.sendAppUsageRecord(Utils.getSerial(), packageName, app_name, openTime, closeTime)
|
.sendAppUsageRecord(Utils.getSerial(), packageName, app_name, openTime, closeTime)
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(new Observer<BaseResponse>() {
|
.subscribe(new Observer<BaseResponse>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSubscribe(Disposable d) {
|
public void onSubscribe(Disposable d) {
|
||||||
|
|||||||
@@ -8,13 +8,15 @@ import android.util.Log;
|
|||||||
import com.aoleyun.os.BuildConfig;
|
import com.aoleyun.os.BuildConfig;
|
||||||
import com.aoleyun.os.uiuiutils.ToastUtil;
|
import com.aoleyun.os.uiuiutils.ToastUtil;
|
||||||
import com.aoleyun.os.uiuiutils.Utils;
|
import com.aoleyun.os.uiuiutils.Utils;
|
||||||
import com.aoleyun.os.jpush.TagAliasOperatorHelper;
|
|
||||||
import com.aoleyun.os.network.HTTPInterface;
|
import com.aoleyun.os.network.HTTPInterface;
|
||||||
import com.aoleyun.os.network.NetworkManager;
|
import com.aoleyun.os.network.NetworkManager;
|
||||||
import com.aoleyun.os.network.URLPath;
|
import com.aoleyun.os.network.URLPath;
|
||||||
import com.aoleyun.os.uiuiutils.JGYUtils;
|
import com.aoleyun.os.uiuiutils.JGYUtils;
|
||||||
import com.aoleyun.os.uiuiutils.TimeUtils;
|
import com.aoleyun.os.uiuiutils.TimeUtils;
|
||||||
import com.arialyy.aria.core.Aria;
|
import com.arialyy.aria.core.Aria;
|
||||||
|
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;
|
||||||
@@ -22,8 +24,6 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
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;
|
||||||
@@ -67,8 +67,21 @@ public class BaseApplication extends Application {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initJPush() {
|
private void initJPush() {
|
||||||
JPushInterface.setDebugMode(BuildConfig.DEBUG); // 设置开启日志,发布时请关闭日志
|
// JPushInterface.setDebugMode(BuildConfig.DEBUG); // 设置开启日志,发布时请关闭日志
|
||||||
JPushInterface.init(this);
|
// JPushInterface.init(this);
|
||||||
|
XGPushConfig.enableDebug(this,true);
|
||||||
|
XGPushManager.registerPush(this, new XGIOperateCallback() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(Object data, int flag) {
|
||||||
|
//token在设备卸载重装的时候有可能会变
|
||||||
|
Log.d("TPush", "注册成功,设备token为:" + data);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFail(Object data, int errCode, String msg) {
|
||||||
|
Log.d("TPush", "注册失败,错误码:" + errCode + ",错误信息:" + msg);
|
||||||
|
}
|
||||||
|
});
|
||||||
initAliasObservable();
|
initAliasObservable();
|
||||||
initTagObservable();
|
initTagObservable();
|
||||||
setJpushAlias();
|
setJpushAlias();
|
||||||
@@ -157,17 +170,17 @@ public class BaseApplication extends Application {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
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 void initTagObservable() {
|
private void initTagObservable() {
|
||||||
@@ -266,13 +279,13 @@ public class BaseApplication extends Application {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
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("jiguangInterface", "30s后重新设置tags");
|
Log.e("jiguangInterface", "30s后重新设置tags");
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.aoleyun.os.jpush;
|
package com.aoleyun.os.jpush;
|
||||||
|
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
import cn.jpush.android.api.JPushInterface;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For developer startup JPush SDK
|
* For developer startup JPush SDK
|
||||||
@@ -16,7 +15,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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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,37 @@ import android.content.Context;
|
|||||||
|
|
||||||
import com.aoleyun.os.base.BaseApplication;
|
import com.aoleyun.os.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);
|
||||||
}
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -15,8 +15,6 @@ import org.json.JSONObject;
|
|||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
import cn.jpush.android.api.JPushInterface;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 自定义接收器
|
* 自定义接收器
|
||||||
* <p>
|
* <p>
|
||||||
@@ -24,132 +22,130 @@ 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 {
|
|
||||||
Bundle bundle = intent.getExtras();
|
|
||||||
Logger.d(TAG, "[MyReceiver] onReceive - " + intent.getAction() + ", extras: " + printBundle(bundle));
|
|
||||||
|
|
||||||
if (JPushInterface.ACTION_REGISTRATION_ID.equals(intent.getAction())) {
|
|
||||||
String regId = bundle.getString(JPushInterface.EXTRA_REGISTRATION_ID);
|
|
||||||
Logger.d(TAG, "[MyReceiver] 接收Registration Id : " + regId);
|
|
||||||
//send the Registration Id to your server...
|
|
||||||
|
|
||||||
} else if (JPushInterface.ACTION_MESSAGE_RECEIVED.equals(intent.getAction())) {
|
|
||||||
Logger.d(TAG, "[MyReceiver] 接收到推送下来的自定义消息: " + bundle.getString(JPushInterface.EXTRA_MESSAGE));
|
|
||||||
processCustomMessage(context, bundle);
|
|
||||||
|
|
||||||
} else if (JPushInterface.ACTION_NOTIFICATION_RECEIVED.equals(intent.getAction())) {
|
|
||||||
Logger.d(TAG, "[MyReceiver] 接收到推送下来的通知");
|
|
||||||
int notifactionId = bundle.getInt(JPushInterface.EXTRA_NOTIFICATION_ID);
|
|
||||||
Logger.d(TAG, "[MyReceiver] 接收到推送下来的通知的ID: " + notifactionId);
|
|
||||||
|
|
||||||
} else if (JPushInterface.ACTION_NOTIFICATION_OPENED.equals(intent.getAction())) {
|
|
||||||
Logger.d(TAG, "[MyReceiver] 用户点击打开了通知");
|
|
||||||
|
|
||||||
//打开自定义的Activity
|
|
||||||
Intent i = new Intent(context, TestActivity.class);
|
|
||||||
i.putExtras(bundle);
|
|
||||||
//i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
||||||
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
|
||||||
context.startActivity(i);
|
|
||||||
|
|
||||||
} else if (JPushInterface.ACTION_CONNECTION_CHANGE.equals(intent.getAction())) {
|
|
||||||
boolean connected = intent.getBooleanExtra(JPushInterface.EXTRA_CONNECTION_CHANGE, false);
|
|
||||||
Logger.w(TAG, "[MyReceiver]" + intent.getAction() + " connected state change to " + connected);
|
|
||||||
} else {
|
|
||||||
Logger.d(TAG, "[MyReceiver] Unhandled intent - " + intent.getAction());
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// 打印所有的 intent extra 数据
|
|
||||||
private static String printBundle(Bundle bundle) {
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
for (String key : bundle.keySet()) {
|
|
||||||
if (key.equals(JPushInterface.EXTRA_NOTIFICATION_ID)) {
|
|
||||||
sb.append("\nkey:" + key + ", value:" + bundle.getInt(key));
|
|
||||||
} else if (key.equals(JPushInterface.EXTRA_CONNECTION_CHANGE)) {
|
|
||||||
sb.append("\nkey:" + key + ", value:" + bundle.getBoolean(key));
|
|
||||||
} else if (key.equals(JPushInterface.EXTRA_EXTRA)) {
|
|
||||||
if (TextUtils.isEmpty(bundle.getString(JPushInterface.EXTRA_EXTRA))) {
|
|
||||||
Logger.i(TAG, "This message has no Extra data");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
JSONObject json = new JSONObject(bundle.getString(JPushInterface.EXTRA_EXTRA));
|
|
||||||
Iterator<String> it = json.keys();
|
|
||||||
|
|
||||||
while (it.hasNext()) {
|
|
||||||
String myKey = it.next();
|
|
||||||
sb.append("\nkey:" + key + ", value: [" +
|
|
||||||
myKey + " - " + json.optString(myKey) + "]");
|
|
||||||
}
|
|
||||||
} catch (JSONException e) {
|
|
||||||
Logger.e(TAG, "Get message extra JSON error!");
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
sb.append("\nkey:" + key + ", value:" + bundle.get(key));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final String SEND_RUNNING_APP = "2";
|
|
||||||
//应用锁
|
|
||||||
private static final String UPDATE_APP_LOCK = "39";
|
|
||||||
|
|
||||||
|
|
||||||
//send msg to MainActivity
|
|
||||||
private void processCustomMessage(Context context, Bundle bundle) {
|
|
||||||
// if (Launcher.isForeground) {
|
|
||||||
// String message = bundle.getString(JPushInterface.EXTRA_MESSAGE);
|
|
||||||
// String extras = bundle.getString(JPushInterface.EXTRA_EXTRA);
|
|
||||||
// Intent msgIntent = new Intent(Launcher.MESSAGE_RECEIVED_ACTION);
|
|
||||||
// msgIntent.putExtra(Launcher.KEY_MESSAGE, message);
|
|
||||||
// if (!ExampleUtil.isEmpty(extras)) {
|
|
||||||
// try {
|
// try {
|
||||||
// JSONObject extraJson = new JSONObject(extras);
|
// Bundle bundle = intent.getExtras();
|
||||||
// if (extraJson.length() > 0) {
|
// Logger.d(TAG, "[MyReceiver] onReceive - " + intent.getAction() + ", extras: " + printBundle(bundle));
|
||||||
// msgIntent.putExtra(Launcher.KEY_EXTRAS, extras);
|
//
|
||||||
|
// if (JPushInterface.ACTION_REGISTRATION_ID.equals(intent.getAction())) {
|
||||||
|
// String regId = bundle.getString(JPushInterface.EXTRA_REGISTRATION_ID);
|
||||||
|
// Logger.d(TAG, "[MyReceiver] 接收Registration Id : " + regId);
|
||||||
|
// //send the Registration Id to your server...
|
||||||
|
//
|
||||||
|
// } else if (JPushInterface.ACTION_MESSAGE_RECEIVED.equals(intent.getAction())) {
|
||||||
|
// Logger.d(TAG, "[MyReceiver] 接收到推送下来的自定义消息: " + bundle.getString(JPushInterface.EXTRA_MESSAGE));
|
||||||
|
// processCustomMessage(context, bundle);
|
||||||
|
//
|
||||||
|
// } else if (JPushInterface.ACTION_NOTIFICATION_RECEIVED.equals(intent.getAction())) {
|
||||||
|
// Logger.d(TAG, "[MyReceiver] 接收到推送下来的通知");
|
||||||
|
// int notifactionId = bundle.getInt(JPushInterface.EXTRA_NOTIFICATION_ID);
|
||||||
|
// Logger.d(TAG, "[MyReceiver] 接收到推送下来的通知的ID: " + notifactionId);
|
||||||
|
//
|
||||||
|
// } else if (JPushInterface.ACTION_NOTIFICATION_OPENED.equals(intent.getAction())) {
|
||||||
|
// Logger.d(TAG, "[MyReceiver] 用户点击打开了通知");
|
||||||
|
//
|
||||||
|
// //打开自定义的Activity
|
||||||
|
// Intent i = new Intent(context, TestActivity.class);
|
||||||
|
// i.putExtras(bundle);
|
||||||
|
// //i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
// i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||||
|
// context.startActivity(i);
|
||||||
|
//
|
||||||
|
// } else if (JPushInterface.ACTION_CONNECTION_CHANGE.equals(intent.getAction())) {
|
||||||
|
// boolean connected = intent.getBooleanExtra(JPushInterface.EXTRA_CONNECTION_CHANGE, false);
|
||||||
|
// Logger.w(TAG, "[MyReceiver]" + intent.getAction() + " connected state change to " + connected);
|
||||||
|
// } else {
|
||||||
|
// Logger.d(TAG, "[MyReceiver] Unhandled intent - " + intent.getAction());
|
||||||
|
// }
|
||||||
|
// } catch (Exception e) {
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // 打印所有的 intent extra 数据
|
||||||
|
// private static String printBundle(Bundle bundle) {
|
||||||
|
// StringBuilder sb = new StringBuilder();
|
||||||
|
// for (String key : bundle.keySet()) {
|
||||||
|
// if (key.equals(JPushInterface.EXTRA_NOTIFICATION_ID)) {
|
||||||
|
// sb.append("\nkey:" + key + ", value:" + bundle.getInt(key));
|
||||||
|
// } else if (key.equals(JPushInterface.EXTRA_CONNECTION_CHANGE)) {
|
||||||
|
// sb.append("\nkey:" + key + ", value:" + bundle.getBoolean(key));
|
||||||
|
// } else if (key.equals(JPushInterface.EXTRA_EXTRA)) {
|
||||||
|
// if (TextUtils.isEmpty(bundle.getString(JPushInterface.EXTRA_EXTRA))) {
|
||||||
|
// Logger.i(TAG, "This message has no Extra data");
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// try {
|
||||||
|
// JSONObject json = new JSONObject(bundle.getString(JPushInterface.EXTRA_EXTRA));
|
||||||
|
// Iterator<String> it = json.keys();
|
||||||
|
//
|
||||||
|
// while (it.hasNext()) {
|
||||||
|
// String myKey = it.next();
|
||||||
|
// sb.append("\nkey:" + key + ", value: [" +
|
||||||
|
// myKey + " - " + json.optString(myKey) + "]");
|
||||||
// }
|
// }
|
||||||
// } catch (JSONException e) {
|
// } catch (JSONException e) {
|
||||||
|
// Logger.e(TAG, "Get message extra JSON error!");
|
||||||
|
// }
|
||||||
//
|
//
|
||||||
|
// } else {
|
||||||
|
// sb.append("\nkey:" + key + ", value:" + bundle.get(key));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return sb.toString();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// private static final String SEND_RUNNING_APP = "2";
|
||||||
|
// //应用锁
|
||||||
|
// private static final String UPDATE_APP_LOCK = "39";
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// //send msg to MainActivity
|
||||||
|
// private void processCustomMessage(Context context, Bundle bundle) {
|
||||||
|
//// if (Launcher.isForeground) {
|
||||||
|
//// String message = bundle.getString(JPushInterface.EXTRA_MESSAGE);
|
||||||
|
//// String extras = bundle.getString(JPushInterface.EXTRA_EXTRA);
|
||||||
|
//// Intent msgIntent = new Intent(Launcher.MESSAGE_RECEIVED_ACTION);
|
||||||
|
//// msgIntent.putExtra(Launcher.KEY_MESSAGE, message);
|
||||||
|
//// if (!ExampleUtil.isEmpty(extras)) {
|
||||||
|
//// try {
|
||||||
|
//// JSONObject extraJson = new JSONObject(extras);
|
||||||
|
//// if (extraJson.length() > 0) {
|
||||||
|
//// msgIntent.putExtra(Launcher.KEY_EXTRAS, extras);
|
||||||
|
//// }
|
||||||
|
//// } catch (JSONException e) {
|
||||||
|
////
|
||||||
|
//// }
|
||||||
|
////
|
||||||
|
//// }
|
||||||
|
//// LocalBroadcastManager.getInstance(context).sendBroadcast(msgIntent);
|
||||||
|
//// }
|
||||||
|
//
|
||||||
|
// String message = bundle.getString(JPushInterface.EXTRA_MESSAGE);
|
||||||
|
// String title = bundle.getString(JPushInterface.EXTRA_TITLE);
|
||||||
|
// String type = bundle.getString(JPushInterface.EXTRA_CONTENT_TYPE);
|
||||||
|
// String extras = bundle.getString(JPushInterface.EXTRA_EXTRA);
|
||||||
|
//
|
||||||
|
// switch (message) {
|
||||||
|
// case SEND_RUNNING_APP:
|
||||||
|
// getRunningApp(context);
|
||||||
|
// break;
|
||||||
|
// case UPDATE_APP_LOCK:
|
||||||
|
// HTTPInterface.getAppPasswd();
|
||||||
|
// break;
|
||||||
|
// default:
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// private void getRunningApp(Context context) {
|
||||||
|
// HTTPInterface.sendRunningApp(context);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
//}
|
//}
|
||||||
// LocalBroadcastManager.getInstance(context).sendBroadcast(msgIntent);
|
|
||||||
// }
|
|
||||||
|
|
||||||
String message = bundle.getString(JPushInterface.EXTRA_MESSAGE);
|
|
||||||
String title = bundle.getString(JPushInterface.EXTRA_TITLE);
|
|
||||||
String type = bundle.getString(JPushInterface.EXTRA_CONTENT_TYPE);
|
|
||||||
String extras = bundle.getString(JPushInterface.EXTRA_EXTRA);
|
|
||||||
|
|
||||||
switch (message) {
|
|
||||||
case SEND_RUNNING_APP:
|
|
||||||
getRunningApp(context);
|
|
||||||
break;
|
|
||||||
case UPDATE_APP_LOCK:
|
|
||||||
HTTPInterface.getAppPasswd();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void getRunningApp(Context context) {
|
|
||||||
HTTPInterface.sendRunningApp(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.aoleyun.os.jpush;
|
package com.aoleyun.os.jpush;
|
||||||
|
|
||||||
import cn.jpush.android.service.JCommonService;
|
|
||||||
|
|
||||||
public class PushService extends JCommonService {
|
//public class PushService extends JCommonService {
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
|||||||
@@ -11,335 +11,334 @@ import com.aoleyun.os.uiuiutils.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) {
|
//
|
||||||
int sequence = jPushMessage.getSequence();
|
// public void onTagOperatorResult(Context context, JPushMessage jPushMessage) {
|
||||||
Logger.i(TAG,"action - onTagOperatorResult, sequence:"+sequence+",tags:"+jPushMessage.getTags());
|
// int sequence = jPushMessage.getSequence();
|
||||||
Logger.i(TAG,"tags size:"+jPushMessage.getTags().size());
|
// Logger.i(TAG,"action - onTagOperatorResult, sequence:"+sequence+",tags:"+jPushMessage.getTags());
|
||||||
init(context);
|
// Logger.i(TAG,"tags size:"+jPushMessage.getTags().size());
|
||||||
//根据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,"action - modify tag Success,sequence:"+sequence);
|
// if(jPushMessage.getErrorCode() == 0){
|
||||||
setActionCache.remove(sequence);
|
// Logger.i(TAG,"action - modify tag Success,sequence:"+sequence);
|
||||||
String logs = getActionStr(tagAliasBean.action)+" tags success";
|
// setActionCache.remove(sequence);
|
||||||
Logger.i(TAG,logs);
|
// String logs = getActionStr(tagAliasBean.action)+" tags success";
|
||||||
Log.e(TAG,"Tag绑定成功: " + jPushMessage.getTags());
|
// Logger.i(TAG,logs);
|
||||||
ToastUtil.betaShow("Tag绑定成功: " + jPushMessage.getTags());
|
// Log.e(TAG,"Tag绑定成功: " + jPushMessage.getTags());
|
||||||
ExampleUtil.showToast(logs, context);
|
// ToastUtil.betaShow("Tag绑定成功: " + jPushMessage.getTags());
|
||||||
}else{
|
// ExampleUtil.showToast(logs, context);
|
||||||
String logs = "Failed to " + getActionStr(tagAliasBean.action)+" tags";
|
// }else{
|
||||||
if(jPushMessage.getErrorCode() == 6018){
|
// String logs = "Failed to " + getActionStr(tagAliasBean.action)+" tags";
|
||||||
//tag数量超过限制,需要先清除一部分再add
|
// if(jPushMessage.getErrorCode() == 6018){
|
||||||
logs += ", tags is exceed limit need to clean";
|
// //tag数量超过限制,需要先清除一部分再add
|
||||||
}
|
// logs += ", tags is exceed limit need to clean";
|
||||||
logs += ", errorCode:" + jPushMessage.getErrorCode();
|
// }
|
||||||
Logger.e(TAG, logs);
|
// logs += ", 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 onCheckTagOperatorResult(Context context, JPushMessage jPushMessage){
|
// }
|
||||||
int sequence = jPushMessage.getSequence();
|
//
|
||||||
Logger.i(TAG,"action - onCheckTagOperatorResult, sequence:"+sequence+",checktag:"+jPushMessage.getCheckTag());
|
// public void onCheckTagOperatorResult(Context context, JPushMessage jPushMessage){
|
||||||
init(context);
|
// int sequence = jPushMessage.getSequence();
|
||||||
//根据sequence从之前操作缓存中获取缓存记录
|
// Logger.i(TAG,"action - onCheckTagOperatorResult, sequence:"+sequence+",checktag:"+jPushMessage.getCheckTag());
|
||||||
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,"tagBean:"+tagAliasBean);
|
// }
|
||||||
setActionCache.remove(sequence);
|
// if(jPushMessage.getErrorCode() == 0){
|
||||||
String logs = getActionStr(tagAliasBean.action)+" tag "+jPushMessage.getCheckTag() + " bind state success,state:"+jPushMessage.getTagCheckStateResult();
|
// Logger.i(TAG,"tagBean:"+tagAliasBean);
|
||||||
Logger.i(TAG,logs);
|
// setActionCache.remove(sequence);
|
||||||
ExampleUtil.showToast(logs, context);
|
// String logs = getActionStr(tagAliasBean.action)+" tag "+jPushMessage.getCheckTag() + " bind state success,state:"+jPushMessage.getTagCheckStateResult();
|
||||||
}else{
|
// Logger.i(TAG,logs);
|
||||||
String logs = "Failed to " + getActionStr(tagAliasBean.action)+" tags, errorCode:" + jPushMessage.getErrorCode();
|
// ExampleUtil.showToast(logs, context);
|
||||||
Logger.e(TAG, logs);
|
// }else{
|
||||||
if(!RetryActionIfNeeded(jPushMessage.getErrorCode(),tagAliasBean)) {
|
// String logs = "Failed to " + getActionStr(tagAliasBean.action)+" tags, errorCode:" + jPushMessage.getErrorCode();
|
||||||
ExampleUtil.showToast(logs, context);
|
// Logger.e(TAG, logs);
|
||||||
}
|
// 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());
|
//
|
||||||
init(context);
|
// public void onAliasOperatorResult(Context context, JPushMessage jPushMessage) {
|
||||||
//根据sequence从之前操作缓存中获取缓存记录
|
// int sequence = jPushMessage.getSequence();
|
||||||
TagAliasBean tagAliasBean = (TagAliasBean)setActionCache.get(sequence);
|
// Logger.i(TAG,"action - onAliasOperatorResult, sequence:"+sequence+",alias:"+jPushMessage.getAlias());
|
||||||
if(tagAliasBean == null){
|
// init(context);
|
||||||
ExampleUtil.showToast("获取缓存记录失败", context);
|
// //根据sequence从之前操作缓存中获取缓存记录
|
||||||
return;
|
// TagAliasBean tagAliasBean = (TagAliasBean)setActionCache.get(sequence);
|
||||||
}
|
// if(tagAliasBean == null){
|
||||||
if(jPushMessage.getErrorCode() == 0){
|
// ExampleUtil.showToast("获取缓存记录失败", context);
|
||||||
Logger.i(TAG,"action - modify alias Success,sequence:"+sequence);
|
// return;
|
||||||
setActionCache.remove(sequence);
|
// }
|
||||||
String logs = getActionStr(tagAliasBean.action)+" alias success";
|
// if(jPushMessage.getErrorCode() == 0){
|
||||||
Logger.i(TAG,logs);
|
// Logger.i(TAG,"action - modify alias Success,sequence:"+sequence);
|
||||||
Log.e(TAG,"Alias绑定成功: "+jPushMessage.getAlias());
|
// setActionCache.remove(sequence);
|
||||||
ToastUtil.betaShow("Alias绑定成功: "+jPushMessage.getAlias());
|
// String logs = getActionStr(tagAliasBean.action)+" alias success";
|
||||||
ExampleUtil.showToast(logs, context);
|
// Logger.i(TAG,logs);
|
||||||
}else{
|
// Log.e(TAG,"Alias绑定成功: "+jPushMessage.getAlias());
|
||||||
String logs = "Failed to " + getActionStr(tagAliasBean.action)+" alias, errorCode:" + jPushMessage.getErrorCode();
|
// ToastUtil.betaShow("Alias绑定成功: "+jPushMessage.getAlias());
|
||||||
Logger.e(TAG, logs);
|
// ExampleUtil.showToast(logs, context);
|
||||||
if(!RetryActionIfNeeded(jPushMessage.getErrorCode(),tagAliasBean)) {
|
// }else{
|
||||||
ExampleUtil.showToast(logs, context);
|
// String logs = "Failed to " + getActionStr(tagAliasBean.action)+" alias, errorCode:" + jPushMessage.getErrorCode();
|
||||||
}
|
// 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());
|
// //设置手机号码回调
|
||||||
init(context);
|
// public void onMobileNumberOperatorResult(Context context, JPushMessage jPushMessage) {
|
||||||
if(jPushMessage.getErrorCode() == 0){
|
// int sequence = jPushMessage.getSequence();
|
||||||
Logger.i(TAG,"action - set mobile number Success,sequence:"+sequence);
|
// Logger.i(TAG,"action - onMobileNumberOperatorResult, sequence:"+sequence+",mobileNumber:"+jPushMessage.getMobileNumber());
|
||||||
setActionCache.remove(sequence);
|
// init(context);
|
||||||
}else{
|
// if(jPushMessage.getErrorCode() == 0){
|
||||||
String logs = "Failed to set mobile number, errorCode:" + jPushMessage.getErrorCode();
|
// Logger.i(TAG,"action - set mobile number Success,sequence:"+sequence);
|
||||||
Logger.e(TAG, logs);
|
// setActionCache.remove(sequence);
|
||||||
if(!RetrySetMObileNumberActionIfNeeded(jPushMessage.getErrorCode(),jPushMessage.getMobileNumber())){
|
// }else{
|
||||||
ExampleUtil.showToast(logs, context);
|
// String logs = "Failed to set mobile number, errorCode:" + jPushMessage.getErrorCode();
|
||||||
}
|
// 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 String alias;
|
//
|
||||||
public boolean isAliasAction;
|
// public static class TagAliasBean{
|
||||||
|
// public int action;
|
||||||
@Override
|
// public Set<String> tags;
|
||||||
public String toString() {
|
// public String alias;
|
||||||
return "TagAliasBean{" +
|
// public boolean isAliasAction;
|
||||||
"action=" + action +
|
//
|
||||||
", tags=" + tags +
|
// @Override
|
||||||
", alias='" + alias + '\'' +
|
// public String toString() {
|
||||||
", isAliasAction=" + isAliasAction +
|
// return "TagAliasBean{" +
|
||||||
'}';
|
// "action=" + action +
|
||||||
}
|
// ", tags=" + tags +
|
||||||
}
|
// ", alias='" + alias + '\'' +
|
||||||
|
// ", isAliasAction=" + isAliasAction +
|
||||||
|
// '}';
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|||||||
@@ -6,8 +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 {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -21,8 +19,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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,6 +35,8 @@ import android.content.pm.ShortcutInfo;
|
|||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Process;
|
import android.os.Process;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
|
import android.provider.Settings;
|
||||||
|
import android.provider.SettingsValidators;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.LongSparseArray;
|
import android.util.LongSparseArray;
|
||||||
@@ -274,8 +276,8 @@ public class LoaderTask implements Runnable {
|
|||||||
this.add("com.aoleyunos.dop1");
|
this.add("com.aoleyunos.dop1");
|
||||||
this.add("com.aoleyunos.dop2");
|
this.add("com.aoleyunos.dop2");
|
||||||
//system
|
//system
|
||||||
this.add("com.android.documentsui");
|
// this.add("com.android.documentsui");
|
||||||
this.add("com.android.messaging");
|
// this.add("com.android.messaging");
|
||||||
this.add("com.android.music");
|
this.add("com.android.music");
|
||||||
this.add("com.android.camera");
|
this.add("com.android.camera");
|
||||||
this.add("com.android.camera2");
|
this.add("com.android.camera2");
|
||||||
@@ -296,16 +298,26 @@ public class LoaderTask implements Runnable {
|
|||||||
final Context context = mApp.getContext();
|
final Context context = mApp.getContext();
|
||||||
ArrayList<Pair<ItemInfo, Object>> installQueue = new ArrayList<>();
|
ArrayList<Pair<ItemInfo, Object>> installQueue = new ArrayList<>();
|
||||||
final List<UserHandle> profiles = mUserManager.getUserProfiles();
|
final List<UserHandle> profiles = mUserManager.getUserProfiles();
|
||||||
|
String whiteList = Settings.System.getString(context.getContentResolver(), "only_jgy_shortcut_list");
|
||||||
for (UserHandle user : profiles) {
|
for (UserHandle user : profiles) {
|
||||||
final List<LauncherActivityInfo> apps = mLauncherApps.getActivityList(null, user);
|
final List<LauncherActivityInfo> apps = mLauncherApps.getActivityList(null, user);
|
||||||
ArrayList<InstallShortcutReceiver.PendingInstallShortcutInfo> added = new ArrayList<InstallShortcutReceiver.PendingInstallShortcutInfo>();
|
ArrayList<InstallShortcutReceiver.PendingInstallShortcutInfo> added = new ArrayList<InstallShortcutReceiver.PendingInstallShortcutInfo>();
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
for (LauncherActivityInfo app : apps) {
|
for (LauncherActivityInfo app : apps) {
|
||||||
|
if (BuildConfig.APPLICATION_ID.equals(app.getApplicationInfo().packageName))
|
||||||
|
continue;
|
||||||
|
Log.e(TAG, "verifyApplications: " + app.getApplicationInfo().packageName);
|
||||||
/*系统应用*/
|
/*系统应用*/
|
||||||
if ((app.getApplicationFlags() & ApplicationInfo.FLAG_SYSTEM) == 1) {
|
if ((app.getApplicationFlags() & ApplicationInfo.FLAG_SYSTEM) == 1) {
|
||||||
if (!showApp.contains(app.getApplicationInfo().packageName)) {
|
if (!showApp.contains(app.getApplicationInfo().packageName)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (TextUtils.isEmpty(whiteList)) {
|
||||||
|
continue;
|
||||||
|
} else if (!whiteList.contains(app.getApplicationInfo().packageName)){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
InstallShortcutReceiver.PendingInstallShortcutInfo pendingInstallShortcutInfo = new InstallShortcutReceiver.PendingInstallShortcutInfo(app, context);
|
InstallShortcutReceiver.PendingInstallShortcutInfo pendingInstallShortcutInfo = new InstallShortcutReceiver.PendingInstallShortcutInfo(app, context);
|
||||||
added.add(pendingInstallShortcutInfo);
|
added.add(pendingInstallShortcutInfo);
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import android.util.Log;
|
|||||||
import com.aoleyun.os.network.bean.AppPasswdBean;
|
import com.aoleyun.os.network.bean.AppPasswdBean;
|
||||||
import com.aoleyun.os.network.bean.BaseResponse;
|
import com.aoleyun.os.network.bean.BaseResponse;
|
||||||
import com.aoleyun.os.uiuiutils.APKUtils;
|
import com.aoleyun.os.uiuiutils.APKUtils;
|
||||||
import com.aoleyun.os.jpush.TagAliasOperatorHelper;
|
//import com.aoleyun.os.jpush.TagAliasOperatorHelper;
|
||||||
import com.aoleyun.os.uiuiutils.JGYUtils;
|
import com.aoleyun.os.uiuiutils.JGYUtils;
|
||||||
import com.aoleyun.os.uiuiutils.TimeUtils;
|
import com.aoleyun.os.uiuiutils.TimeUtils;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
@@ -23,9 +23,6 @@ import io.reactivex.Observer;
|
|||||||
import io.reactivex.annotations.NonNull;
|
import io.reactivex.annotations.NonNull;
|
||||||
import io.reactivex.disposables.Disposable;
|
import io.reactivex.disposables.Disposable;
|
||||||
|
|
||||||
import static com.aoleyun.os.jpush.TagAliasOperatorHelper.ACTION_SET;
|
|
||||||
import static com.aoleyun.os.jpush.TagAliasOperatorHelper.sequence;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author : fanhuitong
|
* @author : fanhuitong
|
||||||
* e-mail :
|
* e-mail :
|
||||||
@@ -97,7 +94,7 @@ public class HTTPInterface {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
setTag(context, set);
|
// setTag(context, set);
|
||||||
} else {
|
} else {
|
||||||
Log.e(TAG + ":" + "setJpushTags", "onNext: " + "batch empty");
|
Log.e(TAG + ":" + "setJpushTags", "onNext: " + "batch empty");
|
||||||
}
|
}
|
||||||
@@ -159,13 +156,13 @@ public class HTTPInterface {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,17 @@
|
|||||||
package com.aoleyun.os.uiuiutils;
|
package com.aoleyun.os.uiuiutils;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
|
import android.content.ComponentName;
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
import android.content.pm.ApplicationInfo;
|
import android.content.pm.ApplicationInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
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 com.android.server.BootReceiver;
|
||||||
import com.aoleyun.os.BuildConfig;
|
import com.aoleyun.os.BuildConfig;
|
||||||
import com.aoleyun.os.model.LoaderTask;
|
import com.aoleyun.os.model.LoaderTask;
|
||||||
|
|
||||||
@@ -180,5 +183,30 @@ public class JGYUtils {
|
|||||||
appSet.addAll(LoaderTask.showApp);
|
appSet.addAll(LoaderTask.showApp);
|
||||||
return appSet.contains(pkg);
|
return appSet.contains(pkg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static final String PACKAGE_DEVICEINFO = "com.aoleyun.sn";
|
||||||
|
public static final String PACKAGE_APPSTORE = "com.aoleyun.appstore";
|
||||||
|
|
||||||
|
public static final String CLASS_DEVICEINFO = "com.aoleyun.sn.receiver.BootReceiver";
|
||||||
|
public static final String CLASS_APPSTORE = "com.aoleyun.appstore.receiver.BootReceiver";
|
||||||
|
|
||||||
|
public static final String ACTION_DEVICEINFO = "com.aoleyun.sn.intent.action.BOOT_COMPLETED";
|
||||||
|
public static final String ACTION_APPSTORE = "com.aoleyun.appstore.intent.action.BOOT_COMPLETED";
|
||||||
|
|
||||||
|
public void wakeUpDeviceInfo() {
|
||||||
|
//启动设备信息
|
||||||
|
Intent bootIntent = new Intent(ACTION_DEVICEINFO);
|
||||||
|
bootIntent.setComponent(new ComponentName(PACKAGE_DEVICEINFO, CLASS_DEVICEINFO));
|
||||||
|
mContext.sendBroadcast(bootIntent);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void wakeUpAppstore() {
|
||||||
|
//启动应用市场
|
||||||
|
Intent bootIntent = new Intent(ACTION_APPSTORE);
|
||||||
|
bootIntent.setComponent(new ComponentName(PACKAGE_APPSTORE, CLASS_APPSTORE));
|
||||||
|
mContext.sendBroadcast(bootIntent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||