am 71144266: skip backup if launcher is in a bad state
* commit '7114426665c21a11464147a8bb5e094b7949db42': skip backup if launcher is in a bad state
This commit is contained in:
@@ -50,9 +50,7 @@ import android.util.Base64;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
@@ -188,16 +186,20 @@ public class LauncherBackupHelper implements BackupHelper {
|
|||||||
Log.v(TAG, "lastBackupTime = " + lastBackupTime);
|
Log.v(TAG, "lastBackupTime = " + lastBackupTime);
|
||||||
|
|
||||||
ArrayList<Key> keys = new ArrayList<Key>();
|
ArrayList<Key> keys = new ArrayList<Key>();
|
||||||
try {
|
if (launcherIsReady()) {
|
||||||
backupFavorites(in, data, out, keys);
|
try {
|
||||||
backupScreens(in, data, out, keys);
|
backupFavorites(in, data, out, keys);
|
||||||
backupIcons(in, data, out, keys);
|
backupScreens(in, data, out, keys);
|
||||||
backupWidgets(in, data, out, keys);
|
backupIcons(in, data, out, keys);
|
||||||
} catch (IOException e) {
|
backupWidgets(in, data, out, keys);
|
||||||
Log.e(TAG, "launcher backup has failed", e);
|
} 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);
|
writeJournal(newState, out);
|
||||||
Log.v(TAG, "onBackup: wrote " + out.bytes + "b in " + out.rows + " rows.");
|
Log.v(TAG, "onBackup: wrote " + out.bytes + "b in " + out.rows + " rows.");
|
||||||
}
|
}
|
||||||
@@ -1129,6 +1131,26 @@ public class LauncherBackupHelper implements BackupHelper {
|
|||||||
return mIconCache != null;
|
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 class KeyParsingException extends Throwable {
|
||||||
private KeyParsingException(Throwable cause) {
|
private KeyParsingException(Throwable cause) {
|
||||||
super(cause);
|
super(cause);
|
||||||
|
|||||||
Reference in New Issue
Block a user