Search in sources :

Example 31 with Nullable

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

the class ShortcutInfo method getIntents.

/**
     * Return the intent set with {@link Builder#setIntents(Intent[])}.
     *
     * <p>Launcher apps <b>cannot</b> see the intents.  If a {@link ShortcutInfo} is
     * obtained via {@link LauncherApps}, then this method will always return null.
     * Launchers can only start a shortcut intent with {@link LauncherApps#startShortcut}.
     *
     * @see Builder#setIntents(Intent[])
     */
@Nullable
public Intent[] getIntents() {
    final Intent[] ret = new Intent[mIntents.length];
    for (int i = 0; i < ret.length; i++) {
        ret[i] = new Intent(mIntents[i]);
        setIntentExtras(ret[i], mIntentPersistableExtrases[i]);
    }
    return ret;
}
Also used : Intent(android.content.Intent) Nullable(android.annotation.Nullable)

Example 32 with Nullable

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

the class TimePickerClockDelegate method applyLegacyColorFixes.

/**
     * The legacy text color might have been poorly defined. Ensures that it
     * has an appropriate activated state, using the selected state if one
     * exists or modifying the default text color otherwise.
     *
     * @param color a legacy text color, or {@code null}
     * @return a color state list with an appropriate activated state, or
     *         {@code null} if a valid activated state could not be generated
     */
@Nullable
private ColorStateList applyLegacyColorFixes(@Nullable ColorStateList color) {
    if (color == null || color.hasState(R.attr.state_activated)) {
        return color;
    }
    final int activatedColor;
    final int defaultColor;
    if (color.hasState(R.attr.state_selected)) {
        activatedColor = color.getColorForState(StateSet.get(StateSet.VIEW_STATE_ENABLED | StateSet.VIEW_STATE_SELECTED), 0);
        defaultColor = color.getColorForState(StateSet.get(StateSet.VIEW_STATE_ENABLED), 0);
    } else {
        activatedColor = color.getDefaultColor();
        // Generate a non-activated color using the disabled alpha.
        final TypedArray ta = mContext.obtainStyledAttributes(ATTRS_DISABLED_ALPHA);
        final float disabledAlpha = ta.getFloat(0, 0.30f);
        defaultColor = multiplyAlphaComponent(activatedColor, disabledAlpha);
    }
    if (activatedColor == 0 || defaultColor == 0) {
        // We somehow failed to obtain the colors.
        return null;
    }
    final int[][] stateSet = new int[][] { { R.attr.state_activated }, {} };
    final int[] colors = new int[] { activatedColor, defaultColor };
    return new ColorStateList(stateSet, colors);
}
Also used : TypedArray(android.content.res.TypedArray) ColorStateList(android.content.res.ColorStateList) Nullable(android.annotation.Nullable)

Example 33 with Nullable

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

the class ShortcutPackage method deleteOrDisableWithId.

@Nullable
private ShortcutInfo deleteOrDisableWithId(@NonNull String shortcutId, boolean disable, boolean overrideImmutable) {
    final ShortcutInfo oldShortcut = mShortcuts.get(shortcutId);
    if (oldShortcut == null || !oldShortcut.isEnabled()) {
        // Doesn't exist or already disabled.
        return null;
    }
    if (!overrideImmutable) {
        ensureNotImmutable(oldShortcut);
    }
    if (oldShortcut.isPinned()) {
        oldShortcut.setRank(0);
        oldShortcut.clearFlags(ShortcutInfo.FLAG_DYNAMIC | ShortcutInfo.FLAG_MANIFEST);
        if (disable) {
            oldShortcut.addFlags(ShortcutInfo.FLAG_DISABLED);
        }
        oldShortcut.setTimestamp(mShortcutUser.mService.injectCurrentTimeMillis());
        return oldShortcut;
    } else {
        deleteShortcutInner(shortcutId);
        return null;
    }
}
Also used : ShortcutInfo(android.content.pm.ShortcutInfo) Nullable(android.annotation.Nullable)

Example 34 with Nullable

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

the class MediaCodec method getInputBuffer.

/**
     * Returns a {@link java.nio.Buffer#clear cleared}, writable ByteBuffer
     * object for a dequeued input buffer index to contain the input data.
     *
     * After calling this method any ByteBuffer or Image object
     * previously returned for the same input index MUST no longer
     * be used.
     *
     * @param index The index of a client-owned input buffer previously
     *              returned from a call to {@link #dequeueInputBuffer},
     *              or received via an onInputBufferAvailable callback.
     *
     * @return the input buffer, or null if the index is not a dequeued
     * input buffer, or if the codec is configured for surface input.
     *
     * @throws IllegalStateException if not in the Executing state.
     * @throws MediaCodec.CodecException upon codec error.
     */
@Nullable
public ByteBuffer getInputBuffer(int index) {
    ByteBuffer newBuffer = getBuffer(true, /* input */
    index);
    synchronized (mBufferLock) {
        invalidateByteBuffer(mCachedInputBuffers, index);
        mDequeuedInputBuffers.put(index, newBuffer);
    }
    return newBuffer;
}
Also used : ByteBuffer(java.nio.ByteBuffer) Nullable(android.annotation.Nullable)

Example 35 with Nullable

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

the class Main method renderAndVerify.

/**
     * Create a new rendering session and test that rendering the given layout doesn't throw any
     * exceptions and matches the provided image.
     * <p>
     * If frameTimeNanos is >= 0 a frame will be executed during the rendering. The time indicates
     * how far in the future is.
     */
@Nullable
private RenderResult renderAndVerify(SessionParams params, String goldenFileName, long frameTimeNanos) throws ClassNotFoundException {
    // TODO: Set up action bar handler properly to test menu rendering.
    // Create session params.
    RenderSession session = sBridge.createSession(params);
    if (frameTimeNanos != -1) {
        session.setElapsedFrameTimeNanos(frameTimeNanos);
    }
    if (!session.getResult().isSuccess()) {
        getLogger().error(session.getResult().getException(), session.getResult().getErrorMessage());
    }
    // Render the session with a timeout of 50s.
    Result renderResult = session.render(50000);
    if (!renderResult.isSuccess()) {
        getLogger().error(session.getResult().getException(), session.getResult().getErrorMessage());
    }
    try {
        String goldenImagePath = APP_TEST_DIR + "/golden/" + goldenFileName;
        ImageUtils.requireSimilar(goldenImagePath, session.getImage());
        return RenderResult.getFromSession(session);
    } catch (IOException e) {
        getLogger().error(e, e.getMessage());
    } finally {
        session.dispose();
    }
    return null;
}
Also used : RenderSession(com.android.ide.common.rendering.api.RenderSession) IOException(java.io.IOException) Result(com.android.ide.common.rendering.api.Result) 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