summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2015-05-28 00:16:08 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-05-28 00:18:01 +0000
commit5cc7af12f10c4bd97bd732305398c7ad6a7fa4ca (patch)
tree005838aae9bf91919fc79e80e8593af6949d894e /src
parentcadc29c7e55cc14526878e511a85ae6c9c7e23c7 (diff)
parentf0e1fd9938b26fa2fa7484613f6160e99c157a9d (diff)
downloadandroid_packages_apps_Trebuchet-5cc7af12f10c4bd97bd732305398c7ad6a7fa4ca.tar.gz
android_packages_apps_Trebuchet-5cc7af12f10c4bd97bd732305398c7ad6a7fa4ca.tar.bz2
android_packages_apps_Trebuchet-5cc7af12f10c4bd97bd732305398c7ad6a7fa4ca.zip
Merge "Removing file IO used for checking configuration change" into ub-launcher3-burnaby
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher3/IconCache.java9
-rw-r--r--src/com/android/launcher3/Launcher.java108
-rw-r--r--src/com/android/launcher3/LauncherFiles.java3
3 files changed, 1 insertions, 119 deletions
diff --git a/src/com/android/launcher3/IconCache.java b/src/com/android/launcher3/IconCache.java
index 0c91a7113..77d90456e 100644
--- a/src/com/android/launcher3/IconCache.java
+++ b/src/com/android/launcher3/IconCache.java
@@ -49,10 +49,8 @@ import com.android.launcher3.util.Thunk;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import java.util.Locale;
-import java.util.Map.Entry;
import java.util.Stack;
/**
@@ -367,13 +365,6 @@ public class IconCache {
}
/**
- * Empty out the cache.
- */
- public synchronized void flush() {
- mCache.clear();
- }
-
- /**
* Fetches high-res icon for the provided ItemInfo and updates the caller when done.
* @return a request ID that can be used to cancel the request.
*/
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 1aa446e31..5dac3b3da 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -112,11 +112,8 @@ import com.android.launcher3.widget.PendingAddWidgetInfo;
import com.android.launcher3.widget.WidgetHostViewLoader;
import com.android.launcher3.widget.WidgetsContainerView;
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
import java.io.File;
import java.io.FileDescriptor;
-import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
@@ -310,8 +307,6 @@ public class Launcher extends Activity
private boolean mHasFocus = false;
private boolean mAttached = false;
- @Thunk static LocaleConfiguration sLocaleConfiguration = null;
-
private static LongArrayMap<FolderInfo> sFolders = new LongArrayMap<>();
private View.OnTouchListener mHapticFeedbackTouchListener;
@@ -469,7 +464,6 @@ public class Launcher extends Activity
Environment.getExternalStorageDirectory() + "/launcher");
}
- checkForLocaleChange();
setContentView(R.layout.launcher);
setupViews();
@@ -636,108 +630,6 @@ public class Launcher extends Activity
}
}
- @Thunk void checkForLocaleChange() {
- if (sLocaleConfiguration == null) {
- new AsyncTask<Void, Void, LocaleConfiguration>() {
- @Override
- protected LocaleConfiguration doInBackground(Void... unused) {
- LocaleConfiguration localeConfiguration = new LocaleConfiguration();
- readConfiguration(Launcher.this, localeConfiguration);
- return localeConfiguration;
- }
-
- @Override
- protected void onPostExecute(LocaleConfiguration result) {
- sLocaleConfiguration = result;
- checkForLocaleChange(); // recursive, but now with a locale configuration
- }
- }.execute();
- return;
- }
-
- final Configuration configuration = getResources().getConfiguration();
-
- final String previousLocale = sLocaleConfiguration.locale;
- final String locale = configuration.locale.toString();
-
- final int previousMcc = sLocaleConfiguration.mcc;
- final int mcc = configuration.mcc;
-
- final int previousMnc = sLocaleConfiguration.mnc;
- final int mnc = configuration.mnc;
-
- boolean localeChanged = !locale.equals(previousLocale) || mcc != previousMcc || mnc != previousMnc;
-
- if (localeChanged) {
- sLocaleConfiguration.locale = locale;
- sLocaleConfiguration.mcc = mcc;
- sLocaleConfiguration.mnc = mnc;
-
- mIconCache.flush();
-
- final LocaleConfiguration localeConfiguration = sLocaleConfiguration;
- new AsyncTask<Void, Void, Void>() {
- public Void doInBackground(Void ... args) {
- writeConfiguration(Launcher.this, localeConfiguration);
- return null;
- }
- }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Void) null);
- }
- }
-
- @Thunk static class LocaleConfiguration {
- public String locale;
- public int mcc = -1;
- public int mnc = -1;
- }
-
- @Thunk static void readConfiguration(Context context, LocaleConfiguration configuration) {
- DataInputStream in = null;
- try {
- in = new DataInputStream(context.openFileInput(LauncherFiles.LAUNCHER_PREFERENCES));
- configuration.locale = in.readUTF();
- configuration.mcc = in.readInt();
- configuration.mnc = in.readInt();
- } catch (FileNotFoundException e) {
- // Ignore
- } catch (IOException e) {
- // Ignore
- } finally {
- if (in != null) {
- try {
- in.close();
- } catch (IOException e) {
- // Ignore
- }
- }
- }
- }
-
- @Thunk static void writeConfiguration(Context context, LocaleConfiguration configuration) {
- DataOutputStream out = null;
- try {
- out = new DataOutputStream(context.openFileOutput(
- LauncherFiles.LAUNCHER_PREFERENCES, MODE_PRIVATE));
- out.writeUTF(configuration.locale);
- out.writeInt(configuration.mcc);
- out.writeInt(configuration.mnc);
- out.flush();
- } catch (FileNotFoundException e) {
- // Ignore
- } catch (IOException e) {
- //noinspection ResultOfMethodCallIgnored
- context.getFileStreamPath(LauncherFiles.LAUNCHER_PREFERENCES).delete();
- } finally {
- if (out != null) {
- try {
- out.close();
- } catch (IOException e) {
- // Ignore
- }
- }
- }
- }
-
public Stats getStats() {
return mStats;
}
diff --git a/src/com/android/launcher3/LauncherFiles.java b/src/com/android/launcher3/LauncherFiles.java
index 03ec4bf7a..c08cd0bf5 100644
--- a/src/com/android/launcher3/LauncherFiles.java
+++ b/src/com/android/launcher3/LauncherFiles.java
@@ -17,7 +17,6 @@ public class LauncherFiles {
public static final String DEFAULT_WALLPAPER_THUMBNAIL = "default_thumb2.jpg";
public static final String DEFAULT_WALLPAPER_THUMBNAIL_OLD = "default_thumb.jpg";
public static final String LAUNCHER_DB = "launcher.db";
- public static final String LAUNCHER_PREFERENCES = "launcher.preferences";
public static final String SHARED_PREFERENCES_KEY = "com.android.launcher3.prefs";
public static final String WALLPAPER_CROP_PREFERENCES_KEY =
"com.android.launcher3.WallpaperCropActivity";
@@ -31,7 +30,6 @@ public class LauncherFiles {
DEFAULT_WALLPAPER_THUMBNAIL,
DEFAULT_WALLPAPER_THUMBNAIL_OLD,
LAUNCHER_DB,
- LAUNCHER_PREFERENCES,
SHARED_PREFERENCES_KEY + XML,
WALLPAPER_CROP_PREFERENCES_KEY + XML,
WALLPAPER_IMAGES_DB,
@@ -43,5 +41,6 @@ public class LauncherFiles {
public static final List<String> OBSOLETE_FILES = Collections.unmodifiableList(Arrays.asList(
"launches.log",
"stats.log",
+ "launcher.preferences",
"com.android.launcher3.compat.PackageInstallerCompatV16.queue"));
}