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


Java Preconditions.checkState方法代码示例

本文整理汇总了Java中com.android.internal.util.Preconditions.checkState方法的典型用法代码示例。如果您正苦于以下问题:Java Preconditions.checkState方法的具体用法?Java Preconditions.checkState怎么用?Java Preconditions.checkState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.android.internal.util.Preconditions的用法示例。


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

示例1: getRestoreData

import com.android.internal.util.Preconditions; //导入方法依赖的package包/类
@Override
public int getRestoreData(ParcelFileDescriptor outputFileDescriptor) {
    Preconditions.checkState(restoreState != null, "startRestore() not called");
    Preconditions.checkState(restoreState.getPackageIndex() >= 0, "nextRestorePackage() not called");
    Preconditions.checkState(restoreState.getRestoreType() == TYPE_KEY_VALUE,
            "getRestoreData() for non-key/value dataset");

    PackageInfo packageInfo = restoreState.getPackages()[restoreState.getPackageIndex()];

    try {
        return transferIncrementalRestoreData(packageInfo.packageName, outputFileDescriptor);

    } catch (Exception ex) {
        Log.e(TAG, "Unable to read backup records: ", ex);
        return TRANSPORT_ERROR;
    }
}
 
开发者ID:stevesoltys,项目名称:backup,代码行数:18,代码来源:ContentProviderRestoreComponent.java

示例2: initialize

import com.android.internal.util.Preconditions; //导入方法依赖的package包/类
public void initialize(BackupComponent backupComponent, RestoreComponent restoreComponent) {
    Preconditions.checkNotNull(backupComponent);
    Preconditions.checkNotNull(restoreComponent);
    Preconditions.checkState(!isActive());

    this.restoreComponent = restoreComponent;
    this.backupComponent = backupComponent;
}
 
开发者ID:stevesoltys,项目名称:backup,代码行数:9,代码来源:ConfigurableBackupTransport.java

示例3: build

import com.android.internal.util.Preconditions; //导入方法依赖的package包/类
public ContentProviderBackupConfiguration build() {
    Preconditions.checkState(context != null, "Context must be set.");
    Preconditions.checkState(outputUri != null, "Output URI must be set.");
    Preconditions.checkState(packages != null, "Package list must be set.");
    Preconditions.checkState(incrementalBackupDirectory != null, "Incremental backup directory must be set.");
    Preconditions.checkState(fullBackupDirectory != null, "Full backup directory must be set.");

    return new ContentProviderBackupConfiguration(context, outputUri, packages, backupSizeQuota,
            fullBackupDirectory, incrementalBackupDirectory);
}
 
开发者ID:stevesoltys,项目名称:backup,代码行数:11,代码来源:ContentProviderBackupConfigurationBuilder.java

示例4: getNextFullRestoreDataChunk

import com.android.internal.util.Preconditions; //导入方法依赖的package包/类
@Override
public int getNextFullRestoreDataChunk(ParcelFileDescriptor outputFileDescriptor) {
    Preconditions.checkState(restoreState.getRestoreType() == TYPE_FULL_STREAM,
            "Asked for full restore data for non-stream package");

    ParcelFileDescriptor inputFileDescriptor = restoreState.getInputFileDescriptor();

    if (inputFileDescriptor == null) {
        String name = restoreState.getPackages()[restoreState.getPackageIndex()].packageName;

        try {
            inputFileDescriptor = buildInputFileDescriptor();
            restoreState.setInputFileDescriptor(inputFileDescriptor);

            ZipInputStream inputStream = buildInputStream(inputFileDescriptor);
            restoreState.setInputStream(inputStream);

            if (!seekToEntry(inputStream, configuration.getFullBackupDirectory() + name).isPresent()) {
                IoUtils.closeQuietly(inputFileDescriptor);
                IoUtils.closeQuietly(outputFileDescriptor);
                return TRANSPORT_PACKAGE_REJECTED;
            }

        } catch (IOException ex) {
            Log.e(TAG, "Unable to read archive for " + name, ex);

            IoUtils.closeQuietly(inputFileDescriptor);
            IoUtils.closeQuietly(outputFileDescriptor);
            return TRANSPORT_PACKAGE_REJECTED;
        }
    }

    return transferFullRestoreData(outputFileDescriptor);
}
 
开发者ID:stevesoltys,项目名称:backup,代码行数:35,代码来源:ContentProviderRestoreComponent.java

示例5: resetFullRestoreState

import com.android.internal.util.Preconditions; //导入方法依赖的package包/类
private void resetFullRestoreState() {
    Preconditions.checkNotNull(restoreState);
    Preconditions.checkState(restoreState.getRestoreType() == TYPE_FULL_STREAM);

    IoUtils.closeQuietly(restoreState.getInputFileDescriptor());
    restoreState = null;
}
 
开发者ID:stevesoltys,项目名称:backup,代码行数:8,代码来源:ContentProviderRestoreComponent.java


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