Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
ShenghuoquanBusiness
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bp
ShenghuoquanBusiness
Commits
1b40fe53
Commit
1b40fe53
authored
Jul 28, 2021
by
chengkun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add push policy and mipush sdk
parent
9bf2c4da
Changes
15
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
398 additions
and
3 deletions
+398
-3
build.gradle
Components/BPush/build.gradle
+1
-1
MiPush_SDK_Client_4_2_0.jar
Components/BPush/libs/MiPush_SDK_Client_4_2_0.jar
+0
-0
AndroidManifest.xml
Components/BPush/src/main/AndroidManifest.xml
+57
-0
BPushApplication.kt
...ava/com/yidian/shenghuoquan/bpush/app/BPushApplication.kt
+5
-0
BrandConstant.kt
...a/com/yidian/shenghuoquan/bpush/constant/BrandConstant.kt
+9
-0
PushPolicy.kt
...ain/java/com/yidian/shenghuoquan/bpush/push/PushPolicy.kt
+6
-0
PushSdkManager.kt
...java/com/yidian/shenghuoquan/bpush/push/PushSdkManager.kt
+16
-0
HuaWdeiPushPolicy.kt
...n/shenghuoquan/bpush/push/huaweipush/HuaWdeiPushPolicy.kt
+13
-0
MiPushPolicy.kt
...com/yidian/shenghuoquan/bpush/push/mipush/MiPushPolicy.kt
+38
-0
MiPushReceiver.kt
...shenghuoquan/bpush/push/mipush/receiver/MiPushReceiver.kt
+127
-0
OppoPushPolicy.kt
...yidian/shenghuoquan/bpush/push/oppopush/OppoPushPolicy.kt
+13
-0
UmengPushPolicy.kt
...dian/shenghuoquan/bpush/push/umengpush/UmengPushPolicy.kt
+13
-0
ViVoPushPolicy.kt
...yidian/shenghuoquan/bpush/push/vivopush/ViVoPushPolicy.kt
+13
-0
PushService.kt
...java/com/yidian/shenghuoquan/bpush/service/PushService.kt
+35
-2
SystemUtil.kt
...in/java/com/yidian/shenghuoquan/bpush/utils/SystemUtil.kt
+52
-0
No files found.
Components/BPush/build.gradle
View file @
1b40fe53
...
@@ -55,7 +55,7 @@ android {
...
@@ -55,7 +55,7 @@ android {
}
}
dependencies
{
dependencies
{
implementation
fileTree
(
dir:
'libs'
,
include:
[
'*.jar'
,
'*.aar'
])
api
fileTree
(
dir:
'libs'
,
include:
[
'*.jar'
,
'*.aar'
])
implementation
"org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation
"org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
rootProject
.
ext
.
dependencies
.
other
.
each
{
rootProject
.
ext
.
dependencies
.
other
.
each
{
implementation
project
(
it
)
implementation
project
(
it
)
...
...
Components/BPush/libs/MiPush_SDK_Client_4_2_0.jar
0 → 100644
View file @
1b40fe53
File added
Components/BPush/src/main/AndroidManifest.xml
View file @
1b40fe53
...
@@ -2,4 +2,61 @@
...
@@ -2,4 +2,61 @@
<manifest
xmlns:android=
"http://schemas.android.com/apk/res/android"
<manifest
xmlns:android=
"http://schemas.android.com/apk/res/android"
package=
"com.yidian.shenghuoquan.bpush"
>
package=
"com.yidian.shenghuoquan.bpush"
>
<uses-permission
android:name=
"android.permission.INTERNET"
/>
<uses-permission
android:name=
"android.permission.ACCESS_NETWORK_STATE"
/>
<uses-permission
android:name=
"android.permission.ACCESS_WIFI_STATE"
/>
<uses-permission
android:name=
"android.permission.READ_PHONE_STATE"
/>
<uses-permission
android:name=
"android.permission.VIBRATE"
/>
<permission
android:name=
"com.shenghuoquan.business.permission.MIPUSH_RECEIVE"
android:protectionLevel=
"signature"
/>
<uses-permission
android:name=
"com.shenghuoquan.business.permission.MIPUSH_RECEIVE"
/>
<application>
<receiver
android:name=
".push.mipush.receiver.MiPushReceiver"
android:enabled=
"true"
android:exported=
"true"
>
</receiver>
<service
android:name=
"com.xiaomi.push.service.XMPushService"
android:enabled=
"true"
android:process=
":pushservice"
/>
<!-- 注:此service必须在3.0.1版本以后(包括3.0.1版本)加入 -->
<service
android:name=
"com.xiaomi.push.service.XMJobService"
android:enabled=
"true"
android:exported=
"false"
android:permission=
"android.permission.BIND_JOB_SERVICE"
android:process=
":pushservice"
/>
<service
android:name=
"com.xiaomi.mipush.sdk.PushMessageHandler"
android:enabled=
"true"
android:exported=
"true"
/>
<!-- 注:此service必须在2.2.5版本以后(包括2.2.5版本)加入 -->
<service
android:name=
"com.xiaomi.mipush.sdk.MessageHandleService"
android:enabled=
"true"
/>
<receiver
android:name=
"com.xiaomi.push.service.receivers.NetworkStatusReceiver"
android:exported=
"true"
>
<intent-filter>
<action
android:name=
"android.net.conn.CONNECTIVITY_CHANGE"
/>
<category
android:name=
"android.intent.category.DEFAULT"
/>
</intent-filter>
</receiver>
<receiver
android:name=
"com.xiaomi.push.service.receivers.PingReceiver"
android:exported=
"false"
android:process=
":pushservice"
>
<intent-filter>
<action
android:name=
"com.xiaomi.push.PING_TIMER"
/>
</intent-filter>
</receiver>
</application>
</manifest>
</manifest>
\ No newline at end of file
Components/BPush/src/main/java/com/yidian/shenghuoquan/bpush/app/BPushApplication.kt
View file @
1b40fe53
package
com.yidian.shenghuoquan.bpush.app
package
com.yidian.shenghuoquan.bpush.app
import
android.content.Context
import
com.yidian.bcommon.app.YdBaseApplication
import
com.yidian.bcommon.app.YdBaseApplication
import
com.yidian.bcommon.services.ZapServiceNameConstants
import
com.yidian.bcommon.services.ZapServiceNameConstants
import
com.yidian.news.util.ProcessUtil
import
com.yidian.news.util.ProcessUtil
...
@@ -10,8 +11,12 @@ import timber.log.Timber
...
@@ -10,8 +11,12 @@ import timber.log.Timber
@YacModuleSpec
@YacModuleSpec
class
BPushApplication
:
YdBaseApplication
()
{
class
BPushApplication
:
YdBaseApplication
()
{
companion
object
{
lateinit
var
context
:
Context
}
override
fun
onCreate
()
{
override
fun
onCreate
()
{
super
.
onCreate
()
super
.
onCreate
()
context
=
this
;
if
(
ProcessUtil
.
isMainProcess
(
this
))
{
if
(
ProcessUtil
.
isMainProcess
(
this
))
{
registerXpage
()
registerXpage
()
initService
()
initService
()
...
...
Components/BPush/src/main/java/com/yidian/shenghuoquan/bpush/constant/BrandConstant.kt
0 → 100644
View file @
1b40fe53
package
com.yidian.shenghuoquan.bpush.constant
object
BrandConstant
{
const
val
XIAOMI
=
"XIAOMI11"
const
val
HUAWEI
=
"HUAWEI"
const
val
OPPO
=
"OPPO"
const
val
VIVO
=
"VIVO"
const
val
UMENG
=
"UMENG"
}
Components/BPush/src/main/java/com/yidian/shenghuoquan/bpush/push/PushPolicy.kt
0 → 100644
View file @
1b40fe53
package
com.yidian.shenghuoquan.bpush.push
interface
PushPolicy
{
fun
initPushSdk
()
fun
pubMessage
(
message
:
String
)
}
Components/BPush/src/main/java/com/yidian/shenghuoquan/bpush/push/PushSdkManager.kt
0 → 100644
View file @
1b40fe53
package
com.yidian.shenghuoquan.bpush.push
class
PushSdkManager
{
private
val
pushPolicy
:
PushPolicy
constructor
(
pushPolicy
:
PushPolicy
)
{
this
.
pushPolicy
=
pushPolicy
}
public
fun
initSpecealSdk
()
{
pushPolicy
.
initPushSdk
()
}
public
fun
pushMessage
(
message
:
String
)
{
pushPolicy
.
pubMessage
(
message
)
}
}
Components/BPush/src/main/java/com/yidian/shenghuoquan/bpush/push/huaweipush/HuaWdeiPushPolicy.kt
0 → 100644
View file @
1b40fe53
package
com.yidian.shenghuoquan.bpush.push.huaweipush
import
com.yidian.shenghuoquan.bpush.push.PushPolicy
class
HuaWdeiPushPolicy
:
PushPolicy
{
override
fun
initPushSdk
()
{
TODO
(
"Not yet implemented"
)
}
override
fun
pubMessage
(
message
:
String
)
{
TODO
(
"Not yet implemented"
)
}
}
Components/BPush/src/main/java/com/yidian/shenghuoquan/bpush/push/mipush/MiPushPolicy.kt
0 → 100644
View file @
1b40fe53
package
com.yidian.shenghuoquan.bpush.push.mipush
import
android.app.ActivityManager
import
android.content.Context
import
android.os.Process
import
com.xiaomi.mipush.sdk.MiPushClient
import
com.yidian.shenghuoquan.bpush.app.BPushApplication
import
com.yidian.shenghuoquan.bpush.push.PushPolicy
class
MiPushPolicy
:
PushPolicy
{
companion
object
{
const
val
appId
=
""
const
val
appkey
=
""
const
val
packageName
=
""
}
override
fun
initPushSdk
()
{
if
(
shouldInit
())
{
MiPushClient
.
registerPush
(
BPushApplication
.
context
,
appId
,
appkey
)
}
}
override
fun
pubMessage
(
message
:
String
)
{
TODO
(
"Not yet implemented"
)
}
private
fun
shouldInit
():
Boolean
{
val
am
=
BPushApplication
.
context
.
getSystemService
(
Context
.
ACTIVITY_SERVICE
)
as
ActivityManager
val
processInfos
=
am
.
runningAppProcesses
val
mainProcessName
:
String
=
BPushApplication
.
context
.
getPackageName
()
val
myPid
=
Process
.
myPid
()
for
(
info
in
processInfos
)
{
if
(
info
.
pid
==
myPid
&&
mainProcessName
==
info
.
processName
)
{
return
true
}
}
return
false
}
}
Components/BPush/src/main/java/com/yidian/shenghuoquan/bpush/push/mipush/receiver/MiPushReceiver.kt
0 → 100644
View file @
1b40fe53
package
com.yidian.shenghuoquan.bpush.push.mipush.receiver
import
android.annotation.SuppressLint
import
android.content.Context
import
android.os.Message
import
android.text.TextUtils
import
android.util.Log
import
com.xiaomi.mipush.sdk.*
import
timber.log.Timber
import
java.text.SimpleDateFormat
import
java.util.*
class
MiPushReceiver
:
PushMessageReceiver
()
{
private
val
TAG
:
String
?
=
"MiPushReceiver"
private
var
mRegId
:
String
?
=
null
private
var
mTopic
:
String
?
=
null
private
var
mAlias
:
String
?
=
null
private
var
mAccount
:
String
?
=
null
private
var
mStartTime
:
String
?
=
null
private
var
mEndTime
:
String
?
=
null
override
fun
onReceivePassThroughMessage
(
context
:
Context
,
message
:
MiPushMessage
)
{
Timber
.
tag
(
TAG
).
i
(
"onReceivePassThroughMessage is called. $message"
)
if
(!
TextUtils
.
isEmpty
(
message
.
topic
))
{
mTopic
=
message
.
topic
}
else
if
(!
TextUtils
.
isEmpty
(
message
.
alias
))
{
mAlias
=
message
.
alias
}
val
msg
=
Message
.
obtain
()
}
override
fun
onNotificationMessageClicked
(
context
:
Context
,
message
:
MiPushMessage
)
{
Timber
.
tag
(
TAG
).
i
(
"onNotificationMessageClicked is called. $message"
)
if
(!
TextUtils
.
isEmpty
(
message
.
topic
))
{
mTopic
=
message
.
topic
}
else
if
(!
TextUtils
.
isEmpty
(
message
.
alias
))
{
mAlias
=
message
.
alias
}
val
msg
=
Message
.
obtain
()
}
override
fun
onNotificationMessageArrived
(
context
:
Context
,
message
:
MiPushMessage
)
{
Timber
.
tag
(
TAG
).
i
(
"onNotificationMessageArrived is called. $message"
)
if
(!
TextUtils
.
isEmpty
(
message
.
topic
))
{
mTopic
=
message
.
topic
}
else
if
(!
TextUtils
.
isEmpty
(
message
.
alias
))
{
mAlias
=
message
.
alias
}
}
override
fun
onCommandResult
(
context
:
Context
,
message
:
MiPushCommandMessage
)
{
Timber
.
tag
(
TAG
).
i
(
"onCommandResult is called. $message"
)
val
command
=
message
.
command
val
arguments
=
message
.
commandArguments
val
cmdArg1
=
if
(
arguments
!=
null
&&
arguments
.
size
>
0
)
arguments
[
0
]
else
null
val
cmdArg2
=
if
(
arguments
!=
null
&&
arguments
.
size
>
1
)
arguments
[
1
]
else
null
val
log
:
String
if
(
MiPushClient
.
COMMAND_REGISTER
==
command
)
{
if
(
message
.
resultCode
==
ErrorCode
.
SUCCESS
.
toLong
())
{
mRegId
=
cmdArg1
}
else
{
}
}
else
if
(
MiPushClient
.
COMMAND_SET_ALIAS
==
command
)
{
if
(
message
.
resultCode
==
ErrorCode
.
SUCCESS
.
toLong
())
{
mAlias
=
cmdArg1
}
else
{
}
}
else
if
(
MiPushClient
.
COMMAND_UNSET_ALIAS
==
command
)
{
if
(
message
.
resultCode
==
ErrorCode
.
SUCCESS
.
toLong
())
{
mAlias
=
cmdArg1
}
else
{
}
}
else
if
(
MiPushClient
.
COMMAND_SET_ACCOUNT
==
command
)
{
if
(
message
.
resultCode
==
ErrorCode
.
SUCCESS
.
toLong
())
{
mAccount
=
cmdArg1
}
else
{
}
}
else
if
(
MiPushClient
.
COMMAND_UNSET_ACCOUNT
==
command
)
{
if
(
message
.
resultCode
==
ErrorCode
.
SUCCESS
.
toLong
())
{
mAccount
=
cmdArg1
}
else
{
}
}
else
if
(
MiPushClient
.
COMMAND_SUBSCRIBE_TOPIC
==
command
)
{
if
(
message
.
resultCode
==
ErrorCode
.
SUCCESS
.
toLong
())
{
mTopic
=
cmdArg1
}
else
{
}
}
else
if
(
MiPushClient
.
COMMAND_UNSUBSCRIBE_TOPIC
==
command
)
{
if
(
message
.
resultCode
==
ErrorCode
.
SUCCESS
.
toLong
())
{
mTopic
=
cmdArg1
}
else
{
}
}
else
if
(
MiPushClient
.
COMMAND_SET_ACCEPT_TIME
==
command
)
{
if
(
message
.
resultCode
==
ErrorCode
.
SUCCESS
.
toLong
())
{
mStartTime
=
cmdArg1
mEndTime
=
cmdArg2
}
else
{
}
}
else
{
log
=
message
.
reason
}
}
override
fun
onReceiveRegisterResult
(
context
:
Context
,
message
:
MiPushCommandMessage
)
{
Timber
.
tag
(
TAG
).
i
(
"onReceiveRegisterResult is called. $message"
)
val
command
=
message
.
command
val
arguments
=
message
.
commandArguments
val
cmdArg1
=
if
(
arguments
!=
null
&&
arguments
.
size
>
0
)
arguments
[
0
]
else
null
val
log
:
String
if
(
MiPushClient
.
COMMAND_REGISTER
==
command
)
{
if
(
message
.
resultCode
==
ErrorCode
.
SUCCESS
.
toLong
())
{
mRegId
=
cmdArg1
}
else
{
}
}
else
{
log
=
message
.
reason
}
}
@SuppressLint
(
"SimpleDateFormat"
)
private
fun
getSimpleDate
():
String
{
return
SimpleDateFormat
(
"MM-dd hh:mm:ss"
).
format
(
Date
())
}
}
Components/BPush/src/main/java/com/yidian/shenghuoquan/bpush/push/oppopush/OppoPushPolicy.kt
0 → 100644
View file @
1b40fe53
package
com.yidian.shenghuoquan.bpush.push.oppopush
import
com.yidian.shenghuoquan.bpush.push.PushPolicy
class
OppoPushPolicy
:
PushPolicy
{
override
fun
initPushSdk
()
{
TODO
(
"Not yet implemented"
)
}
override
fun
pubMessage
(
message
:
String
)
{
TODO
(
"Not yet implemented"
)
}
}
Components/BPush/src/main/java/com/yidian/shenghuoquan/bpush/push/umengpush/UmengPushPolicy.kt
0 → 100644
View file @
1b40fe53
package
com.yidian.shenghuoquan.bpush.push.umengpush
import
com.yidian.shenghuoquan.bpush.push.PushPolicy
class
UmengPushPolicy
:
PushPolicy
{
override
fun
initPushSdk
()
{
TODO
(
"Not yet implemented"
)
}
override
fun
pubMessage
(
message
:
String
)
{
TODO
(
"Not yet implemented"
)
}
}
Components/BPush/src/main/java/com/yidian/shenghuoquan/bpush/push/vivopush/ViVoPushPolicy.kt
0 → 100644
View file @
1b40fe53
package
com.yidian.shenghuoquan.bpush.push.vivopush
import
com.yidian.shenghuoquan.bpush.push.PushPolicy
class
ViVoPushPolicy
:
PushPolicy
{
override
fun
initPushSdk
()
{
TODO
(
"Not yet implemented"
)
}
override
fun
pubMessage
(
message
:
String
)
{
TODO
(
"Not yet implemented"
)
}
}
Components/BPush/src/main/java/com/yidian/shenghuoquan/bpush/service/PushService.kt
View file @
1b40fe53
package
com.yidian.shenghuoquan.bpush.service
package
com.yidian.shenghuoquan.bpush.service
import
android.util.Log
import
com.yidian.bcommon.services.ZapServiceActionConstants
import
com.yidian.bcommon.services.ZapServiceActionConstants
import
com.yidian.shenghuoquan.bpush.constant.BrandConstant
import
com.yidian.shenghuoquan.bpush.push.*
import
com.yidian.shenghuoquan.bpush.push.huaweipush.HuaWdeiPushPolicy
import
com.yidian.shenghuoquan.bpush.push.mipush.MiPushPolicy
import
com.yidian.shenghuoquan.bpush.push.oppopush.OppoPushPolicy
import
com.yidian.shenghuoquan.bpush.push.umengpush.UmengPushPolicy
import
com.yidian.shenghuoquan.bpush.push.vivopush.ViVoPushPolicy
import
com.yidian.shenghuoquan.bpush.utils.SystemUtil
import
com.yidian.xarc.xrouter.ResultResolver
import
com.yidian.xarc.xrouter.ResultResolver
import
com.yidian.yac.core.zap.ZapService
import
com.yidian.yac.core.zap.ZapService
import
org.json.JSONObject
import
org.json.JSONObject
import
timber.log.Timber
import
timber.log.Timber
class
PushService
:
ZapService
()
{
class
PushService
:
ZapService
()
{
private
val
TAG
=
"PushService"
private
lateinit
var
resolver
:
ResultResolver
private
lateinit
var
resolver
:
ResultResolver
private
lateinit
var
pushSdkManager
:
PushSdkManager
override
fun
onAction
(
path
:
String
,
action
:
String
,
params
:
Any
,
options
:
Any
,
resolver
:
ResultResolver
)
{
override
fun
onAction
(
path
:
String
,
action
:
String
,
params
:
Any
,
options
:
Any
,
resolver
:
ResultResolver
)
{
Log
.
i
(
"PushService"
,
"acit
on is "
+
action
)
Timber
.
tag
(
"PushService"
).
i
(
"acti
on is "
+
action
)
this
.
resolver
=
resolver
this
.
resolver
=
resolver
params
as
JSONObject
params
as
JSONObject
when
(
action
)
{
when
(
action
)
{
ZapServiceActionConstants
.
ActionPushMessage
->
pushMessage
(
params
.
toString
())
ZapServiceActionConstants
.
ActionPushMessage
->
pushMessage
(
params
.
toString
())
ZapServiceActionConstants
.
ActionInitPushService
->
{
when
(
SystemUtil
.
getDeviceBrand
())
{
BrandConstant
.
HUAWEI
->
{
pushSdkManager
=
PushSdkManager
(
HuaWdeiPushPolicy
())
}
BrandConstant
.
OPPO
->
{
pushSdkManager
=
PushSdkManager
(
OppoPushPolicy
())
}
BrandConstant
.
VIVO
->
{
pushSdkManager
=
PushSdkManager
(
ViVoPushPolicy
())
}
BrandConstant
.
XIAOMI
->
{
pushSdkManager
=
PushSdkManager
(
MiPushPolicy
())
}
BrandConstant
.
UMENG
->
{
pushSdkManager
=
PushSdkManager
(
UmengPushPolicy
())
}
else
->
{
pushSdkManager
=
PushSdkManager
(
UmengPushPolicy
())
}
}
pushSdkManager
.
initSpecealSdk
()
}
}
}
}
}
...
@@ -22,6 +54,7 @@ class PushService : ZapService() {
...
@@ -22,6 +54,7 @@ class PushService : ZapService() {
}
}
override
fun
onInit
()
{
override
fun
onInit
()
{
Timber
.
tag
(
TAG
).
i
(
"onInit"
)
}
}
private
fun
pushMessage
(
message
:
String
)
{
private
fun
pushMessage
(
message
:
String
)
{
...
...
Components/BPush/src/main/java/com/yidian/shenghuoquan/bpush/utils/SystemUtil.kt
0 → 100644
View file @
1b40fe53
package
com.yidian.shenghuoquan.bpush.utils
import
android.os.Build
import
java.util.*
/**
* 系统工具类
*/
object
SystemUtil
{
/**
* 获取当前手机系统语言。
*
* @return 返回当前系统语言。例如:当前设置的是“中文-中国”,则返回“zh-CN”
*/
fun
getSystemLanguage
():
String
?
{
return
Locale
.
getDefault
().
getLanguage
()
}
/**
* 获取当前系统上的语言列表(Locale列表)
*
* @return 语言列表
*/
fun
getSystemLanguageList
():
Array
<
Locale
?
>?
{
return
Locale
.
getAvailableLocales
()
}
/**
* 获取当前手机系统版本号
*
* @return 系统版本号
*/
fun
getSystemVersion
():
String
?
{
return
Build
.
VERSION
.
RELEASE
}
/**
* 获取手机型号
*
* @return 手机型号
*/
fun
getSystemModel
():
String
?
{
return
Build
.
MODEL
}
/**
* 获取手机厂商
*
* @return 手机厂商
*/
fun
getDeviceBrand
():
String
{
return
Build
.
BRAND
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment