diff --git a/CHANGELOG.md b/CHANGELOG.md index be6496f3f4..05cb4ea8f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -67,6 +67,7 @@ Attention: don't forget to add the flag for F-Droid before release - [FIX] Fix remote-controls duplication ir files - [FIX] Fix infrared remotes card beta text color - [FIX] Fix disappeared file manager +- [FIX] Add deeplink fallback for flipper scheme uri - [FIX] Change description of remotes library card - [CI] Fix merge-queue files diff - [CI] Add https://github.com/LionZXY/detekt-decompose-rule diff --git a/components/deeplink/impl/src/main/java/com/flipperdevices/deeplink/impl/parser/delegates/DeepLinkFlipperFormatSharing.kt b/components/deeplink/impl/src/main/java/com/flipperdevices/deeplink/impl/parser/delegates/DeepLinkFlipperFormatSharing.kt index 0abd813bdf..5f0b533f21 100644 --- a/components/deeplink/impl/src/main/java/com/flipperdevices/deeplink/impl/parser/delegates/DeepLinkFlipperFormatSharing.kt +++ b/components/deeplink/impl/src/main/java/com/flipperdevices/deeplink/impl/parser/delegates/DeepLinkFlipperFormatSharing.kt @@ -7,6 +7,7 @@ import com.flipperdevices.bridge.dao.api.model.FlipperFilePath import com.flipperdevices.core.di.AppGraph import com.flipperdevices.core.ktx.jre.FlipperDispatchers import com.flipperdevices.core.log.LogTagProvider +import com.flipperdevices.core.log.info import com.flipperdevices.deeplink.api.DeepLinkParserDelegate import com.flipperdevices.deeplink.impl.utils.Constants import com.flipperdevices.deeplink.model.DeepLinkParserDelegatePriority @@ -44,13 +45,18 @@ class DeepLinkFlipperFormatSharing @Inject constructor( override suspend fun fromIntent(context: Context, intent: Intent): Deeplink? { var pureUri = intent.data ?: return null + info { "Try parse uri $pureUri. ${pureUri.query}${pureUri.fragment}" } if (pureUri.scheme == SCHEME_FLIPPERKEY) { - val query = pureUri.query + var query = "${pureUri.query}" + if (pureUri.fragment.isNullOrBlank().not()) { + query += "#${pureUri.fragment}" + } val decodedQuery = withContext(FlipperDispatchers.workStealingDispatcher) { URLDecoder.decode(query, "UTF-8") } pureUri = Uri.parse(decodedQuery) + info { "Found flipper scheme, new uri is $pureUri" } } return getUrlDeeplink(pureUri) ?: getCryptoFileDeeplink(pureUri) @@ -66,7 +72,11 @@ class DeepLinkFlipperFormatSharing @Inject constructor( } private fun getCryptoFileDeeplink(uri: Uri): Deeplink? { - val flipperKeyCrypto = parser.parseUriToCryptoKeyData(uri) ?: return null + val flipperKeyCrypto = parser.parseUriToCryptoKeyData(uri) + if (flipperKeyCrypto == null) { + info { "Failed parse $uri because flipperKeyCrypto is null" } + return null + } val path = flipperKeyCrypto.pathToKey val flipperFilePath = FlipperFilePath( diff --git a/components/keyparser/impl/src/main/kotlin/com/flipperdevices/keyparser/impl/api/KeyParserImpl.kt b/components/keyparser/impl/src/main/kotlin/com/flipperdevices/keyparser/impl/api/KeyParserImpl.kt index 13814495db..60d18b6b12 100644 --- a/components/keyparser/impl/src/main/kotlin/com/flipperdevices/keyparser/impl/api/KeyParserImpl.kt +++ b/components/keyparser/impl/src/main/kotlin/com/flipperdevices/keyparser/impl/api/KeyParserImpl.kt @@ -10,6 +10,7 @@ import com.flipperdevices.core.data.PredefinedEnumMap import com.flipperdevices.core.di.AppGraph import com.flipperdevices.core.ktx.jre.FlipperDispatchers import com.flipperdevices.core.log.LogTagProvider +import com.flipperdevices.core.log.info import com.flipperdevices.core.log.warn import com.flipperdevices.keyparser.api.KeyParser import com.flipperdevices.keyparser.api.model.FlipperKeyParsed @@ -108,23 +109,29 @@ class KeyParserImpl @Inject constructor() : KeyParser, LogTagProvider { } override fun parseUriToCryptoKeyData(uri: Uri): FlipperKeyCrypto? { - val fragment = uri.encodedFragment ?: return null + val fragment = uri.encodedFragment + if (fragment == null) { + info { "Failed parse $uri because fragment is null" } + return null + } val parsedFragment = urlDecoder.decodeQuery(fragment) val path = parsedFragment .firstOrNull { it.first == QUERY_KEY_PATH } ?.second - ?: return null val key = parsedFragment .firstOrNull { it.first == QUERY_KEY } ?.second - ?: return null val fileId = parsedFragment .firstOrNull { it.first == QUERY_ID } ?.second - ?: return null + + if (path == null || key == null || fileId == null) { + info { "Failed parse uri $uri because path, key or fileId is null ($path,$key,$fileId)" } + return null + } return FlipperKeyCrypto( fileId = fileId,