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