mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-24 03:19:06 +00:00
bug 589906 - Fennec hangs at startup with black screen when out of disk space r=mwu uir=beltzner a=blocking-fennec
This commit is contained in:
parent
09f8d096e6
commit
a2a7b949f7
@ -86,7 +86,19 @@ abstract public class GeckoApp
|
||||
void launch()
|
||||
{
|
||||
// unpack files in the components directory
|
||||
unpackComponents();
|
||||
try {
|
||||
unpackComponents();
|
||||
} catch (FileNotFoundException fnfe) {
|
||||
showErrorDialog(getString(R.string.error_loading_file));
|
||||
return;
|
||||
} catch (IOException ie) {
|
||||
String msg = ie.getMessage();
|
||||
if (msg.equalsIgnoreCase("No space left on device"))
|
||||
showErrorDialog(getString(R.string.no_space_to_start_error));
|
||||
else
|
||||
showErrorDialog(getString(R.string.error_loading_file));
|
||||
return;
|
||||
}
|
||||
// and then fire us up
|
||||
Intent i = getIntent();
|
||||
String env = i.getStringExtra("env0");
|
||||
@ -336,49 +348,38 @@ abstract public class GeckoApp
|
||||
abstract public int getMinCPUVersion();
|
||||
|
||||
protected void unpackComponents()
|
||||
throws IOException, FileNotFoundException
|
||||
{
|
||||
ZipFile zip;
|
||||
InputStream listStream;
|
||||
|
||||
try {
|
||||
File componentsDir = new File("/data/data/org.mozilla." + getAppName() +"/components");
|
||||
componentsDir.mkdir();
|
||||
zip = new ZipFile(getApplication().getPackageResourcePath());
|
||||
} catch (Exception e) {
|
||||
Log.i("GeckoAppJava", e.toString());
|
||||
return;
|
||||
}
|
||||
File componentsDir = new File("/data/data/org.mozilla." + getAppName() +
|
||||
"/components");
|
||||
componentsDir.mkdir();
|
||||
zip = new ZipFile(getApplication().getPackageResourcePath());
|
||||
|
||||
byte[] buf = new byte[8192];
|
||||
unpackFile(zip, buf, null, "application.ini");
|
||||
unpackFile(zip, buf, null, getContentProcessName());
|
||||
unpackFile(zip, buf, null, "update.locale");
|
||||
|
||||
try {
|
||||
ZipEntry componentsList = zip.getEntry("components/components.manifest");
|
||||
if (componentsList == null) {
|
||||
Log.i("GeckoAppJava", "Can't find components.manifest!");
|
||||
return;
|
||||
}
|
||||
unpackFile(zip, buf, null, "update.locale");
|
||||
} catch (Exception e) {/* this is non-fatal */}
|
||||
|
||||
listStream = new BufferedInputStream(zip.getInputStream(componentsList));
|
||||
} catch (Exception e) {
|
||||
Log.i("GeckoAppJava", e.toString());
|
||||
ZipEntry componentsList = zip.getEntry("components/components.manifest");
|
||||
if (componentsList == null) {
|
||||
Log.i("GeckoAppJava", "Can't find components.manifest!");
|
||||
return;
|
||||
}
|
||||
|
||||
listStream = new BufferedInputStream(zip.getInputStream(componentsList));
|
||||
|
||||
StreamTokenizer tkn = new StreamTokenizer(new InputStreamReader(listStream));
|
||||
String line = "components/";
|
||||
int status;
|
||||
boolean addnext = false;
|
||||
tkn.eolIsSignificant(true);
|
||||
do {
|
||||
try {
|
||||
status = tkn.nextToken();
|
||||
} catch (IOException e) {
|
||||
Log.i("GeckoAppJava", e.toString());
|
||||
return;
|
||||
}
|
||||
status = tkn.nextToken();
|
||||
switch (status) {
|
||||
case StreamTokenizer.TT_WORD:
|
||||
if (tkn.sval.equals("binary-component"))
|
||||
@ -399,57 +400,42 @@ abstract public class GeckoApp
|
||||
} while (status != StreamTokenizer.TT_EOF);
|
||||
}
|
||||
|
||||
private void unpackFile(ZipFile zip, byte[] buf, ZipEntry fileEntry, String name)
|
||||
private void unpackFile(ZipFile zip, byte[] buf, ZipEntry fileEntry,
|
||||
String name)
|
||||
throws IOException, FileNotFoundException
|
||||
{
|
||||
if (fileEntry == null)
|
||||
fileEntry = zip.getEntry(name);
|
||||
if (fileEntry == null) {
|
||||
Log.i("GeckoAppJava", "Can't find " + name + " in " + zip.getName());
|
||||
return;
|
||||
}
|
||||
if (fileEntry == null)
|
||||
throw new FileNotFoundException("Can't find " + name + " in " +
|
||||
zip.getName());
|
||||
|
||||
File outFile = new File("/data/data/org.mozilla." + getAppName() + "/" + name);
|
||||
File outFile = new File("/data/data/org.mozilla." + getAppName() +
|
||||
"/" + name);
|
||||
if (outFile.exists() &&
|
||||
outFile.lastModified() >= fileEntry.getTime() &&
|
||||
outFile.length() == fileEntry.getSize())
|
||||
return;
|
||||
|
||||
try {
|
||||
File dir = outFile.getParentFile();
|
||||
if (!outFile.exists())
|
||||
dir.mkdirs();
|
||||
} catch (Exception e) {
|
||||
Log.i("GeckoAppJava", e.toString());
|
||||
return;
|
||||
}
|
||||
File dir = outFile.getParentFile();
|
||||
if (!outFile.exists())
|
||||
dir.mkdirs();
|
||||
|
||||
InputStream fileStream;
|
||||
try {
|
||||
fileStream = zip.getInputStream(fileEntry);
|
||||
} catch (Exception e) {
|
||||
Log.i("GeckoAppJava", e.toString());
|
||||
return;
|
||||
}
|
||||
|
||||
OutputStream outStream;
|
||||
try {
|
||||
outStream = new FileOutputStream(outFile);
|
||||
|
||||
while (fileStream.available() > 0) {
|
||||
int read = fileStream.read(buf, 0, buf.length);
|
||||
outStream.write(buf, 0, read);
|
||||
}
|
||||
|
||||
fileStream.close();
|
||||
outStream.close();
|
||||
} catch (Exception e) {
|
||||
Log.i("GeckoAppJava", e.toString());
|
||||
return;
|
||||
fileStream = zip.getInputStream(fileEntry);
|
||||
|
||||
OutputStream outStream = new FileOutputStream(outFile);
|
||||
|
||||
while (fileStream.available() > 0) {
|
||||
int read = fileStream.read(buf, 0, buf.length);
|
||||
outStream.write(buf, 0, read);
|
||||
}
|
||||
|
||||
fileStream.close();
|
||||
outStream.close();
|
||||
outFile.setLastModified(fileEntry.getTime());
|
||||
}
|
||||
|
||||
|
||||
public String getEnvString() {
|
||||
Map<String,String> envMap = System.getenv();
|
||||
Set<Map.Entry<String,String>> envSet = envMap.entrySet();
|
||||
|
@ -1,2 +1,4 @@
|
||||
<!ENTITY splash_screen_label "&brandShortName; is loading">
|
||||
<!ENTITY incompatable_cpu_error "This device does not meet the minimum system requirements for &brandShortName;.">
|
||||
<!ENTITY no_space_to_start_error "There is not enough space available for &brandShortName; to start.">
|
||||
<!ENTITY error_loading_file "An error occurred when trying to load files required to run &brandShortName;">
|
||||
|
@ -7,4 +7,6 @@
|
||||
<resources>
|
||||
<string name="splash_screen_label">&splash_screen_label;</string>
|
||||
<string name="incompatable_cpu_error">&incompatable_cpu_error;</string>
|
||||
<string name="no_space_to_start_error">&no_space_to_start_error;</string>
|
||||
<string name="error_loading_file">&error_loading_file;</string>
|
||||
</resources>
|
||||
|
Loading…
x
Reference in New Issue
Block a user