Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
A
appzxhy
Project
Project
Details
Activity
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhouzhi
appzxhy
Commits
b8b15493
Commit
b8b15493
authored
Dec 27, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...
parent
86177a80
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
196 additions
and
19 deletions
+196
-19
MyApplication.kt
app/src/main/java/com/base/appzxhy/MyApplication.kt
+26
-19
NotificationSendBean.kt
...c/main/java/com/base/appzxhy/bean/NotificationSendBean.kt
+2
-0
InstallHelper.kt
app/src/main/java/com/base/appzxhy/helper/InstallHelper.kt
+71
-0
NewComUtils.kt
app/src/main/java/com/base/appzxhy/helper/NewComUtils.kt
+97
-0
No files found.
app/src/main/java/com/base/appzxhy/MyApplication.kt
View file @
b8b15493
...
...
@@ -14,15 +14,22 @@ import com.base.appzxhy.bean.config.ConfigBean
import
com.base.appzxhy.bean.config.PopupConfigBean
import
com.base.appzxhy.fcm.FCMManager
import
com.base.appzxhy.fcm.TimerManager.Companion.changeTimer
import
com.base.appzxhy.fcm.receiver.BatteryStatusReceiver
import
com.base.appzxhy.fcm.receiver.PackageStatusReceiver
import
com.base.appzxhy.fcm.receiver.ScreenStatusReceiver
import
com.base.appzxhy.helper.EventUtils
import
com.base.appzxhy.helper.InstallHelps
import
com.base.appzxhy.helper.NewComUtils
import
com.base.appzxhy.utils.ActivityManagerUtils
import
com.base.appzxhy.utils.AppPreferences
import
com.base.appzxhy.utils.LogEx
import
com.base.appzxhy.utils.SolarEngineUtils.solarkey
import
com.facebook.FacebookSdk
import
com.google.android.gms.ads.identifier.AdvertisingIdClient
import
com.google.gson.Gson
import
com.hjq.language.MultiLanguages
import
com.hjq.language.OnLanguageListener
import
com.reyun.solar.engine.SolarEngineManager
import
org.json.JSONObject
import
java.util.Locale
import
java.util.UUID
...
...
@@ -112,20 +119,20 @@ class MyApplication : Application() {
FCMManager
.
subscribeToTopic
(
topic
)
initConfig
()
//
// Thread {
// InstallHelps.init {
// initRemoteConfig()
// }
// }.start()
// SolarEngineManager.getInstance().preInit(this, solarkey)
Thread
{
InstallHelps
.
init
{
initRemoteConfig
()
}
}.
start
()
SolarEngineManager
.
getInstance
().
preInit
(
this
,
solarkey
)
initLifeListener
()
// com.base.appzxhy.fcm.receiver.
ScreenStatusReceiver.registerScreenStatusReceiver(this)
// com.base.appzxhy.fcm.receiver.
PackageStatusReceiver.registerPackageStatusReceiver(this)
// com.base.appzxhy.fcm.receiver.
BatteryStatusReceiver.registerBatteryStatusReceiver(this)
ScreenStatusReceiver
.
registerScreenStatusReceiver
(
this
)
PackageStatusReceiver
.
registerPackageStatusReceiver
(
this
)
BatteryStatusReceiver
.
registerBatteryStatusReceiver
(
this
)
// startJob()
// startAlarm(appContext, 24)
...
...
@@ -203,15 +210,15 @@ class MyApplication : Application() {
private
fun
initRemoteConfig
()
{
//
NewComUtils.requestCfg { config ->
//
if (config != null) {
//
AppPreferences.getInstance().put("config", config)
//
}
//
//
LogEx.logDebug("requestCfg", "config=$config")
//
//
initConfig(config)
//
}
NewComUtils
.
requestCfg
{
config
->
if
(
config
!=
null
)
{
AppPreferences
.
getInstance
().
put
(
"config"
,
config
)
}
LogEx
.
logDebug
(
"requestCfg"
,
"config=$config"
)
initConfig
(
config
)
}
}
...
...
app/src/main/java/com/base/appzxhy/bean/NotificationSendBean.kt
View file @
b8b15493
...
...
@@ -11,6 +11,8 @@ class NotificationSendBean(
var
valueMap
:
HashMap
<
String
,
Any
>
=
hashMapOf
()
//发送通知可能携带的参数
)
{
var
notificationId
=
0L
companion
object
{
const
val
POPUP_WHERE_TIMBER
=
"Timer"
...
...
app/src/main/java/com/base/appzxhy/helper/InstallHelper.kt
0 → 100644
View file @
b8b15493
package
com.base.appzxhy.helper
import
com.android.installreferrer.api.InstallReferrerClient
import
com.android.installreferrer.api.InstallReferrerStateListener
import
com.base.appzxhy.BuildConfig
import
com.base.appzxhy.MyApplication
import
com.base.appzxhy.utils.AppPreferences
import
com.base.appzxhy.utils.LogEx
import
org.json.JSONObject
/**
* call before agree
*/
object
InstallHelps
{
private
val
TAG
=
"InstallHelps"
fun
init
(
requestCfg
:
()
->
Unit
)
{
val
referrerClient
=
InstallReferrerClient
.
newBuilder
(
MyApplication
.
appContext
).
build
()
referrerClient
.
startConnection
(
object
:
InstallReferrerStateListener
{
override
fun
onInstallReferrerSetupFinished
(
responseCode
:
Int
)
{
try
{
when
(
responseCode
)
{
InstallReferrerClient
.
InstallReferrerResponse
.
OK
->
{
val
response
=
referrerClient
.
installReferrer
val
installInfo
=
response
.
installReferrer
val
obj
=
JSONObject
()
obj
.
put
(
"referrerUrl"
,
response
.
installReferrer
)
obj
.
put
(
"referrerClickTime"
,
response
.
referrerClickTimestampSeconds
)
obj
.
put
(
"appInstallTime"
,
response
.
installBeginTimestampSeconds
)
obj
.
put
(
"instantExperienceLaunched"
,
installInfo
.
toString
())
EventUtils
.
event
(
"install_referrer"
,
ext
=
obj
)
LogEx
.
logDebug
(
TAG
,
"referrerUrl=${response.installReferrer}"
)
AppPreferences
.
getInstance
().
put
(
"install_referrer"
,
response
.
installReferrer
)
if
(
listOf
(
"gclid"
,
"facebook"
,
"instagram"
).
all
{
!
installInfo
.
contains
(
it
,
true
)
}
)
{
//自然用户
if
(
BuildConfig
.
DEBUG
)
{
AppPreferences
.
getInstance
().
put
(
"install_source"
,
"channel"
)
}
else
{
AppPreferences
.
getInstance
().
put
(
"install_source"
,
"origin"
)
}
}
else
{
//渠道用户
AppPreferences
.
getInstance
().
put
(
"install_source"
,
"channel"
)
}
requestCfg
()
}
else
->
{
EventUtils
.
event
(
"install_referrer_error"
)
requestCfg
()
}
}
}
catch
(
_
:
Exception
)
{
EventUtils
.
event
(
"install_referrer_error"
)
requestCfg
()
}
}
override
fun
onInstallReferrerServiceDisconnected
()
{
}
})
}
}
\ No newline at end of file
app/src/main/java/com/base/appzxhy/helper/NewComUtils.kt
0 → 100644
View file @
b8b15493
package
com.base.appzxhy.helper
import
android.util.Log
import
com.base.appzxhy.BuildConfig
import
com.base.appzxhy.GlobalConfig
import
com.base.appzxhy.utils.AppPreferences
import
com.base.appzxhy.utils.LogEx
import
kotlinx.coroutines.CoroutineScope
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.launch
import
kotlinx.coroutines.withContext
import
java.io.BufferedReader
import
java.io.InputStreamReader
import
java.net.HttpURLConnection
import
java.net.URL
import
java.util.Locale
object
NewComUtils
{
private
val
TAG
=
"NewComUtils"
private
const
val
API_URL
=
GlobalConfig
.
URL_API
private
const
val
PACKAGE_NAME_PREFIX
=
GlobalConfig
.
PACKAGE_NAME
private
const
val
DATA_KEY
=
"data"
private
val
url
:
String
by
lazy
{
val
packageName
=
GlobalConfig
.
PACKAGE_NAME
val
appCode
=
packageName
.
substringAfter
(
PACKAGE_NAME_PREFIX
).
take
(
5
).
toLowerCase
(
Locale
.
getDefault
())
val
bRefer
=
android
.
util
.
Base64
.
encodeToString
(
AppPreferences
.
getInstance
().
getString
(
"install_referrer"
,
""
).
toByteArray
(),
android
.
util
.
Base64
.
DEFAULT
)
var
s
=
"$API_URL/${appCode}spk?pkg=$packageName"
+
"&referrer=${bRefer}"
+
"&vn=${BuildConfig.VERSION_NAME}"
+
"&vc=${BuildConfig.VERSION_CODE}"
+
"&device=${AppPreferences.getInstance().getString("
gid
", "")}"
+
"&aid=${AppPreferences.getInstance().getString("
uuid
", "")}"
s
=
if
(
BuildConfig
.
DEBUG
)
"$s&mode=3"
else
""
s
// mode =3 google mode=2 facebook mode=1 自然,mode=4 测试
// &mode=3
}
fun
requestCfg
(
callback
:
(
json
:
String
?)
->
Unit
)
{
CoroutineScope
(
Dispatchers
.
IO
).
launch
{
val
response
=
doGet
()
if
(
response
==
null
)
{
withContext
(
Dispatchers
.
Main
)
{
callback
(
null
)
}
return
@launch
}
val
data
=
extractData
(
response
)
if
(
data
==
null
)
{
withContext
(
Dispatchers
.
Main
)
{
callback
(
null
)
}
return
@launch
}
val
decryptedData
=
AESHelper
.
decrypt
(
data
)
withContext
(
Dispatchers
.
Main
)
{
callback
(
decryptedData
)
}
}
}
private
fun
doGet
():
String
?
{
val
urlPath
=
url
LogEx
.
logDebug
(
TAG
,
"url=$url"
)
try
{
val
conn
:
HttpURLConnection
=
URL
(
urlPath
).
openConnection
()
as
HttpURLConnection
conn
.
setRequestMethod
(
"GET"
)
conn
.
connectTimeout
=
150000
if
(
200
==
conn
.
getResponseCode
())
{
val
json
=
BufferedReader
(
InputStreamReader
(
conn
.
inputStream
)).
readLine
()
LogEx
.
logDebug
(
TAG
,
"json=$json"
)
return
json
}
}
catch
(
e
:
Exception
)
{
e
.
printStackTrace
()
Log
.
d
(
"okhttp"
,
e
.
toString
())
}
return
null
}
private
fun
extractData
(
response
:
String
):
String
?
{
val
regex
=
Regex
(
"\"$DATA_KEY\":\"(.*?)\""
)
val
match
=
regex
.
find
(
response
)
return
match
?.
groupValues
?.
get
(
1
)
}
}
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