summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorke Lee <yorkelee@google.com>2014-11-17 17:43:18 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-11-17 17:43:18 +0000
commit1191766a3e1b4e43b68bba4e7792d913c3e4665d (patch)
tree5c0a70246c72ff95a7b70189bc2c4b6489c53c6a
parent0decca8e703695ff7e44e1ee16c16af622234cd4 (diff)
parent118ca2cc6456a8cdf1be90d0a9d7378c69fa7a62 (diff)
am 118ca2cc: Merge "Move ToneGenerator recreation/release to onStart/onStop" into lmp-mr1-dev
* commit '118ca2cc6456a8cdf1be90d0a9d7378c69fa7a62': Move ToneGenerator recreation/release to onStart/onStop
-rw-r--r--src/com/android/dialer/dialpad/DialpadFragment.java49
1 files changed, 29 insertions, 20 deletions
diff --git a/src/com/android/dialer/dialpad/DialpadFragment.java b/src/com/android/dialer/dialpad/DialpadFragment.java
index 6daa89cd1..321207682 100644
--- a/src/com/android/dialer/dialpad/DialpadFragment.java
+++ b/src/com/android/dialer/dialpad/DialpadFragment.java
@@ -565,6 +565,28 @@ public class DialpadFragment extends Fragment
}
@Override
+ public void onStart() {
+ super.onStart();
+ // if the mToneGenerator creation fails, just continue without it. It is
+ // a local audio signal, and is not as important as the dtmf tone itself.
+ final long start = System.currentTimeMillis();
+ synchronized (mToneGeneratorLock) {
+ if (mToneGenerator == null) {
+ try {
+ mToneGenerator = new ToneGenerator(DIAL_TONE_STREAM_TYPE, TONE_RELATIVE_VOLUME);
+ } catch (RuntimeException e) {
+ Log.w(TAG, "Exception caught while creating local tone generator: " + e);
+ mToneGenerator = null;
+ }
+ }
+ }
+ final long total = System.currentTimeMillis() - start;
+ if (total > 50) {
+ Log.i(TAG, "Time for ToneGenerator creation: " + total);
+ }
+ };
+
+ @Override
public void onResume() {
super.onResume();
@@ -592,20 +614,6 @@ public class DialpadFragment extends Fragment
stopWatch.lap("hptc");
- // if the mToneGenerator creation fails, just continue without it. It is
- // a local audio signal, and is not as important as the dtmf tone itself.
- synchronized (mToneGeneratorLock) {
- if (mToneGenerator == null) {
- try {
- mToneGenerator = new ToneGenerator(DIAL_TONE_STREAM_TYPE, TONE_RELATIVE_VOLUME);
- } catch (RuntimeException e) {
- Log.w(TAG, "Exception caught while creating local tone generator: " + e);
- mToneGenerator = null;
- }
- }
- }
- stopWatch.lap("tg");
-
mPressedDialpadKeys.clear();
configureScreenFromIntent(getActivity());
@@ -657,12 +665,6 @@ public class DialpadFragment extends Fragment
stopTone();
mPressedDialpadKeys.clear();
- synchronized (mToneGeneratorLock) {
- if (mToneGenerator != null) {
- mToneGenerator.release();
- mToneGenerator = null;
- }
- }
// TODO: I wonder if we should not check if the AsyncTask that
// lookup the last dialed number has completed.
mLastNumberDialed = EMPTY_NUMBER; // Since we are going to query again, free stale number.
@@ -674,6 +676,13 @@ public class DialpadFragment extends Fragment
public void onStop() {
super.onStop();
+ synchronized (mToneGeneratorLock) {
+ if (mToneGenerator != null) {
+ mToneGenerator.release();
+ mToneGenerator = null;
+ }
+ }
+
if (mClearDigitsOnStop) {
mClearDigitsOnStop = false;
clearDialpad();