Cleanup an unused return value

Change-Id: I974964aa3cc24b5480e57bd38c197fe7a49acaa4
This commit is contained in:
Ken Wakasa 2013-04-30 11:10:22 +09:00
parent 965329c192
commit 0d6c87d113
2 changed files with 10 additions and 21 deletions

View file

@ -210,7 +210,7 @@ public final class BinaryDictionaryFileDumper {
* to the cache file name designated by its id and locale, overwriting it if already present * to the cache file name designated by its id and locale, overwriting it if already present
* and creating it (and its containing directory) if necessary. * and creating it (and its containing directory) if necessary.
*/ */
private static AssetFileAddress cacheWordList(final String wordlistId, final String locale, private static void cacheWordList(final String wordlistId, final String locale,
final ContentProviderClient providerClient, final Context context) { final ContentProviderClient providerClient, final Context context) {
final int COMPRESSED_CRYPTED_COMPRESSED = 0; final int COMPRESSED_CRYPTED_COMPRESSED = 0;
final int CRYPTED_COMPRESSED = 1; final int CRYPTED_COMPRESSED = 1;
@ -228,7 +228,7 @@ public final class BinaryDictionaryFileDumper {
providerClient, QUERY_PATH_DATAFILE, wordlistId /* extraPath */); providerClient, QUERY_PATH_DATAFILE, wordlistId /* extraPath */);
} catch (RemoteException e) { } catch (RemoteException e) {
Log.e(TAG, "Can't communicate with the dictionary pack", e); Log.e(TAG, "Can't communicate with the dictionary pack", e);
return null; return;
} }
final String finalFileName = final String finalFileName =
DictionaryInfoUtils.getCacheFileName(wordlistId, locale, context); DictionaryInfoUtils.getCacheFileName(wordlistId, locale, context);
@ -237,11 +237,11 @@ public final class BinaryDictionaryFileDumper {
tempFileName = BinaryDictionaryGetter.getTempFileName(wordlistId, context); tempFileName = BinaryDictionaryGetter.getTempFileName(wordlistId, context);
} catch (IOException e) { } catch (IOException e) {
Log.e(TAG, "Can't open the temporary file", e); Log.e(TAG, "Can't open the temporary file", e);
return null; return;
} }
for (int mode = MODE_MIN; mode <= MODE_MAX; ++mode) { for (int mode = MODE_MIN; mode <= MODE_MAX; ++mode) {
InputStream originalSourceStream = null; final InputStream originalSourceStream;
InputStream inputStream = null; InputStream inputStream = null;
InputStream uncompressedStream = null; InputStream uncompressedStream = null;
InputStream decryptedStream = null; InputStream decryptedStream = null;
@ -254,7 +254,7 @@ public final class BinaryDictionaryFileDumper {
// Open input. // Open input.
afd = openAssetFileDescriptor(providerClient, wordListUri); afd = openAssetFileDescriptor(providerClient, wordListUri);
// If we can't open it at all, don't even try a number of times. // If we can't open it at all, don't even try a number of times.
if (null == afd) return null; if (null == afd) return;
originalSourceStream = afd.createInputStream(); originalSourceStream = afd.createInputStream();
// Open output. // Open output.
outputFile = new File(tempFileName); outputFile = new File(tempFileName);
@ -305,7 +305,7 @@ public final class BinaryDictionaryFileDumper {
} }
BinaryDictionaryGetter.removeFilesWithIdExcept(context, wordlistId, finalFile); BinaryDictionaryGetter.removeFilesWithIdExcept(context, wordlistId, finalFile);
// Success! Close files (through the finally{} clause) and return. // Success! Close files (through the finally{} clause) and return.
return AssetFileAddress.makeFromFileName(finalFileName); return;
} catch (Exception e) { } catch (Exception e) {
if (DEBUG) { if (DEBUG) {
Log.i(TAG, "Can't open word list in mode " + mode, e); Log.i(TAG, "Can't open word list in mode " + mode, e);
@ -320,7 +320,7 @@ public final class BinaryDictionaryFileDumper {
} finally { } finally {
// Ignore exceptions while closing files. // Ignore exceptions while closing files.
try { try {
// inputStream.close() will close afd, we should not call afd.close(). if (null != afd) afd.close();
if (null != inputStream) inputStream.close(); if (null != inputStream) inputStream.close();
if (null != uncompressedStream) uncompressedStream.close(); if (null != uncompressedStream) uncompressedStream.close();
if (null != decryptedStream) decryptedStream.close(); if (null != decryptedStream) decryptedStream.close();
@ -350,7 +350,6 @@ public final class BinaryDictionaryFileDumper {
} catch (RemoteException e) { } catch (RemoteException e) {
Log.e(TAG, "In addition, communication with the dictionary provider was cut", e); Log.e(TAG, "In addition, communication with the dictionary provider was cut", e);
} }
return null;
} }
/** /**
@ -359,30 +358,23 @@ public final class BinaryDictionaryFileDumper {
* This will query a content provider for word list data for a given locale, and copy the * This will query a content provider for word list data for a given locale, and copy the
* files locally so that they can be mmap'ed. This may overwrite previously cached word lists * files locally so that they can be mmap'ed. This may overwrite previously cached word lists
* with newer versions if a newer version is made available by the content provider. * with newer versions if a newer version is made available by the content provider.
* @returns the addresses of the word list files, or null if no data could be obtained.
* @throw FileNotFoundException if the provider returns non-existent data. * @throw FileNotFoundException if the provider returns non-existent data.
* @throw IOException if the provider-returned data could not be read. * @throw IOException if the provider-returned data could not be read.
*/ */
public static List<AssetFileAddress> cacheWordListsFromContentProvider(final Locale locale, public static void cacheWordListsFromContentProvider(final Locale locale,
final Context context, final boolean hasDefaultWordList) { final Context context, final boolean hasDefaultWordList) {
final ContentProviderClient providerClient = context.getContentResolver(). final ContentProviderClient providerClient = context.getContentResolver().
acquireContentProviderClient(getProviderUriBuilder("").build()); acquireContentProviderClient(getProviderUriBuilder("").build());
if (null == providerClient) { if (null == providerClient) {
Log.e(TAG, "Can't establish communication with the dictionary provider"); Log.e(TAG, "Can't establish communication with the dictionary provider");
return CollectionUtils.newArrayList(); return;
} }
try { try {
final List<WordListInfo> idList = getWordListWordListInfos(locale, context, final List<WordListInfo> idList = getWordListWordListInfos(locale, context,
hasDefaultWordList); hasDefaultWordList);
final ArrayList<AssetFileAddress> fileAddressList = CollectionUtils.newArrayList();
for (WordListInfo id : idList) { for (WordListInfo id : idList) {
final AssetFileAddress afd = cacheWordList(id.mId, id.mLocale, providerClient, context);
cacheWordList(id.mId, id.mLocale, providerClient, context);
if (null != afd) {
fileAddressList.add(afd);
}
} }
return fileAddressList;
} finally { } finally {
providerClient.release(); providerClient.release();
} }

View file

@ -290,9 +290,6 @@ final class BinaryDictionaryGetter {
final Context context) { final Context context) {
final boolean hasDefaultWordList = DictionaryFactory.isDictionaryAvailable(context, locale); final boolean hasDefaultWordList = DictionaryFactory.isDictionaryAvailable(context, locale);
// cacheWordListsFromContentProvider returns the list of files it copied to local
// storage, but we don't really care about what was copied NOW: what we want is the
// list of everything we ever cached, so we ignore the return value.
// TODO: The development-only-diagnostic version is not supported by the Dictionary Pack // TODO: The development-only-diagnostic version is not supported by the Dictionary Pack
// Service yet // Service yet
if (!ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) { if (!ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {