当前位置: 首页>>代码示例>>Java>>正文


Java BackupDataInput类代码示例

本文整理汇总了Java中android.app.backup.BackupDataInput的典型用法代码示例。如果您正苦于以下问题:Java BackupDataInput类的具体用法?Java BackupDataInput怎么用?Java BackupDataInput使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


BackupDataInput类属于android.app.backup包,在下文中一共展示了BackupDataInput类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: performIncrementalBackup

import android.app.backup.BackupDataInput; //导入依赖的package包/类
@Override
public int performIncrementalBackup(PackageInfo packageInfo, ParcelFileDescriptor data) {
    BackupDataInput backupDataInput = new BackupDataInput(data.getFileDescriptor());

    try {
        initializeBackupState();
        backupState.setPackageIndex(backupState.getPackageIndex() + 1);
        backupState.setPackageName(packageInfo.packageName);

        return transferIncrementalBackupData(backupDataInput);

    } catch (Exception ex) {
        Log.e(TAG, "Error reading backup input: ", ex);
        return TRANSPORT_ERROR;
    }
}
 
开发者ID:stevesoltys,项目名称:backup,代码行数:17,代码来源:ContentProviderBackupComponent.java

示例2: onRestore

import android.app.backup.BackupDataInput; //导入依赖的package包/类
@Override
public void onRestore(BackupDataInput data, int appVersionCode,
    ParcelFileDescriptor newState) throws IOException {
  Log.i(TAG, "Restoring from backup");
  while (data.readNextHeader()) {
    String key = data.getKey();
    Log.d(TAG, "Restoring entity " + key);
    if (key.equals(PREFERENCES_ENTITY)) {
      restorePreferences(data);
    } else {
      Log.e(TAG, "Found unknown backup entity: " + key);
      data.skipEntityData();
    }
  }
  Log.i(TAG, "Done restoring from backup");
}
 
开发者ID:Plonk42,项目名称:mytracks,代码行数:17,代码来源:MyTracksBackupAgent.java

示例3: onRestore

import android.app.backup.BackupDataInput; //导入依赖的package包/类
@Override
public void onRestore(BackupDataInput data, int appVersionCode, ParcelFileDescriptor newState)
        throws IOException {
    Analytics.event(EventType.BACKUP_RESTORE, "onRestore -> current",
            appVersionCode + "/" + BuildConfig.VERSION_CODE);

    lock.lock();
    try {
        Timber.d("onRestore in-lock");
        super.onRestore(data, appVersionCode, newState);
        if (appVersionCode < 22) {
            // migrate db to db.ver=3
            Database.restart(this.getApplicationContext());
        }
    } finally {
        lock.unlock();
    }
}
 
开发者ID:sewerk,项目名称:Bill-Calculator,代码行数:19,代码来源:PrefsAndDbBackupAgent.java

示例4: onRestore

import android.app.backup.BackupDataInput; //导入依赖的package包/类
@Override
public void onRestore(BackupDataInput data, int appVersionCode, ParcelFileDescriptor newState) throws IOException {
    synchronized (GeoPingBackupAgent.sDataLock) {
        Log.i(TAG, "----- ----- ----- ----- ----- ----- ----- ----- ----- ");
        Log.i(TAG, "----- ----- ----- ----- ----- ----- ----- ----- ----- ");
        Log.i(TAG, "----- onRestore GeoPing Backup : Version = " + appVersionCode);
        Log.i(TAG, "----- onRestore GeoPing Backup --- Begin");
        super.onRestore(data, appVersionCode, newState);
        // Apply Prefs Config
        try {
            applyPrefsConfig();
        } catch (Throwable e) {
            Log.e(TAG, "Error Prefs Config Apply to Service : " + e.getMessage(), e);
        }

        Log.i(TAG, "----- onRestore GeoPing End --- End");
        Log.i(TAG, "----- ----- ----- ----- ----- ----- ----- ----- ----- ");
        Log.i(TAG, "----- ----- ----- ----- ----- ----- ----- ----- ----- ");
    }
}
 
开发者ID:gabuzomeu,项目名称:geoPingProject,代码行数:21,代码来源:GeoPingBackupAgent.java

示例5: onRestore

import android.app.backup.BackupDataInput; //导入依赖的package包/类
@Override
public void onRestore(BackupDataInput data, int appVersionCode, ParcelFileDescriptor newState)
        throws IOException {
    Log.d(THIS_FILE, "App version code : " + appVersionCode);
    super.onRestore(data, appVersionCode, newState);


}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:9,代码来源:SipBackupAgent.java

示例6: transferIncrementalBackupData

import android.app.backup.BackupDataInput; //导入依赖的package包/类
private int transferIncrementalBackupData(BackupDataInput backupDataInput)
        throws IOException, InvalidAlgorithmParameterException, InvalidKeyException {

    ZipOutputStream outputStream = backupState.getOutputStream();

    int bufferSize = INITIAL_BUFFER_SIZE;
    byte[] buffer = new byte[bufferSize];

    while (backupDataInput.readNextHeader()) {
        String chunkFileName = Base64.encodeToString(backupDataInput.getKey().getBytes(), Base64.DEFAULT);
        int dataSize = backupDataInput.getDataSize();

        if (dataSize >= 0) {
            ZipEntry zipEntry = new ZipEntry(configuration.getIncrementalBackupDirectory() +
                    backupState.getPackageName() + "/" + chunkFileName);
            outputStream.putNextEntry(zipEntry);

            if (dataSize > bufferSize) {
                bufferSize = dataSize;
                buffer = new byte[bufferSize];
            }

            backupDataInput.readEntityData(buffer, 0, dataSize);

            try {
                outputStream.write(buffer, 0, dataSize);

            } catch (Exception ex) {
                Log.e(TAG, "Error performing incremental backup for " + backupState.getPackageName() + ": ", ex);
                clearBackupState(true);
                return TRANSPORT_ERROR;
            }
        }
    }

    return TRANSPORT_OK;
}
 
开发者ID:stevesoltys,项目名称:backup,代码行数:38,代码来源:ContentProviderBackupComponent.java

示例7: onRestore

import android.app.backup.BackupDataInput; //导入依赖的package包/类
/**
 * Adding locking around the file rewrite that happens during restore is
 * similarly straightforward.
 */
@Override
public void onRestore(BackupDataInput data, int appVersionCode,
        ParcelFileDescriptor newState) throws IOException {
    // Hold the lock while the FileBackupHelper restores the file from
    // the data provided here.
    synchronized (BackupRestoreActivity.sDataLock) {
        super.onRestore(data, appVersionCode, newState);
    }
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:14,代码来源:FileHelperExampleAgent.java

示例8: onRestore

import android.app.backup.BackupDataInput; //导入依赖的package包/类
@Override
public void onRestore(BackupDataInput data, int appVersionCode, ParcelFileDescriptor newState)
        throws IOException {
    // Let the restore operation go through
    super.onRestore(data, appVersionCode, newState);

    // Remove the preferences that we don't want restored.
    final SharedPreferences.Editor prefEditor = getSharedPreferences(
            getPackageName() + PREF_SUFFIX, MODE_PRIVATE).edit();
    for (final String key : LocalSettingsConstants.PREFS_TO_SKIP_RESTORING) {
        prefEditor.remove(key);
    }
    // Flush the changes to disk.
    prefEditor.commit();
}
 
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:16,代码来源:BackupAgent.java

示例9: restorePreferences

import android.app.backup.BackupDataInput; //导入依赖的package包/类
/**
 * Restores all preferences from the backup.
 * 
 * @param data the backup data to read from
 * @throws IOException if there are any errors while reading
 */
private void restorePreferences(BackupDataInput data) throws IOException {
  int dataSize = data.getDataSize();
  byte[] dataBuffer = new byte[dataSize];
  int read = data.readEntityData(dataBuffer, 0, dataSize);
  if (read != dataSize) {
    throw new IOException("Failed to read all the preferences data");
  }

  SharedPreferences preferences = this.getSharedPreferences(
      Constants.SETTINGS_NAME, Context.MODE_PRIVATE);
  PreferenceBackupHelper importer = createPreferenceBackupHelper();
  importer.importPreferences(dataBuffer, preferences);
}
 
开发者ID:Plonk42,项目名称:mytracks,代码行数:20,代码来源:MyTracksBackupAgent.java

示例10: onRestore

import android.app.backup.BackupDataInput; //导入依赖的package包/类
@Override
public void onRestore(BackupDataInput data, int appVersionCode,
		ParcelFileDescriptor newState) throws IOException {
	Log.d("ConnectBot.BackupAgent", "onRestore called");

	synchronized (HostDatabase.dbLock) {
		Log.d("ConnectBot.BackupAgent", "onRestore in-lock");

		super.onRestore(data, appVersionCode, newState);
	}
}
 
开发者ID:dragonlinux,项目名称:connectbot,代码行数:12,代码来源:BackupAgent.java

示例11: onRestore

import android.app.backup.BackupDataInput; //导入依赖的package包/类
@Override
public void onRestore(BackupDataInput data, int appVersionCode, ParcelFileDescriptor newState) throws IOException {
    Log.d(LOG_TAG, "onRestore called");

    synchronized (DbHelper.dbLock) {
        Log.d(LOG_TAG, "onRestore in-lock");

        super.onRestore(data, appVersionCode, newState);

        ContactsUtils.restoreRawContacts(this.getApplicationContext());
    }
}
 
开发者ID:bdiegel,项目名称:android-giftwise,代码行数:13,代码来源:BackupAgent.java

示例12: onRestore

import android.app.backup.BackupDataInput; //导入依赖的package包/类
@Override
public void onRestore(BackupDataInput data, int appVersionCode, ParcelFileDescriptor newState) throws IOException {
	super.onRestore(data, appVersionCode, newState);

	SharedPreferences.Editor editor = Util.getPreferences(this).edit();
	editor.remove(Constants.PREFERENCES_KEY_CACHE_LOCATION);
	editor.remove(Constants.CACHE_AUDIO_SESSION_ID);
	editor.apply();
}
 
开发者ID:popeen,项目名称:Popeens-DSub,代码行数:10,代码来源:SettingsBackupAgent.java

示例13: onRestore

import android.app.backup.BackupDataInput; //导入依赖的package包/类
@Override
public void onRestore(BackupDataInput data, int appVersionCode,
        ParcelFileDescriptor newState) throws IOException {
	
	Log.v(TAG, "onRestore called");
	
    // Hold the lock while the FileBackupHelper restores the file
    synchronized (StreamDatabase.dbLock) {
        super.onRestore(data, appVersionCode, newState);
    }
}
 
开发者ID:wseemann,项目名称:ServeStream,代码行数:12,代码来源:BackupAgent.java

示例14: onRestore

import android.app.backup.BackupDataInput; //导入依赖的package包/类
@Override
public void onRestore(BackupDataInput data, int appVersionCode, ParcelFileDescriptor newState)
        throws IOException {
    if (!Utilities.isLmpOrAbove()) {
        // No restore for old devices.
        Log.i(TAG, "You shall not pass!!!");
        Log.d(TAG, "Restore is only supported on devices running Lollipop and above.");
        return;
    }

    // Clear dB before restore
    LauncherAppState.getLauncherProvider().createEmptyDB();

    boolean hasData;
    try {
        super.onRestore(data, appVersionCode, newState);
        // If no favorite was migrated, clear the data and start fresh.
        final Cursor c = getContentResolver().query(
                LauncherSettings.Favorites.CONTENT_URI_NO_NOTIFICATION, null, null, null, null);
        hasData = c.moveToNext();
        c.close();
    } catch (Exception e) {
        // If the restore fails, we should do a fresh start.
        Log.e(TAG, "Restore failed", e);
        hasData = false;
    }

    if (hasData && mHelper.restoreSuccessful) {
        LauncherAppState.getLauncherProvider().clearFlagEmptyDbCreated();
        LauncherClings.synchonouslyMarkFirstRunClingDismissed(this);
    } else {
        if (VERBOSE) Log.v(TAG, "Nothing was restored, clearing DB");
        LauncherAppState.getLauncherProvider().createEmptyDB();
    }
}
 
开发者ID:AndroidDeveloperLB,项目名称:LB-Launcher,代码行数:36,代码来源:LauncherBackupAgentHelper.java

示例15: onRestore

import android.app.backup.BackupDataInput; //导入依赖的package包/类
@Override
public void onRestore(BackupDataInput data, int appVersionCode, ParcelFileDescriptor newState)
        throws IOException {
    // Hold the lock while the BackupHelper restores
    synchronized (SafeSlinger.sDataLock) {
        super.onRestore(data, appVersionCode, newState);
    }

    // store restoration time and cancel pending notifications...
    SafeSlingerPrefs.setRestoreCompleteDate(new Date().getTime());
    String ns = Context.NOTIFICATION_SERVICE;
    NotificationManager nm = (NotificationManager) getSystemService(ns);
    nm.cancel(HomeActivity.NOTIFY_BACKUP_DELAY_ID);
}
 
开发者ID:SafeSlingerProject,项目名称:SafeSlinger-Android,代码行数:15,代码来源:KeyBackupAgent.java


注:本文中的android.app.backup.BackupDataInput类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。