Java Code Examples for com.android.verifiedboot.storage.BasicLock

Following code examples demonstrate how to use com.android.verifiedboot.storage.BasicLockfrom android. These examples are extracted from various highly rated open source projects. You can directly use these code snippets or view their entire linked source code. These snippets are extracted to provide contextual information about how to use this class in the real world. These samples also let you understand some good practices on how to use com.android.verifiedboot.storage.BasicLockand various code implementation of this class.

    private Storage() {
        globalState = new GlobalStateImpl();
        osBackupImpl = new JcopBackupImpl();

        versionStorage = new VersionStorage(globalState);
        osBackupImpl.track(OsBackupInterface.TAG_VERSION_STORAGE,
                           versionStorage);

        lockStorage = new byte[4096];
        reservedMetadata = new byte[OWNER_LOCK_METADATA_SIZE];
        metadata = null;

        locks = new LockInterface[4];
        locks[LOCK_CARRIER] = new CarrierLock();
        osBackupImpl.track(OsBackupInterface.TAG_LOCK_CARRIER,
                           locks[LOCK_CARRIER]);

        locks[LOCK_DEVICE] = new BasicLock(NO_METADATA, NO_REQ_LOCKS);
        BasicLock lockRef = (BasicLock)locks[LOCK_DEVICE];
        lockRef.requireHLOS(true);
        osBackupImpl.track(OsBackupInterface.TAG_LOCK_DEVICE,
                           lockRef);

        locks[LOCK_BOOT] = new BasicLock(NO_METADATA, (short) 2);
        lockRef = (BasicLock)locks[LOCK_BOOT];
        lockRef.addRequiredLock(locks[LOCK_CARRIER]);
        lockRef.addRequiredLock(locks[LOCK_DEVICE]);
        lockRef.requireBootloader(true);
        osBackupImpl.track(OsBackupInterface.TAG_LOCK_BOOT,
                           lockRef);

        locks[LOCK_OWNER] = new BasicLock(OWNER_LOCK_METADATA_SIZE, (short) 1);
        lockRef = (BasicLock)locks[LOCK_OWNER];
        lockRef.addRequiredLock(locks[LOCK_BOOT]);
        lockRef.requireMetadata(true);
        osBackupImpl.track(OsBackupInterface.TAG_LOCK_OWNER,
                           lockRef);

        short offset = (short) 0;
        byte lockNum = (byte) 0;
        for ( ; lockNum < (byte) locks.length; ++lockNum) {
            if (locks[lockNum].getStorageNeeded() >
                (short)(lockStorage.length - offset)) {
                ISOException.throwIt((short) 0xfeed);
            }
            locks[lockNum].initialize(globalState, lockStorage, offset);
            offset += locks[lockNum].getStorageNeeded();
        }

    } 


Advertisement
Advertisement