Search in sources :

Example 6 with Nullable

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

the class ContentProviderClient method openTypedAssetFileDescriptor.

/** See {@link ContentProvider#openTypedAssetFile ContentProvider.openTypedAssetFile} */
@Nullable
public final AssetFileDescriptor openTypedAssetFileDescriptor(@NonNull Uri uri, @NonNull String mimeType, @Nullable Bundle opts, @Nullable CancellationSignal signal) throws RemoteException, FileNotFoundException {
    Preconditions.checkNotNull(uri, "uri");
    Preconditions.checkNotNull(mimeType, "mimeType");
    beforeRemote();
    try {
        ICancellationSignal remoteSignal = null;
        if (signal != null) {
            signal.throwIfCanceled();
            remoteSignal = mContentProvider.createCancellationSignal();
            signal.setRemote(remoteSignal);
        }
        return mContentProvider.openTypedAssetFile(mPackageName, uri, mimeType, opts, remoteSignal);
    } catch (DeadObjectException e) {
        if (!mStable) {
            mContentResolver.unstableProviderDied(mContentProvider);
        }
        throw e;
    } finally {
        afterRemote();
    }
}
Also used : ICancellationSignal(android.os.ICancellationSignal) DeadObjectException(android.os.DeadObjectException) Nullable(android.annotation.Nullable)

Example 7 with Nullable

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

the class ThemedResourceCache method getThemedLocked.

/**
     * Returns the cached data for the specified theme, optionally creating a
     * new entry if one does not already exist.
     *
     * @param t the theme for which to return cached data
     * @param create {@code true} to create an entry if one does not already
     *               exist, {@code false} otherwise
     * @return the cached data for the theme, or {@code null} if the cache is
     *         empty and {@code create} was {@code false}
     */
@Nullable
private LongSparseArray<WeakReference<T>> getThemedLocked(@Nullable Theme t, boolean create) {
    if (t == null) {
        if (mNullThemedEntries == null && create) {
            mNullThemedEntries = new LongSparseArray<>(1);
        }
        return mNullThemedEntries;
    }
    if (mThemedEntries == null) {
        if (create) {
            mThemedEntries = new ArrayMap<>(1);
        } else {
            return null;
        }
    }
    final ThemeKey key = t.getKey();
    LongSparseArray<WeakReference<T>> cache = mThemedEntries.get(key);
    if (cache == null && create) {
        cache = new LongSparseArray<>(1);
        final ThemeKey keyClone = key.clone();
        mThemedEntries.put(keyClone, cache);
    }
    return cache;
}
Also used : ThemeKey(android.content.res.Resources.ThemeKey) WeakReference(java.lang.ref.WeakReference) Nullable(android.annotation.Nullable)

Example 8 with Nullable

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

the class CryptoHelper method decryptBundle.

@Nullable
/* default */
Bundle decryptBundle(@NonNull Bundle bundle) throws GeneralSecurityException {
    Preconditions.checkNotNull(bundle, "Cannot decrypt null bundle.");
    byte[] iv = bundle.getByteArray(KEY_IV);
    byte[] encryptedBytes = bundle.getByteArray(KEY_CIPHER);
    byte[] mac = bundle.getByteArray(KEY_MAC);
    if (!verifyMac(encryptedBytes, iv, mac)) {
        Log.w(TAG, "Escrow mac mismatched!");
        return null;
    }
    IvParameterSpec ivSpec = new IvParameterSpec(iv);
    Cipher cipher = Cipher.getInstance(CIPHER_ALGORITHM);
    cipher.init(Cipher.DECRYPT_MODE, mEncryptionKey, ivSpec);
    byte[] decryptedBytes = cipher.doFinal(encryptedBytes);
    Parcel decryptedParcel = Parcel.obtain();
    decryptedParcel.unmarshall(decryptedBytes, 0, decryptedBytes.length);
    decryptedParcel.setDataPosition(0);
    Bundle decryptedBundle = new Bundle();
    decryptedBundle.readFromParcel(decryptedParcel);
    decryptedParcel.recycle();
    return decryptedBundle;
}
Also used : Parcel(android.os.Parcel) Bundle(android.os.Bundle) IvParameterSpec(javax.crypto.spec.IvParameterSpec) Cipher(javax.crypto.Cipher) Nullable(android.annotation.Nullable)

