mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-24 10:35:19 +00:00
SA1390 - Session ID regeneration on focus loss (#1392)
* Fixes #1390 * Clean up prior to PR * Removed unused logging imports introduced during debugging * Added mechanism to store the session ID seed temporarily during account creation * Implemented keeping session ID on lose/regain focus via Hariss' better way using the savedInstanceState Bundle * Removed now unused imports
This commit is contained in:
parent
2fff9eceb7
commit
343820579c
@ -14,6 +14,11 @@ class LandingActivity : BaseActionBarActivity() {
|
|||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
|
// We always hit this LandingActivity on launch - but if there is a previous instance of
|
||||||
|
// Session then close this activity to resume the last activity from the previous instance.
|
||||||
|
if (!isTaskRoot) { finish(); return }
|
||||||
|
|
||||||
val binding = ActivityLandingBinding.inflate(layoutInflater)
|
val binding = ActivityLandingBinding.inflate(layoutInflater)
|
||||||
setContentView(binding.root)
|
setContentView(binding.root)
|
||||||
setUpActionBarSessionLogo(true)
|
setUpActionBarSessionLogo(true)
|
||||||
|
@ -35,6 +35,8 @@ import javax.inject.Inject
|
|||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
class RegisterActivity : BaseActionBarActivity() {
|
class RegisterActivity : BaseActionBarActivity() {
|
||||||
|
|
||||||
|
private val temporarySeedKey = "TEMPORARY_SEED_KEY"
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var configFactory: ConfigFactory
|
lateinit var configFactory: ConfigFactory
|
||||||
|
|
||||||
@ -77,13 +79,20 @@ class RegisterActivity : BaseActionBarActivity() {
|
|||||||
}, 61, 75, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)
|
}, 61, 75, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)
|
||||||
binding.termsTextView.movementMethod = LinkMovementMethod.getInstance()
|
binding.termsTextView.movementMethod = LinkMovementMethod.getInstance()
|
||||||
binding.termsTextView.text = termsExplanation
|
binding.termsTextView.text = termsExplanation
|
||||||
updateKeyPair()
|
updateKeyPair(savedInstanceState?.getByteArray(temporarySeedKey))
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onSaveInstanceState(outState: Bundle) {
|
||||||
|
super.onSaveInstanceState(outState)
|
||||||
|
seed?.let { tempSeed ->
|
||||||
|
outState.putByteArray(temporarySeedKey, tempSeed)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// endregion
|
// endregion
|
||||||
|
|
||||||
// region Updating
|
// region Updating
|
||||||
private fun updateKeyPair() {
|
private fun updateKeyPair(temporaryKey: ByteArray?) {
|
||||||
val keyPairGenerationResult = KeyPairUtilities.generate()
|
val keyPairGenerationResult = temporaryKey?.let(KeyPairUtilities::generate) ?: KeyPairUtilities.generate()
|
||||||
seed = keyPairGenerationResult.seed
|
seed = keyPairGenerationResult.seed
|
||||||
ed25519KeyPair = keyPairGenerationResult.ed25519KeyPair
|
ed25519KeyPair = keyPairGenerationResult.ed25519KeyPair
|
||||||
x25519KeyPair = keyPairGenerationResult.x25519KeyPair
|
x25519KeyPair = keyPairGenerationResult.x25519KeyPair
|
||||||
@ -125,7 +134,6 @@ class RegisterActivity : BaseActionBarActivity() {
|
|||||||
// which can result in an invalid database state
|
// which can result in an invalid database state
|
||||||
database.clearAllLastMessageHashes()
|
database.clearAllLastMessageHashes()
|
||||||
database.clearReceivedMessageHashValues()
|
database.clearReceivedMessageHashValues()
|
||||||
|
|
||||||
KeyPairUtilities.store(this, seed!!, ed25519KeyPair!!, x25519KeyPair!!)
|
KeyPairUtilities.store(this, seed!!, ed25519KeyPair!!, x25519KeyPair!!)
|
||||||
configFactory.keyPairChanged()
|
configFactory.keyPairChanged()
|
||||||
val userHexEncodedPublicKey = x25519KeyPair!!.hexEncodedPublicKey
|
val userHexEncodedPublicKey = x25519KeyPair!!.hexEncodedPublicKey
|
||||||
|
Loading…
Reference in New Issue
Block a user