yashsingh1/xdaforums huggingface dataset:
[Sony Cross-Device General] serajr:
Maybe we could listen to property

sys.boot_completed

(on property:sys.boot_completed=1) and trigger another script to remove/recreate that file.

Or still with the init.ta.sh, but with parameters in it to perform things, like:

exec u:r:init:s0 -- /init.ta.sh ta (copy TA.img and/or set permissions)

exec u:r:init:s0 -- /init.ta.sh modem (remove and recreate modem_switcher_status)
[Sony Cross-Device General] munjeni:
Yes ofcourse, only solution (easy one) is removing that old /cache/modem/modem_switcher_status && recreating new one by executing /sbin/ua-modem-switcher , your idea is good! Didn't researched if it will be universal for all roms, maybe better idea replacing string in init.sh "on boot" with one line more e.g "on boot\n /init.ta.sh modem"
[Sony Cross-Device General] serajr:
Yeah, I always forget the "universal" part! :p Still a possible workaround, I hope so.
[Sony Cross-Device General] munjeni:
Just need everybody confirm that removing /cache/modem/modem_switcher_status && recreating new one by executing /sbin/ua-modem-switcher does the job :)
[Sony Cross-Device General] munjeni:
Hmm I don't have /cache/modem/modem_switcher_status but have it in /cache/recovery/fota/modem_switcher_status , how that is possible but I have no unknown modem in service menu!? That might be a isue making thing universal if we have diferent path to the modem_switcher_status :(
[Sony Cross-Device General] x_one:
Looks like different structure of the system. Z1C have Lollipop?

Maybe in your device ua-modem-switcher is started later than in ours.
[Sony Cross-Device General] fluffi444:
Works here. Got 2 in status before and now 0,amss_fsg_aries_tar.mbn
[Sony Cross-Device General] munjeni:
Yes lolipop. Ua-modem-switcher is started by fota-ua, and it is started after tad, have no odea how I havr no unknown modem status
[Sony Cross-Device General] wzhy:
It works!!!!

To the diff path, you can let users input theri path when patching ramdisk for universal;)
[Sony Cross-Device General] nolawardana:
How about if we make init.d on startup,, and make comand on it,, so we can remove modem_switcer on /cache/modem/modem_switcher_status

I sucssesful creat line or comand on init.rc to creat init.d and run it folder based on your POC,,

Sorry for my bad english
[Sony Cross-Device General] wzhy:
I have a question about selinux.

As u said, on nougat, kernel cmdline is fail for setting selinux to permissive. But I try to run setenforce with root and it changed.

Does setenforce completely works for 7.0?

---------- Post added at 16:31 ---------- Previous post was at 16:27 ----------

I try moving fota-ua run after init.ta.sh, but still unknow status. Why?

Del this line from init.sony-platforms.rc

exec u:r:fota-ua:s0 -- /sbin/fota-ua c

and add it below exec u:r:init:s0 -- /init.ta.sh in init.rc
[Sony Cross-Device General] Dilesh Perera:
[MENTION=4120742]munjeni[/MENTION]

seems like i have lost some play after i went to sleep yesterday :) nevertheless i can confirm after running /sbin/ua-modem-switcher modem name appears in the service menu now

hope to have permanent fix from u in coming days :)
[Sony Cross-Device General] wzhy:
I wonder that why not use cache partition instead of userdata?
[Sony Cross-Device General] munjeni:
For?
[Sony Cross-Device General] munjeni:
New version is out! In case ua modem switcher not working I will need your dmesg! In case it working just confirm please!

I have added ua modem switcher execution to section "on boot", and for after MM roms it uses selinux context "exec u:r:tad:s0 system -- /sbin/ua-modem-switcher" hope it is right one. Didn't added removal of the modem_switcher_status since I think it is not need since ua modem switcher overwrite old one?
[Sony Cross-Device General] wzhy:
copy TA.img to cache because cache has no encrypt that we can mount it esay
[Sony Cross-Device General] munjeni:
Ok, but if we change thing whole concept probably can move us to the beggining, better idea is fixing that ua modem switcher bug and leaving all as it is
[Sony Cross-Device General] wzhy:
Tested new version. Still not working. Even if I del status manual.
[Sony Cross-Device General] Dilesh Perera:
not working

