• Introducing XDA Computing: Discussion zones for Hardware, Software, and more!    Check it out!
  • Fill out your device list and let everyone know which phones you have!    Edit Your Device Inventory

[guide][root] Tweaks Redmi 4x stock ROM

Search This thread

tweakradje

Senior Member
Mar 18, 2005
1,066
536
Android
sites.google.com
Hello xda world,

EDIT 24 may 2018: using Luis kernel now on RR 5.8.4. Best I have tried so far!!
Link: http://luis-builds.de/downloads/lineageos/rr/Xiaomi_Redmi_4X_(santoni)/

EDIT 10-feb-2018: battery drain due to *alarm* and *launcher* system wakelocks solved with firmware V32.
Grab it here and flash with TWRP: https://forum.xda-developers.com/xiaomi-redmi-4x/how-to/firmwares-t3682965

Here I hope to collect some tweaks and mods that work in rooted Redmi 4x stock rom. (8.2.10.0 Global)
EDIT: since I use Resurrection Remix now I also added some RR tweaks

Since I just own the device it will be work in progress for a while. I search the forums for solutions for problems I encounter.

My Redmi 4x is OEM unlocked via Xiaomi, has twrp and Magisk root. (you need root for tweaks)
For OEM unlock you need account and register at miui.com, ask for unlock, wait 30+ hours and then use the miui unlock tool that checks if you are granted bij Xiaomi for unlock.

Some Redmi 4x facts:

- Xiaomi Redmi 4x has codename Santoni
- The Soc is Qualcomm 435 (msm8940 socid 313, msm8937 for the firmware), 4 cpu cores perf and 4 cpu cores power
- The gpu is Adreno 505
- main camera is Samsung S5K3L8, front camera is Omnivision ov5675
- notification LED has RGB!
- 5 GHz (11ac) only supported for wifi hotspot (wlan.ko issue)
- MIUI features are setup in the /etc/device_features/santoni.xml file
- CPU/kernel features are mostly setup in the /etc/init.qcom.post_boot.sh file
- fastboot: hold vol- and power, release power after vibrate
- recovery: hold vol+ and vol- and power, release power after vibrate

Redmi 4x related sites:

- Official miui.com for Redmi 4x http://en.miui.com/forum-123-1.html
- Resurrection Remix ROM for Redmi 4x https://sourceforge.net/projects/resurrectionremix/files/santoni/ (Antutu score 43000+)
- Miui EU ROM https://xiaomi.eu/community/forums/miui-weekly-rom-releases.103/
- Mi-Globe ROM (like EU ROM but with options) Mi-Globe
- Miui Belarus (MiuiPro) ROM https://miuipro.by/roms/
- Redmi 4x Global Edition on Bangood
- AOSP Extended (AEX) ROM Redmi 4X http://downloads.aospextended.com/santoni/

Note: If you change any file always make a copy of it first. I always copy the file in the same folder and give it extension .ORG. So build.prop becomes build.prop.ORG with adb shell: cp -p build.prop build.prop.ORG
Be sure the permissions of the files are set to rw-r--r-- (644)!!!!!!

Example adb/linux commands

From pc:
adb push "afile" /sdcard
adb shell

On device:
su
stop
mount -o remount,rw /system
cd "/afolder"
cp -p "afile" "afile.ORG"
cp /sdcard/"afile" .
ls -l "afile*"
chmod 644 "afile"
reboot

Ofcourse afile and afolder are just example names.

If you are not familiar with linux shell or adb then you can find zip files to flash in TWRP mode.
You need to REBOOT after changing any of these files.

Note 2: I am not responsible for any damage to your device. Use this at your own risk!

Audio recording mod (mixer mod)

Recording audio on stock rom is terrible. On the internet I found a solution. You need to change 2 mixer files.
If you also want louder speaker you need to copy /etc/mixer_paths.xml too.

/etc/mixer_paths_qrd_sku1.xml
mic volume for voice call
Code:
    <path name="voice-call">
<!-- tweakradje add 2 lines -->
		<ctl name="DEC1 Volume" value="88" />
		<ctl name="DEC2 Volume" value="88" />
        <ctl name="PRI_MI2S_RX_Voice Mixer CSVoice" value="1" />
        <ctl name="Voice_Tx Mixer TERT_MI2S_TX_Voice" value="1" />
    </path>
mic volume for audio rec like movie, try between 100-124, use 100 for very loud env
Code:
    <path name="handset-mic">
        <path name="adc1" />
<!-- tweakradje add 2 lines -->
		<ctl name="DEC1 Volume" value="110" />
		<ctl name="DEC2 Volume" value="110" />
        <ctl name="IIR1 INP1 MUX" value="DEC1" />
    </path>
mic volume for audio rec like movie, try between 100-124, use 100 for very loud env
Code:
    <path name="handset-stereo-dmic-ef">
<!-- tweakradje add 2 lines -->
        <ctl name="DEC1 Volume" value="110" />
        <ctl name="DEC2 Volume" value="110" />
        <path name="speaker-dmic-endfire" />
    </path>

/etc/audio_platform_info.xml
Code:
    <acdb_ids>
<!-- tweakradje add 2 lines, but no more auto rec mic volume -->
        <device name="SND_DEVICE_IN_HANDSET_MIC" acdb_id="1"/>
        <device name="SND_DEVICE_IN_HANDSET_STEREO_DMIC" acdb_id="1"/>
        <device name="SND_DEVICE_OUT_SPEAKER_PROTECTED" acdb_id="136"/>
        <device name="SND_DEVICE_OUT_VOICE_SPEAKER_PROTECTED" acdb_id="136"/>
        <device name="SND_DEVICE_OUT_SPEAKER_PROTECTED_VBAT" acdb_id="136"/>
        <device name="SND_DEVICE_OUT_VOICE_SPEAKER_PROTECTED_VBAT" acdb_id="136"/>
        <device name="SND_DEVICE_IN_CAPTURE_VI_FEEDBACK" acdb_id="137"/>
    </acdb_ids>

Now audio is fine when recording video and sounds even great!
You can download the 2 files below. Check if you need to insert these lines in your file or that you can use mine.
For recording stereo audio only I use Sony Audio Recorder which is free and perfect.

EDIT 18 dec 2017: Found that acdb_id="4" works well, which is the default mic profile in ACDB. However you need to lower the "DEC1 Volume" and "DEC2 Volume" to 94.

EDIT 23 dec 2017: About Audio Calibration (ACDB) files
You might have noticed that there are more than one set of acdb file in /etc/acdbdata folder. There are MTP end QRD sets. QRD stands for Qualcomm Reference Design. You can play with these Calibration Profiles for speakers and microphone.
Easiest is to create a new build.prop (644) in the /vendor folder.

Then play with these values. You can also mix MTP and QRD for devices. Like using all MTP but for General and Handset use the QRD version.
Code:
persist.audio.calfile0=/etc/acdbdata/QRD/QRD_Bluetooth_cal.acdb
persist.audio.calfile1=/etc/acdbdata/QRD/QRD_General_cal.acdb
persist.audio.calfile2=/etc/acdbdata/QRD/QRD_Global_cal.acdb
persist.audio.calfile3=/etc/acdbdata/QRD/QRD_Handset_cal.acdb
persist.audio.calfile4=/etc/acdbdata/QRD/QRD_Hdmi_cal.acdb
persist.audio.calfile5=/etc/acdbdata/QRD/QRD_Headset_cal.acdb
persist.audio.calfile6=/etc/acdbdata/QRD/QRD_Speaker_cal.acdb

#persist.audio.calfile0=/etc/acdbdata/MTP/MTP_Bluetooth_cal.acdb
#persist.audio.calfile1=/etc/acdbdata/MTP/MTP_General_cal.acdb
#persist.audio.calfile2=/etc/acdbdata/MTP/MTP_Global_cal.acdb
#persist.audio.calfile3=/etc/acdbdata/MTP/MTP_Handset_cal.acdb
#persist.audio.calfile4=/etc/acdbdata/MTP/MTP_Hdmi_cal.acdb
#persist.audio.calfile5=/etc/acdbdata/MTP/MTP_Headset_cal.acdb
#persist.audio.calfile6=/etc/acdbdata/MTP/MTP_Speaker_cal.acdb




MIUI Camera mod (features unlock)

This is how you unlock those high end features you find on higher end models. To enable the features you need to edit the /etc/device_features/santoni.xml (or /sdcard/device_features/santoni.xml) file. Mostly change false into true to enable them.
Some are also added from other Xiaomi devices.
Download from below.

Camera parameters found:
Code:
support_camera_4k_quality
support_camera_age_detection
support_camera_aohdr
support_camera_audio_focus
support_camera_boost_brightness
support_camera_burst_shoot
support_camera_gradienter
support_camera_hfr
support_camera_manual_function
support_camera_movie_solid
support_camera_peaking_mf
!support_camera_press_down_capture
support_camera_quick_snap
support_camera_record_location
support_camera_shader_effect
support_camera_skin_beauty
support_camera_tilt_shift
support_camera_torch_capture
support_camera_ubifocus
support_camera_video_pause
support_camera_water_mark


Camera 2 API

You can enable Camera 2 API for 3rd party camera apps. Think about manual focus etc.
Add this line to your build.prop:

persist.camera.HAL3.enabled=1

More interesting Camera's: https://forum.xda-developers.com/mi-5/themes/app-collection-camera-modded-t3591177


Better (modded) MIUI Camera

From my friends at 4pda. Much better camera at low light. Also JPEG quality set to 98.
http://4pda.ru/forum/index.php?showtopic=793497&view=findpost&p=57013739
Flash zip in twrp (backup of original camera is made by script)

If you want to do it manualy:
- take the MiuiCamera.apk from the zip
- adb push MiuiCamera.apk /sdcard/
- adb shell
- su
- mount -o remount,rw /system
- cd /system/priv-app/MiuiCamera
- mv MiuiCamera.apk MiuiCamera.apk.ORG
- mv oat oat.ORG
- cp /sdcard/MiuiCamera.apk .
- chmod 644 MiuiCamera.apk
- ls -l
- stop
- sync
- reboot


Enable Dalvik JIT (Android 6)

Add this line to your build.prop file:

debug.usejit=true

When cleaning the dalvik cache your phone will boot much faster. Don't have to wait for 5 or 10 minutes anymore :)


Test Color Notification Led

See here: http://en.miui.com/thread-605570-1-1.html
EDIT 15 sep 2017:
Color Notification led support: http://en.miui.com/thread-850569-1-1.html
or at the source: http://4pda.ru/forum/index.php?showtopic=841683&st=0#entry64978644


Change MIUI theme and launcher

You can change variables of the package (apk) using MIUI themes. But you can also change the default theme.
The default theme is located at /system/media/theme/default
Changes to the MIUI Launcher (home screen) can easily made. It is a zip file (com.miui.home.zip) with a theme_values.xml in it. Change or add values to the xml file, copy it to /system/media/theme/default/com.miui.home and reboot.
Note that the zip has no extension when you copy it to the folder!!! It must have the name of the package.

Below you find an example of a 5x6 launcher grid. If you want to know more better search google with MIUI_Theme_Values

You can do this for example also with MiuiSystemUI.apk (com.android.systemui) and many more


Alternative CPU core control

There are 4 performance cpu's (cpu 0123) and 4 powersave cpu's (cpu 4567). Depending on the task load they increase or decrease their cpu frequency. But they can also switch on or off. Default 2 perf cores and all 4 power cores stay on.
I modified the /etc/init.qcom.post_boot.sh script for the purpose that only 1 perf and 1 power core stay on with no task load. This consumes less power and increases battery life.
Copy init.qcom.post_boot.sh.txt to /etc/init.qcom.post_boot.sh and reboot. Don't forget to make a copy.

Code:
                echo 1 > /sys/devices/system/cpu/cpu0/core_ctl/min_cpus

### power cluster min 1 cpu max 4, busy up/down from 0000 to 68 and 40, perf cluster up like 80+
### prefer (low-)power cores cpu4567 up before perf cores cpu0123 (high power consumtion)
                echo "80 85 90 95" > /sys/devices/system/cpu/cpu0/core_ctl/busy_up_thres #68, only looks at 1st value
                echo 68 > /sys/devices/system/cpu/cpu4/core_ctl/busy_up_thres
                echo 40 > /sys/devices/system/cpu/cpu4/core_ctl/busy_down_thres
### Wait x ms before switching core off, you might need it again
                echo 500 > /sys/devices/system/cpu/cpu0/core_ctl/offline_delay_ms #100 (test .5 sec)
                echo 500 > /sys/devices/system/cpu/cpu4/core_ctl/offline_delay_ms #100 (test .5 sec)


Resurrection Remix strange adb shell prompt

Change /etc/mkshrc, comment last 3 lines
Code:
}$HOSTNAME:${PWD:-?} '"$PS1 "

#if [ "z$ANDROID_SOCKET_adbd" != "z" ]; then
#   resize
#fi


Force battery charge to 90%
Code:
# Charge only up to 89% instead of 100% for longer battery life? cat /sys/class/power_supply/battery/voltage_now
echo 4260 > /sys/class/power_supply/battery/voltage_max # 4400 (nominal 3.85V)

My additions to build.prop (/vendor/build.prop)

This is my current /vendor/build.prop and the big advantage is that you can leave your ROM's /system/build.prop as it is. The /vendor/build.prop will overwrite settings from /system/build.prop!

High wakelock with low signal data connection? Try this in build.prop
ro.ril.wake_lock_timeout=2000

Ps: Check for property errors direct after reboot with: dmesg | grep prop

Code:
### always check values with "dmesg | grep prop"
### /default.prop
### /system/build.prop
### /vendor/build.prop (*)
### /factory/factory.prop
### /data/local.prop
### tweakradje RR 5.8.4/5

lockscreen.rot_override=true
#ro.radio.noril=true
# dumpsys SurfaceFlinger will give 1920x1200 density of 295 dpi
#ro.sf.lcd_density=295

#30% faster app loading?
sys.use_fifo_ui=1
# pm multitask def = 6
persist.pm.multitask=8
#ro.recents.grid=true
ro.cutoff_voltage_mv=3200
ro.config.swap=false
ro.config.zram=false
ro.sys.sdcardfs=true
ro.ril.wake_lock_timeout=2000
persist.radio.aosp_usr_pref_sel=true
#ro.audio.offload_wakelock=true (default)
#audio.offload.ignore_setawake=false (default)
#opengl 3d hw accel
debug.egl.hw=1
# hw compositing, if 0 then always software
debug.sf.hw=1
#sys.hwc.gpu_perf_mode=1
### composition valid if debug.sf.hw=0 (and sys.hwc.gpu_perf_mode=0)
#debug.composition.type=c2d
debug.composition.type=mdp
ro.sf.compbypass.enable=0
# use development settings for force gpu
#persist.sys.ui.hw=true
debug.gr.numframebuffers=3
#no debug messages
debug.hwui.level=0


#debug.egl.swapinterval=-1 (def)
#debug.egl.swapinterval=0
#HWUI properties
#ro.hwui.texture_cache_size=72
#ro.hwui.layer_cache_size=48
#ro.hwui.r_buffer_cache_size=8
#ro.hwui.path_cache_size=32
#ro.hwui.gradient_cache_size=1
#ro.hwui.drop_shadow_cache_size=6
###ro.hwui.texture_cache_flushrate=0.4
#ro.hwui.text_small_cache_width=1024
#ro.hwui.text_small_cache_height=1024
#ro.hwui.text_large_cache_width=2048
#ro.hwui.text_large_cache_height=2048
###ro.hwui.fbo_cache_size=32
#debug.hwui.skip_empty_damage=true
#debug.hwui.use_buffer_age=true
#debug.hwui.enable_partial_updates=true
#debug.hwui.render_dirty_regions=true
#debug.hwui.disable_draw_defer=false
#debug.hwui.disable_draw_reorder=true
#debug.choreographer.vsync=false
#debug.choreographer.frametime=false
#debug.choreographer.skipwarning=20
# Use UBWC 
###debug.gralloc.map_fb_memory=0
###debug.gralloc.enable_fb_ubwc=1
# 0 = force to enable scrollingCacheEnabled regardless of app setting
# 1 = default is to enable scrollingCacheEnabled unless app specifies
# 2 = default is to disable scrollingCacheEnabled unless app specifies
# 3 = force to disable scrollingCacheEnabled regardless of app setting
persist.sys.scrollingcache=3
ro.config.max_starting_bg=12
#ro.sys.fw.bg_apps_limit=20
ro.config.vc_call_vol_steps=14
ro.config.media_vol_steps=30
#ro.hardware.egl=adreno
#perstist.power.usetwilightadj=true
# JIT Android 6
debug.usejit=true
# JIT Android 7
#dalvik.vm.usejit=true
#dalvik.vm.usejitprofiles=true
#ro.core_ctl_min_cpu=0
#ro.min_freq_0=200000
#ro.min_freq_0=384000
#ro.min_freq_4=384000

### EXTRA CAMERA ###

###https://android.googlesource.com/platform/hardware/qcom/camera/+/9fc7225504a6f969bd7277c1070f0b91b0ce4874/msmcobalt/QCamera2/HAL/QCameraParameters.cpp
###https://android.googlesource.com/platform/hardware/qcom/camera/+/nougat-dev/QCamera2/HAL/QCameraParameters.cpp

persist.sys.camera-sound=0
persist.camera.HAL3.enabled=1
###https://android.googlesource.com/platform/hardware/qcom/camera/+/f9a41d251fab1320345588e7654a1b0f4c70ae1c/QCamera2/stack/common/cam_types.h
#-persist.camera.hal3.feature=32
### HAL3 High Frame Rate 
#-persist.camera.hal3hfr.enable=1
#-persist.camera.hal3.force.hdr=0
#persist.camera.perflock.enable=1
# fps def is 60
persist.camera.disp.fps=30
persist.camera.max.previewfps=30
#persist.camera.pdaf.enable=1
# focus call back (def 1)
#-persist.camera.depth.focus.cb=0
#persist.camera.disp.num_vsync=4
#persist.camera.disp.ms_to_vsync=2
#persist.camera.disp.filter_max=2
#persist.camera.disp.filter_min=4
# thumbnail needed
#-persist.camera.tn.disable=0
# anti banding 0 1=auto 2=50Hz 1=60Hz
#persist.camera.set.afd=2
# 0=disable 1=with aggressive AEC 2=with fast AEC
#-persist.camera.instant.capture=2
#-persist.camera.instant.aec=2

#persist.camera.dt=0
#persist.camera.vc=0

### adb shell setprop persist.camera.effect <effect>
### none,mono,negative,solarize,sepia,posterize,whiteboard,blackboard,aqua,emboss,sketch,neon,beauty
#persist.camera.effect=none

### check for raw images /data/misc/camera folder!
#persist.camera.raw.dump=0
#persist.camera.raw.debug.dump=0
# raw format 16(yuv?) 17 or 18
#persist.camera.raw.format=17
#persist.camera.raw.subformat=
#persist.camera.raw_yuv=0
#persist.camera.zsl_raw=0
#persist.camera.snapshot_raw=20
# nr buffers, adb shell setprop persist.camera.preview_yuv 20 <20 preview buffers>
#persist.camera.preview_yuv=0
#persist.camera.preview_raw=0
#persist.camera.video_raw=0
# raw data i? mode
#persist.camera.rdi.mode=disable
#persist.camera.offlineraw=0
### manual exposure, enables persist.camera.exposure.time
#persist.camera.manual.capture=1
### adb shell setprop persist.camera.exposure.time "exposure time" (in millisec) 10 = 1/100
#persist.camera.exposure.time=10
#persist.camera.initial.exp.val=10
# 1=CAM_ISO_MODE_DEBLUR 100 200 ...
#persist.camera.iso=1
#persist.camera.continuous.iso=100

#correlated double sampling mode on off auto(def) (noise reduction)
#persist.camera.CDS=on
#persist.camera.video.CDS=auto
# TemporalDenoise (Supported at all?)
#persist.camera.tnr_cds=1
#persist.camera.tnr.snapshot=on
#persist.camera.tnr.video=on
#persist.camera.tnr.preview=on
# Low light noise feature is to avoid noise seen at the snapshot frame edges due to WNR processing
#persist.camera.llnoise=0
# low light capture
#persist.camera.llc=1
# 0=CAM_WAVELET_DENOISE_YCBCR_PLANE
# 1=CAM_WAVELET_DENOISE_CBCR_ONLY
# 2=CAM_WAVELET_DENOISE_STREAMLINE_YCBCR
# 3=CAM_WAVELET_DENOISE_STREAMLINED_CBCR
#persist.denoise.process.plates=2
#persist.tnr.process.plates=2

#persist.camera.tintless=enable

# Burst LED on period 1-799 def 300
#persist.camera.led.on.period=150

#persist.camera.secure.mode=disable
#camera.lowpower.record.enable=1
#cpp or vfe scaling
#persist.camera.pp_scaling=0
#persist.camera.ltmforseemore=1
#persist.camera.preview.seemore=1
#persist.camera.liveshot.size=1280x720
#persist.camera.stats.af.paaf=1
#persist.camera.preview.ubwc=1
# high temp? then lower fps (or frameskip)
persist.camera.thermal.mode=fps
#persist.camera.batchcount=0
#persist.camera.video.batchsize=6
#persist.camera.opt.livepic=1
# Chromatic Aberation enabled? Check logcat grep -i chroma
# E mm-camera: <IMGLIB><ERROR> 695: module_cac_handle_aec_update: module_cac_handle_aec_update 695: Invalid chromatix ptr
#persist.camera.feature.cac=1
persist.camera.eis.enable=1
# preferred IS type for 8937 is IS_TYPE_DIS i.e, 1
# IS_TYPE_NONE=0, IS_TYPE_DIS=1, IS_TYPE_GA_DIS=2, IS_TYPE_EIS_1_0=3, IS_TYPE_EIS_2_0=4 IS_TYPE_MAX=5
persist.camera.is_type=4
persist.camera.is_type_preview=4

#CAMERA_LONGSHOT_STAGES=4
#persist.camera.longshot.stages=1
#persist.camera.longshot.max=5
#persist.camera.longshot.shotnum=5
#persist.camera.longshot.save=0
# use jpeg burst if persist.camera.longshot.save=0
#persist.camera.jpeg_burst=1
### Check whether shutter should be triggered immediately after capture
persist.camera.feature.shutter=1

#persist.camera.facedetect=1
#persist.camera.snapshot.fd=1
# face detect in video 0 1 2(only for focus)
#persist.camera.fdvideo=1
#persist.camera.mem.usepool=1
# video shooting ION cache, disable for faster shooting
persist.camera.mem.usecache=0
persist.sys.exif.make=Xiaomi
persist.sys.exif.model=Redmi 4X Tweakradje
#persist.camera.auto.hdr.enable=enable
### dual camera range finding
persist.camera.dcrf.enable=0
### multi_pass cause 3/4 green effect when zoomin
persist.camera.multi_pass=0
#persist.camera.zsl.mode=1
#persist.camera.zsl.interval=1
#persist.camera.zsl.backlookcnt=2
#persist.camera.zsl.queuedepth=2
#persist.camera.zsl.buffer.size=
# zigzag hdr
#persist.camera.hdr.outcrop=enable
persist.camera.zzhdr.enable=1
persist.camera.zzhdr.video=1
# disable UBWC (universal bandwidth compression) if enable eztune
#debug.gralloc.gfx_ubwc_disable=0
#persist.camera.eztune.enable=0
#persist.camera.perf.memlimit=0x800
#persist.camera.capture.animate=1
camera.qcom.misc.disable=0
persist.ts.rtmakeup=0
#persist.camcorder.4k.nolimit=1
#persist.camcorder.eis.maxfps=30
#debug.camera.yv12=true
#debug.camera.preview.flip=90
#debug.camera.video.flip=90
#debug.camera.picture.flip=90

#ClearSight? settings
#persist.camera.cs.threshold=0xf4240    clearsight threshold (long)
#persist.camera.cs.burstcount=4
#persist.camera.cs.dumpframes=0
#persist.camera.cs.timeout=0x12c

#ro.miui.screen_layout_size=3
#ro.sys.oosenhance.enable=true
#ro.sys.oosenhance.timer=2000
#debug.oosenhance.turnon=true

### EXTRA AUDIO ###

# resampler DEFAULT=0
# OLD values LOW_QUALITY=1(1st order) MED_QUALITY=2(3rd order) HIGH_QUALITY=3(fixed multi-tap FIR) 4 VERY_HIGH_QUALITY
# 1-3 AudioResampler: Assertion failed: format != AUDIO_FORMAT_PCM_16_BIT /system/lib/libaudioresampler.so (_ZN7android14AudioResampler6createE14audio_format_tiiNS0_11src_qualityE+1024)
# Using the new DYN_*_QUALITY resamplers (modes 5-7) allows floating point audio to work. 8 works too
af.resampler.quality=7

# cat /proc/asound/card0/id -> msm8920sku7sndc -> /etc/acdbdata/QRD/msm8920-sku7-snd-card

### QRD (Qualcomm Reference Design) or MTP Audio Calibration files?

#persist.audio.calfile0=/etc/acdbdata/MTP/MTP_Bluetooth_cal.acdb
#persist.audio.calfile1=/etc/acdbdata/MTP/MTP_General_cal.acdb
#persist.audio.calfile2=/etc/acdbdata/MTP/MTP_Global_cal.acdb
#persist.audio.calfile3=/etc/acdbdata/MTP/MTP_Handset_cal.acdb
#persist.audio.calfile4=/etc/acdbdata/MTP/MTP_Hdmi_cal.acdb
#persist.audio.calfile5=/etc/acdbdata/MTP/MTP_Headset_cal.acdb
#persist.audio.calfile6=/etc/acdbdata/MTP/MTP_Speaker_cal.acdb

# calibrate speaker duration (0) if spk prot true
persist.speaker.prot.enable=false
#persist.spkr.cal.duration=50

# audio, offload to audio hardware
audio.offload.disable=false
audio.offload.buffer.size.kb=256
av.streaming.offload.enable=true
audio.offload.multiple.enabled=true
ro.audio.max_fast_tracks=8
ro.audio.flinger_standbytime_ms=500
audio_hal.period_multiplier=2
#audio_hal.period_size=192
audio_hal.in_period_size=50

#Qualcomm Immersive Audio Noise Cancellation (Fluence), Pro is quadmic
#ro.qc.sdk.audio.fluencetype=fluencepro
#ro.qc.sdk.audio.fluencetype=fluence
#ro.qc.sdk.audio.fluencetype=none
#persist.audio.fluence.voicecall=true
#persist.audio.fluence.audiorec=false
persist.audio.fluence.mode=endfire
#persist.audio.fluence.mode=broadside
#rec.playback.conc.disabled=false
#surround recording
ro.qc.sdk.audio.ssr=false
# dump recording /data/misc/audio/ssr_input_3ch.pcm
#ssr.pcmdump=true
# acdb full freq spectrum on speakers ACDB 131
# persist.audio.FFSP.enable=true -> gives acdb error in logcat!!!
# native audio?
audio.nat.codec.enabled=true
persist.audio.hifi.int_codec=true
# active noise cancelation
#persist.aanc.enable=1
#persist.headset.anc.type=
#persist.audio.vbat.enabled=true
#libdirac.so also /vendor/etc/diracmobile.config
audio.dirac.logging=0
#persist.audio.dirac.headset=5
#persist.audio.dirac.eq=
#persist.audio.dirac.music.state=0
# not complete lib files to enable dirac in RR
persist.audio.dirac.speaker=false
#
use.dts_eagle=false
persist.bt.max.hs.connections=4
persist.bt.max.a2dp.connections=4
persist.bt.enableAptXHD=true
persist.service.bt.a2dp.sink=false
#ro.bluetooth.hfp.ver=1.5
#ro.bluetooth.hfp.ver=1.6
ro.bluetooth.hfp.ver=1.7
#persist.bluetooth.disableabsvol=true
#wc_transport.force_special_byte=true
#bt.pts.certification=true

audio.dolby.ds2.enabled=false
audio.dolby.ds2.hardbypass=true

### EXTRA NETWORK ###

ro.net.dns_cache_size=1500
net.dns.cache_size=1500
net.dns.cache_ttl=1800
net.http.threads=20
net.dns2=8.8.8.8

### EXTRA SQLITE ###

# find /data/data \( -name *-journal -o -name *-wal -o -name *-shm \) -exec rm {} \;
#debug.sqlite.journalmode=DELETE
#debug.sqlite.syncmode=FULL
#debug.sqlite.pagesize=
#sqlite Write Ahead Logging on? creates big WAL files and shm (shared mem) files, log 512KB
debug.sqlite.journalmode=WAL
debug.sqlite.wal.autocheckpoint=0
debug.sqlite.wal.syncmode=FULL
debug.sqlite.journalsizelimit=524288
#debug.sqlite.wal.poolsize=

If you have more interesting mods don't hesitate to post them and I will add them to the OP.

EDIT 5 sep 2017: added new RR init script (v2), better CPU cores and audio !!! v2 might cause battery drain, then v3

EDIT 8 sep 2017: added /etc/wifi/WCNSS_qcom_cfg.ini for 40 Mhz channel on 2.4Ghz
added new RR init script (v3) for better battery life

EDIT 15 oct 2017: removed mixer_paths.xml, use stock. Changes applied to new mixer_paths_qrd_sku1.xml

EDIT 21 oct 2017: added V4 for RR, better target_loads for big/little CPU's

EDIT 31 oct 2017: added V5 for RR, better big perf/little lowpower cpu switching. Perf cpu minimal is 0. Most tasks done with lowpower cpu's. Can run youtube for almost 11 hours now!

EDIT 4 nov 2017: Noticed one little error in V5 RR script.
Echo Y > /sys/module/workqueue/parameters/power_efficient
should be
echo Y > /sys/module/workqueue/parameters/power_efficient

EDIT 16 nov 2017: V6 RR script. Optimal use of RAM. Tested for 3 GB only. All apps stay in ram. Almost no swapping. Example, Chrome keep tabs without reloading. Antutu score now 46350!

EDIT 20 nov 2017: V7 RR script. Create 512 MB ZRAM swap if RAM < 2GB and don't lower swappiness (only for 3 GB)
Little change for V7 script:
### tweakradje use small cores to the max before switch to big cores (antutu only 35000 instead of 46000)
echo 0 > /dev/cpuctl/cpu.upmigrate_discourage

