diff --git a/mobile/android/base/GeckoApp.java b/mobile/android/base/GeckoApp.java index d4e806f7704f..25facb741d14 100644 --- a/mobile/android/base/GeckoApp.java +++ b/mobile/android/base/GeckoApp.java @@ -111,6 +111,7 @@ abstract public class GeckoApp public static File sGREDir = null; public static Menu sMenu; public Handler mMainHandler; + private File mProfileDir; private IntentFilter mConnectivityFilter; private IntentFilter mBatteryFilter; @@ -387,8 +388,10 @@ abstract public class GeckoApp return false; String args = intent.getStringExtra("args"); - if (args != null && args.contains("-profile")) + if (args != null && args.contains("-profile")) { + // XXX: TO-DO set mProfileDir to the path passed in mUserDefinedProfile = true; + } if (intent == null) intent = getIntent(); @@ -691,6 +694,21 @@ abstract public class GeckoApp }); } + File getProfileDir() { + if (mProfileDir == null && !mUserDefinedProfile) { + File mozDir = new File(GeckoAppShell.sHomeDir, "mozilla"); + File[] profiles = mozDir.listFiles(new FileFilter() { + public boolean accept(File pathname) { + return pathname.getName().endsWith(".default"); + } + }); + if (profiles.length == 1) + mProfileDir = profiles[0]; + // XXX: TO-DO read profiles.ini to get the default profile + } + return mProfileDir; + } + void addTab() { Intent intent = new Intent(mAppContext, AwesomeBar.class); intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION | Intent.FLAG_ACTIVITY_NO_HISTORY); diff --git a/mobile/android/base/GeckoAppShell.java b/mobile/android/base/GeckoAppShell.java index 41e2cbcb1d40..7d74686efdd3 100644 --- a/mobile/android/base/GeckoAppShell.java +++ b/mobile/android/base/GeckoAppShell.java @@ -108,6 +108,7 @@ public class GeckoAppShell static private File sCacheFile = null; static private int sFreeSpace = -1; + static File sHomeDir = null; private static HashMap> mEventListeners; @@ -299,8 +300,8 @@ public class GeckoAppShell if (Build.VERSION.SDK_INT < 8 || geckoApp.getApplication().getPackageResourcePath().startsWith("/data") || geckoApp.getApplication().getPackageResourcePath().startsWith("/system")) { - File home = geckoApp.getFilesDir(); - homeDir = home.getPath(); + sHomeDir = geckoApp.getFilesDir(); + homeDir = sHomeDir.getPath(); // handle the application being moved to phone from sdcard File profileDir = new File(homeDir, "mozilla"); File oldHome = new File("/data/data/" + @@ -314,8 +315,8 @@ public class GeckoAppShell moveDir(extProf, profileDir); } } else { - File home = geckoApp.getExternalFilesDir(null); - homeDir = home.getPath(); + sHomeDir = geckoApp.getExternalFilesDir(null); + homeDir = sHomeDir.getPath(); // handle the application being moved to phone from sdcard File profileDir = new File(homeDir, "mozilla"); File oldHome = new File("/data/data/" +