Welcome to XDA

Search to go directly to your device's forum

Register an account

Unlock full posting privileges

Ask a question

No registration required
Post Reply

Thumbs up [MOD][GUIDE][HOWTO] * Enable Private Mode with KNOX 0x1 and deodex rom*

OP Wuby986

14th October 2014, 01:19 AM   |  #1  
Wuby986's Avatar
OP Senior Member
Thanks Meter: 1,645
 
1,611 posts
Join Date:Joined: Oct 2013
Hello there !!!

I would like to present you a guide on how to enable the Private Mode feature once you have tripped your knox and/or on deodexed roms...

Intro:
when you trip knox this feature isn't supposed to work anymore, basically because it checks the security of your device and since knox is voided is not anymore for Samsung standards. i recently found out that the reason is deodex, since even if you trip knox and you're on stock rom and wipe data you can still access the partition after is wiped

what i did was running a log while enabling the P.M. and i got that it "failed to get key value from SecureProperties"

Actions:
decompiling the app we find that navigating to /smali/com/samsung/android/personalpage/service/util/ there is a smali called SecureProperties.smali
opening it we found:
Code:
# direct methods
.method public constructor <init>(Landroid/content/Context;)V
    .locals 1
    .param p1, "context"    # Landroid/content/Context;

    .prologue
    .line 59
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 52
    const/4 v0, 0x0

    iput-object v0, p0, Lcom/samsung/android/personalpage/service/util/SecureProperties;->mImpl:Lcom/samsung/android/personalpage/service/util/SecureProperties$PropertiesImpl;

    .line 62
    invoke-static {p1}, Lcom/samsung/android/personalpage/service/util/SecureProperties$SecureStorageProperties;->getInstance(Landroid/content/Context;)Lcom/samsung/android/personalpage/service/util/SecureProperties$PropertiesImpl;

    move-result-object v0

    iput-object v0, p0, Lcom/samsung/android/personalpage/service/util/SecureProperties;->mImpl:Lcom/samsung/android/personalpage/service/util/SecureProperties$PropertiesImpl;

    .line 64
    iget-object v0, p0, Lcom/samsung/android/personalpage/service/util/SecureProperties;->mImpl:Lcom/samsung/android/personalpage/service/util/SecureProperties$PropertiesImpl;

    if-nez v0, :cond_0

    .line 65
    invoke-static {p1}, Lcom/samsung/android/personalpage/service/util/SecureProperties$NonSecureProperties;->getInstance(Landroid/content/Context;)Lcom/samsung/android/personalpage/service/util/SecureProperties$PropertiesImpl;

    move-result-object v0

    iput-object v0, p0, Lcom/samsung/android/personalpage/service/util/SecureProperties;->mImpl:Lcom/samsung/android/personalpage/service/util/SecureProperties$PropertiesImpl;

    .line 67
    :cond_0
    return-void
.end method


this will get the value from knox and we don't want it
so basically we're now going make it read that the knox is still 0x0 adding a line in the method above like below:

Code:
# direct methods
.method public constructor <init>(Landroid/content/Context;)V
    .locals 1
    .param p1, "context"    # Landroid/content/Context;

    .prologue
    .line 59
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 52
    const/4 v0, 0x0

    iput-object v0, p0, Lcom/samsung/android/personalpage/service/util/SecureProperties;->mImpl:Lcom/samsung/android/personalpage/service/util/SecureProperties$PropertiesImpl;

    .line 62
    invoke-static {p1}, Lcom/samsung/android/personalpage/service/util/SecureProperties$SecureStorageProperties;->getInstance(Landroid/content/Context;)Lcom/samsung/android/personalpage/service/util/SecureProperties$PropertiesImpl;

    move-result-object v0

    const/4 v0, 0x0

    iput-object v0, p0, Lcom/samsung/android/personalpage/service/util/SecureProperties;->mImpl:Lcom/samsung/android/personalpage/service/util/SecureProperties$PropertiesImpl;

    .line 64
    iget-object v0, p0, Lcom/samsung/android/personalpage/service/util/SecureProperties;->mImpl:Lcom/samsung/android/personalpage/service/util/SecureProperties$PropertiesImpl;

    if-nez v0, :cond_0

    .line 65
    invoke-static {p1}, Lcom/samsung/android/personalpage/service/util/SecureProperties$NonSecureProperties;->getInstance(Landroid/content/Context;)Lcom/samsung/android/personalpage/service/util/SecureProperties$PropertiesImpl;

    move-result-object v0

    iput-object v0, p0, Lcom/samsung/android/personalpage/service/util/SecureProperties;->mImpl:Lcom/samsung/android/personalpage/service/util/SecureProperties$PropertiesImpl;

    .line 67
    :cond_0
    return-void
