Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6b904c8f authored by Christopher Tate's avatar Christopher Tate Committed by Android (Google) Code Review
Browse files

Merge "App widget backup/restore infrastructure"

parents 160c9c8e adfe8b86
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -4976,15 +4976,19 @@ package android.appwidget {
    field public static final java.lang.String ACTION_APPWIDGET_DELETED = "android.appwidget.action.APPWIDGET_DELETED";
    field public static final java.lang.String ACTION_APPWIDGET_DISABLED = "android.appwidget.action.APPWIDGET_DISABLED";
    field public static final java.lang.String ACTION_APPWIDGET_ENABLED = "android.appwidget.action.APPWIDGET_ENABLED";
    field public static final java.lang.String ACTION_APPWIDGET_HOST_RESTORED = "android.appwidget.action.APPWIDGET_HOST_RESTORED";
    field public static final java.lang.String ACTION_APPWIDGET_OPTIONS_CHANGED = "android.appwidget.action.APPWIDGET_UPDATE_OPTIONS";
    field public static final java.lang.String ACTION_APPWIDGET_PICK = "android.appwidget.action.APPWIDGET_PICK";
    field public static final java.lang.String ACTION_APPWIDGET_RESTORED = "android.appwidget.action.APPWIDGET_RESTORED";
    field public static final java.lang.String ACTION_APPWIDGET_UPDATE = "android.appwidget.action.APPWIDGET_UPDATE";
    field public static final java.lang.String EXTRA_APPWIDGET_ID = "appWidgetId";
    field public static final java.lang.String EXTRA_APPWIDGET_IDS = "appWidgetIds";
    field public static final java.lang.String EXTRA_APPWIDGET_OLD_IDS = "appWidgetOldIds";
    field public static final java.lang.String EXTRA_APPWIDGET_OPTIONS = "appWidgetOptions";
    field public static final java.lang.String EXTRA_APPWIDGET_PROVIDER = "appWidgetProvider";
    field public static final java.lang.String EXTRA_CUSTOM_EXTRAS = "customExtras";
    field public static final java.lang.String EXTRA_CUSTOM_INFO = "customInfo";
    field public static final java.lang.String EXTRA_HOST_ID = "hostId";
    field public static final int INVALID_APPWIDGET_ID = 0; // 0x0
    field public static final java.lang.String META_DATA_APPWIDGET_PROVIDER = "android.appwidget.provider";
    field public static final java.lang.String OPTION_APPWIDGET_HOST_CATEGORY = "appWidgetCategory";
@@ -5001,6 +5005,7 @@ package android.appwidget {
    method public void onDisabled(android.content.Context);
    method public void onEnabled(android.content.Context);
    method public void onReceive(android.content.Context, android.content.Intent);
    method public void onRestored(android.content.Context, int[], int[]);
    method public void onUpdate(android.content.Context, android.appwidget.AppWidgetManager, int[]);
  }
+7 −2
Original line number Diff line number Diff line
@@ -68,6 +68,7 @@ public final class Backup {
        boolean saveObbs = false;
        boolean saveShared = false;
        boolean doEverything = false;
        boolean doWidgets = false;
        boolean allIncludesSystem = true;

        String arg;
@@ -89,6 +90,10 @@ public final class Backup {
                    allIncludesSystem = true;
                } else if ("-nosystem".equals(arg)) {
                    allIncludesSystem = false;
                } else if ("-widgets".equals(arg)) {
                    doWidgets = true;
                } else if ("-nowidgets".equals(arg)) {
                    doWidgets = false;
                } else if ("-all".equals(arg)) {
                    doEverything = true;
                } else {
@@ -114,8 +119,8 @@ public final class Backup {
        try {
            fd = ParcelFileDescriptor.adoptFd(socketFd);
            String[] packArray = new String[packages.size()];
            mBackupManager.fullBackup(fd, saveApks, saveObbs, saveShared, doEverything,
                    allIncludesSystem, packages.toArray(packArray));
            mBackupManager.fullBackup(fd, saveApks, saveObbs, saveShared, doWidgets,
                    doEverything, allIncludesSystem, packages.toArray(packArray));
        } catch (RemoteException e) {
            Log.e(TAG, "Unable to invoke backup manager for backup");
        } finally {
+10 −2
Original line number Diff line number Diff line
@@ -76,8 +76,9 @@ oneway interface IBackupAgent {
     * @param callbackBinder Binder on which to indicate operation completion,
     *        passed here as a convenience to the agent.
     */
    void doRestore(in ParcelFileDescriptor data, int appVersionCode,
            in ParcelFileDescriptor newState, int token, IBackupManager callbackBinder);
    void doRestore(in ParcelFileDescriptor data,
            int appVersionCode, in ParcelFileDescriptor newState,
            int token, IBackupManager callbackBinder);

    /**
     * Perform a "full" backup to the given file descriptor.  The output file is presumed
@@ -112,8 +113,15 @@ oneway interface IBackupAgent {
     * @param path Relative path of the file within its semantic domain.
     * @param mode Access mode of the file system entity, e.g. 0660.
     * @param mtime Last modification time of the file system entity.
     * @param token Opaque token identifying this transaction.  This must
     *        be echoed back to the backup service binder once the agent is
     *        finished restoring the application based on the restore data
     *        contents.
     * @param callbackBinder Binder on which to indicate operation completion,
     *        passed here as a convenience to the agent.
     */
    void doRestoreFile(in ParcelFileDescriptor data, long size,
            int type, String domain, String path, long mode, long mtime,
            int token, IBackupManager callbackBinder);

}
+8 −1
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package android.app.backup;

import android.os.ParcelFileDescriptor;
import android.os.Process;

import java.io.FileDescriptor;
import java.io.IOException;
@@ -76,13 +77,19 @@ public class BackupDataOutput {
    /**
     * Mark the beginning of one record in the backup data stream. This must be called before
     * {@link #writeEntityData}.
     * @param key A string key that uniquely identifies the data record within the application
     * @param key A string key that uniquely identifies the data record within the application.
     *    Keys whose first character is \uFF00 or higher are not valid.
     * @param dataSize The size in bytes of this record's data.  Passing a dataSize
     *    of -1 indicates that the record under this key should be deleted.
     * @return The number of bytes written to the backup stream
     * @throws IOException if the write failed
     */
    public int writeEntityHeader(String key, int dataSize) throws IOException {
        if (key != null && key.charAt(0) >= 0xff00) {
            if (Process.myUid() != Process.SYSTEM_UID) {
                throw new IllegalArgumentException("Invalid key " + key);
            }
        }
        int result = writeEntityHeader_native(mBackupWriter, key, dataSize);
        if (result >= 0) {
            return result;
+1 −1
Original line number Diff line number Diff line
@@ -167,7 +167,7 @@ interface IBackupManager {
     *     are to be backed up.  The <code>allApps</code> parameter supersedes this.
     */
    void fullBackup(in ParcelFileDescriptor fd, boolean includeApks, boolean includeObbs,
            boolean includeShared, boolean allApps, boolean allIncludesSystem,
            boolean includeShared, boolean doWidgets, boolean allApps, boolean allIncludesSystem,
            in String[] packageNames);

    /**
Loading