Search in sources :

Example 46 with NonNull

use of android.annotation.NonNull in project android_frameworks_base by ResurrectionRemix.

the class PackageManagerSettingsTests method createFakeUsers.

@NonNull
private List<UserInfo> createFakeUsers() {
    ArrayList<UserInfo> users = new ArrayList<>();
    users.add(new UserInfo(UserHandle.USER_SYSTEM, "test user", UserInfo.FLAG_INITIALIZED));
    return users;
}
Also used : ArrayList(java.util.ArrayList) UserInfo(android.content.pm.UserInfo) NonNull(android.annotation.NonNull)

Example 47 with NonNull

use of android.annotation.NonNull in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class PhysicalKeyboardFragment method getHardKeyboards.

@NonNull
private static ArrayList<HardKeyboardDeviceInfo> getHardKeyboards() {
    final ArrayList<HardKeyboardDeviceInfo> keyboards = new ArrayList<>();
    final int[] devicesIds = InputDevice.getDeviceIds();
    for (int deviceId : devicesIds) {
        final InputDevice device = InputDevice.getDevice(deviceId);
        if (device != null && !device.isVirtual() && device.isFullKeyboard()) {
            keyboards.add(new HardKeyboardDeviceInfo(device.getName(), device.getIdentifier()));
        }
    }
    return keyboards;
}
Also used : InputDevice(android.view.InputDevice) ArrayList(java.util.ArrayList) NonNull(android.annotation.NonNull)

Example 48 with NonNull

use of android.annotation.NonNull in project android_frameworks_base by ResurrectionRemix.

the class CameraManager method getCameraCharacteristics.

/**
     * <p>Query the capabilities of a camera device. These capabilities are
     * immutable for a given camera.</p>
     *
     * @param cameraId The id of the camera device to query
     * @return The properties of the given camera
     *
     * @throws IllegalArgumentException if the cameraId does not match any
     *         known camera device.
     * @throws CameraAccessException if the camera device has been disconnected.
     *
     * @see #getCameraIdList
     * @see android.app.admin.DevicePolicyManager#setCameraDisabled
     */
@NonNull
public CameraCharacteristics getCameraCharacteristics(@NonNull String cameraId) throws CameraAccessException {
    CameraCharacteristics characteristics = null;
    synchronized (mLock) {
        if (!getOrCreateDeviceIdListLocked().contains(cameraId)) {
            throw new IllegalArgumentException(String.format("Camera id %s does not match any" + " currently connected camera device", cameraId));
        }
        int id = Integer.parseInt(cameraId);
        /*
             * Get the camera characteristics from the camera service directly if it supports it,
             * otherwise get them from the legacy shim instead.
             */
        ICameraService cameraService = CameraManagerGlobal.get().getCameraService();
        if (cameraService == null) {
            throw new CameraAccessException(CameraAccessException.CAMERA_DISCONNECTED, "Camera service is currently unavailable");
        }
        try {
            if (!supportsCamera2ApiLocked(cameraId)) {
                // Legacy backwards compatibility path; build static info from the camera
                // parameters
                String parameters = cameraService.getLegacyParameters(id);
                CameraInfo info = cameraService.getCameraInfo(id);
                characteristics = LegacyMetadataMapper.createCharacteristics(parameters, info);
            } else {
                // Normal path: Get the camera characteristics directly from the camera service
                CameraMetadataNative info = cameraService.getCameraCharacteristics(id);
                characteristics = new CameraCharacteristics(info);
            }
        } catch (ServiceSpecificException e) {
            throwAsPublicException(e);
        } catch (RemoteException e) {
            // Camera service died - act as if the camera was disconnected
            throw new CameraAccessException(CameraAccessException.CAMERA_DISCONNECTED, "Camera service is currently unavailable", e);
        }
    }
    return characteristics;
}
Also used : ServiceSpecificException(android.os.ServiceSpecificException) CameraMetadataNative(android.hardware.camera2.impl.CameraMetadataNative) RemoteException(android.os.RemoteException) ICameraService(android.hardware.ICameraService) CameraInfo(android.hardware.CameraInfo) NonNull(android.annotation.NonNull)

Example 49 with NonNull

