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
3abac7e2
Commit
3abac7e2
authored
12 years ago
by
Jean Chalard
Browse files
Options
Downloads
Patches
Plain Diff
Notify the dictionary pack about copy failures
Bug: 6532896 Change-Id: I57f7b1a400222c89776f9bff652a7da4470232c5
parent
ff4c037c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
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
+13
-5
13 additions, 5 deletions
...android/inputmethod/latin/BinaryDictionaryFileDumper.java
with
13 additions
and
5 deletions
java/src/com/android/inputmethod/latin/BinaryDictionaryFileDumper.java
+
13
−
5
View file @
3abac7e2
...
@@ -58,6 +58,9 @@ public class BinaryDictionaryFileDumper {
...
@@ -58,6 +58,9 @@ public class BinaryDictionaryFileDumper {
public
static
final
String
QUERY_PARAMETER_MAY_PROMPT_USER
=
"mayPrompt"
;
public
static
final
String
QUERY_PARAMETER_MAY_PROMPT_USER
=
"mayPrompt"
;
public
static
final
String
QUERY_PARAMETER_TRUE
=
"true"
;
public
static
final
String
QUERY_PARAMETER_TRUE
=
"true"
;
public
static
final
String
QUERY_PARAMETER_DELETE_RESULT
=
"result"
;
public
static
final
String
QUERY_PARAMETER_SUCCESS
=
"success"
;
public
static
final
String
QUERY_PARAMETER_FAILURE
=
"failure"
;
// Prevents this class to be accidentally instantiated.
// Prevents this class to be accidentally instantiated.
private
BinaryDictionaryFileDumper
()
{
private
BinaryDictionaryFileDumper
()
{
...
@@ -145,7 +148,7 @@ public class BinaryDictionaryFileDumper {
...
@@ -145,7 +148,7 @@ public class BinaryDictionaryFileDumper {
final
int
MODE_MIN
=
COMPRESSED_CRYPTED_COMPRESSED
;
final
int
MODE_MIN
=
COMPRESSED_CRYPTED_COMPRESSED
;
final
int
MODE_MAX
=
NONE
;
final
int
MODE_MAX
=
NONE
;
final
Uri
wordListUri
=
getProviderUriBuilder
(
id
)
.
build
()
;
final
Uri
.
Builder
wordListUri
Builder
=
getProviderUriBuilder
(
id
);
final
String
outputFileName
=
BinaryDictionaryGetter
.
getCacheFileName
(
id
,
locale
,
context
);
final
String
outputFileName
=
BinaryDictionaryGetter
.
getCacheFileName
(
id
,
locale
,
context
);
for
(
int
mode
=
MODE_MIN
;
mode
<=
MODE_MAX
;
++
mode
)
{
for
(
int
mode
=
MODE_MIN
;
mode
<=
MODE_MAX
;
++
mode
)
{
...
@@ -154,6 +157,7 @@ public class BinaryDictionaryFileDumper {
...
@@ -154,6 +157,7 @@ public class BinaryDictionaryFileDumper {
File
outputFile
=
null
;
File
outputFile
=
null
;
FileOutputStream
outputStream
=
null
;
FileOutputStream
outputStream
=
null
;
AssetFileDescriptor
afd
=
null
;
AssetFileDescriptor
afd
=
null
;
final
Uri
wordListUri
=
wordListUriBuilder
.
build
();
try
{
try
{
// Open input.
// Open input.
afd
=
openAssetFileDescriptor
(
resolver
,
wordListUri
);
afd
=
openAssetFileDescriptor
(
resolver
,
wordListUri
);
...
@@ -190,7 +194,9 @@ public class BinaryDictionaryFileDumper {
...
@@ -190,7 +194,9 @@ public class BinaryDictionaryFileDumper {
break
;
break
;
}
}
checkMagicAndCopyFileTo
(
new
BufferedInputStream
(
inputStream
),
outputStream
);
checkMagicAndCopyFileTo
(
new
BufferedInputStream
(
inputStream
),
outputStream
);
if
(
0
>=
resolver
.
delete
(
wordListUri
,
null
,
null
))
{
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"
);
Log
.
e
(
TAG
,
"Could not have the dictionary pack delete a word list"
);
}
}
BinaryDictionaryGetter
.
removeFilesWithIdExcept
(
context
,
id
,
outputFile
);
BinaryDictionaryGetter
.
removeFilesWithIdExcept
(
context
,
id
,
outputFile
);
...
@@ -226,9 +232,11 @@ public class BinaryDictionaryFileDumper {
...
@@ -226,9 +232,11 @@ public class BinaryDictionaryFileDumper {
// We could not copy the file at all. This is very unexpected.
// We could not copy the file at all. This is very unexpected.
// I'd rather not print the word list ID to the log out of security concerns
// I'd rather not print the word list ID to the log out of security concerns
Log
.
e
(
TAG
,
"Could not copy a word list. Will not be able to use it."
);
Log
.
e
(
TAG
,
"Could not copy a word list. Will not be able to use it."
);
// If we can't copy it we should probably delete it to avoid trying to copy it over
// If we can't copy it we should warn the dictionary provider so that it can mark it
// and over each time we open LatinIME.
// as invalid.
if
(
0
>=
resolver
.
delete
(
wordListUri
,
null
,
null
))
{
wordListUriBuilder
.
appendQueryParameter
(
QUERY_PARAMETER_DELETE_RESULT
,
QUERY_PARAMETER_FAILURE
);
if
(
0
>=
resolver
.
delete
(
wordListUriBuilder
.
build
(),
null
,
null
))
{
Log
.
e
(
TAG
,
"In addition, we were unable to delete it."
);
Log
.
e
(
TAG
,
"In addition, we were unable to delete it."
);
}
}
return
null
;
return
null
;
...
...
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