version:zhanrui 6.4.0
fix: update:更换推送
This commit is contained in:
@@ -48,6 +48,7 @@
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.READ_PRIVILEGED_PHONE_STATE" />
|
||||
|
||||
<!-- 【必须】 移动推送 TPNS SDK VIP版本所需权限 -->
|
||||
<permission
|
||||
@@ -233,161 +234,6 @@
|
||||
android:readPermission="android.permission.WRITE_SECURE_SETTINGS"
|
||||
android:writePermission="android.permission.WRITE_SECURE_SETTINGS" />
|
||||
|
||||
|
||||
<!-- Rich push 核心功能 since 2.0.6-->
|
||||
<!-- <activity-->
|
||||
<!-- android:name="cn.jpush.android.ui.PopWinActivity"-->
|
||||
<!-- android:exported="false"-->
|
||||
<!-- android:theme="@style/MyDialogStyle"-->
|
||||
<!-- tools:replace="android:exported"></activity>-->
|
||||
|
||||
<!-- Required SDK核心功能-->
|
||||
<!-- <activity-->
|
||||
<!-- android:name="cn.jpush.android.ui.PushActivity"-->
|
||||
<!-- android:configChanges="orientation|keyboardHidden"-->
|
||||
<!-- android:exported="false"-->
|
||||
<!-- android:theme="@android:style/Theme.NoTitleBar"-->
|
||||
<!-- tools:replace="android:exported">-->
|
||||
<!-- <intent-filter>-->
|
||||
<!-- <action android:name="cn.jpush.android.ui.PushActivity" />-->
|
||||
|
||||
<!-- <category android:name="android.intent.category.DEFAULT" />-->
|
||||
<!-- <category android:name="${applicationId}" />-->
|
||||
<!-- </intent-filter>-->
|
||||
<!-- </activity>-->
|
||||
|
||||
<!-- Required SDK 核心功能-->
|
||||
<!-- 可配置android:process参数将PushService放在其他进程中 -->
|
||||
<!-- <service-->
|
||||
<!-- android:name="cn.jpush.android.service.PushService"-->
|
||||
<!-- android:exported="false"-->
|
||||
<!-- android:process=":pushcore">-->
|
||||
<!-- <intent-filter>-->
|
||||
<!-- <action android:name="cn.jpush.android.intent.REGISTER" />-->
|
||||
<!-- <action android:name="cn.jpush.android.intent.REPORT" />-->
|
||||
<!-- <action android:name="cn.jpush.android.intent.PushService" />-->
|
||||
<!-- <action android:name="cn.jpush.android.intent.PUSH_TIME" />-->
|
||||
<!-- </intent-filter>-->
|
||||
<!-- </service>-->
|
||||
|
||||
<!-- since 3.0.9 Required SDK 核心功能-->
|
||||
<!-- <provider-->
|
||||
<!-- android:name="cn.jpush.android.service.DataProvider"-->
|
||||
<!-- android:authorities="${applicationId}.DataProvider"-->
|
||||
<!-- android:exported="false"-->
|
||||
<!-- android:process=":pushcore"-->
|
||||
<!-- tools:replace="android:authorities" />-->
|
||||
|
||||
<!-- since 1.8.0 option 可选项。用于同一设备中不同应用的JPush服务相互拉起的功能。 -->
|
||||
<!-- 若不启用该功能可删除该组件,将不拉起其他应用也不能被其他应用拉起 -->
|
||||
<!-- <service-->
|
||||
<!-- android:name="cn.jpush.android.service.DaemonService"-->
|
||||
<!-- android:enabled="true"-->
|
||||
<!-- android:exported="true">-->
|
||||
<!-- <intent-filter>-->
|
||||
<!-- <action android:name="cn.jpush.android.intent.DaemonService" />-->
|
||||
<!-- <category android:name="${applicationId}" />-->
|
||||
<!-- </intent-filter>-->
|
||||
|
||||
<!-- </service>-->
|
||||
|
||||
<!-- since 3.1.0 Required SDK 核心功能-->
|
||||
<!-- <provider-->
|
||||
<!-- android:name="cn.jpush.android.service.DownloadProvider"-->
|
||||
<!-- android:authorities="${applicationId}.DownloadProvider"-->
|
||||
<!-- android:exported="true"-->
|
||||
<!-- tools:replace="android:authorities" />-->
|
||||
|
||||
<!-- Required SDK核心功能-->
|
||||
<!-- <receiver-->
|
||||
<!-- android:name="cn.jpush.android.service.PushReceiver"-->
|
||||
<!-- android:enabled="true"-->
|
||||
<!-- android:exported="false"-->
|
||||
<!-- tools:replace="android:exported">-->
|
||||
<!-- <intent-filter android:priority="1000">-->
|
||||
<!-- <action android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED_PROXY" /> <!–Required 显示通知栏 –>-->
|
||||
<!-- <category android:name="${applicationId}" />-->
|
||||
<!-- </intent-filter>-->
|
||||
<!-- <intent-filter>-->
|
||||
<!-- <action android:name="android.intent.action.USER_PRESENT" />-->
|
||||
<!-- <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />-->
|
||||
<!-- </intent-filter>-->
|
||||
<!-- <!– Optional –>-->
|
||||
<!-- <intent-filter>-->
|
||||
<!-- <action android:name="android.intent.action.PACKAGE_ADDED" />-->
|
||||
<!-- <action android:name="android.intent.action.PACKAGE_REMOVED" />-->
|
||||
|
||||
<!-- <data android:scheme="package" />-->
|
||||
<!-- </intent-filter>-->
|
||||
<!-- </receiver>-->
|
||||
|
||||
<!-- Required SDK核心功能-->
|
||||
<!-- <receiver-->
|
||||
<!-- android:name="cn.jpush.android.service.AlarmReceiver"-->
|
||||
<!-- android:exported="false" />-->
|
||||
|
||||
|
||||
<!-- <!– User defined. For test only 用户自定义的广播接收器–>-->
|
||||
<!-- <receiver-->
|
||||
<!-- android:name="com.aoleyun.os.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="${applicationId}" />-->
|
||||
<!-- </intent-filter>-->
|
||||
<!-- </receiver>-->
|
||||
|
||||
|
||||
<!-- <!– User defined. For test only 用户自定义接收消息器,3.0.7开始支持,目前新tag/alias接口设置结果会在该广播接收器对应的方法中回调–>-->
|
||||
<!-- <!–since 3.3.0 接收JPush相关事件–>-->
|
||||
<!-- <receiver android:name="com.aoleyun.os.jpush.MyJPushMessageReceiver">-->
|
||||
<!-- <intent-filter>-->
|
||||
<!-- <action android:name="cn.jpush.android.intent.RECEIVE_MESSAGE" />-->
|
||||
<!-- <category android:name="${applicationId}" />-->
|
||||
<!-- </intent-filter>-->
|
||||
<!-- </receiver>-->
|
||||
<!-- <receiver-->
|
||||
<!-- android:name="com.aoleyun.os.receiver.InstallResultReceiver"-->
|
||||
<!-- android:enabled="true"-->
|
||||
<!-- android:exported="true" />-->
|
||||
|
||||
<!--since 3.3.0 Required SDK核心功能-->
|
||||
<!-- <activity-->
|
||||
<!-- android:name="cn.jpush.android.service.JNotifyActivity"-->
|
||||
<!-- android:exported="true"-->
|
||||
<!-- android:taskAffinity="jpush.custom"-->
|
||||
<!-- android:theme="@android:style/Theme.Translucent.NoTitleBar">-->
|
||||
<!-- <intent-filter>-->
|
||||
<!-- <action android:name="cn.jpush.android.intent.JNotifyActivity" />-->
|
||||
<!-- <category android:name="${applicationId}" />-->
|
||||
<!-- </intent-filter>-->
|
||||
<!-- </activity>-->
|
||||
|
||||
<!-- <!– since 3.3.0 Required SDK 核心功能–>-->
|
||||
<!-- <!– 可配置android:process参数将PushService放在其他进程中 –>-->
|
||||
<!-- <!–User defined. For test only 继承自cn.jpush.android.service.JCommonService–>-->
|
||||
<!-- <service-->
|
||||
<!-- android:name="com.aoleyun.os.jpush.PushService"-->
|
||||
<!-- android:process=":pushcore">-->
|
||||
<!-- <intent-filter>-->
|
||||
<!-- <action android:name="cn.jiguang.user.service.action" />-->
|
||||
<!-- </intent-filter>-->
|
||||
<!-- </service>-->
|
||||
|
||||
<!-- Required . Enable it you can get statistics data with channel -->
|
||||
<!-- <meta-data-->
|
||||
<!-- android:name="JPUSH_CHANNEL"-->
|
||||
<!-- android:value="${JPUSH_CHANNEL}" />-->
|
||||
<!-- <meta-data-->
|
||||
<!-- android:name="JPUSH_APPKEY"-->
|
||||
<!-- android:value="${JPUSH_APPKEY}" /> -->
|
||||
<!-- <!– </>值来自开发者平台取得的AppKey–>-->
|
||||
|
||||
<!-- 应用的其它配置 -->
|
||||
<uses-library
|
||||
android:name="org.apache.http.legacy"
|
||||
@@ -464,7 +310,7 @@
|
||||
|
||||
<!-- 【可选】APP实现的Receiver,用于接收消息透传和操作结果的回调,请根据需要添加 -->
|
||||
<!-- YOUR_PACKAGE_PATH.CustomPushReceiver需要改为自己的Receiver: -->
|
||||
<receiver android:name="com.aoleyun.os.tpush.MessageReceiver">
|
||||
<receiver android:name="com.aoleyun.os.push.tpush.MessageReceiver">
|
||||
<intent-filter>
|
||||
<!-- 接收消息透传 -->
|
||||
<action android:name="com.tencent.android.xg.vip.action.PUSH_MESSAGE" />
|
||||
@@ -487,6 +333,35 @@
|
||||
|
||||
<!-- MQTT END-->
|
||||
|
||||
<!-- 消息接收监听器 (用户可自主扩展) -->
|
||||
<receiver
|
||||
android:name=".push.alipush.AliyunMessageReceiver"
|
||||
android:exported="false">
|
||||
<intent-filter>
|
||||
<action android:name="com.alibaba.push2.action.NOTIFICATION_OPENED" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="com.alibaba.push2.action.NOTIFICATION_REMOVED" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="com.alibaba.sdk.android.push.RECEIVE" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<service
|
||||
android:name=".push.alipush.AliMessageIntentService"
|
||||
android:exported="false">
|
||||
<intent-filter>
|
||||
<action android:name="com.alibaba.push2.action.NOTIFICATION_OPENED" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="com.alibaba.push2.action.NOTIFICATION_REMOVED" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="com.alibaba.sdk.android.push.RECEIVE" />
|
||||
</intent-filter>
|
||||
</service>
|
||||
|
||||
<!-- 【必须】 请修改为 APP 的 AccessId,“15”开头的10位数字,中间没空格 -->
|
||||
<meta-data
|
||||
android:name="XG_V2_ACCESS_ID"
|
||||
@@ -496,6 +371,13 @@
|
||||
android:name="XG_V2_ACCESS_KEY"
|
||||
android:value="AH5QD9ZMBJ6R" />
|
||||
|
||||
|
||||
<!-- 请填写你自己的- appKey -->
|
||||
<meta-data
|
||||
android:name="com.alibaba.app.appkey"
|
||||
android:value="333598281" />
|
||||
<!-- 请填写你自己的appSecret -->
|
||||
<meta-data
|
||||
android:name="com.alibaba.app.appsecret"
|
||||
android:value="4a3f7e105d894a239ed089f18607bc5a" />
|
||||
</application>
|
||||
</manifest>
|
||||
|
||||
48
build.gradle
48
build.gradle
@@ -2,10 +2,10 @@ buildscript {
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
maven { url 'http://developer.huawei.com/repo/' }
|
||||
maven { url "https://jitpack.io" }
|
||||
maven { url 'http://developer.huawei.com/repo/' }
|
||||
maven { url 'http://maven.aliyun.com/nexus/content/repositories/jcenter' }
|
||||
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
|
||||
maven { url 'http://maven.aliyun.com/nexus/content/repositories/releases/' }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@@ -67,11 +67,12 @@ android {
|
||||
targetSdkVersion 28
|
||||
|
||||
//// //MTK
|
||||
// versionCode 43
|
||||
// versionName "2.3.3"
|
||||
// versionCode 48
|
||||
// versionName "2.3.8"
|
||||
|
||||
//cube
|
||||
versionCode 73
|
||||
versionName "6.3.3"
|
||||
versionCode 80
|
||||
versionName "6.4.0"
|
||||
|
||||
ndk {
|
||||
//选择要添加的对应 cpu 类型的 .so 库。
|
||||
@@ -116,6 +117,14 @@ android {
|
||||
v1SigningEnabled true
|
||||
v2SigningEnabled true
|
||||
}
|
||||
|
||||
TeclastP20S {
|
||||
storeFile file("src/doc/MTKP20S.keystore")
|
||||
storePassword "123456"
|
||||
keyAlias "MTKP20S"
|
||||
keyPassword "123456"
|
||||
v2SigningEnabled false
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
@@ -142,6 +151,20 @@ android {
|
||||
signingConfig signingConfigs.zhanRuiUserdebug
|
||||
}
|
||||
|
||||
TeclastP20SDebug.initWith(debug)
|
||||
TeclastP20SDebug {
|
||||
debuggable true
|
||||
versionNameSuffix "-debug"
|
||||
buildConfigField "String", "platform", '"P20S"'
|
||||
signingConfig signingConfigs.TeclastP20S
|
||||
}
|
||||
|
||||
TeclastP20SRelease.initWith(release)
|
||||
TeclastP20SRelease {
|
||||
buildConfigField "String", "platform", '"P20S"'
|
||||
signingConfig signingConfigs.TeclastP20S
|
||||
}
|
||||
|
||||
debug {
|
||||
buildConfigField "String", "platform", '"MTK"'
|
||||
debuggable true
|
||||
@@ -295,13 +318,17 @@ android {
|
||||
repositories {
|
||||
maven { url "../../../prebuilts/fullsdk-darwin/extras/android/m2repository" }
|
||||
maven { url "../../../prebuilts/fullsdk-linux/extras/android/m2repository" }
|
||||
mavenCentral()
|
||||
google()
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
maven { url "https://jitpack.io" }
|
||||
maven { url 'http://developer.huawei.com/repo/' }
|
||||
maven { url 'http://maven.aliyun.com/nexus/content/repositories/jcenter' }
|
||||
maven { url 'http://maven.aliyun.com/nexus/content/repositories/releases/' }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly files('libs/framework.jar')
|
||||
implementation files('libs/vendor.mediatek.hardware.nvram-V1.0-java.jar')
|
||||
|
||||
implementation "androidx.dynamicanimation:dynamicanimation:${ANDROID_X_VERSION}"
|
||||
implementation "androidx.recyclerview:recyclerview:${ANDROID_X_VERSION}"
|
||||
@@ -344,9 +371,8 @@ dependencies {
|
||||
implementation 'com.tencent:mmkv-static:1.2.13'
|
||||
//腾讯移动推送 TPNS
|
||||
implementation 'com.tencent.tpns:tpns:1.3.2.0-release'
|
||||
//极光推送
|
||||
// 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 'com.aliyun.ams:alicloud-android-push:3.8.0'
|
||||
//下载
|
||||
implementation 'me.laoyuyu.aria:core:3.8.16'
|
||||
annotationProcessor 'me.laoyuyu.aria:compiler:3.8.16'
|
||||
|
||||
@@ -13,29 +13,14 @@ android {
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
zhanRuiDebug {
|
||||
minifyEnabled false
|
||||
}
|
||||
|
||||
zhanRuiRelease {
|
||||
minifyEnabled false
|
||||
}
|
||||
|
||||
alldocubeDebug {
|
||||
minifyEnabled false
|
||||
}
|
||||
|
||||
alldocubeDebugReleas {
|
||||
minifyEnabled false
|
||||
}
|
||||
|
||||
debug {
|
||||
minifyEnabled false
|
||||
}
|
||||
|
||||
release {
|
||||
minifyEnabled false
|
||||
}
|
||||
zhanRuiDebug {}
|
||||
zhanRuiRelease {}
|
||||
alldocubeDebug {}
|
||||
alldocubeDebugReleas {}
|
||||
TeclastP20SDebug {}
|
||||
TeclastP20SRelease {}
|
||||
debug {}
|
||||
release {}
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
|
||||
BIN
libs/vendor.mediatek.hardware.nvram-V1.0-java.jar
Normal file
BIN
libs/vendor.mediatek.hardware.nvram-V1.0-java.jar
Normal file
Binary file not shown.
@@ -71,6 +71,9 @@ import android.widget.Toast;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.alibaba.sdk.android.push.CloudPushService;
|
||||
import com.alibaba.sdk.android.push.CommonCallback;
|
||||
import com.alibaba.sdk.android.push.noonesdk.PushServiceFactory;
|
||||
import com.aoleyun.os.DropTarget.DragObject;
|
||||
import com.aoleyun.os.uiuiutils.APKUtils;
|
||||
import com.aoleyun.os.uiuiutils.Utils;
|
||||
@@ -92,8 +95,6 @@ import com.aoleyun.os.folder.FolderIcon;
|
||||
import com.aoleyun.os.folder.FolderIconPreviewVerifier;
|
||||
import com.aoleyun.os.graphics.RotationMode;
|
||||
import com.aoleyun.os.icons.IconCache;
|
||||
import com.aoleyun.os.jpush.ExampleUtil;
|
||||
import com.aoleyun.os.jpush.LocalBroadcastManager;
|
||||
import com.aoleyun.os.keyboard.CustomActionsPopup;
|
||||
import com.aoleyun.os.keyboard.ViewGroupFocusHelper;
|
||||
import com.aoleyun.os.logging.FileLog;
|
||||
@@ -363,6 +364,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||
.build());
|
||||
}
|
||||
TraceHelper.beginSection("Launcher-onCreate");
|
||||
Log.e(TAG, "onCreate: " + Utils.getSerial(Launcher.this));
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
TraceHelper.partitionSection("Launcher-onCreate", "super call");
|
||||
@@ -428,7 +430,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||
|
||||
if (!isDefaultHome()) {
|
||||
// setDefaultL();
|
||||
setRoleHolderAsUser(this, BuildConfig.APPLICATION_ID);
|
||||
// setRoleHolderAsUser(this, BuildConfig.APPLICATION_ID);
|
||||
}
|
||||
SharedPreferences sharedPref = getPreferences(MODE_PRIVATE);
|
||||
int i = sharedPref.getInt("SetWallPaper", 0);
|
||||
@@ -476,13 +478,6 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||
}
|
||||
}
|
||||
});
|
||||
registerMessageReceiver(); // used for receive msg
|
||||
// JPushInterface.init(this);
|
||||
// String rid = JPushInterface.getRegistrationID(this);
|
||||
// if (!TextUtils.isEmpty(rid)) {
|
||||
// Log.e("setJpushAlias", "RegId:" + rid);
|
||||
// }
|
||||
// JPushInterface.getAlias(this, new Random().nextInt(100));
|
||||
JGYUtils.getInstance().wakeUpAppstore();
|
||||
JGYUtils.getInstance().wakeUpDeviceInfo();
|
||||
XGPushConfig.enableDebug(this, true);
|
||||
@@ -504,41 +499,49 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||
Log.e("TPush", "注册失败,错误码:" + errCode + ",错误信息:" + msg);
|
||||
}
|
||||
});
|
||||
PushServiceFactory.init(this);
|
||||
final CloudPushService pushService = PushServiceFactory.getCloudPushService();
|
||||
pushService.setLogLevel(CloudPushService.LOG_DEBUG);
|
||||
pushService.register(this, new CommonCallback() {
|
||||
@Override
|
||||
public void onSuccess(String response) {
|
||||
Log.e("AliyunPush", "init cloudchannel success");
|
||||
Log.e("AliyunPush", "init cloudchannel success " + pushService.getDeviceId());
|
||||
String sn = Utils.getSerial(Launcher.this);
|
||||
if (TextUtils.isEmpty(sn)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//for receive customer msg from jpush server
|
||||
private MessageReceiver mMessageReceiver;
|
||||
public static final String MESSAGE_RECEIVED_ACTION = "com.example.jpushdemo.MESSAGE_RECEIVED_ACTION";
|
||||
public static final String KEY_TITLE = "title";
|
||||
public static final String KEY_MESSAGE = "message";
|
||||
public static final String KEY_EXTRAS = "extras";
|
||||
|
||||
public void registerMessageReceiver() {
|
||||
mMessageReceiver = new MessageReceiver();
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
|
||||
filter.addAction(MESSAGE_RECEIVED_ACTION);
|
||||
LocalBroadcastManager.getInstance(this).registerReceiver(mMessageReceiver, filter);
|
||||
pushService.bindAccount(sn, new CommonCallback() {
|
||||
@Override
|
||||
public void onSuccess(String s) {
|
||||
Log.e("AliyunPush", "bind account " + sn + " success\n");
|
||||
}
|
||||
|
||||
public class MessageReceiver extends BroadcastReceiver {
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
try {
|
||||
if (MESSAGE_RECEIVED_ACTION.equals(intent.getAction())) {
|
||||
String messge = intent.getStringExtra(KEY_MESSAGE);
|
||||
String extras = intent.getStringExtra(KEY_EXTRAS);
|
||||
StringBuilder showMsg = new StringBuilder();
|
||||
showMsg.append(KEY_MESSAGE + " : " + messge + "\n");
|
||||
if (!ExampleUtil.isEmpty(extras)) {
|
||||
showMsg.append(KEY_EXTRAS + " : " + extras + "\n");
|
||||
public void onFailed(String errorCode, String errorMsg) {
|
||||
Log.e("AliyunPush", "bind account " + sn + " failed." +
|
||||
"errorCode: " + errorCode + ", errorMsg:" + errorMsg);
|
||||
}
|
||||
});
|
||||
pushService.addAlias(sn, new CommonCallback() {
|
||||
@Override
|
||||
public void onSuccess(String s) {
|
||||
Log.e("AliyunPush", "add alias " + sn + " success\n");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
@Override
|
||||
public void onFailed(String errorCode, String errorMsg) {
|
||||
Log.e("AliyunPush", "add alias " + sn + " failed." +
|
||||
"errorCode: " + errorCode + ", errorMsg:" + errorMsg + "\n");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailed(String errorCode, String errorMessage) {
|
||||
Log.e("AliyunPush", "init cloudchannel failed -- errorcode:" + errorCode + " -- errorMessage:" + errorMessage);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void SetWallPaper() {
|
||||
@@ -1180,7 +1183,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||
long closeTime = TimeUtils.getInstance().getEndTime() / 1000;
|
||||
NetInterfaceManager.getInstance()
|
||||
.getAppUsageRecordControl()
|
||||
.sendAppUsageRecord(Utils.getSerial(), packageName, app_name, openTime, closeTime)
|
||||
.sendAppUsageRecord(Utils.getSerial(Launcher.this), packageName, app_name, openTime, closeTime)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@@ -1983,7 +1986,6 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||
if (mLauncherCallbacks != null) {
|
||||
mLauncherCallbacks.onDestroy();
|
||||
}
|
||||
LocalBroadcastManager.getInstance(this).unregisterReceiver(mMessageReceiver);
|
||||
}
|
||||
|
||||
public LauncherAccessibilityDelegate getAccessibilityDelegate() {
|
||||
|
||||
@@ -1,337 +1,32 @@
|
||||
package com.aoleyun.os.base;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import com.aoleyun.os.manager.ConnectManager;
|
||||
import com.aoleyun.os.uiuiutils.ToastUtil;
|
||||
import com.aoleyun.os.uiuiutils.Utils;
|
||||
import com.aoleyun.os.network.NetInterfaceManager;
|
||||
import com.aoleyun.os.network.UrlAddress;
|
||||
import com.aoleyun.os.push.PushManager;
|
||||
import com.aoleyun.os.uiuiutils.JGYUtils;
|
||||
import com.aoleyun.os.uiuiutils.TimeUtils;
|
||||
import com.aoleyun.os.uiuiutils.ToastUtil;
|
||||
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 org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.ObservableEmitter;
|
||||
import io.reactivex.ObservableOnSubscribe;
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import okhttp3.Call;
|
||||
import okhttp3.Callback;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
|
||||
public class BaseApplication extends Application {
|
||||
private static final String TAG = BaseApplication.class.getSimpleName();
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
private static BaseApplication app;
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
private static Context context;
|
||||
|
||||
public static BaseApplication getInstance() {
|
||||
return app;
|
||||
}
|
||||
|
||||
public static Context getContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
app = this;
|
||||
context = this;
|
||||
String rootDir = MMKV.initialize(this);
|
||||
Log.e(TAG, "onCreate: " + rootDir);
|
||||
|
||||
PushManager.init(this);
|
||||
JGYUtils.init(this);
|
||||
TimeUtils.init(this);
|
||||
Aria.init(this);
|
||||
NetInterfaceManager.init(this);
|
||||
ToastUtil.init(this);
|
||||
ConnectManager.init(this);
|
||||
|
||||
initPush();
|
||||
}
|
||||
|
||||
private void initPush() {
|
||||
|
||||
}
|
||||
|
||||
private void initAliasObservable() {
|
||||
Log.e(TAG, "initAliasObservable: ");
|
||||
Observable.create(new ObservableOnSubscribe<Integer>() {
|
||||
@Override
|
||||
public void subscribe(ObservableEmitter<Integer> emitter) throws Exception {
|
||||
onAliasResult = new OnAliasResult() {
|
||||
@Override
|
||||
public void onResult(int code) {
|
||||
Log.e("initAliasObservable", "onResult: " + code);
|
||||
emitter.onNext(code);
|
||||
}
|
||||
};
|
||||
}
|
||||
}).throttleLast(1, TimeUnit.HOURS)
|
||||
.subscribe(new Observer<Integer>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(Integer integer) {
|
||||
Log.e("initAliasObservable", "onNext: " + integer);
|
||||
String s = "alias:\t";
|
||||
switch (integer) {
|
||||
case 0:
|
||||
Log.e("jiguangInterface", s + "Alias绑定成功");
|
||||
break;
|
||||
case 6001:
|
||||
Log.e("jiguangInterface", s + "无效的设置");
|
||||
break;
|
||||
case 6011:
|
||||
Log.e("jiguangInterface", s + "短时间内操作过于频繁");
|
||||
break;
|
||||
case 6013:
|
||||
Log.e("jiguangInterface", s + "用户设备时间轴异常");
|
||||
ToastUtil.show("用户设备时间轴异常,修改后重新登陆\t" + s + "code:6013");
|
||||
break;
|
||||
case 6022:
|
||||
Log.e("jiguangInterface", s + "alias 操作正在进行中");
|
||||
break;
|
||||
//需要重新设置
|
||||
case 6002:
|
||||
Log.e("jiguangInterface", s + "设置超时,请重试");
|
||||
setJpushAlias();
|
||||
break;
|
||||
case 6014:
|
||||
Log.e("jiguangInterface", s + "服务器繁忙,建议重试");
|
||||
setJpushAlias();
|
||||
break;
|
||||
case 6020:
|
||||
Log.e("jiguangInterface", s + "建议过一段时间再设置");
|
||||
setJpushAlias();
|
||||
break;
|
||||
case 6024:
|
||||
Log.e("jiguangInterface", s + "服务器内部错误");
|
||||
setJpushAlias();
|
||||
break;
|
||||
case 6017:
|
||||
case 6027:
|
||||
Log.e("jiguangInterface", s + "别名绑定的设备数超过限制");
|
||||
cleanJpushAlias();
|
||||
setJpushAlias();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// public void onAliasOperatorResult(JPushMessage jPushMessage) {
|
||||
// if (jPushMessage == null) {
|
||||
// return;
|
||||
// }
|
||||
// int errorCode = jPushMessage.getErrorCode();
|
||||
// onAliasResult.onResult(errorCode);
|
||||
// }
|
||||
|
||||
public static void setJpushAlias() {
|
||||
Log.e("jiguangInterface", "30s后重新设置alias");
|
||||
// JPushInterface.setAlias(context, TagAliasOperatorHelper.sequence++, Utils.getSerial());
|
||||
}
|
||||
|
||||
private void initTagObservable() {
|
||||
Log.e(TAG, "initTagObservable: ");
|
||||
Observable.create(new ObservableOnSubscribe<Integer>() {
|
||||
@Override
|
||||
public void subscribe(ObservableEmitter<Integer> emitter) {
|
||||
onTagResult = new OnTagResult() {
|
||||
@Override
|
||||
public void onResult(int code) {
|
||||
Log.e("initTagObservable", "onResult: " + code);
|
||||
emitter.onNext(code);
|
||||
}
|
||||
};
|
||||
}
|
||||
}).throttleLast(1, TimeUnit.HOURS)
|
||||
.subscribe(new Observer<Integer>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(Integer integer) {
|
||||
Log.e("initTagObservable", "onNext: " + integer);
|
||||
String s = "tags:\t";
|
||||
switch (integer) {
|
||||
case 0:
|
||||
Log.e("jiguangInterface", s + "Tag绑定成功");
|
||||
break;
|
||||
case 6001:
|
||||
Log.e("jiguangInterface", s + "无效的设置");
|
||||
break;
|
||||
case 6005:
|
||||
Log.e("jiguangInterface", s + "某一个 tag 字符串不合法");
|
||||
ToastUtil.show("设备标签不合法,联系管理员修改\t" + "code:6005");
|
||||
break;
|
||||
case 6006:
|
||||
Log.e("jiguangInterface", s + "某一个 tag 超长");
|
||||
ToastUtil.show("设备标签过长,联系管理员修改\t" + "code:6006");
|
||||
break;
|
||||
case 6007:
|
||||
Log.e("jiguangInterface", s + "tags 数量超出限制");
|
||||
ToastUtil.show("设备标签数量超出限制,联系管理员修改\t" + "code:6007");
|
||||
break;
|
||||
case 6008:
|
||||
Log.e("jiguangInterface", s + "tag 超出总长度限制");
|
||||
ToastUtil.show("设备标签超出总长度限制,联系管理员修改\t" + "code:6008");
|
||||
break;
|
||||
case 6011:
|
||||
Log.e("jiguangInterface", s + "短时间内操作过于频繁");
|
||||
break;
|
||||
case 6013:
|
||||
Log.e("jiguangInterface", s + "用户设备时间轴异常");
|
||||
ToastUtil.show("用户设备时间轴异常,修改后重新登陆\t" + "code:6013");
|
||||
break;
|
||||
case 6018:
|
||||
Log.e("jiguangInterface", s + "Tags 过多");
|
||||
cleanJpushTag();
|
||||
ToastUtil.show("设备标签数量超出限制,联系管理员修改\t" + "code:6018");
|
||||
break;
|
||||
case 6021:
|
||||
Log.e("jiguangInterface", s + "tags 操作正在进行中");
|
||||
break;
|
||||
//需要重新设置
|
||||
case 6002:
|
||||
Log.e("jiguangInterface", s + "设置超时,请重试");
|
||||
setJpushTags();
|
||||
break;
|
||||
case 6014:
|
||||
Log.e("jiguangInterface", s + "服务器繁忙,建议重试");
|
||||
setJpushTags();
|
||||
break;
|
||||
case 6020:
|
||||
Log.e("jiguangInterface", s + "建议过一段时间再设置");
|
||||
setJpushTags();
|
||||
break;
|
||||
case 6024:
|
||||
Log.e("jiguangInterface", s + "服务器内部错误");
|
||||
setJpushTags();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// public void onTagOperatorResult(JPushMessage jPushMessage) {
|
||||
// if (jPushMessage == null) {
|
||||
// return;
|
||||
// }
|
||||
// int errorCode = jPushMessage.getErrorCode();
|
||||
// onTagResult.onResult(errorCode);
|
||||
// }
|
||||
|
||||
public static void setJpushTags() {
|
||||
Log.e("jiguangInterface", "30s后重新设置tags");
|
||||
// HTTPInterface.setJpushTags(context);
|
||||
}
|
||||
|
||||
private static OnAliasResult onAliasResult;
|
||||
|
||||
interface OnAliasResult {
|
||||
void onResult(int code);
|
||||
}
|
||||
|
||||
private static OnTagResult onTagResult;
|
||||
|
||||
interface OnTagResult {
|
||||
void onResult(int code);
|
||||
}
|
||||
|
||||
private String key = "MGM3YmE1YTE2MjJkYmE3OGQ1YmQwMGNjOjFjOTJiODVjZjM0ODhiNTJkNDQyNDJlOA==";
|
||||
|
||||
synchronized public void cleanJpushAlias() {
|
||||
//alias的绑定的设备超过10个,但是alias应该是一个设备对应一个,在重置设备后jpush的regid会变动,所以需要清除
|
||||
//https://docs.jiguang.cn/jpush/server/push/rest_api_v3_device/#_5
|
||||
OkHttpClient client = new OkHttpClient();
|
||||
Request request = new Request.Builder()
|
||||
.url(UrlAddress.DELETE_JPUSH_ALIAS + Utils.getSerial())
|
||||
.header("Authorization", key)
|
||||
.delete()
|
||||
.build();
|
||||
Call call = client.newCall(request);
|
||||
call.enqueue(new Callback() {
|
||||
@Override
|
||||
public void onFailure(@NotNull Call call, @NotNull IOException e) {
|
||||
Log.e("cleanJpushAlias", "onFailure: " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
|
||||
Log.e("cleanJpushAlias", "onResponse: " + response.toString());
|
||||
Log.e(TAG, "onResponse: " + "清除Alias成功");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
synchronized public void cleanJpushTag() {
|
||||
OkHttpClient client = new OkHttpClient();
|
||||
Request request = new Request.Builder()
|
||||
.url(UrlAddress.DELETE_JPUSH_TAG + Utils.getSerial())
|
||||
.header("Authorization", key)
|
||||
.delete()
|
||||
.build();
|
||||
Call call = client.newCall(request);
|
||||
call.enqueue(new Callback() {
|
||||
@Override
|
||||
public void onFailure(@NotNull Call call, @NotNull IOException e) {
|
||||
Log.e("cleanJpushTag", "onFailure: " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
|
||||
Log.e("cleanJpushTag", "onResponse: " + response.toString());
|
||||
Log.e(TAG, "onResponse: " + "清除Tag成功");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
6
src/com/aoleyun/os/comm/CommonConfig.java
Normal file
6
src/com/aoleyun/os/comm/CommonConfig.java
Normal file
@@ -0,0 +1,6 @@
|
||||
package com.aoleyun.os.comm;
|
||||
|
||||
public class CommonConfig {
|
||||
public static final String MMKV_ID = "InterProcessKV";
|
||||
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package com.aoleyun.os.jpush;
|
||||
|
||||
import android.app.Application;
|
||||
|
||||
/**
|
||||
* For developer startup JPush SDK
|
||||
*
|
||||
* 一般建议在自定义 Application 类里初始化。也可以在主 Activity 里。
|
||||
*/
|
||||
public class ExampleApplication extends Application {
|
||||
private static final String TAG = "JIGUANG-Example";
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
Logger.d(TAG, "[ExampleApplication] onCreate");
|
||||
super.onCreate();
|
||||
|
||||
// JPushInterface.setDebugMode(true); // 设置开启日志,发布时请关闭日志
|
||||
// JPushInterface.init(this); // 初始化 JPush
|
||||
}
|
||||
}
|
||||
@@ -1,131 +0,0 @@
|
||||
package com.aoleyun.os.jpush;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.os.Bundle;
|
||||
import android.os.Looper;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
||||
public class ExampleUtil {
|
||||
public static final String PREFS_NAME = "JPUSH_EXAMPLE";
|
||||
public static final String PREFS_DAYS = "JPUSH_EXAMPLE_DAYS";
|
||||
public static final String PREFS_START_TIME = "PREFS_START_TIME";
|
||||
public static final String PREFS_END_TIME = "PREFS_END_TIME";
|
||||
public static final String KEY_APP_KEY = "JPUSH_APPKEY";
|
||||
|
||||
public static boolean isEmpty(String s) {
|
||||
if (null == s)
|
||||
return true;
|
||||
if (s.length() == 0)
|
||||
return true;
|
||||
if (s.trim().length() == 0)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* 只能以 “+” 或者 数字开头;后面的内容只能包含 “-” 和 数字。
|
||||
* */
|
||||
private final static String MOBILE_NUMBER_CHARS = "^[+0-9][-0-9]{1,}$";
|
||||
public static boolean isValidMobileNumber(String s) {
|
||||
if(TextUtils.isEmpty(s)) return true;
|
||||
Pattern p = Pattern.compile(MOBILE_NUMBER_CHARS);
|
||||
Matcher m = p.matcher(s);
|
||||
return m.matches();
|
||||
}
|
||||
// 校验Tag Alias 只能是数字,英文字母和中文
|
||||
public static boolean isValidTagAndAlias(String s) {
|
||||
Pattern p = Pattern.compile("^[\u4E00-\u9FA50-9a-zA-Z_!@#$&*+=.|]+$");
|
||||
Matcher m = p.matcher(s);
|
||||
return m.matches();
|
||||
}
|
||||
|
||||
// 取得AppKey
|
||||
public static String getAppKey(Context context) {
|
||||
Bundle metaData = null;
|
||||
String appKey = null;
|
||||
try {
|
||||
ApplicationInfo ai = context.getPackageManager().getApplicationInfo(
|
||||
context.getPackageName(), PackageManager.GET_META_DATA);
|
||||
if (null != ai)
|
||||
metaData = ai.metaData;
|
||||
if (null != metaData) {
|
||||
appKey = metaData.getString(KEY_APP_KEY);
|
||||
if ((null == appKey) || appKey.length() != 24) {
|
||||
appKey = null;
|
||||
}
|
||||
}
|
||||
} catch (NameNotFoundException e) {
|
||||
|
||||
}
|
||||
return appKey;
|
||||
}
|
||||
|
||||
// 取得版本号
|
||||
public static String GetVersion(Context context) {
|
||||
try {
|
||||
PackageInfo manager = context.getPackageManager().getPackageInfo(
|
||||
context.getPackageName(), 0);
|
||||
return manager.versionName;
|
||||
} catch (NameNotFoundException e) {
|
||||
return "Unknown";
|
||||
}
|
||||
}
|
||||
|
||||
public static void showToast(final String toast, final Context context)
|
||||
{
|
||||
new Thread(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Looper.prepare();
|
||||
// Toast.makeText(context, toast, Toast.LENGTH_SHORT).show();
|
||||
Looper.loop();
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
public static boolean isConnected(Context context) {
|
||||
ConnectivityManager conn = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
NetworkInfo info = conn.getActiveNetworkInfo();
|
||||
return (info != null && info.isConnected());
|
||||
}
|
||||
|
||||
public static String getImei(Context context, String imei) {
|
||||
String ret = null;
|
||||
try {
|
||||
TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
ret = telephonyManager.getDeviceId();
|
||||
} catch (Exception e) {
|
||||
Logger.e(ExampleUtil.class.getSimpleName(), e.getMessage());
|
||||
}
|
||||
if (isReadableASCII(ret)){
|
||||
return ret;
|
||||
} else {
|
||||
return imei;
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isReadableASCII(CharSequence string){
|
||||
if (TextUtils.isEmpty(string)) return false;
|
||||
try {
|
||||
Pattern p = Pattern.compile("[\\x20-\\x7E]+");
|
||||
return p.matcher(string).matches();
|
||||
} catch (Throwable e){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// public static String getDeviceId(Context context) {
|
||||
// return JPushInterface.getUdid(context);
|
||||
// }
|
||||
}
|
||||
@@ -1,263 +0,0 @@
|
||||
package com.aoleyun.os.jpush;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.net.Uri;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Created by efan on 2017/4/14.
|
||||
*/
|
||||
|
||||
public final class LocalBroadcastManager {
|
||||
private static final String TAG = "JIGUANG-Example";
|
||||
private static final boolean DEBUG = false;
|
||||
private final Context mAppContext;
|
||||
private final HashMap<BroadcastReceiver, ArrayList<IntentFilter>> mReceivers = new HashMap<BroadcastReceiver, ArrayList<IntentFilter>>();
|
||||
private final HashMap<String, ArrayList<ReceiverRecord>> mActions = new HashMap<String, ArrayList<ReceiverRecord>>();
|
||||
private final ArrayList<BroadcastRecord> mPendingBroadcasts = new ArrayList<BroadcastRecord>();
|
||||
static final int MSG_EXEC_PENDING_BROADCASTS = 1;
|
||||
private final Handler mHandler;
|
||||
private static final Object mLock = new Object();
|
||||
private static LocalBroadcastManager mInstance;
|
||||
|
||||
public static LocalBroadcastManager getInstance(Context context) {
|
||||
Object var1 = mLock;
|
||||
synchronized (mLock) {
|
||||
if (mInstance == null) {
|
||||
mInstance = new LocalBroadcastManager(context.getApplicationContext());
|
||||
}
|
||||
|
||||
return mInstance;
|
||||
}
|
||||
}
|
||||
|
||||
private LocalBroadcastManager(Context context) {
|
||||
this.mAppContext = context;
|
||||
this.mHandler = new Handler(context.getMainLooper()) {
|
||||
public void handleMessage(Message msg) {
|
||||
switch (msg.what) {
|
||||
case 1:
|
||||
LocalBroadcastManager.this.executePendingBroadcasts();
|
||||
break;
|
||||
default:
|
||||
super.handleMessage(msg);
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public void registerReceiver(BroadcastReceiver receiver, IntentFilter filter) {
|
||||
HashMap var3 = this.mReceivers;
|
||||
synchronized (this.mReceivers) {
|
||||
ReceiverRecord entry = new ReceiverRecord(filter, receiver);
|
||||
ArrayList filters = (ArrayList) this.mReceivers.get(receiver);
|
||||
if (filters == null) {
|
||||
filters = new ArrayList(1);
|
||||
this.mReceivers.put(receiver, filters);
|
||||
}
|
||||
|
||||
filters.add(filter);
|
||||
|
||||
for (int i = 0; i < filter.countActions(); ++i) {
|
||||
String action = filter.getAction(i);
|
||||
ArrayList entries = (ArrayList) this.mActions.get(action);
|
||||
if (entries == null) {
|
||||
entries = new ArrayList(1);
|
||||
this.mActions.put(action, entries);
|
||||
}
|
||||
|
||||
entries.add(entry);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void unregisterReceiver(BroadcastReceiver receiver) {
|
||||
HashMap var2 = this.mReceivers;
|
||||
synchronized (this.mReceivers) {
|
||||
ArrayList filters = (ArrayList) this.mReceivers.remove(receiver);
|
||||
if (filters != null) {
|
||||
for (int i = 0; i < filters.size(); ++i) {
|
||||
IntentFilter filter = (IntentFilter) filters.get(i);
|
||||
|
||||
for (int j = 0; j < filter.countActions(); ++j) {
|
||||
String action = filter.getAction(j);
|
||||
ArrayList receivers = (ArrayList) this.mActions.get(action);
|
||||
if (receivers != null) {
|
||||
for (int k = 0; k < receivers.size(); ++k) {
|
||||
if (((ReceiverRecord) receivers.get(k)).receiver == receiver) {
|
||||
receivers.remove(k);
|
||||
--k;
|
||||
}
|
||||
}
|
||||
|
||||
if (receivers.size() <= 0) {
|
||||
this.mActions.remove(action);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean sendBroadcast(Intent intent) {
|
||||
HashMap var2 = this.mReceivers;
|
||||
synchronized (this.mReceivers) {
|
||||
String action = intent.getAction();
|
||||
String type = intent.resolveTypeIfNeeded(this.mAppContext.getContentResolver());
|
||||
Uri data = intent.getData();
|
||||
String scheme = intent.getScheme();
|
||||
Set categories = intent.getCategories();
|
||||
boolean debug = (intent.getFlags() & 8) != 0;
|
||||
if (debug) {
|
||||
Logger.v("LocalBroadcastManager", "Resolving type " + type + " scheme " + scheme + " of intent " + intent);
|
||||
}
|
||||
|
||||
ArrayList entries = (ArrayList) this.mActions.get(intent.getAction());
|
||||
if (entries != null) {
|
||||
if (debug) {
|
||||
Logger.v("LocalBroadcastManager", "Action list: " + entries);
|
||||
}
|
||||
|
||||
ArrayList receivers = null;
|
||||
|
||||
int i;
|
||||
for (i = 0; i < entries.size(); ++i) {
|
||||
ReceiverRecord receiver = (ReceiverRecord) entries.get(i);
|
||||
if (debug) {
|
||||
Logger.v("LocalBroadcastManager", "Matching against filter " + receiver.filter);
|
||||
}
|
||||
|
||||
if (receiver.broadcasting) {
|
||||
if (debug) {
|
||||
Logger.v("LocalBroadcastManager", " Filter\'s target already added");
|
||||
}
|
||||
} else {
|
||||
int match = receiver.filter.match(action, type, scheme, data, categories, "LocalBroadcastManager");
|
||||
if (match >= 0) {
|
||||
if (debug) {
|
||||
Logger.v("LocalBroadcastManager", " Filter matched! match=0x" + Integer.toHexString(match));
|
||||
}
|
||||
|
||||
if (receivers == null) {
|
||||
receivers = new ArrayList();
|
||||
}
|
||||
|
||||
receivers.add(receiver);
|
||||
receiver.broadcasting = true;
|
||||
} else if (debug) {
|
||||
String reason;
|
||||
switch (match) {
|
||||
case -4:
|
||||
reason = "category";
|
||||
break;
|
||||
case -3:
|
||||
reason = "action";
|
||||
break;
|
||||
case -2:
|
||||
reason = "data";
|
||||
break;
|
||||
case -1:
|
||||
reason = "type";
|
||||
break;
|
||||
default:
|
||||
reason = "unknown reason";
|
||||
}
|
||||
|
||||
Logger.v("LocalBroadcastManager", " Filter did not match: " + reason);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (receivers != null) {
|
||||
for (i = 0; i < receivers.size(); ++i) {
|
||||
((ReceiverRecord) receivers.get(i)).broadcasting = false;
|
||||
}
|
||||
|
||||
this.mPendingBroadcasts.add(new BroadcastRecord(intent, receivers));
|
||||
if (!this.mHandler.hasMessages(1)) {
|
||||
this.mHandler.sendEmptyMessage(1);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void sendBroadcastSync(Intent intent) {
|
||||
if (this.sendBroadcast(intent)) {
|
||||
this.executePendingBroadcasts();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void executePendingBroadcasts() {
|
||||
while (true) {
|
||||
BroadcastRecord[] brs = null;
|
||||
HashMap i = this.mReceivers;
|
||||
synchronized (this.mReceivers) {
|
||||
int br = this.mPendingBroadcasts.size();
|
||||
if (br <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
brs = new BroadcastRecord[br];
|
||||
this.mPendingBroadcasts.toArray(brs);
|
||||
this.mPendingBroadcasts.clear();
|
||||
}
|
||||
|
||||
for (int var6 = 0; var6 < brs.length; ++var6) {
|
||||
BroadcastRecord var7 = brs[var6];
|
||||
|
||||
for (int j = 0; j < var7.receivers.size(); ++j) {
|
||||
((ReceiverRecord) var7.receivers.get(j)).receiver.onReceive(this.mAppContext, var7.intent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class BroadcastRecord {
|
||||
final Intent intent;
|
||||
final ArrayList<ReceiverRecord> receivers;
|
||||
|
||||
BroadcastRecord(Intent _intent, ArrayList<ReceiverRecord> _receivers) {
|
||||
this.intent = _intent;
|
||||
this.receivers = _receivers;
|
||||
}
|
||||
}
|
||||
|
||||
private static class ReceiverRecord {
|
||||
final IntentFilter filter;
|
||||
final BroadcastReceiver receiver;
|
||||
boolean broadcasting;
|
||||
|
||||
ReceiverRecord(IntentFilter _filter, BroadcastReceiver _receiver) {
|
||||
this.filter = _filter;
|
||||
this.receiver = _receiver;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder(128);
|
||||
builder.append("Receiver{");
|
||||
builder.append(this.receiver);
|
||||
builder.append(" filter=");
|
||||
builder.append(this.filter);
|
||||
builder.append("}");
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
package com.aoleyun.os.jpush;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
/**
|
||||
* Created by efan on 2017/4/13.
|
||||
*/
|
||||
|
||||
public class Logger {
|
||||
|
||||
//设为false关闭日志
|
||||
private static final boolean LOG_ENABLE = true;
|
||||
|
||||
public static void i(String tag, String msg){
|
||||
if (LOG_ENABLE){
|
||||
Log.i(tag, msg);
|
||||
}
|
||||
}
|
||||
public static void v(String tag, String msg){
|
||||
if (LOG_ENABLE){
|
||||
Log.v(tag, msg);
|
||||
}
|
||||
}
|
||||
public static void d(String tag, String msg){
|
||||
if (LOG_ENABLE){
|
||||
Log.d(tag, msg);
|
||||
}
|
||||
}
|
||||
public static void w(String tag, String msg){
|
||||
if (LOG_ENABLE){
|
||||
Log.w(tag, msg);
|
||||
}
|
||||
}
|
||||
public static void e(String tag, String msg){
|
||||
if (LOG_ENABLE){
|
||||
Log.e(tag, msg);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
package com.aoleyun.os.jpush;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.aoleyun.os.base.BaseApplication;
|
||||
|
||||
/**
|
||||
* 自定义JPush message 接收器,包括操作tag/alias的结果返回(仅仅包含tag/alias新接口部分)
|
||||
* */
|
||||
//public class MyJPushMessageReceiver extends JPushMessageReceiver {
|
||||
//
|
||||
// @Override
|
||||
// public void onTagOperatorResult(Context context, JPushMessage jPushMessage) {
|
||||
// TagAliasOperatorHelper.getInstance().onTagOperatorResult(context,jPushMessage);
|
||||
// super.onTagOperatorResult(context, jPushMessage);
|
||||
// BaseApplication.getInstance().onTagOperatorResult(jPushMessage);
|
||||
// }
|
||||
// @Override
|
||||
// public void onCheckTagOperatorResult(Context context, JPushMessage jPushMessage){
|
||||
// TagAliasOperatorHelper.getInstance().onCheckTagOperatorResult(context,jPushMessage);
|
||||
// super.onCheckTagOperatorResult(context, jPushMessage);
|
||||
// }
|
||||
// @Override
|
||||
// public void onAliasOperatorResult(Context context, JPushMessage jPushMessage) {
|
||||
// TagAliasOperatorHelper.getInstance().onAliasOperatorResult(context,jPushMessage);
|
||||
// super.onAliasOperatorResult(context, jPushMessage);
|
||||
// BaseApplication.getInstance().onAliasOperatorResult(jPushMessage);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onMobileNumberOperatorResult(Context context, JPushMessage jPushMessage) {
|
||||
// TagAliasOperatorHelper.getInstance().onMobileNumberOperatorResult(context,jPushMessage);
|
||||
// super.onMobileNumberOperatorResult(context, jPushMessage);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onMessage(Context context, CustomMessage customMessage) {
|
||||
// super.onMessage(context, customMessage);
|
||||
// }
|
||||
//}
|
||||
@@ -1,151 +0,0 @@
|
||||
package com.aoleyun.os.jpush;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.aoleyun.os.network.HTTPInterface;
|
||||
import com.aoleyun.os.service.MainService;
|
||||
import com.aoleyun.os.uiuiutils.ForegroundAppUtil;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* 自定义接收器
|
||||
* <p>
|
||||
* 如果不定义这个 Receiver,则:
|
||||
* 1) 默认用户会打开主界面
|
||||
* 2) 接收不到自定义消息
|
||||
*/
|
||||
//public class MyReceiver extends BroadcastReceiver {
|
||||
// private static final String TAG = "JIGUANG-Example";
|
||||
//
|
||||
// @Override
|
||||
// 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 {
|
||||
//// 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);
|
||||
// }
|
||||
//
|
||||
//}
|
||||
@@ -1,6 +0,0 @@
|
||||
package com.aoleyun.os.jpush;
|
||||
|
||||
|
||||
//public class PushService extends JCommonService {
|
||||
//
|
||||
//}
|
||||
@@ -1,344 +0,0 @@
|
||||
package com.aoleyun.os.jpush;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.util.Log;
|
||||
import android.util.SparseArray;
|
||||
|
||||
import com.aoleyun.os.uiuiutils.ToastUtil;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 处理tagalias相关的逻辑
|
||||
* */
|
||||
//public class TagAliasOperatorHelper {
|
||||
// private static final String TAG = "JIGUANG-TagAliasHelper";
|
||||
// public static int sequence = 1;
|
||||
// /**增加*/
|
||||
// public static final int ACTION_ADD = 1;
|
||||
// /**覆盖*/
|
||||
// public static final int ACTION_SET = 2;
|
||||
// /**删除部分*/
|
||||
// public static final int ACTION_DELETE = 3;
|
||||
// /**删除所有*/
|
||||
// public static final int ACTION_CLEAN = 4;
|
||||
// /**查询*/
|
||||
// public static final int ACTION_GET = 5;
|
||||
//
|
||||
// public static final int ACTION_CHECK = 6;
|
||||
//
|
||||
// public static final int DELAY_SEND_ACTION = 1;
|
||||
//
|
||||
// public static final int DELAY_SET_MOBILE_NUMBER_ACTION = 2;
|
||||
//
|
||||
// private Context context;
|
||||
//
|
||||
// private static TagAliasOperatorHelper mInstance;
|
||||
// private TagAliasOperatorHelper(){
|
||||
// }
|
||||
// public static TagAliasOperatorHelper getInstance(){
|
||||
// if(mInstance == null){
|
||||
// synchronized (TagAliasOperatorHelper.class){
|
||||
// if(mInstance == null){
|
||||
// mInstance = new TagAliasOperatorHelper();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return mInstance;
|
||||
// }
|
||||
// public void init(Context context){
|
||||
// if(context != null) {
|
||||
// this.context = context.getApplicationContext();
|
||||
// }
|
||||
// }
|
||||
// private SparseArray<Object> setActionCache = new SparseArray<Object>();
|
||||
//
|
||||
// public Object get(int sequence){
|
||||
// return setActionCache.get(sequence);
|
||||
// }
|
||||
// public Object remove(int sequence){
|
||||
// return setActionCache.get(sequence);
|
||||
// }
|
||||
// public void put(int sequence, Object tagAliasBean){
|
||||
// setActionCache.put(sequence,tagAliasBean);
|
||||
// }
|
||||
// private Handler delaySendHandler = new Handler(){
|
||||
// @Override
|
||||
// public void handleMessage(Message msg) {
|
||||
// switch (msg.what){
|
||||
// case DELAY_SEND_ACTION:
|
||||
// if(msg.obj !=null && msg.obj instanceof TagAliasBean){
|
||||
// Logger.i(TAG,"on delay time");
|
||||
// sequence++;
|
||||
// TagAliasBean tagAliasBean = (TagAliasBean) msg.obj;
|
||||
// setActionCache.put(sequence, tagAliasBean);
|
||||
// if(context!=null) {
|
||||
// handleAction(context, sequence, tagAliasBean);
|
||||
// }else{
|
||||
// Logger.e(TAG,"#unexcepted - context was null");
|
||||
// }
|
||||
// }else{
|
||||
// Logger.w(TAG,"#unexcepted - msg obj was incorrect");
|
||||
// }
|
||||
// break;
|
||||
// case DELAY_SET_MOBILE_NUMBER_ACTION:
|
||||
// if(msg.obj !=null && msg.obj instanceof String) {
|
||||
// Logger.i(TAG, "retry set mobile number");
|
||||
// sequence++;
|
||||
// String mobileNumber = (String) msg.obj;
|
||||
// setActionCache.put(sequence, mobileNumber);
|
||||
// if(context !=null) {
|
||||
// handleAction(context, sequence, mobileNumber);
|
||||
// }else {
|
||||
// Logger.e(TAG, "#unexcepted - context was null");
|
||||
// }
|
||||
// }else{
|
||||
// Logger.w(TAG,"#unexcepted - msg obj was incorrect");
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// };
|
||||
// public void handleAction(Context context, int sequence, String mobileNumber){
|
||||
// put(sequence,mobileNumber);
|
||||
// Logger.d(TAG,"sequence:"+sequence+",mobileNumber:"+mobileNumber);
|
||||
// JPushInterface.setMobileNumber(context,sequence,mobileNumber);
|
||||
// }
|
||||
// /**
|
||||
// * 处理设置tag
|
||||
// * */
|
||||
// public void handleAction(Context context, int sequence, TagAliasBean tagAliasBean){
|
||||
// init(context);
|
||||
// if(tagAliasBean == null){
|
||||
// Logger.w(TAG,"tagAliasBean was null");
|
||||
// return;
|
||||
// }
|
||||
// put(sequence,tagAliasBean);
|
||||
// if(tagAliasBean.isAliasAction){
|
||||
// switch (tagAliasBean.action){
|
||||
// case ACTION_GET:
|
||||
// JPushInterface.getAlias(context,sequence);
|
||||
// break;
|
||||
// case ACTION_DELETE:
|
||||
// JPushInterface.deleteAlias(context,sequence);
|
||||
// break;
|
||||
// case ACTION_SET:
|
||||
// JPushInterface.setAlias(context,sequence,tagAliasBean.alias);
|
||||
// break;
|
||||
// default:
|
||||
// Logger.w(TAG,"unsupport alias action type");
|
||||
// return;
|
||||
// }
|
||||
// }else {
|
||||
// switch (tagAliasBean.action) {
|
||||
// case ACTION_ADD:
|
||||
// JPushInterface.addTags(context, sequence, tagAliasBean.tags);
|
||||
// break;
|
||||
// case ACTION_SET:
|
||||
// JPushInterface.setTags(context, sequence, tagAliasBean.tags);
|
||||
// break;
|
||||
// case ACTION_DELETE:
|
||||
// JPushInterface.deleteTags(context, sequence, tagAliasBean.tags);
|
||||
// break;
|
||||
// case ACTION_CHECK:
|
||||
// //一次只能check一个tag
|
||||
// String tag = (String)tagAliasBean.tags.toArray()[0];
|
||||
// JPushInterface.checkTagBindState(context,sequence,tag);
|
||||
// break;
|
||||
// case ACTION_GET:
|
||||
// JPushInterface.getAllTags(context, sequence);
|
||||
// break;
|
||||
// case ACTION_CLEAN:
|
||||
// JPushInterface.cleanTags(context, sequence);
|
||||
// break;
|
||||
// default:
|
||||
// Logger.w(TAG,"unsupport tag action type");
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// private boolean RetryActionIfNeeded(int errorCode,TagAliasBean tagAliasBean){
|
||||
// if(!ExampleUtil.isConnected(context)){
|
||||
// Logger.w(TAG,"no network");
|
||||
// return false;
|
||||
// }
|
||||
// //返回的错误码为6002 超时,6014 服务器繁忙,都建议延迟重试
|
||||
// if(errorCode == 6002 || errorCode == 6014){
|
||||
// Logger.d(TAG,"need retry");
|
||||
// if(tagAliasBean!=null){
|
||||
// Message message = new Message();
|
||||
// message.what = DELAY_SEND_ACTION;
|
||||
// message.obj = tagAliasBean;
|
||||
// delaySendHandler.sendMessageDelayed(message,1000*60);
|
||||
// String logs =getRetryStr(tagAliasBean.isAliasAction, tagAliasBean.action,errorCode);
|
||||
// ExampleUtil.showToast(logs, context);
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
// private boolean RetrySetMObileNumberActionIfNeeded(int errorCode, String mobileNumber){
|
||||
// if(!ExampleUtil.isConnected(context)){
|
||||
// Logger.w(TAG,"no network");
|
||||
// return false;
|
||||
// }
|
||||
// //返回的错误码为6002 超时,6024 服务器内部错误,建议稍后重试
|
||||
// if(errorCode == 6002 || errorCode == 6024){
|
||||
// Logger.d(TAG,"need retry");
|
||||
// Message message = new Message();
|
||||
// message.what = DELAY_SET_MOBILE_NUMBER_ACTION;
|
||||
// message.obj = mobileNumber;
|
||||
// delaySendHandler.sendMessageDelayed(message,1000*60);
|
||||
// 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”"));
|
||||
// ExampleUtil.showToast(str, context);
|
||||
// return true;
|
||||
// }
|
||||
// return false;
|
||||
//
|
||||
// }
|
||||
// private String getRetryStr(boolean isAliasAction, int actionType, int errorCode){
|
||||
// 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"));
|
||||
// return str;
|
||||
// }
|
||||
//
|
||||
// private String getActionStr(int actionType){
|
||||
// switch (actionType){
|
||||
// case ACTION_ADD:
|
||||
// return "add";
|
||||
// case ACTION_SET:
|
||||
// return "set";
|
||||
// case ACTION_DELETE:
|
||||
// return "delete";
|
||||
// case ACTION_GET:
|
||||
// return "get";
|
||||
// case ACTION_CLEAN:
|
||||
// return "clean";
|
||||
// case ACTION_CHECK:
|
||||
// return "check";
|
||||
// }
|
||||
// return "unkonw operation";
|
||||
// }
|
||||
//
|
||||
// public void onTagOperatorResult(Context context, JPushMessage jPushMessage) {
|
||||
// int sequence = jPushMessage.getSequence();
|
||||
// Logger.i(TAG,"action - onTagOperatorResult, sequence:"+sequence+",tags:"+jPushMessage.getTags());
|
||||
// Logger.i(TAG,"tags size:"+jPushMessage.getTags().size());
|
||||
// init(context);
|
||||
// //根据sequence从之前操作缓存中获取缓存记录
|
||||
// TagAliasBean tagAliasBean = (TagAliasBean)setActionCache.get(sequence);
|
||||
// if(tagAliasBean == null){
|
||||
// ExampleUtil.showToast("获取缓存记录失败", context);
|
||||
// return;
|
||||
// }
|
||||
// if(jPushMessage.getErrorCode() == 0){
|
||||
// Logger.i(TAG,"action - modify tag Success,sequence:"+sequence);
|
||||
// setActionCache.remove(sequence);
|
||||
// String logs = getActionStr(tagAliasBean.action)+" tags success";
|
||||
// Logger.i(TAG,logs);
|
||||
// Log.e(TAG,"Tag绑定成功: " + jPushMessage.getTags());
|
||||
// ToastUtil.betaShow("Tag绑定成功: " + jPushMessage.getTags());
|
||||
// ExampleUtil.showToast(logs, context);
|
||||
// }else{
|
||||
// String logs = "Failed to " + getActionStr(tagAliasBean.action)+" tags";
|
||||
// if(jPushMessage.getErrorCode() == 6018){
|
||||
// //tag数量超过限制,需要先清除一部分再add
|
||||
// logs += ", tags is exceed limit need to clean";
|
||||
// }
|
||||
// logs += ", errorCode:" + jPushMessage.getErrorCode();
|
||||
// Logger.e(TAG, logs);
|
||||
// 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());
|
||||
// init(context);
|
||||
// //根据sequence从之前操作缓存中获取缓存记录
|
||||
// TagAliasBean tagAliasBean = (TagAliasBean)setActionCache.get(sequence);
|
||||
// if(tagAliasBean == null){
|
||||
// ExampleUtil.showToast("获取缓存记录失败", context);
|
||||
// return;
|
||||
// }
|
||||
// if(jPushMessage.getErrorCode() == 0){
|
||||
// Logger.i(TAG,"tagBean:"+tagAliasBean);
|
||||
// setActionCache.remove(sequence);
|
||||
// String logs = getActionStr(tagAliasBean.action)+" tag "+jPushMessage.getCheckTag() + " bind state success,state:"+jPushMessage.getTagCheckStateResult();
|
||||
// Logger.i(TAG,logs);
|
||||
// ExampleUtil.showToast(logs, context);
|
||||
// }else{
|
||||
// String logs = "Failed to " + getActionStr(tagAliasBean.action)+" tags, errorCode:" + jPushMessage.getErrorCode();
|
||||
// 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);
|
||||
// //根据sequence从之前操作缓存中获取缓存记录
|
||||
// TagAliasBean tagAliasBean = (TagAliasBean)setActionCache.get(sequence);
|
||||
// if(tagAliasBean == null){
|
||||
// ExampleUtil.showToast("获取缓存记录失败", context);
|
||||
// return;
|
||||
// }
|
||||
// if(jPushMessage.getErrorCode() == 0){
|
||||
// Logger.i(TAG,"action - modify alias Success,sequence:"+sequence);
|
||||
// setActionCache.remove(sequence);
|
||||
// String logs = getActionStr(tagAliasBean.action)+" alias success";
|
||||
// Logger.i(TAG,logs);
|
||||
// Log.e(TAG,"Alias绑定成功: "+jPushMessage.getAlias());
|
||||
// ToastUtil.betaShow("Alias绑定成功: "+jPushMessage.getAlias());
|
||||
// ExampleUtil.showToast(logs, context);
|
||||
// }else{
|
||||
// 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);
|
||||
// if(jPushMessage.getErrorCode() == 0){
|
||||
// Logger.i(TAG,"action - set mobile number Success,sequence:"+sequence);
|
||||
// setActionCache.remove(sequence);
|
||||
// }else{
|
||||
// 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;
|
||||
//
|
||||
// @Override
|
||||
// public String toString() {
|
||||
// return "TagAliasBean{" +
|
||||
// "action=" + action +
|
||||
// ", tags=" + tags +
|
||||
// ", alias='" + alias + '\'' +
|
||||
// ", isAliasAction=" + isAliasAction +
|
||||
// '}';
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
@@ -1,30 +0,0 @@
|
||||
package com.aoleyun.os.jpush;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.ViewGroup.LayoutParams;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class TestActivity extends Activity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
TextView tv = new TextView(this);
|
||||
tv.setText("用户自定义打开的Activity");
|
||||
Intent intent = getIntent();
|
||||
if (null != intent) {
|
||||
Bundle bundle = getIntent().getExtras();
|
||||
String title = null;
|
||||
String content = null;
|
||||
if(bundle!=null){
|
||||
// title = bundle.getString(JPushInterface.EXTRA_NOTIFICATION_TITLE);
|
||||
// content = bundle.getString(JPushInterface.EXTRA_ALERT);
|
||||
}
|
||||
tv.setText("Title : " + title + " " + "Content : " + content);
|
||||
}
|
||||
addContentView(tv, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -327,7 +327,9 @@ public class LoaderTask implements Runnable {
|
||||
synchronized (this) {
|
||||
for (LauncherActivityInfo app : apps) {
|
||||
Log.e("verifyApplications", "AllAPP: " + app.getApplicationInfo().packageName);
|
||||
if (BuildConfig.APPLICATION_ID.equals(app.getApplicationInfo().packageName))
|
||||
if (BuildConfig.APPLICATION_ID.equals(app.getApplicationInfo().packageName)
|
||||
|| "com.ygyb.yischool".equals(app.getApplicationInfo().packageName)
|
||||
)
|
||||
continue;
|
||||
/*系统应用*/
|
||||
if (JGYUtils.getInstance().getDeviceIsLocked() && aihuaUnlock != 1) {
|
||||
|
||||
@@ -1,26 +1,20 @@
|
||||
package com.aoleyun.os.network;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.aoleyun.os.network.bean.AppPasswdBean;
|
||||
import com.aoleyun.os.network.bean.BaseResponse;
|
||||
import com.aoleyun.os.uiuiutils.APKUtils;
|
||||
//import com.aoleyun.os.jpush.TagAliasOperatorHelper;
|
||||
import com.aoleyun.os.uiuiutils.JGYUtils;
|
||||
import com.aoleyun.os.uiuiutils.TimeUtils;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.annotations.NonNull;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
/**
|
||||
@@ -66,56 +60,6 @@ public class HTTPInterface {
|
||||
});
|
||||
}
|
||||
|
||||
synchronized public static void setJpushTags(final Context context) {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getJpushTagsObservable()
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e(TAG + ":" + "setJpushTags", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse response) {
|
||||
if (response.code == 200) {
|
||||
JsonObject jsonObject = JsonParser.parseString(new Gson().toJson(response.data)).getAsJsonObject();
|
||||
String batch = jsonObject.get("batch").getAsString();
|
||||
Log.e(TAG + ":" + "setJpushTags", "onNext: " + batch);
|
||||
if (!TextUtils.isEmpty(batch)) {
|
||||
Set set = new HashSet();
|
||||
set.add(batch);
|
||||
JGYUtils.getInstance().getAppPlatform(new JGYUtils.GetAppPlatformCallback() {
|
||||
@Override
|
||||
public void AppPlatform(int platform) {
|
||||
if (platform == JGYUtils.MTKPlatform) {
|
||||
set.add(JGYUtils.MTKTag);
|
||||
} else if (platform == JGYUtils.ZhanruiPlatform) {
|
||||
set.add(JGYUtils.ZhanruiTag);
|
||||
}
|
||||
}
|
||||
});
|
||||
// setTag(context, set);
|
||||
} else {
|
||||
Log.e(TAG + ":" + "setJpushTags", "onNext: " + "batch empty");
|
||||
}
|
||||
} else {
|
||||
Log.e(TAG + ":" + "setJpushTags", "onNext: " + response.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e(TAG + ":" + "setJpushTags", "onError: " + e.getMessage());
|
||||
onComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e(TAG + ":" + "setJpushTags", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送正在运行的app信息
|
||||
*
|
||||
|
||||
@@ -5,6 +5,9 @@ import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.alibaba.sdk.android.push.CloudPushService;
|
||||
import com.alibaba.sdk.android.push.CommonCallback;
|
||||
import com.alibaba.sdk.android.push.noonesdk.PushServiceFactory;
|
||||
import com.aoleyun.os.disklrucache.CacheHelper;
|
||||
import com.aoleyun.os.manager.ConnectManager;
|
||||
import com.aoleyun.os.manager.ConnectMode;
|
||||
@@ -12,7 +15,7 @@ import com.aoleyun.os.network.api.AddAppLog;
|
||||
import com.aoleyun.os.network.api.AppUsageRecordApi;
|
||||
import com.aoleyun.os.network.api.CheckUpdate;
|
||||
import com.aoleyun.os.network.api.GetAppPassword;
|
||||
import com.aoleyun.os.network.api.GetJpushTagsApi;
|
||||
import com.aoleyun.os.network.api.GetPushTagsApi;
|
||||
import com.aoleyun.os.network.api.RunningApp;
|
||||
import com.aoleyun.os.network.api.SendScreenshotApi;
|
||||
import com.aoleyun.os.network.bean.AppPasswdBean;
|
||||
@@ -26,6 +29,8 @@ import com.tencent.android.tpush.XGPushManager;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@@ -110,14 +115,14 @@ public class NetInterfaceManager {
|
||||
|
||||
public Observable<BaseResponse> getRunningAppObservable(String json) {
|
||||
return mRetrofit.create(RunningApp.class)
|
||||
.sendRunningInfo(Utils.getSerial(), json)
|
||||
.sendRunningInfo(Utils.getSerial(mContext), json)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
}
|
||||
|
||||
public Observable<BaseResponse<List<AppPasswdBean>>> getAppPasswordObservable() {
|
||||
return mRetrofit.create(GetAppPassword.class)
|
||||
.getAppPasswd(Utils.getSerial())
|
||||
.getAppPasswd(Utils.getSerial(mContext))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
}
|
||||
@@ -135,9 +140,9 @@ public class NetInterfaceManager {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Observable<BaseResponse<Batch>> getJpushTagsObservable() {
|
||||
return mRetrofit.create(GetJpushTagsApi.class)
|
||||
.getJpushTags(Utils.getSerial())
|
||||
public Observable<BaseResponse<Batch>> getPushTagsObservable() {
|
||||
return mRetrofit.create(GetPushTagsApi.class)
|
||||
.getPushTags(Utils.getSerial(mContext))
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
}
|
||||
@@ -189,7 +194,7 @@ public class NetInterfaceManager {
|
||||
}
|
||||
}
|
||||
});
|
||||
getJpushTagsObservable()
|
||||
getPushTagsObservable()
|
||||
.subscribe(new Observer<BaseResponse<Batch>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
@@ -228,7 +233,7 @@ public class NetInterfaceManager {
|
||||
});
|
||||
}
|
||||
|
||||
synchronized private void clearAndAppendTags(Set tagSets) {
|
||||
synchronized private void clearAndAppendTags(Set<String> tagSets) {
|
||||
XGPushManager.clearAndAppendTags(mContext, "clearAndAppendTags :" + System.currentTimeMillis(), tagSets, new XGIOperateCallback() {
|
||||
@Override
|
||||
public void onSuccess(Object o, int i) {
|
||||
@@ -240,5 +245,19 @@ public class NetInterfaceManager {
|
||||
Log.e("clearAndAppendTags", "onFail: " + o);
|
||||
}
|
||||
});
|
||||
String[] tag = new ArrayList<>(tagSets).toArray(new String[tagSets.size()]);
|
||||
CloudPushService pushService = PushServiceFactory.getCloudPushService();
|
||||
pushService.bindTag(CloudPushService.DEVICE_TARGET, tag, null, new CommonCallback() {
|
||||
@Override
|
||||
public void onSuccess(String s) {
|
||||
Log.e("bindTag", "bind tag " + Arrays.toString(tag) + " success\n");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailed(String errorCode, String errorMsg) {
|
||||
Log.e("bindTag", "bind tag " + Arrays.toString(tag) + " failed." +
|
||||
"errorCode: " + errorCode + ", errorMsg:" + errorMsg + "\n");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -19,9 +19,4 @@ public class UrlAddress {
|
||||
public static final String SEND_APP_RECORD = "And/appUsageRecord";
|
||||
//上传截图
|
||||
public static final String SEND_SCREENSHOT = "Screenshot/addImg";
|
||||
|
||||
//删除alias
|
||||
public static final String DELETE_JPUSH_ALIAS = "https://device.jpush.cn/v3/aliases/";
|
||||
//删除tags
|
||||
public static final String DELETE_JPUSH_TAG = "https://device.jpush.cn/v3/tags/";
|
||||
}
|
||||
|
||||
@@ -9,9 +9,9 @@ import io.reactivex.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface GetJpushTagsApi {
|
||||
public interface GetPushTagsApi {
|
||||
@GET(UrlAddress.GET_DEVICES_TAGS)
|
||||
Observable<BaseResponse<Batch>> getJpushTags(
|
||||
Observable<BaseResponse<Batch>> getPushTags(
|
||||
@Query("sn") String sn
|
||||
);
|
||||
}
|
||||
51
src/com/aoleyun/os/push/PushManager.java
Normal file
51
src/com/aoleyun/os/push/PushManager.java
Normal file
@@ -0,0 +1,51 @@
|
||||
package com.aoleyun.os.push;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
|
||||
import com.aoleyun.os.comm.CommonConfig;
|
||||
import com.aoleyun.os.disklrucache.CacheHelper;
|
||||
import com.aoleyun.os.network.HTTPInterface;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
|
||||
public class PushManager {
|
||||
private static final String TAG = PushManager.class.getSimpleName();
|
||||
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
private static PushManager sInstance;
|
||||
private Context mContext;
|
||||
|
||||
private PushManager(Context context) {
|
||||
if (context == null) {
|
||||
throw new RuntimeException("Context is NULL");
|
||||
}
|
||||
this.mContext = context;
|
||||
}
|
||||
|
||||
public static void init(Context context) {
|
||||
if (sInstance == null) {
|
||||
sInstance = new PushManager(context);
|
||||
}
|
||||
}
|
||||
|
||||
public static PushManager getInstance() {
|
||||
if (sInstance == null) {
|
||||
throw new IllegalStateException("You must be init PushManager first");
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
/*删除应用*/
|
||||
private final String UPDATEPASSWD = "39";
|
||||
|
||||
public void setPushContent(String title, String extras) {
|
||||
switch (title) {
|
||||
case UPDATEPASSWD:
|
||||
HTTPInterface.getAppPasswd();
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
}
|
||||
99
src/com/aoleyun/os/push/alipush/AliMessageIntentService.java
Normal file
99
src/com/aoleyun/os/push/alipush/AliMessageIntentService.java
Normal file
@@ -0,0 +1,99 @@
|
||||
package com.aoleyun.os.push.alipush;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import com.alibaba.sdk.android.push.AliyunMessageIntentService;
|
||||
import com.alibaba.sdk.android.push.notification.CPushMessage;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by liyazhou on 17/8/22.
|
||||
* 为避免推送广播被系统拦截的小概率事件,我们推荐用户通过IntentService处理消息互调,接入步骤:
|
||||
* 1. 创建IntentService并继承AliyunMessageIntentService
|
||||
* 2. 覆写相关方法,并在Manifest的注册该Service
|
||||
* 3. 调用接口CloudPushService.setPushIntentService
|
||||
* 详细用户可参考:https://help.aliyun.com/document_detail/30066.html#h2-2-messagereceiver-aliyunmessageintentservice
|
||||
*/
|
||||
|
||||
public class AliMessageIntentService extends AliyunMessageIntentService {
|
||||
private static final String TAG = AliyunMessageIntentService.class.getSimpleName();
|
||||
|
||||
/**
|
||||
* 推送通知的回调方法
|
||||
*
|
||||
* @param context
|
||||
* @param title
|
||||
* @param summary
|
||||
* @param extraMap
|
||||
*/
|
||||
@Override
|
||||
protected void onNotification(Context context, String title, String summary, Map<String, String> extraMap) {
|
||||
Log.i(TAG, "收到一条推送通知 : " + title + ", summary:" + summary);
|
||||
}
|
||||
|
||||
/**
|
||||
* 推送消息的回调方法
|
||||
*
|
||||
* @param context
|
||||
* @param cPushMessage
|
||||
*/
|
||||
@Override
|
||||
protected void onMessage(Context context, CPushMessage cPushMessage) {
|
||||
Log.i(TAG, "收到一条推送消息 : " + cPushMessage.getTitle() + ", content:" + cPushMessage.getContent());
|
||||
}
|
||||
|
||||
/**
|
||||
* 从通知栏打开通知的扩展处理
|
||||
*
|
||||
* @param context
|
||||
* @param title
|
||||
* @param summary
|
||||
* @param extraMap
|
||||
*/
|
||||
@Override
|
||||
protected void onNotificationOpened(Context context, String title, String summary, String extraMap) {
|
||||
Log.i(TAG, "onNotificationOpened : " + " : " + title + " : " + summary + " : " + extraMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* 无动作通知点击回调。当在后台或阿里云控制台指定的通知动作为无逻辑跳转时,通知点击回调为onNotificationClickedWithNoAction而不是onNotificationOpened
|
||||
*
|
||||
* @param context
|
||||
* @param title
|
||||
* @param summary
|
||||
* @param extraMap
|
||||
*/
|
||||
@Override
|
||||
protected void onNotificationClickedWithNoAction(Context context, String title, String summary, String extraMap) {
|
||||
Log.i(TAG, "onNotificationClickedWithNoAction : " + " : " + title + " : " + summary + " : " + extraMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通知删除回调
|
||||
*
|
||||
* @param context
|
||||
* @param messageId
|
||||
*/
|
||||
@Override
|
||||
protected void onNotificationRemoved(Context context, String messageId) {
|
||||
Log.i(TAG, "onNotificationRemoved : " + messageId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 应用处于前台时通知到达回调。注意:该方法仅对自定义样式通知有效,相关详情请参考https://help.aliyun.com/document_detail/30066.html#h3-3-4-basiccustompushnotification-api
|
||||
*
|
||||
* @param context
|
||||
* @param title
|
||||
* @param summary
|
||||
* @param extraMap
|
||||
* @param openType
|
||||
* @param openActivity
|
||||
* @param openUrl
|
||||
*/
|
||||
@Override
|
||||
protected void onNotificationReceivedInApp(Context context, String title, String summary, Map<String, String> extraMap, int openType, String openActivity, String openUrl) {
|
||||
Log.i(TAG, "onNotificationReceivedInApp : " + " : " + title + " : " + summary + " " + extraMap + " : " + openType + " : " + openActivity + " : " + openUrl);
|
||||
}
|
||||
}
|
||||
116
src/com/aoleyun/os/push/alipush/AliyunMessageReceiver.java
Normal file
116
src/com/aoleyun/os/push/alipush/AliyunMessageReceiver.java
Normal file
@@ -0,0 +1,116 @@
|
||||
package com.aoleyun.os.push.alipush;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import com.alibaba.sdk.android.push.MessageReceiver;
|
||||
import com.alibaba.sdk.android.push.notification.CPushMessage;
|
||||
import com.aoleyun.os.push.PushManager;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author: 正纬
|
||||
* @since: 15/4/9
|
||||
* @version: 1.1
|
||||
* @feature: 用于接收推送的通知和消息
|
||||
*/
|
||||
public class AliyunMessageReceiver extends MessageReceiver {
|
||||
// 消息接收部分的LOG_TAG
|
||||
public static final String TAG = AliyunMessageReceiver.class.getSimpleName();
|
||||
|
||||
/**
|
||||
* 推送通知的回调方法
|
||||
*
|
||||
* @param context
|
||||
* @param title
|
||||
* @param summary
|
||||
* @param extraMap
|
||||
*/
|
||||
@Override
|
||||
public void onNotification(Context context, String title, String summary, Map<String, String> extraMap) {
|
||||
// TODO 处理推送通知
|
||||
if (null != extraMap) {
|
||||
for (Map.Entry<String, String> entry : extraMap.entrySet()) {
|
||||
Log.i(TAG, "@Get diy param : Key=" + entry.getKey() + " , Value=" + entry.getValue());
|
||||
}
|
||||
} else {
|
||||
Log.i(TAG, "@收到通知 && 自定义消息为空");
|
||||
}
|
||||
Log.i(TAG, "收到一条推送通知 : " + title + ", summary:" + summary);
|
||||
}
|
||||
|
||||
/**
|
||||
* 应用处于前台时通知到达回调。注意:该方法仅对自定义样式通知有效,相关详情请参考https://help.aliyun.com/document_detail/30066.html?spm=5176.product30047.6.620.wjcC87#h3-3-4-basiccustompushnotification-api
|
||||
*
|
||||
* @param context
|
||||
* @param title
|
||||
* @param summary
|
||||
* @param extraMap
|
||||
* @param openType
|
||||
* @param openActivity
|
||||
* @param openUrl
|
||||
*/
|
||||
@Override
|
||||
protected void onNotificationReceivedInApp(Context context, String title, String summary, Map<String, String> extraMap, int openType, String openActivity, String openUrl) {
|
||||
Log.i(TAG, "onNotificationReceivedInApp : " + " : " + title + " : " + summary + " " + extraMap + " : " + openType + " : " + openActivity + " : " + openUrl);
|
||||
}
|
||||
|
||||
/**
|
||||
* 推送消息的回调方法
|
||||
*
|
||||
* @param context
|
||||
* @param cPushMessage
|
||||
*/
|
||||
@Override
|
||||
public void onMessage(Context context, CPushMessage cPushMessage) {
|
||||
Log.e(TAG, "收到一条推送消息 : " + cPushMessage.getTitle() + ", content:" + cPushMessage.getContent());
|
||||
String title = cPushMessage.getTitle();
|
||||
String content = cPushMessage.getContent();
|
||||
JsonObject extrasJson = JsonParser.parseString(content).getAsJsonObject();
|
||||
String extras = "";
|
||||
if (extrasJson.get("extras") != null) {
|
||||
extras = extrasJson.get("extras").toString();
|
||||
}
|
||||
PushManager.getInstance().setPushContent(title, extras);
|
||||
}
|
||||
|
||||
/**
|
||||
* 从通知栏打开通知的扩展处理
|
||||
*
|
||||
* @param context
|
||||
* @param title
|
||||
* @param summary
|
||||
* @param extraMap
|
||||
*/
|
||||
@Override
|
||||
public void onNotificationOpened(Context context, String title, String summary, String extraMap) {
|
||||
Log.i(TAG, "onNotificationOpened : " + " : " + title + " : " + summary + " : " + extraMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通知删除回调
|
||||
*
|
||||
* @param context
|
||||
* @param messageId
|
||||
*/
|
||||
@Override
|
||||
public void onNotificationRemoved(Context context, String messageId) {
|
||||
Log.i(TAG, "onNotificationRemoved : " + messageId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 无动作通知点击回调。当在后台或阿里云控制台指定的通知动作为无逻辑跳转时,通知点击回调为onNotificationClickedWithNoAction而不是onNotificationOpened
|
||||
*
|
||||
* @param context
|
||||
* @param title
|
||||
* @param summary
|
||||
* @param extraMap
|
||||
*/
|
||||
@Override
|
||||
protected void onNotificationClickedWithNoAction(Context context, String title, String summary, String extraMap) {
|
||||
Log.i(TAG, "onNotificationClickedWithNoAction : " + " : " + title + " : " + summary + " : " + extraMap);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.aoleyun.os.tpush;
|
||||
package com.aoleyun.os.push.tpush;
|
||||
|
||||
/**
|
||||
* Created by chacewang on 2019/7/5.
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.aoleyun.os.tpush;
|
||||
package com.aoleyun.os.push.tpush;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
@@ -9,8 +9,9 @@ import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.aoleyun.os.network.HTTPInterface;
|
||||
import com.aoleyun.os.tpush.common.NotificationService;
|
||||
import com.aoleyun.os.tpush.po.XGNotification;
|
||||
import com.aoleyun.os.push.PushManager;
|
||||
import com.aoleyun.os.push.tpush.common.NotificationService;
|
||||
import com.aoleyun.os.push.tpush.po.XGNotification;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.tencent.android.tpush.NotificationAction;
|
||||
@@ -24,20 +25,12 @@ import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
|
||||
public class MessageReceiver extends XGPushBaseReceiver {
|
||||
private static final String TAG = MessageReceiver.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 UPDATEPASSWD = "39";
|
||||
|
||||
|
||||
private Context mContext;
|
||||
private ContentResolver mResolver;
|
||||
private PackageManager mPackageManager;
|
||||
|
||||
/**
|
||||
* 消息透传处理
|
||||
*
|
||||
@@ -46,9 +39,6 @@ public class MessageReceiver extends XGPushBaseReceiver {
|
||||
*/
|
||||
@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();
|
||||
@@ -290,10 +280,6 @@ public class MessageReceiver extends XGPushBaseReceiver {
|
||||
// Toast.makeText(context, text, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
private int changeNum(int paramInt) {
|
||||
return paramInt == 0 ? 1 : 0;
|
||||
}
|
||||
|
||||
private void processCustomMessage(Context context, XGPushTextMessage message) {
|
||||
if (context == null || message == null) {
|
||||
return;
|
||||
@@ -307,14 +293,7 @@ public class MessageReceiver extends XGPushBaseReceiver {
|
||||
if (extrasJson.get("extras") != null) {
|
||||
extras = extrasJson.get("extras").toString();
|
||||
}
|
||||
|
||||
switch (title) {
|
||||
case UPDATEPASSWD:
|
||||
HTTPInterface.getAppPasswd();
|
||||
break;
|
||||
default:
|
||||
}
|
||||
PushManager.getInstance().setPushContent(title, extras);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.aoleyun.os.tpush.common;
|
||||
package com.aoleyun.os.push.tpush.common;
|
||||
|
||||
import android.content.Context;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.aoleyun.os.tpush.common;
|
||||
package com.aoleyun.os.push.tpush.common;
|
||||
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
@@ -6,7 +6,7 @@ import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
|
||||
|
||||
import com.aoleyun.os.tpush.po.XGNotification;
|
||||
import com.aoleyun.os.push.tpush.po.XGNotification;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.aoleyun.os.tpush.po;
|
||||
package com.aoleyun.os.push.tpush.po;
|
||||
|
||||
public class XGNotification {
|
||||
private Integer id;
|
||||
@@ -183,7 +183,7 @@ public class MainService extends Service {
|
||||
//设置一个file文件
|
||||
MultipartBody.Part body = MultipartBody.Part.createFormData("file", file.getName(), fileBody);
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("sn", Utils.getSerial());
|
||||
params.put("sn", Utils.getSerial(MainService.this));
|
||||
params.put("createtime", String.valueOf(time));
|
||||
NetInterfaceManager.getInstance().getScreenshotApi()
|
||||
.sendScreenshot(params, body)
|
||||
|
||||
@@ -255,20 +255,6 @@ public class ItemClickHandler {
|
||||
"com.jiaoguanyi.store"
|
||||
};
|
||||
|
||||
public static AppInformation getInfoFromPackageName(String packageName) {
|
||||
List<AppInformation> list;
|
||||
AppInformation app = null;
|
||||
StatisticsInfo statisticsInfo = new StatisticsInfo(BaseApplication.getInstance().getApplicationContext());
|
||||
list = statisticsInfo.getShowList();
|
||||
for (AppInformation appInformation : list) {
|
||||
String name = appInformation.getPackageName();
|
||||
if (appInformation.getPackageName().equals(packageName)) {
|
||||
return appInformation;
|
||||
}
|
||||
}
|
||||
return app;
|
||||
}
|
||||
|
||||
/**
|
||||
* Event handler for a folder icon click.
|
||||
*
|
||||
|
||||
@@ -29,18 +29,18 @@ public class JGYUtils {
|
||||
private ContentResolver mResolver;
|
||||
|
||||
|
||||
public static int UnknowPlatform = 0;
|
||||
public static int MTKPlatform = 1;
|
||||
public static final int UnknowPlatform = 0;
|
||||
public static final int MTKPlatform = 1;
|
||||
// TODO: 2022/4/23 标签替换未完成
|
||||
public static int CubePlatform = 2;
|
||||
public static int ZhanruiPlatform = 3;
|
||||
public static final int CubePlatform = 2;
|
||||
public static final int ZhanruiPlatform = 3;
|
||||
|
||||
|
||||
public static String Other = "其他";
|
||||
public static String MTKTag = "MTK";
|
||||
public static final String Other = "其他";
|
||||
public static final String MTKTag = "MTK";
|
||||
// TODO: 2022/4/23 标签替换未完成
|
||||
public static String CubeTag = "展锐cube";
|
||||
public static String ZhanruiTag = "展锐";
|
||||
public static final String CubeTag = "展锐cube";
|
||||
public static final String ZhanruiTag = "展锐";
|
||||
|
||||
|
||||
private JGYUtils(Context context) {
|
||||
|
||||
@@ -7,30 +7,214 @@ import android.app.ActivityTaskManager;
|
||||
import android.app.IActivityTaskManager;
|
||||
import android.content.Context;
|
||||
import android.content.pm.UserInfo;
|
||||
import android.net.wifi.WifiInfo;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.os.Build;
|
||||
import android.os.RemoteException;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.aoleyun.os.BuildConfig;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.NetworkInterface;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import vendor.mediatek.hardware.nvram.V1_0.INvram;
|
||||
|
||||
import static android.app.ActivityManager.RECENT_IGNORE_UNAVAILABLE;
|
||||
|
||||
public class Utils {
|
||||
public static String getAndroid10MAC(Context context) {
|
||||
// if (Build.VERSION.SDK_INT > Build.VERSION_CODES.N_MR1) {
|
||||
// return getMacAddress(context);
|
||||
// } else {
|
||||
// return getAndroid7MAC();
|
||||
// }
|
||||
return getAllMacAddress(context);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取MAC地址
|
||||
*
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
public static String getAllMacAddress(Context context) {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
|
||||
return getMacDefault(context);
|
||||
} else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
|
||||
return getMacAddressM();
|
||||
} else {
|
||||
return getMacFromHardware();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Android 6.0 之前(不包括6.0)
|
||||
*
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
private static String getMacDefault(Context context) {
|
||||
String mac = "未获取到设备Mac地址";
|
||||
if (context == null) {
|
||||
return mac;
|
||||
}
|
||||
WifiManager wifi = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
|
||||
WifiInfo info = null;
|
||||
try {
|
||||
info = wifi.getConnectionInfo();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (info == null) {
|
||||
return mac;
|
||||
}
|
||||
mac = info.getMacAddress();
|
||||
if (!TextUtils.isEmpty(mac)) {
|
||||
mac = mac.toUpperCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
return mac;
|
||||
}
|
||||
|
||||
/**
|
||||
* Android 6.0(包括) - Android 7.0(不包括)
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private static String getMacAddressM() {
|
||||
String mac = "未获取到设备Mac地址";
|
||||
|
||||
try {
|
||||
mac = new BufferedReader(new FileReader("/sys/class/net/wlan0/address")).readLine();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return mac;
|
||||
}
|
||||
|
||||
/**
|
||||
* 遍历循环所有的网络接口,找到接口是 wlan0
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private static String getMacFromHardware() {
|
||||
try {
|
||||
List<NetworkInterface> all = Collections.list(NetworkInterface.getNetworkInterfaces());
|
||||
|
||||
for (NetworkInterface nif : all) {
|
||||
if (!nif.getName().equalsIgnoreCase("wlan0")) {
|
||||
continue;
|
||||
}
|
||||
byte[] macBytes = nif.getHardwareAddress();
|
||||
StringBuilder res1 = new StringBuilder();
|
||||
for (byte b : macBytes) {
|
||||
res1.append(String.format("%02X:", b));
|
||||
}
|
||||
if (res1 != null) {
|
||||
res1.deleteCharAt(res1.length() - 1);
|
||||
}
|
||||
return res1.toString();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return "未获取到设备Mac地址";
|
||||
}
|
||||
|
||||
private static String TAG = Utils.class.getSimpleName();
|
||||
|
||||
public static final String NOSN = "012345679ABCDEF";
|
||||
public static final String TECLAST_BRAND = "Teclast";
|
||||
|
||||
/**
|
||||
* 获取设备序列号
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@SuppressLint({"MissingPermission", "NewApi"})
|
||||
public static String getSerial() {
|
||||
public static String getSerial(Context context) {
|
||||
if (TECLAST_BRAND.equalsIgnoreCase(Build.BRAND)) {
|
||||
return getPushMac(context);
|
||||
} else {
|
||||
if (NOSN.equalsIgnoreCase(getSn())) {
|
||||
return getIMEI(context);
|
||||
} else {
|
||||
return getSn();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static String getPushMac(Context context) {
|
||||
String macaddr = Utils.getMacAddrFromNvram();
|
||||
return macaddr.replace(":", "").toUpperCase();
|
||||
}
|
||||
|
||||
//mh add start----
|
||||
private static final int MAC_ADDRESS_ID = 30;
|
||||
private static final int MAC_ADDRESS_OFFSET = 4;
|
||||
private static final int MAC_ADDRESS_DIGITS = 6;
|
||||
private static final int MAX_ADDRESS_VALUE = 0xff;
|
||||
private static final int INVALID_RSSI = -200;
|
||||
|
||||
private static final String MAC_ADDRESS_FILENAME = "/mnt/vendor/nvdata/APCFG/APRDEB/WIFI";
|
||||
|
||||
private static String getMacAddrFromNvram() {
|
||||
StringBuffer nvramBuf = new StringBuffer();
|
||||
try {
|
||||
int i = 0;
|
||||
String buff = null;
|
||||
INvram agent = INvram.getService();
|
||||
if (agent == null) {
|
||||
// mToast.setText("No support MAC address writing due to NVRAM");
|
||||
// mToast.show();
|
||||
Log.e("mh_mac", "NvRAMAgent is null");
|
||||
return "";
|
||||
}
|
||||
try {
|
||||
buff = agent.readFileByName(
|
||||
MAC_ADDRESS_FILENAME, MAC_ADDRESS_OFFSET + MAC_ADDRESS_DIGITS);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return "";
|
||||
}
|
||||
Log.i("mh_mac", "Raw data:" + buff);
|
||||
if (buff.length() < 2 * (MAC_ADDRESS_OFFSET + MAC_ADDRESS_DIGITS)) {
|
||||
// mToast.setText("The foramt of NVRAM is not correct");
|
||||
// mToast.show();
|
||||
return "";
|
||||
}
|
||||
// Remove the \0 special character.
|
||||
int macLen = buff.length() - 1;
|
||||
for (i = MAC_ADDRESS_OFFSET * 2; i < macLen; i += 2) {
|
||||
if ((i + 2) < macLen) {
|
||||
nvramBuf.append(buff.substring(i, i + 2));
|
||||
nvramBuf.append(":");
|
||||
} else {
|
||||
nvramBuf.append(buff.substring(i));
|
||||
}
|
||||
}
|
||||
Log.d("mh_mac", "buff:" + nvramBuf.toString());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return "";
|
||||
}
|
||||
return nvramBuf.toString();
|
||||
}
|
||||
//mh add end------
|
||||
|
||||
@SuppressLint({"MissingPermission", "HardwareIds"})
|
||||
public static String getSn() {
|
||||
String serial = "unknow";
|
||||
try {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {//9.0+
|
||||
@@ -44,11 +228,39 @@ public class Utils {
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.e("e", "读取设备序列号异常:" + e.toString());
|
||||
Log.e("getSerial", "读取设备序列号异常:" + e.toString());
|
||||
}
|
||||
return serial;
|
||||
}
|
||||
|
||||
@SuppressLint("HardwareIds")
|
||||
public static String getIMEI(Context context) {
|
||||
String IMEI = "unknow";
|
||||
//获取手机设备号
|
||||
TelephonyManager TelephonyMgr = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
//8.0及以后版本获取
|
||||
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
IMEI = TelephonyMgr.getDeviceId();
|
||||
// } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
// try {
|
||||
// Method method = TelephonyMgr.getClass().getMethod("getImei");
|
||||
// IMEI = (String) method.invoke(TelephonyMgr);
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// Log.e("getIMEI", e.getMessage());
|
||||
// }
|
||||
// IMEI = TelephonyMgr.getDeviceId();
|
||||
|
||||
// } else {//9.0到10.0获取
|
||||
// IMEI = Settings.System.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
|
||||
}
|
||||
Log.e("IMEI:", "IMEI: " + IMEI);
|
||||
if (null == IMEI) {
|
||||
return "-";
|
||||
} else {
|
||||
return IMEI.toUpperCase();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除所有最近记录
|
||||
|
||||
BIN
src/doc/MTKP20S.keystore
Normal file
BIN
src/doc/MTKP20S.keystore
Normal file
Binary file not shown.
Reference in New Issue
Block a user