.end method


adding the line const/4 v0, 0x0 replaces the one from secure storage with a null value and makes it load the PrivateFsKey value from properties.xml and enabling the feature
so we're done.. just save the smali, recompile and.. enjoy....

optional editing you can apply to the app: (curtesy of @Goldie )
force secure storage to true ( be supported):
in smali/com/sec/android/securestorage/SecureStorage.smali change the .method public static isSupported()Z
like this:
Code:
.method public static isSupported()Z
.locals 1

.prologue
.line 2060
const/4 v0, 0x1

return v0
.end method
with the const/4 v0, 0x1 we're forcing it to load a positive value and saing it is supported anyway, instead of loading the value from output


let the app work without the lockscreen keyguard enabled
in smali/com/samsung/android/personalpage/service/PersonalPageService.smali search for new-instance v0, Lcom/android/internal/widget/LockPatternUtils;
the code is now looking like this in stock :
Code:
new-instance v0, Lcom/android/internal/widget/LockPatternUtils;

    iget-object v1, p0, Lcom/samsung/android/personalpage/service/PersonalPageService;->mContext:Landroid/content/Context;

    invoke-direct {v0, v1}, Lcom/android/internal/widget/LockPatternUtils;-><init>(Landroid/content/Context;)V

    .line 282
    .local v0, "lockPatternUtils":Lcom/android/internal/widget/LockPatternUtils;
    invoke-virtual {v0}, Lcom/android/internal/widget/LockPatternUtils;->isSecure()Z

    move-result v1

    if-nez v1, :cond_0

    .line 283
    const/4 v1, 0x1

    invoke-direct {p0, v1}, Lcom/samsung/android/personalpage/service/PersonalPageService;->showPrivateModeDialog(Z)V

    .line 288
    .end local v0    # "lockPatternUtils":Lcom/android/internal/widget/LockPatternUtils;
    :cond_0
    const/4 v1, 0x1

    invoke-direct {p0, v1}, Lcom/samsung/android/personalpage/service/PersonalPageService;->handleChangePrivateMode(Z)V
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0
and we're going to add const/4 v1, 0x1 like below:
Code:
 new-instance v0, Lcom/android/internal/widget/LockPatternUtils;

    iget-object v1, p0, Lcom/samsung/android/personalpage/service/PersonalPageService;->mContext:Landroid/content/Context;

    invoke-direct {v0, v1}, Lcom/android/internal/widget/LockPatternUtils;-><init>(Landroid/content/Context;)V

    .line 282
    .local v0, "lockPatternUtils":Lcom/android/internal/widget/LockPatternUtils;
    invoke-virtual {v0}, Lcom/android/internal/widget/LockPatternUtils;->isSecure()Z

    move-result v1

    const/4 v1, 0x1

    if-nez v1, :cond_0

    .line 283
    const/4 v1, 0x1

    invoke-direct {p0, v1}, Lcom/samsung/android/personalpage/service/PersonalPageService;->showPrivateModeDialog(Z)V

    .line 288
    .end local v0    # "lockPatternUtils":Lcom/android/internal/widget/LockPatternUtils;
    :cond_0
    const/4 v1, 0x1

    invoke-direct {p0, v1}, Lcom/samsung/android/personalpage/service/PersonalPageService;->handleChangePrivateMode(Z)V
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0


and remove the notification in status bar when personal page is enbled
in smali/com/samsung/android/personalpage/service/util/PersonalPageNotiManager.smali search for .method private static secretModeSetNotification(Landroid/app/NotificationManager;IIIIII)V
chance the whole method to retur void so it won't load the notification like this
Code:
.method private static secretModeSetNotification(Landroid/app/NotificationManager;IIIIII)V
    .locals 9
    .param p0, "notificationManager"    # Landroid/app/NotificationManager;
    .param p1, "nMoodId"    # I
    .param p2, "nTitleId"    # I
    .param p3, "nTextId"    # I
    .param p4, "nTickerId"    # I
    .param p5, "nId"    # I
    .param p6, "nIndicatorState"    # I

    .prologue
    const/4 v8, 0x0
    return-void

.end method


btw the feature is really cool because even if rooted with the P.M. off you cannot find the photos or any other file you've added to the private partition;
also if you enable it and connect to the pc you find a third partition among with internal and external sd called private of course

for those not able to decompile and recompile an app i have attached a flashable zip till the devs will include the feature in their rom.. this is intended for deodexed roms, if you are on odex stock you should be able to enable it also with knox 0x1


devs can include of course the app in the rom, or preferibly mod the actual current app for their base even if i think it should be the same and work on any.. (not tested actually on other then ng9 wich is the attached one)
no credits need except for samsung that actually made this nice feature...

i just want to thank @daxgirl for moral help first and for helping me making the guide more clear as possible
Attached Files
File Type: zip Private_mode_enabler.zip - [Click for QR Code] (267.2 KB, 830 views)
File Type: zip Private_mode_enabler_full_mod.zip - [Click for QR Code] (264.1 KB, 1109 views)
Last edited by Wuby986; 19th October 2014 at 11:31 AM. Reason: updated guide
The Following 38 Users Say Thank You to Wuby986 For This Useful Post: [ View ]
14th October 2014, 01:25 AM   |  #2  
daxgirl's Avatar
Senior Member
Flag Jerusalem
Thanks Meter: 3,908
 
1,966 posts
Join Date:Joined: Jun 2012
More
Seriously, you're the best! This is AMAZING! Absolutely superb job, Wuby!

Sent from my SM-G900F using Tapatalk
The Following 6 Users Say Thank You to daxgirl For This Useful Post: [ View ]
14th October 2014, 01:44 AM   |  #3  
daxgirl's Avatar
Senior Member
Flag Jerusalem
Thanks Meter: 3,908
 
1,966 posts
Join Date:Joined: Jun 2012
More
It WOOOORRRRRRKKKKSSSSSS! GENIUS!

Sent from my SM-G900F using Tapatalk
Attached Thumbnails
Click image for larger version

Name:	uploadfromtaptalk1413243863767.png
Views:	2280
Size:	191.4 KB
ID:	2970301  
The Following 4 Users Say Thank You to daxgirl For This Useful Post: [ View ]
14th October 2014, 03:12 AM   |  #4  
ragz's Avatar
Senior Member
Flag Regina, Saskatchewan
Thanks Meter: 459
 
876 posts
Join Date:Joined: Aug 2011
More
Working here to, appreciate the zip, thanks. (NeatROM v2.3)

SM-G900W8 / 0x1
Last edited by ragz; 14th October 2014 at 10:04 AM.
The Following 2 Users Say Thank You to ragz For This Useful Post: [ View ]
14th October 2014, 07:18 AM   |  #5  
Senior Member
Thanks Meter: 375
 
574 posts
Join Date:Joined: Oct 2010
Great guide @Wuby986 ! I am sure many moders & users will benefit from your clean work ! What a nice and simple guide . Private mode can have it's uses, finally !

With friendship,

Thomas
The Following 2 Users Say Thank You to DaOldMan For This Useful Post: [ View ]
14th October 2014, 10:29 AM   |  #6  
BoBCatRoM's Avatar
Senior Member
Flag Venice
Thanks Meter: 3,557
 
1,557 posts
Join Date:Joined: Dec 2011
Donate to Me
thanks magician wuby, it works perfectly
The Following 2 Users Say Thank You to BoBCatRoM For This Useful Post: [ View ]
14th October 2014, 04:16 PM   |  #7  
Senior Member
Thanks Meter: 465
 
185 posts
Join Date:Joined: Feb 2011
Samsung stock odex NG2 not work
14th October 2014, 04:22 PM   |  #8  
daxgirl's Avatar
Senior Member
Flag Jerusalem
Thanks Meter: 3,908
 
1,966 posts
Join Date:Joined: Jun 2012
More
Quote:
Originally Posted by Tamerlan2009

Samsung stock odex NG2 not work

You need to delete the odex file of the apk. The zip replaced the apk. But the odex is still there. Delete it and it should work.
Find PersonalPageService.apk. in /system/priv-app and see if you have PersonalPageService.odex. delete it.

Sent from my SM-G900F using Tapatalk
Last edited by daxgirl; 14th October 2014 at 04:25 PM.
The Following User Says Thank You to daxgirl For This Useful Post: [ View ]
14th October 2014, 04:32 PM   |  #9  
Senior Member
Thanks Meter: 465
 
185 posts
Join Date:Joined: Feb 2011
Quote:
Originally Posted by daxgirl

You need to delete the odex file of the apk. The zip replaced the apk. But the odex is still there. Delete it and it should work.
Find PersonalPageService.apk. in /system/priv-app and see if you have PersonalPageService.odex. delete it.

Sent from my SM-G900F using Tapatalk


long the file has been deleted) that I just did not do. still does not work
14th October 2014, 04:34 PM   |  #10  
daxgirl's Avatar
Senior Member
Flag Jerusalem
Thanks Meter: 3,908
 
1,966 posts
Join Date:Joined: Jun 2012
More
Quote:
Originally Posted by Tamerlan2009

long the file has been deleted) that I just did not do. still does not work

Then I suggest opening the actual deodexed apk for ng2 base and modding it according to the guide. Maybe there are differences.

Sent from my SM-G900F using Tapatalk

Post Reply Subscribe to Thread

Tags
guide, private mode
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes