本文整理匯總了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;
}
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}