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
private List<byte[]> readRawBytesSlowPathRemainingChunks(int sizeLeft) throws IOException { // The size is very large. For security reasons, we can't allocate the // entire byte array yet. The size comes directly from the input, so a // maliciously-crafted message could provide a bogus very large size in // order to trick the app into allocating a lot of memory. We avoid this // by allocating and reading only a small chunk at a time, so that the // malicious message must actually *be* extremely large to cause // problems. Meanwhile, we limit the allowed size of a message elsewhere. final List<byte[]> chunks = new ArrayList<>(); while (sizeLeft > 0) { // TODO(nathanmittler): Consider using a value larger than DEFAULT_BUFFER_SIZE. final byte[] chunk = new byte[Math.min(sizeLeft, DEFAULT_BUFFER_SIZE)]; int tempPos = 0; while (tempPos < chunk.length) { final int n = input.read(chunk, tempPos, chunk.length - tempPos); if (n == -1) { throw InvalidProtocolBufferException.truncatedMessage(); } totalBytesRetired += n; tempPos += n; } sizeLeft -= chunk.length; chunks.add(chunk); } return chunks; }
Reads the remaining data in small chunks from the input stream. Returns a byte[] that may have escaped to user code via InputStream APIs.
StreamDecoder::readRawBytesSlowPathRemainingChunks
java
Reginer/aosp-android-jar
android-34/src/com/google/protobuf/CodedInputStream.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/google/protobuf/CodedInputStream.java
MIT
private ByteString readBytesSlowPath(final int size) throws IOException { final byte[] result = readRawBytesSlowPathOneChunk(size); if (result != null) { // We must copy as the byte array was handed off to the InputStream and a malicious // implementation could retain a reference. return ByteString.copyFrom(result); } final int originalBufferPos = pos; final int bufferedBytes = bufferSize - pos; // Mark the current buffer consumed. totalBytesRetired += bufferSize; pos = 0; bufferSize = 0; // Determine the number of bytes we need to read from the input stream. int sizeLeft = size - bufferedBytes; // The size is very large. For security reasons we read them in small // chunks. List<byte[]> chunks = readRawBytesSlowPathRemainingChunks(sizeLeft); // OK, got everything. Now concatenate it all into one buffer. final byte[] bytes = new byte[size]; // Start by copying the leftover bytes from this.buffer. System.arraycopy(buffer, originalBufferPos, bytes, 0, bufferedBytes); // And now all the chunks. int tempPos = bufferedBytes; for (final byte[] chunk : chunks) { System.arraycopy(chunk, 0, bytes, tempPos, chunk.length); tempPos += chunk.length; } return ByteString.wrap(bytes); }
Like readBytes, but caller must have already checked the fast path: (size <= (bufferSize - pos) && size > 0 || size == 0)
StreamDecoder::readBytesSlowPath
java
Reginer/aosp-android-jar
android-34/src/com/google/protobuf/CodedInputStream.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/google/protobuf/CodedInputStream.java
MIT
private void skipRawBytesSlowPath(final int size) throws IOException { if (size < 0) { throw InvalidProtocolBufferException.negativeSize(); } if (totalBytesRetired + pos + size > currentLimit) { // Read to the end of the stream anyway. skipRawBytes(currentLimit - totalBytesRetired - pos); // Then fail. throw InvalidProtocolBufferException.truncatedMessage(); } int totalSkipped = 0; if (refillCallback == null) { // Skipping more bytes than are in the buffer. First skip what we have. totalBytesRetired += pos; totalSkipped = bufferSize - pos; bufferSize = 0; pos = 0; try { while (totalSkipped < size) { int toSkip = size - totalSkipped; long skipped = skip(input, toSkip); if (skipped < 0 || skipped > toSkip) { throw new IllegalStateException( input.getClass() + "#skip returned invalid result: " + skipped + "\nThe InputStream implementation is buggy."); } else if (skipped == 0) { // The API contract of skip() permits an inputstream to skip zero bytes for any reason // it wants. In particular, ByteArrayInputStream will just return zero over and over // when it's at the end of its input. In order to actually confirm that we've hit the // end of input, we need to issue a read call via the other path. break; } totalSkipped += (int) skipped; } } finally { totalBytesRetired += totalSkipped; recomputeBufferSizeAfterLimit(); } } if (totalSkipped < size) { // Skipping more bytes than are in the buffer. First skip what we have. int tempPos = bufferSize - pos; pos = bufferSize; // Keep refilling the buffer until we get to the point we wanted to skip to. // This has the side effect of ensuring the limits are updated correctly. refillBuffer(1); while (size - tempPos > bufferSize) { tempPos += bufferSize; pos = bufferSize; refillBuffer(1); } pos = size - tempPos; } }
Exactly like skipRawBytes, but caller must have already checked the fast path: (size <= (bufferSize - pos) && size >= 0)
StreamDecoder::skipRawBytesSlowPath
java
Reginer/aosp-android-jar
android-34/src/com/google/protobuf/CodedInputStream.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/google/protobuf/CodedInputStream.java
MIT
private IterableDirectByteBufferDecoder( Iterable<ByteBuffer> inputBufs, int size, boolean immutableFlag) { totalBufferSize = size; input = inputBufs; iterator = input.iterator(); immutable = immutableFlag; startOffset = totalBytesRead = 0; if (size == 0) { currentByteBuffer = EMPTY_BYTE_BUFFER; currentByteBufferPos = 0; currentByteBufferStartPos = 0; currentByteBufferLimit = 0; currentAddress = 0; } else { tryGetNextByteBuffer(); } }
The constructor of {@code Iterable<ByteBuffer>} decoder. @param inputBufs The input data. @param size The total size of the input data. @param immutableFlag whether the input data is immutable.
IterableDirectByteBufferDecoder::IterableDirectByteBufferDecoder
java
Reginer/aosp-android-jar
android-34/src/com/google/protobuf/CodedInputStream.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/google/protobuf/CodedInputStream.java
MIT
private void getNextByteBuffer() throws InvalidProtocolBufferException { if (!iterator.hasNext()) { throw InvalidProtocolBufferException.truncatedMessage(); } tryGetNextByteBuffer(); }
The constructor of {@code Iterable<ByteBuffer>} decoder. @param inputBufs The input data. @param size The total size of the input data. @param immutableFlag whether the input data is immutable. private IterableDirectByteBufferDecoder( Iterable<ByteBuffer> inputBufs, int size, boolean immutableFlag) { totalBufferSize = size; input = inputBufs; iterator = input.iterator(); immutable = immutableFlag; startOffset = totalBytesRead = 0; if (size == 0) { currentByteBuffer = EMPTY_BYTE_BUFFER; currentByteBufferPos = 0; currentByteBufferStartPos = 0; currentByteBufferLimit = 0; currentAddress = 0; } else { tryGetNextByteBuffer(); } } /** To get the next ByteBuffer from {@code input}, and then update the parameters
IterableDirectByteBufferDecoder::getNextByteBuffer
java
Reginer/aosp-android-jar
android-34/src/com/google/protobuf/CodedInputStream.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/google/protobuf/CodedInputStream.java
MIT
private void readRawBytesTo(byte[] bytes, int offset, final int length) throws IOException { if (length >= 0 && length <= remaining()) { int l = length; while (l > 0) { if (currentRemaining() == 0) { getNextByteBuffer(); } int bytesToCopy = Math.min(l, (int) currentRemaining()); UnsafeUtil.copyMemory(currentByteBufferPos, bytes, length - l + offset, bytesToCopy); l -= bytesToCopy; currentByteBufferPos += bytesToCopy; } return; } if (length <= 0) { if (length == 0) { return; } else { throw InvalidProtocolBufferException.negativeSize(); } } throw InvalidProtocolBufferException.truncatedMessage(); }
Try to get raw bytes from {@code input} with the size of {@code length} and copy to {@code bytes} array. If the size is bigger than the number of remaining bytes in the input, then throw {@code truncatedMessage} exception.
IterableDirectByteBufferDecoder::readRawBytesTo
java
Reginer/aosp-android-jar
android-34/src/com/google/protobuf/CodedInputStream.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/google/protobuf/CodedInputStream.java
MIT
private int remaining() { return (int) (totalBufferSize - totalBytesRead - currentByteBufferPos + currentByteBufferStartPos); }
Try to get the number of remaining bytes in {@code input}. @return the number of remaining bytes in {@code input}.
IterableDirectByteBufferDecoder::remaining
java
Reginer/aosp-android-jar
android-34/src/com/google/protobuf/CodedInputStream.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/google/protobuf/CodedInputStream.java
MIT
private long currentRemaining() { return (currentByteBufferLimit - currentByteBufferPos); }
Try to get the number of remaining bytes in {@code currentByteBuffer}. @return the number of remaining bytes in {@code currentByteBuffer}
IterableDirectByteBufferDecoder::currentRemaining
java
Reginer/aosp-android-jar
android-34/src/com/google/protobuf/CodedInputStream.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/google/protobuf/CodedInputStream.java
MIT
public ArrayMap() { this(0, false); }
Create a new empty ArrayMap. The default capacity of an array map is 0, and will grow once items are added to it.
ArrayMap::ArrayMap
java
Reginer/aosp-android-jar
android-34/src/android/util/ArrayMap.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/util/ArrayMap.java
MIT
public ArrayMap(int capacity) { this(capacity, false); }
Create a new ArrayMap with a given initial capacity.
ArrayMap::ArrayMap
java
Reginer/aosp-android-jar
android-34/src/android/util/ArrayMap.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/util/ArrayMap.java
MIT
public ArrayMap(int capacity, boolean identityHashCode) { mIdentityHashCode = identityHashCode; // If this is immutable, use the sentinal EMPTY_IMMUTABLE_INTS // instance instead of the usual EmptyArray.INT. The reference // is checked later to see if the array is allowed to grow. if (capacity < 0) { mHashes = EMPTY_IMMUTABLE_INTS; mArray = EmptyArray.OBJECT; } else if (capacity == 0) { mHashes = EmptyArray.INT; mArray = EmptyArray.OBJECT; } else { allocArrays(capacity); } mSize = 0; }
Create a new ArrayMap with a given initial capacity. public ArrayMap(int capacity) { this(capacity, false); } /** {@hide}
ArrayMap::ArrayMap
java
Reginer/aosp-android-jar
android-34/src/android/util/ArrayMap.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/util/ArrayMap.java
MIT
public ArrayMap(ArrayMap<K, V> map) { this(); if (map != null) { putAll(map); } }
Create a new ArrayMap with the mappings from the given ArrayMap.
ArrayMap::ArrayMap
java
Reginer/aosp-android-jar
android-34/src/android/util/ArrayMap.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/util/ArrayMap.java
MIT
public void erase() { if (mSize > 0) { final int N = mSize<<1; final Object[] array = mArray; for (int i=0; i<N; i++) { array[i] = null; } mSize = 0; } }
@hide Like {@link #clear}, but doesn't reduce the capacity of the ArrayMap.
ArrayMap::erase
java
Reginer/aosp-android-jar
android-34/src/android/util/ArrayMap.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/util/ArrayMap.java
MIT
public void ensureCapacity(int minimumCapacity) { final int osize = mSize; if (mHashes.length < minimumCapacity) { final int[] ohashes = mHashes; final Object[] oarray = mArray; allocArrays(minimumCapacity); if (mSize > 0) { System.arraycopy(ohashes, 0, mHashes, 0, osize); System.arraycopy(oarray, 0, mArray, 0, osize<<1); } freeArrays(ohashes, oarray, osize); } if (CONCURRENT_MODIFICATION_EXCEPTIONS && mSize != osize) { throw new ConcurrentModificationException(); } }
Ensure the array map can hold at least <var>minimumCapacity</var> items.
ArrayMap::ensureCapacity
java
Reginer/aosp-android-jar
android-34/src/android/util/ArrayMap.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/util/ArrayMap.java
MIT
public int indexOfKey(Object key) { return key == null ? indexOfNull() : indexOf(key, mIdentityHashCode ? System.identityHashCode(key) : key.hashCode()); }
Returns the index of a key in the set. @param key The key to search for. @return Returns the index of the key if it exists, else a negative integer.
ArrayMap::indexOfKey
java
Reginer/aosp-android-jar
android-34/src/android/util/ArrayMap.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/util/ArrayMap.java
MIT
public int indexOfValue(Object value) { final int N = mSize*2; final Object[] array = mArray; if (value == null) { for (int i=1; i<N; i+=2) { if (array[i] == null) { return i>>1; } } } else { for (int i=1; i<N; i+=2) { if (value.equals(array[i])) { return i>>1; } } } return -1; }
Returns an index for which {@link #valueAt} would return the specified value, or a negative number if no keys map to the specified value. Beware that this is a linear search, unlike lookups by key, and that multiple keys can map to the same value and this will find only one of them.
ArrayMap::indexOfValue
java
Reginer/aosp-android-jar
android-34/src/android/util/ArrayMap.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/util/ArrayMap.java
MIT
public K keyAt(int index) { if (index >= mSize && UtilConfig.sThrowExceptionForUpperArrayOutOfBounds) { // The array might be slightly bigger than mSize, in which case, indexing won't fail. // Check if exception should be thrown outside of the critical path. throw new ArrayIndexOutOfBoundsException(index); } return (K)mArray[index << 1]; }
Return the key at the given index in the array. <p>For indices outside of the range <code>0...size()-1</code>, the behavior is undefined for apps targeting {@link android.os.Build.VERSION_CODES#P} and earlier, and an {@link ArrayIndexOutOfBoundsException} is thrown for apps targeting {@link android.os.Build.VERSION_CODES#Q} and later.</p> @param index The desired index, must be between 0 and {@link #size()}-1. @return Returns the key stored at the given index.
ArrayMap::keyAt
java
Reginer/aosp-android-jar
android-34/src/android/util/ArrayMap.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/util/ArrayMap.java
MIT
public V valueAt(int index) { if (index >= mSize && UtilConfig.sThrowExceptionForUpperArrayOutOfBounds) { // The array might be slightly bigger than mSize, in which case, indexing won't fail. // Check if exception should be thrown outside of the critical path. throw new ArrayIndexOutOfBoundsException(index); } return (V)mArray[(index << 1) + 1]; }
Return the value at the given index in the array. <p>For indices outside of the range <code>0...size()-1</code>, the behavior is undefined for apps targeting {@link android.os.Build.VERSION_CODES#P} and earlier, and an {@link ArrayIndexOutOfBoundsException} is thrown for apps targeting {@link android.os.Build.VERSION_CODES#Q} and later.</p> @param index The desired index, must be between 0 and {@link #size()}-1. @return Returns the value stored at the given index.
ArrayMap::valueAt
java
Reginer/aosp-android-jar
android-34/src/android/util/ArrayMap.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/util/ArrayMap.java
MIT
public V setValueAt(int index, V value) { if (index >= mSize && UtilConfig.sThrowExceptionForUpperArrayOutOfBounds) { // The array might be slightly bigger than mSize, in which case, indexing won't fail. // Check if exception should be thrown outside of the critical path. throw new ArrayIndexOutOfBoundsException(index); } index = (index << 1) + 1; V old = (V)mArray[index]; mArray[index] = value; return old; }
Set the value at a given index in the array. <p>For indices outside of the range <code>0...size()-1</code>, the behavior is undefined for apps targeting {@link android.os.Build.VERSION_CODES#P} and earlier, and an {@link ArrayIndexOutOfBoundsException} is thrown for apps targeting {@link android.os.Build.VERSION_CODES#Q} and later.</p> @param index The desired index, must be between 0 and {@link #size()}-1. @param value The new value to store at this index. @return Returns the previous value at the given index.
ArrayMap::setValueAt
java
Reginer/aosp-android-jar
android-34/src/android/util/ArrayMap.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/util/ArrayMap.java
MIT
public void validate() { final int N = mSize; if (N <= 1) { // There can't be dups. return; } int basehash = mHashes[0]; int basei = 0; for (int i=1; i<N; i++) { int hash = mHashes[i]; if (hash != basehash) { basehash = hash; basei = i; continue; } // We are in a run of entries with the same hash code. Go backwards through // the array to see if any keys are the same. final Object cur = mArray[i<<1]; for (int j=i-1; j>=basei; j--) { final Object prev = mArray[j<<1]; if (cur == prev) { throw new IllegalArgumentException("Duplicate key in ArrayMap: " + cur); } if (cur != null && prev != null && cur.equals(prev)) { throw new IllegalArgumentException("Duplicate key in ArrayMap: " + cur); } } } }
The use of the {@link #append} function can result in invalid array maps, in particular an array map where the same key appears multiple times. This function verifies that the array map is valid, throwing IllegalArgumentException if a problem is found. The main use for this method is validating an array map after unpacking from an IPC, to protect against malicious callers. @hide
ArrayMap::validate
java
Reginer/aosp-android-jar
android-34/src/android/util/ArrayMap.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/util/ArrayMap.java
MIT
public void putAll(ArrayMap<? extends K, ? extends V> array) { final int N = array.mSize; ensureCapacity(mSize + N); if (mSize == 0) { if (N > 0) { System.arraycopy(array.mHashes, 0, mHashes, 0, N); System.arraycopy(array.mArray, 0, mArray, 0, N<<1); mSize = N; } } else { for (int i=0; i<N; i++) { put(array.keyAt(i), array.valueAt(i)); } } }
Perform a {@link #put(Object, Object)} of all key/value pairs in <var>array</var> @param array The array whose contents are to be retrieved.
ArrayMap::putAll
java
Reginer/aosp-android-jar
android-34/src/android/util/ArrayMap.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/util/ArrayMap.java
MIT
public V removeAt(int index) { if (index >= mSize && UtilConfig.sThrowExceptionForUpperArrayOutOfBounds) { // The array might be slightly bigger than mSize, in which case, indexing won't fail. // Check if exception should be thrown outside of the critical path. throw new ArrayIndexOutOfBoundsException(index); } final Object old = mArray[(index << 1) + 1]; final int osize = mSize; final int nsize; if (osize <= 1) { // Now empty. if (DEBUG) Log.d(TAG, "remove: shrink from " + mHashes.length + " to 0"); final int[] ohashes = mHashes; final Object[] oarray = mArray; mHashes = EmptyArray.INT; mArray = EmptyArray.OBJECT; freeArrays(ohashes, oarray, osize); nsize = 0; } else { nsize = osize - 1; if (mHashes.length > (BASE_SIZE*2) && mSize < mHashes.length/3) { // Shrunk enough to reduce size of arrays. We don't allow it to // shrink smaller than (BASE_SIZE*2) to avoid flapping between // that and BASE_SIZE. final int n = osize > (BASE_SIZE*2) ? (osize + (osize>>1)) : (BASE_SIZE*2); if (DEBUG) Log.d(TAG, "remove: shrink from " + mHashes.length + " to " + n); final int[] ohashes = mHashes; final Object[] oarray = mArray; allocArrays(n); if (CONCURRENT_MODIFICATION_EXCEPTIONS && osize != mSize) { throw new ConcurrentModificationException(); } if (index > 0) { if (DEBUG) Log.d(TAG, "remove: copy from 0-" + index + " to 0"); System.arraycopy(ohashes, 0, mHashes, 0, index); System.arraycopy(oarray, 0, mArray, 0, index << 1); } if (index < nsize) { if (DEBUG) Log.d(TAG, "remove: copy from " + (index+1) + "-" + nsize + " to " + index); System.arraycopy(ohashes, index + 1, mHashes, index, nsize - index); System.arraycopy(oarray, (index + 1) << 1, mArray, index << 1, (nsize - index) << 1); } } else { if (index < nsize) { if (DEBUG) Log.d(TAG, "remove: move " + (index+1) + "-" + nsize + " to " + index); System.arraycopy(mHashes, index + 1, mHashes, index, nsize - index); System.arraycopy(mArray, (index + 1) << 1, mArray, index << 1, (nsize - index) << 1); } mArray[nsize << 1] = null; mArray[(nsize << 1) + 1] = null; } } if (CONCURRENT_MODIFICATION_EXCEPTIONS && osize != mSize) { throw new ConcurrentModificationException(); } mSize = nsize; return (V)old; }
Remove the key/value mapping at the given index. <p>For indices outside of the range <code>0...size()-1</code>, the behavior is undefined for apps targeting {@link android.os.Build.VERSION_CODES#P} and earlier, and an {@link ArrayIndexOutOfBoundsException} is thrown for apps targeting {@link android.os.Build.VERSION_CODES#Q} and later.</p> @param index The desired index, must be between 0 and {@link #size()}-1. @return Returns the value that was stored at this index.
ArrayMap::removeAt
java
Reginer/aosp-android-jar
android-34/src/android/util/ArrayMap.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/util/ArrayMap.java
MIT
public boolean containsAll(Collection<?> collection) { return MapCollections.containsAllHelper(this, collection); }
Determine if the array map contains all of the keys in the given collection. @param collection The collection whose contents are to be checked against. @return Returns true if this array map contains a key for every entry in <var>collection</var>, else returns false.
ArrayMap::containsAll
java
Reginer/aosp-android-jar
android-34/src/android/util/ArrayMap.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/util/ArrayMap.java
MIT
public boolean removeAll(Collection<?> collection) { return MapCollections.removeAllHelper(this, collection); }
Remove all keys in the array map that exist in the given collection. @param collection The collection whose contents are to be used to remove keys. @return Returns true if any keys were removed from the array map, else false.
ArrayMap::removeAll
java
Reginer/aosp-android-jar
android-34/src/android/util/ArrayMap.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/util/ArrayMap.java
MIT
public boolean retainAll(Collection<?> collection) { return MapCollections.retainAllHelper(this, collection); }
Remove all keys in the array map that do <b>not</b> exist in the given collection. @param collection The collection whose contents are to be used to determine which keys to keep. @return Returns true if any keys were removed from the array map, else false.
ArrayMap::retainAll
java
Reginer/aosp-android-jar
android-34/src/android/util/ArrayMap.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/android/util/ArrayMap.java
MIT
public PKIXBuilderParameters(Set<TrustAnchor> trustAnchors, CertSelector targetConstraints) throws InvalidAlgorithmParameterException { super(trustAnchors); setTargetCertConstraints(targetConstraints); }
Creates an instance of {@code PKIXBuilderParameters} with the specified {@code Set} of most-trusted CAs. Each element of the set is a {@link TrustAnchor TrustAnchor}. <p>Note that the {@code Set} is copied to protect against subsequent modifications. @param trustAnchors a {@code Set} of {@code TrustAnchor}s @param targetConstraints a {@code CertSelector} specifying the constraints on the target certificate @throws InvalidAlgorithmParameterException if {@code trustAnchors} is empty {@code (trustAnchors.isEmpty() == true)} @throws NullPointerException if {@code trustAnchors} is {@code null} @throws ClassCastException if any of the elements of {@code trustAnchors} are not of type {@code java.security.cert.TrustAnchor}
PKIXBuilderParameters::PKIXBuilderParameters
java
Reginer/aosp-android-jar
android-31/src/java/security/cert/PKIXBuilderParameters.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/java/security/cert/PKIXBuilderParameters.java
MIT
public PKIXBuilderParameters(KeyStore keystore, CertSelector targetConstraints) throws KeyStoreException, InvalidAlgorithmParameterException { super(keystore); setTargetCertConstraints(targetConstraints); }
Creates an instance of {@code PKIXBuilderParameters} that populates the set of most-trusted CAs from the trusted certificate entries contained in the specified {@code KeyStore}. Only keystore entries that contain trusted {@code X509Certificate}s are considered; all other certificate types are ignored. @param keystore a {@code KeyStore} from which the set of most-trusted CAs will be populated @param targetConstraints a {@code CertSelector} specifying the constraints on the target certificate @throws KeyStoreException if {@code keystore} has not been initialized @throws InvalidAlgorithmParameterException if {@code keystore} does not contain at least one trusted certificate entry @throws NullPointerException if {@code keystore} is {@code null}
PKIXBuilderParameters::PKIXBuilderParameters
java
Reginer/aosp-android-jar
android-31/src/java/security/cert/PKIXBuilderParameters.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/java/security/cert/PKIXBuilderParameters.java
MIT
public void setMaxPathLength(int maxPathLength) { if (maxPathLength < -1) { throw new InvalidParameterException("the maximum path " + "length parameter can not be less than -1"); } this.maxPathLength = maxPathLength; }
Sets the value of the maximum number of non-self-issued intermediate certificates that may exist in a certification path. A certificate is self-issued if the DNs that appear in the subject and issuer fields are identical and are not empty. Note that the last certificate in a certification path is not an intermediate certificate, and is not included in this limit. Usually the last certificate is an end entity certificate, but it can be a CA certificate. A PKIX {@code CertPathBuilder} instance must not build paths longer than the length specified. <p> A value of 0 implies that the path can only contain a single certificate. A value of -1 implies that the path length is unconstrained (i.e. there is no maximum). The default maximum path length, if not specified, is 5. Setting a value less than -1 will cause an exception to be thrown. <p> If any of the CA certificates contain the {@code BasicConstraintsExtension}, the value of the {@code pathLenConstraint} field of the extension overrides the maximum path length parameter whenever the result is a certification path of smaller length. @param maxPathLength the maximum number of non-self-issued intermediate certificates that may exist in a certification path @throws InvalidParameterException if {@code maxPathLength} is set to a value less than -1 @see #getMaxPathLength
PKIXBuilderParameters::setMaxPathLength
java
Reginer/aosp-android-jar
android-31/src/java/security/cert/PKIXBuilderParameters.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/java/security/cert/PKIXBuilderParameters.java
MIT
public int getMaxPathLength() { return maxPathLength; }
Returns the value of the maximum number of intermediate non-self-issued certificates that may exist in a certification path. See the {@link #setMaxPathLength} method for more details. @return the maximum number of non-self-issued intermediate certificates that may exist in a certification path, or -1 if there is no limit @see #setMaxPathLength
PKIXBuilderParameters::getMaxPathLength
java
Reginer/aosp-android-jar
android-31/src/java/security/cert/PKIXBuilderParameters.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/java/security/cert/PKIXBuilderParameters.java
MIT
public String toString() { StringBuffer sb = new StringBuffer(); sb.append("[\n"); sb.append(super.toString()); sb.append(" Maximum Path Length: " + maxPathLength + "\n"); sb.append("]\n"); return sb.toString(); }
Returns a formatted string describing the parameters. @return a formatted string describing the parameters
PKIXBuilderParameters::toString
java
Reginer/aosp-android-jar
android-31/src/java/security/cert/PKIXBuilderParameters.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/java/security/cert/PKIXBuilderParameters.java
MIT
public RequireScrollMixin(@NonNull TemplateLayout templateLayout) { }
A delegate to detect scrollability changes and to scroll the page. This provides a layer of abstraction for BottomScrollView, RecyclerView and ListView. The delegate should call {@link #notifyScrollabilityChange(boolean)} when the view scrollability is changed. interface ScrollHandlingDelegate { /** Starts listening to scrollability changes at the target scrollable container. void startListening(); /** Scroll the page content down by one page. void pageScrollDown(); } /* non-static section private final Handler handler = new Handler(Looper.getMainLooper()); private boolean requiringScrollToBottom = false; // Whether the user have seen the more button yet. private boolean everScrolledToBottom = false; private ScrollHandlingDelegate delegate; @Nullable private OnRequireScrollStateChangedListener listener; /** @param templateLayout The template containing this mixin
RequireScrollMixin::RequireScrollMixin
java
Reginer/aosp-android-jar
android-33/src/com/android/setupwizardlib/template/RequireScrollMixin.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/setupwizardlib/template/RequireScrollMixin.java
MIT
public void setScrollHandlingDelegate(@NonNull ScrollHandlingDelegate delegate) { this.delegate = delegate; }
Sets the delegate to handle scrolling. The type of delegate should depend on whether the scrolling view is a BottomScrollView, RecyclerView or ListView.
RequireScrollMixin::setScrollHandlingDelegate
java
Reginer/aosp-android-jar
android-33/src/com/android/setupwizardlib/template/RequireScrollMixin.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/setupwizardlib/template/RequireScrollMixin.java
MIT
public void setOnRequireScrollStateChangedListener( @Nullable OnRequireScrollStateChangedListener listener) { this.listener = listener; }
Listen to require scroll state changes. When scroll is required, {@link OnRequireScrollStateChangedListener#onRequireScrollStateChanged(boolean)} is called with {@code true}, and vice versa.
RequireScrollMixin::setOnRequireScrollStateChangedListener
java
Reginer/aosp-android-jar
android-33/src/com/android/setupwizardlib/template/RequireScrollMixin.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/setupwizardlib/template/RequireScrollMixin.java
MIT
public OnRequireScrollStateChangedListener getOnRequireScrollStateChangedListener() { return listener; }
Listen to require scroll state changes. When scroll is required, {@link OnRequireScrollStateChangedListener#onRequireScrollStateChanged(boolean)} is called with {@code true}, and vice versa. public void setOnRequireScrollStateChangedListener( @Nullable OnRequireScrollStateChangedListener listener) { this.listener = listener; } /** @return The scroll state listener previously set, or {@code null} if none is registered.
RequireScrollMixin::getOnRequireScrollStateChangedListener
java
Reginer/aosp-android-jar
android-33/src/com/android/setupwizardlib/template/RequireScrollMixin.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/setupwizardlib/template/RequireScrollMixin.java
MIT
public OnClickListener createOnClickListener(@Nullable final OnClickListener listener) { return new OnClickListener() { @Override public void onClick(View view) { if (requiringScrollToBottom) { delegate.pageScrollDown(); } else if (listener != null) { listener.onClick(view); } } }; }
Creates an {@link OnClickListener} which if scrolling is required, will scroll the page down, and if scrolling is not required, delegates to the wrapped {@code listener}. Note that you should call {@link #requireScroll()} as well in order to start requiring scrolling. @param listener The listener to be invoked when scrolling is not needed and the user taps on the button. If {@code null}, the click listener will be a no-op when scroll is not required. @return A new {@link OnClickListener} which will scroll the page down or delegate to the given listener depending on the current require-scroll state.
RequireScrollMixin::createOnClickListener
java
Reginer/aosp-android-jar
android-33/src/com/android/setupwizardlib/template/RequireScrollMixin.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/setupwizardlib/template/RequireScrollMixin.java
MIT
public void requireScrollWithNavigationBar(@NonNull final NavigationBar navigationBar) { setOnRequireScrollStateChangedListener( new OnRequireScrollStateChangedListener() { @Override public void onRequireScrollStateChanged(boolean scrollNeeded) { navigationBar.getMoreButton().setVisibility(scrollNeeded ? View.VISIBLE : View.GONE); navigationBar.getNextButton().setVisibility(scrollNeeded ? View.GONE : View.VISIBLE); } }); navigationBar.getMoreButton().setOnClickListener(createOnClickListener(null)); requireScroll(); }
Coordinate with the given navigation bar to require scrolling on the page. The more button will be shown instead of the next button while scrolling is required.
RequireScrollMixin::requireScrollWithNavigationBar
java
Reginer/aosp-android-jar
android-33/src/com/android/setupwizardlib/template/RequireScrollMixin.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/setupwizardlib/template/RequireScrollMixin.java
MIT
public void requireScrollWithButton( @NonNull Button button, @StringRes int moreText, @Nullable OnClickListener onClickListener) { requireScrollWithButton(button, button.getContext().getText(moreText), onClickListener); }
Coordinate with the given navigation bar to require scrolling on the page. The more button will be shown instead of the next button while scrolling is required. public void requireScrollWithNavigationBar(@NonNull final NavigationBar navigationBar) { setOnRequireScrollStateChangedListener( new OnRequireScrollStateChangedListener() { @Override public void onRequireScrollStateChanged(boolean scrollNeeded) { navigationBar.getMoreButton().setVisibility(scrollNeeded ? View.VISIBLE : View.GONE); navigationBar.getNextButton().setVisibility(scrollNeeded ? View.GONE : View.VISIBLE); } }); navigationBar.getMoreButton().setOnClickListener(createOnClickListener(null)); requireScroll(); } /** @see #requireScrollWithButton(Button, CharSequence, OnClickListener)
RequireScrollMixin::requireScrollWithButton
java
Reginer/aosp-android-jar
android-33/src/com/android/setupwizardlib/template/RequireScrollMixin.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/setupwizardlib/template/RequireScrollMixin.java
MIT
public void requireScrollWithButton( @NonNull final Button button, final CharSequence moreText, @Nullable OnClickListener onClickListener) { final CharSequence nextText = button.getText(); button.setOnClickListener(createOnClickListener(onClickListener)); setOnRequireScrollStateChangedListener( new OnRequireScrollStateChangedListener() { @Override public void onRequireScrollStateChanged(boolean scrollNeeded) { button.setText(scrollNeeded ? moreText : nextText); } }); requireScroll(); }
Use the given {@code button} to require scrolling. When scrolling is required, the button label will change to {@code moreText}, and tapping the button will cause the page to scroll down. <p>Note: Calling {@link View#setOnClickListener} on the button after this method will remove its link to the require-scroll mechanism. If you need to do that, obtain the click listener from {@link #createOnClickListener(OnClickListener)}. <p>Note: The normal button label is taken from the button's text at the time of calling this method. Calling {@link android.widget.TextView#setText} after calling this method causes undefined behavior. @param button The button to use for require scroll. The button's "normal" label is taken from the text at the time of calling this method, and the click listener of it will be replaced. @param moreText The button label when scroll is required. @param onClickListener The listener for clicks when scrolling is not required.
RequireScrollMixin::requireScrollWithButton
java
Reginer/aosp-android-jar
android-33/src/com/android/setupwizardlib/template/RequireScrollMixin.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/setupwizardlib/template/RequireScrollMixin.java
MIT
public boolean isScrollingRequired() { return requiringScrollToBottom; }
@return True if scrolling is required. Note that this mixin only requires the user to scroll to the bottom once - if the user scrolled to the bottom and back-up, scrolling to bottom is not required again.
RequireScrollMixin::isScrollingRequired
java
Reginer/aosp-android-jar
android-33/src/com/android/setupwizardlib/template/RequireScrollMixin.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/setupwizardlib/template/RequireScrollMixin.java
MIT
public void requireScroll() { delegate.startListening(); }
Start requiring scrolling on the layout. After calling this method, this mixin will start listening to scroll events from the scrolling container, and call {@link OnRequireScrollStateChangedListener} when the scroll state changes.
RequireScrollMixin::requireScroll
java
Reginer/aosp-android-jar
android-33/src/com/android/setupwizardlib/template/RequireScrollMixin.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/setupwizardlib/template/RequireScrollMixin.java
MIT
void notifyScrollabilityChange(boolean canScrollDown) { if (canScrollDown == requiringScrollToBottom) { // Already at the desired require-scroll state return; } if (canScrollDown) { if (!everScrolledToBottom) { postScrollStateChange(true); requiringScrollToBottom = true; } } else { postScrollStateChange(false); requiringScrollToBottom = false; everScrolledToBottom = true; } }
{@link ScrollHandlingDelegate} should call this method when the scrollability of the scrolling container changed, so this mixin can recompute whether scrolling should be required. @param canScrollDown True if the view can scroll down further.
RequireScrollMixin::notifyScrollabilityChange
java
Reginer/aosp-android-jar
android-33/src/com/android/setupwizardlib/template/RequireScrollMixin.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/setupwizardlib/template/RequireScrollMixin.java
MIT
public static Drawable getManagedUserDrawable(Context context) { return getDrawableForDisplayDensity (context, com.android.internal.R.drawable.ic_corp_user_badge); }
Gets the system default managed-user badge as a drawable. This drawable is tint-able. For badging purpose, consider {@link android.content.pm.PackageManager#getUserBadgedDrawableForDensity(Drawable, UserHandle, Rect, int)}. @param context @return drawable containing just the badge
UserIconDrawable::getManagedUserDrawable
java
Reginer/aosp-android-jar
android-32/src/com/android/settingslib/drawable/UserIconDrawable.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/settingslib/drawable/UserIconDrawable.java
MIT
public static int getSizeForList(Context context) { return (int) context.getResources().getDimension(R.dimen.circle_avatar_size); }
Gets the preferred list-item size of this drawable. @param context @return size in pixels
UserIconDrawable::getSizeForList
java
Reginer/aosp-android-jar
android-32/src/com/android/settingslib/drawable/UserIconDrawable.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/settingslib/drawable/UserIconDrawable.java
MIT
public UserIconDrawable(int intrinsicSize) { super(); mIconPaint.setAntiAlias(true); mIconPaint.setFilterBitmap(true); mPaint.setFilterBitmap(true); mPaint.setAntiAlias(true); if (intrinsicSize > 0) { setBounds(0, 0, intrinsicSize, intrinsicSize); setIntrinsicSize(intrinsicSize); } setIcon(null); }
Use this constructor if the drawable is intended to be placed in listviews @param intrinsicSize if 0, the intrinsic size will come from the icon itself
UserIconDrawable::UserIconDrawable
java
Reginer/aosp-android-jar
android-32/src/com/android/settingslib/drawable/UserIconDrawable.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-32/src/com/android/settingslib/drawable/UserIconDrawable.java
MIT
@NonNull public static Cleaner cleaner() { return CleanerFactory.cleaner(); }
Return a single Cleaner that's shared across the entire process. Thread-safe. Unlike normal Cleaners, uncaught exceptions during cleaning will throw an uncaught exception from the daemon running the cleaning action. This will normally cause the process to crash, and thus cause the problem to be reported.
SystemCleaner::cleaner
java
Reginer/aosp-android-jar
android-35/src/android/system/SystemCleaner.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/system/SystemCleaner.java
MIT
public boolean isEphemeral() { return mEphemeral; }
Returns whether the user is ephemeral. <p> Ephemeral user will be removed after leaving the foreground.
NewUserRequest::isEphemeral
java
Reginer/aosp-android-jar
android-33/src/android/os/NewUserRequest.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/os/NewUserRequest.java
MIT
public boolean isAdmin() { return mAdmin; }
Returns whether the user is an admin. <p> Admin user is with administrative privileges and such user can create and delete users.
NewUserRequest::isAdmin
java
Reginer/aosp-android-jar
android-33/src/android/os/NewUserRequest.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/os/NewUserRequest.java
MIT
int getFlags() { int flags = 0; if (isAdmin()) flags |= UserInfo.FLAG_ADMIN; if (isEphemeral()) flags |= UserInfo.FLAG_EPHEMERAL; return flags; }
Returns the calculated flags for user creation.
NewUserRequest::getFlags
java
Reginer/aosp-android-jar
android-33/src/android/os/NewUserRequest.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/os/NewUserRequest.java
MIT
public DLApplicationSpecific( int tag, byte[] octets) { this(false, tag, octets); }
Create an application specific object from the passed in data. This will assume the data does not represent a constructed object. @param tag the tag number for this object. @param octets the encoding of the object's body.
DLApplicationSpecific::DLApplicationSpecific
java
Reginer/aosp-android-jar
android-34/src/com/android/org/bouncycastle/asn1/DLApplicationSpecific.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/org/bouncycastle/asn1/DLApplicationSpecific.java
MIT
public DLApplicationSpecific( int tag, ASN1Encodable object) throws IOException { this(true, tag, object); }
Create an application specific object with a tagging of explicit/constructed. @param tag the tag number for this object. @param object the object to be contained.
DLApplicationSpecific::DLApplicationSpecific
java
Reginer/aosp-android-jar
android-34/src/com/android/org/bouncycastle/asn1/DLApplicationSpecific.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/org/bouncycastle/asn1/DLApplicationSpecific.java
MIT
public DLApplicationSpecific( boolean constructed, int tag, ASN1Encodable object) throws IOException { super(constructed || object.toASN1Primitive().isConstructed(), tag, getEncoding(constructed, object)); }
Create an application specific object with the tagging style given by the value of constructed. @param constructed true if the object is constructed. @param tag the tag number for this object. @param object the object to be contained.
DLApplicationSpecific::DLApplicationSpecific
java
Reginer/aosp-android-jar
android-34/src/com/android/org/bouncycastle/asn1/DLApplicationSpecific.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/org/bouncycastle/asn1/DLApplicationSpecific.java
MIT
public DLApplicationSpecific(int tagNo, ASN1EncodableVector vec) { super(true, tagNo, getEncodedVector(vec)); }
Create an application specific object which is marked as constructed @param tagNo the tag number for this object. @param vec the objects making up the application specific object.
DLApplicationSpecific::DLApplicationSpecific
java
Reginer/aosp-android-jar
android-34/src/com/android/org/bouncycastle/asn1/DLApplicationSpecific.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/org/bouncycastle/asn1/DLApplicationSpecific.java
MIT
void encode(ASN1OutputStream out, boolean withTag) throws IOException { int flags = BERTags.APPLICATION; if (isConstructed) { flags |= BERTags.CONSTRUCTED; } out.writeEncoded(withTag, flags, tag, octets); }
Create an application specific object which is marked as constructed @param tagNo the tag number for this object. @param vec the objects making up the application specific object. public DLApplicationSpecific(int tagNo, ASN1EncodableVector vec) { super(true, tagNo, getEncodedVector(vec)); } private static byte[] getEncodedVector(ASN1EncodableVector vec) { ByteArrayOutputStream bOut = new ByteArrayOutputStream(); for (int i = 0; i != vec.size(); i++) { try { bOut.write(((ASN1Object)vec.get(i)).getEncoded(ASN1Encoding.DL)); } catch (IOException e) { throw new ASN1ParsingException("malformed object: " + e, e); } } return bOut.toByteArray(); } /* (non-Javadoc) @see org.bouncycastle.asn1.ASN1Primitive#encode(org.bouncycastle.asn1.DEROutputStream)
DLApplicationSpecific::encode
java
Reginer/aosp-android-jar
android-34/src/com/android/org/bouncycastle/asn1/DLApplicationSpecific.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/org/bouncycastle/asn1/DLApplicationSpecific.java
MIT
public static String getDefaultMessage(@AccessError int problem) { switch (problem) { case CAMERA_IN_USE: return "The camera device is in use already"; case MAX_CAMERAS_IN_USE: return "The system-wide limit for number of open cameras has been reached, " + "and more camera devices cannot be opened until previous instances " + "are closed."; case CAMERA_DISCONNECTED: return "The camera device is removable and has been disconnected from the " + "Android device, or the camera service has shut down the connection due " + "to a higher-priority access request for the camera device."; case CAMERA_DISABLED: return "The camera is disabled due to a device policy, and cannot be opened."; case CAMERA_ERROR: return "The camera device is currently in the error state; " + "no further calls to it will succeed."; } return null; }
@hide
CameraAccessException::getDefaultMessage
java
Reginer/aosp-android-jar
android-33/src/android/hardware/camera2/CameraAccessException.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/hardware/camera2/CameraAccessException.java
MIT
AudioVolumeGroup(@NonNull String name, int id, @NonNull AudioAttributes[] audioAttributes, @NonNull int[] legacyStreamTypes) { Preconditions.checkNotNull(name, "name must not be null"); Preconditions.checkNotNull(audioAttributes, "audioAttributes must not be null"); Preconditions.checkNotNull(legacyStreamTypes, "legacyStreamTypes must not be null"); mName = name; mId = id; mAudioAttributes = audioAttributes; mLegacyStreamTypes = legacyStreamTypes; }
@param name of the volume group @param id of the volume group @param legacyStreamTypes of volume group
AudioVolumeGroup::AudioVolumeGroup
java
Reginer/aosp-android-jar
android-33/src/android/media/audiopolicy/AudioVolumeGroup.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/media/audiopolicy/AudioVolumeGroup.java
MIT
public @NonNull List<AudioAttributes> getAudioAttributes() { return Arrays.asList(mAudioAttributes); }
@return List of {@link AudioAttributes} involved in this {@link AudioVolumeGroup}.
AudioVolumeGroup::getAudioAttributes
java
Reginer/aosp-android-jar
android-33/src/android/media/audiopolicy/AudioVolumeGroup.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/media/audiopolicy/AudioVolumeGroup.java
MIT
public @NonNull int[] getLegacyStreamTypes() { return mLegacyStreamTypes; }
@return the stream types involved in this {@link AudioVolumeGroup}.
AudioVolumeGroup::getLegacyStreamTypes
java
Reginer/aosp-android-jar
android-33/src/android/media/audiopolicy/AudioVolumeGroup.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/media/audiopolicy/AudioVolumeGroup.java
MIT
public @NonNull String name() { return mName; }
@return human-readable name of this volume group.
AudioVolumeGroup::name
java
Reginer/aosp-android-jar
android-33/src/android/media/audiopolicy/AudioVolumeGroup.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/media/audiopolicy/AudioVolumeGroup.java
MIT
public int getId() { return mId; }
@return the volume group unique identifier id.
AudioVolumeGroup::getId
java
Reginer/aosp-android-jar
android-33/src/android/media/audiopolicy/AudioVolumeGroup.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/media/audiopolicy/AudioVolumeGroup.java
MIT
default Integer getGravity() { return null; }
Retrieve the Toast view's gravity. If no changes, returns null.
getGravity
java
Reginer/aosp-android-jar
android-34/src/com/android/systemui/plugins/ToastPlugin.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/systemui/plugins/ToastPlugin.java
MIT
default Integer getXOffset() { return null; }
Retrieve the Toast view's X-offset. If no changes, returns null.
getXOffset
java
Reginer/aosp-android-jar
android-34/src/com/android/systemui/plugins/ToastPlugin.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/systemui/plugins/ToastPlugin.java
MIT
default Integer getYOffset() { return null; }
Retrieve the Toast view's Y-offset. If no changes, returns null.
getYOffset
java
Reginer/aosp-android-jar
android-34/src/com/android/systemui/plugins/ToastPlugin.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/systemui/plugins/ToastPlugin.java
MIT
default Integer getHorizontalMargin() { return null; }
Retrieve the Toast view's horizontal margin. If no changes, returns null.
getHorizontalMargin
java
Reginer/aosp-android-jar
android-34/src/com/android/systemui/plugins/ToastPlugin.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/systemui/plugins/ToastPlugin.java
MIT
default Integer getVerticalMargin() { return null; }
Retrieve the Toast view's vertical margin. If no changes, returns null.
getVerticalMargin
java
Reginer/aosp-android-jar
android-34/src/com/android/systemui/plugins/ToastPlugin.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/systemui/plugins/ToastPlugin.java
MIT
default View getView() { return null; }
Retrieve the Toast view to show. If no changes, returns null.
getView
java
Reginer/aosp-android-jar
android-34/src/com/android/systemui/plugins/ToastPlugin.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/systemui/plugins/ToastPlugin.java
MIT
default Animator getInAnimation() { return null; }
Retrieve the Toast's animate in. If no changes, returns null.
getInAnimation
java
Reginer/aosp-android-jar
android-34/src/com/android/systemui/plugins/ToastPlugin.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/systemui/plugins/ToastPlugin.java
MIT
default Animator getOutAnimation() { return null; }
Retrieve the Toast's animate out. If no changes, returns null.
getOutAnimation
java
Reginer/aosp-android-jar
android-34/src/com/android/systemui/plugins/ToastPlugin.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/systemui/plugins/ToastPlugin.java
MIT
default void onOrientationChange(int orientation) { }
Called on orientation changes.
onOrientationChange
java
Reginer/aosp-android-jar
android-34/src/com/android/systemui/plugins/ToastPlugin.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/systemui/plugins/ToastPlugin.java
MIT
public FlingAnimationUtils(DisplayMetrics displayMetrics, float maxLengthSeconds, float speedUpFactor) { this(displayMetrics, maxLengthSeconds, speedUpFactor, -1.0f, 1.0f); }
@param maxLengthSeconds the longest duration an animation can become in seconds @param speedUpFactor a factor from 0 to 1 how much the slow down should be shifted towards the end of the animation. 0 means it's at the beginning and no acceleration will take place.
FlingAnimationUtils::FlingAnimationUtils
java
Reginer/aosp-android-jar
android-31/src/com/android/wm/shell/animation/FlingAnimationUtils.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/wm/shell/animation/FlingAnimationUtils.java
MIT
public FlingAnimationUtils(DisplayMetrics displayMetrics, float maxLengthSeconds, float speedUpFactor, float x2, float y2) { mMaxLengthSeconds = maxLengthSeconds; mSpeedUpFactor = speedUpFactor; if (x2 < 0) { mLinearOutSlowInX2 = interpolate(LINEAR_OUT_SLOW_IN_X2, LINEAR_OUT_SLOW_IN_X2_MAX, mSpeedUpFactor); } else { mLinearOutSlowInX2 = x2; } mY2 = y2; mMinVelocityPxPerSecond = MIN_VELOCITY_DP_PER_SECOND * displayMetrics.density; mHighVelocityPxPerSecond = HIGH_VELOCITY_DP_PER_SECOND * displayMetrics.density; }
@param maxLengthSeconds the longest duration an animation can become in seconds @param speedUpFactor a factor from 0 to 1 how much the slow down should be shifted towards the end of the animation. 0 means it's at the beginning and no acceleration will take place. @param x2 the x value to take for the second point of the bezier spline. If a value below 0 is provided, the value is automatically calculated. @param y2 the y value to take for the second point of the bezier spline
FlingAnimationUtils::FlingAnimationUtils
java
Reginer/aosp-android-jar
android-31/src/com/android/wm/shell/animation/FlingAnimationUtils.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/wm/shell/animation/FlingAnimationUtils.java
MIT
public void apply(Animator animator, float currValue, float endValue, float velocity) { apply(animator, currValue, endValue, velocity, Math.abs(endValue - currValue)); }
Applies the interpolator and length to the animator, such that the fling animation is consistent with the finger motion. @param animator the animator to apply @param currValue the current value @param endValue the end value of the animator @param velocity the current velocity of the motion
FlingAnimationUtils::apply
java
Reginer/aosp-android-jar
android-31/src/com/android/wm/shell/animation/FlingAnimationUtils.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/wm/shell/animation/FlingAnimationUtils.java
MIT
public void apply(ViewPropertyAnimator animator, float currValue, float endValue, float velocity) { apply(animator, currValue, endValue, velocity, Math.abs(endValue - currValue)); }
Applies the interpolator and length to the animator, such that the fling animation is consistent with the finger motion. @param animator the animator to apply @param currValue the current value @param endValue the end value of the animator @param velocity the current velocity of the motion
FlingAnimationUtils::apply
java
Reginer/aosp-android-jar
android-31/src/com/android/wm/shell/animation/FlingAnimationUtils.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/wm/shell/animation/FlingAnimationUtils.java
MIT
public void apply(Animator animator, float currValue, float endValue, float velocity, float maxDistance) { AnimatorProperties properties = getProperties(currValue, endValue, velocity, maxDistance); animator.setDuration(properties.mDuration); animator.setInterpolator(properties.mInterpolator); }
Applies the interpolator and length to the animator, such that the fling animation is consistent with the finger motion. @param animator the animator to apply @param currValue the current value @param endValue the end value of the animator @param velocity the current velocity of the motion @param maxDistance the maximum distance for this interaction; the maximum animation length gets multiplied by the ratio between the actual distance and this value
FlingAnimationUtils::apply
java
Reginer/aosp-android-jar
android-31/src/com/android/wm/shell/animation/FlingAnimationUtils.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/wm/shell/animation/FlingAnimationUtils.java
MIT
public void apply(ViewPropertyAnimator animator, float currValue, float endValue, float velocity, float maxDistance) { AnimatorProperties properties = getProperties(currValue, endValue, velocity, maxDistance); animator.setDuration(properties.mDuration); animator.setInterpolator(properties.mInterpolator); }
Applies the interpolator and length to the animator, such that the fling animation is consistent with the finger motion. @param animator the animator to apply @param currValue the current value @param endValue the end value of the animator @param velocity the current velocity of the motion @param maxDistance the maximum distance for this interaction; the maximum animation length gets multiplied by the ratio between the actual distance and this value
FlingAnimationUtils::apply
java
Reginer/aosp-android-jar
android-31/src/com/android/wm/shell/animation/FlingAnimationUtils.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/wm/shell/animation/FlingAnimationUtils.java
MIT
public void applyDismissing(Animator animator, float currValue, float endValue, float velocity, float maxDistance) { AnimatorProperties properties = getDismissingProperties(currValue, endValue, velocity, maxDistance); animator.setDuration(properties.mDuration); animator.setInterpolator(properties.mInterpolator); }
Applies the interpolator and length to the animator, such that the fling animation is consistent with the finger motion for the case when the animation is making something disappear. @param animator the animator to apply @param currValue the current value @param endValue the end value of the animator @param velocity the current velocity of the motion @param maxDistance the maximum distance for this interaction; the maximum animation length gets multiplied by the ratio between the actual distance and this value
FlingAnimationUtils::applyDismissing
java
Reginer/aosp-android-jar
android-31/src/com/android/wm/shell/animation/FlingAnimationUtils.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/wm/shell/animation/FlingAnimationUtils.java
MIT
public void applyDismissing(ViewPropertyAnimator animator, float currValue, float endValue, float velocity, float maxDistance) { AnimatorProperties properties = getDismissingProperties(currValue, endValue, velocity, maxDistance); animator.setDuration(properties.mDuration); animator.setInterpolator(properties.mInterpolator); }
Applies the interpolator and length to the animator, such that the fling animation is consistent with the finger motion for the case when the animation is making something disappear. @param animator the animator to apply @param currValue the current value @param endValue the end value of the animator @param velocity the current velocity of the motion @param maxDistance the maximum distance for this interaction; the maximum animation length gets multiplied by the ratio between the actual distance and this value
FlingAnimationUtils::applyDismissing
java
Reginer/aosp-android-jar
android-31/src/com/android/wm/shell/animation/FlingAnimationUtils.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/wm/shell/animation/FlingAnimationUtils.java
MIT
private float calculateLinearOutFasterInY2(float velocity) { float t = (velocity - mMinVelocityPxPerSecond) / (mHighVelocityPxPerSecond - mMinVelocityPxPerSecond); t = Math.max(0, Math.min(1, t)); return (1 - t) * LINEAR_OUT_FASTER_IN_Y2_MIN + t * LINEAR_OUT_FASTER_IN_Y2_MAX; }
Calculates the y2 control point for a linear-out-faster-in path interpolator depending on the velocity. The faster the velocity, the more "linear" the interpolator gets. @param velocity the velocity of the gesture. @return the y2 control point for a cubic bezier path interpolator
FlingAnimationUtils::calculateLinearOutFasterInY2
java
Reginer/aosp-android-jar
android-31/src/com/android/wm/shell/animation/FlingAnimationUtils.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/wm/shell/animation/FlingAnimationUtils.java
MIT
public float getMinVelocityPxPerSecond() { return mMinVelocityPxPerSecond; }
@return the minimum velocity a gesture needs to have to be considered a fling
FlingAnimationUtils::getMinVelocityPxPerSecond
java
Reginer/aosp-android-jar
android-31/src/com/android/wm/shell/animation/FlingAnimationUtils.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/wm/shell/animation/FlingAnimationUtils.java
MIT
public float getHighVelocityPxPerSecond() { return mHighVelocityPxPerSecond; }
@return a velocity considered fast
FlingAnimationUtils::getHighVelocityPxPerSecond
java
Reginer/aosp-android-jar
android-31/src/com/android/wm/shell/animation/FlingAnimationUtils.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/wm/shell/animation/FlingAnimationUtils.java
MIT
public Builder setMaxLengthSeconds(float maxLengthSeconds) { mMaxLengthSeconds = maxLengthSeconds; return this; }
An interpolator which interpolates with a fixed velocity. private static final class VelocityInterpolator implements Interpolator { private float mDurationSeconds; private float mVelocity; private float mDiff; private VelocityInterpolator(float durationSeconds, float velocity, float diff) { mDurationSeconds = durationSeconds; mVelocity = velocity; mDiff = diff; } @Override public float getInterpolation(float input) { float time = input * mDurationSeconds; return time * mVelocity / mDiff; } } private static class AnimatorProperties { Interpolator mInterpolator; long mDuration; } /** Builder for {@link #FlingAnimationUtils}. public static class Builder { private final DisplayMetrics mDisplayMetrics; float mMaxLengthSeconds; float mSpeedUpFactor; float mX2; float mY2; @Inject public Builder(DisplayMetrics displayMetrics) { mDisplayMetrics = displayMetrics; reset(); } /** Sets the longest duration an animation can become in seconds.
Builder::setMaxLengthSeconds
java
Reginer/aosp-android-jar
android-31/src/com/android/wm/shell/animation/FlingAnimationUtils.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/wm/shell/animation/FlingAnimationUtils.java
MIT
public Builder setSpeedUpFactor(float speedUpFactor) { mSpeedUpFactor = speedUpFactor; return this; }
Sets the factor for how much the slow down should be shifted towards the end of the animation.
Builder::setSpeedUpFactor
java
Reginer/aosp-android-jar
android-31/src/com/android/wm/shell/animation/FlingAnimationUtils.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/wm/shell/animation/FlingAnimationUtils.java
MIT
public Builder setX2(float x2) { mX2 = x2; return this; }
Sets the factor for how much the slow down should be shifted towards the end of the animation. public Builder setSpeedUpFactor(float speedUpFactor) { mSpeedUpFactor = speedUpFactor; return this; } /** Sets the x value to take for the second point of the bezier spline.
Builder::setX2
java
Reginer/aosp-android-jar
android-31/src/com/android/wm/shell/animation/FlingAnimationUtils.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/wm/shell/animation/FlingAnimationUtils.java
MIT
public Builder setY2(float y2) { mY2 = y2; return this; }
Sets the factor for how much the slow down should be shifted towards the end of the animation. public Builder setSpeedUpFactor(float speedUpFactor) { mSpeedUpFactor = speedUpFactor; return this; } /** Sets the x value to take for the second point of the bezier spline. public Builder setX2(float x2) { mX2 = x2; return this; } /** Sets the y value to take for the second point of the bezier spline.
Builder::setY2
java
Reginer/aosp-android-jar
android-31/src/com/android/wm/shell/animation/FlingAnimationUtils.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/wm/shell/animation/FlingAnimationUtils.java
MIT
public Builder reset() { mMaxLengthSeconds = 0; mSpeedUpFactor = 0.0f; mX2 = -1.0f; mY2 = 1.0f; return this; }
Sets the factor for how much the slow down should be shifted towards the end of the animation. public Builder setSpeedUpFactor(float speedUpFactor) { mSpeedUpFactor = speedUpFactor; return this; } /** Sets the x value to take for the second point of the bezier spline. public Builder setX2(float x2) { mX2 = x2; return this; } /** Sets the y value to take for the second point of the bezier spline. public Builder setY2(float y2) { mY2 = y2; return this; } /** Resets all parameters of the builder.
Builder::reset
java
Reginer/aosp-android-jar
android-31/src/com/android/wm/shell/animation/FlingAnimationUtils.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/wm/shell/animation/FlingAnimationUtils.java
MIT
public FlingAnimationUtils build() { return new FlingAnimationUtils(mDisplayMetrics, mMaxLengthSeconds, mSpeedUpFactor, mX2, mY2); }
Sets the factor for how much the slow down should be shifted towards the end of the animation. public Builder setSpeedUpFactor(float speedUpFactor) { mSpeedUpFactor = speedUpFactor; return this; } /** Sets the x value to take for the second point of the bezier spline. public Builder setX2(float x2) { mX2 = x2; return this; } /** Sets the y value to take for the second point of the bezier spline. public Builder setY2(float y2) { mY2 = y2; return this; } /** Resets all parameters of the builder. public Builder reset() { mMaxLengthSeconds = 0; mSpeedUpFactor = 0.0f; mX2 = -1.0f; mY2 = 1.0f; return this; } /** Builds {@link #FlingAnimationUtils}.
Builder::build
java
Reginer/aosp-android-jar
android-31/src/com/android/wm/shell/animation/FlingAnimationUtils.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/com/android/wm/shell/animation/FlingAnimationUtils.java
MIT
public void init( KeyGenerationParameters param) { this.random = param.getRandom(); this.strength = (param.getStrength() + 7) / 8; }
initialise the key generator. @param param the parameters to be used for key generation
CipherKeyGenerator::init
java
Reginer/aosp-android-jar
android-34/src/com/android/internal/org/bouncycastle/crypto/CipherKeyGenerator.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/internal/org/bouncycastle/crypto/CipherKeyGenerator.java
MIT
public byte[] generateKey() { byte[] key = new byte[strength]; random.nextBytes(key); return key; }
generate a secret key. @return a byte array containing the key value.
CipherKeyGenerator::generateKey
java
Reginer/aosp-android-jar
android-34/src/com/android/internal/org/bouncycastle/crypto/CipherKeyGenerator.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/internal/org/bouncycastle/crypto/CipherKeyGenerator.java
MIT
public void aggregatePowerStats(long startTimeMs, long endTimeMs, Consumer<AggregatedPowerStats> consumer) { synchronized (this) { if (mStats == null) { mStats = new AggregatedPowerStats(mAggregatedPowerStatsConfig); } start(mStats, startTimeMs); boolean clockUpdateAdded = false; long baseTime = startTimeMs > 0 ? startTimeMs : UNINITIALIZED; long lastTime = 0; int lastStates = 0xFFFFFFFF; int lastStates2 = 0xFFFFFFFF; try (BatteryStatsHistoryIterator iterator = mHistory.iterate(startTimeMs, endTimeMs)) { while (iterator.hasNext()) { BatteryStats.HistoryItem item = iterator.next(); if (!clockUpdateAdded) { mStats.addClockUpdate(item.time, item.currentTime); if (baseTime == UNINITIALIZED) { baseTime = item.time; } clockUpdateAdded = true; } else if (item.cmd == BatteryStats.HistoryItem.CMD_CURRENT_TIME || item.cmd == BatteryStats.HistoryItem.CMD_RESET) { mStats.addClockUpdate(item.time, item.currentTime); } lastTime = item.time; int batteryState = (item.states & BatteryStats.HistoryItem.STATE_BATTERY_PLUGGED_FLAG) != 0 ? AggregatedPowerStatsConfig.POWER_STATE_OTHER : AggregatedPowerStatsConfig.POWER_STATE_BATTERY; if (batteryState != mCurrentBatteryState) { mStats.setDeviceState(AggregatedPowerStatsConfig.STATE_POWER, batteryState, item.time); mCurrentBatteryState = batteryState; } int screenState = (item.states & BatteryStats.HistoryItem.STATE_SCREEN_ON_FLAG) != 0 ? AggregatedPowerStatsConfig.SCREEN_STATE_ON : AggregatedPowerStatsConfig.SCREEN_STATE_OTHER; if (screenState != mCurrentScreenState) { mStats.setDeviceState(AggregatedPowerStatsConfig.STATE_SCREEN, screenState, item.time); mCurrentScreenState = screenState; } if ((item.states & BatteryStats.HistoryItem.IMPORTANT_FOR_POWER_STATS_STATES) != lastStates || (item.states2 & BatteryStats.HistoryItem.IMPORTANT_FOR_POWER_STATS_STATES2) != lastStates2) { mStats.noteStateChange(item); lastStates = item.states & BatteryStats.HistoryItem.IMPORTANT_FOR_POWER_STATS_STATES; lastStates2 = item.states2 & BatteryStats.HistoryItem.IMPORTANT_FOR_POWER_STATS_STATES2; } if (item.processStateChange != null) { mStats.setUidState(item.processStateChange.uid, AggregatedPowerStatsConfig.STATE_PROCESS_STATE, item.processStateChange.processState, item.time); } if (item.powerStats != null) { if (!mStats.isCompatible(item.powerStats)) { if (lastTime > baseTime) { mStats.setDuration(lastTime - baseTime); finish(mStats, lastTime); consumer.accept(mStats); } mStats.reset(); mStats.addClockUpdate(item.time, item.currentTime); baseTime = lastTime = item.time; } mStats.addPowerStats(item.powerStats, item.time); } } } if (lastTime > baseTime) { mStats.setDuration(lastTime - baseTime); finish(mStats, lastTime); consumer.accept(mStats); } mStats.reset(); // to free up memory } }
Iterates of the battery history and aggregates power stats between the specified times. The start and end are specified in the battery-stats monotonic time, which is the adjusted elapsed time found in HistoryItem.time. <p> The aggregated stats are sent to the consumer. One aggregation pass may produce multiple sets of aggregated stats if there was an incompatible change that occurred in the middle of the recorded battery history. <p> Note: the AggregatedPowerStats object is reused, so the consumer should fully consume the stats in the <code>accept</code> method and never cache it.
PowerStatsAggregator::aggregatePowerStats
java
Reginer/aosp-android-jar
android-35/src/com/android/server/power/stats/PowerStatsAggregator.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/server/power/stats/PowerStatsAggregator.java
MIT
public void reset() { synchronized (this) { mStats = null; } }
Reset to prepare for a new aggregation session.
PowerStatsAggregator::reset
java
Reginer/aosp-android-jar
android-35/src/com/android/server/power/stats/PowerStatsAggregator.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/server/power/stats/PowerStatsAggregator.java
MIT
public CarrierActionAgent(Phone phone) { mPhone = phone; mPhone.getContext().registerReceiver(mReceiver, new IntentFilter(TelephonyIntents.ACTION_SIM_STATE_CHANGED)); mSettingsObserver = new SettingsObserver(mPhone.getContext(), this); if (DBG) log("Creating CarrierActionAgent"); }
Carrier Action Agent(CAA) paired with {@link com.android.internal.telephony.CarrierSignalAgent CarrierSignalAgent}, serves as an agent to dispatch carrier actions from carrier apps to different telephony modules, {@link android.telephony.TelephonyManager#carrierActionSetRadioEnabled(int, boolean) carrierActionSetRadioEnabled} for example. CAA supports dynamic registration where different telephony modules could listen for a specific carrier action event and implement their own handler. CCA will dispatch the event to all interested parties and maintain the received action states internally for future inspection. Each CarrierActionAgent is associated with a phone object. public class CarrierActionAgent extends Handler { private static final String LOG_TAG = "CarrierActionAgent"; private static final boolean DBG = true; private static final boolean VDBG = Rlog.isLoggable(LOG_TAG, Log.VERBOSE); /** A list of carrier actions public static final int CARRIER_ACTION_SET_METERED_APNS_ENABLED = 0; public static final int CARRIER_ACTION_SET_RADIO_ENABLED = 1; public static final int CARRIER_ACTION_RESET = 2; public static final int CARRIER_ACTION_REPORT_DEFAULT_NETWORK_STATUS = 3; public static final int EVENT_APM_SETTINGS_CHANGED = 4; public static final int EVENT_MOBILE_DATA_SETTINGS_CHANGED = 5; public static final int EVENT_DATA_ROAMING_OFF = 6; public static final int EVENT_SIM_STATE_CHANGED = 7; public static final int EVENT_APN_SETTINGS_CHANGED = 8; /** Member variables private final Phone mPhone; /** registrant list per carrier action private RegistrantList mMeteredApnEnableRegistrants = new RegistrantList(); private RegistrantList mRadioEnableRegistrants = new RegistrantList(); private RegistrantList mDefaultNetworkReportRegistrants = new RegistrantList(); /** local log for carrier actions private LocalLog mMeteredApnEnabledLog = new LocalLog(8); private LocalLog mRadioEnabledLog = new LocalLog(8); private LocalLog mReportDefaultNetworkStatusLog = new LocalLog(8); /** carrier actions private Boolean mCarrierActionOnMeteredApnEnabled = true; private Boolean mCarrierActionOnRadioEnabled = true; private Boolean mCarrierActionReportDefaultNetworkStatus = false; /** content observer for APM change private final SettingsObserver mSettingsObserver; private final BroadcastReceiver mReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { final String action = intent.getAction(); final String iccState = intent.getStringExtra(IccCardConstants.INTENT_KEY_ICC_STATE); if (TelephonyIntents.ACTION_SIM_STATE_CHANGED.equals(action)){ if (intent.getBooleanExtra(Intent.EXTRA_REBROADCAST_ON_UNLOCK, false)) { // ignore rebroadcast since carrier apps are direct boot aware. return; } sendMessage(obtainMessage(EVENT_SIM_STATE_CHANGED, iccState)); } } }; /** Constructor
CarrierActionAgent::CarrierActionAgent
java
Reginer/aosp-android-jar
android-33/src/com/android/internal/telephony/CarrierActionAgent.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/internal/telephony/CarrierActionAgent.java
MIT
public void carrierActionSetRadioEnabled(boolean enabled) { sendMessage(obtainMessage(CARRIER_ACTION_SET_RADIO_ENABLED, enabled)); }
Action set from carrier app to enable/disable radio
CarrierActionAgent::carrierActionSetRadioEnabled
java
Reginer/aosp-android-jar
android-33/src/com/android/internal/telephony/CarrierActionAgent.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/internal/telephony/CarrierActionAgent.java
MIT
public void carrierActionSetMeteredApnsEnabled(boolean enabled) { sendMessage(obtainMessage(CARRIER_ACTION_SET_METERED_APNS_ENABLED, enabled)); }
Action set from carrier app to enable/disable metered APNs
CarrierActionAgent::carrierActionSetMeteredApnsEnabled
java
Reginer/aosp-android-jar
android-33/src/com/android/internal/telephony/CarrierActionAgent.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/internal/telephony/CarrierActionAgent.java
MIT
public void carrierActionReportDefaultNetworkStatus(boolean report) { sendMessage(obtainMessage(CARRIER_ACTION_REPORT_DEFAULT_NETWORK_STATUS, report)); }
Action set from carrier app to start/stop reporting default network status.
CarrierActionAgent::carrierActionReportDefaultNetworkStatus
java
Reginer/aosp-android-jar
android-33/src/com/android/internal/telephony/CarrierActionAgent.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/internal/telephony/CarrierActionAgent.java
MIT
public void registerForCarrierAction(int action, Handler h, int what, Object obj, boolean notifyNow) { Boolean carrierAction = getCarrierActionEnabled(action); if (carrierAction == null) { throw new IllegalArgumentException("invalid carrier action: " + action); } RegistrantList list = getRegistrantsFromAction(action); Registrant r = new Registrant(h, what, obj); list.add(r); if (notifyNow) { r.notifyRegistrant(new AsyncResult(null, carrierAction, null)); } }
Register with CAA for a specific event. @param action which carrier action registrant is interested in @param notifyNow if carrier action has once set, notify registrant right after registering, so that registrants will get the latest carrier action.
CarrierActionAgent::registerForCarrierAction
java
Reginer/aosp-android-jar
android-33/src/com/android/internal/telephony/CarrierActionAgent.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/internal/telephony/CarrierActionAgent.java
MIT
public void unregisterForCarrierAction(Handler h, int action) { RegistrantList list = getRegistrantsFromAction(action); if (list == null) { throw new IllegalArgumentException("invalid carrier action: " + action); } list.remove(h); }
Unregister with CAA for a specific event. Callers will no longer be notified upon such event. @param action which carrier action caller is no longer interested in
CarrierActionAgent::unregisterForCarrierAction
java
Reginer/aosp-android-jar
android-33/src/com/android/internal/telephony/CarrierActionAgent.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/internal/telephony/CarrierActionAgent.java
MIT
public SurroundingText(@NonNull final CharSequence text, @IntRange(from = 0) int selectionStart, @IntRange(from = 0) int selectionEnd, @IntRange(from = -1) int offset) { mText = copyWithParcelableSpans(text); mSelectionStart = selectionStart; mSelectionEnd = selectionEnd; mOffset = offset; }
Constructor. @param text The surrounding text. @param selectionStart The text offset of the start of the selection in the surrounding text. Reversed selection is allowed. @param selectionEnd The text offset of the end of the selection in the surrounding text. Reversed selection is allowed. @param offset The text offset between the start of the editor's text and the start of the surrounding text. -1 indicates the offset is unknown.
SurroundingText::SurroundingText
java
Reginer/aosp-android-jar
android-33/src/android/view/inputmethod/SurroundingText.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/view/inputmethod/SurroundingText.java
MIT
private void handleContactDeletedCase(Context context, long timeStamp) { String selection = ""; if (timeStamp != -1) { selection = ContactsContract.DeletedContacts.CONTACT_DELETED_TIMESTAMP + ">" + timeStamp; } Cursor cursor = context.getContentResolver().query( ContactsContract.DeletedContacts.CONTENT_URI, new String[]{ContactsContract.DeletedContacts.CONTACT_ID, ContactsContract.DeletedContacts.CONTACT_DELETED_TIMESTAMP}, selection, null, null); if (cursor == null) { Log.d(TAG, "handleContactDeletedCase() cursor is null."); return; } Log.d(TAG, "(Case 1) The count of contact that need to be deleted: " + cursor.getCount()); StringBuilder deleteClause = new StringBuilder(); while (cursor.moveToNext()) { if (deleteClause.length() > 0) { deleteClause.append(" OR "); } String contactId = cursor.getString(cursor.getColumnIndex( ContactsContract.DeletedContacts.CONTACT_ID)); deleteClause.append(EabProvider.ContactColumns.CONTACT_ID + "=" + contactId); } if (deleteClause.toString().length() > 0) { int number = context.getContentResolver().delete( EabProvider.CONTACT_URI, deleteClause.toString(), null); Log.d(TAG, "(Case 1) Deleted contact count=" + number); } }
Delete the phone numbers that contact has been deleted in contact provider. Query based on {@link ContactsContract.DeletedContacts#CONTENT_URI} to know which contact has been removed. @param timeStamp last updated timestamp
EabContactSyncController::handleContactDeletedCase
java
Reginer/aosp-android-jar
android-34/src/com/android/ims/rcs/uce/eab/EabContactSyncController.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/ims/rcs/uce/eab/EabContactSyncController.java
MIT
private void handlePhoneNumberDeletedCase(Context context, Cursor cursor) { // The map represent which contacts have which numbers. Map<String, List<String>> phoneNumberMap = new HashMap<>(); cursor.moveToPosition(-1); while (cursor.moveToNext()) { String mimeType = cursor.getString( cursor.getColumnIndex(ContactsContract.Data.MIMETYPE)); if (!mimeType.equals(ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE)) { continue; } String rawContactId = cursor.getString( cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.RAW_CONTACT_ID)); String number = formatNumber(context, cursor.getString( cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER))); if (phoneNumberMap.containsKey(rawContactId)) { phoneNumberMap.get(rawContactId).add(number); } else { List<String> phoneNumberList = new ArrayList<>(); phoneNumberList.add(number); phoneNumberMap.put(rawContactId, phoneNumberList); } } // Build a SQL statement that delete the phone number not exist in contact provider. // For example: // raw_contact_id = 1 AND phone_number NOT IN (12345, 23456) StringBuilder deleteClause = new StringBuilder(); List<String> deleteClauseArgs = new ArrayList<>(); for (Map.Entry<String, List<String>> entry : phoneNumberMap.entrySet()) { String rawContactId = entry.getKey(); List<String> phoneNumberList = entry.getValue(); if (deleteClause.length() > 0) { deleteClause.append(" OR "); } deleteClause.append("(" + EabProvider.ContactColumns.RAW_CONTACT_ID + "=? "); deleteClauseArgs.add(rawContactId); if (phoneNumberList.size() > 0) { String argsList = phoneNumberList.stream() .map(s -> "?") .collect(Collectors.joining(", ")); deleteClause.append(" AND " + EabProvider.ContactColumns.PHONE_NUMBER + " NOT IN (" + argsList + "))"); deleteClauseArgs.addAll(phoneNumberList); } else { deleteClause.append(")"); } } int number = context.getContentResolver().delete( EabProvider.CONTACT_URI, deleteClause.toString(), deleteClauseArgs.toArray(new String[0])); Log.d(TAG, "(Case 2, 3) handlePhoneNumberDeletedCase number count= " + number); }
Delete phone numbers that have been deleted in the contact provider. There is no API to get deleted phone numbers easily, so check all updated contact's phone number and delete the phone number. It will also delete the phone number that has been changed.
EabContactSyncController::handlePhoneNumberDeletedCase
java
Reginer/aosp-android-jar
android-34/src/com/android/ims/rcs/uce/eab/EabContactSyncController.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/ims/rcs/uce/eab/EabContactSyncController.java
MIT
private List<Uri> handlePhoneNumberInsertedCase(Context context, Cursor contactCursor) { List<Uri> refreshContacts = new ArrayList<>(); List<ContentValues> allContactData = new ArrayList<>(); contactCursor.moveToPosition(-1); // Query all of contacts that store in eab provider Cursor eabContact = context.getContentResolver().query( EabProvider.CONTACT_URI, null, EabProvider.ContactColumns.DATA_ID + " IS NOT NULL", null, EabProvider.ContactColumns.DATA_ID); while (contactCursor.moveToNext()) { String contactId = contactCursor.getString(contactCursor.getColumnIndex( ContactsContract.Data.CONTACT_ID)); String rawContactId = contactCursor.getString(contactCursor.getColumnIndex( ContactsContract.CommonDataKinds.Phone.RAW_CONTACT_ID)); String dataId = contactCursor.getString( contactCursor.getColumnIndex(ContactsContract.Data._ID)); String mimeType = contactCursor.getString( contactCursor.getColumnIndex(ContactsContract.Data.MIMETYPE)); if (!mimeType.equals(ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE)) { continue; } String number = formatNumber(context, contactCursor.getString( contactCursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER))); int index = searchDataIdIndex(eabContact, Integer.parseInt(dataId)); if (index == -1) { Log.d(TAG, "Data id does not exist. Insert phone number into EAB db."); refreshContacts.add(Uri.parse(number)); ContentValues data = new ContentValues(); data.put(EabProvider.ContactColumns.CONTACT_ID, contactId); data.put(EabProvider.ContactColumns.DATA_ID, dataId); data.put(EabProvider.ContactColumns.RAW_CONTACT_ID, rawContactId); data.put(EabProvider.ContactColumns.PHONE_NUMBER, number); allContactData.add(data); } } // Insert contacts at once int result = context.getContentResolver().bulkInsert( EabProvider.CONTACT_URI, allContactData.toArray(new ContentValues[0])); Log.d(TAG, "(Case 3, 4) Phone number insert count: " + result); return refreshContacts; }
Insert new phone number. @param contactCursor the result of updated contact @return the contacts that need to refresh
EabContactSyncController::handlePhoneNumberInsertedCase
java
Reginer/aosp-android-jar
android-34/src/com/android/ims/rcs/uce/eab/EabContactSyncController.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/ims/rcs/uce/eab/EabContactSyncController.java
MIT
private int searchDataIdIndex(Cursor cursor, int targetDataId) { int start = 0; int end = cursor.getCount() - 1; while (start <= end) { int position = (start + end) >>> 1; cursor.moveToPosition(position); int dataId = cursor.getInt(cursor.getColumnIndex(EabProvider.ContactColumns.DATA_ID)); if (dataId > targetDataId) { end = position - 1; } else if (dataId < targetDataId) { start = position + 1; } else { return position; } } return -1; }
Binary search the target data_id in the cursor. @param cursor EabProvider contact which sorted by {@link EabProvider.ContactColumns#DATA_ID} @param targetDataId the data_id to search for @return the index of cursor
EabContactSyncController::searchDataIdIndex
java
Reginer/aosp-android-jar
android-34/src/com/android/ims/rcs/uce/eab/EabContactSyncController.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/ims/rcs/uce/eab/EabContactSyncController.java
MIT