http://pastebin.com/hDZeJ4PT
[Sony Cross-Device General] x_one:
I don't think it will overwrite modem_switcher_status since it's not overwriting it if you run /sbin/ua-modem-switcher from terminal emulator..
[Sony Cross-Device General] Dilesh Perera:
hi serajr

let me try and update u :)

edit - [MENTION=3989065]serajr[/MENTION]

heres dmesg

http://pastebin.com/Kd1uq4rU
[Sony Cross-Device General] yakupTR:
Hey bro ub my z2 but scrolling lag? Why? Pls pls fixed ...

D6503 cihazımdan Tapatalk kullanılarak gönderildi
[Sony Cross-Device General] munjeni:
That lines is not related to thing. :)
[Sony Cross-Device General] Dilesh Perera:
still not :(

http://pastebin.com/EMfY5Sv0
[Sony Cross-Device General] munjeni:
I can see it run succesfully without error! See:

[ 42.918468] init: Starting service 'exec 20 (/sbin/ua-modem-switcher)'...
[ 42.945458] init: Service 'exec 20 (/sbin/ua-modem-switcher)' (pid 924) exited with status 0

Can you check existence of the modem_switcher_status ?
[Sony Cross-Device General] serajr:
Really? So sorry bro... it's the only one in the log related to cache! I'll edit my posts!!

Maybe dmesg was produced too late.
[Sony Cross-Device General] munjeni:
True! :( Just checked now and it realy didn't overwrite old one
[Sony Cross-Device General] serajr:
Exactly, just saw it now. So do you think the file must be removed prior to be reconstructed?
[Sony Cross-Device General] munjeni:
Bro no prob at all! :good:
[Sony Cross-Device General] munjeni:
Yes, checked right now, manualy modified context of the file, run ua-modem-switcher and found no changes in file :( Seems some more extra lines is need to init.rc
[Sony Cross-Device General] Dilesh Perera:
its always 2,default

:)

time to bed now. will test 2moro your findings.........
[Sony Cross-Device General] munjeni:
New version is out! Tested on my z1c, it deletes old file than run ua modem switcher and recreates new file, in case error happen log is copied to /data/local/tmp/init.ta.log
[Sony Cross-Device General] wzhy:
lastest version hasnt try yet, but I think we who know using fdisk can use an advance mode that using fdosk to make a new disk and dump TA.img into it for performance and compatipility

---------- Post added at 11:57 ---------- Previous post was at 11:22 ----------

BTW, the previous version didnt work, dmesg I have confirm today is return status 255 fail.

And why you del all space at the beginning of all lines? Thats so terrible.
[Sony Cross-Device General] Dilesh Perera:
new version tested and not working

captured dmesg. it has 3 dmesgs as i run as soon as boot completed . ....again and again ..... if that helps

http://pastebin.com/3XdnjTcg

init.ta.sh

rm:/stufs/TAimg:Read_only file system
[Sony Cross-Device General] wzhy:
OK, I found a way to patch TA.

First u must insert a SD card. Then unpack your kernel, replace all /dev/block/mmcblk0p1 to /dev/block/mmcblk1p2 in ramdisk. sepolicy.bin also has this, U can mod this file with hex editor

PS: this kernel must NOT patch with Poc before.

then do the follow steps on your PC: MUST BACKUP YOUR SDCARD FIRST!!!!!

boot up a linux PC or virtual machine. then insert your sdcard.

run this command in terminal: sudo fdisk /dev/sdx (x is your sdcard's letter, dont with number)

then input "p"

Usually it has only one partition will show.

attention to the Start row of /dev/sdx1, If it start after 7000, U R lucky. Jump to next step.

input "d" to del partition 1. input "n" to make a new partition. input "p" select primary partition. input "1" to select the partition number. input "2048" to select with unit start this partition. THEN LOOK AT WHAT TERMINAL SHOW TO YOU.

Like this, you should input 31452149 ( 31457246-4097). After that partition 1 is created.

then input "n" to creat the second partition. still select primart partition and input "2" of partition number. use default start then input "4096" to end.

input "p" to confirm there is 2 partition. the first is bagger and the second is 2MB. then input "w" to save all changes to your sdcard.

now, you can dump your TA.img to the second partition of sdcard

use "sudo dd if=TA.img of=/dev/sdx2" in terminal

to confirm all is OK, just use dd to dump /dev/sdx2 to some file like test.img them md5sum test.img and TA.img.

After all you can insert your sdcard in your phone, flash the modify kernel and boot up
[Sony Cross-Device General] Dilesh Perera:
This cannot be done by everyone unfortunately :( . and i dont have linux or VB.

whats bout the idea provide by @nolawardana? i know its not perfect but still it works. i have tested his modificaton and init.d script provide correct modem after boot completes
[Sony Cross-Device General] wzhy:
what is his idea? I just look at demsg and found that tad_static was started much times at the begining of boot but run failed. As the stock TA is a block device of the phone, we can do the same by using sdcard. First I thought we can make a new partition under mmcblk0, but I found it has too many partitions that we didnt know which can modify safely, so I try to use sdcard.

Now all is working fine on my phone !

I will update some screenshot for the tutorial later.

Mac maybe also can do this, except for the path of sdcard, I'm using hackintosh and found fdisk and dd is also useful.
[Sony Cross-Device General] Dilesh Perera:
this

Quote- How about if we make init.d on startup,, and make comand on it,, so we can remove modem_switcer on /cache/modem/modem_switcher_status - Unquote
[Sony Cross-Device General] wzhy:
Toturial for make TA partition on sdcard:

FIRST BACKUP ALL YOUR DATA ON SDCARD!!!!!

All steps are in terminal on PC!

1. sudo fdisk /dev/sdb (your sdcard letter maybe diff, like sdc of sdd an so on)

2. input "p" print partition table

If your partition start after 7000, you can jump to creat new TA partition step.

3.input "d" delete partition

4.input "n" creat FAT partition. input "p" for primary type, "1" for partition nember, 2048 for start addr. THEN USE THE LARGEST NUM subtract 5120! Like screenshot. For me, use 124735487−5120.

5. this step is creating TA partition!

input "n" then "p" then "2", start addr use default like screenshot. end addr also use default.

For others the FAT partition start after 7000 can use this: start: 2048 end: 6143

when done, input "p" confirm TA partition's size is 2M, sectors is 4096!!!!!

If yes, you can input "w" to save all changes to your sdcard.

Then input "sudo dd if=TA.img of=/dev/sdx2" dump your TA to your sdcard.

check if correct:

confirm 2 files has same md5 hash.

All sdcard's step is done. You need flash kernel that all string /dev/block/mmcblk0p1 replace with /dev/block/mmcblk1p2.

(DO NOT USE THIS WITH PoC's KERNEL)
[Sony Cross-Device General] shoey63:
This is a workaround. I prefer a clean solution.

Now This ^^ is a clean solution! No scripts or hacks, just recreate your TA partition on a MicroSD and edit the ramdisk to point to it. Pure and simple logic.

I think this was the direction [MENTION=4120742]munjeni[/MENTION] originally wanted to go, but most users prefer a "one click" method.
[Sony Cross-Device General] wzhy:
one click method is not easy to done. But this way reminds me of HTC Gold Card :D
[Sony Cross-Device General] Dilesh Perera:
yes u are correct . thats why i said init.d is not the perfect solution but not everyone can perform what wzhy said. its for for more advance users at least .........but munjeni can make it work for all POC users? im waiting with hope :D
[Sony Cross-Device General] wzhy:
I found that you can modify your sdcard by using recovery mode via adb. :)

I use official TWRP 3.1.0 and confirm it has fdisk command line tool. Just BACKUP your sdcard and try. If failed you can reformat your sdcard:p

The sdcard's path on recovery is /dev/block/mmcblk0

---------- Post added at 18:22 ---------- Previous post was at 18:02 ----------

Hey, I found you can use "sed" command to modify file_context.bin. Just run this in terminal
[Sony Cross-Device General] munjeni:
This failed:

[ 41.992017] type=1400 audit(8673492.689:6): avc: denied { read } for pid=927 comm="init.ta.sh" path="/system/bin/sh" dev="mmcblk0p23" ino=1252 scontext=u:r:tad:s0 tcontext=u:object_r:shell_exec:s0 tclass=file permissive=0 ppid=1 pcomm="init" tgid=1 tgcomm="init"
[ 41.992495] init: Service 'exec 20 (/init.ta.sh)' (pid 927) exited with status 1
[Sony Cross-Device General] munjeni:
No and no! We have tool for patching sepolicy & file_contexts.bin! You must do in mind not all users is experienced for that! We have working solution for almost every device, we just need to fix remaining bug related to ua modem switcher. I agree sdcard solution is ok, its nothing new, but not all can do it
[Sony Cross-Device General] munjeni:
Can you replace line in patch_things.sh:

echo -n -e "on boot\n# Part of the TA PoC\nexec u:r:tad:s0 system -- /init.ta.sh modem\n\n"

to

echo -n -e "on boot\n# Part of the TA PoC\nexec u:r:init:s0 -- /init.ta.sh modem\n\n"

and try?
[Sony Cross-Device General] wzhy:
yes, I agree you. My way is only one of the ways. BTW, I have tested the status file must delete manually. ua-modem-switcher will not del it and will still report an error to report file.

Also I'd like to know how to hack init binary for permissive mode?
[Sony Cross-Device General] munjeni:
This might work https://xdaforums.com/showpost.php?p=71525716&postcount=1152 Btw I'm prefering security and not recommend selinux permissive! You can get idea about init binary on google aosp tree!
[Sony Cross-Device General] wzhy:
Thanks I will check this:)

---------- Post added 03-22-2017 at 00:02 ---------- Previous post was 03-21-2017 at 23:09 ----------

[MENTION=4120742]munjeni[/MENTION] Still not working!
[Sony Cross-Device General] munjeni:
Ok but how can I fix without your log? Log please to http://www.pastebin.com !
[Sony Cross-Device General] wzhy:
Still this:

you dont need removing /stufs/TA.img at all. still have no ua-modem-switcher's log.

Wait, I dont check the kernel log, wait a minute
[Sony Cross-Device General] munjeni:
Log mean your dmesg :)
[Sony Cross-Device General] wzhy:
Sorry for my mistake. ;)

http://pastebin.com/LyqpG0L2
[Sony Cross-Device General] munjeni:
No more denials in your log & init.ta.sh exited with satus 0 which mean ok! But what is a status of the ua_modem_switcher and its created file?
[Sony Cross-Device General] wzhy:
I saw you use "exit 0", maybe this so return is 0?
[Sony Cross-Device General] munjeni:
Huh yes my mistake, $? need replace 0 , but I didn't see ua-modem-switcher in your log at all :confused:

Edit:

And this one is strange:

[ 38.896468] init: Service 'tad_static' (pid 651) killed by signal 15
[ 38.896486] init: Service 'tad_static' (pid 651) killing any children in process group
[ 38.897033] init: Starting service 'tad_static'...
[ 40.002584] init: Service 'tad_static' (pid 828) killed by signal 9
[ 40.002602] init: Service 'tad_static' (pid 828) killing any children in process group
[Sony Cross-Device General] wzhy:
Maybe ua-modem-switcher didnt run at all

new log with del "exit" 0 line

http://pastebin.com/teh2Pr4M

---------- Post added at 00:59 ---------- Previous post was at 00:55 ----------

I add tow line echo some log to /data/local/tmp/init.ta.sh.log to see if ua-modem-switcher has ran.
[Sony Cross-Device General] munjeni:
init.ta.sh exited with status 0 on booth! Did modem-switcher-status created in cache?
[Sony Cross-Device General] wzhy:
From the begining I have this log, but other things are OK
[Sony Cross-Device General] munjeni:
Oh damn, this is a reason:

line 2140: (init: Service 'exec 31 (/init.ta.sh)' (pid 843) exited with status 0)

line 2201: (init: Starting service 'tad_static'...)

Init.ta.sh is started before tad :( that is a reason why thing not working! "init.ta.sh modem" must start after tad gets running
[Sony Cross-Device General] wzhy:
NO, ua-modem-switcher DID NOT RUN AT ALL!!!!!

Look at my init.ta.sh

I remove "echo "init.ta.sh" ..."to log, then I reboot. Then I found all my echo log isnt in init.ta.log.txt file!!!
[Sony Cross-Device General] munjeni:
But maybe you removed "/init.ta.sh modem" from init.rc? Or maybe init.rc didn't sends argument "modem" to init.ta.sh? Strange!
[Sony Cross-Device General] munjeni:
Because init.ta.sh starts before tad start, that's not ok and will not work anyway. I think I will move to something diferent e.g.

service uamodemswitcher /sbin/ua_modem_switcher.sh
class late_start
disabled
oneshot
[Sony Cross-Device General] munjeni:
This one working for me:

init.ta.sh:

#!/system/bin/sh

is_modem="$1"
LOG="/data/local/tmp/init.ta-log.txt"

if [ "$is_modem" == "modem" ]; then
rm -f /cache/modem/modem_switcher_status 2>> ${LOG}
rm -f /cache/recovery/fota/modem_switcher_status 2>> ${LOG}
echo "Prepare to run ua modem switcher" >> ${LOG}
/sbin/ua-modem-switcher 2>> ${LOG}
uastatus=$?
echo "Run ua modem switcher finished with status $uastatus" >> ${LOG}
exit $(($uastatus))
fi

echo "Log from init.ta.sh" > ${LOG}

if [ ! -e "/data/local/tmp/TA.img" ]; then
cp -f /stufs/TA.img /data/local/tmp/TA.img 2>> ${LOG}
fi

if [ -e "/data/local/tmp/TA.img" ]; then
chown 2997.0 /data/local/tmp/TA.img 2>> ${LOG}
chmod 0660 /data/local/tmp/TA.img 2>> ${LOG}
fi

and this is a log:

Log from init.ta.sh
Prepare to run ua modem switcher
Run ua modem switcher finished with status 0
[Sony Cross-Device General] wzhy:
I confirm init.rc has init.ta.sh modem. now I test this.

init.ta.sh:

then init.rc's line change to "exec ..... init.ta.sh init" and exec .......init.ta.sh modem"

echo $$ for the PID, so in kernel log we can confirm which PID is running.

I have check the /data/local/tmp/init.ta-log.txt, ONLY PID 840 IS THERE !!!

My init.ta.sh will not over write the log file

http://pastebin.com/0NMqFxyN

---------- Post added at 01:46 ---------- Previous post was at 01:36 ----------

Still as last time, /data/local/tmp/log has this:

dmesg is here

http://pastebin.com/jyEeXHcd

anyway its my last test tonight, I have to go to bed:angel:
[Sony Cross-Device General] munjeni:
This one working for me at least, can you try? https://xdaforums.com/showpost.php?p=71528197&postcount=1170

About pids you can't catch pids that way, probably pid in dmesg is pid of the exec but pid in log pid of the /system/bin/sh as script uses that shell
[Sony Cross-Device General] Dilesh Perera:
i did try after modify as u mentioned

output is the same :(

modem switcher status 2, default

init ta log - Log from init.ta.sh

http://pastebin.com/4PpJS1Et
[Sony Cross-Device General] munjeni:
What say init.ta.log ?
[Sony Cross-Device General] Dilesh Perera:
this and thats all

Log from init.ta.sh

:eek:
[Sony Cross-Device General] munjeni:
New version is out, thing is now service on late_init, tested and for me working, also init.ta.log contain exit status of the ua modem switcher, let me know! :)
[Sony Cross-Device General] Dilesh Perera:
ok last time for the day ..... :)

news is ittttttttttttttttttttttttttts working finally :)

thanks a lot for ur hard work [MENTION=4120742]munjeni[/MENTION]

and not forgetting [MENTION=1552108]wzhy[/MENTION] [MENTION=3989065]serajr[/MENTION] [MENTION=4675598]shoey63[/MENTION] for the input :) finally can sleep good now

PS: [MENTION=4120742]munjeni[/MENTION] i still see /modem_switcher_report with the error . we can forget about this right ?

Report of UA Modem Switcher

UA Modem Switcher status: 2

Current Modem Config : default

Last log messages:

Info [496] Logging OK

WARN [376] Could not read modem command unit. Code: 1

ERROR [598] Could not read active customization unit. Code: 1

ERROR [545] Failed to read active customization status

ERROR [78] Failed to contact TAD within 1000 ms, giving up

ERROR [154] tad not launched

ERROR [161] Read failed (unit 2404)

ERROR [73] Could not get size of TA_FOTA_INTERNAL
[Sony Cross-Device General] munjeni:
Finally! Yes it failed first time but that's a reason why we run it manualy seccond time. :)
[Sony Cross-Device General] Hamidreza2010:
[MENTION=4120742]munjeni[/MENTION] thanks for update

Just can we ignore this error or its important?
[Sony Cross-Device General] munjeni:
As I say in post above your it is ua modem switcher log, the rest of thing see post above your :)
[Sony Cross-Device General] Hamidreza2010:
OK thanks

