How to read app's Privacy Guard status (Rom/AppOps integrated version)

Search This thread

brainflakes

Member
May 8, 2013
12
9
Hi guys, I've recently started a personal project to extend the Privacy Guard feature of several custom roms to block certain methods of READ_PHONE_STATE when enabled (eg. getLine1Number)

Since I last looked at the Privacy Guard code it seems to have been integrated into the AppOpsService, and I'm at a loss as how to read the privacy guard status of an app inside framework code to block specific framework methods (blocking the READ_PHONE_STATE permission entirely isn't desirable as there are genuinely useful methods such as detecting phone calls etc)

Given the application context (context.getApplicationContext()) is available in the TelephonyManager class I should be able to check whether privacy guard is enabled for that app in methods I'd like to mask, but I don't know app ops well enough to do this. Does anyone have any examples or pointers? Thanks!

I'm currently working with the Simroms KitKat source, but IIRC the Privacy Guard code was merged from CM.