Use PhoneProxy instead of creating new Phone types.
Original change that added CachedPhoneFactory: 50037868e3d7e9a3af7b09bc8bb1ae88c77dd633
PhoneProxy is a better instance to use than cached phone objects.
Bug: 15015329
Change-Id: I544cf946408390ff1fa3d1514cf1597818525d65
diff --git a/src/com/android/services/telephony/CachedPhoneFactory.java b/src/com/android/services/telephony/CachedPhoneFactory.java
deleted file mode 100644
index 34a1fc0..0000000
--- a/src/com/android/services/telephony/CachedPhoneFactory.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.services.telephony;
-
-import com.android.internal.telephony.Phone;
-import com.android.internal.telephony.PhoneFactory;
-
-/**
- * Creates and caches phone objects for use with call services. Incoming call listening and the call
- * service itself exist independently (and across threads) but need to share their references to the
- * {@link Phone} objects that they use. This class is used to provide those cached references.
- * TODO(santoscordon): Investigate if this functionality can be folded into PhoneFactory once
- * PhoneFactory is no longer being used by the old system.
- */
-class CachedPhoneFactory {
- private static Phone sCdmaPhone;
- private static Phone sGsmPhone;
-
- /**
- * @return The GSM Phone instance.
- */
- public static synchronized Phone getGsmPhone() {
- if (sGsmPhone == null) {
- sGsmPhone = PhoneFactory.getGsmPhone();
- }
- return sGsmPhone;
- }
-
- /**
- * @return The CDMA Phone instance.
- */
- public static synchronized Phone getCdmaPhone() {
- if (sCdmaPhone == null) {
- sCdmaPhone = PhoneFactory.getCdmaPhone();
- }
- return sCdmaPhone;
- }
-}
diff --git a/src/com/android/services/telephony/CdmaConnectionService.java b/src/com/android/services/telephony/CdmaConnectionService.java
index 06add1b..792de70 100644
--- a/src/com/android/services/telephony/CdmaConnectionService.java
+++ b/src/com/android/services/telephony/CdmaConnectionService.java
@@ -22,6 +22,7 @@
import com.android.internal.telephony.Connection;
import com.android.internal.telephony.Phone;
+import com.android.internal.telephony.PhoneFactory;
import com.android.phone.Constants;
import com.android.services.telecomm.ConnectionRequest;
@@ -33,7 +34,7 @@
/** {@inheritDoc} */
@Override
protected Phone getPhone() {
- return CachedPhoneFactory.getCdmaPhone();
+ return PhoneFactory.getDefaultPhone();
}
/** {@inheritDoc} */
diff --git a/src/com/android/services/telephony/GsmConnectionService.java b/src/com/android/services/telephony/GsmConnectionService.java
index bf4fe7d..e29f9e2 100644
--- a/src/com/android/services/telephony/GsmConnectionService.java
+++ b/src/com/android/services/telephony/GsmConnectionService.java
@@ -22,6 +22,7 @@
import com.android.internal.telephony.Connection;
import com.android.internal.telephony.Phone;
+import com.android.internal.telephony.PhoneFactory;
import com.android.phone.Constants;
import com.android.services.telecomm.ConnectionRequest;
@@ -32,7 +33,7 @@
/** {@inheritDoc} */
@Override
protected Phone getPhone() {
- return CachedPhoneFactory.getGsmPhone();
+ return PhoneFactory.getDefaultPhone();
}
/** {@inheritDoc} */
diff --git a/src/com/android/services/telephony/TelephonyGlobals.java b/src/com/android/services/telephony/TelephonyGlobals.java
index 8ca7e03..2830e26 100644
--- a/src/com/android/services/telephony/TelephonyGlobals.java
+++ b/src/com/android/services/telephony/TelephonyGlobals.java
@@ -66,12 +66,12 @@
if (TelephonyManager.PHONE_TYPE_GSM == phoneType) {
Log.d(this, "Phone type GSM found");
mGsmIncomingCallNotifier = new IncomingCallNotifier(
- GsmConnectionService.class, CachedPhoneFactory.getGsmPhone());
+ GsmConnectionService.class, PhoneFactory.getDefaultPhone());
} else if (TelephonyManager.PHONE_TYPE_CDMA == phoneType) {
Log.d(this, "Phone type CDMA found");
mCdmaIncomingCallNotifier = new IncomingCallNotifier(
- CdmaConnectionService.class, CachedPhoneFactory.getCdmaPhone());
+ CdmaConnectionService.class, PhoneFactory.getDefaultPhone());
}
// TODO(santoscordon): Do SIP. SIP will require a slightly different solution since it