Then we can ignore it
[Sony Cross-Device General] serajr:
Great job mate!

On Nougat we need to explicitly specify a security label to the service, see dmesg error:

[ 44.670396] init: Service uamodemswitcher does not have a SELinux domain defined.

So we need to add the seclabel line:

service uamodemswitcher /init.uamodemswitcher.sh
class late_start
oneshot
[COLOR="Blue"]seclabel u:r:init:s0[/COLOR]

Not tested yet!
[Sony Cross-Device General] wzhy:
This doesnt matter. Just del it manually and it will run away until ua-modem-switcher has exit with error.
[Sony Cross-Device General] Dilesh Perera:
yes . but deleting and reboot phone and again im seeing the error. but modem switcher status correct with modem 0,amss_fsg_sirus_tar.mbn

so we ignore modem switcher report?

also i have run manually in terminal : /sbin/ua-modem-switcher . after reboot error log still generate : :) asking again to reconfirm we are good to ignore it :good:
[Sony Cross-Device General] wzhy:
I know what happen. Just fota-ua run before init.ta.sh that make ua-modem-switcher report an error. Then after init.ta.sh run we del status file and run ua-modem-switcher again. But init.ta.sh only del status file so we can see error report still there
[Sony Cross-Device General] zohaib0001:
[MENTION=4120742]munjeni[/MENTION]

