Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated WearDataLayerAppHelper methods #2446

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
2 changes: 0 additions & 2 deletions datalayer/watch/api/current.api
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ package com.google.android.horologist.datalayer.watch {
method public suspend Object? markComplicationAsDeactivated(int complicationInstanceId, kotlin.coroutines.Continuation<? super kotlin.Unit>);
method public suspend Object? markSetupComplete(kotlin.coroutines.Continuation<? super kotlin.Unit>);
method public suspend Object? markSetupNoLongerComplete(kotlin.coroutines.Continuation<? super kotlin.Unit>);
method @Deprecated public suspend Object? markTileAsInstalled(String tileName, kotlin.coroutines.Continuation<? super kotlin.Unit>);
method @Deprecated public suspend Object? markTileAsRemoved(String tileName, kotlin.coroutines.Continuation<? super kotlin.Unit>);
method @CheckResult public suspend Object? startCompanion(String nodeId, kotlin.coroutines.Continuation<? super com.google.android.horologist.data.AppHelperResultCode>);
method public suspend Object? updateInstalledTiles(kotlin.coroutines.Continuation<? super kotlin.Unit>);
property public kotlinx.coroutines.flow.Flow<java.util.Set<com.google.android.gms.wearable.Node>> connectedAndInstalledNodes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,28 +151,6 @@ public class WearDataLayerAppHelper internal constructor(
return sendRequestWithTimeout(nodeId, LAUNCH_APP, request.toByteArray())
}

/**
* Marks a tile as installed. Call this in [TileService#onTileAddEvent]. Supplying a name is
* mandatory to disambiguate from the installation or removal of other tiles your app may have.
*
* @param tileName The name of the tile.
*/
@Deprecated("Please use updateInstalledTiles instead")
public suspend fun markTileAsInstalled(tileName: String) {
surfacesInfoDataStore.updateData { info ->
val tile = tileInfo {
timestamp = System.currentTimeMillis().toProtoTimestamp()
name = tileName
}
info.copy {
val exists = tiles.find { it.equalWithoutTimestamp(tile) } != null
if (!exists) {
tiles.add(tile)
}
}
}
}

/**
* Updates the list of currently installed tiles on this watch.
*
Expand Down Expand Up @@ -269,29 +247,6 @@ public class WearDataLayerAppHelper internal constructor(
}
}

/**
* Marks a tile as removed. Call this in [TileService#onTileRemoveEvent]. Supplying a name is
* mandatory to disambiguate from the installation or removal of other tiles your app may have.
*
* @param tileName The name of the tile.
*/
@Deprecated("Please use updateInstalledTiles instead")
public suspend fun markTileAsRemoved(tileName: String) {
surfacesInfoDataStore.updateData { info ->
val tile = tileInfo {
timestamp = System.currentTimeMillis().toProtoTimestamp()
name = tileName
}
info.copy {
val filtered = tiles.filter { !tile.equalWithoutTimestamp(it) }
if (filtered.size != tiles.size) {
tiles.clear()
tiles.addAll(filtered)
}
}
}
}

/**
* Marks a complication as activated. Call this in
* [ComplicationDataSourceService.onComplicationActivated].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,43 +77,6 @@ class WearDataLayerAppHelperTest {
coroutineContext.cancelChildren()
}

@Test
fun testTiles() = runTest {
val context = ApplicationProvider.getApplicationContext<Application>()
val registry = WearDataLayerRegistry.fromContext(context, this)

val testDataStore: DataStore<SurfacesInfo> =
DataStoreFactory.create(
scope = this,
produceFile = { context.dataStoreFile("testTiles") },
serializer = SurfacesInfoSerializer,
)

val helper = WearDataLayerAppHelper(
context = context,
registry = registry,
appStoreUri = null,
scope = this,
surfacesInfoDataStoreFn = { testDataStore },
)

val infoInitial = testDataStore.data.first()
assertThat(infoInitial.tilesList).isEmpty()

helper.markTileAsInstalled("my.SampleTileService")

val infoUpdated = testDataStore.data.first()
assertThat(infoUpdated.tilesList).hasSize(1)
assertThat(infoUpdated.tilesList.first().name).isEqualTo("my.SampleTileService")

helper.markTileAsRemoved("my.SampleTileService")

val infoReverted = testDataStore.data.first()
assertThat(infoReverted.tilesList).isEmpty()

coroutineContext.cancelChildren()
}

@Test
fun testComplications() = runTest {
val context = ApplicationProvider.getApplicationContext<Application>()
Expand Down
Loading