use of android.annotation.NonNull in project android_frameworks_base by ResurrectionRemix.

the class FontFamily_Delegate method deriveFont.

/**
     * Try to derive a font from {@code srcFont} for the style in {@code outFont}.
     * <p/>
     * {@code outFont} is updated to reflect the style of the derived font.
     * @param srcFont the source font
     * @param outFont contains the desired font style. Updated to contain the derived font and
     *                its style
     * @return outFont
     */
@NonNull
private FontInfo deriveFont(@NonNull FontInfo srcFont, @NonNull FontInfo outFont) {
    int desiredWeight = outFont.mWeight;
    int srcWeight = srcFont.mWeight;
    assert srcFont.mFont != null;
    Font derivedFont = srcFont.mFont;
    // Embolden the font if required.
    if (desiredWeight >= BOLD_FONT_WEIGHT && desiredWeight - srcWeight > BOLD_FONT_WEIGHT_DELTA / 2) {
        derivedFont = derivedFont.deriveFont(Font.BOLD);
        srcWeight += BOLD_FONT_WEIGHT_DELTA;
    }
    // Italicize the font if required.
    if (outFont.mIsItalic && !srcFont.mIsItalic) {
        derivedFont = derivedFont.deriveFont(Font.ITALIC);
    } else if (outFont.mIsItalic != srcFont.mIsItalic) {
        // The desired font is plain, but the src font is italics. We can't convert it back. So
        // we update the value to reflect the true style of the font we're deriving.
        outFont.mIsItalic = srcFont.mIsItalic;
    }
    outFont.mFont = derivedFont;
    outFont.mWeight = srcWeight;
    // No need to update mIsItalics, as it's already been handled above.
    return outFont;
}
Also used : Font(java.awt.Font) NonNull(android.annotation.NonNull)

Example 50 with NonNull

use of android.annotation.NonNull in project android_frameworks_base by ResurrectionRemix.

the class CryptoHelper method encryptBundle.

@NonNull
/* default */
Bundle encryptBundle(@NonNull Bundle bundle) throws GeneralSecurityException {
    Preconditions.checkNotNull(bundle, "Cannot encrypt null bundle.");
    Parcel parcel = Parcel.obtain();
    bundle.writeToParcel(parcel, 0);
    byte[] clearBytes = parcel.marshall();
    parcel.recycle();
    Cipher cipher = Cipher.getInstance(CIPHER_ALGORITHM);
    cipher.init(Cipher.ENCRYPT_MODE, mEncryptionKey);
    byte[] encryptedBytes = cipher.doFinal(clearBytes);
    byte[] iv = cipher.getIV();
    byte[] mac = createMac(encryptedBytes, iv);
    Bundle encryptedBundle = new Bundle();
    encryptedBundle.putByteArray(KEY_CIPHER, encryptedBytes);
    encryptedBundle.putByteArray(KEY_MAC, mac);
    encryptedBundle.putByteArray(KEY_IV, iv);
    return encryptedBundle;
}
Also used : Parcel(android.os.Parcel) Bundle(android.os.Bundle) Cipher(javax.crypto.Cipher) NonNull(android.annotation.NonNull)

Aggregations

NonNull (android.annotation.NonNull)322 ArrayList (java.util.ArrayList)46 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)45 IOException (java.io.IOException)35 ComponentName (android.content.ComponentName)25 File (java.io.File)22 XmlPullParser (org.xmlpull.v1.XmlPullParser)20 Intent (android.content.Intent)18 EphemeralResolveInfo (android.content.pm.EphemeralResolveInfo)16 ResolveInfo (android.content.pm.ResolveInfo)16 Bundle (android.os.Bundle)15 RemoteException (android.os.RemoteException)15 FileNotFoundException (java.io.FileNotFoundException)15 Paint (android.graphics.Paint)14 PackageParser (android.content.pm.PackageParser)12 ContentResolver (android.content.ContentResolver)10 UserInfo (android.content.pm.UserInfo)10 StorageManager (android.os.storage.StorageManager)10 VolumeInfo (android.os.storage.VolumeInfo)10 KeyCharacteristics (android.security.keymaster.KeyCharacteristics)10