From 91d43cf9c985cc5a83795f256ef5c46ebb8fbdc1 Mon Sep 17 00:00:00 2001 From: Tyler Gunn Date: Wed, 17 Sep 2014 12:19:39 -0700 Subject: 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 --- src/com/android/server/telecom/QuickResponseUtils.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/com/android/server/telecom/QuickResponseUtils.java') diff --git a/src/com/android/server/telecom/QuickResponseUtils.java b/src/com/android/server/telecom/QuickResponseUtils.java index dad2907c..ec77b33e 100644 --- a/src/com/android/server/telecom/QuickResponseUtils.java +++ b/src/com/android/server/telecom/QuickResponseUtils.java @@ -21,6 +21,7 @@ import android.content.SharedPreferences; import android.content.pm.PackageManager; import android.content.res.Resources; +// TODO: Needed for move to system service: import com.android.internal.R; /** * Utils class that exposes some helper routines to used to manage the QuickResponses @@ -48,7 +49,7 @@ public class QuickResponseUtils { * current SharedPreferences. This is a lazy migration as it happens only when * the QuickResponse settings are viewed or if they are queried via RespondViaSmsManager. */ - public static void maybeMigrateLegacyQuickResponses() { + public static void maybeMigrateLegacyQuickResponses(Context context) { // The algorithm will go as such: // If Telecom QuickResponses exist, we will skip migration because this implies // that a user has already specified their desired QuickResponses and have abandoned any @@ -59,11 +60,9 @@ public class QuickResponseUtils { // function is called. Log.d(LOG_TAG, "maybeMigrateLegacyQuickResponses() - Starting"); - - final Context telecomContext = TelecomApp.getInstance(); - final SharedPreferences prefs = telecomContext.getSharedPreferences( + final SharedPreferences prefs = context.getSharedPreferences( SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE); - final Resources res = telecomContext.getResources(); + final Resources res = context.getResources(); final boolean responsesExist = prefs.contains(KEY_CANNED_RESPONSE_PREF_1); if (responsesExist) { @@ -84,7 +83,7 @@ public class QuickResponseUtils { // the Telephony package and we'll fall back on using our default values. Context telephonyContext = null; try { - telephonyContext = telecomContext.createPackageContext(PACKAGE_NAME_TELEPHONY, 0); + telephonyContext = context.createPackageContext(PACKAGE_NAME_TELEPHONY, 0); } catch (PackageManager.NameNotFoundException e) { Log.e(LOG_TAG, e, "maybeMigrateLegacyQuickResponses() - Can't find Telephony package."); } -- cgit v1.2.3