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 static Byte2 add(Byte2 a, Byte2 b) { Byte2 result = new Byte2(); result.x = (byte)(a.x + b.x); result.y = (byte)(a.y + b.y); return result; }
@hide Vector add @param a @param b @return
Byte2::add
java
Reginer/aosp-android-jar
android-31/src/android/renderscript/Byte2.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/renderscript/Byte2.java
MIT
public void add(byte value) { x += value; y += value; }
@hide Vector add @param value
Byte2::add
java
Reginer/aosp-android-jar
android-31/src/android/renderscript/Byte2.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/renderscript/Byte2.java
MIT
public static Byte2 add(Byte2 a, byte b) { Byte2 result = new Byte2(); result.x = (byte)(a.x + b); result.y = (byte)(a.y + b); return result; }
@hide Vector add @param a @param b @return
Byte2::add
java
Reginer/aosp-android-jar
android-31/src/android/renderscript/Byte2.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/renderscript/Byte2.java
MIT
public void sub(Byte2 a) { this.x -= a.x; this.y -= a.y; }
@hide Vector subtraction @param a
Byte2::sub
java
Reginer/aosp-android-jar
android-31/src/android/renderscript/Byte2.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/renderscript/Byte2.java
MIT
public static Byte2 sub(Byte2 a, Byte2 b) { Byte2 result = new Byte2(); result.x = (byte)(a.x - b.x); result.y = (byte)(a.y - b.y); return result; }
@hide Vector subtraction @param a @param b @return
Byte2::sub
java
Reginer/aosp-android-jar
android-31/src/android/renderscript/Byte2.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/renderscript/Byte2.java
MIT
public void sub(byte value) { x -= value; y -= value; }
@hide Vector subtraction @param value
Byte2::sub
java
Reginer/aosp-android-jar
android-31/src/android/renderscript/Byte2.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/renderscript/Byte2.java
MIT
public static Byte2 sub(Byte2 a, byte b) { Byte2 result = new Byte2(); result.x = (byte)(a.x - b); result.y = (byte)(a.y - b); return result; }
@hide Vector subtraction @param a @param b @return
Byte2::sub
java
Reginer/aosp-android-jar
android-31/src/android/renderscript/Byte2.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/renderscript/Byte2.java
MIT
public void mul(Byte2 a) { this.x *= a.x; this.y *= a.y; }
@hide Vector multiplication @param a
Byte2::mul
java
Reginer/aosp-android-jar
android-31/src/android/renderscript/Byte2.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/renderscript/Byte2.java
MIT
public static Byte2 mul(Byte2 a, Byte2 b) { Byte2 result = new Byte2(); result.x = (byte)(a.x * b.x); result.y = (byte)(a.y * b.y); return result; }
@hide Vector multiplication @param a @param b @return
Byte2::mul
java
Reginer/aosp-android-jar
android-31/src/android/renderscript/Byte2.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/renderscript/Byte2.java
MIT
public void mul(byte value) { x *= value; y *= value; }
@hide Vector multiplication @param value
Byte2::mul
java
Reginer/aosp-android-jar
android-31/src/android/renderscript/Byte2.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/renderscript/Byte2.java
MIT
public static Byte2 mul(Byte2 a, byte b) { Byte2 result = new Byte2(); result.x = (byte)(a.x * b); result.y = (byte)(a.y * b); return result; }
@hide Vector multiplication @param a @param b @return
Byte2::mul
java
Reginer/aosp-android-jar
android-31/src/android/renderscript/Byte2.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/renderscript/Byte2.java
MIT
public void div(Byte2 a) { this.x /= a.x; this.y /= a.y; }
@hide Vector division @param a
Byte2::div
java
Reginer/aosp-android-jar
android-31/src/android/renderscript/Byte2.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/renderscript/Byte2.java
MIT
public static Byte2 div(Byte2 a, Byte2 b) { Byte2 result = new Byte2(); result.x = (byte)(a.x / b.x); result.y = (byte)(a.y / b.y); return result; }
@hide Vector division @param a @param b @return
Byte2::div
java
Reginer/aosp-android-jar
android-31/src/android/renderscript/Byte2.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/renderscript/Byte2.java
MIT
public void div(byte value) { x /= value; y /= value; }
@hide Vector division @param value
Byte2::div
java
Reginer/aosp-android-jar
android-31/src/android/renderscript/Byte2.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/renderscript/Byte2.java
MIT
public static Byte2 div(Byte2 a, byte b) { Byte2 result = new Byte2(); result.x = (byte)(a.x / b); result.y = (byte)(a.y / b); return result; }
@hide Vector division @param a @param b @return
Byte2::div
java
Reginer/aosp-android-jar
android-31/src/android/renderscript/Byte2.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/renderscript/Byte2.java
MIT
public byte length() { return 2; }
@hide get vector length @return
Byte2::length
java
Reginer/aosp-android-jar
android-31/src/android/renderscript/Byte2.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/renderscript/Byte2.java
MIT
public void negate() { this.x = (byte)(-x); this.y = (byte)(-y); }
@hide set vector negate
Byte2::negate
java
Reginer/aosp-android-jar
android-31/src/android/renderscript/Byte2.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/renderscript/Byte2.java
MIT
public byte dotProduct(Byte2 a) { return (byte)((x * a.x) + (y * a.y)); }
@hide Vector dot Product @param a @return
Byte2::dotProduct
java
Reginer/aosp-android-jar
android-31/src/android/renderscript/Byte2.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/renderscript/Byte2.java
MIT
public static byte dotProduct(Byte2 a, Byte2 b) { return (byte)((b.x * a.x) + (b.y * a.y)); }
@hide Vector dot Product @param a @param b @return
Byte2::dotProduct
java
Reginer/aosp-android-jar
android-31/src/android/renderscript/Byte2.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/renderscript/Byte2.java
MIT
public void addMultiple(Byte2 a, byte factor) { x += a.x * factor; y += a.y * factor; }
@hide Vector add Multiple @param a @param factor
Byte2::addMultiple
java
Reginer/aosp-android-jar
android-31/src/android/renderscript/Byte2.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/renderscript/Byte2.java
MIT
public void set(Byte2 a) { this.x = a.x; this.y = a.y; }
@hide set vector value by Byte2 @param a
Byte2::set
java
Reginer/aosp-android-jar
android-31/src/android/renderscript/Byte2.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/renderscript/Byte2.java
MIT
public void setValues(byte a, byte b) { this.x = a; this.y = b; }
@hide set the vector field value by Char @param a @param b
Byte2::setValues
java
Reginer/aosp-android-jar
android-31/src/android/renderscript/Byte2.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/renderscript/Byte2.java
MIT
public byte elementSum() { return (byte)(x + y); }
@hide return the element sum of vector @return
Byte2::elementSum
java
Reginer/aosp-android-jar
android-31/src/android/renderscript/Byte2.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/renderscript/Byte2.java
MIT
public byte get(int i) { switch (i) { case 0: return x; case 1: return y; default: throw new IndexOutOfBoundsException("Index: i"); } }
@hide get the vector field value by index @param i @return
Byte2::get
java
Reginer/aosp-android-jar
android-31/src/android/renderscript/Byte2.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/renderscript/Byte2.java
MIT
public void setAt(int i, byte value) { switch (i) { case 0: x = value; return; case 1: y = value; return; default: throw new IndexOutOfBoundsException("Index: i"); } }
@hide set the vector field value by index @param i @param value
Byte2::setAt
java
Reginer/aosp-android-jar
android-31/src/android/renderscript/Byte2.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/renderscript/Byte2.java
MIT
public void addAt(int i, byte value) { switch (i) { case 0: x += value; return; case 1: y += value; return; default: throw new IndexOutOfBoundsException("Index: i"); } }
@hide add the vector field value by index @param i @param value
Byte2::addAt
java
Reginer/aosp-android-jar
android-31/src/android/renderscript/Byte2.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/renderscript/Byte2.java
MIT
public void copyTo(byte[] data, int offset) { data[offset] = x; data[offset + 1] = y; }
@hide copy the vector to Char array @param data @param offset
Byte2::copyTo
java
Reginer/aosp-android-jar
android-31/src/android/renderscript/Byte2.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/renderscript/Byte2.java
MIT
public static String nameOf(int event) { String name = EVENT_NAMES.get(event); if (name == null) { return Integer.toString(event); } return name; }
Network service discovery is enabled @see #ACTION_NSD_STATE_CHANGED public static final int NSD_STATE_ENABLED = 2; /** @hide public static final int DISCOVER_SERVICES = 1; /** @hide public static final int DISCOVER_SERVICES_STARTED = 2; /** @hide public static final int DISCOVER_SERVICES_FAILED = 3; /** @hide public static final int SERVICE_FOUND = 4; /** @hide public static final int SERVICE_LOST = 5; /** @hide public static final int STOP_DISCOVERY = 6; /** @hide public static final int STOP_DISCOVERY_FAILED = 7; /** @hide public static final int STOP_DISCOVERY_SUCCEEDED = 8; /** @hide public static final int REGISTER_SERVICE = 9; /** @hide public static final int REGISTER_SERVICE_FAILED = 10; /** @hide public static final int REGISTER_SERVICE_SUCCEEDED = 11; /** @hide public static final int UNREGISTER_SERVICE = 12; /** @hide public static final int UNREGISTER_SERVICE_FAILED = 13; /** @hide public static final int UNREGISTER_SERVICE_SUCCEEDED = 14; /** @hide public static final int RESOLVE_SERVICE = 15; /** @hide public static final int RESOLVE_SERVICE_FAILED = 16; /** @hide public static final int RESOLVE_SERVICE_SUCCEEDED = 17; /** @hide public static final int DAEMON_CLEANUP = 18; /** @hide public static final int DAEMON_STARTUP = 19; /** @hide public static final int MDNS_SERVICE_EVENT = 20; /** @hide public static final int REGISTER_CLIENT = 21; /** @hide public static final int UNREGISTER_CLIENT = 22; /** @hide public static final int MDNS_DISCOVERY_MANAGER_EVENT = 23; /** @hide public static final int STOP_RESOLUTION = 24; /** @hide public static final int STOP_RESOLUTION_FAILED = 25; /** @hide public static final int STOP_RESOLUTION_SUCCEEDED = 26; /** @hide public static final int REGISTER_SERVICE_CALLBACK = 27; /** @hide public static final int REGISTER_SERVICE_CALLBACK_FAILED = 28; /** @hide public static final int SERVICE_UPDATED = 29; /** @hide public static final int SERVICE_UPDATED_LOST = 30; /** @hide public static final int UNREGISTER_SERVICE_CALLBACK = 31; /** @hide public static final int UNREGISTER_SERVICE_CALLBACK_SUCCEEDED = 32; /** Dns based service discovery protocol public static final int PROTOCOL_DNS_SD = 0x0001; private static final SparseArray<String> EVENT_NAMES = new SparseArray<>(); static { EVENT_NAMES.put(DISCOVER_SERVICES, "DISCOVER_SERVICES"); EVENT_NAMES.put(DISCOVER_SERVICES_STARTED, "DISCOVER_SERVICES_STARTED"); EVENT_NAMES.put(DISCOVER_SERVICES_FAILED, "DISCOVER_SERVICES_FAILED"); EVENT_NAMES.put(SERVICE_FOUND, "SERVICE_FOUND"); EVENT_NAMES.put(SERVICE_LOST, "SERVICE_LOST"); EVENT_NAMES.put(STOP_DISCOVERY, "STOP_DISCOVERY"); EVENT_NAMES.put(STOP_DISCOVERY_FAILED, "STOP_DISCOVERY_FAILED"); EVENT_NAMES.put(STOP_DISCOVERY_SUCCEEDED, "STOP_DISCOVERY_SUCCEEDED"); EVENT_NAMES.put(REGISTER_SERVICE, "REGISTER_SERVICE"); EVENT_NAMES.put(REGISTER_SERVICE_FAILED, "REGISTER_SERVICE_FAILED"); EVENT_NAMES.put(REGISTER_SERVICE_SUCCEEDED, "REGISTER_SERVICE_SUCCEEDED"); EVENT_NAMES.put(UNREGISTER_SERVICE, "UNREGISTER_SERVICE"); EVENT_NAMES.put(UNREGISTER_SERVICE_FAILED, "UNREGISTER_SERVICE_FAILED"); EVENT_NAMES.put(UNREGISTER_SERVICE_SUCCEEDED, "UNREGISTER_SERVICE_SUCCEEDED"); EVENT_NAMES.put(RESOLVE_SERVICE, "RESOLVE_SERVICE"); EVENT_NAMES.put(RESOLVE_SERVICE_FAILED, "RESOLVE_SERVICE_FAILED"); EVENT_NAMES.put(RESOLVE_SERVICE_SUCCEEDED, "RESOLVE_SERVICE_SUCCEEDED"); EVENT_NAMES.put(DAEMON_CLEANUP, "DAEMON_CLEANUP"); EVENT_NAMES.put(DAEMON_STARTUP, "DAEMON_STARTUP"); EVENT_NAMES.put(MDNS_SERVICE_EVENT, "MDNS_SERVICE_EVENT"); EVENT_NAMES.put(STOP_RESOLUTION, "STOP_RESOLUTION"); EVENT_NAMES.put(STOP_RESOLUTION_FAILED, "STOP_RESOLUTION_FAILED"); EVENT_NAMES.put(STOP_RESOLUTION_SUCCEEDED, "STOP_RESOLUTION_SUCCEEDED"); EVENT_NAMES.put(REGISTER_SERVICE_CALLBACK, "REGISTER_SERVICE_CALLBACK"); EVENT_NAMES.put(REGISTER_SERVICE_CALLBACK_FAILED, "REGISTER_SERVICE_CALLBACK_FAILED"); EVENT_NAMES.put(SERVICE_UPDATED, "SERVICE_UPDATED"); EVENT_NAMES.put(UNREGISTER_SERVICE_CALLBACK, "UNREGISTER_SERVICE_CALLBACK"); EVENT_NAMES.put(UNREGISTER_SERVICE_CALLBACK_SUCCEEDED, "UNREGISTER_SERVICE_CALLBACK_SUCCEEDED"); EVENT_NAMES.put(MDNS_DISCOVERY_MANAGER_EVENT, "MDNS_DISCOVERY_MANAGER_EVENT"); EVENT_NAMES.put(REGISTER_CLIENT, "REGISTER_CLIENT"); EVENT_NAMES.put(UNREGISTER_CLIENT, "UNREGISTER_CLIENT"); } /** @hide
getSimpleName::nameOf
java
Reginer/aosp-android-jar
android-34/src/android/net/nsd/NsdManager.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/net/nsd/NsdManager.java
MIT
public hc_namednodemapinuseattributeerr(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_namednodemapinuseattributeerr::hc_namednodemapinuseattributeerr
java
Reginer/aosp-android-jar
android-34/src/org/w3c/domts/level1/core/hc_namednodemapinuseattributeerr.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/w3c/domts/level1/core/hc_namednodemapinuseattributeerr.java
MIT
public void runTest() throws Throwable { Document doc; NodeList elementList; Element firstNode; Node testNode; NamedNodeMap attributes; Attr domesticAttr; Attr setAttr; Node setNode; doc = (Document) load("hc_staff", true); elementList = doc.getElementsByTagName("acronym"); firstNode = (Element) elementList.item(0); domesticAttr = doc.createAttribute("title"); domesticAttr.setValue("Y\u03b1"); // Android-changed: GREEK LOWER CASE ALPHA setAttr = firstNode.setAttributeNode(domesticAttr); elementList = doc.getElementsByTagName("acronym"); testNode = elementList.item(2); attributes = testNode.getAttributes(); { boolean success = false; try { setNode = attributes.setNamedItem(domesticAttr); } catch (DOMException ex) { success = (ex.code == DOMException.INUSE_ATTRIBUTE_ERR); } assertTrue("throw_INUSE_ATTRIBUTE_ERR", success); } }
Runs the test case. @throws Throwable Any uncaught exception causes test to fail
hc_namednodemapinuseattributeerr::runTest
java
Reginer/aosp-android-jar
android-34/src/org/w3c/domts/level1/core/hc_namednodemapinuseattributeerr.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/w3c/domts/level1/core/hc_namednodemapinuseattributeerr.java
MIT
public String getTargetURI() { return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/hc_namednodemapinuseattributeerr"; }
Gets URI that identifies the test. @return uri identifier of test
hc_namednodemapinuseattributeerr::getTargetURI
java
Reginer/aosp-android-jar
android-34/src/org/w3c/domts/level1/core/hc_namednodemapinuseattributeerr.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/w3c/domts/level1/core/hc_namednodemapinuseattributeerr.java
MIT
public static void main(final String[] args) { DOMTestCase.doMain(hc_namednodemapinuseattributeerr.class, args); }
Runs this test from the command line. @param args command line arguments
hc_namednodemapinuseattributeerr::main
java
Reginer/aosp-android-jar
android-34/src/org/w3c/domts/level1/core/hc_namednodemapinuseattributeerr.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/w3c/domts/level1/core/hc_namednodemapinuseattributeerr.java
MIT
public void onTimeChanged() { mTime.setTimeInMillis(System.currentTimeMillis()); final float hourAngle = mTime.get(Calendar.HOUR) * 30f + mTime.get(Calendar.MINUTE) * 0.5f; mHourHand.setRotation(hourAngle); final float minuteAngle = mTime.get(Calendar.MINUTE) * 6f; mMinuteHand.setRotation(minuteAngle); setContentDescription(DateFormat.format(mDescFormat, mTime)); invalidate(); }
Call when the time changes to update the rotation of the clock hands.
ImageClock::onTimeChanged
java
Reginer/aosp-android-jar
android-32/src/com/android/keyguard/clock/ImageClock.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/keyguard/clock/ImageClock.java
MIT
public void onTimeZoneChanged(TimeZone timeZone) { mTimeZone = timeZone; mTime.setTimeZone(timeZone); }
Call when the time zone has changed to update clock hands. @param timeZone The updated time zone that will be used.
ImageClock::onTimeZoneChanged
java
Reginer/aosp-android-jar
android-32/src/com/android/keyguard/clock/ImageClock.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/keyguard/clock/ImageClock.java
MIT
public void setClockColors(int dark, int light) { mHourHand.setColorFilter(dark); mMinuteHand.setColorFilter(light); }
Sets the colors to use on the clock face. @param dark Darker color obtained from color palette. @param light Lighter color obtained from color palette.
ImageClock::setClockColors
java
Reginer/aosp-android-jar
android-32/src/com/android/keyguard/clock/ImageClock.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/keyguard/clock/ImageClock.java
MIT
public Iterator<E> iterator() { return new EnumSetIterator<>(); }
Returns an iterator over the elements contained in this set. The iterator traverses the elements in their <i>natural order</i> (which is the order in which the enum constants are declared). The returned Iterator is a "snapshot" iterator that will never throw {@link ConcurrentModificationException}; the elements are traversed as they existed when this call was invoked. @return an iterator over the elements contained in this set
RegularEnumSet::iterator
java
Reginer/aosp-android-jar
android-34/src/java/util/RegularEnumSet.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/java/util/RegularEnumSet.java
MIT
public int size() { return Long.bitCount(elements); }
Returns the number of elements in this set. @return the number of elements in this set
EnumSetIterator::size
java
Reginer/aosp-android-jar
android-34/src/java/util/RegularEnumSet.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/java/util/RegularEnumSet.java
MIT
public boolean isEmpty() { return elements == 0; }
Returns {@code true} if this set contains no elements. @return {@code true} if this set contains no elements
EnumSetIterator::isEmpty
java
Reginer/aosp-android-jar
android-34/src/java/util/RegularEnumSet.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/java/util/RegularEnumSet.java
MIT
public boolean contains(Object e) { if (e == null) return false; Class<?> eClass = e.getClass(); if (eClass != elementType && eClass.getSuperclass() != elementType) return false; return (elements & (1L << ((Enum<?>)e).ordinal())) != 0; }
Returns {@code true} if this set contains the specified element. @param e element to be checked for containment in this collection @return {@code true} if this set contains the specified element
EnumSetIterator::contains
java
Reginer/aosp-android-jar
android-34/src/java/util/RegularEnumSet.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/java/util/RegularEnumSet.java
MIT
public boolean add(E e) { typeCheck(e); long oldElements = elements; elements |= (1L << ((Enum<?>)e).ordinal()); return elements != oldElements; }
Adds the specified element to this set if it is not already present. @param e element to be added to this set @return {@code true} if the set changed as a result of the call @throws NullPointerException if {@code e} is null
EnumSetIterator::add
java
Reginer/aosp-android-jar
android-34/src/java/util/RegularEnumSet.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/java/util/RegularEnumSet.java
MIT
public boolean containsAll(Collection<?> c) { if (!(c instanceof RegularEnumSet<?> es)) return super.containsAll(c); if (es.elementType != elementType) return es.isEmpty(); return (es.elements & ~elements) == 0; }
Returns {@code true} if this set contains all of the elements in the specified collection. @param c collection to be checked for containment in this set @return {@code true} if this set contains all of the elements in the specified collection @throws NullPointerException if the specified collection is null
RegularEnumSet::containsAll
java
Reginer/aosp-android-jar
android-34/src/java/util/RegularEnumSet.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/java/util/RegularEnumSet.java
MIT
public boolean addAll(Collection<? extends E> c) { if (!(c instanceof RegularEnumSet<?> es)) return super.addAll(c); if (es.elementType != elementType) { if (es.isEmpty()) return false; else throw new ClassCastException( es.elementType + " != " + elementType); } long oldElements = elements; elements |= es.elements; return elements != oldElements; }
Adds all of the elements in the specified collection to this set. @param c collection whose elements are to be added to this set @return {@code true} if this set changed as a result of the call @throws NullPointerException if the specified collection or any of its elements are null
RegularEnumSet::addAll
java
Reginer/aosp-android-jar
android-34/src/java/util/RegularEnumSet.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/java/util/RegularEnumSet.java
MIT
public boolean removeAll(Collection<?> c) { if (!(c instanceof RegularEnumSet<?> es)) return super.removeAll(c); if (es.elementType != elementType) return false; long oldElements = elements; elements &= ~es.elements; return elements != oldElements; }
Removes from this set all of its elements that are contained in the specified collection. @param c elements to be removed from this set @return {@code true} if this set changed as a result of the call @throws NullPointerException if the specified collection is null
RegularEnumSet::removeAll
java
Reginer/aosp-android-jar
android-34/src/java/util/RegularEnumSet.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/java/util/RegularEnumSet.java
MIT
public boolean retainAll(Collection<?> c) { if (!(c instanceof RegularEnumSet<?> es)) return super.retainAll(c); if (es.elementType != elementType) { boolean changed = (elements != 0); elements = 0; return changed; } long oldElements = elements; elements &= es.elements; return elements != oldElements; }
Retains only the elements in this set that are contained in the specified collection. @param c elements to be retained in this set @return {@code true} if this set changed as a result of the call @throws NullPointerException if the specified collection is null
RegularEnumSet::retainAll
java
Reginer/aosp-android-jar
android-34/src/java/util/RegularEnumSet.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/java/util/RegularEnumSet.java
MIT
public void clear() { elements = 0; }
Removes all of the elements from this set.
RegularEnumSet::clear
java
Reginer/aosp-android-jar
android-34/src/java/util/RegularEnumSet.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/java/util/RegularEnumSet.java
MIT
public boolean equals(Object o) { if (!(o instanceof RegularEnumSet<?> es)) return super.equals(o); if (es.elementType != elementType) return elements == 0 && es.elements == 0; return es.elements == elements; }
Compares the specified object with this set for equality. Returns {@code true} if the given object is also a set, the two sets have the same size, and every member of the given set is contained in this set. @param o object to be compared for equality with this set @return {@code true} if the specified object is equal to this set
RegularEnumSet::equals
java
Reginer/aosp-android-jar
android-34/src/java/util/RegularEnumSet.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/java/util/RegularEnumSet.java
MIT
private ShortcutInfo forceDeleteShortcutInner(@NonNull String id) { final ShortcutInfo shortcut = findShortcutById(id); if (shortcut != null) { removeShortcut(id); mShortcutUser.mService.removeIconLocked(shortcut); shortcut.clearFlags(ShortcutInfo.FLAG_DYNAMIC | ShortcutInfo.FLAG_PINNED | ShortcutInfo.FLAG_MANIFEST | ShortcutInfo.FLAG_CACHED_ALL); } return shortcut; }
Delete a shortcut by ID. This will *always* remove it even if it's immutable or invisible.
ShortcutPackage::forceDeleteShortcutInner
java
Reginer/aosp-android-jar
android-32/src/com/android/server/pm/ShortcutPackage.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/server/pm/ShortcutPackage.java
MIT
private void forceReplaceShortcutInner(@NonNull ShortcutInfo newShortcut) { final ShortcutService s = mShortcutUser.mService; forceDeleteShortcutInner(newShortcut.getId()); // Extract Icon and update the icon res ID and the bitmap path. s.saveIconAndFixUpShortcutLocked(newShortcut); s.fixUpShortcutResourceNamesAndValues(newShortcut); saveShortcut(newShortcut); }
Force replace a shortcut. If there's already a shortcut with the same ID, it'll be removed, even if it's invisible.
ShortcutPackage::forceReplaceShortcutInner
java
Reginer/aosp-android-jar
android-32/src/com/android/server/pm/ShortcutPackage.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/server/pm/ShortcutPackage.java
MIT
public boolean addOrReplaceDynamicShortcut(@NonNull ShortcutInfo newShortcut) { Preconditions.checkArgument(newShortcut.isEnabled(), "add/setDynamicShortcuts() cannot publish disabled shortcuts"); newShortcut.addFlags(ShortcutInfo.FLAG_DYNAMIC); final ShortcutInfo oldShortcut = findShortcutById(newShortcut.getId()); if (oldShortcut != null) { // It's an update case. // Make sure the target is updatable. (i.e. should be mutable.) oldShortcut.ensureUpdatableWith(newShortcut, /*isUpdating=*/ false); // If it was originally pinned or cached, the new one should be pinned or cached too. newShortcut.addFlags(oldShortcut.getFlags() & (ShortcutInfo.FLAG_PINNED | ShortcutInfo.FLAG_CACHED_ALL)); } forceReplaceShortcutInner(newShortcut); return oldShortcut != null; }
Add a shortcut. If there's already a one with the same ID, it'll be removed, even if it's invisible. It checks the max number of dynamic shortcuts. @return True if it replaced an existing shortcut, False otherwise.
ShortcutPackage::addOrReplaceDynamicShortcut
java
Reginer/aosp-android-jar
android-32/src/com/android/server/pm/ShortcutPackage.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/server/pm/ShortcutPackage.java
MIT
public boolean pushDynamicShortcut(@NonNull ShortcutInfo newShortcut, @NonNull List<ShortcutInfo> changedShortcuts) { Preconditions.checkArgument(newShortcut.isEnabled(), "pushDynamicShortcuts() cannot publish disabled shortcuts"); newShortcut.addFlags(ShortcutInfo.FLAG_DYNAMIC); changedShortcuts.clear(); final ShortcutInfo oldShortcut = findShortcutById(newShortcut.getId()); boolean deleted = false; if (oldShortcut == null) { final ShortcutService service = mShortcutUser.mService; final int maxShortcuts = service.getMaxActivityShortcuts(); final ArrayMap<ComponentName, ArrayList<ShortcutInfo>> all = sortShortcutsToActivities(); final ArrayList<ShortcutInfo> activityShortcuts = all.get(newShortcut.getActivity()); if (activityShortcuts != null && activityShortcuts.size() == maxShortcuts) { // Max has reached. Delete the shortcut with lowest rank. // Sort by isManifestShortcut() and getRank(). Collections.sort(activityShortcuts, mShortcutTypeAndRankComparator); final ShortcutInfo shortcut = activityShortcuts.get(maxShortcuts - 1); if (shortcut.isManifestShortcut()) { // All shortcuts are manifest shortcuts and cannot be removed. Slog.e(TAG, "Failed to remove manifest shortcut while pushing dynamic shortcut " + newShortcut.getId()); return true; // poppedShortcuts is empty which indicates a failure. } changedShortcuts.add(shortcut); deleted = deleteDynamicWithId(shortcut.getId(), /*ignoreInvisible=*/ true) != null; } } else { // It's an update case. // Make sure the target is updatable. (i.e. should be mutable.) oldShortcut.ensureUpdatableWith(newShortcut, /*isUpdating=*/ false); // If it was originally pinned or cached, the new one should be pinned or cached too. newShortcut.addFlags(oldShortcut.getFlags() & (ShortcutInfo.FLAG_PINNED | ShortcutInfo.FLAG_CACHED_ALL)); } forceReplaceShortcutInner(newShortcut); if (isAppSearchEnabled()) { mShortcutUser.mService.injectPostToHandler(() -> awaitInAppSearch("reportUsage", session -> { final AndroidFuture<Boolean> future = new AndroidFuture<>(); session.reportUsage( new ReportUsageRequest.Builder( getPackageName(), newShortcut.getId()).build(), mShortcutUser.mExecutor, result -> future.complete(result.isSuccess())); return future; })); } return deleted; }
Push a shortcut. If the max number of dynamic shortcuts is already reached, remove the shortcut with the lowest rank before adding the new shortcut. Any shortcut that gets altered (removed or changed) as a result of this push operation will be included and returned in changedShortcuts. @return True if a shortcut had to be removed to complete this operation, False otherwise.
ShortcutPackage::pushDynamicShortcut
java
Reginer/aosp-android-jar
android-32/src/com/android/server/pm/ShortcutPackage.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/server/pm/ShortcutPackage.java
MIT
private List<ShortcutInfo> removeOrphans() { final List<ShortcutInfo> removeList = new ArrayList<>(1); final String query = String.format("%s OR %s OR %s OR %s", AppSearchShortcutInfo.QUERY_IS_PINNED, AppSearchShortcutInfo.QUERY_IS_DYNAMIC, AppSearchShortcutInfo.QUERY_IS_MANIFEST, AppSearchShortcutInfo.QUERY_IS_CACHED); forEachShortcut(query, si -> { if (si.isAlive()) return; removeList.add(si); }); if (!removeList.isEmpty()) { for (int i = removeList.size() - 1; i >= 0; i--) { forceDeleteShortcutInner(removeList.get(i).getId()); } } return removeList; }
Remove all shortcuts that aren't pinned, cached nor dynamic. @return List of removed shortcuts.
ShortcutPackage::removeOrphans
java
Reginer/aosp-android-jar
android-32/src/com/android/server/pm/ShortcutPackage.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/server/pm/ShortcutPackage.java
MIT
public List<ShortcutInfo> deleteAllDynamicShortcuts(boolean ignoreInvisible) { final long now = mShortcutUser.mService.injectCurrentTimeMillis(); final String query; if (!ignoreInvisible) { query = AppSearchShortcutInfo.QUERY_IS_DYNAMIC; } else { query = String.format("%s %s", AppSearchShortcutInfo.QUERY_IS_DYNAMIC, AppSearchShortcutInfo.QUERY_IS_VISIBLE_TO_PUBLISHER); } final boolean[] changed = new boolean[1]; forEachShortcutMutateIf(query, si -> { if (si.isDynamic() && (!ignoreInvisible || si.isVisibleToPublisher())) { changed[0] = true; si.setTimestamp(now); si.clearFlags(ShortcutInfo.FLAG_DYNAMIC); si.setRank(0); // It may still be pinned, so clear the rank. return true; } return false; }); if (changed[0]) { return removeOrphans(); } return null; }
Remove all dynamic shortcuts. @return List of shortcuts that actually got removed.
ShortcutPackage::deleteAllDynamicShortcuts
java
Reginer/aosp-android-jar
android-32/src/com/android/server/pm/ShortcutPackage.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/server/pm/ShortcutPackage.java
MIT
public ShortcutInfo deleteDynamicWithId(@NonNull String shortcutId, boolean ignoreInvisible) { return deleteOrDisableWithId( shortcutId, /* disable =*/ false, /* overrideImmutable=*/ false, ignoreInvisible, ShortcutInfo.DISABLED_REASON_NOT_DISABLED); }
Remove a dynamic shortcut by ID. It'll be removed from the dynamic set, but if the shortcut is pinned or cached, it'll remain as a pinned or cached shortcut, and is still enabled. @return The deleted shortcut, or null if it was not actually removed because it is either pinned or cached.
ShortcutPackage::deleteDynamicWithId
java
Reginer/aosp-android-jar
android-32/src/com/android/server/pm/ShortcutPackage.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/server/pm/ShortcutPackage.java
MIT
private ShortcutInfo disableDynamicWithId(@NonNull String shortcutId, boolean ignoreInvisible, int disabledReason) { return deleteOrDisableWithId(shortcutId, /* disable =*/ true, /* overrideImmutable=*/ false, ignoreInvisible, disabledReason); }
Disable a dynamic shortcut by ID. It'll be removed from the dynamic set, but if the shortcut is pinned, it'll remain as a pinned shortcut, but will be disabled. @return Shortcut if the disabled shortcut got removed because it wasn't pinned. Or null if it's still pinned.
ShortcutPackage::disableDynamicWithId
java
Reginer/aosp-android-jar
android-32/src/com/android/server/pm/ShortcutPackage.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/server/pm/ShortcutPackage.java
MIT
public ShortcutInfo deleteLongLivedWithId(@NonNull String shortcutId, boolean ignoreInvisible) { final ShortcutInfo shortcut = findShortcutById(shortcutId); if (shortcut != null) { mutateShortcut(shortcutId, null, si -> si.clearFlags(ShortcutInfo.FLAG_CACHED_ALL)); } return deleteOrDisableWithId( shortcutId, /* disable =*/ false, /* overrideImmutable=*/ false, ignoreInvisible, ShortcutInfo.DISABLED_REASON_NOT_DISABLED); }
Remove a long lived shortcut by ID. If the shortcut is pinned, it'll remain as a pinned shortcut, and is still enabled. @return The deleted shortcut, or null if it was not actually removed because it's pinned.
ShortcutPackage::deleteLongLivedWithId
java
Reginer/aosp-android-jar
android-32/src/com/android/server/pm/ShortcutPackage.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/server/pm/ShortcutPackage.java
MIT
public ShortcutInfo disableWithId(@NonNull String shortcutId, String disabledMessage, int disabledMessageResId, boolean overrideImmutable, boolean ignoreInvisible, int disabledReason) { final ShortcutInfo deleted = deleteOrDisableWithId(shortcutId, /* disable =*/ true, overrideImmutable, ignoreInvisible, disabledReason); // If disabled id still exists, it is pinned and we need to update the disabled message. mutateShortcut(shortcutId, null, disabled -> { if (disabled != null) { if (disabledMessage != null) { disabled.setDisabledMessage(disabledMessage); } else if (disabledMessageResId != 0) { disabled.setDisabledMessageResId(disabledMessageResId); mShortcutUser.mService.fixUpShortcutResourceNamesAndValues(disabled); } } }); return deleted; }
Disable a dynamic shortcut by ID. It'll be removed from the dynamic set, but if the shortcut is pinned, it'll remain as a pinned shortcut but will be disabled. @return Shortcut if the disabled shortcut got removed because it wasn't pinned. Or null if it's still pinned.
ShortcutPackage::disableWithId
java
Reginer/aosp-android-jar
android-32/src/com/android/server/pm/ShortcutPackage.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/server/pm/ShortcutPackage.java
MIT
public void refreshPinnedFlags() { final Set<String> pinnedShortcuts = new ArraySet<>(); // First, gather the pinned set from each launcher. mShortcutUser.forAllLaunchers(launcherShortcuts -> { final ArraySet<String> pinned = launcherShortcuts.getPinnedShortcutIds( getPackageName(), getPackageUserId()); if (pinned == null || pinned.size() == 0) { return; } pinnedShortcuts.addAll(pinned); }); // Then, update the pinned state if necessary. final List<ShortcutInfo> pinned = getShortcutById(pinnedShortcuts); if (pinned != null) { pinned.forEach(si -> { if (!si.isPinned()) { si.addFlags(ShortcutInfo.FLAG_PINNED); } }); saveShortcut(pinned); } forEachShortcutMutateIf(AppSearchShortcutInfo.QUERY_IS_PINNED, si -> { if (!pinnedShortcuts.contains(si.getId()) && si.isPinned()) { si.clearFlags(ShortcutInfo.FLAG_PINNED); return true; } return false; }); // Lastly, remove the ones that are no longer pinned, cached nor dynamic. removeOrphans(); }
Called after a launcher updates the pinned set. For each shortcut in this package, set FLAG_PINNED if any launcher has pinned it. Otherwise, clear it. <p>Then remove all shortcuts that are not dynamic and no longer pinned either.
ShortcutPackage::refreshPinnedFlags
java
Reginer/aosp-android-jar
android-32/src/com/android/server/pm/ShortcutPackage.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/server/pm/ShortcutPackage.java
MIT
public int getApiCallCount(boolean unlimited) { final ShortcutService s = mShortcutUser.mService; // Reset the counter if: // - the package is in foreground now. // - the package is *not* in foreground now, but was in foreground at some point // since the previous time it had been. if (s.isUidForegroundLocked(mPackageUid) || (mLastKnownForegroundElapsedTime < s.getUidLastForegroundElapsedTimeLocked(mPackageUid)) || unlimited) { mLastKnownForegroundElapsedTime = s.injectElapsedRealtime(); resetRateLimiting(); } // Note resetThrottlingIfNeeded() and resetRateLimiting() will set 0 to mApiCallCount, // but we just can't return 0 at this point, because we may have to update // mLastResetTime. final long last = s.getLastResetTimeLocked(); final long now = s.injectCurrentTimeMillis(); if (ShortcutService.isClockValid(now) && mLastResetTime > now) { Slog.w(TAG, "Clock rewound"); // Clock rewound. mLastResetTime = now; mApiCallCount = 0; return mApiCallCount; } // If not reset yet, then reset. if (mLastResetTime < last) { if (ShortcutService.DEBUG || ShortcutService.DEBUG_REBOOT) { Slog.d(TAG, String.format("%s: last reset=%d, now=%d, last=%d: resetting", getPackageName(), mLastResetTime, now, last)); } mApiCallCount = 0; mLastResetTime = last; } return mApiCallCount; }
Number of calls that the caller has made, since the last reset. <p>This takes care of the resetting the counter for foreground apps as well as after locale changes.
ShortcutPackage::getApiCallCount
java
Reginer/aosp-android-jar
android-32/src/com/android/server/pm/ShortcutPackage.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/server/pm/ShortcutPackage.java
MIT
public boolean tryApiCall(boolean unlimited) { final ShortcutService s = mShortcutUser.mService; if (getApiCallCount(unlimited) >= s.mMaxUpdatesPerInterval) { return false; } mApiCallCount++; s.scheduleSaveUser(getOwnerUserId()); return true; }
If the caller app hasn't been throttled yet, increment {@link #mApiCallCount} and return true. Otherwise just return false. <p>This takes care of the resetting the counter for foreground apps as well as after locale changes, which is done internally by {@link #getApiCallCount}.
ShortcutPackage::tryApiCall
java
Reginer/aosp-android-jar
android-32/src/com/android/server/pm/ShortcutPackage.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/server/pm/ShortcutPackage.java
MIT
public void findAll(@NonNull List<ShortcutInfo> result, @Nullable String query, @Nullable Predicate<ShortcutInfo> filter, int cloneFlag) { findAll(result, query, filter, cloneFlag, null, 0, /*getPinnedByAnyLauncher=*/ false); }
Find all shortcuts that match {@code query}.
ShortcutPackage::findAll
java
Reginer/aosp-android-jar
android-32/src/com/android/server/pm/ShortcutPackage.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/server/pm/ShortcutPackage.java
MIT
public void findAll(@NonNull List<ShortcutInfo> result, @Nullable String query, @Nullable Predicate<ShortcutInfo> filter, int cloneFlag, @Nullable String callingLauncher, int launcherUserId, boolean getPinnedByAnyLauncher) { if (getPackageInfo().isShadow()) { // Restored and the app not installed yet, so don't return any. return; } final ShortcutService s = mShortcutUser.mService; // Set of pinned shortcuts by the calling launcher. final ArraySet<String> pinnedByCallerSet = (callingLauncher == null) ? null : s.getLauncherShortcutsLocked(callingLauncher, getPackageUserId(), launcherUserId) .getPinnedShortcutIds(getPackageName(), getPackageUserId()); forEachShortcut(query == null ? "" : query, si -> filter(result, filter, cloneFlag, callingLauncher, pinnedByCallerSet, getPinnedByAnyLauncher, si)); }
Find all shortcuts that match {@code query}. This will also provide a "view" for each launcher -- a non-dynamic shortcut that's not pinned by the calling launcher will not be included in the result, and also "isPinned" will be adjusted for the caller too.
ShortcutPackage::findAll
java
Reginer/aosp-android-jar
android-32/src/com/android/server/pm/ShortcutPackage.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/server/pm/ShortcutPackage.java
MIT
public void findAllByIds(@NonNull final List<ShortcutInfo> result, @NonNull final Collection<String> ids, @Nullable final Predicate<ShortcutInfo> filter, final int cloneFlag) { findAllByIds(result, ids, filter, cloneFlag, null, 0, /*getPinnedByAnyLauncher=*/ false); }
Find all shortcuts that has id matching {@code ids}.
ShortcutPackage::findAllByIds
java
Reginer/aosp-android-jar
android-32/src/com/android/server/pm/ShortcutPackage.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/server/pm/ShortcutPackage.java
MIT
public void findAllByIds(@NonNull List<ShortcutInfo> result, @NonNull final Collection<String> ids, @Nullable final Predicate<ShortcutInfo> query, int cloneFlag, @Nullable String callingLauncher, int launcherUserId, boolean getPinnedByAnyLauncher) { if (getPackageInfo().isShadow()) { // Restored and the app not installed yet, so don't return any. return; } final ShortcutService s = mShortcutUser.mService; // Set of pinned shortcuts by the calling launcher. final ArraySet<String> pinnedByCallerSet = (callingLauncher == null) ? null : s.getLauncherShortcutsLocked(callingLauncher, getPackageUserId(), launcherUserId) .getPinnedShortcutIds(getPackageName(), getPackageUserId()); final List<ShortcutInfo> shortcuts = getShortcutById(ids); if (shortcuts != null) { for (ShortcutInfo si : shortcuts) { filter(result, query, cloneFlag, callingLauncher, pinnedByCallerSet, getPinnedByAnyLauncher, si); } } }
Find all shortcuts that has id matching {@code ids}. This will also provide a "view" for each launcher -- a non-dynamic shortcut that's not pinned by the calling launcher will not be included in the result, and also "isPinned" will be adjusted for the caller too.
ShortcutPackage::findAllByIds
java
Reginer/aosp-android-jar
android-32/src/com/android/server/pm/ShortcutPackage.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/server/pm/ShortcutPackage.java
MIT
public void findAllPinned(@NonNull List<ShortcutInfo> result, @Nullable Predicate<ShortcutInfo> query, int cloneFlag, @Nullable String callingLauncher, int launcherUserId, boolean getPinnedByAnyLauncher) { if (getPackageInfo().isShadow()) { // Restored and the app not installed yet, so don't return any. return; } final ShortcutService s = mShortcutUser.mService; // Set of pinned shortcuts by the calling launcher. final ArraySet<String> pinnedByCallerSet = (callingLauncher == null) ? null : s.getLauncherShortcutsLocked(callingLauncher, getPackageUserId(), launcherUserId) .getPinnedShortcutIds(getPackageName(), getPackageUserId()); mShortcuts.values().forEach(si -> filter(result, query, cloneFlag, callingLauncher, pinnedByCallerSet, getPinnedByAnyLauncher, si)); }
Find all pinned shortcuts that match {@code query}.
ShortcutPackage::findAllPinned
java
Reginer/aosp-android-jar
android-32/src/com/android/server/pm/ShortcutPackage.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/server/pm/ShortcutPackage.java
MIT
public List<ShortcutManager.ShareShortcutInfo> getMatchingShareTargets( @NonNull IntentFilter filter) { final List<ShareTargetInfo> matchedTargets = new ArrayList<>(); for (int i = 0; i < mShareTargets.size(); i++) { final ShareTargetInfo target = mShareTargets.get(i); for (ShareTargetInfo.TargetData data : target.mTargetData) { if (filter.hasDataType(data.mMimeType)) { // Matched at least with one data type matchedTargets.add(target); break; } } } if (matchedTargets.isEmpty()) { return new ArrayList<>(); } // Get the list of all dynamic shortcuts in this package. final ArrayList<ShortcutInfo> shortcuts = new ArrayList<>(); findAll(shortcuts, AppSearchShortcutInfo.QUERY_IS_NON_MANIFEST_VISIBLE, ShortcutInfo::isNonManifestVisible, ShortcutInfo.CLONE_REMOVE_FOR_APP_PREDICTION); final List<ShortcutManager.ShareShortcutInfo> result = new ArrayList<>(); for (int i = 0; i < shortcuts.size(); i++) { final Set<String> categories = shortcuts.get(i).getCategories(); if (categories == null || categories.isEmpty()) { continue; } for (int j = 0; j < matchedTargets.size(); j++) { // Shortcut must have all of share target categories boolean hasAllCategories = true; final ShareTargetInfo target = matchedTargets.get(j); for (int q = 0; q < target.mCategories.length; q++) { if (!categories.contains(target.mCategories[q])) { hasAllCategories = false; break; } } if (hasAllCategories) { result.add(new ShortcutManager.ShareShortcutInfo(shortcuts.get(i), new ComponentName(getPackageName(), target.mTargetClass))); break; } } } return result; }
Returns a list of ShortcutInfos that match the given intent filter and the category of available ShareTarget definitions in this package.
ShortcutPackage::getMatchingShareTargets
java
Reginer/aosp-android-jar
android-32/src/com/android/server/pm/ShortcutPackage.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/server/pm/ShortcutPackage.java
MIT
int getSharingShortcutCount() { if (mShareTargets.isEmpty()) { return 0; } // Get the list of all dynamic shortcuts in this package final ArrayList<ShortcutInfo> shortcuts = new ArrayList<>(); findAll(shortcuts, AppSearchShortcutInfo.QUERY_IS_NON_MANIFEST_VISIBLE, ShortcutInfo::isNonManifestVisible, ShortcutInfo.CLONE_REMOVE_FOR_LAUNCHER); int sharingShortcutCount = 0; for (int i = 0; i < shortcuts.size(); i++) { final Set<String> categories = shortcuts.get(i).getCategories(); if (categories == null || categories.isEmpty()) { continue; } for (int j = 0; j < mShareTargets.size(); j++) { // A SharingShortcut must have all of share target categories boolean hasAllCategories = true; final ShareTargetInfo target = mShareTargets.get(j); for (int q = 0; q < target.mCategories.length; q++) { if (!categories.contains(target.mCategories[q])) { hasAllCategories = false; break; } } if (hasAllCategories) { sharingShortcutCount++; break; } } } return sharingShortcutCount; }
Returns the number of shortcuts that can be used as a share target in the ShareSheet. Such shortcuts must have a matching category with at least one of the defined ShareTargets from the app's Xml resource.
ShortcutPackage::getSharingShortcutCount
java
Reginer/aosp-android-jar
android-32/src/com/android/server/pm/ShortcutPackage.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/server/pm/ShortcutPackage.java
MIT
public ArraySet<String> getUsedBitmapFiles() { final ArraySet<String> usedFiles = new ArraySet<>(1); forEachShortcut(AppSearchShortcutInfo.QUERY_HAS_BITMAP_PATH, si -> { if (si.getBitmapPath() != null) { usedFiles.add(getFileName(si.getBitmapPath())); } }); return usedFiles; }
Return the filenames (excluding path names) of icon bitmap files from this package.
ShortcutPackage::getUsedBitmapFiles
java
Reginer/aosp-android-jar
android-32/src/com/android/server/pm/ShortcutPackage.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/server/pm/ShortcutPackage.java
MIT
private boolean areAllActivitiesStillEnabled() { final ShortcutService s = mShortcutUser.mService; // Normally the number of target activities is 1 or so, so no need to use a complex // structure like a set. final ArrayList<ComponentName> checked = new ArrayList<>(4); final boolean[] reject = new boolean[1]; forEachShortcutStopWhen(si -> { final ComponentName activity = si.getActivity(); if (checked.contains(activity)) { return false; // Already checked. } checked.add(activity); if ((activity != null) && !s.injectIsActivityEnabledAndExported(activity, getOwnerUserId())) { reject[0] = true; return true; // Found at least 1 activity is disabled, so skip the rest. } return false; }); return !reject[0]; }
@return false if any of the target activities are no longer enabled.
ShortcutPackage::areAllActivitiesStillEnabled
java
Reginer/aosp-android-jar
android-32/src/com/android/server/pm/ShortcutPackage.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/server/pm/ShortcutPackage.java
MIT
public boolean rescanPackageIfNeeded(boolean isNewApp, boolean forceRescan) { final ShortcutService s = mShortcutUser.mService; final long start = s.getStatStartTime(); final PackageInfo pi; try { pi = mShortcutUser.mService.getPackageInfo( getPackageName(), getPackageUserId()); if (pi == null) { return false; // Shouldn't happen. } if (!isNewApp && !forceRescan) { // Return if the package hasn't changed, ie: // - version code hasn't change // - lastUpdateTime hasn't change // - all target activities are still enabled. // Note, system apps timestamps do *not* change after OTAs. (But they do // after an adb sync or a local flash.) // This means if a system app's version code doesn't change on an OTA, // we don't notice it's updated. But that's fine since their version code *should* // really change on OTAs. if ((getPackageInfo().getVersionCode() == pi.getLongVersionCode()) && (getPackageInfo().getLastUpdateTime() == pi.lastUpdateTime) && areAllActivitiesStillEnabled()) { return false; } } } finally { s.logDurationStat(Stats.PACKAGE_UPDATE_CHECK, start); } // Now prepare to publish manifest shortcuts. List<ShortcutInfo> newManifestShortcutList = null; try { newManifestShortcutList = ShortcutParser.parseShortcuts(mShortcutUser.mService, getPackageName(), getPackageUserId(), mShareTargets); } catch (IOException|XmlPullParserException e) { Slog.e(TAG, "Failed to load shortcuts from AndroidManifest.xml.", e); } final int manifestShortcutSize = newManifestShortcutList == null ? 0 : newManifestShortcutList.size(); if (ShortcutService.DEBUG || ShortcutService.DEBUG_REBOOT) { Slog.d(TAG, String.format("Package %s has %d manifest shortcut(s), and %d share target(s)", getPackageName(), manifestShortcutSize, mShareTargets.size())); } if (isNewApp && (manifestShortcutSize == 0)) { // If it's a new app, and it doesn't have manifest shortcuts, then nothing to do. // If it's an update, then it may already have manifest shortcuts, which need to be // disabled. return false; } if (ShortcutService.DEBUG || ShortcutService.DEBUG_REBOOT) { Slog.d(TAG, String.format("Package %s %s, version %d -> %d", getPackageName(), (isNewApp ? "added" : "updated"), getPackageInfo().getVersionCode(), pi.getLongVersionCode())); } getPackageInfo().updateFromPackageInfo(pi); if (isAppSearchEnabled()) { // Save the states in memory and resume package rescan when needed mRescanRequired = true; mIsNewApp = isNewApp; mManifestShortcuts = newManifestShortcutList; } else { rescanPackage(isNewApp, newManifestShortcutList); } return true; // true means changed. }
Called when the package may be added or updated, or its activities may be disabled, and if so, rescan the package and do the necessary stuff. Add case: - Publish manifest shortcuts. Update case: - Re-publish manifest shortcuts. - If there are shortcuts with resources (icons or strings), update their timestamps. - Disable shortcuts whose target activities are disabled. @return TRUE if any shortcuts have been changed.
ShortcutPackage::rescanPackageIfNeeded
java
Reginer/aosp-android-jar
android-32/src/com/android/server/pm/ShortcutPackage.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/server/pm/ShortcutPackage.java
MIT
private boolean pushOutExcessShortcuts() { final ShortcutService service = mShortcutUser.mService; final int maxShortcuts = service.getMaxActivityShortcuts(); boolean changed = false; final ArrayMap<ComponentName, ArrayList<ShortcutInfo>> all = sortShortcutsToActivities(); for (int outer = all.size() - 1; outer >= 0; outer--) { final ArrayList<ShortcutInfo> list = all.valueAt(outer); if (list.size() <= maxShortcuts) { continue; } // Sort by isManifestShortcut() and getRank(). Collections.sort(list, mShortcutTypeAndRankComparator); // Keep [0 .. max), and remove (as dynamic) [max .. size) for (int inner = list.size() - 1; inner >= maxShortcuts; inner--) { final ShortcutInfo shortcut = list.get(inner); if (shortcut.isManifestShortcut()) { // This shouldn't happen -- excess shortcuts should all be non-manifest. // But just in case. service.wtf("Found manifest shortcuts in excess list."); continue; } deleteDynamicWithId(shortcut.getId(), /*ignoreInvisible=*/ true); } } return changed; }
For each target activity, make sure # of dynamic + manifest shortcuts <= max. If too many, we'll remove the dynamic with the lowest ranks.
ShortcutPackage::pushOutExcessShortcuts
java
Reginer/aosp-android-jar
android-32/src/com/android/server/pm/ShortcutPackage.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/server/pm/ShortcutPackage.java
MIT
private ArrayMap<ComponentName, ArrayList<ShortcutInfo>> sortShortcutsToActivities() { final ArrayMap<ComponentName, ArrayList<ShortcutInfo>> activitiesToShortcuts = new ArrayMap<>(); forEachShortcut(AppSearchShortcutInfo.QUERY_IS_NOT_FLOATING, si -> { if (si.isFloating()) { return; // Ignore floating shortcuts, which are not tied to any activities. } final ComponentName activity = si.getActivity(); if (activity == null) { mShortcutUser.mService.wtf("null activity detected."); return; } ArrayList<ShortcutInfo> list = activitiesToShortcuts.computeIfAbsent(activity, k -> new ArrayList<>()); list.add(si); }); return activitiesToShortcuts; }
Build a list of shortcuts for each target activity and return as a map. The result won't contain "floating" shortcuts because they don't belong on any activities.
ShortcutPackage::sortShortcutsToActivities
java
Reginer/aosp-android-jar
android-32/src/com/android/server/pm/ShortcutPackage.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/server/pm/ShortcutPackage.java
MIT
private void incrementCountForActivity(ArrayMap<ComponentName, Integer> counts, ComponentName cn, int increment) { Integer oldValue = counts.get(cn); if (oldValue == null) { oldValue = 0; } counts.put(cn, oldValue + increment); }
Build a list of shortcuts for each target activity and return as a map. The result won't contain "floating" shortcuts because they don't belong on any activities. private ArrayMap<ComponentName, ArrayList<ShortcutInfo>> sortShortcutsToActivities() { final ArrayMap<ComponentName, ArrayList<ShortcutInfo>> activitiesToShortcuts = new ArrayMap<>(); forEachShortcut(AppSearchShortcutInfo.QUERY_IS_NOT_FLOATING, si -> { if (si.isFloating()) { return; // Ignore floating shortcuts, which are not tied to any activities. } final ComponentName activity = si.getActivity(); if (activity == null) { mShortcutUser.mService.wtf("null activity detected."); return; } ArrayList<ShortcutInfo> list = activitiesToShortcuts.computeIfAbsent(activity, k -> new ArrayList<>()); list.add(si); }); return activitiesToShortcuts; } /** Used by {@link #enforceShortcutCountsBeforeOperation}
ShortcutPackage::incrementCountForActivity
java
Reginer/aosp-android-jar
android-32/src/com/android/server/pm/ShortcutPackage.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/server/pm/ShortcutPackage.java
MIT
public void enforceShortcutCountsBeforeOperation(List<ShortcutInfo> newList, @ShortcutOperation int operation) { final ShortcutService service = mShortcutUser.mService; // Current # of dynamic / manifest shortcuts for each activity. // (If it's for update, then don't count dynamic shortcuts, since they'll be replaced // anyway.) final ArrayMap<ComponentName, Integer> counts = new ArrayMap<>(4); final String query; if (operation != ShortcutService.OPERATION_SET) { query = AppSearchShortcutInfo.QUERY_IS_MANIFEST + " OR " + AppSearchShortcutInfo.QUERY_IS_DYNAMIC; } else { query = AppSearchShortcutInfo.QUERY_IS_MANIFEST; } forEachShortcut(query, shortcut -> { if (shortcut.isManifestShortcut()) { incrementCountForActivity(counts, shortcut.getActivity(), 1); } else if (shortcut.isDynamic() && (operation != ShortcutService.OPERATION_SET)) { incrementCountForActivity(counts, shortcut.getActivity(), 1); } }); for (int i = newList.size() - 1; i >= 0; i--) { final ShortcutInfo newShortcut = newList.get(i); final ComponentName newActivity = newShortcut.getActivity(); if (newActivity == null) { if (operation != ShortcutService.OPERATION_UPDATE) { service.wtf("Activity must not be null at this point"); continue; // Just ignore this invalid case. } continue; // Activity can be null for update. } final ShortcutInfo original = findShortcutById(newShortcut.getId()); if (original == null) { if (operation == ShortcutService.OPERATION_UPDATE) { continue; // When updating, ignore if there's no target. } // Add() or set(), and there's no existing shortcut with the same ID. We're // simply publishing (as opposed to updating) this shortcut, so just +1. incrementCountForActivity(counts, newActivity, 1); continue; } if (original.isFloating() && (operation == ShortcutService.OPERATION_UPDATE)) { // Updating floating shortcuts doesn't affect the count, so ignore. continue; } // If it's add() or update(), then need to decrement for the previous activity. // Skip it for set() since it's already been taken care of by not counting the original // dynamic shortcuts in the first loop. if (operation != ShortcutService.OPERATION_SET) { final ComponentName oldActivity = original.getActivity(); if (!original.isFloating()) { incrementCountForActivity(counts, oldActivity, -1); } } incrementCountForActivity(counts, newActivity, 1); } // Then make sure none of the activities have more than the max number of shortcuts. for (int i = counts.size() - 1; i >= 0; i--) { service.enforceMaxActivityShortcuts(counts.valueAt(i)); } }
Called by {@link android.content.pm.ShortcutManager#setDynamicShortcuts}, {@link android.content.pm.ShortcutManager#addDynamicShortcuts}, and {@link android.content.pm.ShortcutManager#updateShortcuts} before actually performing the operation to make sure the operation wouldn't result in the target activities having more than the allowed number of dynamic/manifest shortcuts. @param newList shortcut list passed to set, add or updateShortcuts(). @param operation add, set or update. @throws IllegalArgumentException if the operation would result in going over the max shortcut count for any activity.
ShortcutPackage::enforceShortcutCountsBeforeOperation
java
Reginer/aosp-android-jar
android-32/src/com/android/server/pm/ShortcutPackage.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/server/pm/ShortcutPackage.java
MIT
public void resolveResourceStrings() { final ShortcutService s = mShortcutUser.mService; final Resources publisherRes = getPackageResources(); final List<ShortcutInfo> changedShortcuts = new ArrayList<>(1); if (publisherRes != null) { forEachShortcutMutateIf(AppSearchShortcutInfo.QUERY_HAS_STRING_RESOURCE, si -> { if (!si.hasStringResources()) return false; si.resolveResourceStrings(publisherRes); si.setTimestamp(s.injectCurrentTimeMillis()); changedShortcuts.add(si); return true; }); } if (!CollectionUtils.isEmpty(changedShortcuts)) { s.packageShortcutsChanged(getPackageName(), getPackageUserId(), changedShortcuts, null); } }
For all the text fields, refresh the string values if they're from resources.
ShortcutPackage::resolveResourceStrings
java
Reginer/aosp-android-jar
android-32/src/com/android/server/pm/ShortcutPackage.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/server/pm/ShortcutPackage.java
MIT
public void clearAllImplicitRanks() { forEachShortcutMutate(ShortcutInfo::clearImplicitRankAndRankChangedFlag); }
For all the text fields, refresh the string values if they're from resources. public void resolveResourceStrings() { final ShortcutService s = mShortcutUser.mService; final Resources publisherRes = getPackageResources(); final List<ShortcutInfo> changedShortcuts = new ArrayList<>(1); if (publisherRes != null) { forEachShortcutMutateIf(AppSearchShortcutInfo.QUERY_HAS_STRING_RESOURCE, si -> { if (!si.hasStringResources()) return false; si.resolveResourceStrings(publisherRes); si.setTimestamp(s.injectCurrentTimeMillis()); changedShortcuts.add(si); return true; }); } if (!CollectionUtils.isEmpty(changedShortcuts)) { s.packageShortcutsChanged(getPackageName(), getPackageUserId(), changedShortcuts, null); } } /** Clears the implicit ranks for all shortcuts.
ShortcutPackage::clearAllImplicitRanks
java
Reginer/aosp-android-jar
android-32/src/com/android/server/pm/ShortcutPackage.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/server/pm/ShortcutPackage.java
MIT
public void adjustRanks() { final ShortcutService s = mShortcutUser.mService; final long now = s.injectCurrentTimeMillis(); // First, clear ranks for floating shortcuts. forEachShortcutMutateIf(AppSearchShortcutInfo.QUERY_IS_FLOATING_AND_HAS_RANK, si -> { if (si.isFloating() && si.getRank() != 0) { si.setTimestamp(now); si.setRank(0); return true; } return false; }); // Then adjust ranks. Ranks are unique for each activity, so we first need to sort // shortcuts to each activity. // Then sort the shortcuts within each activity with mShortcutRankComparator, and // assign ranks from 0. final ArrayMap<ComponentName, ArrayList<ShortcutInfo>> all = sortShortcutsToActivities(); for (int outer = all.size() - 1; outer >= 0; outer--) { // For each activity. final ArrayList<ShortcutInfo> list = all.valueAt(outer); // Sort by ranks and other signals. Collections.sort(list, mShortcutRankComparator); int rank = 0; final int size = list.size(); for (int i = 0; i < size; i++) { final ShortcutInfo si = list.get(i); if (si.isManifestShortcut()) { // Don't adjust ranks for manifest shortcuts. continue; } // At this point, it must be dynamic. if (!si.isDynamic()) { s.wtf("Non-dynamic shortcut found."); continue; } final int thisRank = rank++; if (si.getRank() != thisRank) { mutateShortcut(si.getId(), si, shortcut -> { shortcut.setTimestamp(now); shortcut.setRank(thisRank); }); } } } }
Re-calculate the ranks for all shortcuts.
ShortcutPackage::adjustRanks
java
Reginer/aosp-android-jar
android-32/src/com/android/server/pm/ShortcutPackage.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/server/pm/ShortcutPackage.java
MIT
public boolean hasNonManifestShortcuts() { final boolean[] condition = new boolean[1]; forEachShortcutStopWhen(AppSearchShortcutInfo.QUERY_IS_NOT_MANIFEST, si -> { if (!si.isDeclaredInManifest()) { condition[0] = true; return true; } return false; }); return condition[0]; }
Re-calculate the ranks for all shortcuts. public void adjustRanks() { final ShortcutService s = mShortcutUser.mService; final long now = s.injectCurrentTimeMillis(); // First, clear ranks for floating shortcuts. forEachShortcutMutateIf(AppSearchShortcutInfo.QUERY_IS_FLOATING_AND_HAS_RANK, si -> { if (si.isFloating() && si.getRank() != 0) { si.setTimestamp(now); si.setRank(0); return true; } return false; }); // Then adjust ranks. Ranks are unique for each activity, so we first need to sort // shortcuts to each activity. // Then sort the shortcuts within each activity with mShortcutRankComparator, and // assign ranks from 0. final ArrayMap<ComponentName, ArrayList<ShortcutInfo>> all = sortShortcutsToActivities(); for (int outer = all.size() - 1; outer >= 0; outer--) { // For each activity. final ArrayList<ShortcutInfo> list = all.valueAt(outer); // Sort by ranks and other signals. Collections.sort(list, mShortcutRankComparator); int rank = 0; final int size = list.size(); for (int i = 0; i < size; i++) { final ShortcutInfo si = list.get(i); if (si.isManifestShortcut()) { // Don't adjust ranks for manifest shortcuts. continue; } // At this point, it must be dynamic. if (!si.isDynamic()) { s.wtf("Non-dynamic shortcut found."); continue; } final int thisRank = rank++; if (si.getRank() != thisRank) { mutateShortcut(si.getId(), si, shortcut -> { shortcut.setTimestamp(now); shortcut.setRank(thisRank); }); } } } } /** @return true if there's any shortcuts that are not manifest shortcuts.
ShortcutPackage::hasNonManifestShortcuts
java
Reginer/aosp-android-jar
android-32/src/com/android/server/pm/ShortcutPackage.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/server/pm/ShortcutPackage.java
MIT
void removeShortcuts() { if (!isAppSearchEnabled()) { return; } awaitInAppSearch("Removing all shortcuts from " + getPackageName(), session -> { final AndroidFuture<Boolean> future = new AndroidFuture<>(); session.remove("", getSearchSpec(), mShortcutUser.mExecutor, result -> { if (!result.isSuccess()) { future.completeExceptionally( new RuntimeException(result.getErrorMessage())); return; } future.complete(true); }); return future; }); }
Removes shortcuts from AppSearch.
ShortcutPackage::removeShortcuts
java
Reginer/aosp-android-jar
android-32/src/com/android/server/pm/ShortcutPackage.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/server/pm/ShortcutPackage.java
MIT
void restoreParsedShortcuts() { restoreParsedShortcuts(true); }
Replace shortcuts parsed from xml file.
ShortcutPackage::restoreParsedShortcuts
java
Reginer/aosp-android-jar
android-32/src/com/android/server/pm/ShortcutPackage.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/server/pm/ShortcutPackage.java
MIT
public ContentCaptureCondition(@NonNull LocusId locusId, @Flags int flags) { this.mLocusId = Objects.requireNonNull(locusId); this.mFlags = flags; }
Default constructor. @param locusId id of the condition, as defined by {@link ContentCaptureContext#getLocusId()}. @param flags either {@link ContentCaptureCondition#FLAG_IS_REGEX} (to use a regular expression match) or {@code 0} (in which case the {@code LocusId} must be an exact match of the {@code LocusId} used in the {@link ContentCaptureContext}).
ContentCaptureCondition::ContentCaptureCondition
java
Reginer/aosp-android-jar
android-35/src/android/view/contentcapture/ContentCaptureCondition.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/view/contentcapture/ContentCaptureCondition.java
MIT
public @Flags int getFlags() { return mFlags; }
Gets the flags associates with this condition. @return either {@link ContentCaptureCondition#FLAG_IS_REGEX} or {@code 0}.
ContentCaptureCondition::getFlags
java
Reginer/aosp-android-jar
android-35/src/android/view/contentcapture/ContentCaptureCondition.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/view/contentcapture/ContentCaptureCondition.java
MIT
public Ser() { }
Constructor for deserialization.
Ser::Ser
java
Reginer/aosp-android-jar
android-34/src/java/time/Ser.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/java/time/Ser.java
MIT
Ser(byte type, Serializable object) { this.type = type; this.object = object; }
Creates an instance for serialization. @param type the type @param object the object
Ser::Ser
java
Reginer/aosp-android-jar
android-34/src/java/time/Ser.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/java/time/Ser.java
MIT
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { type = in.readByte(); object = readInternal(type, in); }
Implements the {@code Externalizable} interface to read the object. @serialData The streamed type and parameters defined by the type's {@code writeReplace} method are read and passed to the corresponding static factory for the type to create a new instance. That instance is returned as the de-serialized {@code Ser} object. <ul> <li><a href="{@docRoot}/serialized-form.html#java.time.Duration">Duration</a> - {@code Duration.ofSeconds(seconds, nanos);} <li><a href="{@docRoot}/serialized-form.html#java.time.Instant">Instant</a> - {@code Instant.ofEpochSecond(seconds, nanos);} <li><a href="{@docRoot}/serialized-form.html#java.time.LocalDate">LocalDate</a> - {@code LocalDate.of(year, month, day);} <li><a href="{@docRoot}/serialized-form.html#java.time.LocalDateTime">LocalDateTime</a> - {@code LocalDateTime.of(date, time);} <li><a href="{@docRoot}/serialized-form.html#java.time.LocalTime">LocalTime</a> - {@code LocalTime.of(hour, minute, second, nano);} <li><a href="{@docRoot}/serialized-form.html#java.time.MonthDay">MonthDay</a> - {@code MonthDay.of(month, day);} <li><a href="{@docRoot}/serialized-form.html#java.time.OffsetTime">OffsetTime</a> - {@code OffsetTime.of(time, offset);} <li><a href="{@docRoot}/serialized-form.html#java.time.OffsetDateTime">OffsetDateTime</a> - {@code OffsetDateTime.of(dateTime, offset);} <li><a href="{@docRoot}/serialized-form.html#java.time.Period">Period</a> - {@code Period.of(years, months, days);} <li><a href="{@docRoot}/serialized-form.html#java.time.Year">Year</a> - {@code Year.of(year);} <li><a href="{@docRoot}/serialized-form.html#java.time.YearMonth">YearMonth</a> - {@code YearMonth.of(year, month);} <li><a href="{@docRoot}/serialized-form.html#java.time.ZonedDateTime">ZonedDateTime</a> - {@code ZonedDateTime.ofLenient(dateTime, offset, zone);} <li><a href="{@docRoot}/serialized-form.html#java.time.ZoneId">ZoneId</a> - {@code ZoneId.of(id);} <li><a href="{@docRoot}/serialized-form.html#java.time.ZoneOffset">ZoneOffset</a> - {@code (offsetByte == 127 ? ZoneOffset.ofTotalSeconds(in.readInt()) : ZoneOffset.ofTotalSeconds(offsetByte * 900));} </ul> @param in the data to read, not null
Ser::readExternal
java
Reginer/aosp-android-jar
android-34/src/java/time/Ser.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/java/time/Ser.java
MIT
public boolean wouldLaunchResolverActivity(Intent intent, int currentUserId) { ActivityInfo targetActivityInfo = getTargetActivityInfo(intent, currentUserId, false /* onlyDirectBootAware */); return targetActivityInfo == null; }
Determines if sending the given intent would result in starting an Intent resolver activity, instead of resolving to a specific component. @param intent the intent @param currentUserId the id for the user to resolve as @return true if the intent would launch a resolver activity
ActivityIntentHelper::wouldLaunchResolverActivity
java
Reginer/aosp-android-jar
android-34/src/com/android/systemui/ActivityIntentHelper.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/systemui/ActivityIntentHelper.java
MIT
public boolean wouldPendingLaunchResolverActivity(PendingIntent intent, int currentUserId) { ActivityInfo targetActivityInfo = getPendingTargetActivityInfo(intent, currentUserId, false /* onlyDirectBootAware */); return targetActivityInfo == null; }
@see #wouldLaunchResolverActivity(Intent, int)
ActivityIntentHelper::wouldPendingLaunchResolverActivity
java
Reginer/aosp-android-jar
android-34/src/com/android/systemui/ActivityIntentHelper.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/systemui/ActivityIntentHelper.java
MIT
public ActivityInfo getTargetActivityInfo(Intent intent, int currentUserId, boolean onlyDirectBootAware) { int flags = PackageManager.MATCH_DEFAULT_ONLY | PackageManager.GET_META_DATA; if (!onlyDirectBootAware) { flags |= PackageManager.MATCH_DIRECT_BOOT_AWARE | PackageManager.MATCH_DIRECT_BOOT_UNAWARE; } final List<ResolveInfo> appList = mPm.queryIntentActivitiesAsUser( intent, flags, currentUserId); if (appList.size() == 0) { return null; } if (appList.size() == 1) { return appList.get(0).activityInfo; } ResolveInfo resolved = mPm.resolveActivityAsUser(intent, flags, currentUserId); if (resolved == null || wouldLaunchResolverActivity(resolved, appList)) { return null; } else { return resolved.activityInfo; } }
Returns info about the target Activity of a given intent, or null if the intent does not resolve to a specific component meeting the requirements. @param onlyDirectBootAware a boolean indicating whether the matched activity packages must be direct boot aware when in direct boot mode if false, all packages are considered a match even if they are not aware. @return the target activity info of the intent it resolves to a specific package or {@code null} if it resolved to the resolver activity
ActivityIntentHelper::getTargetActivityInfo
java
Reginer/aosp-android-jar
android-34/src/com/android/systemui/ActivityIntentHelper.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/systemui/ActivityIntentHelper.java
MIT
public ActivityInfo getPendingTargetActivityInfo(PendingIntent intent, int currentUserId, boolean onlyDirectBootAware) { int flags = PackageManager.MATCH_DEFAULT_ONLY | PackageManager.GET_META_DATA; if (!onlyDirectBootAware) { flags |= PackageManager.MATCH_DIRECT_BOOT_AWARE | PackageManager.MATCH_DIRECT_BOOT_UNAWARE; } final List<ResolveInfo> appList = intent.queryIntentComponents(flags); if (appList.size() == 0) { return null; } if (appList.size() == 1) { return appList.get(0).activityInfo; } ResolveInfo resolved = mPm.resolveActivityAsUser(intent.getIntent(), flags, currentUserId); if (resolved == null || wouldLaunchResolverActivity(resolved, appList)) { return null; } else { return resolved.activityInfo; } }
@see #getTargetActivityInfo(Intent, int, boolean)
ActivityIntentHelper::getPendingTargetActivityInfo
java
Reginer/aosp-android-jar
android-34/src/com/android/systemui/ActivityIntentHelper.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/systemui/ActivityIntentHelper.java
MIT
public boolean wouldShowOverLockscreen(Intent intent, int currentUserId) { ActivityInfo targetActivityInfo = getTargetActivityInfo(intent, currentUserId, false /* onlyDirectBootAware */); return targetActivityInfo != null && (targetActivityInfo.flags & (ActivityInfo.FLAG_SHOW_WHEN_LOCKED | ActivityInfo.FLAG_SHOW_FOR_ALL_USERS)) > 0; }
Determines if the given intent resolves to an Activity which is allowed to appear above the lock screen. @param intent the intent to resolve @return true if the launched Activity would appear above the lock screen
ActivityIntentHelper::wouldShowOverLockscreen
java
Reginer/aosp-android-jar
android-34/src/com/android/systemui/ActivityIntentHelper.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/systemui/ActivityIntentHelper.java
MIT
public boolean wouldPendingShowOverLockscreen(PendingIntent intent, int currentUserId) { ActivityInfo targetActivityInfo = getPendingTargetActivityInfo(intent, currentUserId, false /* onlyDirectBootAware */); return targetActivityInfo != null && (targetActivityInfo.flags & (ActivityInfo.FLAG_SHOW_WHEN_LOCKED | ActivityInfo.FLAG_SHOW_FOR_ALL_USERS)) > 0; }
@see #wouldShowOverLockscreen(Intent, int)
ActivityIntentHelper::wouldPendingShowOverLockscreen
java
Reginer/aosp-android-jar
android-34/src/com/android/systemui/ActivityIntentHelper.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/systemui/ActivityIntentHelper.java
MIT
public boolean wouldLaunchResolverActivity(ResolveInfo resolved, List<ResolveInfo> appList) { // If the list contains the above resolved activity, then it can't be // ResolverActivity itself. for (int i = 0; i < appList.size(); i++) { ResolveInfo tmp = appList.get(i); if (tmp.activityInfo.name.equals(resolved.activityInfo.name) && tmp.activityInfo.packageName.equals(resolved.activityInfo.packageName)) { return false; } } return true; }
Determines if sending the given intent would result in starting an Intent resolver activity, instead of resolving to a specific component. @param resolved the resolveInfo for the intent as returned by resolveActivityAsUser @param appList a list of resolveInfo as returned by queryIntentActivitiesAsUser @return true if the intent would launch a resolver activity
ActivityIntentHelper::wouldLaunchResolverActivity
java
Reginer/aosp-android-jar
android-34/src/com/android/systemui/ActivityIntentHelper.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/systemui/ActivityIntentHelper.java
MIT
public CarLaunchParamsModifier(Context context) { // This can be very early stage. So postpone interaction with other system until init. mContext = context; }
This one is for holding all passenger (=profile user) displays which are mostly static unless displays are added / removed. Note that {@link #mDisplayToProfileUserMapping} can be empty while user is assigned and that cannot always tell if specific display is for driver or not. @GuardedBy("mLock") private final ArrayList<Integer> mPassengerDisplays = new ArrayList<>(); /** key: display id, value: profile user id @GuardedBy("mLock") private final SparseIntArray mDisplayToProfileUserMapping = new SparseIntArray(); /** key: profile user id, value: display id @GuardedBy("mLock") private final SparseIntArray mDefaultDisplayForProfileUser = new SparseIntArray(); @GuardedBy("mLock") private boolean mIsSourcePreferred; @GuardedBy("mLock") private List<ComponentName> mSourcePreferredComponents; @GuardedBy("mLock") private final ArrayMap<ComponentName, TaskDisplayArea> mPersistentActivities = new ArrayMap<>(); @VisibleForTesting final DisplayManager.DisplayListener mDisplayListener = new DisplayManager.DisplayListener() { @Override public void onDisplayAdded(int displayId) { // ignore. car service should update whiltelist. } @Override public void onDisplayRemoved(int displayId) { synchronized (mLock) { mPassengerDisplays.remove(Integer.valueOf(displayId)); updateProfileUserConfigForDisplayRemovalLocked(displayId); } } @Override public void onDisplayChanged(int displayId) { // ignore } }; private void updateProfileUserConfigForDisplayRemovalLocked(int displayId) { mDisplayToProfileUserMapping.delete(displayId); int i = mDefaultDisplayForProfileUser.indexOfValue(displayId); if (i >= 0) { mDefaultDisplayForProfileUser.removeAt(i); } } /** Constructor. Can be constructed any time.
CarLaunchParamsModifier::CarLaunchParamsModifier
java
Reginer/aosp-android-jar
android-32/src/com/android/server/wm/CarLaunchParamsModifier.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/server/wm/CarLaunchParamsModifier.java
MIT
public void init() { mAtm = (ActivityTaskManagerService) ActivityTaskManager.getService(); LaunchParamsController controller = mAtm.mTaskSupervisor.getLaunchParamsController(); controller.registerModifier(this); mDisplayManager = mContext.getSystemService(DisplayManager.class); mDisplayManager.registerDisplayListener(mDisplayListener, new Handler(Looper.getMainLooper())); }
Initializes all internal stuffs. This should be called only after ATMS, DisplayManagerService are ready.
CarLaunchParamsModifier::init
java
Reginer/aosp-android-jar
android-32/src/com/android/server/wm/CarLaunchParamsModifier.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/server/wm/CarLaunchParamsModifier.java
MIT
public void startObserving(Handler handler, ContentResolver resolver) { mResolver = resolver; mSettingsObserver = new SettingsObserver(handler); mResolver.registerContentObserver(Settings.Global.getUriFor(mSettingsKey), false, mSettingsObserver); updateSettingsConstants(); DeviceConfig.addOnPropertiesChangedListener(NAMESPACE_ACTIVITY_MANAGER_NATIVE_BOOT, new HandlerExecutor(handler), this::updateDeviceConfigConstants); updateDeviceConfigConstants(); }
Spin up the observer lazily, since it can only happen once the settings provider has been brought into service
SettingsObserver::startObserving
java
Reginer/aosp-android-jar
android-35/src/com/android/server/am/BroadcastConstants.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/server/am/BroadcastConstants.java
MIT
private static @NonNull String propertyFor(@NonNull String key) { return "persist.device_config." + NAMESPACE_ACTIVITY_MANAGER_NATIVE_BOOT + "." + key; }
Return the {@link SystemProperties} name for the given key in our {@link DeviceConfig} namespace.
SettingsObserver::propertyFor
java
Reginer/aosp-android-jar
android-35/src/com/android/server/am/BroadcastConstants.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/server/am/BroadcastConstants.java
MIT
private static @NonNull String propertyOverrideFor(@NonNull String key) { return "persist.sys." + NAMESPACE_ACTIVITY_MANAGER_NATIVE_BOOT + "." + key; }
Return the {@link SystemProperties} name for the given key in our {@link DeviceConfig} namespace, but with a different prefix that can be used to locally override the {@link DeviceConfig} value.
SettingsObserver::propertyOverrideFor
java
Reginer/aosp-android-jar
android-35/src/com/android/server/am/BroadcastConstants.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/server/am/BroadcastConstants.java
MIT
private void updateDeviceConfigConstants() { synchronized (this) { MAX_RUNNING_PROCESS_QUEUES = getDeviceConfigInt(KEY_MAX_RUNNING_PROCESS_QUEUES, DEFAULT_MAX_RUNNING_PROCESS_QUEUES); EXTRA_RUNNING_URGENT_PROCESS_QUEUES = getDeviceConfigInt( KEY_EXTRA_RUNNING_URGENT_PROCESS_QUEUES, DEFAULT_EXTRA_RUNNING_URGENT_PROCESS_QUEUES); MAX_CONSECUTIVE_URGENT_DISPATCHES = getDeviceConfigInt( KEY_MAX_CONSECUTIVE_URGENT_DISPATCHES, DEFAULT_MAX_CONSECUTIVE_URGENT_DISPATCHES); MAX_CONSECUTIVE_NORMAL_DISPATCHES = getDeviceConfigInt( KEY_MAX_CONSECUTIVE_NORMAL_DISPATCHES, DEFAULT_MAX_CONSECUTIVE_NORMAL_DISPATCHES); MAX_RUNNING_ACTIVE_BROADCASTS = getDeviceConfigInt(KEY_MAX_RUNNING_ACTIVE_BROADCASTS, DEFAULT_MAX_RUNNING_ACTIVE_BROADCASTS); MAX_CORE_RUNNING_BLOCKING_BROADCASTS = getDeviceConfigInt( KEY_CORE_MAX_RUNNING_BLOCKING_BROADCASTS, DEFAULT_MAX_CORE_RUNNING_BLOCKING_BROADCASTS); MAX_CORE_RUNNING_NON_BLOCKING_BROADCASTS = getDeviceConfigInt( KEY_CORE_MAX_RUNNING_NON_BLOCKING_BROADCASTS, DEFAULT_MAX_CORE_RUNNING_NON_BLOCKING_BROADCASTS); MAX_PENDING_BROADCASTS = getDeviceConfigInt(KEY_MAX_PENDING_BROADCASTS, DEFAULT_MAX_PENDING_BROADCASTS); DELAY_NORMAL_MILLIS = getDeviceConfigLong(KEY_DELAY_NORMAL_MILLIS, DEFAULT_DELAY_NORMAL_MILLIS); DELAY_CACHED_MILLIS = getDeviceConfigLong(KEY_DELAY_CACHED_MILLIS, DEFAULT_DELAY_CACHED_MILLIS); DELAY_URGENT_MILLIS = getDeviceConfigLong(KEY_DELAY_URGENT_MILLIS, DEFAULT_DELAY_URGENT_MILLIS); DELAY_FOREGROUND_PROC_MILLIS = getDeviceConfigLong(KEY_DELAY_FOREGROUND_PROC_MILLIS, DEFAULT_DELAY_FOREGROUND_PROC_MILLIS); DELAY_PERSISTENT_PROC_MILLIS = getDeviceConfigLong(KEY_DELAY_PERSISTENT_PROC_MILLIS, DEFAULT_DELAY_PERSISTENT_PROC_MILLIS); MAX_HISTORY_COMPLETE_SIZE = getDeviceConfigInt(KEY_MAX_HISTORY_COMPLETE_SIZE, DEFAULT_MAX_HISTORY_COMPLETE_SIZE); MAX_HISTORY_SUMMARY_SIZE = getDeviceConfigInt(KEY_MAX_HISTORY_SUMMARY_SIZE, DEFAULT_MAX_HISTORY_SUMMARY_SIZE); CORE_DEFER_UNTIL_ACTIVE = getDeviceConfigBoolean(KEY_CORE_DEFER_UNTIL_ACTIVE, DEFAULT_CORE_DEFER_UNTIL_ACTIVE); PENDING_COLD_START_CHECK_INTERVAL_MILLIS = getDeviceConfigLong( KEY_PENDING_COLD_START_CHECK_INTERVAL_MILLIS, DEFAULT_PENDING_COLD_START_CHECK_INTERVAL_MILLIS); MAX_FROZEN_OUTGOING_BROADCASTS = getDeviceConfigInt( KEY_MAX_FROZEN_OUTGOING_BROADCASTS, DEFAULT_MAX_FROZEN_OUTGOING_BROADCASTS); } // TODO: migrate BroadcastRecord to accept a BroadcastConstants BroadcastRecord.CORE_DEFER_UNTIL_ACTIVE = CORE_DEFER_UNTIL_ACTIVE; }
Since our values are stored in a "native boot" namespace, we load them directly from the system properties.
SettingsObserver::updateDeviceConfigConstants
java
Reginer/aosp-android-jar
android-35/src/com/android/server/am/BroadcastConstants.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/server/am/BroadcastConstants.java
MIT
public void activityIdle(IBinder token, Configuration config, boolean stopProfiling) { try { getActivityClientController().activityIdle(token, config, stopProfiling); } catch (RemoteException e) { e.rethrowFromSystemServer(); } }
Provides the activity associated operations that communicate with system. @hide public class ActivityClient { private ActivityClient() {} /** Reports the main thread is idle after the activity is resumed.
ActivityClient::activityIdle
java
Reginer/aosp-android-jar
android-31/src/android/app/ActivityClient.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/app/ActivityClient.java
MIT
public void activityResumed(IBinder token, boolean handleSplashScreenExit) { try { getActivityClientController().activityResumed(token, handleSplashScreenExit); } catch (RemoteException e) { e.rethrowFromSystemServer(); } }
Provides the activity associated operations that communicate with system. @hide public class ActivityClient { private ActivityClient() {} /** Reports the main thread is idle after the activity is resumed. public void activityIdle(IBinder token, Configuration config, boolean stopProfiling) { try { getActivityClientController().activityIdle(token, config, stopProfiling); } catch (RemoteException e) { e.rethrowFromSystemServer(); } } /** Reports {@link Activity#onResume()} is done.
ActivityClient::activityResumed
java
Reginer/aosp-android-jar
android-31/src/android/app/ActivityClient.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/app/ActivityClient.java
MIT
public void activityTopResumedStateLost() { try { getActivityClientController().activityTopResumedStateLost(); } catch (RemoteException e) { e.rethrowFromSystemServer(); } }
Reports after {@link Activity#onTopResumedActivityChanged(boolean)} is called for losing the top most position.
ActivityClient::activityTopResumedStateLost
java
Reginer/aosp-android-jar
android-31/src/android/app/ActivityClient.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/android/app/ActivityClient.java
MIT