當前位置: 首頁>>代碼示例>>Java>>正文


Java Preconditions類代碼示例

本文整理匯總了Java中com.android.internal.util.Preconditions的典型用法代碼示例。如果您正苦於以下問題:Java Preconditions類的具體用法?Java Preconditions怎麽用?Java Preconditions使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Preconditions類屬於com.android.internal.util包,在下文中一共展示了Preconditions類的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: StorageVolume

import com.android.internal.util.Preconditions; //導入依賴的package包/類
public StorageVolume(String id, int storageId, File path, String description, boolean primary,
                     boolean removable, boolean emulated, long mtpReserveSize, boolean allowMassStorage,
                     long maxFileSize, UserHandle owner, String fsUuid, String state) {
    mId = Preconditions.checkNotNull(id);
    mStorageId = storageId;
    mPath = Preconditions.checkNotNull(path);
    mDescription = Preconditions.checkNotNull(description);
    mPrimary = primary;
    mRemovable = removable;
    mEmulated = emulated;
    mMtpReserveSize = mtpReserveSize;
    mAllowMassStorage = allowMassStorage;
    mMaxFileSize = maxFileSize;
    mOwner = Preconditions.checkNotNull(owner);
    mFsUuid = fsUuid;
    mState = Preconditions.checkNotNull(state);
}
 
開發者ID:meonwax,項目名稱:soundboard,代碼行數:18,代碼來源:StorageVolume.java

示例3: 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

示例4: 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

示例5: nextRestorePackage

import com.android.internal.util.Preconditions; //導入依賴的package包/類
@Override
public RestoreDescription nextRestorePackage() {
    Preconditions.checkNotNull(restoreState, "startRestore() not called");

    int packageIndex = restoreState.getPackageIndex();
    PackageInfo[] packages = restoreState.getPackages();

    while (++packageIndex < packages.length) {
        restoreState.setPackageIndex(packageIndex);
        String name = packages[packageIndex].packageName;

        try {
            if (containsPackageFile(configuration.getIncrementalBackupDirectory() + name)) {
                restoreState.setRestoreType(TYPE_KEY_VALUE);
                return new RestoreDescription(name, restoreState.getRestoreType());

            } else if (containsPackageFile(configuration.getFullBackupDirectory() + name)) {
                restoreState.setRestoreType(TYPE_FULL_STREAM);
                return new RestoreDescription(name, restoreState.getRestoreType());
            }

        } catch (IOException | InvalidKeyException | InvalidAlgorithmParameterException ex) {
            Log.e(TAG, "Error choosing package  " + name + "  at index " + packageIndex + "failed selection:", ex);
        }
    }
    return RestoreDescription.NO_MORE_PACKAGES;
}
 
開發者ID:stevesoltys,項目名稱:backup,代碼行數:28,代碼來源:ContentProviderRestoreComponent.java

示例6: 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

示例7: 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

示例8: getIntentForStatusPanel

import com.android.internal.util.Preconditions; //導入依賴的package包/類
public static PendingIntent getIntentForStatusPanel(Context context, VpnConfig config) {
    Preconditions.checkNotNull(config);

    Intent intent = new Intent();
    intent.setClassName(DIALOGS_PACKAGE, DIALOGS_PACKAGE + ".ManageDialog");
    intent.putExtra("config", config);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_HISTORY |
            Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
    return PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
}
 
開發者ID:moezbhatti,項目名稱:qksms,代碼行數:11,代碼來源:VpnConfig.java


注:本文中的com.android.internal.util.Preconditions類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。