Search in sources :

Example 81 with Nullable

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

the class PackageManagerService method getSetupWizardPackageName.

@Nullable
private String getSetupWizardPackageName() {
    final Intent intent = new Intent(Intent.ACTION_MAIN);
    intent.addCategory(Intent.CATEGORY_SETUP_WIZARD);
    final List<ResolveInfo> matches = queryIntentActivitiesInternal(intent, null, MATCH_SYSTEM_ONLY | MATCH_DIRECT_BOOT_AWARE | MATCH_DIRECT_BOOT_UNAWARE | MATCH_DISABLED_COMPONENTS, UserHandle.myUserId());
    if (matches.size() == 1) {
        return matches.get(0).getComponentInfo().packageName;
    } else {
        Slog.e(TAG, "There should probably be exactly one setup wizard; found " + matches.size() + ": matches=" + matches);
        return null;
    }
}
Also used : EphemeralResolveInfo(android.content.pm.EphemeralResolveInfo) ResolveInfo(android.content.pm.ResolveInfo) Intent(android.content.Intent) Nullable(android.annotation.Nullable)

Example 82 with Nullable

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

the class PackageManagerService method getEphemeralInstallerLPr.

@Nullable
private ComponentName getEphemeralInstallerLPr() {
    final Intent intent = new Intent(Intent.ACTION_INSTALL_EPHEMERAL_PACKAGE);
    intent.addCategory(Intent.CATEGORY_DEFAULT);
    intent.setDataAndType(Uri.fromFile(new File("foo.apk")), PACKAGE_MIME_TYPE);
    final int resolveFlags = MATCH_DIRECT_BOOT_AWARE | MATCH_DIRECT_BOOT_UNAWARE | (!Build.IS_DEBUGGABLE ? MATCH_SYSTEM_ONLY : 0);
    final List<ResolveInfo> matches = queryIntentActivitiesInternal(intent, PACKAGE_MIME_TYPE, resolveFlags, UserHandle.USER_SYSTEM);
    if (matches.size() == 0) {
        return null;
    } else if (matches.size() == 1) {
        return matches.get(0).getComponentInfo().getComponentName();
    } else {
        throw new RuntimeException("There must be at most one ephemeral installer; found " + matches);
    }
}
Also used : EphemeralResolveInfo(android.content.pm.EphemeralResolveInfo) ResolveInfo(android.content.pm.ResolveInfo) Intent(android.content.Intent) PackageParser.isApkFile(android.content.pm.PackageParser.isApkFile) File(java.io.File) DexFile(dalvik.system.DexFile) StrictJarFile(android.util.jar.StrictJarFile) Nullable(android.annotation.Nullable)

Example 83 with Nullable

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

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 84 with Nullable

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

the class CascadingMenuPopup method findParentViewForSubmenu.

/**
     * Attempts to find the view for the menu item that owns the specified
     * submenu.
     *
     * @param parentInfo info for the parent menu
     * @param submenu the submenu whose parent view should be obtained
     * @return the parent view, or {@code null} if one could not be found
     */
@Nullable
private View findParentViewForSubmenu(@NonNull CascadingMenuInfo parentInfo, @NonNull MenuBuilder submenu) {
    final MenuItem owner = findMenuItemForSubmenu(parentInfo.menu, submenu);
    if (owner == null) {
        // Couldn't find the submenu owner.
        return null;
    }
    // The adapter may be wrapped. Adjust the index if necessary.
    final int headersCount;
    final MenuAdapter menuAdapter;
    final ListView listView = parentInfo.getListView();
    final ListAdapter listAdapter = listView.getAdapter();
    if (listAdapter instanceof HeaderViewListAdapter) {
        final HeaderViewListAdapter headerAdapter = (HeaderViewListAdapter) listAdapter;
        headersCount = headerAdapter.getHeadersCount();
        menuAdapter = (MenuAdapter) headerAdapter.getWrappedAdapter();
    } else {
        headersCount = 0;
        menuAdapter = (MenuAdapter) listAdapter;
    }
    // Find the index within the menu adapter's data set of the menu item.
    int ownerPosition = AbsListView.INVALID_POSITION;
    for (int i = 0, count = menuAdapter.getCount(); i < count; i++) {
        if (owner == menuAdapter.getItem(i)) {
            ownerPosition = i;
            break;
        }
    }
    if (ownerPosition == AbsListView.INVALID_POSITION) {
        // Couldn't find the owner within the menu adapter.
        return null;
    }
    // Adjust the index for the adapter used to display views.
    ownerPosition += headersCount;
    // Adjust the index for the visible views.
    final int ownerViewPosition = ownerPosition - listView.getFirstVisiblePosition();
    if (ownerViewPosition < 0 || ownerViewPosition >= listView.getChildCount()) {
        // Not visible on screen.
        return null;
    }
    return listView.getChildAt(ownerViewPosition);
}
Also used : AbsListView(android.widget.AbsListView) ListView(android.widget.ListView) HeaderViewListAdapter(android.widget.HeaderViewListAdapter) MenuItem(android.view.MenuItem) HeaderViewListAdapter(android.widget.HeaderViewListAdapter) ListAdapter(android.widget.ListAdapter) Nullable(android.annotation.Nullable)

Example 85 with Nullable

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

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)313 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 File (java.io.File)26 Resources (android.content.res.Resources)25 FileNotFoundException (java.io.FileNotFoundException)24 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)24 Configuration (android.content.res.Configuration)20 ResourcesImpl (android.content.res.ResourcesImpl)20 Drawable (android.graphics.drawable.Drawable)20 ComponentName (android.content.ComponentName)15 NotFoundException (android.content.res.Resources.NotFoundException)15 Cursor (android.database.Cursor)15 ParcelFileDescriptor (android.os.ParcelFileDescriptor)15 TypedValue (android.util.TypedValue)15 ByteBuffer (java.nio.ByteBuffer)15 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)15