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 String getTargetURI() { return "http://www.w3.org/2001/DOM-Test-Suite/level2/core/internalSubset01"; }
Gets URI that identifies the test. @return uri identifier of test
internalSubset01::getTargetURI
java
Reginer/aosp-android-jar
android-34/src/org/w3c/domts/level2/core/internalSubset01.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/w3c/domts/level2/core/internalSubset01.java
MIT
public static void main(final String[] args) { DOMTestCase.doMain(internalSubset01.class, args); }
Runs this test from the command line. @param args command line arguments
internalSubset01::main
java
Reginer/aosp-android-jar
android-34/src/org/w3c/domts/level2/core/internalSubset01.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/w3c/domts/level2/core/internalSubset01.java
MIT
static Pair<ByteBuffer, Long> findZipEndOfCentralDirectoryRecord(RandomAccessFile zip) throws IOException { // ZIP End of Central Directory (EOCD) record is located at the very end of the ZIP archive. // The record can be identified by its 4-byte signature/magic which is located at the very // beginning of the record. A complication is that the record is variable-length because of // the comment field. // The algorithm for locating the ZIP EOCD record is as follows. We search backwards from // end of the buffer for the EOCD record signature. Whenever we find a signature, we check // the candidate record's comment length is such that the remainder of the record takes up // exactly the remaining bytes in the buffer. The search is bounded because the maximum // size of the comment field is 65535 bytes because the field is an unsigned 16-bit number. // TODO(b/193592496) RandomAccessFile#length long fileSize = zip.getChannel().size(); if (fileSize < ZIP_EOCD_REC_MIN_SIZE) { return null; } // Optimization: 99.99% of APKs have a zero-length comment field in the EoCD record and thus // the EoCD record offset is known in advance. Try that offset first to avoid unnecessarily // reading more data. Pair<ByteBuffer, Long> result = findZipEndOfCentralDirectoryRecord(zip, 0); if (result != null) { return result; } // EoCD does not start where we expected it to. Perhaps it contains a non-empty comment // field. Expand the search. The maximum size of the comment field in EoCD is 65535 because // the comment length field is an unsigned 16-bit number. return findZipEndOfCentralDirectoryRecord(zip, UINT16_MAX_VALUE); }
Returns the ZIP End of Central Directory record of the provided ZIP file. @return contents of the ZIP End of Central Directory record and the record's offset in the file or {@code null} if the file does not contain the record. @throws IOException if an I/O error occurs while reading the file.
ZipUtils::findZipEndOfCentralDirectoryRecord
java
Reginer/aosp-android-jar
android-33/src/android/util/apk/ZipUtils.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/util/apk/ZipUtils.java
MIT
private static Pair<ByteBuffer, Long> findZipEndOfCentralDirectoryRecord( RandomAccessFile zip, int maxCommentSize) throws IOException { // ZIP End of Central Directory (EOCD) record is located at the very end of the ZIP archive. // The record can be identified by its 4-byte signature/magic which is located at the very // beginning of the record. A complication is that the record is variable-length because of // the comment field. // The algorithm for locating the ZIP EOCD record is as follows. We search backwards from // end of the buffer for the EOCD record signature. Whenever we find a signature, we check // the candidate record's comment length is such that the remainder of the record takes up // exactly the remaining bytes in the buffer. The search is bounded because the maximum // size of the comment field is 65535 bytes because the field is an unsigned 16-bit number. if ((maxCommentSize < 0) || (maxCommentSize > UINT16_MAX_VALUE)) { throw new IllegalArgumentException("maxCommentSize: " + maxCommentSize); } // TODO(b/193592496) RandomAccessFile#length long fileSize = zip.getChannel().size(); if (fileSize < ZIP_EOCD_REC_MIN_SIZE) { // No space for EoCD record in the file. return null; } // Lower maxCommentSize if the file is too small. maxCommentSize = (int) Math.min(maxCommentSize, fileSize - ZIP_EOCD_REC_MIN_SIZE); ByteBuffer buf = ByteBuffer.allocate(ZIP_EOCD_REC_MIN_SIZE + maxCommentSize); buf.order(ByteOrder.LITTLE_ENDIAN); long bufOffsetInFile = fileSize - buf.capacity(); zip.seek(bufOffsetInFile); zip.readFully(buf.array(), buf.arrayOffset(), buf.capacity()); int eocdOffsetInBuf = findZipEndOfCentralDirectoryRecord(buf); if (eocdOffsetInBuf == -1) { // No EoCD record found in the buffer return null; } // EoCD found buf.position(eocdOffsetInBuf); ByteBuffer eocd = buf.slice(); eocd.order(ByteOrder.LITTLE_ENDIAN); return Pair.create(eocd, bufOffsetInFile + eocdOffsetInBuf); }
Returns the ZIP End of Central Directory record of the provided ZIP file. @param maxCommentSize maximum accepted size (in bytes) of EoCD comment field. The permitted value is from 0 to 65535 inclusive. The smaller the value, the faster this method locates the record, provided its comment field is no longer than this value. @return contents of the ZIP End of Central Directory record and the record's offset in the file or {@code null} if the file does not contain the record. @throws IOException if an I/O error occurs while reading the file.
ZipUtils::findZipEndOfCentralDirectoryRecord
java
Reginer/aosp-android-jar
android-33/src/android/util/apk/ZipUtils.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/util/apk/ZipUtils.java
MIT
private static int findZipEndOfCentralDirectoryRecord(ByteBuffer zipContents) { assertByteOrderLittleEndian(zipContents); // ZIP End of Central Directory (EOCD) record is located at the very end of the ZIP archive. // The record can be identified by its 4-byte signature/magic which is located at the very // beginning of the record. A complication is that the record is variable-length because of // the comment field. // The algorithm for locating the ZIP EOCD record is as follows. We search backwards from // end of the buffer for the EOCD record signature. Whenever we find a signature, we check // the candidate record's comment length is such that the remainder of the record takes up // exactly the remaining bytes in the buffer. The search is bounded because the maximum // size of the comment field is 65535 bytes because the field is an unsigned 16-bit number. int archiveSize = zipContents.capacity(); if (archiveSize < ZIP_EOCD_REC_MIN_SIZE) { return -1; } int maxCommentLength = Math.min(archiveSize - ZIP_EOCD_REC_MIN_SIZE, UINT16_MAX_VALUE); int eocdWithEmptyCommentStartPosition = archiveSize - ZIP_EOCD_REC_MIN_SIZE; for (int expectedCommentLength = 0; expectedCommentLength <= maxCommentLength; expectedCommentLength++) { int eocdStartPos = eocdWithEmptyCommentStartPosition - expectedCommentLength; if (zipContents.getInt(eocdStartPos) == ZIP_EOCD_REC_SIG) { int actualCommentLength = getUnsignedInt16( zipContents, eocdStartPos + ZIP_EOCD_COMMENT_LENGTH_FIELD_OFFSET); if (actualCommentLength == expectedCommentLength) { return eocdStartPos; } } } return -1; }
Returns the position at which ZIP End of Central Directory record starts in the provided buffer or {@code -1} if the record is not present. <p>NOTE: Byte order of {@code zipContents} must be little-endian.
ZipUtils::findZipEndOfCentralDirectoryRecord
java
Reginer/aosp-android-jar
android-33/src/android/util/apk/ZipUtils.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/util/apk/ZipUtils.java
MIT
public static final boolean isZip64EndOfCentralDirectoryLocatorPresent( RandomAccessFile zip, long zipEndOfCentralDirectoryPosition) throws IOException { // ZIP64 End of Central Directory Locator immediately precedes the ZIP End of Central // Directory Record. long locatorPosition = zipEndOfCentralDirectoryPosition - ZIP64_EOCD_LOCATOR_SIZE; if (locatorPosition < 0) { return false; } zip.seek(locatorPosition); // RandomAccessFile.readInt assumes big-endian byte order, but ZIP format uses // little-endian. return zip.readInt() == ZIP64_EOCD_LOCATOR_SIG_REVERSE_BYTE_ORDER; }
Returns {@code true} if the provided file contains a ZIP64 End of Central Directory Locator. @param zipEndOfCentralDirectoryPosition offset of the ZIP End of Central Directory record in the file. @throws IOException if an I/O error occurs while reading the file.
ZipUtils::isZip64EndOfCentralDirectoryLocatorPresent
java
Reginer/aosp-android-jar
android-33/src/android/util/apk/ZipUtils.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/util/apk/ZipUtils.java
MIT
public static long getZipEocdCentralDirectoryOffset(ByteBuffer zipEndOfCentralDirectory) { assertByteOrderLittleEndian(zipEndOfCentralDirectory); return getUnsignedInt32( zipEndOfCentralDirectory, zipEndOfCentralDirectory.position() + ZIP_EOCD_CENTRAL_DIR_OFFSET_FIELD_OFFSET); }
Returns the offset of the start of the ZIP Central Directory in the archive. <p>NOTE: Byte order of {@code zipEndOfCentralDirectory} must be little-endian.
ZipUtils::getZipEocdCentralDirectoryOffset
java
Reginer/aosp-android-jar
android-33/src/android/util/apk/ZipUtils.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/util/apk/ZipUtils.java
MIT
public static void setZipEocdCentralDirectoryOffset( ByteBuffer zipEndOfCentralDirectory, long offset) { assertByteOrderLittleEndian(zipEndOfCentralDirectory); setUnsignedInt32( zipEndOfCentralDirectory, zipEndOfCentralDirectory.position() + ZIP_EOCD_CENTRAL_DIR_OFFSET_FIELD_OFFSET, offset); }
Sets the offset of the start of the ZIP Central Directory in the archive. <p>NOTE: Byte order of {@code zipEndOfCentralDirectory} must be little-endian.
ZipUtils::setZipEocdCentralDirectoryOffset
java
Reginer/aosp-android-jar
android-33/src/android/util/apk/ZipUtils.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/util/apk/ZipUtils.java
MIT
public static long getZipEocdCentralDirectorySizeBytes(ByteBuffer zipEndOfCentralDirectory) { assertByteOrderLittleEndian(zipEndOfCentralDirectory); return getUnsignedInt32( zipEndOfCentralDirectory, zipEndOfCentralDirectory.position() + ZIP_EOCD_CENTRAL_DIR_SIZE_FIELD_OFFSET); }
Returns the size (in bytes) of the ZIP Central Directory. <p>NOTE: Byte order of {@code zipEndOfCentralDirectory} must be little-endian.
ZipUtils::getZipEocdCentralDirectorySizeBytes
java
Reginer/aosp-android-jar
android-33/src/android/util/apk/ZipUtils.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/util/apk/ZipUtils.java
MIT
private NotificationHistory(Parcel in) { byte[] bytes = in.readBlob(); Parcel data = Parcel.obtain(); data.unmarshall(bytes, 0, bytes.length); data.setDataPosition(0); mHistoryCount = data.readInt(); mIndex = data.readInt(); if (mHistoryCount > 0) { mStringPool = data.createStringArray(); final int listByteLength = data.readInt(); final int positionInParcel = data.readInt(); mParcel = Parcel.obtain(); mParcel.setDataPosition(0); mParcel.appendFrom(data, data.dataPosition(), listByteLength); mParcel.setDataSize(mParcel.dataPosition()); mParcel.setDataPosition(positionInParcel); } }
Construct the iterator from a parcel.
HistoricalNotification::NotificationHistory
java
Reginer/aosp-android-jar
android-33/src/android/app/NotificationHistory.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/app/NotificationHistory.java
MIT
public NotificationHistory() { mHistoryCount = 0; }
Create an empty iterator.
HistoricalNotification::NotificationHistory
java
Reginer/aosp-android-jar
android-33/src/android/app/NotificationHistory.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/app/NotificationHistory.java
MIT
public boolean hasNextNotification() { return mIndex < mHistoryCount; }
Returns whether or not there are more events to read using {@link #getNextNotification()}. @return true if there are more events, false otherwise.
HistoricalNotification::hasNextNotification
java
Reginer/aosp-android-jar
android-33/src/android/app/NotificationHistory.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/app/NotificationHistory.java
MIT
public @Nullable HistoricalNotification getNextNotification() { if (!hasNextNotification()) { return null; } HistoricalNotification n = readNotificationFromParcel(mParcel); mIndex++; if (!hasNextNotification()) { mParcel.recycle(); mParcel = null; } return n; }
Retrieve the next {@link HistoricalNotification} from the collection and put the resulting data into {@code notificationOut}. @return The next {@link HistoricalNotification} or null if there are no more notifications.
HistoricalNotification::getNextNotification
java
Reginer/aosp-android-jar
android-33/src/android/app/NotificationHistory.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/app/NotificationHistory.java
MIT
public void addPooledStrings(@NonNull List<String> strings) { mStringsToWrite.addAll(strings); }
Adds all of the pooled strings that have been read from disk
HistoricalNotification::addPooledStrings
java
Reginer/aosp-android-jar
android-33/src/android/app/NotificationHistory.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/app/NotificationHistory.java
MIT
public void poolStringsFromNotifications() { mStringsToWrite.clear(); for (int i = 0; i < mNotificationsToWrite.size(); i++) { final HistoricalNotification notification = mNotificationsToWrite.get(i); mStringsToWrite.add(notification.getPackage()); mStringsToWrite.add(notification.getChannelName()); mStringsToWrite.add(notification.getChannelId()); if (!TextUtils.isEmpty(notification.getConversationId())) { mStringsToWrite.add(notification.getConversationId()); } } }
Builds the pooled strings from pending notifications. Useful if the pooled strings on disk contains strings that aren't relevant to the notifications in our collection.
HistoricalNotification::poolStringsFromNotifications
java
Reginer/aosp-android-jar
android-33/src/android/app/NotificationHistory.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/app/NotificationHistory.java
MIT
public void addNotificationToWrite(@NonNull HistoricalNotification notification) { if (notification == null) { return; } mNotificationsToWrite.add(notification); mHistoryCount++; }
Used when populating a history from disk; adds an historical notification.
HistoricalNotification::addNotificationToWrite
java
Reginer/aosp-android-jar
android-33/src/android/app/NotificationHistory.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/app/NotificationHistory.java
MIT
public void addNewNotificationToWrite(@NonNull HistoricalNotification notification) { if (notification == null) { return; } mNotificationsToWrite.add(0, notification); mHistoryCount++; }
Used when populating a history from disk; adds an historical notification.
HistoricalNotification::addNewNotificationToWrite
java
Reginer/aosp-android-jar
android-33/src/android/app/NotificationHistory.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/app/NotificationHistory.java
MIT
public void removeNotificationsFromWrite(String packageName) { for (int i = mNotificationsToWrite.size() - 1; i >= 0; i--) { if (packageName.equals(mNotificationsToWrite.get(i).getPackage())) { mNotificationsToWrite.remove(i); } } poolStringsFromNotifications(); }
Removes a package's historical notifications and regenerates the string pool
HistoricalNotification::removeNotificationsFromWrite
java
Reginer/aosp-android-jar
android-33/src/android/app/NotificationHistory.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/app/NotificationHistory.java
MIT
public boolean removeNotificationFromWrite(String packageName, long postedTime) { boolean removed = false; for (int i = mNotificationsToWrite.size() - 1; i >= 0; i--) { HistoricalNotification hn = mNotificationsToWrite.get(i); if (packageName.equals(hn.getPackage()) && postedTime == hn.getPostedTimeMs()) { removed = true; mNotificationsToWrite.remove(i); } } if (removed) { poolStringsFromNotifications(); } return removed; }
Removes an individual historical notification and regenerates the string pool
HistoricalNotification::removeNotificationFromWrite
java
Reginer/aosp-android-jar
android-33/src/android/app/NotificationHistory.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/app/NotificationHistory.java
MIT
public boolean removeConversationsFromWrite(String packageName, Set<String> conversationIds) { boolean removed = false; for (int i = mNotificationsToWrite.size() - 1; i >= 0; i--) { HistoricalNotification hn = mNotificationsToWrite.get(i); if (packageName.equals(hn.getPackage()) && hn.getConversationId() != null && conversationIds.contains(hn.getConversationId())) { removed = true; mNotificationsToWrite.remove(i); } } if (removed) { poolStringsFromNotifications(); } return removed; }
Removes all notifications from a conversation and regenerates the string pool
HistoricalNotification::removeConversationsFromWrite
java
Reginer/aosp-android-jar
android-33/src/android/app/NotificationHistory.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/app/NotificationHistory.java
MIT
public boolean removeChannelFromWrite(String packageName, String channelId) { boolean removed = false; for (int i = mNotificationsToWrite.size() - 1; i >= 0; i--) { HistoricalNotification hn = mNotificationsToWrite.get(i); if (packageName.equals(hn.getPackage()) && Objects.equals(channelId, hn.getChannelId())) { removed = true; mNotificationsToWrite.remove(i); } } if (removed) { poolStringsFromNotifications(); } return removed; }
Removes all notifications from a channel and regenerates the string pool
HistoricalNotification::removeChannelFromWrite
java
Reginer/aosp-android-jar
android-33/src/android/app/NotificationHistory.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/app/NotificationHistory.java
MIT
public @NonNull String[] getPooledStringsToWrite() { String[] stringsToWrite = mStringsToWrite.toArray(new String[]{}); Arrays.sort(stringsToWrite); return stringsToWrite; }
Gets pooled strings in order to write them to disk
HistoricalNotification::getPooledStringsToWrite
java
Reginer/aosp-android-jar
android-33/src/android/app/NotificationHistory.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/app/NotificationHistory.java
MIT
public @NonNull List<HistoricalNotification> getNotificationsToWrite() { return mNotificationsToWrite; }
Gets the historical notifications in order to write them to disk
HistoricalNotification::getNotificationsToWrite
java
Reginer/aosp-android-jar
android-33/src/android/app/NotificationHistory.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/app/NotificationHistory.java
MIT
public int getHistoryCount() { return mHistoryCount; }
Gets the number of notifications in the collection
HistoricalNotification::getHistoryCount
java
Reginer/aosp-android-jar
android-33/src/android/app/NotificationHistory.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/app/NotificationHistory.java
MIT
private void writeNotificationToParcel(HistoricalNotification notification, Parcel p, int flags) { final int packageIndex; if (notification.mPackage != null) { packageIndex = findStringIndex(notification.mPackage); } else { packageIndex = -1; } final int channelNameIndex; if (notification.getChannelName() != null) { channelNameIndex = findStringIndex(notification.getChannelName()); } else { channelNameIndex = -1; } final int channelIdIndex; if (notification.getChannelId() != null) { channelIdIndex = findStringIndex(notification.getChannelId()); } else { channelIdIndex = -1; } final int conversationIdIndex; if (!TextUtils.isEmpty(notification.getConversationId())) { conversationIdIndex = findStringIndex(notification.getConversationId()); } else { conversationIdIndex = -1; } p.writeInt(packageIndex); p.writeInt(channelNameIndex); p.writeInt(channelIdIndex); p.writeInt(conversationIdIndex); p.writeInt(notification.getUid()); p.writeInt(notification.getUserId()); p.writeLong(notification.getPostedTimeMs()); p.writeString(notification.getTitle()); p.writeString(notification.getText()); p.writeBoolean(false); // The current design does not display icons, so don't bother adding them to the parcel //if (notification.getIcon() != null) { // notification.getIcon().writeToParcel(p, flags); //} }
Writes a single notification to the parcel. Modify this when updating member variables of {@link HistoricalNotification}.
HistoricalNotification::writeNotificationToParcel
java
Reginer/aosp-android-jar
android-33/src/android/app/NotificationHistory.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/app/NotificationHistory.java
MIT
private HistoricalNotification readNotificationFromParcel(Parcel p) { HistoricalNotification.Builder notificationOut = new HistoricalNotification.Builder(); final int packageIndex = p.readInt(); if (packageIndex >= 0) { notificationOut.mPackage = mStringPool[packageIndex]; } else { notificationOut.mPackage = null; } final int channelNameIndex = p.readInt(); if (channelNameIndex >= 0) { notificationOut.setChannelName(mStringPool[channelNameIndex]); } else { notificationOut.setChannelName(null); } final int channelIdIndex = p.readInt(); if (channelIdIndex >= 0) { notificationOut.setChannelId(mStringPool[channelIdIndex]); } else { notificationOut.setChannelId(null); } final int conversationIdIndex = p.readInt(); if (conversationIdIndex >= 0) { notificationOut.setConversationId(mStringPool[conversationIdIndex]); } else { notificationOut.setConversationId(null); } notificationOut.setUid(p.readInt()); notificationOut.setUserId(p.readInt()); notificationOut.setPostedTimeMs(p.readLong()); notificationOut.setTitle(p.readString()); notificationOut.setText(p.readString()); if (p.readBoolean()) { notificationOut.setIcon(Icon.CREATOR.createFromParcel(p)); } return notificationOut.build(); }
Reads a single notification from the parcel. Modify this when updating member variables of {@link HistoricalNotification}.
HistoricalNotification::readNotificationFromParcel
java
Reginer/aosp-android-jar
android-33/src/android/app/NotificationHistory.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/app/NotificationHistory.java
MIT
public WrongMethodTypeException() { super(); }
Constructs a {@code WrongMethodTypeException} with no detail message.
WrongMethodTypeException::WrongMethodTypeException
java
Reginer/aosp-android-jar
android-31/src/java/lang/invoke/WrongMethodTypeException.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/java/lang/invoke/WrongMethodTypeException.java
MIT
public WrongMethodTypeException(String s) { super(s); }
Constructs a {@code WrongMethodTypeException} with the specified detail message. @param s the detail message.
WrongMethodTypeException::WrongMethodTypeException
java
Reginer/aosp-android-jar
android-31/src/java/lang/invoke/WrongMethodTypeException.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-31/src/java/lang/invoke/WrongMethodTypeException.java
MIT
public ArraySet() { this(0, false); }
Create a new empty ArraySet. The default capacity of an array map is 0, and will grow once items are added to it.
ArraySet::ArraySet
java
Reginer/aosp-android-jar
android-35/src/android/util/ArraySet.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/util/ArraySet.java
MIT
public ArraySet(int capacity) { this(capacity, false); }
Create a new ArraySet with a given initial capacity.
ArraySet::ArraySet
java
Reginer/aosp-android-jar
android-35/src/android/util/ArraySet.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/util/ArraySet.java
MIT
public ArraySet(int capacity, boolean identityHashCode) { mIdentityHashCode = identityHashCode; if (capacity == 0) { mHashes = EmptyArray.INT; mArray = EmptyArray.OBJECT; } else { allocArrays(capacity); } mSize = 0; }
Create a new ArraySet with a given initial capacity. public ArraySet(int capacity) { this(capacity, false); } /** {@hide}
ArraySet::ArraySet
java
Reginer/aosp-android-jar
android-35/src/android/util/ArraySet.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/util/ArraySet.java
MIT
public ArraySet(ArraySet<E> set) { this(); if (set != null) { addAll(set); } }
Create a new ArraySet with the mappings from the given ArraySet.
ArraySet::ArraySet
java
Reginer/aosp-android-jar
android-35/src/android/util/ArraySet.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/util/ArraySet.java
MIT
public ArraySet(Collection<? extends E> set) { this(); if (set != null) { addAll(set); } }
Create a new ArraySet with items from the given collection.
ArraySet::ArraySet
java
Reginer/aosp-android-jar
android-35/src/android/util/ArraySet.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/util/ArraySet.java
MIT
public ArraySet(@Nullable E[] array) { this(); if (array != null) { for (E value : array) { add(value); } } }
Create a new ArraySet with items from the given array
ArraySet::ArraySet
java
Reginer/aosp-android-jar
android-35/src/android/util/ArraySet.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/util/ArraySet.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, mSize); System.arraycopy(oarray, 0, mArray, 0, mSize); } freeArrays(ohashes, oarray, mSize); } if (mSize != oSize) { throw new ConcurrentModificationException(); } }
Ensure the array map can hold at least <var>minimumCapacity</var> items.
ArraySet::ensureCapacity
java
Reginer/aosp-android-jar
android-35/src/android/util/ArraySet.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/util/ArraySet.java
MIT
public int indexOf(Object key) { return key == null ? indexOfNull() : indexOf(key, mIdentityHashCode ? System.identityHashCode(key) : key.hashCode()); }
Returns the index of a value in the set. @param key The value to search for. @return Returns the index of the value if it exists, else a negative integer.
ArraySet::indexOf
java
Reginer/aosp-android-jar
android-35/src/android/util/ArraySet.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/util/ArraySet.java
MIT
public E 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 valueAtUnchecked(index); }
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.
ArraySet::valueAt
java
Reginer/aosp-android-jar
android-35/src/android/util/ArraySet.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/util/ArraySet.java
MIT
public void append(E value) { final int oSize = mSize; final int index = mSize; final int hash = value == null ? 0 : (mIdentityHashCode ? System.identityHashCode(value) : value.hashCode()); if (index >= mHashes.length) { throw new IllegalStateException("Array is full"); } if (index > 0 && mHashes[index - 1] > hash) { // Cannot optimize since it would break the sorted order - fallback to add() if (DEBUG) { RuntimeException e = new RuntimeException("here"); e.fillInStackTrace(); Log.w(TAG, "New hash " + hash + " is before end of array hash " + mHashes[index - 1] + " at index " + index, e); } add(value); return; } if (oSize != mSize) { throw new ConcurrentModificationException(); } mSize = index + 1; mHashes[index] = hash; mArray[index] = value; }
Special fast path for appending items to the end of the array without validation. The array must already be large enough to contain the item. @hide
ArraySet::append
java
Reginer/aosp-android-jar
android-35/src/android/util/ArraySet.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/util/ArraySet.java
MIT
public void addAll(ArraySet<? extends E> 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); if (0 != mSize) { throw new ConcurrentModificationException(); } mSize = N; } } else { for (int i = 0; i < N; i++) { add(array.valueAt(i)); } } }
Perform a {@link #add(Object)} of all values in <var>array</var> @param array The array whose contents are to be retrieved.
ArraySet::addAll
java
Reginer/aosp-android-jar
android-35/src/android/util/ArraySet.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/util/ArraySet.java
MIT
private boolean shouldShrink() { return mHashes.length > (BASE_SIZE * 2) && mSize < mHashes.length / 3; }
Removes the specified object from this set. @param object the object to remove. @return {@code true} if this set was modified, {@code false} otherwise. @Override public boolean remove(Object object) { final int index = indexOf(object); if (index >= 0) { removeAt(index); return true; } return false; } /** Returns true if the array size should be decreased.
ArraySet::shouldShrink
java
Reginer/aosp-android-jar
android-35/src/android/util/ArraySet.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/util/ArraySet.java
MIT
private int getNewShrunkenSize() { // We don't allow it to shrink smaller than (BASE_SIZE*2) to avoid flapping between that // and BASE_SIZE. return mSize > (BASE_SIZE * 2) ? (mSize + (mSize >> 1)) : (BASE_SIZE * 2); }
Returns the new size the array should have. Is only valid if {@link #shouldShrink} returns true.
ArraySet::getNewShrunkenSize
java
Reginer/aosp-android-jar
android-35/src/android/util/ArraySet.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/util/ArraySet.java
MIT
public E 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 int oSize = mSize; final Object old = mArray[index]; if (oSize <= 1) { // Now empty. if (DEBUG) Log.d(TAG, "remove: shrink from " + mHashes.length + " to 0"); clear(); } else { final int nSize = oSize - 1; if (shouldShrink()) { // Shrunk enough to reduce size of arrays. final int n = getNewShrunkenSize(); if (DEBUG) Log.d(TAG, "remove: shrink from " + mHashes.length + " to " + n); final int[] ohashes = mHashes; final Object[] oarray = mArray; allocArrays(n); 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); } 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, mArray, index, nSize - index); } } 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, mArray, index, nSize - index); } mArray[nSize] = null; } if (oSize != mSize) { throw new ConcurrentModificationException(); } mSize = nSize; } return (E) 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.
ArraySet::removeAt
java
Reginer/aosp-android-jar
android-35/src/android/util/ArraySet.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/util/ArraySet.java
MIT
public boolean removeAll(ArraySet<? extends E> array) { // TODO: If array is sufficiently large, a marking approach might be beneficial. In a first // pass, use the property that the sets are sorted by hash to make this linear passes // (except for hash collisions, which means worst case still n*m), then do one // collection pass into a new array. This avoids binary searches and excessive memcpy. final int N = array.mSize; // Note: ArraySet does not make thread-safety guarantees. So instead of OR-ing together all // the single results, compare size before and after. final int originalSize = mSize; for (int i = 0; i < N; i++) { remove(array.valueAt(i)); } return originalSize != mSize; }
Perform a {@link #remove(Object)} of all values in <var>array</var> @param array The array whose contents are to be removed.
ArraySet::removeAll
java
Reginer/aosp-android-jar
android-35/src/android/util/ArraySet.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/util/ArraySet.java
MIT
public void prepareAppDataAfterInstallLIF(AndroidPackage pkg) { prepareAppDataPostCommitLIF(pkg, 0 /* previousAppId */); }
Prepare app data for the given app just after it was installed or upgraded. This method carefully only touches users that it's installed for, and it forces a restorecon to handle any seinfo changes. <p> Verifies that directories exist and that ownership and labeling is correct for all installed apps. If there is an ownership mismatch, it will wipe and recreate the data. <p> <em>Note: To avoid a deadlock, do not call this method with {@code mLock} lock held</em>
AppDataHelper::prepareAppDataAfterInstallLIF
java
Reginer/aosp-android-jar
android-33/src/com/android/server/pm/AppDataHelper.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/server/pm/AppDataHelper.java
MIT
private @NonNull CompletableFuture<?> prepareAppData(@NonNull Installer.Batch batch, @Nullable AndroidPackage pkg, int previousAppId, int userId, @StorageManager.StorageFlags int flags) { if (pkg == null) { Slog.wtf(TAG, "Package was null!", new Throwable()); return CompletableFuture.completedFuture(null); } if (!shouldHaveAppStorage(pkg)) { Slog.w(TAG, "Skipping preparing app data for " + pkg.getPackageName()); return CompletableFuture.completedFuture(null); } return prepareAppDataLeaf(batch, pkg, previousAppId, userId, flags); }
Prepare app data for the given app. <p> Verifies that directories exist and that ownership and labeling is correct for all installed apps. If there is an ownership mismatch: <ul> <li>If previousAppId < 0, app data will be migrated to the new app ID <li>If previousAppId == 0, no migration will happen and data will be wiped and recreated <li>If previousAppId > 0, app data owned by previousAppId will be migrated to the new app ID </ul>
AppDataHelper::prepareAppData
java
Reginer/aosp-android-jar
android-33/src/com/android/server/pm/AppDataHelper.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/server/pm/AppDataHelper.java
MIT
private boolean maybeMigrateAppDataLIF(AndroidPackage pkg, int userId) { if (pkg.isSystem() && !StorageManager.isFileEncryptedNativeOrEmulated() && PackageManager.APPLY_DEFAULT_TO_DEVICE_PROTECTED_STORAGE) { final int storageTarget = pkg.isDefaultToDeviceProtectedStorage() ? StorageManager.FLAG_STORAGE_DE : StorageManager.FLAG_STORAGE_CE; try { mInstaller.migrateAppData(pkg.getVolumeUuid(), pkg.getPackageName(), userId, storageTarget); } catch (Installer.InstallerException e) { logCriticalInfo(Log.WARN, "Failed to migrate " + pkg.getPackageName() + ": " + e.getMessage()); } return true; } else { return false; } }
For system apps on non-FBE devices, this method migrates any existing CE/DE data to match the {@code defaultToDeviceProtectedStorage} flag requested by the app.
AppDataHelper::maybeMigrateAppDataLIF
java
Reginer/aosp-android-jar
android-33/src/com/android/server/pm/AppDataHelper.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/server/pm/AppDataHelper.java
MIT
public boolean isInEncoding(char ch) { if (m_encoding == null) { m_encoding = new EncodingImpl(); // One could put alternate logic in here to // instantiate another object that implements the // InEncoding interface. For example if the JRE is 1.4 or up // we could have an object that uses JRE 1.4 methods } return m_encoding.isInEncoding(ch); }
This is not a public API. It returns true if the char in question is in the encoding. @param ch the char in question. <p> This method is not a public API. @xsl.usage internal
EncodingInfo::isInEncoding
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/serializer/EncodingInfo.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/serializer/EncodingInfo.java
MIT
public boolean isInEncoding(char high, char low) { if (m_encoding == null) { m_encoding = new EncodingImpl(); // One could put alternate logic in here to // instantiate another object that implements the // InEncoding interface. For example if the JRE is 1.4 or up // we could have an object that uses JRE 1.4 methods } return m_encoding.isInEncoding(high, low); }
This is not a public API. It returns true if the character formed by the high/low pair is in the encoding. @param high a char that the a high char of a high/low surrogate pair. @param low a char that is the low char of a high/low surrogate pair. <p> This method is not a public API. @xsl.usage internal
EncodingInfo::isInEncoding
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/serializer/EncodingInfo.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/serializer/EncodingInfo.java
MIT
public EncodingInfo(String name, String javaName, char highChar) { this.name = name; this.javaName = javaName; this.m_highCharInContiguousGroup = highChar; }
Create an EncodingInfo object based on the ISO name and Java name. If both parameters are null any character will be considered to be in the encoding. This is useful for when the serializer is in temporary output state, and has no assciated encoding. @param name reference to the ISO name. @param javaName reference to the Java encoding name. @param highChar The char for which characters at or below this value are definately in the encoding, although for characters above this point they might be in the encoding.
EncodingInfo::EncodingInfo
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/serializer/EncodingInfo.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/serializer/EncodingInfo.java
MIT
private static boolean inEncoding(char ch, String encoding) { boolean isInEncoding; try { char cArray[] = new char[1]; cArray[0] = ch; // Construct a String from the char String s = new String(cArray); // Encode the String into a sequence of bytes // using the given, named charset. byte[] bArray = s.getBytes(encoding); isInEncoding = inEncoding(ch, bArray); } catch (Exception e) { isInEncoding = false; // If for some reason the encoding is null, e.g. // for a temporary result tree, we should just // say that every character is in the encoding. if (encoding == null) isInEncoding = true; } return isInEncoding; }
This is heart of the code that determines if a given character is in the given encoding. This method is probably expensive, and the answer should be cached. <p> This method is not a public API, and should only be used internally within the serializer. @param ch the char in question, that is not a high char of a high/low surrogate pair. @param encoding the Java name of the enocding. @xsl.usage internal
EncodingImpl::inEncoding
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/serializer/EncodingInfo.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/serializer/EncodingInfo.java
MIT
private static boolean inEncoding(char high, char low, String encoding) { boolean isInEncoding; try { char cArray[] = new char[2]; cArray[0] = high; cArray[1] = low; // Construct a String from the char String s = new String(cArray); // Encode the String into a sequence of bytes // using the given, named charset. byte[] bArray = s.getBytes(encoding); isInEncoding = inEncoding(high,bArray); } catch (Exception e) { isInEncoding = false; } return isInEncoding; }
This is heart of the code that determines if a given high/low surrogate pair forms a character that is in the given encoding. This method is probably expensive, and the answer should be cached. <p> This method is not a public API, and should only be used internally within the serializer. @param high the high char of a high/low surrogate pair. @param low the low char of a high/low surrogate pair. @param encoding the Java name of the encoding. @xsl.usage internal
EncodingImpl::inEncoding
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/serializer/EncodingInfo.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/serializer/EncodingInfo.java
MIT
private static boolean inEncoding(char ch, byte[] data) { final boolean isInEncoding; // If the string written out as data is not in the encoding, // the output is not specified according to the documentation // on the String.getBytes(encoding) method, // but we do our best here. if (data==null || data.length == 0) { isInEncoding = false; } else { if (data[0] == 0) isInEncoding = false; else if (data[0] == '?' && ch != '?') isInEncoding = false; /* * else if (isJapanese) { * // isJapanese is really * // ( "EUC-JP".equals(javaName) * // || "EUC_JP".equals(javaName) * // || "SJIS".equals(javaName) ) * * // Work around some bugs in JRE for Japanese * if(data[0] == 0x21) * isInEncoding = false; * else if (ch == 0xA5) * isInEncoding = false; * else * isInEncoding = true; * } */ else { // We don't know for sure, but it looks like it is in the encoding isInEncoding = true; } } return isInEncoding; }
This method is the core of determining if character is in the encoding. The method is not foolproof, because s.getBytes(encoding) has specified behavior only if the characters are in the specified encoding. However this method tries it's best. @param ch the char that was converted using getBytes, or the first char of a high/low pair that was converted. @param data the bytes written out by the call to s.getBytes(encoding); @return true if the character is in the encoding.
EncodingImpl::inEncoding
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/serializer/EncodingInfo.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/serializer/EncodingInfo.java
MIT
public final char getHighChar() { return m_highCharInContiguousGroup; }
This method exists for performance reasons. <p> Except for '\u0000', if a char is less than or equal to the value returned by this method then it in the encoding. <p> The characters in an encoding are not contiguous, however there is a lowest group of chars starting at '\u0001' upto and including the char returned by this method that are all in the encoding. So the char returned by this method essentially defines the lowest contiguous group. <p> chars above the value returned might be in the encoding, but chars at or below the value returned are definately in the encoding. <p> In any case however, the isInEncoding(char) method can be used regardless of the value of the char returned by this method. <p> If the value returned is '\u0000' it means that every character must be tested with an isInEncoding method {@link #isInEncoding(char)} or {@link #isInEncoding(char, char)} for surrogate pairs. <p> This method is not a public API. @xsl.usage internal
EncodingImpl::getHighChar
java
Reginer/aosp-android-jar
android-34/src/org/apache/xml/serializer/EncodingInfo.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/org/apache/xml/serializer/EncodingInfo.java
MIT
public @android.annotation.NonNull TrainingExampleRecord build() { checkNotUsed(); mBuilderFieldsSet |= 0x4; // Mark builder used if ((mBuilderFieldsSet & 0x1) == 0) { mTrainingExample = null; } if ((mBuilderFieldsSet & 0x2) == 0) { mResumptionToken = null; } TrainingExampleRecord o = new TrainingExampleRecord( mTrainingExample, mResumptionToken); return o; }
The resumption token byte arrays corresponding to training examples. The last processed example's corresponding resumption token will be passed to {@link IsolatedWorker#onTrainingExamples} to support resumption. @DataClass.Generated.Member public @android.annotation.NonNull Builder setResumptionToken(@Nullable byte... value) { checkNotUsed(); mBuilderFieldsSet |= 0x2; mResumptionToken = value; return this; } /** Builds the instance. This builder should not be touched after calling this!
Builder::build
java
Reginer/aosp-android-jar
android-35/src/android/adservices/ondevicepersonalization/TrainingExampleRecord.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/android/adservices/ondevicepersonalization/TrainingExampleRecord.java
MIT
private List sortCerts( List certs) { if (certs.size() < 2) { return certs; } X500Principal issuer = ((X509Certificate)certs.get(0)).getIssuerX500Principal(); boolean okay = true; for (int i = 1; i != certs.size(); i++) { X509Certificate cert = (X509Certificate)certs.get(i); if (issuer.equals(cert.getSubjectX500Principal())) { issuer = ((X509Certificate)certs.get(i)).getIssuerX500Principal(); } else { okay = false; break; } } if (okay) { return certs; } // find end-entity cert List retList = new ArrayList(certs.size()); List orig = new ArrayList(certs); for (int i = 0; i < certs.size(); i++) { X509Certificate cert = (X509Certificate)certs.get(i); boolean found = false; X500Principal subject = cert.getSubjectX500Principal(); for (int j = 0; j != certs.size(); j++) { X509Certificate c = (X509Certificate)certs.get(j); if (c.getIssuerX500Principal().equals(subject)) { found = true; break; } } if (!found) { retList.add(cert); certs.remove(i); } } // can only have one end entity cert - something's wrong, give up. if (retList.size() > 1) { return orig; } for (int i = 0; i != retList.size(); i++) { issuer = ((X509Certificate)retList.get(i)).getIssuerX500Principal(); for (int j = 0; j < certs.size(); j++) { X509Certificate c = (X509Certificate)certs.get(j); if (issuer.equals(c.getSubjectX500Principal())) { retList.add(c); certs.remove(j); break; } } } // make sure all certificates are accounted for. if (certs.size() > 0) { return orig; } return retList; }
@param certs
PKIXCertPath::sortCerts
java
Reginer/aosp-android-jar
android-35/src/com/android/org/bouncycastle/jcajce/provider/asymmetric/x509/PKIXCertPath.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/org/bouncycastle/jcajce/provider/asymmetric/x509/PKIXCertPath.java
MIT
PKIXCertPath( InputStream inStream, String encoding) throws CertificateException { super("X.509"); try { if (encoding.equalsIgnoreCase("PkiPath")) { ASN1InputStream derInStream = new ASN1InputStream(inStream); ASN1Primitive derObject = derInStream.readObject(); if (!(derObject instanceof ASN1Sequence)) { throw new CertificateException("input stream does not contain a ASN1 SEQUENCE while reading PkiPath encoded data to load CertPath"); } Enumeration e = ((ASN1Sequence)derObject).getObjects(); certificates = new ArrayList(); CertificateFactory certFactory = helper.createCertificateFactory("X.509"); while (e.hasMoreElements()) { ASN1Encodable element = (ASN1Encodable)e.nextElement(); byte[] encoded = element.toASN1Primitive().getEncoded(ASN1Encoding.DER); certificates.add(0, certFactory.generateCertificate( new ByteArrayInputStream(encoded))); } } else if (encoding.equalsIgnoreCase("PKCS7") || encoding.equalsIgnoreCase("PEM")) { inStream = new BufferedInputStream(inStream); certificates = new ArrayList(); CertificateFactory certFactory= helper.createCertificateFactory("X.509"); Certificate cert; while ((cert = certFactory.generateCertificate(inStream)) != null) { certificates.add(cert); } } else { throw new CertificateException("unsupported encoding: " + encoding); } } catch (IOException ex) { throw new CertificateException("IOException throw while decoding CertPath:\n" + ex.toString()); } catch (NoSuchProviderException ex) { throw new CertificateException("BouncyCastle provider not found while trying to get a CertificateFactory:\n" + ex.toString()); } this.certificates = sortCerts(certificates); }
Creates a CertPath of the specified type. This constructor is protected because most users should use a CertificateFactory to create CertPaths.
PKIXCertPath::PKIXCertPath
java
Reginer/aosp-android-jar
android-35/src/com/android/org/bouncycastle/jcajce/provider/asymmetric/x509/PKIXCertPath.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/org/bouncycastle/jcajce/provider/asymmetric/x509/PKIXCertPath.java
MIT
public Iterator getEncodings() { return certPathEncodings.iterator(); }
Returns an iteration of the encodings supported by this certification path, with the default encoding first. Attempts to modify the returned Iterator via its remove method result in an UnsupportedOperationException. @return an Iterator over the names of the supported encodings (as Strings)
PKIXCertPath::getEncodings
java
Reginer/aosp-android-jar
android-35/src/com/android/org/bouncycastle/jcajce/provider/asymmetric/x509/PKIXCertPath.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/org/bouncycastle/jcajce/provider/asymmetric/x509/PKIXCertPath.java
MIT
public byte[] getEncoded() throws CertificateEncodingException { Iterator iter = getEncodings(); if (iter.hasNext()) { Object enc = iter.next(); if (enc instanceof String) { return getEncoded((String)enc); } } return null; }
Returns the encoded form of this certification path, using the default encoding. @return the encoded bytes @exception java.security.cert.CertificateEncodingException if an encoding error occurs
PKIXCertPath::getEncoded
java
Reginer/aosp-android-jar
android-35/src/com/android/org/bouncycastle/jcajce/provider/asymmetric/x509/PKIXCertPath.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/org/bouncycastle/jcajce/provider/asymmetric/x509/PKIXCertPath.java
MIT
public byte[] getEncoded(String encoding) throws CertificateEncodingException { if (encoding.equalsIgnoreCase("PkiPath")) { ASN1EncodableVector v = new ASN1EncodableVector(); ListIterator iter = certificates.listIterator(certificates.size()); while (iter.hasPrevious()) { v.add(toASN1Object((X509Certificate)iter.previous())); } return toDEREncoded(new DERSequence(v)); } else if (encoding.equalsIgnoreCase("PKCS7")) { ContentInfo encInfo = new ContentInfo(PKCSObjectIdentifiers.data, null); ASN1EncodableVector v = new ASN1EncodableVector(); for (int i = 0; i != certificates.size(); i++) { v.add(toASN1Object((X509Certificate)certificates.get(i))); } SignedData sd = new SignedData( new ASN1Integer(1), new DERSet(), encInfo, new DERSet(v), null, new DERSet()); return toDEREncoded(new ContentInfo( PKCSObjectIdentifiers.signedData, sd)); } // BEGIN Android-removed: Unsupported algorithms /* else if (encoding.equalsIgnoreCase("PEM")) { ByteArrayOutputStream bOut = new ByteArrayOutputStream(); PemWriter pWrt = new PemWriter(new OutputStreamWriter(bOut)); try { for (int i = 0; i != certificates.size(); i++) { pWrt.writeObject(new PemObject("CERTIFICATE", ((X509Certificate)certificates.get(i)).getEncoded())); } pWrt.close(); } catch (Exception e) { throw new CertificateEncodingException("can't encode certificate for PEM encoded path"); } return bOut.toByteArray(); } */ // END Android-removed: Unsupported algorithms else { throw new CertificateEncodingException("unsupported encoding: " + encoding); } }
Returns the encoded form of this certification path, using the specified encoding. @param encoding the name of the encoding to use @return the encoded bytes @exception java.security.cert.CertificateEncodingException if an encoding error occurs or the encoding requested is not supported
PKIXCertPath::getEncoded
java
Reginer/aosp-android-jar
android-35/src/com/android/org/bouncycastle/jcajce/provider/asymmetric/x509/PKIXCertPath.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/org/bouncycastle/jcajce/provider/asymmetric/x509/PKIXCertPath.java
MIT
public List getCertificates() { return Collections.unmodifiableList(new ArrayList(certificates)); }
Returns the list of certificates in this certification path. The List returned must be immutable and thread-safe. @return an immutable List of Certificates (may be empty, but not null)
PKIXCertPath::getCertificates
java
Reginer/aosp-android-jar
android-35/src/com/android/org/bouncycastle/jcajce/provider/asymmetric/x509/PKIXCertPath.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/org/bouncycastle/jcajce/provider/asymmetric/x509/PKIXCertPath.java
MIT
private ASN1Primitive toASN1Object( X509Certificate cert) throws CertificateEncodingException { try { return new ASN1InputStream(cert.getEncoded()).readObject(); } catch (Exception e) { throw new CertificateEncodingException("Exception while encoding certificate: " + e.toString()); } }
Return a DERObject containing the encoded certificate. @param cert the X509Certificate object to be encoded @return the DERObject
PKIXCertPath::toASN1Object
java
Reginer/aosp-android-jar
android-35/src/com/android/org/bouncycastle/jcajce/provider/asymmetric/x509/PKIXCertPath.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/org/bouncycastle/jcajce/provider/asymmetric/x509/PKIXCertPath.java
MIT
public GsmCdmaCall (GsmCdmaCallTracker owner) { mOwner = owner; }
{@hide} public class GsmCdmaCall extends Call { /*************************** Instance Variables /*package*/ GsmCdmaCallTracker mOwner; /****************************** Constructors /*package
GsmCdmaCall::GsmCdmaCall
java
Reginer/aosp-android-jar
android-35/src/com/android/internal/telephony/GsmCdmaCall.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/internal/telephony/GsmCdmaCall.java
MIT
public boolean connectionDisconnected(GsmCdmaConnection conn) { if (mState != State.DISCONNECTED) { /* If only disconnected connections remain, we are disconnected*/ boolean hasOnlyDisconnectedConnections = true; for (Connection c : getConnections()) { if (c.getState() != State.DISCONNECTED) { hasOnlyDisconnectedConnections = false; break; } } if (hasOnlyDisconnectedConnections) { mState = State.DISCONNECTED; return true; } } return false; }
Called by GsmCdmaConnection when it has disconnected
GsmCdmaCall::connectionDisconnected
java
Reginer/aosp-android-jar
android-35/src/com/android/internal/telephony/GsmCdmaCall.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/internal/telephony/GsmCdmaCall.java
MIT
/*package*/ boolean isFull() { return getConnectionsCount() == mOwner.getMaxConnectionsPerCall(); }
@return true if there's no space in this call for additional connections to be added via "conference"
GsmCdmaCall::isFull
java
Reginer/aosp-android-jar
android-35/src/com/android/internal/telephony/GsmCdmaCall.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-35/src/com/android/internal/telephony/GsmCdmaCall.java
MIT
public static SaveEventLogger forSessionId(int sessionId) { return new SaveEventLogger(sessionId); }
A factory constructor to create FillRequestEventLogger.
SaveEventLogger::forSessionId
java
Reginer/aosp-android-jar
android-34/src/com/android/server/autofill/SaveEventLogger.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/server/autofill/SaveEventLogger.java
MIT
public void maybeSetRequestId(int requestId) { mEventInternal.ifPresent(event -> event.mRequestId = requestId); }
Set request_id as long as mEventInternal presents.
SaveEventLogger::maybeSetRequestId
java
Reginer/aosp-android-jar
android-34/src/com/android/server/autofill/SaveEventLogger.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/server/autofill/SaveEventLogger.java
MIT
public void maybeSetAppPackageUid(int val) { mEventInternal.ifPresent(event -> { event.mAppPackageUid = val; }); }
Set app_package_uid as long as mEventInternal presents.
SaveEventLogger::maybeSetAppPackageUid
java
Reginer/aosp-android-jar
android-34/src/com/android/server/autofill/SaveEventLogger.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/server/autofill/SaveEventLogger.java
MIT
public void maybeSetSaveUiTriggerIds(int val) { mEventInternal.ifPresent(event -> { event.mSaveUiTriggerIds = val; }); }
Set save_ui_trigger_ids as long as mEventInternal presents.
SaveEventLogger::maybeSetSaveUiTriggerIds
java
Reginer/aosp-android-jar
android-34/src/com/android/server/autofill/SaveEventLogger.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/server/autofill/SaveEventLogger.java
MIT
public void maybeSetFlag(int val) { mEventInternal.ifPresent(event -> { event.mFlag = val; }); }
Set flag as long as mEventInternal presents.
SaveEventLogger::maybeSetFlag
java
Reginer/aosp-android-jar
android-34/src/com/android/server/autofill/SaveEventLogger.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/server/autofill/SaveEventLogger.java
MIT
public void maybeSetIsNewField(boolean val) { mEventInternal.ifPresent(event -> { event.mIsNewField = val; }); }
Set is_new_field as long as mEventInternal presents.
SaveEventLogger::maybeSetIsNewField
java
Reginer/aosp-android-jar
android-34/src/com/android/server/autofill/SaveEventLogger.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/server/autofill/SaveEventLogger.java
MIT
public void maybeSetSaveUiShownReason(@SaveUiShownReason int reason) { mEventInternal.ifPresent(event -> { event.mSaveUiShownReason = reason; }); }
Set save_ui_shown_reason as long as mEventInternal presents.
SaveEventLogger::maybeSetSaveUiShownReason
java
Reginer/aosp-android-jar
android-34/src/com/android/server/autofill/SaveEventLogger.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/server/autofill/SaveEventLogger.java
MIT
public void maybeSetSaveUiNotShownReason(@SaveUiNotShownReason int reason) { mEventInternal.ifPresent(event -> { event.mSaveUiNotShownReason = reason; }); }
Set save_ui_not_shown_reason as long as mEventInternal presents.
SaveEventLogger::maybeSetSaveUiNotShownReason
java
Reginer/aosp-android-jar
android-34/src/com/android/server/autofill/SaveEventLogger.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/server/autofill/SaveEventLogger.java
MIT
public void maybeSetSaveButtonClicked(boolean val) { mEventInternal.ifPresent(event -> { event.mSaveButtonClicked = val; }); }
Set save_button_clicked as long as mEventInternal presents.
SaveEventLogger::maybeSetSaveButtonClicked
java
Reginer/aosp-android-jar
android-34/src/com/android/server/autofill/SaveEventLogger.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/server/autofill/SaveEventLogger.java
MIT
public void maybeSetCancelButtonClicked(boolean val) { mEventInternal.ifPresent(event -> { event.mCancelButtonClicked = val; }); }
Set cancel_button_clicked as long as mEventInternal presents.
SaveEventLogger::maybeSetCancelButtonClicked
java
Reginer/aosp-android-jar
android-34/src/com/android/server/autofill/SaveEventLogger.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/server/autofill/SaveEventLogger.java
MIT
public void maybeSetDialogDismissed(boolean val) { mEventInternal.ifPresent(event -> { event.mDialogDismissed = val; }); }
Set dialog_dismissed as long as mEventInternal presents.
SaveEventLogger::maybeSetDialogDismissed
java
Reginer/aosp-android-jar
android-34/src/com/android/server/autofill/SaveEventLogger.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/server/autofill/SaveEventLogger.java
MIT
public void maybeSetIsSaved(boolean val) { mEventInternal.ifPresent(event -> { event.mIsSaved = val; }); }
Set is_saved as long as mEventInternal presents.
SaveEventLogger::maybeSetIsSaved
java
Reginer/aosp-android-jar
android-34/src/com/android/server/autofill/SaveEventLogger.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/server/autofill/SaveEventLogger.java
MIT
public void maybeSetLatencySaveUiDisplayMillis(long timestamp) { mEventInternal.ifPresent(event -> { event.mLatencySaveUiDisplayMillis = timestamp; }); }
Set latency_save_ui_display_millis as long as mEventInternal presents.
SaveEventLogger::maybeSetLatencySaveUiDisplayMillis
java
Reginer/aosp-android-jar
android-34/src/com/android/server/autofill/SaveEventLogger.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/server/autofill/SaveEventLogger.java
MIT
public void maybeSetLatencySaveRequestMillis(long timestamp) { mEventInternal.ifPresent(event -> { event.mLatencySaveRequestMillis = timestamp; }); }
Set latency_save_request_millis as long as mEventInternal presents.
SaveEventLogger::maybeSetLatencySaveRequestMillis
java
Reginer/aosp-android-jar
android-34/src/com/android/server/autofill/SaveEventLogger.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/server/autofill/SaveEventLogger.java
MIT
public void maybeSetLatencySaveFinishMillis(long timestamp) { mEventInternal.ifPresent(event -> { event.mLatencySaveFinishMillis = timestamp; }); }
Set latency_save_finish_millis as long as mEventInternal presents.
SaveEventLogger::maybeSetLatencySaveFinishMillis
java
Reginer/aosp-android-jar
android-34/src/com/android/server/autofill/SaveEventLogger.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/server/autofill/SaveEventLogger.java
MIT
public void maybeSetIsFrameworkCreatedSaveInfo(boolean val) { mEventInternal.ifPresent(event -> { event.mIsFrameworkCreatedSaveInfo = val; }); }
Set is_framework_created_save_info as long as mEventInternal presents.
SaveEventLogger::maybeSetIsFrameworkCreatedSaveInfo
java
Reginer/aosp-android-jar
android-34/src/com/android/server/autofill/SaveEventLogger.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/server/autofill/SaveEventLogger.java
MIT
public void logAndEndEvent() { if (!mEventInternal.isPresent()) { Slog.w(TAG, "Shouldn't be logging AutofillSaveEventReported again for same " + "event"); return; } SaveEventInternal event = mEventInternal.get(); if (sVerbose) { Slog.v(TAG, "Log AutofillSaveEventReported:" + " requestId=" + event.mRequestId + " sessionId=" + mSessionId + " mAppPackageUid=" + event.mAppPackageUid + " mSaveUiTriggerIds=" + event.mSaveUiTriggerIds + " mFlag=" + event.mFlag + " mIsNewField=" + event.mIsNewField + " mSaveUiShownReason=" + event.mSaveUiShownReason + " mSaveUiNotShownReason=" + event.mSaveUiNotShownReason + " mSaveButtonClicked=" + event.mSaveButtonClicked + " mCancelButtonClicked=" + event.mCancelButtonClicked + " mDialogDismissed=" + event.mDialogDismissed + " mIsSaved=" + event.mIsSaved + " mLatencySaveUiDisplayMillis=" + event.mLatencySaveUiDisplayMillis + " mLatencySaveRequestMillis=" + event.mLatencySaveRequestMillis + " mLatencySaveFinishMillis=" + event.mLatencySaveFinishMillis + " mIsFrameworkCreatedSaveInfo=" + event.mIsFrameworkCreatedSaveInfo); } FrameworkStatsLog.write( AUTOFILL_SAVE_EVENT_REPORTED, event.mRequestId, mSessionId, event.mAppPackageUid, event.mSaveUiTriggerIds, event.mFlag, event.mIsNewField, event.mSaveUiShownReason, event.mSaveUiNotShownReason, event.mSaveButtonClicked, event.mCancelButtonClicked, event.mDialogDismissed, event.mIsSaved, event.mLatencySaveUiDisplayMillis, event.mLatencySaveRequestMillis, event.mLatencySaveFinishMillis, event.mIsFrameworkCreatedSaveInfo); mEventInternal = Optional.empty(); }
Log an AUTOFILL_SAVE_EVENT_REPORTED event.
SaveEventLogger::logAndEndEvent
java
Reginer/aosp-android-jar
android-34/src/com/android/server/autofill/SaveEventLogger.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/android/server/autofill/SaveEventLogger.java
MIT
public SSLEngineResult(Status status, HandshakeStatus handshakeStatus, int bytesConsumed, int bytesProduced) { if ((status == null) || (handshakeStatus == null) || (bytesConsumed < 0) || (bytesProduced < 0)) { throw new IllegalArgumentException("Invalid Parameter(s)"); } this.status = status; this.handshakeStatus = handshakeStatus; this.bytesConsumed = bytesConsumed; this.bytesProduced = bytesProduced; }
Initializes a new instance of this class. @param status the return value of the operation. @param handshakeStatus the current handshaking status. @param bytesConsumed the number of bytes consumed from the source ByteBuffer @param bytesProduced the number of bytes placed into the destination ByteBuffer @throws IllegalArgumentException if the <code>status</code> or <code>handshakeStatus</code> arguments are null, or if <code>bytesConsumed</code> or <code>bytesProduced</code> is negative.
HandshakeStatus::SSLEngineResult
java
Reginer/aosp-android-jar
android-33/src/javax/net/ssl/SSLEngineResult.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/javax/net/ssl/SSLEngineResult.java
MIT
final public Status getStatus() { return status; }
Gets the return value of this <code>SSLEngine</code> operation. @return the return value
HandshakeStatus::getStatus
java
Reginer/aosp-android-jar
android-33/src/javax/net/ssl/SSLEngineResult.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/javax/net/ssl/SSLEngineResult.java
MIT
final public HandshakeStatus getHandshakeStatus() { return handshakeStatus; }
Gets the handshake status of this <code>SSLEngine</code> operation. @return the handshake status
HandshakeStatus::getHandshakeStatus
java
Reginer/aosp-android-jar
android-33/src/javax/net/ssl/SSLEngineResult.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/javax/net/ssl/SSLEngineResult.java
MIT
final public int bytesConsumed() { return bytesConsumed; }
Returns the number of bytes consumed from the input buffer. @return the number of bytes consumed.
HandshakeStatus::bytesConsumed
java
Reginer/aosp-android-jar
android-33/src/javax/net/ssl/SSLEngineResult.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/javax/net/ssl/SSLEngineResult.java
MIT
final public int bytesProduced() { return bytesProduced; }
Returns the number of bytes written to the output buffer. @return the number of bytes produced
HandshakeStatus::bytesProduced
java
Reginer/aosp-android-jar
android-33/src/javax/net/ssl/SSLEngineResult.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/javax/net/ssl/SSLEngineResult.java
MIT
public Builder(Context context) { mContext = context; }
Creates a builder for the confirmation prompt. @param context the application context
Builder::Builder
java
Reginer/aosp-android-jar
android-33/src/android/security/ConfirmationPrompt.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/security/ConfirmationPrompt.java
MIT
public Builder setPromptText(CharSequence promptText) { mPromptText = promptText; return this; }
Sets the prompt text for the prompt. @param promptText the text to present in the prompt. @return the builder.
Builder::setPromptText
java
Reginer/aosp-android-jar
android-33/src/android/security/ConfirmationPrompt.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/security/ConfirmationPrompt.java
MIT
public Builder setExtraData(byte[] extraData) { mExtraData = extraData; return this; }
Sets the extra data for the prompt. @param extraData data to include in the response data. @return the builder.
Builder::setExtraData
java
Reginer/aosp-android-jar
android-33/src/android/security/ConfirmationPrompt.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/security/ConfirmationPrompt.java
MIT
public ConfirmationPrompt build() { if (TextUtils.isEmpty(mPromptText)) { throw new IllegalArgumentException("prompt text must be set and non-empty"); } if (mExtraData == null) { throw new IllegalArgumentException("extraData must be set"); } return new ConfirmationPrompt(mContext, mPromptText, mExtraData); }
Creates a {@link ConfirmationPrompt} with the arguments supplied to this builder. @return a {@link ConfirmationPrompt} @throws IllegalArgumentException if any of the required fields are not set.
Builder::build
java
Reginer/aosp-android-jar
android-33/src/android/security/ConfirmationPrompt.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/security/ConfirmationPrompt.java
MIT
public void presentPrompt(@NonNull Executor executor, @NonNull ConfirmationCallback callback) throws ConfirmationAlreadyPresentingException, ConfirmationNotAvailableException { if (mCallback != null) { throw new ConfirmationAlreadyPresentingException(); } if (isAccessibilityServiceRunning(mContext)) { throw new ConfirmationNotAvailableException(); } mCallback = callback; mExecutor = executor; String locale = Locale.getDefault().toLanguageTag(); int uiOptionsAsFlags = getUiOptionsAsFlags(); int responseCode = getService().presentConfirmationPrompt( mConfirmationCallback, mPromptText.toString(), mExtraData, locale, uiOptionsAsFlags); switch (responseCode) { case AndroidProtectedConfirmation.ERROR_OK: return; case AndroidProtectedConfirmation.ERROR_OPERATION_PENDING: throw new ConfirmationAlreadyPresentingException(); case AndroidProtectedConfirmation.ERROR_UNIMPLEMENTED: throw new ConfirmationNotAvailableException(); default: // Unexpected error code. Log.w(TAG, "Unexpected responseCode=" + responseCode + " from presentConfirmationPrompt() call."); throw new IllegalArgumentException(); } }
Requests a confirmation prompt to be presented to the user. When the prompt is no longer being presented, one of the methods in {@link ConfirmationCallback} is called on the supplied callback object. Confirmation prompts may not be available when accessibility services are running so this may fail with a {@link ConfirmationNotAvailableException} exception even if {@link #isSupported} returns {@code true}. @param executor the executor identifying the thread that will receive the callback. @param callback the callback to use when the prompt is done showing. @throws IllegalArgumentException if the prompt text is too long or malfomed. @throws ConfirmationAlreadyPresentingException if another prompt is being presented. @throws ConfirmationNotAvailableException if confirmation prompts are not supported.
Builder::presentPrompt
java
Reginer/aosp-android-jar
android-33/src/android/security/ConfirmationPrompt.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/security/ConfirmationPrompt.java
MIT
public void cancelPrompt() { int responseCode = getService().cancelConfirmationPrompt(mConfirmationCallback); if (responseCode == AndroidProtectedConfirmation.ERROR_OK) { return; } else if (responseCode == AndroidProtectedConfirmation.ERROR_OPERATION_PENDING) { throw new IllegalStateException(); } else { // Unexpected error code. Log.w(TAG, "Unexpected responseCode=" + responseCode + " from cancelConfirmationPrompt() call."); throw new IllegalStateException(); } }
Cancels a prompt currently being displayed. On success, the {@link ConfirmationCallback#onCanceled onCanceled()} method on the supplied callback object will be called asynchronously. @throws IllegalStateException if no prompt is currently being presented.
Builder::cancelPrompt
java
Reginer/aosp-android-jar
android-33/src/android/security/ConfirmationPrompt.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/security/ConfirmationPrompt.java
MIT
public static boolean isSupported(Context context) { if (isAccessibilityServiceRunning(context)) { return false; } return new AndroidProtectedConfirmation().isConfirmationPromptSupported(); }
Checks if the device supports confirmation prompts. @param context the application context. @return true if confirmation prompts are supported by the device.
Builder::isSupported
java
Reginer/aosp-android-jar
android-33/src/android/security/ConfirmationPrompt.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/android/security/ConfirmationPrompt.java
MIT
public static BinaryReader newInstance(ByteBuffer buffer, boolean bufferIsImmutable) { if (buffer.hasArray()) { // TODO(nathanmittler): Add support for unsafe operations. return new SafeHeapReader(buffer, bufferIsImmutable); } // TODO(nathanmittler): Add support for direct buffers throw new IllegalArgumentException("Direct buffers not yet supported"); }
Creates a new reader using the given {@code buffer} as input. @param buffer the input buffer. The buffer (including position, limit, etc.) will not be modified. To increment the buffer position after the read completes, use the value returned by {@link #getTotalBytesRead()}. @param bufferIsImmutable if {@code true} the reader assumes that the content of {@code buffer} will never change and any allocated {@link ByteString} instances will by directly wrap slices of {@code buffer}. @return the reader
BinaryReader::newInstance
java
Reginer/aosp-android-jar
android-34/src/com/google/protobuf/BinaryReader.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/google/protobuf/BinaryReader.java
MIT
private BinaryReader() {}
Creates a new reader using the given {@code buffer} as input. @param buffer the input buffer. The buffer (including position, limit, etc.) will not be modified. To increment the buffer position after the read completes, use the value returned by {@link #getTotalBytesRead()}. @param bufferIsImmutable if {@code true} the reader assumes that the content of {@code buffer} will never change and any allocated {@link ByteString} instances will by directly wrap slices of {@code buffer}. @return the reader public static BinaryReader newInstance(ByteBuffer buffer, boolean bufferIsImmutable) { if (buffer.hasArray()) { // TODO(nathanmittler): Add support for unsafe operations. return new SafeHeapReader(buffer, bufferIsImmutable); } // TODO(nathanmittler): Add support for direct buffers throw new IllegalArgumentException("Direct buffers not yet supported"); } /** Only allow subclassing for inner classes.
BinaryReader::BinaryReader
java
Reginer/aosp-android-jar
android-34/src/com/google/protobuf/BinaryReader.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/google/protobuf/BinaryReader.java
MIT
private int readVarint32() throws IOException { // See implementation notes for readRawVarint64 int i = pos; if (limit == pos) { throw InvalidProtocolBufferException.truncatedMessage(); } int x; if ((x = buffer[i++]) >= 0) { pos = i; return x; } else if (limit - i < 9) { return (int) readVarint64SlowPath(); } else if ((x ^= (buffer[i++] << 7)) < 0) { x ^= (~0 << 7); } else if ((x ^= (buffer[i++] << 14)) >= 0) { x ^= (~0 << 7) ^ (~0 << 14); } else if ((x ^= (buffer[i++] << 21)) < 0) { x ^= (~0 << 7) ^ (~0 << 14) ^ (~0 << 21); } else { int y = buffer[i++]; x ^= y << 28; x ^= (~0 << 7) ^ (~0 << 14) ^ (~0 << 21) ^ (~0 << 28); if (y < 0 && buffer[i++] < 0 && buffer[i++] < 0 && buffer[i++] < 0 && buffer[i++] < 0 && buffer[i++] < 0) { throw InvalidProtocolBufferException.malformedVarint(); } } pos = i; return x; }
A {@link BinaryReader} implementation that operates on a heap {@link ByteBuffer}. Uses only safe operations on the underlying array. private static final class SafeHeapReader extends BinaryReader { private final boolean bufferIsImmutable; private final byte[] buffer; private int pos; private final int initialPos; private int limit; private int tag; private int endGroupTag; public SafeHeapReader(ByteBuffer bytebuf, boolean bufferIsImmutable) { this.bufferIsImmutable = bufferIsImmutable; buffer = bytebuf.array(); initialPos = pos = bytebuf.arrayOffset() + bytebuf.position(); limit = bytebuf.arrayOffset() + bytebuf.limit(); } private boolean isAtEnd() { return pos == limit; } @Override public int getTotalBytesRead() { return pos - initialPos; } @Override public int getFieldNumber() throws IOException { if (isAtEnd()) { return Reader.READ_DONE; } tag = readVarint32(); if (tag == endGroupTag) { return Reader.READ_DONE; } return WireFormat.getTagFieldNumber(tag); } @Override public int getTag() { return tag; } @Override public boolean skipField() throws IOException { if (isAtEnd() || tag == endGroupTag) { return false; } switch (WireFormat.getTagWireType(tag)) { case WIRETYPE_VARINT: skipVarint(); return true; case WIRETYPE_FIXED64: skipBytes(FIXED64_SIZE); return true; case WIRETYPE_LENGTH_DELIMITED: skipBytes(readVarint32()); return true; case WIRETYPE_FIXED32: skipBytes(FIXED32_SIZE); return true; case WIRETYPE_START_GROUP: skipGroup(); return true; default: throw InvalidProtocolBufferException.invalidWireType(); } } @Override public double readDouble() throws IOException { requireWireType(WIRETYPE_FIXED64); return Double.longBitsToDouble(readLittleEndian64()); } @Override public float readFloat() throws IOException { requireWireType(WIRETYPE_FIXED32); return Float.intBitsToFloat(readLittleEndian32()); } @Override public long readUInt64() throws IOException { requireWireType(WIRETYPE_VARINT); return readVarint64(); } @Override public long readInt64() throws IOException { requireWireType(WIRETYPE_VARINT); return readVarint64(); } @Override public int readInt32() throws IOException { requireWireType(WIRETYPE_VARINT); return readVarint32(); } @Override public long readFixed64() throws IOException { requireWireType(WIRETYPE_FIXED64); return readLittleEndian64(); } @Override public int readFixed32() throws IOException { requireWireType(WIRETYPE_FIXED32); return readLittleEndian32(); } @Override public boolean readBool() throws IOException { requireWireType(WIRETYPE_VARINT); return readVarint32() != 0; } @Override public String readString() throws IOException { return readStringInternal(false); } @Override public String readStringRequireUtf8() throws IOException { return readStringInternal(true); } public String readStringInternal(boolean requireUtf8) throws IOException { requireWireType(WIRETYPE_LENGTH_DELIMITED); final int size = readVarint32(); if (size == 0) { return ""; } requireBytes(size); if (requireUtf8 && !Utf8.isValidUtf8(buffer, pos, pos + size)) { throw InvalidProtocolBufferException.invalidUtf8(); } String result = new String(buffer, pos, size, Internal.UTF_8); pos += size; return result; } @Override public <T> T readMessage(Class<T> clazz, ExtensionRegistryLite extensionRegistry) throws IOException { requireWireType(WIRETYPE_LENGTH_DELIMITED); return readMessage(Protobuf.getInstance().schemaFor(clazz), extensionRegistry); } @Override public <T> T readMessageBySchemaWithCheck( Schema<T> schema, ExtensionRegistryLite extensionRegistry) throws IOException { requireWireType(WIRETYPE_LENGTH_DELIMITED); return readMessage(schema, extensionRegistry); } private <T> T readMessage(Schema<T> schema, ExtensionRegistryLite extensionRegistry) throws IOException { T newInstance = schema.newInstance(); mergeMessageField(newInstance, schema, extensionRegistry); schema.makeImmutable(newInstance); return newInstance; } @Override public <T> void mergeMessageField( T target, Schema<T> schema, ExtensionRegistryLite extensionRegistry) throws IOException { int size = readVarint32(); requireBytes(size); // Update the limit. int prevLimit = limit; int newLimit = pos + size; limit = newLimit; try { schema.mergeFrom(target, this, extensionRegistry); if (pos != newLimit) { throw InvalidProtocolBufferException.parseFailure(); } } finally { // Restore the limit. limit = prevLimit; } } @Deprecated @Override public <T> T readGroup(Class<T> clazz, ExtensionRegistryLite extensionRegistry) throws IOException { requireWireType(WIRETYPE_START_GROUP); return readGroup(Protobuf.getInstance().schemaFor(clazz), extensionRegistry); } @Deprecated @Override public <T> T readGroupBySchemaWithCheck( Schema<T> schema, ExtensionRegistryLite extensionRegistry) throws IOException { requireWireType(WIRETYPE_START_GROUP); return readGroup(schema, extensionRegistry); } private <T> T readGroup(Schema<T> schema, ExtensionRegistryLite extensionRegistry) throws IOException { T newInstance = schema.newInstance(); mergeGroupField(newInstance, schema, extensionRegistry); schema.makeImmutable(newInstance); return newInstance; } @Override public <T> void mergeGroupField( T target, Schema<T> schema, ExtensionRegistryLite extensionRegistry) throws IOException { int prevEndGroupTag = endGroupTag; endGroupTag = WireFormat.makeTag(WireFormat.getTagFieldNumber(tag), WIRETYPE_END_GROUP); try { schema.mergeFrom(target, this, extensionRegistry); if (tag != endGroupTag) { throw InvalidProtocolBufferException.parseFailure(); } } finally { // Restore the old end group tag. endGroupTag = prevEndGroupTag; } } @Override public ByteString readBytes() throws IOException { requireWireType(WIRETYPE_LENGTH_DELIMITED); int size = readVarint32(); if (size == 0) { return ByteString.EMPTY; } requireBytes(size); ByteString bytes = bufferIsImmutable ? ByteString.wrap(buffer, pos, size) : ByteString.copyFrom(buffer, pos, size); pos += size; return bytes; } @Override public int readUInt32() throws IOException { requireWireType(WIRETYPE_VARINT); return readVarint32(); } @Override public int readEnum() throws IOException { requireWireType(WIRETYPE_VARINT); return readVarint32(); } @Override public int readSFixed32() throws IOException { requireWireType(WIRETYPE_FIXED32); return readLittleEndian32(); } @Override public long readSFixed64() throws IOException { requireWireType(WIRETYPE_FIXED64); return readLittleEndian64(); } @Override public int readSInt32() throws IOException { requireWireType(WIRETYPE_VARINT); return CodedInputStream.decodeZigZag32(readVarint32()); } @Override public long readSInt64() throws IOException { requireWireType(WIRETYPE_VARINT); return CodedInputStream.decodeZigZag64(readVarint64()); } @Override public void readDoubleList(List<Double> target) throws IOException { if (target instanceof DoubleArrayList) { DoubleArrayList plist = (DoubleArrayList) target; switch (WireFormat.getTagWireType(tag)) { case WIRETYPE_LENGTH_DELIMITED: final int bytes = readVarint32(); verifyPackedFixed64Length(bytes); final int fieldEndPos = pos + bytes; while (pos < fieldEndPos) { plist.addDouble(Double.longBitsToDouble(readLittleEndian64_NoCheck())); } break; case WIRETYPE_FIXED64: while (true) { plist.addDouble(readDouble()); if (isAtEnd()) { return; } int prevPos = pos; int nextTag = readVarint32(); if (nextTag != tag) { // We've reached the end of the repeated field. Rewind the buffer position to before // the new tag. pos = prevPos; return; } } default: throw InvalidProtocolBufferException.invalidWireType(); } } else { switch (WireFormat.getTagWireType(tag)) { case WIRETYPE_LENGTH_DELIMITED: final int bytes = readVarint32(); verifyPackedFixed64Length(bytes); final int fieldEndPos = pos + bytes; while (pos < fieldEndPos) { target.add(Double.longBitsToDouble(readLittleEndian64_NoCheck())); } break; case WIRETYPE_FIXED64: while (true) { target.add(readDouble()); if (isAtEnd()) { return; } int prevPos = pos; int nextTag = readVarint32(); if (nextTag != tag) { // We've reached the end of the repeated field. Rewind the buffer position to before // the new tag. pos = prevPos; return; } } default: throw InvalidProtocolBufferException.invalidWireType(); } } } @Override public void readFloatList(List<Float> target) throws IOException { if (target instanceof FloatArrayList) { FloatArrayList plist = (FloatArrayList) target; switch (WireFormat.getTagWireType(tag)) { case WIRETYPE_LENGTH_DELIMITED: final int bytes = readVarint32(); verifyPackedFixed32Length(bytes); final int fieldEndPos = pos + bytes; while (pos < fieldEndPos) { plist.addFloat(Float.intBitsToFloat(readLittleEndian32_NoCheck())); } break; case WIRETYPE_FIXED32: while (true) { plist.addFloat(readFloat()); if (isAtEnd()) { return; } int prevPos = pos; int nextTag = readVarint32(); if (nextTag != tag) { // We've reached the end of the repeated field. Rewind the buffer position to before // the new tag. pos = prevPos; return; } } default: throw InvalidProtocolBufferException.invalidWireType(); } } else { switch (WireFormat.getTagWireType(tag)) { case WIRETYPE_LENGTH_DELIMITED: final int bytes = readVarint32(); verifyPackedFixed32Length(bytes); final int fieldEndPos = pos + bytes; while (pos < fieldEndPos) { target.add(Float.intBitsToFloat(readLittleEndian32_NoCheck())); } break; case WIRETYPE_FIXED32: while (true) { target.add(readFloat()); if (isAtEnd()) { return; } int prevPos = pos; int nextTag = readVarint32(); if (nextTag != tag) { // We've reached the end of the repeated field. Rewind the buffer position to before // the new tag. pos = prevPos; return; } } default: throw InvalidProtocolBufferException.invalidWireType(); } } } @Override public void readUInt64List(List<Long> target) throws IOException { if (target instanceof LongArrayList) { LongArrayList plist = (LongArrayList) target; switch (WireFormat.getTagWireType(tag)) { case WIRETYPE_LENGTH_DELIMITED: final int bytes = readVarint32(); final int fieldEndPos = pos + bytes; while (pos < fieldEndPos) { plist.addLong(readVarint64()); } requirePosition(fieldEndPos); break; case WIRETYPE_VARINT: while (true) { plist.addLong(readUInt64()); if (isAtEnd()) { return; } int prevPos = pos; int nextTag = readVarint32(); if (nextTag != tag) { // We've reached the end of the repeated field. Rewind the buffer position to before // the new tag. pos = prevPos; return; } } default: throw InvalidProtocolBufferException.invalidWireType(); } } else { switch (WireFormat.getTagWireType(tag)) { case WIRETYPE_LENGTH_DELIMITED: final int bytes = readVarint32(); final int fieldEndPos = pos + bytes; while (pos < fieldEndPos) { target.add(readVarint64()); } requirePosition(fieldEndPos); break; case WIRETYPE_VARINT: while (true) { target.add(readUInt64()); if (isAtEnd()) { return; } int prevPos = pos; int nextTag = readVarint32(); if (nextTag != tag) { // We've reached the end of the repeated field. Rewind the buffer position to before // the new tag. pos = prevPos; return; } } default: throw InvalidProtocolBufferException.invalidWireType(); } } } @Override public void readInt64List(List<Long> target) throws IOException { if (target instanceof LongArrayList) { LongArrayList plist = (LongArrayList) target; switch (WireFormat.getTagWireType(tag)) { case WIRETYPE_LENGTH_DELIMITED: final int bytes = readVarint32(); final int fieldEndPos = pos + bytes; while (pos < fieldEndPos) { plist.addLong(readVarint64()); } requirePosition(fieldEndPos); break; case WIRETYPE_VARINT: while (true) { plist.addLong(readInt64()); if (isAtEnd()) { return; } int prevPos = pos; int nextTag = readVarint32(); if (nextTag != tag) { // We've reached the end of the repeated field. Rewind the buffer position to before // the new tag. pos = prevPos; return; } } default: throw InvalidProtocolBufferException.invalidWireType(); } } else { switch (WireFormat.getTagWireType(tag)) { case WIRETYPE_LENGTH_DELIMITED: final int bytes = readVarint32(); final int fieldEndPos = pos + bytes; while (pos < fieldEndPos) { target.add(readVarint64()); } requirePosition(fieldEndPos); break; case WIRETYPE_VARINT: while (true) { target.add(readInt64()); if (isAtEnd()) { return; } int prevPos = pos; int nextTag = readVarint32(); if (nextTag != tag) { // We've reached the end of the repeated field. Rewind the buffer position to before // the new tag. pos = prevPos; return; } } default: throw InvalidProtocolBufferException.invalidWireType(); } } } @Override public void readInt32List(List<Integer> target) throws IOException { if (target instanceof IntArrayList) { IntArrayList plist = (IntArrayList) target; switch (WireFormat.getTagWireType(tag)) { case WIRETYPE_LENGTH_DELIMITED: final int bytes = readVarint32(); final int fieldEndPos = pos + bytes; while (pos < fieldEndPos) { plist.addInt(readVarint32()); } requirePosition(fieldEndPos); break; case WIRETYPE_VARINT: while (true) { plist.addInt(readInt32()); if (isAtEnd()) { return; } int prevPos = pos; int nextTag = readVarint32(); if (nextTag != tag) { // We've reached the end of the repeated field. Rewind the buffer position to before // the new tag. pos = prevPos; return; } } default: throw InvalidProtocolBufferException.invalidWireType(); } } else { switch (WireFormat.getTagWireType(tag)) { case WIRETYPE_LENGTH_DELIMITED: final int bytes = readVarint32(); final int fieldEndPos = pos + bytes; while (pos < fieldEndPos) { target.add(readVarint32()); } requirePosition(fieldEndPos); break; case WIRETYPE_VARINT: while (true) { target.add(readInt32()); if (isAtEnd()) { return; } int prevPos = pos; int nextTag = readVarint32(); if (nextTag != tag) { // We've reached the end of the repeated field. Rewind the buffer position to before // the new tag. pos = prevPos; return; } } default: throw InvalidProtocolBufferException.invalidWireType(); } } } @Override public void readFixed64List(List<Long> target) throws IOException { if (target instanceof LongArrayList) { LongArrayList plist = (LongArrayList) target; switch (WireFormat.getTagWireType(tag)) { case WIRETYPE_LENGTH_DELIMITED: final int bytes = readVarint32(); verifyPackedFixed64Length(bytes); final int fieldEndPos = pos + bytes; while (pos < fieldEndPos) { plist.addLong(readLittleEndian64_NoCheck()); } break; case WIRETYPE_FIXED64: while (true) { plist.addLong(readFixed64()); if (isAtEnd()) { return; } int prevPos = pos; int nextTag = readVarint32(); if (nextTag != tag) { // We've reached the end of the repeated field. Rewind the buffer position to before // the new tag. pos = prevPos; return; } } default: throw InvalidProtocolBufferException.invalidWireType(); } } else { switch (WireFormat.getTagWireType(tag)) { case WIRETYPE_LENGTH_DELIMITED: final int bytes = readVarint32(); verifyPackedFixed64Length(bytes); final int fieldEndPos = pos + bytes; while (pos < fieldEndPos) { target.add(readLittleEndian64_NoCheck()); } break; case WIRETYPE_FIXED64: while (true) { target.add(readFixed64()); if (isAtEnd()) { return; } int prevPos = pos; int nextTag = readVarint32(); if (nextTag != tag) { // We've reached the end of the repeated field. Rewind the buffer position to before // the new tag. pos = prevPos; return; } } default: throw InvalidProtocolBufferException.invalidWireType(); } } } @Override public void readFixed32List(List<Integer> target) throws IOException { if (target instanceof IntArrayList) { IntArrayList plist = (IntArrayList) target; switch (WireFormat.getTagWireType(tag)) { case WIRETYPE_LENGTH_DELIMITED: final int bytes = readVarint32(); verifyPackedFixed32Length(bytes); final int fieldEndPos = pos + bytes; while (pos < fieldEndPos) { plist.addInt(readLittleEndian32_NoCheck()); } break; case WIRETYPE_FIXED32: while (true) { plist.addInt(readFixed32()); if (isAtEnd()) { return; } int prevPos = pos; int nextTag = readVarint32(); if (nextTag != tag) { // We've reached the end of the repeated field. Rewind the buffer position to before // the new tag. pos = prevPos; return; } } default: throw InvalidProtocolBufferException.invalidWireType(); } } else { switch (WireFormat.getTagWireType(tag)) { case WIRETYPE_LENGTH_DELIMITED: final int bytes = readVarint32(); verifyPackedFixed32Length(bytes); final int fieldEndPos = pos + bytes; while (pos < fieldEndPos) { target.add(readLittleEndian32_NoCheck()); } break; case WIRETYPE_FIXED32: while (true) { target.add(readFixed32()); if (isAtEnd()) { return; } int prevPos = pos; int nextTag = readVarint32(); if (nextTag != tag) { // We've reached the end of the repeated field. Rewind the buffer position to before // the new tag. pos = prevPos; return; } } default: throw InvalidProtocolBufferException.invalidWireType(); } } } @Override public void readBoolList(List<Boolean> target) throws IOException { if (target instanceof BooleanArrayList) { BooleanArrayList plist = (BooleanArrayList) target; switch (WireFormat.getTagWireType(tag)) { case WIRETYPE_LENGTH_DELIMITED: final int bytes = readVarint32(); final int fieldEndPos = pos + bytes; while (pos < fieldEndPos) { plist.addBoolean(readVarint32() != 0); } requirePosition(fieldEndPos); break; case WIRETYPE_VARINT: while (true) { plist.addBoolean(readBool()); if (isAtEnd()) { return; } int prevPos = pos; int nextTag = readVarint32(); if (nextTag != tag) { // We've reached the end of the repeated field. Rewind the buffer position to before // the new tag. pos = prevPos; return; } } default: throw InvalidProtocolBufferException.invalidWireType(); } } else { switch (WireFormat.getTagWireType(tag)) { case WIRETYPE_LENGTH_DELIMITED: final int bytes = readVarint32(); final int fieldEndPos = pos + bytes; while (pos < fieldEndPos) { target.add(readVarint32() != 0); } requirePosition(fieldEndPos); break; case WIRETYPE_VARINT: while (true) { target.add(readBool()); if (isAtEnd()) { return; } int prevPos = pos; int nextTag = readVarint32(); if (nextTag != tag) { // We've reached the end of the repeated field. Rewind the buffer position to before // the new tag. pos = prevPos; return; } } default: throw InvalidProtocolBufferException.invalidWireType(); } } } @Override public void readStringList(List<String> target) throws IOException { readStringListInternal(target, false); } @Override public void readStringListRequireUtf8(List<String> target) throws IOException { readStringListInternal(target, true); } public void readStringListInternal(List<String> target, boolean requireUtf8) throws IOException { if (WireFormat.getTagWireType(tag) != WIRETYPE_LENGTH_DELIMITED) { throw InvalidProtocolBufferException.invalidWireType(); } if (target instanceof LazyStringList && !requireUtf8) { LazyStringList lazyList = (LazyStringList) target; while (true) { lazyList.add(readBytes()); if (isAtEnd()) { return; } int prevPos = pos; int nextTag = readVarint32(); if (nextTag != tag) { // We've reached the end of the repeated field. Rewind the buffer position to before // the new tag. pos = prevPos; return; } } } else { while (true) { target.add(readStringInternal(requireUtf8)); if (isAtEnd()) { return; } int prevPos = pos; int nextTag = readVarint32(); if (nextTag != tag) { // We've reached the end of the repeated field. Rewind the buffer position to before // the new tag. pos = prevPos; return; } } } } @Override public <T> void readMessageList( List<T> target, Class<T> targetType, ExtensionRegistryLite extensionRegistry) throws IOException { final Schema<T> schema = Protobuf.getInstance().schemaFor(targetType); readMessageList(target, schema, extensionRegistry); } @Override public <T> void readMessageList( List<T> target, Schema<T> schema, ExtensionRegistryLite extensionRegistry) throws IOException { if (WireFormat.getTagWireType(tag) != WIRETYPE_LENGTH_DELIMITED) { throw InvalidProtocolBufferException.invalidWireType(); } final int listTag = tag; while (true) { target.add(readMessage(schema, extensionRegistry)); if (isAtEnd()) { return; } int prevPos = pos; int nextTag = readVarint32(); if (nextTag != listTag) { // We've reached the end of the repeated field. Rewind the buffer position to before // the new tag. pos = prevPos; return; } } } @Deprecated @Override public <T> void readGroupList( List<T> target, Class<T> targetType, ExtensionRegistryLite extensionRegistry) throws IOException { final Schema<T> schema = Protobuf.getInstance().schemaFor(targetType); readGroupList(target, schema, extensionRegistry); } @Deprecated @Override public <T> void readGroupList( List<T> target, Schema<T> schema, ExtensionRegistryLite extensionRegistry) throws IOException { if (WireFormat.getTagWireType(tag) != WIRETYPE_START_GROUP) { throw InvalidProtocolBufferException.invalidWireType(); } final int listTag = tag; while (true) { target.add(readGroup(schema, extensionRegistry)); if (isAtEnd()) { return; } int prevPos = pos; int nextTag = readVarint32(); if (nextTag != listTag) { // We've reached the end of the repeated field. Rewind the buffer position to before // the new tag. pos = prevPos; return; } } } @Override public void readBytesList(List<ByteString> target) throws IOException { if (WireFormat.getTagWireType(tag) != WIRETYPE_LENGTH_DELIMITED) { throw InvalidProtocolBufferException.invalidWireType(); } while (true) { target.add(readBytes()); if (isAtEnd()) { return; } int prevPos = pos; int nextTag = readVarint32(); if (nextTag != tag) { // We've reached the end of the repeated field. Rewind the buffer position to before // the new tag. pos = prevPos; return; } } } @Override public void readUInt32List(List<Integer> target) throws IOException { if (target instanceof IntArrayList) { IntArrayList plist = (IntArrayList) target; switch (WireFormat.getTagWireType(tag)) { case WIRETYPE_LENGTH_DELIMITED: final int bytes = readVarint32(); final int fieldEndPos = pos + bytes; while (pos < fieldEndPos) { plist.addInt(readVarint32()); } break; case WIRETYPE_VARINT: while (true) { plist.addInt(readUInt32()); if (isAtEnd()) { return; } int prevPos = pos; int nextTag = readVarint32(); if (nextTag != tag) { // We've reached the end of the repeated field. Rewind the buffer position to before // the new tag. pos = prevPos; return; } } default: throw InvalidProtocolBufferException.invalidWireType(); } } else { switch (WireFormat.getTagWireType(tag)) { case WIRETYPE_LENGTH_DELIMITED: final int bytes = readVarint32(); final int fieldEndPos = pos + bytes; while (pos < fieldEndPos) { target.add(readVarint32()); } break; case WIRETYPE_VARINT: while (true) { target.add(readUInt32()); if (isAtEnd()) { return; } int prevPos = pos; int nextTag = readVarint32(); if (nextTag != tag) { // We've reached the end of the repeated field. Rewind the buffer position to before // the new tag. pos = prevPos; return; } } default: throw InvalidProtocolBufferException.invalidWireType(); } } } @Override public void readEnumList(List<Integer> target) throws IOException { if (target instanceof IntArrayList) { IntArrayList plist = (IntArrayList) target; switch (WireFormat.getTagWireType(tag)) { case WIRETYPE_LENGTH_DELIMITED: final int bytes = readVarint32(); final int fieldEndPos = pos + bytes; while (pos < fieldEndPos) { plist.addInt(readVarint32()); } break; case WIRETYPE_VARINT: while (true) { plist.addInt(readEnum()); if (isAtEnd()) { return; } int prevPos = pos; int nextTag = readVarint32(); if (nextTag != tag) { // We've reached the end of the repeated field. Rewind the buffer position to before // the new tag. pos = prevPos; return; } } default: throw InvalidProtocolBufferException.invalidWireType(); } } else { switch (WireFormat.getTagWireType(tag)) { case WIRETYPE_LENGTH_DELIMITED: final int bytes = readVarint32(); final int fieldEndPos = pos + bytes; while (pos < fieldEndPos) { target.add(readVarint32()); } break; case WIRETYPE_VARINT: while (true) { target.add(readEnum()); if (isAtEnd()) { return; } int prevPos = pos; int nextTag = readVarint32(); if (nextTag != tag) { // We've reached the end of the repeated field. Rewind the buffer position to before // the new tag. pos = prevPos; return; } } default: throw InvalidProtocolBufferException.invalidWireType(); } } } @Override public void readSFixed32List(List<Integer> target) throws IOException { if (target instanceof IntArrayList) { IntArrayList plist = (IntArrayList) target; switch (WireFormat.getTagWireType(tag)) { case WIRETYPE_LENGTH_DELIMITED: final int bytes = readVarint32(); verifyPackedFixed32Length(bytes); final int fieldEndPos = pos + bytes; while (pos < fieldEndPos) { plist.addInt(readLittleEndian32_NoCheck()); } break; case WIRETYPE_FIXED32: while (true) { plist.addInt(readSFixed32()); if (isAtEnd()) { return; } int prevPos = pos; int nextTag = readVarint32(); if (nextTag != tag) { // We've reached the end of the repeated field. Rewind the buffer position to before // the new tag. pos = prevPos; return; } } default: throw InvalidProtocolBufferException.invalidWireType(); } } else { switch (WireFormat.getTagWireType(tag)) { case WIRETYPE_LENGTH_DELIMITED: final int bytes = readVarint32(); verifyPackedFixed32Length(bytes); final int fieldEndPos = pos + bytes; while (pos < fieldEndPos) { target.add(readLittleEndian32_NoCheck()); } break; case WIRETYPE_FIXED32: while (true) { target.add(readSFixed32()); if (isAtEnd()) { return; } int prevPos = pos; int nextTag = readVarint32(); if (nextTag != tag) { // We've reached the end of the repeated field. Rewind the buffer position to before // the new tag. pos = prevPos; return; } } default: throw InvalidProtocolBufferException.invalidWireType(); } } } @Override public void readSFixed64List(List<Long> target) throws IOException { if (target instanceof LongArrayList) { LongArrayList plist = (LongArrayList) target; switch (WireFormat.getTagWireType(tag)) { case WIRETYPE_LENGTH_DELIMITED: final int bytes = readVarint32(); verifyPackedFixed64Length(bytes); final int fieldEndPos = pos + bytes; while (pos < fieldEndPos) { plist.addLong(readLittleEndian64_NoCheck()); } break; case WIRETYPE_FIXED64: while (true) { plist.addLong(readSFixed64()); if (isAtEnd()) { return; } int prevPos = pos; int nextTag = readVarint32(); if (nextTag != tag) { // We've reached the end of the repeated field. Rewind the buffer position to before // the new tag. pos = prevPos; return; } } default: throw InvalidProtocolBufferException.invalidWireType(); } } else { switch (WireFormat.getTagWireType(tag)) { case WIRETYPE_LENGTH_DELIMITED: final int bytes = readVarint32(); verifyPackedFixed64Length(bytes); final int fieldEndPos = pos + bytes; while (pos < fieldEndPos) { target.add(readLittleEndian64_NoCheck()); } break; case WIRETYPE_FIXED64: while (true) { target.add(readSFixed64()); if (isAtEnd()) { return; } int prevPos = pos; int nextTag = readVarint32(); if (nextTag != tag) { // We've reached the end of the repeated field. Rewind the buffer position to before // the new tag. pos = prevPos; return; } } default: throw InvalidProtocolBufferException.invalidWireType(); } } } @Override public void readSInt32List(List<Integer> target) throws IOException { if (target instanceof IntArrayList) { IntArrayList plist = (IntArrayList) target; switch (WireFormat.getTagWireType(tag)) { case WIRETYPE_LENGTH_DELIMITED: final int bytes = readVarint32(); final int fieldEndPos = pos + bytes; while (pos < fieldEndPos) { plist.addInt(CodedInputStream.decodeZigZag32(readVarint32())); } break; case WIRETYPE_VARINT: while (true) { plist.addInt(readSInt32()); if (isAtEnd()) { return; } int prevPos = pos; int nextTag = readVarint32(); if (nextTag != tag) { // We've reached the end of the repeated field. Rewind the buffer position to before // the new tag. pos = prevPos; return; } } default: throw InvalidProtocolBufferException.invalidWireType(); } } else { switch (WireFormat.getTagWireType(tag)) { case WIRETYPE_LENGTH_DELIMITED: final int bytes = readVarint32(); final int fieldEndPos = pos + bytes; while (pos < fieldEndPos) { target.add(CodedInputStream.decodeZigZag32(readVarint32())); } break; case WIRETYPE_VARINT: while (true) { target.add(readSInt32()); if (isAtEnd()) { return; } int prevPos = pos; int nextTag = readVarint32(); if (nextTag != tag) { // We've reached the end of the repeated field. Rewind the buffer position to before // the new tag. pos = prevPos; return; } } default: throw InvalidProtocolBufferException.invalidWireType(); } } } @Override public void readSInt64List(List<Long> target) throws IOException { if (target instanceof LongArrayList) { LongArrayList plist = (LongArrayList) target; switch (WireFormat.getTagWireType(tag)) { case WIRETYPE_LENGTH_DELIMITED: final int bytes = readVarint32(); final int fieldEndPos = pos + bytes; while (pos < fieldEndPos) { plist.addLong(CodedInputStream.decodeZigZag64(readVarint64())); } break; case WIRETYPE_VARINT: while (true) { plist.addLong(readSInt64()); if (isAtEnd()) { return; } int prevPos = pos; int nextTag = readVarint32(); if (nextTag != tag) { // We've reached the end of the repeated field. Rewind the buffer position to before // the new tag. pos = prevPos; return; } } default: throw InvalidProtocolBufferException.invalidWireType(); } } else { switch (WireFormat.getTagWireType(tag)) { case WIRETYPE_LENGTH_DELIMITED: final int bytes = readVarint32(); final int fieldEndPos = pos + bytes; while (pos < fieldEndPos) { target.add(CodedInputStream.decodeZigZag64(readVarint64())); } break; case WIRETYPE_VARINT: while (true) { target.add(readSInt64()); if (isAtEnd()) { return; } int prevPos = pos; int nextTag = readVarint32(); if (nextTag != tag) { // We've reached the end of the repeated field. Rewind the buffer position to before // the new tag. pos = prevPos; return; } } default: throw InvalidProtocolBufferException.invalidWireType(); } } } @SuppressWarnings("unchecked") @Override public <K, V> void readMap( Map<K, V> target, MapEntryLite.Metadata<K, V> metadata, ExtensionRegistryLite extensionRegistry) throws IOException { requireWireType(WIRETYPE_LENGTH_DELIMITED); int size = readVarint32(); requireBytes(size); // Update the limit. int prevLimit = limit; int newLimit = pos + size; limit = newLimit; try { K key = metadata.defaultKey; V value = metadata.defaultValue; while (true) { int number = getFieldNumber(); if (number == READ_DONE) { break; } try { switch (number) { case 1: key = (K) readField(metadata.keyType, null, null); break; case 2: value = (V) readField( metadata.valueType, metadata.defaultValue.getClass(), extensionRegistry); break; default: if (!skipField()) { throw new InvalidProtocolBufferException("Unable to parse map entry."); } break; } } catch (InvalidProtocolBufferException.InvalidWireTypeException ignore) { // the type doesn't match, skip the field. if (!skipField()) { throw new InvalidProtocolBufferException("Unable to parse map entry."); } } } target.put(key, value); } finally { // Restore the limit. limit = prevLimit; } } private Object readField( WireFormat.FieldType fieldType, Class<?> messageType, ExtensionRegistryLite extensionRegistry) throws IOException { switch (fieldType) { case BOOL: return readBool(); case BYTES: return readBytes(); case DOUBLE: return readDouble(); case ENUM: return readEnum(); case FIXED32: return readFixed32(); case FIXED64: return readFixed64(); case FLOAT: return readFloat(); case INT32: return readInt32(); case INT64: return readInt64(); case MESSAGE: return readMessage(messageType, extensionRegistry); case SFIXED32: return readSFixed32(); case SFIXED64: return readSFixed64(); case SINT32: return readSInt32(); case SINT64: return readSInt64(); case STRING: return readStringRequireUtf8(); case UINT32: return readUInt32(); case UINT64: return readUInt64(); default: throw new RuntimeException("unsupported field type."); } } /** Read a raw Varint from the stream. If larger than 32 bits, discard the upper bits.
SafeHeapReader::readVarint32
java
Reginer/aosp-android-jar
android-34/src/com/google/protobuf/BinaryReader.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-34/src/com/google/protobuf/BinaryReader.java
MIT
public Rect getNonMinimizedSplitScreenSecondaryBounds() { mOtherTaskRect.set(mSplitLayout.mSecondary); return mOtherTaskRect; }
How much the background gets scaled when we are in the minimized dock state. private static final float MINIMIZE_DOCK_SCALE = 0f; private static final float ADJUSTED_FOR_IME_SCALE = 0.5f; private static final Interpolator IME_ADJUST_INTERPOLATOR = new PathInterpolator(0.2f, 0f, 0.1f, 1f); private DividerHandleView mHandle; private View mBackground; private MinimizedDockShadow mMinimizedShadow; private int mStartX; private int mStartY; private int mStartPosition; private int mDockSide; private boolean mMoving; private int mTouchSlop; private boolean mBackgroundLifted; private boolean mIsInMinimizeInteraction; SnapTarget mSnapTargetBeforeMinimized; private int mDividerInsets; private final Display mDefaultDisplay; private int mDividerSize; private int mTouchElevation; private int mLongPressEntraceAnimDuration; private final Rect mDockedRect = new Rect(); private final Rect mDockedTaskRect = new Rect(); private final Rect mOtherTaskRect = new Rect(); private final Rect mOtherRect = new Rect(); private final Rect mDockedInsetRect = new Rect(); private final Rect mOtherInsetRect = new Rect(); private final Rect mLastResizeRect = new Rect(); private final Rect mTmpRect = new Rect(); private LegacySplitScreenController mSplitScreenController; private WindowManagerProxy mWindowManagerProxy; private DividerWindowManager mWindowManager; private VelocityTracker mVelocityTracker; private FlingAnimationUtils mFlingAnimationUtils; private LegacySplitDisplayLayout mSplitLayout; private DividerImeController mImeController; private DividerCallbacks mCallback; private AnimationHandler mSfVsyncAnimationHandler; private ValueAnimator mCurrentAnimator; private boolean mEntranceAnimationRunning; private boolean mExitAnimationRunning; private int mExitStartPosition; private boolean mDockedStackMinimized; private boolean mHomeStackResizable; private boolean mAdjustedForIme; private DividerState mState; private LegacySplitScreenTaskListener mTiles; boolean mFirstLayout = true; int mDividerPositionX; int mDividerPositionY; private final Matrix mTmpMatrix = new Matrix(); private final float[] mTmpValues = new float[9]; // The view is removed or in the process of been removed from the system. private boolean mRemoved; // Whether the surface for this view has been hidden regardless of actual visibility. This is // used interact with keyguard. private boolean mSurfaceHidden = false; private final AccessibilityDelegate mHandleDelegate = new AccessibilityDelegate() { @Override public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfo info) { super.onInitializeAccessibilityNodeInfo(host, info); final DividerSnapAlgorithm snapAlgorithm = getSnapAlgorithm(); if (isHorizontalDivision()) { info.addAction(new AccessibilityAction(R.id.action_move_tl_full, mContext.getString(R.string.accessibility_action_divider_top_full))); if (snapAlgorithm.isFirstSplitTargetAvailable()) { info.addAction(new AccessibilityAction(R.id.action_move_tl_70, mContext.getString(R.string.accessibility_action_divider_top_70))); } if (snapAlgorithm.showMiddleSplitTargetForAccessibility()) { // Only show the middle target if there are more than 1 split target info.addAction(new AccessibilityAction(R.id.action_move_tl_50, mContext.getString(R.string.accessibility_action_divider_top_50))); } if (snapAlgorithm.isLastSplitTargetAvailable()) { info.addAction(new AccessibilityAction(R.id.action_move_tl_30, mContext.getString(R.string.accessibility_action_divider_top_30))); } info.addAction(new AccessibilityAction(R.id.action_move_rb_full, mContext.getString(R.string.accessibility_action_divider_bottom_full))); } else { info.addAction(new AccessibilityAction(R.id.action_move_tl_full, mContext.getString(R.string.accessibility_action_divider_left_full))); if (snapAlgorithm.isFirstSplitTargetAvailable()) { info.addAction(new AccessibilityAction(R.id.action_move_tl_70, mContext.getString(R.string.accessibility_action_divider_left_70))); } if (snapAlgorithm.showMiddleSplitTargetForAccessibility()) { // Only show the middle target if there are more than 1 split target info.addAction(new AccessibilityAction(R.id.action_move_tl_50, mContext.getString(R.string.accessibility_action_divider_left_50))); } if (snapAlgorithm.isLastSplitTargetAvailable()) { info.addAction(new AccessibilityAction(R.id.action_move_tl_30, mContext.getString(R.string.accessibility_action_divider_left_30))); } info.addAction(new AccessibilityAction(R.id.action_move_rb_full, mContext.getString(R.string.accessibility_action_divider_right_full))); } } @Override public boolean performAccessibilityAction(View host, int action, Bundle args) { int currentPosition = getCurrentPosition(); SnapTarget nextTarget = null; DividerSnapAlgorithm snapAlgorithm = mSplitLayout.getSnapAlgorithm(); if (action == R.id.action_move_tl_full) { nextTarget = snapAlgorithm.getDismissEndTarget(); } else if (action == R.id.action_move_tl_70) { nextTarget = snapAlgorithm.getLastSplitTarget(); } else if (action == R.id.action_move_tl_50) { nextTarget = snapAlgorithm.getMiddleTarget(); } else if (action == R.id.action_move_tl_30) { nextTarget = snapAlgorithm.getFirstSplitTarget(); } else if (action == R.id.action_move_rb_full) { nextTarget = snapAlgorithm.getDismissStartTarget(); } if (nextTarget != null) { startDragging(true /* animate */, false /* touching */); stopDragging(currentPosition, nextTarget, 250, Interpolators.FAST_OUT_SLOW_IN); return true; } return super.performAccessibilityAction(host, action, args); } }; private final Runnable mResetBackgroundRunnable = new Runnable() { @Override public void run() { resetBackground(); } }; public DividerView(Context context) { this(context, null); } public DividerView(Context context, @Nullable AttributeSet attrs) { this(context, attrs, 0); } public DividerView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { this(context, attrs, defStyleAttr, 0); } public DividerView(Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); final DisplayManager displayManager = (DisplayManager) mContext.getSystemService(Context.DISPLAY_SERVICE); mDefaultDisplay = displayManager.getDisplay(Display.DEFAULT_DISPLAY); } public void setAnimationHandler(AnimationHandler sfVsyncAnimationHandler) { mSfVsyncAnimationHandler = sfVsyncAnimationHandler; } @Override protected void onFinishInflate() { super.onFinishInflate(); mHandle = findViewById(R.id.docked_divider_handle); mBackground = findViewById(R.id.docked_divider_background); mMinimizedShadow = findViewById(R.id.minimized_dock_shadow); mHandle.setOnTouchListener(this); final int dividerWindowWidth = getResources().getDimensionPixelSize( com.android.internal.R.dimen.docked_stack_divider_thickness); mDividerInsets = getResources().getDimensionPixelSize( com.android.internal.R.dimen.docked_stack_divider_insets); mDividerSize = dividerWindowWidth - 2 * mDividerInsets; mTouchElevation = getResources().getDimensionPixelSize( R.dimen.docked_stack_divider_lift_elevation); mLongPressEntraceAnimDuration = getResources().getInteger( R.integer.long_press_dock_anim_duration); mTouchSlop = ViewConfiguration.get(mContext).getScaledTouchSlop(); mFlingAnimationUtils = new FlingAnimationUtils(getResources().getDisplayMetrics(), 0.3f); boolean landscape = getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE; mHandle.setPointerIcon(PointerIcon.getSystemIcon(getContext(), landscape ? TYPE_HORIZONTAL_DOUBLE_ARROW : TYPE_VERTICAL_DOUBLE_ARROW)); getViewTreeObserver().addOnComputeInternalInsetsListener(this); mHandle.setAccessibilityDelegate(mHandleDelegate); } @Override protected void onAttachedToWindow() { super.onAttachedToWindow(); // Save the current target if not minimized once attached to window if (mDockSide != WindowManager.DOCKED_INVALID && !mIsInMinimizeInteraction) { saveSnapTargetBeforeMinimized(mSnapTargetBeforeMinimized); } mFirstLayout = true; } void onDividerRemoved() { mRemoved = true; mCallback = null; } @Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { super.onLayout(changed, left, top, right, bottom); if (mFirstLayout) { // Wait for first layout so that the ViewRootImpl surface has been created. initializeSurfaceState(); mFirstLayout = false; } int minimizeLeft = 0; int minimizeTop = 0; if (mDockSide == WindowManager.DOCKED_TOP) { minimizeTop = mBackground.getTop(); } else if (mDockSide == WindowManager.DOCKED_LEFT) { minimizeLeft = mBackground.getLeft(); } else if (mDockSide == WindowManager.DOCKED_RIGHT) { minimizeLeft = mBackground.getRight() - mMinimizedShadow.getWidth(); } mMinimizedShadow.layout(minimizeLeft, minimizeTop, minimizeLeft + mMinimizedShadow.getMeasuredWidth(), minimizeTop + mMinimizedShadow.getMeasuredHeight()); if (changed) { notifySplitScreenBoundsChanged(); } } void injectDependencies(LegacySplitScreenController splitScreenController, DividerWindowManager windowManager, DividerState dividerState, DividerCallbacks callback, LegacySplitScreenTaskListener tiles, LegacySplitDisplayLayout sdl, DividerImeController imeController, WindowManagerProxy wmProxy) { mSplitScreenController = splitScreenController; mWindowManager = windowManager; mState = dividerState; mCallback = callback; mTiles = tiles; mSplitLayout = sdl; mImeController = imeController; mWindowManagerProxy = wmProxy; if (mState.mRatioPositionBeforeMinimized == 0) { // Set the middle target as the initial state mSnapTargetBeforeMinimized = mSplitLayout.getSnapAlgorithm().getMiddleTarget(); } else { repositionSnapTargetBeforeMinimized(); } } /** Gets non-minimized secondary bounds of split screen.
DividerView::getNonMinimizedSplitScreenSecondaryBounds
java
Reginer/aosp-android-jar
android-33/src/com/android/wm/shell/legacysplitscreen/DividerView.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/wm/shell/legacysplitscreen/DividerView.java
MIT
void setHidden(boolean hidden) { if (mSurfaceHidden == hidden) { return; } mSurfaceHidden = hidden; post(() -> { final SurfaceControl sc = getWindowSurfaceControl(); if (sc == null) { return; } Transaction t = mTiles.getTransaction(); if (hidden) { t.hide(sc); } else { t.show(sc); } mImeController.setDimsHidden(t, hidden); t.apply(); mTiles.releaseTransaction(t); }); }
How much the background gets scaled when we are in the minimized dock state. private static final float MINIMIZE_DOCK_SCALE = 0f; private static final float ADJUSTED_FOR_IME_SCALE = 0.5f; private static final Interpolator IME_ADJUST_INTERPOLATOR = new PathInterpolator(0.2f, 0f, 0.1f, 1f); private DividerHandleView mHandle; private View mBackground; private MinimizedDockShadow mMinimizedShadow; private int mStartX; private int mStartY; private int mStartPosition; private int mDockSide; private boolean mMoving; private int mTouchSlop; private boolean mBackgroundLifted; private boolean mIsInMinimizeInteraction; SnapTarget mSnapTargetBeforeMinimized; private int mDividerInsets; private final Display mDefaultDisplay; private int mDividerSize; private int mTouchElevation; private int mLongPressEntraceAnimDuration; private final Rect mDockedRect = new Rect(); private final Rect mDockedTaskRect = new Rect(); private final Rect mOtherTaskRect = new Rect(); private final Rect mOtherRect = new Rect(); private final Rect mDockedInsetRect = new Rect(); private final Rect mOtherInsetRect = new Rect(); private final Rect mLastResizeRect = new Rect(); private final Rect mTmpRect = new Rect(); private LegacySplitScreenController mSplitScreenController; private WindowManagerProxy mWindowManagerProxy; private DividerWindowManager mWindowManager; private VelocityTracker mVelocityTracker; private FlingAnimationUtils mFlingAnimationUtils; private LegacySplitDisplayLayout mSplitLayout; private DividerImeController mImeController; private DividerCallbacks mCallback; private AnimationHandler mSfVsyncAnimationHandler; private ValueAnimator mCurrentAnimator; private boolean mEntranceAnimationRunning; private boolean mExitAnimationRunning; private int mExitStartPosition; private boolean mDockedStackMinimized; private boolean mHomeStackResizable; private boolean mAdjustedForIme; private DividerState mState; private LegacySplitScreenTaskListener mTiles; boolean mFirstLayout = true; int mDividerPositionX; int mDividerPositionY; private final Matrix mTmpMatrix = new Matrix(); private final float[] mTmpValues = new float[9]; // The view is removed or in the process of been removed from the system. private boolean mRemoved; // Whether the surface for this view has been hidden regardless of actual visibility. This is // used interact with keyguard. private boolean mSurfaceHidden = false; private final AccessibilityDelegate mHandleDelegate = new AccessibilityDelegate() { @Override public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfo info) { super.onInitializeAccessibilityNodeInfo(host, info); final DividerSnapAlgorithm snapAlgorithm = getSnapAlgorithm(); if (isHorizontalDivision()) { info.addAction(new AccessibilityAction(R.id.action_move_tl_full, mContext.getString(R.string.accessibility_action_divider_top_full))); if (snapAlgorithm.isFirstSplitTargetAvailable()) { info.addAction(new AccessibilityAction(R.id.action_move_tl_70, mContext.getString(R.string.accessibility_action_divider_top_70))); } if (snapAlgorithm.showMiddleSplitTargetForAccessibility()) { // Only show the middle target if there are more than 1 split target info.addAction(new AccessibilityAction(R.id.action_move_tl_50, mContext.getString(R.string.accessibility_action_divider_top_50))); } if (snapAlgorithm.isLastSplitTargetAvailable()) { info.addAction(new AccessibilityAction(R.id.action_move_tl_30, mContext.getString(R.string.accessibility_action_divider_top_30))); } info.addAction(new AccessibilityAction(R.id.action_move_rb_full, mContext.getString(R.string.accessibility_action_divider_bottom_full))); } else { info.addAction(new AccessibilityAction(R.id.action_move_tl_full, mContext.getString(R.string.accessibility_action_divider_left_full))); if (snapAlgorithm.isFirstSplitTargetAvailable()) { info.addAction(new AccessibilityAction(R.id.action_move_tl_70, mContext.getString(R.string.accessibility_action_divider_left_70))); } if (snapAlgorithm.showMiddleSplitTargetForAccessibility()) { // Only show the middle target if there are more than 1 split target info.addAction(new AccessibilityAction(R.id.action_move_tl_50, mContext.getString(R.string.accessibility_action_divider_left_50))); } if (snapAlgorithm.isLastSplitTargetAvailable()) { info.addAction(new AccessibilityAction(R.id.action_move_tl_30, mContext.getString(R.string.accessibility_action_divider_left_30))); } info.addAction(new AccessibilityAction(R.id.action_move_rb_full, mContext.getString(R.string.accessibility_action_divider_right_full))); } } @Override public boolean performAccessibilityAction(View host, int action, Bundle args) { int currentPosition = getCurrentPosition(); SnapTarget nextTarget = null; DividerSnapAlgorithm snapAlgorithm = mSplitLayout.getSnapAlgorithm(); if (action == R.id.action_move_tl_full) { nextTarget = snapAlgorithm.getDismissEndTarget(); } else if (action == R.id.action_move_tl_70) { nextTarget = snapAlgorithm.getLastSplitTarget(); } else if (action == R.id.action_move_tl_50) { nextTarget = snapAlgorithm.getMiddleTarget(); } else if (action == R.id.action_move_tl_30) { nextTarget = snapAlgorithm.getFirstSplitTarget(); } else if (action == R.id.action_move_rb_full) { nextTarget = snapAlgorithm.getDismissStartTarget(); } if (nextTarget != null) { startDragging(true /* animate */, false /* touching */); stopDragging(currentPosition, nextTarget, 250, Interpolators.FAST_OUT_SLOW_IN); return true; } return super.performAccessibilityAction(host, action, args); } }; private final Runnable mResetBackgroundRunnable = new Runnable() { @Override public void run() { resetBackground(); } }; public DividerView(Context context) { this(context, null); } public DividerView(Context context, @Nullable AttributeSet attrs) { this(context, attrs, 0); } public DividerView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { this(context, attrs, defStyleAttr, 0); } public DividerView(Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); final DisplayManager displayManager = (DisplayManager) mContext.getSystemService(Context.DISPLAY_SERVICE); mDefaultDisplay = displayManager.getDisplay(Display.DEFAULT_DISPLAY); } public void setAnimationHandler(AnimationHandler sfVsyncAnimationHandler) { mSfVsyncAnimationHandler = sfVsyncAnimationHandler; } @Override protected void onFinishInflate() { super.onFinishInflate(); mHandle = findViewById(R.id.docked_divider_handle); mBackground = findViewById(R.id.docked_divider_background); mMinimizedShadow = findViewById(R.id.minimized_dock_shadow); mHandle.setOnTouchListener(this); final int dividerWindowWidth = getResources().getDimensionPixelSize( com.android.internal.R.dimen.docked_stack_divider_thickness); mDividerInsets = getResources().getDimensionPixelSize( com.android.internal.R.dimen.docked_stack_divider_insets); mDividerSize = dividerWindowWidth - 2 * mDividerInsets; mTouchElevation = getResources().getDimensionPixelSize( R.dimen.docked_stack_divider_lift_elevation); mLongPressEntraceAnimDuration = getResources().getInteger( R.integer.long_press_dock_anim_duration); mTouchSlop = ViewConfiguration.get(mContext).getScaledTouchSlop(); mFlingAnimationUtils = new FlingAnimationUtils(getResources().getDisplayMetrics(), 0.3f); boolean landscape = getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE; mHandle.setPointerIcon(PointerIcon.getSystemIcon(getContext(), landscape ? TYPE_HORIZONTAL_DOUBLE_ARROW : TYPE_VERTICAL_DOUBLE_ARROW)); getViewTreeObserver().addOnComputeInternalInsetsListener(this); mHandle.setAccessibilityDelegate(mHandleDelegate); } @Override protected void onAttachedToWindow() { super.onAttachedToWindow(); // Save the current target if not minimized once attached to window if (mDockSide != WindowManager.DOCKED_INVALID && !mIsInMinimizeInteraction) { saveSnapTargetBeforeMinimized(mSnapTargetBeforeMinimized); } mFirstLayout = true; } void onDividerRemoved() { mRemoved = true; mCallback = null; } @Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { super.onLayout(changed, left, top, right, bottom); if (mFirstLayout) { // Wait for first layout so that the ViewRootImpl surface has been created. initializeSurfaceState(); mFirstLayout = false; } int minimizeLeft = 0; int minimizeTop = 0; if (mDockSide == WindowManager.DOCKED_TOP) { minimizeTop = mBackground.getTop(); } else if (mDockSide == WindowManager.DOCKED_LEFT) { minimizeLeft = mBackground.getLeft(); } else if (mDockSide == WindowManager.DOCKED_RIGHT) { minimizeLeft = mBackground.getRight() - mMinimizedShadow.getWidth(); } mMinimizedShadow.layout(minimizeLeft, minimizeTop, minimizeLeft + mMinimizedShadow.getMeasuredWidth(), minimizeTop + mMinimizedShadow.getMeasuredHeight()); if (changed) { notifySplitScreenBoundsChanged(); } } void injectDependencies(LegacySplitScreenController splitScreenController, DividerWindowManager windowManager, DividerState dividerState, DividerCallbacks callback, LegacySplitScreenTaskListener tiles, LegacySplitDisplayLayout sdl, DividerImeController imeController, WindowManagerProxy wmProxy) { mSplitScreenController = splitScreenController; mWindowManager = windowManager; mState = dividerState; mCallback = callback; mTiles = tiles; mSplitLayout = sdl; mImeController = imeController; mWindowManagerProxy = wmProxy; if (mState.mRatioPositionBeforeMinimized == 0) { // Set the middle target as the initial state mSnapTargetBeforeMinimized = mSplitLayout.getSnapAlgorithm().getMiddleTarget(); } else { repositionSnapTargetBeforeMinimized(); } } /** Gets non-minimized secondary bounds of split screen. public Rect getNonMinimizedSplitScreenSecondaryBounds() { mOtherTaskRect.set(mSplitLayout.mSecondary); return mOtherTaskRect; } private boolean inSplitMode() { return getVisibility() == VISIBLE; } /** Unlike setVisible, this directly hides the surface without changing view visibility.
DividerView::setHidden
java
Reginer/aosp-android-jar
android-33/src/com/android/wm/shell/legacysplitscreen/DividerView.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/wm/shell/legacysplitscreen/DividerView.java
MIT
public boolean startDragging(boolean animate, boolean touching) { cancelFlingAnimation(); if (touching) { mHandle.setTouching(true, animate); } mDockSide = mSplitLayout.getPrimarySplitSide(); mWindowManagerProxy.setResizing(true); if (touching) { mWindowManager.setSlippery(false); liftBackground(); } if (mCallback != null) { mCallback.onDraggingStart(); } return inSplitMode(); }
How much the background gets scaled when we are in the minimized dock state. private static final float MINIMIZE_DOCK_SCALE = 0f; private static final float ADJUSTED_FOR_IME_SCALE = 0.5f; private static final Interpolator IME_ADJUST_INTERPOLATOR = new PathInterpolator(0.2f, 0f, 0.1f, 1f); private DividerHandleView mHandle; private View mBackground; private MinimizedDockShadow mMinimizedShadow; private int mStartX; private int mStartY; private int mStartPosition; private int mDockSide; private boolean mMoving; private int mTouchSlop; private boolean mBackgroundLifted; private boolean mIsInMinimizeInteraction; SnapTarget mSnapTargetBeforeMinimized; private int mDividerInsets; private final Display mDefaultDisplay; private int mDividerSize; private int mTouchElevation; private int mLongPressEntraceAnimDuration; private final Rect mDockedRect = new Rect(); private final Rect mDockedTaskRect = new Rect(); private final Rect mOtherTaskRect = new Rect(); private final Rect mOtherRect = new Rect(); private final Rect mDockedInsetRect = new Rect(); private final Rect mOtherInsetRect = new Rect(); private final Rect mLastResizeRect = new Rect(); private final Rect mTmpRect = new Rect(); private LegacySplitScreenController mSplitScreenController; private WindowManagerProxy mWindowManagerProxy; private DividerWindowManager mWindowManager; private VelocityTracker mVelocityTracker; private FlingAnimationUtils mFlingAnimationUtils; private LegacySplitDisplayLayout mSplitLayout; private DividerImeController mImeController; private DividerCallbacks mCallback; private AnimationHandler mSfVsyncAnimationHandler; private ValueAnimator mCurrentAnimator; private boolean mEntranceAnimationRunning; private boolean mExitAnimationRunning; private int mExitStartPosition; private boolean mDockedStackMinimized; private boolean mHomeStackResizable; private boolean mAdjustedForIme; private DividerState mState; private LegacySplitScreenTaskListener mTiles; boolean mFirstLayout = true; int mDividerPositionX; int mDividerPositionY; private final Matrix mTmpMatrix = new Matrix(); private final float[] mTmpValues = new float[9]; // The view is removed or in the process of been removed from the system. private boolean mRemoved; // Whether the surface for this view has been hidden regardless of actual visibility. This is // used interact with keyguard. private boolean mSurfaceHidden = false; private final AccessibilityDelegate mHandleDelegate = new AccessibilityDelegate() { @Override public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfo info) { super.onInitializeAccessibilityNodeInfo(host, info); final DividerSnapAlgorithm snapAlgorithm = getSnapAlgorithm(); if (isHorizontalDivision()) { info.addAction(new AccessibilityAction(R.id.action_move_tl_full, mContext.getString(R.string.accessibility_action_divider_top_full))); if (snapAlgorithm.isFirstSplitTargetAvailable()) { info.addAction(new AccessibilityAction(R.id.action_move_tl_70, mContext.getString(R.string.accessibility_action_divider_top_70))); } if (snapAlgorithm.showMiddleSplitTargetForAccessibility()) { // Only show the middle target if there are more than 1 split target info.addAction(new AccessibilityAction(R.id.action_move_tl_50, mContext.getString(R.string.accessibility_action_divider_top_50))); } if (snapAlgorithm.isLastSplitTargetAvailable()) { info.addAction(new AccessibilityAction(R.id.action_move_tl_30, mContext.getString(R.string.accessibility_action_divider_top_30))); } info.addAction(new AccessibilityAction(R.id.action_move_rb_full, mContext.getString(R.string.accessibility_action_divider_bottom_full))); } else { info.addAction(new AccessibilityAction(R.id.action_move_tl_full, mContext.getString(R.string.accessibility_action_divider_left_full))); if (snapAlgorithm.isFirstSplitTargetAvailable()) { info.addAction(new AccessibilityAction(R.id.action_move_tl_70, mContext.getString(R.string.accessibility_action_divider_left_70))); } if (snapAlgorithm.showMiddleSplitTargetForAccessibility()) { // Only show the middle target if there are more than 1 split target info.addAction(new AccessibilityAction(R.id.action_move_tl_50, mContext.getString(R.string.accessibility_action_divider_left_50))); } if (snapAlgorithm.isLastSplitTargetAvailable()) { info.addAction(new AccessibilityAction(R.id.action_move_tl_30, mContext.getString(R.string.accessibility_action_divider_left_30))); } info.addAction(new AccessibilityAction(R.id.action_move_rb_full, mContext.getString(R.string.accessibility_action_divider_right_full))); } } @Override public boolean performAccessibilityAction(View host, int action, Bundle args) { int currentPosition = getCurrentPosition(); SnapTarget nextTarget = null; DividerSnapAlgorithm snapAlgorithm = mSplitLayout.getSnapAlgorithm(); if (action == R.id.action_move_tl_full) { nextTarget = snapAlgorithm.getDismissEndTarget(); } else if (action == R.id.action_move_tl_70) { nextTarget = snapAlgorithm.getLastSplitTarget(); } else if (action == R.id.action_move_tl_50) { nextTarget = snapAlgorithm.getMiddleTarget(); } else if (action == R.id.action_move_tl_30) { nextTarget = snapAlgorithm.getFirstSplitTarget(); } else if (action == R.id.action_move_rb_full) { nextTarget = snapAlgorithm.getDismissStartTarget(); } if (nextTarget != null) { startDragging(true /* animate */, false /* touching */); stopDragging(currentPosition, nextTarget, 250, Interpolators.FAST_OUT_SLOW_IN); return true; } return super.performAccessibilityAction(host, action, args); } }; private final Runnable mResetBackgroundRunnable = new Runnable() { @Override public void run() { resetBackground(); } }; public DividerView(Context context) { this(context, null); } public DividerView(Context context, @Nullable AttributeSet attrs) { this(context, attrs, 0); } public DividerView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { this(context, attrs, defStyleAttr, 0); } public DividerView(Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); final DisplayManager displayManager = (DisplayManager) mContext.getSystemService(Context.DISPLAY_SERVICE); mDefaultDisplay = displayManager.getDisplay(Display.DEFAULT_DISPLAY); } public void setAnimationHandler(AnimationHandler sfVsyncAnimationHandler) { mSfVsyncAnimationHandler = sfVsyncAnimationHandler; } @Override protected void onFinishInflate() { super.onFinishInflate(); mHandle = findViewById(R.id.docked_divider_handle); mBackground = findViewById(R.id.docked_divider_background); mMinimizedShadow = findViewById(R.id.minimized_dock_shadow); mHandle.setOnTouchListener(this); final int dividerWindowWidth = getResources().getDimensionPixelSize( com.android.internal.R.dimen.docked_stack_divider_thickness); mDividerInsets = getResources().getDimensionPixelSize( com.android.internal.R.dimen.docked_stack_divider_insets); mDividerSize = dividerWindowWidth - 2 * mDividerInsets; mTouchElevation = getResources().getDimensionPixelSize( R.dimen.docked_stack_divider_lift_elevation); mLongPressEntraceAnimDuration = getResources().getInteger( R.integer.long_press_dock_anim_duration); mTouchSlop = ViewConfiguration.get(mContext).getScaledTouchSlop(); mFlingAnimationUtils = new FlingAnimationUtils(getResources().getDisplayMetrics(), 0.3f); boolean landscape = getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE; mHandle.setPointerIcon(PointerIcon.getSystemIcon(getContext(), landscape ? TYPE_HORIZONTAL_DOUBLE_ARROW : TYPE_VERTICAL_DOUBLE_ARROW)); getViewTreeObserver().addOnComputeInternalInsetsListener(this); mHandle.setAccessibilityDelegate(mHandleDelegate); } @Override protected void onAttachedToWindow() { super.onAttachedToWindow(); // Save the current target if not minimized once attached to window if (mDockSide != WindowManager.DOCKED_INVALID && !mIsInMinimizeInteraction) { saveSnapTargetBeforeMinimized(mSnapTargetBeforeMinimized); } mFirstLayout = true; } void onDividerRemoved() { mRemoved = true; mCallback = null; } @Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { super.onLayout(changed, left, top, right, bottom); if (mFirstLayout) { // Wait for first layout so that the ViewRootImpl surface has been created. initializeSurfaceState(); mFirstLayout = false; } int minimizeLeft = 0; int minimizeTop = 0; if (mDockSide == WindowManager.DOCKED_TOP) { minimizeTop = mBackground.getTop(); } else if (mDockSide == WindowManager.DOCKED_LEFT) { minimizeLeft = mBackground.getLeft(); } else if (mDockSide == WindowManager.DOCKED_RIGHT) { minimizeLeft = mBackground.getRight() - mMinimizedShadow.getWidth(); } mMinimizedShadow.layout(minimizeLeft, minimizeTop, minimizeLeft + mMinimizedShadow.getMeasuredWidth(), minimizeTop + mMinimizedShadow.getMeasuredHeight()); if (changed) { notifySplitScreenBoundsChanged(); } } void injectDependencies(LegacySplitScreenController splitScreenController, DividerWindowManager windowManager, DividerState dividerState, DividerCallbacks callback, LegacySplitScreenTaskListener tiles, LegacySplitDisplayLayout sdl, DividerImeController imeController, WindowManagerProxy wmProxy) { mSplitScreenController = splitScreenController; mWindowManager = windowManager; mState = dividerState; mCallback = callback; mTiles = tiles; mSplitLayout = sdl; mImeController = imeController; mWindowManagerProxy = wmProxy; if (mState.mRatioPositionBeforeMinimized == 0) { // Set the middle target as the initial state mSnapTargetBeforeMinimized = mSplitLayout.getSnapAlgorithm().getMiddleTarget(); } else { repositionSnapTargetBeforeMinimized(); } } /** Gets non-minimized secondary bounds of split screen. public Rect getNonMinimizedSplitScreenSecondaryBounds() { mOtherTaskRect.set(mSplitLayout.mSecondary); return mOtherTaskRect; } private boolean inSplitMode() { return getVisibility() == VISIBLE; } /** Unlike setVisible, this directly hides the surface without changing view visibility. void setHidden(boolean hidden) { if (mSurfaceHidden == hidden) { return; } mSurfaceHidden = hidden; post(() -> { final SurfaceControl sc = getWindowSurfaceControl(); if (sc == null) { return; } Transaction t = mTiles.getTransaction(); if (hidden) { t.hide(sc); } else { t.show(sc); } mImeController.setDimsHidden(t, hidden); t.apply(); mTiles.releaseTransaction(t); }); } boolean isHidden() { return getVisibility() != View.VISIBLE || mSurfaceHidden; } /** Starts dragging the divider bar.
DividerView::startDragging
java
Reginer/aosp-android-jar
android-33/src/com/android/wm/shell/legacysplitscreen/DividerView.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/wm/shell/legacysplitscreen/DividerView.java
MIT
public void stopDragging(int position, float velocity, boolean avoidDismissStart, boolean logMetrics) { mHandle.setTouching(false, true /* animate */); fling(position, velocity, avoidDismissStart, logMetrics); mWindowManager.setSlippery(true); releaseBackground(); }
How much the background gets scaled when we are in the minimized dock state. private static final float MINIMIZE_DOCK_SCALE = 0f; private static final float ADJUSTED_FOR_IME_SCALE = 0.5f; private static final Interpolator IME_ADJUST_INTERPOLATOR = new PathInterpolator(0.2f, 0f, 0.1f, 1f); private DividerHandleView mHandle; private View mBackground; private MinimizedDockShadow mMinimizedShadow; private int mStartX; private int mStartY; private int mStartPosition; private int mDockSide; private boolean mMoving; private int mTouchSlop; private boolean mBackgroundLifted; private boolean mIsInMinimizeInteraction; SnapTarget mSnapTargetBeforeMinimized; private int mDividerInsets; private final Display mDefaultDisplay; private int mDividerSize; private int mTouchElevation; private int mLongPressEntraceAnimDuration; private final Rect mDockedRect = new Rect(); private final Rect mDockedTaskRect = new Rect(); private final Rect mOtherTaskRect = new Rect(); private final Rect mOtherRect = new Rect(); private final Rect mDockedInsetRect = new Rect(); private final Rect mOtherInsetRect = new Rect(); private final Rect mLastResizeRect = new Rect(); private final Rect mTmpRect = new Rect(); private LegacySplitScreenController mSplitScreenController; private WindowManagerProxy mWindowManagerProxy; private DividerWindowManager mWindowManager; private VelocityTracker mVelocityTracker; private FlingAnimationUtils mFlingAnimationUtils; private LegacySplitDisplayLayout mSplitLayout; private DividerImeController mImeController; private DividerCallbacks mCallback; private AnimationHandler mSfVsyncAnimationHandler; private ValueAnimator mCurrentAnimator; private boolean mEntranceAnimationRunning; private boolean mExitAnimationRunning; private int mExitStartPosition; private boolean mDockedStackMinimized; private boolean mHomeStackResizable; private boolean mAdjustedForIme; private DividerState mState; private LegacySplitScreenTaskListener mTiles; boolean mFirstLayout = true; int mDividerPositionX; int mDividerPositionY; private final Matrix mTmpMatrix = new Matrix(); private final float[] mTmpValues = new float[9]; // The view is removed or in the process of been removed from the system. private boolean mRemoved; // Whether the surface for this view has been hidden regardless of actual visibility. This is // used interact with keyguard. private boolean mSurfaceHidden = false; private final AccessibilityDelegate mHandleDelegate = new AccessibilityDelegate() { @Override public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfo info) { super.onInitializeAccessibilityNodeInfo(host, info); final DividerSnapAlgorithm snapAlgorithm = getSnapAlgorithm(); if (isHorizontalDivision()) { info.addAction(new AccessibilityAction(R.id.action_move_tl_full, mContext.getString(R.string.accessibility_action_divider_top_full))); if (snapAlgorithm.isFirstSplitTargetAvailable()) { info.addAction(new AccessibilityAction(R.id.action_move_tl_70, mContext.getString(R.string.accessibility_action_divider_top_70))); } if (snapAlgorithm.showMiddleSplitTargetForAccessibility()) { // Only show the middle target if there are more than 1 split target info.addAction(new AccessibilityAction(R.id.action_move_tl_50, mContext.getString(R.string.accessibility_action_divider_top_50))); } if (snapAlgorithm.isLastSplitTargetAvailable()) { info.addAction(new AccessibilityAction(R.id.action_move_tl_30, mContext.getString(R.string.accessibility_action_divider_top_30))); } info.addAction(new AccessibilityAction(R.id.action_move_rb_full, mContext.getString(R.string.accessibility_action_divider_bottom_full))); } else { info.addAction(new AccessibilityAction(R.id.action_move_tl_full, mContext.getString(R.string.accessibility_action_divider_left_full))); if (snapAlgorithm.isFirstSplitTargetAvailable()) { info.addAction(new AccessibilityAction(R.id.action_move_tl_70, mContext.getString(R.string.accessibility_action_divider_left_70))); } if (snapAlgorithm.showMiddleSplitTargetForAccessibility()) { // Only show the middle target if there are more than 1 split target info.addAction(new AccessibilityAction(R.id.action_move_tl_50, mContext.getString(R.string.accessibility_action_divider_left_50))); } if (snapAlgorithm.isLastSplitTargetAvailable()) { info.addAction(new AccessibilityAction(R.id.action_move_tl_30, mContext.getString(R.string.accessibility_action_divider_left_30))); } info.addAction(new AccessibilityAction(R.id.action_move_rb_full, mContext.getString(R.string.accessibility_action_divider_right_full))); } } @Override public boolean performAccessibilityAction(View host, int action, Bundle args) { int currentPosition = getCurrentPosition(); SnapTarget nextTarget = null; DividerSnapAlgorithm snapAlgorithm = mSplitLayout.getSnapAlgorithm(); if (action == R.id.action_move_tl_full) { nextTarget = snapAlgorithm.getDismissEndTarget(); } else if (action == R.id.action_move_tl_70) { nextTarget = snapAlgorithm.getLastSplitTarget(); } else if (action == R.id.action_move_tl_50) { nextTarget = snapAlgorithm.getMiddleTarget(); } else if (action == R.id.action_move_tl_30) { nextTarget = snapAlgorithm.getFirstSplitTarget(); } else if (action == R.id.action_move_rb_full) { nextTarget = snapAlgorithm.getDismissStartTarget(); } if (nextTarget != null) { startDragging(true /* animate */, false /* touching */); stopDragging(currentPosition, nextTarget, 250, Interpolators.FAST_OUT_SLOW_IN); return true; } return super.performAccessibilityAction(host, action, args); } }; private final Runnable mResetBackgroundRunnable = new Runnable() { @Override public void run() { resetBackground(); } }; public DividerView(Context context) { this(context, null); } public DividerView(Context context, @Nullable AttributeSet attrs) { this(context, attrs, 0); } public DividerView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { this(context, attrs, defStyleAttr, 0); } public DividerView(Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); final DisplayManager displayManager = (DisplayManager) mContext.getSystemService(Context.DISPLAY_SERVICE); mDefaultDisplay = displayManager.getDisplay(Display.DEFAULT_DISPLAY); } public void setAnimationHandler(AnimationHandler sfVsyncAnimationHandler) { mSfVsyncAnimationHandler = sfVsyncAnimationHandler; } @Override protected void onFinishInflate() { super.onFinishInflate(); mHandle = findViewById(R.id.docked_divider_handle); mBackground = findViewById(R.id.docked_divider_background); mMinimizedShadow = findViewById(R.id.minimized_dock_shadow); mHandle.setOnTouchListener(this); final int dividerWindowWidth = getResources().getDimensionPixelSize( com.android.internal.R.dimen.docked_stack_divider_thickness); mDividerInsets = getResources().getDimensionPixelSize( com.android.internal.R.dimen.docked_stack_divider_insets); mDividerSize = dividerWindowWidth - 2 * mDividerInsets; mTouchElevation = getResources().getDimensionPixelSize( R.dimen.docked_stack_divider_lift_elevation); mLongPressEntraceAnimDuration = getResources().getInteger( R.integer.long_press_dock_anim_duration); mTouchSlop = ViewConfiguration.get(mContext).getScaledTouchSlop(); mFlingAnimationUtils = new FlingAnimationUtils(getResources().getDisplayMetrics(), 0.3f); boolean landscape = getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE; mHandle.setPointerIcon(PointerIcon.getSystemIcon(getContext(), landscape ? TYPE_HORIZONTAL_DOUBLE_ARROW : TYPE_VERTICAL_DOUBLE_ARROW)); getViewTreeObserver().addOnComputeInternalInsetsListener(this); mHandle.setAccessibilityDelegate(mHandleDelegate); } @Override protected void onAttachedToWindow() { super.onAttachedToWindow(); // Save the current target if not minimized once attached to window if (mDockSide != WindowManager.DOCKED_INVALID && !mIsInMinimizeInteraction) { saveSnapTargetBeforeMinimized(mSnapTargetBeforeMinimized); } mFirstLayout = true; } void onDividerRemoved() { mRemoved = true; mCallback = null; } @Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { super.onLayout(changed, left, top, right, bottom); if (mFirstLayout) { // Wait for first layout so that the ViewRootImpl surface has been created. initializeSurfaceState(); mFirstLayout = false; } int minimizeLeft = 0; int minimizeTop = 0; if (mDockSide == WindowManager.DOCKED_TOP) { minimizeTop = mBackground.getTop(); } else if (mDockSide == WindowManager.DOCKED_LEFT) { minimizeLeft = mBackground.getLeft(); } else if (mDockSide == WindowManager.DOCKED_RIGHT) { minimizeLeft = mBackground.getRight() - mMinimizedShadow.getWidth(); } mMinimizedShadow.layout(minimizeLeft, minimizeTop, minimizeLeft + mMinimizedShadow.getMeasuredWidth(), minimizeTop + mMinimizedShadow.getMeasuredHeight()); if (changed) { notifySplitScreenBoundsChanged(); } } void injectDependencies(LegacySplitScreenController splitScreenController, DividerWindowManager windowManager, DividerState dividerState, DividerCallbacks callback, LegacySplitScreenTaskListener tiles, LegacySplitDisplayLayout sdl, DividerImeController imeController, WindowManagerProxy wmProxy) { mSplitScreenController = splitScreenController; mWindowManager = windowManager; mState = dividerState; mCallback = callback; mTiles = tiles; mSplitLayout = sdl; mImeController = imeController; mWindowManagerProxy = wmProxy; if (mState.mRatioPositionBeforeMinimized == 0) { // Set the middle target as the initial state mSnapTargetBeforeMinimized = mSplitLayout.getSnapAlgorithm().getMiddleTarget(); } else { repositionSnapTargetBeforeMinimized(); } } /** Gets non-minimized secondary bounds of split screen. public Rect getNonMinimizedSplitScreenSecondaryBounds() { mOtherTaskRect.set(mSplitLayout.mSecondary); return mOtherTaskRect; } private boolean inSplitMode() { return getVisibility() == VISIBLE; } /** Unlike setVisible, this directly hides the surface without changing view visibility. void setHidden(boolean hidden) { if (mSurfaceHidden == hidden) { return; } mSurfaceHidden = hidden; post(() -> { final SurfaceControl sc = getWindowSurfaceControl(); if (sc == null) { return; } Transaction t = mTiles.getTransaction(); if (hidden) { t.hide(sc); } else { t.show(sc); } mImeController.setDimsHidden(t, hidden); t.apply(); mTiles.releaseTransaction(t); }); } boolean isHidden() { return getVisibility() != View.VISIBLE || mSurfaceHidden; } /** Starts dragging the divider bar. public boolean startDragging(boolean animate, boolean touching) { cancelFlingAnimation(); if (touching) { mHandle.setTouching(true, animate); } mDockSide = mSplitLayout.getPrimarySplitSide(); mWindowManagerProxy.setResizing(true); if (touching) { mWindowManager.setSlippery(false); liftBackground(); } if (mCallback != null) { mCallback.onDraggingStart(); } return inSplitMode(); } /** Stops dragging the divider bar.
DividerView::stopDragging
java
Reginer/aosp-android-jar
android-33/src/com/android/wm/shell/legacysplitscreen/DividerView.java
https://github.com/Reginer/aosp-android-jar/blob/master/android-33/src/com/android/wm/shell/legacysplitscreen/DividerView.java
MIT