Merge "Fix NPE in Call Forwarding Menu" am: ee39e6e007
am: aa84d8298a
Change-Id: I8ff3f7a861aa64812d362b5d507ff88011f9e257
diff --git a/src/com/android/phone/CallForwardEditPreference.java b/src/com/android/phone/CallForwardEditPreference.java
index 8a82e05..bfeee7a 100644
--- a/src/com/android/phone/CallForwardEditPreference.java
+++ b/src/com/android/phone/CallForwardEditPreference.java
@@ -1,9 +1,7 @@
package com.android.phone;
-import com.android.internal.telephony.CallForwardInfo;
-import com.android.internal.telephony.CommandException;
-import com.android.internal.telephony.CommandsInterface;
-import com.android.internal.telephony.Phone;
+import static com.android.phone.TimeConsumingPreferenceActivity.EXCEPTION_ERROR;
+import static com.android.phone.TimeConsumingPreferenceActivity.RESPONSE_ERROR;
import android.app.AlertDialog;
import android.content.Context;
@@ -24,8 +22,10 @@
import android.util.Log;
import android.view.View;
-import static com.android.phone.TimeConsumingPreferenceActivity.RESPONSE_ERROR;
-import static com.android.phone.TimeConsumingPreferenceActivity.EXCEPTION_ERROR;
+import com.android.internal.telephony.CallForwardInfo;
+import com.android.internal.telephony.CommandException;
+import com.android.internal.telephony.CommandsInterface;
+import com.android.internal.telephony.Phone;
public class CallForwardEditPreference extends EditPhoneNumberPreference {
private static final String LOG_TAG = "CallForwardEditPreference";
@@ -69,22 +69,11 @@
this(context, null);
}
- void init(TimeConsumingPreferenceListener listener, boolean skipReading, Phone phone,
+ void init(TimeConsumingPreferenceListener listener, Phone phone,
boolean replaceInvalidCFNumber) {
mPhone = phone;
mTcpListener = listener;
mReplaceInvalidCFNumber = replaceInvalidCFNumber;
-
- if (!skipReading) {
- mPhone.getCallForwardingOption(reason,
- mHandler.obtainMessage(MyHandler.MESSAGE_GET_CF,
- // unused in this case
- CommandsInterface.CF_ACTION_DISABLE,
- MyHandler.MESSAGE_GET_CF, null));
- if (mTcpListener != null) {
- mTcpListener.onStarted(this, true);
- }
- }
}
@Override
@@ -176,6 +165,23 @@
setPhoneNumber(displayVoicemailNumber ? voicemailNumber : callForwardInfo.number);
}
+ /**
+ * Starts the Call Forwarding Option query to the network and calls
+ * {@link TimeConsumingPreferenceListener#onStarted}. Will call
+ * {@link TimeConsumingPreferenceListener#onFinished} when finished, or
+ * {@link TimeConsumingPreferenceListener#onError} if an error has occurred.
+ */
+ void startCallForwardOptionsQuery() {
+ mPhone.getCallForwardingOption(reason,
+ mHandler.obtainMessage(MyHandler.MESSAGE_GET_CF,
+ // unused in this case
+ CommandsInterface.CF_ACTION_DISABLE,
+ MyHandler.MESSAGE_GET_CF, null));
+ if (mTcpListener != null) {
+ mTcpListener.onStarted(this, true);
+ }
+ }
+
private void updateSummaryText() {
if (isToggled()) {
final String number = getRawPhoneNumber();
diff --git a/src/com/android/phone/GsmUmtsCallForwardOptions.java b/src/com/android/phone/GsmUmtsCallForwardOptions.java
index 77cc6cc..e562e46 100644
--- a/src/com/android/phone/GsmUmtsCallForwardOptions.java
+++ b/src/com/android/phone/GsmUmtsCallForwardOptions.java
@@ -1,9 +1,5 @@
package com.android.phone;
-import com.android.internal.telephony.CallForwardInfo;
-import com.android.internal.telephony.CommandsInterface;
-import com.android.internal.telephony.Phone;
-
import android.app.ActionBar;
import android.content.Intent;
import android.database.Cursor;
@@ -14,8 +10,11 @@
import android.util.Log;
import android.view.MenuItem;
-import java.util.ArrayList;
+import com.android.internal.telephony.CallForwardInfo;
+import com.android.internal.telephony.CommandsInterface;
+import com.android.internal.telephony.Phone;
+import java.util.ArrayList;
public class GsmUmtsCallForwardOptions extends TimeConsumingPreferenceActivity {
private static final String LOG_TAG = "GsmUmtsCallForwardOptions";
@@ -103,7 +102,10 @@
if (mFirstResume) {
if (mIcicle == null) {
Log.d(LOG_TAG, "start to init ");
- mPreferences.get(mInitIndex).init(this, false, mPhone, mReplaceInvalidCFNumbers);
+ CallForwardEditPreference pref = mPreferences.get(mInitIndex);
+ pref.init(this, mPhone, mReplaceInvalidCFNumbers);
+ pref.startCallForwardOptionsQuery();
+
} else {
mInitIndex = mPreferences.size();
@@ -113,8 +115,8 @@
CallForwardInfo cf = new CallForwardInfo();
cf.number = bundle.getString(KEY_NUMBER);
cf.status = bundle.getInt(KEY_STATUS);
+ pref.init(this, mPhone, mReplaceInvalidCFNumbers);
pref.handleCallForwardResult(cf);
- pref.init(this, true, mPhone, mReplaceInvalidCFNumbers);
}
}
mFirstResume = false;
@@ -141,7 +143,9 @@
public void onFinished(Preference preference, boolean reading) {
if (mInitIndex < mPreferences.size()-1 && !isFinishing()) {
mInitIndex++;
- mPreferences.get(mInitIndex).init(this, false, mPhone, mReplaceInvalidCFNumbers);
+ CallForwardEditPreference pref = mPreferences.get(mInitIndex);
+ pref.init(this, mPhone, mReplaceInvalidCFNumbers);
+ pref.startCallForwardOptionsQuery();
}
super.onFinished(preference, reading);