yashsingh1/xdaforums huggingface dataset:
[Android Software Development] Calkulin:
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.

.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

.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.

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)

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

<string name="app_ops_settings_summary">Manage app permissions</string>

Add this to xml/security_settings_misc.xml under the device admin title

<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" />
[Android Software Development] Fenny:
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.
[Android Software Development] Calkulin:
That was actually the first step
[Android Software Development] Fenny:
Right, but there is a line after the end of the code snippet that actually uses the constant /16 that is being defined to initialize the array. Without that, it's just changing an arbitrary constant.
[Android Software Development] XBlackChaosX:
You can also just use AppOpsXposed module for xposed framework.

Sent from my Droid Razr Maxx HD (GSM)
[Android Software Development] Fenny:
That would break ART.
[Android Software Development] Calkulin:
Both the Nexus 4 and 5 builds that I did, did not have that, so post it and let me see it
[Android Software Development] XBlackChaosX:
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)
[Android Software Development] nikodr:
Less memory usage,faster loading of some applications,and phone had quicker response.
[Android Software Development] Fenny:
.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:

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...
[Android Software Development] zaventh:
-edit- nm ;)
[Android Software Development] Kobayashi_SRK:
I've never done this before! I followed this guide, but I cant find Settings.apk in /system/app. Halp? Thanks!
[Android Software Development] zaventh:
/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.
[Android Software Development] Fenny:
It is in /system/priv-app IIRC.
[Android Software Development] Kobayashi_SRK:
Awesome! Everything worked until I tried to rebuild the APK. I know I must be missing some simple step somewhere...

stdout:

[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:

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!
[Android Software Development] GhostSamuraiX:
Will this work on SGH-M919?
[Android Software Development] Fenny:
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.

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
[Android Software Development] Kobayashi_SRK:
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:

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...
[Android Software Development] Fenny:
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.
[Android Software Development] Mr.Yawnie:
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:

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

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

<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..
[Android Software Development] Diaz1999:
[MENTION=1188493]Calkulin[/MENTION] HELP! Mine Settings.smali is like this

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

.prologue
const/4 v2, 0x0

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

.line 316
const/16 v0, [B][COLOR="Red"]0x37[/COLOR][/B]

Are it's okay to change it to

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

.prologue
const/4 v2, 0x0

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

.line 316
const/16 v0, [B][COLOR="Red"]0x2d[/COLOR][/B]

Or I must change it to

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

.prologue
const/4 v2, 0x0

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

.line 316
const/16 v0, [B][COLOR="Red"]0x38[/COLOR][/B]

:confused::confused::confused:
[Android Software Development] Calkulin:
Sorry, I misunderstood what you were trying to say but I added it
[Android Software Development] Calkulin:
I'm guessing that's CM based but it should be 38 as all you need to do is add 1 but remember to change the number also in step 2 as that one should be 37 instead of 2c
[Android Software Development] Calkulin:
Did you figure this out? Cause if not, I can post what I used to get it to display and open App ops from security
[Android Software Development] Mr.Yawnie:
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.
[Android Software Development] Calkulin:
Here's what I did

Added this line to Strings.xml

<string name="app_ops_settings_summary">Manage app permissions</string>

Added this line to security_settings_misc.xml under the device admin label

<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" />
[Android Software Development] Mr.Yawnie:
THANK YOU! I will give it a try tomorrow :) I tried with the key and fragment as well but guess what? Even though I got the fragment right, I messed up with the key since I had it "com.android.settings.APP_OPS_SUMMARY" and it didn't work.. In your example the key is just app_ops_summary and I'm sure it'll work. Thanks :)
[Android Software Development] ss4rob:
Thanks for the guide - it took a bit, but I created my new Settings.apk, extracted the updated classes.dex, inserted that into the original Settings.apk, and put it back on the phone - boom, I'm able to get back into App Ops via activity. I would like to add a menu item, so I followed the two edits above, but given that I want to continue running ANT, I just inserted the classes.dex - I would guess I'd have to do more for those resource changes to be seen. Is there a way to keep using ANT but modify the settings menu like above and insert more back into the original Settings.apk? Thanks for any help!
[Android Software Development] lozohcum:
[MENTION=1188493]Calkulin[/MENTION] thank you for the tutorial, I was looking for it!

