From 6b8ef174a7164829f9632340a1661297a31ce250 Mon Sep 17 00:00:00 2001 From: Eiichi Ohnishi Date: Tue, 4 Feb 2014 19:43:56 +0900 Subject: [PATCH] Fix can't change airplane mode from GlobalActions. A PhoneStateListener is registered in the constructor of GlobalActions which, on rare occasions, leads to a callback being received immediately. In these cases because mHasTelephony has not been initialized, airplane mode is not refreshed in the callback which disables the option to set airplane mode from GlobalActions. To fix this issue mHasTelephony has to be set before registering the listener. Change-Id: If117a879d3244414b369a1711bf46526b7a5ae24 --- .../com/android/internal/policy/impl/GlobalActions.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/policy/src/com/android/internal/policy/impl/GlobalActions.java b/policy/src/com/android/internal/policy/impl/GlobalActions.java index 7c0735bbfe023..4db7d4d9563dd 100644 --- a/policy/src/com/android/internal/policy/impl/GlobalActions.java +++ b/policy/src/com/android/internal/policy/impl/GlobalActions.java @@ -121,13 +121,14 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac filter.addAction(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED); context.registerReceiver(mBroadcastReceiver, filter); + ConnectivityManager cm = (ConnectivityManager) + context.getSystemService(Context.CONNECTIVITY_SERVICE); + mHasTelephony = cm.isNetworkSupported(ConnectivityManager.TYPE_MOBILE); + // get notified of phone state changes TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); telephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_SERVICE_STATE); - ConnectivityManager cm = (ConnectivityManager) - context.getSystemService(Context.CONNECTIVITY_SERVICE); - mHasTelephony = cm.isNetworkSupported(ConnectivityManager.TYPE_MOBILE); mContext.getContentResolver().registerContentObserver( Settings.Global.getUriFor(Settings.Global.AIRPLANE_MODE_ON), true, mAirplaneModeObserver);