[DATA] Note4 QMG / converted to PNG - Android

source : Note4 Korean Version
apks in /system/app, /system/priv-app, /system/framework folder
All QMG images are converted to PNG
Let's Theme It !!
Have FUN !!
https://www.mediafire.com/?13bircd90fm6xl3
** replace .qmg with same-named .png in apk
- works fine....

Unreal...u r a madman. Downloading now, assuming u r say on all the image extensions originally were .qmg but in the dump they r .PNG so we can use cs6, as we theme each as indivual file resave as .qmg correct?

wally3614 said:
Unreal...u r a madman. Downloading now, assuming u r say on all the image extensions originally were .qmg but in the dump they r .PNG so we can use cs6, as we theme each as indivual file resave as .qmg correct?
Click to expand...
Click to collapse
AGREED!....mind sharing this secret to conversion?!?!?!?!?

converted with my phone
jimmydene84 said:
AGREED!....mind sharing this secret to conversion?!?!?!?!?
Click to expand...
Click to collapse
http://forum.xda-developers.com/chef-central/android/hint-convert-qmg-image-to-png-image-t2903896
qmg image is a kind of png
no decoding codec we can use
but Samsung mobile has the decoding codec
so... my phone can read qmg ( in many gallery apps ) just after renaming .qmg to .png
and QuickPic re-save as .png format...
DISADVANTAGE of convertsion to png
- qmg has smaller size (about 1/2 )
- qmg rapid speed (max - 7 times than png )
BUT using png images, We can theme....

wally3614 said:
Unreal...u r a madman. Downloading now, assuming u r say on all the image extensions originally were .qmg but in the dump they r .PNG so we can use cs6, as we theme each as indivual file resave as .qmg correct?
Click to expand...
Click to collapse
No We can't make .qmg image.
No encoding codec...
But replaced .png images works fine in apk...
So We can use that apk without .qmg images

hansmoon said:
No We can't make .qmg image.
No encoding codec...
But replaced .png images works fine in apk...
So We can use that apk without .qmg images
Click to expand...
Click to collapse
I was dealing with qmg images in my S3 4.4.4 official ROM (yeah, S3 4.4.4 uses QMG because of limited size of system partition).
I found one major difference from PNG - it doesn't use .9. in names of nine-patch images, but still use none-patch images.
It means, you have to find all these converted png images and rename them to .9.png. I even don't know how these nine patches are coded in QMG. Same as in .9.png - black 1-pixel wide lines on the edges?

I appreciate you work but I think that put only PNG instead of Qmg isn't working. For example on my S4 Note 4 stock camera runs, your Png one runs too but you can't see any button so it means that it didn't read the new Png.

sorg said:
I was dealing with qmg images in my S3 4.4.4 official ROM (yeah, S3 4.4.4 uses QMG because of limited size of system partition).
I found one major difference from PNG - it doesn't use .9. in names of nine-patch images, but still use none-patch images.
It means, you have to find all these converted png images and rename them to .9.png. I even don't know how these nine patches are coded in QMG. Same as in .9.png - black 1-pixel wide lines on the edges?
Click to expand...
Click to collapse
my S3
- 9.pmg
- png
- no qmg
S4
- 9.png
- qmg
- no png
Your S3 ???
- png
- qmg
image.9.png in my phone
so I don't have any problem
** .png anf 9.png had same magic file head.
9.png has npTc chunk bytes betweem file header and image data
you can check it in hex editor.

Albe95 said:
I appreciate you work but I think that put only PNG instead of Qmg isn't working. For example on my S4 Note 4 stock camera runs, your Png one runs too but you can't see any button so it means that it didn't read the new Png.
Click to expand...
Click to collapse
aapt list -a file.apk results :
resource 0x7f0201b1 com.google.android.apps.plus:drawable/hp_ll_20: t=0x03 d=0x000000d3 (s=0x0008 r=0x00)
drawable image described without any ext.
So I replaced .qmg with .png
I don't know any difference in Note4
BUT some devices have no problem S3, Note2, S4 ...
I think ... (may be)
Decompile - Replace - Recompile
it Will Works FINE.
** needs RECOMPILE

hansmoon said:
my S3
- 9.pmg
- png
- no qmg
S4
- 9.png
- qmg
- no png
Your S3 ???
- png
- qmg
image.9.png in my phone
so I don't have any problem
** .png anf 9.png had same magic file head.
9.png has npTc chunk bytes betweem file header and image data
you can check it in hex editor.
Click to expand...
Click to collapse
It's very interesting! Can you tell which S3 ROM you've checked?
My ROM is I9305XXUFNI3. There are no *.pmg files in resources (i've checked SecMms, SecSettings, SecContacts, SecPhone). Only *.qmg. And there are no *.9.qmg either. So all images are simply *.qmg. If i want to replace it to .png then i have to discover by myself if it should be simple png or 9.png.
I'm using Apktool v2.0.0-625d04-SNAPSHOT (should be pre-rc2, i've compled by myself). What version of Apktool you're using?
---------- Post added at 09:15 AM ---------- Previous post was at 09:09 AM ----------
Argghhh.. i see where is the problem!
I've just unzipped one of original apk - and i see 9.qmg (not 9.pmg) there.
Thus i need to update Apktool to not let it rename 9.qmg to qmg.
Another interesting thing: android works with 9.qmg as qmg without problem (with correct resizing).

E210SKSUKNI3
E210S - Korean Version I9305, BUT fstab is COMPATIBLE I9300
in my phone No .qmg, 9.qmg
only .png and 9.png
SO~ no any apktool problem

hansmoon said:
E210SKSUKNI3
E210S - Korean Version I9305, BUT fstab is COMPATIBLE I9300
in my phone No .qmg, 9.qmg
only .png and 9.png
SO~ no any apktool problem
Click to expand...
Click to collapse
You can check my signature - my S3 is also E210, but i've made custom ROM from I9305 ROM to get rid of all Korean customizations.
Anyway, we are talking about QMG file format. Now i know where is the problem.

hansmoon said:
so... my phone can read qmg ( in many gallery apps ) just after renaming .qmg to .png
and QuickPic re-save as .png format...
Click to expand...
Click to collapse
can you explain how to mass-re-save the images?
Also, it looks like you will loose 9-patches after re-save. Original 9-patch png (and 9.qmg as well) in apk has special header about patches. Apktool convert it to stripes at the edges of image. But, if you save 9.png (9.qmg originally) then you will loose original header and also image won't have stripes. Thus you cannot use neither directly by re-zipping the APK nor in apktool.

sorg said:
can you explain how to mass-re-save the images?
Also, it looks like you will loose 9-patches after re-save. Original 9-patch png (and 9.qmg as well) in apk has special header about patches. Apktool convert it to stripes at the edges of image. But, if you save 9.png (9.qmg originally) then you will loose original header and also image won't have stripes. Thus you cannot use neither directly by re-zipping the APK nor in apktool.
Click to expand...
Click to collapse
I converted thousands of .qmg images USING shell script.
I made script that extraxt only .qmg ( using 7z binary)
and then send intent QuickPic CropActivity
for...
am start -W -a android.intent.action.VIEW -n com.alensw.PicFolder/.CropActivity -d "file://..........png"
And touch event...
done
like this...
And I converted .qmg to .png ONLY.
There is no .9.qmg in My S3 Firm and Note4 Firm.
(All Nine Patch images are .9.png format filename)
Sorry~
this is my script
(7za zipalign binary needed)
sh - /sdcard/Download/modding
input
app - /sdcard/Download/modding/app
priv-app - /sdcard/Download/modding/priv-app
output
conv_app - /sdcard/Download/modding/app
conv_priv-app - /sdcard/Download/modding/priv-app
(output apk contains only res folder, converted .png images from .qmg)
#!/system/bin/sh
dir=/sdcard/Download/modding
cd $dir
N='\e[0m'
black='\e[0;30m'
green='\e[1;32m'
yellow='\e[1;33m'
purple='\e[1;35m'
cyan='\e[1;36m'
white='\e[1;37m'
bins="busybox 7za zipalign"
for binary in $bins ; do
bin=`which $binary`
if [ -z $bin ]
then
echo
echo ${yellow}"No $binary Binary."
echo "Needs : "$bins${N}
exit
fi
done
clear
echo
ltup="┌" ; rtup="┐"
ltlo="└" ; rtlo="┘"
hori="─" ; vert="│"
box() {
isko=
msg=$1
isko=$2
msglen=${#msg}
if [ "$isko" = "k" ] ; then
msglen=$(( msglen * 2 / 3 ))
elif [ "$isko" -gt 0 ] ; then
msglen=$isko
fi
boxwidth=$((msglen+2))
echo -n $ltup
for i in `seq 1 $boxwidth` ; do
echo -n $hori
done
echo $rtup
echo $vert" "$msg" "$vert
echo -n $ltlo
for i in `seq 1 $boxwidth` ; do
echo -n $hori
done
echo $rtlo
}
echo ${cyan}"╔══════════════════════════════╗"
echo "║ QMG Image Converter. - MELFY ║"
echo "╚══════════════════════════════╝"${N}
echo
conv_qmg() {
echo ${yellow}"APK : "$apkname${N}
echo
isqmg=$( 7za l -tzip $apkname | grep ".qmg" )
if [ -z "$isqmg" ] ; then
echo ${purple}"No qmg image in APK."${N}
echo
return 1
fi
rm -rf res
7za x -tzip $apkname res/*.qmg -r -y > /dev/null 2>&1
qmgs=$( find ./res -iname "*.qmg" )
qcnt=$( echo $qmgs | wc -w )
tqcnt=0
for j in $qmgs ; do
echo ${green}${j##*/}${N}
echo
(( tqcnt += 1 ))
echo ${cyan}$tqcnt" / "$qcnt${N}
pngname=${j/.qmg/.png}
tmpname=${pngname/.png/~01.png}
fpath=${j%/*}
fname=${j##*/}
onlyname=${fname%.*}
mv $j $fpath"/"$onlyname".png"
fullpath=$( echo $fpath | sed "s/^.//" )
fullpath=$dir"/"$fullpath
am start -W -a android.intent.action.VIEW -n com.alensw.PicFolder/.CropActivity -d "file://"$fullpath"/"$onlyname".png" > /dev/null 2>&1
input tap 700 100
#pid_jobs=`jobs -p`
#pid_jobs=$!
#sleep 3
#rm -f $pngname
wait #$pid_jobs
if [[ $tqcnt -le 3 ]] ;
then
sleep 2
fi
mv $tmpname $pngname
rm -f $tmpname
echo $tmpname
echo
done
#7za d -tzip $apkname res/*.qmg -r -y > /dev/null 2>&1
7za a -tzip $apkname".tmp" res -y > /dev/null 2>&1
mv $apkname".tmp" $apkname
zipalign -f 4 $apkname aligned_$apkname
mv aligned_$apkname $apkname
touch $apkname
(( cnt += 1 ))
echo ${yellow}" $cnt / $tcnt"
rm -rf res
cp $apkname $fol
#rm -f $apk
}
count_qmg() {
echo
echo $1
cnt_qmg=$( 7za l -tzip $1 | grep ".qmg" | wc -l )
total_qmg=$((total_qmg+cnt_qmg))
#echo $cnt_qmg
#echo $total_qmg
}
out="/dev/null"
quickpic="/data/app/com.alensw.PicFolder*.apk"
isapp=$( ls $quickpic )
if [ -z "$isapp" ] ; then
echo
echo ${purple}"Quickpic app Must Be Installed."${N}
exit
fi
rm -rf res
mkdir -p conv_app
mkdir -p conv_priv-app
applist=$( find $dir/app -type f -iname "*.apk" | sort )
papplist=$( find $dir/priv-app -type f -iname "*.apk" | sort )
tapplist=$applist" "$papplist
acnt=$( echo $applist | wc -w )
pacnt=$( echo $papplist | wc -w )
tcnt=$((acnt+pacnt))
total_qmg=0
cnt_qmg=0
for cqmg in $tapplist ; do
count_qmg $cqmg
echo -n " Total : "$total_qmg" : "$cnt_qmg" "\\r
done
echo
echo
echo ${green}"APK LIST"${N}
echo
echo "APK in app folder : "$acnt
echo "APK in priv-app folder : "$pacnt
echo "Total APKs COUNT : "$tcnt
echo
echo "Total qmg images : "$total_qmg
echo
echo -n "OK? (y/n)" ; read ok
if [ "$ok" != "y" ] ; then
echo
echo ${purple}"Canceled..."${N}
echo
exit
fi
cnt=0
for sa in $applist; do
fol="./conv_app/"
apk=$sa
apkname=${apk##*/}
cp $apk .
conv_qmg $apkname
rm -f $apkname
done
echo
for spa in $papplist; do
fol="./conv_priv-app/"
apk=$spa
apkname=${apk##*/}
cp $apk .
conv_qmg $apkname
rm -f $apkname
done
echo
echo
echo ${cyan}"Finished."${N}
echo
echo ${cyan}"════════════════════════════════"${N}
exit

Well... I think it's better to write small app for android which will simply load picture and save it back. For 9-patch pics need to check aapt source and simply copy the header (it looks like 9-patch qmg header is the same as in png). Or just produce png with stripes like apktool does.

Can anybody send me the system/APP/CoverService.apk?
Sent from my SM-N910C using XDA Premium HD app

without RE-compile
Replacing .qmg file with .png
RENAME converted & modified your own .png to same named .qmg
THROW into apk & Replace ORIGINAL .qmg
Sent from my SHV-E210S using XDA Free mobile app

I've posted simple converter http://forum.xda-developers.com/note-4/themes-apps/tool-converter-qmg-png-t2916486

thanks
Sent from my SHV-E210S using XDA Free mobile app

Related

[Q] Has anybody know how to root GT-I9001

Hi,
Is there some way to root I9001 now or I have to wait.
Firmware I9001XXKE8
Android 2.3.3
Kernel 2.6.35.7
I tried several methods (Superoneclick 1.7, 1.9.1, Gingerbreak 1.2) available for I9000 but nothing positive.
If someone can guide me in this process will be very appreciated.
Go here for step by step instructions: http://androidhogger.com/how-to-root-samsung-galaxy-s2-heres-the-tutorial.html.
Hi,
It is guide for I9100 but I have I9001 it is completely different hardware, so I doubt that the same guide can be applied to I9001.
Any news on rooting? Have you sucseeded?
No, still waiting, but it starts to sell to mass in Russia so soon will get news.
Since yesterday the new 2.3.4 firmware is out:
http://netload.in/datei5X4ZyAkNkO/I9001XXKP4_v2.3.4.rar.htm
(edit: maybe its not 2.3.4 ... samfirmware write 2.3.3)
... but we wait still for the root...
SPOOKY
afaik 2.3.x cannot be rooted. only 2.2.x
sweetnsour said:
afaik 2.3.x cannot be rooted. only 2.2.x
Click to expand...
Click to collapse
Say what? Ofcourse 2.3.x can be rooted. We just have to get more attention to the 9001 so that the rom builders actively start devving this device.
Any one knows how to root this device?
Sent from my GT-I9001 using XDA Premium App
I'm looking for a solution as well, please don't make me use Touchwiz..
Have tried to look into ways to root this phone. It looks like it'll need to be root in similar way to i9100. So guess will need to wait for dev to come up with a special kernel for rooting.
İ hope they they ll come up with new karnel as soon.as possible
Sent from my GT-I9001 using Tapatalk
sweetnsour said:
afaik 2.3.x cannot be rooted. only 2.2.x
Click to expand...
Click to collapse
Here http://forum.xda-developers.com/archive/index.php/t-1136781.html is afaik 2.3.3 rotted. I think there is a posibility to root I9001.
I hope so ....! Did u try this method?
Sent from my GT-I9001 using Tapatalk
westcrip said:
I hope so ....! Did u try this method?
Sent from my GT-I9001 using Tapatalk
Click to expand...
Click to collapse
Nope but I will try in this weekend. I found how to restore phone when you brick it (if something happen) , and it's not so hard. That's why I will use different method to root it. I just wonder if one of brick is avilable or more. I only know how to unbrick by this method http://www.youtube.com/watch?v=2qB4RNoXTd8 . Its very simple just install software downoladed from http://www.samfirmware.com/WEBPROTECT-i9001.htm our software is in the middle I9001XXKF8 ##. Odin as well recognize my phone.
I have managed it to root the i9001. So far it is very complicated, and the detailed guide as well as the analysis of SMD archives is only in German available:
http://www.android-hilfe.de/samsung...g-galaxy-s-plus-i9001-rooten.html#post1911955
As always: You are responsible for your Phone! If someone bricks his device using this guide, I am not responsible for that! Bad Luck, I have warned you! Its a dangerous job! You really shouldn't do it.
In short:
- extract the PDA SMD File
- mount system.ext4
- copy su binary and Superuser.apk into the mounted image
- adjust the file permissions (especially the suid bit for su)
- umount system.ext4
- repack the PDA SMD.
I have created two Linux bash scripts for extracting and packing SMD Archives. Warning: I'm not very experienced in bash scripting. If someone is here who is capable of making a nice script of it, feel free! The scripts are working, that's all so far. They won't win a price in a beauty contest.
First the extract.sh:
Code:
#!/bin/bash
base=0
length=1
while (( length > 0 ))
do
# calculate Length
let "skip = base + 18"
length=`hexdump -e '"%d"' -s ${skip} -n 2 ${1}`
let "length = length * 65536"
let "skip = base + 16"
length2=`hexdump -e '"%d"' -s ${skip} -n 2 ${1}`
let "length += length2"
let "length = length / 512" # Number of 512-Byte blocks
# calculate offset
let "skip = base + 22"
offset=`hexdump -e '"%d"' -s ${skip} -n 2 ${1}`
let "offset = offset * 65536"
let "skip = base + 20"
offset2=`hexdump -e '"%d"' -s ${skip} -n 2 ${1}`
let "offset += offset2"
let "offset = offset / 512" # Number of 512-Byte blocks
# save header in case of first loop
if (( base == 0 ))
then
dd if=${1} bs=512 of=header count=${offset}
fi
# extract filename
let "skip = base + 32"
filename=`dd if=${1} skip=${skip} count=16 bs=1 2>/dev/null`
# and finally: extract image
if (( length > 0 ))
then
echo "Length: ${length}"
echo "Offset: ${offset}"
echo "Filename: ${filename}"
dd if=${1} bs=512 of=${filename} skip=${offset} count=${length} 2>/dev/null
fi
# next header
let "base += 64"
done
Syntax: ./extract.sh Archive.smd
The script will extract the archive and create a lot of local files (system.ext, boot.img and so on). Well, the content of the Archive obviously.
Root the system.ext4:
I have used the newest su and Superuser.apk from here (3.0-beta4 at the moment. Newer ones should be ok):
http://goo-inside.me/superuser
The steps for rooting a system.ext4:
Code:
mkdir system
sudo mount -o loop system.ext4 system
sudo cp su system/xbin/
sudo chown 0.0 system/xbin/su
sudo chmod 4755 system/xbin/su
sudo cp Superuser.apk system/app/
sudo chown 0.0 system/app/Superuser.apk
sudo chmod 644 system/app/Superuser.apk
sudo umount system
And the pack.sh. Note: The pack.sh so far expects an existing "header" file created from an extract action and all files to be added into the archive. The resulting archive will have the same contents, as the starting archive (of course with a modified system.ext4). MD5 Checksums in the archive are calculated automatically.
Code:
#!/bin/bash
base=16
length=0
filename=dummy
# save the beginning
dd if=header of=newheader bs=1 count=16 2>/dev/null
# First create the MD5 checksums of all included (and maybe modified) files and generate the new header
while [ ! -z "${filename}" ]
do
# Length, offset, etc. is unchanged, just copy it.
let "skip = base"
dd if=header of=newheadertmp bs=1 skip=${skip} count=32 2>/dev/null
cat newheadertmp >> newheader
rm newheadertmp
# extract filename
let "skip = base + 16"
filename=`dd if=header skip=${skip} count=16 bs=1 2>/dev/null`
if [ ! -z "${filename}" ]
then
echo "creating MD5Sum of: ${filename}"
checksum=`md5sum ${filename} | tr '[a-z]' '[A-Z]'`
echo -n ${checksum:0:32} >> newheader
fi
# next header
let "base += 64"
done
# save the rest of the old header.
filesize=$(stat -c%s header)
let "base -= 32"
let "size = filesize - base"
dd if=header of=newheadertmp bs=1 skip=${base} count=${size} 2>/dev/null
cat newheadertmp >> newheader
rm newheadertmp
# the new header is the first content of the new archive.
cat newheader > ${1}
# now add all files to the archive.
filename=dummy
base=16
while [ ! -z "${filename}" ]
do
# extract filename
let "skip = base + 16"
filename=`dd if=header skip=${skip} count=16 bs=1 2>/dev/null`
if [ ! -z "${filename}" ]
then
echo "Adding: ${filename}"
cat ${filename} >> ${1}
fi
# next header
let "base += 64"
done
rm newheader
Syntax: ./pack.sh Archive.smd
Flash the resulting .smd files using Odin Multi Downloader an be happy about a rooted SGS Plus.
Note: The procedure has been tested with European KF6 and KP4 firmware. the scripts are capable of extracting and packing other SMD Archives as well, like Modem or CSC SMDs. But you don't need it for rooting (but maybe for debranding or customizing ROMs).
I'm thinking about an simpler root method like a modified kernel with a "magic" initramfs (like CF Root is working). This would make rooting of course much easier. But I have to investigate a lot of things handling boot.imgs.
Nice one RiverSource! Let's hope this is the start of more to come (ie. easier root, custom roms..).
Hello,
ok, next step for rooting the SGS Plus: The FMROOT (hehe). FMROOT is the original untouched Samsung Kernel with a modified init.rc. The init.rc calls a script which places the su binary and the Superuser.apk into the /system partition.
As always: You are responsible for your Phone! If someone bricks his device using this guide, I am not responsible for that! Bad Luck, I have warned you! Its a dangerous job! You really shouldn't do it.
Howto:
Download the appropriate file for your firmware.
Extract it
There should be 2 Files: AriesVE.ops and FMROOT_?????.smd
Use Odin Multi Downloader
Put "AriesVE.ops" in OPS
Put "FMROOT_?????.smd" in PDA
Flash. Wait 5 Seconds. Phone reboots. Phone is rooted. Normally without loosing data or settings.
Please ask here, if your Firmware is not available. It should be possible to create an appropriate FMROOT Kernel.
Credits:
astuermer for pointing me to the correct su and Superuser binaries.
Chainfire here from XDA Developers. My script is based on the CF-Root
Paul from Madaco. I had a closer look into his "superboot".
Lots and Lots of Custom ROM Developers for i9000 and i9100. I have learned a lot about Android Images on Samsung phones from them.
For the developers: the FMBOOT Script called by init.rc:
Code:
mount -o rw,remount -t ext4 /dev/block/mmcblk0p15 /system
rm /system/xbin/su
rm /system/bin/su
mkdir /system/xbin
cat /fmboot/su > /system/xbin/su
chmod 4755 /system/xbin/su
cat /fmboot/Superuser.apk > /system/app/Superuser.apk
mount -o ro,remount -t ext4 /dev/block/mmcblk0p15 /system
And the calling code inside the init.rc:
Code:
start fmboot
class_start default
## Daemon processes to be run by init.
##
service fmboot /system/bin/sh /fmboot/fmboot.sh
user root
group root
oneshot
If someone is interested, I can post a howto on modifying boot.imgs for SGS Plus. Don't hesitate to ask. BTW, i have also coded a script which is capable of generating SMD archives with any content (not based on a previous SMD archive). I can also post it, if someone is interested.
I think, I will optimize the script in the future. Checking if the phone is already rooted and skip the thing for example. Or adding busybox. Are there any additional ideas?
Thank you very [email protected]@@@ Come on!
THX, THX,..
It works, rooted..!!

need help to translate MIUI V4 (ICS)

Hi,
i tried to translate a MIUI for Galaxy Nexus rom into french (can also be an other language)
i wrote an unix script to automate the process.
What i do is quite simple:
i get a specific MIUI V4 version for my device and the same translated version for the nexus S (because the nexus S has a french version)
i decompile each apk from the french rom, an put the french files into to decompile galaxy nexus directories
i recompile each apk
and i copy the compiled resources into the origin galaxy nexus apks
and i build the new ROM
but i get a bootloop any ideas ?
here is my script
if there are any part of this script that isn't clear, i could try to explain them.
of course this script could also be used on other device or other translation with some changes.
Thanks in advance .
Code:
#!/bin/bash
# MIUI-FRENCH TRANSLATE SCRIPT FOR GNEX V1.0 By Alain57
BASE_DIR=$PWD
FRENCH_DIR=$BASE_DIR/french_rom
ORIGINAL_DIR=$BASE_DIR/original_rom
OUTPUT_ROM_DIR=$BASE_DIR/output_rom
OUT_DIR=$BASE_DIR/out
WORK_DIR=$BASE_DIR/workdir
ORIGIN_APK_DIR=$WORK_DIR/origin
TRANSLATION_DIR=$WORK_DIR/translation
DECODED_APK_DIR=$WORK_DIR/decoded
LOG_FILE=$BASE_DIR/log.txt
TEMP_DIR=$BASE_DIR/temp
# clean the log file and create the missing directories if they don't exist (for exemple on first run)
function cleanLog(){
rm -fr $LOG_FILE
ARRAY_DIR=( $FRENCH_DIR $ORIGINAL_DIR $OUTPUT_ROM_DIR $OUT_DIR $WORK_DIR $ORIGIN_APK_DIR $TRANSLATION_DIR $DECODED_APK_DIR $TEMP_DIR )
echo "creating missing directoriesi if needed"
for DIR in ${ARRAY_DIR[@]}; do
if [ ! -d $DIR ]; then
mkdir $DIR
fi
done
}
# configure apktool to use framework-res and framework-miui-res
function setFramework(){
cd $FRENCH_DIR
echo "<- apktool if system/framework/framework-res.apk ->" >> $LOG_FILE
apktool if framework-res.apk >> $LOG_FILE 2>&1
echo "<- apktool if system/framework/framework-miui-res.apk ->" >> $LOG_FILE
apktool if framework-miui-res.apk >> $LOG_FILE 2>&1
}
#decompile all apk file from the english Gnex miui rom
function decompileOriginFiles(){
cd $ORIGINAL_DIR
COUNT_ORIGINAL_ZIP=`ls . | grep '.zip' | wc -l`
if [ "$COUNT_ORIGINAL_ZIP" -eq "1" ]; then
mv *.zip en.zip
echo "unzip the original rom"
unzip -q -o en.zip
echo "copy the apks to the origin dir"
cp -a system/framework/*.apk $ORIGIN_APK_DIR
cp -a system/app/*apk $ORIGIN_APK_DIR
cd $ORIGIN_APK_DIR
for F in *.apk; do
echo "decompiling origianl file $F ..." | tee -a $LOG_FILE
apktool d $F $DECODED_APK_DIR/${F%.apk} >> $LOG_FILE 2>&1
done
else
echo "there need to be ONE zip file in the original directory"
exit
fi
}
# decompile all apk files from the french Nexus S ROM
function decompileTranslatedFiles(){
cd $FRENCH_DIR
COUNT_FRENCH_ZIP=`ls . | grep '.zip' | wc -l`
if [ "$COUNT_FRENCH_ZIP" -eq "1" ]; then
mv *.zip fr.zip
echo "unzip the french rom"
unzip -q -o fr.zip
setFramework
echo "copy the apks to the working dir"
cp -a system/framework/*.apk $WORK_DIR
cp -a system/app/*.apk $WORK_DIR
cd $WORK_DIR
for F in *.apk; do
echo "decompiling french file $F ..." | tee -a $LOG_FILE
apktool d $F $TRANSLATION_DIR/${F%.apk} >> $LOG_FILE 2>&1
done
else
echo "there neeed to be ONE zip file in the french directory"
exit
fi
}
# Delete the given directory, because it is not needed
function deleteDirectoryWithoutTranslation(){
echo " ---> directory useless, removed"
cd $TRANSLATION_APK_DIR
rm -fr $1
}
# delete all useless data from the french apks
function cleanTranslatedFiles(){
cd $TRANSLATION_DIR
for d in *; do
echo "cleaning the directory $d"
cd $TRANSLATION_DIR/$d
if [ -d "res" ]; then
ls . | grep -v res | xargs -o rm -fr
cd "res"
CONTAINS_FRENCH_TRANSLATION=`ls .| grep '\-fr' | wc -l`
if [ "$CONTAINS_FRENCH_TRANSLATION" -eq "0" ]; then
deleteDirectoryWithoutTranslation $d
else
echo "---> transltation here, clean it"
ls . | grep -v '\-fr\|\./\|\.\./' | xargs -o rm -fr
fi
else
echo "no res directory"
deleteDirectoryWithoutTranslation $d
fi
if [ ! -f $ORIGIN_APK_DIR/$d.apk ];then
echo "directory not in original rom $d"
deleteDirectoryWithoutTranslation $d
fi
done
}
# merge the decoded translation in the decoded english files
function mergeTranslations(){
cd $DECODED_APK_DIR
mv $TRANSLATION_DIR/* .
cd $WORK_DIR
rm -f *.apk
}
# compile new apks including french files
function compileApk(){
cd $ORIGIN_APK_DIR
for f in *.apk; do
echo "compiling $f"
echo "apktool b $DECODED_APK_DIR/${f%.apk} $WORK_DIR/$f"
apktool b $DECODED_APK_DIR/${f%.apk} $WORK_DIR/$f >> $LOG_FILE 2>&1
done
}
# delete apk in work directory and put the original apks there
function deleteWorkFileAndCopyOriginalApk(){
cd $WORK_DIR
rm -f *.apk
cp -a $ORIGIN_APK_DIR/*.apk .
}
# put the compiled modified files in the original apk files
function finalMerge(){
cd $DECODED_APK_DIR
for F in *.apk; do
echo "doing final build $F"
cd $TEMP_DIR
rm -fr *
unzip -q $DECODED_DIR/$F
ls . | grep -v 'res\|classes.dex\|resources.arsc\|\./\|\.\./' | xargs -o rm -fr
if [ -d res ]; then
cd res
ls . | grep -v '\-fr\|\./\|\.\./' | xargs -o rm -fr
HAS_FR=`ls . | grep '\-fr' | wc -l`
if [ "$HAS_FR" -eq "0" ]; then
cd ..
rm -fr res
else
cd ..
fi
fi
zip -r $WORK_DIR/$F *
done
}
#replace the english apk files with the new french apk files, change the build.prop value and create an unsigned zip that can be flashed
function createRom(){
cd $OUTPUT_ROM_DIR
mv $ORIGINAL_DIR/system $ORIGINAL_DIR/boot.img $ORIGINAL_DIR/META-INF .
mv $WORK_DIR/*.apk system/app
mv system/app/framework*.apk system/framework
mv system/build.prop build.prop
sed 's/=en/=fr/g' build.prop > build1.prop
rm -f build.prop
sed 's/=US/=FR/g' build1.prop > system/build.prop
rm -f build1.prop
zip -r $BASE_DIR/new_rom.zip *
}
cleanLog
decompileTranslatedFiles
decompileOriginFiles
cleanTranslatedFiles
mergeTranslations
compileApk
deleteWorkFileAndCopyOriginalApk
finalMerge
createRom
Questions or Problems Should Not Be Posted in the Development Forum
Please Post in the Correct Forums & Read the Forum Rules
Moving to Q&A

Deodex

As of now I have all of the sys apps deodexed and about half of the framework deodexed. I'm working to find out why i cannot complete the framework deodex. I will edit this post with downloads as I go. The first edit will be the deodexed apk's and the partial on the framework. just need to get them uploaded first.
Current thanks list is:
abcdjdj- Universal Deodexer V4
Alokbina- Universal Deodexer V4
framework- http://www.androidfilehost.com/?fid=23134718111253137
apps- http://www.androidfilehost.com/?fid=23134718111253138
xkwr27 said:
As of now I have all of the sys apps deodexed and about half of the framework deodexed. I'm working to find out why i cannot complete the framework deodex. I will edit this post with downloads as I go. The first edit will be the deodexed apk's and the partial on the framework. just need to get them uploaded first.
Current thanks list is:
abcdjdj- Universal Deodexer V4
Alokbina- Universal Deodexer V4
framework- http://www.androidfilehost.com/?fid=23134718111253137
apps- http://www.androidfilehost.com/?fid=23134718111253138
Click to expand...
Click to collapse
I managed to fully deodex this ROM: P5200XXUAMG7_P5200OXXAMG4_XEH.zip (it's for P5200 3G model)
Here is the script I wrote for deodexing:
Code:
#!/bin/bash
for f in *.odex; do
no_ext=`echo $f | sed 's/.odex//'`
echo "deodexing $no_ext"
java -Xmx512m -jar /home/android/bin/baksmali-2.0b6.jar -a 17 -d ../system/framework -x $no_ext.odex
java -Xmx512m -jar /home/android/bin/smali-2.0b6.jar -a 17 -o classes.dex out
rm -rf out
if [ -e $no_ext.apk ]
then
zip -r -q $no_ext.apk classes.dex
fi
if [ -e $no_ext.jar ]
then
zip -r -q $no_ext.jar classes.dex
fi
rm -rf classes.dex
done
I used the latest baksmali and smali. It showed some error messages for Dropbox.odex and Magazines.odex files, but these two can be deodexed as well if you remove the -a switch from baksmali and smali lines.
Hope this helps.
Thanks if you have it linked anywhere on here I'll have to look at it to make sure I am not trying to do the same work twice. but in the mean time I'll give that script a try.
I have all deodexed...
But I have a update-binary issue that lets me not install a custom rom.
Status 7
set_perm issue
or
set_symlink issue
xkwr27 said:
As of now I have all of the sys apps deodexed and about half of the framework deodexed. I'm working to find out why i cannot complete the framework deodex. I will edit this post with downloads as I go. The first edit will be the deodexed apk's and the partial on the framework. just need to get them uploaded first.
Current thanks list is:
abcdjdj- Universal Deodexer V4
Alokbina- Universal Deodexer V4
framework- http://www.androidfilehost.com/?fid=23134718111253137
apps- http://www.androidfilehost.com/?fid=23134718111253138
Click to expand...
Click to collapse
i was looking for this.. but i cant downlaod it its telling me " no mirror found" but only with this file
framework- http://www.androidfilehost.com/?fid=23134718111253137
johnso said:
i was looking for this.. but i cant downlaod it its telling me " no mirror found" but only with this file
framework- http://www.androidfilehost.com/?fid=23134718111253137
Click to expand...
Click to collapse
Well I've deleted them now... Dutch dany has them completed up in a post anyway, that's why I never bothered finishing.
Oohh to bad because the one you hsve is for p5200and the one from dutchdanny is for p5210
I just need the framework data ..
Sent from my GT-P5200 using xda app-developers app
xmaczi123 said:
I managed to fully deodex this ROM: P5200XXUAMG7_P5200OXXAMG4_XEH.zip (it's for P5200 3G model)
Here is the script I wrote for deodexing:
Code:
#!/bin/bash
for f in *.odex; do
no_ext=`echo $f | sed 's/.odex//'`
echo "deodexing $no_ext"
java -Xmx512m -jar /home/android/bin/baksmali-2.0b6.jar -a 17 -d ../system/framework -x $no_ext.odex
java -Xmx512m -jar /home/android/bin/smali-2.0b6.jar -a 17 -o classes.dex out
rm -rf out
if [ -e $no_ext.apk ]
then
zip -r -q $no_ext.apk classes.dex
fi
if [ -e $no_ext.jar ]
then
zip -r -q $no_ext.jar classes.dex
fi
rm -rf classes.dex
done
I used the latest baksmali and smali. It showed some error messages for Dropbox.odex and Magazines.odex files, but these two can be deodexed as well if you remove the -a switch from baksmali and smali lines.
Hope this helps.
Click to expand...
Click to collapse
Thanks for the info about the "a" option. Ran in to this dilemma earlier.

Guide: Fix WhatsApp Images mess after restoring backup

Hey there
Thought this might help some of you finding yourself in a huge mess because WhatApp restores all its media with the date the restore takes place. I wrote a little shellscript you can run in "adb shell". Just paste it into the shell and run it inside WhatsApps Folders.
In "WhatsApp Images" and it's subfolder "Sent" use this:
Code:
for file in *; do
if [ -f "$file" ]; then
timestamp=$(echo "$file" | sed 's/^IMG-\(.*\)-WA\(...\)\(.\)\..*/\10\2\.0\3/g')
echo $timestamp
echo $file
touch -m -t $timestamp $file
fi
done
For "WhatsApp Animated Gifs" and "WhatsApp Video" use this:
Code:
for file in *; do
if [ -f "$file" ]; then
timestamp=$(echo "$file" | sed 's/^VID-\(.*\)-WA\(...\)\(.\)\..*/\10\2\.0\3/g')
echo $timestamp
echo $file
touch -m -t $timestamp $file
fi
done
Keep the following in mind:
- This code works only if your version of Android allows you to change the modified date of files without root. As far as I know this is the case since Andoid 9
- This code doesn't work if you have files with a WA-Number higher than 0599 as my script doesn't take care to match the number with a proper timeformat.
- This code changes the last modified date of your files like this:
Filename: IMG-20190915-WA0039.jpg
Timestamp: 201909150003.09 -> 20190915 00:03:09
Feedbacks and comments welcome
Greets Air

A script to get a random file

Dear developers,
I have an issue in my script switching from Android 9 to 10 (devices from a Umidigi s3 Pro to a Umidigi F2)
I have installed Bosybox App on the first and Busybox Magisk module on the latter
Now the script does not work because the command
list=(`busybox find "$dirs" -type f -name *.$ext`)
returns an empty array
This is the complete script:
Bash:
#!/system/bin/sh
echo
if test "$1" = ""; then
echo "Randomfile script by Uranya <[email protected]> v1.4 01.01.2021"
echo "Usage:"
echo "sh randomfile.sh <sourcedir> <extension> <destdir>"
exit 1
fi
dirs=$1
ext=$2
dird=$3'/'
dest=$dird'random'
delim1=""
delim2=""
last='last.txt'
# create filename's array
IFS=$'\n'
# here we have the ISSUE
list=(`busybox find "$dirs" -type f -name *.$ext`)
# count number of files
num=${#list[@]}
# initialize random generator
RANDOM=$$
# generate random number in range 1-NUM
let "ran=(${RANDOM} % ${num})+ 1"
echo Random from $num files is $ran
sour=${list[ran]}
sourn=${sour#$dirs}
sourn=${sourn:1:${#sourn}}
date=$(date +"%Y.%m.%d %H:%M")
day=$(date +"%d")
hour=$(date +"%H")
minute=$(date +"%M")
message='---------------------------------------\n'$date' - '$num' >>> '$ran'\n'$delim1$sourn$delim2
if ([ "$day" = "01" ] && [[ "$minute" < "29" ]]) || [ ! -f $dird$last ]; then
echo >$dird$last $message
else
sed -i '1i'$message $dird$last
fi
echo $delim1$sourn$delim2
# rename the old file
cp $dest.$ext $dest'_back.'$ext
# copy the file
cat "$sour" >$dest.$ext
echo File copied as $delim1$dest.$ext$delim2
Can you please help me why this happens, and how to fix it?
Thank you very much for your attention!
Uranya said:
[...]
Click to expand...
Click to collapse
Having done some tests I have found this:
opening a root privileged terminal and executing
---
echo `find /storage/7BC3-1805/Music/MP3/Abba -type f -name *.mp3`
---
it returns two strings containing the names of files inside that folder, but putting it in my script continues to return an empty array, so the issue is not in the access to the folder, but in the syntax, I guess
try putting that *.$ext into quotes...
Dear friends, CXZa, after a couple of hours debugging the script, finally, I have found the mistake!
The line to be used is:
list=( `find "$dirs" -type f -name "*.$ext"` )
it is a very subtle difference: the space after and before the parenthesis!
(even the word busybox is useless)
Oddly in the Busybox app (I have had on my S3 Pro) the spaces are not mandatory, whilst in the Busybox Magisk module those spaces ARE mandatory!
I'm using that script for almost 8 years to have an every day different music for my wake up.
I'm using Tasker to call it just before my alarm get off, so the same file contains every day, a different song.
I have done a change also in the array index that did not began by 0...
So, here it is the right script:
Bash:
#!/system/bin/sh
echo
if test "$1" = ""; then
echo "Randomfile script by Uranya <@uranya7x> v1.5 26.03.2021"
echo "Usage:"
echo "sh randomfile.sh <sourcedir> <extension> <destdir>"
exit 1
fi
dirs=$1
ext=$2
dird=$3'/'
dest=$dird'random'
delim1=""
delim2=""
last='last.txt'
# create filename's array
IFS=$'\n'
list=( `find "$dirs" -type f -name "*.$ext"` )
# count number of files
num=${#list[@]}
# generate random number in range 1-NUM
let "ran=(${RANDOM} % ${num})+ 1"
echo Random from $num files is $ran
sour=${list[$ran-1]}
sourn=${sour#$dirs}
sourn=${sourn:1:${#sourn}}
date=$(date +"%Y.%m.%d %H:%M")
day=$(date +"%d")
hour=$(date +"%H")
minute=$(date +"%M")
message='---------------------------------------\n'$date' - '$num' >>> '$ran'\n'$delim1$sourn$delim2
if ([ "$day" = "01" ] && [[ "$minute" < "29" ]]) || [ ! -f $dird$last ]; then
echo >$dird$last $message
else
sed -i '1i'$message $dird$last
fi
echo $delim1$sourn$delim2
# rename the old file
cp $dest.$ext $dest'_back.'$ext
# copy the file
cat "$sour" >$dest.$ext
echo File copied as $delim1$dest.$ext
I hope it will be useful to someone else that loves to be waked up by music...
Peace everywhere!

Categories

Resources