[ How-to ] Enable App Ops again in 4.4.2 / KOT49H

Search This thread

Calkulin

Recognized Developer
Sep 3, 2008
1,647
9,109
Samsung Galaxy S21+
Here's a quick guide on how to enable App Ops in 4.4.2 / KOT49H. Decompile Settings.apk, open the Settings.smali and make these changes. Now if you want to keep ART working, don't deodex and just use the classes.dex that already included in the apk.

1.
Code:
.method static constructor <clinit>()V
    .locals 3

    .prologue
    const/4 v2, 0x0

    .line 126
    sput-boolean v2, Lcom/android/settings/Settings;->sShowNoHomeNotice:Z

    .line 309
    const/16 v0, 0x2[COLOR="Red"]c[/COLOR]

    new-array v0, v0, [Ljava/lang/String;

Change to - +1

Code:
.method static constructor <clinit>()V
    .locals 3

    .prologue
    const/4 v2, 0x0

    .line 126
    sput-boolean v2, Lcom/android/settings/Settings;->sShowNoHomeNotice:Z

    .line 309
    const/16 v0, 0x2[COLOR="red"]d[/COLOR]

    new-array v0, v0, [Ljava/lang/String;

2.
Code:
    const/16 v1, 0x2b

    const-class v2, Lcom/android/settings/inputmethod/KeyboardLayoutPickerFragment;

    invoke-virtual {v2}, Ljava/lang/Class;->getName()Ljava/lang/String;

    move-result-object v2

    aput-object v2, v0, v1

    sput-object v0, Lcom/android/settings/Settings;->ENTRY_FRAGMENTS:[Ljava/lang/String;

Add this - What's marked in red should be 1 less than what you changed in the previous step (Or the previous number before adding 1)

Code:
    const/16 v1, 0x2b

    const-class v2, Lcom/android/settings/inputmethod/KeyboardLayoutPickerFragment;

    invoke-virtual {v2}, Ljava/lang/Class;->getName()Ljava/lang/String;

    move-result-object v2

    aput-object v2, v0, v1

    [B][COLOR="green"]const/16 v1, 0x[COLOR="red"]2c[/COLOR]

    const-class v2, Lcom/android/settings/applications/AppOpsSummary;

    invoke-virtual {v2}, Ljava/lang/Class;->getName()Ljava/lang/String;

    move-result-object v2

    aput-object v2, v0, v1[/COLOR][/B]

    sput-object v0, Lcom/android/settings/Settings;->ENTRY_FRAGMENTS:[Ljava/lang/String;


EDIT: Here's how to add it to Settings/Security

Added this to values/strings.xml
Code:
    <string name="app_ops_settings_summary">Manage app permissions</string>

Add this to xml/security_settings_misc.xml under the device admin title
Code:
        <Preference android:title="@string/app_ops_settings" android:key="app_ops_summary" android:summary="@string/app_ops_settings_summary" android:fragment="com.android.settings.applications.AppOpsSummary" />

d5av.png
 
Last edited:

Fenny

Inactive Recognized Developer
Jun 28, 2007
1,386
2,073
F(x)tec Pro1-X
Google Pixel 6 Pro
Great tutorial, but you left out the line that makes the first change actually make sense. The one that initializes the collection to a certain size. I.E. 0x2d instead of 0x2c
Other than that, easy to follow, and useful. Thank you very much for this.
 

Calkulin

Recognized Developer
Sep 3, 2008
1,647
9,109
Samsung Galaxy S21+
Great tutorial, but you left out the line that makes the first change actually make sense. The one that initializes the collection to a certain size. I.E. 0x2d instead of 0x2c
Other than that, easy to follow, and useful. Thank you very much for this.


That was actually the first step

1.
Code:
.method static constructor <clinit>()V
    .locals 3

    .prologue
    const/4 v2, 0x0

    .line 126
    sput-boolean v2, Lcom/android/settings/Settings;->sShowNoHomeNotice:Z

    .line 309
    const/16 v0, 0x2[B]c[/B]

Change to

Code:
.method static constructor <clinit>()V
    .locals 3

    .prologue
    const/4 v2, 0x0

    .line 126
    sput-boolean v2, Lcom/android/settings/Settings;->sShowNoHomeNotice:Z

    .line 309
    const/16 v0, 0x2[B]d[/B]
 

XBlackChaosX

Senior Member
Oct 30, 2011
497
169
New York
OnePlus 7 Pro
True, I haven't gotten the chance to try ART, and I won't until xposed framework somehow starts working with ART. Does ART improve anything on your phone?

Sent from my Droid Razr Maxx HD (GSM)
 

Fenny

Inactive Recognized Developer
Jun 28, 2007
1,386
2,073
F(x)tec Pro1-X
Google Pixel 6 Pro
Both the Nexus 4 and 5 builds that I did, did not have that, so post it and let me see it

Code:
.method static constructor <clinit>()V
    .locals 3

    .prologue
    const/4 v2, 0x0

    .line 126
    sput-boolean v2, Lcom/android/settings/Settings;->sShowNoHomeNotice:Z

    .line 309
    const/16 v0, 0x2c

    new-array v0, v0, [Ljava/lang/String;

Quite literally, it is the line after it.
I am just suggesting that it should be included for context.

That way we know that this is referring to the array we defined as v0:

Code:
 aput-object v2, v0, v1

Don't mind me though. I just have this thing about people blindly following tutorials while not really knowing why they are doing what they are doing...
 
Last edited:
  • Like
Reactions: Calkulin

Kobayashi_SRK

Member
Nov 30, 2013
35
17
I've never done this before! I followed this guide, but I cant find Settings.apk in /system/app. Halp? Thanks!
 
Last edited:

zaventh

Senior Member
Jul 26, 2010
165
136
San Francisco
www.jeffmixon.com
I've never done this before! I followed this guide, but I cant find Settings.apk in /system/app. Halp? Thanks!

/system/priv-app/

You will always need /system/framework/framework-res.apk. Install this as a framework.

Once you rebuild, take just the classes.dex from the build/apk/ folder and jam it back in the original apk. Repush that to your device with adb and chmod 644 it.

Also, if you're on a ROM with custom settings already, the values in this guide might not be suitable. Mine were offset by +2.
 
Last edited:
  • Like
Reactions: Kobayashi_SRK

Kobayashi_SRK

Member
Nov 30, 2013
35
17
Awesome! Everything worked until I tried to rebuild the APK. I know I must be missing some simple step somewhere...

stdout:
Code:
[kobayashi@DansGame android_****ery]$ sudo apktool b Settings
I: Checking whether sources has changed...
I: Smaling...
I: Checking whether resources has changed...
I: Building resources...
Exception in thread "main" brut.androlib.AndrolibException: brut.androlib.AndrolibException: brut.common.BrutException: could not exec command: [aapt, p, --min-sdk-version, 19, --target-sdk-version, 19, -F, /tmp/APKTOOL8793864650703229355.tmp, -0, arsc, -I, /root/apktool/framework/1.apk, -S, /home/kobayashi/android_****ery/Settings/res, -M, /home/kobayashi/android_****ery/Settings/AndroidManifest.xml]
	at brut.androlib.Androlib.buildResourcesFull(Androlib.java:358)
	at brut.androlib.Androlib.buildResources(Androlib.java:283)
	at brut.androlib.Androlib.build(Androlib.java:206)
	at brut.androlib.Androlib.build(Androlib.java:176)
	at brut.apktool.Main.cmdBuild(Main.java:228)
	at brut.apktool.Main.main(Main.java:79)
Caused by: brut.androlib.AndrolibException: brut.common.BrutException: could not exec command: [aapt, p, --min-sdk-version, 19, --target-sdk-version, 19, -F, /tmp/APKTOOL8793864650703229355.tmp, -0, arsc, -I, /root/apktool/framework/1.apk, -S, /home/kobayashi/android_****ery/Settings/res, -M, /home/kobayashi/android_****ery/Settings/AndroidManifest.xml]
	at brut.androlib.res.AndrolibResources.aaptPackage(AndrolibResources.java:357)
	at brut.androlib.Androlib.buildResourcesFull(Androlib.java:336)
	... 5 more
Caused by: brut.common.BrutException: could not exec command: [aapt, p, --min-sdk-version, 19, --target-sdk-version, 19, -F, /tmp/APKTOOL8793864650703229355.tmp, -0, arsc, -I, /root/apktool/framework/1.apk, -S, /home/kobayashi/android_****ery/Settings/res, -M, /home/kobayashi/android_****ery/Settings/AndroidManifest.xml]
	at brut.util.OS.exec(OS.java:93)
	at brut.androlib.res.AndrolibResources.aaptPackage(AndrolibResources.java:355)
	... 6 more
Caused by: java.io.IOException: Cannot run program "aapt": error=2, No such file or directory
	at java.lang.ProcessBuilder.start(ProcessBuilder.java:1041)
	at java.lang.Runtime.exec(Runtime.java:617)
	at java.lang.Runtime.exec(Runtime.java:485)
	at brut.util.OS.exec(OS.java:84)
	... 7 more
Caused by: java.io.IOException: error=2, No such file or directory
	at java.lang.UNIXProcess.forkAndExec(Native Method)
	at java.lang.UNIXProcess.<init>(UNIXProcess.java:135)
	at java.lang.ProcessImpl.start(ProcessImpl.java:130)
	at java.lang.ProcessBuilder.start(ProcessBuilder.java:1022)
	... 10 more

My previous commands:

Code:
adb pull /system/priv-app/Settings.apk
adb pull /system/framework/framework-res.apk
apktool if framework-res.apk
apktool d Settings.apk
nano Settings.smali
apktool b Settings

Thanks in advance, guys!
 

Fenny

Inactive Recognized Developer
Jun 28, 2007
1,386
2,073
F(x)tec Pro1-X
Google Pixel 6 Pro
Awesome! Everything worked until I tried to rebuild the APK. I know I must be missing some simple step somewhere...

stdout:
Code:
[kobayashi@DansGame android_****ery]$ sudo apktool b Settings
I: Checking whether sources has changed...
I: Smaling...
I: Checking whether resources has changed...
I: Building resources...
Exception in thread "main" brut.androlib.AndrolibException: brut.androlib.AndrolibException: brut.common.BrutException: could not exec command: [aapt, p, --min-sdk-version, 19, --target-sdk-version, 19, -F, /tmp/APKTOOL8793864650703229355.tmp, -0, arsc, -I, /root/apktool/framework/1.apk, -S, /home/kobayashi/android_****ery/Settings/res, -M, /home/kobayashi/android_****ery/Settings/AndroidManifest.xml]
at brut.androlib.Androlib.buildResourcesFull(Androlib.java:358)
at brut.androlib.Androlib.buildResources(Androlib.java:283)
at brut.androlib.Androlib.build(Androlib.java:206)
at brut.androlib.Androlib.build(Androlib.java:176)
at brut.apktool.Main.cmdBuild(Main.java:228)
at brut.apktool.Main.main(Main.java:79)
Caused by: brut.androlib.AndrolibException: brut.common.BrutException: could not exec command: [aapt, p, --min-sdk-version, 19, --target-sdk-version, 19, -F, /tmp/APKTOOL8793864650703229355.tmp, -0, arsc, -I, /root/apktool/framework/1.apk, -S, /home/kobayashi/android_****ery/Settings/res, -M, /home/kobayashi/android_****ery/Settings/AndroidManifest.xml]
at brut.androlib.res.AndrolibResources.aaptPackage(AndrolibResources.java:357)
at brut.androlib.Androlib.buildResourcesFull(Androlib.java:336)
... 5 more
Caused by: brut.common.BrutException: could not exec command: [aapt, p, --min-sdk-version, 19, --target-sdk-version, 19, -F, /tmp/APKTOOL8793864650703229355.tmp, -0, arsc, -I, /root/apktool/framework/1.apk, -S, /home/kobayashi/android_****ery/Settings/res, -M, /home/kobayashi/android_****ery/Settings/AndroidManifest.xml]
at brut.util.OS.exec(OS.java:93)
at brut.androlib.res.AndrolibResources.aaptPackage(AndrolibResources.java:355)
... 6 more
Caused by: java.io.IOException: Cannot run program "aapt": error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1041)
at java.lang.Runtime.exec(Runtime.java:617)
at java.lang.Runtime.exec(Runtime.java:485)
at brut.util.OS.exec(OS.java:84)
... 7 more
Caused by: java.io.IOException: error=2, No such file or directory
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.<init>(UNIXProcess.java:135)
at java.lang.ProcessImpl.start(ProcessImpl.java:130)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1022)
... 10 more

My previous commands:

Code:
adb pull /system/priv-app/Settings.apk
adb pull /system/framework/framework-res.apk
apktool if framework-res.apk
apktool d Settings.apk
nano Settings.smali
apktool b Settings

Thanks in advance, guys!

Apktool can't find aapt from the android toolkit. Make sure that utility is in your path. You could set apktool not to decompile resources, or alternatively you can use smali / baksmali to the same effect.

Code:
java -jar baksmali.jar -o Settings
nano Settings.smali
java -jar smali.jar Settings -o classes.dex

Then just rezip the apk with the new built classes.dex

Sent from my Nexus 7 using Tapatalk 4
 
  • Like
Reactions: Kobayashi_SRK

Kobayashi_SRK

Member
Nov 30, 2013
35
17
Apktool can't find aapt from the android toolkit. Make sure that utility is in your path.

I dunno how to use java -jar yet, and decompiling with -s doesn't give me the Settings.smali file I need to alter.

However, I already had aapt installed, just had to logout for the changes to take effect in my bash config.

--------

Thanks so much everyone for your help!

Here's everything I did:
Code:
adb pull /system/priv-app/Settings.apk
adb pull /system/framework/framework-res.apk
apktool if framework-res.apk
apktool d Settings.apk
nano Settings/smali/com/android/settings/Settings.smali
apktool b Settings
adb push Settings.apk /sdcard/
adb root
adb remount
adb shell cp /system/priv-app/Settings.apk /system/priv-app/Settings.bak
adb shell cp /sdcard/Settings.apk /system/priv-app/Settings.apk
adb reboot

Here's the million dollar question. Everything appears to have worked right, but where do I access AppOps?

EDIT:
I just tried pulling my new Settings.apk from my phone. I decompiled it, and looked again at the Settings.smali file to find that none of my changes were saved... Gonna try this again.

EDIT 2:
Okay, yeah. Just pulled Settings.bak, decompiled, re-applied changes to Settings.smali, apktool b Settings, then moved the Settings.apk file to a different folder, decompiled that, and found none of my changes to Settings.smali stuck. I must be missing something obvious here....

Does apktool spit out the newly built .apk somewhere else?

EDIT 3:
Oh! It puts the new Settings.apk file in Settings/dist/
Derp. Now I think I understand what everyone's been saying about jamming the classes.dex file into the new .apk. I dunno how to do that though. Time for more researching...
 
Last edited:
  • Like
Reactions: Seattleite

Fenny

Inactive Recognized Developer
Jun 28, 2007
1,386
2,073
F(x)tec Pro1-X
Google Pixel 6 Pro
Here's the million dollar question. Everything appears to have worked right, but where do I access AppOps?

EDIT:
I just tried pulling my new Settings.apk from my phone. I decompiled it, and looked again at the Settings.smali file to find that none of my changes were saved... Gonna try this again.

EDIT 2:
Okay, yeah. Just pulled Settings.bak, decompiled, re-applied changes to Settings.smali, apktool b Settings, then moved the Settings.apk file to a different folder, decompiled that, and found none of my changes to Settings.smali stuck. I must be missing something obvious here....

Does apktool spit out the newly built .apk somewhere else?

EDIT 3:
Oh! It puts the new Settings.apk file in Settings/dist/
Derp. Now I think I understand what everyone's been saying about jamming the classes.dex file into the new .apk. I dunno how to do that though. Time for more researching...

Okay, here is the big secret. Apk files are secretly zip files. Unzip the original apk file to a folder. Copy your newly built classes.dex into that folder, and rezip. Just make sure you maintain the same folder structure. (I.E. make sure that classes.dex is in the root of the zip)

Since this is a system apk there should be no need to re-sign the apk. You can check to see if you need to re-sign by looking to see if the classes.dex file is included in the signatures in the meta-inf folder. If you modify any file included in that list of hashes, you must re-sign the apk.

P.S. You should probably also chmod the apk to 644 rw,r,r.

Sent from my Nexus 7 using Tapatalk 4
 
Last edited:
  • Like
Reactions: Seattleite

Mr.Yawnie

Senior Member
Jun 27, 2013
2,305
3,056
Thank you!! Worked brilliantly.

Only thing is that i can't see App Ops in activities when creating a shortcut. I can use App Ops Starter from playstore though to launch app ops (people commented it didn't work with 4.4.2 but worked for me after this smali hack).

I just want to add a straight "link" to App Ops on EchoeRom Settings app, but couldn't for the life of me get the activities or target classes right.. Always caused a FC when pressing "Launch App Ops" from my settings. That forced me to continue using App Ops Starter app, even though i wanted to get rid of extra apps..

Anyone has an idea why it didn't work? I tried it so many times, but this was the simplest one i thought would work:

Code:
PreferenceScreen android:icon="@drawable/app_ops" android:title="App Ops" android:summary="Control app permissions">
            <intent android:targetPackage="com.android.settings" android:action="android.intent.action.MAIN" android:targetClass="com.android.settings.applications.AppOpsSummary" />
        </PreferenceScreen>

and


Code:
PreferenceScreen android:icon="@drawable/app_ops" android:title="App Ops" android:summary="Control app permissions">
            <intent android:targetPackage="com.android.settings" android:action="android.intent.action.MAIN" android:targetClass="com.android.settings.Settings$AppOpsSummaryActivity" />
        </PreferenceScreen>

but couldn't get it to work. I also tried this

Code:
<PreferenceScreen android:title="App Ops" android:summary="Control app permissions" android:fragment="com.android.settings.applications.AppOpsSummary">
        <extra android:name="classname" android:value="com.android.settings.Settings$AppOpsSummaryActivity" />

without any luck. I tried around 20 different variations.. Anyone could tell me where i'm going wrong and how i should implement the "link" to items inside system settings. I have only added links to other apps before..
 

Top Liked Posts

  • There are no posts matching your filters.
  • 30
    Here's a quick guide on how to enable App Ops in 4.4.2 / KOT49H. Decompile Settings.apk, open the Settings.smali and make these changes. Now if you want to keep ART working, don't deodex and just use the classes.dex that already included in the apk.

    1.
    Code:
    .method static constructor <clinit>()V
        .locals 3
    
        .prologue
        const/4 v2, 0x0
    
        .line 126
        sput-boolean v2, Lcom/android/settings/Settings;->sShowNoHomeNotice:Z
    
        .line 309
        const/16 v0, 0x2[COLOR="Red"]c[/COLOR]
    
        new-array v0, v0, [Ljava/lang/String;

    Change to - +1

    Code:
    .method static constructor <clinit>()V
        .locals 3
    
        .prologue
        const/4 v2, 0x0
    
        .line 126
        sput-boolean v2, Lcom/android/settings/Settings;->sShowNoHomeNotice:Z
    
        .line 309
        const/16 v0, 0x2[COLOR="red"]d[/COLOR]
    
        new-array v0, v0, [Ljava/lang/String;

    2.
    Code:
        const/16 v1, 0x2b
    
        const-class v2, Lcom/android/settings/inputmethod/KeyboardLayoutPickerFragment;
    
        invoke-virtual {v2}, Ljava/lang/Class;->getName()Ljava/lang/String;
    
        move-result-object v2
    
        aput-object v2, v0, v1
    
        sput-object v0, Lcom/android/settings/Settings;->ENTRY_FRAGMENTS:[Ljava/lang/String;

    Add this - What's marked in red should be 1 less than what you changed in the previous step (Or the previous number before adding 1)

    Code:
        const/16 v1, 0x2b
    
        const-class v2, Lcom/android/settings/inputmethod/KeyboardLayoutPickerFragment;
    
        invoke-virtual {v2}, Ljava/lang/Class;->getName()Ljava/lang/String;
    
        move-result-object v2
    
        aput-object v2, v0, v1
    
        [B][COLOR="green"]const/16 v1, 0x[COLOR="red"]2c[/COLOR]
    
        const-class v2, Lcom/android/settings/applications/AppOpsSummary;
    
        invoke-virtual {v2}, Ljava/lang/Class;->getName()Ljava/lang/String;
    
        move-result-object v2
    
        aput-object v2, v0, v1[/COLOR][/B]
    
        sput-object v0, Lcom/android/settings/Settings;->ENTRY_FRAGMENTS:[Ljava/lang/String;


    EDIT: Here's how to add it to Settings/Security

    Added this to values/strings.xml
    Code:
        <string name="app_ops_settings_summary">Manage app permissions</string>

    Add this to xml/security_settings_misc.xml under the device admin title
    Code:
            <Preference android:title="@string/app_ops_settings" android:key="app_ops_summary" android:summary="@string/app_ops_settings_summary" android:fragment="com.android.settings.applications.AppOpsSummary" />

    d5av.png
    3
    here it is
    4.4.3 settings for nexus 5 with app ops enabled
    its only the apk in a rar file so extract it and rename and manually replace Settings.apk under system/priv-app/
    this is NOT a flashable zip!

    sha1:ec526b50082edf0564364253c1b8aee4a8438a2d
    https://www.mediafire.com/?m8edtkj9kx59s70
    2
    I used App Ops Starter app from playstore as a work around. But it'd be great if you shared your method so I could avoid using 3rd party apps for it and have it more as an "native" rom feature.

    Sent from my GT-I9505G using Tapatalk


    Here's what I did

    Added this line to Strings.xml
    Code:
        <string name="app_ops_settings_summary">Manage app permissions</string>

    Added this line to security_settings_misc.xml under the device admin label
    Code:
            <Preference android:title="@string/app_ops_settings" android:key="app_ops_summary" android:summary="@string/app_ops_settings_summary" android:fragment="com.android.settings.applications.AppOpsSummary" />

    d5av.png
    1
    Both the Nexus 4 and 5 builds that I did, did not have that, so post it and let me see it

    Code:
    .method static constructor <clinit>()V
        .locals 3
    
        .prologue
        const/4 v2, 0x0
    
        .line 126
        sput-boolean v2, Lcom/android/settings/Settings;->sShowNoHomeNotice:Z
    
        .line 309
        const/16 v0, 0x2c
    
        new-array v0, v0, [Ljava/lang/String;

    Quite literally, it is the line after it.
    I am just suggesting that it should be included for context.

    That way we know that this is referring to the array we defined as v0:

    Code:
     aput-object v2, v0, v1

    Don't mind me though. I just have this thing about people blindly following tutorials while not really knowing why they are doing what they are doing...
    1
    I've never done this before! I followed this guide, but I cant find Settings.apk in /system/app. Halp? Thanks!

    /system/priv-app/

    You will always need /system/framework/framework-res.apk. Install this as a framework.

    Once you rebuild, take just the classes.dex from the build/apk/ folder and jam it back in the original apk. Repush that to your device with adb and chmod 644 it.

    Also, if you're on a ROM with custom settings already, the values in this guide might not be suitable. Mine were offset by +2.