0

I have a media player application.

On my phone, the player is stable and works as I expected.

However on android tv box, it stops after some time. (Rockchip TV BOX Android 8.1.0 API 25)

I have searched that I need to add some configurations to make it work on android tv boxes.

I have followed these steps in here = https://developer.android.com/training/tv/start/start.html#prerequisites

However still the player stops after some time.

This is the link of the log file from the start to the time that it is paused by the OS, I recommend to review this:

https://www.scribd.com/document/442914371/Hilallogcat-Tvbox-Sem-Log

There are some suspicious parts in the log file:

01-13 21:24:00.009   454   454 W System.err: java.io.FileNotFoundException: /dev/fd628_dev (Permission denied)
01-13 21:24:00.009   454   454 W System.err:    at java.io.FileOutputStream.open(Native Method)
01-13 21:24:00.009   454   454 W System.err:    at java.io.FileOutputStream.<init>(FileOutputStream.java:221)
01-13 21:24:00.010   454   454 W System.err:    at java.io.FileOutputStream.<init>(FileOutputStream.java:108)
01-13 21:24:00.010   454   454 W System.err:    at com.android.server.NetworkTimeUpdateService.fd628_display(NetworkTimeUpdateService.java:439)
01-13 21:24:00.010   454   454 W System.err:    at com.android.server.NetworkTimeUpdateService$4.onReceive(NetworkTimeUpdateService.java:522)
01-13 21:24:00.010   454   454 W System.err:    at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:1122)
01-13 21:24:00.010   454   454 W System.err:    at android.os.Handler.handleCallback(Handler.java:755)
01-13 21:24:00.011   454   454 W System.err:    at android.os.Handler.dispatchMessage(Handler.java:95)
01-13 21:24:00.011   454   454 W System.err:    at android.os.Looper.loop(Looper.java:154)
01-13 21:24:00.011   454   454 W System.err:    at com.android.server.SystemServer.run(SystemServer.java:358)
01-13 21:24:00.012   454   454 W System.err:    at com.android.server.SystemServer.main(SystemServer.java:225)
01-13 21:24:00.012   454   454 W System.err:    at java.lang.reflect.Method.invoke(Native Method)
01-13 21:24:00.012   454   454 W System.err:    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912)
01-13 21:24:00.012   454   454 W System.err:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:802)

Also like this:

01-13 21:24:12.227  1595  1606 W art     : Suspending all threads took: 16.847ms

This one:

01-13 21:26:17.182   193  6998 E RockFFPlayer: file_read: offset=9473373, c->offset=0, c->length=9473373

This one:

01-13 21:26:17.970   193  7000 W AudioDecoder: audio decode error send exception error

However I could not figure out the reason.

UPDATE:

After the suggestion of @CuriousMind I have added setTime to my application class. But we could not avoid the FileNotFoundException.

This is the log file when I setTime at the beginning of the application:

https://www.scribd.com/document/442936061/hilallogcat-tvbox-setTime

UPDATE 2:

Inside of the /system/etc/ folder:

