am 49ac0f9d: Merge change 21210 into donut
Merge commit '49ac0f9df009ace5175267ad60be51114ee19817' into eclair * commit '49ac0f9df009ace5175267ad60be51114ee19817': Make sure that the android pref folder is always present when queried.
This commit is contained in:
@@ -37,36 +37,46 @@ public final class AndroidLocation {
|
|||||||
super(string);
|
super(string);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String sPrefsLocation = null;
|
private static String sPrefsLocation = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the folder used to store android related files.
|
* Returns the folder used to store android related files.
|
||||||
* @return an OS specific path, terminated by a separator.
|
* @return an OS specific path, terminated by a separator.
|
||||||
* @throws AndroidLocationException
|
* @throws AndroidLocationException
|
||||||
*/
|
*/
|
||||||
public final static String getFolder() throws AndroidLocationException {
|
public final static String getFolder() throws AndroidLocationException {
|
||||||
if (sPrefsLocation == null) {
|
if (sPrefsLocation == null) {
|
||||||
String home = findValidPath("ANDROID_SDK_HOME", "user.home", "HOME");
|
String home = findValidPath("ANDROID_SDK_HOME", "user.home", "HOME");
|
||||||
|
|
||||||
// if the above failed, we throw an exception.
|
// if the above failed, we throw an exception.
|
||||||
if (home == null) {
|
if (home == null) {
|
||||||
throw new AndroidLocationException(
|
throw new AndroidLocationException(
|
||||||
"Unable to get the home directory. Make sure the user.home property is set up");
|
"Unable to get the home directory. Make sure the user.home property is set up");
|
||||||
} else {
|
} else {
|
||||||
sPrefsLocation = home + File.separator + ".android" + File.separator;
|
sPrefsLocation = home + File.separator + ".android" + File.separator;
|
||||||
|
|
||||||
// make sure the folder exists!
|
|
||||||
File f = new File(sPrefsLocation);
|
|
||||||
if (f.exists() == false) {
|
|
||||||
f.mkdir();
|
|
||||||
} else if (f.isFile()) {
|
|
||||||
throw new AndroidLocationException(sPrefsLocation +
|
|
||||||
" is not a directory! This is required to run Android tools.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// make sure the folder exists!
|
||||||
|
File f = new File(sPrefsLocation);
|
||||||
|
if (f.exists() == false) {
|
||||||
|
try {
|
||||||
|
f.mkdir();
|
||||||
|
} catch (SecurityException e) {
|
||||||
|
AndroidLocationException e2 = new AndroidLocationException(String.format(
|
||||||
|
"Unable to create folder '%1$s'. " +
|
||||||
|
"This is the path of preference folder expected by the Android tools.",
|
||||||
|
sPrefsLocation));
|
||||||
|
e2.initCause(e);
|
||||||
|
throw e2;
|
||||||
|
}
|
||||||
|
} else if (f.isFile()) {
|
||||||
|
throw new AndroidLocationException(sPrefsLocation +
|
||||||
|
" is not a directory! " +
|
||||||
|
"This is the path of preference folder expected by the Android tools.");
|
||||||
|
}
|
||||||
|
|
||||||
return sPrefsLocation;
|
return sPrefsLocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,7 +102,7 @@ public final class AndroidLocation {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,8 +3,8 @@
|
|||||||
<classpathentry excluding="Makefile|resources/" kind="src" path="src"/>
|
<classpathentry excluding="Makefile|resources/" kind="src" path="src"/>
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||||
<classpathentry kind="lib" path="jarutils.jar"/>
|
<classpathentry kind="lib" path="jarutils.jar" sourcepath="/JarUtils"/>
|
||||||
<classpathentry kind="lib" path="androidprefs.jar"/>
|
<classpathentry kind="lib" path="androidprefs.jar" sourcepath="/AndroidPrefs"/>
|
||||||
<classpathentry kind="lib" path="sdkstats.jar" sourcepath="/SdkStatsService"/>
|
<classpathentry kind="lib" path="sdkstats.jar" sourcepath="/SdkStatsService"/>
|
||||||
<classpathentry kind="lib" path="kxml2-2.3.0.jar"/>
|
<classpathentry kind="lib" path="kxml2-2.3.0.jar"/>
|
||||||
<classpathentry kind="lib" path="layoutlib_api.jar"/>
|
<classpathentry kind="lib" path="layoutlib_api.jar"/>
|
||||||
|
|||||||
Reference in New Issue
Block a user