I have xperia XZ dual android 7.0 running on it.

By using Latest update of POC my device reboot it self again & again and i was unable to get dmesg because of reboots
[Sony Cross-Device General] wzhy:
make sure U have your own TA backup and unlock your boorloader
[Sony Cross-Device General] zohaib0001:
Bro i am using POC from last one month, before latest update its working fine in my device
[Sony Cross-Device General] s.hossein:
Is it possible to restore My TA backup on LineageOS boot.img with poc tool, or it just for stock roms?
[Sony Cross-Device General] zohaib0001:
[MENTION=3989065]serajr[/MENTION] [MENTION=4120742]munjeni[/MENTION]

i want to get recovery dmesg or recovery kmsg

Please can you help me what adb command i used for that

I want that logs because touch is not working in recovery and i want to share that logs with munjeni

My Device Xperia XZ on Android 7.0
[Sony Cross-Device General] wzhy:
look at /proc/last_kmsg or

---------- Post added at 12:26 PM ---------- Previous post was at 12:25 PM ----------
[Sony Cross-Device General] shoey63:
Hey [MENTION=4120742]munjeni[/MENTION]

I have a couple of 3.1.0 recovery images for you to try

This one is built with cm13 sources - no /boot/device, just /dev/block/platform/msm_sdcc.1/by-name, as expected by LP kernel.

And This one is the same, expect it uses [MENTION=4904057][NUT][/MENTION]'s old XZDualRecovery sepolicy.

Hopefully one of them works for your device with PoC. :fingers-crossed:
[Sony Cross-Device General] serajr:
Which twrp build are you talking about (Androplus, Adrian DC, other one)?

At least for the XP, Androplus one has touch issues, but turning screen off and on again fixes it temporarily. If you didn't tried out Adrian DC's one yet, I'd recomend you go for it!!

And for both, always flash them first in the FotaKernel to make sure everything is working. All new recoveries are built to be run there, and not embedded into the kernel (luckly most of them still work this manner too, but they also may present issues)!
[Sony Cross-Device General] zohaib0001:
I am using stock 3.1.0 TWRP recovery for XZ.

i found recovery for XZ by Adrian DC's will try it and report here.

Thanks.
[Sony Cross-Device General] munjeni:
Last kmesg is need! Do not ask please how you can do it, our thread contain two times about last kmsg
[Sony Cross-Device General] wzhy:
I just wonder how to fix the touch issues?
[Sony Cross-Device General] munjeni:
Today I will test and let you know, thanks!
[Sony Cross-Device General] munjeni:
I missed that :) Thanks! New version is out