GithubHelp home page GithubHelp logo

Comments (27)

ADeadTrousers avatar ADeadTrousers commented on May 28, 2024 1

It fucking works now!!!
Only modification needed in the source code was to set the conversion to 100. Everything else I will keep to the opensource standard provided by LOS.

I now just need to include a script which changes the permissions of /dev/fm to 666. The ueventd.rc script on vendor is currently responsible for setting the permission to 660 cause the fmradio device is a loaded kernel module (lsmod). So I need a way to change that right after ueventd.rc is executed. Do you know a way to achieve that?

Also maybe I'm going to combine custom.cpp and fmlib_cust.h into my very own fmlibcust.so so I can modify the settings provided to libfmjni.so. (e.g. lower the frequency band from 8750 to 7600 as it's hinted as the lowest value in the logfiles)

from android_device_unihertz_atom_lxl.

shadowofleaf96 avatar shadowofleaf96 commented on May 28, 2024 1

you did it nice

from android_device_unihertz_atom_lxl.

SepticFuddy avatar SepticFuddy commented on May 28, 2024

I did a little digging to try to save you some time. It seems that AOSP has its own FM Radio app and it seems to be what came with the XL, since it is named com.android.fmradio according to logcat. From reading the LOS Reddit, Gerrit, and Github, it seems that it should be included already in 17.1. If you don't already have it, I'll have to leave it to you to figure out what to do about it.

from android_device_unihertz_atom_lxl.

ADeadTrousers avatar ADeadTrousers commented on May 28, 2024

I'm already ahead of you: 081c9229aafea14388ef2570e3885b1735b32e46
But it keeps force closing, so I need to take some logs to see what is causing them.

from android_device_unihertz_atom_lxl.

ADeadTrousers avatar ADeadTrousers commented on May 28, 2024

The FMRadio uses a library called libfmjni.so and this in turn requires a libfmcust.so to be present.
libfmjni.so is part of AOSP and built alongside FMRadio.
libfmcust.so seems to be a custom vendor specific library.
Searching for this particular name I found many mentions of MTK devices (in fact almost all mention that) and that it needs to be copied over from stock ROM but it's not there on the Atom XL. So my best guess is, that its functionality was patched right into libfmjni.so (which is present on the phone) to not needing an additional library. But according to its timestamp it is nearly eleven years old.
Before I use this methusalem I want to make sure that I'm not overlooking something else.
Can you please do a logcat during the start of the FMRadio app? I'm especially interested in the lines containing FMLIB_JNI. These are the ones that are being written by libfmjni.so and if it wasn't changed too much it should tell us what is going on in detail.

from android_device_unihertz_atom_lxl.

SepticFuddy avatar SepticFuddy commented on May 28, 2024

fmlib.txt
I took it from the app reader filtering for "fmlib"

from android_device_unihertz_atom_lxl.

ADeadTrousers avatar ADeadTrousers commented on May 28, 2024
[01-27 12:12:33.516 12613:12613 I/FMLIB_CORE]
FMR idx = 0

[01-27 12:12:33.516 12613:12613 I/FMLIB_CUST]
CONSYS CHIP ID=mt6631

[01-27 12:12:33.516 12613:12613 I/FMLIB_CORE]
OK

hmmm... that is the interesting part. The LOG_TAG (internal variable for the logging according to the source code) is being switched FMLIB_CORE > FMLIB_CUST > FMLIB_CORE. This suggest that there is in fact another player on the field. All other logging messages I was able to find in the source code. Only the FMLIB_CUST part seems to have another origin.
But there is another clue: In the source code, right before the OK message there should be a Go to run cust function message which isn't in the logcat. This tells me it's either an older version or being tinkered with.

from android_device_unihertz_atom_lxl.

ADeadTrousers avatar ADeadTrousers commented on May 28, 2024

