mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-22 16:07:30 +00:00
...
This commit is contained in:
parent
41d24ef2c3
commit
cc6f880665
@ -26,21 +26,21 @@
|
|||||||
"SG_back":"connect-ws-dra.hispace.dbankcloud.com"
|
"SG_back":"connect-ws-dra.hispace.dbankcloud.com"
|
||||||
},
|
},
|
||||||
"client":{
|
"client":{
|
||||||
"cp_id":"30061000024605000",
|
"cp_id":"890061000023000573",
|
||||||
"product_id":"99536292102650699",
|
"product_id":"99536292102532562",
|
||||||
"client_id":"993355872258247936",
|
"client_id":"954244311350791232",
|
||||||
"client_secret":"0A83DC166FBF0696B884D38830E0B90AE8BBFF2D9CA8C26C9D9DA26816C2A9E3",
|
"client_secret":"555999202D718B6744DAD2E923B386DC17F3F4E29F5105CE0D061EED328DADEE",
|
||||||
"project_id":"99536292102650699",
|
"project_id":"99536292102532562",
|
||||||
"app_id":"107146885",
|
"app_id":"107205081",
|
||||||
"api_key":"DAEDAPld5VAZXpjfD+g0PwlXfya5ykPMYTMRYkySUjGfJg055ijAFNZBUtcykDPWZiaUcc4Mo9oJqmooL6HT8n4toO5COlWZjkqGXA==",
|
"api_key":"DAEDABeddLEqUy0QRwa1THLwRA0OqrSuyci/HjNvVSmsdWsXRM2U2hRaCyqfvGYH1IFOKrauArssz/WPMLRHCYxliWf+DTj9bDwlWA==",
|
||||||
"package_name":"network.loki.messenger"
|
"package_name":"network.loki.messenger"
|
||||||
},
|
},
|
||||||
"oauth_client":{
|
"oauth_client":{
|
||||||
"client_id":"107146885",
|
"client_id":"107205081",
|
||||||
"client_type":1
|
"client_type":1
|
||||||
},
|
},
|
||||||
"app_info":{
|
"app_info":{
|
||||||
"app_id":"107146885",
|
"app_id":"107205081",
|
||||||
"package_name":"network.loki.messenger"
|
"package_name":"network.loki.messenger"
|
||||||
},
|
},
|
||||||
"service":{
|
"service":{
|
||||||
@ -53,6 +53,10 @@
|
|||||||
"resource_id":"p1",
|
"resource_id":"p1",
|
||||||
"channel_id":""
|
"channel_id":""
|
||||||
},
|
},
|
||||||
|
"edukit":{
|
||||||
|
"edu_url":"edukit.edu.cloud.huawei.com.cn",
|
||||||
|
"dh_url":"edukit.edu.cloud.huawei.com.cn"
|
||||||
|
},
|
||||||
"search":{
|
"search":{
|
||||||
"url":"https://search-dre.cloud.huawei.com"
|
"url":"https://search-dre.cloud.huawei.com"
|
||||||
},
|
},
|
||||||
@ -77,15 +81,15 @@
|
|||||||
{
|
{
|
||||||
"package_name":"network.loki.messenger",
|
"package_name":"network.loki.messenger",
|
||||||
"client":{
|
"client":{
|
||||||
"app_id":"107146885"
|
"app_id":"107205081"
|
||||||
},
|
},
|
||||||
"app_info":{
|
"app_info":{
|
||||||
"package_name":"network.loki.messenger",
|
"package_name":"network.loki.messenger",
|
||||||
"app_id":"107146885"
|
"app_id":"107205081"
|
||||||
},
|
},
|
||||||
"oauth_client":{
|
"oauth_client":{
|
||||||
"client_type":1,
|
"client_type":1,
|
||||||
"client_id":"107146885"
|
"client_id":"107205081"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -31,16 +31,17 @@ class HuaweiPushManager @Inject constructor(
|
|||||||
if (force) cancel() else if (isActive) return
|
if (force) cancel() else if (isActive) return
|
||||||
}
|
}
|
||||||
|
|
||||||
val appId = "107146885"
|
val appId = "107205081"
|
||||||
val tokenScope = "HCM"
|
val tokenScope = "HCM"
|
||||||
val hmsInstanceId = HmsInstanceId.getInstance(context)
|
val hmsInstanceId = HmsInstanceId.getInstance(context)
|
||||||
|
|
||||||
|
genericPushManager.refresh(TextSecurePreferences.getFCMToken(context), force)
|
||||||
|
|
||||||
MainScope().launch(Dispatchers.IO) {
|
MainScope().launch(Dispatchers.IO) {
|
||||||
val token = hmsInstanceId.getToken(appId, tokenScope)
|
val token = hmsInstanceId.getToken(appId, tokenScope)
|
||||||
|
Log.d(TAG, "refresh() hmsInstanceId => huawei token: $token")
|
||||||
Log.d(TAG, "refresh() with huawei token: $token")
|
//
|
||||||
|
//// genericPushManager.refresh(token, force)
|
||||||
genericPushManager.refresh(token, force)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import android.os.Bundle
|
|||||||
import com.huawei.hms.push.HmsMessageService
|
import com.huawei.hms.push.HmsMessageService
|
||||||
import com.huawei.hms.push.RemoteMessage
|
import com.huawei.hms.push.RemoteMessage
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
|
import org.session.libsession.utilities.TextSecurePreferences
|
||||||
import org.session.libsignal.utilities.Log
|
import org.session.libsignal.utilities.Log
|
||||||
import java.lang.Exception
|
import java.lang.Exception
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
@ -40,6 +41,10 @@ class HuaweiPushNotificationService: HmsMessageService() {
|
|||||||
|
|
||||||
override fun onNewToken(token: String?, bundle: Bundle?) {
|
override fun onNewToken(token: String?, bundle: Bundle?) {
|
||||||
Log.d("pnh", "New HCM token: $token.")
|
Log.d("pnh", "New HCM token: $token.")
|
||||||
|
|
||||||
|
if (token == TextSecurePreferences.getFCMToken(this)) return
|
||||||
|
|
||||||
|
TextSecurePreferences.setFCMToken(this, token)
|
||||||
pushManager.refresh(true)
|
pushManager.refresh(true)
|
||||||
}
|
}
|
||||||
override fun onMessageReceived(message: RemoteMessage?) {
|
override fun onMessageReceived(message: RemoteMessage?) {
|
||||||
|
@ -80,7 +80,7 @@
|
|||||||
|
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="com.huawei.hms.client.appid"
|
android:name="com.huawei.hms.client.appid"
|
||||||
android:value="appid=107146885">
|
android:value="appid=107205081">
|
||||||
</meta-data>
|
</meta-data>
|
||||||
|
|
||||||
<meta-data
|
<meta-data
|
||||||
|
@ -24,9 +24,10 @@ class GenericPushManager @Inject constructor(
|
|||||||
private val tokenManager: FcmTokenManager,
|
private val tokenManager: FcmTokenManager,
|
||||||
private val pushManagerV2: PushManagerV2,
|
private val pushManagerV2: PushManagerV2,
|
||||||
) {
|
) {
|
||||||
fun refresh(token: String, force: Boolean): Promise<*, Exception> {
|
fun refresh(token: String?, force: Boolean): Promise<*, Exception> {
|
||||||
Log.d(TAG, "refresh() called")
|
Log.d(TAG, "refresh($token, $force) called")
|
||||||
|
|
||||||
|
token ?: return emptyPromise()
|
||||||
val userPublicKey = TextSecurePreferences.getLocalNumber(context) ?: return emptyPromise()
|
val userPublicKey = TextSecurePreferences.getLocalNumber(context) ?: return emptyPromise()
|
||||||
val userEdKey = KeyPairUtilities.getUserED25519KeyPair(context) ?: return emptyPromise()
|
val userEdKey = KeyPairUtilities.getUserED25519KeyPair(context) ?: return emptyPromise()
|
||||||
|
|
||||||
@ -62,6 +63,11 @@ class GenericPushManager @Inject constructor(
|
|||||||
userEd25519Key: KeyPair,
|
userEd25519Key: KeyPair,
|
||||||
namespaces: List<Int> = listOf(Namespace.DEFAULT)
|
namespaces: List<Int> = listOf(Namespace.DEFAULT)
|
||||||
): Promise<*, Exception> {
|
): Promise<*, Exception> {
|
||||||
|
android.util.Log.d(
|
||||||
|
TAG,
|
||||||
|
"register() called with: token = $token, publicKey = $publicKey, userEd25519Key = $userEd25519Key, namespaces = $namespaces"
|
||||||
|
)
|
||||||
|
|
||||||
val v1 = PushManagerV1.register(
|
val v1 = PushManagerV1.register(
|
||||||
device = device,
|
device = device,
|
||||||
token = token,
|
token = token,
|
||||||
|
@ -32,18 +32,25 @@ object PushManagerV1 {
|
|||||||
token: String? = TextSecurePreferences.getFCMToken(context),
|
token: String? = TextSecurePreferences.getFCMToken(context),
|
||||||
publicKey: String? = TextSecurePreferences.getLocalNumber(context),
|
publicKey: String? = TextSecurePreferences.getLocalNumber(context),
|
||||||
legacyGroupPublicKeys: Collection<String> = MessagingModuleConfiguration.shared.storage.getAllClosedGroupPublicKeys()
|
legacyGroupPublicKeys: Collection<String> = MessagingModuleConfiguration.shared.storage.getAllClosedGroupPublicKeys()
|
||||||
): Promise<*, Exception> =
|
): Promise<*, Exception> = when {
|
||||||
when {
|
|
||||||
isUsingFCM -> retryIfNeeded(maxRetryCount) {
|
isUsingFCM -> retryIfNeeded(maxRetryCount) {
|
||||||
|
android.util.Log.d(
|
||||||
|
TAG,
|
||||||
|
"register() called with: device = $device, isUsingFCM = $isUsingFCM, token = $token, publicKey = $publicKey, legacyGroupPublicKeys = $legacyGroupPublicKeys"
|
||||||
|
)
|
||||||
doRegister(token, publicKey, device, legacyGroupPublicKeys)
|
doRegister(token, publicKey, device, legacyGroupPublicKeys)
|
||||||
} fail { exception ->
|
} fail { exception ->
|
||||||
Log.d(TAG, "Couldn't register for FCM due to error: $exception.")
|
Log.d(TAG, "Couldn't register for FCM due to error: $exception... $device $token $publicKey $legacyGroupPublicKeys")
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> emptyPromise()
|
else -> emptyPromise()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun doRegister(token: String?, publicKey: String?, device: Device, legacyGroupPublicKeys: Collection<String>): Promise<*, Exception> {
|
private fun doRegister(token: String?, publicKey: String?, device: Device, legacyGroupPublicKeys: Collection<String>): Promise<*, Exception> {
|
||||||
Log.d(TAG, "registerV1 requested")
|
android.util.Log.d(
|
||||||
|
TAG,
|
||||||
|
"doRegister() called with: token = $token, publicKey = $publicKey, device = $device, legacyGroupPublicKeys = $legacyGroupPublicKeys"
|
||||||
|
)
|
||||||
|
|
||||||
token ?: return emptyPromise()
|
token ?: return emptyPromise()
|
||||||
publicKey ?: return emptyPromise()
|
publicKey ?: return emptyPromise()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user