Merge branch 'enable-connect-via-bluetooth' into 'master'

Enable connect via Bluetooth feature in release builds

See merge request briar/briar!1531
This commit is contained in:
akwizgran
2021-08-31 13:07:59 +00:00
14 changed files with 44 additions and 57 deletions

View File

@@ -31,15 +31,6 @@
<option name="PACKAGES_TO_USE_STAR_IMPORTS"> <option name="PACKAGES_TO_USE_STAR_IMPORTS">
<value /> <value />
</option> </option>
<option name="PACKAGES_IMPORT_LAYOUT">
<value>
<package name="" alias="false" withSubpackages="true" />
<package name="java" alias="false" withSubpackages="true" />
<package name="javax" alias="false" withSubpackages="true" />
<package name="kotlin" alias="false" withSubpackages="true" />
<package name="" alias="true" withSubpackages="true" />
</value>
</option>
<option name="NAME_COUNT_TO_USE_STAR_IMPORT" value="2147483647" /> <option name="NAME_COUNT_TO_USE_STAR_IMPORT" value="2147483647" />
<option name="NAME_COUNT_TO_USE_STAR_IMPORT_FOR_MEMBERS" value="2147483647" /> <option name="NAME_COUNT_TO_USE_STAR_IMPORT_FOR_MEMBERS" value="2147483647" />
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" /> <option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
@@ -197,9 +188,9 @@
</codeStyleSettings> </codeStyleSettings>
<codeStyleSettings language="kotlin"> <codeStyleSettings language="kotlin">
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" /> <option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
<option name="PARAMETER_ANNOTATION_WRAP" value="1" /> <indentOptions>
<option name="VARIABLE_ANNOTATION_WRAP" value="1" /> <option name="CONTINUATION_INDENT_SIZE" value="4" />
<option name="ENUM_CONSTANTS_WRAP" value="1" /> </indentOptions>
</codeStyleSettings> </codeStyleSettings>
</code_scheme> </code_scheme>
</component> </component>

View File

@@ -11,8 +11,6 @@ public interface FeatureFlags {
boolean shouldEnableDisappearingMessages(); boolean shouldEnableDisappearingMessages();
boolean shouldEnableConnectViaBluetooth();
boolean shouldEnableTransferData(); boolean shouldEnableTransferData();
boolean shouldEnableShareAppViaOfflineHotspot(); boolean shouldEnableShareAppViaOfflineHotspot();

View File

@@ -25,11 +25,6 @@ public class TestFeatureFlagModule {
return true; return true;
} }
@Override
public boolean shouldEnableConnectViaBluetooth() {
return true;
}
@Override @Override
public boolean shouldEnableTransferData() { public boolean shouldEnableTransferData() {
return true; return true;

View File

@@ -313,11 +313,6 @@ public class AppModule {
return true; return true;
} }
@Override
public boolean shouldEnableConnectViaBluetooth() {
return IS_DEBUG_BUILD;
}
@Override @Override
public boolean shouldEnableTransferData() { public boolean shouldEnableTransferData() {
return IS_DEBUG_BUILD; return IS_DEBUG_BUILD;

View File

@@ -379,9 +379,6 @@ public class ConversationActivity extends BriarActivity
this::showIntroductionOnboarding); this::showIntroductionOnboarding);
} }
}); });
if (!featureFlags.shouldEnableConnectViaBluetooth()) {
menu.findItem(R.id.action_connect_via_bluetooth).setVisible(false);
}
// Transfer Data feature only supported on API 19+ // Transfer Data feature only supported on API 19+
if (SDK_INT >= 19 && featureFlags.shouldEnableTransferData()) { if (SDK_INT >= 19 && featureFlags.shouldEnableTransferData()) {
menu.findItem(R.id.action_transfer_data).setVisible(true); menu.findItem(R.id.action_transfer_data).setVisible(true);

View File

@@ -37,7 +37,7 @@ constructor(
?: throw UsageError("Could not get password. Is STDIN connected?") ?: throw UsageError("Could not get password. Is STDIN connected?")
try { try {
accountManager.signIn(password) accountManager.signIn(password)
} catch (e : DecryptionException) { } catch (e: DecryptionException) {
echo("Error: Password invalid") echo("Error: Password invalid")
exitProcess(1) exitProcess(1)
} }

View File

@@ -95,7 +95,6 @@ internal class HeadlessModule(private val appDir: File) {
override fun shouldEnableImageAttachments() = false override fun shouldEnableImageAttachments() = false
override fun shouldEnableProfilePictures() = false override fun shouldEnableProfilePictures() = false
override fun shouldEnableDisappearingMessages() = false override fun shouldEnableDisappearingMessages() = false
override fun shouldEnableConnectViaBluetooth() = false
override fun shouldEnableTransferData() = false override fun shouldEnableTransferData() = false
override fun shouldEnableShareAppViaOfflineHotspot() = false override fun shouldEnableShareAppViaOfflineHotspot() = false
} }

View File

@@ -3,7 +3,11 @@ package org.briarproject.briar.headless
import com.fasterxml.jackson.core.JsonParseException import com.fasterxml.jackson.core.JsonParseException
import com.fasterxml.jackson.databind.ObjectMapper import com.fasterxml.jackson.databind.ObjectMapper
import io.javalin.Javalin import io.javalin.Javalin
import io.javalin.apibuilder.ApiBuilder.* import io.javalin.apibuilder.ApiBuilder.delete
import io.javalin.apibuilder.ApiBuilder.get
import io.javalin.apibuilder.ApiBuilder.path
import io.javalin.apibuilder.ApiBuilder.post
import io.javalin.apibuilder.ApiBuilder.put
import io.javalin.core.security.AccessManager import io.javalin.core.security.AccessManager
import io.javalin.core.util.Header.AUTHORIZATION import io.javalin.core.util.Header.AUTHORIZATION
import io.javalin.http.BadRequestResponse import io.javalin.http.BadRequestResponse

View File

@@ -6,16 +6,16 @@ import org.briarproject.briar.api.blog.MessageType
import org.briarproject.briar.headless.json.JsonDict import org.briarproject.briar.headless.json.JsonDict
internal fun BlogPostHeader.output(text: String) = JsonDict( internal fun BlogPostHeader.output(text: String) = JsonDict(
"text" to text, "text" to text,
"author" to author.output(), "author" to author.output(),
"authorStatus" to authorInfo.status.output(), "authorStatus" to authorInfo.status.output(),
"type" to type.output(), "type" to type.output(),
"id" to id.bytes, "id" to id.bytes,
"parentId" to parentId?.bytes, "parentId" to parentId?.bytes,
"read" to isRead, "read" to isRead,
"rssFeed" to isRssFeed, "rssFeed" to isRssFeed,
"timestamp" to timestamp, "timestamp" to timestamp,
"timestampReceived" to timeReceived "timestampReceived" to timeReceived
) )
internal fun MessageType.output() = name.toLowerCase() internal fun MessageType.output() = name.toLowerCase()

View File

@@ -2,7 +2,11 @@ package org.briarproject.briar.headless.contact
import org.briarproject.bramble.api.contact.PendingContact import org.briarproject.bramble.api.contact.PendingContact
import org.briarproject.bramble.api.contact.PendingContactState import org.briarproject.bramble.api.contact.PendingContactState
import org.briarproject.bramble.api.contact.PendingContactState.* import org.briarproject.bramble.api.contact.PendingContactState.ADDING_CONTACT
import org.briarproject.bramble.api.contact.PendingContactState.CONNECTING
import org.briarproject.bramble.api.contact.PendingContactState.FAILED
import org.briarproject.bramble.api.contact.PendingContactState.OFFLINE
import org.briarproject.bramble.api.contact.PendingContactState.WAITING_FOR_CONNECTION
import org.briarproject.bramble.api.contact.event.PendingContactAddedEvent import org.briarproject.bramble.api.contact.event.PendingContactAddedEvent
import org.briarproject.bramble.api.contact.event.PendingContactRemovedEvent import org.briarproject.bramble.api.contact.event.PendingContactRemovedEvent
import org.briarproject.bramble.api.contact.event.PendingContactStateChangedEvent import org.briarproject.bramble.api.contact.event.PendingContactStateChangedEvent
@@ -14,7 +18,7 @@ internal fun PendingContact.output() = JsonDict(
"timestamp" to timestamp "timestamp" to timestamp
) )
internal fun PendingContactState.output() = when(this) { internal fun PendingContactState.output() = when (this) {
WAITING_FOR_CONNECTION -> "waiting_for_connection" WAITING_FOR_CONNECTION -> "waiting_for_connection"
OFFLINE -> "offline" OFFLINE -> "offline"
CONNECTING -> "connecting" CONNECTING -> "connecting"

View File

@@ -14,7 +14,12 @@ import org.briarproject.bramble.api.identity.LocalAuthor
import org.briarproject.bramble.api.sync.Group import org.briarproject.bramble.api.sync.Group
import org.briarproject.bramble.api.sync.Message import org.briarproject.bramble.api.sync.Message
import org.briarproject.bramble.api.system.Clock import org.briarproject.bramble.api.system.Clock
import org.briarproject.bramble.test.TestUtils.* import org.briarproject.bramble.test.TestUtils.getAuthor
import org.briarproject.bramble.test.TestUtils.getClientId
import org.briarproject.bramble.test.TestUtils.getContact
import org.briarproject.bramble.test.TestUtils.getGroup
import org.briarproject.bramble.test.TestUtils.getLocalAuthor
import org.briarproject.bramble.test.TestUtils.getMessage
import org.briarproject.bramble.util.StringUtils.getRandomString import org.briarproject.bramble.util.StringUtils.getRandomString
import org.briarproject.briar.api.conversation.ConversationManager import org.briarproject.briar.api.conversation.ConversationManager
import org.briarproject.briar.headless.event.WebSocketController import org.briarproject.briar.headless.event.WebSocketController

View File

@@ -48,31 +48,31 @@ abstract class IntegrationTest {
dataDir.deleteRecursively() dataDir.deleteRecursively()
} }
protected fun get(url: String) : Response { protected fun get(url: String): Response {
return khttp.get(url, getAuthTokenHeader(token)) return khttp.get(url, getAuthTokenHeader(token))
} }
protected fun getWithWrongToken(url: String) : Response { protected fun getWithWrongToken(url: String): Response {
return khttp.get(url, getAuthTokenHeader("wrongToken")) return khttp.get(url, getAuthTokenHeader("wrongToken"))
} }
protected fun post(url: String, data: String) : Response { protected fun post(url: String, data: String): Response {
return khttp.post(url, getAuthTokenHeader(token), data = data) return khttp.post(url, getAuthTokenHeader(token), data = data)
} }
protected fun postWithWrongToken(url: String) : Response { protected fun postWithWrongToken(url: String): Response {
return khttp.post(url, getAuthTokenHeader("wrongToken"), data = "") return khttp.post(url, getAuthTokenHeader("wrongToken"), data = "")
} }
protected fun delete(url: String) : Response { protected fun delete(url: String): Response {
return khttp.delete(url, getAuthTokenHeader(token)) return khttp.delete(url, getAuthTokenHeader(token))
} }
protected fun delete(url: String, data: String) : Response { protected fun delete(url: String, data: String): Response {
return khttp.delete(url, getAuthTokenHeader(token), data = data) return khttp.delete(url, getAuthTokenHeader(token), data = data)
} }
protected fun deleteWithWrongToken(url: String) : Response { protected fun deleteWithWrongToken(url: String): Response {
return khttp.delete(url, getAuthTokenHeader("wrongToken")) return khttp.delete(url, getAuthTokenHeader("wrongToken"))
} }

View File

@@ -8,7 +8,7 @@ import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
class ContactControllerIntegrationTest: IntegrationTest() { class ContactControllerIntegrationTest : IntegrationTest() {
@Test @Test
fun `returning list of contacts needs authentication token`() { fun `returning list of contacts needs authentication token`() {
@@ -24,7 +24,7 @@ class ContactControllerIntegrationTest: IntegrationTest() {
assertEquals(0, response.jsonArray.length()) assertEquals(0, response.jsonArray.length())
// add one test contact // add one test contact
val testContactName= "testContactName" val testContactName = "testContactName"
testDataCreator.addContact(testContactName, true, false) testDataCreator.addContact(testContactName, true, false)
// retrieve list with one test contact // retrieve list with one test contact

View File

@@ -1,8 +1,6 @@
package org.briarproject.briar.headless.contact package org.briarproject.briar.headless.contact
import io.javalin.http.BadRequestResponse import io.javalin.http.BadRequestResponse
import io.javalin.http.ForbiddenResponse
import io.javalin.http.HttpResponseException
import io.javalin.http.NotFoundResponse import io.javalin.http.NotFoundResponse
import io.javalin.plugin.json.JavalinJson.toJson import io.javalin.plugin.json.JavalinJson.toJson
import io.mockk.Runs import io.mockk.Runs
@@ -35,7 +33,6 @@ import org.briarproject.bramble.util.StringUtils.getRandomString
import org.briarproject.briar.headless.ControllerTest import org.briarproject.briar.headless.ControllerTest
import org.briarproject.briar.headless.getFromJson import org.briarproject.briar.headless.getFromJson
import org.briarproject.briar.headless.json.JsonDict import org.briarproject.briar.headless.json.JsonDict
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertNotNull import org.junit.jupiter.api.Assertions.assertNotNull
import org.junit.jupiter.api.Assertions.assertThrows import org.junit.jupiter.api.Assertions.assertThrows
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
@@ -316,7 +313,9 @@ internal class ContactControllerTest : ControllerTest() {
fun testSetContactAliasInvalid() { fun testSetContactAliasInvalid() {
mockkStatic("org.briarproject.briar.headless.RouterKt") mockkStatic("org.briarproject.briar.headless.RouterKt")
every { ctx.pathParam("contactId") } returns "1" every { ctx.pathParam("contactId") } returns "1"
every { ctx.getFromJson(objectMapper, "alias") } returns getRandomString(MAX_AUTHOR_NAME_LENGTH + 1) every {
ctx.getFromJson(objectMapper, "alias")
} returns getRandomString(MAX_AUTHOR_NAME_LENGTH + 1)
assertThrows(BadRequestResponse::class.java) { assertThrows(BadRequestResponse::class.java) {
controller.setContactAlias(ctx) controller.setContactAlias(ctx)
} }