Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,810,466 Members 49,927 Now Online
XDA Developers Android and Mobile Development Forum

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

Tip us?
 
vishal_android freak
Old
(Last edited by vishal_android freak; 14th August 2014 at 09:15 AM.)
#1  
vishal_android freak's Avatar
Recognized Developer / Recognized Contributor - OP
Thanks Meter 4,731
Posts: 1,702
Join Date: Dec 2012
Location: Mumbai


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

My ROMs

| Pure Xperia HD, Official Carbon Rom 4.4.2, Unofficial Omni Rom 4.4.2, AOKP-4.4.2, Unofficial HellKat 4.4.2, Carbon Rom 4.3.1, Dark Xperia |

My Guides and Tools

| All in one drivers guide for ubislate tabs, CWM recovery for a13 tabs |

My kernel

| Super Fusion kernel for all HDPI devices |

Devices I Support

| All 2011 Xperias , Xperia M , Lg p760 and p765, Xperia Tipo, Xperia L |
The Following 5 Users Say Thank You to vishal_android freak For This Useful Post: [ Click to Expand ]
 
vishal_android freak
Old
#2  
vishal_android freak's Avatar
Recognized Developer / Recognized Contributor - OP
Thanks Meter 4,731
Posts: 1,702
Join Date: Dec 2012
Location: Mumbai
Reserved

My ROMs

| Pure Xperia HD, Official Carbon Rom 4.4.2, Unofficial Omni Rom 4.4.2, AOKP-4.4.2, Unofficial HellKat 4.4.2, Carbon Rom 4.3.1, Dark Xperia |

My Guides and Tools

| All in one drivers guide for ubislate tabs, CWM recovery for a13 tabs |

My kernel

| Super Fusion kernel for all HDPI devices |

Devices I Support

| All 2011 Xperias , Xperia M , Lg p760 and p765, Xperia Tipo, Xperia L |
The Following 2 Users Say Thank You to vishal_android freak For This Useful Post: [ Click to Expand ]
 
vishal_android freak
Old
#3  
vishal_android freak's Avatar
Recognized Developer / Recognized Contributor - OP
Thanks Meter 4,731
Posts: 1,702
Join Date: Dec 2012
Location: Mumbai
One more

My ROMs

| Pure Xperia HD, Official Carbon Rom 4.4.2, Unofficial Omni Rom 4.4.2, AOKP-4.4.2, Unofficial HellKat 4.4.2, Carbon Rom 4.3.1, Dark Xperia |

My Guides and Tools

| All in one drivers guide for ubislate tabs, CWM recovery for a13 tabs |

My kernel

| Super Fusion kernel for all HDPI devices |

Devices I Support

| All 2011 Xperias , Xperia M , Lg p760 and p765, Xperia Tipo, Xperia L |
The Following 2 Users Say Thank You to vishal_android freak For This Useful Post: [ Click to Expand ]
 
Somcom3X
Old
#4  
Somcom3X's Avatar
Senior Member
Thanks Meter 1,569
Posts: 2,507
Join Date: Aug 2012
Location: Dearborn

 
DONATE TO ME
Wouldn't this be better to add to a general android hacking section as it could also apply to more devices? :P
Moto G "peregrine" 4G Bringup Team
 
Want to support other phones? Donate a device to Team Carbon.

Phones:
Samsung Galaxy S Blaze 4G T769
Motorola Moto G 4G "peregrine"

Mentions on XDA Portal:|
My PeregrineEasyRecovery \ XDA Video
My CM11 for the peregrine /
 
vishal_android freak
Old
#5  
vishal_android freak's Avatar
Recognized Developer / Recognized Contributor - OP
Thanks Meter 4,731
Posts: 1,702
Join Date: Dec 2012
Location: Mumbai
Quote:
Originally Posted by Somcom3X View Post
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

My ROMs

| Pure Xperia HD, Official Carbon Rom 4.4.2, Unofficial Omni Rom 4.4.2, AOKP-4.4.2, Unofficial HellKat 4.4.2, Carbon Rom 4.3.1, Dark Xperia |

My Guides and Tools

| All in one drivers guide for ubislate tabs, CWM recovery for a13 tabs |

My kernel

| Super Fusion kernel for all HDPI devices |

Devices I Support

| All 2011 Xperias , Xperia M , Lg p760 and p765, Xperia Tipo, Xperia L |
The Following User Says Thank You to vishal_android freak For This Useful Post: [ Click to Expand ]
 
Somcom3X
Old
#6  
Somcom3X's Avatar
Senior Member
Thanks Meter 1,569
Posts: 2,507
Join Date: Aug 2012
Location: Dearborn

 
DONATE TO ME
Looks like it was moved
Moto G "peregrine" 4G Bringup Team
 
Want to support other phones? Donate a device to Team Carbon.

Phones:
Samsung Galaxy S Blaze 4G T769
Motorola Moto G 4G "peregrine"

Mentions on XDA Portal:|
My PeregrineEasyRecovery \ XDA Video
My CM11 for the peregrine /
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes