summaryrefslogtreecommitdiffstats
path: root/telephony/java
diff options
context:
space:
mode:
authorRobert Greenwalt <rgreenwalt@google.com>2011-02-02 13:22:33 -0800
committerAndroid Git Automerger <android-git-automerger@android.com>2011-02-02 13:22:33 -0800
commitadf851755ff8ca50e1023601fff1cb595d86fbc1 (patch)
tree3779ea632bd9d29797b845379a4baaa0d2a83593 /telephony/java
parent8930a1259dccd3d0639e74d7a9125f1f968dc65f (diff)
parent746ef9b8f0c080e247c6726b294fa2ab5cf53dac (diff)
downloadframeworks_base-adf851755ff8ca50e1023601fff1cb595d86fbc1.zip
frameworks_base-adf851755ff8ca50e1023601fff1cb595d86fbc1.tar.gz
frameworks_base-adf851755ff8ca50e1023601fff1cb595d86fbc1.tar.bz2
am 746ef9b8: am 2c507b92: Merge "Use a cached context when possible." into honeycomb
* commit '746ef9b8f0c080e247c6726b294fa2ab5cf53dac': Use a cached context when possible.
Diffstat (limited to 'telephony/java')
-rw-r--r--telephony/java/android/telephony/TelephonyManager.java29
1 files changed, 20 insertions, 9 deletions
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index b0f0a43..821e39f 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -23,6 +23,7 @@ import android.os.Bundle;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SystemProperties;
+import android.util.Log;
import com.android.internal.telephony.IPhoneSubInfo;
import com.android.internal.telephony.ITelephony;
@@ -55,14 +56,21 @@ import java.util.List;
public class TelephonyManager {
private static final String TAG = "TelephonyManager";
- private Context mContext;
- private ITelephonyRegistry mRegistry;
+ private static Context sContext;
+ private static ITelephonyRegistry sRegistry;
/** @hide */
public TelephonyManager(Context context) {
- mContext = context;
- mRegistry = ITelephonyRegistry.Stub.asInterface(ServiceManager.getService(
+ if (sContext == null) {
+ sContext = context;
+
+ sRegistry = ITelephonyRegistry.Stub.asInterface(ServiceManager.getService(
"telephony.registry"));
+ } else {
+ Log.e(TAG, "Hidden constructor called more than once per process!");
+ Log.e(TAG, "Original: " + sContext.getPackageName() + ", new: " +
+ context.getPackageName());
+ }
}
/** @hide */
@@ -71,7 +79,8 @@ public class TelephonyManager {
private static TelephonyManager sInstance = new TelephonyManager();
- /** @hide */
+ /** @hide
+ /* @deprecated - use getSystemService as described above */
public static TelephonyManager getDefault() {
return sInstance;
}
@@ -889,10 +898,10 @@ public class TelephonyManager {
* LISTEN_ flags.
*/
public void listen(PhoneStateListener listener, int events) {
- String pkgForDebug = mContext != null ? mContext.getPackageName() : "<unknown>";
+ String pkgForDebug = sContext != null ? sContext.getPackageName() : "<unknown>";
try {
Boolean notifyNow = (getITelephony() != null);
- mRegistry.listen(pkgForDebug, listener.callback, events, notifyNow);
+ sRegistry.listen(pkgForDebug, listener.callback, events, notifyNow);
} catch (RemoteException ex) {
// system process dead
} catch (NullPointerException ex) {
@@ -967,7 +976,8 @@ public class TelephonyManager {
* @hide pending API review
*/
public boolean isVoiceCapable() {
- return mContext.getResources().getBoolean(
+ if (sContext == null) return true;
+ return sContext.getResources().getBoolean(
com.android.internal.R.bool.config_voice_capable);
}
@@ -983,7 +993,8 @@ public class TelephonyManager {
* @hide pending API review
*/
public boolean isSmsCapable() {
- return mContext.getResources().getBoolean(
+ if (sContext == null) return true;
+ return sContext.getResources().getBoolean(
com.android.internal.R.bool.config_sms_capable);
}
}