Example 9 with Nullable

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

the class UserState method getPrintServices.

@Nullable
public List<PrintServiceInfo> getPrintServices(int selectionFlags) {
    synchronized (mLock) {
        List<PrintServiceInfo> selectedServices = null;
        final int installedServiceCount = mInstalledServices.size();
        for (int i = 0; i < installedServiceCount; i++) {
            PrintServiceInfo installedService = mInstalledServices.get(i);
            ComponentName componentName = new ComponentName(installedService.getResolveInfo().serviceInfo.packageName, installedService.getResolveInfo().serviceInfo.name);
            // Update isEnabled under the same lock the final returned list is created
            installedService.setIsEnabled(mActiveServices.containsKey(componentName));
            if (installedService.isEnabled()) {
                if ((selectionFlags & PrintManager.ENABLED_SERVICES) == 0) {
                    continue;
                }
            } else {
                if ((selectionFlags & PrintManager.DISABLED_SERVICES) == 0) {
                    continue;
                }
            }
            if (selectedServices == null) {
                selectedServices = new ArrayList<>();
            }
            selectedServices.add(installedService);
        }
        return selectedServices;
    }
}
Also used : PrintServiceInfo(android.printservice.PrintServiceInfo) ComponentName(android.content.ComponentName) Nullable(android.annotation.Nullable)

Example 10 with Nullable

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

the class InputManagerService method getKeyboardLayoutForInputDevice.

// Binder call
@Override
@Nullable
public KeyboardLayout getKeyboardLayoutForInputDevice(InputDeviceIdentifier identifier, InputMethodInfo imeInfo, InputMethodSubtype imeSubtype) {
    InputMethodSubtypeHandle handle = new InputMethodSubtypeHandle(imeInfo, imeSubtype);
    String key = getLayoutDescriptor(identifier);
    final String keyboardLayoutDescriptor;
    synchronized (mDataStore) {
        keyboardLayoutDescriptor = mDataStore.getKeyboardLayout(key, handle);
    }
    if (keyboardLayoutDescriptor == null) {
        return null;
    }
    final KeyboardLayout[] result = new KeyboardLayout[1];
    visitKeyboardLayout(keyboardLayoutDescriptor, new KeyboardLayoutVisitor() {

        @Override
        public void visitKeyboardLayout(Resources resources, int keyboardLayoutResId, KeyboardLayout layout) {
            result[0] = layout;
        }
    });
    if (result[0] == null) {
        Slog.w(TAG, "Could not get keyboard layout with descriptor '" + keyboardLayoutDescriptor + "'.");
    }
    return result[0];
}
Also used : InputMethodSubtypeHandle(com.android.internal.inputmethod.InputMethodSubtypeHandle) KeyboardLayout(android.hardware.input.KeyboardLayout) Resources(android.content.res.Resources) Nullable(android.annotation.Nullable)

Aggregations

Nullable (android.annotation.Nullable)368 RemoteException (android.os.RemoteException)40 Intent (android.content.Intent)39 DeadObjectException (android.os.DeadObjectException)35 ICancellationSignal (android.os.ICancellationSignal)35 IOException (java.io.IOException)29 FileNotFoundException (java.io.FileNotFoundException)28 File (java.io.File)26 Resources (android.content.res.Resources)25 Implementation (org.robolectric.annotation.Implementation)25 CppAssetManager2 (org.robolectric.res.android.CppAssetManager2)24 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)24 Configuration (android.content.res.Configuration)22 ResourcesImpl (android.content.res.ResourcesImpl)20 Drawable (android.graphics.drawable.Drawable)20 TypedArray (android.content.res.TypedArray)17 ByteBuffer (java.nio.ByteBuffer)16 ComponentName (android.content.ComponentName)15 ResolveInfo (android.content.pm.ResolveInfo)15 NotFoundException (android.content.res.Resources.NotFoundException)15