This mod allows you to replace easily the system fonts
or to move your system fonts to the SD card freeing
some space in the ROM.
First thing to do is to replace libsgl.so with my modified version
or if you prefer compile it yourself after applying the attached patch.
Code:
adb remount
adb shell
cp /system/lib/libsgl.so /system/lib/libsgl.so.bak
mkdir /system/sd/fonts
exit
adb push libsgl.so /system/lib/
adb shell reboot
At reboot the system will check first in
Code:
/system/sd/fonts
if some suitable fonts are found there they will be loaded
else the default fonts in
Code:
/system/fonts
will be loaded.
The fonts in /system/sd/fonts must be named:
Code:
DroidSans.ttf
DroidSans-Bold.ttf
DroidSerif-Regular.ttf
DroidSerif-Bold.ttf
DroidSerif-Italic.ttf
DroidSerif-BoldItalic.ttf
DroidSansMono.ttf
These are optional, and can be ignored if not found in the file system.
DroidSansJapanese.ttf
DroidSansFallback.ttf
You can achieve this by moving or copying the default system fonts,
renaming the fonts you want to use or by a symbolic link e.g.
Code:
cd /system/sd/fonts
ln -s Vera.ttf DroidSans.ttf
I have tested it with DejaVu and DejaVu condensed fonts.
Enjoy and try out your own font combinations.
Related
Hi,
I developed a custom Settings.apk with some changes.I installed it on emulator it woks fine.But when i install on device,after reboot the Settings application is not visible.I checke using ADB whether it is system/app or not,it is in system/app
but not visible.
I tested on LGP350 device
My steps are
1)Rooted the phone using GingerBreak
2)Take backup of Setting.apk,Settings.odex
3)Remove Setting.apk,Settings.odex from system/app
4)Copied my custom Settings.apk to System/app(i have no Settings.odex )
5)Reboot the device
My command sequence is :-
C:\Users\ramkumar\.android\avd\android_simulator.avd>adb shell
$ su
# mount -o remount,rw -t yaffs2 /dev/block/mtdblock1 /system
# chmod 777 system/app
# exit
$ exit
C:\Users\ramkumar\.android\avd\android_simulator.avd>adb push Settings.apk system/app
C:\Users\ramkumar\.android\avd\android_simulator.avd>adb reboot
After reboot there is no Settings app on my device
Hj, how do you install settings.apk on emulator?
Ramkumar Pinninti said:
Hi,
I developed a custom Settings.apk with some changes.I installed it on emulator it woks fine.But when i install on device,after reboot the Settings application is not visible.I checke using ADB whether it is system/app or not,it is in system/app
but not visible.
I tested on LGP350 device
My steps are
1)Rooted the phone using GingerBreak
2)Take backup of Setting.apk,Settings.odex
3)Remove Setting.apk,Settings.odex from system/app
4)Copied my custom Settings.apk to System/app(i have no Settings.odex )
5)Reboot the device
My command sequence is :-
C:\Users\ramkumar\.android\avd\android_simulator.avd>adb shell
$ su
# mount -o remount,rw -t yaffs2 /dev/block/mtdblock1 /system
# chmod 777 system/app
# exit
$ exit
C:\Users\ramkumar\.android\avd\android_simulator.avd>adb push Settings.apk system/app
C:\Users\ramkumar\.android\avd\android_simulator.avd>adb reboot
After reboot there is no Settings app on my device
Click to expand...
Click to collapse
sorry for my english!
Hj, how do you install settings.apk on emulator?
I try to install settings.apk, but It error.
Please tell me how to install it on emulator.
What emulator do you use?
thanks!
In MIUI 2.6.22 themes don't work because the direcory theme does't exist in /data/system
To repair this issue you need:
- MIUI themes version 4 (v4)
- Create the directory theme in /data/system/
To create the directory theme follow this instruction ( from terminal emulator )
[email protected]:/$
[email protected]:/$ su
[email protected]:/# cd /data/system
[email protected]:/data/syste/# mkdir theme
[email protected]:/data/syste/# chown system theme
[email protected]:/data/syste/# chgrp system theme
Also you can use a root explorer like ES File Explorer to create the directory
If you copied melodies to system folder and you want to save it on all contacts after update firmware you need:
1. Make text file and save it as melody.sh with this text:
Code:
#!/bin/sh
cp ring/alarms/* /system/media/audio/alarms
cp ring/ringtones/* /system/media/audio/ringtones
cp ring/notifications/* /system/media/audio/notifications
chmod 644 /system/media/audio/alarms/*
chmod 644 /system/media/audio/ringtones/*
chmod 644 /system/media/audio/notifications/*
2. Make folder with name ring on your internal or external sdcard and copy melody.sh near this folder
3. Make in this folder empty .nomedia file to prevent melody's duplicate
4. Make also folders alarms, ringtones, notifications.
5. After update firmware in TWRP-Advanced-Terminal Command, select your sdcard . Write sh melody.sh
6. All done.
Lollipop deodexing
Deodexing apk's on lollipop is almost as simple as API < 21 and only invoves two extra steps.
The workflow for the new deodex process is as follows below. The <arch> is the architecture for the apk being deodexed.
oat2dex boot system/framework/<arch>/boot.oat
oat2dex <path/to/app/<arch>/app.odex> system/framework/<arch>/odex
baksmali as normal
smali as normal
The actual behind-the-scenes info
ART changes things with its 'Ahead of Time Compiling'. Android creates a boot.oat on boot containing the classpath jars that apks
link against for functionality. Before these the .odex for the classpath was compatible with baksmali/smali, but due to changes with
ART vs Dalvik this is no longer the case now. The classpath needs to extracted from the boot.oat. The resulting dex/ and odex/ are then
used to create a bootclasspath that can be used to create a baksmali/smali compatible odex, by essentially deoptimizing it. Once
the compatible odex is created, baksmali and smali can be used like normal - even allowing smali edits to exisiting APKs.
A working (manual) example
To get started you will need to pull the framework directory off the device.
Code:
mkdir framework
cd framework
adb pull system/framework
The next step is to pull the app's folder from system/app or system/priv-app.
For this example I will be using SecSettings2.apk from a Samsung Galaxy S6.
Code:
mkdir SecSettings2
cd SecSettings2
adb pull /system/priv-app/SecSettings2
The next step is to determine the architecture of the apk to be deodexed. This is done checking whether the directory that the
apk's folder contents were extracted to contains an arm or arm64 folder (32-bit or 64-bit, respectively).
The SecSettings2.apk is 64-bit as its folder contains an arm64 folder.
Once the architecture is determined, the next step is to extract the classpath from boot.oat. Replace arm64 with arm below
if your app is only 32-bit.
Code:
oat2dex boot framework/arm64/boot.oat
This will extract the classpath from the boot.oat and place the dex and odex into separate directories in framework/<arch>.
Now the classpath can be used to create a compatible odex that baksmali and smali is compatible with. Note that the result odex
will have a .dex extension. This is NOT to be placed into the apk as the app will NOT work.
Code:
oat2dex SecSettings2/arm64/SecSettings2.odex framework/arm64/odex
We now have a odex (labled SecSettings2.dex in SecSettings2/) that is compatible with baksmali and smali.
To baksmali the odex:
Code:
baksmali -a 21 -x SecSettings2.dex -d framework -o smali/SecSettings2
To deodex the smali into a dex:
Code:
smali smali/SecSettings2
The last command outputs a classes.dex that is going to go into the apk.
Code:
zip -gjq SecSettings2 classes.dex
Now we need to remove the arm or arm64 folder from the apk's location on the device.
Code:
adb shell su -c 'mount -o remount,rw /system'
adb shell su -c 'rm -rf system/priv-app/SecSettings2/arm64'
Now we simply need to push the apk to the device, fix permissions, and reboot.
Code:
adb push SecSettings2.apk /data/local/tmp/
adb shell su -c 'dd if=/data/local/tmp/SecSettings2.apk of=/system/priv-app/SecSettings2/SecSettings2.apk'
adb shell su -c 'chmod 644 /system/priv-app/SecSettings2/SecSettings2.apk'
adb reboot (You may need to wipe data depending on the app being deodexed)
That's it. Happy modding
But I have made it easy for ya.....
deodex-app makes it stupid simple to deodex an apk from the device by running one command
Code:
./deodex-app SecSettings2.apk
That's it. The script will determine the apk's location in system, check if it's already deodexed, pull the neccessary
files to perform the deodexing, and will push the apk back to the device and reboot.
/lazydev
Huge credits to @JesusFreke for baksmali and smali, and credit to @svadev for the updated oat2dex
A few days ago, I flashed a zip onto my phone that set SELinux to permissive. However, there was a problem: it deleted logd, which is essential to adb logcat. Considering I'm an Android developer, that isn't a good thing! It took me a bit to figure out how to get it back, so I'm making this guide to share with you guys to help whatever poor soul has to fix this next.
Note that these steps were designed with Linux in mind, though they might be adaptable to Cygwin/OSX with some effort.
Also, make sure you delete any SELinux permissive scripts from init.d/su.d first!
Prerequisites
The OTA or custom rom zip that your device is currently running
adb
simg2img (available in the Ubuntu software repositories)
sdat2img (available here)
Instructions
Put your OTA/custom ROM zip file in a new folder and unzip it (this example is using the Pure Nexus ZIP):
Code:
mkdir restore_logd
cp pure_nexus_hammerhead-7.0-20161025-HOMEMADE.zip restore_logd
cd restore_logd
unzip pure_nexus_hammerhead-7.0-20161025-HOMEMADE.zip
Now, look for a file named either system.new.dat or system.img.
If you have system.img, then run:
Code:
simg2img system.img system.raw.img
If you have system.new.dat AND system.transfer.list, instead run:
Code:
sdat2img.py system.transfer.list system.new.dat system.raw.img
Either way, you should now have a file named system.raw.img. Next, mount it:
Code:
mkdir system_mnt
sudo mount -t ext4 -o loop system.raw.img system_mnt
This will mount the system image onto the system_mnt folder.
Plug in your device to your computer and make sure USB debugging is enabled, then run:
Code:
adb push system_mnt/bin/logd /sdcard/logd
adb shell
You should now be in a shell connected to your device. Inside, run:
Code:
su
mount -o rw,remount /system
cp /sdcard/logd /system/bin/logd
chmod 755 /system/bin/logd
exit
This will install the logd binary and close the shell.
This next part is very important! Making sure you closed the adb shell and are still inside the directory you created, run:
Code:
ls -Z system_mnt/bin/logd
If the output looks like this:
Code:
? system_mnt/bin/logd
then you have nothing else to do. Otherwise, it might look a bit like this:
Code:
u:object_r:logd_exec:s0 system_mnt/bin/logd
Copy part before the path; in this case, it's:
Code:
u:object_r:logd_exec:s0
Then, run:
Code:
adb shell su root chcon permission /system/bin/logd
replacing permission with the string you copied.
Now you can unplug and restart your device; logd should now be fully working!
Last but not least, run:
Code:
sudo fusermount -u system_mnt
to unmount the system image from your computer.
Enjoy!
Execute command failed while replacing permission
Code:
adb shell su root chcon permission /system/bin/logd
u:object_r:logd_exec:s0
/system/bin/sh: <stdin>[1]: u:object_r:logd_exec:s0: not found