Preparatory work to move Telecom to system service.

- Removed use of TelecomApp.getInstance() as context.
- Refactored singleton logic and initialization to support being
performed from a SystemService.
- Note: You will see some commented out references to
"import com.android.internal.R"; these must uncommented when the code
is moved to a system service.
- You will also notice in PhoneAccountRegistrar.java a comment block with:
"UNCOMMENT_FOR_MOVE_TO_SYSTEM_SERVICE"
The code in that comment block will replace the existing file path
code.
These were added as a convenience so that I can run a simple sed script
to make the required changes to the code in an automated manner once it
is moved to its new location.

Bug: 17364651
Change-Id: I8e80e9cffc481b688c10a2bca0b59f5ccf8e0fb2
diff --git a/src/com/android/server/telecom/DtmfLocalTonePlayer.java b/src/com/android/server/telecom/DtmfLocalTonePlayer.java
index eb3f9a0..6b4b74d 100644
--- a/src/com/android/server/telecom/DtmfLocalTonePlayer.java
+++ b/src/com/android/server/telecom/DtmfLocalTonePlayer.java
@@ -16,10 +16,12 @@
 
 package com.android.server.telecom;
 
+import android.content.Context;
 import android.media.AudioManager;
 import android.media.ToneGenerator;
 import android.provider.Settings;
 
+// TODO: Needed for move to system service: import com.android.internal.R;
 import com.google.common.collect.ImmutableMap;
 
 import java.util.Map;
@@ -53,6 +55,13 @@
     /** The current call associated with an existing dtmf session. */
     private Call mCall;
 
+    /** The context. */
+    private final Context mContext;
+
+    public DtmfLocalTonePlayer(Context context) {
+        mContext = context;
+    }
+
     /** {@inheritDoc} */
     @Override
     public void onForegroundCallChanged(Call oldForegroundCall, Call newForegroundCall) {
@@ -110,12 +119,11 @@
         if (call == null) {
             return;
         }
-        TelecomApp app = TelecomApp.getInstance();
-
+        final Context context = call.getContext();
         final boolean areLocalTonesEnabled;
-        if (app.getResources().getBoolean(R.bool.allow_local_dtmf_tones)) {
+        if (context.getResources().getBoolean(R.bool.allow_local_dtmf_tones)) {
             areLocalTonesEnabled = Settings.System.getInt(
-                    app.getContentResolver(), Settings.System.DTMF_TONE_WHEN_DIALING, 1) == 1;
+                    context.getContentResolver(), Settings.System.DTMF_TONE_WHEN_DIALING, 1) == 1;
         } else {
             areLocalTonesEnabled = false;
         }