Adding a utility method for getting device prefs

Change-Id: I1e3c7df0a3f4e847b40d722d44890e441cc73509
diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java
index ffda67c..d48b9ab 100644
--- a/src/com/android/launcher3/Utilities.java
+++ b/src/com/android/launcher3/Utilities.java
@@ -551,6 +551,11 @@
                 LauncherFiles.SHARED_PREFERENCES_KEY, Context.MODE_PRIVATE);
     }
 
+    public static SharedPreferences getDevicePrefs(Context context) {
+        return context.getSharedPreferences(
+                LauncherFiles.DEVICE_PREFERENCES_KEY, Context.MODE_PRIVATE);
+    }
+
     public static boolean isPowerSaverOn(Context context) {
         PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
         return powerManager.isPowerSaveMode();
diff --git a/src/com/android/launcher3/compat/WallpaperManagerCompatVL.java b/src/com/android/launcher3/compat/WallpaperManagerCompatVL.java
index 3431664..d61b564 100644
--- a/src/com/android/launcher3/compat/WallpaperManagerCompatVL.java
+++ b/src/com/android/launcher3/compat/WallpaperManagerCompatVL.java
@@ -17,6 +17,8 @@
 
 import static android.app.WallpaperManager.FLAG_SYSTEM;
 
+import static com.android.launcher3.Utilities.getDevicePrefs;
+
 import android.app.IntentService;
 import android.app.WallpaperInfo;
 import android.app.WallpaperManager;
@@ -24,7 +26,6 @@
 import android.content.Context;
 import android.content.Intent;
 import android.content.IntentFilter;
-import android.content.SharedPreferences;
 import android.graphics.Bitmap;
 import android.graphics.BitmapFactory;
 import android.graphics.BitmapRegionDecoder;
@@ -41,7 +42,6 @@
 import android.util.Pair;
 import android.util.SparseIntArray;
 
-import com.android.launcher3.LauncherFiles;
 import com.android.launcher3.Utilities;
 
 import java.io.IOException;
@@ -63,7 +63,7 @@
     WallpaperManagerCompatVL(Context context) {
         mContext = context;
 
-        String colors = prefs(mContext).getString(KEY_COLORS, "");
+        String colors = getDevicePrefs(mContext).getString(KEY_COLORS, "");
         int wallpaperId = -1;
         if (colors.startsWith(VERSION_PREFIX)) {
             Pair<Integer, WallpaperColorsCompat> storedValue = parseValue(colors);
@@ -106,18 +106,13 @@
     }
 
     private void handleResult(String result) {
-        prefs(mContext).edit().putString(KEY_COLORS, result).apply();
+        getDevicePrefs(mContext).edit().putString(KEY_COLORS, result).apply();
         mColorsCompat = parseValue(result).second;
         for (OnColorsChangedListenerCompat listener : mListeners) {
             listener.onColorsChanged(mColorsCompat, FLAG_SYSTEM);
         }
     }
 
-    private static SharedPreferences prefs(Context context) {
-        return context.getSharedPreferences(
-                LauncherFiles.DEVICE_PREFERENCES_KEY, Context.MODE_PRIVATE);
-    }
-
     private static final int getWallpaperId(Context context) {
         if (!Utilities.ATLEAST_NOUGAT) {
             return -1;
diff --git a/src/com/android/launcher3/graphics/IconShapeOverride.java b/src/com/android/launcher3/graphics/IconShapeOverride.java
index a0727fb..e2d1d50 100644
--- a/src/com/android/launcher3/graphics/IconShapeOverride.java
+++ b/src/com/android/launcher3/graphics/IconShapeOverride.java
@@ -15,13 +15,14 @@
  */
 package com.android.launcher3.graphics;
 
+import static com.android.launcher3.Utilities.getDevicePrefs;
+
 import android.annotation.TargetApi;
 import android.app.AlarmManager;
 import android.app.PendingIntent;
 import android.app.ProgressDialog;
 import android.content.Context;
 import android.content.Intent;
-import android.content.SharedPreferences;
 import android.content.res.Resources;
 import android.os.Build;
 import android.os.SystemClock;
@@ -34,7 +35,6 @@
 import android.util.Log;
 
 import com.android.launcher3.LauncherAppState;
-import com.android.launcher3.LauncherFiles;
 import com.android.launcher3.LauncherModel;
 import com.android.launcher3.R;
 import com.android.launcher3.Utilities;
@@ -101,7 +101,7 @@
         } catch (Exception e) {
             Log.e(TAG, "Unable to override icon shape", e);
             // revert value.
-            prefs(context).edit().remove(KEY_PREFERENCE).apply();
+            getDevicePrefs(context).edit().remove(KEY_PREFERENCE).apply();
         }
     }
 
@@ -116,11 +116,7 @@
     }
 
     private static String getAppliedValue(Context context) {
-        return prefs(context).getString(KEY_PREFERENCE, "");
-    }
-
-    private static SharedPreferences prefs(Context context) {
-        return context.getSharedPreferences(LauncherFiles.DEVICE_PREFERENCES_KEY, 0);
+        return getDevicePrefs(context).getString(KEY_PREFERENCE, "");
     }
 
     public static void handlePreferenceUi(ListPreference preference) {
@@ -189,7 +185,7 @@
         @Override
         public void run() {
             // Synchronously write the preference.
-            prefs(mContext).edit().putString(KEY_PREFERENCE, mValue).commit();
+            getDevicePrefs(mContext).edit().putString(KEY_PREFERENCE, mValue).commit();
             // Clear the icon cache.
             LauncherAppState.getInstance(mContext).getIconCache().clear();
 
diff --git a/src/com/android/launcher3/provider/ImportDataTask.java b/src/com/android/launcher3/provider/ImportDataTask.java
index 3e4cd01..314f244 100644
--- a/src/com/android/launcher3/provider/ImportDataTask.java
+++ b/src/com/android/launcher3/provider/ImportDataTask.java
@@ -16,6 +16,8 @@
 
 package com.android.launcher3.provider;
 
+import static com.android.launcher3.Utilities.getDevicePrefs;
+
 import android.content.ContentProviderOperation;
 import android.content.ContentValues;
 import android.content.Context;
@@ -36,7 +38,6 @@
 import com.android.launcher3.DefaultLayoutParser;
 import com.android.launcher3.LauncherAppState;
 import com.android.launcher3.LauncherAppWidgetInfo;
-import com.android.launcher3.LauncherFiles;
 import com.android.launcher3.LauncherProvider;
 import com.android.launcher3.LauncherSettings;
 import com.android.launcher3.LauncherSettings.Favorites;
@@ -377,10 +378,6 @@
         return false;
     }
 
-    private static SharedPreferences getDevicePrefs(Context c) {
-        return c.getSharedPreferences(LauncherFiles.DEVICE_PREFERENCES_KEY, Context.MODE_PRIVATE);
-    }
-
     private static final int getMyHotseatLayoutId(Context context) {
         return LauncherAppState.getIDP(context).numHotseatIcons <= 5
                 ? R.xml.dw_phone_hotseat