Looking into both libfmjni.so with an hex editor hardens my suspicion that the source code was modified:
linage version only includes the Tags FMLIB_COM, FMLIB_CORE and FMLIB_JNI.
stock version also includes FMLIB_CUST.
I will try to find something else regarding CONSYS CHIP ID=mt6631. Maybe there is some other device with a libfmcust.so for this chip we could use. Otherwise I will try to use the stock library.

from android_device_unihertz_atom_lxl.

ADeadTrousers avatar ADeadTrousers commented on May 28, 2024

Why should it be easy?
LOS FMRadio + LOS libfmjni.so + libfmcust.so (from another mt6771) = App starts but not working, permission error in log
LOS FMRadio + Stock libfmjni.so = App crashes, general protection fault
Stock FMRadio + Stock ibfmjni.so = App crashes, missing resources (drawable etc.)
Found one resource file but that's explicitly for "mediatek" so my hopes are really low on this one,
If that's not helping I'm back on the LOS FMRadio and either trying to find other ibfmcust.so or fixing the permissions.

from android_device_unihertz_atom_lxl.

shadowofleaf96 avatar shadowofleaf96 commented on May 28, 2024

Im Working on Fixing Radio FM in UMIDIGI F1 PLAY in LOS 17.1
i think it is not a stock ordinary fm radio, it is a custom app to work on mediatek so prebuilt is only solution cause we dont have source for that
however logcat show me that i need com.agold.server.aservicemanager
i dont know if it is an mediatek app or mediatek framework

from android_device_unihertz_atom_lxl.

ADeadTrousers avatar ADeadTrousers commented on May 28, 2024

Im Working on Fixing Radio FM in UMIDIGI F1 PLAY in LOS 17.1
i think it is not a stock ordinary fm radio, it is a custom app to work on mediatek so prebuilt is only solution cause we dont have source for that
however logcat show me that i need com.agold.server.aservicemanager
i dont know if it is an mediatek app or mediatek framework

Not quite:
Mediatek/Stock ROM if it is Android 10 uses modified libfmjni.so and a CONSYS service(?) to communicate with /dev/fm.
Mediatek/Stock ROM if it is Android 9 uses vendor provided libfmcust.so to communicate directly with /dev/fm.
LineageOS (and AOSP) relies on libfmcust.so.

The FMradio app itself should be AOSP in most parts. The communication with the device is outsourced to libfmjni.so. Maybe mediatek did a little bit of modifications because I run into a ressource not found error. So my guess is that the rssource files (*-res.apk) of LOS and Mediatek/AOSP differ somehow.

com.agold.* is a component supplier from china for mediatek I guess. They also made the intercom app for the DMR of the Atom XL.

If you get lucky with the stock app please let me know.
Also if I find anything usefull on the AOSP front (libfmcust.so) I'll let you know.

from android_device_unihertz_atom_lxl.

shadowofleaf96 avatar shadowofleaf96 commented on May 28, 2024

after further investagtion i manage to get fm radio working (no dev/fm permission issue) but sound on the app is not working (speaker or earpiece)
for the fix
you need stock rom fm radio app (android 10)
and libfmjni and libfmcust from android 9 (cause my stock rom is android 9)
and some reverse engineering of the stock rom framework.jar
i will commit the fix soon

from android_device_unihertz_atom_lxl.

ADeadTrousers avatar ADeadTrousers commented on May 28, 2024

#7

from android_device_unihertz_atom_lxl.

ADeadTrousers avatar ADeadTrousers commented on May 28, 2024

Stock FMRadio seems to be working now: 607294e
The frequency can be set and RDS receives current song title information from the stations.
BUT no sound from headphones or speakers.

from android_device_unihertz_atom_lxl.

ADeadTrousers avatar ADeadTrousers commented on May 28, 2024

With the changes on
https://github.com/ADeadTrousers/android_device_Unihertz_Atom_LXL/tree/fmradio
I was able to get a little bit further on my goal of /dev/fm working together with LOS FMradio app.

