Using the DataLayer code in the Wear OS samples, I...
# compose-wear
n
Using the DataLayer code in the Wear OS samples, I am getting this warning:
This method should only be accessed from tests or within private scope
Should I just ignore it?
a
Which method
n
This one:
Copy code
private fun sendPhoto() {
        lifecycleScope.launch {
            try {
                val image = clientDataViewModel.image ?: return@launch
                val imageAsset = image.toAsset()
                val request = PutDataMapRequest.create(IMAGE_PATH).apply {
                    dataMap.putAsset(IMAGE_KEY, imageAsset)
                    dataMap.putLong(TIME_KEY, Instant.now().epochSecond)
                }
                    .asPutDataRequest()
                    .setUrgent()

                val result = dataClient.putDataItem(request).await()

                Log.d(TAG, "DataItem saved: $result")
            } catch (cancellationException: CancellationException) {
                throw cancellationException
            } catch (exception: Exception) {
                Log.d(TAG, "Saving DataItem failed: $exception")
            }
        }
    }
a
There should be a specific method that warning applies to - is this a code comment or an IDE warning?
n
An IDE warning
on a few code parts
like :
Copy code
.asPutDataRequest()
.setUrgent()
message has been deleted
a
You can use CMD+click to navigate to those methods and see their definition/more info
n
Well it says
@VisibleForTesting
but I'm not sure what to do about it.
I'm currently using the sample to adapt it to my own needs.
a
If it's visible for testing it shouldn't be used except in tests. It's either that it's incorrectly marked as such or the sample should be updated.
n
There are other bits that have the same warnings
a
same deal. If this is a sample on GitHub, please could you open an issue saying that the sample is using code which is marked as visible for testing 🙏
n
ok will do!
a
Ta!
y
But a bug on the sample would be great as we should suppress these warnings also.
n
y
I suspect @Ataul Munim meant here https://github.com/android/wear-os-samples/issues, also that bug seems to be at the top level without a component, so not sure it will get routed correctly. But it should get cleaned up anyway.
a
I'll look tomorrow - thanks for raising!
139 Views