-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0d533fa
commit 234b6a1
Showing
17 changed files
with
204 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
components/bridge/connection/feature/appstart/api/build.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
plugins { | ||
id("flipper.multiplatform") | ||
id("flipper.multiplatform-dependencies") | ||
} | ||
|
||
android.namespace = "com.flipperdevices.bridge.connection.feature.appstart.api" | ||
|
||
commonDependencies { | ||
implementation(projects.components.core.data) | ||
implementation(projects.components.core.ktx) | ||
|
||
implementation(projects.components.bridge.connection.feature.common.api) | ||
implementation(projects.components.bridge.connection.transport.common.api) | ||
implementation(projects.components.bridge.connection.feature.rpcinfo.api) | ||
|
||
implementation(libs.kotlin.immutable.collections) | ||
implementation(libs.kotlin.coroutines) | ||
implementation(libs.okio) | ||
} |
7 changes: 7 additions & 0 deletions
7
...n/kotlin/com/flipperdevices/bridge/connection/feature/appstart/api/FAppStartFeatureApi.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.flipperdevices.bridge.connection.feature.appstart.api | ||
|
||
import com.flipperdevices.bridge.connection.feature.common.api.FDeviceFeatureApi | ||
|
||
interface FAppStartFeatureApi : FDeviceFeatureApi { | ||
suspend fun startApp(path: okio.Path): Result<Unit> | ||
} |
28 changes: 28 additions & 0 deletions
28
components/bridge/connection/feature/appstart/impl/build.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
plugins { | ||
id("flipper.multiplatform") | ||
id("flipper.multiplatform-dependencies") | ||
id("flipper.anvil-multiplatform") | ||
} | ||
|
||
android.namespace = "com.flipperdevices.bridge.connection.feature.appstart.impl" | ||
|
||
commonDependencies { | ||
implementation(projects.components.bridge.connection.feature.appstart.api) | ||
|
||
implementation(projects.components.core.di) | ||
implementation(projects.components.core.log) | ||
implementation(projects.components.core.ktx) | ||
implementation(projects.components.core.data) | ||
|
||
implementation(projects.components.bridge.connection.feature.common.api) | ||
implementation(projects.components.bridge.connection.transport.common.api) | ||
implementation(projects.components.bridge.connection.feature.rpc.api) | ||
implementation(projects.components.bridge.connection.feature.rpc.model) | ||
implementation(projects.components.bridge.connection.feature.rpcinfo.api) | ||
implementation(projects.components.bridge.connection.feature.protocolversion.api) | ||
|
||
implementation(projects.components.bridge.connection.pbutils) | ||
|
||
implementation(libs.kotlin.coroutines) | ||
implementation(libs.okio) | ||
} |
34 changes: 34 additions & 0 deletions
34
...com/flipperdevices/bridge/connection/feature/appstart/impl/api/FAppStartFeatureApiImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.flipperdevices.bridge.connection.feature.appstart.impl.api | ||
|
||
import com.flipperdevices.bridge.connection.feature.appstart.api.FAppStartFeatureApi | ||
import com.flipperdevices.bridge.connection.feature.rpc.api.FRpcFeatureApi | ||
import com.flipperdevices.bridge.connection.feature.rpc.model.wrapToRequest | ||
import com.flipperdevices.core.log.LogTagProvider | ||
import com.flipperdevices.protobuf.Main | ||
import com.flipperdevices.protobuf.app.StartRequest | ||
import dagger.assisted.Assisted | ||
import dagger.assisted.AssistedFactory | ||
import dagger.assisted.AssistedInject | ||
import okio.Path | ||
|
||
class FAppStartFeatureApiImpl @AssistedInject constructor( | ||
@Assisted private val rpcFeatureApi: FRpcFeatureApi, | ||
) : FAppStartFeatureApi, | ||
LogTagProvider { | ||
override val TAG = "FAlarmFeatureApi" | ||
|
||
override suspend fun startApp(path: Path): Result<Unit> { | ||
return rpcFeatureApi.requestOnce( | ||
Main( | ||
app_start_request = StartRequest(path.toString()) | ||
).wrapToRequest() | ||
).map { } | ||
} | ||
|
||
@AssistedFactory | ||
fun interface InternalFactory { | ||
operator fun invoke( | ||
rpcFeatureApi: FRpcFeatureApi, | ||
): FAppStartFeatureApiImpl | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
...flipperdevices/bridge/connection/feature/appstart/impl/api/FAppStartFeatureFactoryImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.flipperdevices.bridge.connection.feature.appstart.impl.api | ||
|
||
import com.flipperdevices.bridge.connection.feature.common.api.FDeviceFeature | ||
import com.flipperdevices.bridge.connection.feature.common.api.FDeviceFeatureApi | ||
import com.flipperdevices.bridge.connection.feature.common.api.FDeviceFeatureQualifier | ||
import com.flipperdevices.bridge.connection.feature.common.api.FUnsafeDeviceFeatureApi | ||
import com.flipperdevices.bridge.connection.feature.protocolversion.api.FVersionFeatureApi | ||
import com.flipperdevices.bridge.connection.feature.rpc.api.FRpcFeatureApi | ||
import com.flipperdevices.bridge.connection.transport.common.api.FConnectedDeviceApi | ||
import com.flipperdevices.core.data.SemVer | ||
import com.flipperdevices.core.di.AppGraph | ||
import com.flipperdevices.core.log.error | ||
import com.flipperdevices.core.log.info | ||
import com.squareup.anvil.annotations.ContributesMultibinding | ||
import kotlinx.coroutines.CoroutineScope | ||
import javax.inject.Inject | ||
|
||
// TODO move to consts | ||
val API_SUPPORTED_LOAD_FAP = SemVer( | ||
majorVersion = 0, | ||
minorVersion = 18 | ||
) | ||
|
||
@FDeviceFeatureQualifier(FDeviceFeature.APP_START) | ||
@ContributesMultibinding(AppGraph::class, FDeviceFeatureApi.Factory::class) | ||
class FAppStartFeatureFactoryImpl @Inject constructor( | ||
private val factory: FAppStartFeatureApiImpl.InternalFactory | ||
) : FDeviceFeatureApi.Factory { | ||
override suspend fun invoke( | ||
unsafeFeatureDeviceApi: FUnsafeDeviceFeatureApi, | ||
scope: CoroutineScope, | ||
connectedDevice: FConnectedDeviceApi | ||
): FDeviceFeatureApi? { | ||
val versionApi = unsafeFeatureDeviceApi.getUnsafe(FVersionFeatureApi::class) ?: return null | ||
info { "Start request supported state for api level $API_SUPPORTED_LOAD_FAP" } | ||
val isSupported = versionApi.isSupported(API_SUPPORTED_LOAD_FAP) | ||
if (!isSupported) { | ||
error { "Failed init FDeviceColorFeatureApi, because isSupported=false" } | ||
return null | ||
} | ||
val rpcApi = unsafeFeatureDeviceApi.getUnsafe(FRpcFeatureApi::class) ?: return null | ||
return factory( | ||
rpcFeatureApi = rpcApi, | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.