Solution needed to grant appwidget bind permission to phone launchers on AndroidTV firmware so widgets don't crash these launchers

@Gouwa

Hi

You or someone can help with this problem affecting Rockchip and Amlogic devices if using AndroidTV firmware?

Can you add a setting to TvSettings that detect launchers with Home intent and list them for AndroidTV firmwares?
Perhaps if you click on the names of the phone launchers that it automatically grants the launchers the Widget bind permission or if you click on the name of the launcher, perhaps it can just show a quick message on the screen that Widget permissions is going to be granted and you can accept it?

It seems on AndroidTV firmware the Leanback launcher or something restricts phone launchers from getting the widget permission.
It’s the same problem on the Amazon FireTV and the Nvidia Shield.

Read here for more information how they fixed it manually:


I added a init.rc script that fixes the problem but then it runs on every boot, increasing boot time, existing launcher is then killed and restarted and only for launchers I pre-programmed, the command only has to run once not on every boot after the launcher is installed, so a manual setting is better in Android TvSettings perhaps and if users install other new launchers it must also fix the widget service for them or allow them to manually fix it by clicking on launcher name or something.

init.rc file
on property:dev.bootcomplete=1
start Widget_service

service Widget_service /system/bin/Launcher_Daemon
class main
disabled
oneshot
seclabel u:r:init:s0

Launcher_Daemon script file with 755 execute permission(5 pre-grogrammed launcher names added)
#!/system/bin/sh

appwidget grantbind --package amirz.shade --user 0
appwidget grantbind --package org.zimmob.zimlx --user 0
appwidget grantbind --package com.mi.android.globallauncher --user 0
appwidget grantbind --package amirz.rootless.nexuslauncher --user 0
appwidget grantbind --package com.teslacoilsw.launcher --user 0

Copy the 2 files to eg. vendor/opengapps/etc or any folder you choose

In eg. opengapps.mk(or any other make file) add
+ vendor/opengapps/etc/Launcher_Daemon:system/bin/Launcher_Daemon
+ vendor/opengapps/etc/init.rc:system/etc/init/init.rc \

Here is a link to Nova launcher(com.teslacoilsw.launcher )
For Nova Launcher, you have to go in the Appdrawer then the search at the top to search for an app then long press the app icon then select widgets that you then can drag to the homescreen.
https://apkpure.com/nova-launcher/com.teslacoilsw.launcher

Here is a link to Zim Launcher(org.zimmob.zimlx)
With this launcher you can just directly long press on the homescreen and add a widget eg. analog clock.
So perhaps it’s easier to test with it.

If you eg. add a clock widget eg. one from Google Clock https://apkpure.com/clock/com.google.android.deskclock
to them then the launchers crash back to the Leanback launcher.

Also if you root with Magisk and in a terminal type
su
then
appwidget grantbind --package com.teslacoilsw.launcher --user 0
then eg. Nova Launcher can work correctly with the clock widget without crashing.
But on non rooted firmware or not typing su first seems to not work, so this command needs some higher level permission I think. Perhaps a TvSettings menu can automatically get the right permissions and then grant selected phone launcher this permission or it can execute my script with correct permissions then I can just add 20 launcher package names or something if that is too difficult.

So if a TvSettings option can be added for the launcher apps where it detects the package name of selected or clicked launcher and then run
appwidget grantbind --package launcher_package_name–user 0
then it will fix the problem.
But it must run it correctly without users first rooting their device.
Perhaps there is another way in frameworks to add support for /system/bin/appwidget for phone launchers on AndroidTV too so it’s not disabled by default?

Here are apps to change the home launcher too if needed on AndroidTV.
https://apkpure.com/no-me-launcher-manager/com.flea.gsd.flea

I’m trying this on Edge-V but it will be the same problem on Vim3.

Regards

1 Like

If I eg. type in a terminal app
su
then

appwidget grantbind --package com.teslacoilsw.launcher --user 0

then the Nova launcher gets widget permissions correctly.
https://apkpure.com/nova-launcher/com.teslacoilsw.launcher

So I was wondering if there is a way to add a menu setting to TvSettings to execute such command with the right permissions without a user getting root access with Magisk first or using a terminal app?
1 Like