code
stringlengths
11
173k
docstring
stringlengths
2
593k
func_name
stringlengths
2
189
language
stringclasses
1 value
repo
stringclasses
844 values
path
stringlengths
11
294
url
stringlengths
60
339
license
stringclasses
4 values
public Builder(@NonNull Slice.Builder parent) { mUri = parent.mUri.buildUpon().appendPath("_gen") .appendPath(String.valueOf(mItems.size())).build(); }
Create a builder for a {@link Slice} that is a sub-slice of the slice being constructed by the provided builder. @param parent The builder constructing the parent slice
Builder::Builder
java
Reginer/aosp-android-jar
android-31/src/android/app/slice/Slice.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/app/slice/Slice.java
MIT
public Builder setCallerNeeded(boolean callerNeeded) { if (callerNeeded) { mHints.add(HINT_CALLER_NEEDED); } else { mHints.remove(HINT_CALLER_NEEDED); } return this; }
Tells the system whether for this slice the return value of {@link SliceProvider#onBindSlice(Uri, java.util.Set)} may be different depending on {@link SliceProvider#getCallingPackage()} and should not be cached for multiple apps.
Builder::setCallerNeeded
java
Reginer/aosp-android-jar
android-31/src/android/app/slice/Slice.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/app/slice/Slice.java
MIT
public Builder addHints(@SliceHint List<String> hints) { mHints.addAll(hints); return this; }
Add hints to the Slice being constructed
Builder::addHints
java
Reginer/aosp-android-jar
android-31/src/android/app/slice/Slice.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/app/slice/Slice.java
MIT
public Builder setSpec(SliceSpec spec) { mSpec = spec; return this; }
@deprecated TO BE REMOVED @removed
Builder::setSpec
java
Reginer/aosp-android-jar
android-31/src/android/app/slice/Slice.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/app/slice/Slice.java
MIT
public Builder addSubSlice(@NonNull Slice slice, @Nullable @SliceSubtype String subType) { Objects.requireNonNull(slice); mItems.add(new SliceItem(slice, SliceItem.FORMAT_SLICE, subType, slice.getHints().toArray(new String[slice.getHints().size()]))); return this; }
Add a sub-slice to the slice being constructed @param subType Optional template-specific type information @see SliceItem#getSubType()
Builder::addSubSlice
java
Reginer/aosp-android-jar
android-31/src/android/app/slice/Slice.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/app/slice/Slice.java
MIT
public Slice.Builder addAction(@NonNull PendingIntent action, @NonNull Slice s, @Nullable @SliceSubtype String subType) { Objects.requireNonNull(action); Objects.requireNonNull(s); List<String> hints = s.getHints(); s.mSpec = null; mItems.add(new SliceItem(action, s, SliceItem.FORMAT_ACTION, subType, hints.toArray( new String[hints.size()]))); return this; }
Add an action to the slice being constructed @param subType Optional template-specific type information @see SliceItem#getSubType()
Builder::addAction
java
Reginer/aosp-android-jar
android-31/src/android/app/slice/Slice.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/app/slice/Slice.java
MIT
public Builder addText(CharSequence text, @Nullable @SliceSubtype String subType, @SliceHint List<String> hints) { mItems.add(new SliceItem(text, SliceItem.FORMAT_TEXT, subType, hints)); return this; }
Add text to the slice being constructed @param subType Optional template-specific type information @see SliceItem#getSubType()
Builder::addText
java
Reginer/aosp-android-jar
android-31/src/android/app/slice/Slice.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/app/slice/Slice.java
MIT
public Builder addIcon(Icon icon, @Nullable @SliceSubtype String subType, @SliceHint List<String> hints) { Objects.requireNonNull(icon); mItems.add(new SliceItem(icon, SliceItem.FORMAT_IMAGE, subType, hints)); return this; }
Add an image to the slice being constructed @param subType Optional template-specific type information @see SliceItem#getSubType()
Builder::addIcon
java
Reginer/aosp-android-jar
android-31/src/android/app/slice/Slice.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/app/slice/Slice.java
MIT
public Slice.Builder addRemoteInput(RemoteInput remoteInput, @Nullable @SliceSubtype String subType, @SliceHint List<String> hints) { Objects.requireNonNull(remoteInput); mItems.add(new SliceItem(remoteInput, SliceItem.FORMAT_REMOTE_INPUT, subType, hints)); return this; }
Add remote input to the slice being constructed @param subType Optional template-specific type information @see SliceItem#getSubType()
Builder::addRemoteInput
java
Reginer/aosp-android-jar
android-31/src/android/app/slice/Slice.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/app/slice/Slice.java
MIT
public Builder addInt(int value, @Nullable @SliceSubtype String subType, @SliceHint List<String> hints) { mItems.add(new SliceItem(value, SliceItem.FORMAT_INT, subType, hints)); return this; }
Add an integer to the slice being constructed @param subType Optional template-specific type information @see SliceItem#getSubType()
Builder::addInt
java
Reginer/aosp-android-jar
android-31/src/android/app/slice/Slice.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/app/slice/Slice.java
MIT
public Slice.Builder addLong(long value, @Nullable @SliceSubtype String subType, @SliceHint List<String> hints) { mItems.add(new SliceItem(value, SliceItem.FORMAT_LONG, subType, hints.toArray(new String[hints.size()]))); return this; }
Add a long to the slice being constructed @param subType Optional template-specific type information @see SliceItem#getSubType()
Builder::addLong
java
Reginer/aosp-android-jar
android-31/src/android/app/slice/Slice.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/app/slice/Slice.java
MIT
public Slice.Builder addBundle(Bundle bundle, @Nullable @SliceSubtype String subType, @SliceHint List<String> hints) { Objects.requireNonNull(bundle); mItems.add(new SliceItem(bundle, SliceItem.FORMAT_BUNDLE, subType, hints)); return this; }
Add a bundle to the slice being constructed. <p>Expected to be used for support library extension, should not be used for general development @param subType Optional template-specific type information @see SliceItem#getSubType()
Builder::addBundle
java
Reginer/aosp-android-jar
android-31/src/android/app/slice/Slice.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/app/slice/Slice.java
MIT
public Slice build() { return new Slice(mItems, mHints.toArray(new String[mHints.size()]), mUri, mSpec); }
Construct the slice.
Builder::build
java
Reginer/aosp-android-jar
android-31/src/android/app/slice/Slice.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/app/slice/Slice.java
MIT
public String toString() { return toString(""); }
@hide @return A string representation of this slice.
Builder::toString
java
Reginer/aosp-android-jar
android-31/src/android/app/slice/Slice.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/app/slice/Slice.java
MIT
public LocatorImpl () { }
Zero-argument constructor. <p>This will not normally be useful, since the main purpose of this class is to make a snapshot of an existing Locator.</p>
LocatorImpl::LocatorImpl
java
Reginer/aosp-android-jar
android-34/src/org/xml/sax/helpers/LocatorImpl.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/xml/sax/helpers/LocatorImpl.java
MIT
public LocatorImpl (Locator locator) { setPublicId(locator.getPublicId()); setSystemId(locator.getSystemId()); setLineNumber(locator.getLineNumber()); setColumnNumber(locator.getColumnNumber()); }
Copy constructor. <p>Create a persistent copy of the current state of a locator. When the original locator changes, this copy will still keep the original values (and it can be used outside the scope of DocumentHandler methods).</p> @param locator The locator to copy.
LocatorImpl::LocatorImpl
java
Reginer/aosp-android-jar
android-34/src/org/xml/sax/helpers/LocatorImpl.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/xml/sax/helpers/LocatorImpl.java
MIT
private void initAbsSpinner() { setFocusable(true); setWillNotDraw(false); }
Common code for different constructor flavors
getSimpleName::initAbsSpinner
java
Reginer/aosp-android-jar
android-35/src/android/widget/AbsSpinner.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/widget/AbsSpinner.java
MIT
void resetList() { mDataChanged = false; mNeedSync = false; removeAllViewsInLayout(); mOldSelectedPosition = INVALID_POSITION; mOldSelectedRowId = INVALID_ROW_ID; setSelectedPositionInt(INVALID_POSITION); setNextSelectedPositionInt(INVALID_POSITION); invalidate(); }
Clear out all children from the list
getSimpleName::resetList
java
Reginer/aosp-android-jar
android-35/src/android/widget/AbsSpinner.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/widget/AbsSpinner.java
MIT
public void setSelection(int position, boolean animate) { // Animate only if requested position is already on screen somewhere boolean shouldAnimate = animate && mFirstPosition <= position && position <= mFirstPosition + getChildCount() - 1; setSelectionInt(position, shouldAnimate); }
Jump directly to a specific item in the adapter data.
getSimpleName::setSelection
java
Reginer/aosp-android-jar
android-35/src/android/widget/AbsSpinner.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/widget/AbsSpinner.java
MIT
void setSelectionInt(int position, boolean animate) { if (position != mOldSelectedPosition) { mBlockLayoutRequests = true; int delta = position - mSelectedPosition; setNextSelectedPositionInt(position); layout(delta, animate); mBlockLayoutRequests = false; } }
Makes the item at the supplied position selected. @param position Position to select @param animate Should the transition be animated
getSimpleName::setSelectionInt
java
Reginer/aosp-android-jar
android-35/src/android/widget/AbsSpinner.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/widget/AbsSpinner.java
MIT
public int pointToPosition(int x, int y) { Rect frame = mTouchFrame; if (frame == null) { mTouchFrame = new Rect(); frame = mTouchFrame; } final int count = getChildCount(); for (int i = count - 1; i >= 0; i--) { View child = getChildAt(i); if (child.getVisibility() == View.VISIBLE) { child.getHitRect(frame); if (frame.contains(x, y)) { return mFirstPosition + i; } } } return INVALID_POSITION; }
Maps a point to a position in the list. @param x X in local coordinate @param y Y in local coordinate @return The position of the item which contains the specified point, or {@link #INVALID_POSITION} if the point does not intersect an item.
getSimpleName::pointToPosition
java
Reginer/aosp-android-jar
android-35/src/android/widget/AbsSpinner.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/widget/AbsSpinner.java
MIT
SavedState(Parcelable superState) { super(superState); }
Constructor called from {@link AbsSpinner#onSaveInstanceState()}
SavedState::SavedState
java
Reginer/aosp-android-jar
android-35/src/android/widget/AbsSpinner.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/widget/AbsSpinner.java
MIT
SavedState(Parcel in) { super(in); selectedId = in.readLong(); position = in.readInt(); }
Constructor called from {@link #CREATOR}
SavedState::SavedState
java
Reginer/aosp-android-jar
android-35/src/android/widget/AbsSpinner.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/widget/AbsSpinner.java
MIT
CompatDisplayInsets(DisplayContent display, ActivityRecord container, @Nullable Rect fixedOrientationBounds) { mOriginalRotation = display.getRotation(); mIsFloating = container.getWindowConfiguration().tasksAreFloating(); mOriginalRequestedOrientation = container.getRequestedConfigurationOrientation(); if (mIsFloating) { final Rect containerBounds = container.getWindowConfiguration().getBounds(); mWidth = containerBounds.width(); mHeight = containerBounds.height(); // For apps in freeform, the task bounds are the parent bounds from the app's // perspective. No insets because within a window. final Rect emptyRect = new Rect(); for (int rotation = 0; rotation < 4; rotation++) { mNonDecorInsets[rotation] = emptyRect; mStableInsets[rotation] = emptyRect; } mIsInFixedOrientationLetterbox = false; return; } final Task task = container.getTask(); mIsInFixedOrientationLetterbox = fixedOrientationBounds != null; // Store the bounds of the Task for the non-resizable activity to use in size compat // mode so that the activity will not be resized regardless the windowing mode it is // currently in. // When an activity needs to be letterboxed because of fixed orientation, use fixed // orientation bounds instead of task bounds since the activity will be displayed // within these even if it is in size compat mode. final Rect filledContainerBounds = mIsInFixedOrientationLetterbox ? fixedOrientationBounds : task != null ? task.getBounds() : display.getBounds(); final int filledContainerRotation = task != null ? task.getConfiguration().windowConfiguration.getRotation() : display.getConfiguration().windowConfiguration.getRotation(); final Point dimensions = getRotationZeroDimensions( filledContainerBounds, filledContainerRotation); mWidth = dimensions.x; mHeight = dimensions.y; // Bounds of the filled container if it doesn't fill the display. final Rect unfilledContainerBounds = filledContainerBounds.equals(display.getBounds()) ? null : new Rect(); final DisplayPolicy policy = display.getDisplayPolicy(); for (int rotation = 0; rotation < 4; rotation++) { mNonDecorInsets[rotation] = new Rect(); mStableInsets[rotation] = new Rect(); final boolean rotated = (rotation == ROTATION_90 || rotation == ROTATION_270); final int dw = rotated ? display.mBaseDisplayHeight : display.mBaseDisplayWidth; final int dh = rotated ? display.mBaseDisplayWidth : display.mBaseDisplayHeight; final DisplayPolicy.DecorInsets.Info decorInfo = policy.getDecorInsetsInfo(rotation, dw, dh); mNonDecorInsets[rotation].set(decorInfo.mNonDecorInsets); mStableInsets[rotation].set(decorInfo.mConfigInsets); if (unfilledContainerBounds == null) { continue; } // The insets is based on the display, but the container may be smaller than the // display, so update the insets to exclude parts that are not intersected with the // container. unfilledContainerBounds.set(filledContainerBounds); display.rotateBounds( filledContainerRotation, rotation, unfilledContainerBounds); updateInsetsForBounds(unfilledContainerBounds, dw, dh, mNonDecorInsets[rotation]); updateInsetsForBounds(unfilledContainerBounds, dw, dh, mStableInsets[rotation]); } }
The stableInsets for each rotation. Includes the status bar inset and the nonDecorInsets. It is used to compute {@link Configuration#screenWidthDp} and {@link Configuration#screenHeightDp}. final Rect[] mStableInsets = new Rect[4]; /** Constructs the environment to simulate the bounds behavior of the given container.
CompatDisplayInsets::CompatDisplayInsets
java
Reginer/aosp-android-jar
android-34/src/com/android/server/wm/ActivityRecord.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/server/wm/ActivityRecord.java
MIT
private static Point getRotationZeroDimensions(final Rect bounds, int rotation) { final boolean rotated = (rotation == ROTATION_90 || rotation == ROTATION_270); final int width = bounds.width(); final int height = bounds.height(); return rotated ? new Point(height, width) : new Point(width, height); }
Gets the width and height of the {@code container} when it is not rotated, so that after the display is rotated, we can calculate the bounds by rotating the dimensions. @see #getBoundsByRotation
CompatDisplayInsets::getRotationZeroDimensions
java
Reginer/aosp-android-jar
android-34/src/com/android/server/wm/ActivityRecord.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/server/wm/ActivityRecord.java
MIT
private static void updateInsetsForBounds(Rect bounds, int displayWidth, int displayHeight, Rect inset) { inset.left = Math.max(0, inset.left - bounds.left); inset.top = Math.max(0, inset.top - bounds.top); inset.right = Math.max(0, bounds.right - displayWidth + inset.right); inset.bottom = Math.max(0, bounds.bottom - displayHeight + inset.bottom); }
Updates the display insets to exclude the parts that are not intersected with the given bounds.
CompatDisplayInsets::updateInsetsForBounds
java
Reginer/aosp-android-jar
android-34/src/com/android/server/wm/ActivityRecord.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/server/wm/ActivityRecord.java
MIT
void getContainerBounds(Rect outAppBounds, Rect outBounds, int rotation, int orientation, boolean orientationRequested, boolean isFixedToUserRotation) { getFrameByOrientation(outBounds, orientation); if (mIsFloating) { outAppBounds.set(outBounds); return; } getBoundsByRotation(outAppBounds, rotation); final int dW = outAppBounds.width(); final int dH = outAppBounds.height(); final boolean isOrientationMismatched = ((outBounds.width() > outBounds.height()) != (dW > dH)); if (isOrientationMismatched && isFixedToUserRotation && orientationRequested) { // The orientation is mismatched but the display cannot rotate. The bounds will fit // to the short side of container. if (orientation == ORIENTATION_LANDSCAPE) { outBounds.bottom = (int) ((float) dW * dW / dH); outBounds.right = dW; } else { outBounds.bottom = dH; outBounds.right = (int) ((float) dH * dH / dW); } outBounds.offset(getCenterOffset(mWidth, outBounds.width()), 0 /* dy */); } outAppBounds.set(outBounds); if (isOrientationMismatched) { // One side of container is smaller than the requested size, then it will be scaled // and the final position will be calculated according to the parent container and // scale, so the original size shouldn't be shrunk by insets. final Rect insets = mNonDecorInsets[rotation]; outBounds.offset(insets.left, insets.top); outAppBounds.offset(insets.left, insets.top); } else if (rotation != ROTATION_UNDEFINED) { // Ensure the app bounds won't overlap with insets. TaskFragment.intersectWithInsetsIfFits(outAppBounds, outBounds, mNonDecorInsets[rotation]); } }
Updates the display insets to exclude the parts that are not intersected with the given bounds. private static void updateInsetsForBounds(Rect bounds, int displayWidth, int displayHeight, Rect inset) { inset.left = Math.max(0, inset.left - bounds.left); inset.top = Math.max(0, inset.top - bounds.top); inset.right = Math.max(0, bounds.right - displayWidth + inset.right); inset.bottom = Math.max(0, bounds.bottom - displayHeight + inset.bottom); } void getBoundsByRotation(Rect outBounds, int rotation) { final boolean rotated = (rotation == ROTATION_90 || rotation == ROTATION_270); final int dw = rotated ? mHeight : mWidth; final int dh = rotated ? mWidth : mHeight; outBounds.set(0, 0, dw, dh); } void getFrameByOrientation(Rect outBounds, int orientation) { final int longSide = Math.max(mWidth, mHeight); final int shortSide = Math.min(mWidth, mHeight); final boolean isLandscape = orientation == ORIENTATION_LANDSCAPE; outBounds.set(0, 0, isLandscape ? longSide : shortSide, isLandscape ? shortSide : longSide); } // TODO(b/267151420): Explore removing getContainerBounds() from CompatDisplayInsets. /** Gets the horizontal centered container bounds for size compatibility mode.
CompatDisplayInsets::getContainerBounds
java
Reginer/aosp-android-jar
android-34/src/com/android/server/wm/ActivityRecord.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/server/wm/ActivityRecord.java
MIT
private void adjustPictureInPictureParamsIfNeeded(Rect windowBounds) { if (pictureInPictureArgs != null && pictureInPictureArgs.hasSourceBoundsHint()) { pictureInPictureArgs.getSourceRectHint().offset(windowBounds.left, windowBounds.top); } }
Adjust the source rect hint in {@link #pictureInPictureArgs} by window bounds since it is relative to its root view (see also b/235599028). It is caller's responsibility to make sure this is called exactly once when we update {@link #pictureInPictureArgs} to avoid double offset.
hasAnimatingParent::adjustPictureInPictureParamsIfNeeded
java
Reginer/aosp-android-jar
android-34/src/com/android/server/wm/ActivityRecord.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/server/wm/ActivityRecord.java
MIT
public hc_noderemovechild(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { super(factory); // // check if loaded documents are supported for content type // String contentType = getContentType(); preload(contentType, "hc_staff", true); }
Constructor. @param factory document factory, may not be null @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration
hc_noderemovechild::hc_noderemovechild
java
Reginer/aosp-android-jar
android-32/src/org/w3c/domts/level1/core/hc_noderemovechild.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/org/w3c/domts/level1/core/hc_noderemovechild.java
MIT
public void runTest() throws Throwable { Document doc; Element rootNode; NodeList childList; Node childToRemove; Node removedChild; Node parentNode; doc = (Document) load("hc_staff", true); rootNode = doc.getDocumentElement(); childList = rootNode.getChildNodes(); childToRemove = childList.item(1); removedChild = rootNode.removeChild(childToRemove); parentNode = removedChild.getParentNode(); assertNull("parentNodeNull", parentNode); }
Runs the test case. @throws Throwable Any uncaught exception causes test to fail
hc_noderemovechild::runTest
java
Reginer/aosp-android-jar
android-32/src/org/w3c/domts/level1/core/hc_noderemovechild.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/org/w3c/domts/level1/core/hc_noderemovechild.java
MIT
public String getTargetURI() { return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_noderemovechild"; }
Gets URI that identifies the test. @return uri identifier of test
hc_noderemovechild::getTargetURI
java
Reginer/aosp-android-jar
android-32/src/org/w3c/domts/level1/core/hc_noderemovechild.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/org/w3c/domts/level1/core/hc_noderemovechild.java
MIT
public static void main(final String[] args) { DOMTestCase.doMain(hc_noderemovechild.class, args); }
Runs this test from the command line. @param args command line arguments
hc_noderemovechild::main
java
Reginer/aosp-android-jar
android-32/src/org/w3c/domts/level1/core/hc_noderemovechild.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/org/w3c/domts/level1/core/hc_noderemovechild.java
MIT
public void prepare(ScrimState previousState) { }
Unlocked on top of an app (launcher or any other activity.) UNLOCKED { @Override public void prepare(ScrimState previousState) { // State that UI will sync to. mBehindAlpha = mClipQsScrim ? 1 : 0; mNotifAlpha = 0; mFrontAlpha = 0; mAnimationDuration = mKeyguardFadingAway ? mKeyguardFadingAwayDuration : CentralSurfaces.FADE_KEYGUARD_DURATION; boolean fromAod = previousState == AOD || previousState == PULSING; // If launch/occlude animations were playing, they already animated the scrim // alpha to 0f as part of the animation. If we animate it now, we'll set it back // to 1f and animate it back to 0f, causing an unwanted scrim flash. mAnimateChange = !mLaunchingAffordanceWithPreview && !mOccludeAnimationPlaying && !fromAod; mFrontTint = Color.TRANSPARENT; mBehindTint = Color.BLACK; mBlankScreen = false; if (mDisplayRequiresBlanking && previousState == ScrimState.AOD) { // Set all scrims black, before they fade transparent. updateScrimColor(mScrimInFront, 1f /* alpha */, Color.BLACK /* tint */); updateScrimColor(mScrimBehind, 1f /* alpha */, Color.BLACK /* tint */); // Scrims should still be black at the end of the transition. mFrontTint = Color.BLACK; mBehindTint = Color.BLACK; mBlankScreen = true; } if (mClipQsScrim) { updateScrimColor(mScrimBehind, 1f /* alpha */, Color.BLACK); } } }, DREAMING { @Override public void prepare(ScrimState previousState) { mFrontTint = Color.TRANSPARENT; mBehindTint = Color.BLACK; mNotifTint = mClipQsScrim ? Color.BLACK : Color.TRANSPARENT; mFrontAlpha = 0; mBehindAlpha = mClipQsScrim ? 1 : 0; mNotifAlpha = 0; mBlankScreen = false; if (mClipQsScrim) { updateScrimColor(mScrimBehind, 1f /* alpha */, Color.BLACK); } } }; boolean mBlankScreen = false; long mAnimationDuration = ScrimController.ANIMATION_DURATION; int mFrontTint = Color.TRANSPARENT; int mBehindTint = Color.TRANSPARENT; int mNotifTint = Color.TRANSPARENT; boolean mAnimateChange = true; float mAodFrontScrimAlpha; float mFrontAlpha; float mBehindAlpha; float mNotifAlpha; float mScrimBehindAlphaKeyguard; float mDefaultScrimAlpha; ScrimView mScrimInFront; ScrimView mScrimBehind; DozeParameters mDozeParameters; DockManager mDockManager; boolean mDisplayRequiresBlanking; boolean mWallpaperSupportsAmbientMode; boolean mHasBackdrop; boolean mLaunchingAffordanceWithPreview; boolean mOccludeAnimationPlaying; boolean mWakeLockScreenSensorActive; boolean mKeyguardFadingAway; long mKeyguardFadingAwayDuration; boolean mClipQsScrim; public void init(ScrimView scrimInFront, ScrimView scrimBehind, DozeParameters dozeParameters, DockManager dockManager) { mScrimInFront = scrimInFront; mScrimBehind = scrimBehind; mDozeParameters = dozeParameters; mDockManager = dockManager; mDisplayRequiresBlanking = dozeParameters.getDisplayNeedsBlanking(); } /** Prepare state for transition.
ScrimState::prepare
java
Reginer/aosp-android-jar
android-34/src/com/android/systemui/statusbar/phone/ScrimState.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/systemui/statusbar/phone/ScrimState.java
MIT
public boolean shouldBlendWithMainColor() { return true; }
Whether a particular state should enable blending with extracted theme colors.
ScrimState::shouldBlendWithMainColor
java
Reginer/aosp-android-jar
android-34/src/com/android/systemui/statusbar/phone/ScrimState.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/systemui/statusbar/phone/ScrimState.java
MIT
public hc_characterdatasubstringvalue(final DOMTestDocumentBuilderFactory factory) throws org.w3c.domts.DOMTestIncompatibleException { super(factory); // // check if loaded documents are supported for content type // String contentType = getContentType(); preload(contentType, "hc_staff", false); }
Constructor. @param factory document factory, may not be null @throws org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration
hc_characterdatasubstringvalue::hc_characterdatasubstringvalue
java
Reginer/aosp-android-jar
android-32/src/org/w3c/domts/level1/core/hc_characterdatasubstringvalue.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/org/w3c/domts/level1/core/hc_characterdatasubstringvalue.java
MIT
public void runTest() throws Throwable { Document doc; NodeList elementList; Node nameNode; CharacterData child; String substring; doc = (Document) load("hc_staff", false); elementList = doc.getElementsByTagName("strong"); nameNode = elementList.item(0); child = (CharacterData) nameNode.getFirstChild(); substring = child.substringData(0, 8); assertEquals("characterdataSubStringValueAssert", "Margaret", substring); }
Runs the test case. @throws Throwable Any uncaught exception causes test to fail
hc_characterdatasubstringvalue::runTest
java
Reginer/aosp-android-jar
android-32/src/org/w3c/domts/level1/core/hc_characterdatasubstringvalue.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/org/w3c/domts/level1/core/hc_characterdatasubstringvalue.java
MIT
public String getTargetURI() { return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_characterdatasubstringvalue"; }
Gets URI that identifies the test. @return uri identifier of test
hc_characterdatasubstringvalue::getTargetURI
java
Reginer/aosp-android-jar
android-32/src/org/w3c/domts/level1/core/hc_characterdatasubstringvalue.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/org/w3c/domts/level1/core/hc_characterdatasubstringvalue.java
MIT
public static void main(final String[] args) { DOMTestCase.doMain(hc_characterdatasubstringvalue.class, args); }
Runs this test from the command line. @param args command line arguments
hc_characterdatasubstringvalue::main
java
Reginer/aosp-android-jar
android-32/src/org/w3c/domts/level1/core/hc_characterdatasubstringvalue.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/org/w3c/domts/level1/core/hc_characterdatasubstringvalue.java
MIT
public BaseMenuPresenter(Context context, int menuLayoutRes, int itemLayoutRes) { mSystemContext = context; mSystemInflater = LayoutInflater.from(context); mMenuLayoutRes = menuLayoutRes; mItemLayoutRes = itemLayoutRes; }
Construct a new BaseMenuPresenter. @param context Context for generating system-supplied views @param menuLayoutRes Layout resource ID for the menu container view @param itemLayoutRes Layout resource ID for a single item view
BaseMenuPresenter::BaseMenuPresenter
java
Reginer/aosp-android-jar
android-33/src/com/android/internal/view/menu/BaseMenuPresenter.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/internal/view/menu/BaseMenuPresenter.java
MIT
public void updateMenuView(boolean cleared) { final ViewGroup parent = (ViewGroup) mMenuView; if (parent == null) return; int childIndex = 0; if (mMenu != null) { mMenu.flagActionItems(); ArrayList<MenuItemImpl> visibleItems = mMenu.getVisibleItems(); final int itemCount = visibleItems.size(); for (int i = 0; i < itemCount; i++) { MenuItemImpl item = visibleItems.get(i); if (shouldIncludeItem(childIndex, item)) { final View convertView = parent.getChildAt(childIndex); final MenuItemImpl oldItem = convertView instanceof MenuView.ItemView ? ((MenuView.ItemView) convertView).getItemData() : null; final View itemView = getItemView(item, convertView, parent); if (item != oldItem) { // Don't let old states linger with new data. itemView.setPressed(false); itemView.jumpDrawablesToCurrentState(); } if (itemView != convertView) { addItemView(itemView, childIndex); } childIndex++; } } } // Remove leftover views. while (childIndex < parent.getChildCount()) { if (!filterLeftoverView(parent, childIndex)) { childIndex++; } } }
Reuses item views when it can
BaseMenuPresenter::updateMenuView
java
Reginer/aosp-android-jar
android-33/src/com/android/internal/view/menu/BaseMenuPresenter.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/internal/view/menu/BaseMenuPresenter.java
MIT
protected void addItemView(View itemView, int childIndex) { final ViewGroup currentParent = (ViewGroup) itemView.getParent(); if (currentParent != null) { currentParent.removeView(itemView); } ((ViewGroup) mMenuView).addView(itemView, childIndex); }
Add an item view at the given index. @param itemView View to add @param childIndex Index within the parent to insert at
BaseMenuPresenter::addItemView
java
Reginer/aosp-android-jar
android-33/src/com/android/internal/view/menu/BaseMenuPresenter.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/internal/view/menu/BaseMenuPresenter.java
MIT
protected boolean filterLeftoverView(ViewGroup parent, int childIndex) { parent.removeViewAt(childIndex); return true; }
Filter the child view at index and remove it if appropriate. @param parent Parent to filter from @param childIndex Index to filter @return true if the child view at index was removed
BaseMenuPresenter::filterLeftoverView
java
Reginer/aosp-android-jar
android-33/src/com/android/internal/view/menu/BaseMenuPresenter.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/internal/view/menu/BaseMenuPresenter.java
MIT
public MenuView.ItemView createItemView(ViewGroup parent) { return (MenuView.ItemView) mSystemInflater.inflate(mItemLayoutRes, parent, false); }
Create a new item view that can be re-bound to other item data later. @return The new item view
BaseMenuPresenter::createItemView
java
Reginer/aosp-android-jar
android-33/src/com/android/internal/view/menu/BaseMenuPresenter.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/internal/view/menu/BaseMenuPresenter.java
MIT
public View getItemView(MenuItemImpl item, View convertView, ViewGroup parent) { MenuView.ItemView itemView; if (convertView instanceof MenuView.ItemView) { itemView = (MenuView.ItemView) convertView; } else { itemView = createItemView(parent); } bindItemView(item, itemView); return (View) itemView; }
Prepare an item view for use. See AdapterView for the basic idea at work here. This may require creating a new item view, but well-behaved implementations will re-use the view passed as convertView if present. The returned view will be populated with data from the item parameter. @param item Item to present @param convertView Existing view to reuse @param parent Intended parent view - use for inflation. @return View that presents the requested menu item
BaseMenuPresenter::getItemView
java
Reginer/aosp-android-jar
android-33/src/com/android/internal/view/menu/BaseMenuPresenter.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/internal/view/menu/BaseMenuPresenter.java
MIT
public boolean shouldIncludeItem(int childIndex, MenuItemImpl item) { return true; }
Filter item by child index and item data. @param childIndex Indended presentation index of this item @param item Item to present @return true if this item should be included in this menu presentation; false otherwise
BaseMenuPresenter::shouldIncludeItem
java
Reginer/aosp-android-jar
android-33/src/com/android/internal/view/menu/BaseMenuPresenter.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/internal/view/menu/BaseMenuPresenter.java
MIT
public static WrappedKey fromSecretKey(PlatformEncryptionKey wrappingKey, SecretKey key, @Nullable byte[] metadata) throws InvalidKeyException, KeyStoreException { if (key.getEncoded() == null) { throw new InvalidKeyException( "key does not expose encoded material. It cannot be wrapped."); } Cipher cipher; try { cipher = Cipher.getInstance(KEY_WRAP_CIPHER_ALGORITHM); } catch (NoSuchAlgorithmException | NoSuchPaddingException e) { throw new RuntimeException( "Android does not support AES/GCM/NoPadding. This should never happen."); } cipher.init(Cipher.WRAP_MODE, wrappingKey.getKey()); byte[] encryptedKeyMaterial; try { encryptedKeyMaterial = cipher.wrap(key); } catch (IllegalBlockSizeException e) { Throwable cause = e.getCause(); if (cause instanceof KeyStoreException) { // If AndroidKeyStore encounters any error here, it throws IllegalBlockSizeException // with KeyStoreException as the cause. This is due to there being no better option // here, as the Cipher#wrap only checked throws InvalidKeyException or // IllegalBlockSizeException. If this is the case, we want to propagate it to the // caller, so rethrow the cause. throw (KeyStoreException) cause; } else { throw new RuntimeException( "IllegalBlockSizeException should not be thrown by AES/GCM/NoPadding mode.", e); } } return new WrappedKey( /*nonce=*/ cipher.getIV(), /*keyMaterial=*/ encryptedKeyMaterial, /*keyMetadata=*/ metadata, /*platformKeyGenerationId=*/ wrappingKey.getGenerationId(), RecoveryController.RECOVERY_STATUS_SYNC_IN_PROGRESS); }
Returns a wrapped form of {@code key}, using {@code wrappingKey} to encrypt the key material. @throws InvalidKeyException if {@code wrappingKey} cannot be used to encrypt {@code key}, or if {@code key} does not expose its key material. See {@link android.security.keystore.AndroidKeyStoreKey} for an example of a key that does not expose its key material.
WrappedKey::fromSecretKey
java
Reginer/aosp-android-jar
android-31/src/com/android/server/locksettings/recoverablekeystore/WrappedKey.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/locksettings/recoverablekeystore/WrappedKey.java
MIT
public WrappedKey(byte[] nonce, byte[] keyMaterial, @Nullable byte[] keyMetadata, int platformKeyGenerationId) { this(nonce, keyMaterial, keyMetadata, platformKeyGenerationId, RecoveryController.RECOVERY_STATUS_SYNC_IN_PROGRESS); }
A new instance with default recovery status. @param nonce The nonce with which the key material was encrypted. @param keyMaterial The encrypted bytes of the key material. @param platformKeyGenerationId The generation ID of the key used to wrap this key. @see RecoveryController#RECOVERY_STATUS_SYNC_IN_PROGRESS @hide
WrappedKey::WrappedKey
java
Reginer/aosp-android-jar
android-31/src/com/android/server/locksettings/recoverablekeystore/WrappedKey.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/locksettings/recoverablekeystore/WrappedKey.java
MIT
public WrappedKey(byte[] nonce, byte[] keyMaterial, @Nullable byte[] keyMetadata, int platformKeyGenerationId, int recoveryStatus) { mNonce = nonce; mKeyMaterial = keyMaterial; mKeyMetadata = keyMetadata; mPlatformKeyGenerationId = platformKeyGenerationId; mRecoveryStatus = recoveryStatus; }
A new instance. @param nonce The nonce with which the key material was encrypted. @param keyMaterial The encrypted bytes of the key material. @param keyMetadata The metadata that will be authenticated (but unencrypted) together with the key material when the key is uploaded to cloud. @param platformKeyGenerationId The generation ID of the key used to wrap this key. @param recoveryStatus recovery status of the key. @hide
WrappedKey::WrappedKey
java
Reginer/aosp-android-jar
android-31/src/com/android/server/locksettings/recoverablekeystore/WrappedKey.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/locksettings/recoverablekeystore/WrappedKey.java
MIT
public byte[] getNonce() { return mNonce; }
Returns the nonce with which the key material was encrypted. @hide
WrappedKey::getNonce
java
Reginer/aosp-android-jar
android-31/src/com/android/server/locksettings/recoverablekeystore/WrappedKey.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/locksettings/recoverablekeystore/WrappedKey.java
MIT
public byte[] getKeyMaterial() { return mKeyMaterial; }
Returns the encrypted key material. @hide
WrappedKey::getKeyMaterial
java
Reginer/aosp-android-jar
android-31/src/com/android/server/locksettings/recoverablekeystore/WrappedKey.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/locksettings/recoverablekeystore/WrappedKey.java
MIT
public @Nullable byte[] getKeyMetadata() { return mKeyMetadata; }
Returns the key metadata. @hide
WrappedKey::getKeyMetadata
java
Reginer/aosp-android-jar
android-31/src/com/android/server/locksettings/recoverablekeystore/WrappedKey.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/locksettings/recoverablekeystore/WrappedKey.java
MIT
public int getPlatformKeyGenerationId() { return mPlatformKeyGenerationId; }
Returns the generation ID of the platform key, with which this key was wrapped. @hide
WrappedKey::getPlatformKeyGenerationId
java
Reginer/aosp-android-jar
android-31/src/com/android/server/locksettings/recoverablekeystore/WrappedKey.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/locksettings/recoverablekeystore/WrappedKey.java
MIT
public int getRecoveryStatus() { return mRecoveryStatus; }
Returns recovery status of the key. @hide
WrappedKey::getRecoveryStatus
java
Reginer/aosp-android-jar
android-31/src/com/android/server/locksettings/recoverablekeystore/WrappedKey.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/locksettings/recoverablekeystore/WrappedKey.java
MIT
public static Map<String, Pair<SecretKey, byte[]>> unwrapKeys( PlatformDecryptionKey platformKey, Map<String, WrappedKey> wrappedKeys) throws NoSuchAlgorithmException, NoSuchPaddingException, BadPlatformKeyException, InvalidKeyException, InvalidAlgorithmParameterException { HashMap<String, Pair<SecretKey, byte[]>> unwrappedKeys = new HashMap<>(); Cipher cipher = Cipher.getInstance(KEY_WRAP_CIPHER_ALGORITHM); int platformKeyGenerationId = platformKey.getGenerationId(); for (String alias : wrappedKeys.keySet()) { WrappedKey wrappedKey = wrappedKeys.get(alias); if (wrappedKey.getPlatformKeyGenerationId() != platformKeyGenerationId) { throw new BadPlatformKeyException(String.format( Locale.US, "WrappedKey with alias '%s' was wrapped with platform key %d, not " + "platform key %d", alias, wrappedKey.getPlatformKeyGenerationId(), platformKey.getGenerationId())); } cipher.init( Cipher.UNWRAP_MODE, platformKey.getKey(), new GCMParameterSpec(GCM_TAG_LENGTH_BITS, wrappedKey.getNonce())); SecretKey key; try { key = (SecretKey) cipher.unwrap( wrappedKey.getKeyMaterial(), APPLICATION_KEY_ALGORITHM, Cipher.SECRET_KEY); } catch (InvalidKeyException | NoSuchAlgorithmException e) { Log.e(TAG, String.format( Locale.US, "Error unwrapping recoverable key with alias '%s'", alias), e); continue; } unwrappedKeys.put(alias, Pair.create(key, wrappedKey.getKeyMetadata())); } return unwrappedKeys; }
Unwraps the {@code wrappedKeys} with the {@code platformKey}. @return The unwrapped keys, indexed by alias. @throws NoSuchAlgorithmException if AES/GCM/NoPadding Cipher or AES key type is unavailable. @throws BadPlatformKeyException if the {@code platformKey} has a different generation ID to any of the {@code wrappedKeys}. @hide
WrappedKey::unwrapKeys
java
Reginer/aosp-android-jar
android-31/src/com/android/server/locksettings/recoverablekeystore/WrappedKey.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/server/locksettings/recoverablekeystore/WrappedKey.java
MIT
public StrictJarManifest() { entries = new HashMap<String, Attributes>(); mainAttributes = new Attributes(); }
Creates a new {@code StrictJarManifest} instance.
Chunk::StrictJarManifest
java
Reginer/aosp-android-jar
android-35/src/android/util/jar/StrictJarManifest.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/util/jar/StrictJarManifest.java
MIT
public StrictJarManifest(InputStream is) throws IOException { this(); read(Streams.readFully(is)); }
Creates a new {@code StrictJarManifest} instance using the attributes obtained from the input stream. @param is {@code InputStream} to parse for attributes. @throws IOException if an IO error occurs while creating this {@code StrictJarManifest}
Chunk::StrictJarManifest
java
Reginer/aosp-android-jar
android-35/src/android/util/jar/StrictJarManifest.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/util/jar/StrictJarManifest.java
MIT
public void clear() { entries.clear(); mainAttributes.clear(); }
Resets the both the main attributes as well as the entry attributes associated with this {@code StrictJarManifest}.
Chunk::clear
java
Reginer/aosp-android-jar
android-35/src/android/util/jar/StrictJarManifest.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/util/jar/StrictJarManifest.java
MIT
public Attributes getAttributes(String name) { return getEntries().get(name); }
Returns the {@code Attributes} associated with the parameter entry {@code name}. @param name the name of the entry to obtain {@code Attributes} from. @return the Attributes for the entry or {@code null} if the entry does not exist.
Chunk::getAttributes
java
Reginer/aosp-android-jar
android-35/src/android/util/jar/StrictJarManifest.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/util/jar/StrictJarManifest.java
MIT
public Map<String, Attributes> getEntries() { return entries; }
Returns a map containing the {@code Attributes} for each entry in the {@code StrictJarManifest}. @return the map of entry attributes.
Chunk::getEntries
java
Reginer/aosp-android-jar
android-35/src/android/util/jar/StrictJarManifest.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/util/jar/StrictJarManifest.java
MIT
public Attributes getMainAttributes() { return mainAttributes; }
Returns the main {@code Attributes} of the {@code JarFile}. @return main {@code Attributes} associated with the source {@code JarFile}.
Chunk::getMainAttributes
java
Reginer/aosp-android-jar
android-35/src/android/util/jar/StrictJarManifest.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/util/jar/StrictJarManifest.java
MIT
public void write(OutputStream os) throws IOException { write(this, os); }
Writes this {@code StrictJarManifest}'s name/attributes pairs to the given {@code OutputStream}. The {@code MANIFEST_VERSION} or {@code SIGNATURE_VERSION} attribute must be set before calling this method, or no attributes will be written. @throws IOException If an error occurs writing the {@code StrictJarManifest}.
Chunk::write
java
Reginer/aosp-android-jar
android-35/src/android/util/jar/StrictJarManifest.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/util/jar/StrictJarManifest.java
MIT
public void read(InputStream is) throws IOException { read(Streams.readFullyNoClose(is)); }
Merges name/attribute pairs read from the input stream {@code is} into this manifest. @param is The {@code InputStream} to read from. @throws IOException If an error occurs reading the manifest.
Chunk::read
java
Reginer/aosp-android-jar
android-35/src/android/util/jar/StrictJarManifest.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/util/jar/StrictJarManifest.java
MIT
static void write(StrictJarManifest manifest, OutputStream out) throws IOException { CharsetEncoder encoder = StandardCharsets.UTF_8.newEncoder(); ByteBuffer buffer = ByteBuffer.allocate(LINE_LENGTH_LIMIT); Attributes.Name versionName = Attributes.Name.MANIFEST_VERSION; String version = manifest.mainAttributes.getValue(versionName); if (version == null) { versionName = Attributes.Name.SIGNATURE_VERSION; version = manifest.mainAttributes.getValue(versionName); } if (version != null) { writeEntry(out, versionName, version, encoder, buffer); Iterator<?> entries = manifest.mainAttributes.keySet().iterator(); while (entries.hasNext()) { Attributes.Name name = (Attributes.Name) entries.next(); if (!name.equals(versionName)) { writeEntry(out, name, manifest.mainAttributes.getValue(name), encoder, buffer); } } } out.write(LINE_SEPARATOR); Iterator<String> i = manifest.getEntries().keySet().iterator(); while (i.hasNext()) { String key = i.next(); writeEntry(out, ATTRIBUTE_NAME_NAME, key, encoder, buffer); Attributes attributes = manifest.entries.get(key); Iterator<?> entries = attributes.keySet().iterator(); while (entries.hasNext()) { Attributes.Name name = (Attributes.Name) entries.next(); writeEntry(out, name, attributes.getValue(name), encoder, buffer); } out.write(LINE_SEPARATOR); } }
Writes out the attribute information of the specified manifest to the specified {@code OutputStream} @param manifest the manifest to write out. @param out The {@code OutputStream} to write to. @throws IOException If an error occurs writing the {@code StrictJarManifest}.
Chunk::write
java
Reginer/aosp-android-jar
android-35/src/android/util/jar/StrictJarManifest.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/util/jar/StrictJarManifest.java
MIT
public Handler getHandler() { return mHandler; }
Get the handler
AsyncServiceInfo::getHandler
java
Reginer/aosp-android-jar
android-33/src/com/android/internal/util/AsyncService.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/internal/util/AsyncService.java
MIT
public void assertCalled() { try { final boolean updated = mLatch.await(mTimeoutMs, TimeUnit.MILLISECONDS); if (!updated) { throw new IllegalStateException( "Settings " + mKey + " not called in " + mTimeoutMs + "ms"); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new IllegalStateException("Interrupted", e); } }
Blocks for a few seconds until it's called, or throws an {@link IllegalStateException} if it isn't.
OneTimeSettingsListener::assertCalled
java
Reginer/aosp-android-jar
android-34/src/android/perftests/utils/OneTimeSettingsListener.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/perftests/utils/OneTimeSettingsListener.java
MIT
public NetworkSlicingConfig(List<UrspRule> urspRules, List<NetworkSliceInfo> sliceInfo) { this(); mUrspRules.addAll(urspRules); mSliceInfo.addAll(sliceInfo); }
Represents a slicing configuration public final class NetworkSlicingConfig implements Parcelable { private final List<UrspRule> mUrspRules; private final List<NetworkSliceInfo> mSliceInfo; public NetworkSlicingConfig() { mUrspRules = new ArrayList<>(); mSliceInfo = new ArrayList<>(); } /** @hide
NetworkSlicingConfig::NetworkSlicingConfig
java
Reginer/aosp-android-jar
android-34/src/android/telephony/data/NetworkSlicingConfig.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/telephony/data/NetworkSlicingConfig.java
MIT
public NetworkSlicingConfig(Parcel p) { mUrspRules = p.createTypedArrayList(UrspRule.CREATOR); mSliceInfo = p.createTypedArrayList(NetworkSliceInfo.CREATOR); }
Represents a slicing configuration public final class NetworkSlicingConfig implements Parcelable { private final List<UrspRule> mUrspRules; private final List<NetworkSliceInfo> mSliceInfo; public NetworkSlicingConfig() { mUrspRules = new ArrayList<>(); mSliceInfo = new ArrayList<>(); } /** @hide public NetworkSlicingConfig(List<UrspRule> urspRules, List<NetworkSliceInfo> sliceInfo) { this(); mUrspRules.addAll(urspRules); mSliceInfo.addAll(sliceInfo); } /** @hide
NetworkSlicingConfig::NetworkSlicingConfig
java
Reginer/aosp-android-jar
android-34/src/android/telephony/data/NetworkSlicingConfig.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/telephony/data/NetworkSlicingConfig.java
MIT
public @NonNull List<UrspRule> getUrspRules() { return mUrspRules; }
This list contains the current URSP rules. Empty list represents that no rules are configured. @return the current URSP rules for this slicing configuration.
NetworkSlicingConfig::getUrspRules
java
Reginer/aosp-android-jar
android-34/src/android/telephony/data/NetworkSlicingConfig.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/telephony/data/NetworkSlicingConfig.java
MIT
public @NonNull List<NetworkSliceInfo> getSliceInfo() { return mSliceInfo; }
@return the list of all slices for this slicing configuration.
NetworkSlicingConfig::getSliceInfo
java
Reginer/aosp-android-jar
android-34/src/android/telephony/data/NetworkSlicingConfig.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/telephony/data/NetworkSlicingConfig.java
MIT
private FpUtils() {}
Don't let anyone instantiate this class.
FpUtils::FpUtils
java
Reginer/aosp-android-jar
android-35/src/sun/misc/FpUtils.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/sun/misc/FpUtils.java
MIT
public static boolean isInfinite(double d) { return Double.isInfinite(d); }
Returns {@code true} if the specified number is infinitely large in magnitude, {@code false} otherwise. <p>Note that this method is equivalent to the {@link Double#isInfinite(double) Double.isInfinite} method; the functionality is included in this class for convenience. @param d the value to be tested. @return {@code true} if the value of the argument is positive infinity or negative infinity; {@code false} otherwise.
FpUtils::isInfinite
java
Reginer/aosp-android-jar
android-35/src/sun/misc/FpUtils.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/sun/misc/FpUtils.java
MIT
public static boolean isInfinite(float f) { return Float.isInfinite(f); }
Returns {@code true} if the specified number is infinitely large in magnitude, {@code false} otherwise. <p>Note that this method is equivalent to the {@link Float#isInfinite(float) Float.isInfinite} method; the functionality is included in this class for convenience. @param f the value to be tested. @return {@code true} if the argument is positive infinity or negative infinity; {@code false} otherwise.
FpUtils::isInfinite
java
Reginer/aosp-android-jar
android-35/src/sun/misc/FpUtils.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/sun/misc/FpUtils.java
MIT
public static boolean isNaN(double d) { return Double.isNaN(d); }
Returns {@code true} if the specified number is a Not-a-Number (NaN) value, {@code false} otherwise. <p>Note that this method is equivalent to the {@link Double#isNaN(double) Double.isNaN} method; the functionality is included in this class for convenience. @param d the value to be tested. @return {@code true} if the value of the argument is NaN; {@code false} otherwise.
FpUtils::isNaN
java
Reginer/aosp-android-jar
android-35/src/sun/misc/FpUtils.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/sun/misc/FpUtils.java
MIT
public static boolean isNaN(float f) { return Float.isNaN(f); }
Returns {@code true} if the specified number is a Not-a-Number (NaN) value, {@code false} otherwise. <p>Note that this method is equivalent to the {@link Float#isNaN(float) Float.isNaN} method; the functionality is included in this class for convenience. @param f the value to be tested. @return {@code true} if the argument is NaN; {@code false} otherwise.
FpUtils::isNaN
java
Reginer/aosp-android-jar
android-35/src/sun/misc/FpUtils.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/sun/misc/FpUtils.java
MIT
public static boolean isUnordered(double arg1, double arg2) { return isNaN(arg1) || isNaN(arg2); }
Returns {@code true} if the unordered relation holds between the two arguments. When two floating-point values are unordered, one value is neither less than, equal to, nor greater than the other. For the unordered relation to be true, at least one argument must be a {@code NaN}. @param arg1 the first argument @param arg2 the second argument @return {@code true} if at least one argument is a NaN, {@code false} otherwise.
FpUtils::isUnordered
java
Reginer/aosp-android-jar
android-35/src/sun/misc/FpUtils.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/sun/misc/FpUtils.java
MIT
public static boolean isUnordered(float arg1, float arg2) { return isNaN(arg1) || isNaN(arg2); }
Returns {@code true} if the unordered relation holds between the two arguments. When two floating-point values are unordered, one value is neither less than, equal to, nor greater than the other. For the unordered relation to be true, at least one argument must be a {@code NaN}. @param arg1 the first argument @param arg2 the second argument @return {@code true} if at least one argument is a NaN, {@code false} otherwise.
FpUtils::isUnordered
java
Reginer/aosp-android-jar
android-35/src/sun/misc/FpUtils.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/sun/misc/FpUtils.java
MIT
public static int ilogb(double d) { int exponent = getExponent(d); switch (exponent) { case DoubleConsts.MAX_EXPONENT+1: // NaN or infinity if( isNaN(d) ) return (1<<30); // 2^30 else // infinite value return (1<<28); // 2^28 case DoubleConsts.MIN_EXPONENT-1: // zero or subnormal if(d == 0.0) { return -(1<<28); // -(2^28) } else { long transducer = Double.doubleToRawLongBits(d); /* * To avoid causing slow arithmetic on subnormals, * the scaling to determine when d's significand * is normalized is done in integer arithmetic. * (there must be at least one "1" bit in the * significand since zero has been screened out. */ // isolate significand bits transducer &= DoubleConsts.SIGNIF_BIT_MASK; assert(transducer != 0L); // This loop is simple and functional. We might be // able to do something more clever that was faster; // e.g. number of leading zero detection on // (transducer << (# exponent and sign bits). while (transducer < (1L << (DoubleConsts.SIGNIFICAND_WIDTH - 1))) { transducer *= 2; exponent--; } exponent++; assert( exponent >= DoubleConsts.MIN_EXPONENT - (DoubleConsts.SIGNIFICAND_WIDTH-1) && exponent < DoubleConsts.MIN_EXPONENT); return exponent; } default: assert( exponent >= DoubleConsts.MIN_EXPONENT && exponent <= DoubleConsts.MAX_EXPONENT); return exponent; } }
Returns unbiased exponent of a {@code double}; for subnormal values, the number is treated as if it were normalized. That is for all finite, non-zero, positive numbers <i>x</i>, <code>scalb(<i>x</i>, -ilogb(<i>x</i>))</code> is always in the range [1, 2). <p> Special cases: <ul> <li> If the argument is NaN, then the result is 2<sup>30</sup>. <li> If the argument is infinite, then the result is 2<sup>28</sup>. <li> If the argument is zero, then the result is -(2<sup>28</sup>). </ul> @param d floating-point number whose exponent is to be extracted @return unbiased exponent of the argument. @author Joseph D. Darcy
FpUtils::ilogb
java
Reginer/aosp-android-jar
android-35/src/sun/misc/FpUtils.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/sun/misc/FpUtils.java
MIT
public static int ilogb(float f) { int exponent = getExponent(f); switch (exponent) { case FloatConsts.MAX_EXPONENT+1: // NaN or infinity if( isNaN(f) ) return (1<<30); // 2^30 else // infinite value return (1<<28); // 2^28 case FloatConsts.MIN_EXPONENT-1: // zero or subnormal if(f == 0.0f) { return -(1<<28); // -(2^28) } else { int transducer = Float.floatToRawIntBits(f); /* * To avoid causing slow arithmetic on subnormals, * the scaling to determine when f's significand * is normalized is done in integer arithmetic. * (there must be at least one "1" bit in the * significand since zero has been screened out. */ // isolate significand bits transducer &= FloatConsts.SIGNIF_BIT_MASK; assert(transducer != 0); // This loop is simple and functional. We might be // able to do something more clever that was faster; // e.g. number of leading zero detection on // (transducer << (# exponent and sign bits). while (transducer < (1 << (FloatConsts.SIGNIFICAND_WIDTH - 1))) { transducer *= 2; exponent--; } exponent++; assert( exponent >= FloatConsts.MIN_EXPONENT - (FloatConsts.SIGNIFICAND_WIDTH-1) && exponent < FloatConsts.MIN_EXPONENT); return exponent; } default: assert( exponent >= FloatConsts.MIN_EXPONENT && exponent <= FloatConsts.MAX_EXPONENT); return exponent; } }
Returns unbiased exponent of a {@code float}; for subnormal values, the number is treated as if it were normalized. That is for all finite, non-zero, positive numbers <i>x</i>, <code>scalb(<i>x</i>, -ilogb(<i>x</i>))</code> is always in the range [1, 2). <p> Special cases: <ul> <li> If the argument is NaN, then the result is 2<sup>30</sup>. <li> If the argument is infinite, then the result is 2<sup>28</sup>. <li> If the argument is zero, then the result is -(2<sup>28</sup>). </ul> @param f floating-point number whose exponent is to be extracted @return unbiased exponent of the argument. @author Joseph D. Darcy
FpUtils::ilogb
java
Reginer/aosp-android-jar
android-35/src/sun/misc/FpUtils.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/sun/misc/FpUtils.java
MIT
public static String getDefaultCellBroadcastReceiverPackageName(Context context) { PackageManager packageManager = context.getPackageManager(); ResolveInfo resolveInfo = packageManager.resolveActivity( new Intent(Telephony.Sms.Intents.SMS_CB_RECEIVED_ACTION), PackageManager.MATCH_SYSTEM_ONLY); String packageName; if (resolveInfo == null) { Log.e(TAG, "getDefaultCellBroadcastReceiverPackageName: no package found"); return null; } packageName = resolveInfo.activityInfo.applicationInfo.packageName; if (VDBG) { Log.d(TAG, "getDefaultCellBroadcastReceiverPackageName: found package: " + packageName); } if (TextUtils.isEmpty(packageName) || packageManager.checkPermission( android.Manifest.permission.READ_CELL_BROADCASTS, packageName) == PackageManager.PERMISSION_DENIED) { Log.e(TAG, "getDefaultCellBroadcastReceiverPackageName: returning null; " + "permission check failed for : " + packageName); return null; } return packageName; }
Utility method to query the default CBR's package name.
CellBroadcastUtils::getDefaultCellBroadcastReceiverPackageName
java
Reginer/aosp-android-jar
android-35/src/com/android/internal/telephony/CellBroadcastUtils.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/internal/telephony/CellBroadcastUtils.java
MIT
public static ComponentName getDefaultCellBroadcastAlertDialogComponent(Context context) { String cellBroadcastReceiverPackageName = getDefaultCellBroadcastReceiverPackageName(context); if (TextUtils.isEmpty(cellBroadcastReceiverPackageName)) { return null; } return ComponentName.createRelative(cellBroadcastReceiverPackageName, "com.android.cellbroadcastreceiver.CellBroadcastAlertDialog"); }
Utility method to get cellbroadcast alert dialog component name
CellBroadcastUtils::getDefaultCellBroadcastAlertDialogComponent
java
Reginer/aosp-android-jar
android-35/src/com/android/internal/telephony/CellBroadcastUtils.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/internal/telephony/CellBroadcastUtils.java
MIT
public long getTime() { return SystemClock.uptimeNanos() / 1000; }
Return the current time in the internal time unit. Call it before an event happens, and give it back to the {@link #logDurationStat(int, long)}} after the event.
StatLogger::getTime
java
Reginer/aosp-android-jar
android-33/src/com/android/internal/util/StatLogger.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/internal/util/StatLogger.java
MIT
public long logDurationStat(int eventId, long start) { synchronized (mLock) { final long duration = getTime() - start; if (eventId >= 0 && eventId < SIZE) { mCountStats[eventId]++; mDurationStats[eventId] += duration; } else { Slog.wtf(TAG, "Invalid event ID: " + eventId); return duration; } if (mMaxDurationStats[eventId] < duration) { mMaxDurationStats[eventId] = duration; } // Keep track of the per-second max. final long nowRealtime = SystemClock.elapsedRealtime(); if (nowRealtime > mNextTickTime) { if (mMaxCallsPerSecond[eventId] < mCallsPerSecond[eventId]) { mMaxCallsPerSecond[eventId] = mCallsPerSecond[eventId]; } if (mMaxDurationPerSecond[eventId] < mDurationPerSecond[eventId]) { mMaxDurationPerSecond[eventId] = mDurationPerSecond[eventId]; } mCallsPerSecond[eventId] = 0; mDurationPerSecond[eventId] = 0; mNextTickTime = nowRealtime + 1000; } mCallsPerSecond[eventId]++; mDurationPerSecond[eventId] += duration; return duration; } }
@see {@link #getTime()} @return the duration in microseconds.
StatLogger::logDurationStat
java
Reginer/aosp-android-jar
android-33/src/com/android/internal/util/StatLogger.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/internal/util/StatLogger.java
MIT
public static ObbInfo getObbInfo(String filePath) throws IOException { if (filePath == null) { throw new IllegalArgumentException("file path cannot be null"); } final File obbFile = new File(filePath); if (!obbFile.exists()) { throw new IllegalArgumentException("OBB file does not exist: " + filePath); } /* * XXX This will fail to find the real canonical path if bind mounts are * used, but we don't use any bind mounts right now. */ final String canonicalFilePath = obbFile.getCanonicalPath(); ObbInfo obbInfo = new ObbInfo(); obbInfo.filename = canonicalFilePath; getObbInfo_native(canonicalFilePath, obbInfo); return obbInfo; }
Scan a file for OBB information. @param filePath path to the OBB file to be scanned. @return ObbInfo object information corresponding to the file path @throws IllegalArgumentException if the OBB file couldn't be found @throws IOException if the OBB file couldn't be read
ObbScanner::getObbInfo
java
Reginer/aosp-android-jar
android-35/src/android/content/res/ObbScanner.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/content/res/ObbScanner.java
MIT
public static boolean isCombinationValid(@Nullable List<ParsedAttribution> attributions) { if (attributions == null) { return true; } ArraySet<String> attributionTags = new ArraySet<>(attributions.size()); ArraySet<String> inheritFromAttributionTags = new ArraySet<>(); int numAttributions = attributions.size(); if (numAttributions > ParsedAttributionImpl.MAX_NUM_ATTRIBUTIONS) { return false; } for (int attributionNum = 0; attributionNum < numAttributions; attributionNum++) { boolean wasAdded = attributionTags.add(attributions.get(attributionNum).getTag()); if (!wasAdded) { // feature id is not unique return false; } } for (int attributionNum = 0; attributionNum < numAttributions; attributionNum++) { ParsedAttribution feature = attributions.get(attributionNum); final List<String> inheritFromList = feature.getInheritFrom(); int numInheritFrom = inheritFromList.size(); for (int inheritFromNum = 0; inheritFromNum < numInheritFrom; inheritFromNum++) { String inheritFrom = inheritFromList.get(inheritFromNum); if (attributionTags.contains(inheritFrom)) { // Cannot inherit from a attribution that is still defined return false; } boolean wasAdded = inheritFromAttributionTags.add(inheritFrom); if (!wasAdded) { // inheritFrom is not unique return false; } } } return true; }
@return Is this set of attributions a valid combination for a single package?
ParsedAttributionUtils::isCombinationValid
java
Reginer/aosp-android-jar
android-33/src/com/android/server/pm/pkg/component/ParsedAttributionUtils.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/server/pm/pkg/component/ParsedAttributionUtils.java
MIT
public PipedWriter(PipedReader snk) throws IOException { connect(snk); }
Creates a piped writer connected to the specified piped reader. Data characters written to this stream will then be available as input from <code>snk</code>. @param snk The piped reader to connect to. @exception IOException if an I/O error occurs.
PipedWriter::PipedWriter
java
Reginer/aosp-android-jar
android-32/src/java/io/PipedWriter.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/java/io/PipedWriter.java
MIT
public PipedWriter() { }
Creates a piped writer that is not yet connected to a piped reader. It must be connected to a piped reader, either by the receiver or the sender, before being used. @see java.io.PipedReader#connect(java.io.PipedWriter) @see java.io.PipedWriter#connect(java.io.PipedReader)
PipedWriter::PipedWriter
java
Reginer/aosp-android-jar
android-32/src/java/io/PipedWriter.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/java/io/PipedWriter.java
MIT
public synchronized void connect(PipedReader snk) throws IOException { if (snk == null) { throw new NullPointerException(); } else if (sink != null || snk.connected) { throw new IOException("Already connected"); } else if (snk.closedByReader || closed) { throw new IOException("Pipe closed"); } sink = snk; snk.in = -1; snk.out = 0; snk.connected = true; }
Connects this piped writer to a receiver. If this object is already connected to some other piped reader, an <code>IOException</code> is thrown. <p> If <code>snk</code> is an unconnected piped reader and <code>src</code> is an unconnected piped writer, they may be connected by either the call: <blockquote><pre> src.connect(snk)</pre></blockquote> or the call: <blockquote><pre> snk.connect(src)</pre></blockquote> The two calls have the same effect. @param snk the piped reader to connect to. @exception IOException if an I/O error occurs.
PipedWriter::connect
java
Reginer/aosp-android-jar
android-32/src/java/io/PipedWriter.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/java/io/PipedWriter.java
MIT
public void write(int c) throws IOException { if (sink == null) { throw new IOException("Pipe not connected"); } sink.receive(c); }
Writes the specified <code>char</code> to the piped output stream. If a thread was reading data characters from the connected piped input stream, but the thread is no longer alive, then an <code>IOException</code> is thrown. <p> Implements the <code>write</code> method of <code>Writer</code>. @param c the <code>char</code> to be written. @exception IOException if the pipe is <a href=PipedOutputStream.html#BROKEN> <code>broken</code></a>, {@link #connect(java.io.PipedReader) unconnected}, closed or an I/O error occurs.
PipedWriter::write
java
Reginer/aosp-android-jar
android-32/src/java/io/PipedWriter.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/java/io/PipedWriter.java
MIT
public void write(char cbuf[], int off, int len) throws IOException { if (sink == null) { throw new IOException("Pipe not connected"); } else if ((off | len | (off + len) | (cbuf.length - (off + len))) < 0) { throw new IndexOutOfBoundsException(); } sink.receive(cbuf, off, len); }
Writes <code>len</code> characters from the specified character array starting at offset <code>off</code> to this piped output stream. This method blocks until all the characters are written to the output stream. If a thread was reading data characters from the connected piped input stream, but the thread is no longer alive, then an <code>IOException</code> is thrown. @param cbuf the data. @param off the start offset in the data. @param len the number of characters to write. @exception IOException if the pipe is <a href=PipedOutputStream.html#BROKEN> <code>broken</code></a>, {@link #connect(java.io.PipedReader) unconnected}, closed or an I/O error occurs.
PipedWriter::write
java
Reginer/aosp-android-jar
android-32/src/java/io/PipedWriter.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/java/io/PipedWriter.java
MIT
public synchronized void flush() throws IOException { if (sink != null) { if (sink.closedByReader || closed) { throw new IOException("Pipe closed"); } synchronized (sink) { sink.notifyAll(); } } }
Flushes this output stream and forces any buffered output characters to be written out. This will notify any readers that characters are waiting in the pipe. @exception IOException if the pipe is closed, or an I/O error occurs.
PipedWriter::flush
java
Reginer/aosp-android-jar
android-32/src/java/io/PipedWriter.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/java/io/PipedWriter.java
MIT
public void close() throws IOException { closed = true; if (sink != null) { sink.receivedLast(); } }
Closes this piped output stream and releases any system resources associated with this stream. This stream may no longer be used for writing characters. @exception IOException if an I/O error occurs.
PipedWriter::close
java
Reginer/aosp-android-jar
android-32/src/java/io/PipedWriter.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/java/io/PipedWriter.java
MIT
public static <T> boolean contains(@Nullable Collection<T> collection, T element) { return collection != null && collection.contains(element); }
@see Collection#contains(Object)
CollectionUtils::contains
java
Reginer/aosp-android-jar
android-34/src/com/android/internal/util/CollectionUtils.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/internal/util/CollectionUtils.java
MIT
public static @NonNull <T> List<T> filter(@Nullable List<T> list, java.util.function.Predicate<? super T> predicate) { ArrayList<T> result = null; for (int i = 0; i < size(list); i++) { final T item = list.get(i); if (predicate.test(item)) { result = ArrayUtils.add(result, item); } } return emptyIfNull(result); }
Returns a list of items from the provided list that match the given condition. This is similar to {@link Stream#filter} but without the overhead of creating an intermediate {@link Stream} instance
CollectionUtils::filter
java
Reginer/aosp-android-jar
android-34/src/com/android/internal/util/CollectionUtils.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/internal/util/CollectionUtils.java
MIT
public static @NonNull <T> Set<T> filter(@Nullable Set<T> set, java.util.function.Predicate<? super T> predicate) { if (set == null || set.size() == 0) return emptySet(); ArraySet<T> result = null; if (set instanceof ArraySet) { ArraySet<T> arraySet = (ArraySet<T>) set; int size = arraySet.size(); for (int i = 0; i < size; i++) { final T item = arraySet.valueAt(i); if (predicate.test(item)) { result = ArrayUtils.add(result, item); } } } else { for (T item : set) { if (predicate.test(item)) { result = ArrayUtils.add(result, item); } } } return emptyIfNull(result); }
@see #filter(List, java.util.function.Predicate)
CollectionUtils::filter
java
Reginer/aosp-android-jar
android-34/src/com/android/internal/util/CollectionUtils.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/internal/util/CollectionUtils.java
MIT
public static <T> void addIf(@Nullable List<T> source, @NonNull Collection<? super T> dest, @Nullable Predicate<? super T> predicate) { for (int i = 0; i < size(source); i++) { final T item = source.get(i); if (predicate.test(item)) { dest.add(item); } } }
@see #filter(List, java.util.function.Predicate) public static @NonNull <T> Set<T> filter(@Nullable Set<T> set, java.util.function.Predicate<? super T> predicate) { if (set == null || set.size() == 0) return emptySet(); ArraySet<T> result = null; if (set instanceof ArraySet) { ArraySet<T> arraySet = (ArraySet<T>) set; int size = arraySet.size(); for (int i = 0; i < size; i++) { final T item = arraySet.valueAt(i); if (predicate.test(item)) { result = ArrayUtils.add(result, item); } } } else { for (T item : set) { if (predicate.test(item)) { result = ArrayUtils.add(result, item); } } } return emptyIfNull(result); } /** Add all elements matching {@code predicate} in {@code source} to {@code dest}.
CollectionUtils::addIf
java
Reginer/aosp-android-jar
android-34/src/com/android/internal/util/CollectionUtils.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/internal/util/CollectionUtils.java
MIT
public static @NonNull <I, O> List<O> map(@Nullable List<I> cur, Function<? super I, ? extends O> f) { if (isEmpty(cur)) return Collections.emptyList(); final ArrayList<O> result = new ArrayList<>(); for (int i = 0; i < cur.size(); i++) { result.add(f.apply(cur.get(i))); } return result; }
Returns a list of items resulting from applying the given function to each element of the provided list. The resulting list will have the same {@link #size} as the input one. This is similar to {@link Stream#map} but without the overhead of creating an intermediate {@link Stream} instance
CollectionUtils::map
java
Reginer/aosp-android-jar
android-34/src/com/android/internal/util/CollectionUtils.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/internal/util/CollectionUtils.java
MIT
public static @NonNull <I, O> Set<O> map(@Nullable Set<I> cur, Function<? super I, ? extends O> f) { if (isEmpty(cur)) return emptySet(); ArraySet<O> result = new ArraySet<>(); if (cur instanceof ArraySet) { ArraySet<I> arraySet = (ArraySet<I>) cur; int size = arraySet.size(); for (int i = 0; i < size; i++) { result.add(f.apply(arraySet.valueAt(i))); } } else { for (I item : cur) { result.add(f.apply(item)); } } return result; }
@see #map(List, Function)
CollectionUtils::map
java
Reginer/aosp-android-jar
android-34/src/com/android/internal/util/CollectionUtils.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/internal/util/CollectionUtils.java
MIT
public static @NonNull <I, O> List<O> mapNotNull(@Nullable List<I> cur, Function<? super I, ? extends O> f) { if (isEmpty(cur)) return Collections.emptyList(); List<O> result = null; for (int i = 0; i < cur.size(); i++) { O transformed = f.apply(cur.get(i)); if (transformed != null) { result = add(result, transformed); } } return emptyIfNull(result); }
{@link #map(List, Function)} + {@link #filter(List, java.util.function.Predicate)} Calling this is equivalent (but more memory efficient) to: {@code filter( map(cur, f), i -> { i != null }) }
CollectionUtils::mapNotNull
java
Reginer/aosp-android-jar
android-34/src/com/android/internal/util/CollectionUtils.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/internal/util/CollectionUtils.java
MIT
public static @NonNull <T> List<T> emptyIfNull(@Nullable List<T> cur) { return cur == null ? Collections.emptyList() : cur; }
Returns the given list, or an immutable empty list if the provided list is null This can be used to guarantee null-safety without paying the price of extra allocations @see Collections#emptyList
CollectionUtils::emptyIfNull
java
Reginer/aosp-android-jar
android-34/src/com/android/internal/util/CollectionUtils.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/internal/util/CollectionUtils.java
MIT
public static @NonNull <T> Set<T> emptyIfNull(@Nullable Set<T> cur) { return cur == null ? emptySet() : cur; }
Returns the given set, or an immutable empty set if the provided set is null This can be used to guarantee null-safety without paying the price of extra allocations @see Collections#emptySet
CollectionUtils::emptyIfNull
java
Reginer/aosp-android-jar
android-34/src/com/android/internal/util/CollectionUtils.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/internal/util/CollectionUtils.java
MIT