pre_boot.sh - Xperia Z1 Q&A, Help & Troubleshooting

there is a .sh file in the system/etc folder on my Z1 that checks and loads the touch screen firmware - I tried running it through an adb shell (very new to this stuff) and got permission denied - my phone is rooted correctly as far as I can see with su #
can someone help me to run this manually on my rooted Z1 or offer some help in forcing a firmware load of the touchscreen FW
I have a Z1 with a replaced screen all hardware has been replaced except for the main board
surely some of you whiz kids can help me out here

@Geoffxx, u mean pre_hw_config.sh ?
Code:
#!/system/bin/sh
# pre_hw_config.sh.
# Used to set special parameters during early boot.
#KOTO hw boot
if [ -e /system/bin/snfcboot ]; then
/system/bin/snfcboot
fi
#Touch fw update
touch_path="/sys/devices/virtual/input/"
touch_vendor_id=$(/system/bin/ta_param_loader -p -t 4950 -d 0 -f "0x%02x")
if [ "$touch_vendor_id" = "0x01" ]; then
touch_module_id=0x$(/system/bin/ta_param_loader -p -t 4950 -d 3 -c 2 -f "%02x")
/system/bin/clearpad_fwloader default $touch_module_id
elif [ "$touch_vendor_id" = "0x02" ]; then
touch_chip_id=0x$(/system/bin/ta_param_loader -p -t 4950 -d 1 -c 2 -f "%02x")
touch_config_id=0x$(/system/bin/ta_param_loader -p -t 4950 -d 3 -c 2 -f "%02x")
echo 1 $touch_config_id $touch_chip_id > "$touch_path/max1187x/dflt_cfg"
echo default > "$touch_path/max1187x/fw_update"
else
if [ -a "$touch_path/clearpad" ]; then
touch_module_id=$(/system/bin/ta_param_loader -t 60221 -f "0x%02x")
if [ "$touch_module_id" = "0x00" ]; then
touch_module_id=0x$(cat $touch_path/clearpad/fwfamily)
fi
/system/bin/clearpad_fwloader default $touch_module_id
elif [ -a "$touch_path/max1187x" ]; then
touch_chip_id=$(cat $touch_path/max1187x/chip_id)
touch_config_id=$(cat $touch_path/max1187x/config_id)
echo 1 $touch_config_id $touch_chip_id > "$touch_path/max1187x/dflt_cfg"
echo default > "$touch_path/max1187x/fw_update"
fi
log "*** touch: No valid Misc TA 4950"
fi

yes sorry I was doing it from memory, the phone is in bits right now
There are about 15 different variants of touch firmware, I believe the above code checks to see which variant is present then loads the FW for it from the selection
what I don't know is if this routine runs every time or is called from another part of the boot process to run on an error condition
at present all I know is that I have a dead touchscreen and all the hardware has been replace except the motherboard - everything on the phone works 100% except the touch, so I want to make sure that touch firmware has been loaded by doing it manually
the Z1 has the synaptics touch hardware and so must be identified somewhere
So there are two checks I'd like to do
see if the hardware is being identified/read - there must be a manual way to do this through adb shell
and if the hardware is being identified then force load the Firmware for it
there was a problem with the xperia T family and here is a thread that identified a similar solution http://forum.xda-developers.com/showthread.php?t=2220290&highlight=touch+screen+not+working , unfortunately the Z family of phones/tablets are different, I suspect it's because they all use the same main firmware and have to identify hardware between all the devices and load appropriate software to drive them

Related

[Solved]Help to mount SDcard

Hi I built a little script to mount my SDcard @ startup of the phone and install some apps.
here it is:
Code:
sleep 2
busybox mount > /data/mount.txt
busybox ls /dev/block/vold >> /data/mount.txt
busybox mount -t vfat -o rw,dirsync,nosuid,nodev,noexec,uid=1000,gid=1015,fmask=0702,dmask=0702,allow_utime=0020,shortname=mixed,utf8 /dev/block/vold/179:1 /sdcard >> /data/mount.txt
busybox mount >> /data/mount.txt
sleep 3
echo "APPS installation"
if [ -e /sdcard/Apps-install/install.txt ];
then
echo "found file" > /sdcard/Apps-install/install.txt
cd /sdcard/Apps-install
ls *.apk > ./apps.txt
for line in $(cat apps.txt); do install -c -D /sdcard/Apps-install/"$line" /data/app >> /sdcard/Apps-install/install.txt; done
echo "ok" >> /sdcard/Apps-install/install.txt
else
echo "file not found" > /sdcard/Apps-install/install.txt
fi;
sleep 2
echo "Finish"
if [ -e /data/firstboot.sh ];
then
busybox rm -f /data/firstboot.sh;
busybox rm -f /sdcard/Apps-install/apps.txt;
fi;
echo "Restart"
sleep 1
reboot
I'm sure that the code is well executed (as is have data in /data/mount.txt) but the mount of the SD and so every work related to the SD
What is strange is that script work if i execute it after the phone has completely started.
Can someone help please.
Bye
Herc.8)
A Little up for a little help
Hi,
I still need help,
thx by advance
Bye
Herc. 8)
Ok finally found bye myself.
I changed the device: /dev/block/vold/179:1 for /dev/block/mmcblk0p1
That's all.
Bye
Herc. 8)

[Q] how to move dalvik-cache to ext in cm7.1.0 RC5 11.05.20?

milestone 1 on cm7 0.08-11.04.24 7.0.1 , i have one ext3 partition on my sdcard, everything was working fine,
but after upgrading to cm7.1.0 RC0 11.05.03 yesterday , i can't move the dalvik-cache to ext partition any longer.
even if i do this
mv /data/dalvik-cache /sddata/dalvik-cache
ln -s /sd-ext/dalvik-cache/ /data/dalvik-cache
next time phone reboots, it delete my link and create dalvik-cache directory in "internal storage" while not on my ext3 partition
when i boot into OR 3.3 , the ext3 partition is mounted as /sddata
if i boot into phone ui, the ext3 partition is mounted as /sd-ext
i tiried linking to both directory , none of them works
anyone knows how to do it ?
[edit] after updating to 7.1.0 RC5 11.05.20, the file update-07app2ext-dalvik.on.ext.zip provided by zeppelin doesn't work , ahhhhh.
You will need to edit the 07app2ext file in /system/etc/init.d
Yep.
I did this yesterday actually since my internal storage was getting too low for my liking.
From github, the earlier 07app2ext:
Code:
#!/system/bin/sh
if [ "$SD_EXT_DIRECTORY" = "" ];
then
SD_EXT_DIRECTORY=/sd-ext
fi
if [ "`egrep -q $SD_EXT_DIRECTORY /proc/mounts;echo $?`" != "0" ];
then
echo "$SD_EXT_DIRECTORY not mounted.. skipping a2sd"
exit
fi
for dir in app app-private dalvik-cache;do
if [ "`egrep -q \"/data/${dir}\" /proc/mounts;echo $?`" != "0" ];
then
if [ ! -e "${SD_EXT_DIRECTORY}/${dir}" ];
then
install -m 771 -o 1000 -g 1000 -d ${SD_EXT_DIRECTORY}/${dir}
fi
if [ -L "/data/${dir}" ];
then
rm /data/${dir}
install -m 771 -o 1000 -g 1000 -d /data/${dir}
fi
if [ "${dir}" = "dalvik-cache" ];
then
if [ ! -L "/data/${dir}" ];
then
rm -rf /data/${dir}
install -m 771 -o 1000 -g 1000 -d /data/${dir}
fi
fi
if [ "${dir}" = "app" -o "${dir}" = "app-private" ];
then
for app in `find /data/${dir} -type f -iname "*.apk" -o -iname "*.zip"`;do
mv ${app} ${SD_EXT_DIRECTORY}/${dir}/
done
fi
mount -o bind ${SD_EXT_DIRECTORY}/${dir}/ /data/${dir}
fi
done
chmod 755 /system/etc/init.d/07app2ext
chown -R 0.2000 /system/etc/init.d
sleep 1
I just started using s2e from the market, its working so far
zeppelinrox said:
Yep.
I did this yesterday actually since my internal storage was getting too low for my liking.
From github, the earlier 07app2ext:
Code:
#!/system/bin/sh
if [ "$SD_EXT_DIRECTORY" = "" ];
then
SD_EXT_DIRECTORY=/sd-ext
fi
if [ "`egrep -q $SD_EXT_DIRECTORY /proc/mounts;echo $?`" != "0" ];
then
echo "$SD_EXT_DIRECTORY not mounted.. skipping a2sd"
exit
fi
for dir in app app-private dalvik-cache;do
if [ "`egrep -q \"/data/${dir}\" /proc/mounts;echo $?`" != "0" ];
then
if [ ! -e "${SD_EXT_DIRECTORY}/${dir}" ];
then
install -m 771 -o 1000 -g 1000 -d ${SD_EXT_DIRECTORY}/${dir}
fi
if [ -L "/data/${dir}" ];
then
rm /data/${dir}
install -m 771 -o 1000 -g 1000 -d /data/${dir}
fi
if [ "${dir}" = "dalvik-cache" ];
then
if [ ! -L "/data/${dir}" ];
then
rm -rf /data/${dir}
install -m 771 -o 1000 -g 1000 -d /data/${dir}
fi
fi
if [ "${dir}" = "app" -o "${dir}" = "app-private" ];
then
for app in `find /data/${dir} -type f -iname "*.apk" -o -iname "*.zip"`;do
mv ${app} ${SD_EXT_DIRECTORY}/${dir}/
done
fi
mount -o bind ${SD_EXT_DIRECTORY}/${dir}/ /data/${dir}
fi
done
chmod 755 /system/etc/init.d/07app2ext
chown -R 0.2000 /system/etc/init.d
sleep 1
Click to expand...
Click to collapse
It works on MIUI?
I think so.
It's based on CM7, yeah?
If people are using app2ext on MIUI then I'd say yes.
If it has an 07app2ext file, then it's 100% guaranteed.
What I did was I replaced the 07app2ext file in the update zip with the one above so when it gets flashed I don't have to do anything.
It has an 07app2ext file, so a replace with this and my app2ext didnt work anymore...
There is my older app2ext code:
Code:
#!/system/bin/sh
if [ "$SD_EXT_DIRECTORY" = "" ];
then
SD_EXT_DIRECTORY=/sd-ext
fi
if [ "`egrep -q $SD_EXT_DIRECTORY /proc/mounts;echo $?`" != "0" ];
then
echo "$SD_EXT_DIRECTORY not mounted.. skipping a2sd"
exit
fi
if [ -L "/data/dalvik-cache" ];
then
rm /data/dalvik-cache
install -m 771 -o 1000 -g 1000 -d /data/dalvik-cache
fi
if [ -e "${SD_EXT_DIRECTORY}/dalvik-cache" ];
then
rm -rf ${SD_EXT_DIRECTORY}/dalvik-cache
fi
for dir in app app-private;do
if [ "`egrep -q \"/data/${dir}\" /proc/mounts;echo $?`" != "0" ];
then
if [ ! -e "${SD_EXT_DIRECTORY}/${dir}" ];
then
install -m 771 -o 1000 -g 1000 -d ${SD_EXT_DIRECTORY}/${dir}
fi
if [ -L "/data/${dir}" ];
then
rm /data/${dir}
install -m 771 -o 1000 -g 1000 -d /data/${dir}
fi
if [ "${dir}" = "app" -o "${dir}" = "app-private" ];
then
for app in `find /data/${dir} -type f -iname "*.apk" -o -iname "*.zip"`;do
mv ${app} ${SD_EXT_DIRECTORY}/${dir}/
done
fi
mount -o bind ${SD_EXT_DIRECTORY}/${dir}/ /data/${dir}
fi
done
ah... sometimes that happens...
If you were to put that in the MIUI update zip and flash it, it will work.
I don't know why that happens.
When it happened to me I couldnt figure it out either since I made sure the permissions stayed the same. Maybe it would work as a standalone flashable zip but I have never made one.
Zeppe, can you send me your 07app2ext and tell me what permissions it have? I have 500 mb in the ext partition but i can load it to maximum 'cause my internal storage get full. Now i have about 80 apps, and only 22mb left in the internal storage.
Attached.
Permissions are the same as other files in ect/init.d
xxx
xox
ooo
But when I did it manually, it didn't work
edit... try the attached update.zip... it just might work
either way, the file is in there.
BAZINGA! lol!! It works!!! Thanks a lot zeppelin!
heh
Sent from my Milestone using Tapatalk
zeppelinrox said:
Attached.
Permissions are the same as other files in ect/init.d
xxx
xox
ooo
But when I did it manually, it didn't work
edit... try the attached update.zip... it just might work
either way, the file is in there.
Click to expand...
Click to collapse
zeppelinrox, can I apply this update on CM7 RC10? Is it safe to do it?
I want to move my dalvik cache to ext2 because my internal storage its almost full (less than 20MB free).
Yes its fine.
It's a mod of an overclock flashable zip so when you flash it, it gives an overclock related message.
You can also replace the app2ext script in the cm7 update with the one in this zip file with 7zip and without extracting the cm7 update.
I just leave it in AOR's update folder tho.
So when I flash a rom, I flash this too
Sent from my Milestone using Tapatalk
Thanks for this script, it works perfectly.
I've applied the update from AOR and after move any app from SD to ext2 and reboot, CM7 moves dalvik cache for that apps to ext2.
Now, I suppose any time I update the ROM then before reboot I need to apply this script again.
Sent from my Milestone using XDA App
Yes as an update would probably overwrite this app2ext script
Sent from my Milestone using Tapatalk

What replaces stagefright?

I found a script that adds boot audio. In it there is a line calling stagefright, stagefright either doesn't exist on my ROM and I have no clue as to add it. Here is the script in question which I don't know the original author however lithid from http://forum.cyanogenmod.org did some work on it and was close to creating a updater-script. Please Help Me as I know some scripting but not a lot
PS I was advised to ask this question to the devs by a cyanogenmod.org mod named bassmadrigal
Code:
#!/system/bin/sh
#I just made this into a script this was from a post on XDA by spiicytuna
#http://forum.xda-developers.com/showpost.php?p=8274824&postcount=2
#Please give the credit to him not me.
echo "preparing system..."
#Setting up the system for read/write access
mount -o remount,rw /system
#linking busybox mkdir (broken in rc2)
rm /system/bin/mkdir
ln -s /system/xbin/mkdir /system/bin/mkdir
mkdir -p /data/local/boot
echo "checking for previous bootsound installation..."
if [ -e /system/bin/bootsound ];
then
echo "bootsound already enabled, exiting.."
mount -o remount,ro /system
exit
fi
if [ "`ls /sbin|grep -q recovery;echo $?`" = "0" ];
then
mount -a > /dev/null
recoverymode=y
else
mount -o rw,remount /system
recoverymode=n
fi
echo "preparing startup scripts..."
#This is to create the needed scripts in init.local.rc
echo '' >> /system/etc/init.local.rc
echo '' >> /system/etc/init.local.rc
echo '###Bootsound - Safe to Delete: Start ###' >> /system/etc/init.local.rc
echo "" >> /system/etc/init.local.rc
echo 'service bootsound /system/bin/bootsound' >> /system/etc/init.local.rc
echo ' user media' >> /system/etc/init.local.rc
echo ' group audio' >> /system/etc/init.local.rc
echo ' disabled' >> /system/etc/init.local.rc
echo ' oneshot' >> /system/etc/init.local.rc
echo '' >> /system/etc/init.local.rc
echo 'on property:init.svc.bootanim=running # to correct timin' >> /system/etc/init.local.rc
echo ' start bootsound' >> /system/etc/init.local.rc
echo '' >> /system/etc/init.local.rc
echo 'on property:dev.bootcomplete=1' >> /system/etc/init.local.rc
echo ' stop bootsound' >> /system/etc/init.local.rc
echo '### Bootsound - Safe to Delete: End ###' >> /system/etc/init.local.rc
echo "creating script for bootsound in /system/bin..."
echo '#Now creating the bootsound script'
touch /system/bin/bootsound
echo '#!/system/bin/sh' >> /system/bin/bootsound
echo '' >> /system/bin/bootsound
echo 'bprop=/system/build.prop' >> /system/bin/bootsound
echo '' >> /system/bin/bootsound
echo 'play=$(cat $bprop | egrep -c -i -o ro.config.play.bootsound=1)' >> /system/bin/bootsound
echo 'if [ "$play" = "1" ]; then' >> /system/bin/bootsound
echo ' stagefright -a -o /system/media/android_audio.mp3' >> /system/bin/bootsound #this is the line that breaks the code
echo 'fi' >> /system/bin/bootsound
echo 'exit 0' >> /system/bin/bootsound
#Changing some permissions
chmod 777 /system/bin/bootsound
chown root:shell /system/bin/bootsound
echo '' >> /system/build.pro
echo 'ro.config.play.bootsound=1' >> /system/build.prop
echo 'media.stagefright.enable-player=true' >> /system/build.prop
echo 'media.stagefright.enable-meta=true' >> /system/build.prop
echo 'media.stagefright.enable-scan=true' >> /system/build.prop
echo 'media.stagefright.enable-http=true' >> /system/build.prop
#removed self-destruct, script checks for previous install
sleep 1
mount -o ro,remount /system
echo "done."
exit
ethan_hines said:
I found a script that adds boot audio. In it there is a line calling stagefright, stagefright either doesn't exist on my ROM and I have no clue as to add it. Here is the script in question which I don't know the original author however lithid from http://forum.cyanogenmod.org did some work on it and was close to creating a updater-script. Please Help Me as I know some scripting but not a lot
PS I was advised to ask this question to the devs by a cyanogenmod.org mod named bassmadrigal
Click to expand...
Click to collapse
Not sure if this works , but I will eventually try it , but not now , on my free time.
stagefright indeed is not included , my phone too doesn't have stagefright , if you go to youtube and search for android developement tutorials by "thenewboston" . you'll find 200 videos series , just watch the first 20 ones and you'll learn to use Media which replaces stagefright...I didn't try it yet.
It includes
Our_Player and Media Player and the directory of the song....check it out and give us heads ups!
thethiny said:
Not sure if this works , but I will eventually try it , but not now , on my free time.
stagefright indeed is not included , my phone too doesn't have stagefright , if you go to youtube and search for android developement tutorials by "thenewboston" . you'll find 200 videos series , just watch the first 20 ones and you'll learn to use Media which replaces stagefright...I didn't try it yet.
It includes
Our_Player and Media Player and the directory of the song....check it out and give us heads ups!
Click to expand...
Click to collapse
I appreciate the info, I took a look at his tutorials esp the ones involving animation, he really knows his stuff. I am not a Java programmer by any means and to be honest I find it quite tedious, it's like trying to teach a baby (this case the Dalvik VM) to do basic stuff like draw a green ball took like 20 lines of code!
What I need to know essentially is, do I have to use JAVA to get this to work now? In the past ie ICS and lower, there wasn't a problem with Custom Boot Audio, now with JB it seems it has disappeared from the radar.
I know the binary /system/bin/bootanimation (is this written in JAVA?, is there a source code for this bin?) is called at boot time by init.rc in the following manner:
Code:
service bootanim /system/bin/bootanimation
class main
user graphics
group graphics
disabled
oneshot
/system/bin/bootanimation (at least from what I gather) looks in /system/media for bootanimation.zip (zipped in store mode) decompresses it , looks at desc.txt for the code and displays the animation png by png.
In some desc.txt there is an s line, example:
Code:
# mobility
p 1 0 SOUND
s transdroid.mp3
which is SUPPOSED TO call a custom boot audio from /system/media (.mp3?) at the same time. This appears not to work. So logicaly I think the binary needs some tweaking. Can you offer any suggestions?
As you can see I have spent ALLOT of time mulling over why this,one would think, simple task: display a series of images and play audio at boot time I mean how hard can that be?
I am not trying to be a pest I just need to know WHY this doesn't work in JB (CM10.1)

Build script for 'Nightlies'

Hi guys,
just shameless ripped from the jenkins build script from the wiki and adapted it to our build environment, for 1 device:
build.sh
Code:
#!/bin/bash
export USE_CCACHE=1
################# Your device here:
DEVICE=n7100
################################
cd ~/android/omni
. build/envsetup.sh
repo sync -j4
rm -rf out/target
brunch $DEVICE
make it executeable:
Code:
chmod +x build.sh
Pretty simple, but works for my private nightlies - and maybe as a cron job.
TODO / IDEAS:
Checking if build did work (exit codes? checking for if zip exists?)
Moving the flashable ZIP to a safe (public?) place
purging old builds (tmpwatch?)
check for changes before building
notify on finished builds (notify my android?)
check for changes before building
notify on finished builds (notify my android?)
cb5264 said:
Hi guys,
just shameless ripped from the jenkins build script from the wiki and adapted it to our build environment, for 1 device:
build.sh
Code:
#!/bin/bash
export USE_CCACHE=1
Click to expand...
Click to collapse
This is incomplete. It could be good enough for Jerkins™, but for your desktop rig it should be
Code:
export USE_CCACHE=1
prebuilts/misc/linux-x86/ccache/ccache -M 50G <---- whatever you can spare, I use 50Gbs
cb5264 said:
repo sync -j4
Click to expand...
Click to collapse
Also unnecessary, because the default is -j4.
Code:
repo sync
would suffice.
Keep in mind that we don't have nightlies ready yet as none of the devices are ready yet (nightly builds for us are meant to be stable) but we will have some ready soon
Sent from my SM-N900T using XDA Premium 4 mobile app
Regarding ccache, why should we need to set up the ccache size every compile?
It's a set once value...
Gesendet von meinem GT-N7100 mit Tapatalk
You dont need to. You might add a 'ccache -s' afterwards though - to see how useful ccache was for the build.
If you build OmniROM (when its ready), for yourself, you will want to cherry-pick changes from the Gerrit review, or add changes of your own, to make your build different from that on Jenkins. So it might be better not to have 'repo sync' in your script -- that will wipe out all your changes.
HippyTed said:
You dont need to. You might add a 'ccache -s' afterwards though - to see how useful ccache was for the build.
If you build OmniROM (when its ready), for yourself, you will want to cherry-pick changes from the Gerrit review, or add changes of your own, to make your build different from that on Jenkins. So it might be better not to have 'repo sync' in your script -- that will wipe out all your changes.
Click to expand...
Click to collapse
regarding ccache, as far as I know data that needs to be computed more than once but doesn't change is put into a cache so it will be generated once and then read from the cache, in that case if I delete the cache every time i lose the advantage of a cache...
regarding cherry picks, I would put the cherry picks after the repo sync command to have the best of both worlds (updated core and cherry picks)
regards
Steven
NemesisRE said:
regarding ccache, as far as I know data that needs to be computed more than once but doesn't change is put into a cache so it will be generated once and then read from the cache, in that case if I delete the cache every time i lose the advantage of a cache...
Click to expand...
Click to collapse
Check man pages for ccache - '-C' clears it, '-z' zeroes stats, '-s' shows stats.
regarding cherry picks, I would put the cherry picks after the repo sync command to have the best of both worlds (updated core and cherry picks)
Click to expand...
Click to collapse
Ok.
HippyTed said:
Check man pages for ccache - '-C' clears it, '-z' zeroes stats, '-s' shows stats.
Ok.
Click to expand...
Click to collapse
this doesn't disprove my assertion...
NemesisRE said:
this doesn't disprove my assertion...
Click to expand...
Click to collapse
True. Maybe I misunderstood your reason for making the assertion.
HippyTed said:
True. Maybe I misunderstood your reason for making the assertion.
Click to expand...
Click to collapse
I think so ^^ the reason was to say that rebuilding the cache on every run would be dumb
cb5264 said:
Hi guys,
just shameless ripped from the jenkins build script from the wiki and adapted it to our build environment, for 1 device:
build.sh
Code:
rm -rf out/target
brunch $DEVICE
Click to expand...
Click to collapse
for personal use I don't remove the /out folder but maybe once every few weeks. You're essentially doing a make clobber but leaving your out/host folder so that's good but, even so, it isn't necessary to flush out the target folder every time unless your compiling is pooping out. I suppose it depends whether you're making it a cron job in which case I'd do what you're doing.
---------- Post added at 12:16 AM ---------- Previous post was at 12:14 AM ----------
... what I do think would be nice is to set up a delta update mechanism like cyandelta so we could update on mobile data without killing our data plans.
cd omni
rm -rf out
repo sync -j 16
time brunch n7100
that's what I use
Seems I have the most Advances
Code:
#!/bin/bash
cd ~/
clear
export USE_CCACHE=1
export CCACHE_DIR=~/.ccache
prebuilts/misc/linux-x86/ccache/ccache -M 50G
DATE=$(date -u +%Y%m%d)
OMNIBUILDTODEL=`expr $DATE - 5`
DEVICE=$*
. build/envsetup.sh
rm -f out/target/product/$DEVICE/obj/KERNEL_OBJ/.version
rm -f out/target/product/$DEVICE/system/build.prop
rm -f out/target/product/$DEVICE/system/app/*.odex
rm -f out/target/product/$DEVICE/omni*.zip
rm -f out/target/product/$DEVICE/omni*.zip.md5sum
rm -f out/target/product/$DEVICE/system/framework/*.odex
brunch omni_$DEVICE-userdebug -j12
sftp {-p PORT#} {USER-NAME}@xxx.xxx.xxx.xxx << EOF
cd /var/www/mithun46/hammerhead/omni/
put out/target/product/$DEVICE/omni-4.4-$DATE-$DEVICE-HOMEMADE.zip
put out/target/product/$DEVICE/omni-4.4-$DATE-$DEVICE-HOMEMADE.zip.md5sum
rm omni-4.4-$OMNIBUILDTODEL-$DEVICE-HOMEMADE.zip
rm omni-4.4-$OMNIBUILDTODEL-$DEVICE-HOMEMADE.zip.md5sum
EOF
This:
Uses 50 gigs of ccache
Uploads to my personal server [zip+md5]
Deletes 5 days old builds and their md5sum
This is not clean builds [i clean manually] [is kinda clean though]
Is in the smallest form possible
mithun46 said:
#!/bin/{SHELL}
...
sftp {-p PORT#} {USER-NAME}@xxx.xxx.xxx.xxx
cd /var/www/{what/should/possibly/be/an/obscured/path/to}/omni/
Click to expand...
Click to collapse
You also just provided me with:
1) Verification of an operable {SHELL} compatible shell.
2) Your server's IP.
3) A good indicator that your server accepts SSH AND SFTP connections at the port {PORT#}.
4) Verification that your SSH server accepts "{USER-NAME}" logins.
5) Pretty solid evidence of, and possibly even an otherwise inaccessible path on, a web server
Please edit your post. Ive already made my post as vague as possible without failing to make my point, i hope.
Also, please consider SSH's known_hosts or at the least shell aliases/functions so you don't have to hardcode IP addresses and user-names in random shell scripts.
-Mike
* While it's possible that... EDIT: *REDACTED* no problem, Mithun. I said it for myself as much as I did you; nobody likes a botnet. Well, maybe very few like a botnet.
mithun46 said:
Code:
...
sftp {-p PORT#} {USER-NAME}@xxx.xxx.xxx.xxx << EOF
cd /var/www/mithun46/hammerhead/omni/
put out/target/product/$DEVICE/omni-4.4-$DATE-$DEVICE-HOMEMADE.zip
put out/target/product/$DEVICE/omni-4.4-$DATE-$DEVICE-HOMEMADE.zip.md5sum
rm omni-4.4-$OMNIBUILDTODEL-$DEVICE-HOMEMADE.zip
rm omni-4.4-$OMNIBUILDTODEL-$DEVICE-HOMEMADE.zip.md5sum
EOF
[/LIST]
Click to expand...
Click to collapse
That part got a disturbing 'issue' imho - it doesn't check for a build being successful. I'd work that out with an if-clause checking if the file exists...
cb5264 said:
That part got a disturbing 'issue' imho - it doesn't check for a build being successful. I'd work that out with an if-clause checking if the file exists...
Click to expand...
Click to collapse
If no file exists it shows errors while trying to upload the file in sftp
This is my try, it´s not perfect and for the most people too much... but it`s mine ^^
https://gist.github.com/NemesisRE/7518954
EDIT: Will update the gist until i think it is all ok, but the code here will stay as it is
Code:
#!/bin/bash
##################################################
#
# vim: ai ts=4 sw=4 noet sts=4 ft=sh
#
# Copyright 2013, Steven Koeberich ([email protected])
#
# Title: dinner.sh
# Author: Steven "NemesisRE" Koeberich
# Date: 20131117
# Version: 1.1
# Description: Builds Roms automatically
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License at (http://www.gnu.org/licenses/) for
# more details.
#set -e #do not enable otherwise brunch will fail
#set -x
#For compatibility set Language to en_US.UTF8 and timezone to UTC
export LANGUAGE="en_US.UTF-8"
export LC_ALL="en_US.UTF-8"
export LANG="en_US.UTF-8"
export TZ="/usr/share/zoneinfo/UTC"
#Make us of CCACHE
export USE_CCACHE=1
# Define global variables
REPO_DIR="${HOME}/android/omni"
MAIL_BIN=$(which mail)
LOG_DIR="${HOME}/logs"
SHOW_VERBOSE="> /dev/null 2>&1"
CONVERT_TO_HTML="| ansi2html" # install package kbtin to use this feature
#Set initial exitcodes
SYNC_REPO_EXIT_CODE="0"
GET_BREAKFAST_VARIABLES_EXIT_CODE="0"
BRUNCH_DEVICE_EXIT_CODE="0"
MOVE_BUILD_EXIT_CODE="0"
RUN_COMMAND_EXIT_CODE="0"
CLEAN_OLD_BUILDS_EXIT_CODE="0"
SEND_MAIL_EXIT_CODE="0"
# This variables can be overwritten by command line parameters
MAIL='' # set this if you want always an email
ADMIN_MAIL='' # set this if you want always an email (with logs)
TARGET_DIR='' # set this if you want always move your build to the given directorie
CLEANUP_OLDER_THEN="" # set this if you want always automatic cleanup
DOWNLOAD_LINK='' # set this if you want always a download link
RUN_COMMAND='' # set this if you want always run a command after a build was successful
BUILD_FOR_DEVICE="" # set this if you want always build for the given device/s
#Source envsetup
. ${REPO_DIR}/build/envsetup.sh > /dev/null 2>&1
######################
#
# function _usage
#
#
function _usage() {
echo $"Usage: ${0} [-n \"[email protected]\"] [-t \'/var/www/awsome-download-dir\'] [-r \'scp \$\{OUTPUT_FILE\} example.com:\' ][-l \"http://example.com/download/omnirom\"] [-c 7] [-v] [-- i9300 mako ]"
cat<<EOF
Options:
-n Send notification to given Mail-Adress
-t Move files into given Directorie
-r Run command on successful build
-l If you choose a target dir you may want put
a download link into the mail message
-c Cleanup builds older then N days
-v Verbose Output
-h See this Message
EOF
}
function _e_notice () {
echo -e "NOTICE: ${1}"
}
function _e_warning () {
echo -e "WARNING:Something went wrong ${1} (${2})"
}
function _e_error () {
echo -e "ERROR: ${1}"
}
function _check_prerequisites () {
if [ ! -x $(which ansi2html) ]; then
CONVERT_TO_HTML=""
fi
if [ ${TARGET_DIR} ]; then
TARGET_DIR=$(echo "${TARGET_DIR}"|sed 's/\/$//g')
fi
if [ ${LOG_DIR} ]; then
LOG_DIR=$(echo "${LOG_DIR}"|sed 's/\/$//g')
fi
if [ -z ${BUILD_FOR_DEVICE} ]; then
echo "ERROR: No Device given! Stopping..."
_usage
exit 1
fi
if [ ! -d ${LOG_DIR} ]; then
mkdir -p ${LOG_DIR}
fi
}
function _sync_repo () {
_e_notice "Running repo sync..."
eval "repo sync ${SHOW_VERBOSE}"
SYNC_REPO_EXIT_CODE=$?
if [ ${SYNC_REPO_EXIT_CODE} != 0 ]; then
_e_warning "while doing repo sync" "${SYNC_REPO_EXIT_CODE}"
fi
}
function _get_breakfast_variables () {
for VARIABLE in `breakfast ${DEVICE} | sed -e 's/^=.*//' -e 's/[ ^I]*$//' -e '/^$/ d'`; do
eval ${VARIABLE}
done
GET_BREAKFAST_VARIABLES_EXIT_CODE=$?
if [ ${GET_BREAKFAST_VARIABLES_EXIT_CODE} != 0 ]; then
_e_warning "while getting breakfast variables" "${GET_BREAKFAST_VARIABLES_EXIT_CODE}"
fi
}
function _brunch_device () {
_e_notice "Running brunch for ${DEVICE} with version ${PLATFORM_VERSION} ..."
eval "brunch ${DEVICE} 2>&1 | tee ${LOG_DIR}/brunch_${DEVICE}.log ${SHOW_VERBOSE}"
BRUNCH_DEVICE_EXIT_CODE=$?
BRUNCH_RUN_TIME=$(tail ${LOG_DIR}/brunch_${DEVICE}.log | grep "real" | awk '{print $2}')
if [ ${BRUNCH_DEVICE_EXIT_CODE} != 0 ]; then
_e_warning "while brunch the ${DEVICE}, see logfile for more information" "${BRUNCH_DEVICE_EXIT_CODE}"
fi
}
function _move_build () {
_e_notice "Moving files to target directory..."
mv ${OUTPUT_FILE}* ${TARGET_DIR}/
MOVE_BUILD_EXIT_CODE=$?
if [ ${MOVE_BUILD_EXIT_CODE} != 0 ]; then
_e_warning "while moving the build" "${MOVE_BUILD_EXIT_CODE}"
fi
}
function _run_command () {
_e_notice "Run command..."
eval ${RUN_COMMAND}
RUN_COMMAND_EXIT_CODE=$?
if [ ${RUN_COMMAND_EXIT_CODE} != 0 ]; then
_e_warning "while running your command" "${RUN_COMMAND_EXIT_CODE}"
fi
}
function _clean_old_builds () {
_e_notice "Running cleanup of old builds..."
if [ ${TARGET_DIR} ]; then
CLEANED_FILES=$(find ${TARGET_DIR}/ -name "omni-${PLATFORM_VERSION}-*-${DEVICE}-HOMEMADE.zip*" -type f -mtime +${CLEANUP_OLDER_THEN}d -delete)
else
CLEANED_FILES=$(find `dirname ${OUTPUT_FILE}` -name "omni-${PLATFORM_VERSION}-*-${DEVICE}-HOMEMADE.zip*" -type f -mtime +${CLEANUP_OLDER_THEN}d -delete)
fi
CLEAN_OLD_BUILDS_EXIT_CODE=$?
if [ ! ${CLEANED_FILES} ]; then
CLEANED_FILES="Nothing to clean up."
fi
_e_notice "${CLEANED_FILES}"
if [ ${CLEAN_OLD_BUILDS_EXIT_CODE} != 0 ]; then
_e_warning "while cleaning builds" "${CLEAN_OLD_BUILDS_EXIT_CODE}"
fi
}
function _send_mail () {
_e_notice "Sending status mail..."
MAIL_MESSAGE="Build Status:\n\n"
ADMIN_MAIL_MESSAGE=""
if ${BUILD_SUCCESSFUL}; then
MAIL_MESSAGE+="Build for ${DEVICE} was successfull finished after ${BRUNCH_RUN_TIME}\n"
if [ ${DOWNLOAD_LINK} ]; then
MAIL_MESSAGE+="You can download your Build at ${DOWNLOAD_LINK}\n\n"
fi
if [ ${CLEANED_FILES} ]; then
ADMIN_MAIL_MESSAGE+="Removed the following files:\n"
ADMIN_MAIL_MESSAGE+=${CLEANED_FILES}
fi
else
MAIL_MESSAGE+="Build was not successfull ran ${BRUNCH_RUN_TIME}.\n\n"
ADMIN_MAIL_MESSAGE+="Logfile:"
ADMIN_MAIL_MESSAGE+=$(cat ${HOME}/brunch_${DEVICE}.log ${CONVERT_TO_HTML})
fi
if [ ${MAIL} ]; then
echo -e "${MAIL_MESSAGE}" | ${MAIL_BIN} -s "Finished dinner." "${MAIL}"
fi
if [ ${ADMIN_MAIL} ]; then
echo -e "${MAIL_MESSAGE}${ADMIN_MAIL_MESSAGE}" | ${MAIL_BIN} -s "Finished dinner." "${ADMIN_MAIL}"
fi
SEND_MAIL_EXIT_CODE=$?
if [ ${SEND_MAIL_EXIT_CODE} != 0 ]; then
_e_warning "while sending E-Mail" "${SEND_MAIL_EXIT_CODE}"
fi
}
function _check_build () {
OUT_FILE_SECONDS_SINCE_CREATION=$(/bin/date -d "now - $( /usr/bin/stat -c "%Y" ${OUTPUT_FILE} ) seconds" +%s)
if [ -f ${OUTPUT_FILE} ] && [ "${OUT_FILE_SECONDS_SINCE_CREATION}" -lt "120" ] ; then
BUILD_SUCCESSFUL=true
else
BUILD_SUCCESSFUL=false
fi
}
######################
#
# function _main
#
#
function _main() {
_check_prerequisites
cd ${REPO_DIR}
_sync_repo
for DEVICE in ${BUILD_FOR_DEVICE}; do
_get_breakfast_variables
_brunch_device
OUTPUT_FILE="${OUT_DIR}/target/product/${DEVICE}/omni-${PLATFORM_VERSION}-$(date +%Y%m%d)-${DEVICE}-HOMEMADE.zip"
_check_build
if ${BUILD_SUCCESSFUL} && [ ${TARGET_DIR} ]; then
eval TARGET_DIR=${TARGET_DIR}
_move_build
fi
if ${BUILD_SUCCESSFUL} && [ ${CLEANUP_OLDER_THEN} ]; then
_clean_old_builds
fi
if [ ${MAIL} ] || [ ${ADMIN_MAIL} ]; then
eval MAIL=${MAIL}
eval ADMIN_MAIL=${ADMIN_MAIL}
_send_mail
fi
done
OVERALL_EXIT_CODE=$((${SYNC_REPO_EXIT_CODE}+${GET_BREAKFAST_VARIABLES_EXIT_CODE}+${BRUNCH_DEVICE_EXIT_CODE}+${MOVE_BUILD_EXIT_CODE}+${CLEAN_OLD_BUILDS_EXIT_CODE}+${SEND_MAIL_EXIT_CODE}))
if ! ${BUILD_SUCCESSFUL} && [ ${OVERALL_EXIT_CODE} -gt 0 ]; then
_e_warning "buildcheck failed and Overall exit code is higher then 0 will exit with 1" "${OVERALL_EXIT_CODE}"
exit 1
elif ${BUILD_SUCCESSFUL} && [ ${OVERALL_EXIT_CODE} -gt 0 ]; then
_e_warning "buildcheck was successful but Overall exit code is higher then 0 will exit with 1" "${OVERALL_EXIT_CODE}"
exit 1
else
_e_notice "All jobs finished successfully."
fi
}
## Parameter handling
while getopts ":n:t:l:c:vh" opt; do
case ${opt} in
"n")
MAIL='${OPTARG}'
;;
"t")
TARGET_DIR='${OPTARG}'
;;
"r")
RUN_COMMAND='${OPTARG}'
;;
"l")
DOWNLOAD_LINK='${OPTARG}'
;;
"c")
CLEANUP_OLDER_THEN="${OPTARG}"
;;
"v")
SHOW_VERBOSE=""
;;
"h")
_usage
exit 0
;;
\?)
echo "Invalid option: -${OPTARG}"
_usage
exit 1
;;
:)
echo "Option -${OPTARG} requires an argument."
_usage
exit 1
;;
esac
done
shift $((${OPTIND}-1))
if [ ${@} ]; then
BUILD_FOR_DEVICE=${@}
fi
_main
exit 0
Cheers
Steven
No more gist
The script is now called Dinner, more information at http://forum.xda-developers.com/showthread.php?t=2690995

How To Guide How to configure the WiFI in Android via script

In the current version of Android the WiFi configuration is stored in the file
/data/misc/apexdata/com.android.wifi/WifiConfigStore.xml
e.g.
Code:
ASUS_I006D:/ # ls -lZtr /data/misc/apexdata/com.android.wifi/WifiConfigStore.xml
-rw------- 1 system system u:object_r:apex_system_server_data_file:s0 4884 2023-01-29 08:55 /data/misc/apexdata/com.android.wifi/WifiConfigStore.xml
ASUS_I006D:/ #
The file is in plain ASCII xml format so it can be processed by any executable to change text files (editor, sed, etc).
But IMHO it's better to configure the WiFi manually via GUI and then use the file WifiConfigStore.xml with that configuration for configuring the WiFi via script. Therefor I use this code in the post install script to install and configure my phone (see How to install and configure the Android OS via Script):
Spoiler: script commands to enable and configure WiFi
Bash:
#
# sample post install script for the customizing of the phone
#
# This script will be copied to the phone and executed there
#
# The script is executed by the user shell; use "su - -c <command>" to execute commands as user root
#
echo ""
echo "*** Postinstall script is running ..."
echo ""
# ... other customizations ....
#
# create the WiFi config file
#
# -rw------- 1 system system u:object_r:apex_system_server_data_file:s0 4884 2023-01-29 08:55 /data/misc/apexdata/com.android.wifi/WifiConfigStore.xml
#
WIFI_CONFIG_FILE="/data/misc/apexdata/com.android.wifi/WifiConfigStore.xml"
WIFI_CONFIG_FILE_BACKUP="${WIFI_CONFIG_FILE}.$$.bkp"
NEW_WIFI_CONFIG_FILE="/sdcard/Download/WifiConfigStore.xml"
if [ -r "${WIFI_CONFIG_FILE}" ] ; then
echo "Creating a backup of the file \"${WIFI_CONFIG_FILE}\" in \"${WIFI_CONFIG_FILE_BACKUP}\" ...."
cp "${WIFI_CONFIG_FILE}" "${WIFI_CONFIG_FILE_BACKUP}"
fi
echo "Creating the file \"${NEW_WIFI_CONFIG_FILE}\" ..."
cat >"${NEW_WIFI_CONFIG_FILE}" <<-\EOT
*** add here the contents of the file /data/misc/apexdata/com.android.wifi/WifiConfigStore.xml from the phone after manually configuring the WLAN
EOT
if [ $? -eq 0 ] ; then
echo "Creating the file \"${WIFI_CONFIG_FILE}\" ..."
su - -c cp "${NEW_WIFI_CONFIG_FILE}" "${WIFI_CONFIG_FILE}" && \
su - -c chmod 600 "${WIFI_CONFIG_FILE}" && \
su - -c chown system:system "${WIFI_CONFIG_FILE}" && \
su - -c chcon -v "u:object_r:apex_system_server_data_file:s0" "${WIFI_CONFIG_FILE}"
if [ $? -ne 0 ] ; then
echo "Error creating the file \"${WIFI_CONFIG_FILE}\" "
fi
else
echo "Error creating the file \"${NEW_WIFI_CONFIG_FILE}\" "
fi
# enable WiFi
#
echo "Enabling WiFi ..."
svc wifi enable
# optional: Disable mobile data connections
#
echo "Disabling mobile data ..."
svc data disable
# Now reboot the phone to activate the new WiFi config ..
#
echo "Waiting 15 seconds now before rebooting - press CTRL-C to abort ...."
i=0
while [ $i -lt 15 ] ; do
(( i = i + 1 ))
printf "."
sleep 1
done
printf "\n"
echo "Now rebooting the phone ..."
reboot
#
Notes:
Be aware the the file /data/misc/apexdata/com.android.wifi/WifiConfigStore.xml contains the passwords for all configured WLANs in plain text.
There should be a command to force Android to reread the file WifIConfigStore.xml but I don't know that.
Android can be forced to re-read the file WifIConfigStore.xml by killing the process system_server, e.g:
Bash:
pkill system_server
But that is more or less a warm reboot and I do not know what other side effects that restart triggers
There is an app to configure WiFi via adb command
https://github.com/steinwurf/adb-join-wifi
Bash:
adb shell am start -n com.steinwurf.adbjoinwifi/.MainActivity -e ssid myssid -e password mywlan_password -e password_type WPA
The app works but unfortunately it does not support enabling the setting to use the device MAC instead of the random MAC so it's not usable in my environment.
Another app to configure WiFi via adb command is available here:
https://github.com/pr4bh4sh/adb-wifi-setting-manager
Unfortunately that app also does not support enabling choosing the MAC address for the connection.
There is also a script to convert an old Android wpa_supplicant.conf file to the newer (post-Oreo) WifiConfigStore.xml file (not tested):
https://github.com/mnalis/android-wifi-upgrade
It's also possible to use the command wpa_cli to configure WiFi but be aware the wpa_cli only works if selinux is (temporary) disabled, example:
Spoiler: wpa_cli example
Code:
ASUS_I006D:/ $ su -
ASUS_I006D:/ #
ASUS_I006D:/ # setenforce 0
ASUS_I006D:/ #
ASUS_I006D:/ #
ASUS_I006D:/ # wpa_cli
wpa_cli v2.10-devel-11
Copyright (c) 2004-2019, Jouni Malinen <[email protected]> and contributors
This software may be distributed under the terms of the BSD license.
See README for more details.
Using interface 'wlan0'
Interactive mode
<3>Control interface command 'BSS RANGE=ALL MASK=0x2'
<3>Control interface command 'LIST_CREDS'
<3>Control interface command 'LIST_NETWORKS'
<3>Control interface command 'STA-FIRST'
>
> list_networks
network id / ssid / bssid / flags
0 Zeilsheim any [CURRENT]
1 any [DISABLED]
<3>Control interface command 'LIST_NETWORKS'
>
> quit
ASUS_I006D:/ #
Note: Use help to get list of known commands
Test Environment
I tested the WiFi config via script described above in these Android distributions:
OmniROM 13 (Android 13)
OmniROM 12 (Android 12)
ASUS Android 12
ASUS Android 13
This method seems not to work in Android 11

Categories

Resources