Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/ExtQuickSettingsModel.java +56 −9 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ import android.database.ContentObserver; import android.database.Cursor; import android.net.Uri; import android.net.ConnectivityManager; import android.os.AsyncTask; import android.os.Handler; import android.os.SystemProperties; import android.provider.Settings; Loading Loading @@ -353,11 +354,14 @@ class ExtQuickSettingsModel extends QuickSettingsModel { public void startObserving() { final ContentResolver cr = mContext.getContentResolver(); cr.registerContentObserver(Telephony.Carriers.CONTENT_URI, true, this);; cr.registerContentObserver(Telephony.Carriers.CONTENT_URI, true, this); cr.registerContentObserver(Settings.Global.getUriFor( Settings.Global.MULTI_SIM_DEFAULT_DATA_CALL_SUBSCRIPTION), false, this, mUserTracker.getCurrentUserId()); } }; private final ApnObserver mApnObserver; private ApnObserver mApnObserver; private QuickSettingsTileView mApnTile; private RefreshCallback mApnCallback; private ApnState mApnState = new ApnState(); Loading Loading @@ -453,10 +457,10 @@ class ExtQuickSettingsModel extends QuickSettingsModel { public ExtQuickSettingsModel(Context context) { super(context); mContext = context; mApnObserver = new ApnObserver(mHandler); // APN switcher if (mContext.getResources().getBoolean(R.bool.config_showApnSwitch)) { mApnObserver = new ApnObserver(mHandler); mApnObserver.startObserving(); // Register the receiver to handle the sim state changed event. // And caused by if we open the airplane mode, we couldn't receive the sim state Loading Loading @@ -576,6 +580,19 @@ class ExtQuickSettingsModel extends QuickSettingsModel { refreshApnTile(); } void refreshApnTile() { int dataSub = MSimConstants.DEFAULT_SUBSCRIPTION; if (MSimTelephonyManager.getDefault().isMultiSimEnabled()) { MSimTelephonyManager msimTM = (MSimTelephonyManager) mContext.getSystemService(Context.MSIM_TELEPHONY_SERVICE); dataSub = msimTM.getDefaultDataSubscription(); } // Hide APN switch button if DDS is set to non default subscription if (dataSub != MSimConstants.DEFAULT_SUBSCRIPTION) { mApnState.enabled = false; } else { mApnState.enabled = hasIccCard() && !isAirplaneModeOn(); } if (mApnTile != null && mApnCallback != null) { Resources res = mContext.getResources(); if (mApnState.enabled) { Loading Loading @@ -662,6 +679,7 @@ class ExtQuickSettingsModel extends QuickSettingsModel { private QuickSettingsTileView mDdsTile; private RefreshCallback mDdsCallback; private State mDdsState = new State(); private AsyncTask switchDdsAsyncTask = null; protected void addDdsTile(QuickSettingsTileView view, RefreshCallback cb) { mDdsTile = view; mDdsCallback = cb; Loading @@ -688,13 +706,42 @@ class ExtQuickSettingsModel extends QuickSettingsModel { void switchDdsToNext() { Log.d(DDS_TAG, "switchDdsToNext"); if (MSimTelephonyManager.getDefault().isMultiSimEnabled()) { if (!MSimTelephonyManager.getDefault().isMultiSimEnabled()) { return; } if (switchDdsAsyncTask != null && switchDdsAsyncTask.getStatus() != AsyncTask.Status.FINISHED) { Log.d(DDS_TAG, "Dds switch in progress!"); return; } switchDdsAsyncTask = new AsyncTask<Void, Void, Void>() { @Override protected void onPreExecute() { super.onPreExecute(); // Make DDS switch grayed out and while changing subscription if (mDdsTile != null) { mDdsTile.setAlpha(0.5f); mDdsTile.setEnabled(false); } } @Override protected Void doInBackground(Void... params) { MSimTelephonyManager msimTM = (MSimTelephonyManager) mContext.getSystemService(Context.MSIM_TELEPHONY_SERVICE); int dataSub = msimTM.getDefaultDataSubscription(); int phoneCount = msimTM.getPhoneCount(); msimTM.setDefaultDataSubscription((dataSub+1)%phoneCount); return null; } @Override protected void onPostExecute(Void result) { super.onPostExecute(result); if (mDdsTile != null) { mDdsTile.setAlpha(1f); mDdsTile.setEnabled(true); } } }.execute(); } private void updateDds() { Loading Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/ExtQuickSettingsModel.java +56 −9 Original line number Diff line number Diff line Loading @@ -40,6 +40,7 @@ import android.database.ContentObserver; import android.database.Cursor; import android.net.Uri; import android.net.ConnectivityManager; import android.os.AsyncTask; import android.os.Handler; import android.os.SystemProperties; import android.provider.Settings; Loading Loading @@ -353,11 +354,14 @@ class ExtQuickSettingsModel extends QuickSettingsModel { public void startObserving() { final ContentResolver cr = mContext.getContentResolver(); cr.registerContentObserver(Telephony.Carriers.CONTENT_URI, true, this);; cr.registerContentObserver(Telephony.Carriers.CONTENT_URI, true, this); cr.registerContentObserver(Settings.Global.getUriFor( Settings.Global.MULTI_SIM_DEFAULT_DATA_CALL_SUBSCRIPTION), false, this, mUserTracker.getCurrentUserId()); } }; private final ApnObserver mApnObserver; private ApnObserver mApnObserver; private QuickSettingsTileView mApnTile; private RefreshCallback mApnCallback; private ApnState mApnState = new ApnState(); Loading Loading @@ -453,10 +457,10 @@ class ExtQuickSettingsModel extends QuickSettingsModel { public ExtQuickSettingsModel(Context context) { super(context); mContext = context; mApnObserver = new ApnObserver(mHandler); // APN switcher if (mContext.getResources().getBoolean(R.bool.config_showApnSwitch)) { mApnObserver = new ApnObserver(mHandler); mApnObserver.startObserving(); // Register the receiver to handle the sim state changed event. // And caused by if we open the airplane mode, we couldn't receive the sim state Loading Loading @@ -576,6 +580,19 @@ class ExtQuickSettingsModel extends QuickSettingsModel { refreshApnTile(); } void refreshApnTile() { int dataSub = MSimConstants.DEFAULT_SUBSCRIPTION; if (MSimTelephonyManager.getDefault().isMultiSimEnabled()) { MSimTelephonyManager msimTM = (MSimTelephonyManager) mContext.getSystemService(Context.MSIM_TELEPHONY_SERVICE); dataSub = msimTM.getDefaultDataSubscription(); } // Hide APN switch button if DDS is set to non default subscription if (dataSub != MSimConstants.DEFAULT_SUBSCRIPTION) { mApnState.enabled = false; } else { mApnState.enabled = hasIccCard() && !isAirplaneModeOn(); } if (mApnTile != null && mApnCallback != null) { Resources res = mContext.getResources(); if (mApnState.enabled) { Loading Loading @@ -662,6 +679,7 @@ class ExtQuickSettingsModel extends QuickSettingsModel { private QuickSettingsTileView mDdsTile; private RefreshCallback mDdsCallback; private State mDdsState = new State(); private AsyncTask switchDdsAsyncTask = null; protected void addDdsTile(QuickSettingsTileView view, RefreshCallback cb) { mDdsTile = view; mDdsCallback = cb; Loading @@ -688,13 +706,42 @@ class ExtQuickSettingsModel extends QuickSettingsModel { void switchDdsToNext() { Log.d(DDS_TAG, "switchDdsToNext"); if (MSimTelephonyManager.getDefault().isMultiSimEnabled()) { if (!MSimTelephonyManager.getDefault().isMultiSimEnabled()) { return; } if (switchDdsAsyncTask != null && switchDdsAsyncTask.getStatus() != AsyncTask.Status.FINISHED) { Log.d(DDS_TAG, "Dds switch in progress!"); return; } switchDdsAsyncTask = new AsyncTask<Void, Void, Void>() { @Override protected void onPreExecute() { super.onPreExecute(); // Make DDS switch grayed out and while changing subscription if (mDdsTile != null) { mDdsTile.setAlpha(0.5f); mDdsTile.setEnabled(false); } } @Override protected Void doInBackground(Void... params) { MSimTelephonyManager msimTM = (MSimTelephonyManager) mContext.getSystemService(Context.MSIM_TELEPHONY_SERVICE); int dataSub = msimTM.getDefaultDataSubscription(); int phoneCount = msimTM.getPhoneCount(); msimTM.setDefaultDataSubscription((dataSub+1)%phoneCount); return null; } @Override protected void onPostExecute(Void result) { super.onPostExecute(result); if (mDdsTile != null) { mDdsTile.setAlpha(1f); mDdsTile.setEnabled(true); } } }.execute(); } private void updateDds() { Loading