[Android General] ananjaser1211:
Fixing PrivateMode on nonsupported frameworks (i.e N8/S9) Oreo edition

So, probably one of the most annoying thing users will ask for, since oreo samsung has been at war removing private mode from its unsupported frameworks, And i believe in sharing my findings/fixes for the public and hope more devs do that, as it will make this community generally better.

P.S : For experienced devs, skip to the part about fixing turnon/off issue since you probably did this already.​

P.S (just one more) : Read the bottom notes before doing this so you avoid wasting time if you are using an S8 or perhaps a device that doesnt want to act well with the s7e vold binary.

Most if not all of the needed files will be attached below in a ZIP.

The source of the files etc is from the galaxy S7 Oreo

ROM

Add the etc/permissions and the priv-app

system/etc/permissions/com.sec.feature.secretmode_service.xml
system/etc/permissions/privapp-permissions-com.samsung.android.personalpage.service.xml
system/priv-app/PersonalPageService

(Big thanks to [MENTION=612358]slink_59[/MENTION] and [MENTION=4985020]Grouxho[/MENTION] for editing the app)

Kernel

Add the privatemode mount-points in your kernel if you dont have them

unpack your kernel, inside ramdisk/init.samsungxxxxxxx.rc (exynos7870.rc)

on post-fs-data
#Private Mode
mkdir /mnt/shell/privatemode 0700 system system
mkdir /storage/Private 0000 system system
mkdir /data/privatemode 0770 system system
chown system system /data/privatemode
restorecon /data/privatemode

Framework.jar Merge/replace

smali_classes3\com\samsung\android\privatemode\ contents into your own framework.jar

SecSettings.apk

Adding the privatemode tab in lockscreen settings :

Locate

\smali\com\samsung\android\settings\lockscreen\LockscreenMenuSettings.smali

Find "persona"

iget-object v0, v0, Lcom/samsung/android/settings/lockscreen/LockscreenMenuSettings;->mPrivateMode:Landroid/support/v7/preference/SecPreferenceScreen;

move-object/from16 v18, v0

move-object/from16 v0, v16

move-object/from16 v1, v18

Delete this invoke >> [COLOR="Red"]invoke-virtual {v0, v1}, Landroid/support/v7/preference/SecPreferenceCategory;->removePreference(Landroid/support/v7/preference/Preference;)Z[/COLOR]

:cond_1d

sget-object v18, Lcom/samsung/android/settings/lockscreen/LockscreenMenuSettings;->mContext:Landroid/content/Context;

const-string/jumbo v19, "persona"

Second step is adding/merging in settings

com/samsung/android/settings/personalpage
com/android/settings/Settings$PersonalPageSettingsActivity.smali

Adding QS Toggle

Big thanks for the New Guide by [MENTION=4751298]Carotix[/MENTION] : Post

P.S : FOR THIS PART TO WORK YOU NEED TO RESIGN THE APK WITH GOOGLE TESTKEY AND HAVE SignatureSpoof Applied

Then edit secsettings.apk/res/values/bools.xml

<bool name="support_private_mode">false</bool>
to
<bool name="support_private_mode">true</bool>

Then secsettings.apk/AndroidManifest.xml

Under
<meta-data android:name="com.android.settings.FRAGMENT_CLASS" android:value="com.android.settings.applications.defaultapps.DefaultAutofillPicker"/>
</activity>
Add >> ( you can compare manifest to see)
<service android:enabled="@bool/support_private_mode" android:icon="@drawable/quick_panel_icon_private_mode" android:label="@string/personal_page" android:name="com.samsung.android.settings.qstile.PersonalModeTile" android:permission="android.permission.BIND_QUICK_SETTINGS_TILE" android:process=":QuickSettingsTile">
<intent-filter>
<action android:name="android.service.quicksettings.action.QS_TILE"/>
</intent-filter>
<meta-data android:name="com.samsung.android.multiuser.install_only_owner" android:value="true"/>
</service>

in secsettings.apk/res/values/id.xml

Add

<item type="id" name="personal_mode_description">false</item>

Recompile secsettings.apk once (with the changes above if you added manifest be sure its new signature)

Then decompile the compiled apk.

Then in secsettings.apk/res/layout

add

qs_detail_personalmode.xml

P.S : If you did not follow the previous step for ID it will fail at compiling

add

secsettings.apk/smali/com/samsung/android/settings/qstile

Match 2 IDs (mentioned in PersonalModeTile.smali and PersonalModeTile$2.smali) with the ones from the secsettings you are adding privatemode to

0x7f121432 ##SecSettings.apk/res/values/public.xml "personal_mode_popup_diable_msg_while_afw_profile"
0x7f12144d ##SecSettings.apk/res/values/public.xml "personal_page_toast_disable_while_moving_item"

There can be more IDs (dont think so) but im too lazy to find them if they are there, ill leave that to you.

Now to fix privatemode not tuning on.

We need to add these 3 files from S7E Oreo [sysutils from N8]

system/bin/vold
system/lib/libepm.so
system/lib64/libepm.so
system/lib/libsysutils.so
system/lib64/libsysutils.so

P.S : Guide updated big thanks to [MENTION=7393522]AbrahamGC[/MENTION] for finding out the missing link to make it work on any 64bit base. not only Note 8s.

The attachment has been updated accordingly

So i know this was a long guide, and a hard one to fix, if you use it in your roms it would be appreciated if you credit the people who worked on this

Thanks to [MENTION=612358]slink_59[/MENTION] , [MENTION=4985020]Grouxho[/MENTION] , [MENTION=5493353]Wuby986[/MENTION] for their original work on PV

[MENTION=7098450]Kill-Switch[/MENTION] for working on it with me

[MENTION=4658360]corsicanu[/MENTION] , [MENTION=6911575]BlackMesa123[/MENTION] for being awesome as usual

[MENTION=7393522]AbrahamGC[/MENTION] For making it work on any base