Fix for the toggle airplane mode hidden API
Fix to https://googleplex-android-review.git.corp.google.com/#/c/356900/ Previous implementation throws SecurityException when the API is called from apps. bug:10653570 Change-Id: I95ae6f07db74d881f1a8d3d40a6486105a068e90
This commit is contained in:
@@ -4684,12 +4684,12 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
@Override
|
@Override
|
||||||
public void setAirplaneMode(boolean enable) {
|
public void setAirplaneMode(boolean enable) {
|
||||||
enforceConnectivityInternalPermission();
|
enforceConnectivityInternalPermission();
|
||||||
final ContentResolver cr = mContext.getContentResolver();
|
|
||||||
Settings.Global.putInt(cr, Settings.Global.AIRPLANE_MODE_ON, enable ? 1 : 0);
|
|
||||||
Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
|
|
||||||
intent.putExtra("state", enable);
|
|
||||||
final long ident = Binder.clearCallingIdentity();
|
final long ident = Binder.clearCallingIdentity();
|
||||||
try {
|
try {
|
||||||
|
final ContentResolver cr = mContext.getContentResolver();
|
||||||
|
Settings.Global.putInt(cr, Settings.Global.AIRPLANE_MODE_ON, enable ? 1 : 0);
|
||||||
|
Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
|
||||||
|
intent.putExtra("state", enable);
|
||||||
mContext.sendBroadcast(intent);
|
mContext.sendBroadcast(intent);
|
||||||
} finally {
|
} finally {
|
||||||
Binder.restoreCallingIdentity(ident);
|
Binder.restoreCallingIdentity(ident);
|
||||||
|
|||||||
Reference in New Issue
Block a user