Post Reply

[GUIDE][HOW-TO] Add Koush SuperUser In Settings Of AOSP Or Any Source Built Rom

14th August 2014, 07:23 AM   |  #1  
vishal_android freak's Avatar
OP Recognized Developer / Recognized Contributor
Flag Mumbai
Thanks Meter: 4,882
 
1,727 posts
Join Date:Joined: Dec 2012
More


Quote:

This is for people who build AOSP or any roms from source for general public or for personal use. Koushik Dutta has given quite a good explanation here but some more things are needed to get it fully working. You should know what you are doing before you read ahead. I am not responsible if you mess up your device or any of your personal belongings


Quote:

This guide will focus on Nexus 5 but the same procedure should work on Nexus 4, Nexus 7 (2012 & 2013) or any other device with little or no modifications.

Prerequisite:

  • Knowledge about building roms from source
  • knowledge about cherry-picking commits and resolving the conflicts
  • basic knowledge about device trees
  • A logical and working brain

Step 1: Add the required packages into your source:

You need to add the Superuser related repos from cyanogenmod into your rom source. This can be done using a local manifest. Make a local manifest by any name say su.xml and place it in .repo/local_manifests/su.xml. If the "local_manifests" folder doesn't exists in .repo then make one. Copy paste the following lines in su.xml

Code:

Step 2: Cherry-pick commits

There are many commits to refer. I would link some to you. You can cherry-pick, for example,this or this. You can refer any of such commits. Cherry-pick is to be done in packages/apps/Settings. There might be conflicts in Android.mk & proguard.flags. Just compare the files from the ones in the above linked commits and fix them.

Step 3 : Add some required flags to device make file

To make Superuser to go under Settings, the most important flag needed is this :

Code:
SUPERUSER_EMBEDDED := true
Without this, superuser won't get embedded into Settings.apk. You can add this flag in any ".mk" file. I have added it under device/lge/hammerhead/device.mk. Some build.prop lines are also needed to get root working. Also you need to make the Superuser and su binary packages to be built. All the lines needed are summarized as follows:

Code:
# SU Support
SUPERUSER_EMBEDDED := true

PRODUCT_PACKAGES += \
    Superuser \
    su

PRODUCT_PROPERTY_OVERRIDES += \
    persist.sys.root_access=3

# Enable ADB authentication
PRODUCT_PROPERTY_OVERRIDES += \
    ro.adb.secure=1
Add all of them on the same location device/lge/hammerhead/device.mk.


Step 4[MOST IMPORTANT] : Import init.superuser.rc in init.rc or similar file.

People do everything properly upto step 3 but they never get superuser to work properly. When you try opening any root app, ADB gives the following error :

Code:
D/su      ( 2529): su invoked.
D/su      ( 2529): starting daemon client 10019 10019
E/su      ( 2529): connect failed with 2: No such file or directory
su daemon is started by init.superuser.rc. You need to import it in init.rc or in this case init.hammerhead.rc or any similar init file like this :

Code:
import init.hammerhead.usb.rc
import init.superuser.rc

on early-init
    mount debugfs debugfs /sys/kernel/debug
    chown system system /sys/kernel/debug/kgsl/proc
If you don't do this, system won't know that a file "init.superuser.rc" even exists. Hence, the daemon fails, failing root access eventually


DONE!!!! Just build the rom as you normally do and you have # Superuser under Settings. I hope it was clear enough. I have tried to add everything I recollect but if you find anything missing then please let me know. Thank you!!!! And enjoy coding
Last edited by vishal_android freak; 14th August 2014 at 09:15 AM.
The Following 5 Users Say Thank You to vishal_android freak For This Useful Post: [ View ]
14th August 2014, 07:23 AM   |  #2  
vishal_android freak's Avatar
OP Recognized Developer / Recognized Contributor
Flag Mumbai
Thanks Meter: 4,882
 
1,727 posts
Join Date:Joined: Dec 2012
More
Reserved
The Following 2 Users Say Thank You to vishal_android freak For This Useful Post: [ View ]
14th August 2014, 07:24 AM   |  #3  
vishal_android freak's Avatar
OP Recognized Developer / Recognized Contributor
Flag Mumbai
Thanks Meter: 4,882
 
1,727 posts
Join Date:Joined: Dec 2012
More
One more
The Following 2 Users Say Thank You to vishal_android freak For This Useful Post: [ View ]
14th August 2014, 07:29 AM   |  #4  
Somcom3X's Avatar
Senior Member
Flag Dearborn
Thanks Meter: 1,610
 
2,527 posts
Join Date:Joined: Aug 2012
Donate to Me
More
Wouldn't this be better to add to a general android hacking section as it could also apply to more devices? :P
14th August 2014, 07:32 AM   |  #5  
vishal_android freak's Avatar
OP Recognized Developer / Recognized Contributor
Flag Mumbai
Thanks Meter: 4,882
 
1,727 posts
Join Date:Joined: Dec 2012
More
Quote:
Originally Posted by Somcom3X

Wouldn't this be better to add to a general android hacking section as it could also apply to more devices? :P

Yeah that's right. I kept nexus 5 as example so i added it up here. You can report it to get to general section. I am not near the pc atm
The Following User Says Thank You to vishal_android freak For This Useful Post: [ View ]
14th August 2014, 09:16 PM   |  #6  
Somcom3X's Avatar
Senior Member
Flag Dearborn
Thanks Meter: 1,610
 
2,527 posts
Join Date:Joined: Aug 2012
Donate to Me
More
Looks like it was moved
Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Top Threads in Android General by ThreadRank