NOTICE.html.gz
audio_policy.conf
event-log-tags
init/
media_codecs_performance.xml
mkshrc
ppp/
recovery-resource.dat
smbpasswd
wifi/
alarm_filter.xml
bluetooth/
firmware/
media_codecs.xml
media_codecs_rk_vpu.xml
operator_table
preferred-apps/
seccomp_policy/
smbusers
apns-conf.xml
clatd.conf
fonts.xml
media_codecs_google_audio.xml
media_profiles_default.xml
package_performance.xml
preloaded-classes
security/
spn-conf.xml
audio_effects.conf
compiled-classes
hosts
media_codecs_google_video.xml
mixer_paths.xml
permissions/
public.libraries.txt
smb.conf
sysconfig/
Hilal
  • 902
  • 2
  • 22
  • 47
  • 1
    You could try this, just to debug it: When your app launches, set the time. According to the docs, it should disable the setTime void setTime (long millis) Set the system wall clock time. This method does not guarantee persistence past reboot. This method also disables automatic time updates from NTP. One thing that could help debugging (in this case, checking what is happening in line 439 of the NetworkTimeUpdateService, would be to know the android flavour/version you are working on. Can you add that to the question? – Curious Mind Jan 14 '20 at 16:33
  • @CuriousMind thank you so much for your reply. So I should only setTime at the first of my application for debugging, right? – Hilal Jan 14 '20 at 17:17
  • 1
    Yes, and wait to see if it happens again. Do it programatically.. If it doesn't happen again, the issue is in the NetworkTimeUpdateService. I would advise you also to check the flavour or api number you are using so you can check the correct source of NetworkTimeUpdateService. If you read that line referred in the log - .fd628_display(NetworkTimeUpdateService.java:439) - Line 439... perhaps we can get something out of there. The surface problem is that the code is trying to access some file and aint got permissions (first lines of the stacktrace).. – Curious Mind Jan 14 '20 at 17:21
  • 1
    @CuriousMind I have added these lines `Date d = new Date();` `d.setTime(1000);` inside the Application class. But still I see those lines when I run the command `./adb logcat -d *:I` I will share the log file again. Or maybe I should have added those lines into the service classes? Because there is a foreground service inside of the app. – Hilal Jan 14 '20 at 18:03
  • 1
    Kindly check this: https://developer.android.com/reference/com/google/android/things/device/TimeManager There's an example to setTime using TimeManager. Cannot copy and paste it here because of the comment length. That's the method that should disable NTP sync. Dont forget to add the permissions. And if possible check which api are you using... should help. – Curious Mind Jan 15 '20 at 13:53
  • 1
    You can disable auto time in clock settings, I think it disables the polling from ntp. Recheck it after disabling please. – Curious Mind Jan 15 '20 at 14:08
  • 1
    @CuriousMind My device API is 25 I guess it does not provide min sdk for android things library. Can I use another method to setTime programmatically? – Hilal Jan 15 '20 at 15:09
  • 1
    @CuriousMind I tried to use AlarmManager but that never allow me to setTime. Accordingly it only can be permitted for system applications. – Hilal Jan 15 '20 at 15:44
  • 1
    @CuriousMind I have found this but still could not find out a way to disable that https://stackoverflow.com/questions/14381005/is-android-using-ntp-to-sync-time – Hilal Jan 15 '20 at 16:28
  • "If the automatic time sync option in the system settings is checked and no NITZ time service is available then the time will be synchronized with the NTP server from com.android.internal.R.string.config_ntpServer." -> I was saying to turn it off in the system settings, check the clock and turn that feature off. – Curious Mind Jan 15 '20 at 16:58
  • 1
    @CuriousMind I have already turned it off but it still shows the same `java.io.FileNotFoundException: /dev/fd628_dev (Permission denied)` – Hilal Jan 15 '20 at 17:00
  • 1
    Can you read /system/etc/gps.conf ? Something like cat /system/etc/gps.conf Another thing, are you writing something to the filesystem somewhere in your app? I'm running out of ideas. – Curious Mind Jan 15 '20 at 17:02
  • @CuriousMind There is no `gps.conf` file under /system/etc/. I will share what does that folder have in my post – Hilal Jan 15 '20 at 17:09
  • 1
    @CuriousMind Actually I have searched using this command in the / folder => `ls -lR / | grep 'gps.conf'` but it could not find. I think this device does not have that file. – Hilal Jan 15 '20 at 17:21
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/206018/discussion-between-curious-mind-and-hilal). – Curious Mind Jan 15 '20 at 17:25

1 Answers1

0

I have found out that since my box does not have leds it cannot find the file fd628 because it only exists on devices that has leds as I understand from here:

https://github.com/LibreELEC/linux_openvfd

So I tried to use a box with leds that I already have which is TX9 and this error did not show up and the box never stopped.

But still I do not know what is calling that fd628 file and I could not avoid that but at least I know why the app stops.

Hilal
  • 902
  • 2
  • 22
  • 47