Skip to content
This repository has been archived by the owner on Apr 12, 2022. It is now read-only.

Commit

Permalink
Merge pull request #2880 from vector-im/feature/notification_rework
Browse files Browse the repository at this point in the history
Notification using MessagingStyle
  • Loading branch information
bmarty authored Mar 18, 2019
2 parents b78c5cb + fdd5139 commit 409cf1e
Show file tree
Hide file tree
Showing 68 changed files with 2,466 additions and 2,682 deletions.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ Improvements:
- Better wording in notification for video call (#1421)
- Improve widget banner (#2129)
- Icon for Oreo (#2169)
- Notification reliability and Messaging Style, with inlined reply (#2823, #1016).
- Notification settings re-organization, added bing rule troubleshoot
- Kotlin Code Improvement in VectorSettingsPreferencesFragment.kt
- Remove redundant !! , Replace it with null safe operators in VectorSettingsPreferencesFragment.kt
Expand Down
3 changes: 2 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ Please add a line to the top of the file `CHANGES.rst` describing your change.

Make sure the following commands execute without any error:

> ./tools/check/check_code_quality.sh<br/>./gradlew lintAppRelease
> ./tools/check/check_code_quality.sh
> ./gradlew lintAppRelease
### Unit tests

Expand Down
8 changes: 8 additions & 0 deletions vector/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ android {
resValue "string", "git_revision_date", "\"${gitRevisionDate()}\""
resValue "string", "git_branch_name", "\"${gitBranchName()}\""
resValue "string", "build_number", rootProject.ext.buildNumberProp
buildConfigField "boolean", "LOW_PRIVACY_LOG_ENABLE", "false"
minifyEnabled false
}

Expand All @@ -95,6 +96,7 @@ android {
resValue "string", "git_revision_date", "\"${gitRevisionDate()}\""
resValue "string", "git_branch_name", "\"${gitBranchName()}\""
resValue "string", "build_number", rootProject.ext.buildNumberProp
buildConfigField "boolean", "LOW_PRIVACY_LOG_ENABLE", "false"
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
Expand Down Expand Up @@ -185,6 +187,12 @@ android {
}
}

apply plugin: 'org.jetbrains.kotlin.android.extensions'

androidExtensions {
experimental = true
}

static def gitRevision() {
def cmd = "git rev-parse --short HEAD"
return cmd.execute().text.trim()
Expand Down
154 changes: 154 additions & 0 deletions vector/src/androidTest/java/im/vector/util/SecureSecretStoreTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
package im.vector.util

import android.support.test.InstrumentationRegistry
import org.junit.Assert
import org.junit.Test
import java.io.ByteArrayInputStream
import java.io.ByteArrayOutputStream


class SecureSecretStoreTest {

@Test
fun test_symetric_encrypt_decrypt() {
val clearText = "Hello word!"
val encrypted = SecretStoringUtils.encryptStringM(clearText, "foo")
Assert.assertNotNull(encrypted)
val decrypted = SecretStoringUtils.decryptStringM(encrypted!!, "foo");

Assert.assertEquals(clearText, decrypted)

//Test kitkat way
val context = InstrumentationRegistry.getContext()
val KEncrypted = SecretStoringUtils.encryptStringJ(clearText, "bar", context)

val kDecripted = SecretStoringUtils.decryptStringJ(KEncrypted!!, "bar", context)

Assert.assertEquals(clearText, kDecripted)
}

@Test
fun test_symetric_encrypt_decrypt_kitkat() {

val clearText = "Hello word!"
//Test kitkat way
val context = InstrumentationRegistry.getContext()
val KEncrypted = SecretStoringUtils.encryptStringJ(clearText, "bar", context)
Assert.assertNotNull("Failed to encrypt", KEncrypted)
Assert.assertTrue(KEncrypted!![0] == SecretStoringUtils.FORMAT_1)
val kDecripted = SecretStoringUtils.decryptStringJ(KEncrypted!!, "bar", context)

Assert.assertEquals(clearText, kDecripted)
}

@Test
fun test_symetric_encrypt_decrypt_veryold_device() {

val clearText = "Hello word!"
//Test kitkat way
val KEncrypted = SecretStoringUtils.encryptForOldDevicesNotGood(clearText, "bar")
Assert.assertNotNull("Failed to encrypt", KEncrypted)
Assert.assertTrue(KEncrypted!![0] == SecretStoringUtils.FORMAT_2)
val kDecripted = SecretStoringUtils.decryptForOldDevicesNotGood(KEncrypted!!, "bar")

Assert.assertEquals(clearText, kDecripted)
}

@Test
fun test_store_secret() {

val clearText = "Hello word!"
//Test kitkat way
val context = InstrumentationRegistry.getContext()
val KEncrypted = SecretStoringUtils.securelyStoreString(clearText, "bar", context)
Assert.assertNotNull("Failed to encrypt", KEncrypted)
val kDecripted = SecretStoringUtils.loadSecureSecret(KEncrypted!!, "bar", context)

Assert.assertEquals(clearText, kDecripted)
}


@Test
fun test_secureObjectStoreM() {

val data = listOf<String>("Store", "this", "encrypted", "Please")

val bos = ByteArrayOutputStream()
SecretStoringUtils.saveSecureObjectM("bar1", bos, data)
val bytes = bos.toByteArray()
Assert.assertTrue(bytes.size > 0)

val bis = ByteArrayInputStream(bytes)
val loadedData = SecretStoringUtils.loadSecureObjectM<List<String>>("bar1", bis)
Assert.assertNotNull(loadedData)
Assert.assertEquals(data.size, loadedData!!.size)
for (i in 0..data.size - 1) {
Assert.assertEquals(data[i], loadedData!![i])
System.out.print(loadedData!![i])
}
}

@Test
fun test_secureObjectStore_kitkat() {

val context = InstrumentationRegistry.getContext()
val data = listOf<String>("Store", "this", "encrypted", "Please")

val bos = ByteArrayOutputStream()
SecretStoringUtils.saveSecureObjectK("bar1", bos, data, context)
val bytes = bos.toByteArray()
Assert.assertTrue(bytes.size > 0)

val bis = ByteArrayInputStream(bytes)
val loadedData = SecretStoringUtils.loadSecureObjectK<List<String>>("bar1", bis, context)
Assert.assertNotNull(loadedData)
Assert.assertEquals(data.size, loadedData!!.size)
for (i in 0..data.size - 1) {
Assert.assertEquals(data[i], loadedData!![i])
System.out.print(loadedData!![i])
}
}

@Test
fun test_secureObjectStore_older() {

val data = listOf<String>("Store", "this", "encrypted", "Please")

val bos = ByteArrayOutputStream()
SecretStoringUtils.saveSecureObjectOldNotGood("bar1", bos, data)
val bytes = bos.toByteArray()
Assert.assertTrue(bytes.size > 0)

Assert.assertEquals("Wrong Format", SecretStoringUtils.FORMAT_2, bytes[0])

val bis = ByteArrayInputStream(bytes)
val loadedData = SecretStoringUtils.loadSecureObjectOldNotGood<List<String>>("bar1", bis)
Assert.assertNotNull(loadedData)
Assert.assertEquals(data.size, loadedData!!.size)
for (i in 0..data.size - 1) {
Assert.assertEquals(data[i], loadedData!![i])
System.out.print(loadedData!![i])
}
}

@Test
fun test_secureObjectStore() {

val context = InstrumentationRegistry.getContext()
val data = listOf<String>("Store", "this", "encrypted", "Please")

val bos = ByteArrayOutputStream()
SecretStoringUtils.securelyStoreObject(data, "bar1", bos, context)
val bytes = bos.toByteArray()
Assert.assertTrue(bytes.size > 0)

val bis = ByteArrayInputStream(bytes)
val loadedData = SecretStoringUtils.loadSecureSecret<List<String>>(bis, "bar1", context)
Assert.assertNotNull(loadedData)
Assert.assertEquals(data.size, loadedData!!.size)
for (i in 0..data.size - 1) {
Assert.assertEquals(data[i], loadedData!![i])
System.out.print(loadedData!![i])
}
}
}
Loading

0 comments on commit 409cf1e

Please sign in to comment.