Turning on/off Airplane mode as system app

ohan

New member
Apr 5, 2011
1
0
0
Visit site
Hi,

I've encountered a very strange problem for programmatically turning on/off the airplane mode.
I'm aware that it's one of the secure settings, and my app is a system app that is correctly signed.

However, I'm not able to correctly turn on/off the airplane mode.
I have the following codes: (checked value is from onCheckedChanged callback of a check box UI)

int isAirplaneModeOn = checked ? 1 : 0;
Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.AIRPLANE_MODE_ON, isAirplaneModeOn);
Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
intent.putExtra("state", checked);
mContext.sendBroadcast(intent);

The line where it calls Settings.Global.putInt(....) works, because we can see that the airplane mode's check box in the android's settings app will changes as we change this value from our app, so we know that our app is indeed a system app. Otherwise, it will throw a SecurityException at this line.

However, we're getting "Permission Denial: not allowed to send broadcast android.intent.action.AIRPLANE_MODE", at the line where it calls mContext.sendBroadcast(...). I have no idea why this fails while Settings.Global.putInt works.

One last note is that we're using Android 4.4.2 (KitKat).

Any help will be appreciated

Thanks
 

Forum statistics

Threads
943,148
Messages
6,917,519
Members
3,158,847
Latest member
fallingOutOfLoveWfithTech