EDIT 23 nov 2017: added stereo recording in AAC with Redmi 4X (speakers cyburg needles with Tangband w3-881sjf https://www.youtube.com/watch?v=MsgAFoTghvw )

EDIT 2 dec 2017: little corrections in V7 RR script and changed to flashable zip.

EDIT 6 jan 2018: change emmc max freq from 200 to 300 MHz. Increase the read speed from 80Mb/s to 120 Mb/s (note: you can try 400 or 500 Mhz. Might cause reboot, please report back) Test with busybox hdparm -tT /dev/block/mmcblk0p49

EDIT 13 feb 2018: V9 of the script. Added tweaked deviceidle (doze) settings. Device looses 0-1% overnight!

EDIT 15 feb 2018: V10 of the script. Improved Light/Deep Doze settings with documentation in the script. Put your email app in the whitelist too!!!

EDIT 18 feb 2018: V11 ready. Won battle with Google Play Services that reset the device_idle_constants to "null" every few hours. Solution: pm disable --user 0 com.google.android.gms/.phenotype.service.sync.PhenotypeConfigurator
Doze settings and explanation are in the script for those who want to change some timings. The script sets it to this scheme:
- Enter light doze after screen off
- Light maintenance windows every 5 minutes
- Enter Deep doze after 15 minutes (enter deep if there is no alarm within 5 minutes from now, was 1 hour)
- Deep maintenance windows every hour
- Whatsapp and Gmail white listed (can do their thing regardless of doze state)
- No delays for phone motion or whatever

EDIT 8 mar 2018: updated some audio related files with comments in it. Change to your liking ;), now awesome high quality good calibrated stereo sound recording!!

EDIT 6 apr 2018: V13 of the init script. Changed things like min/max cpu speed for custom kernel

EDIT 9 apr 2018: flashable scripts now create backup of replaced files if not exist. (*.ORG)

EDIT 25 may 2018: V15 of the init script for 7.x Nougat ROMs.

EDIT 16 jun 2018: V16 of the init script for 7.x Nougat ROMs (LAST AND FINAL!)

Cheers
 

Attachments

  • Screenshot_2017-08-18-13-47-23-722_com.android.settings.png
    Screenshot_2017-08-18-13-47-23-722_com.android.settings.png
    63.1 KB · Views: 9,361
  • Screenshot_2017-08-18-21-08-12-902_com.android.camera.jpg
    Screenshot_2017-08-18-21-08-12-902_com.android.camera.jpg
    80.9 KB · Views: 9,281
  • Screenshot_2017-08-18-21-08-26-644_com.android.camera.png
    Screenshot_2017-08-18-21-08-26-644_com.android.camera.png
    54.7 KB · Views: 9,036
  • Screenshot_2017-08-18-21-09-10-608_com.android.camera.jpg
    Screenshot_2017-08-18-21-09-10-608_com.android.camera.jpg
    89.9 KB · Views: 8,850
  • Screenshot_2017-08-18-21-11-47-610_com.android.settings.png
    Screenshot_2017-08-18-21-11-47-610_com.android.settings.png
    70.7 KB · Views: 8,871
  • Screenshot_2017-08-18-21-08-36-891_com.android.camera.jpg
    Screenshot_2017-08-18-21-08-36-891_com.android.camera.jpg
    69.3 KB · Views: 8,770
  • santoni.xml
    11.5 KB · Views: 1,484
  • Screenshot_2017-08-20-21-14-42-504_com.miui.home.jpg
    Screenshot_2017-08-20-21-14-42-504_com.miui.home.jpg
    110.6 KB · Views: 8,970
  • init.qcom.post_boot.sh.txt
    121.8 KB · Views: 1,681
  • com.miui.home.zip
    929 bytes · Views: 532
  • stock_camera_no_noise_redmi_4pro_v6.zip
    3.2 MB · Views: 1,466
  • restore_stock_camera.zip
    177.3 KB · Views: 631
  • WCNSS_qcom_cfg.ini.txt
    7.7 KB · Views: 631
  • RR_Battery_5days.jpg
    RR_Battery_5days.jpg
    140.5 KB · Views: 8,070
  • Screenshot_Antutu_RRV6.png
    Screenshot_Antutu_RRV6.png
    58.2 KB · Views: 5,725
  • init_qcom_post_boot_flash_V13.zip
    143.7 KB · Views: 256
  • audio_platform_and_mixer_flash.zip
    132.6 KB · Views: 362
  • init_qcom_post_boot_flash_V16.zip
    144.9 KB · Views: 418
Last edited:

tweakradje

Senior Member
Mar 18, 2005
1,066
536
Android
sites.google.com
PLEASE don't quote first post. Waste of space and it will change anyway. THANKS

Data partition is encrypted

I found that the data partition is encrypted when coming from Miui ROM to RR. Fingerprint is not working with encrypted data partition.
Data is encrypted if TWRP asks for unlock code.
These steps decrypts it and preserves data.
Code:
- Boot into TWRP
- Backup /data to "internal sd" (or to "ext sd card") with TWRP
- On PC: adb pull /data/media/0
- Wipe -> Format /data in TWRP
- Reboot to TWRP again
- On PC: adb push . /data/media/0
- On PC: adb shell chown -R media_rw.media_rw /data/media/0
- Reboot to TWRP again
- Restore the previous backup with TWRP
- On PC: adb shell rm /data/system/locksettings* /data/system/*.key
- On PC: adb shell rm -r /data/dalvik*
- Reboot

Change Doze (deviceidle) settings

On the device you can change the Doze settings very easy. First list the Doze settings to get all current parameters:
Code:
dumpsys deviceidle

Then change parameters by setting some variables in the Android Global Settings db:
Code:
settings put global Phenotype_flags device_idle_constants
settings put global device_idle_constants inactive_to=300000,idle_after_inactive_to=300000

Enable light doze too (mLightEnabled=true mDeepEnabled=true)
Code:
dumpsys deviceidle enable all

Add whatsapp and gmail to the whitelist
Code:
dumpsys deviceidle whitelist +com.whatsapp +com.google.android.gm

Note: Google Play Services reset the device_idle_constants to "null" every few hours. Solution: pm disable --user 0 com.google.android.gms/.phenotype.service.sync.PhenotypeConfigurator
See more info in post above


Use Fingerprint sensor as button

As you might know hardware keys have keycodes. These keycodes can be found using an app like KeyEvent Dipslay
The mapping between Keycode and Function is done in the kl files in the folder /system/usr/keylayout

To map the Fingerprint key (Keycode 353) you use the gf3208.kl file.
Code:
#key 353 ENTER
#key 353 CAMERA
#key 353 MENU
key 353 SLEEP

Reboot for effect. This will not effect the Fingerprint function.

Super audio for Resurrection Remix

To enable HD audio for headphones and other audio tweaks for RR (maybe for Miui too)
Add these lines to the end of your build.prop

Code:
audio.offload.disable=false
audio.offload.buffer.size.kb=1024
persist.audio.FFSP.enable=true
audio.nat.codec.enabled=true
persist.audio.hifi.int_codec=true
persist.audio.dirac.speaker=false
use.dts_eagle=true


Some tweaks for camera driver

To enable some extra features to play with. You can add these to the end of your build.prop

For the stock camera on RR ROM make sure you disable Color Denoise setting.

Code:
#persist.camera.liveshot.size=1280x720
persist.camera.HAL3.enabled=1
persist.camera.hal3hfr.enable=1
persist.camera.ltmforseemore=1
persist.camera.led.on.period=500
persist.camera.stats.af.paaf=1
persist.camera.manual.capture=1
# high temp? then lower fps (or frameskip)
persist.camera.thermal.mode=fps
persist.camera.opt.livepic=1
# Chromatic Aberation enabled? Check logcat grep -i chroma
# E mm-camera: <IMGLIB><ERROR> 695: module_cac_handle_aec_update: module_cac_handle_aec_update 695: Invalid chromatix ptr
persist.camera.feature.cac=1
persist.camera.eis.enable=1
persist.denoise.process.plates=2
persist.camera.longshot.stages=1
persist.camera.facedetect=1
persist.camera.snapshot.fd=1
# face detect in video 0 1 2(only for focus)
persist.camera.fdvideo=1
persist.camera.mem.usepool=1
persist.camera.mem.usecache=5000000
persist.sys.exif.make=Xiaomi
persist.sys.exif.model=Redmi 4X
persist.camera.feature.shutter=1
persist.camera.auto.hdr.enable=1
persist.camera.tintless=1
#persist.camera.continuous.iso=200
#persist.camera.exposure.time=
# dual camera range finding
persist.camera.dcrf.enable=0
persist.camera.multi_pass=1
persist.camera.zsl.mode=1
persist.camera.zsl.interval=1
persist.camera.zsl.backlookcnt=2
persist.camera.zsl.queuedepth=2
# zigzag hdr
persist.camera.zzhdr.enable=1
persist.camera.zzhdr.video=1
persist.camera.eztune.enable=0
# TemporalDenoise (Supported at all?)
persist.camera.tnr_cds=1
persist.camera.tnr.snapshot=1
persist.camera.tnr.video=1
persist.camera.tnr.preview=1
# low light noise enabled?
persist.camera.llnoise=1




More will follow :)
 
Last edited:

tweakradje

Senior Member
Mar 18, 2005
1,066
536
Android
sites.google.com
Anyone running RR with my V2 script having battery drain issues? I have since yesterday.

I am now running new script to test battery drain. The change is to disable all these
low power modes again. Lets see tomorrow.

Oh and if you see the notification led blinking purple after reboot? The V3 script switches it
off again after 3 sec.
 

Attachments

  • init.qcom.post_boot.sh.RRV3.txt
    127.5 KB · Views: 315

NTLinhHaHa

Senior Member
May 11, 2013
203
65
Hanoi
Anyone running RR with my V2 script having battery drain issues? I have since yesterday.

I am now running new script to test battery drain. The change is to disable all these
low power modes again. Lets see tomorrow.

Oh and if you see the notification led blinking purple after reboot? The V3 script switches it
off again after 3 sec.

Me too, mine dropped 10% after a night with wifi and data off.
I'm on RR build 170815.
 

nightvury

Member
Nov 8, 2015
7
0
Thanks for the feedback. I use v3 of the script now for 2 days and battery is perfect. Try it. After install switch off the phone completely ( no reboot ) and then switch it on again. It worked for me.
How to install it? your cpu Config, Iam using 8.2..10 and have copied the txt to my sh file, i already save it and set to rwrr too, but cpu config still default, even after i restart my phone.. still default config cpu running helpppp
 

Top Liked Posts

  • There are no posts matching your filters.
  • 29
    Hello xda world,

    EDIT 24 may 2018: using Luis kernel now on RR 5.8.4. Best I have tried so far!!
    Link: http://luis-builds.de/downloads/lineageos/rr/Xiaomi_Redmi_4X_(santoni)/

    EDIT 10-feb-2018: battery drain due to *alarm* and *launcher* system wakelocks solved with firmware V32.
    Grab it here and flash with TWRP: https://forum.xda-developers.com/xiaomi-redmi-4x/how-to/firmwares-t3682965

    Here I hope to collect some tweaks and mods that work in rooted Redmi 4x stock rom. (8.2.10.0 Global)
    EDIT: since I use Resurrection Remix now I also added some RR tweaks

    Since I just own the device it will be work in progress for a while. I search the forums for solutions for problems I encounter.

    My Redmi 4x is OEM unlocked via Xiaomi, has twrp and Magisk root. (you need root for tweaks)
    For OEM unlock you need account and register at miui.com, ask for unlock, wait 30+ hours and then use the miui unlock tool that checks if you are granted bij Xiaomi for unlock.

    Some Redmi 4x facts:

    - Xiaomi Redmi 4x has codename Santoni
    - The Soc is Qualcomm 435 (msm8940 socid 313, msm8937 for the firmware), 4 cpu cores perf and 4 cpu cores power
    - The gpu is Adreno 505
    - main camera is Samsung S5K3L8, front camera is Omnivision ov5675
    - notification LED has RGB!
    - 5 GHz (11ac) only supported for wifi hotspot (wlan.ko issue)
    - MIUI features are setup in the /etc/device_features/santoni.xml file
    - CPU/kernel features are mostly setup in the /etc/init.qcom.post_boot.sh file
    - fastboot: hold vol- and power, release power after vibrate
    - recovery: hold vol+ and vol- and power, release power after vibrate

    Redmi 4x related sites:

    - Official miui.com for Redmi 4x http://en.miui.com/forum-123-1.html
    - Resurrection Remix ROM for Redmi 4x https://sourceforge.net/projects/resurrectionremix/files/santoni/ (Antutu score 43000+)
    - Miui EU ROM https://xiaomi.eu/community/forums/miui-weekly-rom-releases.103/
    - Mi-Globe ROM (like EU ROM but with options) Mi-Globe
    - Miui Belarus (MiuiPro) ROM https://miuipro.by/roms/
    - Redmi 4x Global Edition on Bangood
    - AOSP Extended (AEX) ROM Redmi 4X http://downloads.aospextended.com/santoni/

    Note: If you change any file always make a copy of it first. I always copy the file in the same folder and give it extension .ORG. So build.prop becomes build.prop.ORG with adb shell: cp -p build.prop build.prop.ORG
    Be sure the permissions of the files are set to rw-r--r-- (644)!!!!!!

    Example adb/linux commands

    From pc:
    adb push "afile" /sdcard
    adb shell

    On device:
    su
    stop
    mount -o remount,rw /system
    cd "/afolder"
    cp -p "afile" "afile.ORG"
    cp /sdcard/"afile" .
    ls -l "afile*"
    chmod 644 "afile"
    reboot

    Ofcourse afile and afolder are just example names.

    If you are not familiar with linux shell or adb then you can find zip files to flash in TWRP mode.
    You need to REBOOT after changing any of these files.

    Note 2: I am not responsible for any damage to your device. Use this at your own risk!

    Audio recording mod (mixer mod)

    Recording audio on stock rom is terrible. On the internet I found a solution. You need to change 2 mixer files.
    If you also want louder speaker you need to copy /etc/mixer_paths.xml too.

    /etc/mixer_paths_qrd_sku1.xml
    mic volume for voice call
    Code:
        <path name="voice-call">
    <!-- tweakradje add 2 lines -->
    		<ctl name="DEC1 Volume" value="88" />
    		<ctl name="DEC2 Volume" value="88" />
            <ctl name="PRI_MI2S_RX_Voice Mixer CSVoice" value="1" />
            <ctl name="Voice_Tx Mixer TERT_MI2S_TX_Voice" value="1" />
        </path>
    mic volume for audio rec like movie, try between 100-124, use 100 for very loud env
    Code:
        <path name="handset-mic">
            <path name="adc1" />
    <!-- tweakradje add 2 lines -->
    		<ctl name="DEC1 Volume" value="110" />
    		<ctl name="DEC2 Volume" value="110" />
            <ctl name="IIR1 INP1 MUX" value="DEC1" />
        </path>
    mic volume for audio rec like movie, try between 100-124, use 100 for very loud env
    Code:
        <path name="handset-stereo-dmic-ef">
    <!-- tweakradje add 2 lines -->
            <ctl name="DEC1 Volume" value="110" />
            <ctl name="DEC2 Volume" value="110" />
            <path name="speaker-dmic-endfire" />
        </path>

    /etc/audio_platform_info.xml
    Code:
        <acdb_ids>
    <!-- tweakradje add 2 lines, but no more auto rec mic volume -->
            <device name="SND_DEVICE_IN_HANDSET_MIC" acdb_id="1"/>
            <device name="SND_DEVICE_IN_HANDSET_STEREO_DMIC" acdb_id="1"/>
            <device name="SND_DEVICE_OUT_SPEAKER_PROTECTED" acdb_id="136"/>
            <device name="SND_DEVICE_OUT_VOICE_SPEAKER_PROTECTED" acdb_id="136"/>
            <device name="SND_DEVICE_OUT_SPEAKER_PROTECTED_VBAT" acdb_id="136"/>
            <device name="SND_DEVICE_OUT_VOICE_SPEAKER_PROTECTED_VBAT" acdb_id="136"/>
            <device name="SND_DEVICE_IN_CAPTURE_VI_FEEDBACK" acdb_id="137"/>
        </acdb_ids>

    Now audio is fine when recording video and sounds even great!
    You can download the 2 files below. Check if you need to insert these lines in your file or that you can use mine.
    For recording stereo audio only I use Sony Audio Recorder which is free and perfect.

    EDIT 18 dec 2017: Found that acdb_id="4" works well, which is the default mic profile in ACDB. However you need to lower the "DEC1 Volume" and "DEC2 Volume" to 94.

    EDIT 23 dec 2017: About Audio Calibration (ACDB) files
    You might have noticed that there are more than one set of acdb file in /etc/acdbdata folder. There are MTP end QRD sets. QRD stands for Qualcomm Reference Design. You can play with these Calibration Profiles for speakers and microphone.
    Easiest is to create a new build.prop (644) in the /vendor folder.

    Then play with these values. You can also mix MTP and QRD for devices. Like using all MTP but for General and Handset use the QRD version.
    Code:
    persist.audio.calfile0=/etc/acdbdata/QRD/QRD_Bluetooth_cal.acdb
    persist.audio.calfile1=/etc/acdbdata/QRD/QRD_General_cal.acdb
    persist.audio.calfile2=/etc/acdbdata/QRD/QRD_Global_cal.acdb
    persist.audio.calfile3=/etc/acdbdata/QRD/QRD_Handset_cal.acdb
    persist.audio.calfile4=/etc/acdbdata/QRD/QRD_Hdmi_cal.acdb
    persist.audio.calfile5=/etc/acdbdata/QRD/QRD_Headset_cal.acdb
    persist.audio.calfile6=/etc/acdbdata/QRD/QRD_Speaker_cal.acdb
    
    #persist.audio.calfile0=/etc/acdbdata/MTP/MTP_Bluetooth_cal.acdb
    #persist.audio.calfile1=/etc/acdbdata/MTP/MTP_General_cal.acdb
    #persist.audio.calfile2=/etc/acdbdata/MTP/MTP_Global_cal.acdb
    #persist.audio.calfile3=/etc/acdbdata/MTP/MTP_Handset_cal.acdb
    #persist.audio.calfile4=/etc/acdbdata/MTP/MTP_Hdmi_cal.acdb
    #persist.audio.calfile5=/etc/acdbdata/MTP/MTP_Headset_cal.acdb
    #persist.audio.calfile6=/etc/acdbdata/MTP/MTP_Speaker_cal.acdb




    MIUI Camera mod (features unlock)

    This is how you unlock those high end features you find on higher end models. To enable the features you need to edit the /etc/device_features/santoni.xml (or /sdcard/device_features/santoni.xml) file. Mostly change false into true to enable them.
    Some are also added from other Xiaomi devices.
    Download from below.

    Camera parameters found:
    Code:
    support_camera_4k_quality
    support_camera_age_detection
    support_camera_aohdr
    support_camera_audio_focus
    support_camera_boost_brightness
    support_camera_burst_shoot
    support_camera_gradienter
    support_camera_hfr
    support_camera_manual_function
    support_camera_movie_solid
    support_camera_peaking_mf
    !support_camera_press_down_capture
    support_camera_quick_snap
    support_camera_record_location
    support_camera_shader_effect
    support_camera_skin_beauty
    support_camera_tilt_shift
    support_camera_torch_capture
    support_camera_ubifocus
    support_camera_video_pause
    support_camera_water_mark


    Camera 2 API

    You can enable Camera 2 API for 3rd party camera apps. Think about manual focus etc.
    Add this line to your build.prop:

    persist.camera.HAL3.enabled=1

    More interesting Camera's: https://forum.xda-developers.com/mi-5/themes/app-collection-camera-modded-t3591177


    Better (modded) MIUI Camera

    From my friends at 4pda. Much better camera at low light. Also JPEG quality set to 98.
    http://4pda.ru/forum/index.php?showtopic=793497&view=findpost&p=57013739
    Flash zip in twrp (backup of original camera is made by script)

    If you want to do it manualy:
    - take the MiuiCamera.apk from the zip
    - adb push MiuiCamera.apk /sdcard/
    - adb shell
    - su
    - mount -o remount,rw /system
    - cd /system/priv-app/MiuiCamera
    - mv MiuiCamera.apk MiuiCamera.apk.ORG
    - mv oat oat.ORG
    - cp /sdcard/MiuiCamera.apk .
    - chmod 644 MiuiCamera.apk
    - ls -l
    - stop
    - sync
    - reboot


    Enable Dalvik JIT (Android 6)

    Add this line to your build.prop file:

    debug.usejit=true

    When cleaning the dalvik cache your phone will boot much faster. Don't have to wait for 5 or 10 minutes anymore :)


    Test Color Notification Led

    See here: http://en.miui.com/thread-605570-1-1.html
    EDIT 15 sep 2017:
    Color Notification led support: http://en.miui.com/thread-850569-1-1.html
    or at the source: http://4pda.ru/forum/index.php?showtopic=841683&st=0#entry64978644


    Change MIUI theme and launcher

    You can change variables of the package (apk) using MIUI themes. But you can also change the default theme.
    The default theme is located at /system/media/theme/default
    Changes to the MIUI Launcher (home screen) can easily made. It is a zip file (com.miui.home.zip) with a theme_values.xml in it. Change or add values to the xml file, copy it to /system/media/theme/default/com.miui.home and reboot.
    Note that the zip has no extension when you copy it to the folder!!! It must have the name of the package.

    Below you find an example of a 5x6 launcher grid. If you want to know more better search google with MIUI_Theme_Values

    You can do this for example also with MiuiSystemUI.apk (com.android.systemui) and many more


    Alternative CPU core control

    There are 4 performance cpu's (cpu 0123) and 4 powersave cpu's (cpu 4567). Depending on the task load they increase or decrease their cpu frequency. But they can also switch on or off. Default 2 perf cores and all 4 power cores stay on.
    I modified the /etc/init.qcom.post_boot.sh script for the purpose that only 1 perf and 1 power core stay on with no task load. This consumes less power and increases battery life.
    Copy init.qcom.post_boot.sh.txt to /etc/init.qcom.post_boot.sh and reboot. Don't forget to make a copy.

    Code:
                    echo 1 > /sys/devices/system/cpu/cpu0/core_ctl/min_cpus
    
    ### power cluster min 1 cpu max 4, busy up/down from 0000 to 68 and 40, perf cluster up like 80+
    ### prefer (low-)power cores cpu4567 up before perf cores cpu0123 (high power consumtion)
                    echo "80 85 90 95" > /sys/devices/system/cpu/cpu0/core_ctl/busy_up_thres #68, only looks at 1st value
                    echo 68 > /sys/devices/system/cpu/cpu4/core_ctl/busy_up_thres
                    echo 40 > /sys/devices/system/cpu/cpu4/core_ctl/busy_down_thres
    ### Wait x ms before switching core off, you might need it again
                    echo 500 > /sys/devices/system/cpu/cpu0/core_ctl/offline_delay_ms #100 (test .5 sec)
                    echo 500 > /sys/devices/system/cpu/cpu4/core_ctl/offline_delay_ms #100 (test .5 sec)


    Resurrection Remix strange adb shell prompt

    Change /etc/mkshrc, comment last 3 lines
    Code:
    }$HOSTNAME:${PWD:-?} '"$PS1 "
    
    #if [ "z$ANDROID_SOCKET_adbd" != "z" ]; then
    #   resize
    #fi


    Force battery charge to 90%
    Code:
    # Charge only up to 89% instead of 100% for longer battery life? cat /sys/class/power_supply/battery/voltage_now
    echo 4260 > /sys/class/power_supply/battery/voltage_max # 4400 (nominal 3.85V)

    My additions to build.prop (/vendor/build.prop)

    This is my current /vendor/build.prop and the big advantage is that you can leave your ROM's /system/build.prop as it is. The /vendor/build.prop will overwrite settings from /system/build.prop!

    High wakelock with low signal data connection? Try this in build.prop
    ro.ril.wake_lock_timeout=2000

    Ps: Check for property errors direct after reboot with: dmesg | grep prop

    Code:
    ### always check values with "dmesg | grep prop"
    ### /default.prop
    ### /system/build.prop
    ### /vendor/build.prop (*)
    ### /factory/factory.prop
    ### /data/local.prop
    ### tweakradje RR 5.8.4/5
    
    lockscreen.rot_override=true
    #ro.radio.noril=true
    # dumpsys SurfaceFlinger will give 1920x1200 density of 295 dpi
    #ro.sf.lcd_density=295
    
    #30% faster app loading?
    sys.use_fifo_ui=1
    # pm multitask def = 6
    persist.pm.multitask=8
    #ro.recents.grid=true
    ro.cutoff_voltage_mv=3200
    ro.config.swap=false
    ro.config.zram=false
    ro.sys.sdcardfs=true
    ro.ril.wake_lock_timeout=2000
    persist.radio.aosp_usr_pref_sel=true
    #ro.audio.offload_wakelock=true (default)
    #audio.offload.ignore_setawake=false (default)
    #opengl 3d hw accel
    debug.egl.hw=1
    # hw compositing, if 0 then always software
    debug.sf.hw=1
    #sys.hwc.gpu_perf_mode=1
    ### composition valid if debug.sf.hw=0 (and sys.hwc.gpu_perf_mode=0)
    #debug.composition.type=c2d
    debug.composition.type=mdp
    ro.sf.compbypass.enable=0
    # use development settings for force gpu
    #persist.sys.ui.hw=true
    debug.gr.numframebuffers=3
    #no debug messages
    debug.hwui.level=0
    
    
    #debug.egl.swapinterval=-1 (def)
    #debug.egl.swapinterval=0
    #HWUI properties
    #ro.hwui.texture_cache_size=72
    #ro.hwui.layer_cache_size=48
    #ro.hwui.r_buffer_cache_size=8
    #ro.hwui.path_cache_size=32
    #ro.hwui.gradient_cache_size=1
    #ro.hwui.drop_shadow_cache_size=6
    ###ro.hwui.texture_cache_flushrate=0.4
    #ro.hwui.text_small_cache_width=1024
    #ro.hwui.text_small_cache_height=1024
    #ro.hwui.text_large_cache_width=2048
    #ro.hwui.text_large_cache_height=2048
    ###ro.hwui.fbo_cache_size=32
    #debug.hwui.skip_empty_damage=true
    #debug.hwui.use_buffer_age=true
    #debug.hwui.enable_partial_updates=true
    #debug.hwui.render_dirty_regions=true
    #debug.hwui.disable_draw_defer=false
    #debug.hwui.disable_draw_reorder=true
    #debug.choreographer.vsync=false
    #debug.choreographer.frametime=false
    #debug.choreographer.skipwarning=20
    # Use UBWC 
    ###debug.gralloc.map_fb_memory=0
    ###debug.gralloc.enable_fb_ubwc=1
    # 0 = force to enable scrollingCacheEnabled regardless of app setting
    # 1 = default is to enable scrollingCacheEnabled unless app specifies
    # 2 = default is to disable scrollingCacheEnabled unless app specifies
    # 3 = force to disable scrollingCacheEnabled regardless of app setting
    persist.sys.scrollingcache=3
    ro.config.max_starting_bg=12
    #ro.sys.fw.bg_apps_limit=20
    ro.config.vc_call_vol_steps=14
    ro.config.media_vol_steps=30
    #ro.hardware.egl=adreno
    #perstist.power.usetwilightadj=true
    # JIT Android 6
    debug.usejit=true
    # JIT Android 7
    #dalvik.vm.usejit=true
    #dalvik.vm.usejitprofiles=true
    #ro.core_ctl_min_cpu=0
    #ro.min_freq_0=200000
    #ro.min_freq_0=384000
    #ro.min_freq_4=384000
    
    ### EXTRA CAMERA ###
    
    ###https://android.googlesource.com/platform/hardware/qcom/camera/+/9fc7225504a6f969bd7277c1070f0b91b0ce4874/msmcobalt/QCamera2/HAL/QCameraParameters.cpp
    ###https://android.googlesource.com/platform/hardware/qcom/camera/+/nougat-dev/QCamera2/HAL/QCameraParameters.cpp
    
    persist.sys.camera-sound=0
    persist.camera.HAL3.enabled=1
    ###https://android.googlesource.com/platform/hardware/qcom/camera/+/f9a41d251fab1320345588e7654a1b0f4c70ae1c/QCamera2/stack/common/cam_types.h
    #-persist.camera.hal3.feature=32
    ### HAL3 High Frame Rate 
    #-persist.camera.hal3hfr.enable=1
    #-persist.camera.hal3.force.hdr=0
    #persist.camera.perflock.enable=1
    # fps def is 60
    persist.camera.disp.fps=30
    persist.camera.max.previewfps=30
    #persist.camera.pdaf.enable=1
    # focus call back (def 1)
    #-persist.camera.depth.focus.cb=0
    #persist.camera.disp.num_vsync=4
    #persist.camera.disp.ms_to_vsync=2
    #persist.camera.disp.filter_max=2
    #persist.camera.disp.filter_min=4
    # thumbnail needed
    #-persist.camera.tn.disable=0
    # anti banding 0 1=auto 2=50Hz 1=60Hz
    #persist.camera.set.afd=2
    # 0=disable 1=with aggressive AEC 2=with fast AEC
    #-persist.camera.instant.capture=2
    #-persist.camera.instant.aec=2
    
    #persist.camera.dt=0
    #persist.camera.vc=0
    
    ### adb shell setprop persist.camera.effect <effect>
    ### none,mono,negative,solarize,sepia,posterize,whiteboard,blackboard,aqua,emboss,sketch,neon,beauty
    #persist.camera.effect=none
    
    ### check for raw images /data/misc/camera folder!
    #persist.camera.raw.dump=0
    #persist.camera.raw.debug.dump=0
    # raw format 16(yuv?) 17 or 18
    #persist.camera.raw.format=17
    #persist.camera.raw.subformat=
    #persist.camera.raw_yuv=0
    #persist.camera.zsl_raw=0
    #persist.camera.snapshot_raw=20
    # nr buffers, adb shell setprop persist.camera.preview_yuv 20 <20 preview buffers>
    #persist.camera.preview_yuv=0
    #persist.camera.preview_raw=0
    #persist.camera.video_raw=0
    # raw data i? mode
    #persist.camera.rdi.mode=disable
    #persist.camera.offlineraw=0
    ### manual exposure, enables persist.camera.exposure.time
    #persist.camera.manual.capture=1
    ### adb shell setprop persist.camera.exposure.time "exposure time" (in millisec) 10 = 1/100
    #persist.camera.exposure.time=10
    #persist.camera.initial.exp.val=10
    # 1=CAM_ISO_MODE_DEBLUR 100 200 ...
    #persist.camera.iso=1
    #persist.camera.continuous.iso=100
    
    #correlated double sampling mode on off auto(def) (noise reduction)
    #persist.camera.CDS=on
    #persist.camera.video.CDS=auto
    # TemporalDenoise (Supported at all?)
    #persist.camera.tnr_cds=1
    #persist.camera.tnr.snapshot=on
    #persist.camera.tnr.video=on
    #persist.camera.tnr.preview=on
    # Low light noise feature is to avoid noise seen at the snapshot frame edges due to WNR processing
    #persist.camera.llnoise=0
    # low light capture
    #persist.camera.llc=1
    # 0=CAM_WAVELET_DENOISE_YCBCR_PLANE
    # 1=CAM_WAVELET_DENOISE_CBCR_ONLY
    # 2=CAM_WAVELET_DENOISE_STREAMLINE_YCBCR
    # 3=CAM_WAVELET_DENOISE_STREAMLINED_CBCR
    #persist.denoise.process.plates=2
    #persist.tnr.process.plates=2
    
    #persist.camera.tintless=enable
    
    # Burst LED on period 1-799 def 300
    #persist.camera.led.on.period=150
    
    #persist.camera.secure.mode=disable
    #camera.lowpower.record.enable=1
    #cpp or vfe scaling
    #persist.camera.pp_scaling=0
    #persist.camera.ltmforseemore=1
    #persist.camera.preview.seemore=1
    #persist.camera.liveshot.size=1280x720
    #persist.camera.stats.af.paaf=1
    #persist.camera.preview.ubwc=1
    # high temp? then lower fps (or frameskip)
    persist.camera.thermal.mode=fps
    #persist.camera.batchcount=0
    #persist.camera.video.batchsize=6
    #persist.camera.opt.livepic=1
    # Chromatic Aberation enabled? Check logcat grep -i chroma
    # E mm-camera: <IMGLIB><ERROR> 695: module_cac_handle_aec_update: module_cac_handle_aec_update 695: Invalid chromatix ptr
    #persist.camera.feature.cac=1
    persist.camera.eis.enable=1
    # preferred IS type for 8937 is IS_TYPE_DIS i.e, 1
    # IS_TYPE_NONE=0, IS_TYPE_DIS=1, IS_TYPE_GA_DIS=2, IS_TYPE_EIS_1_0=3, IS_TYPE_EIS_2_0=4 IS_TYPE_MAX=5
    persist.camera.is_type=4
    persist.camera.is_type_preview=4
    
    #CAMERA_LONGSHOT_STAGES=4
    #persist.camera.longshot.stages=1
    #persist.camera.longshot.max=5
    #persist.camera.longshot.shotnum=5
    #persist.camera.longshot.save=0
    # use jpeg burst if persist.camera.longshot.save=0
    #persist.camera.jpeg_burst=1
    ### Check whether shutter should be triggered immediately after capture
    persist.camera.feature.shutter=1
    
    #persist.camera.facedetect=1
    #persist.camera.snapshot.fd=1
    # face detect in video 0 1 2(only for focus)
    #persist.camera.fdvideo=1
    #persist.camera.mem.usepool=1
    # video shooting ION cache, disable for faster shooting
    persist.camera.mem.usecache=0
    persist.sys.exif.make=Xiaomi
    persist.sys.exif.model=Redmi 4X Tweakradje
    #persist.camera.auto.hdr.enable=enable
    ### dual camera range finding
    persist.camera.dcrf.enable=0
    ### multi_pass cause 3/4 green effect when zoomin
    persist.camera.multi_pass=0
    #persist.camera.zsl.mode=1
    #persist.camera.zsl.interval=1
    #persist.camera.zsl.backlookcnt=2
    #persist.camera.zsl.queuedepth=2
    #persist.camera.zsl.buffer.size=
    # zigzag hdr
    #persist.camera.hdr.outcrop=enable
    persist.camera.zzhdr.enable=1
    persist.camera.zzhdr.video=1
    # disable UBWC (universal bandwidth compression) if enable eztune
    #debug.gralloc.gfx_ubwc_disable=0
    #persist.camera.eztune.enable=0
    #persist.camera.perf.memlimit=0x800
    #persist.camera.capture.animate=1
    camera.qcom.misc.disable=0
    persist.ts.rtmakeup=0
    #persist.camcorder.4k.nolimit=1
    #persist.camcorder.eis.maxfps=30
    #debug.camera.yv12=true
    #debug.camera.preview.flip=90
    #debug.camera.video.flip=90
    #debug.camera.picture.flip=90
    
    #ClearSight? settings
    #persist.camera.cs.threshold=0xf4240    clearsight threshold (long)
    #persist.camera.cs.burstcount=4
    #persist.camera.cs.dumpframes=0
    #persist.camera.cs.timeout=0x12c
    
    #ro.miui.screen_layout_size=3
    #ro.sys.oosenhance.enable=true
    #ro.sys.oosenhance.timer=2000
    #debug.oosenhance.turnon=true
    
    ### EXTRA AUDIO ###
    
    # resampler DEFAULT=0
    # OLD values LOW_QUALITY=1(1st order) MED_QUALITY=2(3rd order) HIGH_QUALITY=3(fixed multi-tap FIR) 4 VERY_HIGH_QUALITY
    # 1-3 AudioResampler: Assertion failed: format != AUDIO_FORMAT_PCM_16_BIT /system/lib/libaudioresampler.so (_ZN7android14AudioResampler6createE14audio_format_tiiNS0_11src_qualityE+1024)
    # Using the new DYN_*_QUALITY resamplers (modes 5-7) allows floating point audio to work. 8 works too
    af.resampler.quality=7
    
    # cat /proc/asound/card0/id -> msm8920sku7sndc -> /etc/acdbdata/QRD/msm8920-sku7-snd-card
    
    ### QRD (Qualcomm Reference Design) or MTP Audio Calibration files?
    
    #persist.audio.calfile0=/etc/acdbdata/MTP/MTP_Bluetooth_cal.acdb
    #persist.audio.calfile1=/etc/acdbdata/MTP/MTP_General_cal.acdb
    #persist.audio.calfile2=/etc/acdbdata/MTP/MTP_Global_cal.acdb
    #persist.audio.calfile3=/etc/acdbdata/MTP/MTP_Handset_cal.acdb
    #persist.audio.calfile4=/etc/acdbdata/MTP/MTP_Hdmi_cal.acdb
    #persist.audio.calfile5=/etc/acdbdata/MTP/MTP_Headset_cal.acdb
    #persist.audio.calfile6=/etc/acdbdata/MTP/MTP_Speaker_cal.acdb
    
    # calibrate speaker duration (0) if spk prot true
    persist.speaker.prot.enable=false
    #persist.spkr.cal.duration=50
    
    # audio, offload to audio hardware
    audio.offload.disable=false
    audio.offload.buffer.size.kb=256
    av.streaming.offload.enable=true
    audio.offload.multiple.enabled=true
    ro.audio.max_fast_tracks=8
    ro.audio.flinger_standbytime_ms=500
    audio_hal.period_multiplier=2
    #audio_hal.period_size=192
    audio_hal.in_period_size=50
    
    #Qualcomm Immersive Audio Noise Cancellation (Fluence), Pro is quadmic
    #ro.qc.sdk.audio.fluencetype=fluencepro
    #ro.qc.sdk.audio.fluencetype=fluence
    #ro.qc.sdk.audio.fluencetype=none
    #persist.audio.fluence.voicecall=true
    #persist.audio.fluence.audiorec=false
    persist.audio.fluence.mode=endfire
    #persist.audio.fluence.mode=broadside
    #rec.playback.conc.disabled=false
    #surround recording
    ro.qc.sdk.audio.ssr=false
    # dump recording /data/misc/audio/ssr_input_3ch.pcm
    #ssr.pcmdump=true
    # acdb full freq spectrum on speakers ACDB 131
    # persist.audio.FFSP.enable=true -> gives acdb error in logcat!!!
    # native audio?
    audio.nat.codec.enabled=true
    persist.audio.hifi.int_codec=true
    # active noise cancelation
    #persist.aanc.enable=1
    #persist.headset.anc.type=
    #persist.audio.vbat.enabled=true
    #libdirac.so also /vendor/etc/diracmobile.config
    audio.dirac.logging=0
    #persist.audio.dirac.headset=5
    #persist.audio.dirac.eq=
    #persist.audio.dirac.music.state=0
    # not complete lib files to enable dirac in RR
    persist.audio.dirac.speaker=false
    #
    use.dts_eagle=false
    persist.bt.max.hs.connections=4
    persist.bt.max.a2dp.connections=4
    persist.bt.enableAptXHD=true
    persist.service.bt.a2dp.sink=false
    #ro.bluetooth.hfp.ver=1.5
    #ro.bluetooth.hfp.ver=1.6
    ro.bluetooth.hfp.ver=1.7
    #persist.bluetooth.disableabsvol=true
    #wc_transport.force_special_byte=true
    #bt.pts.certification=true
    
    audio.dolby.ds2.enabled=false
    audio.dolby.ds2.hardbypass=true
    
    ### EXTRA NETWORK ###
    
    ro.net.dns_cache_size=1500
    net.dns.cache_size=1500
    net.dns.cache_ttl=1800
    net.http.threads=20
    net.dns2=8.8.8.8
    
    ### EXTRA SQLITE ###
    
    # find /data/data \( -name *-journal -o -name *-wal -o -name *-shm \) -exec rm {} \;
    #debug.sqlite.journalmode=DELETE
    #debug.sqlite.syncmode=FULL
    #debug.sqlite.pagesize=
    #sqlite Write Ahead Logging on? creates big WAL files and shm (shared mem) files, log 512KB
    debug.sqlite.journalmode=WAL
    debug.sqlite.wal.autocheckpoint=0
    debug.sqlite.wal.syncmode=FULL
    debug.sqlite.journalsizelimit=524288
    #debug.sqlite.wal.poolsize=

    If you have more interesting mods don't hesitate to post them and I will add them to the OP.

    EDIT 5 sep 2017: added new RR init script (v2), better CPU cores and audio !!! v2 might cause battery drain, then v3

    EDIT 8 sep 2017: added /etc/wifi/WCNSS_qcom_cfg.ini for 40 Mhz channel on 2.4Ghz
    added new RR init script (v3) for better battery life

    EDIT 15 oct 2017: removed mixer_paths.xml, use stock. Changes applied to new mixer_paths_qrd_sku1.xml

    EDIT 21 oct 2017: added V4 for RR, better target_loads for big/little CPU's

    EDIT 31 oct 2017: added V5 for RR, better big perf/little lowpower cpu switching. Perf cpu minimal is 0. Most tasks done with lowpower cpu's. Can run youtube for almost 11 hours now!

    EDIT 4 nov 2017: Noticed one little error in V5 RR script.
    Echo Y > /sys/module/workqueue/parameters/power_efficient
    should be
    echo Y > /sys/module/workqueue/parameters/power_efficient

    EDIT 16 nov 2017: V6 RR script. Optimal use of RAM. Tested for 3 GB only. All apps stay in ram. Almost no swapping. Example, Chrome keep tabs without reloading. Antutu score now 46350!

    EDIT 20 nov 2017: V7 RR script. Create 512 MB ZRAM swap if RAM < 2GB and don't lower swappiness (only for 3 GB)
    Little change for V7 script:
    ### tweakradje use small cores to the max before switch to big cores (antutu only 35000 instead of 46000)
    echo 0 > /dev/cpuctl/cpu.upmigrate_discourage

    EDIT 23 nov 2017: added stereo recording in AAC with Redmi 4X (speakers cyburg needles with Tangband w3-881sjf https://www.youtube.com/watch?v=MsgAFoTghvw )

    EDIT 2 dec 2017: little corrections in V7 RR script and changed to flashable zip.

    EDIT 6 jan 2018: change emmc max freq from 200 to 300 MHz. Increase the read speed from 80Mb/s to 120 Mb/s (note: you can try 400 or 500 Mhz. Might cause reboot, please report back) Test with busybox hdparm -tT /dev/block/mmcblk0p49

    EDIT 13 feb 2018: V9 of the script. Added tweaked deviceidle (doze) settings. Device looses 0-1% overnight!

    EDIT 15 feb 2018: V10 of the script. Improved Light/Deep Doze settings with documentation in the script. Put your email app in the whitelist too!!!

    EDIT 18 feb 2018: V11 ready. Won battle with Google Play Services that reset the device_idle_constants to "null" every few hours. Solution: pm disable --user 0 com.google.android.gms/.phenotype.service.sync.PhenotypeConfigurator
    Doze settings and explanation are in the script for those who want to change some timings. The script sets it to this scheme:
    - Enter light doze after screen off
    - Light maintenance windows every 5 minutes
    - Enter Deep doze after 15 minutes (enter deep if there is no alarm within 5 minutes from now, was 1 hour)
    - Deep maintenance windows every hour
    - Whatsapp and Gmail white listed (can do their thing regardless of doze state)
    - No delays for phone motion or whatever

    EDIT 8 mar 2018: updated some audio related files with comments in it. Change to your liking ;), now awesome high quality good calibrated stereo sound recording!!

    EDIT 6 apr 2018: V13 of the init script. Changed things like min/max cpu speed for custom kernel

    EDIT 9 apr 2018: flashable scripts now create backup of replaced files if not exist. (*.ORG)

    EDIT 25 may 2018: V15 of the init script for 7.x Nougat ROMs.

    EDIT 16 jun 2018: V16 of the init script for 7.x Nougat ROMs (LAST AND FINAL!)

    Cheers
    11
    PLEASE don't quote first post. Waste of space and it will change anyway. THANKS

    Data partition is encrypted

    I found that the data partition is encrypted when coming from Miui ROM to RR. Fingerprint is not working with encrypted data partition.
    Data is encrypted if TWRP asks for unlock code.
    These steps decrypts it and preserves data.
    Code:
    - Boot into TWRP
    - Backup /data to "internal sd" (or to "ext sd card") with TWRP
    - On PC: adb pull /data/media/0
    - Wipe -> Format /data in TWRP
    - Reboot to TWRP again
    - On PC: adb push . /data/media/0
    - On PC: adb shell chown -R media_rw.media_rw /data/media/0
    - Reboot to TWRP again
    - Restore the previous backup with TWRP
    - On PC: adb shell rm /data/system/locksettings* /data/system/*.key
    - On PC: adb shell rm -r /data/dalvik*
    - Reboot

    Change Doze (deviceidle) settings

    On the device you can change the Doze settings very easy. First list the Doze settings to get all current parameters:
    Code:
    dumpsys deviceidle

    Then change parameters by setting some variables in the Android Global Settings db:
    Code:
    settings put global Phenotype_flags device_idle_constants
    settings put global device_idle_constants inactive_to=300000,idle_after_inactive_to=300000

    Enable light doze too (mLightEnabled=true mDeepEnabled=true)
    Code:
    dumpsys deviceidle enable all

    Add whatsapp and gmail to the whitelist
    Code:
    dumpsys deviceidle whitelist +com.whatsapp +com.google.android.gm

    Note: Google Play Services reset the device_idle_constants to "null" every few hours. Solution: pm disable --user 0 com.google.android.gms/.phenotype.service.sync.PhenotypeConfigurator
    See more info in post above


    Use Fingerprint sensor as button

    As you might know hardware keys have keycodes. These keycodes can be found using an app like KeyEvent Dipslay
    The mapping between Keycode and Function is done in the kl files in the folder /system/usr/keylayout

    To map the Fingerprint key (Keycode 353) you use the gf3208.kl file.
    Code:
    #key 353 ENTER
    #key 353 CAMERA
    #key 353 MENU
    key 353 SLEEP

    Reboot for effect. This will not effect the Fingerprint function.

    Super audio for Resurrection Remix

    To enable HD audio for headphones and other audio tweaks for RR (maybe for Miui too)
    Add these lines to the end of your build.prop

    Code:
    audio.offload.disable=false
    audio.offload.buffer.size.kb=1024
    persist.audio.FFSP.enable=true
    audio.nat.codec.enabled=true
    persist.audio.hifi.int_codec=true
    persist.audio.dirac.speaker=false
    use.dts_eagle=true


    Some tweaks for camera driver

    To enable some extra features to play with. You can add these to the end of your build.prop

    For the stock camera on RR ROM make sure you disable Color Denoise setting.

    Code:
    #persist.camera.liveshot.size=1280x720
    persist.camera.HAL3.enabled=1
    persist.camera.hal3hfr.enable=1
    persist.camera.ltmforseemore=1
    persist.camera.led.on.period=500
    persist.camera.stats.af.paaf=1
    persist.camera.manual.capture=1
    # high temp? then lower fps (or frameskip)
    persist.camera.thermal.mode=fps
    persist.camera.opt.livepic=1
    # Chromatic Aberation enabled? Check logcat grep -i chroma
    # E mm-camera: <IMGLIB><ERROR> 695: module_cac_handle_aec_update: module_cac_handle_aec_update 695: Invalid chromatix ptr
    persist.camera.feature.cac=1
    persist.camera.eis.enable=1
    persist.denoise.process.plates=2
    persist.camera.longshot.stages=1
    persist.camera.facedetect=1
    persist.camera.snapshot.fd=1
    # face detect in video 0 1 2(only for focus)
    persist.camera.fdvideo=1
    persist.camera.mem.usepool=1
    persist.camera.mem.usecache=5000000
    persist.sys.exif.make=Xiaomi
    persist.sys.exif.model=Redmi 4X
    persist.camera.feature.shutter=1
    persist.camera.auto.hdr.enable=1
    persist.camera.tintless=1
    #persist.camera.continuous.iso=200
    #persist.camera.exposure.time=
    # dual camera range finding
    persist.camera.dcrf.enable=0
    persist.camera.multi_pass=1
    persist.camera.zsl.mode=1
    persist.camera.zsl.interval=1
    persist.camera.zsl.backlookcnt=2
    persist.camera.zsl.queuedepth=2
    # zigzag hdr
    persist.camera.zzhdr.enable=1
    persist.camera.zzhdr.video=1
    persist.camera.eztune.enable=0
    # TemporalDenoise (Supported at all?)
    persist.camera.tnr_cds=1
    persist.camera.tnr.snapshot=1
    persist.camera.tnr.video=1
    persist.camera.tnr.preview=1
    # low light noise enabled?
    persist.camera.llnoise=1




    More will follow :)
    4
    I will repost V7 with cpu.upmigrate_discourage = 0
    I think V7 of the script is the best. At least for my 3GB RAM Redmi 4X. I get 46000+ Antutu and got 11,5 hours SOT when used continiously whatching youtube in a test run.
    Again thanks for your feedback.
    3
    The V7 script in the zip file in the OP already has that commented out!
    Code:
    # check actual charging current : cat /sys/class/power_supply/battery/input_current_now
    # USB charging little higher, fully charge in 2 hours
    echo 0 > /sys/class/power_supply/battery/restricted_charging
    # Charge 0nly up to 89% instead of 100% for longer battery life? cat /sys/class/power_supply/battery/voltage_now
    #echo 4260 > /sys/class/power_supply/battery/voltage_max # 4400 (nominal 3.85V)
    #echo 4380 > /sys/class/power_supply/battery/voltage_max # 99%
    #echo 2000000 > /sys/class/power_supply/battery/input_current_max
    echo 2000000 > /sys/class/power_supply/battery/constant_charge_current_max
    #cat /sys/class/power_supply/battery/charge_type -> should be Fast or Taper

    Happy New Year everybody! Best wishes and Heath for 2018!
    3
    V9 of the script. Added tweaked deviceidle (doze) settings. Device looses only 0-1% overnight!

    Be sure to use Firmware V32 from here: https://forum.xda-developers.com/xiaomi-redmi-4x/how-to/firmwares-t3682965

    Cheers