Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
LatinIME
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
keyboard
LatinIME
Commits
4bcf70c9
Commit
4bcf70c9
authored
12 years ago
by
Jean Chalard
Browse files
Options
Downloads
Patches
Plain Diff
Fix a bad interaction with mmap
Bug: 6761221 Change-Id: I7e6d98dc9d7cb34a6163c3957e401ff97abb975c
parent
7f7947c9
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
java/src/com/android/inputmethod/latin/BinaryDictionaryFileDumper.java
+14
-4
14 additions, 4 deletions
...android/inputmethod/latin/BinaryDictionaryFileDumper.java
with
14 additions
and
4 deletions
java/src/com/android/inputmethod/latin/BinaryDictionaryFileDumper.java
+
14
−
4
View file @
4bcf70c9
...
...
@@ -149,7 +149,8 @@ public class BinaryDictionaryFileDumper {
final
int
MODE_MAX
=
NONE
;
final
Uri
.
Builder
wordListUriBuilder
=
getProviderUriBuilder
(
id
);
final
String
outputFileName
=
BinaryDictionaryGetter
.
getCacheFileName
(
id
,
locale
,
context
);
final
String
finalFileName
=
BinaryDictionaryGetter
.
getCacheFileName
(
id
,
locale
,
context
);
final
String
tempFileName
=
finalFileName
+
".tmp"
;
for
(
int
mode
=
MODE_MIN
;
mode
<=
MODE_MAX
;
++
mode
)
{
InputStream
originalSourceStream
=
null
;
...
...
@@ -165,7 +166,10 @@ public class BinaryDictionaryFileDumper {
if
(
null
==
afd
)
return
null
;
originalSourceStream
=
afd
.
createInputStream
();
// Open output.
outputFile
=
new
File
(
outputFileName
);
outputFile
=
new
File
(
tempFileName
);
// Just to be sure, delete the file. This may fail silently, and return false: this
// is the right thing to do, as we just want to continue anyway.
outputFile
.
delete
();
outputStream
=
new
FileOutputStream
(
outputFile
);
// Get the appropriate decryption method for this try
switch
(
mode
)
{
...
...
@@ -194,14 +198,20 @@ public class BinaryDictionaryFileDumper {
break
;
}
checkMagicAndCopyFileTo
(
new
BufferedInputStream
(
inputStream
),
outputStream
);
outputStream
.
flush
();
outputStream
.
close
();
final
File
finalFile
=
new
File
(
finalFileName
);
if
(!
outputFile
.
renameTo
(
finalFile
))
{
throw
new
IOException
(
"Can't move the file to its final name"
);
}
wordListUriBuilder
.
appendQueryParameter
(
QUERY_PARAMETER_DELETE_RESULT
,
QUERY_PARAMETER_SUCCESS
);
if
(
0
>=
resolver
.
delete
(
wordListUriBuilder
.
build
(),
null
,
null
))
{
Log
.
e
(
TAG
,
"Could not have the dictionary pack delete a word list"
);
}
BinaryDictionaryGetter
.
removeFilesWithIdExcept
(
context
,
id
,
output
File
);
BinaryDictionaryGetter
.
removeFilesWithIdExcept
(
context
,
id
,
final
File
);
// Success! Close files (through the finally{} clause) and return.
return
AssetFileAddress
.
makeFromFileName
(
output
FileName
);
return
AssetFileAddress
.
makeFromFileName
(
final
FileName
);
}
catch
(
Exception
e
)
{
if
(
DEBUG
)
{
Log
.
i
(
TAG
,
"Can't open word list in mode "
+
mode
+
" : "
+
e
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment