Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
halo
packages_apps_Launcher3
Commits
71144266
Commit
71144266
authored
11 years ago
by
Chris Wren
Browse files
Options
Download
Email Patches
Plain Diff
skip backup if launcher is in a bad state
Bug: 13153542 Change-Id: I4312ebd200e8e652ef841f54301981c2a486b726
parent
3de6ea86
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
10 deletions
+32
-10
src/com/android/launcher3/LauncherBackupHelper.java
src/com/android/launcher3/LauncherBackupHelper.java
+32
-10
No files found.
src/com/android/launcher3/LauncherBackupHelper.java
View file @
71144266
...
...
@@ -50,9 +50,7 @@ import android.util.Base64;
import
android.util.Log
;
import
java.io.ByteArrayOutputStream
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileNotFoundException
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.net.URISyntaxException
;
...
...
@@ -188,16 +186,20 @@ public class LauncherBackupHelper implements BackupHelper {
Log
.
v
(
TAG
,
"lastBackupTime = "
+
lastBackupTime
);
ArrayList
<
Key
>
keys
=
new
ArrayList
<
Key
>();
try
{
backupFavorites
(
in
,
data
,
out
,
keys
);
backupScreens
(
in
,
data
,
out
,
keys
);
backupIcons
(
in
,
data
,
out
,
keys
);
backupWidgets
(
in
,
data
,
out
,
keys
);
}
catch
(
IOException
e
)
{
Log
.
e
(
TAG
,
"launcher backup has failed"
,
e
);
if
(
launcherIsReady
())
{
try
{
backupFavorites
(
in
,
data
,
out
,
keys
);
backupScreens
(
in
,
data
,
out
,
keys
);
backupIcons
(
in
,
data
,
out
,
keys
);
backupWidgets
(
in
,
data
,
out
,
keys
);
}
catch
(
IOException
e
)
{
Log
.
e
(
TAG
,
"launcher backup has failed"
,
e
);
}
out
.
key
=
keys
.
toArray
(
new
BackupProtos
.
Key
[
keys
.
size
()]);
}
else
{
out
=
in
;
}
out
.
key
=
keys
.
toArray
(
new
BackupProtos
.
Key
[
keys
.
size
()]);
writeJournal
(
newState
,
out
);
Log
.
v
(
TAG
,
"onBackup: wrote "
+
out
.
bytes
+
"b in "
+
out
.
rows
+
" rows."
);
}
...
...
@@ -1129,6 +1131,26 @@ public class LauncherBackupHelper implements BackupHelper {
return
mIconCache
!=
null
;
}
// check if the launcher is in a state to support backup
private
boolean
launcherIsReady
()
{
ContentResolver
cr
=
mContext
.
getContentResolver
();
Cursor
cursor
=
cr
.
query
(
Favorites
.
CONTENT_URI
,
FAVORITE_PROJECTION
,
null
,
null
,
null
);
if
(
cursor
==
null
)
{
// launcher data has been wiped, do nothing
return
false
;
}
cursor
.
close
();
if
(!
initializeIconCache
())
{
// launcher services are unavailable, try again later
dataChanged
();
return
false
;
}
return
true
;
}
private
class
KeyParsingException
extends
Throwable
{
private
KeyParsingException
(
Throwable
cause
)
{
super
(
cause
);
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment