d4rken-org / wakelock-revamp

Rewrite of https://github.com/d4rken/wakelock
GNU General Public License v3.0
142 stars 17 forks source link

Compatibility with Android TV #9

Open Twanislas opened 4 years ago

Twanislas commented 4 years ago

Hi !

It would be very useful to add compatibility with Android TV so users could install the app from the play store on set top boxes instead of sideloading.

Thanks for your consideration :)

Context: https://github.com/JeffLIrion/python-androidtv/issues/18#issuecomment-478183332

d4rken commented 4 years ago

Playstore needs a few extra graphics for Android TV, I can look into that.

We would also need to make sure that the menu can be navigated by remote, I have not looked into how good that currently works. Feel free to help out with that :).

bieniu commented 4 years ago

@d4rken Wakelock menu can be navigated by remote on Xiaomi Mi Box 3 (Android TV 8.0) without any problems. I checked yesterday.

Twanislas commented 4 years ago

+1 on what @bieniu said. I can confirm it works ok on a Mibox S (4) (ATV 9.0). That being said, it's not the perfect interface for ATV but since it's kinda "set it once and forget it" that's pretty ok.

CreaaZ commented 4 years ago

I can confirm it is running on Sony Bravia TV KD-55X8505C as intended. Navigation with remote is also fine - installed via ADB.

magicse commented 4 years ago

After last update (2604) of MiBox S(4) (ATV 9.0), Wakelock not work and MiBox S stay in deep sleep.

potatoxbe commented 4 years ago

After last update (2604) of MiBox S(4) (ATV 9.0), Wakelock not work and MiBox S stay in deep sleep.

Yes same issue here.

keizie commented 4 years ago

After last update (2604) of MiBox S(4) (ATV 9.0), Wakelock not work and MiBox S stay in deep sleep.

FYI, USB Ethernet (connected to MiBox S) LEDs turns on and off soon, periodically. iPhone can connect to MIBOX4 when the time is right.

orholly commented 4 years ago

After last update (2604) of MiBox S(4) (ATV 9.0), Wakelock not work and MiBox S stay in deep sleep.

Yes same issue here.

Me too.

d4rken commented 4 years ago

There is no specific change required in the app. This is likely a ROM change that increases restrictions on battery consumptions. Somewhere in the the system settings is likely a menu where you can exclude wakelock-revamp from these restrictions.

magicse commented 4 years ago

There is no specific change required in the app. This is likely a ROM change that increases restrictions on battery consumptions. Somewhere in the the system settings is likely a menu where you can exclude wakelock-revamp from these restrictions.

Interesting moment - after restart of mi box S with installed and activated WakeLock , wakelock does everything right, and does not allow the device to go into deep sleep ... but it does it only once and after waking up, this does not happen anymore until the next reboot. It looks like the service is not restarting I try recompile wakelock in android studio... but the same.... I know in android 8.0 there are many problems with background services.... on android And I know that people must use foreground service and notify channel....to keep process running, but may be something else in android 9.0 Also I exclude Wakelock from power optimisation.

d4rken commented 4 years ago

It looks like the service is not restarting

Check whether the notification is visible. If it's visible, then the app is doing it's job. If the notification is not visible (and thus the service not started), then there might be an issue.

magicse commented 4 years ago

no any notifications....

magicse commented 4 years ago

Also I found this Android TV: application notifications on O+ Android TV limitations

In case if you will follow any available tutorial to publish notification via notification channel on the Android TV — it will not work. In the logcat you will see the next message:

TVNotifService: skipped notification StatusBarNotification(pkg=com.my.application user=UserHandle{0} id=2 tag=MyChannel key=0|com.my.application|2|MyChannel|1000: Notification(channel=MyChannel pri=0 contentView=null vibrate=null sound=null tick defaults=0x0 flags=0x100 color=0xff048f80 category=sys vis=PUBLIC)) userId: 0

Notification is ignored, this seems totally unexpected to anybody who was working with the notification channels on Android phones, but due to Android TV specific UI/UX — notifications are allowed only for the system white-listed application https://medium.com/@igor.stebliy/android-tv-application-notifications-on-o-c6820ada2086

d4rken commented 4 years ago

That could be an explanation... We can't modify the ROM and whitelist the package... :thinking:

magicse commented 4 years ago

Here is example of notification wrapper for android Tv https://medium.com/@igor.stebliy/android-tv-application-notifications-on-o-c6820ada2086

d4rken commented 4 years ago

You will need to have access to the AOSP sources to white-list your application and configure proper access to the system API.

magicse commented 4 years ago

ok

saarsinai commented 4 years ago

mi box s, latest android version (9), wakelock side loaded, gave all permission, load on startup, power optimization turned off, none made the mi box stay awake after pressing the power button

arefin932 commented 4 years ago

I am getting "Ethernet not Connected" error every time my Xiaomi Mi Box S wakes up from sleep. I have to unplug and replug the USB Ethernet adapter or reboot the box to make the USB Ethernet recognized. Wakelock was working fine until I upgraded my Box to Android 9 (2604). I have done factory reset on my device after the upgrade but no luck. I have "load on startup" checked in the wakelock with the following options, power optimization turned off for Wakelock on the Mibox. But still no luck.
https://imgur.com/S0kHOY8

magicse commented 4 years ago

Powermanager has very aggressive save mode. And Wfi, CEC, USB, partial_wake_locks not work in sleep mode at all! (exclude Bluetooth) Thant is why Wifi (Chromecast) or phone app remote control or CEC can't wake up device from sleep mode.

Here link to bug reports BUG REPORT Mi Box S.... write there about this problem

VoyteckPL commented 4 years ago

I have usb dongle remote control which works great when Mi Box S is turned on. I can turn it off via Usb remote but I can't turn it on back again. Only bluetooth remote can turn Mi Box S on.

darkkatarsis commented 4 years ago

Same here. After updating Mi box to android 9, wakelock stopped working. Someone has already found a workaround?

Ps. eth from usb not working either

IgorEisberg commented 4 years ago

Yep, same issue with Mi Box 3 after update to Android 9. Basically, rendered a universal wireless+IR remote useless, including Xiaomi's own Mi Remote app. (same issue as @VoyteckPL described, no matter what sent the IR signal to put the Mi Box to sleep) You will also see in that broken sleep state that the remote is losing connection with the Mi Box completely, and the remote's LED will be flashing as if it's trying to establish a connection with the dongle to no avail. Things I noticed:

  1. If you enable USB debugging, go into this broken sleep state, then try to connect the Mi Box to a PC - the PC will report "USB device not recognized" and ADB will show no devices connected. Once you wake the device with the Bluetooth remote and reconnect the USB cable to the PC, the Mi Box is recognized on PC again.
  2. If you enable USB debugging, connect the Mi Box to a PC while the device is awake, you will be able to use the IR remote normally with no issues at all - both going to sleep and waking up work normally until you disconnect the Mi Box from the PC.
Cr0WD commented 4 years ago

Any solution ?

arefin932 commented 4 years ago

I ended us using the following USB ethernet adapter and it works flawlessly. Only a USB adapter with AX88179 chipset works flawlessly with Android TV OS and the uGreen one has AX88179 chipset. Hope it helps.

https://www.amazon.com/dp/B00LLUEJFU

darkkatarsis commented 4 years ago

This is not a solution, if you have a connected USB adapter, you cannot use the ADB Debugger function.

tpaniaki commented 3 years ago

Same on MiTV-MSSP2 (Android 9) with battery optimisation disabled.

Xitro01 commented 2 years ago

Would love to be able to install it from the store for my Mi TV Box, not a big fan of sideloading stuff. Hopefully someone can help out with this. I'm not a programmer myself, otherwise I would've helped in my spare time.

ihrapsa commented 2 years ago

Would love to be able to install it from the store for my Mi TV Box, not a big fan of sideloading stuff. Hopefully someone can help out with this. I'm not a programmer myself, otherwise I would've helped in my spare time.

Unfortunately, the app is not working on Mi box anymore (or any other android tv I know of).

joshuaspence commented 2 years ago

Would love to be able to install it from the store for my Mi TV Box, not a big fan of sideloading stuff. Hopefully someone can help out with this. I'm not a programmer myself, otherwise I would've helped in my spare time.

Unfortunately, the app is not working on Mi box anymore (or any other android tv I know of).

It works for me on the latest version of AndroidTV on a Hitachi device.

Xitro01 commented 2 years ago

Would love to be able to install it from the store for my Mi TV Box, not a big fan of sideloading stuff. Hopefully someone can help out with this. I'm not a programmer myself, otherwise I would've helped in my spare time.

Unfortunately, the app is not working on Mi box anymore (or any other android tv I know of).

That sucks, any alternatives available?

magicse commented 2 years ago

The alternative is to require an item in the settings menu. Some developers (for example, Xiaomi) simply blocked this item for no reason. It is for this reason that I abandoned the Xiaomi Mi box S4 and switched to another manufacturer.

Note. The deep standby mode turning off more STB functions (Google services, messengers, Internet, etc.) and results in longer activation latency. screen_29 screen_30

lollilol commented 1 year ago

Any update on this? So far the problem is the notification? Because it's handled differently in Android TV compared to normal Android?