Fix possible ANR in com.android.phone
Creating a tone generator can potentially take a very long time in
native code. Since SignalInfo tones are played only for CDMA phones
(and rarely), instead of creating one everytime Telephony starts up,
which can cause ANRs, delay the creation to a background thread and
make it on-demand.
Bug: 17862188
Bug: 12135722
Change-Id: I0a51a178b3c3590c95d1799d141861ac83e4a9f8
diff --git a/src/com/android/phone/CallNotifier.java b/src/com/android/phone/CallNotifier.java
index be1e3b2..f22913c 100644
--- a/src/com/android/phone/CallNotifier.java
+++ b/src/com/android/phone/CallNotifier.java
@@ -142,8 +142,6 @@
callStateMonitor.addListener(this);
- createSignalInfoToneGenerator();
-
BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
if (adapter != null) {
adapter.getProfileProxy(mApplication.getApplicationContext(),
@@ -944,7 +942,7 @@
@Override
public void run() {
log("SignalInfoTonePlayer.run(toneId = " + mToneId + ")...");
-
+ createSignalInfoToneGenerator();
if (mSignalInfoToneGenerator != null) {
//First stop any ongoing SignalInfo tone
mSignalInfoToneGenerator.stopTone();