Skip to content

Commit 8f4f814

Browse files
author
Robert Greenwalt
committed
Fix TelephonyManager to grab the best context
It may not be called from an app so the app context may not exist. Check and grab the best one. Also remove the log that nobody paid attention to if the constructor is called again from the same process. One context seems to be as useful as another. bug:5572369 bug:5622514 Change-Id: Iad23b30c7c8fe5b8d1f81a1e060eaf0cd0e3019d
1 parent 258576a commit 8f4f814

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

telephony/java/android/telephony/TelephonyManager.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,16 @@ public class TelephonyManager {
6060

6161
/** @hide */
6262
public TelephonyManager(Context context) {
63-
context = context.getApplicationContext();
6463
if (sContext == null) {
65-
sContext = context;
64+
Context appContext = context.getApplicationContext();
65+
if (appContext != null) {
66+
sContext = appContext;
67+
} else {
68+
sContext = context;
69+
}
6670

6771
sRegistry = ITelephonyRegistry.Stub.asInterface(ServiceManager.getService(
6872
"telephony.registry"));
69-
} else if (sContext != context) {
70-
Log.e(TAG, "Hidden constructor called more than once per process!");
71-
Log.e(TAG, "Original: " + sContext.getPackageName() + ", new: " +
72-
context.getPackageName());
7373
}
7474
}
7575

0 commit comments

Comments
 (0)