Merge "Fix two strict mode warnings."
This commit is contained in:
commit
faa7fbfaa2
2 changed files with 42 additions and 25 deletions
|
@ -572,7 +572,8 @@ public class MetadataDbHelper extends SQLiteOpenHelper {
|
||||||
* If several clients use the same metadata URL, we know to only download it once, and
|
* If several clients use the same metadata URL, we know to only download it once, and
|
||||||
* dispatch the update process across all relevant clients when the download ends. This means
|
* dispatch the update process across all relevant clients when the download ends. This means
|
||||||
* several clients may share a single download ID if they share a metadata URI.
|
* several clients may share a single download ID if they share a metadata URI.
|
||||||
* The dispatching is done in {@link UpdateHandler#downloadFinished(Context, Intent)}, which
|
* The dispatching is done in
|
||||||
|
* {@link UpdateHandler#downloadFinished(Context, android.content.Intent)}, which
|
||||||
* finds out about the list of relevant clients by calling this method.
|
* finds out about the list of relevant clients by calling this method.
|
||||||
*
|
*
|
||||||
* @param context a context instance to open the databases
|
* @param context a context instance to open the databases
|
||||||
|
@ -863,17 +864,20 @@ public class MetadataDbHelper extends SQLiteOpenHelper {
|
||||||
r.getAsString(WORDLISTID_COLUMN),
|
r.getAsString(WORDLISTID_COLUMN),
|
||||||
Integer.toString(STATUS_INSTALLED) },
|
Integer.toString(STATUS_INSTALLED) },
|
||||||
null, null, null);
|
null, null, null);
|
||||||
|
try {
|
||||||
if (c.moveToFirst()) {
|
if (c.moveToFirst()) {
|
||||||
// There should never be more than one file, but if there are, it's a bug
|
// There should never be more than one file, but if there are, it's a bug
|
||||||
// and we should remove them all. I think it might happen if the power of the
|
// and we should remove them all. I think it might happen if the power of
|
||||||
// phone is suddenly cut during an update.
|
// the phone is suddenly cut during an update.
|
||||||
final int filenameIndex = c.getColumnIndex(LOCAL_FILENAME_COLUMN);
|
final int filenameIndex = c.getColumnIndex(LOCAL_FILENAME_COLUMN);
|
||||||
do {
|
do {
|
||||||
Utils.l("Setting for removal", c.getString(filenameIndex));
|
Utils.l("Setting for removal", c.getString(filenameIndex));
|
||||||
filenames.add(c.getString(filenameIndex));
|
filenames.add(c.getString(filenameIndex));
|
||||||
} while (c.moveToNext());
|
} while (c.moveToNext());
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
c.close();
|
||||||
|
}
|
||||||
r.put(STATUS_COLUMN, STATUS_INSTALLED);
|
r.put(STATUS_COLUMN, STATUS_INSTALLED);
|
||||||
db.beginTransactionNonExclusive();
|
db.beginTransactionNonExclusive();
|
||||||
// Delete all old entries. There should never be any stalled entries, but if
|
// Delete all old entries. There should never be any stalled entries, but if
|
||||||
|
|
|
@ -32,6 +32,7 @@ import com.android.inputmethod.latin.DictionaryInfoUtils.DictionaryInfo;
|
||||||
|
|
||||||
import java.io.BufferedInputStream;
|
import java.io.BufferedInputStream;
|
||||||
import java.io.BufferedOutputStream;
|
import java.io.BufferedOutputStream;
|
||||||
|
import java.io.Closeable;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
|
@ -319,20 +320,12 @@ public final class BinaryDictionaryFileDumper {
|
||||||
// Try the next method.
|
// Try the next method.
|
||||||
} finally {
|
} finally {
|
||||||
// Ignore exceptions while closing files.
|
// Ignore exceptions while closing files.
|
||||||
try {
|
closeAssetFileDescriptorAndReportAnyException(afd);
|
||||||
if (null != afd) afd.close();
|
closeCloseableAndReportAnyException(inputStream);
|
||||||
if (null != inputStream) inputStream.close();
|
closeCloseableAndReportAnyException(uncompressedStream);
|
||||||
if (null != uncompressedStream) uncompressedStream.close();
|
closeCloseableAndReportAnyException(decryptedStream);
|
||||||
if (null != decryptedStream) decryptedStream.close();
|
closeCloseableAndReportAnyException(bufferedInputStream);
|
||||||
if (null != bufferedInputStream) bufferedInputStream.close();
|
closeCloseableAndReportAnyException(bufferedOutputStream);
|
||||||
} catch (Exception e) {
|
|
||||||
Log.e(TAG, "Exception while closing a file descriptor", e);
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
if (null != bufferedOutputStream) bufferedOutputStream.close();
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log.e(TAG, "Exception while closing a file", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -352,6 +345,26 @@ public final class BinaryDictionaryFileDumper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ideally the two following methods should be merged, but AssetFileDescriptor does not
|
||||||
|
// implement Closeable although it does implement #close(), and Java does not have
|
||||||
|
// structural typing.
|
||||||
|
private static void closeAssetFileDescriptorAndReportAnyException(
|
||||||
|
final AssetFileDescriptor file) {
|
||||||
|
try {
|
||||||
|
if (null != file) file.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.e(TAG, "Exception while closing a file", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void closeCloseableAndReportAnyException(final Closeable file) {
|
||||||
|
try {
|
||||||
|
if (null != file) file.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.e(TAG, "Exception while closing a file", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Queries a content provider for word list data for some locale and cache the returned files
|
* Queries a content provider for word list data for some locale and cache the returned files
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue