[Q] Problems re-odexing a modified framework.jar using dexopt-wrapper - Android Software/Hacking General [Developers Only]

I'm trying to reodex a framework.jar file I have modified, but I'm always getting a bootloop.
I use the following .sh script to odex the file. Example:
Code:
odex_file.sh /sdcard/modded_files/framework.jar
This is the code of odex_file.sh:
Code:
#!/system/bin/sh
export BOOTCLASSPATH="/system/framework/core.jar:/system/framework/bouncycastle.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/android.policy.jar:/system/framework/services.jar:/system/framework/core-junit.jar"
echo "odexing $1"
odex=`echo $1 | sed -e 's/.jar/.odex/g'`
echo "Running: dexopt-wrapper $1 $odex"
dexopt-wrapper $1 $odex
echo "changing file permissions to 666"
busybox chmod 666 $odex
file=`echo $odex | sed -e 's/.*\///g'`
echo "copying signature from system/framework/$file"
busybox dd if=/system/framework/$file of=$odex bs=1 count=20 skip=52 seek=52 conv=notrunc
echo "done"
I then copy the new .odex file to /system/framework.
When I reboot, I always get a boot loop.
BTW - I am using a Galaxy S i9000.
Any ideas on what I'm doing wrong?

(I know it's been a while since the OP, but you have to dig in a few threads to find the solution, and this thread came almost first in a Google search I did.)
Check your framework jars. If they're missing the META-INF folder or the preloaded-classes file, add those to your modified deoxed jars by using those from the original, unmodified odexed jars before running dexopt-wrapper.

Related

HOW TO: Better AD Block

I've seen other post, so I thought I should share this with anyone who may be interested.
This script is based on "Adblock script" by Adrian Jon Kriel, http://lifehacker.com/5060053/set-up-universal-ad-blocking-through-your-router
This will only work on rooted phone.
Download: adblock.sh
or copy-n-paste source code below
Code:
#!/bin/sh
## Adblock script for G1
## By Jason Driver
## firestrife23(at)gmail(dot)com
## Version 1.1
## May 19 2009
##
## This script is based on "Adblock script" by Adrian Jon Kriel,
## http://lifehacker.com/5060053/set-up-universal-ad-blocking-through-your-routerr
##
## This script is free: 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 for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program. If not, see <http://www.gnu.org/licenses/>.
## Required AD Blocklist
eval MVPSSOURCE="1" ## default 1
eval PGLSOURCE="1" ## default 1
## Extra AD Blocklist, Extremist Only
## HUGE FILE!! your G1 may experience performance hit!!
eval HSFSOURCE="0" ## default 0
eval HFPSOURCE="0" ## default 0
## DO NOT EDIT BELOW, UNLESS YOU KNOW WHAT YOU'RE DOING!!!!
eval GENFILE="hosts"
eval MVPSOURCEFILE="http://www.mvps.org/winhelp2002/hosts.txt"
eval PGLSOURCEFILE="http://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts"
eval HSFSOURCEFILE="http://www.it-mate.co.uk/downloads/hosts.txt"
eval HFPSOURCEFILE="http://hostsfile.mine.nu/Hosts"
echo "ADBLOCK: Testing for Internet Connection..."
if ping -c 1 yahoo.com > /dev/null; then
echo "ADBLOCK: Success"
eval GOTSOURCE="0"
echo "" > $GENFILE
## download
if [ "$MVPSSOURCE" = "1" ] ; then
if wget -q $MVPSOURCEFILE -O - >> $GENFILE ; then
echo "ADBLOCK: Downloaded MVPS Source"
eval GOTSOURCE="1"
else
echo "ADBLOCK: Failed to download MVPS Source"
fi
fi
if [ "$PGLSOURCE" = "1" ] ; then
if wget -q $PGLSOURCEFILE -O - >> $GENFILE ; then
echo "ADBLOCK: Downloaded [email protected] Source"
eval GOTSOURCE="1"
else
echo "ADBLOCK: Failed to download [email protected] Source"
fi
fi
if [ "$HSFSOURCE" = "1" ] ; then
if wget -q $HSFSOURCEFILE -O - >> $GENFILE ; then
echo "ADBLOCK: Downloaded I.T. Mate Group Source"
eval GOTSOURCE="1"
else
echo "ADBLOCK: Failed to download I.T. Mate Group Source"
fi
fi
if [ "$HFPSOURCE" = "1" ] ; then
if wget -q $HFPSOURCEFILE -O - >> $GENFILE ; then
echo "ADBLOCK: Downloaded Hosts File Project Source"
eval GOTSOURCE="1"
else
echo "ADBLOCK: Failed to download Host File Project Source"
fi
fi
echo "ADBLOCK: Adding Mobile Ads to blocklist"
echo '127.0.0.1 p.admob.com' >> $GENFILE
echo '127.0.0.1 analytics.admob.com' >> $GENFILE
echo '127.0.0.1 r.admob.com' >> $GENFILE
if [ "$GOTSOURCE" = "1" ]; then
echo "ADBLOCK: Got Source Files"
echo "ADBLOCK: Stripping Source Files"
sed -i -e '/^[0-9A-Za-z]/!d' $GENFILE
sed -i -e '/%/d' $GENFILE
sed -i -e 's/[[:cntrl:][:blank:]]//g' $GENFILE
sed -i -e 's/^[ \t]*//;s/[ \t]*$//' $GENFILE
echo "ADBLOCK: Sanitize, and Optimising"
sed -i -e 's/[[:space:]]*\[.*$//' $GENFILE
sed -i -e 's/[[:space:]]*\].*$//' $GENFILE
sed -i -e '/[[:space:]]*#.*$/ s/[[:space:]]*#.*$//' $GENFILE
sed -i -e '/^$/d' $GENFILE
sed -i -e 's/127.0.0.1/127.0.0.1 /g' $GENFILE
sed -i -e 's/www.//g' $GENFILE
echo "ADBLOCK: Removing Duplicates (Resource Friendly)"
cat $GENFILE | sort -u > $GENFILE.new
mv $GENFILE.new $GENFILE
## including important informations
sed -i -e '1i127.0.0.1 localhost' $GENFILE
sed -i -e '2i##' $GENFILE
sed -i -e '3i##-----------------------------------------' $GENFILE
sed -i -e '4i## Generated by Adblock script v1.1 ' $GENFILE
sed -i -e '5i##-----------------------------------------' $GENFILE
sed -i -e '6i##' $GENFILE
## removing last line (garbage)
sed -i -e '$d' $GENFILE
## info section
echo "ADBLOCK: Unique Hosts Blocked" $(awk 'END { print NR-6 }' $GENFILE)
else
echo "ADBLOCK: Error Files Not Downloaded"
fi
else
echo "ADBLOCK: Error No Internet"
fi
## replacing old hosts with new hosts file
echo "ADBLOCK: Remounting /system to read-write"
mount -o remount,rw /dev/block/mtdblock3 /system
rm /system/etc/hosts
cp /sdcard/hosts /system/etc/hosts
echo "ADBLOCK: Updated Hosts"
echo "ADBLOCK: Remounting /system to read-only"
mount -o remount,ro /dev/block/mtdblock3 /system
rm $GENFILE
be sure to place this script at root level of sdcard
Example:
Code:
/sdcard/adblock.sh
Open terminal emulator and excute as following.
Code:
$ su
# cd /sdcard
# sh adblock.sh
I Hope you find this useful. Enjoy!
Just wondering, is this all your own shell code? Looks awfully similar to one I used on my router -- variable names and all.
Either way -- good post. Just wondering since you posted it with GPL and all
Edit: Ah, here is the script I previously used and thought it reminded me of; "Adblock script" by Adrian Jon Kriel, http://lifehacker.com/5060053/set-up-universal-ad-blocking-through-your-router
yes you're right. Mostly is borrowed from tomato firmware forums (can't remember where), however their script is meant for dnsmasq, and I revised this to work with hosts file.
EDIT: Saw your source link, the reason I GPL'ed this script to prevent anyone else taking credit for Adrain Jon Kriel's work, I'll revision first post to give him proper credit thanks for link.
firestrife23 said:
yes you're right. Mostly is borrowed from tomato firmware forums, however their script is meant for dnsmasq, and I revised this to work with hosts file.
Click to expand...
Click to collapse
Ahh, just wondering -- good work with it. Though I'd assume the original other (no matter how much you edited it) would like a little credit on it too
how/why is this better than the app? doesn't it do the same thing?
Lieu10ant said:
how/why is this better than the app? doesn't it do the same thing?
Click to expand...
Click to collapse
It does the same as app, however my script is only 4.3kb.
Basically it combine multiple hosts source into single hosts file by clean up garbage such as ^M (MS-DOS end of line) which can be quite problematic for linux/unix in general (yes Android is Linux), and trimmed down to much smaller file size by removing comments, duplications, and finally sort everything by 0-9 and A-Z order to speed up hosts look up.
Does this need to be rerun on any sort of schedule? Or will it take care of looking for new address to add to the hosts file?
Love this script, thanks for sharing!
nice work!
way to condense this down to nearly nothing. Quick question, does this autoupdate? Do I have to run this from time to time to update the hosts its blocking?
Thanks!
No it does not auto update, you can just rerun the script yourself.
autoupdate
so then, how could we force this to run at boot so Android will always be adfree? Could we add a line to userinit.sh?
innerspace said:
so then, how could we force this to run at boot so Android will always be adfree? Could we add a line to userinit.sh?
Click to expand...
Click to collapse
I have my doubts that the internet connection is live until phone is fully booted. And it certainly is not if you have SIM card pin enabled.
We have 3 options from where I sit.
We can add it to the userinit.sh (or user.conf) file(s) and perhaps set it up with a delay (since most of our internet won't be on right when the phone is booting) ie sleep 120 like from this post.
We can use Autostart from the Market.
We can just run the script manually.
Thanks, works nice.
(nice name above me )
I keep getting an error, it can't connect to any of the sites to download the files... like it says 'bad address' and then 'error files not downloaded'
Can someone please help me?
I am running JACHero v1.4
I'm pretty sure I'm trying this wrong.
I used the autostart app and created a .sh file (I'll post the content at the end of this) and the corresponding directory in data.
I started the phone and got a SU permission request (which I expected). But I don't know if the script ran right.
BTW I created this script using notepad in XP. Probably not the smartest choice, but I really don't know what I'm doing and figured I'd give it a shot.
Here is the content of the .sh file I created:
--------------------------------------
setPriorityLater()
{
# sleep for 2 minutes
sleep 120
# phone and all processes should surely by up by now
su
cd /sdcard
sh adblock.sh
}
setPriorityLater > /dev/null 2>&1 &
-----------------------------------------
I copied the text of the script from http://forum.xda-developers.com/showpost.php?p=4355721&postcount=78 and inserted the commands to run this script.
Be honest, I screwed it up didn't I?
Couldn't you just use Gscript and run it every so often?
Gilliland12 said:
I'm pretty sure I'm trying this wrong.
I used the autostart app and created a .sh file (I'll post the content at the end of this) and the corresponding directory in data.
I started the phone and got a SU permission request (which I expected). But I don't know if the script ran right.
BTW I created this script using notepad in XP. Probably not the smartest choice, but I really don't know what I'm doing and figured I'd give it a shot.
Here is the content of the .sh file I created:
--------------------------------------
setPriorityLater()
{
# sleep for 2 minutes
sleep 120
# phone and all processes should surely by up by now
su
cd /sdcard
sh adblock.sh
}
setPriorityLater > /dev/null 2>&1 &
-----------------------------------------
I copied the text of the script from http://forum.xda-developers.com/showpost.php?p=4355721&postcount=78 and inserted the commands to run this script.
Be honest, I screwed it up didn't I?
Click to expand...
Click to collapse
It's recommended to use notepad++. Trust me. It's much better than notepad.
cannot create hosts
C:\Documents and Settings\Administrator\Desktop>adb shell
# sh /sdcard/adblock.sh
sh /sdcard/adblock.sh
ADBLOCK: Testing for Internet Connection...
ADBLOCK: Success
/sdcard/adblock.sh: cannot create hosts: read-only file system
/sdcard/adblock.sh: cannot create hosts: read-only file system
ADBLOCK: Failed to download MVPS Source
/sdcard/adblock.sh: cannot create hosts: read-only file system
ADBLOCK: Failed to download [email protected] Source
ADBLOCK: Adding Mobile Ads to blocklist
/sdcard/adblock.sh: cannot create hosts: read-only file system
/sdcard/adblock.sh: cannot create hosts: read-only file system
/sdcard/adblock.sh: cannot create hosts: read-only file system
ADBLOCK: Error Files Not Downloaded
ADBLOCK: Remounting /system to read-write
rm: cannot remove '/system/etc/hosts': No such file or directory
cp: cannot stat '/sdcard/hosts': No such file or directory
ADBLOCK: Updated Hosts
ADBLOCK: Remounting /system to read-only
rm: cannot remove 'hosts': No such file or directory
#
Binary100100 said:
C:\Documents and Settings\Administrator\Desktop>adb shell
# sh /sdcard/adblock.sh
sh /sdcard/adblock.sh
ADBLOCK: Testing for Internet Connection...
ADBLOCK: Success
/sdcard/adblock.sh: cannot create hosts: read-only file system
/sdcard/adblock.sh: cannot create hosts: read-only file system
ADBLOCK: Failed to download MVPS Source
/sdcard/adblock.sh: cannot create hosts: read-only file system
ADBLOCK: Failed to download [email protected] Source
ADBLOCK: Adding Mobile Ads to blocklist
/sdcard/adblock.sh: cannot create hosts: read-only file system
/sdcard/adblock.sh: cannot create hosts: read-only file system
/sdcard/adblock.sh: cannot create hosts: read-only file system
ADBLOCK: Error Files Not Downloaded
ADBLOCK: Remounting /system to read-write
rm: cannot remove '/system/etc/hosts': No such file or directory
cp: cannot stat '/sdcard/hosts': No such file or directory
ADBLOCK: Updated Hosts
ADBLOCK: Remounting /system to read-only
rm: cannot remove 'hosts': No such file or directory
#
Click to expand...
Click to collapse
I had the same problem, thn i moved:
Code:
echo "ADBLOCK: Remounting /system to read-write"
mount -o remount,rw /dev/block/mtdblock3 /system
at the beginning of the script, and now it works fine

[UTIL] signapk.sh: onboard .apk signing. 100% java-free

Since I tend to modify roms before flashing them to my phone, and sometimes want to do so away from a computer, I ended up writing this. It's an ash script that uses the openssl binary found on most custom roms, and infozip. The sdk test/platform/media/etc keys are included. Usage:
Usage: signapk (options) [command] (files)
commands:
sign FILE sign a .zip or .apk
sign FILE1 FILE2 create a signed copy of FILE1 as FILE2
cert FILE(s) print cert info on FILE's signer
certinfo FILE print detailed cert info on FILE's signer
cmp FILE compare signer of FILE with default/selected cert
cmp FILE1 FILE2 compare signer of FILE1 to signer of FILE2
options:
-k, --key FILE key to sign with
-c, --cert FILE cert to sign with
if -c or -k are not files then they are considered
aliases to builtins (ie -k testkey or -c platform)
-f, --force sign even if cert differs from original
-t, --tmp DIR use DIR for tempdir instead of '/cache'
-d, --debug output debugging
-V, --version print 'signapk v0.3.1'
exit codes:
1: read error (file 1) 2: read error (file 2)
3: write error 4: ssl error
5: zip write error 9: key error
8: sign: cert mismatch 10: cmp: cert mismatch
128: script error 255: user error
Installation:
unpack somewhere. If needed, edit the variables at the top of the script. By default it uses /cache/ for 4 small temporary files.
Faq:
* Why did you include a busybox and openssl? * Some roms don't include the openssl utility. Busybox's unzip refuses to deal with zipaligned apks on alot of roms, because it wasn't compiled with ENABLE_DESKTOP. Busybox's ash is missing things that the script needs, on some roms. The script will use whatever the rom provides, if these binaries are not present. Good luck.
* How do I change the cert? * see signapk --help for cert/key selection flags
* Can I use this in my MarketAppThingy? * Sure, and please let me know. If it's a paid MarketAppThingy, consider sending me a free copy.
Changelog:
release 3: cmp function, key selection, documented exit codes that make sense, and paranoia. Includes trimmed down busybox and openssl binaries. If these are present, script will reload itself to run in it's busybox ash interpreter to avoid broken busybox compiles, and can run without using anything provided by the rom. In theory this means no compatibility issues, but is limited to ARM devices.
release 2: Apparently it's valid to have ANYNAME.SF/ANYNAME.RSA or ANYNAME.DSA. signapk cert and certinfo now handles this. The sign function will blindly write to CERT.SF and CERT.RSA as this is the behavior of the standard SignApk.java. This may be fixed later.
If you don't wanna signup to download attachment, snag this from http://code.google.com/p/signapk/downloads/list
very, very useful. I'm testing this now Signing stuff was always way too complicated.
Cool. Can't wait for someone to make a market app that creates a simple ui to edit update.zips before flashing. Hint hint
I put the files in /system/signapk (new folder)
When i run the script I get the error below. The test file is an unsigned apk exported from eclipse.
Code:
# ./signapk sign /sdcard/unsigned.apk
./signapk sign /sdcard/unsigned.apk
Checksumming /mnt/sdcard/unsigned.apk:
res/layout/main.xml AndroidManifest.xml
resources.arsc res/drawable-hdpi/icon.png res/drawable-ldpi/icon.png res/drawable-mdpi/icon.png classes.dex
[COLOR="Red"]unable to write 'random state'
./signapk: line 132: ./signapk.zip: not found[/COLOR]
#
Any idea what needs changing to fix this?
update: When I used the full path it worked.
Code:
# /system/signapk/signapk sign /sdcard/unsigned.apk
/system/signapk/signapk sign /sdcard/unsigned.apk
Checksumming /mnt/sdcard/unsigned.apk:
res/layout/main.xml AndroidManifest.xml
resources.arsc res/drawable-hdpi/icon.png res/drawable-ldpi/icon.png res/drawable-mdpi/icon.png classes.dex
unable to write 'random state'
adding: META-INF/MANIFEST.MF (deflated 49%)
adding: META-INF/CERT.SF (deflated 48%)
adding: META-INF/CERT.RSA (deflated 33%)
# /system/signapk/signapk cert /sdcard/unsigned.apk
/system/signapk/signapk cert /sdcard/unsigned.apk
/sdcard/unsigned.apk 936EACBE07F201DF SDK Test Key
Was playing around with app inventor and came up with this:
edit: AppInventor does not generate java code and it cannot be worked on further in anything else (i.e eclipse)
I was really hoping I would atleast get the activity xml
Heya, the latest is at http://code.google.com/p/signapk/downloads/list and should fix the zip error. signapk-bb, signapk-zip, and signapk-openssl are static, trimmed down versions of utilities required by the script, and should be extracted to the same directory as the script. If they are not present it will try to use stuff in $PATH
Just throwing it (the obvious) out there that this could enable a new generation of morphs for /data apps
Copy apk,uninstall,morph, install
Hmmmm....
britoso said:
Just throwing it (the obvious) out there that this could enable a new generation of morphs for /data apps
Copy apk,uninstall,morph, install
Click to expand...
Click to collapse
How can i get this to work with a morph and to edit the updater-script?
Someone explain the commands with example...
Another noob question is .. it is for android or pc...
Edit:- Made my own mod here https://forum.xda-developers.com/t/...-apk-zip-within-android.3835975/post-81324327
below code works with latest(1.32.0) busybox
Bash:
#!/system/bin/sh
# depends unzip printf zip openssl
# put zip openssl busybox in PATH
# Usage:-
# Sign.sh key.pk8 key.x509.pem in.zip out.zip
ordie() {
if [ $? -ne 0 ]; then
IFS=" "
$BB printf "$1\n"
exit $2
fi
}
PKEY="$1"
CERT="$2"
ORIG="$3"
TARGET="$4"
BB=busybox
cat "$ORIG" > "$TARGET"; ordie "Cannot write to $TARGET" 3
$BB printf "Checksumming $ORIG:\n"
TMP=$HOME
TMPDIR="$TMP/sign-$$"
TMPPKEY="$TMPDIR/tmp.pkey"
mkdir -p "$TMPDIR/META-INF"; ordie "" 3
$BB printf "Manifest-Version: 1.0\r\nCreated-By: 1.0 (Android SignApk)\r\n\r\n" > "$TMPDIR/META-INF/MANIFEST.MF"
ZIPls=$($BB unzip -qql "$ORIG"); ordie "$ORIG: unzip error" 1
OLDIFS=$IFS
IFS=${IFS:2:2}
for i in $ZIPls; do
IFS=$OLDIFS
set -- $i
if [ "$#" -ge 3 ] && [ "$1" != "0" ]; then
file="${i:30}"
case "$file" in META-INF/MANIFEST.MF|META-INF/CERT.SF|META-INF/CERT.RSA) continue;; esac
$BB printf "$file "
hash=$($BB unzip -p "$ORIG" "$file" | openssl sha1 -binary | openssl base64); ordie "$ORIG: unzip error" 1
ret="Name: $file\r\nSHA1-Digest: $hash\r\n\r\n"
$BB printf "$ret" >> "$TMPDIR/META-INF/MANIFEST.MF"
hash=$($BB printf "$ret" | openssl sha1 -binary | openssl base64)
$BB printf "Name: $file\r\nSHA1-Digest: $hash\r\n\r\n" >> "$TMPDIR/META-INF/CERT.SF.temp"
fi
done
$BB printf "\n"
mfhash=$(cat "$TMPDIR/META-INF/MANIFEST.MF" | openssl sha1 -binary | openssl base64)
$BB printf "Signature-Version: 1.0\r\nCreated-By: 1.0 (Android SignApk)\r\nSHA1-Digest-Manifest: $mfhash\r\n\r\n" > "$TMPDIR/META-INF/CERT.SF"
cat "$TMPDIR/META-INF/CERT.SF.temp" >> "$TMPDIR/META-INF/CERT.SF"
openssl pkcs8 -inform DER -nocrypt -in "$PKEY" > "$TMPPKEY"; ordie "" 4
cat "$TMPDIR/META-INF/CERT.SF" | openssl smime -sign -inkey "$TMPPKEY" -signer "$CERT" -binary -outform DER -noattr > "$TMPDIR/META-INF/CERT.RSA"; ordie "" 4
cd "$TMPDIR"
zip "$TARGET" META-INF/MANIFEST.MF META-INF/CERT.SF META-INF/CERT.RSA; ordie "" 5
cd - > /dev/null
rm -r "$TMPDIR"

[Q] How do i Odex a build from my computer

all of the tutorials i have seen on how to odex is pushing a script to the phone after its installed i am looking to do this before first boot. any help its appreciated
here is the script from an and build, try in linux and see what happens (of course edit for your folder structure)
#!/system/bin/sh
#
# system/app odex-er by Paul O'Brien @ www.MoDaCo.com
#
# experimental - nandroid backup before you run this script!
#
# version 0.1, 29th January 2010
# updated by Martin Johnson, M.J.Johnson @ massey.ac.nz June 2010 for Vogue
#
rm /tmp.odex
cd /data/app
# Check for and delete leftover .odex files after uninstalled apps
for filename in *.odex
do
name=`basename $filename .odex`
if [ ! -f $name.apk -a -f $filename ]
then
rm $filename
echo "Removed $filename"
fi
done;
# Loop through all installed apps
for filename in *.apk
do
name=`basename $filename .apk`
if [ ! -f $name.odex -o $filename -nt $name.odex ]
then
# step 1 - odex the apk
rm -f /tmp.odex
/system/bin/dexopt-wrapper $filename /tmp.odex
# step 2 - did we succesfully odex?
if [ $? -eq 0 ]
then
# step 3 - remove the classes.dex from the apk
/system/bin/zip -d $filename classes.dex
# continue only if classes.dex was present
if [ $? -eq 0 ]
then
# step 4 - zipalign, just in case
/system/bin/zipalign -f -v 4 $filename /$filename.new
mv -f /$filename.new $filename
mv -f /tmp.odex $name.odex
touch $name.odex
echo "Odexed $filename"
else
echo "Error $filename did not contain classes.dex"
fi
else
echo "Error creating odex from $filename"
fi
else
echo "Nothing to do: $filename"
fi
done;
Any more thoughts??

[GUIDE] Add init.d scripts support for padfone/padfone 2

First of all, if you don't know what does init.d means then you probably won't need this and I'm not responsible if your padfone explodes when running this . Seriously this is almost completely sure but your device, your responsibility.
Credits:
I gathered information from this thread from DooMLoRD http://forum.xda-developers.com/showthread.php?t=1236446 as well as from others in this forum, but i believe he was the first.
Pre-requisites:
A rooted padfone, busybox and a command-line (adb, terminal, ...)
Explanation:
We are going to use the install-recovery.sh script that recreates the recovery partition (if it has been modified) while the device boots.
The way it works is simple:
- the boot process calls install-recovery.sh while executing init.rc
- the install-recovery.sh calls sysinit script
- the sysinit script runs /system/etc/init.d/* in order
Issues:
I found that the script is called in an early state where the date is still not set (is said Jan 28 1970!!!) and only a few fs are mounted:
/system, /data, /persist, /cache
so no sdcard, no Removable ...
Howto:
you can either copy the following text to a file in your device or download the attached file and in a terminal run:
$su
#cd to the directory where the script was stored
#sh ./enable_initd.sh
Code:
#!/system/bin/sh
echo ''
echo 'This script will enable init.d'
echo ''
echo 'You will need to reboot to check if it worked'
echo ''
echo 'If the script successfully enabled init.d you will'
echo 'have a file in /data/log called init.d-log.txt'
echo 'after the device is done rebooting.'
echo 'Once checked that it is working, you can delete'
echo '/system/etc/init.d/99test and /data/log/init.d-log.txt'
echo 'Remember to always set the proper permissions in your'
echo 'scripts or they will not work.'
echo ''
if [ ! -f /system/xbin/busybox -a ! -f /system/bin/busybox ]
then
echo 'no busybox found! please re-install/update your busybox'
else
# Mount system as rw in order to prepare the paths and scripts
mount -o remount,rw /system
# Create init.d dir
if [ -d '/system/etc/init.d' ]
then
chmod 755 /system/etc/init.d
else
mkdir /system/etc/init.d
chmod 755 /system/etc/init.d
fi
# Create sysinit script if needed
if [ -f /system/bin/sysinit ]
then
echo 'sysinit exists, init.d should be enabled'
chmod 755 /system/bin/sysinit
else
touch /system/bin/sysinit
echo '#!/system/bin/sh' >> /system/bin/sysinit
echo 'export PATH=/sbin:/system/sbin:/system/bin:/system/xbin' >> /system/bin/sysinit
echo '/system/bin/logwrapper busybox run-parts /system/etc/init.d' >> /system/bin/sysinit
chmod 755 /system/bin/sysinit
fi
# Create / modify install-recovery.sh
if [ -f /system/etc/install-recovery.sh ]
then
if cat /system/etc/install-recovery.sh | egrep -i "sysinit"
then
echo 'sysinit already present in install-recovery.sh, skipping this step.'
else
cp /system/etc/install-recovery.sh /system/etc/install-recovery.sh.old
echo '' >> /system/etc/install-recovery.sh
echo '#init.d scripts integration' >> /system/etc/install-recovery.sh
echo '/system/bin/sysinit' >> /system/etc/install-recovery.sh
fi
else
touch /system/etc/install-recovery.sh
echo '#!/system/bin/sh' > /system/etc/install-recovery.sh
echo '' >> /system/etc/install-recovery.sh
echo '/system/bin/sysinit' >> /system/etc/install-recovery.sh
chmod 755 /system/etc/install-recovery.sh
fi
# Create 99test script to check if init.d works
echo '#!/system/bin/sh' > /system/etc/init.d/99test
echo '' >> /system/etc/init.d/99test
echo 'date >> /data/log/init.d-log.txt' >> /system/etc/init.d/99test
echo 'echo init.d works >> /data/log/init.d-log.txt' >> /system/etc/init.d/99test
chmod 755 /system/etc/init.d/99test
# Sync and remount system
sync
mount -o remount,ro /system
#done!
echo 'job done :)'
echo 'reboot your phone and check on'
echo '/data/log/init.d-log.txt to see if it worked'
fi
Good luck!
please make new forum request for the padfone2 here
http://forum.xda-developers.com/showthread.php?t=1660354
we can't be sure that admins look here
Sendt fra min PadFone 2 med Tapatalk2
Thanks
Very Useful! Thanks for your guide.

[Q] Bootloop when trying to odex my ROM

I'm running out of space in /data and I have some space left in /system. So I figured I might try odexing my ROM to get some of that space in /data back.
First, I got zip, zipalign, and dexopt-wrapper from an XDA thread somewhere. I then mkdired a temporary folder in /, pushed the tools to it and chmodded them 755, added the folder to $PATH, and ran this script on the live android system:
Code:
#!/system/bin/sh
set -e
[ -d /odexes ] && rm -r /odexes
mkdir -p /odexes/system/framework /odexes/system/app
dexopt_success=
#for i in $(echo $BOOTCLASSPATH | busybox sed -r -e 's/:/ /g') /system/framework/*.jar /system/app/*.apk
for i in /system/app/*.apk
do
[ -f /odex ] && rm /odex #delete odex from any failed previous run
noext=`echo $i | busybox sed -r -e 's:\...$::'`
if [ ! -f $noext.odex ] && dexopt-wrapper $i /odex $BOOTCLASSPATH
then
dexopt_success="$dexopt_success $i"
busybox mv /odex /odexes/$noext.odex
chmod 644 /odexes/$noext.odex
fi
done
for i in $dexopt_success
do
# remove classes.dex
zip -d $i classes.dex || true
# zipalign the apk
zipalign 4 $i /`basename $i`
rm $i
busybox mv /`basename $i` $i
done
# move odex into place
#busybox mv /odexes/system/framework/* /system/framework/
busybox mv /odexes/system/app/* /system/app/
As you can see from the commented lines in my script, I first tried to odex both /system/framework and /system/app. This did not work - I got into a bootloop, with Dalvik complaining that there were no valid framework files in /system/framework. I thought this was strange, but I didn't think much of it - I'm running a Sense ROM (SVHD) and perhaps they do things that interfere with odexing, I thought. So I restored my nandroid and retried, this time only odexing /system/app. Surprisingly, the same problem occurred. That is, I get into a bootloop. Specifically, the system server segfaults because it can't find a settings provider. Furthermore, even though logcat said 'file /system/app/<any apk>.apk changed, collecting certs', it continued on to say 'app /system/app/<any apk>.apk was deleted, removing data'. This looks to be the same problem as I had with the framework - for some reason, after I odex a file it is no longer recognized as valid.
So, um, what am I doing wrong? My first guess would be that the apks (and also jars) become invalid once I remove classes.dex from them; this file contains the definitions of all executable Java code. But the whole point of odexing is to delete this file so that its contents are read from the precompiled odex file. Thus, it would seem that my real problem is that Dalvik isn't looking at the odex files. But why not - they're right there with the same name as the apks and they're chmodded 644, just like the apks?
Check the lib link in my sig, you can find it usefull. And BTW SVHD cannot be odexed due to not proper modification of the framework which affects the bootclasspath and screws the process. Try another ICS ROM
Thank you for your information! While it was not the answer I was hoping to get, it did inspire me to do something else entirely. Since SVHD does not use the lib partition, I unpacked my boot image and added these lines to init.saga.rc:
Code:
devwait [email protected]
mount ext4 [email protected] /data/dalvik-cache noatime nosuid nodev nodelalloc
Repacked my boot image, flashed it in fastboot, rebooted to recovery and wiped dalvik-cache to reclaim the space from my /data partition, rebooted into Android, and my dalvik-cache is now living in the system_lib partition
So, my problem is solved, in that my dalvik cache is no longer eating up space in /data. I'd still like to know though, just out of curiosity, do you know what exactly is so wrong with the SVHD framework then, and whether it might be repairable? Just asking out of academic interest
Edit: Never mind... my solution failed to work after all, because the system_lib partition is too small to hold all of my dalvik-cache. Some apps failed to launch and when I looked at logcat I saw 'no space left on device' messages while it was running dexopt

Categories

Resources