Currently I need to manually change the mode on /dev/fm from 660 to 666 otherwise I get a permission denied.
After doing that the device is at least reachable for the LOS FMradio app.
Next hurdle is FMLIB_CORE: FMR_pwr_up error freq: 1000

from android_device_unihertz_atom_lxl.

shadowofleaf96 avatar shadowofleaf96 commented on May 28, 2024

i think you should change the power frequency to the number that it is running in stock app (i think is 100) in jni folder of fm radio

from android_device_unihertz_atom_lxl.

ADeadTrousers avatar ADeadTrousers commented on May 28, 2024

According to the libfmcust.so I use (it's from an Android 9 device) the chip is detected with

FMLIB_CORE: FMR_get_cfgs successfully. chip: 0x6631, lband: 8750, hband: 10800, seek_space: 1, max_scan_num: 80

Looking into @SepticFuddy logfile the correct settings for our devices must be

FMR_get_cfgs successfully. chip: 0x6631, lband: 7600, hband: 10800, seek_space: 1, max_scan_num: 40

And looking further down

powerUp, [freq=88]
FMR_pwr_up,[freq=8830]

Comparing that with powerUp inside libfmjni.cpp we need a factor 100 conversion and not only 10.

tmp_freq = (int)(freq * 10); //Eg, 87.5 * 10 --> 875

from android_device_unihertz_atom_lxl.

shadowofleaf96 avatar shadowofleaf96 commented on May 28, 2024

yes that what i was referring to it and you can see it also in Fmutils.java

public static final int DEFAULT_STATION = 1000;
public static final float DEFAULT_STATION_FLOAT = computeFrequency(DEFAULT_STATION);
// maximum station frequency
private static final int HIGHEST_STATION = 1080;
// minimum station frequency
private static final int LOWEST_STATION = 760;

you can use this reverse engineered stock fm radio source code to see difference between the stock and lineage os code
https://www.mediafire.com/file/27r236e66aqgo9w/FMRadio.rar/file

from android_device_unihertz_atom_lxl.

ADeadTrousers avatar ADeadTrousers commented on May 28, 2024

Just merged my branch for fmradio with master
683c285

from android_device_unihertz_atom_lxl.

rumplestilzken avatar rumplestilzken commented on May 28, 2024

yes that what i was referring to it and you can see it also in Fmutils.java

public static final int DEFAULT_STATION = 1000; public static final float DEFAULT_STATION_FLOAT = computeFrequency(DEFAULT_STATION); // maximum station frequency private static final int HIGHEST_STATION = 1080; // minimum station frequency private static final int LOWEST_STATION = 760;

you can use this reverse engineered stock fm radio source code to see difference between the stock and lineage os code https://www.mediafire.com/file/27r236e66aqgo9w/FMRadio.rar/file

You wouldn't happen to have that FMRadio.rar file would you?

from android_device_unihertz_atom_lxl.

ADeadTrousers avatar ADeadTrousers commented on May 28, 2024

I'm not sure if they are from that particular rar file but yes I've got some source files which should allegedly be from mediatek.
If you'd contact me via my email I can send it to you if you'd like to have them.

from android_device_unihertz_atom_lxl.

CANALLA avatar CANALLA commented on May 28, 2024

Hello everyone, I am trying to make the radio work on a device mt6627 chip, according to your method I have made it work but it does not change the station, it always stays on the same, everything else works, sound, rec... ok.
I have found a selinux permission error when dealing with a firmware file that is in the vendor partition and I don't know if this is the error or if it is something else but I don't know how to solve it, in case someone understands and can suggest a fix in the selinux configuration, to see if the error is there or if there is more

04-03 02:06:37.081 4867 4867 I FmRadioServiceT: type=1400 audit(0.0:201): avc: denied { read } for name="mt6627_fm_v1_patch.bin" dev="mmcblk0p29" ino=281 scontext=u:r:system_app:s0 tcontext=u:object_r:vendor_file:s0 tclass=file permissive=1

Thanks in advance

from android_device_unihertz_atom_lxl.

rumplestilzken avatar rumplestilzken commented on May 28, 2024

from android_device_unihertz_atom_lxl.

ADeadTrousers avatar ADeadTrousers commented on May 28, 2024

Hello everyone, I am trying to make the radio work on a device mt6627 chip, according to your method I have made it work but it does not change the station, it always stays on the same, everything else works, sound, rec... ok. I have found a selinux permission error when dealing with a firmware file that is in the vendor partition and I don't know if this is the error or if it is something else but I don't know how to solve it, in case someone understands and can suggest a fix in the selinux configuration, to see if the error is there or if there is more

04-03 02:06:37.081 4867 4867 I FmRadioServiceT: type=1400 audit(0.0:201): avc: denied { read } for name="mt6627_fm_v1_patch.bin" dev="mmcblk0p29" ino=281 scontext=u:r:system_app:s0 tcontext=u:object_r:vendor_file:s0 tclass=file permissive=1

Thanks in advance

The thing with changing selinux on the vendor partition is that you'd need to change quite a bit to just simply add one single rule. All the cil files have to be hashed and signed off. The "easier" approach would be to utilize the LOS app like I did. This way It can be included either in system or product and you'd even be able to add additional features to the app.

from android_device_unihertz_atom_lxl.

CANALLA avatar CANALLA commented on May 28, 2024

I'm using:
-lineage 17.1, without include vendor build
-lineage (FMRadio + libfmjni)
-libfmcust(ADeadTrousers)
-fmradio and sepolicy and libfm_jni patches found here:

683c285

persist.vendor.connsys.fm_chipid=mt6627 added in system.prop, otherwise it couldn't find chip 0xffffffff

With this, the fm radio turns on and off correctly, the sound is heard through the headphones and through the speakers, it records and the recorded audio is heard correctly.
The name of the station is not visible.
Apparently it scans many stations but only one station is heard and changing from the list of stations found only the same one is heard.
the two buttons for small jump and big jump do not advance in the search or change the frequency, although in the logcat it seems that they change the frequency but the sound, after a small mute, stays on the same station and the same is always heard.
In short, although the numbers change visually on the display, only one is heard.
dmesg.log
logcat.txt
scan.txt

from android_device_unihertz_atom_lxl.

ADeadTrousers avatar ADeadTrousers commented on May 28, 2024

Ok sorry, but because you mentioned vendor I automatically assumed you use the stock fm radio app.

Anyway. Maybe this might not be too far off. As your vendor partition apparently includes a "FmRadioService" it might also hold the (exclusive?) access to the fmdevices control interface. So that the LOS libfmjni.so cannot change the settings.

I'd suggest you try to figure out which service that is and stop it via adb or a shell app with su access. After that you should be able to change the station in the los app. Next would be to figure out a way to stop this service during the phone booting.

from android_device_unihertz_atom_lxl.

CANALLA avatar CANALLA commented on May 28, 2024

Investigating the service I found a wmt_loader in dmesg.log that is loaded by a wmt_drv.ko driver, which in turn is loaded by fm_drv.ko, which in turn is only started at startup if the vendor.conssys.driver service is active in init.fm.rc..., but deactivating this flag the fm driver must be loaded by hand but it calls wmt_ko anyway.
This service and subsequent ones find the chipid 0x6763 in my device, for both fm, wifi, gps, bluetooth, fm, I have looked at a combo_consys in some source code of some mediatek kernel. Although my fm firmware is for the mt6627.
I am going to add a define for 0x6763 and a fake_struct in libfmcust to indicate the configuration of 0x6627,, change the vendor.connsys.fm_chipid to mt6763,
to see if the fm driver recognizes the new libfmcust and still uses firmware 0x6627.

from android_device_unihertz_atom_lxl.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.