How To Guide WSA default settings & their tweaking - Windows 11

Preface:
Worthwhile to know is that WSA is a Hosted OS what runs on Top Of Windows OS
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
so it shares all hardware resources with Windows OS, really all.
As in every Android OS - so also in WSA emulator - exist files what contain all the important information and command lines to identify the device and to make it run smoothly along side, they basically are named build.prop and/or default.prop and may be located in different partitions. These setting files are read by the Android kernel and also by apps thus they can mend their interface and their functionality to have a smooth interface between user and apps. These files also contain the build number, manufacturer name and other essential information to identify the emulated Android device distinctly.
In WSA w/ Android 11 image these settings are split into several files what are scattered over various locations: root, root/vendor and root/product. In WSA w/ Android 13 image these settings also are split into several files what are scattered over into 2 locations: root, root/vendor.
Prerequisite:
WSA's Android image must got rooted. This in order to can mount the related partitions where the settings files are housed as RW.
Overview:
Android settings in WSA w/ Android 11 image:
For those who are interested in these setting files I've extracted them from WSA w/ Android 11 image and attached:
File: /build.prop -> attached build.prop.zip
Here is printout of this build.prop file
Spoiler
# begin common build properties
# autogenerated by build/make/tools/buildinfo_common.sh
ro.system.build.date=Tue Aug 24 22:34:56 UTC 2021
ro.system.build.date.utc=1629844496
ro.system.build.fingerprint=google/redfin/redfin:12/SPB5.210812.002/7671067:user/release-keys
ro.system.build.id=SPB5.210812.002
ro.system.build.tags=release-keys
ro.system.build.type=user
ro.system.build.version.incremental=7671067
ro.system.build.version.release=11
ro.system.build.version.release_or_codename=11
ro.system.build.version.sdk=30
ro.product.system.brand=google
ro.product.system.device=generic
ro.product.system.manufacturer=Google
ro.product.system.model=mainline
ro.product.system.name=mainline
# end common build properties
# begin build properties
# autogenerated by buildinfo.sh
ro.build.id=SPB5.210812.002
ro.build.display.id=SPB5.210812.002
ro.build.version.incremental=7671067
ro.build.version.sdk=30
ro.build.version.preview_sdk=0
ro.build.version.preview_sdk_fingerprint=REL
ro.build.version.codename=REL
ro.build.version.all_codenames=REL
ro.build.version.release=11
ro.build.version.release_or_codename=11
ro.build.version.security_patch=2021-09-05
ro.build.version.base_os=
ro.build.version.min_supported_target_sdk=23
ro.build.date=Tue Aug 24 22:34:56 UTC 2021
ro.build.date.utc=1629844496
ro.build.type=user
ro.build.user=android-build
ro.build.host=abfarm807
ro.build.tags=release-keys
ro.build.flavor=redfin-user
ro.build.system_root_image=false
# ro.product.cpu.abi and ro.product.cpu.abi2 are obsolete,
# use ro.product.cpu.abilist instead.
ro.product.cpu.abi=x86_64
ro.product.cpu.abilist=x86_64,x86,arm64-v8a,armeabi-v7a,armeabi
ro.product.cpu.abilist32=x86,armeabi-v7a,armeabi
ro.product.cpu.abilist64=x86_64,arm64-v8a
ro.product.locale=en-US
ro.wifi.channels=
# ro.build.product is obsolete; use ro.product.device
ro.build.product=redfin
# Do not try to parse description or thumbprint
ro.build.description=redfin-user 12 SPB5.210812.002 7671067 release-keys
# end build properties
#
# ADDITIONAL_BUILD_PROPERTIES
#
ro.treble.enabled=true
net.bt.name=Android
ro.build.fingerprint=google/redfin/redfin:12/SPB5.210812.002/7671067:user/release-keys
ro.product.brand=google
ro.product.device=redfin
ro.product.manufacturer=Google
ro.product.model=Pixel 5
ro.product.name=redfin
File: /default.prop -> attached default.prop.zip
File: /vendor/build.prop -> attached vendor.build.prop..zip
File: /vendor/default.prop -> attached vendor.default.prop.zip
File: /product/build.prop -> attached product.build.prop,zip
In WSA w/ Android 11 image also additionally exists file prop.default what isn't of interest here: it's merely a backup of file root/default.prop.
Android settings in WSA w/ Android 13 image:
In WSA w/ Android 13 image only 2 file /build.prop & /vendor/build.prop exist.
File: /build.prop -> attached 13-build.prop.zip
Here is printout of this build.prop file - extracted from WSA w/ Android 13 image
Spoiler
####################################
# from generate-common-build-props
# These properties identify this partition image.
####################################
ro.product.system.brand=google
ro.product.system.device=redfin
ro.product.system.manufacturer=Google
ro.product.system.model=Pixel 5
ro.product.system.name=redfin
ro.system.product.cpu.abilist=x86_64,x86,arm64-v8a,armeabi-v7a,armeabi
ro.system.product.cpu.abilist32=x86,armeabi-v7a,armeabi
ro.system.product.cpu.abilist64=x86_64,arm64-v8a
ro.system.build.date=Wed Dec 14 02:14:23 UTC 2022
ro.system.build.date.utc=1670984063
ro.system.build.fingerprint=google/redfin/redfin:13/TP1A.221105.002/2211.40000.10.0:user/release-keys
ro.system.build.id=TP1A.221105.002
ro.system.build.tags=release-keys
ro.system.build.type=user
ro.system.build.version.incremental=2211.40000.10.0
ro.system.build.version.release=13
ro.system.build.version.release_or_codename=13
ro.system.build.version.sdk=33
####################################
# from out/target/product/windows_x86_64/obj/PACKAGING/system_build_prop_intermediates/buildinfo.prop
####################################
# begin build properties
# autogenerated by buildinfo.sh
ro.build.id=TP1A.221105.002
ro.build.display.id=TP1A.221105.002
ro.build.version.incremental=2211.40000.10.0
ro.build.version.sdk=33
ro.build.version.preview_sdk=0
ro.build.version.preview_sdk_fingerprint=REL
ro.build.version.codename=REL
ro.build.version.all_codenames=REL
ro.build.version.known_codenames=Base,Base11,Cupcake,Donut,Eclair,Eclair01,EclairMr1,Froyo,Gingerbread,GingerbreadMr1,Honeycomb,HoneycombMr1,HoneycombMr2,IceCreamSandwich,IceCreamSandwichMr1,JellyBean,JellyBeanMr1,JellyBeanMr2,Kitkat,KitkatWatch,Lollipop,LollipopMr1,M,N,NMr1,O,OMr1,P,Q,R,S,Sv2,Tiramisu
ro.build.version.release=13
ro.build.version.release_or_codename=13
ro.build.version.release_or_preview_display=13
ro.build.version.security_patch=2022-11-05
ro.build.version.base_os=
ro.build.version.min_supported_target_sdk=23
ro.build.date=Wed Dec 14 02:14:23 UTC 2022
ro.build.date.utc=1670984063
ro.build.type=user
ro.build.user=cloudtest
ro.build.host=8f3cde02c000000
ro.build.tags=release-keys
ro.build.flavor=redfin-user
ro.build.system_root_image=false
# ro.product.cpu.abi and ro.product.cpu.abi2 are obsolete,
# use ro.product.cpu.abilist instead.
ro.product.cpu.abi=x86_64
ro.product.locale=en-US
ro.wifi.channels=
# ro.build.product is obsolete; use ro.product.device
ro.build.product=redfin
# Do not try to parse description or thumbprint
ro.build.description=redfin-user 13 TP1A.221105.002 2211.40000.10.0 release-keys
# end build properties
####################################
# from variable ADDITIONAL_SYSTEM_PROPERTIES
####################################
ro.treble.enabled=true
ro.actionable_compatible_property.enabled=true
ro.postinstall.fstab.prefix=/system
ro.secure=1
security.perf_harden=1
ro.adb.secure=1
ro.allow.mock.location=0
ro.debuggable=0
net.bt.name=Android
####################################
# from variable PRODUCT_SYSTEM_PROPERTIES
####################################
debug.atrace.tags.enableflags=0
persist.traced.enable=1
dalvik.vm.image-dex2oat-Xms=64m
dalvik.vm.image-dex2oat-Xmx=64m
dalvik.vm.dex2oat-Xms=64m
dalvik.vm.dex2oat-Xmx=512m
dalvik.vm.usejit=true
dalvik.vm.usejitprofiles=true
dalvik.vm.dexopt.secondary=true
dalvik.vm.dexopt.thermal-cutoff=2
dalvik.vm.appimageformat=lz4
ro.dalvik.vm.native.bridge=0
pm.dexopt.first-boot=verify
pm.dexopt.boot-after-ota=verify
pm.dexopt.post-boot=extract
pm.dexopt.install=speed-profile
pm.dexopt.install-fast=skip
pm.dexopt.install-bulk=speed-profile
pm.dexopt.install-bulk-secondary=verify
pm.dexopt.install-bulk-downgraded=verify
pm.dexopt.install-bulk-secondary-downgraded=extract
pm.dexopt.bg-dexopt=speed-profile
pm.dexopt.ab-ota=speed-profile
pm.dexopt.inactive=verify
pm.dexopt.cmdline=verify
pm.dexopt.shared=speed
dalvik.vm.dex2oat-resolve-startup-strings=true
dalvik.vm.dex2oat-max-image-block-size=524288
dalvik.vm.minidebuginfo=true
dalvik.vm.dex2oat-minidebuginfo=true
dalvik.vm.madvise.vdexfile.size=104857600
dalvik.vm.madvise.odexfile.size=104857600
dalvik.vm.madvise.artfile.size=4294967295
####################################
# from variable PRODUCT_SYSTEM_DEFAULT_PROPERTIES
####################################
# end of file
# extra prop added by MagiskOnWSA
ro.product.brand=google
ro.product.manufacturer=Google
ro.system.build.product=redfin
ro.product.name=redfin
ro.product.device=redfin
ro.product.model=Pixel 5
ro.system.build.flavor=redfin-user
ro.build.fingerprint=google/redfin/redfin:13/TP1A.221105.002/2211.40000.10.0:user/release-keys
ro.system.build.description=redfin-user 13 TP1A.221105.002 2211.40000.10.0 release-keys
ro.bootimage.build.fingerprint=google/redfin/redfin:13/TP1A.221105.002/2211.40000.10.0:user/release-keys
File: /vendor/build.prop -> attached 13-vendor.build.prop.zip
Here is printout of this build.prop file - extracted from WSA w/ Android 13 image
Spoiler
####################################
# from generate-common-build-props
# These properties identify this partition image.
####################################
ro.product.vendor.brand=google
ro.product.vendor.device=redfin
ro.product.vendor.manufacturer=Google
ro.product.vendor.model=Pixel 5
ro.product.vendor.name=redfin
ro.vendor.product.cpu.abilist=x86_64,x86,arm64-v8a,armeabi-v7a,armeabi
ro.vendor.product.cpu.abilist32=x86,armeabi-v7a,armeabi
ro.vendor.product.cpu.abilist64=x86_64,arm64-v8a
ro.vendor.build.date=Wed Dec 14 02:14:23 UTC 2022
ro.vendor.build.date.utc=1670984063
ro.vendor.build.fingerprint=google/redfin/redfin:13/TP1A.221105.002/2211.40000.10.0:user/release-keys
ro.vendor.build.id=TP1A.221105.002
ro.vendor.build.tags=release-keys
ro.vendor.build.type=user
ro.vendor.build.version.incremental=2211.40000.10.0
ro.vendor.build.version.release=13
ro.vendor.build.version.release_or_codename=13
ro.vendor.build.version.sdk=33
####################################
# from out/target/product/windows_x86_64/obj/ETC/android_info_prop_intermediates/android_info.prop
####################################
####################################
# from variable ADDITIONAL_VENDOR_PROPERTIES
####################################
ro.vndk.version=33
ro.bionic.arch=x86_64
ro.bionic.cpu_variant=
ro.bionic.2nd_arch=x86
ro.bionic.2nd_cpu_variant=
persist.sys.dalvik.vm.lib.2=libart.so
dalvik.vm.isa.x86_64.variant=x86_64
dalvik.vm.isa.x86_64.features=default
dalvik.vm.isa.x86.variant=x86_64
dalvik.vm.isa.x86.features=default
ro.boot.dynamic_partitions=true
ro.product.first_api_level=30
ro.vendor.build.security_patch=
ro.product.board=windows
ro.board.platform=windows
ro.hwui.use_vulkan=
####################################
# from variable PRODUCT_VENDOR_PROPERTIES
####################################
ro.zygote=zygote64_32
# Removed by post_process_props.py because overridden by ro.zygote=zygote64_32
#ro.zygote?=zygote32
ro.logd.size.stats=64K
log.tag.stats_log=I
ro.carrier=unknown
ro.config.notification_sound=OnTheHunt.ogg
ro.config.alarm_alert=Alarm_Classic.ogg
ro.apex.updatable=true
init.userspace_reboot.is_supported=true
ro.virtual_ab.enabled=true
external_storage.projid.enabled=1
external_storage.casefold.enabled=1
external_storage.sdcardfs.enabled=0
dalvik.vm.heapstartsize=16m
dalvik.vm.heapgrowthlimit=192m
dalvik.vm.heapsize=512m
dalvik.vm.heaptargetutilization=0.75
dalvik.vm.heapminfree=512k
dalvik.vm.heapmaxfree=8m
drm.service.enabled=true
wifi.interface=wlan0
####################################
# from variable PRODUCT_DEFAULT_PROPERTY_OVERRIDES
####################################
ro.dalvik.vm.native.bridge=libhoudini.so
####################################
# from variable PRODUCT_PROPERTY_OVERRIDES
####################################
ro.control_privapp_permissions=enforce
debug.sf.nobootanimation=1
ro.opengles.version=196608
debug.stagefright.ccodec=0
debug.latte.hwcodec.avcdec=2
debug.latte.hwcodec.hevcdec=2
debug.latte.hwcodec.vp8dec=2
debug.latte.hwcodec.vp9dec=2
debug.latte.hwcodec.mp4vdec=2
debug.latte.hwcodec.av1dec=2
debug.latte.hwcodec.h263dec=2
debug.latte.hwcodec.mpeg2dec=2
debug.hwui.disable_disk_cache=1
ro.hardware.egl=emulation
ro.surface_flinger.running_without_sync_framework=true
debug.sf.vsync_reactor_ignore_present_fences=true
service.sf.prime_shader_cache=0
ro.hardware.audio.primary=windows
vendor.bt.rootcanal_test_console=off
ro.incremental.enable=true
ro.dalvik.vm.isa.arm=x86
ro.vendor.enable.native.bridge.exec=1
ro.dalvik.vm.isa.arm64=x86_64
ro.vendor.enable.native.bridge.exec64=1
# end of file
# extra prop added by MagiskOnWSA
ro.product.brand=google
ro.product.manufacturer=Google
ro.build.product=redfin
ro.vendor.build.product=redfin
ro.product.name=redfin
ro.product.device=redfin
ro.product.model=Pixel 5
ro.build.flavor=redfin-user
ro.vendor.build.flavor=redfin-user
ro.build.description=redfin-user 13 TP1A.221105.002 2211.40000.10.0 release-keys
ro.build.fingerprint=google/redfin/redfin:13/TP1A.221105.002/2211.40000.10.0:user/release-keys
ro.vendor.build.description=redfin-user 13 TP1A.221105.002 2211.40000.10.0 release-keys
ro.bootimage.build.fingerprint=google/redfin/redfin:13/TP1A.221105.002/2211.40000.10.0:user/release-keys
Take note that settings stored in /vendor/build.prop files take precedence over those stored in default.prop and/or /system/build.prop if they also exist there.
As one can notice contents of build.prop as provided w/ Android 11 image and w/ Android 13 image heavily differ.
Tweaking - Relates to WSA w/ Android 13 image:
We all know Android is the best platform that offers to customize everything. Each operating system has its own config file and All function is stored in the build. prop file, but also in /vendor/build.prop. So changing the /vendor/build. prop file will change the WSA core functioning values. You can tweak your WSA without installing any 3rd party apps or mods, just need root access to edit /vendor/build. prop on WSA emulator.
We know that WSA isn't a smartphone, it's merely an Android emulator that can connect to computer's local Wi-Fi network, hence it's not so much what can get tweaked. But we can try it:
1. Raise RAM Useable by App
Android limits memory per process. Todays apps often require hundreds of MBs of available RAM for exclusive use to flawlessly run. So we give them ( at maximum ) 512 MB - alike Samsung Galaxy S6 SM-G920W8.
dalvik.vm.dex2oat-Xmx=512m
2. Improves Recording Quality.​Most of the WSA user wants the best audio and video quality in this emulator. This code in /vendor/build.prop will improve audio and video recording quality. After applying this code the WSA recording may give better clear and louder quality sound.
ro.media.enc.jpeg.quality=100
ro.media.dec.jpeg.memcap=8000000
ro.media.enc.hprof.vid.bps=8000000
ro.media.capture.maxres=8m
ro.media.panorama.defres=3264×1840
ro.media.panorama.frameres=1280×720
ro.camcorder.videoModes=true
ro.media.enc.hprof.vid.fps=65
3. Improve Network Speed.​If you are facing low network speed? You can overall increase network speed on your emulated Android device by increasing the TCP’s Buffersize. When you are browsing the internet on the android device, Your net has been directly connected with the google DNS. Paste the following code at the bottom of the /vendor/build.prop.
net.tcp.buffersize.default=4096,87380,256960,4096, 16384,256960
net.tcp.buffersize.wifi=4096,87380,256960,4096,163 84,256960
net.tcp.buffersize.umts=4096,87380,256960,4096,163 84,256960
net.tcp.buffersize.gprs=4096,87380,256960,4096,163 84,256960
net.tcp.buffersize.edge=4096,87380,256960,4096,163 84,256960
net.dns1=8.8.8.8
net.dns2=8.8.4.4
4. Disable built-in error reporting.​Every Android user always faces with the Apps crash. After apps crashing, we all noticed a pop-up like Error-Reporting is showing on the screen. It too much annoying for the many users. If you feel this is too much annoying for you and want to disable built-in error reporting features then add the code to the end at the /vendor/build.prop file.
profiler.force_disable_err_rpt=1
profiler.force_disable_ulog=1
5. Change DPI on the emulated Android device.​Changing DPI is one of the most useful build.prop for Android users. DPI refers to the Density Independent on the emulated device. You can find many apps in Google Playstore to change this setting but here you can directly tweak DPI on Android. If you set high amount of value in DPI then the output is smaller UI, smaller texts, smaller icons.
If you set low DPI then the output is a larger UI, larger texts, and larger icons. Always set a perfect DPI otherwise you can’t operate WSA. Add the following line to the end of the /vendor/build.prop.
ro.sf.lcd_density=XXX
Here, XXX refers to the DPI Value. The values are a multiple of 160, That is, 160, 320, 480, 640, etc. XXX replace with a value you like.
6. Disable Android logger – logcat​Every Android device records Android log. It basically stores application and portions logs in the system. It displays messages in real time and keeps a history so you can view older messages. So if you want to Disable Android logger then add the the following line to the end of the /vendor/build.prop.
logcat.live=disable
7. Make sure USB-MTP mode is enabled.
Add the following line to the end of the /vendor/build.prop.
persist.sys.usb.config=adb,mtp
8. Ensure ADB is debuggable
Add the following lines to the end of the /vendor/build.prop.
persist.service.adb.enable=1
persist.service.debuggable1
9. Enable Faster boot.
Paste the following code at the bottom of the /vendor/build.prop:
ro.config.hw_quickpoweron=true
persist.sys.shutdown.mode=hibernate
10. Improve the speed of video streaming.
Add the following lines to the bottom of the /vendor/build.prop:
media.stagefright.enable-player=true
media.stagefright.enable-meta=true
media.stagefright.enable-scan=true
media.stagefright.enable-http=true
media.stagefright.enable-rtsp=true
media.stagefright.enable-record=false
11. Set Wireless & TCP Speed.
Paste the following code at the bottom of the /vendor/build.prop:
net.core.wmem_max=1048576
net.core.rmem_max=1048576
net.core.rmem_default=262144
net.core.wmem_default=262144
net.core.optmem_max=20480
net.unix.max_dgram_qlen=50
12. Set number of CPU-cores to be used
It should be well known that WSA emulator shares the Windows computer's hardware resources, so both RAM and CPU. The RAM usage is fixed to 4 GB ( what can't be changed AFAIK ), the number of virtual CPU cores is not. We may have to configure how the virtual CPUs are assigned in terms of real CPU cores and cores per socket,
Note: You may use Windows Command Prompt to get the number of real CPU cores
IMO it's recommnded to determine the half of real CPU cores as virtual CPU cores. Example:
ro.core_ctl_min_cpu=1
ro.core_ctl_max_cpu=4
Conclusion:
I’m sure that several people will try out tweaking WSA settings as mentioned above. For that reason I've created a batch file named wsa_buildprop_tweaker that'll do the job:
Spoiler
Code:
@echo off & setlocal DISABLEDELAYEDEXPANSION
adb disconnect 2>nul
adb connect 127.0.0.1:58526
adb devices
cls
echo Going to tweak Android system settings...
echo Please keep your computer on
echo(
set "CPU_CORES="
for /F "tokens=*" %%a in ('echo %NUMBER_OF_PROCESSORS%) do (
if NOT "%%a"==[] ( set "CPU_CORES=%X%" )
)
::
:: Open Android terminal
::
adb shell
alias SU='find . -executable -type f -iname "su.*"'
if [ -z "$SU" ] then;
echo "SU ( root ) not found. Exiting...";
sleep 10;
exit 1;
fi;
TMP_SCRIPT='/sdcard/Downloads/tweaker.sh';
if [ ! -f "/system/build.prop" ] then;
echo "File /system/build.prop not found. Exiting...";
sleep 10;
exit 1;
fi;
if [ -f "$TMP_SCRIPT" ] then;
rm -f "$TMP_SCRIPT";
fi;
# mount /sytem as RW
$SU 0 -c "mount -o rw,remount -t auto /system"
# create the script we want to get run
alias TWEAKS='cat << EOF'
echo "########################################" >> /vendor/build.prop; \
echo "# Added by $USER" >> /vendor/build.prop; \
echo "########################################" >> /vendor/build.prop; \
echo "dalvik.vm.dex2oat-Xmx=512m" >> /vendor/build.prop; \
echo "ro.media.enc.jpeg.quality=100" >> /vendor/build.prop; \
echo "ro.media.dec.jpeg.memcap=8000000" >> /vendor/build.prop; \
echo "ro.media.enc.hprof.vid.bps=8000000" >> /system/build.prop, \
echo "ro.media.capture.maxres=8m" >> /vendor/build.prop; \
echo "ro.media.panorama.defres=3264×1840" >> /vendor/build.prop; \
echo "ro.media.panorama.frameres=1280×720" >> /system/build.prop, \
echo "ro.camcorder.videoModes=true" >> /vendor/build.prop; \
echo "ro.media.enc.hprof.vid.fps=65" >> /vendor/build.prop; \
echo "net.tcp.buffersize.default=4096,87380,256960,4096, 16384,256960" >> /vendor/build.prop; \
echo "net.tcp.buffersize.wifi=4096,87380,256960,4096,163 84,256960" >> /vendor/build.prop; \
echo "net.tcp.buffersize.umts=4096,87380,256960,4096,163 84,256960" >> /vendor/build.prop; \
echo "net.tcp.buffersize.gprs=4096,87380,256960,4096,163 84,256960" >> /vendor/build.prop; \
echo "net.tcp.buffersize.edge=4096,87380,256960,4096,163 84,256960" >> /vendor/build.prop; \
echo "ro.sf.lcd_density=480" >> /vendor/build.prop; \
echo "logcat.live=disable" >> /vendor/build.prop; \
echo "profiler.force_disable_err_rpt=1" >> /vendor/build.prop; \
echo "profiler.force_disable_ulog=1" >> /vendor/build.prop; \
echo "ro.config.hw_quickpoweron=true" >> /vendor/build.prop; \
echo "persist.sys.usb.config=adb,mtp" >> /vendor/build.prop; \
echo "#" >> /vendor/build.prop; \
TWEAKS
# run the created script in ROOT mode
$SU 0 -c 'echo "$TWEAKS" > "$TMP_SCRIPT";source "$TMP_SCRIPT";rm -f "$TMP_SCRIPT" 2>/dev/null;'
# unmount /system
umount -af;
::
:: Close Android terminal
::
exit
if defined CPU_CORES (
setlocal ENABLEDELAYEDEXPANSION
set /A CPU_CORES=!CPU_CORES!/=2
adb shell 'echo "ro.core_ctl_min_cpu=1"' >> /vendor/build.prop; \
adb shell 'echo "ro.core_ctl_max_cpu=!CPU_CORES!"' >> /vendor/build.prop; \
endlocal
)
echo Job completed!
timeout /t 10 /nobreak >nul
# reboot WSA
adb disconnect 2>nul
adb usb
adb reboot
exit
It's for your convenience attached.

Thanks for this.. I'm not getting much luck with the batch file. I get the following, and not sure where the error is.
----------
Going to tweak Android system settings..
Please keep your computer on
The system cannot find the file 'echo 8.
----------

May be I'm struck with blindness: Can't detect "echo 8" phrase in file contents.

jwoegerbauer said:
May be I'm struck with blindness: Can't detect "echo 8" phrase in file contents.
Click to expand...
Click to collapse
Yeah, I couldn't find it either. I'm thinking it has something to do with the virtual cores?
Have you tried the script on Android 13?, It could also be related to that.
PS: Do you know of any setting that can make scrolling smoother?
Thanks

You can try to fix it by modifying the maximum and minimum fluid velocity on WSA, which affect the scrolling speed on WSA.
Example:
Code:
windowsmgr.max_events_per_sec=150
ro.min_pointer_dur=8
ro.max.fling_velocity=12000
ro.min.fling_velocity=8000

Related

[Q] Extracting FB contacts from Android's contacts database.

I found this script to extract Facebooks contact info from a Android phone but even though it mostly works and I get all emails and phone numbers the names get left out and I was wondering if someone knew how to fix this script.
I assume it is just a database change since the script was made.
This is all to make it easier to find friends on Google+ since Facebook tries to stop anyone from getting this info.
Code:
#! /bin/sh
###########################################
#
# Android DB contacts exporter (proof-of-concept)
# 2011-01-06
#
# Extracts "certain contacts" from the Android contacts database to a CSV file
# for import into other contact list tools.
#
#
# == Usage ==
#
# 1) Copy your Android contacts database to your computer
# adb pull /data/data/com.android.providers.contacts/databases/contacts2.db ./
# 2) Run this file from the same directory as contacts2.db
# ./fb-extract.sh
# 3) Import csv to an address book of your choice
#
# == Notice ==
#
# This is a proof of concept script. Use at your own risk and check
# with laws and terms of service regarding data usage.
#
###########################################
# In and out files
CONTACTSDB="./contacts2.db"
OUTFILE="./contacts_fb.csv"
# Write table header
echo "First Name,Last Name,E-mail Address,Mobile Phone,Home Phone" >> $OUTFILE
# Get the raw IDs of all facebook contacts
RAWID_LIST=`sqlite3 $CONTACTSDB "SELECT _id from raw_contacts WHERE account_type='com.facebook.auth.login'"`
# Loop through the IDs and extract necessary data
for RAWID in $RAWID_LIST; do
# Get the first and last names
NAME=`sqlite3 $CONTACTSDB "SELECT data2, data3 FROM data WHERE raw_contact_id=$RAWID AND mimetype_id=7"`
FNAME=`echo $NAME | awk '{split($0,a,"|"); print a[1]}'`
LNAME=`echo $NAME | awk '{split($0,a,"|"); print a[2]}'`
# Get the email address
EMAIL=`sqlite3 $CONTACTSDB "SELECT data1 FROM data WHERE raw_contact_id=$RAWID AND mimetype_id=1"`
# Get the phone numbers (mobile & other). Convert international Japanese # to local using `sed`
MPHONE=`sqlite3 $CONTACTSDB "SELECT data1 FROM data WHERE raw_contact_id=$RAWID AND mimetype_id=5 AND data2=2" | sed 's/^81\([0-9]\{7,\}\)/0\1/'`
OPHONE=`sqlite3 $CONTACTSDB "SELECT data1 FROM data WHERE raw_contact_id=$RAWID AND mimetype_id=5 AND data2=7" | sed 's/^81\([0-9]\{7,\}\)/0\1/'`
# If at least one info field was set then write the csv line
if [ -n "$EMAIL" ] || [ -n "$MPHONE" ] || [ -n "$OPHONE" ]; then
echo "$FNAME,$LNAME,$EMAIL,$MPHONE,$OPHONE" >> $OUTFILE
fi
done
Original source of script
http://webcache.googleusercontent.c...c+contacts+sqlite&hl=en&client=ubuntu&strip=1
A simple change
You have to change the line beginning for NAME: at the there should be
mimetype_id=6
Thank you that worked.
Please use the Q&A Forum for questions Thanks
Moving to Q&A

Supremacy Script

{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
I had posted my Supremacy script in the android developments for XS and XU. Tho it will work on P, Go etc.
Decided to have one thread for all. Here: http://forum.xda-developers.com/showthread.php?t=1928200
——————————————————————————————————————————————————————————
Don't know what it is? Read up the thread! ^^
——————————————————————————————————————————————————————————
Here, I will answer your questions and/or anything else.​
Are you working to v3?
Nebunia lu Salam
oache said:
Are you working to v3?
Nebunia lu Salam
Click to expand...
Click to collapse
V3 is out
Tapatalked Xperia S
Mmm... Init.d , will it work in locked rooted stock rom?
LiveSquare said:
Mmm... Init.d , will it work in locked rooted stock rom?
Click to expand...
Click to collapse
The kernel needs init.d support. Check XU dev section there is a thread on how to enable it
Tapatalked !
Rapier07 said:
The kernel needs init.d support. Check XU dev section there is a thread on how to enable it
Tapatalked !
Click to expand...
Click to collapse
You mean enable on stock Kernel?
EDIT: Found and will try. Thanks.
EDIT2: How to test whether it's working?
Sadly this script causes freezes and reboots at random. Tested with KA and AS kernels. Haven't tried v3 but doubt it will make a difference. It's a shame
Skickat från min LT26i via Tapatalk 2
Galaxen said:
Sadly this script causes freezes and reboots at random. Tested with KA and AS kernels. Haven't tried v3 but doubt it will make a difference. It's a shame
Skickat från min LT26i via Tapatalk 2
Click to expand...
Click to collapse
I have no issues on xsspeed kernel V7 and 2.50 firmware
Tapatalked Xperia S
Ben36 said:
I have no issues on xsspeed kernel V7 and 2.50 firmware
Tapatalked Xperia S
Click to expand...
Click to collapse
Im still running .45 so it could be that.
Galaxen said:
Sadly this script causes freezes and reboots at random. Tested with KA and AS kernels. Haven't tried v3 but doubt it will make a difference. It's a shame
Skickat från min LT26i via Tapatalk 2
Click to expand...
Click to collapse
Reboots? Check the kernel Changelog or something, if it includes tweaks such as cache clearingg etc. those might have been conflicting this these scripts
sorry to say it...the script is a lil bit messy. the sysctl.conf is written in wrong way and the command isn't consistent.
Written wrong you say? Well you must be right. I don't know a lot here. Maybe you could helpme out?
emwno said:
Written wrong you say? Well you must be right. I don't know a lot here. Maybe you could helpme out?
Click to expand...
Click to collapse
It works well for me. The device is snappier.
Tapatalked !
kurotsugi said:
sorry to say it...the script is a lil bit messy. the sysctl.conf is written in wrong way and the command isn't consistent.
Click to expand...
Click to collapse
Yes do help and explain
Tapatalked Xperia S
Yup the device became snappier bt there is a decrease in quadrant score
Earlier I used to get above 3000 bt nw I can't go beyond 2900
Still I liked it coz this script actually makes a difference
if you have time, you can rewrite all the stuff by yourself to avoid double typed script with different value. its easy but need a lil more patience. I'll try to give quick explanation. our tweaks mostly work via init.d script. the basic structure will be.
Code:
#!/system/bin/sh --> the header. tell the system to use "sh" command on the script below
echo bla bla bla. --> the script
I'll differentiate the scripts into two parts. the one run a bash script and the one used to change our device setting. the first one is quite complicated and usually written on separated file. the famous one might be zipalign script and sqlite script. basicly you only need to add the script and the required files (the libs and the binary file in /system/bin) into your system and need no modification. just add and leave it.
the second part is the one used to change our device setting. we can differentiate this stuff into two things. the setprop stuff and the "other stuff". the setprop stuff is quite easy to use. the setprop stuff basic form is "setprop <key> <value>" for an example:
Code:
setprop ro.ril.enable.dtm 1
setprop ro.ril.gprsclass 10
setprop ro.ril.hep 1
setprop ro.ril.enable.3g.prefix 1
setprop ro.ril.hsdpa.category 8
setprop ro.ril.hsupa.category 6
setprop ro.ril.hsxpa 2
setprop ro.ril.enable.a53 1
some of these script written in form of "setprop ro.ril.hep=1". that's the wrong way. the correct way is as I've described above.
the second part, the "other stuff" work in three different way. for an example, look at these files
Code:
/proc/sys/kernel/shmmni
/proc/sys/kernel/shmmax
/proc/sys/kernel/shmall
these files have certain value on it. if we want to change the value written on it, we can use three different way.
1. use "sysctl -w <key>=<value>" form. in your init.d script you'll type
Code:
sysctl -w kernel.shmmni=4096
sysctl -w kernel.shmmax=268435456
sysctl -w kernel.shmall=2097152
2. use sysctl.conf file. in your sysctl.conf file, you'll write
Code:
kernel.shmmni=4096
kernel.shmmax=268435456
kernel.shmall=2097152
while in your init.d script you'll write "sysctl -p".
personally I prefer the number 1 since I can made a simple test to check whether if the script is running or not and add it into my log files. anyway, these trick only work for the files under /proc/sys. if you want to change the value of different files, you'll need to use method number 3.
3. use echo command. the form is "echo "<value>" > /path/to/file". in your init.d you'll write
Code:
echo "0" > /sys/module/lowmemorykiller/parameters/debug_level
echo "64" > /sys/module/lowmemorykiller/parameters/cost
echo "0,1,3,5,7,15" > /sys/module/lowmemorykiller/parameters/adj
echo "4096,5182,6400,15360,17920,20480" > /sys/module/lowmemorykiller/parameters/minfree
to avoid double typed script, we can categorize our tweak into several group. I'll show you my tweak as an example. you can learn it or start with it. I don't take credits, so that you can modify it anytime without asking my permission.
Code:
#!/system/bin/sh
# kuro tweak1: the echo stuff
# [email protected] (2012) - lol...i'm just joking. no copyright or whatsoever
# contact : [email protected]
# v.1 - first release
# v.1.1 - new log system and new tweak added.
# v.1.2 - new tweak for xperia
# v.1.3(4-11-12) - new form
LOG_FILE=/data/kuro_tweak1.log
LOG_FILEZ=/data/kuro_sqlite.log
if [ -e $LOG_FILE ]; then
rm $LOG_FILE;
fi;
if [ -e $LOG_FILEZ ]; then
rm $LOG_FILEZ;
fi;
# the preface
echo "==========================
# TWEAK KURO1-LOG FILE #
==========================
in the name of Allah,
the most beneficent,
the most mercifull
==========================
system information:
vendor : $( getprop ro.product.brand )
model : $( getprop ro.product.model )
ROM : $( getprop ro.build.display.id )
running the script...
start at:
$( date +"%m-%d-%Y %H:%M:%S" )
==========================" | tee -a $LOG_FILE;
# perfect mount
mount -o remount,noatime,commit=500,noauto_da_alloc,barrier=0 /system /system;
mount -o remount,noatime,commit=500,noauto_da_alloc,barrier=0 /data /data;
mount -o remount,noatime,commit=500,noauto_da_alloc,barrier=0 /cache /cache;
echo "perfect mount---------[OK]" | tee -a $LOG_FILE;
# sdcard speed fix
# not working yet - need root permission to change these value
if [ -e /sys/devices/virtual/bdi/179:0/read_ahead_kb ]; then
busybox echo "2048" > /sys/devices/virtual/bdi/179:0/read_ahead_kb
busybox echo "2048" > /sys/devices/virtual/bdi/179:32/read_ahead_kb
echo "sdcard speed fix------[OK]
-value set to $( cat /sys/devices/virtual/bdi/179:0/read_ahead_kb )
-value set to $( cat /sys/devices/virtual/bdi/179:32/read_ahead_kb )" | tee -a $LOG_FILE; else
echo "sdcard speed fix----[FAIL]" | tee -a $LOG_FILE;
fi
# kernel kick
sysctl -w kernel.shmmni=4096
sysctl -w kernel.shmmax=268435456
sysctl -w kernel.shmall=2097152
sysctl -w kernel.msgmni=4096
sysctl -w kernel.msgmax=64000
# sysctl -w kernel.sched_latency_ns=20000000
# sysctl -w kernel.sched_wakeup_granularity_ns=2500000
# sysctl -w kernel.sched_min_granularity_ns=10000000
sysctl -w kernel.sem="500 512000 64 2048"
sysctl -w kernel.panic=30
sysctl -w kernel.panic_on_oops=0
sysctl -w kernel.threads-max=10000
sysctl -w kernel.panic=30
# sysctl -w kernel.sched_compat_yield=1
# sysctl -w kernel.sched_shares_ratelimit=256000
sysctl -w kernel.ctrl-alt-del=0
sysctl -w fs.lease-break-time=10
sysctl -w fs.file-max=65536
echo "kernel kick-----------[OK]" | tee -a $LOG_FILE;
# OOM
sysctl -w vm.laptop_mode=0
sysctl -w vm.swappiness=40
sysctl -w vm.dirty_writeback_centisecs=3000
sysctl -w vm.dirty_expire_centisecs=500
sysctl -w vm.dirty_ratio=15
sysctl -w vm.dirty_background_ratio=10
sysctl -w vm.lowmem_reserve_ratio="100 100"
sysctl -w vm.overcommit_ratio=70
sysctl -w vm.highmem_is_dirtyable=1
sysctl -w vm.min_free_order_shift=4
sysctl -w vm.oom_kill_allocating_task=0
sysctl -w vm.panic_on_oom=0
sysctl -w vm.page-cluster=3
sysctl -w vm.drop_caches=3
sysctl -w vm.min_free_kbytes=5120
sysctl -w vm.vfs_cache_pressure=50
sysctl -w vm.block_dump=0
echo "memory management-----[OK]" | tee -a $LOG_FILE;
# network boost
sysctl -w net.ipv4.tcp_congestion_control=cubic
sysctl -w net.ipv4.tcp_timestamps=0
sysctl -w net.ipv4.tcp_tw_reuse=1
sysctl -w net.ipv4.tcp_sack=1
sysctl -w net.ipv4.tcp_dsack=1
sysctl -w net.ipv4.tcp_tw_recycle=1
sysctl -w net.ipv4.tcp_window_scaling=1
sysctl -w net.ipv4.tcp_keepalive_probes=5
sysctl -w net.ipv4.tcp_keepalive_intvl=30
sysctl -w net.ipv4.tcp_fin_timeout=30
sysctl -w net.ipv4.tcp_moderate_rcvbuf=1
sysctl -w net.ipv4.tcp_max_tw_buckets=1440000
sysctl -w net.ipv4.tcp_mem="57344 57344 524288"
sysctl -w net.ipv4.tcp_synack_retries=2
sysctl -w net.ipv4.tcp_syn_retries=2
sysctl -w net.ipv4.tcp_max_syn_backlog=1024
sysctl -w net.ipv4.icmp_echo_ignore_all=1
sysctl -w net.ipv4.route/flush=1
sysctl -w net.ipv4.udp_rmem_min=6144
sysctl -w net.ipv4.udp_wmem_min=6144
sysctl -w net.ipv4.tcp_rfc1337=1
sysctl -w net.ipv4.ip_no_pmtu_disc=0
sysctl -w net.ipv4.tcp_ecn=0
sysctl -w net.ipv4.tcp_wmem="6144 87380 524288"
sysctl -w net.ipv4.tcp_rmem="6144 87380 524288"
sysctl -w net.ipv4.tcp_fack=1
sysctl -w net.ipv4.tcp_synack_retries=2
sysctl -w net.ipv4.tcp_syn_retries=2
sysctl -w net.ipv4.tcp_no_metrics_save=1
sysctl -w net.ipv4.tcp_keepalive_time=1800
sysctl -w net.ipv4.ip_forward=0
sysctl -w net.ipv4.ip_dynaddr=0
sysctl -w net.ipv4.conf.all.accept_source_route=0
sysctl -w net.ipv4.conf.all.accept_redirects=0
sysctl -w net.ipv4.conf.all.rp_filter=1
sysctl -w net.ipv4.conf.all.secure_redirects=0
sysctl -w net.ipv4.conf.default.accept_redirects=0
sysctl -w net.ipv4.conf.default.secure_redirects=0
sysctl -w net.ipv4.conf.default.accept_source_route=0
sysctl -w net.core.rmem_max=524288
sysctl -w net.core.wmem_max=524288
sysctl -w net.core.rmem_default=262144
sysctl -w net.core.wmem_default=262144
sysctl -w net.core.optmem_max=20480
sysctl -w net.core.netdev_max_backlog=25000
sysctl -w net.unix.max_dgram_qlen=50
echo "network boost---------[OK]" | tee -a $LOG_FILE;
# cleaner
busybox rm -f /data/anr/*.*
busybox rm -f /data/cache/*.*
busybox rm -f /data/local/log/*.*
busybox rm -f /data/local/tmp/*.*
busybox rm -f /data/last_alog/*
busybox rm -f /data/last_kmsg/*
busybox rm -f /data/mlog/*
busybox rm -f /data/tombstones/*
busybox rm -f /data/system/dropbox/*
chmod 400 /data/system/dropbox
busybox rm /dev/log/main
busybox rm -f /data/system/usagestats/*
busybox chmod 400 /data/system/usagestats
export sampling_rate=10000
export up_threshold=80
echo "memory cleaner--------[OK]" | tee -a $LOG_FILE;
if [ -e /data/anr/*.* ]; then
echo "-anr not cleaned" | tee -a $LOG_FILE; else
echo "-anr cleaned" | tee -a $LOG_FILE
fi;
if [ -e /data/local/tmp/*.* ]; then
echo "-local/tmp not cleaned" | tee -a $LOG_FILE; else
echo "-local/tmp cleaned" | tee -a $LOG_FILE
fi;
if [ -e /data/cache/*.* ]; then
echo "-cache not cleaned" | tee -a $LOG_FILE; else
echo "-cache cleaned" | tee -a $LOG_FILE
fi;
if [ -e /data/last_log/*.* ]; then
echo "-log not cleaned" | tee -a $LOG_FILE; else
echo "-log cleaned" | tee -a $LOG_FILE
fi;
if [ -e /data/tombstones/*.* ]; then
echo "-tombstones not cleaned" | tee -a $LOG_FILE; else
echo "-tombstones cleaned" | tee -a $LOG_FILE
fi;
# minfree
echo "64" > /sys/module/lowmemorykiller/parameters/cost
echo "0,1,3,5,7,15" > /sys/module/lowmemorykiller/parameters/adj
echo "4096,5182,6400,15360,17920,20480" > /sys/module/lowmemorykiller/parameters/minfree
echo "minfree setting-------[OK]
-minfree value
$( cat /sys/module/lowmemorykiller/parameters/adj )
$( cat /sys/module/lowmemorykiller/parameters/minfree )" | tee -a $LOG_FILE;
# end
echo "==========================
done at:
$( date +"%m-%d-%Y %H:%M:%S" )
all praise is due to Allah
==========================
-- have a nice day --
[email protected]
==========================" | tee -a $LOG_FILE;
note that the line started with # are not executed.
Code:
#!/system/bin/sh
# kuro tweak2: the setprop stuffs and journalismoff
# [email protected] (2012) - lol...i'm just joking. no copyright or whatsoever
# contact : [email protected]
# v.1 - first release
# v.1.1 - new log system and new tweak added.
# v.1.2 - new tweak for xperia
LOG_FILE=/data/kuro_tweak2.log
if [ -e $LOG_FILE ]; then
rm $LOG_FILE;
fi;
# the preface
echo "==========================
# TWEAK KURO2-LOG FILE #
==========================
in the name of Allah,
the most beneficent,
the most mercifull
==========================
system information:
vendor : $( getprop ro.product.brand )
model : $( getprop ro.product.model )
ROM : $( getprop ro.build.display.id )
running the script...
start at:
$( date +"%m-%d-%Y %H:%M:%S" )
==========================" | tee -a $LOG_FILE;
# 3g mod
setprop ro.ril.enable.dtm 1
setprop ro.ril.gprsclass 10
setprop ro.ril.hep 1
setprop ro.ril.enable.3g.prefix 1
setprop ro.ril.hsdpa.category 8
setprop ro.ril.hsupa.category 6
setprop ro.ril.hsxpa 2
setprop ro.ril.enable.a53 1
setprop ro.ril.htcmaskw1.bitmask 4294967295
setprop ro.ril.htcmaskw1 14449
setprop ro.config.hw_fast_dormancy 1
echo "3g signal mod---------[OK]" | tee -a $LOG_FILE;
# battery mod n media
setprop debug.performance.tuning 1
setprop pm.sleep_mode 1
setprop windowsmgr.max_events_per_sec 90
setprop ro.ril.disable.power.collapse 0
setprop wifi.supplicant_scan_interval 180
setprop ro.media.enc.jpeg.quality 100
setprop debug.sf.hw 1
setprop ro.vold.umsdirtyratio 20
echo "battery n media-------[OK]" | tee -a $LOG_FILE;
# performance
# setprop persist.sys.purgeable_assets 1
setprop dalvik.vm.execution-mode int:jit
setprop dalvik.vm.dexopt-flags l=x,n=z,m=y
setprop dalvik.vm.verify-bytecode false
setprop dalvik.vm.heapsize 64m
setprop dalvik.vm.heapgrowthlimit 48m
setprop dalvik.vm.dexopt-data-only 1
setprop dalvik.vm.jmiopts forcecopy
setprop dalvik.vm.lockprof.treshold 250
setprop ro.kernel.android.checkjni 0
setprop ro.telephony.call_ring.delay 0
setprop debug.kill_allocating_task 1
# defaul is zero
# mem adj
setprop ro.FOREGROUND_APP_ADJ 0
setprop ro.VISIBLE_APP_ADJ 4
setprop ro.SECONDARY_SERVER_ADJ 6
setprop ro.HIDDEN_APP_MIN_ADJ 8
setprop ro.CONTENT_PROVIDER_ADJ 12
setprop ro.EMPTY_APP_ADJ 15
# mem minfree
setprop ro.FOREGROUND_APP_MEM 1536
setprop ro.VISIBLE_APP_MEM 2048
setprop ro.SECONDARY_SERVER_MEM 4096
setprop ro.HIDDEN_APP_MEM 5120
setprop ro.CONTENT_PROVIDER_MEM 5632
setprop ro.EMPTY_APP_MEM 6144
echo "performance-----------[OK]" | tee -a $LOG_FILE;
# Disable debugging notify icon on statusbar
setprop persist.adb.notify 0
# Disable blackscreen issue after a call
setprop ro.lge.proximity.delay 0
setprop mot.proximity.delay 0
# Phone will not wake up from hitting the volume rocker
# setprop ro.config.hwfeature_wakeupkey 0
# Enable display Dithering
# setprop persist.sys.use_dithering 1
# xperia mental
setprop persist.android.strictmode 0
setprop persist.sys.ui.hw 1
setprop ro.max.fling_velocity 12000
setprop ro.min.fling_velocity 2000
setprop ro.mot.eri.losalert.delay 1000
setprop ro.kernel.checkjni 0
setprop ro.config.nocheckin 1
setprop debug.qctwa.statusbar 1
setprop debug.qctwa.preservebuf 1
setprop debug.qc.hardware true
setprop com.qc.hardware true
setprop profiler.force_disable_err_rpt 1
setprop profiler.force_disable_ulog 1
setprop logcat.live disable
setprop net.ppp0.dns1 8.8.8.8
setprop net.ppp0.dns2 8.8.4.4
setprop net.dns1 8.8.8.8
setprop net.rmnet0.dns1 8.8.8.8
setprop net.rmnet0.dns2 8.8.4.4
setprop net.dns2 8.8.4.4
setprop debug.egl.profiler 1
setprop debug.egl.hw 1
setprop debug.composition.type gpu
echo "Xperia tweak----------[OK]" | tee -a $LOG_FILE;
# no journal
tune2fs -o journal_data_writeback /dev/block/mmcblk0p10
tune2fs -o journal_data_writeback /dev/block/mmcblk0p11
tune2fs -o journal_data_writeback /dev/block/mmcblk0p15
echo "no journal------------[OK]" | tee -a $LOG_FILE;
# end
echo "==========================
done at:
$( date +"%m-%d-%Y %H:%M:%S" )
all praise is due to Allah
==========================
-- have a nice day --
[email protected]
==========================" | tee -a $LOG_FILE;
the journalism stuff require tune2fs binary file installed into your system.
Code:
#!/system/bin/sh
#keep beats
PPID=$(pidof org.equalizerapp);
echo "17" > /proc/$PPID/oom_adj;
renice -18 $PPID;
#set
setprop.keep_app_1 org.equalizerapp
#audio resample
setprop af.resample 48000;
setprop af.resampler.quality 255;
setprop ro.audio.samplerate 48000;
setprop ro.audio.pcm.samplerate 48000;
setprop persyst.af.resample 48000;
setprop persyst.af.resampler.quality 255;
setprop persyst.ro.audio.samplerate 48000;
setprop persyst.ro.audio.pcm.samplerate 48000;
setprop persyst.dev.pm.dyn_samplingrate 1;
this one is modifying our sound quality. some of the part are still under my investigation but the audio resample part is really working.
Code:
#!/system/bin/sh
# DarkyROM 2011
# Much faster zipalign.
# Changelog:
# 1.3 (5/8/12) new log system. system remount deleted (by: kurotsugi)
# 1.2 (17/1/11) Added /data/zipalign.db file for faster apk check (ninpo,Bo$s)
# 1.1 (12/1/09) Switched to zipalign -c 4 to check the apk instead of MD5 (oknowton)
# 1.0 (11/30/09) Original
LOG_FILE=/data/kuro_zalign.log
ZIPALIGNDB=/data/kuro_zalign.db
if [ -e $LOG_FILE ]; then
rm $LOG_FILE;
fi;
if [ ! -f $ZIPALIGNDB ]; then
touch $ZIPALIGNDB;
fi;
# the preface
echo "==========================
# TWEAK KURO-ZALIGN FILE #
==========================
in the name of Allah,
the most beneficent,
the most mercifull
==========================
system information:
vendor : $( getprop ro.product.brand )
model : $( getprop ro.product.model )
ROM : $( getprop ro.build.display.id )
running the script...
start at:
$( date +"%m-%d-%Y %H:%M:%S" )
==========================" | tee -a $LOG_FILE;
# zipalign script (not modified)
for DIR in /system/app /data/app ; do
cd $DIR
for APK in *.apk ; do
if [ $APK -ot $ZIPALIGNDB ] && [ $(grep "$DIR/$APK" $ZIPALIGNDB|wc -l) -gt 0 ] ; then
echo "zipaligned: $DIR/$APK" | tee -a $LOG_FILE
else
zipalign -c 4 $APK
if [ $? -eq 0 ] ; then
echo "now zipaligned: $DIR/$APK" | tee -a $LOG_FILE
grep "$DIR/$APK" $ZIPALIGNDB > /dev/null || echo $DIR/$APK >> $ZIPALIGNDB
else
echo "Now aligning: $DIR/$APK" | tee -a $LOG_FILE
zipalign -f 4 $APK /cache/$APK
busybox mount -o rw,remount /system
cp -f -p /cache/$APK $APK
busybox rm -f /cache/$APK
grep "$DIR/$APK" $ZIPALIGNDB > /dev/null || echo $DIR/$APK >> $ZIPALIGNDB
fi
fi
done
done
touch $ZIPALIGNDB
# end
echo "==========================
done at:
$( date +"%m-%d-%Y %H:%M:%S" )
all praise is due to Allah
==========================
-- have a nice day --
[email protected]
==========================" | tee -a $LOG_FILE;
the famous zipalign script. i modify the log system. you need the zipalign binary to use it
Code:
#!/system/bin/sh
# kuro akuro: new data2sd method
# [email protected] (2012) - lol...i'm just joking. no copyright or whatsoever
# contact : [email protected]
# v.1 - first release
# v.1.1 - automated system, new build,
LOG_FILE=/data/kuro_akuro.log
if [ -e $LOG_FILE ]; then
rm $LOG_FILE;
fi;
# the preface
echo "==========================
# TWEAK AKURO-LOG FILE #
==========================
in the name of Allah,
the most beneficent,
the most mercifull
==========================
system information:
vendor : $( getprop ro.product.brand )
model : $( getprop ro.product.model )
ROM : $( getprop ro.build.display.id )
running the script...
start at:
$( date +"%m-%d-%Y %H:%M:%S" )
==========================" | tee -a $LOG_FILE;
# fix sdcard speed
if [ -e /sys/devices/virtual/bdi/179:0/read_ahead_kb ]; then
echo "2048" > /sys/devices/virtual/bdi/179:0/read_ahead_kb;
echo "fix sdcard speed tweak [OK]" | tee -a $LOG_FILE;
fi;
# create sdext dir in /system
if [ ! -e /system/sd ]; then
echo "WARNING!: no sdext dir
please create dir /system/sd" | tee -a $LOG_FILE;
fi;
echo "SDEXT directory check [OK]" | tee -a $LOG_FILE;
# mount sdcard all type
busybox mount -o noatime,nodiratime,nosuid,nodev /dev/block/mmcblk0p2 /system/sd;
mountext=`busybox mount | egrep 'ext2|ext3|ext4'`;
if [ -n "$mountext" ]; then
chown 1000:1000 /system/sd;
chmod 771 /system/sd;
fi;
echo "akuro: sd-ext mount [OK]" | tee -a $LOG_FILE;
# create the directories
if [ ! -e /system/sd/app ]; then
mkdir /system/sd/app;
busybox mv /data/app/* /system/sd/app;
fi;
if [ ! -e /system/sd/dalvik-cache ]; then
mkdir /system/sd/dalvik-cache;
busybox mv /data/dalvik-cache/* /system/sd/dalvik-cache;
fi;
echo "akuro: preparation step [OK]" | tee -a $LOG_FILE;
# mount sd to data directories
mount -o bind /system/sd/app /data/app;
chown 1000:1000 /system/sd/app;
chmod 771 /system/sd/app;
if [ -e /system/sd/app ]; then
echo "akuro: app mount step [OK]" | tee -a $LOG_FILE; else
echo "akuro: app mount step [FAIL]" | tee -a $LOG_FILE;
fi;
mount -o bind /system/sd/dalvik-cache /data/dalvik-cache;
chown 1000:1000 /system/sd/dalvik-cache;
chmod 771 /system/sd/dalvik-cache;
if [ -e /system/sd/dalvik-cache ]; then
echo "akuro: dalvik mount step [OK]" | tee -a $LOG_FILE; else
echo "akuro: dalvik mount step [FAIL]" | tee -a $LOG_FILE;
fi;
if [ -e /system/sd/data ]; then
mount -o bind /system/sd/data /data/data;
chown 1000:1000 /system/sd/data;
chmod 771 /system/sd/data;
fi;
if [ -e /system/sd/data ]; then
echo "akuro: data mount step [OK]" | tee -a $LOG_FILE; else
echo "akuro: data mount step [FAIL]" | tee -a $LOG_FILE;
fi;
# end
echo "==========================
done at:
$( date +"%m-%d-%Y %H:%M:%S" )
all praise is due to Allah
==========================
-- have a nice day --
[email protected]
==========================" | tee -a $LOG_FILE;
my own made akuro script. it works to move dalvik-cache,app, and /data/folder from our internal memory to ext2/3/4 partition on our sdcard. it will save our internal mem space. sadly this one is for samsung device. you need to modify some part of it.
have a nice tweaking
EDIT: btw, for my first and second tweak, you should use your own value. my value is taken from sgy and still under investigation to get better result.
Did not work for me using stock rom... It had gfx errors after flashing
Sent from my Xperia S using xda app-developers app
Gfx errors?
emwno said:
Gfx errors?
Click to expand...
Click to collapse
It showed the SIM menu on top of the launcher and after I entered settings this came back and then reboot. I will never apply this again.
Sent from my Xperia S using xda app-developers app

[Ubuntu][How to][4/11/12 Creating a Kernel Build Script

This thread is meant for kernel devs or people who wants to begin building kernels for their first time.
There is a bit of a learning curve to this though, you need to known Linux functions and have android environment setup
This is a UBUNTU script saved as a shell script for any version of UBUNTU
Start off script with executable script definitions
Code:
#!/bin/bash
This next part is important and ultimately optional however it makes coding the script crazy easier
I call these definitions (likely not what they are technically but, it's my interpretation) to enable shortcoding commands which makes the script look cleaner
These can be named whatever you want btw
Kerneldir - is the directory where your kernel files are kept and this is the main place where you build your kernel
Packagedir - is your work environment, this is where your boot.img will be copied to, extra files, updater-script to be later packaged into a zip folder
INITRAMFS_SOURCE - is where the ramdisk should be placed in folder form [Click Here for how to split ramdisk and zimage from boot.img]
Meta - where the updater script is kept so it can be packaged for my kernel to be able to flashed
ARCH - Must stay as this definition as it is needed for compile to become successful
CROSS_COMPILE - Toolchain command, make sure your kernel supports linaro 4.6 and later. Or default to CM's 4.4.3 toolchain. Must stay as this definition as it is needed for compile to become successful
Code:
export KERNELDIR=/home/ayysir/android/kernel/ASDK
export INITRAMFS_DEST=$KERNELDIR/kernel/usr/initramfs
export PACKAGEDIR=/home/ayysir/android/kernel/asdk_out
export INITRAMFS_SOURCE=/home/ayysir/android/kernel
export Meta=/home/ayysir/android/kernel/Ayysir/META-INF
export Drivers=/home/ayysir/android/kernel/Ayysir/Drivers
export App=/home/ayysir/android/kernel/Ayysir/app
export exfat=/home/ayysir/android/kernel/Ayysir/exfat_modules
export ARCH=arm
export CROSS_COMPILE=/home/ayysir/android/kernel/toolchains/android-toolchain-4.7/bin/arm-eabi-
This part are mostly setup commands to clean out workspace deleting previous compile remnants. This is where definitions we made above comes in handy.
The echo commands are like description commands, used for many situations but for our purpose, it tells the user what is currently happening in the script
Assuming you have knowledge about kernel deving so I don't have to hold your hand in describing things
Below commands vary depending on dev as they have their own defconfig setup for their specific device replace my asdk_defconfig with
this is is for configuring what to include the compile build
UPDATE:
OPTIONAL:
Code:
# Colorize and add text parameters
red=$(tput setaf 1) # red
grn=$(tput setaf 2) # green
cya=$(tput setaf 6) # cyan
txtbld=$(tput bold) # Bold
bldred=${txtbld}$(tput setaf 1) # red
bldgrn=${txtbld}$(tput setaf 2) # green
bldblu=${txtbld}$(tput setaf 4) # blue
bldcya=${txtbld}$(tput setaf 6) # cyan
txtrst=$(tput sgr0) # Reset
Above Codes Colorize and add text parameters.. it makes it look cleaner and more concise on what is happening in the terminal
The "echo -e" command tells terminal to apply the following text.
"${bldcya}" refers back to colorize table, making it bold (bld) and making text color cyan (cya)
"${txtrst}" closes the statement and resets the color back to terminal default. So the color parameters do not spill over into the next lines
Click to expand...
Click to collapse
the echo "" adds a space in between lines, just so it looks clean and does not jumble things
so here are some example on how to implement this: [Below]
Code:
echo -e "${bldcya} Making Kernel ${txtrst}"
make asdk_defconfig
echo""
echo -e "${bldcya} Clean Environment ${txtrst}"
make menuconfig
Code:
echo "Remove old Package Files"
rm -rf $PACKAGEDIR/*
echo "Setup Package Directory"
mkdir -p $PACKAGEDIR/system/lib/modules
echo "Setup App Directory"
mkdir -p $PACKAGEDIR/data/app
echo "Remove old zImage"
rm $PACKAGEDIR/zImage
echo "Remove old ramdisk"
rm $INITRAMFS_SOURCE/ramdisk.img.gz
echo "Clean Environment"
cd $KERNELDIR
make clean
echo "Make the kernel"
make asdk_defconfig
echo "Clean Environment"
make menuconfig
Before we get to this important section you need two files put into your /bin folder, mkbootfs and mkbootimg Click Here to download these files.
Then you need to cp these files to bin folder [put the files in home folder]
Code:
sudo cp ~/mkbootfs /bin
sudo cp ~/mkbootimg /bin
cd /bin
sudo chmod +x mkbootfs
sudo chmod +x mkbootimg
Now we are ready for next section
Make -j[num] command tells system how much things can be compiled at once, it's dependent on your system (number of processors] so i cay default to -j4
You also notice the script coding wrapped around the make command, this is what I setup to create compile log for compile session just incase you need to go back to review errors or debug some things
Code:
script -q ~/Compile.log -c "
make -j12 "
Below command searches for modules in zimage file and copies the modules files to workplace modules folder for packaging
Code:
cp -a $(find . -name *.ko -print |grep -v initramfs) $PACKAGEDIR/system/lib/modules/
Like I stated before you should of have already split the boot.img file and extracted ramdisk to a ramdisk folder. Below command uses mkbootfs to compress that folder into a .gz formatted file.
Below part is a bit tricky, because it is dependent on device to device basis.
first the code below moves ramdisk to workfolder
Then it cd's to the package folder and uses mkbootimg command to combine zimage and ramdisk together to make a boot.img
What is tricky is the command mkbootimg uses to determine space for the boot.img to be compiled in
The best way to determine the page size, base, & ramdiskaddr is either use the previous tools that you used to split a already compile boot.img commands and it spits out a file info run down or use DSIXDA ANDROID KITCHEN and using it's advanced options to determine boot.img info. Again I am not going to hold your hand on this one since you should research before trying this build script.
Note: many boot.img's use cmdline option in creation
Code:
echo "Make boot.img"
cp $INITRAMFS_SOURCE/ramdisk.img.gz $PACKAGEDIR
cd $PACKAGEDIR
mkbootimg --cmdline 'console = null androidboot.hardware=qcom user_debug=31 zcache' --kernel $PACKAGEDIR/zImage --ramdisk $PACKAGEDIR/ramdisk.img.gz --base 0x80200000 --pagesize 2048 --ramdiskaddr 0x81500000 --output $PACKAGEDIR/boot.img
Code:
echo "Packaging Ramdisk"
cd $INITRAMFS_SOURCE/
mkbootfs ./ASDK-ramdisk | gzip > ramdisk.img.gz
Code:
echo "Compiling"
script -q ~/Compile.log -c "
make -j12 "
echo "Copy modules to Package"
cp -a $(find . -name *.ko -print |grep -v initramfs) $PACKAGEDIR/system/lib/modules/
cp $Drivers/* $PACKAGEDIR/system/lib/
echo "Copy zImage to Package"
cp $KERNELDIR/arch/arm/boot/zImage $PACKAGEDIR/zImage
echo "Packaging Ramdisk"
cd $INITRAMFS_SOURCE/
mkbootfs ./ASDK-ramdisk | gzip > ramdisk.img.gz
echo "Make boot.img"
cp $INITRAMFS_SOURCE/ramdisk.img.gz $PACKAGEDIR
cd $PACKAGEDIR
mkbootimg --cmdline 'console = null androidboot.hardware=qcom user_debug=31 zcache' --kernel $PACKAGEDIR/zImage --ramdisk $PACKAGEDIR/ramdisk.img.gz --base 0x80200000 --pagesize 2048 --ramdiskaddr 0x81500000 --output $PACKAGEDIR/boot.img
This is where you add files you want packaged into your zip folder
*Remember add new definitions every time you add a new directory to the mix and have them cp all the files to workfolder
Code:
export curdate=`date "+%m-%d-%Y"`
This sets definition to zip to auto-generate dates to date your builds so it takes the work out of renaming the zip file [Your welcome lol]
Code:
zip -r ../ASDK-AOSP-4.2-$curdate.zip
set a name to your build and add $curdate.zip to enable auto dating zip
Code:
echo "Import of META-INF"
cp -R $Meta $PACKAGEDIR
echo "Import Voltage Control"
cp $App/* $PACKAGEDIR/data/app
echo "Importing Exfat fix"
cp $exfat/* $PACKAGEDIR/system/lib/modules
export curdate=`date "+%m-%d-%Y"`
cp ~/Compile.log ~/android/Compile-$curdate.log
rm ~/Compile.log
cd $PACKAGEDIR
rm ramdisk.img.gz
rm zImage
rm ../ASDK-AOSP-4.2*.zip\
rm -R .fr-7q5stU
zip -r ../ASDK-AOSP-4.2-$curdate.zip .
read -p "Press ENTER to Exit"
UPDATE:
Not to confuse anyone, Below is based off my new build script I use. PLEASE DO NOT COPY WORD FOR WORD, CODE BY CODE JUST USE IT AS REFERENCE. IF YOUR NOT SMART ENOUGH TO GET WHAT I AM DOING THEN DONT TRY BUILDING KERNELS LOL
Code:
if [ -e $KERNELDIR/arch/arm/boot/zImage ]; then
echo -e "${bldred} Copy modules to Package ${txtrst}"
cp -a $(find . -name *.ko -print |grep -v initramfs) $PACKAGEDIR/system/lib/modules/
echo ""
echo -e "${bldred} Copy zImage to Package ${txtrst}"
cp $KERNELDIR/arch/arm/boot/zImage $PACKAGEDIR/zImage
echo ""
echo -e "${bldred} Ramdisk Readying.. ${txtrst}"
cp $KERNELDIR/mkbootfs $INITRAMFS_SOURCE
cd $INITRAMFS_SOURCE/
./mkbootfs ASDK-krait | gzip > ramdisk.krait.gz
rm mkbootfs
echo ""
echo -e "${bldred} Making Boot.img.. ${txtrst}"
cp $KERNELDIR/mkbootimg $PACKAGEDIR
cp $INITRAMFS_SOURCE/ramdisk.krait.gz $PACKAGEDIR
cd $PACKAGEDIR
./mkbootimg --cmdline 'console = null androidboot.hardware=qcom user_debug=31 zcache' --kernel $PACKAGEDIR/zImage --ramdisk $PACKAGEDIR/ramdisk.krait.gz --base 0x80200000 --pagesize 2048 --ramdiskaddr 0x81500000 --output $PACKAGEDIR/boot.img
rm mkbootimg
echo ""
export curdate=`date "+%m-%d-%Y"`
cp ~/Compile.log ~/android/compile_logs/Success-Krait-$curdate.log
rm ~/Compile.log
cd $PACKAGEDIR
rm ramdisk.krait.gz
rm zImage
rm ../../ASDK-AOSP-3.4.x-*.zip
rm ../ramdisk.krait.gz
rm ../zImage
zip -r ../ASDK-AOSP-3.4.x-$curdate-EXP.zip .
mv ../ASDK-AOSP-3.4.x-$curdate-EXP.zip ~/android/kernel
echo "ASDK HOT OFF THE PRESS"
else
echo "KERNEL DID NOT BUILD! no zImage exist"
export curdate=`date "+%m-%d-%Y"`
cp ~/Compile.log ~/android/compile_logs/Failed-Krait-$curdate.log
fi;
exit 0
Now before you get mind blown Let me explain the update above:
"if [ -e $KERNELDIR/arch/arm/boot/zImage ]; then" is known as the "if, then" commands. Most used in C and scripting it tells system to look for a certain file or directory first, "if" present "then" it will proceed to following commands after it.
so if the zimage does exist then, the code after the statement will go on and end up making the zip folder.
"else" commands tells terminal, well if that file in the if statement does not exist then use following commands instead. In this case if $KERNELDIR/arch/arm/boot/zImage does not exist then else do this:
Code:
else
echo "KERNEL DID NOT BUILD! no zImage exist"
export curdate=`date "+%m-%d-%Y"`
cp ~/Compile.log ~/android/compile_logs/Failed-Krait-$curdate.log
This else statement makes a fail log to where you keep your build logs. This allows you to see where in the build did you received an error which caused the zimage to not be produced. Also it wont make a zip folder so no useless zips with no boot.img in there
Click to expand...
Click to collapse
chmod +x your script [make sure you save it as blahblah.sh] and boom your done
CLICK HERE TO SEE MY FULL SCRIPT THAT I USE FOR MY GS3 KERNEL BUILDS [NEEDS REVISING THOUGH]
IF YOU HAVE ANY QUESTIONS LEAVE IT IN THE COMMENTS OR PM ME
IF YOU LIKED MY HOW-TO AND WOULD LIKE TO DONATE TO HELP ME DEV FOR MORE DEVICES [APPRECIATED BUT DONATION NOT REQUIRED] CLICK HERE
Reserved
hm
Another Example for Fun
Well this thread looked like it needed a comment or at least some positive feedback so here it goes.
Thanks so much @ayysir for making this tutorial!!!! I've been using scripts to do lots of things for me for about a year now and it all started when I read this thread. (for some reason the though of bash scripts never really crossed my mind before then)
Here is an example of how creative I've got since the beginning of this. My script now includes some colored logos just for fun as well as final build time, uploading to goo.im, and signing of the final zip. (The logos might not show up right on here but they look great in terminal)
Code:
#!/bin/bash
#Cl3Kener's Hammerhead Script
# Colorize and add text parameters (originally grabbed from Ayysir)
red=$(tput setaf 1) # red
grn=$(tput setaf 2) # green
cya=$(tput setaf 6) # cyan
pnk=$(tput bold ; tput setaf 5) # pink
yel=$(tput bold ; tput setaf 3) # yellow
pur=$(tput setaf 5) # purple
txtbld=$(tput bold) # Bold
bldred=${txtbld}$(tput setaf 1) # red
bldgrn=${txtbld}$(tput setaf 2) # green
bldyel=${txtbld}$(tput bold ; tput setaf 3) # yellow
bldblu=${txtbld}$(tput setaf 4) # blue
bldpur=${txtbld}$(tput setaf 5) # purple
bldpnk=${txtbld}$(tput bold ; tput setaf 5) # pink
bldcya=${txtbld}$(tput setaf 6) # cyan
txtrst=$(tput sgr0) # Reset
#Place you defconfig name here:
DEFCONFIG=uber_hammerhead_defconfig
# Change these exports as needed:
export INITRAMFS_DEST=~/android/kernel/usr/initramfs
export PACKAGEDIR=~/android/kernel/OUT
export KERNEL_SOURCE=~/android/kernel
export Meta=~/android/kernel/Cl3Kener/META-INF
export Etc=~/android/kernel/Cl3Kener/etc
export Scripts=~/android/kernel/Cl3Kener/kernel
export Bin=~/android/kernel/Cl3Kener/bin
export Lib=~/android/kernel/Cl3Kener/lib
export GPU=~/android/kernel/Cl3Kener/kcontrol_gpu_msm
export sign=~/android/kernel/Cl3Kener/signapk_files
export ARCH=arm
export CROSS_COMPILE=~/android/kernel/TOOLCHAINS/arm-eabi-4.7/bin/arm-eabi-
# Place your goo.im password here instead of XXXXXX so you don't have to input password (or you can use ssh key if you have one):
export SSHPASS=XXXXXXX
# Start Time
res1=$(date +%s.%N)
# Logo (just for fun)
echo "${bldpur} ${txtrst}"
echo "${bldpur} ________________________________________ ${txtrst}"
echo "${bldpur}| |${txtrst}"
echo "${bldpur}| _| _| _|_|_| _|_|_|_| _|_|_| |${txtrst}"
echo "${bldpur}| _| _| _| _| _| _| _| |${txtrst}"
echo "${bldpur}| _| _| _|_|_| _|_|_| _|_|_| |${txtrst}"
echo "${bldpur}| _| _| _| _| _| _| _| |${txtrst}"
echo "${bldpur}| _| _| _| _| _| _| _| |${txtrst}"
echo "${bldpur}| _|_| _|_|_| _|_|_|_| _| _| |${txtrst}"
echo "${bldpur}|________________________________________|${txtrst}"
echo "${bldpur} ${txtrst}"
echo "${bldcya}Remove Old Package Files ${txtrst}"
rm -rf $PACKAGEDIR/*
echo " "
echo "${bldgrn}Setup Init.d Directory ${txtrst}"
mkdir -p $PACKAGEDIR/system/etc
echo " "
echo "${bldyel}Setup Scripts Directory ${txtrst}"
mkdir -p $PACKAGEDIR/modules
echo " "
echo "${bldblu}Remove old zImage ${txtrst}"
rm $KERNEL_SOURCE/arch/arm/boot/zImage
rm $KERNEL_SOURCE/arch/arm/boot/zImage-dtb
echo " "
echo -e "${bldred}Removing annoying gedit backup files ${txtrst}"
cd ~/android/kernel
find ./ -name '*~' | xargs rm
echo " "
echo "${bldgrn}Clean Environment ${txtrst}"
cd $KERNEL_SOURCE
make $DEFCONFIG
rm $KERNEL_SOURCE/.version
rm $KERNEL_SOURCE/.config.old
rm $KERNEL_SOURCE/.config
make clean
echo " "
echo "${bldpnk}Kernel Menu ${txtrst}"
make menuconfig
echo " "
echo "${bldcya}Compiling.... ${txtrst}"
script -q ~/Compile.log -c "
make -j7"
echo " "
if [ -e $KERNEL_SOURCE/arch/arm/boot/zImage-dtb ]; then
# I used Showp1984 msm_mpdecision hotplug and so I use his KControl Module.
echo "${bldyel}Making GPU Module ${txtrst}"
cd $GPU
make clean
make -j7
echo " "
cd $KERNEL_SOURCE
echo "${bldgrn}Copy Modules to OUT ${txtrst}"
cp -a $(find . -name *.ko -print |grep -v initramfs) $PACKAGEDIR/modules/
echo "${bldblu}Import Scripts ${txtrst}"
cp -R $Scripts $PACKAGEDIR
echo "${bldcya}Copy bin to OUT ${txtrst}"
cp -R $Bin $PACKAGEDIR/system/bin
echo "${bldred}Copy zImage to OUT ${txtrst}"
cp $KERNEL_SOURCE/arch/arm/boot/zImage-dtb $PACKAGEDIR/kernel/zImage
echo "${bldgrn}Import of META-INF ${txtrst}"
cp -R $Meta $PACKAGEDIR
echo "${bldcya}Import Init.d Tweaks ${txtrst}"
cp -R $Etc/init.d $PACKAGEDIR/system/etc
echo "${bldred}Import Dalvik/Bionic Optimized Libs ${txtrst}"
cp -R $Lib $PACKAGEDIR/system
export curdate=`date "+%m-%d-%Y"`
cp ~/Compile.log ~/android/Logs/Completed-Uber-hammerhead-$curdate.log
rm ~/Compile.log
cd $PACKAGEDIR
rm ../UBER-Hammerhead*.zip\
rm -R .fr-7q5stU
zip -r ../UBER-Hammerhead-Nightly.zip .
echo " "
echo "${bldblu}Signing Zip ${txtrst}"
cd $KERNEL_SOURCE
cp $sign/signapk.jar $KERNEL_SOURCE
cp $sign/testkey.pk8 $KERNEL_SOURCE
cp $sign/testkey.x509.pem $KERNEL_SOURCE
java -jar ~/android/kernel/signapk.jar testkey.x509.pem testkey.pk8 UBER-Hammerhead-Nightly.zip UBER-Hammerhead-Linaro-4.8.3-$curdate.zip
rm UBER-Hammerhead-Nightly.zip
rm signapk.jar
rm testkey.pk8
rm testkey.x509.pem
echo "${bldgrn} ${txtrst}"
echo "${bldgrn} ${txtrst}"
echo "${bldgrn} ________________________________________ ${txtrst}"
echo "${bldgrn}| |${txtrst}"
echo "${bldgrn}| _| _| _|_|_| _|_|_|_| _|_|_| |${txtrst}"
echo "${bldgrn}| _| _| _| _| _| _| _| |${txtrst}"
echo "${bldgrn}| _| _| _|_|_| _|_|_| _|_|_| |${txtrst}"
echo "${bldgrn}| _| _| _| _| _| _| _| |${txtrst}"
echo "${bldgrn}| _| _| _| _| _| _| _| |${txtrst}"
echo "${bldgrn}| _|_| _|_|_| _|_|_|_| _| _| |${txtrst}"
echo "${bldgrn}|________________________________________|${txtrst}"
echo "${bldgrn} ${txtrst}"
echo "${bldgrn} ${txtrst}"
echo "${bldgrn}Kernel has completed successfully!!! ${txtrst}"
echo " "
echo " "
echo "${bldgrn}Uploading .... ${txtrst}"
echo " "
sshpass -e scp -P 2222 ~/android/kernel/UBER-Hammerhead-Linaro-4.8.3-$curdate.zip [email protected]:/home/Cl3Kener/public_html/HAMMERHEAD/KERNELS/UBER/EXP-LINARO/UBER-Hammerhead-Linaro-4.8.3-$curdate.zip
# Show Elapsed Time
res2=$(date +%s.%N)
echo "${bldgrn}Total elapsed time of ALL BUILDS AND UPLOADS: ${txtrst}${grn}$(echo "($res2 - $res1) / 60"|bc ) minutes ($(echo "$res2 - $res1"|bc ) seconds) ${txtrst}"
else
export curdate=`date "+%m-%d-%Y"`
cp ~/Compile.log ~/android/Logs/Failed-Uber-hammerhead-$curdate.log
rm ~/Compile.log
echo "${bldred} ${txtrst}"
echo "${bldred} ${txtrst}"
echo "${bldred} ________________________________________ ${txtrst}"
echo "${bldred}| |${txtrst}"
echo "${bldred}| _| _| _|_|_| _|_|_|_| _|_|_| |${txtrst}"
echo "${bldred}| _| _| _| _| _| _| _| |${txtrst}"
echo "${bldred}| _| _| _|_|_| _|_|_| _|_|_| |${txtrst}"
echo "${bldred}| _| _| _| _| _| _| _| |${txtrst}"
echo "${bldred}| _| _| _| _| _| _| _| |${txtrst}"
echo "${bldred}| _|_| _|_|_| _|_|_|_| _| _| |${txtrst}"
echo "${bldred}|________________________________________|${txtrst}"
echo "${bldred} ${txtrst}"
echo "${bldred} ${txtrst}"
echo "${bldred}KERNEL IMAGE DID NOT BUILD PROPERLY! Check Compile log! ${txtrst}"
echo " "
# Show Elapsed Time
res2=$(date +%s.%N)
echo "${bldred}Total elapsed time of ALL BUILDS AND UPLOADS: ${txtrst}${red}$(echo "($res2 - $res1) / 60"|bc ) minutes ($(echo "$res2 - $res1"|bc ) seconds) ${txtrst}"
fi;
echo " "
read -p "Press ENTER to Exit"
Hope this helps some of you get creative!
If you want to see a finished product so you can figure out how everything came together see here: http://goo.im/devs/Cl3Kener/HAMMERHEAD/KERNELS/UBER
Cheers!
Cl3Kener
Awesome guide. probbaly not seen much because of its placement but his is helpful!
This is very helpful. Thanks!
Tapatalk-kal küldve az én Nexus 5-el
I have kali linux,i am using for two years
can i use it for this?

Help including SuperSU and su binaries in stock ROM.

I would like some help in modifying my stock rom to include the SuperSU apk and all five su binaries (su, daemonsu, sukernel, supolicy and suinit).
I am aware that there are multiple tutorials out there for this kind of thing but what I'm trying to do requires the system be repacked into a sparse image to flash through fastboot as the phone has no TWRP build available.
Thank You.
Bythos73 said:
I would like some help in modifying my stock rom to include the SuperSU apk and all five su binaries (su, daemonsu, sukernel, supolicy and suinit).
I am aware that there are multiple tutorials out there for this kind of thing but what I'm trying to do requires the system be repacked into a sparse image to flash through fastboot as the phone has no TWRP build available.
Thank You.
Click to expand...
Click to collapse
Hello, you can unzip the flashable SuperSu zip and take a look at the update-binary script, this will shed some light on how the installation works, for example this is an excerpt taken from version 2.82:
Code:
#!/sbin/sh
#
# SuperSU installer ZIP
# Copyright (c) 2012-2017 - Chainfire, CCMT
#
# ----- GENERIC INFO ------
#
# The following su binary versions are included in the full package. Each
# should be installed only if the system has the same or newer API level
# as listed. The script may fall back to a different binary on older API
# levels. supolicy are all ndk/pie/19+ for 32 bit, ndk/pie/20+ for 64 bit.
#
# binary ARCH/path build type API
#
# arm-v5te arm ndk non-pie 7+
# x86 x86 ndk non-pie 7+
#
# x86 x86 ndk pie 17+ (su.pie, naming exception)
# arm-v7a armv7 ndk pie 17+
# mips mips ndk pie 17+
#
# arm64-v8a arm64 ndk pie 20+
# mips64 mips64 ndk pie 20+
# x86_64 x64 ndk pie 20+
#
# Non-static binaries are supported to be PIE (Position Independent
# Executable) from API level 16, and required from API level 20 (which will
# refuse to execute non-static non-PIE).
#
# The script performs several actions in various ways, sometimes
# multiple times, due to different recoveries and firmwares behaving
# differently, and it thus being required for the correct result.
#
# Overridable variables (shell):
# BIN - Location of architecture specific files (native folder)
# COM - Location of common files (APK folder)
# LESSLOGGING - Reduce ui_print logging (true/false)
# NOOVERRIDE - Do not read variables from /system/.supersu or
# /data/.supersu
#
# Overridable variables (shell, /system/.supersu, /cache/.supersu,
# /data/.supersu):
# SYSTEMLESS - Do a system-less install? (true/false, 6.0+ only)
# PATCHBOOTIMAGE - Automatically patch boot image? (true/false,
# SYSTEMLESS only)
# BOOTIMAGE - Boot image location (PATCHBOOTIMAGE only)
# STOCKBOOTIMAGE - Stock boot image location (PATCHBOOTIMAGE only)
# BINDSYSTEMXBIN - Poor man's overlay on /system/xbin (true/false,
# SYSTEMLESS only)
# PERMISSIVE - Set sepolicy to fake-permissive (true/false, PATCHBOOTIMAGE
# only)
# KEEPVERITY - Do not remove dm-verity (true/false, PATCHBOOTIMAGE only)
# KEEPFORCEENCRYPT - Do not replace forceencrypt with encryptable (true/
# false, PATCHBOOTIMAGE only)
# REMOVEENCRYPTABLE - Remove the encryptable flag, needed on newer
# Samsung devices to disable forced encryption
# (true/false, PATCHBOOTIMAGE only)
# FRP - Place files in boot image that allow root to survive a factory
# reset (true/false, PATCHBOOTIMAGE only). Reverts to su binaries
# from the time the ZIP was originall flashed, updates are lost.
# Shell overrides all, /data/.supersu overrides /cache/.supersu overrides
# /system/.supersu
#
# Note that if SELinux is set to enforcing, the daemonsu binary expects
# to be run at startup (usually from install-recovery.sh, 99SuperSUDaemon,
# app_process, or init.supersu.rc) from u:r:supersu:s0 (7.0+), u:r:init:s0 or
# u:r:kernel:s0 contexts. Depending on the current policies, it can also
# deal with u:r:init_shell:s0 and u:r:toolbox:s0 contexts. Any other context
# will lead to issues eventually.
#
# ----- "SYSTEM" INSTALL -----
#
# "System" install puts all the files needed in /system and does not need
# any boot image modifications. Default install method pre-Android-6.0
# (excluding Samsung-5.1).
#
# Even on Android-6.0+, the script attempts to detect if the current
# firmware is compatible with a system-only installation (see the
# "detect_systemless_required" function), and will prefer that
# (unless the SYSTEMLESS variable is set) if so. This will catch the
# case of several custom ROMs that users like to use custom boot images
# with - SuperSU will not need to patch these. It can also catch some
# locked bootloader cases that do allow security policy updates.
#
# To install SuperSU properly, aside from cleaning old versions and
# other superuser-type apps from the system, the following files need to
# be installed:
#
# API source target chmod chcon required
#
# 7-19 common/Superuser.apk /system/app/Superuser.apk 0644 u:object_r:system_file:s0 gui
# 20+ common/Superuser.apk /system/app/SuperSU/SuperSU.apk 0644 u:object_r:system_file:s0 gui
#
# 17+ common/install-recovery.sh /system/etc/install-recovery.sh 0755 *1 required
# 17+ /system/bin/install-recovery.sh (symlink to /system/etc/...) required
# *1: same as /system/bin/toolbox: u:object_r:system_file:s0 if API < 20, u:object_r:toolbox_exec:s0 if API >= 20
#
# 7+ ARCH/su *2 /system/xbin/su *3 u:object_r:system_file:s0 required
# 7+ /system/bin/.ext/.su *3 u:object_r:system_file:s0 gui
# 17+ /system/xbin/daemonsu 0755 u:object_r:system_file:s0 required
# *2: su.pie for 17+ x86(_32) only
# *3: 06755 if API < 18, 0755 if API >= 18
#
# 19+ ARCH/supolicy /system/xbin/supolicy 0755 u:object_r:system_file:s0 required
# 19+ ARCH/libsupol.so /system/lib(64)/libsupol.so 0644 u:object_r:system_file:s0 required
#
# 21+ /system/bin/app_process32 *5 /system/bin/app_process32_original 0755 u:object_r:zygote_exec:s0 required
# 21+ /system/bin/app_process64 *5 /system/bin/app_process64_original 0755 u:object_r:zygote_exec:s0 required
# 21+ /system/bin/app_processXX *5 /system/bin/app_process_init 0755 u:object_r:system_file:s0 required
# 21+ /system/bin/app_process (symlink to /system/xbin/daemonsu) required
# 21+ *5 /system/bin/app_process32 (symlink to /system/xbin/daemonsu) required
# 21+ *5 /system/bin/app_process64 (symlink to /system/xbin/daemonsu) required
# *5: Only do this for the relevant bits. On a 64 bits system, leave the 32 bits files alone, or dynamic linker errors
# will prevent the system from fully working in subtle ways. The bits of the su binary must also match!
#
# 17+ common/99SuperSUDaemon *6 /system/etc/init.d/99SuperSUDaemon 0755 u:object_r:system_file:s0 optional
# *6: only place this file if /system/etc/init.d is present
#
# 17+ 'echo 1 >' or 'touch' *7 /system/etc/.installed_su_daemon 0644 u:object_r:system_file:s0 optional
# *7: the file just needs to exist or some recoveries will nag you. Even with it there, it may still happen.
#
# It may seem some files are installed multiple times needlessly, but
# it only seems that way. Installing files differently or symlinking
# instead of copying (unless specified) will lead to issues eventually.
#
# After installation, run '/system/xbin/su --install', which may need to
# perform some additional installation steps. Ideally, at one point,
# a lot of this script will be moved there.
#
# The included chattr(.pie) binaries are used to remove ext2's immutable
# flag on some files. This flag is no longer set by SuperSU's OTA
# survival since API level 18, so there is no need for the 64 bit versions.
# Note that chattr does not need to be installed to the system, it's just
# used by this script, and not supported by the busybox used in older
# recoveries.
#
# ----- "SYSTEM-LESS" INSTALL -----
#
# "System-less" install requires a modified boot image (the script can patch
# many boot images on-the-fly), but does not touch /system at all. Instead
# it keeps all the needed files in an image (/data/su.img) which is mounted
# to /su. Default install method on all Android-6.0+ and Samsung-5.1+
# devices.
#
# Note that even on 6.0+, system compatibility is checked. See the "SYSTEM"
# install section above.
#
# An ext4 image is created as /data/su.img, or /cache/su.img if /data could
# not be mounted. Similarly, the APK is placed as either /data/SuperSU.apk
# or /cache/SuperSU.apk. This is so we are not dependent on /data decryption
# working in recovery, which in the past has proved an issue on brand-new
# Android versions and devices.
#
# /sbin/launch_daemonsu.sh, which is added a service to init.rc, will mount
# the image at /su, and launch daemonsu from /su/bin/daemonsu. But before it
# does that, it will try to merge /data/su.img and /cache/su.img (leading),
# if both are present. It will also try to install the SuperSU APK.
#
# Files are expected at the following places (/su being the mountpoint of
# the ext4 image):
#
# API source target chmod chcon required
#
# 22+ common/Superuser.apk /[data|cache]/SuperSU.apk 0644 u:object_r:system_file:s0 gui
#
# 22+ ARCH/su *1 /su/bin/su 0755 u:object_r:system_file:s0 required
# 22+ /su/bin/daemonsu 0755 u:object_r:system_file:s0 required
# *1: su.pie for 17+ x86(_32) only
#
# 22+ ARCH/supolicy /su/bin/supolicy_wrapped 0755 u:object_r:system_file:s0 required
# 22+ /su/bin/su (symlink) *2 /su/bin/supolicy 0755 u:object_r:system_file:s0 required
# 22+ ARCH/libsupol.so /su/lib/libsupol.so 0644 u:object_r:system_file:s0 required
# *2: when called this way, su sets the correct LD_LIBRARY_PATH and calls supolicy_wrapped
#
# 22+ ARCH/sukernel /su/bin/sukernel 0755 u:object_r:system_file:s0 required
#
# These files are automatically created on launch by daemonsu as needed:
# 22+ /system/bin/sh /su/bin/sush 0755 u:object_r:system_file:s0 required
# 22+ /system/bin/app_process[64] /su/bin/app_process 0755 u:object_r:system_file:s0 required
#
# These files are injected into the boot image ramdisk:
# 22+ common/launch_daemonsu.sh /sbin/launch_daemonsu.sh 0700 u:object_r:rootfs:s0 required
#
# On devices where / is in the system partition:
# 22+ ARCH/suinit /init 0750 u:object_r:rootfs:s0 required
#
# The automated boot image patcher included makes the following modifications
# to the ramdisk:
#
# - Uses the supolicy tool to patch the sepolicy file
# - Injects /sbin/launch_daemon.sh
# - Creates /su
# - Removes /verity_key
# - Patches /*fstab*
# --- Removes support_scfs and verify flags
# --- Changes forceencrypt/forcefdeorfbe into encryptable
# --- Set ro mounts to use noatime
# - Patches /init.rc
# --- Removes 'setprop selinux.reload_policy' occurences
# --- Adds a SuperSU:PATCH marker with the version of the sukernel tool
# --- Adds a SuperSU:STOCK marker listed the SHA1 of the original boot image
# - Adds /init.supersu.rc
# --- Adds a sukernel.mount property trigger that mounts /data/su.img to /su
# --- Adds the daemonsu service that launches /sbin/launch_daemon.sh
# --- Adds exec /sbin/launch_daemonsu.sh on post-fs-data
# - Patches /init.environ.rc
# --- Adds PATH variable if it does not exist
# --- Prepends /su/bin to the PATH variable
# - Patches /*.rc
# --- Adds a seclabel to services and execs that are missing one
# - In case the device has the root directory inside the system partition:
# --- /system_root contents are copied to /boot
# --- All files mentioned above are modified in /boot instead of /
# --- /boot/*fstab* is modified to mount / to /system_root, and
# bind-mount /system to /system_root/system
# --- Kernel binary is patched to load from initramfs instead of system
#
# In case this documentation becomes outdated, please note that the sukernel
# tool is very chatty, and its output tells you exactly what it is doing
# and how. In TWRP, you can view this output by catting /tmp/recovery.log
# after flashing the ZIP.
#
# The boot image patcher creates a backup of the boot image it patches, for
# future restoration. It cannot re-patch a patched boot image, it will restore
# the previous boot image first. /[data|cache]/stock_boot_*.gz
#
# The boot image patcher currently only supports GZIP compressed ramdisks, and
# boot images in the standard Android boot image format.
#
# During boot image patch, /data/custom_ramdisk_patch.sh will be called,
# with the name of the ramdisk cpio file as parameter. The script must
# replace the input file and return a 0 exit code.
#
# Just before flashing, the boot image patcher will call
# /data/custom_boot_image_patch.sh with the name of the patched boot image
# as parameter. A device-specific patcher can further patch the boot image
# if needed. It must replace the input file and return a 0 exit code.
OUTFD=$2
ZIP=$3
getvar() {
local VARNAME=$1
local VALUE=$(eval echo \$"$VARNAME");
for FILE in /data/.supersu /cache/.supersu /system/.supersu; do
if [ -z "$VALUE" ]; then
LINE=$(cat $FILE 2>/dev/null | grep "$VARNAME=")
if [ ! -z "$LINE" ]; then
VALUE=${LINE#*=}
fi
fi
done
eval $VARNAME=\$VALUE
}
readlink /proc/$$/fd/$OUTFD 2>/dev/null | grep /tmp >/dev/null
if [ "$?" -eq "0" ]; then
# rerouted to log file, we don't want our ui_print commands going there
OUTFD=0
# we are probably running in embedded mode, see if we can find the right fd
# we know the fd is a pipe and that the parent updater may have been started as
# 'update-binary 3 fd zipfile'
for FD in `ls /proc/$$/fd`; do
readlink /proc/$$/fd/$FD 2>/dev/null | grep pipe >/dev/null
if [ "$?" -eq "0" ]; then
ps | grep " 3 $FD " | grep -v grep >/dev/null
if [ "$?" -eq "0" ]; then
OUTFD=$FD
break
fi
fi
done
fi
ui_print_always() {
echo -n -e "ui_print $1\n" >> /proc/self/fd/$OUTFD
echo -n -e "ui_print\n" >> /proc/self/fd/$OUTFD
}
if [ -z "$LESSLOGGING" ]; then
LESSLOGGING=false
fi
UI_PRINT_LAST=""
ui_print() {
if (! $LESSLOGGING); then
UI_PRINT_LAST="$1"
ui_print_always "$1"
fi
}
ui_print_less() {
if ($LESSLOGGING); then
ui_print_always "$1"
fi
}
ch_con() {
LD_LIBRARY_PATH=$SYSTEMLIB /system/bin/toybox chcon -h u:object_r:system_file:s0 $1 1>/dev/null 2>/dev/null
LD_LIBRARY_PATH=$SYSTEMLIB /system/toolbox chcon -h u:object_r:system_file:s0 $1 1>/dev/null 2>/dev/null
LD_LIBRARY_PATH=$SYSTEMLIB /system/bin/toolbox chcon -h u:object_r:system_file:s0 $1 1>/dev/null 2>/dev/null
chcon -h u:object_r:system_file:s0 $1 1>/dev/null 2>/dev/null
LD_LIBRARY_PATH=$SYSTEMLIB /system/bin/toybox chcon u:object_r:system_file:s0 $1 1>/dev/null 2>/dev/null
LD_LIBRARY_PATH=$SYSTEMLIB /system/toolbox chcon u:object_r:system_file:s0 $1 1>/dev/null 2>/dev/null
LD_LIBRARY_PATH=$SYSTEMLIB /system/bin/toolbox chcon u:object_r:system_file:s0 $1 1>/dev/null 2>/dev/null
chcon u:object_r:system_file:s0 $1 1>/dev/null 2>/dev/null
}
ch_con_ext() {
LD_LIBRARY_PATH=$SYSTEMLIB /system/bin/toybox chcon $2 $1 1>/dev/null 2>/dev/null
LD_LIBRARY_PATH=$SYSTEMLIB /system/toolbox chcon $2 $1 1>/dev/null 2>/dev/null
LD_LIBRARY_PATH=$SYSTEMLIB /system/bin/toolbox chcon $2 $1 1>/dev/null 2>/dev/null
chcon $2 $1 1>/dev/null 2>/dev/null
}
Thanks for the quick response. I have attempted to copy some of the files stated in excerpt to my system image but it seems that I might have missed a few. But I see it stating some chcon commands so I'm just wondering if it'd be possible to chcon the files needed on a linux pc and have it work.
Bythos73 said:
Thanks for the quick response. I have attempted to copy some of the files stated in excerpt to my system image but it seems that I might have missed a few. But I see it stating some chcon commands so I'm just wondering if it'd be possible to chcon the files needed on a linux pc and have it work.
Click to expand...
Click to collapse
I'm not sure what will happen if you run those chcon commands, what happened when you tried it?
Yup, this manual way may be a bit tricky
http://su.chainfire.eu/#embed said:
6. Embedding
6.1. Files
All the files you need are in the latest SuperSU flashable ZIP. The latest 'stable' build can always be retrieved from my server, for the latest 'beta' release you need to check the beta thread in the SuperSU forums.
The installation script inside the ZIP is META-INF/com/google/android/update-binary. This is not a binary as the name suggests, but a shell script, and the standard update ZIP's updater-script file is just a dummy.
This script has comments which document which files go where on which API level, and what their file permissions, ownerhips, and security labels must be. If you have done this exactly right, SuperSU will not complain when you open the app after booting.
6.2. Custom ROMs
It is non-trivial to include SuperSU exactly right on your own. It is therefore often easiest to include the latest SuperSU ZIP inside your own flashable ZIP, and chain its installation.
Click to expand...
Click to collapse
Can you tell us a bit more about your device model & android version, and which files you copied/commands you ran so far?
What errors if any do you get after flashing your modified img?
I secretly hope a custom recovery exists for your device, or porting one proves easier :fingers-crossed:
I'm repacking the image now using img2simg for my first boot attempt.
I have an Alcatel 3 5052A, Device CodeName A3A running Android Oreo 8.1.0. So far I don't believe I can get a custom recovery for this device as the line of devices that this phone was released with seem to have a bootloader which doesn't boot unsigned images, nevermind the fact that it's impossible to flash any partition other than system through fastboot. It's a real pain. Thankfully it does boot GSIs like Phh-Treble so not all hope is lost on that front.
I've copied the su and supolicy binaries, I got daemonsu by copying the su bin, I also copied the SuperSU apk and the libsupol.so library into all of their respective directories.
It has booted but no su, and SuperSU was not in the Launcher so I'm gonna retry it.
Don't give up! there are lots of avenues yet to explore if you want to give the manual method a rest for a while.
What do you get when you try unlocking the bootloader from fastboot?
Are you familiar with SP Flash tools? This is an alternative way to flash images onto various MTK devices.

How To Guide Add updated TOYBOX w/ ROOT to Windows Subsystem for Android™️

Preface​
Unfortunately Windows Subsystem for Android (WSA) is missing fully fledged Toybox ( This is a package of over 200 command-line tools, handy for advanced users - it's located in /usr/{bin,sbin} ) - though according to Microsoft WSA is meant to be used by app developers, as development platform, IIRC.
Toybox v0.8.4 ( released 2020-10-24 ) commands currently provided:
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
So IMO it's time to install latest fully-fledged version ( at time of this writing it's 0.8.8 released 2022-08-12 ) of Toybox on WSA:
As you can see currently the fully-fledged Toybox command suite contains the SU command ( Toybox as provided with WSA is missing it ) what allows you to root Android, will say give you elevated rights so you get complete access to everything in the operating system, and those permissions allow you to change it all.​
Remarks​USB-Debugging is by default enabled in WSA to implicitly give up your encryption secrets to the connected computer: WSA performs per-file encryption that is software-based.
This suggested updating doesn't replace / remove the pre-installed Toybox version.
Installation into Android's data partition ( recommended )​The roadmap
Connect PC to WSA
Save SELinux context of preinstalled Toybox
Download attached Toybox binary and extract it to any location on PC, e.g. C:\
Download attached SU binary and extract it to any location on PC, e.g. C:\
Next thing to do is to transfer the attached SU binary - assumed it got stored in C:\ - to /sdcard/Download because during the updating process we sometimes need elevated rights
and give executable rights to it
and set its file-ownership-UID 2000 is the default user on WSA
Create a directory named toybox under /data/local/tmp
Transfer the downloaded toybox binary to /sdcard/Download
Disable SElinux what by default in WSA is enabled
Copy the transferred toybox binary to /data/local/tmp what sets its owner to shell:shell
and give executable permission to it. (The default permissions set for other binaries is rwxr-xr-x)
Create symlinks for the all the various tools accessible by toybox binary
Set SELinux context on all files created
Re-enable SELinux because by default in WSA it's enabled
Do some housekeeping ...
and restart WSA
The script - it's a hybrid DOS / Linux coded one
@Echo off & setlocal ENABLEDELAYEDEXPANSION
popd "%CD%"
::
title WSA Toybox Updater
color f0 & mode con: cols=54 lines=40
echo(
echo ####################################
echo # #
echo # WSA Toybox Updater #
echo # #
echo # Updates existing Toybox to #
echo # version 0.8.8 what comes with #
echo # SU-function embeddedd #
echo # #
echo # (c) 2022 [email protected] #
echo # License: BSD 2-Clause #
echo # #
echo ####################################
echo(
echo Press 1 to Continue, 0 to Abort
choice /C 10 /M "Please select"
if !errorlevel! NEQ 1 ( goto :done )
cls
::
set "adb="
set "subin="
set "tbbin="
set "adb_org=adb_r33.0.3.exe"
set "tbbin_org=toybox-x86_64"
set "subin_org=su-x86_64"
set "wsa_svc=WsaService.exe"
set "address=127.0.0.1"
::
:: Sanity checks
echo(
echo Verifying availability of required files ..
for /F "tokens=*" %%t in ('fsutil fsinfo drives') do ( set "drives=%%t" )
:: 1st check folder we are running this bat from, 2nd search all drives
set "drive=%CD:~0,2%"
for /F "tokens=*" %%t in ('where /R !drive! !adb_org! 2^>nul') do ( set "adb=%%t" )
if defined adb ( goto :done_query_adb_org )
for /F "tokens=2* delims= " %%a in ("!drives!") do (
set "drive2=%%a"
for /F "tokens=*" %%t in ('where /R !drive2! !adb_org! 2^>nul') do ( set "adb=%%t" )
if defined adb ( goto :done_query_adb_org )
)
echo FATAL: !adb_org! not found on PC & goto :failed
:done_query_adb_org
for /F "tokens=*" %%t in ('where /R !drive! !subin_org! 2^>nul') do ( set "subin=%%t" )
if defined subin ( goto :done_query_subin_org )
for /F "tokens=2* delims= " %%a in ("!drives!") do (
set "drive2=%%a"
for /F "tokens=*" %%t in ('where /R !drive2! !subin_org! 2^>nul') do ( set "subin=%%t" )
if defined subin ( goto :done_query_subin_org )
)
echo FATAL: !subin_org! not found on PC & goto :failed
:done_query_subin_org
for /F "tokens=*" %%t in ('where /R !drive! !tbbin_org! 2^>nul') do ( set "tbbin=%%t" )
if defined tbbin ( goto :done_query_tbbin_org )
for /F "tokens=2* delims= " %%a in ("!drives!") do (
set "drive2=%%a"
for /F "tokens=*" %%t in ('where /R !drive2! !tbbin_org! 2^>nul') do ( set "subin=%%t" )
if defined subin ( goto :done_query_subin_org )
)
echo FATAL: !tbbin_org! not found on PC & goto :failed
:done_query_tbbin_org
echo OK
echo(
echo Checking if WSA emulator is running ...
for /F "tokens=1 delims= " %%t in ('tasklist /FI "IMAGENAME eq !wsa_svc!" 2^>nul ^| findstr /I /C:"!wsa_svc!"') do (
set "proc=%%t"
if NOT "!proc!"==[] ( goto :done_wsa_check )
)
echo FATAL: WSA is not running & goto :failed
:done_wsa_check
echo OK
tasklist /FI "IMAGENAME eq adb*" | findstr /I /C:"adb" >nul && goto :adb_running || goto :adb_not_running
:adb_running
!adb! disconnect >nul 2>&1
:: Force a fresh start of ADB
taskkill /FI "IMAGENAME eq adb*" /IM >nul 2>&1
:adb_not_running
echo(
echo Connecting Windows to WSA emulator ...
:: Ports are odd-numbered in the range 5555 to 5585,
:: the default port is 5555
for /L %%a in (5555,2,5585) do (
set "tcpport=%%a"
!adb! connect !address!:!tcpport! >nul 2>&1
:: Verify WSA emulator is connected
for /F "tokens=*" %%t in ('!adb! get-state 2^>nul') do (
set "state=%%t"
echo !state! | findstr /C:"device" >nul
if !errorlevel! EQU 0 ( goto :done_wsa_connection )
)
)
echo FATAL: WSA emulator got not connected & goto :failed
:done_wsa_connection
echo OK
::
::
::
set "subin_fn=su"
set "tbbin_fn=toybox"
set "dldir=/sdcard/Download"
set "sucmd=!dldir!/!subin_fn!"
set "tmpdir=/data/local/tmp"
set "tbdir=!tmpdir!/!tbbin_fn!"
::
::
set "sucmd=!dldir!/!subin_fn!"
set "tbbin=!dldir!/!tbbin_fn!"
:: Check if job already was done
echo(
echo Validating Toybox update already done ...
set /A fc=0
!adb! pull !sucmd! %TEMP%\!subin_fn! >nul 2>&1
if !errorlevel! EQU 0 ( set /A fc+=1 )
!adb! pull !tbbin! %TEMP%\!tbbin_fn! >nul 2>&1
if !errorlevel! EQU 0 ( set /A fc+=1 )
if exist "%TEMP%\!subin_fn!" ( del /F /Q "%TEMP%\!subin_fn!" )
if exist "%TEMP%\!tbbin_fn!" ( del /F /Q "%TEMP%\!tbbin_fn!" )
if !fc! EQU 2 ( echo OK & goto :done_files_transferred )
echo OK
echo(
echo Transferring files ...
:: Transfer SU binary to /sdcard/Download
:: because during the updating process we sometimes need elevated rights
!adb! push !subin_org! !dldir!/
if !errorlevel! NEQ 0 (
echo Failed: Transferring SU failed
goto :failed
)
:: Transfer the downloaded toybox binary to /sdcard/Download
!adb! push !tbbin_org! !dldir!/ >nul 2>&1
if !errorlevel! NEQ 0 (
echo Failed: Transferring Toybox failed
goto :failed
)
:done_files_transferred
echo OK
::
echo(
echo Updating Toybox ...
::
:: start Android shell on the WSA emulator
::
!adb! shell
set -e
#
#
DL_DIR=/sdcard/Download;
TB_DIR=/data/local/tmp/toybox;
TB_BIN=/data/local/tmp/toybox/toybox;
SU_BIN="$DL_DIR"/su;
SU_BIN_ORG=su-x86_64;
TB_BIN_ORG=toybox-x86_64;
cat < SCRIPT > "$DL_DIR"/cat.sh & chmod +x "$DL_DIR"/cat.sh & source < "$DL_DIR"/cat.sh; \
'# Save SELinux context of pre-installed Toybox' \
TOYBOX="$(which 'toybox')"; \
EXPR=$(ls -lZ "$TOYBOX"); \
TB_SECURITY_CONTEXT=$(cut -d " " -f 4 "$EXPR"); \
'# give SU binary executable rights' \
'# Get UID GID from pre-installed toybox' \
EXPR="$(ls -ld "$TOYBOX")"; \
TB_UID=$(cut -d " " -f 3 "$EXPR"); \
TB_GID=$(cut -d " " -f 4 "$EXPR"); \
'# Set these UID GID on SU too' \
chown -f "$TB_UID":"$TB_GID" "$SU_BIN"; \
'# Create a directory named toybox under /data/local/tmp' \
if [ ! -d "$TB_DIR" ]; then ( \
$SU_BIN -c 'mkdir -p "$TB_DIR" 2>/dev/null; touch "$TB_DIR" 2>/dev/null'; \
fi; \
'# rename SU and Toybox binaries provided if not already exist' \
if [[ (! -f "$SU_BIN" || ! -f "$TB_BIN") ]]; then { \
mv -T "$DL_DIR/$SU_BIN_ORG" "$SU_BIN" 2>/dev/null; \
mv -T "$DL_DIR/$TB_BIN_ORG" "$TB_BIN" 2>/dev/null; \
} \
fi; \
'# Temporarily disable SElinux what by default in WSA is enabled' \
$SU_BIN 0 setenforce 0; \
'# Copy the transferred toybox binary to /data/local/tmp/toybox what sets its owner to shell:shell' \
cp -Tp "$TB_BIN_ORG" "$TB_DIR/$TB_BIN" >/dev/null; \
'# and give executable permission to it' \
chmod -f +x "$TB_DIR"; \
'# Create symlinks for the various Linux applets provided by toybox binary' \
for i in $($TB_DIR/$TB_BIN --long); do ln -s $TB_DIR/$TB_BIN $i; done: \
'# Set SELinux context on all files created'
$SU_BIN -c 'chcon -R "$TB_SECURITY_CONTEXT toybox" "$TB_DIR"; \
'# Re-enable SELinux because by default in WSA it's enabled' \
$SU_BIN 0 setenforce 1; \
'# Do some housekeeping ...' \
rm -f "$SU_BIN","$TB_BIN" 2>/dev/null; \
SCRIPT
#
## exit the Android shell
exit
::
::
echo OK
:: and restart
echo(
echo Restarting WSA ...
!adb! reboot
echo OK
:failed
timeout /t 10 /nobreak >nul
::
:done
echo(
echo Job done. Exiting ...
pause
pushd
taskkill /FI "IMAGENAME eq adb*" /IM >nul 2>&1
endlocal & DISABLEDELAYEDEXPANSION
exit
Screenshot
Done​Enjoy your Toybox and its applets are ready to be executed.
Validation​
( using ADB code stored in a Windows .BAT-file )
Code:
@echo off & setlocal ENABLEDELAYEDEXPANSION
pushd "%CD%"
::
::
set "adb_exe=adb_r33.0.3.exe" & set "adb="
set "ip4_address=" & set "port=58526"
set "wsa_svc=WsaService.exe"
::
::
title WSA-TOYBOX-UPDATE-VALIDATOR
color f0 & mode con: cols=50 lines=40
echo(
echo ####################################
echo # #
echo # WSA Toybox Update Validator #
echo # #
echo # Verifies Toybox got updated to #
echo # version 0.8.8 what comes with #
echo # SU-function embeddedd #
echo # #
echo # (c) 2022 [email protected] #
echo # License: BSD 2-Clause #
echo # #
echo ####################################
echo(
echo Verifying presence of ADB executable ...
:: check folder we are running this bat from
set "drive=%CD:~0,2%"
for /F "tokens=*" %%t in ('where /R !drive! !adb_exe! 2^>nul') do ( set "adb=%%t" )
if defined adb ( goto :done_query_adb )
echo FATAL: !adb_exe! not found on PC & goto :failed
:done_query_adb
echo OK & echo(
echo Checking if WSA emulator is already up ...
for /F "tokens=1 delims= " %%t in ('tasklist /FI "IMAGENAME eq !wsa_svc!" 2^>nul ^| findstr /I /C:"!wsa_svc!"') do (
set "proc=%%t"
if NOT "!proc!"==[] ( goto :done_wsa_check )
)
echo FATAL: WSA is not running & goto :failed
:done_wsa_check
echo OK & echo(
:: Force a fresh start of ADBis
tasklist /FI "IMAGENAME eq adb*" | findstr /I /C:"adb" >nul 2>nul && goto :adb_is_running || goto :adb_isnot_running
:adb_is_running
:: disconnect all
!adb! disconnect >nul 2>&1
taskkill /FI "IMAGENAME eq adb*" /IM >nul 2>&1
:adb_isnot_running
::
:: get our IP4 address
echo Obtaining local IP4 address ...
rem for /F “tokens=1,2 delims=:" %%a in ('ipconfig ^| findstr /I /C:"ipv4" ^>nul') do (
rem if !errorlevel! EQU 0 ( set "ip4_address=%%b" )
rem )
if defined ip4_address ( goto :done_query_ip4_address )
:: workaround
set "ip4_address=127.0.0.1"
:done_query_ip4_address
echo OK ^[ !ip4_address!^] & echo(
echo Connecting to emulator ...
:: start using default port
!adb! connect !ip4_address!:!port! >nul
for /F "tokens=*" %%t in ('!adb! get-state ^>nul 2^>^&1 ^| findstr /C:"device" ^>nul 2^>nul') do (
set "retval=%%t"
if "!retval!"==[] ( echo Internal error occured & timeout /t 5 /nobreak >nul & goto :oops )
)
echo OK & echo(
echo Checking for SU applet is reachable ...
!adb! shell "PATH=/data/local/tmp/toybox:$PATH; su 2>/dev/null; STATUS=$?;[ $STATUS -eq 0 ] && echo "OK" || echo "Failed"; sleep 10s;"
:oops
taskkill /FI "IMAGENAME eq adb*" /IM >nul 2>&1
:failed
echo(
pause
popd
endlocal DISABLEDELAYEDEXPANSION
exit
Screenshot:
Download​
This package got attached for your convenience
Last Note​Toybox applets are for Terminal and shell scripts - you may use ScriptRunner2 for the latter.
BTW:
Before running a script edit your default shell's configuration file via adding in an DOS coded script saved to a .BAT-file
Code:
adb shell "PATH=/data/local/tmp/toybox:$PATH"
at script's begin what would cause the shell to look into /data/local/tmp/toybox first and execute the binary, if available.
Toybox command help​is here:
Toybox 0.8.9 command help
[reserved]
Can you provide an installer script? It would make it easer for all. Thanks in advance.
Sure. But needs some time. Stay tuned.
jwoegerbauer said:
if !su_found! EQU 1 ( echo SU binary found )
else ( echo SU binary not found )
Click to expand...
Click to collapse
"Else" needs to be on the same line as the "if" in order to be read by interpreter.
Or the ")" + "else" needs to drop to the line below it.
Should be:
if !su_found! EQU 1 ( echo SU binary found ) else ( echo SU binary not found )
OR
if !su_found! EQU 1 ( echo SU binary found
) else ( echo SU binary not found )
EDIT: Also, "@ECHO on" turns on verbose command output, does no good to place at the very end (no harm either)
Thanks for that error notice: implicitely corrected it by a complete revamp of the script.
can you provide a shell script command please

Categories

Resources