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

Add camera tile to Wear OS #3870

Merged
merged 10 commits into from
Sep 17, 2023

Conversation

jpelgrom
Copy link
Member

@jpelgrom jpelgrom commented Sep 15, 2023

Summary

Add a camera tile to the Wear OS app which will display a snapshot of a camera. This includes logged out/empty states, UI to customize the tile behavior/camera selection, and support for multiple tiles.

While there are a lot of changes, code is primarily based on existing tiles (shortcuts for multiple tiles functionality, template for layout and refresh interval) and phone camera widget. As a result, some code is moved around to limit duplicate code. Cameras also aren't supported elsewhere in the app so I'm adding code to store the initial states on first load as this is required to select one, should be fine as updates aren't required.

Implements #3763 as far as I'm concerned - matching default Home Assistant camera functionality within the constraints imposed on tiles.

Screenshots

Tile:

Preview Empty Single Multiple
List of tiles on watch including 'Camera' Tile with text 'Edit the tile settings and select a camera to show' with a refresh button Tile with a picture of the Alster Fountain in Hamburg, Germany filling the watch screen with black bars on the left and right, as an example of a camera, refresh button overlaid at the bottom Two camera tiles visible side by side

In-app settings:

Main list No tiles Tiles list Individual tile
'Tile settings' header followed by 'Camera tile' option 'Camera tiles' screen with a message 'There are no camera tiles added yet - add one from the watch face to set it up' 'Camera tiles' screen with three chips labeled 'Camera tile #n' and the entity name 'Camera tile' screen showing the settings for an individual camera: select entity and refresh interval

Link to pull request in Documentation repository

Documentation: home-assistant/companion.home-assistant#984

Any other notes

 - Create UI to set camera tile settings
 - Reuse shortcut tile settings activity as a general tile settings activity
 - On initial load also create a list of camera entities to make it possible to select them without showing up elsewhere in the app
 - Add text to empty state instructing the user to set a camera
 - Update tile preview images
@dshokouhi
Copy link
Member

So I loaded up the debug APK on my phone and watch. First I went to settings and saw the no camera tiles added message. Then I added a tile and it told me to login eventhough I was already logged in. Then going back to settings I am still told I need to add a camera tile despite 1 already being added.

image

image

let me know if there is any logging needed but my setup is kinda stuck like this now

@jpelgrom
Copy link
Member Author

Hmm that's odd. It sounds like somehow onTileAddEvent wasn't called? Does it resolve itself if you remove and add the tile again?

@dshokouhi
Copy link
Member

Hmm that's odd. It sounds like somehow onTileAddEvent wasn't called? Does it resolve itself if you remove and add the tile again?

no it does not, the messaging is still stuck. Tile still tells me to login and settings tells me there are no tiles added

@jpelgrom
Copy link
Member Author

Pushing a fix for telling you login is required while already logged in. Still not sure why the tile add didn't register, if you still have issues with the latest commit could you check logcat, and try editing it from the watch face/tiles list on your watch?

@dshokouhi
Copy link
Member

Will recheck when the build is done but saw this error show up for a tile that has been setup but refuses to show the image

09-15 09:38:21.593 20042-20042 TileService             io....stant.companion.android.debug  E  RemoteException while returning resources payload
                                                                                                    android.os.TransactionTooLargeException: data parcel size 863004 bytes
                                                                                                    	at android.os.BinderProxy.transactNative(Native Method)
                                                                                                    	at android.os.BinderProxy.transact(BinderProxy.java:571)
                                                                                                    	at androidx.wear.tiles.ResourcesCallback$Stub$Proxy.updateResources(ResourcesCallback.java:109)
                                                                                                    	at androidx.wear.tiles.TileService.updateResources(TileService.java:539)
                                                                                                    	at androidx.wear.tiles.TileService$TileProviderWrapper.lambda$onResourcesRequest$2(TileService.java:403)
                                                                                                    	at androidx.wear.tiles.TileService$TileProviderWrapper$$ExternalSyntheticLambda7.run(Unknown Source:4)
                                                                                                    	at android.os.Handler.handleCallback(Handler.java:938)
                                                                                                    	at android.os.Handler.dispatchMessage(Handler.java:99)
                                                                                                    	at android.os.Looper.loop(Looper.java:223)
                                                                                                    	at android.app.ActivityThread.main(ActivityThread.java:7660)
                                                                                                    	at java.lang.reflect.Method.invoke(Native Method)
                                                                                                    	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
                                                                                                    	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)

sometimes I see a blank image and other times I see the tile has not been setup message

@dshokouhi
Copy link
Member

Latest build now resolves the tile log out issue :) will retest when the resizing issue is fixed

 - Scale the received image to a bitmap that does not exceed the screen size to ensure timely refreshes and prevent parcels that are too big
@jpelgrom
Copy link
Member Author

Resizing added, also feels a bit faster here but that could be random.

@dshokouhi
Copy link
Member

Resizing added, also feels a bit faster here but that could be random.

yup I no longer see an error and every camera I have is able to load an image. It does indeed feel faster for me too!

Copy link
Member

@dshokouhi dshokouhi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Been testing the latest build for past 30 hours with 2 camera tiles and default refresh interval and don't experience any extra drain! Great work!

@JBassett JBassett merged commit 2c20baf into home-assistant:master Sep 17, 2023
4 checks passed
@jpelgrom jpelgrom deleted the wear-camera-snapshot-tile branch September 17, 2023 21:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants