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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations