Phone refactor (merging Gsm and Cdma phones)
Bug: 25793157
Change-Id: I8539846dcb8a3a8971616e63aa8b373ab1032259
diff --git a/src/com/android/phone/EmergencyCallbackModeService.java b/src/com/android/phone/EmergencyCallbackModeService.java
index 3310df1..997be83 100644
--- a/src/com/android/phone/EmergencyCallbackModeService.java
+++ b/src/com/android/phone/EmergencyCallbackModeService.java
@@ -35,7 +35,6 @@
import android.os.SystemProperties;
import android.util.Log;
-import com.android.internal.telephony.cdma.CDMAPhone;
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneConstants;
import com.android.internal.telephony.PhoneFactory;
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index d152e22..6f828db 100644
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -2457,14 +2457,20 @@
public String getLine1NumberForDisplay(int subId, String callingPackage) {
// This is open to apps with WRITE_SMS.
if (!canReadPhoneNumber(callingPackage, "getLine1NumberForDisplay")) {
+ if (DBG_MERGE) log("getLine1NumberForDisplay returning null due to permission");
return null;
}
String iccId = getIccId(subId);
if (iccId != null) {
String numberPrefKey = PREF_CARRIERS_NUMBER_PREFIX + iccId;
+ if (DBG_MERGE) {
+ log("getLine1NumberForDisplay returning " +
+ mTelephonySharedPreferences.getString(numberPrefKey, null));
+ }
return mTelephonySharedPreferences.getString(numberPrefKey, null);
}
+ if (DBG_MERGE) log("getLine1NumberForDisplay returning null as iccId is null");
return null;
}
diff --git a/src/com/android/services/telephony/PstnIncomingCallNotifier.java b/src/com/android/services/telephony/PstnIncomingCallNotifier.java
index 5f64f6d..194cb95 100644
--- a/src/com/android/services/telephony/PstnIncomingCallNotifier.java
+++ b/src/com/android/services/telephony/PstnIncomingCallNotifier.java
@@ -27,14 +27,13 @@
import android.os.Message;
import android.telecom.PhoneAccount;
import android.telecom.TelecomManager;
-import android.telephony.TelephonyManager;
import android.text.TextUtils;
import com.android.internal.telephony.Call;
import com.android.internal.telephony.Connection;
import com.android.internal.telephony.Phone;
+import com.android.internal.telephony.PhoneBase;
import com.android.internal.telephony.PhoneConstants;
-import com.android.internal.telephony.PhoneProxy;
import com.android.internal.telephony.TelephonyIntents;
import com.android.internal.telephony.cdma.CdmaCallWaitingNotification;
import com.android.phone.PhoneUtils;
@@ -53,8 +52,8 @@
private static final int EVENT_CDMA_CALL_WAITING = 101;
private static final int EVENT_UNKNOWN_CONNECTION = 102;
- /** The phone proxy object to listen to. */
- private final PhoneProxy mPhoneProxy;
+ /** The phone object to listen to. */
+ private final PhoneBase mPhone;
/**
* The base phone implementation behind phone proxy. The underlying phone implementation can
@@ -105,23 +104,23 @@
/**
* Persists the specified parameters and starts listening to phone events.
*
- * @param phoneProxy The phone object for listening to incoming calls.
+ * @param phone The phone object for listening to incoming calls.
*/
- PstnIncomingCallNotifier(PhoneProxy phoneProxy) {
- Preconditions.checkNotNull(phoneProxy);
+ PstnIncomingCallNotifier(PhoneBase phone) {
+ Preconditions.checkNotNull(phone);
- mPhoneProxy = phoneProxy;
+ mPhone = phone;
registerForNotifications();
IntentFilter intentFilter =
new IntentFilter(TelephonyIntents.ACTION_RADIO_TECHNOLOGY_CHANGED);
- mPhoneProxy.getContext().registerReceiver(mRATReceiver, intentFilter);
+ mPhone.getContext().registerReceiver(mRATReceiver, intentFilter);
}
void teardown() {
unregisterForNotifications();
- mPhoneProxy.getContext().unregisterReceiver(mRATReceiver);
+ mPhone.getContext().unregisterReceiver(mRATReceiver);
}
/**
@@ -135,7 +134,7 @@
* change in opt/telephony code.
*/
private void registerForNotifications() {
- Phone newPhone = mPhoneProxy.getActivePhone();
+ Phone newPhone = mPhone;
if (newPhone != mPhoneBase) {
unregisterForNotifications();
@@ -230,8 +229,8 @@
Uri uri = Uri.fromParts(PhoneAccount.SCHEME_TEL, connection.getAddress(), null);
extras.putParcelable(TelecomManager.EXTRA_UNKNOWN_CALL_HANDLE, uri);
}
- TelecomManager.from(mPhoneProxy.getContext()).addNewUnknownCall(
- PhoneUtils.makePstnPhoneAccountHandle(mPhoneProxy), extras);
+ TelecomManager.from(mPhone.getContext()).addNewUnknownCall(
+ PhoneUtils.makePstnPhoneAccountHandle(mPhone), extras);
} else {
Log.i(this, "swapped an old connection, new one is: %s", connection);
}
@@ -248,8 +247,8 @@
Uri uri = Uri.fromParts(PhoneAccount.SCHEME_TEL, connection.getAddress(), null);
extras.putParcelable(TelecomManager.EXTRA_INCOMING_CALL_ADDRESS, uri);
}
- TelecomManager.from(mPhoneProxy.getContext()).addNewIncomingCall(
- PhoneUtils.makePstnPhoneAccountHandle(mPhoneProxy), extras);
+ TelecomManager.from(mPhone.getContext()).addNewIncomingCall(
+ PhoneUtils.makePstnPhoneAccountHandle(mPhone), extras);
}
/**
diff --git a/src/com/android/services/telephony/PstnPhoneCapabilitiesNotifier.java b/src/com/android/services/telephony/PstnPhoneCapabilitiesNotifier.java
index 7a2adf1..3deb6ca 100644
--- a/src/com/android/services/telephony/PstnPhoneCapabilitiesNotifier.java
+++ b/src/com/android/services/telephony/PstnPhoneCapabilitiesNotifier.java
@@ -28,8 +28,8 @@
import android.telecom.TelecomManager;
import com.android.internal.telephony.Phone;
+import com.android.internal.telephony.PhoneBase;
import com.android.internal.telephony.PhoneConstants;
-import com.android.internal.telephony.PhoneProxy;
import com.android.internal.telephony.TelephonyIntents;
import com.android.internal.util.Preconditions;
import com.android.phone.PhoneUtils;
@@ -48,9 +48,8 @@
public void onVideoCapabilitiesChanged(boolean isVideoCapable);
}
- private final PhoneProxy mPhoneProxy;
+ private final PhoneBase mPhone;
private final Listener mListener;
- private Phone mPhoneBase;
private final Handler mHandler = new Handler() {
@Override
@@ -65,57 +64,33 @@
}
};
- private final BroadcastReceiver mRatReceiver = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- String action = intent.getAction();
- if (TelephonyIntents.ACTION_RADIO_TECHNOLOGY_CHANGED.equals(action)) {
- String newPhone = intent.getStringExtra(PhoneConstants.PHONE_NAME_KEY);
- Log.d(this, "Radio technology switched. Now %s is active.", newPhone);
-
- registerForNotifications();
- }
- }
- };
-
/*package*/
- PstnPhoneCapabilitiesNotifier(PhoneProxy phoneProxy, Listener listener) {
- Preconditions.checkNotNull(phoneProxy);
+ PstnPhoneCapabilitiesNotifier(PhoneBase phone, Listener listener) {
+ Preconditions.checkNotNull(phone);
- mPhoneProxy = phoneProxy;
+ mPhone = phone;
mListener = listener;
registerForNotifications();
-
- IntentFilter intentFilter =
- new IntentFilter(TelephonyIntents.ACTION_RADIO_TECHNOLOGY_CHANGED);
- mPhoneProxy.getContext().registerReceiver(mRatReceiver, intentFilter);
}
/*package*/
void teardown() {
unregisterForNotifications();
- mPhoneProxy.getContext().unregisterReceiver(mRatReceiver);
}
private void registerForNotifications() {
- Phone newPhone = mPhoneProxy.getActivePhone();
- if (newPhone != mPhoneBase) {
- unregisterForNotifications();
-
- if (newPhone != null) {
- Log.d(this, "Registering: " + newPhone);
- mPhoneBase = newPhone;
- mPhoneBase.registerForVideoCapabilityChanged(
- mHandler, EVENT_VIDEO_CAPABILITIES_CHANGED, null);
- }
+ if (mPhone != null) {
+ Log.d(this, "Registering: " + mPhone);
+ mPhone.registerForVideoCapabilityChanged(mHandler, EVENT_VIDEO_CAPABILITIES_CHANGED,
+ null);
}
}
private void unregisterForNotifications() {
- if (mPhoneBase != null) {
- Log.d(this, "Unregistering: " + mPhoneBase);
- mPhoneBase.unregisterForVideoCapabilityChanged(mHandler);
+ if (mPhone != null) {
+ Log.d(this, "Unregistering: " + mPhone);
+ mPhone.unregisterForVideoCapabilityChanged(mHandler);
}
}
@@ -124,9 +99,9 @@
boolean isVideoCapable = (Boolean) ar.result;
Log.d(this, "handleVideoCapabilitesChanged. Video capability - " + isVideoCapable);
PhoneAccountHandle accountHandle =
- PhoneUtils.makePstnPhoneAccountHandle(mPhoneProxy);
+ PhoneUtils.makePstnPhoneAccountHandle(mPhone);
- TelecomManager telecomMgr = TelecomManager.from(mPhoneProxy.getContext());
+ TelecomManager telecomMgr = TelecomManager.from(mPhone.getContext());
PhoneAccount oldPhoneAccount = telecomMgr.getPhoneAccount(accountHandle);
PhoneAccount.Builder builder = new PhoneAccount.Builder(oldPhoneAccount);
diff --git a/src/com/android/services/telephony/TelecomAccountRegistry.java b/src/com/android/services/telephony/TelecomAccountRegistry.java
index c1224fc..aeb433c 100644
--- a/src/com/android/services/telephony/TelecomAccountRegistry.java
+++ b/src/com/android/services/telephony/TelecomAccountRegistry.java
@@ -41,8 +41,8 @@
import android.text.TextUtils;
import com.android.internal.telephony.Phone;
+import com.android.internal.telephony.PhoneBase;
import com.android.internal.telephony.PhoneFactory;
-import com.android.internal.telephony.PhoneProxy;
import com.android.phone.PhoneGlobals;
import com.android.phone.PhoneUtils;
import com.android.phone.R;
@@ -76,8 +76,8 @@
mAccount = registerPstnPhoneAccount(isEmergency, isDummy);
Log.i(this, "Registered phoneAccount: %s with handle: %s",
mAccount, mAccount.getAccountHandle());
- mIncomingCallNotifier = new PstnIncomingCallNotifier((PhoneProxy) mPhone);
- mPhoneCapabilitiesNotifier = new PstnPhoneCapabilitiesNotifier((PhoneProxy) mPhone,
+ mIncomingCallNotifier = new PstnIncomingCallNotifier((PhoneBase) mPhone);
+ mPhoneCapabilitiesNotifier = new PstnPhoneCapabilitiesNotifier((PhoneBase) mPhone,
this);
}
diff --git a/src/com/android/services/telephony/TelephonyConferenceController.java b/src/com/android/services/telephony/TelephonyConferenceController.java
index a1782bb..7da9ea5 100644
--- a/src/com/android/services/telephony/TelephonyConferenceController.java
+++ b/src/com/android/services/telephony/TelephonyConferenceController.java
@@ -34,8 +34,6 @@
import com.android.phone.PhoneUtils;
import com.android.internal.telephony.Call;
-import com.android.internal.telephony.gsm.GsmConnection;
-import com.android.internal.telephony.imsphone.ImsPhoneConnection;
/**
* Maintains a list of all the known TelephonyConnections connections and controls GSM and
diff --git a/src/com/android/services/telephony/TelephonyConnectionService.java b/src/com/android/services/telephony/TelephonyConnectionService.java
index e2d3832..5d82f28 100644
--- a/src/com/android/services/telephony/TelephonyConnectionService.java
+++ b/src/com/android/services/telephony/TelephonyConnectionService.java
@@ -41,9 +41,7 @@
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneConstants;
import com.android.internal.telephony.PhoneFactory;
-import com.android.internal.telephony.PhoneProxy;
import com.android.internal.telephony.SubscriptionController;
-import com.android.internal.telephony.cdma.CDMAPhone;
import com.android.phone.MMIDialogActivity;
import com.android.phone.PhoneUtils;
import com.android.phone.R;
@@ -585,12 +583,8 @@
// For CDMA phones, check if we are in Emergency Callback Mode (ECM). Mute is disallowed
// in ECM mode.
if (phone.getPhoneType() == TelephonyManager.PHONE_TYPE_CDMA) {
- PhoneProxy phoneProxy = (PhoneProxy)phone;
- CDMAPhone cdmaPhone = (CDMAPhone)phoneProxy.getActivePhone();
- if (cdmaPhone != null) {
- if (cdmaPhone.isInEcm()) {
- return false;
- }
+ if (phone.isInEcm()) {
+ return false;
}
}