What about source? Can you explain how to make it using source code?

I want my rom (4.4.2) to have AppOPS already after build :)
[Android Software Development] Zeljko1234:
It is already part of CM11.
[Android Software Development] JazonX:
On Samsung (Note 3) 4.4.2 Rom The Line is as follows,

# direct methods
.method static constructor <clinit>()V
.locals 5

.prologue
const/4 v2, 0x1

const/4 v1, 0x0

.line 303
invoke-static {}, Landroid/os/Debug;->isProductShip()I

move-result v0

if-ne v0, v2, :cond_0

move v0, v1

:goto_0
sput-boolean v0, Lcom/android/settings/Settings;->DBG:Z

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

.line 343
sput v2, Lcom/android/settings/Settings;->mDeviceProvisioned:I

.line 521
const/4 v0, 0x0

sput-object v0, Lcom/android/settings/Settings;->mContext:Landroid/content/Context;

.line 523
const/4 v0, -0x1

What Should I Change?
[Android Software Development] tkari4:
Try this one: http://xdaforums.com/showpost.php?p=51357012&postcount=1

It's for the Note 3 (TW & 4.4.2)

;)
[Android Software Development] JazonX:
Saw that post before you replied this, Already using! Thanks for taking the time to reply mate. ;)
[Android Software Development] munjeni:
Do you have idea why AppOpsSummary activity fail to start ??? Nothing happening when I click on appops in settings menu, but allso nothing in logcat! Only I can see in logcat that appopssumary starting but no errors or something other :( . Here is my unsucesfull atempt https://github.com/munjeni/D5503_14.3.A.0.757/commit/920e7df4a5477186296ab23a5b72c7ba3fb3e0a5 :( Anyone have idea?
[Android Software Development] Bhodi:
Any suggestions on achieving the same results on Sense 6? Verizon M8 running 4.4.2 stock S-off and rooted.

Any suggestions on what to edit would be greatly appreciated!

https://github.com/Cygnuz/Settings/blob/master/Settings.smali
[Android Software Development] Seattleite:
Anybody had a chance to try this method on 4.4.3? I tried the flashable zip, with no luck, and I'm tempted to go back to 4.4.2 without app ops. I won't have time to try it till next week, so hopefully someone else can let us know before then.

Thanks in advance!
[Android Software Development] Kusie:
Applied the 4.4.2 zip after upgrading to 4.4.3 and it worked instantly. Does anyone know if additional features have been introduced in the 4.4.3 settings app that I lost now after flashing the 4.4.2 settings.apk with modified app ops changes?

Gesendet von meinem Nexus 5 mit Tapatalk
[Android Software Development] td32:
can anyone make a flashable zip for 4.4.3 nexus 5?

Edit.

i tried to decompile edit and compile back the settings.apk from 4.4.3

there were some warning during compile(some translation missing in some languages) but there were no errors.

I tried signin the new apk with zipsigner but it dint work, after replacing the system app under priv-app with this new signed one nothing was shown after a reboot. tried to install it through es file explorer but it could install.

Anyone know where am i failing?

Edit:

First i used 7zip and then winrar to replace the AndroidManifest.xml & META-INF in the new apk with the files from the original apk but somehow those to programs changed the type of compression and the new apk was much smaller 5Mb and obviously didnt work.

Then i used the windows build in zip feature and it did work fine.
[Android Software Development] td32:
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
[Android Software Development] osebee:
It's very nice guide.

Thank you.
[Android Software Development] D2Y aka E:
Nice sir...I will try
[Android Software Development] t-ryder:
OP, this made my day. Thanks a bunch, now I can manage that stuff on my MiPad and do not need an extra app.

But I realized that app ops does not work for system apps. They turn on permissions again if turned off. Sucks kind of.
[Android Software Development] Hamidreza2010:
Do you have any guide for 4.3?

I need it
[Android Software Development] brainvision:
hey guys do you think this Guide could work on a pretty Lollipop stock 5.1_r1 ROM? I cannot flash Xposed here because of the Intel x86_64 CPU.. :(

EDIT:

well, it worked but AppOps crashes most of the times with most of the apps.. :(
[AT&T Galaxy Note 3 Q&A, Help & Troubleshooting] Arty Dodger:
I am currently rooted with RDLV on version MI1. I am trying to get to MJ5 unrooted at the moment. Although my knowledge is minimal (coming from Jailbreaking Iphone 5s), I am worried something might happen. If I use Odin and "flash" (I think thats the word), couldn't I just "flash" MJ5 without tripping Knox and messing up my phone?

Or should I go to MI9 and use the OTA update?
[Nexus 7 (2013) Q&A] ldmeeds:
I am wanting to find a way to record audio from my police scanner and ham radio onto my tablet. A simple 3.5mm male-to-male jack is what I use on my computer to do this on the "line-in" jack. Is there ANY way to do something like this on the 2013 Nexus 7? The PC software I love is ScanRec, which is not being supported anymore. It only records whenever there is audio inputted through the jack. It can record my entire 8 hour shift of dispatching, and can be compressed into an .mp3 file around an hour in length depending on how busy I am. Pretty cool!

Basically I want to record audio similar to a "line-in" on pc via either the headphone jack (preferably), or an OTG cable.

I don't mind paying around $5-10 for a specialized app if that is what it will take.

I would also willing to pay a bounty to whomever can figure this out 1st!!
[Nexus 7 (2013) Q&A] subhumanderelict:
I think this should be possible; I mean, surely the audio jack can use an earphone/microphone device like any cellphone, so it sound able to handle input, right?

Just to throw an idea out there, have you looked into a 3.5mm-to-Bluetooth transmitter? Maybe you could do this wirelessly.
[Galaxy Tab 3 Q&A, Help & Troubleshooting] 3soteric:
Hey guys, first time poster 3-4 year lurker.

I have a question about my Odin flash that I did last night. I followed these steps http://xdaforums.com/showthread.php?t=2391367

and everything flashed and tablet is working. The only problem I have is when I restart or cold boot the device the screen stays on but with a black screen for about 20 seconds then the screen dims for another 15 seconds after that the screen goes black for another ten seconds. I wait another 10 seconds with the screen black (off) and then I can press the home button and my home screen comes up. The device is rooted and everything seems to working fine.

Power > Samsung splash screen > bright 20s > dim 15s > screen off 15s > wait 10s > home screen comes up. (no sound during this process)

during this process my power, volume and home screen button does not do anything till after I wait 10s after the screen off

I have attempted to re-flash the rom using the same method and even downloaded "prerooted.tar.md5" and the "odin 3.07 from other sources and I still get the same results. I have also download drivers directly form Samsung page, uninstalled, rebooted, re-installed. I have also used different USB ports and I still get the same results. I read a suggetion to try odin 3.09 but I receive a "FAILED" when flashing.

I am using windows 7 pro X64 my tablet is Mo:SM-T210, current kernal 3.4.5-1256430-user, Build JZO54K. T210XXAMG2

unfortunately I have searched for this problem on Google and the forums but nothing I have found fits this description. I am not allowed to post in the dev section due to my lack of post. Hope to hear from you soon and thank you for the years of support you have given me. Hopefully I will be able to be of some use to someone in the future.
[JASJAR, XDA Exec, MDA Pro Software Upgrading] mackaby007:
READ THIS:

http://xdaforums.com/viewtopic.php?t=41204&sid=67d40d1a55945464024342a16e3c9235
[Motorola Droid RAZR] Shopen9:
hi all!

i have problem: when i turn on my Droid first run fastboot mode

so i need first run/turn on boot mode and next Normal Powerup

how to fix to run normaly?
[Motorola Droid RAZR] drissMOTOxt912:
I have the same problem and no one is answering, its driving me crazyyyyyyy:crying:
[Nexus 4 Q&A, Help & Troubleshooting] diegoasis:
I installed android 4.4.2 and i found this change... is it normal or not?

www(dot)freeimagehosting(dot)net/newuploads/hka59.png

Part of the navbar is black
[Nexus 4 Q&A, Help & Troubleshooting] xinseo:
Post links like this:

site(dot)com
[Nexus 4 Q&A, Help & Troubleshooting] diegoasis:
www(dot)freeimagehosting(dot)net/newuploads/hka59.png