Merge "Display file names in Media libraries in grid mode" into nyc-dev
diff --git a/Android.mk b/Android.mk
index 08f3468..74cf4ee 100644
--- a/Android.mk
+++ b/Android.mk
@@ -870,9 +870,11 @@
framework_docs_SDK_REL_ID:=1
framework_docs_LOCAL_DROIDDOC_OPTIONS += \
+ -hdf sdk.codename N \
+ -hdf sdk.preview.version 2 \
-hdf sdk.version $(framework_docs_SDK_VERSION) \
-hdf sdk.rel.id $(framework_docs_SDK_REL_ID) \
- -hdf sdk.preview 0
+ -hdf sdk.preview 1
# ==== the api stubs and current.xml ===========================
include $(CLEAR_VARS)
@@ -1027,23 +1029,24 @@
-offlinemode \
-title "Android SDK" \
-proofread $(OUT_DOCS)/$(LOCAL_MODULE)-proofread.txt \
- -todo $(OUT_DOCS)/$(LOCAL_MODULE)-docs-todo.html \
-sdkvalues $(OUT_DOCS) \
- -hdf android.whichdoc offline
+ -hdf android.whichdoc offline \
+ -referenceonly
-LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR:=build/tools/droiddoc/templates-sdk
+LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR:=build/tools/droiddoc/templates-sdk-refonly
include $(BUILD_DROIDDOC)
static_doc_index_redirect := $(out_dir)/index.html
$(static_doc_index_redirect): \
- $(LOCAL_PATH)/docs/docs-documentation-redirect.html | $(ACP)
+ $(LOCAL_PATH)/docs/docs-preview-index.html | $(ACP)
$(hide) mkdir -p $(dir $@)
$(hide) $(ACP) $< $@
$(full_target): $(static_doc_index_redirect)
$(full_target): $(framework_built)
+
# ==== docs for the web (on the androiddevdocs app engine server) =======================
include $(CLEAR_VARS)
diff --git a/api/current.txt b/api/current.txt
index d8d5ce1..9d4674e 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -20182,37 +20182,129 @@
field public static final int ORIENTATION_TRANSVERSE = 7; // 0x7
field public static final int ORIENTATION_UNDEFINED = 0; // 0x0
field public static final java.lang.String TAG_APERTURE = "FNumber";
+ field public static final java.lang.String TAG_APERTURE_VALUE = "ApertureValue";
+ field public static final java.lang.String TAG_ARTIST = "Artist";
+ field public static final java.lang.String TAG_BITS_PER_SAMPLE = "BitsPerSample";
+ field public static final java.lang.String TAG_BRIGHTNESS_VALUE = "BrightnessValue";
+ field public static final java.lang.String TAG_CFA_PATTERN = "CFAPattern";
+ field public static final java.lang.String TAG_COLOR_SPACE = "ColorSpace";
+ field public static final java.lang.String TAG_COMPONENTS_CONFIGURATION = "ComponentsConfiguration";
+ field public static final java.lang.String TAG_COMPRESSED_BITS_PER_PIXEL = "CompressedBitsPerPixel";
+ field public static final java.lang.String TAG_COMPRESSION = "Compression";
+ field public static final java.lang.String TAG_CONTRAST = "Contrast";
+ field public static final java.lang.String TAG_COPYRIGHT = "Copyright";
+ field public static final java.lang.String TAG_CUSTOM_RENDERED = "CustomRendered";
field public static final java.lang.String TAG_DATETIME = "DateTime";
field public static final java.lang.String TAG_DATETIME_DIGITIZED = "DateTimeDigitized";
+ field public static final java.lang.String TAG_DATETIME_ORIGINAL = "DateTimeOriginal";
+ field public static final java.lang.String TAG_DEVICE_SETTING_DESCRIPTION = "DeviceSettingDescription";
field public static final java.lang.String TAG_DIGITAL_ZOOM_RATIO = "DigitalZoomRatio";
+ field public static final java.lang.String TAG_EXIF_VERSION = "ExifVersion";
field public static final java.lang.String TAG_EXPOSURE_BIAS_VALUE = "ExposureBiasValue";
+ field public static final java.lang.String TAG_EXPOSURE_INDEX = "ExposureIndex";
field public static final java.lang.String TAG_EXPOSURE_MODE = "ExposureMode";
field public static final java.lang.String TAG_EXPOSURE_PROGRAM = "ExposureProgram";
field public static final java.lang.String TAG_EXPOSURE_TIME = "ExposureTime";
+ field public static final java.lang.String TAG_FILE_SOURCE = "FileSource";
field public static final java.lang.String TAG_FLASH = "Flash";
+ field public static final java.lang.String TAG_FLASHPIX_VERSION = "FlashpixVersion";
+ field public static final java.lang.String TAG_FLASH_ENERGY = "FlashEnergy";
field public static final java.lang.String TAG_FOCAL_LENGTH = "FocalLength";
+ field public static final java.lang.String TAG_FOCAL_LENGTH_IN_35MM_FILM = "FocalLengthIn35mmFilm";
+ field public static final java.lang.String TAG_FOCAL_PLANE_RESOLUTION_UNIT = "FocalPlaneResolutionUnit";
+ field public static final java.lang.String TAG_FOCAL_PLANE_X_RESOLUTION = "FocalPlaneXResolution";
+ field public static final java.lang.String TAG_FOCAL_PLANE_Y_RESOLUTION = "FocalPlaneYResolution";
+ field public static final java.lang.String TAG_F_NUMBER = "FNumber";
+ field public static final java.lang.String TAG_GAIN_CONTROL = "GainControl";
field public static final java.lang.String TAG_GPS_ALTITUDE = "GPSAltitude";
field public static final java.lang.String TAG_GPS_ALTITUDE_REF = "GPSAltitudeRef";
+ field public static final java.lang.String TAG_GPS_AREA_INFORMATION = "GPSAreaInformation";
field public static final java.lang.String TAG_GPS_DATESTAMP = "GPSDateStamp";
+ field public static final java.lang.String TAG_GPS_DEST_BEARING = "GPSDestBearing";
+ field public static final java.lang.String TAG_GPS_DEST_BEARING_REF = "GPSDestBearingRef";
+ field public static final java.lang.String TAG_GPS_DEST_DISTANCE = "GPSDestDistance";
+ field public static final java.lang.String TAG_GPS_DEST_DISTANCE_REF = "GPSDestDistanceRef";
+ field public static final java.lang.String TAG_GPS_DEST_LATITUDE = "GPSDestLatitude";
+ field public static final java.lang.String TAG_GPS_DEST_LATITUDE_REF = "GPSDestLatitudeRef";
+ field public static final java.lang.String TAG_GPS_DEST_LONGITUDE = "GPSDestLongitude";
+ field public static final java.lang.String TAG_GPS_DEST_LONGITUDE_REF = "GPSDestLongitudeRef";
+ field public static final java.lang.String TAG_GPS_DIFFERENTIAL = "GPSDifferential";
+ field public static final java.lang.String TAG_GPS_DOP = "GPSDOP";
+ field public static final java.lang.String TAG_GPS_IMG_DIRECTION = "GPSImgDirection";
+ field public static final java.lang.String TAG_GPS_IMG_DIRECTION_REF = "GPSImgDirectionRef";
field public static final java.lang.String TAG_GPS_LATITUDE = "GPSLatitude";
field public static final java.lang.String TAG_GPS_LATITUDE_REF = "GPSLatitudeRef";
field public static final java.lang.String TAG_GPS_LONGITUDE = "GPSLongitude";
field public static final java.lang.String TAG_GPS_LONGITUDE_REF = "GPSLongitudeRef";
+ field public static final java.lang.String TAG_GPS_MAP_DATUM = "GPSMapDatum";
+ field public static final java.lang.String TAG_GPS_MEASURE_MODE = "GPSMeasureMode";
field public static final java.lang.String TAG_GPS_PROCESSING_METHOD = "GPSProcessingMethod";
+ field public static final java.lang.String TAG_GPS_SATELLITES = "GPSSatellites";
+ field public static final java.lang.String TAG_GPS_SPEED = "GPSSpeed";
+ field public static final java.lang.String TAG_GPS_SPEED_REF = "GPSSpeedRef";
+ field public static final java.lang.String TAG_GPS_STATUS = "GPSStatus";
field public static final java.lang.String TAG_GPS_TIMESTAMP = "GPSTimeStamp";
+ field public static final java.lang.String TAG_GPS_TRACK = "GPSTrack";
+ field public static final java.lang.String TAG_GPS_TRACK_REF = "GPSTrackRef";
+ field public static final java.lang.String TAG_GPS_VERSION_ID = "GPSVersionID";
+ field public static final java.lang.String TAG_IMAGE_DESCRIPTION = "ImageDescription";
field public static final java.lang.String TAG_IMAGE_LENGTH = "ImageLength";
+ field public static final java.lang.String TAG_IMAGE_UNIQUE_ID = "ImageUniqueID";
field public static final java.lang.String TAG_IMAGE_WIDTH = "ImageWidth";
+ field public static final java.lang.String TAG_INTEROPERABILITY_INDEX = "InteroperabilityIndex";
field public static final java.lang.String TAG_ISO = "ISOSpeedRatings";
+ field public static final java.lang.String TAG_ISO_SPEED_RATINGS = "ISOSpeedRatings";
+ field public static final java.lang.String TAG_JPEG_INTERCHANGE_FORMAT = "JPEGInterchangeFormat";
+ field public static final java.lang.String TAG_JPEG_INTERCHANGE_FORMAT_LENGTH = "JPEGInterchangeFormatLength";
field public static final java.lang.String TAG_LIGHT_SOURCE = "LightSource";
field public static final java.lang.String TAG_MAKE = "Make";
+ field public static final java.lang.String TAG_MAKER_NOTE = "MakerNote";
+ field public static final java.lang.String TAG_MAX_APERTURE_VALUE = "MaxApertureValue";
field public static final java.lang.String TAG_METERING_MODE = "MeteringMode";
field public static final java.lang.String TAG_MODEL = "Model";
+ field public static final java.lang.String TAG_OECF = "OECF";
field public static final java.lang.String TAG_ORIENTATION = "Orientation";
+ field public static final java.lang.String TAG_PHOTOMETRIC_INTERPRETATION = "PhotometricInterpretation";
+ field public static final java.lang.String TAG_PIXEL_X_DIMENSION = "PixelXDimension";
+ field public static final java.lang.String TAG_PIXEL_Y_DIMENSION = "PixelYDimension";
+ field public static final java.lang.String TAG_PLANAR_CONFIGURATION = "PlanarConfiguration";
+ field public static final java.lang.String TAG_PRIMARY_CHROMATICITIES = "PrimaryChromaticities";
+ field public static final java.lang.String TAG_REFERENCE_BLACK_WHITE = "ReferenceBlackWhite";
+ field public static final java.lang.String TAG_RELATED_SOUND_FILE = "RelatedSoundFile";
+ field public static final java.lang.String TAG_RESOLUTION_UNIT = "ResolutionUnit";
+ field public static final java.lang.String TAG_ROWS_PER_STRIP = "RowsPerStrip";
+ field public static final java.lang.String TAG_SAMPLES_PER_PIXEL = "SamplesPerPixel";
+ field public static final java.lang.String TAG_SATURATION = "Saturation";
+ field public static final java.lang.String TAG_SCENE_CAPTURE_TYPE = "SceneCaptureType";
+ field public static final java.lang.String TAG_SCENE_TYPE = "SceneType";
+ field public static final java.lang.String TAG_SENSING_METHOD = "SensingMethod";
+ field public static final java.lang.String TAG_SHARPNESS = "Sharpness";
+ field public static final java.lang.String TAG_SHUTTER_SPEED_VALUE = "ShutterSpeedValue";
+ field public static final java.lang.String TAG_SOFTWARE = "Software";
+ field public static final java.lang.String TAG_SPATIAL_FREQUENCY_RESPONSE = "SpatialFrequencyResponse";
+ field public static final java.lang.String TAG_SPECTRAL_SENSITIVITY = "SpectralSensitivity";
+ field public static final java.lang.String TAG_STRIP_BYTE_COUNTS = "StripByteCounts";
+ field public static final java.lang.String TAG_STRIP_OFFSETS = "StripOffsets";
+ field public static final java.lang.String TAG_SUBJECT_AREA = "SubjectArea";
field public static final java.lang.String TAG_SUBJECT_DISTANCE = "SubjectDistance";
+ field public static final java.lang.String TAG_SUBJECT_DISTANCE_RANGE = "SubjectDistanceRange";
+ field public static final java.lang.String TAG_SUBJECT_LOCATION = "SubjectLocation";
field public static final java.lang.String TAG_SUBSEC_TIME = "SubSecTime";
field public static final java.lang.String TAG_SUBSEC_TIME_DIG = "SubSecTimeDigitized";
+ field public static final java.lang.String TAG_SUBSEC_TIME_DIGITIZED = "SubSecTimeDigitized";
field public static final java.lang.String TAG_SUBSEC_TIME_ORIG = "SubSecTimeOriginal";
+ field public static final java.lang.String TAG_SUBSEC_TIME_ORIGINAL = "SubSecTimeOriginal";
+ field public static final java.lang.String TAG_THUMBNAIL_IMAGE_LENGTH = "ThumbnailImageLength";
+ field public static final java.lang.String TAG_THUMBNAIL_IMAGE_WIDTH = "ThumbnailImageWidth";
+ field public static final java.lang.String TAG_TRANSFER_FUNCTION = "TransferFunction";
+ field public static final java.lang.String TAG_USER_COMMENT = "UserComment";
field public static final java.lang.String TAG_WHITE_BALANCE = "WhiteBalance";
+ field public static final java.lang.String TAG_WHITE_POINT = "WhitePoint";
+ field public static final java.lang.String TAG_X_RESOLUTION = "XResolution";
+ field public static final java.lang.String TAG_Y_CB_CR_COEFFICIENTS = "YCbCrCoefficients";
+ field public static final java.lang.String TAG_Y_CB_CR_POSITIONING = "YCbCrPositioning";
+ field public static final java.lang.String TAG_Y_CB_CR_SUB_SAMPLING = "YCbCrSubSampling";
+ field public static final java.lang.String TAG_Y_RESOLUTION = "YResolution";
field public static final int WHITEBALANCE_AUTO = 0; // 0x0
field public static final int WHITEBALANCE_MANUAL = 1; // 0x1
}
@@ -50815,6 +50907,7 @@
public abstract interface Iterable {
method public default void forEach(java.util.function.Consumer<? super T>);
method public abstract java.util.Iterator<T> iterator();
+ method public default java.util.Spliterator<T> spliterator();
}
public class LinkageError extends java.lang.Error {
@@ -57235,6 +57328,7 @@
method public E removeLast();
method public boolean removeLastOccurrence(java.lang.Object);
method public int size();
+ method public java.util.Spliterator<E> spliterator();
}
public class ArrayList extends java.util.AbstractList implements java.lang.Cloneable java.util.List java.util.RandomAccess java.io.Serializable {
@@ -57246,6 +57340,7 @@
method public void forEach(java.util.function.Consumer<? super E>);
method public E get(int);
method public int size();
+ method public java.util.Spliterator<E> spliterator();
method public void trimToSize();
}
@@ -57346,6 +57441,14 @@
method public static void sort(java.lang.Object[], int, int);
method public static void sort(T[], java.util.Comparator<? super T>);
method public static void sort(T[], int, int, java.util.Comparator<? super T>);
+ method public static java.util.Spliterator<T> spliterator(T[]);
+ method public static java.util.Spliterator<T> spliterator(T[], int, int);
+ method public static java.util.Spliterator.OfInt spliterator(int[]);
+ method public static java.util.Spliterator.OfInt spliterator(int[], int, int);
+ method public static java.util.Spliterator.OfLong spliterator(long[]);
+ method public static java.util.Spliterator.OfLong spliterator(long[], int, int);
+ method public static java.util.Spliterator.OfDouble spliterator(double[]);
+ method public static java.util.Spliterator.OfDouble spliterator(double[], int, int);
method public static java.lang.String toString(long[]);
method public static java.lang.String toString(int[]);
method public static java.lang.String toString(short[]);
@@ -57845,6 +57948,7 @@
method public java.lang.Object clone();
method public java.util.Iterator<E> iterator();
method public int size();
+ method public java.util.Spliterator<E> spliterator();
}
public class Hashtable extends java.util.Dictionary implements java.lang.Cloneable java.util.Map java.io.Serializable {
@@ -57989,6 +58093,7 @@
method public E removeLast();
method public boolean removeLastOccurrence(java.lang.Object);
method public int size();
+ method public java.util.Spliterator<E> spliterator();
}
public abstract interface List implements java.util.Collection {
@@ -58155,6 +58260,8 @@
}
public static abstract interface Map.Entry {
+ method public static java.util.Comparator<java.util.Map.Entry<K, V>> comparingByKey();
+ method public static java.util.Comparator<java.util.Map.Entry<K, V>> comparingByKey(java.util.Comparator<? super K>);
method public abstract boolean equals(java.lang.Object);
method public abstract K getKey();
method public abstract V getValue();
@@ -58333,6 +58440,7 @@
public class PriorityQueue extends java.util.AbstractQueue implements java.io.Serializable {
ctor public PriorityQueue();
ctor public PriorityQueue(int);
+ ctor public PriorityQueue(java.util.Comparator<? super E>);
ctor public PriorityQueue(int, java.util.Comparator<? super E>);
ctor public PriorityQueue(java.util.Collection<? extends E>);
ctor public PriorityQueue(java.util.PriorityQueue<? extends E>);
@@ -58343,6 +58451,7 @@
method public E peek();
method public E poll();
method public int size();
+ method public final java.util.Spliterator<E> spliterator();
}
public class Properties extends java.util.Hashtable {
@@ -58585,6 +58694,111 @@
method public abstract java.util.SortedSet<E> tailSet(E);
}
+ public abstract interface Spliterator {
+ method public abstract int characteristics();
+ method public abstract long estimateSize();
+ method public default void forEachRemaining(java.util.function.Consumer<? super T>);
+ method public default java.util.Comparator<? super T> getComparator();
+ method public default long getExactSizeIfKnown();
+ method public default boolean hasCharacteristics(int);
+ method public abstract boolean tryAdvance(java.util.function.Consumer<? super T>);
+ method public abstract java.util.Spliterator<T> trySplit();
+ field public static final int CONCURRENT = 4096; // 0x1000
+ field public static final int DISTINCT = 1; // 0x1
+ field public static final int IMMUTABLE = 1024; // 0x400
+ field public static final int NONNULL = 256; // 0x100
+ field public static final int ORDERED = 16; // 0x10
+ field public static final int SIZED = 64; // 0x40
+ field public static final int SORTED = 4; // 0x4
+ field public static final int SUBSIZED = 16384; // 0x4000
+ }
+
+ public static abstract interface Spliterator.OfDouble implements java.util.Spliterator.OfPrimitive {
+ method public default void forEachRemaining(java.util.function.DoubleConsumer);
+ method public default void forEachRemaining(java.util.function.Consumer<? super java.lang.Double>);
+ method public abstract boolean tryAdvance(java.util.function.DoubleConsumer);
+ method public default boolean tryAdvance(java.util.function.Consumer<? super java.lang.Double>);
+ method public abstract java.util.Spliterator.OfDouble trySplit();
+ }
+
+ public static abstract interface Spliterator.OfInt implements java.util.Spliterator.OfPrimitive {
+ method public default void forEachRemaining(java.util.function.IntConsumer);
+ method public default void forEachRemaining(java.util.function.Consumer<? super java.lang.Integer>);
+ method public abstract boolean tryAdvance(java.util.function.IntConsumer);
+ method public default boolean tryAdvance(java.util.function.Consumer<? super java.lang.Integer>);
+ method public abstract java.util.Spliterator.OfInt trySplit();
+ }
+
+ public static abstract interface Spliterator.OfLong implements java.util.Spliterator.OfPrimitive {
+ method public default void forEachRemaining(java.util.function.LongConsumer);
+ method public default void forEachRemaining(java.util.function.Consumer<? super java.lang.Long>);
+ method public abstract boolean tryAdvance(java.util.function.LongConsumer);
+ method public default boolean tryAdvance(java.util.function.Consumer<? super java.lang.Long>);
+ method public abstract java.util.Spliterator.OfLong trySplit();
+ }
+
+ public static abstract interface Spliterator.OfPrimitive implements java.util.Spliterator {
+ method public default void forEachRemaining(T_CONS);
+ method public abstract boolean tryAdvance(T_CONS);
+ method public abstract T_SPLITR trySplit();
+ }
+
+ public final class Spliterators {
+ method public static java.util.Spliterator.OfDouble emptyDoubleSpliterator();
+ method public static java.util.Spliterator.OfInt emptyIntSpliterator();
+ method public static java.util.Spliterator.OfLong emptyLongSpliterator();
+ method public static java.util.Spliterator<T> emptySpliterator();
+ method public static java.util.Iterator<T> iterator(java.util.Spliterator<? extends T>);
+ method public static java.util.PrimitiveIterator.OfInt iterator(java.util.Spliterator.OfInt);
+ method public static java.util.PrimitiveIterator.OfLong iterator(java.util.Spliterator.OfLong);
+ method public static java.util.PrimitiveIterator.OfDouble iterator(java.util.Spliterator.OfDouble);
+ method public static java.util.Spliterator<T> spliterator(java.lang.Object[], int);
+ method public static java.util.Spliterator<T> spliterator(java.lang.Object[], int, int, int);
+ method public static java.util.Spliterator.OfInt spliterator(int[], int);
+ method public static java.util.Spliterator.OfInt spliterator(int[], int, int, int);
+ method public static java.util.Spliterator.OfLong spliterator(long[], int);
+ method public static java.util.Spliterator.OfLong spliterator(long[], int, int, int);
+ method public static java.util.Spliterator.OfDouble spliterator(double[], int);
+ method public static java.util.Spliterator.OfDouble spliterator(double[], int, int, int);
+ method public static java.util.Spliterator<T> spliterator(java.util.Collection<? extends T>, int);
+ method public static java.util.Spliterator<T> spliterator(java.util.Iterator<? extends T>, long, int);
+ method public static java.util.Spliterator.OfInt spliterator(java.util.PrimitiveIterator.OfInt, long, int);
+ method public static java.util.Spliterator.OfLong spliterator(java.util.PrimitiveIterator.OfLong, long, int);
+ method public static java.util.Spliterator.OfDouble spliterator(java.util.PrimitiveIterator.OfDouble, long, int);
+ method public static java.util.Spliterator<T> spliteratorUnknownSize(java.util.Iterator<? extends T>, int);
+ method public static java.util.Spliterator.OfInt spliteratorUnknownSize(java.util.PrimitiveIterator.OfInt, int);
+ method public static java.util.Spliterator.OfLong spliteratorUnknownSize(java.util.PrimitiveIterator.OfLong, int);
+ method public static java.util.Spliterator.OfDouble spliteratorUnknownSize(java.util.PrimitiveIterator.OfDouble, int);
+ }
+
+ public static abstract class Spliterators.AbstractDoubleSpliterator implements java.util.Spliterator.OfDouble {
+ ctor protected Spliterators.AbstractDoubleSpliterator(long, int);
+ method public int characteristics();
+ method public long estimateSize();
+ method public java.util.Spliterator.OfDouble trySplit();
+ }
+
+ public static abstract class Spliterators.AbstractIntSpliterator implements java.util.Spliterator.OfInt {
+ ctor protected Spliterators.AbstractIntSpliterator(long, int);
+ method public int characteristics();
+ method public long estimateSize();
+ method public java.util.Spliterator.OfInt trySplit();
+ }
+
+ public static abstract class Spliterators.AbstractLongSpliterator implements java.util.Spliterator.OfLong {
+ ctor protected Spliterators.AbstractLongSpliterator(long, int);
+ method public int characteristics();
+ method public long estimateSize();
+ method public java.util.Spliterator.OfLong trySplit();
+ }
+
+ public static abstract class Spliterators.AbstractSpliterator implements java.util.Spliterator {
+ ctor protected Spliterators.AbstractSpliterator(long, int);
+ method public int characteristics();
+ method public long estimateSize();
+ method public java.util.Spliterator<T> trySplit();
+ }
+
public class Stack extends java.util.Vector {
ctor public Stack();
method public boolean empty();
@@ -58594,6 +58808,15 @@
method public synchronized int search(java.lang.Object);
}
+ public final class StringJoiner {
+ ctor public StringJoiner(java.lang.CharSequence);
+ ctor public StringJoiner(java.lang.CharSequence, java.lang.CharSequence, java.lang.CharSequence);
+ method public java.util.StringJoiner add(java.lang.CharSequence);
+ method public int length();
+ method public java.util.StringJoiner merge(java.util.StringJoiner);
+ method public java.util.StringJoiner setEmptyValue(java.lang.CharSequence);
+ }
+
public class StringTokenizer implements java.util.Enumeration {
ctor public StringTokenizer(java.lang.String, java.lang.String, boolean);
ctor public StringTokenizer(java.lang.String, java.lang.String);
@@ -58715,6 +58938,7 @@
method public E pollFirst();
method public E pollLast();
method public int size();
+ method public java.util.Spliterator<E> spliterator();
method public java.util.NavigableSet<E> subSet(E, boolean, E, boolean);
method public java.util.SortedSet<E> subSet(E, E);
method public java.util.NavigableSet<E> tailSet(E, boolean);
@@ -58771,6 +58995,7 @@
method public synchronized void setElementAt(E, int);
method public synchronized void setSize(int);
method public synchronized int size();
+ method public java.util.Spliterator<E> spliterator();
method public synchronized void trimToSize();
field protected int capacityIncrement;
field protected int elementCount;
diff --git a/api/system-current.txt b/api/system-current.txt
index 06ba88a..23b9d97 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -21674,37 +21674,129 @@
field public static final int ORIENTATION_TRANSVERSE = 7; // 0x7
field public static final int ORIENTATION_UNDEFINED = 0; // 0x0
field public static final java.lang.String TAG_APERTURE = "FNumber";
+ field public static final java.lang.String TAG_APERTURE_VALUE = "ApertureValue";
+ field public static final java.lang.String TAG_ARTIST = "Artist";
+ field public static final java.lang.String TAG_BITS_PER_SAMPLE = "BitsPerSample";
+ field public static final java.lang.String TAG_BRIGHTNESS_VALUE = "BrightnessValue";
+ field public static final java.lang.String TAG_CFA_PATTERN = "CFAPattern";
+ field public static final java.lang.String TAG_COLOR_SPACE = "ColorSpace";
+ field public static final java.lang.String TAG_COMPONENTS_CONFIGURATION = "ComponentsConfiguration";
+ field public static final java.lang.String TAG_COMPRESSED_BITS_PER_PIXEL = "CompressedBitsPerPixel";
+ field public static final java.lang.String TAG_COMPRESSION = "Compression";
+ field public static final java.lang.String TAG_CONTRAST = "Contrast";
+ field public static final java.lang.String TAG_COPYRIGHT = "Copyright";
+ field public static final java.lang.String TAG_CUSTOM_RENDERED = "CustomRendered";
field public static final java.lang.String TAG_DATETIME = "DateTime";
field public static final java.lang.String TAG_DATETIME_DIGITIZED = "DateTimeDigitized";
+ field public static final java.lang.String TAG_DATETIME_ORIGINAL = "DateTimeOriginal";
+ field public static final java.lang.String TAG_DEVICE_SETTING_DESCRIPTION = "DeviceSettingDescription";
field public static final java.lang.String TAG_DIGITAL_ZOOM_RATIO = "DigitalZoomRatio";
+ field public static final java.lang.String TAG_EXIF_VERSION = "ExifVersion";
field public static final java.lang.String TAG_EXPOSURE_BIAS_VALUE = "ExposureBiasValue";
+ field public static final java.lang.String TAG_EXPOSURE_INDEX = "ExposureIndex";
field public static final java.lang.String TAG_EXPOSURE_MODE = "ExposureMode";
field public static final java.lang.String TAG_EXPOSURE_PROGRAM = "ExposureProgram";
field public static final java.lang.String TAG_EXPOSURE_TIME = "ExposureTime";
+ field public static final java.lang.String TAG_FILE_SOURCE = "FileSource";
field public static final java.lang.String TAG_FLASH = "Flash";
+ field public static final java.lang.String TAG_FLASHPIX_VERSION = "FlashpixVersion";
+ field public static final java.lang.String TAG_FLASH_ENERGY = "FlashEnergy";
field public static final java.lang.String TAG_FOCAL_LENGTH = "FocalLength";
+ field public static final java.lang.String TAG_FOCAL_LENGTH_IN_35MM_FILM = "FocalLengthIn35mmFilm";
+ field public static final java.lang.String TAG_FOCAL_PLANE_RESOLUTION_UNIT = "FocalPlaneResolutionUnit";
+ field public static final java.lang.String TAG_FOCAL_PLANE_X_RESOLUTION = "FocalPlaneXResolution";
+ field public static final java.lang.String TAG_FOCAL_PLANE_Y_RESOLUTION = "FocalPlaneYResolution";
+ field public static final java.lang.String TAG_F_NUMBER = "FNumber";
+ field public static final java.lang.String TAG_GAIN_CONTROL = "GainControl";
field public static final java.lang.String TAG_GPS_ALTITUDE = "GPSAltitude";
field public static final java.lang.String TAG_GPS_ALTITUDE_REF = "GPSAltitudeRef";
+ field public static final java.lang.String TAG_GPS_AREA_INFORMATION = "GPSAreaInformation";
field public static final java.lang.String TAG_GPS_DATESTAMP = "GPSDateStamp";
+ field public static final java.lang.String TAG_GPS_DEST_BEARING = "GPSDestBearing";
+ field public static final java.lang.String TAG_GPS_DEST_BEARING_REF = "GPSDestBearingRef";
+ field public static final java.lang.String TAG_GPS_DEST_DISTANCE = "GPSDestDistance";
+ field public static final java.lang.String TAG_GPS_DEST_DISTANCE_REF = "GPSDestDistanceRef";
+ field public static final java.lang.String TAG_GPS_DEST_LATITUDE = "GPSDestLatitude";
+ field public static final java.lang.String TAG_GPS_DEST_LATITUDE_REF = "GPSDestLatitudeRef";
+ field public static final java.lang.String TAG_GPS_DEST_LONGITUDE = "GPSDestLongitude";
+ field public static final java.lang.String TAG_GPS_DEST_LONGITUDE_REF = "GPSDestLongitudeRef";
+ field public static final java.lang.String TAG_GPS_DIFFERENTIAL = "GPSDifferential";
+ field public static final java.lang.String TAG_GPS_DOP = "GPSDOP";
+ field public static final java.lang.String TAG_GPS_IMG_DIRECTION = "GPSImgDirection";
+ field public static final java.lang.String TAG_GPS_IMG_DIRECTION_REF = "GPSImgDirectionRef";
field public static final java.lang.String TAG_GPS_LATITUDE = "GPSLatitude";
field public static final java.lang.String TAG_GPS_LATITUDE_REF = "GPSLatitudeRef";
field public static final java.lang.String TAG_GPS_LONGITUDE = "GPSLongitude";
field public static final java.lang.String TAG_GPS_LONGITUDE_REF = "GPSLongitudeRef";
+ field public static final java.lang.String TAG_GPS_MAP_DATUM = "GPSMapDatum";
+ field public static final java.lang.String TAG_GPS_MEASURE_MODE = "GPSMeasureMode";
field public static final java.lang.String TAG_GPS_PROCESSING_METHOD = "GPSProcessingMethod";
+ field public static final java.lang.String TAG_GPS_SATELLITES = "GPSSatellites";
+ field public static final java.lang.String TAG_GPS_SPEED = "GPSSpeed";
+ field public static final java.lang.String TAG_GPS_SPEED_REF = "GPSSpeedRef";
+ field public static final java.lang.String TAG_GPS_STATUS = "GPSStatus";
field public static final java.lang.String TAG_GPS_TIMESTAMP = "GPSTimeStamp";
+ field public static final java.lang.String TAG_GPS_TRACK = "GPSTrack";
+ field public static final java.lang.String TAG_GPS_TRACK_REF = "GPSTrackRef";
+ field public static final java.lang.String TAG_GPS_VERSION_ID = "GPSVersionID";
+ field public static final java.lang.String TAG_IMAGE_DESCRIPTION = "ImageDescription";
field public static final java.lang.String TAG_IMAGE_LENGTH = "ImageLength";
+ field public static final java.lang.String TAG_IMAGE_UNIQUE_ID = "ImageUniqueID";
field public static final java.lang.String TAG_IMAGE_WIDTH = "ImageWidth";
+ field public static final java.lang.String TAG_INTEROPERABILITY_INDEX = "InteroperabilityIndex";
field public static final java.lang.String TAG_ISO = "ISOSpeedRatings";
+ field public static final java.lang.String TAG_ISO_SPEED_RATINGS = "ISOSpeedRatings";
+ field public static final java.lang.String TAG_JPEG_INTERCHANGE_FORMAT = "JPEGInterchangeFormat";
+ field public static final java.lang.String TAG_JPEG_INTERCHANGE_FORMAT_LENGTH = "JPEGInterchangeFormatLength";
field public static final java.lang.String TAG_LIGHT_SOURCE = "LightSource";
field public static final java.lang.String TAG_MAKE = "Make";
+ field public static final java.lang.String TAG_MAKER_NOTE = "MakerNote";
+ field public static final java.lang.String TAG_MAX_APERTURE_VALUE = "MaxApertureValue";
field public static final java.lang.String TAG_METERING_MODE = "MeteringMode";
field public static final java.lang.String TAG_MODEL = "Model";
+ field public static final java.lang.String TAG_OECF = "OECF";
field public static final java.lang.String TAG_ORIENTATION = "Orientation";
+ field public static final java.lang.String TAG_PHOTOMETRIC_INTERPRETATION = "PhotometricInterpretation";
+ field public static final java.lang.String TAG_PIXEL_X_DIMENSION = "PixelXDimension";
+ field public static final java.lang.String TAG_PIXEL_Y_DIMENSION = "PixelYDimension";
+ field public static final java.lang.String TAG_PLANAR_CONFIGURATION = "PlanarConfiguration";
+ field public static final java.lang.String TAG_PRIMARY_CHROMATICITIES = "PrimaryChromaticities";
+ field public static final java.lang.String TAG_REFERENCE_BLACK_WHITE = "ReferenceBlackWhite";
+ field public static final java.lang.String TAG_RELATED_SOUND_FILE = "RelatedSoundFile";
+ field public static final java.lang.String TAG_RESOLUTION_UNIT = "ResolutionUnit";
+ field public static final java.lang.String TAG_ROWS_PER_STRIP = "RowsPerStrip";
+ field public static final java.lang.String TAG_SAMPLES_PER_PIXEL = "SamplesPerPixel";
+ field public static final java.lang.String TAG_SATURATION = "Saturation";
+ field public static final java.lang.String TAG_SCENE_CAPTURE_TYPE = "SceneCaptureType";
+ field public static final java.lang.String TAG_SCENE_TYPE = "SceneType";
+ field public static final java.lang.String TAG_SENSING_METHOD = "SensingMethod";
+ field public static final java.lang.String TAG_SHARPNESS = "Sharpness";
+ field public static final java.lang.String TAG_SHUTTER_SPEED_VALUE = "ShutterSpeedValue";
+ field public static final java.lang.String TAG_SOFTWARE = "Software";
+ field public static final java.lang.String TAG_SPATIAL_FREQUENCY_RESPONSE = "SpatialFrequencyResponse";
+ field public static final java.lang.String TAG_SPECTRAL_SENSITIVITY = "SpectralSensitivity";
+ field public static final java.lang.String TAG_STRIP_BYTE_COUNTS = "StripByteCounts";
+ field public static final java.lang.String TAG_STRIP_OFFSETS = "StripOffsets";
+ field public static final java.lang.String TAG_SUBJECT_AREA = "SubjectArea";
field public static final java.lang.String TAG_SUBJECT_DISTANCE = "SubjectDistance";
+ field public static final java.lang.String TAG_SUBJECT_DISTANCE_RANGE = "SubjectDistanceRange";
+ field public static final java.lang.String TAG_SUBJECT_LOCATION = "SubjectLocation";
field public static final java.lang.String TAG_SUBSEC_TIME = "SubSecTime";
field public static final java.lang.String TAG_SUBSEC_TIME_DIG = "SubSecTimeDigitized";
+ field public static final java.lang.String TAG_SUBSEC_TIME_DIGITIZED = "SubSecTimeDigitized";
field public static final java.lang.String TAG_SUBSEC_TIME_ORIG = "SubSecTimeOriginal";
+ field public static final java.lang.String TAG_SUBSEC_TIME_ORIGINAL = "SubSecTimeOriginal";
+ field public static final java.lang.String TAG_THUMBNAIL_IMAGE_LENGTH = "ThumbnailImageLength";
+ field public static final java.lang.String TAG_THUMBNAIL_IMAGE_WIDTH = "ThumbnailImageWidth";
+ field public static final java.lang.String TAG_TRANSFER_FUNCTION = "TransferFunction";
+ field public static final java.lang.String TAG_USER_COMMENT = "UserComment";
field public static final java.lang.String TAG_WHITE_BALANCE = "WhiteBalance";
+ field public static final java.lang.String TAG_WHITE_POINT = "WhitePoint";
+ field public static final java.lang.String TAG_X_RESOLUTION = "XResolution";
+ field public static final java.lang.String TAG_Y_CB_CR_COEFFICIENTS = "YCbCrCoefficients";
+ field public static final java.lang.String TAG_Y_CB_CR_POSITIONING = "YCbCrPositioning";
+ field public static final java.lang.String TAG_Y_CB_CR_SUB_SAMPLING = "YCbCrSubSampling";
+ field public static final java.lang.String TAG_Y_RESOLUTION = "YResolution";
field public static final int WHITEBALANCE_AUTO = 0; // 0x0
field public static final int WHITEBALANCE_MANUAL = 1; // 0x1
}
@@ -53913,6 +54005,7 @@
public abstract interface Iterable {
method public default void forEach(java.util.function.Consumer<? super T>);
method public abstract java.util.Iterator<T> iterator();
+ method public default java.util.Spliterator<T> spliterator();
}
public class LinkageError extends java.lang.Error {
@@ -60333,6 +60426,7 @@
method public E removeLast();
method public boolean removeLastOccurrence(java.lang.Object);
method public int size();
+ method public java.util.Spliterator<E> spliterator();
}
public class ArrayList extends java.util.AbstractList implements java.lang.Cloneable java.util.List java.util.RandomAccess java.io.Serializable {
@@ -60344,6 +60438,7 @@
method public void forEach(java.util.function.Consumer<? super E>);
method public E get(int);
method public int size();
+ method public java.util.Spliterator<E> spliterator();
method public void trimToSize();
}
@@ -60444,6 +60539,14 @@
method public static void sort(java.lang.Object[], int, int);
method public static void sort(T[], java.util.Comparator<? super T>);
method public static void sort(T[], int, int, java.util.Comparator<? super T>);
+ method public static java.util.Spliterator<T> spliterator(T[]);
+ method public static java.util.Spliterator<T> spliterator(T[], int, int);
+ method public static java.util.Spliterator.OfInt spliterator(int[]);
+ method public static java.util.Spliterator.OfInt spliterator(int[], int, int);
+ method public static java.util.Spliterator.OfLong spliterator(long[]);
+ method public static java.util.Spliterator.OfLong spliterator(long[], int, int);
+ method public static java.util.Spliterator.OfDouble spliterator(double[]);
+ method public static java.util.Spliterator.OfDouble spliterator(double[], int, int);
method public static java.lang.String toString(long[]);
method public static java.lang.String toString(int[]);
method public static java.lang.String toString(short[]);
@@ -60943,6 +61046,7 @@
method public java.lang.Object clone();
method public java.util.Iterator<E> iterator();
method public int size();
+ method public java.util.Spliterator<E> spliterator();
}
public class Hashtable extends java.util.Dictionary implements java.lang.Cloneable java.util.Map java.io.Serializable {
@@ -61087,6 +61191,7 @@
method public E removeLast();
method public boolean removeLastOccurrence(java.lang.Object);
method public int size();
+ method public java.util.Spliterator<E> spliterator();
}
public abstract interface List implements java.util.Collection {
@@ -61253,6 +61358,8 @@
}
public static abstract interface Map.Entry {
+ method public static java.util.Comparator<java.util.Map.Entry<K, V>> comparingByKey();
+ method public static java.util.Comparator<java.util.Map.Entry<K, V>> comparingByKey(java.util.Comparator<? super K>);
method public abstract boolean equals(java.lang.Object);
method public abstract K getKey();
method public abstract V getValue();
@@ -61431,6 +61538,7 @@
public class PriorityQueue extends java.util.AbstractQueue implements java.io.Serializable {
ctor public PriorityQueue();
ctor public PriorityQueue(int);
+ ctor public PriorityQueue(java.util.Comparator<? super E>);
ctor public PriorityQueue(int, java.util.Comparator<? super E>);
ctor public PriorityQueue(java.util.Collection<? extends E>);
ctor public PriorityQueue(java.util.PriorityQueue<? extends E>);
@@ -61441,6 +61549,7 @@
method public E peek();
method public E poll();
method public int size();
+ method public final java.util.Spliterator<E> spliterator();
}
public class Properties extends java.util.Hashtable {
@@ -61683,6 +61792,111 @@
method public abstract java.util.SortedSet<E> tailSet(E);
}
+ public abstract interface Spliterator {
+ method public abstract int characteristics();
+ method public abstract long estimateSize();
+ method public default void forEachRemaining(java.util.function.Consumer<? super T>);
+ method public default java.util.Comparator<? super T> getComparator();
+ method public default long getExactSizeIfKnown();
+ method public default boolean hasCharacteristics(int);
+ method public abstract boolean tryAdvance(java.util.function.Consumer<? super T>);
+ method public abstract java.util.Spliterator<T> trySplit();
+ field public static final int CONCURRENT = 4096; // 0x1000
+ field public static final int DISTINCT = 1; // 0x1
+ field public static final int IMMUTABLE = 1024; // 0x400
+ field public static final int NONNULL = 256; // 0x100
+ field public static final int ORDERED = 16; // 0x10
+ field public static final int SIZED = 64; // 0x40
+ field public static final int SORTED = 4; // 0x4
+ field public static final int SUBSIZED = 16384; // 0x4000
+ }
+
+ public static abstract interface Spliterator.OfDouble implements java.util.Spliterator.OfPrimitive {
+ method public default void forEachRemaining(java.util.function.DoubleConsumer);
+ method public default void forEachRemaining(java.util.function.Consumer<? super java.lang.Double>);
+ method public abstract boolean tryAdvance(java.util.function.DoubleConsumer);
+ method public default boolean tryAdvance(java.util.function.Consumer<? super java.lang.Double>);
+ method public abstract java.util.Spliterator.OfDouble trySplit();
+ }
+
+ public static abstract interface Spliterator.OfInt implements java.util.Spliterator.OfPrimitive {
+ method public default void forEachRemaining(java.util.function.IntConsumer);
+ method public default void forEachRemaining(java.util.function.Consumer<? super java.lang.Integer>);
+ method public abstract boolean tryAdvance(java.util.function.IntConsumer);
+ method public default boolean tryAdvance(java.util.function.Consumer<? super java.lang.Integer>);
+ method public abstract java.util.Spliterator.OfInt trySplit();
+ }
+
+ public static abstract interface Spliterator.OfLong implements java.util.Spliterator.OfPrimitive {
+ method public default void forEachRemaining(java.util.function.LongConsumer);
+ method public default void forEachRemaining(java.util.function.Consumer<? super java.lang.Long>);
+ method public abstract boolean tryAdvance(java.util.function.LongConsumer);
+ method public default boolean tryAdvance(java.util.function.Consumer<? super java.lang.Long>);
+ method public abstract java.util.Spliterator.OfLong trySplit();
+ }
+
+ public static abstract interface Spliterator.OfPrimitive implements java.util.Spliterator {
+ method public default void forEachRemaining(T_CONS);
+ method public abstract boolean tryAdvance(T_CONS);
+ method public abstract T_SPLITR trySplit();
+ }
+
+ public final class Spliterators {
+ method public static java.util.Spliterator.OfDouble emptyDoubleSpliterator();
+ method public static java.util.Spliterator.OfInt emptyIntSpliterator();
+ method public static java.util.Spliterator.OfLong emptyLongSpliterator();
+ method public static java.util.Spliterator<T> emptySpliterator();
+ method public static java.util.Iterator<T> iterator(java.util.Spliterator<? extends T>);
+ method public static java.util.PrimitiveIterator.OfInt iterator(java.util.Spliterator.OfInt);
+ method public static java.util.PrimitiveIterator.OfLong iterator(java.util.Spliterator.OfLong);
+ method public static java.util.PrimitiveIterator.OfDouble iterator(java.util.Spliterator.OfDouble);
+ method public static java.util.Spliterator<T> spliterator(java.lang.Object[], int);
+ method public static java.util.Spliterator<T> spliterator(java.lang.Object[], int, int, int);
+ method public static java.util.Spliterator.OfInt spliterator(int[], int);
+ method public static java.util.Spliterator.OfInt spliterator(int[], int, int, int);
+ method public static java.util.Spliterator.OfLong spliterator(long[], int);
+ method public static java.util.Spliterator.OfLong spliterator(long[], int, int, int);
+ method public static java.util.Spliterator.OfDouble spliterator(double[], int);
+ method public static java.util.Spliterator.OfDouble spliterator(double[], int, int, int);
+ method public static java.util.Spliterator<T> spliterator(java.util.Collection<? extends T>, int);
+ method public static java.util.Spliterator<T> spliterator(java.util.Iterator<? extends T>, long, int);
+ method public static java.util.Spliterator.OfInt spliterator(java.util.PrimitiveIterator.OfInt, long, int);
+ method public static java.util.Spliterator.OfLong spliterator(java.util.PrimitiveIterator.OfLong, long, int);
+ method public static java.util.Spliterator.OfDouble spliterator(java.util.PrimitiveIterator.OfDouble, long, int);
+ method public static java.util.Spliterator<T> spliteratorUnknownSize(java.util.Iterator<? extends T>, int);
+ method public static java.util.Spliterator.OfInt spliteratorUnknownSize(java.util.PrimitiveIterator.OfInt, int);
+ method public static java.util.Spliterator.OfLong spliteratorUnknownSize(java.util.PrimitiveIterator.OfLong, int);
+ method public static java.util.Spliterator.OfDouble spliteratorUnknownSize(java.util.PrimitiveIterator.OfDouble, int);
+ }
+
+ public static abstract class Spliterators.AbstractDoubleSpliterator implements java.util.Spliterator.OfDouble {
+ ctor protected Spliterators.AbstractDoubleSpliterator(long, int);
+ method public int characteristics();
+ method public long estimateSize();
+ method public java.util.Spliterator.OfDouble trySplit();
+ }
+
+ public static abstract class Spliterators.AbstractIntSpliterator implements java.util.Spliterator.OfInt {
+ ctor protected Spliterators.AbstractIntSpliterator(long, int);
+ method public int characteristics();
+ method public long estimateSize();
+ method public java.util.Spliterator.OfInt trySplit();
+ }
+
+ public static abstract class Spliterators.AbstractLongSpliterator implements java.util.Spliterator.OfLong {
+ ctor protected Spliterators.AbstractLongSpliterator(long, int);
+ method public int characteristics();
+ method public long estimateSize();
+ method public java.util.Spliterator.OfLong trySplit();
+ }
+
+ public static abstract class Spliterators.AbstractSpliterator implements java.util.Spliterator {
+ ctor protected Spliterators.AbstractSpliterator(long, int);
+ method public int characteristics();
+ method public long estimateSize();
+ method public java.util.Spliterator<T> trySplit();
+ }
+
public class Stack extends java.util.Vector {
ctor public Stack();
method public boolean empty();
@@ -61692,6 +61906,15 @@
method public synchronized int search(java.lang.Object);
}
+ public final class StringJoiner {
+ ctor public StringJoiner(java.lang.CharSequence);
+ ctor public StringJoiner(java.lang.CharSequence, java.lang.CharSequence, java.lang.CharSequence);
+ method public java.util.StringJoiner add(java.lang.CharSequence);
+ method public int length();
+ method public java.util.StringJoiner merge(java.util.StringJoiner);
+ method public java.util.StringJoiner setEmptyValue(java.lang.CharSequence);
+ }
+
public class StringTokenizer implements java.util.Enumeration {
ctor public StringTokenizer(java.lang.String, java.lang.String, boolean);
ctor public StringTokenizer(java.lang.String, java.lang.String);
@@ -61813,6 +62036,7 @@
method public E pollFirst();
method public E pollLast();
method public int size();
+ method public java.util.Spliterator<E> spliterator();
method public java.util.NavigableSet<E> subSet(E, boolean, E, boolean);
method public java.util.SortedSet<E> subSet(E, E);
method public java.util.NavigableSet<E> tailSet(E, boolean);
@@ -61869,6 +62093,7 @@
method public synchronized void setElementAt(E, int);
method public synchronized void setSize(int);
method public synchronized int size();
+ method public java.util.Spliterator<E> spliterator();
method public synchronized void trimToSize();
field protected int capacityIncrement;
field protected int elementCount;
diff --git a/api/test-current.txt b/api/test-current.txt
index 8533471..cdffa46 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -20248,37 +20248,129 @@
field public static final int ORIENTATION_TRANSVERSE = 7; // 0x7
field public static final int ORIENTATION_UNDEFINED = 0; // 0x0
field public static final java.lang.String TAG_APERTURE = "FNumber";
+ field public static final java.lang.String TAG_APERTURE_VALUE = "ApertureValue";
+ field public static final java.lang.String TAG_ARTIST = "Artist";
+ field public static final java.lang.String TAG_BITS_PER_SAMPLE = "BitsPerSample";
+ field public static final java.lang.String TAG_BRIGHTNESS_VALUE = "BrightnessValue";
+ field public static final java.lang.String TAG_CFA_PATTERN = "CFAPattern";
+ field public static final java.lang.String TAG_COLOR_SPACE = "ColorSpace";
+ field public static final java.lang.String TAG_COMPONENTS_CONFIGURATION = "ComponentsConfiguration";
+ field public static final java.lang.String TAG_COMPRESSED_BITS_PER_PIXEL = "CompressedBitsPerPixel";
+ field public static final java.lang.String TAG_COMPRESSION = "Compression";
+ field public static final java.lang.String TAG_CONTRAST = "Contrast";
+ field public static final java.lang.String TAG_COPYRIGHT = "Copyright";
+ field public static final java.lang.String TAG_CUSTOM_RENDERED = "CustomRendered";
field public static final java.lang.String TAG_DATETIME = "DateTime";
field public static final java.lang.String TAG_DATETIME_DIGITIZED = "DateTimeDigitized";
+ field public static final java.lang.String TAG_DATETIME_ORIGINAL = "DateTimeOriginal";
+ field public static final java.lang.String TAG_DEVICE_SETTING_DESCRIPTION = "DeviceSettingDescription";
field public static final java.lang.String TAG_DIGITAL_ZOOM_RATIO = "DigitalZoomRatio";
+ field public static final java.lang.String TAG_EXIF_VERSION = "ExifVersion";
field public static final java.lang.String TAG_EXPOSURE_BIAS_VALUE = "ExposureBiasValue";
+ field public static final java.lang.String TAG_EXPOSURE_INDEX = "ExposureIndex";
field public static final java.lang.String TAG_EXPOSURE_MODE = "ExposureMode";
field public static final java.lang.String TAG_EXPOSURE_PROGRAM = "ExposureProgram";
field public static final java.lang.String TAG_EXPOSURE_TIME = "ExposureTime";
+ field public static final java.lang.String TAG_FILE_SOURCE = "FileSource";
field public static final java.lang.String TAG_FLASH = "Flash";
+ field public static final java.lang.String TAG_FLASHPIX_VERSION = "FlashpixVersion";
+ field public static final java.lang.String TAG_FLASH_ENERGY = "FlashEnergy";
field public static final java.lang.String TAG_FOCAL_LENGTH = "FocalLength";
+ field public static final java.lang.String TAG_FOCAL_LENGTH_IN_35MM_FILM = "FocalLengthIn35mmFilm";
+ field public static final java.lang.String TAG_FOCAL_PLANE_RESOLUTION_UNIT = "FocalPlaneResolutionUnit";
+ field public static final java.lang.String TAG_FOCAL_PLANE_X_RESOLUTION = "FocalPlaneXResolution";
+ field public static final java.lang.String TAG_FOCAL_PLANE_Y_RESOLUTION = "FocalPlaneYResolution";
+ field public static final java.lang.String TAG_F_NUMBER = "FNumber";
+ field public static final java.lang.String TAG_GAIN_CONTROL = "GainControl";
field public static final java.lang.String TAG_GPS_ALTITUDE = "GPSAltitude";
field public static final java.lang.String TAG_GPS_ALTITUDE_REF = "GPSAltitudeRef";
+ field public static final java.lang.String TAG_GPS_AREA_INFORMATION = "GPSAreaInformation";
field public static final java.lang.String TAG_GPS_DATESTAMP = "GPSDateStamp";
+ field public static final java.lang.String TAG_GPS_DEST_BEARING = "GPSDestBearing";
+ field public static final java.lang.String TAG_GPS_DEST_BEARING_REF = "GPSDestBearingRef";
+ field public static final java.lang.String TAG_GPS_DEST_DISTANCE = "GPSDestDistance";
+ field public static final java.lang.String TAG_GPS_DEST_DISTANCE_REF = "GPSDestDistanceRef";
+ field public static final java.lang.String TAG_GPS_DEST_LATITUDE = "GPSDestLatitude";
+ field public static final java.lang.String TAG_GPS_DEST_LATITUDE_REF = "GPSDestLatitudeRef";
+ field public static final java.lang.String TAG_GPS_DEST_LONGITUDE = "GPSDestLongitude";
+ field public static final java.lang.String TAG_GPS_DEST_LONGITUDE_REF = "GPSDestLongitudeRef";
+ field public static final java.lang.String TAG_GPS_DIFFERENTIAL = "GPSDifferential";
+ field public static final java.lang.String TAG_GPS_DOP = "GPSDOP";
+ field public static final java.lang.String TAG_GPS_IMG_DIRECTION = "GPSImgDirection";
+ field public static final java.lang.String TAG_GPS_IMG_DIRECTION_REF = "GPSImgDirectionRef";
field public static final java.lang.String TAG_GPS_LATITUDE = "GPSLatitude";
field public static final java.lang.String TAG_GPS_LATITUDE_REF = "GPSLatitudeRef";
field public static final java.lang.String TAG_GPS_LONGITUDE = "GPSLongitude";
field public static final java.lang.String TAG_GPS_LONGITUDE_REF = "GPSLongitudeRef";
+ field public static final java.lang.String TAG_GPS_MAP_DATUM = "GPSMapDatum";
+ field public static final java.lang.String TAG_GPS_MEASURE_MODE = "GPSMeasureMode";
field public static final java.lang.String TAG_GPS_PROCESSING_METHOD = "GPSProcessingMethod";
+ field public static final java.lang.String TAG_GPS_SATELLITES = "GPSSatellites";
+ field public static final java.lang.String TAG_GPS_SPEED = "GPSSpeed";
+ field public static final java.lang.String TAG_GPS_SPEED_REF = "GPSSpeedRef";
+ field public static final java.lang.String TAG_GPS_STATUS = "GPSStatus";
field public static final java.lang.String TAG_GPS_TIMESTAMP = "GPSTimeStamp";
+ field public static final java.lang.String TAG_GPS_TRACK = "GPSTrack";
+ field public static final java.lang.String TAG_GPS_TRACK_REF = "GPSTrackRef";
+ field public static final java.lang.String TAG_GPS_VERSION_ID = "GPSVersionID";
+ field public static final java.lang.String TAG_IMAGE_DESCRIPTION = "ImageDescription";
field public static final java.lang.String TAG_IMAGE_LENGTH = "ImageLength";
+ field public static final java.lang.String TAG_IMAGE_UNIQUE_ID = "ImageUniqueID";
field public static final java.lang.String TAG_IMAGE_WIDTH = "ImageWidth";
+ field public static final java.lang.String TAG_INTEROPERABILITY_INDEX = "InteroperabilityIndex";
field public static final java.lang.String TAG_ISO = "ISOSpeedRatings";
+ field public static final java.lang.String TAG_ISO_SPEED_RATINGS = "ISOSpeedRatings";
+ field public static final java.lang.String TAG_JPEG_INTERCHANGE_FORMAT = "JPEGInterchangeFormat";
+ field public static final java.lang.String TAG_JPEG_INTERCHANGE_FORMAT_LENGTH = "JPEGInterchangeFormatLength";
field public static final java.lang.String TAG_LIGHT_SOURCE = "LightSource";
field public static final java.lang.String TAG_MAKE = "Make";
+ field public static final java.lang.String TAG_MAKER_NOTE = "MakerNote";
+ field public static final java.lang.String TAG_MAX_APERTURE_VALUE = "MaxApertureValue";
field public static final java.lang.String TAG_METERING_MODE = "MeteringMode";
field public static final java.lang.String TAG_MODEL = "Model";
+ field public static final java.lang.String TAG_OECF = "OECF";
field public static final java.lang.String TAG_ORIENTATION = "Orientation";
+ field public static final java.lang.String TAG_PHOTOMETRIC_INTERPRETATION = "PhotometricInterpretation";
+ field public static final java.lang.String TAG_PIXEL_X_DIMENSION = "PixelXDimension";
+ field public static final java.lang.String TAG_PIXEL_Y_DIMENSION = "PixelYDimension";
+ field public static final java.lang.String TAG_PLANAR_CONFIGURATION = "PlanarConfiguration";
+ field public static final java.lang.String TAG_PRIMARY_CHROMATICITIES = "PrimaryChromaticities";
+ field public static final java.lang.String TAG_REFERENCE_BLACK_WHITE = "ReferenceBlackWhite";
+ field public static final java.lang.String TAG_RELATED_SOUND_FILE = "RelatedSoundFile";
+ field public static final java.lang.String TAG_RESOLUTION_UNIT = "ResolutionUnit";
+ field public static final java.lang.String TAG_ROWS_PER_STRIP = "RowsPerStrip";
+ field public static final java.lang.String TAG_SAMPLES_PER_PIXEL = "SamplesPerPixel";
+ field public static final java.lang.String TAG_SATURATION = "Saturation";
+ field public static final java.lang.String TAG_SCENE_CAPTURE_TYPE = "SceneCaptureType";
+ field public static final java.lang.String TAG_SCENE_TYPE = "SceneType";
+ field public static final java.lang.String TAG_SENSING_METHOD = "SensingMethod";
+ field public static final java.lang.String TAG_SHARPNESS = "Sharpness";
+ field public static final java.lang.String TAG_SHUTTER_SPEED_VALUE = "ShutterSpeedValue";
+ field public static final java.lang.String TAG_SOFTWARE = "Software";
+ field public static final java.lang.String TAG_SPATIAL_FREQUENCY_RESPONSE = "SpatialFrequencyResponse";
+ field public static final java.lang.String TAG_SPECTRAL_SENSITIVITY = "SpectralSensitivity";
+ field public static final java.lang.String TAG_STRIP_BYTE_COUNTS = "StripByteCounts";
+ field public static final java.lang.String TAG_STRIP_OFFSETS = "StripOffsets";
+ field public static final java.lang.String TAG_SUBJECT_AREA = "SubjectArea";
field public static final java.lang.String TAG_SUBJECT_DISTANCE = "SubjectDistance";
+ field public static final java.lang.String TAG_SUBJECT_DISTANCE_RANGE = "SubjectDistanceRange";
+ field public static final java.lang.String TAG_SUBJECT_LOCATION = "SubjectLocation";
field public static final java.lang.String TAG_SUBSEC_TIME = "SubSecTime";
field public static final java.lang.String TAG_SUBSEC_TIME_DIG = "SubSecTimeDigitized";
+ field public static final java.lang.String TAG_SUBSEC_TIME_DIGITIZED = "SubSecTimeDigitized";
field public static final java.lang.String TAG_SUBSEC_TIME_ORIG = "SubSecTimeOriginal";
+ field public static final java.lang.String TAG_SUBSEC_TIME_ORIGINAL = "SubSecTimeOriginal";
+ field public static final java.lang.String TAG_THUMBNAIL_IMAGE_LENGTH = "ThumbnailImageLength";
+ field public static final java.lang.String TAG_THUMBNAIL_IMAGE_WIDTH = "ThumbnailImageWidth";
+ field public static final java.lang.String TAG_TRANSFER_FUNCTION = "TransferFunction";
+ field public static final java.lang.String TAG_USER_COMMENT = "UserComment";
field public static final java.lang.String TAG_WHITE_BALANCE = "WhiteBalance";
+ field public static final java.lang.String TAG_WHITE_POINT = "WhitePoint";
+ field public static final java.lang.String TAG_X_RESOLUTION = "XResolution";
+ field public static final java.lang.String TAG_Y_CB_CR_COEFFICIENTS = "YCbCrCoefficients";
+ field public static final java.lang.String TAG_Y_CB_CR_POSITIONING = "YCbCrPositioning";
+ field public static final java.lang.String TAG_Y_CB_CR_SUB_SAMPLING = "YCbCrSubSampling";
+ field public static final java.lang.String TAG_Y_RESOLUTION = "YResolution";
field public static final int WHITEBALANCE_AUTO = 0; // 0x0
field public static final int WHITEBALANCE_MANUAL = 1; // 0x1
}
@@ -50889,6 +50981,7 @@
public abstract interface Iterable {
method public default void forEach(java.util.function.Consumer<? super T>);
method public abstract java.util.Iterator<T> iterator();
+ method public default java.util.Spliterator<T> spliterator();
}
public class LinkageError extends java.lang.Error {
@@ -57309,6 +57402,7 @@
method public E removeLast();
method public boolean removeLastOccurrence(java.lang.Object);
method public int size();
+ method public java.util.Spliterator<E> spliterator();
}
public class ArrayList extends java.util.AbstractList implements java.lang.Cloneable java.util.List java.util.RandomAccess java.io.Serializable {
@@ -57320,6 +57414,7 @@
method public void forEach(java.util.function.Consumer<? super E>);
method public E get(int);
method public int size();
+ method public java.util.Spliterator<E> spliterator();
method public void trimToSize();
}
@@ -57420,6 +57515,14 @@
method public static void sort(java.lang.Object[], int, int);
method public static void sort(T[], java.util.Comparator<? super T>);
method public static void sort(T[], int, int, java.util.Comparator<? super T>);
+ method public static java.util.Spliterator<T> spliterator(T[]);
+ method public static java.util.Spliterator<T> spliterator(T[], int, int);
+ method public static java.util.Spliterator.OfInt spliterator(int[]);
+ method public static java.util.Spliterator.OfInt spliterator(int[], int, int);
+ method public static java.util.Spliterator.OfLong spliterator(long[]);
+ method public static java.util.Spliterator.OfLong spliterator(long[], int, int);
+ method public static java.util.Spliterator.OfDouble spliterator(double[]);
+ method public static java.util.Spliterator.OfDouble spliterator(double[], int, int);
method public static java.lang.String toString(long[]);
method public static java.lang.String toString(int[]);
method public static java.lang.String toString(short[]);
@@ -57919,6 +58022,7 @@
method public java.lang.Object clone();
method public java.util.Iterator<E> iterator();
method public int size();
+ method public java.util.Spliterator<E> spliterator();
}
public class Hashtable extends java.util.Dictionary implements java.lang.Cloneable java.util.Map java.io.Serializable {
@@ -58063,6 +58167,7 @@
method public E removeLast();
method public boolean removeLastOccurrence(java.lang.Object);
method public int size();
+ method public java.util.Spliterator<E> spliterator();
}
public abstract interface List implements java.util.Collection {
@@ -58229,6 +58334,8 @@
}
public static abstract interface Map.Entry {
+ method public static java.util.Comparator<java.util.Map.Entry<K, V>> comparingByKey();
+ method public static java.util.Comparator<java.util.Map.Entry<K, V>> comparingByKey(java.util.Comparator<? super K>);
method public abstract boolean equals(java.lang.Object);
method public abstract K getKey();
method public abstract V getValue();
@@ -58407,6 +58514,7 @@
public class PriorityQueue extends java.util.AbstractQueue implements java.io.Serializable {
ctor public PriorityQueue();
ctor public PriorityQueue(int);
+ ctor public PriorityQueue(java.util.Comparator<? super E>);
ctor public PriorityQueue(int, java.util.Comparator<? super E>);
ctor public PriorityQueue(java.util.Collection<? extends E>);
ctor public PriorityQueue(java.util.PriorityQueue<? extends E>);
@@ -58417,6 +58525,7 @@
method public E peek();
method public E poll();
method public int size();
+ method public final java.util.Spliterator<E> spliterator();
}
public class Properties extends java.util.Hashtable {
@@ -58659,6 +58768,111 @@
method public abstract java.util.SortedSet<E> tailSet(E);
}
+ public abstract interface Spliterator {
+ method public abstract int characteristics();
+ method public abstract long estimateSize();
+ method public default void forEachRemaining(java.util.function.Consumer<? super T>);
+ method public default java.util.Comparator<? super T> getComparator();
+ method public default long getExactSizeIfKnown();
+ method public default boolean hasCharacteristics(int);
+ method public abstract boolean tryAdvance(java.util.function.Consumer<? super T>);
+ method public abstract java.util.Spliterator<T> trySplit();
+ field public static final int CONCURRENT = 4096; // 0x1000
+ field public static final int DISTINCT = 1; // 0x1
+ field public static final int IMMUTABLE = 1024; // 0x400
+ field public static final int NONNULL = 256; // 0x100
+ field public static final int ORDERED = 16; // 0x10
+ field public static final int SIZED = 64; // 0x40
+ field public static final int SORTED = 4; // 0x4
+ field public static final int SUBSIZED = 16384; // 0x4000
+ }
+
+ public static abstract interface Spliterator.OfDouble implements java.util.Spliterator.OfPrimitive {
+ method public default void forEachRemaining(java.util.function.DoubleConsumer);
+ method public default void forEachRemaining(java.util.function.Consumer<? super java.lang.Double>);
+ method public abstract boolean tryAdvance(java.util.function.DoubleConsumer);
+ method public default boolean tryAdvance(java.util.function.Consumer<? super java.lang.Double>);
+ method public abstract java.util.Spliterator.OfDouble trySplit();
+ }
+
+ public static abstract interface Spliterator.OfInt implements java.util.Spliterator.OfPrimitive {
+ method public default void forEachRemaining(java.util.function.IntConsumer);
+ method public default void forEachRemaining(java.util.function.Consumer<? super java.lang.Integer>);
+ method public abstract boolean tryAdvance(java.util.function.IntConsumer);
+ method public default boolean tryAdvance(java.util.function.Consumer<? super java.lang.Integer>);
+ method public abstract java.util.Spliterator.OfInt trySplit();
+ }
+
+ public static abstract interface Spliterator.OfLong implements java.util.Spliterator.OfPrimitive {
+ method public default void forEachRemaining(java.util.function.LongConsumer);
+ method public default void forEachRemaining(java.util.function.Consumer<? super java.lang.Long>);
+ method public abstract boolean tryAdvance(java.util.function.LongConsumer);
+ method public default boolean tryAdvance(java.util.function.Consumer<? super java.lang.Long>);
+ method public abstract java.util.Spliterator.OfLong trySplit();
+ }
+
+ public static abstract interface Spliterator.OfPrimitive implements java.util.Spliterator {
+ method public default void forEachRemaining(T_CONS);
+ method public abstract boolean tryAdvance(T_CONS);
+ method public abstract T_SPLITR trySplit();
+ }
+
+ public final class Spliterators {
+ method public static java.util.Spliterator.OfDouble emptyDoubleSpliterator();
+ method public static java.util.Spliterator.OfInt emptyIntSpliterator();
+ method public static java.util.Spliterator.OfLong emptyLongSpliterator();
+ method public static java.util.Spliterator<T> emptySpliterator();
+ method public static java.util.Iterator<T> iterator(java.util.Spliterator<? extends T>);
+ method public static java.util.PrimitiveIterator.OfInt iterator(java.util.Spliterator.OfInt);
+ method public static java.util.PrimitiveIterator.OfLong iterator(java.util.Spliterator.OfLong);
+ method public static java.util.PrimitiveIterator.OfDouble iterator(java.util.Spliterator.OfDouble);
+ method public static java.util.Spliterator<T> spliterator(java.lang.Object[], int);
+ method public static java.util.Spliterator<T> spliterator(java.lang.Object[], int, int, int);
+ method public static java.util.Spliterator.OfInt spliterator(int[], int);
+ method public static java.util.Spliterator.OfInt spliterator(int[], int, int, int);
+ method public static java.util.Spliterator.OfLong spliterator(long[], int);
+ method public static java.util.Spliterator.OfLong spliterator(long[], int, int, int);
+ method public static java.util.Spliterator.OfDouble spliterator(double[], int);
+ method public static java.util.Spliterator.OfDouble spliterator(double[], int, int, int);
+ method public static java.util.Spliterator<T> spliterator(java.util.Collection<? extends T>, int);
+ method public static java.util.Spliterator<T> spliterator(java.util.Iterator<? extends T>, long, int);
+ method public static java.util.Spliterator.OfInt spliterator(java.util.PrimitiveIterator.OfInt, long, int);
+ method public static java.util.Spliterator.OfLong spliterator(java.util.PrimitiveIterator.OfLong, long, int);
+ method public static java.util.Spliterator.OfDouble spliterator(java.util.PrimitiveIterator.OfDouble, long, int);
+ method public static java.util.Spliterator<T> spliteratorUnknownSize(java.util.Iterator<? extends T>, int);
+ method public static java.util.Spliterator.OfInt spliteratorUnknownSize(java.util.PrimitiveIterator.OfInt, int);
+ method public static java.util.Spliterator.OfLong spliteratorUnknownSize(java.util.PrimitiveIterator.OfLong, int);
+ method public static java.util.Spliterator.OfDouble spliteratorUnknownSize(java.util.PrimitiveIterator.OfDouble, int);
+ }
+
+ public static abstract class Spliterators.AbstractDoubleSpliterator implements java.util.Spliterator.OfDouble {
+ ctor protected Spliterators.AbstractDoubleSpliterator(long, int);
+ method public int characteristics();
+ method public long estimateSize();
+ method public java.util.Spliterator.OfDouble trySplit();
+ }
+
+ public static abstract class Spliterators.AbstractIntSpliterator implements java.util.Spliterator.OfInt {
+ ctor protected Spliterators.AbstractIntSpliterator(long, int);
+ method public int characteristics();
+ method public long estimateSize();
+ method public java.util.Spliterator.OfInt trySplit();
+ }
+
+ public static abstract class Spliterators.AbstractLongSpliterator implements java.util.Spliterator.OfLong {
+ ctor protected Spliterators.AbstractLongSpliterator(long, int);
+ method public int characteristics();
+ method public long estimateSize();
+ method public java.util.Spliterator.OfLong trySplit();
+ }
+
+ public static abstract class Spliterators.AbstractSpliterator implements java.util.Spliterator {
+ ctor protected Spliterators.AbstractSpliterator(long, int);
+ method public int characteristics();
+ method public long estimateSize();
+ method public java.util.Spliterator<T> trySplit();
+ }
+
public class Stack extends java.util.Vector {
ctor public Stack();
method public boolean empty();
@@ -58668,6 +58882,15 @@
method public synchronized int search(java.lang.Object);
}
+ public final class StringJoiner {
+ ctor public StringJoiner(java.lang.CharSequence);
+ ctor public StringJoiner(java.lang.CharSequence, java.lang.CharSequence, java.lang.CharSequence);
+ method public java.util.StringJoiner add(java.lang.CharSequence);
+ method public int length();
+ method public java.util.StringJoiner merge(java.util.StringJoiner);
+ method public java.util.StringJoiner setEmptyValue(java.lang.CharSequence);
+ }
+
public class StringTokenizer implements java.util.Enumeration {
ctor public StringTokenizer(java.lang.String, java.lang.String, boolean);
ctor public StringTokenizer(java.lang.String, java.lang.String);
@@ -58789,6 +59012,7 @@
method public E pollFirst();
method public E pollLast();
method public int size();
+ method public java.util.Spliterator<E> spliterator();
method public java.util.NavigableSet<E> subSet(E, boolean, E, boolean);
method public java.util.SortedSet<E> subSet(E, E);
method public java.util.NavigableSet<E> tailSet(E, boolean);
@@ -58845,6 +59069,7 @@
method public synchronized void setElementAt(E, int);
method public synchronized void setSize(int);
method public synchronized int size();
+ method public java.util.Spliterator<E> spliterator();
method public synchronized void trimToSize();
field protected int capacityIncrement;
field protected int elementCount;
diff --git a/cmds/screencap/screencap.cpp b/cmds/screencap/screencap.cpp
index c469ae4..7bf073b 100644
--- a/cmds/screencap/screencap.cpp
+++ b/cmds/screencap/screencap.cpp
@@ -67,30 +67,6 @@
}
}
-static status_t vinfoToPixelFormat(const fb_var_screeninfo& vinfo,
- uint32_t* bytespp, uint32_t* f)
-{
-
- switch (vinfo.bits_per_pixel) {
- case 16:
- *f = PIXEL_FORMAT_RGB_565;
- *bytespp = 2;
- break;
- case 24:
- *f = PIXEL_FORMAT_RGB_888;
- *bytespp = 3;
- break;
- case 32:
- // TODO: do better decoding of vinfo here
- *f = PIXEL_FORMAT_RGBX_8888;
- *bytespp = 4;
- break;
- default:
- return BAD_VALUE;
- }
- return NO_ERROR;
-}
-
static status_t notifyMediaScanner(const char* fileName) {
String8 cmd("am broadcast -a android.intent.action.MEDIA_SCANNER_SCAN_FILE -d file://");
String8 fileUrl("\"");
@@ -147,7 +123,7 @@
png = true;
}
}
-
+
if (fd == -1) {
usage(pname);
return 1;
@@ -195,28 +171,6 @@
s = screenshot.getStride();
f = screenshot.getFormat();
size = screenshot.getSize();
- } else {
- const char* fbpath = "/dev/graphics/fb0";
- int fb = open(fbpath, O_RDONLY);
- if (fb >= 0) {
- struct fb_var_screeninfo vinfo;
- if (ioctl(fb, FBIOGET_VSCREENINFO, &vinfo) == 0) {
- uint32_t bytespp;
- if (vinfoToPixelFormat(vinfo, &bytespp, &f) == NO_ERROR) {
- size_t offset = (vinfo.xoffset + vinfo.yoffset*vinfo.xres) * bytespp;
- w = vinfo.xres;
- h = vinfo.yres;
- s = vinfo.xres;
- size = w*h*bytespp;
- mapsize = offset + size;
- mapbase = mmap(0, mapsize, PROT_READ, MAP_PRIVATE, fb, 0);
- if (mapbase != MAP_FAILED) {
- base = (void const *)((char const *)mapbase + offset);
- }
- }
- }
- close(fb);
- }
}
if (base != NULL) {
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index d8bc119..060ac5e 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -1793,24 +1793,9 @@
* Resources if one has already been created.
*/
Resources getTopLevelResources(String resDir, String[] splitResDirs, String[] overlayDirs,
- String[] libDirs, int displayId, Configuration overrideConfiguration,
- LoadedApk pkgInfo) {
- return mResourcesManager.getTopLevelResources(resDir, splitResDirs, overlayDirs, libDirs,
- displayId, overrideConfiguration, pkgInfo.getCompatibilityInfo(),
- pkgInfo.getClassLoader());
- }
-
- /**
- * Creates a new top level resources for the given package. Will always create a new
- * Resources, regardless if one has already been created.
- */
- Resources getNewTopLevelResources(String resDir, String[] splitResDirs, String[] overlayDirs,
- String[] libDirs, int displayId, Configuration overrideConfiguration,
- LoadedApk pkgInfo) {
- mResourcesManager.removeTopLevelResources(
- resDir, displayId, overrideConfiguration, pkgInfo.getCompatibilityInfo());
- return getTopLevelResources(resDir, splitResDirs, overlayDirs, libDirs,
- displayId, overrideConfiguration, pkgInfo);
+ String[] libDirs, int displayId, LoadedApk pkgInfo) {
+ return mResourcesManager.getResources(null, resDir, splitResDirs, overlayDirs, libDirs,
+ displayId, null, pkgInfo.getCompatibilityInfo(), pkgInfo.getClassLoader());
}
final Handler getHandler() {
@@ -2624,7 +2609,7 @@
}
ContextImpl appContext = ContextImpl.createActivityContext(
- this, r.packageInfo, displayId, r.overrideConfig);
+ this, r.packageInfo, r.token, displayId, r.overrideConfig);
appContext.setOuterContext(activity);
Context baseContext = appContext;
@@ -3481,14 +3466,9 @@
if (!r.activity.mFinished && willBeVisible
&& r.activity.mDecor != null && !r.hideForNow) {
if (r.newConfig != null) {
- r.tmpConfig.setTo(r.newConfig);
- if (r.overrideConfig != null) {
- r.tmpConfig.updateFrom(r.overrideConfig);
- }
+ performConfigurationChangedForActivity(r, r.newConfig, REPORT_TO_ACTIVITY);
if (DEBUG_CONFIGURATION) Slog.v(TAG, "Resuming activity "
- + r.activityInfo.name + " with newConfig " + r.tmpConfig);
- performConfigurationChanged(r.activity, r.tmpConfig, REPORT_TO_ACTIVITY);
- freeTextLayoutCachesIfNeeded(r.activity.mCurrentConfig.diff(r.tmpConfig));
+ + r.activityInfo.name + " with newConfig " + r.activity.mCurrentConfig);
r.newConfig = null;
}
if (localLOGV) Slog.v(TAG, "Resuming " + r + " with isForward="
@@ -3833,14 +3813,10 @@
}
}
if (r.newConfig != null) {
- r.tmpConfig.setTo(r.newConfig);
- if (r.overrideConfig != null) {
- r.tmpConfig.updateFrom(r.overrideConfig);
- }
+ performConfigurationChangedForActivity(r, r.newConfig, REPORT_TO_ACTIVITY);
if (DEBUG_CONFIGURATION) Slog.v(TAG, "Updating activity vis "
- + r.activityInfo.name + " with new config " + r.tmpConfig);
- performConfigurationChanged(r.activity, r.tmpConfig, REPORT_TO_ACTIVITY);
- freeTextLayoutCachesIfNeeded(r.activity.mCurrentConfig.diff(r.tmpConfig));
+ + r.activityInfo.name + " with new config "
+ + r.activity.mCurrentConfig);
r.newConfig = null;
}
} else {
@@ -4545,8 +4521,44 @@
return callbacks;
}
- private static void performConfigurationChanged(ComponentCallbacks2 cb, Configuration config,
- boolean reportToActivity) {
+ /**
+ * Updates the configuration for an Activity. The ActivityClientRecord's
+ * {@link ActivityClientRecord#overrideConfig} is used to compute the final Configuration for
+ * that Activity. {@link ActivityClientRecord#tmpConfig} is used as a temporary for delivering
+ * the updated Configuration.
+ * @param r ActivityClientRecord representing the Activity.
+ * @param newBaseConfig The new configuration to use. This may be augmented with
+ * {@link ActivityClientRecord#overrideConfig}.
+ * @param reportToActivity true if the change should be reported to the Activity's callback.
+ */
+ private void performConfigurationChangedForActivity(ActivityClientRecord r,
+ Configuration newBaseConfig,
+ boolean reportToActivity) {
+ r.tmpConfig.setTo(newBaseConfig);
+ if (r.overrideConfig != null) {
+ r.tmpConfig.updateFrom(r.overrideConfig);
+ }
+ performConfigurationChanged(r.activity, r.token, r.tmpConfig, r.overrideConfig,
+ reportToActivity);
+ freeTextLayoutCachesIfNeeded(r.activity.mCurrentConfig.diff(r.tmpConfig));
+ }
+
+ /**
+ * Decides whether to update an Activity's configuration and whether to tell the
+ * Activity/Component about it.
+ * @param cb The component callback to notify of configuration change.
+ * @param activityToken The Activity binder token for which this configuration change happened.
+ * If the change is global, this is null.
+ * @param newConfig The new configuration.
+ * @param overrideConfig The override config that differentiates the Activity's configuration
+ * from the base global configuration.
+ * @param reportToActivity Notify the Activity of the change.
+ */
+ private void performConfigurationChanged(ComponentCallbacks2 cb,
+ IBinder activityToken,
+ Configuration newConfig,
+ Configuration overrideConfig,
+ boolean reportToActivity) {
// Only for Activity objects, check that they actually call up to their
// superclass implementation. ComponentCallbacks2 is an interface, so
// we check the runtime type and act accordingly.
@@ -4563,7 +4575,7 @@
// If the new config is the same as the config this Activity
// is already running with then don't bother calling
// onConfigurationChanged
- int diff = activity.mCurrentConfig.diff(config);
+ int diff = activity.mCurrentConfig.diff(newConfig);
if (diff != 0) {
// If this activity doesn't handle any of the config changes then don't bother
// calling onConfigurationChanged as we're going to destroy it.
@@ -4578,21 +4590,31 @@
}
}
- if (DEBUG_CONFIGURATION) Slog.v(TAG, "Config callback " + cb
- + ": shouldChangeConfig=" + shouldChangeConfig);
+ if (DEBUG_CONFIGURATION) {
+ Slog.v(TAG, "Config callback " + cb + ": shouldChangeConfig=" + shouldChangeConfig);
+ }
+
if (shouldChangeConfig) {
+ if (activityToken != null) {
+ // We only update an Activity's configuration if this is not a global
+ // configuration change. This must also be done before the callback,
+ // or else we violate the contract that the new resources are available
+ // in {@link ComponentCallbacks2#onConfigurationChanged(Configuration)}.
+ mResourcesManager.updateResourcesForActivity(activityToken, overrideConfig);
+ }
+
if (reportToActivity) {
- cb.onConfigurationChanged(config);
+ cb.onConfigurationChanged(newConfig);
}
if (activity != null) {
if (reportToActivity && !activity.mCalled) {
throw new SuperNotCalledException(
"Activity " + activity.getLocalClassName() +
- " did not call through to super.onConfigurationChanged()");
+ " did not call through to super.onConfigurationChanged()");
}
activity.mConfigChangeFlags = 0;
- activity.mCurrentConfig = new Configuration(config);
+ activity.mCurrentConfig = new Configuration(newConfig);
}
}
}
@@ -4609,7 +4631,8 @@
mCompatConfiguration = new Configuration();
}
mCompatConfiguration.setTo(mConfiguration);
- if (mResourcesManager.applyCompatConfiguration(displayDensity, mCompatConfiguration)) {
+ if (mResourcesManager.applyCompatConfigurationLocked(displayDensity,
+ mCompatConfiguration)) {
config = mCompatConfiguration;
}
return config;
@@ -4661,7 +4684,8 @@
if (callbacks != null) {
final int N = callbacks.size();
for (int i=0; i<N; i++) {
- performConfigurationChanged(callbacks.get(i), config, REPORT_TO_ACTIVITY);
+ performConfigurationChanged(callbacks.get(i), null, config, null,
+ REPORT_TO_ACTIVITY);
}
}
}
@@ -4687,15 +4711,8 @@
if (DEBUG_CONFIGURATION) Slog.v(TAG, "Handle activity config changed: "
+ r.activityInfo.name + ", with callback=" + reportToActivity);
- r.tmpConfig.setTo(mCompatConfiguration);
- if (data.overrideConfig != null) {
- r.overrideConfig = data.overrideConfig;
- r.tmpConfig.updateFrom(data.overrideConfig);
- }
- performConfigurationChanged(r.activity, r.tmpConfig, reportToActivity);
-
- freeTextLayoutCachesIfNeeded(r.activity.mCurrentConfig.diff(mCompatConfiguration));
-
+ r.overrideConfig = data.overrideConfig;
+ performConfigurationChangedForActivity(r, mCompatConfiguration, reportToActivity);
mSomeActivitiesChanged = true;
}
@@ -5032,21 +5049,25 @@
*/
TimeZone.setDefault(null);
- /*
- * Initialize the default locales in this process for the reasons we set the time zone.
- *
- * We do this through ResourcesManager, since we need to do locale negotiation.
- */
- mResourcesManager.setDefaultLocalesLocked(data.config.getLocales());
+ synchronized (mResourcesManager) {
+ /*
+ * Initialize the default locales in this process for the reasons we set the time zone.
+ *
+ * We do this through ResourcesManager, since we need to do locale negotiation.
+ */
+ mResourcesManager.setDefaultLocalesLocked(data.config.getLocales());
- /*
- * Update the system configuration since its preloaded and might not
- * reflect configuration changes. The configuration object passed
- * in AppBindData can be safely assumed to be up to date
- */
- mResourcesManager.applyConfigurationToResourcesLocked(data.config, data.compatInfo);
- mCurDefaultDisplayDpi = data.config.densityDpi;
- applyCompatConfiguration(mCurDefaultDisplayDpi);
+ /*
+ * Update the system configuration since its preloaded and might not
+ * reflect configuration changes. The configuration object passed
+ * in AppBindData can be safely assumed to be up to date
+ */
+ mResourcesManager.applyConfigurationToResourcesLocked(data.config, data.compatInfo);
+ mCurDefaultDisplayDpi = data.config.densityDpi;
+
+ // This calls mResourcesManager so keep it within the synchronized block.
+ applyCompatConfiguration(mCurDefaultDisplayDpi);
+ }
data.info = getPackageInfoNoCheck(data.appInfo, data.compatInfo);
diff --git a/core/java/android/app/AlarmManager.java b/core/java/android/app/AlarmManager.java
index 455f869..b08142a 100644
--- a/core/java/android/app/AlarmManager.java
+++ b/core/java/android/app/AlarmManager.java
@@ -985,11 +985,16 @@
/**
* Gets information about the next alarm clock currently scheduled.
*
- * The alarm clocks considered are those scheduled by {@link #setAlarmClock}
- * from any package of the calling user.
+ * The alarm clocks considered are those scheduled by any application
+ * using the {@link #setAlarmClock} method.
+ *
+ * @return An {@link AlarmClockInfo} object describing the next upcoming alarm
+ * clock event that will occur. If there are no alarm clock events currently
+ * scheduled, this method will return {@code null}.
*
* @see #setAlarmClock
* @see AlarmClockInfo
+ * @see #ACTION_NEXT_ALARM_CLOCK_CHANGED
*/
public AlarmClockInfo getNextAlarmClock() {
return getNextAlarmClock(UserHandle.myUserId());
@@ -998,11 +1003,16 @@
/**
* Gets information about the next alarm clock currently scheduled.
*
- * The alarm clocks considered are those scheduled by {@link #setAlarmClock}
- * from any package of the given {@parm userId}.
+ * The alarm clocks considered are those scheduled by any application
+ * using the {@link #setAlarmClock} method within the given user.
+ *
+ * @return An {@link AlarmClockInfo} object describing the next upcoming alarm
+ * clock event that will occur within the given user. If there are no alarm clock
+ * events currently scheduled in that user, this method will return {@code null}.
*
* @see #setAlarmClock
* @see AlarmClockInfo
+ * @see #ACTION_NEXT_ALARM_CLOCK_CHANGED
*
* @hide
*/
@@ -1015,7 +1025,7 @@
}
/**
- * An immutable description of an alarm clock.
+ * An immutable description of a scheduled "alarm clock" event.
*
* @see AlarmManager#setAlarmClock
* @see AlarmManager#getNextAlarmClock
diff --git a/core/java/android/app/ApplicationPackageManager.java b/core/java/android/app/ApplicationPackageManager.java
index 0b44925..ca05091 100644
--- a/core/java/android/app/ApplicationPackageManager.java
+++ b/core/java/android/app/ApplicationPackageManager.java
@@ -1182,7 +1182,7 @@
sameUid ? app.sourceDir : app.publicSourceDir,
sameUid ? app.splitSourceDirs : app.splitPublicSourceDirs,
app.resourceDirs, app.sharedLibraryFiles, Display.DEFAULT_DISPLAY,
- null, mContext.mPackageInfo);
+ mContext.mPackageInfo);
if (r != null) {
return r;
}
diff --git a/core/java/android/app/ContextImpl.java b/core/java/android/app/ContextImpl.java
index e76f991..32ace14 100644
--- a/core/java/android/app/ContextImpl.java
+++ b/core/java/android/app/ContextImpl.java
@@ -1994,9 +1994,10 @@
}
static ContextImpl createActivityContext(ActivityThread mainThread,
- LoadedApk packageInfo, int displayId, Configuration overrideConfiguration) {
+ LoadedApk packageInfo, IBinder activityToken, int displayId,
+ Configuration overrideConfiguration) {
if (packageInfo == null) throw new IllegalArgumentException("packageInfo");
- return new ContextImpl(null, mainThread, packageInfo, null, null, 0,
+ return new ContextImpl(null, mainThread, packageInfo, activityToken, null, 0,
null, overrideConfiguration, displayId);
}
@@ -2054,10 +2055,16 @@
|| overrideConfiguration != null
|| (compatInfo != null && compatInfo.applicationScale
!= resources.getCompatibilityInfo().applicationScale)) {
- resources = mResourcesManager.getTopLevelResources(packageInfo.getResDir(),
- packageInfo.getSplitResDirs(), packageInfo.getOverlayDirs(),
- packageInfo.getApplicationInfo().sharedLibraryFiles, displayId,
- overrideConfiguration, compatInfo, packageInfo.getClassLoader());
+ resources = mResourcesManager.getResources(
+ activityToken,
+ packageInfo.getResDir(),
+ packageInfo.getSplitResDirs(),
+ packageInfo.getOverlayDirs(),
+ packageInfo.getApplicationInfo().sharedLibraryFiles,
+ displayId,
+ overrideConfiguration,
+ compatInfo,
+ packageInfo.getClassLoader());
}
}
mResources = resources;
diff --git a/core/java/android/app/LoadedApk.java b/core/java/android/app/LoadedApk.java
index cd17078..b8fc323 100644
--- a/core/java/android/app/LoadedApk.java
+++ b/core/java/android/app/LoadedApk.java
@@ -283,9 +283,9 @@
synchronized (this) {
mClassLoader = createOrUpdateClassLoaderLocked(addedPaths);
if (mResources != null) {
- mResources = mActivityThread.getNewTopLevelResources(mResDir, mSplitResDirs,
+ mResources = mActivityThread.getTopLevelResources(mResDir, mSplitResDirs,
mOverlayDirs, mApplicationInfo.sharedLibraryFiles, Display.DEFAULT_DISPLAY,
- null /*overrideConfiguration*/, this);
+ this);
}
}
}
@@ -668,7 +668,7 @@
public Resources getResources(ActivityThread mainThread) {
if (mResources == null) {
mResources = mainThread.getTopLevelResources(mResDir, mSplitResDirs, mOverlayDirs,
- mApplicationInfo.sharedLibraryFiles, Display.DEFAULT_DISPLAY, null, this);
+ mApplicationInfo.sharedLibraryFiles, Display.DEFAULT_DISPLAY, this);
}
return mResources;
}
diff --git a/core/java/android/app/ResourcesManager.java b/core/java/android/app/ResourcesManager.java
index bc44553d..54d813d 100644
--- a/core/java/android/app/ResourcesManager.java
+++ b/core/java/android/app/ResourcesManager.java
@@ -18,6 +18,8 @@
import static android.app.ActivityThread.DEBUG_CONFIGURATION;
+import android.annotation.NonNull;
+import android.annotation.Nullable;
import android.content.pm.ActivityInfo;
import android.content.res.AssetManager;
import android.content.res.CompatibilityInfo;
@@ -26,6 +28,7 @@
import android.content.res.ResourcesImpl;
import android.content.res.ResourcesKey;
import android.hardware.display.DisplayManagerGlobal;
+import android.os.IBinder;
import android.util.ArrayMap;
import android.util.DisplayMetrics;
import android.util.LocaleList;
@@ -34,11 +37,16 @@
import android.util.Slog;
import android.view.Display;
import android.view.DisplayAdjustments;
+import com.android.internal.annotations.VisibleForTesting;
+import com.android.internal.util.ArrayUtils;
import java.lang.ref.WeakReference;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
-import java.util.List;
+import java.util.Objects;
+import java.util.WeakHashMap;
+import java.util.function.Predicate;
/** @hide */
public class ResourcesManager {
@@ -46,18 +54,56 @@
private static final boolean DEBUG = false;
private static ResourcesManager sResourcesManager;
- private final ArrayMap<ResourcesKey, WeakReference<Resources>> mActiveResources =
- new ArrayMap<>();
- private final ArrayMap<Pair<Integer, DisplayAdjustments>, WeakReference<Display>> mDisplays =
- new ArrayMap<>();
+
+ /**
+ * Predicate that returns true if a WeakReference is gc'ed.
+ */
+ private static final Predicate<WeakReference<Resources>> sEmptyReferencePredicate =
+ new Predicate<WeakReference<Resources>>() {
+ @Override
+ public boolean test(WeakReference<Resources> weakRef) {
+ return weakRef == null || weakRef.get() == null;
+ }
+ };
private String[] mSystemLocales = {};
- private final HashSet<String> mNonSystemLocales = new HashSet<String>();
+ private final HashSet<String> mNonSystemLocales = new HashSet<>();
private boolean mHasNonSystemLocales = false;
- CompatibilityInfo mResCompatibilityInfo;
+ /**
+ * The global compatibility settings.
+ */
+ private CompatibilityInfo mResCompatibilityInfo;
- Configuration mResConfiguration;
+ /**
+ * The global configuration upon which all Resources are based. Multi-window Resources
+ * apply their overrides to this configuration.
+ */
+ private final Configuration mResConfiguration = new Configuration();
+
+ /**
+ * A mapping of ResourceImpls and their configurations. These are heavy weight objects
+ * which should be reused as much as possible.
+ */
+ private final ArrayMap<ResourcesKey, WeakReference<ResourcesImpl>> mResourceImpls =
+ new ArrayMap<>();
+
+ /**
+ * A list of Resource references that can be reused.
+ */
+ private final ArrayList<WeakReference<Resources>> mResourceReferences = new ArrayList<>();
+
+ /**
+ * Each Activity may have only one Resources object.
+ */
+ private final WeakHashMap<IBinder, WeakReference<Resources>> mActivityResourceReferences =
+ new WeakHashMap<>();
+
+ /**
+ * A cache of DisplayId to DisplayAdjustments.
+ */
+ private final ArrayMap<Pair<Integer, DisplayAdjustments>, WeakReference<Display>> mDisplays =
+ new ArrayMap<>();
public static ResourcesManager getInstance() {
synchronized (ResourcesManager.class) {
@@ -76,7 +122,11 @@
return getDisplayMetricsLocked(Display.DEFAULT_DISPLAY);
}
- DisplayMetrics getDisplayMetricsLocked(int displayId) {
+ /**
+ * Protected so that tests can override and returns something a fixed value.
+ */
+ @VisibleForTesting
+ protected DisplayMetrics getDisplayMetricsLocked(int displayId) {
DisplayMetrics dm = new DisplayMetrics();
final Display display =
getAdjustedDisplay(displayId, DisplayAdjustments.DEFAULT_DISPLAY_ADJUSTMENTS);
@@ -88,12 +138,12 @@
return dm;
}
- final void applyNonDefaultDisplayMetricsToConfigurationLocked(
- DisplayMetrics dm, Configuration config) {
+ private static void applyNonDefaultDisplayMetricsToConfiguration(
+ @NonNull DisplayMetrics dm, @NonNull Configuration config) {
config.touchscreen = Configuration.TOUCHSCREEN_NOTOUCH;
config.densityDpi = dm.densityDpi;
- config.screenWidthDp = (int)(dm.widthPixels / dm.density);
- config.screenHeightDp = (int)(dm.heightPixels / dm.density);
+ config.screenWidthDp = (int) (dm.widthPixels / dm.density);
+ config.screenHeightDp = (int) (dm.heightPixels / dm.density);
int sl = Configuration.resetScreenLayout(config.screenLayout);
if (dm.widthPixels > dm.heightPixels) {
config.orientation = Configuration.ORIENTATION_LANDSCAPE;
@@ -110,8 +160,8 @@
config.compatSmallestScreenWidthDp = config.smallestScreenWidthDp;
}
- public boolean applyCompatConfiguration(int displayDensity,
- Configuration compatConfiguration) {
+ public boolean applyCompatConfigurationLocked(int displayDensity,
+ @NonNull Configuration compatConfiguration) {
if (mResCompatibilityInfo != null && !mResCompatibilityInfo.supportsScreen()) {
mResCompatibilityInfo.applyToConfiguration(displayDensity, compatConfiguration);
return true;
@@ -126,7 +176,8 @@
* @param displayId display Id.
* @param displayAdjustments display adjustments.
*/
- public Display getAdjustedDisplay(final int displayId, DisplayAdjustments displayAdjustments) {
+ public Display getAdjustedDisplay(final int displayId,
+ @Nullable DisplayAdjustments displayAdjustments) {
final DisplayAdjustments displayAdjustmentsCopy = (displayAdjustments != null)
? new DisplayAdjustments(displayAdjustments) : new DisplayAdjustments();
final Pair<Integer, DisplayAdjustments> key =
@@ -153,76 +204,42 @@
}
/**
- * Creates the top level Resources for applications with the given compatibility info.
+ * Creates an AssetManager from the paths within the ResourcesKey.
*
- * @param resDir the resource directory.
- * @param splitResDirs split resource directories.
- * @param overlayDirs the resource overlay directories.
- * @param libDirs the shared library resource dirs this app references.
- * @param displayId display Id.
- * @param overrideConfiguration override configurations.
- * @param compatInfo the compatibility info. Must not be null.
- * @param classLoader the class loader for the resource package
- */
- Resources getTopLevelResources(String resDir, String[] splitResDirs,
- String[] overlayDirs, String[] libDirs, int displayId,
- Configuration overrideConfiguration, CompatibilityInfo compatInfo,
- ClassLoader classLoader) {
- final float scale = compatInfo.applicationScale;
- Configuration overrideConfigCopy = (overrideConfiguration != null)
- ? new Configuration(overrideConfiguration) : null;
- ResourcesKey key = new ResourcesKey(resDir, displayId, overrideConfigCopy, scale);
- Resources r;
- final boolean findSystemLocales;
- final boolean hasNonSystemLocales;
- synchronized (this) {
- // Resources is app scale dependent.
- if (DEBUG) Slog.w(TAG, "getTopLevelResources: " + resDir + " / " + scale);
-
- WeakReference<Resources> wr = mActiveResources.get(key);
- r = wr != null ? wr.get() : null;
- //if (r != null) Log.i(TAG, "isUpToDate " + resDir + ": " + r.getAssets().isUpToDate());
- if (r != null && r.getAssets().isUpToDate()) {
- if (DEBUG) Slog.w(TAG, "Returning cached resources " + r + " " + resDir
- + ": appScale=" + r.getCompatibilityInfo().applicationScale
- + " key=" + key + " overrideConfig=" + overrideConfiguration);
- return r;
- }
- findSystemLocales = (mSystemLocales.length == 0);
- hasNonSystemLocales = mHasNonSystemLocales;
- }
-
- //if (r != null) {
- // Log.w(TAG, "Throwing away out-of-date resources!!!! "
- // + r + " " + resDir);
- //}
-
+ * This can be overridden in tests so as to avoid creating a real AssetManager with
+ * real APK paths.
+ * @param key The key containing the resource paths to add to the AssetManager.
+ * @return a new AssetManager.
+ */
+ @VisibleForTesting
+ protected AssetManager createAssetManager(@NonNull final ResourcesKey key) {
AssetManager assets = new AssetManager();
+
// resDir can be null if the 'android' package is creating a new Resources object.
// This is fine, since each AssetManager automatically loads the 'android' package
// already.
- if (resDir != null) {
- if (assets.addAssetPath(resDir) == 0) {
+ if (key.mResDir != null) {
+ if (assets.addAssetPath(key.mResDir) == 0) {
return null;
}
}
- if (splitResDirs != null) {
- for (String splitResDir : splitResDirs) {
+ if (key.mSplitResDirs != null) {
+ for (final String splitResDir : key.mSplitResDirs) {
if (assets.addAssetPath(splitResDir) == 0) {
return null;
}
}
}
- if (overlayDirs != null) {
- for (String idmapPath : overlayDirs) {
+ if (key.mOverlayDirs != null) {
+ for (final String idmapPath : key.mOverlayDirs) {
assets.addOverlayPath(idmapPath);
}
}
- if (libDirs != null) {
- for (String libDir : libDirs) {
+ if (key.mLibDirs != null) {
+ for (final String libDir : key.mLibDirs) {
if (libDir.endsWith(".apk")) {
// Avoid opening files we know do not have resources,
// like code-only .jar files.
@@ -233,16 +250,17 @@
}
}
}
+ return assets;
+ }
- //Log.i(TAG, "Resource: key=" + key + ", display metrics=" + metrics);
- DisplayMetrics dm = getDisplayMetricsLocked(displayId);
+ private Configuration generateConfig(@NonNull ResourcesKey key, @NonNull DisplayMetrics dm) {
Configuration config;
- final boolean isDefaultDisplay = (displayId == Display.DEFAULT_DISPLAY);
+ final boolean isDefaultDisplay = (key.mDisplayId == Display.DEFAULT_DISPLAY);
final boolean hasOverrideConfig = key.hasOverrideConfiguration();
if (!isDefaultDisplay || hasOverrideConfig) {
config = new Configuration(getConfiguration());
if (!isDefaultDisplay) {
- applyNonDefaultDisplayMetricsToConfigurationLocked(dm, config);
+ applyNonDefaultDisplayMetricsToConfiguration(dm, config);
}
if (hasOverrideConfig) {
config.updateFrom(key.mOverrideConfiguration);
@@ -251,16 +269,212 @@
} else {
config = getConfiguration();
}
- r = new Resources(classLoader);
- r.setImpl(new ResourcesImpl(assets, dm, config, compatInfo));
- if (DEBUG) Slog.i(TAG, "Created app resources " + resDir + " " + r + ": "
- + r.getConfiguration() + " appScale=" + r.getCompatibilityInfo().applicationScale);
+ return config;
+ }
- final String[] systemLocales = (
- findSystemLocales ?
- AssetManager.getSystem().getLocales() :
- null);
- final String[] nonSystemLocales = assets.getNonSystemLocales();
+
+ private ResourcesImpl createResourcesImpl(@NonNull ResourcesKey key) {
+ AssetManager assets = createAssetManager(key);
+ DisplayMetrics dm = getDisplayMetricsLocked(key.mDisplayId);
+ Configuration config = generateConfig(key, dm);
+ ResourcesImpl impl = new ResourcesImpl(assets, dm, config, key.mCompatInfo);
+ if (DEBUG) {
+ Slog.d(TAG, "- creating impl=" + impl + " with key: " + key);
+ }
+ return impl;
+ }
+
+ /**
+ * Finds a cached ResourcesImpl object that matches the given ResourcesKey.
+ *
+ * @param key The key to match.
+ * @return a ResourcesImpl if the key matches a cache entry, null otherwise.
+ */
+ private ResourcesImpl findResourcesImplForKey(@NonNull ResourcesKey key) {
+ WeakReference<ResourcesImpl> weakImplRef = mResourceImpls.get(key);
+ ResourcesImpl impl = weakImplRef != null ? weakImplRef.get() : null;
+ if (impl != null && impl.getAssets().isUpToDate()) {
+ return impl;
+ }
+ return null;
+ }
+
+ /**
+ * Find the ResourcesKey that this ResourcesImpl object is associated with.
+ * @return the ResourcesKey or null if none was found.
+ */
+ private ResourcesKey findKeyForResourceImpl(@NonNull ResourcesImpl resourceImpl) {
+ final int refCount = mResourceImpls.size();
+ for (int i = 0; i < refCount; i++) {
+ WeakReference<ResourcesImpl> weakImplRef = mResourceImpls.valueAt(i);
+ ResourcesImpl impl = weakImplRef != null ? weakImplRef.get() : null;
+ if (impl != null && resourceImpl == impl) {
+ return mResourceImpls.keyAt(i);
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Gets an existing Resources object tied to this Activity, or creates one if it doesn't exist
+ * or the class loader is different.
+ */
+ private Resources getOrCreateResourcesForActivityLocked(@NonNull IBinder activityToken,
+ @NonNull ClassLoader classLoader, @NonNull ResourcesImpl impl) {
+ // This is a request tied to an Activity, meaning we will need to update all
+ // Activity related Resources to match this configuration.
+ WeakReference<Resources> weakResourceRef = mActivityResourceReferences.get(activityToken);
+ Resources resources = weakResourceRef != null ? weakResourceRef.get() : null;
+ if (resources == null || !Objects.equals(resources.getClassLoader(), classLoader)) {
+ resources = new Resources(classLoader);
+ mActivityResourceReferences.put(activityToken, new WeakReference<>(resources));
+ if (DEBUG) {
+ Slog.d(TAG, "- creating new ref=" + resources);
+ }
+ } else {
+ if (DEBUG) {
+ Slog.d(TAG, "- using existing ref=" + resources);
+ }
+ }
+
+ if (resources.getImpl() != impl) {
+ if (DEBUG) {
+ Slog.d(TAG, "- setting ref=" + resources + " with impl=" + impl);
+ }
+
+ // Setting an impl is expensive because we update all ThemeImpl references.
+ // too.
+ resources.setImpl(impl);
+ }
+ return resources;
+ }
+
+ /**
+ * Gets an existing Resources object if the class loader and ResourcesImpl are the same,
+ * otherwise creates a new Resources object.
+ */
+ private Resources getOrCreateResourcesLocked(@NonNull ClassLoader classLoader,
+ @NonNull ResourcesImpl impl) {
+ // Find an existing Resources that has this ResourcesImpl set.
+ final int refCount = mResourceReferences.size();
+ for (int i = 0; i < refCount; i++) {
+ WeakReference<Resources> weakResourceRef = mResourceReferences.get(i);
+ Resources resources = weakResourceRef != null ? weakResourceRef.get() : null;
+ if (resources != null &&
+ Objects.equals(resources.getClassLoader(), classLoader) &&
+ resources.getImpl() == impl) {
+ if (DEBUG) {
+ Slog.d(TAG, "- using existing ref=" + resources);
+ }
+ return resources;
+ }
+ }
+
+ // Create a new Resources reference and use the existing ResourcesImpl object.
+ Resources resources = new Resources(classLoader);
+ resources.setImpl(impl);
+ mResourceReferences.add(new WeakReference<>(resources));
+ if (DEBUG) {
+ Slog.d(TAG, "- creating new ref=" + resources);
+ Slog.d(TAG, "- setting ref=" + resources + " with impl=" + impl);
+ }
+ return resources;
+ }
+
+ /**
+ * Gets or creates a new Resources object associated with the IBinder token. References returned
+ * by this method live as long as the Activity, meaning they can be cached and used by the
+ * Activity even after a configuration change. If any other parameter is changed
+ * (resDir, splitResDirs, overrideConfig) for a given Activity, the same Resources object
+ * is updated and handed back to the caller. However, changing the class loader will result in a
+ * new Resources object.
+ * <p/>
+ * If activityToken is null, a cached Resources object will be returned if it matches the
+ * input parameters. Otherwise a new Resources object that satisfies these parameters is
+ * returned.
+ *
+ * @param activityToken Represents an Activity. If null, global resources are assumed.
+ * @param resDir The base resource path. Can be null (only framework resources will be loaded).
+ * @param splitResDirs An array of split resource paths. Can be null.
+ * @param overlayDirs An array of overlay paths. Can be null.
+ * @param libDirs An array of resource library paths. Can be null.
+ * @param displayId The ID of the display for which to create the resources.
+ * @param overrideConfig The configuration to apply on top of the base configuration. Can be
+ * null. Mostly used with Activities that are in multi-window which may override width and
+ * height properties from the base config.
+ * @param compatInfo The compatibility settings to use. Cannot be null. A default to use is
+ * {@link CompatibilityInfo#DEFAULT_COMPATIBILITY_INFO}.
+ * @param classLoader The class loader to use when inflating Resources. If null, the
+ * {@link ClassLoader#getSystemClassLoader()} is used.
+ * @return a Resources object from which to access resources.
+ */
+ public Resources getResources(@Nullable IBinder activityToken,
+ @Nullable String resDir,
+ @Nullable String[] splitResDirs,
+ @Nullable String[] overlayDirs,
+ @Nullable String[] libDirs,
+ int displayId,
+ @Nullable Configuration overrideConfig,
+ @NonNull CompatibilityInfo compatInfo,
+ @Nullable ClassLoader classLoader) {
+ final ResourcesKey key = new ResourcesKey(
+ resDir,
+ splitResDirs,
+ overlayDirs,
+ libDirs,
+ displayId,
+ overrideConfig != null ? new Configuration(overrideConfig) : null, // Copy
+ compatInfo);
+
+ classLoader = classLoader != null ? classLoader : ClassLoader.getSystemClassLoader();
+
+ final boolean findSystemLocales;
+ final boolean hasNonSystemLocales;
+ synchronized (this) {
+ findSystemLocales = (mSystemLocales.length == 0);
+ hasNonSystemLocales = mHasNonSystemLocales;
+
+ if (DEBUG) {
+ Throwable here = new Throwable();
+ here.fillInStackTrace();
+ Slog.w(TAG, "!! Get resources for activity=" + activityToken + " key=" + key, here);
+ }
+
+ if (activityToken != null) {
+ ResourcesImpl resourcesImpl = findResourcesImplForKey(key);
+ if (resourcesImpl != null) {
+ if (DEBUG) {
+ Slog.d(TAG, "- using existing impl=" + resourcesImpl);
+ }
+ return getOrCreateResourcesForActivityLocked(activityToken, classLoader,
+ resourcesImpl);
+ }
+
+ // We will create the ResourcesImpl object outside of holding this lock.
+
+ } else {
+ // Clean up any dead references so they don't pile up.
+ ArrayUtils.unstableRemoveIf(mResourceReferences, sEmptyReferencePredicate);
+
+ // Not tied to an Activity, find a shared Resources that has the right ResourcesImpl
+ ResourcesImpl resourcesImpl = findResourcesImplForKey(key);
+ if (resourcesImpl != null) {
+ if (DEBUG) {
+ Slog.d(TAG, "- using existing impl=" + resourcesImpl);
+ }
+ return getOrCreateResourcesLocked(classLoader, resourcesImpl);
+ }
+
+ // We will create the ResourcesImpl object outside of holding this lock.
+ }
+ }
+
+ // If we're here, we didn't find a suitable ResourcesImpl to use, so create one now.
+ ResourcesImpl resourcesImpl = createResourcesImpl(key);
+
+ final String[] systemLocales = findSystemLocales
+ ? AssetManager.getSystem().getLocales() : null;
+ final String[] nonSystemLocales = resourcesImpl.getAssets().getNonSystemLocales();
// Avoid checking for non-pseudo-locales if we already know there were some from a previous
// Resources. The default value (for when hasNonSystemLocales is true) doesn't matter,
// since mHasNonSystemLocales will also be true, and thus isPseudoLocalesOnly would not be
@@ -269,41 +483,75 @@
LocaleList.isPseudoLocalesOnly(nonSystemLocales);
synchronized (this) {
- WeakReference<Resources> wr = mActiveResources.get(key);
- Resources existing = wr != null ? wr.get() : null;
- if (existing != null && existing.getAssets().isUpToDate()) {
- // Someone else already created the resources while we were
- // unlocked; go ahead and use theirs.
- r.getAssets().close();
- return existing;
- }
-
- // XXX need to remove entries when weak references go away
- mActiveResources.put(key, new WeakReference<>(r));
if (mSystemLocales.length == 0) {
mSystemLocales = systemLocales;
}
mNonSystemLocales.addAll(Arrays.asList(nonSystemLocales));
mHasNonSystemLocales = mHasNonSystemLocales || !isPseudoLocalesOnly;
- if (DEBUG) Slog.v(TAG, "mActiveResources.size()=" + mActiveResources.size());
- return r;
+
+ ResourcesImpl existingResourcesImpl = findResourcesImplForKey(key);
+ if (existingResourcesImpl != null) {
+ if (DEBUG) {
+ Slog.d(TAG, "- got beat! existing impl=" + existingResourcesImpl
+ + " new impl=" + resourcesImpl);
+ }
+ resourcesImpl.getAssets().close();
+ resourcesImpl = existingResourcesImpl;
+ } else {
+ // Add this ResourcesImpl to the cache.
+ mResourceImpls.put(key, new WeakReference<>(resourcesImpl));
+ }
+
+ final Resources resources;
+ if (activityToken != null) {
+ resources = getOrCreateResourcesForActivityLocked(activityToken, classLoader,
+ resourcesImpl);
+ } else {
+ resources = getOrCreateResourcesLocked(classLoader, resourcesImpl);
+ }
+ return resources;
}
}
/**
- * Removes the top level Resources for applications with the given compatibility info.
- * @see #getTopLevelResources(String, String[], String[], String[], int, Configuration, CompatibilityInfo, ClassLoader)
+ * Updates an Activity's Resources object with overrideConfig. The Resources object
+ * that was previously returned by
+ * {@link #getResources(IBinder, String, String[], String[], String[], int, Configuration,
+ * CompatibilityInfo, ClassLoader)} is
+ * still valid and will have the updated configuration.
+ * @param activityToken The Activity token.
+ * @param overrideConfig The configuration override to update.
*/
- void removeTopLevelResources(String resDir, int displayId, Configuration overrideConfiguration,
- CompatibilityInfo compatInfo) {
- final float scale = compatInfo.applicationScale;
- final Configuration overrideConfigCopy = (overrideConfiguration != null)
- ? new Configuration(overrideConfiguration) : null;
- final ResourcesKey key = new ResourcesKey(resDir, displayId, overrideConfigCopy, scale);
- mActiveResources.remove(key);
+ public void updateResourcesForActivity(@NonNull IBinder activityToken,
+ @Nullable Configuration overrideConfig) {
+ final ClassLoader classLoader;
+ final ResourcesKey oldKey;
+ synchronized (this) {
+ // Extract the ResourcesKey that was last used to create the Resources for this
+ // activity.
+ WeakReference<Resources> weakResRef = mActivityResourceReferences.get(activityToken);
+ final Resources resources = weakResRef != null ? weakResRef.get() : null;
+ if (resources == null) {
+ Slog.e(TAG, "can't update resources for uncached activity " + activityToken);
+ return;
+ }
+
+ classLoader = resources.getClassLoader();
+ oldKey = findKeyForResourceImpl(resources.getImpl());
+ if (oldKey == null) {
+ Slog.e(TAG, "can't find ResourcesKey for resources impl=" + resources.getImpl());
+ return;
+ }
+ }
+
+ // Update the Resources object with the new override config and all of the existing
+ // settings.
+ getResources(activityToken, oldKey.mResDir, oldKey.mSplitResDirs, oldKey.mOverlayDirs,
+ oldKey.mLibDirs, oldKey.mDisplayId, overrideConfig, oldKey.mCompatInfo,
+ classLoader);
}
- /* package */ void setDefaultLocalesLocked(LocaleList locales) {
+ /* package */ void setDefaultLocalesLocked(@NonNull LocaleList locales) {
final int bestLocale;
if (mHasNonSystemLocales) {
bestLocale = locales.getFirstMatchIndexWithEnglishSupported(mNonSystemLocales);
@@ -317,11 +565,8 @@
LocaleList.setDefault(locales, bestLocale);
}
- final boolean applyConfigurationToResourcesLocked(Configuration config,
- CompatibilityInfo compat) {
- if (mResConfiguration == null) {
- mResConfiguration = new Configuration();
- }
+ public final boolean applyConfigurationToResourcesLocked(@NonNull Configuration config,
+ @Nullable CompatibilityInfo compat) {
if (!mResConfiguration.isOtherSeqNewer(config) && compat == null) {
if (DEBUG || DEBUG_CONFIGURATION) Slog.v(TAG, "Skipping new config: curSeq="
+ mResConfiguration.seq + ", newSeq=" + config.seq);
@@ -368,9 +613,9 @@
Configuration tmpConfig = null;
- for (int i = mActiveResources.size() - 1; i >= 0; i--) {
- ResourcesKey key = mActiveResources.keyAt(i);
- Resources r = mActiveResources.valueAt(i).get();
+ for (int i = mResourceImpls.size() - 1; i >= 0; i--) {
+ ResourcesKey key = mResourceImpls.keyAt(i);
+ ResourcesImpl r = mResourceImpls.valueAt(i).get();
if (r != null) {
if (DEBUG || DEBUG_CONFIGURATION) Slog.v(TAG, "Changing resources "
+ r + " config to: " + localeAdjustedConfig);
@@ -385,7 +630,7 @@
tmpConfig.setTo(localeAdjustedConfig);
if (!isDefaultDisplay) {
dm = getDisplayMetricsLocked(displayId);
- applyNonDefaultDisplayMetricsToConfigurationLocked(dm, tmpConfig);
+ applyNonDefaultDisplayMetricsToConfiguration(dm, tmpConfig);
}
if (hasOverrideConfiguration) {
tmpConfig.updateFrom(key.mOverrideConfiguration);
@@ -398,11 +643,10 @@
// + " " + r + ": " + r.getConfiguration());
} else {
//Slog.i(TAG, "Removing old resources " + v.getKey());
- mActiveResources.removeAt(i);
+ mResourceImpls.removeAt(i);
}
}
return changes != 0;
}
-
-}
+}
\ No newline at end of file
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java
index af9705f..53a6351 100644
--- a/core/java/android/app/admin/DevicePolicyManager.java
+++ b/core/java/android/app/admin/DevicePolicyManager.java
@@ -3723,7 +3723,9 @@
* be hidden, it will not show up in recents, will not be able to show toasts or dialogs
* or ring the device.
*
- * <p>The package must already be installed.
+ * <p>The package must already be installed. If the package is uninstalled while suspended
+ * the package will no longer be suspended. The admin can block this by using
+ * {@link #setUninstallBlocked}.
*
* @param admin The name of the admin component to check.
* @param packageNames The package names to suspend or unsuspend.
diff --git a/core/java/android/content/pm/PackageInstaller.java b/core/java/android/content/pm/PackageInstaller.java
index ec536e0..1f603ef 100644
--- a/core/java/android/content/pm/PackageInstaller.java
+++ b/core/java/android/content/pm/PackageInstaller.java
@@ -1000,8 +1000,8 @@
}
/**
- * Optionally set the URI where this package was downloaded from. Used for
- * verification purposes.
+ * Optionally set the URI where this package was downloaded from. This is
+ * informational and may be used as a signal for anti-malware purposes.
*
* @see Intent#EXTRA_ORIGINATING_URI
*/
@@ -1010,7 +1010,8 @@
}
/**
- * Sets the UID that initiated package installation. Used for verification purposes.
+ * Sets the UID that initiated package installation. This is informational
+ * and may be used as a signal for anti-malware purposes.
*
* @see PackageManager#EXTRA_VERIFICATION_INSTALLER_UID
*/
@@ -1019,8 +1020,8 @@
}
/**
- * Optionally set the URI that referred you to install this package. Used
- * for verification purposes.
+ * Optionally set the URI that referred you to install this package. This is
+ * informational and may be used as a signal for anti-malware purposes.
*
* @see Intent#EXTRA_REFERRER
*/
diff --git a/core/java/android/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java
index 0dc856c..e1e8a07 100644
--- a/core/java/android/content/pm/PackageManager.java
+++ b/core/java/android/content/pm/PackageManager.java
@@ -1596,9 +1596,9 @@
/**
* Feature for {@link #getSystemAvailableFeatures} and
- * {@link #hasSystemFeature}: If this feature is supported, the Vulkan native API will enumerate
- * at least one {@code VkPhysicalDevice}, and the feature version will indicate what
- * level of optional hardware features limits it supports.
+ * {@link #hasSystemFeature(String, int)}: If this feature is supported, the Vulkan native API
+ * will enumerate at least one {@code VkPhysicalDevice}, and the feature version will indicate
+ * what level of optional hardware features limits it supports.
* <p>
* Level 0 includes the base Vulkan requirements as well as:
* <ul><li>{@code VkPhysicalDeviceFeatures::textureCompressionETC2}</li></ul>
@@ -1623,7 +1623,7 @@
/**
* Feature for {@link #getSystemAvailableFeatures} and
- * {@link #hasSystemFeature}: The version of this feature indicates the highest
+ * {@link #hasSystemFeature(String, int)}: The version of this feature indicates the highest
* {@code VkPhysicalDeviceProperties::apiVersion} supported by the physical devices that support
* the hardware level indicated by {@link #FEATURE_VULKAN_HARDWARE_LEVEL}. The feature version
* uses the same encoding as Vulkan version numbers:
@@ -5367,6 +5367,9 @@
* will be hidden, the application will not show up in recents, will not be able to show
* toasts or dialogs or ring the device.
*
+ * <p>The package must already be installed. If the package is uninstalled while suspended
+ * the package will no longer be suspended.
+ *
* @param packageNames The names of the packages to set the suspended status.
* @param suspended If set to {@code true} than the packages will be suspended, if set to
* {@code false} the packages will be unsuspended.
diff --git a/core/java/android/content/res/Resources.java b/core/java/android/content/res/Resources.java
index f337fe6..fb706fc 100644
--- a/core/java/android/content/res/Resources.java
+++ b/core/java/android/content/res/Resources.java
@@ -54,6 +54,7 @@
import android.view.ViewDebug;
import android.view.ViewHierarchyEncoder;
+import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.GrowingArrayUtils;
import com.android.internal.util.XmlUtils;
@@ -62,6 +63,8 @@
import java.io.IOException;
import java.io.InputStream;
+import java.lang.ref.WeakReference;
+import java.util.ArrayList;
/**
* Class for accessing an application's resources. This sits on top of the
@@ -113,6 +116,13 @@
final ClassLoader mClassLoader;
/**
+ * WeakReferences to Themes that were constructed from this Resources object.
+ * We keep track of these in case our underlying implementation is changed, in which case
+ * the Themes must also get updated ThemeImpls.
+ */
+ private final ArrayList<WeakReference<Theme>> mThemeRefs = new ArrayList<>();
+
+ /**
* Returns the most appropriate default theme for the specified target SDK version.
* <ul>
* <li>Below API 11: Gingerbread
@@ -231,10 +241,42 @@
}
/**
+ * Set the underlying implementation (containing all the resources and caches)
+ * and updates all Theme references to new implementations as well.
* @hide
*/
public void setImpl(ResourcesImpl impl) {
+ if (impl == mResourcesImpl) {
+ return;
+ }
+
mResourcesImpl = impl;
+
+ // Create new ThemeImpls that are identical to the ones we have.
+ synchronized (mThemeRefs) {
+ final int count = mThemeRefs.size();
+ for (int i = 0; i < count; i++) {
+ WeakReference<Theme> weakThemeRef = mThemeRefs.get(i);
+ Theme theme = weakThemeRef != null ? weakThemeRef.get() : null;
+ if (theme != null) {
+ theme.setImpl(mResourcesImpl.newThemeImpl(theme.getKey()));
+ }
+ }
+ }
+ }
+
+ /**
+ * @hide
+ */
+ public ResourcesImpl getImpl() {
+ return mResourcesImpl;
+ }
+
+ /**
+ * @hide
+ */
+ public ClassLoader getClassLoader() {
+ return mClassLoader;
}
/**
@@ -1683,6 +1725,7 @@
public final Theme newTheme() {
Theme theme = new Theme();
theme.setImpl(mResourcesImpl.newThemeImpl());
+ mThemeRefs.add(new WeakReference<>(theme));
return theme;
}
@@ -1785,6 +1828,7 @@
* This is just for testing.
* @hide
*/
+ @VisibleForTesting
public void setCompatibilityInfo(CompatibilityInfo ci) {
if (ci != null) {
mResourcesImpl.updateConfiguration(null, null, ci);
@@ -2069,6 +2113,15 @@
}
/**
+ * Called by ConfigurationBoundResourceCacheTest.
+ * @hide
+ */
+ @VisibleForTesting
+ public int calcConfigChanges(Configuration config) {
+ return mResourcesImpl.calcConfigChanges(config);
+ }
+
+ /**
* Obtains styled attributes from the theme, if available, or unstyled
* resources if the theme is null.
*
diff --git a/core/java/android/content/res/ResourcesImpl.java b/core/java/android/content/res/ResourcesImpl.java
index 2ffd372..0858cb8 100644
--- a/core/java/android/content/res/ResourcesImpl.java
+++ b/core/java/android/content/res/ResourcesImpl.java
@@ -48,6 +48,13 @@
import java.util.Locale;
/**
+ * The implementation of Resource access. This class contains the AssetManager and all caches
+ * associated with it.
+ *
+ * {@link Resources} is just a thing wrapper around this class. When a configuration change
+ * occurs, clients can retain the same {@link Resources} reference because the underlying
+ * {@link ResourcesImpl} object will be updated or re-created.
+ *
* @hide
*/
public class ResourcesImpl {
@@ -126,14 +133,14 @@
* @param compatInfo this resource's compatibility info. Must not be null.
*/
public ResourcesImpl(AssetManager assets, DisplayMetrics metrics, Configuration config,
- CompatibilityInfo compatInfo) {
+ CompatibilityInfo compatInfo) {
mAssets = assets;
mMetrics.setToDefaults();
updateConfiguration(config, metrics, compatInfo);
mAssets.ensureStringBlocks();
}
- AssetManager getAssets() {
+ public AssetManager getAssets() {
return mAssets;
}
@@ -174,7 +181,7 @@
}
void getValueForDensity(@AnyRes int id, int density, TypedValue outValue,
- boolean resolveRefs) throws NotFoundException {
+ boolean resolveRefs) throws NotFoundException {
boolean found = mAssets.getResourceValue(id, density, outValue, resolveRefs);
if (found) {
return;
@@ -298,8 +305,8 @@
return mStateListAnimatorCache;
}
- void updateConfiguration(Configuration config, DisplayMetrics metrics,
- CompatibilityInfo compat) {
+ public void updateConfiguration(Configuration config, DisplayMetrics metrics,
+ CompatibilityInfo compat) {
synchronized (mAccessLock) {
if (false) {
Slog.i(TAG, "**** Updating config of " + this + ": old config is "
@@ -388,9 +395,9 @@
}
/**
- * Called by ConfigurationBoundResourceCacheTest via reflection.
+ * Called by ConfigurationBoundResourceCacheTest.
*/
- private int calcConfigChanges(Configuration config) {
+ public int calcConfigChanges(Configuration config) {
int configChanges = 0xfffffff;
if (config != null) {
mTmpConfig.setTo(config);
@@ -460,7 +467,7 @@
@Nullable
Drawable loadDrawable(Resources wrapper, TypedValue value, int id, Resources.Theme theme,
- boolean useCache) throws NotFoundException {
+ boolean useCache) throws NotFoundException {
try {
if (TRACE_FOR_PRELOAD) {
// Log only framework resources
@@ -553,7 +560,7 @@
}
private void cacheDrawable(TypedValue value, boolean isColorDrawable, DrawableCache caches,
- Resources.Theme theme, boolean usesTheme, long key, Drawable dr) {
+ Resources.Theme theme, boolean usesTheme, long key, Drawable dr) {
final Drawable.ConstantState cs = dr.getConstantState();
if (cs == null) {
return;
@@ -587,7 +594,7 @@
}
private boolean verifyPreloadConfig(int changingConfigurations, int allowVarying,
- int resourceId, String name) {
+ int resourceId, String name) {
// We allow preloading of resources even if they vary by font scale (which
// doesn't impact resource selection) or density (which we handle specially by
// simply turning off all preloading), as well as any other configs specified
@@ -625,7 +632,7 @@
* Loads a drawable from XML or resources stream.
*/
private Drawable loadDrawableForCookie(Resources wrapper, TypedValue value, int id,
- Resources.Theme theme) {
+ Resources.Theme theme) {
if (value.string == null) {
throw new NotFoundException("Resource \"" + getResourceName(id) + "\" ("
+ Integer.toHexString(id) + ") is not a Drawable (color or path): " + value);
@@ -681,7 +688,7 @@
* Last, parse the XML and generate the CSL.
*/
private ComplexColor loadComplexColorFromName(Resources wrapper, Resources.Theme theme,
- TypedValue value, int id) {
+ TypedValue value, int id) {
final long key = (((long) value.assetCookie) << 32) | value.data;
final ConfigurationBoundResourceCache<ComplexColor> cache = mComplexColorCache;
ComplexColor complexColor = cache.getInstance(key, wrapper, theme);
@@ -714,7 +721,7 @@
@Nullable
ComplexColor loadComplexColor(Resources wrapper, @NonNull TypedValue value, int id,
- Resources.Theme theme) {
+ Resources.Theme theme) {
if (TRACE_FOR_PRELOAD) {
// Log only framework resources
if ((id >>> 24) == 0x1) {
@@ -755,7 +762,7 @@
@Nullable
ColorStateList loadColorStateList(Resources wrapper, TypedValue value, int id,
- Resources.Theme theme)
+ Resources.Theme theme)
throws NotFoundException {
if (TRACE_FOR_PRELOAD) {
// Log only framework resources
@@ -815,7 +822,7 @@
*/
@Nullable
private ComplexColor loadComplexColorForCookie(Resources wrapper, TypedValue value, int id,
- Resources.Theme theme) {
+ Resources.Theme theme) {
if (value.string == null) {
throw new UnsupportedOperationException(
"Can't convert to ComplexColor: type=0x" + value.type);
@@ -893,8 +900,8 @@
* @throws NotFoundException if the file could not be loaded
*/
@NonNull
- XmlResourceParser loadXmlResourceParser(@NonNull String file, @AnyRes int id,
- int assetCookie, @NonNull String type)
+ XmlResourceParser loadXmlResourceParser(@NonNull String file, @AnyRes int id, int assetCookie,
+ @NonNull String type)
throws NotFoundException {
if (id != 0) {
try {
@@ -975,6 +982,16 @@
return new ThemeImpl();
}
+ /**
+ * Creates a new ThemeImpl which is already set to the given Resources.ThemeKey.
+ */
+ ThemeImpl newThemeImpl(Resources.ThemeKey key) {
+ ThemeImpl impl = new ThemeImpl();
+ impl.mKey.setTo(key);
+ impl.rebase();
+ return impl;
+ }
+
public class ThemeImpl {
/**
* Unique key for the series of styles applied to this theme.
@@ -1035,10 +1052,10 @@
@NonNull
TypedArray obtainStyledAttributes(@NonNull Resources.Theme wrapper,
- AttributeSet set,
- @StyleableRes int[] attrs,
- @AttrRes int defStyleAttr,
- @StyleRes int defStyleRes) {
+ AttributeSet set,
+ @StyleableRes int[] attrs,
+ @AttrRes int defStyleAttr,
+ @StyleRes int defStyleRes) {
synchronized (mKey) {
final int len = attrs.length;
final TypedArray array = TypedArray.obtain(wrapper.getResources(), len);
@@ -1060,8 +1077,8 @@
@NonNull
TypedArray resolveAttributes(@NonNull Resources.Theme wrapper,
- @NonNull int[] values,
- @NonNull int[] attrs) {
+ @NonNull int[] values,
+ @NonNull int[] attrs) {
synchronized (mKey) {
final int len = attrs.length;
if (values == null || len != values.length) {
diff --git a/core/java/android/content/res/ResourcesKey.java b/core/java/android/content/res/ResourcesKey.java
index 2620571..e894492 100644
--- a/core/java/android/content/res/ResourcesKey.java
+++ b/core/java/android/content/res/ResourcesKey.java
@@ -17,32 +17,59 @@
package android.content.res;
import android.annotation.NonNull;
+import android.annotation.Nullable;
+import android.text.TextUtils;
+import java.util.Arrays;
import java.util.Objects;
/** @hide */
public final class ResourcesKey {
- private final String mResDir;
- private final float mScale;
- private final int mHash;
+ @Nullable
+ public final String mResDir;
+
+ @Nullable
+ public final String[] mSplitResDirs;
+
+ @Nullable
+ public final String[] mOverlayDirs;
+
+ @Nullable
+ public final String[] mLibDirs;
public final int mDisplayId;
+
@NonNull
public final Configuration mOverrideConfiguration;
- public ResourcesKey(String resDir, int displayId, Configuration overrideConfiguration,
- float scale) {
+ @NonNull
+ public final CompatibilityInfo mCompatInfo;
+
+ private final int mHash;
+
+ public ResourcesKey(@Nullable String resDir,
+ @Nullable String[] splitResDirs,
+ @Nullable String[] overlayDirs,
+ @Nullable String[] libDirs,
+ int displayId,
+ @Nullable Configuration overrideConfig,
+ @Nullable CompatibilityInfo compatInfo) {
mResDir = resDir;
+ mSplitResDirs = splitResDirs;
+ mOverlayDirs = overlayDirs;
+ mLibDirs = libDirs;
mDisplayId = displayId;
- mOverrideConfiguration = overrideConfiguration != null
- ? overrideConfiguration : Configuration.EMPTY;
- mScale = scale;
+ mOverrideConfiguration = overrideConfig != null ? overrideConfig : Configuration.EMPTY;
+ mCompatInfo = compatInfo != null ? compatInfo : CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO;
int hash = 17;
- hash = 31 * hash + (mResDir == null ? 0 : mResDir.hashCode());
+ hash = 31 * hash + Objects.hashCode(mResDir);
+ hash = 31 * hash + Arrays.hashCode(mSplitResDirs);
+ hash = 31 * hash + Arrays.hashCode(mOverlayDirs);
+ hash = 31 * hash + Arrays.hashCode(mLibDirs);
hash = 31 * hash + mDisplayId;
- hash = 31 * hash + mOverrideConfiguration.hashCode();
- hash = 31 * hash + Float.floatToIntBits(mScale);
+ hash = 31 * hash + Objects.hashCode(mOverrideConfiguration);
+ hash = 31 * hash + Objects.hashCode(mCompatInfo);
mHash = hash;
}
@@ -60,18 +87,32 @@
if (!(obj instanceof ResourcesKey)) {
return false;
}
+
ResourcesKey peer = (ResourcesKey) obj;
+ if (mHash != peer.mHash) {
+ // If the hashes don't match, the objects can't match.
+ return false;
+ }
if (!Objects.equals(mResDir, peer.mResDir)) {
return false;
}
+ if (!Arrays.equals(mSplitResDirs, peer.mSplitResDirs)) {
+ return false;
+ }
+ if (!Arrays.equals(mOverlayDirs, peer.mOverlayDirs)) {
+ return false;
+ }
+ if (!Arrays.equals(mLibDirs, peer.mLibDirs)) {
+ return false;
+ }
if (mDisplayId != peer.mDisplayId) {
return false;
}
- if (!mOverrideConfiguration.equals(peer.mOverrideConfiguration)) {
+ if (!Objects.equals(mOverrideConfiguration, peer.mOverrideConfiguration)) {
return false;
}
- if (mScale != peer.mScale) {
+ if (!Objects.equals(mCompatInfo, peer.mCompatInfo)) {
return false;
}
return true;
@@ -79,6 +120,29 @@
@Override
public String toString() {
- return Integer.toHexString(mHash);
+ StringBuilder builder = new StringBuilder().append("ResourcesKey{");
+ builder.append(" mHash=").append(Integer.toHexString(mHash));
+ builder.append(" mResDir=").append(mResDir);
+ builder.append(" mSplitDirs=[");
+ if (mSplitResDirs != null) {
+ builder.append(TextUtils.join(",", mSplitResDirs));
+ }
+ builder.append("]");
+ builder.append(" mOverlayDirs=[");
+ if (mOverlayDirs != null) {
+ builder.append(TextUtils.join(",", mOverlayDirs));
+ }
+ builder.append("]");
+ builder.append(" mLibDirs=[");
+ if (mLibDirs != null) {
+ builder.append(TextUtils.join(",", mLibDirs));
+ }
+ builder.append("]");
+ builder.append(" mDisplayId=").append(mDisplayId);
+ builder.append(" mOverrideConfig=").append(Configuration.resourceQualifierString(
+ mOverrideConfiguration));
+ builder.append(" mCompatInfo=").append(mCompatInfo);
+ builder.append("}");
+ return builder.toString();
}
}
diff --git a/core/java/android/provider/DocumentsContract.java b/core/java/android/provider/DocumentsContract.java
index d27131c..e7a9b7d 100644
--- a/core/java/android/provider/DocumentsContract.java
+++ b/core/java/android/provider/DocumentsContract.java
@@ -119,8 +119,6 @@
public static final String EXTRA_PROMPT = "android.provider.extra.PROMPT";
/** {@hide} */
- public static final String ACTION_MANAGE_ROOT = "android.provider.action.MANAGE_ROOT";
- /** {@hide} */
public static final String ACTION_MANAGE_DOCUMENT = "android.provider.action.MANAGE_DOCUMENT";
/** {@hide} */
diff --git a/core/java/android/service/notification/NotificationRankerService.java b/core/java/android/service/notification/NotificationRankerService.java
index e325354..47fdac6 100644
--- a/core/java/android/service/notification/NotificationRankerService.java
+++ b/core/java/android/service/notification/NotificationRankerService.java
@@ -119,7 +119,13 @@
@Override
public void registerAsSystemService(Context context, ComponentName componentName,
int currentUser) {
- throw new IllegalStateException("the ranker may not start itself.");
+ throw new UnsupportedOperationException("the ranker lifecycle is managed by the system.");
+ }
+
+ /** @hide */
+ @Override
+ public void unregisterAsSystemService() {
+ throw new UnsupportedOperationException("the ranker lifecycle is managed by the system.");
}
@Override
diff --git a/core/java/android/transition/ArcMotion.java b/core/java/android/transition/ArcMotion.java
index fa4c8d2..70443ba 100644
--- a/core/java/android/transition/ArcMotion.java
+++ b/core/java/android/transition/ArcMotion.java
@@ -15,13 +15,13 @@
*/
package android.transition;
-import com.android.internal.R;
-
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Path;
import android.util.AttributeSet;
+import com.android.internal.R;
+
/**
* A PathMotion that generates a curved path along an arc on an imaginary circle containing
* the two points. If the horizontal distance between the points is less than the vertical
@@ -207,7 +207,7 @@
ey = (startY + endY) / 2;
} else {
float deltaX = endX - startX;
- float deltaY = startY - endY; // Y is inverted compared to diagram above.
+ float deltaY = endY - startY;
// hypotenuse squared.
float h2 = deltaX * deltaX + deltaY * deltaY;
@@ -219,24 +219,35 @@
float midDist2 = h2 * 0.25f;
float minimumArcDist2 = 0;
+ boolean isQuadrant1Or3 = (deltaX * deltaY) > 0;
- if (Math.abs(deltaX) < Math.abs(deltaY)) {
+ if ((Math.abs(deltaX) < Math.abs(deltaY))) {
// Similar triangles bfa and bde mean that (ab/fb = eb/bd)
// Therefore, eb = ab * bd / fb
// ab = hypotenuse
// bd = hypotenuse/2
// fb = deltaY
float eDistY = h2 / (2 * deltaY);
- ey = endY + eDistY;
- ex = endX;
+ if (isQuadrant1Or3) {
+ ey = startY + eDistY;
+ ex = startX;
+ } else {
+ ey = endY - eDistY;
+ ex = endX;
+ }
minimumArcDist2 = midDist2 * mMinimumVerticalTangent
* mMinimumVerticalTangent;
} else {
// Same as above, but flip X & Y
float eDistX = h2 / (2 * deltaX);
- ex = endX + eDistX;
- ey = endY;
+ if (isQuadrant1Or3) {
+ ex = endX - eDistX;
+ ey = endY;
+ } else {
+ ex = startX + eDistX;
+ ey = startY;
+ }
minimumArcDist2 = midDist2 * mMinimumHorizontalTangent
* mMinimumHorizontalTangent;
diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java
index c54ce80..d29bc21 100644
--- a/core/java/android/view/ViewGroup.java
+++ b/core/java/android/view/ViewGroup.java
@@ -5357,9 +5357,6 @@
void offsetRectBetweenParentAndChild(View descendant, Rect rect,
boolean offsetFromChildToParent, boolean clipToBounds) {
- final RectF rectF = mAttachInfo != null ? mAttachInfo.mTmpTransformRect1 : new RectF();
- final Matrix inverse = mAttachInfo != null ? mAttachInfo.mTmpMatrix : new Matrix();
-
// already in the same coord system :)
if (descendant == this) {
return;
@@ -5373,16 +5370,8 @@
&& (theParent != this)) {
if (offsetFromChildToParent) {
- rect.offset(-descendant.mScrollX, -descendant.mScrollY);
-
- if (!descendant.hasIdentityMatrix()) {
- rectF.set(rect);
- descendant.getMatrix().mapRect(rectF);
- rectF.roundOut(rect);
- }
-
- rect.offset(descendant.mLeft, descendant.mTop);
-
+ rect.offset(descendant.mLeft - descendant.mScrollX,
+ descendant.mTop - descendant.mScrollY);
if (clipToBounds) {
View p = (View) theParent;
boolean intersected = rect.intersect(0, 0, p.mRight - p.mLeft,
@@ -5400,16 +5389,8 @@
rect.setEmpty();
}
}
- rect.offset(-descendant.mLeft, -descendant.mTop);
-
- if (!descendant.hasIdentityMatrix()) {
- descendant.getMatrix().invert(inverse);
- rectF.set(rect);
- inverse.mapRect(rectF);
- rectF.roundOut(rect);
- }
-
- rect.offset(descendant.mScrollX, descendant.mScrollY);
+ rect.offset(descendant.mScrollX - descendant.mLeft,
+ descendant.mScrollY - descendant.mTop);
}
descendant = (View) theParent;
@@ -5420,26 +5401,11 @@
// to get into our coordinate space
if (theParent == this) {
if (offsetFromChildToParent) {
- rect.offset(-descendant.mScrollX, -descendant.mScrollY);
-
- if (!descendant.hasIdentityMatrix()) {
- rectF.set(rect);
- descendant.getMatrix().mapRect(rectF);
- rectF.roundOut(rect);
- }
-
- rect.offset(descendant.mLeft, descendant.mTop);
+ rect.offset(descendant.mLeft - descendant.mScrollX,
+ descendant.mTop - descendant.mScrollY);
} else {
- rect.offset(-descendant.mLeft, -descendant.mTop);
-
- if (!descendant.hasIdentityMatrix()) {
- descendant.getMatrix().invert(inverse);
- rectF.set(rect);
- inverse.mapRect(rectF);
- rectF.roundOut(rect);
- }
-
- rect.offset(descendant.mScrollX, descendant.mScrollY);
+ rect.offset(descendant.mScrollX - descendant.mLeft,
+ descendant.mScrollY - descendant.mTop);
}
} else {
throw new IllegalArgumentException("parameter must be a descendant of this view");
diff --git a/core/java/com/android/internal/policy/DividerSnapAlgorithm.java b/core/java/com/android/internal/policy/DividerSnapAlgorithm.java
index 84d0fc7..9907ea9 100644
--- a/core/java/com/android/internal/policy/DividerSnapAlgorithm.java
+++ b/core/java/com/android/internal/policy/DividerSnapAlgorithm.java
@@ -279,6 +279,26 @@
}
/**
+ * Cycles through all non-dismiss targets with a stepping of {@param increment}. It moves left
+ * if {@param increment} is negative and moves right otherwise.
+ */
+ public SnapTarget cycleNonDismissTarget(SnapTarget snapTarget, int increment) {
+ int index = mTargets.indexOf(snapTarget);
+ if (index != -1) {
+ SnapTarget newTarget = mTargets.get((index + mTargets.size() + increment)
+ % mTargets.size());
+ if (newTarget == mDismissStartTarget) {
+ return mLastSplitTarget;
+ } else if (newTarget == mDismissEndTarget) {
+ return mFirstSplitTarget;
+ } else {
+ return newTarget;
+ }
+ }
+ return snapTarget;
+ }
+
+ /**
* Represents a snap target for the divider.
*/
public static class SnapTarget {
diff --git a/core/java/com/android/internal/util/ArrayUtils.java b/core/java/com/android/internal/util/ArrayUtils.java
index a84a061..ee73b90 100644
--- a/core/java/com/android/internal/util/ArrayUtils.java
+++ b/core/java/com/android/internal/util/ArrayUtils.java
@@ -27,6 +27,7 @@
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
import java.util.Objects;
@@ -477,4 +478,48 @@
}
return !diff;
}
+
+ /**
+ * Removes elements that match the predicate in an efficient way that alters the order of
+ * elements in the collection. This should only be used if order is not important.
+ * @param collection The ArrayList from which to remove elements.
+ * @param predicate The predicate that each element is tested against.
+ * @return the number of elements removed.
+ */
+ public static <T> int unstableRemoveIf(@Nullable ArrayList<T> collection,
+ @NonNull java.util.function.Predicate<T> predicate) {
+ if (collection == null) {
+ return 0;
+ }
+
+ final int size = collection.size();
+ int leftIdx = 0;
+ int rightIdx = size - 1;
+ while (leftIdx <= rightIdx) {
+ // Find the next element to remove moving left to right.
+ while (leftIdx < size && !predicate.test(collection.get(leftIdx))) {
+ leftIdx++;
+ }
+
+ // Find the next element to keep moving right to left.
+ while (rightIdx > leftIdx && predicate.test(collection.get(rightIdx))) {
+ rightIdx--;
+ }
+
+ if (leftIdx >= rightIdx) {
+ // Done.
+ break;
+ }
+
+ Collections.swap(collection, leftIdx, rightIdx);
+ leftIdx++;
+ rightIdx--;
+ }
+
+ // leftIdx is now at the end.
+ for (int i = size - 1; i >= leftIdx; i--) {
+ collection.remove(i);
+ }
+ return size - leftIdx;
+ }
}
diff --git a/core/jni/android/graphics/BitmapFactory.cpp b/core/jni/android/graphics/BitmapFactory.cpp
index 29c1075..fb9b1e5 100644
--- a/core/jni/android/graphics/BitmapFactory.cpp
+++ b/core/jni/android/graphics/BitmapFactory.cpp
@@ -201,6 +201,26 @@
const unsigned int mSize;
};
+// Necessary for decodes when the native decoder cannot scale to appropriately match the sampleSize
+// (for example, RAW). If the sampleSize divides evenly into the dimension, we require that the
+// scale matches exactly. If sampleSize does not divide evenly, we allow the decoder to choose how
+// best to round.
+static bool needsFineScale(const int fullSize, const int decodedSize, const int sampleSize) {
+ if (fullSize % sampleSize == 0 && fullSize / sampleSize != decodedSize) {
+ return true;
+ } else if ((fullSize / sampleSize + 1) != decodedSize &&
+ (fullSize / sampleSize) != decodedSize) {
+ return true;
+ }
+ return false;
+}
+
+static bool needsFineScale(const SkISize fullSize, const SkISize decodedSize,
+ const int sampleSize) {
+ return needsFineScale(fullSize.width(), decodedSize.width(), sampleSize) ||
+ needsFineScale(fullSize.height(), decodedSize.height(), sampleSize);
+}
+
static jobject doDecode(JNIEnv* env, SkStreamRewindable* stream, jobject padding, jobject options) {
// This function takes ownership of the input stream. Since the SkAndroidCodec
// will take ownership of the stream, we don't necessarily need to take ownership
@@ -250,7 +270,6 @@
}
}
}
- const bool willScale = scale != 1.0f;
// Create the codec.
NinePatchPeeker peeker;
@@ -269,15 +288,28 @@
prefColorType = kN32_SkColorType;
}
- // Determine the output size and return if the client only wants the size.
+ // Determine the output size.
SkISize size = codec->getSampledDimensions(sampleSize);
+
+ int scaledWidth = size.width();
+ int scaledHeight = size.height();
+ bool willScale = false;
+
+ // Apply a fine scaling step if necessary.
+ if (needsFineScale(codec->getInfo().dimensions(), size, sampleSize)) {
+ willScale = true;
+ scaledWidth = codec->getInfo().width() / sampleSize;
+ scaledHeight = codec->getInfo().height() / sampleSize;
+ }
+
+ // Set the options and return if the client only wants the size.
if (options != NULL) {
jstring mimeType = encodedFormatToString(env, codec->getEncodedFormat());
if (env->ExceptionCheck()) {
return nullObjectReturn("OOM in encodedFormatToString()");
}
- env->SetIntField(options, gOptions_widthFieldID, size.width());
- env->SetIntField(options, gOptions_heightFieldID, size.height());
+ env->SetIntField(options, gOptions_widthFieldID, scaledWidth);
+ env->SetIntField(options, gOptions_heightFieldID, scaledHeight);
env->SetObjectField(options, gOptions_mimeFieldID, mimeType);
if (onlyDecodeSize) {
@@ -285,6 +317,13 @@
}
}
+ // Scale is necessary due to density differences.
+ if (scale != 1.0f) {
+ willScale = true;
+ scaledWidth = static_cast<int>(scaledWidth * scale + 0.5f);
+ scaledHeight = static_cast<int>(scaledHeight * scale + 0.5f);
+ }
+
android::Bitmap* reuseBitmap = nullptr;
unsigned int existingBufferSize = 0;
if (javaBitmap != NULL) {
@@ -381,13 +420,6 @@
return nullObjectReturn("codec->getAndroidPixels() failed.");
}
- int scaledWidth = size.width();
- int scaledHeight = size.height();
- if (willScale) {
- scaledWidth = int(scaledWidth * scale + 0.5f);
- scaledHeight = int(scaledHeight * scale + 0.5f);
- }
-
jbyteArray ninePatchChunk = NULL;
if (peeker.mPatch != NULL) {
if (willScale) {
diff --git a/core/jni/android_hardware_camera2_DngCreator.cpp b/core/jni/android_hardware_camera2_DngCreator.cpp
index c6baf1c..d80d8f2 100644
--- a/core/jni/android_hardware_camera2_DngCreator.cpp
+++ b/core/jni/android_hardware_camera2_DngCreator.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define LOG_NDEBUG 0
+//#define LOG_NDEBUG 0
#define LOG_TAG "DngCreator_JNI"
#include <inttypes.h>
#include <string.h>
@@ -1792,6 +1792,8 @@
{
// Set up orientation tags.
+ // Note: There's only one orientation field for the whole file, in IFD0
+ // The main image and any thumbnails therefore have the same orientation.
uint16_t orientation = nativeContext->getOrientation();
BAIL_IF_INVALID_RET_NULL_SP(writer->addEntry(TAG_ORIENTATION, 1, &orientation, TIFF_IFD_0),
env, TAG_ORIENTATION, writer);
@@ -1873,7 +1875,6 @@
}
Vector<uint16_t> tagsToMove;
- tagsToMove.add(TAG_ORIENTATION);
tagsToMove.add(TAG_NEWSUBFILETYPE);
tagsToMove.add(TAG_ACTIVEAREA);
tagsToMove.add(TAG_BITSPERSAMPLE);
@@ -1904,12 +1905,6 @@
return nullptr;
}
- // Make sure both IFDs get the same orientation tag
- sp<TiffEntry> orientEntry = writer->getEntry(TAG_ORIENTATION, TIFF_IFD_SUB1);
- if (orientEntry.get() != nullptr) {
- writer->addEntry(orientEntry, TIFF_IFD_0);
- }
-
// Setup thumbnail tags
{
diff --git a/core/res/res/values-mcc232-mnc11/config.xml b/core/res/res/values-mcc232-mnc11/config.xml
new file mode 100644
index 0000000..91e37b4
--- /dev/null
+++ b/core/res/res/values-mcc232-mnc11/config.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+ ** Copyright 2016, The Android Open Source Project
+ **
+ ** Licensed under the Apache License, Version 2.0 (the "License");
+ ** you may not use this file except in compliance with the License.
+ ** You may obtain a copy of the License at
+ **
+ ** http://www.apache.org/licenses/LICENSE-2.0
+ **
+ ** Unless required by applicable law or agreed to in writing, software
+ ** distributed under the License is distributed on an "AS IS" BASIS,
+ ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ** See the License for the specific language governing permissions and
+ ** limitations under the License.
+ */
+-->
+
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <!-- Don't use roaming icon for considered operators -->
+ <string-array translatable="false" name="config_operatorConsideredNonRoaming">
+ <item>23201</item>
+ </string-array>
+</resources>
diff --git a/core/res/res/values-mcc232-mnc12/config.xml b/core/res/res/values-mcc232-mnc12/config.xml
new file mode 100644
index 0000000..91e37b4
--- /dev/null
+++ b/core/res/res/values-mcc232-mnc12/config.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+ ** Copyright 2016, The Android Open Source Project
+ **
+ ** Licensed under the Apache License, Version 2.0 (the "License");
+ ** you may not use this file except in compliance with the License.
+ ** You may obtain a copy of the License at
+ **
+ ** http://www.apache.org/licenses/LICENSE-2.0
+ **
+ ** Unless required by applicable law or agreed to in writing, software
+ ** distributed under the License is distributed on an "AS IS" BASIS,
+ ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ** See the License for the specific language governing permissions and
+ ** limitations under the License.
+ */
+-->
+
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <!-- Don't use roaming icon for considered operators -->
+ <string-array translatable="false" name="config_operatorConsideredNonRoaming">
+ <item>23201</item>
+ </string-array>
+</resources>
diff --git a/core/tests/coretests/src/android/app/DownloadManagerBaseTest.java b/core/tests/coretests/src/android/app/DownloadManagerBaseTest.java
index af2a944..bae4ecc 100644
--- a/core/tests/coretests/src/android/app/DownloadManagerBaseTest.java
+++ b/core/tests/coretests/src/android/app/DownloadManagerBaseTest.java
@@ -81,8 +81,7 @@
protected static final int DEFAULT_WAIT_POLL_TIME = 5 * 1000; // 5 seconds
protected static final int WAIT_FOR_DOWNLOAD_POLL_TIME = 1 * 1000; // 1 second
- protected static final int MAX_WAIT_FOR_DOWNLOAD_TIME = 5 * 60 * 1000; // 5 minutes
- protected static final int MAX_WAIT_FOR_LARGE_DOWNLOAD_TIME = 15 * 60 * 1000; // 15 minutes
+ protected static final int MAX_WAIT_FOR_DOWNLOAD_TIME = 30 * 1000; // 30 seconds
protected static final int DOWNLOAD_TO_SYSTEM_CACHE = 1;
protected static final int DOWNLOAD_TO_DOWNLOAD_CACHE_DIR = 2;
@@ -970,7 +969,7 @@
protected void verifyInt(Cursor cursor, String columnName, int expected) {
int index = cursor.getColumnIndex(columnName);
int actual = cursor.getInt(index);
- assertEquals(expected, actual);
+ assertEquals(String.format("Expected = %d : Actual = %d", expected, actual), expected, actual);
}
/**
diff --git a/core/tests/coretests/src/android/app/DownloadManagerFunctionalTest.java b/core/tests/coretests/src/android/app/DownloadManagerFunctionalTest.java
index 7019980..4a53852 100644
--- a/core/tests/coretests/src/android/app/DownloadManagerFunctionalTest.java
+++ b/core/tests/coretests/src/android/app/DownloadManagerFunctionalTest.java
@@ -23,18 +23,16 @@
import android.os.Environment;
import android.os.ParcelFileDescriptor;
import android.test.suitebuilder.annotation.LargeTest;
-
-import android.test.suitebuilder.annotation.Suppress;
import com.google.mockwebserver.MockResponse;
import java.io.File;
+import java.util.concurrent.TimeoutException;
import java.util.Iterator;
import java.util.Set;
/**
* Integration tests of the DownloadManager API.
*/
-@Suppress // Failing.
public class DownloadManagerFunctionalTest extends DownloadManagerBaseTest {
private static final String TAG = "DownloadManagerFunctionalTest";
private final static String CACHE_DIR =
@@ -79,7 +77,11 @@
request.setTitle(DEFAULT_FILENAME);
long dlRequest = mDownloadManager.enqueue(request);
- waitForDownloadOrTimeout(dlRequest);
+ try {
+ waitForDownloadOrTimeout(dlRequest);
+ } catch (TimeoutException ex) {
+ // it is expected to timeout as download never finishes
+ }
Cursor cursor = getCursor(dlRequest);
try {
@@ -114,7 +116,7 @@
verifyDownload(dlRequest, blobData);
mDownloadManager.remove(dlRequest);
}
-
+
/**
* Helper to verify a standard single-file download from the mock server, and clean up after
* verification
@@ -135,9 +137,7 @@
verifyFileSize(pfd, fileSize);
verifyFileContents(pfd, fileData);
- int colIndex = cursor.getColumnIndex(DownloadManager.COLUMN_LOCAL_FILENAME);
- String fileName = cursor.getString(colIndex);
- assertTrue(fileName.startsWith(CACHE_DIR));
+ assertTrue(new File(CACHE_DIR + "/" + DEFAULT_FILENAME).exists());
} finally {
pfd.close();
cursor.close();
@@ -161,7 +161,6 @@
Uri localUri = Uri.fromFile(existentFile);
request.setDestinationUri(localUri);
-
long dlRequest = mDownloadManager.enqueue(request);
// wait for the download to complete
diff --git a/core/tests/coretests/src/android/content/res/ConfigurationBoundResourceCacheTest.java b/core/tests/coretests/src/android/content/res/ConfigurationBoundResourceCacheTest.java
index 5d46489..47554a6 100644
--- a/core/tests/coretests/src/android/content/res/ConfigurationBoundResourceCacheTest.java
+++ b/core/tests/coretests/src/android/content/res/ConfigurationBoundResourceCacheTest.java
@@ -17,20 +17,18 @@
package android.content.res;
import android.test.ActivityInstrumentationTestCase2;
+import android.test.suitebuilder.annotation.SmallTest;
import android.util.TypedValue;
import com.android.frameworks.coretests.R;
import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
public class ConfigurationBoundResourceCacheTest
extends ActivityInstrumentationTestCase2<ResourceCacheActivity> {
ConfigurationBoundResourceCache<Float> mCache;
- Method mCalcConfigChanges;
-
public ConfigurationBoundResourceCacheTest() {
super(ResourceCacheActivity.class);
}
@@ -41,33 +39,42 @@
mCache = new ConfigurationBoundResourceCache<>();
}
+ @SmallTest
public void testGetEmpty() {
- assertNull(mCache.get(-1, null));
+ final Resources res = getActivity().getResources();
+ assertNull(mCache.getInstance(-1, res, null));
}
+ @SmallTest
public void testSetGet() {
mCache.put(1, null, new DummyFloatConstantState(5f));
- assertEquals(5f, mCache.get(1, null));
- assertNotSame(5f, mCache.get(1, null));
- assertEquals(null, mCache.get(1, getActivity().getTheme()));
+ final Resources res = getActivity().getResources();
+ assertEquals(5f, mCache.getInstance(1, res, null));
+ assertNotSame(5f, mCache.getInstance(1, res, null));
+ assertEquals(null, mCache.getInstance(1, res, getActivity().getTheme()));
}
+ @SmallTest
public void testSetGetThemed() {
mCache.put(1, getActivity().getTheme(), new DummyFloatConstantState(5f));
- assertEquals(null, mCache.get(1, null));
- assertEquals(5f, mCache.get(1, getActivity().getTheme()));
- assertNotSame(5f, mCache.get(1, getActivity().getTheme()));
+ final Resources res = getActivity().getResources();
+ assertEquals(null, mCache.getInstance(1, res, null));
+ assertEquals(5f, mCache.getInstance(1, res, getActivity().getTheme()));
+ assertNotSame(5f, mCache.getInstance(1, res, getActivity().getTheme()));
}
+ @SmallTest
public void testMultiThreadPutGet() {
mCache.put(1, getActivity().getTheme(), new DummyFloatConstantState(5f));
mCache.put(1, null, new DummyFloatConstantState(10f));
- assertEquals(10f, mCache.get(1, null));
- assertNotSame(10f, mCache.get(1, null));
- assertEquals(5f, mCache.get(1, getActivity().getTheme()));
- assertNotSame(5f, mCache.get(1, getActivity().getTheme()));
+ final Resources res = getActivity().getResources();
+ assertEquals(10f, mCache.getInstance(1, res, null));
+ assertNotSame(10f, mCache.getInstance(1, res, null));
+ assertEquals(5f, mCache.getInstance(1, res, getActivity().getTheme()));
+ assertNotSame(5f, mCache.getInstance(1, res, getActivity().getTheme()));
}
+ @SmallTest
public void testVoidConfigChange()
throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
TypedValue staticValue = new TypedValue();
@@ -83,11 +90,12 @@
Configuration.ORIENTATION_PORTRAIT
: Configuration.ORIENTATION_LANDSCAPE;
int changes = calcConfigChanges(res, newCnf);
- assertEquals(staticDim, mCache.get(key, getActivity().getTheme()));
+ assertEquals(staticDim, mCache.getInstance(key, res, getActivity().getTheme()));
mCache.onConfigurationChange(changes);
- assertEquals(staticDim, mCache.get(key, getActivity().getTheme()));
+ assertEquals(staticDim, mCache.getInstance(key, res, getActivity().getTheme()));
}
+ @SmallTest
public void testEffectiveConfigChange()
throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
TypedValue changingValue = new TypedValue();
@@ -105,11 +113,12 @@
Configuration.ORIENTATION_PORTRAIT
: Configuration.ORIENTATION_LANDSCAPE;
int changes = calcConfigChanges(res, newCnf);
- assertEquals(changingDim, mCache.get(key, getActivity().getTheme()));
+ assertEquals(changingDim, mCache.getInstance(key, res, getActivity().getTheme()));
mCache.onConfigurationChange(changes);
assertNull(mCache.get(key, getActivity().getTheme()));
}
+ @SmallTest
public void testConfigChangeMultipleResources()
throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
TypedValue staticValue = new TypedValue();
@@ -130,17 +139,19 @@
Configuration.ORIENTATION_PORTRAIT
: Configuration.ORIENTATION_LANDSCAPE;
int changes = calcConfigChanges(res, newCnf);
- assertEquals(staticDim, mCache.get(R.dimen.resource_cache_test_generic,
+ assertEquals(staticDim, mCache.getInstance(R.dimen.resource_cache_test_generic, res,
getActivity().getTheme()));
- assertEquals(changingDim, mCache.get(R.dimen.resource_cache_test_orientation_dependent,
- getActivity().getTheme()));
+ assertEquals(changingDim,
+ mCache.getInstance(R.dimen.resource_cache_test_orientation_dependent, res,
+ getActivity().getTheme()));
mCache.onConfigurationChange(changes);
- assertEquals(staticDim, mCache.get(R.dimen.resource_cache_test_generic,
+ assertEquals(staticDim, mCache.getInstance(R.dimen.resource_cache_test_generic, res,
getActivity().getTheme()));
- assertNull(mCache.get(R.dimen.resource_cache_test_orientation_dependent,
+ assertNull(mCache.getInstance(R.dimen.resource_cache_test_orientation_dependent, res,
getActivity().getTheme()));
}
+ @SmallTest
public void testConfigChangeMultipleThemes()
throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
TypedValue[] staticValues = new TypedValue[]{new TypedValue(), new TypedValue()};
@@ -172,31 +183,27 @@
int changes = calcConfigChanges(res, newCnf);
for (int i = 0; i < 2; i++) {
final Resources.Theme theme = i == 0 ? getActivity().getTheme() : null;
- assertEquals(staticDim, mCache.get(R.dimen.resource_cache_test_generic, theme));
+ assertEquals(staticDim,
+ mCache.getInstance(R.dimen.resource_cache_test_generic, res, theme));
assertEquals(changingDim,
- mCache.get(R.dimen.resource_cache_test_orientation_dependent, theme));
+ mCache.getInstance(R.dimen.resource_cache_test_orientation_dependent, res,
+ theme));
}
mCache.onConfigurationChange(changes);
for (int i = 0; i < 2; i++) {
final Resources.Theme theme = i == 0 ? getActivity().getTheme() : null;
- assertEquals(staticDim, mCache.get(R.dimen.resource_cache_test_generic, theme));
- assertNull(mCache.get(R.dimen.resource_cache_test_orientation_dependent, theme));
+ assertEquals(staticDim,
+ mCache.getInstance(R.dimen.resource_cache_test_generic, res, theme));
+ assertNull(mCache.getInstance(R.dimen.resource_cache_test_orientation_dependent, res,
+ theme));
}
}
- private int calcConfigChanges(Resources resources, Configuration configuration)
- throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
- if (mCalcConfigChanges == null) {
- mCalcConfigChanges = Resources.class.getDeclaredMethod("calcConfigChanges",
- Configuration.class);
- mCalcConfigChanges.setAccessible(true);
- }
- return (Integer) mCalcConfigChanges.invoke(resources, configuration);
-
+ private static int calcConfigChanges(Resources resources, Configuration configuration) {
+ return resources.calcConfigChanges(configuration);
}
- static class DummyFloatConstantState extends
- ConstantState<Float> {
+ static class DummyFloatConstantState extends ConstantState<Float> {
final Float mObj;
diff --git a/core/tests/coretests/src/android/content/res/ResourcesManagerTest.java b/core/tests/coretests/src/android/content/res/ResourcesManagerTest.java
new file mode 100644
index 0000000..3cadbf6
--- /dev/null
+++ b/core/tests/coretests/src/android/content/res/ResourcesManagerTest.java
@@ -0,0 +1,222 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package android.content.res;
+
+import android.annotation.NonNull;
+import android.app.ResourcesManager;
+import android.os.Binder;
+import android.test.suitebuilder.annotation.SmallTest;
+import android.util.DisplayMetrics;
+import android.util.LocaleList;
+import android.util.TypedValue;
+import android.view.Display;
+import junit.framework.TestCase;
+
+public class ResourcesManagerTest extends TestCase {
+ private static final String APP_ONE_RES_DIR = "app_one.apk";
+ private static final String APP_ONE_RES_SPLIT_DIR = "app_one_split.apk";
+ private static final String APP_TWO_RES_DIR = "app_two.apk";
+ private static final String LIB_RES_DIR = "lib.apk";
+
+ private ResourcesManager mResourcesManager;
+ private DisplayMetrics mDisplayMetrics;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ mDisplayMetrics = new DisplayMetrics();
+ mDisplayMetrics.setToDefaults();
+
+ // Override defaults (which take device specific properties).
+ mDisplayMetrics.density = 1.0f;
+ mDisplayMetrics.densityDpi = DisplayMetrics.DENSITY_DEFAULT;
+ mDisplayMetrics.xdpi = DisplayMetrics.DENSITY_DEFAULT;
+ mDisplayMetrics.ydpi = DisplayMetrics.DENSITY_DEFAULT;
+ mDisplayMetrics.noncompatDensity = mDisplayMetrics.density;
+ mDisplayMetrics.noncompatDensityDpi = mDisplayMetrics.densityDpi;
+ mDisplayMetrics.noncompatXdpi = DisplayMetrics.DENSITY_DEFAULT;
+ mDisplayMetrics.noncompatYdpi = DisplayMetrics.DENSITY_DEFAULT;
+
+ mResourcesManager = new ResourcesManager() {
+ @Override
+ protected AssetManager createAssetManager(@NonNull ResourcesKey key) {
+ return new AssetManager();
+ }
+
+ @Override
+ protected DisplayMetrics getDisplayMetricsLocked(int displayId) {
+ return mDisplayMetrics;
+ }
+ };
+ }
+
+ @SmallTest
+ public void testMultipleCallsWithIdenticalParametersCacheReference() {
+ Resources resources = mResourcesManager.getResources(
+ null, APP_ONE_RES_DIR, null, null, null, Display.DEFAULT_DISPLAY, null,
+ CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO, null);
+ assertNotNull(resources);
+
+ Resources newResources = mResourcesManager.getResources(
+ null, APP_ONE_RES_DIR, null, null, null, Display.DEFAULT_DISPLAY, null,
+ CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO, null);
+ assertNotNull(newResources);
+ assertSame(resources, newResources);
+ }
+
+ @SmallTest
+ public void testMultipleCallsWithDifferentParametersReturnDifferentReferences() {
+ Resources resources = mResourcesManager.getResources(
+ null, APP_ONE_RES_DIR, null, null, null, Display.DEFAULT_DISPLAY, null,
+ CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO, null);
+ assertNotNull(resources);
+
+ Configuration overrideConfig = new Configuration();
+ overrideConfig.smallestScreenWidthDp = 200;
+ Resources newResources = mResourcesManager.getResources(
+ null, APP_ONE_RES_DIR, null, null, null, Display.DEFAULT_DISPLAY, overrideConfig,
+ CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO, null);
+ assertNotNull(newResources);
+ assertNotSame(resources, newResources);
+ }
+
+ @SmallTest
+ public void testAddingASplitCreatesANewImpl() {
+ Resources resources1 = mResourcesManager.getResources(
+ null, APP_ONE_RES_DIR, null, null, null, Display.DEFAULT_DISPLAY, null,
+ CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO, null);
+ assertNotNull(resources1);
+
+ Resources resources2 = mResourcesManager.getResources(
+ null, APP_ONE_RES_DIR, new String[] { APP_ONE_RES_SPLIT_DIR }, null, null,
+ Display.DEFAULT_DISPLAY, null, CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO, null);
+ assertNotNull(resources2);
+
+ assertNotSame(resources1, resources2);
+ assertNotSame(resources1.getImpl(), resources2.getImpl());
+ }
+
+ @SmallTest
+ public void testUpdateConfigurationUpdatesAllAssetManagers() {
+ Resources resources1 = mResourcesManager.getResources(
+ null, APP_ONE_RES_DIR, null, null, null, Display.DEFAULT_DISPLAY, null,
+ CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO, null);
+ assertNotNull(resources1);
+
+ Resources resources2 = mResourcesManager.getResources(
+ null, APP_TWO_RES_DIR, null, null, null, Display.DEFAULT_DISPLAY, null,
+ CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO, null);
+ assertNotNull(resources2);
+
+ Binder activity = new Binder();
+ final Configuration overrideConfig = new Configuration();
+ overrideConfig.orientation = Configuration.ORIENTATION_LANDSCAPE;
+ Resources resources3 = mResourcesManager.getResources(
+ activity, APP_ONE_RES_DIR, null, null, null, Display.DEFAULT_DISPLAY,
+ overrideConfig, CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO, null);
+ assertNotNull(resources3);
+
+ // No Resources object should be the same.
+ assertNotSame(resources1, resources2);
+ assertNotSame(resources1, resources3);
+ assertNotSame(resources2, resources3);
+
+ // Each ResourcesImpl should be different.
+ assertNotSame(resources1.getImpl(), resources2.getImpl());
+ assertNotSame(resources1.getImpl(), resources3.getImpl());
+ assertNotSame(resources2.getImpl(), resources3.getImpl());
+
+ Configuration newConfig = new Configuration();
+ newConfig.orientation = Configuration.ORIENTATION_LANDSCAPE;
+ mResourcesManager.applyConfigurationToResourcesLocked(newConfig, null);
+
+ final Configuration expectedConfig = new Configuration();
+ expectedConfig.setLocales(LocaleList.getAdjustedDefault());
+ expectedConfig.densityDpi = mDisplayMetrics.densityDpi;
+ expectedConfig.orientation = Configuration.ORIENTATION_LANDSCAPE;
+
+ assertEquals(expectedConfig, resources1.getConfiguration());
+ assertEquals(expectedConfig, resources2.getConfiguration());
+ assertEquals(expectedConfig, resources3.getConfiguration());
+ }
+
+ @SmallTest
+ public void testTwoActivitiesWithIdenticalParametersShareImpl() {
+ Binder activity1 = new Binder();
+ Resources resources1 = mResourcesManager.getResources(
+ activity1, APP_ONE_RES_DIR, null, null, null, Display.DEFAULT_DISPLAY, null,
+ CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO, null);
+ assertNotNull(resources1);
+
+ Binder activity2 = new Binder();
+ Resources resources2 = mResourcesManager.getResources(
+ activity2, APP_ONE_RES_DIR, null, null, null, Display.DEFAULT_DISPLAY, null,
+ CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO, null);
+ assertNotNull(resources1);
+
+ // The references themselves should be unique.
+ assertNotSame(resources1, resources2);
+
+ // The implementations should be the same.
+ assertSame(resources1.getImpl(), resources2.getImpl());
+
+ final Configuration overrideConfig = new Configuration();
+ overrideConfig.orientation = Configuration.ORIENTATION_LANDSCAPE;
+ Resources resources3 = mResourcesManager.getResources(
+ activity2, APP_ONE_RES_DIR, null, null, null, Display.DEFAULT_DISPLAY,
+ overrideConfig, CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO, null);
+
+ // Since we requested new resources for activity2, the resource should be the same
+ // as the one returned before for activity2.
+ assertSame(resources2, resources3);
+
+ // But the implementation has changed.
+ assertNotSame(resources1.getImpl(), resources2.getImpl());
+ }
+
+ @SmallTest
+ public void testThemesGetUpdatedWithNewImpl() {
+ Binder activity1 = new Binder();
+ Resources resources1 = mResourcesManager.getResources(
+ activity1, APP_ONE_RES_DIR, null, null, null, Display.DEFAULT_DISPLAY, null,
+ CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO, null);
+ assertNotNull(resources1);
+
+ Resources.Theme theme = resources1.newTheme();
+ assertSame(resources1, theme.getResources());
+ theme.applyStyle(android.R.style.Theme_NoTitleBar, false);
+
+ TypedValue value = new TypedValue();
+ assertTrue(theme.resolveAttribute(android.R.attr.windowNoTitle, value, true));
+ assertEquals(TypedValue.TYPE_INT_BOOLEAN, value.type);
+ assertTrue(value.data != 0);
+
+ final Configuration overrideConfig = new Configuration();
+ overrideConfig.orientation = Configuration.ORIENTATION_LANDSCAPE;
+ Resources resources2 = mResourcesManager.getResources(
+ activity1, APP_ONE_RES_DIR, null, null, null, Display.DEFAULT_DISPLAY,
+ overrideConfig, CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO, null);
+ assertNotNull(resources2);
+ assertSame(resources1, resources2);
+ assertSame(resources2, theme.getResources());
+
+ // Make sure we can still access the data.
+ assertTrue(theme.resolveAttribute(android.R.attr.windowNoTitle, value, true));
+ assertEquals(TypedValue.TYPE_INT_BOOLEAN, value.type);
+ assertTrue(value.data != 0);
+ }
+}
diff --git a/core/tests/coretests/src/com/android/internal/util/ArrayUtilsTest.java b/core/tests/coretests/src/com/android/internal/util/ArrayUtilsTest.java
new file mode 100644
index 0000000..b3897ce
--- /dev/null
+++ b/core/tests/coretests/src/com/android/internal/util/ArrayUtilsTest.java
@@ -0,0 +1,119 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.android.internal.util;
+
+import android.test.suitebuilder.annotation.SmallTest;
+import junit.framework.TestCase;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+
+public class ArrayUtilsTest extends TestCase {
+
+ @SmallTest
+ public void testUnstableRemoveIf() throws Exception {
+ java.util.function.Predicate<Object> isNull = new java.util.function.Predicate<Object>() {
+ @Override
+ public boolean test(Object o) {
+ return o == null;
+ }
+ };
+
+ final Object a = new Object();
+ final Object b = new Object();
+ final Object c = new Object();
+
+ ArrayList<Object> collection = null;
+ assertEquals(0, ArrayUtils.unstableRemoveIf(collection, isNull));
+
+ collection = new ArrayList<>();
+ assertEquals(0, ArrayUtils.unstableRemoveIf(collection, isNull));
+
+ collection = new ArrayList<>(Collections.singletonList(a));
+ assertEquals(0, ArrayUtils.unstableRemoveIf(collection, isNull));
+ assertEquals(1, collection.size());
+ assertTrue(collection.contains(a));
+
+ collection = new ArrayList<>(Collections.singletonList(null));
+ assertEquals(1, ArrayUtils.unstableRemoveIf(collection, isNull));
+ assertEquals(0, collection.size());
+
+ collection = new ArrayList<>(Arrays.asList(a, b));
+ assertEquals(0, ArrayUtils.unstableRemoveIf(collection, isNull));
+ assertEquals(2, collection.size());
+ assertTrue(collection.contains(a));
+ assertTrue(collection.contains(b));
+
+ collection = new ArrayList<>(Arrays.asList(a, null));
+ assertEquals(1, ArrayUtils.unstableRemoveIf(collection, isNull));
+ assertEquals(1, collection.size());
+ assertTrue(collection.contains(a));
+
+ collection = new ArrayList<>(Arrays.asList(null, a));
+ assertEquals(1, ArrayUtils.unstableRemoveIf(collection, isNull));
+ assertEquals(1, collection.size());
+ assertTrue(collection.contains(a));
+
+ collection = new ArrayList<>(Arrays.asList(null, null));
+ assertEquals(2, ArrayUtils.unstableRemoveIf(collection, isNull));
+ assertEquals(0, collection.size());
+
+ collection = new ArrayList<>(Arrays.asList(a, b, c));
+ assertEquals(0, ArrayUtils.unstableRemoveIf(collection, isNull));
+ assertEquals(3, collection.size());
+ assertTrue(collection.contains(a));
+ assertTrue(collection.contains(b));
+ assertTrue(collection.contains(c));
+
+ collection = new ArrayList<>(Arrays.asList(a, b, null));
+ assertEquals(1, ArrayUtils.unstableRemoveIf(collection, isNull));
+ assertEquals(2, collection.size());
+ assertTrue(collection.contains(a));
+ assertTrue(collection.contains(b));
+
+ collection = new ArrayList<>(Arrays.asList(a, null, b));
+ assertEquals(1, ArrayUtils.unstableRemoveIf(collection, isNull));
+ assertEquals(2, collection.size());
+ assertTrue(collection.contains(a));
+ assertTrue(collection.contains(b));
+
+ collection = new ArrayList<>(Arrays.asList(null, a, b));
+ assertEquals(1, ArrayUtils.unstableRemoveIf(collection, isNull));
+ assertEquals(2, collection.size());
+ assertTrue(collection.contains(a));
+ assertTrue(collection.contains(b));
+
+ collection = new ArrayList<>(Arrays.asList(a, null, null));
+ assertEquals(2, ArrayUtils.unstableRemoveIf(collection, isNull));
+ assertEquals(1, collection.size());
+ assertTrue(collection.contains(a));
+
+ collection = new ArrayList<>(Arrays.asList(null, null, a));
+ assertEquals(2, ArrayUtils.unstableRemoveIf(collection, isNull));
+ assertEquals(1, collection.size());
+ assertTrue(collection.contains(a));
+
+ collection = new ArrayList<>(Arrays.asList(null, a, null));
+ assertEquals(2, ArrayUtils.unstableRemoveIf(collection, isNull));
+ assertEquals(1, collection.size());
+ assertTrue(collection.contains(a));
+
+ collection = new ArrayList<>(Arrays.asList(null, null, null));
+ assertEquals(3, ArrayUtils.unstableRemoveIf(collection, isNull));
+ assertEquals(0, collection.size());
+ }
+}
diff --git a/data/fonts/fonts.xml b/data/fonts/fonts.xml
index dc302c7..bcac6a1 100644
--- a/data/fonts/fonts.xml
+++ b/data/fonts/fonts.xml
@@ -88,242 +88,246 @@
</family>
<!-- fallback fonts -->
- <family variant="elegant">
+ <family lang="und-Arab" variant="elegant">
<font weight="400" style="normal">NotoNaskhArabic-Regular.ttf</font>
<font weight="700" style="normal">NotoNaskhArabic-Bold.ttf</font>
</family>
- <family variant="compact">
+ <family lang="und-Arab" variant="compact">
<font weight="400" style="normal">NotoNaskhArabicUI-Regular.ttf</font>
<font weight="700" style="normal">NotoNaskhArabicUI-Bold.ttf</font>
</family>
- <family>
+ <family lang="und-Ethi">
<font weight="400" style="normal">NotoSansEthiopic-Regular.ttf</font>
<font weight="700" style="normal">NotoSansEthiopic-Bold.ttf</font>
</family>
- <family>
+ <family lang="und-Hebr">
<font weight="400" style="normal">NotoSansHebrew-Regular.ttf</font>
<font weight="700" style="normal">NotoSansHebrew-Bold.ttf</font>
</family>
- <family variant="elegant">
+ <family lang="und-Thai" variant="elegant">
<font weight="400" style="normal">NotoSansThai-Regular.ttf</font>
<font weight="700" style="normal">NotoSansThai-Bold.ttf</font>
</family>
- <family variant="compact">
+ <family lang="und-Thai" variant="compact">
<font weight="400" style="normal">NotoSansThaiUI-Regular.ttf</font>
<font weight="700" style="normal">NotoSansThaiUI-Bold.ttf</font>
</family>
- <family>
+ <family lang="und-Armn">
<font weight="400" style="normal">NotoSansArmenian-Regular.ttf</font>
<font weight="700" style="normal">NotoSansArmenian-Bold.ttf</font>
</family>
- <family>
+ <!-- TODO: add Geok -->
+ <family lang="und-Geor">
<font weight="400" style="normal">NotoSansGeorgian-Regular.ttf</font>
<font weight="700" style="normal">NotoSansGeorgian-Bold.ttf</font>
</family>
- <family variant="elegant">
+ <family lang="und-Deva" variant="elegant">
<font weight="400" style="normal">NotoSansDevanagari-Regular.ttf</font>
<font weight="700" style="normal">NotoSansDevanagari-Bold.ttf</font>
</family>
- <family variant="compact">
+ <family lang="und-Deva" variant="compact">
<font weight="400" style="normal">NotoSansDevanagariUI-Regular.ttf</font>
<font weight="700" style="normal">NotoSansDevanagariUI-Bold.ttf</font>
</family>
- <!-- Gujarati should come after Devanagari -->
- <family variant="elegant">
+
+ <!-- All scripts of India should come after Devanagari, due to shared
+ danda characters.
+ -->
+ <family lang="und-Gujr" variant="elegant">
<font weight="400" style="normal">NotoSansGujarati-Regular.ttf</font>
<font weight="700" style="normal">NotoSansGujarati-Bold.ttf</font>
</family>
- <family variant="compact">
+ <family lang="und-Gujr" variant="compact">
<font weight="400" style="normal">NotoSansGujaratiUI-Regular.ttf</font>
<font weight="700" style="normal">NotoSansGujaratiUI-Bold.ttf</font>
</family>
- <!-- Gurmukhi should come after Devanagari -->
- <family variant="elegant">
+ <family lang="und-Guru" variant="elegant">
<font weight="400" style="normal">NotoSansGurmukhi-Regular.ttf</font>
<font weight="700" style="normal">NotoSansGurmukhi-Bold.ttf</font>
</family>
- <family variant="compact">
+ <family lang="und-Guru" variant="compact">
<font weight="400" style="normal">NotoSansGurmukhiUI-Regular.ttf</font>
<font weight="700" style="normal">NotoSansGurmukhiUI-Bold.ttf</font>
</family>
- <family variant="elegant">
+ <family lang="und-Taml" variant="elegant">
<font weight="400" style="normal">NotoSansTamil-Regular.ttf</font>
<font weight="700" style="normal">NotoSansTamil-Bold.ttf</font>
</family>
- <family variant="compact">
+ <family lang="und-Taml" variant="compact">
<font weight="400" style="normal">NotoSansTamilUI-Regular.ttf</font>
<font weight="700" style="normal">NotoSansTamilUI-Bold.ttf</font>
</family>
- <family variant="elegant">
+ <family lang="und-Mlym" variant="elegant">
<font weight="400" style="normal">NotoSansMalayalam-Regular.ttf</font>
<font weight="700" style="normal">NotoSansMalayalam-Bold.ttf</font>
</family>
- <family variant="compact">
+ <family lang="und-Mlym" variant="compact">
<font weight="400" style="normal">NotoSansMalayalamUI-Regular.ttf</font>
<font weight="700" style="normal">NotoSansMalayalamUI-Bold.ttf</font>
</family>
- <family variant="elegant">
+ <family lang="und-Beng" variant="elegant">
<font weight="400" style="normal">NotoSansBengali-Regular.ttf</font>
<font weight="700" style="normal">NotoSansBengali-Bold.ttf</font>
</family>
- <family variant="compact">
+ <family lang="und-Beng" variant="compact">
<font weight="400" style="normal">NotoSansBengaliUI-Regular.ttf</font>
<font weight="700" style="normal">NotoSansBengaliUI-Bold.ttf</font>
</family>
- <family variant="elegant">
+ <family lang="und-Telu" variant="elegant">
<font weight="400" style="normal">NotoSansTelugu-Regular.ttf</font>
<font weight="700" style="normal">NotoSansTelugu-Bold.ttf</font>
</family>
- <family variant="compact">
+ <family lang="und-Telu" variant="compact">
<font weight="400" style="normal">NotoSansTeluguUI-Regular.ttf</font>
<font weight="700" style="normal">NotoSansTeluguUI-Bold.ttf</font>
</family>
- <family variant="elegant">
+ <family lang="und-Knda" variant="elegant">
<font weight="400" style="normal">NotoSansKannada-Regular.ttf</font>
<font weight="700" style="normal">NotoSansKannada-Bold.ttf</font>
</family>
- <family variant="compact">
+ <family lang="und-Knda" variant="compact">
<font weight="400" style="normal">NotoSansKannadaUI-Regular.ttf</font>
<font weight="700" style="normal">NotoSansKannadaUI-Bold.ttf</font>
</family>
- <family variant="elegant">
+ <family lang="und-Orya" variant="elegant">
<font weight="400" style="normal">NotoSansOriya-Regular.ttf</font>
<font weight="700" style="normal">NotoSansOriya-Bold.ttf</font>
</family>
- <family variant="compact">
+ <family lang="und-Orya" variant="compact">
<font weight="400" style="normal">NotoSansOriyaUI-Regular.ttf</font>
<font weight="700" style="normal">NotoSansOriyaUI-Bold.ttf</font>
</family>
- <family>
+
+ <family lang="und-Sinh">
<font weight="400" style="normal">NotoSansSinhala-Regular.ttf</font>
<font weight="700" style="normal">NotoSansSinhala-Bold.ttf</font>
</family>
- <family variant="elegant">
+ <family lang="und-Khmr" variant="elegant">
<font weight="400" style="normal">NotoSansKhmer-Regular.ttf</font>
<font weight="700" style="normal">NotoSansKhmer-Bold.ttf</font>
</family>
- <family variant="compact">
+ <family lang="und-Khmr" variant="compact">
<font weight="400" style="normal">NotoSansKhmerUI-Regular.ttf</font>
<font weight="700" style="normal">NotoSansKhmerUI-Bold.ttf</font>
</family>
- <family variant="elegant">
+ <family lang="und-Laoo" variant="elegant">
<font weight="400" style="normal">NotoSansLao-Regular.ttf</font>
<font weight="700" style="normal">NotoSansLao-Bold.ttf</font>
</family>
- <family variant="compact">
+ <family lang="und-Laoo" variant="compact">
<font weight="400" style="normal">NotoSansLaoUI-Regular.ttf</font>
<font weight="700" style="normal">NotoSansLaoUI-Bold.ttf</font>
</family>
- <family variant="elegant">
+ <family lang="und-Mymr" variant="elegant">
<font weight="400" style="normal">NotoSansMyanmar-Regular.ttf</font>
<font weight="700" style="normal">NotoSansMyanmar-Bold.ttf</font>
</family>
- <family variant="compact">
+ <family lang="und-Mymr" variant="compact">
<font weight="400" style="normal">NotoSansMyanmarUI-Regular.ttf</font>
<font weight="700" style="normal">NotoSansMyanmarUI-Bold.ttf</font>
</family>
- <family>
+ <family lang="und-Thaa">
<font weight="400" style="normal">NotoSansThaana-Regular.ttf</font>
<font weight="700" style="normal">NotoSansThaana-Bold.ttf</font>
</family>
- <family>
+ <family lang="und-Cham">
<font weight="400" style="normal">NotoSansCham-Regular.ttf</font>
<font weight="700" style="normal">NotoSansCham-Bold.ttf</font>
</family>
- <family>
+ <family lang="und-Bali">
<font weight="400" style="normal">NotoSansBalinese-Regular.ttf</font>
</family>
- <family>
+ <family lang="und-Bamu">
<font weight="400" style="normal">NotoSansBamum-Regular.ttf</font>
</family>
- <family>
+ <family lang="und-Batk">
<font weight="400" style="normal">NotoSansBatak-Regular.ttf</font>
</family>
- <family>
+ <family lang="und-Bugi">
<font weight="400" style="normal">NotoSansBuginese-Regular.ttf</font>
</family>
- <family>
+ <family lang="und-Buhd">
<font weight="400" style="normal">NotoSansBuhid-Regular.ttf</font>
</family>
- <family>
+ <family lang="und-Cans">
<font weight="400" style="normal">NotoSansCanadianAboriginal-Regular.ttf</font>
</family>
- <family>
+ <family lang="und-Cher">
<font weight="400" style="normal">NotoSansCherokee-Regular.ttf</font>
</family>
- <family>
+ <family lang="und-Copt">
<font weight="400" style="normal">NotoSansCoptic-Regular.ttf</font>
</family>
- <family>
+ <family lang="und-Glag">
<font weight="400" style="normal">NotoSansGlagolitic-Regular.ttf</font>
</family>
- <family>
+ <family lang="und-Hano">
<font weight="400" style="normal">NotoSansHanunoo-Regular.ttf</font>
</family>
- <family>
+ <family lang="und-Java">
<font weight="400" style="normal">NotoSansJavanese-Regular.ttf</font>
</family>
- <family>
+ <family lang="und-Kali">
<font weight="400" style="normal">NotoSansKayahLi-Regular.ttf</font>
</family>
- <family>
+ <family lang="und-Lepc">
<font weight="400" style="normal">NotoSansLepcha-Regular.ttf</font>
</family>
- <family>
+ <family lang="und-Limb">
<font weight="400" style="normal">NotoSansLimbu-Regular.ttf</font>
</family>
- <family>
+ <family lang="und-Lisu">
<font weight="400" style="normal">NotoSansLisu-Regular.ttf</font>
</family>
- <family>
+ <family lang="und-Mand">
<font weight="400" style="normal">NotoSansMandaic-Regular.ttf</font>
</family>
- <family>
+ <family lang="und-Mtei">
<font weight="400" style="normal">NotoSansMeeteiMayek-Regular.ttf</font>
</family>
- <family>
+ <family lang="und-Talu">
<font weight="400" style="normal">NotoSansNewTaiLue-Regular.ttf</font>
</family>
- <family>
+ <family lang="und-Nkoo">
<font weight="400" style="normal">NotoSansNKo-Regular.ttf</font>
</family>
- <family>
+ <family lang="und-Olck">
<font weight="400" style="normal">NotoSansOlChiki-Regular.ttf</font>
</family>
- <family>
+ <family lang="und-Rjng">
<font weight="400" style="normal">NotoSansRejang-Regular.ttf</font>
</family>
- <family>
+ <family lang="und-Saur">
<font weight="400" style="normal">NotoSansSaurashtra-Regular.ttf</font>
</family>
- <family>
+ <family lang="und-Sund">
<font weight="400" style="normal">NotoSansSundanese-Regular.ttf</font>
</family>
- <family>
+ <family lang="und-Sylo">
<font weight="400" style="normal">NotoSansSylotiNagri-Regular.ttf</font>
</family>
- <family>
+ <family lang="und-Syre">
<font weight="400" style="normal">NotoSansSyriacEstrangela-Regular.ttf</font>
</family>
- <family>
+ <family lang="und-Tagb">
<font weight="400" style="normal">NotoSansTagbanwa-Regular.ttf</font>
</family>
- <family>
+ <family lang="und-Lana">
<font weight="400" style="normal">NotoSansTaiTham-Regular.ttf</font>
</family>
- <family>
+ <family lang="und-Tavt">
<font weight="400" style="normal">NotoSansTaiViet-Regular.ttf</font>
</family>
- <family>
+ <family lang="und-Tibt">
<font weight="400" style="normal">NotoSansTibetan-Regular.ttf</font>
</family>
- <family>
+ <family lang="und-Tfng">
<font weight="400" style="normal">NotoSansTifinagh-Regular.ttf</font>
</family>
- <family>
+ <family lang="und-Vaii">
<font weight="400" style="normal">NotoSansVai-Regular.ttf</font>
</family>
- <family>
+ <family lang="und-Yiii">
<font weight="400" style="normal">NotoSansYi-Regular.ttf</font>
</family>
<family>
@@ -332,6 +336,7 @@
<family lang="zh-Hans">
<font weight="400" style="normal" index="2">NotoSansCJK-Regular.ttc</font>
</family>
+ <!-- TODO: Add Bopo -->
<family lang="zh-Hant">
<font weight="400" style="normal" index="3">NotoSansCJK-Regular.ttc</font>
</family>
@@ -351,10 +356,10 @@
Tai Le and Mongolian are intentionally kept last, to make sure they don't override
the East Asian punctuation for Chinese.
-->
- <family>
+ <family lang="und-Tale">
<font weight="400" style="normal">NotoSansTaiLe-Regular.ttf</font>
</family>
- <family>
+ <family lang="und-Mong">
<font weight="400" style="normal">NotoSansMongolian-Regular.ttf</font>
</family>
</familyset>
diff --git a/docs/docs-documentation-redirect.html b/docs/docs-documentation-redirect.html
index 98a265e..dbdf8b4 100644
--- a/docs/docs-documentation-redirect.html
+++ b/docs/docs-documentation-redirect.html
@@ -1,9 +1,9 @@
<html>
<head>
-<meta http-equiv="refresh" content="0;url=documentation.html">
+<meta http-equiv="refresh" content="0;url=reference/packages.html">
</head>
<body>
-<a href="documentation.html">click here if you are not redirected</a>
+<a href="reference/packages.html">click here if you are not redirected</a>
</body>
</html>
diff --git a/docs/docs-preview-index.html b/docs/docs-preview-index.html
new file mode 100644
index 0000000..e26b57c
--- /dev/null
+++ b/docs/docs-preview-index.html
@@ -0,0 +1,103 @@
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
+<meta content="IE=edge" http-equiv="X-UA-Compatible">
+<link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />
+
+<title>Android N Developer Preview</title>
+
+<!-- STYLESHEETS -->
+<link rel="stylesheet"
+href="http://fonts.googleapis.com/css?family=Roboto+Condensed">
+<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Roboto:light,regular,medium,thin,italic,mediumitalic,bold"
+ title="roboto">
+<link href="assets/css/default.css?v=17" rel="stylesheet" type="text/css">
+<!-- JAVASCRIPT -->
+<script src="https://www.google.com/jsapi" type="text/javascript"></script>
+<script src="assets/js/android_3p-bundle.js" type="text/javascript"></script>
+<script type="text/javascript">
+ var toRoot = "../";
+ var metaTags = ["develop, getstarted, sdk, appquality, landing"];
+ var devsite = false;
+</script>
+<script src="assets/js/docs.js?v=3" type="text/javascript"></script>
+</head>
+
+<body>
+<div id="header-wrapper">
+ <div class="dac-header" id="header">
+ <div class="dac-header-inner">
+ <a class="dac-nav-toggle" data-dac-toggle-nav="" href="javascript:;"
+ title="Open navigation">
+ <span class="dac-nav-hamburger">
+ <span class="dac-nav-hamburger-top"></span>
+ <span class="dac-nav-hamburger-mid"></span>
+ <span class="dac-nav-hamburger-bot"></span>
+ </span>
+ </a>
+ <a class="dac-header-logo" href="index.html">
+ <img class="dac-header-logo-image" src="assets/images/android_logo.png"
+ srcset="assets/images/android_logo@2x.png 2x" width="32" height="36"
+ alt="Android"> Developers
+ </a>
+ </div>
+ </div>
+</div>
+<nav class="dac-nav">
+ <div class="dac-nav-dimmer" data-dac-toggle-nav=""></div>
+ <ul class="dac-nav-list" data-dac-nav="">
+ <li class="dac-nav-item dac-nav-head">
+ <a class="dac-nav-link dac-nav-logo" data-dac-toggle-nav=""
+ href="javascript:;" title="Close navigation">
+ <img class="dac-logo-image" src="assets/images/android_logo.png"
+ srcset="assets/images/android_logo@2x.png 2x" width="32" height="36"
+ alt="Android"> Developers
+ </a>
+ </li>
+ <li class="dac-nav-item develop">
+ <a class="dac-nav-link" href="reference/packages.html"
+ >API Reference</a>
+ </li>
+ </ul>
+</nav>
+
+<section class="dac-expand" style="padding-top:40px;background-color:#eee">
+ <div class="wrap" style="max-width:1100px;margin-top:0;height:100%">
+ <div class="cols dac-hero-content" style="padding-bottom:1em;">
+ <div class="col-11of16">
+
+
+<h1>Android N Developer Preview</h1>
+<p>
+ Get ready for Android N!
+ <strong>Test your apps</strong> on Nexus devices. Support new system
+ behaviors to <strong>save power and memory</strong>.
+ Extend your apps with <strong>multi-window UI</strong>,
+ <strong>direct reply notifications</strong> and more.
+</p>
+
+<h2>Get Started</h2>
+<ul>
+ <li>View the <a href="reference/packages.html">API Reference</a></li>
+ <li>Read Diff Reports:</a>
+ <ul>
+ <li><a href="sdk/api_diff/n-preview-1/changes.html"
+ >API 23 --> Preview 1</a></li>
+ </ul>
+ </li>
+ <li>Downloads and additional documentation are available at the
+ <a href="http://developer.android.com/preview/index.html">
+ Android N Developer Preview site</a></li>
+ <li>For information about Developer Preview 1, visit the
+ <a href="http://developer.android.com/preview/support.html">Support</a>
+ page.</li>
+</ul>
+
+
+ </div>
+ </div>
+ </div>
+</section>
+</body>
+</html>
diff --git a/include/androidfw/ResourceTypes.h b/include/androidfw/ResourceTypes.h
index 6813c89..05596f0 100644
--- a/include/androidfw/ResourceTypes.h
+++ b/include/androidfw/ResourceTypes.h
@@ -35,6 +35,8 @@
#include <android/configuration.h>
+#include <memory>
+
namespace android {
/**
@@ -1876,9 +1878,30 @@
struct Entry;
struct Package;
struct PackageGroup;
- struct bag_set;
typedef Vector<Type*> TypeList;
+ struct bag_set {
+ size_t numAttrs; // number in array
+ size_t availAttrs; // total space in array
+ uint32_t typeSpecFlags;
+ // Followed by 'numAttr' bag_entry structures.
+ };
+
+ /**
+ * Configuration dependent cached data. This must be cleared when the configuration is
+ * changed (setParameters).
+ */
+ struct TypeCacheEntry {
+ TypeCacheEntry() : cachedBags(NULL) {}
+
+ // Computed attribute bags for this type.
+ bag_set** cachedBags;
+
+ // Pre-filtered list of configurations (per asset path) that match the parameters set on this
+ // ResTable.
+ Vector<std::shared_ptr<Vector<const ResTable_type*>>> filteredConfigs;
+ };
+
status_t addInternal(const void* data, size_t size, const void* idmapData, size_t idmapDataSize,
bool appAsLib, const int32_t cookie, bool copyData, bool isSystemAsset=false);
@@ -1900,6 +1923,13 @@
mutable Mutex mLock;
+ // Mutex that controls access to the list of pre-filtered configurations
+ // to check when looking up entries.
+ // When iterating over a bag, the mLock mutex is locked. While mLock is locked,
+ // we do resource lookups.
+ // Mutex is not reentrant, so we must use a different lock than mLock.
+ mutable Mutex mFilteredConfigLock;
+
status_t mError;
ResTable_config mParams;
diff --git a/libs/androidfw/ResourceTypes.cpp b/libs/androidfw/ResourceTypes.cpp
index bf6ff11..52fe973 100644
--- a/libs/androidfw/ResourceTypes.cpp
+++ b/libs/androidfw/ResourceTypes.cpp
@@ -25,6 +25,7 @@
#include <string.h>
#include <limits>
+#include <memory>
#include <type_traits>
#include <androidfw/ByteBucketArray.h>
@@ -3193,7 +3194,6 @@
, name(_name)
, id(_id)
, largestTypeId(0)
- , bags(NULL)
, dynamicRefTable(static_cast<uint8_t>(_id), appAsLib)
, isSystemAsset(_isSystemAsset)
{ }
@@ -3220,36 +3220,41 @@
}
}
+ /**
+ * Clear all cache related data that depends on parameters/configuration.
+ * This includes the bag caches and filtered types.
+ */
void clearBagCache() {
- if (bags) {
+ for (size_t i = 0; i < typeCacheEntries.size(); i++) {
if (kDebugTableNoisy) {
- printf("bags=%p\n", bags);
+ printf("type=%zu\n", i);
}
- for (size_t i = 0; i < bags->size(); i++) {
+ const TypeList& typeList = types[i];
+ if (!typeList.isEmpty()) {
+ TypeCacheEntry& cacheEntry = typeCacheEntries.editItemAt(i);
+
+ // Reset the filtered configurations.
+ cacheEntry.filteredConfigs.clear();
+
+ bag_set** typeBags = cacheEntry.cachedBags;
if (kDebugTableNoisy) {
- printf("type=%zu\n", i);
+ printf("typeBags=%p\n", typeBags);
}
- const TypeList& typeList = types[i];
- if (!typeList.isEmpty()) {
- bag_set** typeBags = bags->get(i);
+
+ if (typeBags) {
+ const size_t N = typeList[0]->entryCount;
if (kDebugTableNoisy) {
- printf("typeBags=%p\n", typeBags);
+ printf("type->entryCount=%zu\n", N);
}
- if (typeBags) {
- const size_t N = typeList[0]->entryCount;
- if (kDebugTableNoisy) {
- printf("type->entryCount=%zu\n", N);
+ for (size_t j = 0; j < N; j++) {
+ if (typeBags[j] && typeBags[j] != (bag_set*)0xFFFFFFFF) {
+ free(typeBags[j]);
}
- for (size_t j = 0; j < N; j++) {
- if (typeBags[j] && typeBags[j] != (bag_set*)0xFFFFFFFF)
- free(typeBags[j]);
- }
- free(typeBags);
}
+ free(typeBags);
+ cacheEntry.cachedBags = NULL;
}
}
- delete bags;
- bags = NULL;
}
}
@@ -3277,9 +3282,11 @@
uint8_t largestTypeId;
- // Computed attribute bags, first indexed by the type and second
- // by the entry in that type.
- ByteBucketArray<bag_set**>* bags;
+ // Cached objects dependent on the parameters/configuration of this ResTable.
+ // Gets cleared whenever the parameters/configuration changes.
+ // These are stored here in a parallel structure because the data in `types` may
+ // be shared by other ResTable's (framework resources are shared this way).
+ ByteBucketArray<TypeCacheEntry> typeCacheEntries;
// The table mapping dynamic references to resolved references for
// this package group.
@@ -3293,14 +3300,6 @@
const bool isSystemAsset;
};
-struct ResTable::bag_set
-{
- size_t numAttrs; // number in array
- size_t availAttrs; // total space in array
- uint32_t typeSpecFlags;
- // Followed by 'numAttr' bag_entry structures.
-};
-
ResTable::Theme::Theme(const ResTable& table)
: mTable(table)
, mTypeSpecFlags(0)
@@ -4192,39 +4191,32 @@
}
// First see if we've already computed this bag...
- if (grp->bags) {
- bag_set** typeSet = grp->bags->get(t);
- if (typeSet) {
- bag_set* set = typeSet[e];
- if (set) {
- if (set != (bag_set*)0xFFFFFFFF) {
- if (outTypeSpecFlags != NULL) {
- *outTypeSpecFlags = set->typeSpecFlags;
- }
- *outBag = (bag_entry*)(set+1);
- if (kDebugTableSuperNoisy) {
- ALOGI("Found existing bag for: 0x%x\n", resID);
- }
- return set->numAttrs;
+ TypeCacheEntry& cacheEntry = grp->typeCacheEntries.editItemAt(t);
+ bag_set** typeSet = cacheEntry.cachedBags;
+ if (typeSet) {
+ bag_set* set = typeSet[e];
+ if (set) {
+ if (set != (bag_set*)0xFFFFFFFF) {
+ if (outTypeSpecFlags != NULL) {
+ *outTypeSpecFlags = set->typeSpecFlags;
}
- ALOGW("Attempt to retrieve bag 0x%08x which is invalid or in a cycle.",
- resID);
- return BAD_INDEX;
+ *outBag = (bag_entry*)(set+1);
+ if (kDebugTableSuperNoisy) {
+ ALOGI("Found existing bag for: 0x%x\n", resID);
+ }
+ return set->numAttrs;
}
+ ALOGW("Attempt to retrieve bag 0x%08x which is invalid or in a cycle.",
+ resID);
+ return BAD_INDEX;
}
}
// Bag not found, we need to compute it!
- if (!grp->bags) {
- grp->bags = new ByteBucketArray<bag_set**>();
- if (!grp->bags) return NO_MEMORY;
- }
-
- bag_set** typeSet = grp->bags->get(t);
if (!typeSet) {
typeSet = (bag_set**)calloc(NENTRY, sizeof(bag_set*));
if (!typeSet) return NO_MEMORY;
- grp->bags->set(t, typeSet);
+ cacheEntry.cachedBags = typeSet;
}
// Mark that we are currently working on this one.
@@ -4430,18 +4422,56 @@
void ResTable::setParameters(const ResTable_config* params)
{
- mLock.lock();
+ AutoMutex _lock(mLock);
+ AutoMutex _lock2(mFilteredConfigLock);
+
if (kDebugTableGetEntry) {
ALOGI("Setting parameters: %s\n", params->toString().string());
}
mParams = *params;
- for (size_t i=0; i<mPackageGroups.size(); i++) {
+ for (size_t p = 0; p < mPackageGroups.size(); p++) {
+ PackageGroup* packageGroup = mPackageGroups.editItemAt(p);
if (kDebugTableNoisy) {
- ALOGI("CLEARING BAGS FOR GROUP %zu!", i);
+ ALOGI("CLEARING BAGS FOR GROUP %zu!", p);
}
- mPackageGroups[i]->clearBagCache();
+ packageGroup->clearBagCache();
+
+ // Find which configurations match the set of parameters. This allows for a much
+ // faster lookup in getEntry() if the set of values is narrowed down.
+ for (size_t t = 0; t < packageGroup->types.size(); t++) {
+ if (packageGroup->types[t].isEmpty()) {
+ continue;
+ }
+
+ TypeList& typeList = packageGroup->types.editItemAt(t);
+
+ // Retrieve the cache entry for this type.
+ TypeCacheEntry& cacheEntry = packageGroup->typeCacheEntries.editItemAt(t);
+
+ for (size_t ts = 0; ts < typeList.size(); ts++) {
+ Type* type = typeList.editItemAt(ts);
+
+ std::shared_ptr<Vector<const ResTable_type*>> newFilteredConfigs =
+ std::make_shared<Vector<const ResTable_type*>>();
+
+ for (size_t ti = 0; ti < type->configs.size(); ti++) {
+ ResTable_config config;
+ config.copyFromDtoH(type->configs[ti]->config);
+
+ if (config.match(mParams)) {
+ newFilteredConfigs->add(type->configs[ti]);
+ }
+ }
+
+ if (kDebugTableNoisy) {
+ ALOGD("Updating pkg=%zu type=%zu with %zu filtered configs",
+ p, t, newFilteredConfigs->size());
+ }
+
+ cacheEntry.filteredConfigs.add(newFilteredConfigs);
+ }
+ }
}
- mLock.unlock();
}
void ResTable::getParameters(ResTable_config* params) const
@@ -5974,9 +6004,32 @@
specFlags = -1;
}
- const size_t numConfigs = typeSpec->configs.size();
+ const Vector<const ResTable_type*>* candidateConfigs = &typeSpec->configs;
+
+ std::shared_ptr<Vector<const ResTable_type*>> filteredConfigs;
+ if (config && memcmp(&mParams, config, sizeof(mParams)) == 0) {
+ // Grab the lock first so we can safely get the current filtered list.
+ AutoMutex _lock(mFilteredConfigLock);
+
+ // This configuration is equal to the one we have previously cached for,
+ // so use the filtered configs.
+
+ const TypeCacheEntry& cacheEntry = packageGroup->typeCacheEntries[typeIndex];
+ if (i < cacheEntry.filteredConfigs.size()) {
+ if (cacheEntry.filteredConfigs[i]) {
+ // Grab a reference to the shared_ptr so it doesn't get destroyed while
+ // going through this list.
+ filteredConfigs = cacheEntry.filteredConfigs[i];
+
+ // Use this filtered list.
+ candidateConfigs = filteredConfigs.get();
+ }
+ }
+ }
+
+ const size_t numConfigs = candidateConfigs->size();
for (size_t c = 0; c < numConfigs; c++) {
- const ResTable_type* const thisType = typeSpec->configs[c];
+ const ResTable_type* const thisType = candidateConfigs->itemAt(c);
if (thisType == NULL) {
continue;
}
diff --git a/libs/androidfw/tests/ResTable_test.cpp b/libs/androidfw/tests/ResTable_test.cpp
index dcfe91e..7cd7fb5 100644
--- a/libs/androidfw/tests/ResTable_test.cpp
+++ b/libs/androidfw/tests/ResTable_test.cpp
@@ -282,4 +282,46 @@
testU16StringToInt(u"0x1ffffffff", 0U, false, true);
}
+TEST(ResTableTest, ShareButDontModifyResTable) {
+ ResTable sharedTable;
+ ASSERT_EQ(NO_ERROR, sharedTable.add(basic_arsc, basic_arsc_len));
+
+ ResTable_config param;
+ memset(¶m, 0, sizeof(param));
+ param.language[0] = 'v';
+ param.language[1] = 's';
+ sharedTable.setParameters(¶m);
+
+ // Check that we get the default value for @integer:number1
+ Res_value val;
+ ssize_t block = sharedTable.getResource(base::R::integer::number1, &val, MAY_NOT_BE_BAG);
+ ASSERT_GE(block, 0);
+ ASSERT_EQ(Res_value::TYPE_INT_DEC, val.dataType);
+ ASSERT_EQ(uint32_t(600), val.data);
+
+ // Create a new table that shares the entries of the shared table.
+ ResTable table;
+ ASSERT_EQ(NO_ERROR, table.add(&sharedTable, false));
+
+ // Set a new configuration on the new table.
+ memset(¶m, 0, sizeof(param));
+ param.language[0] = 's';
+ param.language[1] = 'v';
+ param.country[0] = 'S';
+ param.country[1] = 'E';
+ table.setParameters(¶m);
+
+ // Check that we get a new value in the new table.
+ block = table.getResource(base::R::integer::number1, &val, MAY_NOT_BE_BAG);
+ ASSERT_GE(block, 0);
+ ASSERT_EQ(Res_value::TYPE_INT_DEC, val.dataType);
+ ASSERT_EQ(uint32_t(400), val.data);
+
+ // Check that we still get the old value in the shared table.
+ block = sharedTable.getResource(base::R::integer::number1, &val, MAY_NOT_BE_BAG);
+ ASSERT_GE(block, 0);
+ ASSERT_EQ(Res_value::TYPE_INT_DEC, val.dataType);
+ ASSERT_EQ(uint32_t(600), val.data);
}
+
+} // namespace
diff --git a/libs/androidfw/tests/data/basic/R.h b/libs/androidfw/tests/data/basic/R.h
index aaac740..6694dd0 100644
--- a/libs/androidfw/tests/data/basic/R.h
+++ b/libs/androidfw/tests/data/basic/R.h
@@ -46,7 +46,7 @@
namespace integer {
enum {
- number1 = 0x7f040000, // default, sv
+ number1 = 0x7f040000, // default, sv, vs
number2 = 0x7f040001, // default
test3 = 0x7f090000, // default (in feature)
diff --git a/libs/androidfw/tests/data/basic/basic_arsc.h b/libs/androidfw/tests/data/basic/basic_arsc.h
index 13ab4fa..e497401 100644
--- a/libs/androidfw/tests/data/basic/basic_arsc.h
+++ b/libs/androidfw/tests/data/basic/basic_arsc.h
@@ -1,5 +1,5 @@
unsigned char basic_arsc[] = {
- 0x02, 0x00, 0x0c, 0x00, 0x68, 0x07, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x02, 0x00, 0x0c, 0x00, 0x0c, 0x08, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x01, 0x00, 0x1c, 0x00, 0xbc, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x00, 0x00,
@@ -16,7 +16,7 @@
0x00, 0x00, 0x05, 0x00, 0x74, 0x00, 0x65, 0x00, 0x73, 0x00, 0x74, 0x00,
0x31, 0x00, 0x00, 0x00, 0x05, 0x00, 0x74, 0x00, 0x65, 0x00, 0x73, 0x00,
0x74, 0x00, 0x32, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x01,
- 0xa0, 0x06, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x63, 0x00, 0x6f, 0x00,
+ 0x44, 0x07, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x63, 0x00, 0x6f, 0x00,
0x6d, 0x00, 0x2e, 0x00, 0x61, 0x00, 0x6e, 0x00, 0x64, 0x00, 0x72, 0x00,
0x6f, 0x00, 0x69, 0x00, 0x64, 0x00, 0x2e, 0x00, 0x74, 0x00, 0x65, 0x00,
0x73, 0x00, 0x74, 0x00, 0x2e, 0x00, 0x62, 0x00, 0x61, 0x00, 0x73, 0x00,
@@ -73,68 +73,81 @@
0x41, 0x00, 0x72, 0x00, 0x72, 0x00, 0x61, 0x00, 0x79, 0x00, 0x31, 0x00,
0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x10, 0x00, 0x18, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x44, 0x00, 0x84, 0x00, 0x00, 0x00,
- 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00,
- 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x4c, 0x00, 0x8c, 0x00, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00,
+ 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x10, 0x00, 0x01, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x1c, 0x00, 0x00, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
+ 0x08, 0x00, 0x00, 0x10, 0x05, 0x00, 0x00, 0x00, 0x10, 0x00, 0x01, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x01, 0x08, 0x00, 0x00, 0x10, 0x05, 0x00, 0x00, 0x00,
- 0x10, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x08, 0x00, 0x00, 0x10,
- 0x05, 0x00, 0x00, 0x00, 0x02, 0x02, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00,
- 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x24, 0x00, 0x00,
- 0x01, 0x02, 0x44, 0x00, 0x58, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
- 0x01, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00,
+ 0x02, 0x02, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x04, 0x24, 0x00, 0x00, 0x01, 0x02, 0x4c, 0x00,
+ 0x60, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x50, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x08, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x03,
- 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x44, 0x00, 0x58, 0x00, 0x00, 0x00,
- 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00,
- 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x72, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x58, 0x02, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
+ 0x08, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x4c, 0x00,
+ 0x60, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x50, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x66, 0x72, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x58, 0x02,
+ 0x00, 0x00, 0x00, 0x00, 0x4c, 0x61, 0x74, 0x6e, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
0x08, 0x00, 0x00, 0x03, 0x01, 0x00, 0x00, 0x00, 0x02, 0x02, 0x10, 0x00,
0x1c, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x01, 0x02, 0x44, 0x00, 0x70, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
- 0x03, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00,
+ 0x01, 0x02, 0x4c, 0x00, 0x78, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
+ 0x03, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x10, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x08, 0x00, 0x00, 0x00,
- 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x03, 0x02, 0x00, 0x00, 0x00,
- 0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x03,
- 0x03, 0x00, 0x00, 0x00, 0x02, 0x02, 0x10, 0x00, 0x18, 0x00, 0x00, 0x00,
- 0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x44, 0x00, 0x6c, 0x00, 0x00, 0x00,
- 0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00,
- 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
+ 0xff, 0xff, 0xff, 0xff, 0x08, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
+ 0x08, 0x00, 0x00, 0x03, 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
+ 0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, 0x00,
+ 0x02, 0x02, 0x10, 0x00, 0x18, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x01, 0x02, 0x4c, 0x00, 0x74, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
- 0x05, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x10, 0xc8, 0x00, 0x00, 0x00,
- 0x08, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x01,
- 0x00, 0x00, 0x06, 0x7f, 0x01, 0x02, 0x44, 0x00, 0x5c, 0x00, 0x00, 0x00,
- 0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00,
- 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x73, 0x76, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
+ 0x08, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x10,
+ 0xc8, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
+ 0x08, 0x00, 0x00, 0x01, 0x00, 0x00, 0x06, 0x7f, 0x01, 0x02, 0x4c, 0x00,
+ 0x64, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
+ 0x54, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x76, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x08, 0x00, 0x00, 0x00,
- 0x05, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x10, 0x90, 0x01, 0x00, 0x00,
- 0x02, 0x02, 0x10, 0x00, 0x18, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
- 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x01, 0x02, 0x44, 0x00, 0x90, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
- 0x02, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00,
+ 0x05, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x10, 0x58, 0x02, 0x00, 0x00,
+ 0x01, 0x02, 0x4c, 0x00, 0x64, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x73, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4c, 0x61, 0x74, 0x6e,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
+ 0x08, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x10,
+ 0x90, 0x01, 0x00, 0x00, 0x02, 0x02, 0x10, 0x00, 0x18, 0x00, 0x00, 0x00,
+ 0x05, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x4c, 0x00, 0x98, 0x00, 0x00, 0x00,
+ 0x05, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00,
+ 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -146,16 +159,17 @@
0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x7f, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x01, 0x7f, 0x08, 0x00, 0x00, 0x10, 0x2c, 0x01, 0x00, 0x00,
0x02, 0x02, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
- 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x44, 0x00,
- 0x7c, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
- 0x48, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x4c, 0x00,
+ 0x84, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x50, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x01, 0x00,
- 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x02, 0x08, 0x00, 0x00, 0x10, 0x01, 0x00, 0x00, 0x00,
- 0x01, 0x00, 0x00, 0x02, 0x08, 0x00, 0x00, 0x10, 0x02, 0x00, 0x00, 0x00,
- 0x02, 0x00, 0x00, 0x02, 0x08, 0x00, 0x00, 0x10, 0x03, 0x00, 0x00, 0x00
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x01, 0x00, 0x09, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
+ 0x08, 0x00, 0x00, 0x10, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x02,
+ 0x08, 0x00, 0x00, 0x10, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x02,
+ 0x08, 0x00, 0x00, 0x10, 0x03, 0x00, 0x00, 0x00
};
-unsigned int basic_arsc_len = 1896;
+unsigned int basic_arsc_len = 2060;
diff --git a/libs/androidfw/tests/data/basic/res/values-vs/values.xml b/libs/androidfw/tests/data/basic/res/values-vs/values.xml
new file mode 100644
index 0000000..4a5a640
--- /dev/null
+++ b/libs/androidfw/tests/data/basic/res/values-vs/values.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<resources>
+ <integer name="number1">600</integer>
+</resources>
diff --git a/libs/androidfw/tests/data/basic/split_de_fr_arsc.h b/libs/androidfw/tests/data/basic/split_de_fr_arsc.h
index b742d28..a2aa598 100644
--- a/libs/androidfw/tests/data/basic/split_de_fr_arsc.h
+++ b/libs/androidfw/tests/data/basic/split_de_fr_arsc.h
@@ -1,5 +1,5 @@
unsigned char split_de_fr_arsc[] = {
- 0x02, 0x00, 0x0c, 0x00, 0xe4, 0x03, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x02, 0x00, 0x0c, 0x00, 0xf4, 0x03, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x01, 0x00, 0x1c, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00,
@@ -10,7 +10,7 @@
0x32, 0x00, 0x00, 0x00, 0x07, 0x00, 0x65, 0x00, 0x73, 0x00, 0x73, 0x00,
0x61, 0x00, 0x69, 0x00, 0x20, 0x00, 0x31, 0x00, 0x00, 0x00, 0x07, 0x00,
0x65, 0x00, 0x73, 0x00, 0x73, 0x00, 0x61, 0x00, 0x69, 0x00, 0x20, 0x00,
- 0x32, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x01, 0x5c, 0x03, 0x00, 0x00,
+ 0x32, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x01, 0x6c, 0x03, 0x00, 0x00,
0x7f, 0x00, 0x00, 0x00, 0x63, 0x00, 0x6f, 0x00, 0x6d, 0x00, 0x2e, 0x00,
0x61, 0x00, 0x6e, 0x00, 0x64, 0x00, 0x72, 0x00, 0x6f, 0x00, 0x69, 0x00,
0x64, 0x00, 0x2e, 0x00, 0x74, 0x00, 0x65, 0x00, 0x73, 0x00, 0x74, 0x00,
@@ -57,30 +57,32 @@
0x14, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x00,
0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
- 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x44, 0x00,
- 0x70, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
- 0x50, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x4c, 0x00,
+ 0x78, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
+ 0x58, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x64, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x4c, 0x61, 0x74, 0x6e, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
+ 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x03,
+ 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x08, 0x00, 0x00, 0x03, 0x01, 0x00, 0x00, 0x00, 0x01, 0x02, 0x4c, 0x00,
+ 0x78, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
+ 0x58, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x66, 0x72, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
- 0xff, 0xff, 0xff, 0xff, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x08, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
- 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x03, 0x01, 0x00, 0x00, 0x00,
- 0x01, 0x02, 0x44, 0x00, 0x70, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
- 0x03, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x66, 0x72, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x10, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x08, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x03, 0x02, 0x00, 0x00, 0x00,
- 0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x03,
- 0x03, 0x00, 0x00, 0x00, 0x02, 0x02, 0x10, 0x00, 0x18, 0x00, 0x00, 0x00,
- 0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x10, 0x00, 0x18, 0x00, 0x00, 0x00,
- 0x05, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00,
- 0x06, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+ 0x00, 0x00, 0x00, 0x00, 0x4c, 0x61, 0x74, 0x6e, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
+ 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x03,
+ 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x08, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, 0x00, 0x02, 0x02, 0x10, 0x00,
+ 0x18, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x10, 0x00,
+ 0x18, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x10, 0x00,
+ 0x14, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00
};
-unsigned int split_de_fr_arsc_len = 996;
+unsigned int split_de_fr_arsc_len = 1012;
diff --git a/libs/androidfw/tests/data/basic/split_hdpi_v4_arsc.h b/libs/androidfw/tests/data/basic/split_hdpi_v4_arsc.h
index e9fb7ea..0cc3915 100644
--- a/libs/androidfw/tests/data/basic/split_hdpi_v4_arsc.h
+++ b/libs/androidfw/tests/data/basic/split_hdpi_v4_arsc.h
@@ -1,10 +1,10 @@
unsigned char split_hdpi_v4_arsc[] = {
- 0x02, 0x00, 0x0c, 0x00, 0x08, 0x03, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x02, 0x00, 0x0c, 0x00, 0x10, 0x03, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x01, 0x00, 0x1c, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x68, 0x00,
0x64, 0x00, 0x70, 0x00, 0x69, 0x00, 0x00, 0x00, 0x00, 0x02, 0x20, 0x01,
- 0xd0, 0x02, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x63, 0x00, 0x6f, 0x00,
+ 0xd8, 0x02, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x63, 0x00, 0x6f, 0x00,
0x6d, 0x00, 0x2e, 0x00, 0x61, 0x00, 0x6e, 0x00, 0x64, 0x00, 0x72, 0x00,
0x6f, 0x00, 0x69, 0x00, 0x64, 0x00, 0x2e, 0x00, 0x74, 0x00, 0x65, 0x00,
0x73, 0x00, 0x74, 0x00, 0x2e, 0x00, 0x62, 0x00, 0x61, 0x00, 0x73, 0x00,
@@ -50,19 +50,20 @@
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x10, 0x00,
0x1c, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x01, 0x02, 0x44, 0x00, 0x60, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
- 0x03, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00,
+ 0x01, 0x02, 0x4c, 0x00, 0x68, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
+ 0x03, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
- 0x02, 0x02, 0x10, 0x00, 0x18, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
- 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x02, 0x02, 0x10, 0x00, 0x18, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
- 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x02, 0x02, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
- 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x08, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x10, 0x00,
+ 0x18, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x10, 0x00,
+ 0x18, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x10, 0x00,
+ 0x14, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00
};
-unsigned int split_hdpi_v4_arsc_len = 776;
+unsigned int split_hdpi_v4_arsc_len = 784;
diff --git a/libs/androidfw/tests/data/basic/split_xhdpi_v4_arsc.h b/libs/androidfw/tests/data/basic/split_xhdpi_v4_arsc.h
index 7835f71..d44ba96 100644
--- a/libs/androidfw/tests/data/basic/split_xhdpi_v4_arsc.h
+++ b/libs/androidfw/tests/data/basic/split_xhdpi_v4_arsc.h
@@ -1,10 +1,10 @@
unsigned char split_xhdpi_v4_arsc[] = {
- 0x02, 0x00, 0x0c, 0x00, 0x0c, 0x03, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x02, 0x00, 0x0c, 0x00, 0x14, 0x03, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x01, 0x00, 0x1c, 0x00, 0x30, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x78, 0x00,
0x68, 0x00, 0x64, 0x00, 0x70, 0x00, 0x69, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x02, 0x20, 0x01, 0xd0, 0x02, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00,
+ 0x00, 0x02, 0x20, 0x01, 0xd8, 0x02, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00,
0x63, 0x00, 0x6f, 0x00, 0x6d, 0x00, 0x2e, 0x00, 0x61, 0x00, 0x6e, 0x00,
0x64, 0x00, 0x72, 0x00, 0x6f, 0x00, 0x69, 0x00, 0x64, 0x00, 0x2e, 0x00,
0x74, 0x00, 0x65, 0x00, 0x73, 0x00, 0x74, 0x00, 0x2e, 0x00, 0x62, 0x00,
@@ -50,19 +50,20 @@
0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x02, 0x02, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x44, 0x00, 0x60, 0x00, 0x00, 0x00,
- 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00,
- 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x4c, 0x00, 0x68, 0x00, 0x00, 0x00,
+ 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00,
+ 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x40, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
- 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x03,
- 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x10, 0x00, 0x18, 0x00, 0x00, 0x00,
- 0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x10, 0x00, 0x18, 0x00, 0x00, 0x00,
- 0x05, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00,
- 0x06, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
+ 0x02, 0x02, 0x10, 0x00, 0x18, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x02, 0x02, 0x10, 0x00, 0x18, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x02, 0x02, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
-unsigned int split_xhdpi_v4_arsc_len = 780;
+unsigned int split_xhdpi_v4_arsc_len = 788;
diff --git a/libs/androidfw/tests/data/basic/split_xxhdpi_v4_arsc.h b/libs/androidfw/tests/data/basic/split_xxhdpi_v4_arsc.h
index f805db1..2f3f682 100644
--- a/libs/androidfw/tests/data/basic/split_xxhdpi_v4_arsc.h
+++ b/libs/androidfw/tests/data/basic/split_xxhdpi_v4_arsc.h
@@ -1,10 +1,10 @@
unsigned char split_xxhdpi_v4_arsc[] = {
- 0x02, 0x00, 0x0c, 0x00, 0x0c, 0x03, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x02, 0x00, 0x0c, 0x00, 0x14, 0x03, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x01, 0x00, 0x1c, 0x00, 0x30, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x78, 0x00,
0x78, 0x00, 0x68, 0x00, 0x64, 0x00, 0x70, 0x00, 0x69, 0x00, 0x00, 0x00,
- 0x00, 0x02, 0x20, 0x01, 0xd0, 0x02, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00,
+ 0x00, 0x02, 0x20, 0x01, 0xd8, 0x02, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00,
0x63, 0x00, 0x6f, 0x00, 0x6d, 0x00, 0x2e, 0x00, 0x61, 0x00, 0x6e, 0x00,
0x64, 0x00, 0x72, 0x00, 0x6f, 0x00, 0x69, 0x00, 0x64, 0x00, 0x2e, 0x00,
0x74, 0x00, 0x65, 0x00, 0x73, 0x00, 0x74, 0x00, 0x2e, 0x00, 0x62, 0x00,
@@ -50,19 +50,20 @@
0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x02, 0x02, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x44, 0x00, 0x60, 0x00, 0x00, 0x00,
- 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00,
- 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x4c, 0x00, 0x68, 0x00, 0x00, 0x00,
+ 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00,
+ 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xe0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
- 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x03,
- 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x10, 0x00, 0x18, 0x00, 0x00, 0x00,
- 0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x10, 0x00, 0x18, 0x00, 0x00, 0x00,
- 0x05, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00,
- 0x06, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
+ 0x02, 0x02, 0x10, 0x00, 0x18, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x02, 0x02, 0x10, 0x00, 0x18, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x02, 0x02, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
-unsigned int split_xxhdpi_v4_arsc_len = 780;
+unsigned int split_xxhdpi_v4_arsc_len = 788;
diff --git a/libs/hwui/RecordingCanvas.cpp b/libs/hwui/RecordingCanvas.cpp
index ddf0528..f0c79d7 100644
--- a/libs/hwui/RecordingCanvas.cpp
+++ b/libs/hwui/RecordingCanvas.cpp
@@ -24,8 +24,8 @@
namespace android {
namespace uirenderer {
-
-static Rect sUnreasonablyLargeBounds(-10000, -10000, 10000, 10000);
+#define MIL_PIX 1000000
+static Rect sUnreasonablyLargeBounds(-MIL_PIX, -MIL_PIX, MIL_PIX, MIL_PIX);
static const Rect& getConservativeOpBounds(const ClipBase* clip) {
// if op is clipped, that rect can be used, but otherwise just use a conservatively large rect
@@ -564,15 +564,17 @@
getRecordedClip(),
renderNode);
int opIndex = addOp(op);
- int childIndex = mDisplayList->addChild(op);
+ if (CC_LIKELY(opIndex >= 0)) {
+ int childIndex = mDisplayList->addChild(op);
- // update the chunk's child indices
- DisplayList::Chunk& chunk = mDisplayList->chunks.back();
- chunk.endChildIndex = childIndex + 1;
+ // update the chunk's child indices
+ DisplayList::Chunk& chunk = mDisplayList->chunks.back();
+ chunk.endChildIndex = childIndex + 1;
- if (renderNode->stagingProperties().isProjectionReceiver()) {
- // use staging property, since recording on UI thread
- mDisplayList->projectionReceiveIndex = opIndex;
+ if (renderNode->stagingProperties().isProjectionReceiver()) {
+ // use staging property, since recording on UI thread
+ mDisplayList->projectionReceiveIndex = opIndex;
+ }
}
}
@@ -595,7 +597,7 @@
mDisplayList->functors.push_back(functor);
auto clip = getRecordedClip();
addOp(alloc().create_trivial<FunctorOp>(
- getConservativeOpBounds(clip), // TODO: explicitly define bounds
+ getConservativeOpBounds(clip),
*(mState.currentSnapshot()->transform),
clip,
functor));
diff --git a/libs/hwui/tests/unit/FrameBuilderTests.cpp b/libs/hwui/tests/unit/FrameBuilderTests.cpp
index 4c56a22..f147fd4 100644
--- a/libs/hwui/tests/unit/FrameBuilderTests.cpp
+++ b/libs/hwui/tests/unit/FrameBuilderTests.cpp
@@ -349,6 +349,29 @@
EXPECT_EQ(1, renderer.getIndex());
}
+TEST(FrameBuilder, functor_reject) {
+ class FunctorTestRenderer : public TestRendererBase {
+ public:
+ void onFunctorOp(const FunctorOp& op, const BakedOpState& state) override {
+ EXPECT_EQ(0, mIndex++);
+ }
+ };
+ Functor noopFunctor;
+
+ // 1 million pixel tall view, scrolled down 80%
+ auto scrolledFunctorView = TestUtils::createNode(0, 0, 400, 1000000,
+ [&noopFunctor](RenderProperties& props, RecordingCanvas& canvas) {
+ canvas.translate(0, -800000);
+ canvas.callDrawGLFunction(&noopFunctor);
+ });
+
+ FrameBuilder frameBuilder(sEmptyLayerUpdateQueue, SkRect::MakeWH(200, 200), 200, 200,
+ TestUtils::createSyncedNodeList(scrolledFunctorView), sLightGeometry, nullptr);
+ FunctorTestRenderer renderer;
+ frameBuilder.replayBakedOps<TestDispatcher>(renderer);
+ EXPECT_EQ(1, renderer.getIndex()) << "Functor should not be rejected";
+}
+
TEST(FrameBuilder, renderNode) {
class RenderNodeTestRenderer : public TestRendererBase {
public:
@@ -391,6 +414,7 @@
TestUtils::createSyncedNodeList(parent), sLightGeometry, nullptr);
RenderNodeTestRenderer renderer;
frameBuilder.replayBakedOps<TestDispatcher>(renderer);
+ EXPECT_EQ(2, renderer.getIndex());
}
TEST(FrameBuilder, clipped) {
diff --git a/libs/hwui/tests/unit/RecordingCanvasTests.cpp b/libs/hwui/tests/unit/RecordingCanvasTests.cpp
index d35b1f9..c3165bb 100644
--- a/libs/hwui/tests/unit/RecordingCanvasTests.cpp
+++ b/libs/hwui/tests/unit/RecordingCanvasTests.cpp
@@ -451,6 +451,21 @@
EXPECT_EQ(3, count);
}
+TEST(RecordingCanvas, drawRenderNode_rejection) {
+ auto child = TestUtils::createNode(50, 50, 150, 150,
+ [](RenderProperties& props, RecordingCanvas& canvas) {
+ SkPaint paint;
+ paint.setColor(SK_ColorWHITE);
+ canvas.drawRect(0, 0, 100, 100, paint);
+ });
+
+ auto dl = TestUtils::createDisplayList<RecordingCanvas>(200, 200, [&child](RecordingCanvas& canvas) {
+ canvas.clipRect(0, 0, 0, 0, SkRegion::kIntersect_Op); // empty clip, reject node
+ canvas.drawRenderNode(child.get()); // shouldn't crash when rejecting node...
+ });
+ ASSERT_TRUE(dl->isEmpty());
+}
+
TEST(RecordingCanvas, drawRenderNode_projection) {
sp<RenderNode> background = TestUtils::createNode(50, 50, 150, 150,
[](RenderProperties& props, RecordingCanvas& canvas) {
diff --git a/media/java/android/media/ExifInterface.java b/media/java/android/media/ExifInterface.java
index 3fa078f..ce12e76 100644
--- a/media/java/android/media/ExifInterface.java
+++ b/media/java/android/media/ExifInterface.java
@@ -24,7 +24,6 @@
import android.system.Os;
import android.system.OsConstants;
import android.util.Log;
-import android.util.Pair;
import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
@@ -47,6 +46,7 @@
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
+import java.util.Set;
import java.util.TimeZone;
import java.util.regex.Pattern;
@@ -65,84 +65,267 @@
private static final boolean DEBUG = false;
// The Exif tag names
+ /** Type is String. */
+ public static final String TAG_ARTIST = "Artist";
/** Type is int. */
- public static final String TAG_ORIENTATION = "Orientation";
+ public static final String TAG_BITS_PER_SAMPLE = "BitsPerSample";
+ /** Type is int. */
+ public static final String TAG_COMPRESSION = "Compression";
+ /** Type is String. */
+ public static final String TAG_COPYRIGHT = "Copyright";
/** Type is String. */
public static final String TAG_DATETIME = "DateTime";
/** Type is String. */
+ public static final String TAG_IMAGE_DESCRIPTION = "ImageDescription";
+ /** Type is int. */
+ public static final String TAG_IMAGE_LENGTH = "ImageLength";
+ /** Type is int. */
+ public static final String TAG_IMAGE_WIDTH = "ImageWidth";
+ /** Type is int. */
+ public static final String TAG_JPEG_INTERCHANGE_FORMAT = "JPEGInterchangeFormat";
+ /** Type is int. */
+ public static final String TAG_JPEG_INTERCHANGE_FORMAT_LENGTH = "JPEGInterchangeFormatLength";
+ /** Type is String. */
public static final String TAG_MAKE = "Make";
/** Type is String. */
public static final String TAG_MODEL = "Model";
/** Type is int. */
- public static final String TAG_FLASH = "Flash";
+ public static final String TAG_ORIENTATION = "Orientation";
/** Type is int. */
- public static final String TAG_IMAGE_WIDTH = "ImageWidth";
+ public static final String TAG_PHOTOMETRIC_INTERPRETATION = "PhotometricInterpretation";
/** Type is int. */
- public static final String TAG_IMAGE_LENGTH = "ImageLength";
- /** String. Format is "num1/denom1,num2/denom2,num3/denom3". */
- public static final String TAG_GPS_LATITUDE = "GPSLatitude";
- /** String. Format is "num1/denom1,num2/denom2,num3/denom3". */
- public static final String TAG_GPS_LONGITUDE = "GPSLongitude";
+ public static final String TAG_PLANAR_CONFIGURATION = "PlanarConfiguration";
+ /** Type is rational. */
+ public static final String TAG_PRIMARY_CHROMATICITIES = "PrimaryChromaticities";
+ /** Type is rational. */
+ public static final String TAG_REFERENCE_BLACK_WHITE = "ReferenceBlackWhite";
+ /** Type is int. */
+ public static final String TAG_RESOLUTION_UNIT = "ResolutionUnit";
+ /** Type is int. */
+ public static final String TAG_ROWS_PER_STRIP = "RowsPerStrip";
+ /** Type is int. */
+ public static final String TAG_SAMPLES_PER_PIXEL = "SamplesPerPixel";
/** Type is String. */
- public static final String TAG_GPS_LATITUDE_REF = "GPSLatitudeRef";
+ public static final String TAG_SOFTWARE = "Software";
+ /** Type is int. */
+ public static final String TAG_STRIP_BYTE_COUNTS = "StripByteCounts";
+ /** Type is int. */
+ public static final String TAG_STRIP_OFFSETS = "StripOffsets";
+ /** Type is int. */
+ public static final String TAG_TRANSFER_FUNCTION = "TransferFunction";
+ /** Type is rational. */
+ public static final String TAG_WHITE_POINT = "WhitePoint";
+ /** Type is rational. */
+ public static final String TAG_X_RESOLUTION = "XResolution";
+ /** Type is rational. */
+ public static final String TAG_Y_CB_CR_COEFFICIENTS = "YCbCrCoefficients";
+ /** Type is int. */
+ public static final String TAG_Y_CB_CR_POSITIONING = "YCbCrPositioning";
+ /** Type is int. */
+ public static final String TAG_Y_CB_CR_SUB_SAMPLING = "YCbCrSubSampling";
+ /** Type is rational. */
+ public static final String TAG_Y_RESOLUTION = "YResolution";
+ /** Type is rational. */
+ public static final String TAG_APERTURE_VALUE = "ApertureValue";
+ /** Type is rational. */
+ public static final String TAG_BRIGHTNESS_VALUE = "BrightnessValue";
/** Type is String. */
- public static final String TAG_GPS_LONGITUDE_REF = "GPSLongitudeRef";
+ public static final String TAG_CFA_PATTERN = "CFAPattern";
+ /** Type is int. */
+ public static final String TAG_COLOR_SPACE = "ColorSpace";
/** Type is String. */
+ public static final String TAG_COMPONENTS_CONFIGURATION = "ComponentsConfiguration";
+ /** Type is rational. */
+ public static final String TAG_COMPRESSED_BITS_PER_PIXEL = "CompressedBitsPerPixel";
+ /** Type is int. */
+ public static final String TAG_CONTRAST = "Contrast";
+ /** Type is int. */
+ public static final String TAG_CUSTOM_RENDERED = "CustomRendered";
+ /** Type is String. */
+ public static final String TAG_DATETIME_DIGITIZED = "DateTimeDigitized";
+ /** Type is String. */
+ public static final String TAG_DATETIME_ORIGINAL = "DateTimeOriginal";
+ /** Type is String. */
+ public static final String TAG_DEVICE_SETTING_DESCRIPTION = "DeviceSettingDescription";
+ /** Type is double. */
+ public static final String TAG_DIGITAL_ZOOM_RATIO = "DigitalZoomRatio";
+ /** Type is String. */
+ public static final String TAG_EXIF_VERSION = "ExifVersion";
+ /** Type is double. */
+ public static final String TAG_EXPOSURE_BIAS_VALUE = "ExposureBiasValue";
+ /** Type is rational. */
+ public static final String TAG_EXPOSURE_INDEX = "ExposureIndex";
+ /** Type is int. */
+ public static final String TAG_EXPOSURE_MODE = "ExposureMode";
+ /** Type is int. */
+ public static final String TAG_EXPOSURE_PROGRAM = "ExposureProgram";
+ /** Type is double. */
public static final String TAG_EXPOSURE_TIME = "ExposureTime";
/** Type is String. */
+ public static final String TAG_F_NUMBER = "FNumber";
+ /** Type is String. */
public static final String TAG_APERTURE = "FNumber";
/** Type is String. */
+ public static final String TAG_FILE_SOURCE = "FileSource";
+ /** Type is int. */
+ public static final String TAG_FLASH = "Flash";
+ /** Type is rational. */
+ public static final String TAG_FLASH_ENERGY = "FlashEnergy";
+ /** Type is String. */
+ public static final String TAG_FLASHPIX_VERSION = "FlashpixVersion";
+ /** Type is rational. */
+ public static final String TAG_FOCAL_LENGTH = "FocalLength";
+ /** Type is int. */
+ public static final String TAG_FOCAL_LENGTH_IN_35MM_FILM = "FocalLengthIn35mmFilm";
+ /** Type is int. */
+ public static final String TAG_FOCAL_PLANE_RESOLUTION_UNIT = "FocalPlaneResolutionUnit";
+ /** Type is rational. */
+ public static final String TAG_FOCAL_PLANE_X_RESOLUTION = "FocalPlaneXResolution";
+ /** Type is rational. */
+ public static final String TAG_FOCAL_PLANE_Y_RESOLUTION = "FocalPlaneYResolution";
+ /** Type is rational. */
+ public static final String TAG_GAIN_CONTROL = "GainControl";
+ /** Type is String. */
+ public static final String TAG_ISO_SPEED_RATINGS = "ISOSpeedRatings";
+ /** Type is String. */
public static final String TAG_ISO = "ISOSpeedRatings";
/** Type is String. */
- public static final String TAG_DATETIME_DIGITIZED = "DateTimeDigitized";
+ public static final String TAG_IMAGE_UNIQUE_ID = "ImageUniqueID";
+ /** Type is int. */
+ public static final String TAG_LIGHT_SOURCE = "LightSource";
+ /** Type is String. */
+ public static final String TAG_MAKER_NOTE = "MakerNote";
+ /** Type is rational. */
+ public static final String TAG_MAX_APERTURE_VALUE = "MaxApertureValue";
+ /** Type is int. */
+ public static final String TAG_METERING_MODE = "MeteringMode";
+ /** Type is String. */
+ public static final String TAG_OECF = "OECF";
+ /** Type is int. */
+ public static final String TAG_PIXEL_X_DIMENSION = "PixelXDimension";
+ /** Type is int. */
+ public static final String TAG_PIXEL_Y_DIMENSION = "PixelYDimension";
+ /** Type is String. */
+ public static final String TAG_RELATED_SOUND_FILE = "RelatedSoundFile";
+ /** Type is int. */
+ public static final String TAG_SATURATION = "Saturation";
+ /** Type is int. */
+ public static final String TAG_SCENE_CAPTURE_TYPE = "SceneCaptureType";
+ /** Type is String. */
+ public static final String TAG_SCENE_TYPE = "SceneType";
+ /** Type is int. */
+ public static final String TAG_SENSING_METHOD = "SensingMethod";
+ /** Type is int. */
+ public static final String TAG_SHARPNESS = "Sharpness";
+ /** Type is rational. */
+ public static final String TAG_SHUTTER_SPEED_VALUE = "ShutterSpeedValue";
+ /** Type is String. */
+ public static final String TAG_SPATIAL_FREQUENCY_RESPONSE = "SpatialFrequencyResponse";
+ /** Type is String. */
+ public static final String TAG_SPECTRAL_SENSITIVITY = "SpectralSensitivity";
/** Type is int. */
public static final String TAG_SUBSEC_TIME = "SubSecTime";
+ /** Type is int. @hide */
+ public static final String TAG_SUBSECTIME = "SubSecTime";
+ /** Type is int. */
+ public static final String TAG_SUBSEC_TIME_DIGITIZED = "SubSecTimeDigitized";
+ /** Type is int. */
+ public static final String TAG_SUBSEC_TIME_DIG = "SubSecTimeDigitized";
/** Type is int. */
public static final String TAG_SUBSEC_TIME_ORIG = "SubSecTimeOriginal";
/** Type is int. */
- public static final String TAG_SUBSEC_TIME_DIG = "SubSecTimeDigitized";
-
- /**
- * @hide
- */
- public static final String TAG_SUBSECTIME = "SubSecTime";
-
+ public static final String TAG_SUBSEC_TIME_ORIGINAL = "SubSecTimeOriginal";
+ /** Type is int. */
+ public static final String TAG_SUBJECT_AREA = "SubjectArea";
+ /** Type is double. */
+ public static final String TAG_SUBJECT_DISTANCE = "SubjectDistance";
+ /** Type is int. */
+ public static final String TAG_SUBJECT_DISTANCE_RANGE = "SubjectDistanceRange";
+ /** Type is int. */
+ public static final String TAG_SUBJECT_LOCATION = "SubjectLocation";
+ /** Type is String. */
+ public static final String TAG_USER_COMMENT = "UserComment";
+ /** Type is int. */
+ public static final String TAG_WHITE_BALANCE = "WhiteBalance";
/**
* The altitude (in meters) based on the reference in TAG_GPS_ALTITUDE_REF.
* Type is rational.
*/
public static final String TAG_GPS_ALTITUDE = "GPSAltitude";
-
/**
* 0 if the altitude is above sea level. 1 if the altitude is below sea
* level. Type is int.
*/
public static final String TAG_GPS_ALTITUDE_REF = "GPSAltitudeRef";
-
/** Type is String. */
- public static final String TAG_GPS_TIMESTAMP = "GPSTimeStamp";
+ public static final String TAG_GPS_AREA_INFORMATION = "GPSAreaInformation";
+ /** Type is rational. */
+ public static final String TAG_GPS_DOP = "GPSDOP";
/** Type is String. */
public static final String TAG_GPS_DATESTAMP = "GPSDateStamp";
- /** Type is int. */
- public static final String TAG_WHITE_BALANCE = "WhiteBalance";
/** Type is rational. */
- public static final String TAG_FOCAL_LENGTH = "FocalLength";
+ public static final String TAG_GPS_DEST_BEARING = "GPSDestBearing";
+ /** Type is String. */
+ public static final String TAG_GPS_DEST_BEARING_REF = "GPSDestBearingRef";
+ /** Type is rational. */
+ public static final String TAG_GPS_DEST_DISTANCE = "GPSDestDistance";
+ /** Type is String. */
+ public static final String TAG_GPS_DEST_DISTANCE_REF = "GPSDestDistanceRef";
+ /** Type is rational. */
+ public static final String TAG_GPS_DEST_LATITUDE = "GPSDestLatitude";
+ /** Type is String. */
+ public static final String TAG_GPS_DEST_LATITUDE_REF = "GPSDestLatitudeRef";
+ /** Type is rational. */
+ public static final String TAG_GPS_DEST_LONGITUDE = "GPSDestLongitude";
+ /** Type is String. */
+ public static final String TAG_GPS_DEST_LONGITUDE_REF = "GPSDestLongitudeRef";
+ /** Type is int. */
+ public static final String TAG_GPS_DIFFERENTIAL = "GPSDifferential";
+ /** Type is rational. */
+ public static final String TAG_GPS_IMG_DIRECTION = "GPSImgDirection";
+ /** Type is String. */
+ public static final String TAG_GPS_IMG_DIRECTION_REF = "GPSImgDirectionRef";
+ /** String. Format is "num1/denom1,num2/denom2,num3/denom3". */
+ public static final String TAG_GPS_LATITUDE = "GPSLatitude";
+ /** Type is String. */
+ public static final String TAG_GPS_LATITUDE_REF = "GPSLatitudeRef";
+ /** String. Format is "num1/denom1,num2/denom2,num3/denom3". */
+ public static final String TAG_GPS_LONGITUDE = "GPSLongitude";
+ /** Type is String. */
+ public static final String TAG_GPS_LONGITUDE_REF = "GPSLongitudeRef";
+ /** Type is String. */
+ public static final String TAG_GPS_MAP_DATUM = "GPSMapDatum";
+ /** Type is String. */
+ public static final String TAG_GPS_MEASURE_MODE = "GPSMeasureMode";
/** Type is String. Name of GPS processing method used for location finding. */
public static final String TAG_GPS_PROCESSING_METHOD = "GPSProcessingMethod";
- /** Type is double. */
- public static final String TAG_DIGITAL_ZOOM_RATIO = "DigitalZoomRatio";
- /** Type is double. */
- public static final String TAG_SUBJECT_DISTANCE = "SubjectDistance";
- /** Type is double. */
- public static final String TAG_EXPOSURE_BIAS_VALUE = "ExposureBiasValue";
+ /** Type is String. */
+ public static final String TAG_GPS_SATELLITES = "GPSSatellites";
+ /** Type is rational. */
+ public static final String TAG_GPS_SPEED = "GPSSpeed";
+ /** Type is String. */
+ public static final String TAG_GPS_SPEED_REF = "GPSSpeedRef";
+ /** Type is String. */
+ public static final String TAG_GPS_STATUS = "GPSStatus";
+ /** Type is String. */
+ public static final String TAG_GPS_TIMESTAMP = "GPSTimeStamp";
+ /** Type is rational. */
+ public static final String TAG_GPS_TRACK = "GPSTrack";
+ /** Type is String. */
+ public static final String TAG_GPS_TRACK_REF = "GPSTrackRef";
+ /** Type is String. */
+ public static final String TAG_GPS_VERSION_ID = "GPSVersionID";
+ /** Type is String. */
+ public static final String TAG_INTEROPERABILITY_INDEX = "InteroperabilityIndex";
/** Type is int. */
- public static final String TAG_LIGHT_SOURCE = "LightSource";
+ public static final String TAG_THUMBNAIL_IMAGE_LENGTH = "ThumbnailImageLength";
/** Type is int. */
- public static final String TAG_METERING_MODE = "MeteringMode";
- /** Type is int. */
- public static final String TAG_EXPOSURE_PROGRAM = "ExposureProgram";
- /** Type is int. */
- public static final String TAG_EXPOSURE_MODE = "ExposureMode";
+ public static final String TAG_THUMBNAIL_IMAGE_WIDTH = "ThumbnailImageWidth";
+
+ // Private tags used for pointing the other IFD offset. The types of the following tags are int.
+ private static final String TAG_EXIF_IFD_POINTER = "ExifIFDPointer";
+ private static final String TAG_GPS_INFO_IFD_POINTER = "GPSInfoIFDPointer";
+ private static final String TAG_INTEROPERABILITY_IFD_POINTER = "InteroperabilityIFDPointer";
// Private tags used for thumbnail information.
private static final String TAG_HAS_THUMBNAIL = "hasThumbnail";
@@ -215,171 +398,171 @@
// Primary image IFD TIFF tags (See JEITA CP-3451 Table 14. page 54).
private static final ExifTag[] IFD_TIFF_TAGS = new ExifTag[] {
- new ExifTag("ImageWidth", 256),
- new ExifTag("ImageLength", 257),
- new ExifTag("BitsPerSample", 258),
- new ExifTag("Compression", 259),
- new ExifTag("PhotometricInterpretation", 262),
- new ExifTag("ImageDescription", 270),
- new ExifTag("Make", 271),
- new ExifTag("Model", 272),
- new ExifTag("StripOffsets", 273),
- new ExifTag("Orientation", 274),
- new ExifTag("SamplesPerPixel", 277),
- new ExifTag("RowsPerStrip", 278),
- new ExifTag("StripByteCounts", 279),
- new ExifTag("XResolution", 282),
- new ExifTag("YResolution", 283),
- new ExifTag("PlanarConfiguration", 284),
- new ExifTag("ResolutionUnit", 296),
- new ExifTag("TransferFunction", 301),
- new ExifTag("Software", 305),
- new ExifTag("DateTime", 306),
- new ExifTag("Artist", 315),
- new ExifTag("WhitePoint", 318),
- new ExifTag("PrimaryChromaticities", 319),
- new ExifTag("JPEGInterchangeFormat", 513),
- new ExifTag("JPEGInterchangeFormatLength", 514),
- new ExifTag("YCbCrCoefficients", 529),
- new ExifTag("YCbCrSubSampling", 530),
- new ExifTag("YCbCrPositioning", 531),
- new ExifTag("ReferenceBlackWhite", 532),
- new ExifTag("Copyright", 33432),
- new ExifTag("ExifIFDPointer", 34665),
- new ExifTag("GPSInfoIFDPointer", 34853),
+ new ExifTag(TAG_IMAGE_WIDTH, 256),
+ new ExifTag(TAG_IMAGE_LENGTH, 257),
+ new ExifTag(TAG_BITS_PER_SAMPLE, 258),
+ new ExifTag(TAG_COMPRESSION, 259),
+ new ExifTag(TAG_PHOTOMETRIC_INTERPRETATION, 262),
+ new ExifTag(TAG_IMAGE_DESCRIPTION, 270),
+ new ExifTag(TAG_MAKE, 271),
+ new ExifTag(TAG_MODEL, 272),
+ new ExifTag(TAG_STRIP_OFFSETS, 273),
+ new ExifTag(TAG_ORIENTATION, 274),
+ new ExifTag(TAG_SAMPLES_PER_PIXEL, 277),
+ new ExifTag(TAG_ROWS_PER_STRIP, 278),
+ new ExifTag(TAG_STRIP_BYTE_COUNTS, 279),
+ new ExifTag(TAG_X_RESOLUTION, 282),
+ new ExifTag(TAG_Y_RESOLUTION, 283),
+ new ExifTag(TAG_PLANAR_CONFIGURATION, 284),
+ new ExifTag(TAG_RESOLUTION_UNIT, 296),
+ new ExifTag(TAG_TRANSFER_FUNCTION, 301),
+ new ExifTag(TAG_SOFTWARE, 305),
+ new ExifTag(TAG_DATETIME, 306),
+ new ExifTag(TAG_ARTIST, 315),
+ new ExifTag(TAG_WHITE_POINT, 318),
+ new ExifTag(TAG_PRIMARY_CHROMATICITIES, 319),
+ new ExifTag(TAG_JPEG_INTERCHANGE_FORMAT, 513),
+ new ExifTag(TAG_JPEG_INTERCHANGE_FORMAT_LENGTH, 514),
+ new ExifTag(TAG_Y_CB_CR_COEFFICIENTS, 529),
+ new ExifTag(TAG_Y_CB_CR_SUB_SAMPLING, 530),
+ new ExifTag(TAG_Y_CB_CR_POSITIONING, 531),
+ new ExifTag(TAG_REFERENCE_BLACK_WHITE, 532),
+ new ExifTag(TAG_COPYRIGHT, 33432),
+ new ExifTag(TAG_EXIF_IFD_POINTER, 34665),
+ new ExifTag(TAG_GPS_INFO_IFD_POINTER, 34853),
};
// Primary image IFD Exif Private tags (See JEITA CP-3451 Table 15. page 55).
private static final ExifTag[] IFD_EXIF_TAGS = new ExifTag[] {
- new ExifTag("ExposureTime", 33434),
- new ExifTag("FNumber", 33437),
- new ExifTag("ExposureProgram", 34850),
- new ExifTag("SpectralSensitivity", 34852),
- new ExifTag("ISOSpeedRatings", 34855),
- new ExifTag("OECF", 34856),
- new ExifTag("ExifVersion", 36864),
- new ExifTag("DateTimeOriginal", 36867),
- new ExifTag("DateTimeDigitized", 36868),
- new ExifTag("ComponentsConfiguration", 37121),
- new ExifTag("CompressedBitsPerPixel", 37122),
- new ExifTag("ShutterSpeedValue", 37377),
- new ExifTag("ApertureValue", 37378),
- new ExifTag("BrightnessValue", 37379),
- new ExifTag("ExposureBiasValue", 37380),
- new ExifTag("MaxApertureValue", 37381),
- new ExifTag("SubjectDistance", 37382),
- new ExifTag("MeteringMode", 37383),
- new ExifTag("LightSource", 37384),
- new ExifTag("Flash", 37385),
- new ExifTag("FocalLength", 37386),
- new ExifTag("SubjectArea", 37396),
- new ExifTag("MakerNote", 37500),
- new ExifTag("UserComment", 37510),
- new ExifTag("SubSecTime", 37520),
- new ExifTag("SubSecTimeOriginal", 37521),
- new ExifTag("SubSecTimeDigitized", 37522),
- new ExifTag("FlashpixVersion", 40960),
- new ExifTag("ColorSpace", 40961),
- new ExifTag("PixelXDimension", 40962),
- new ExifTag("PixelYDimension", 40963),
- new ExifTag("RelatedSoundFile", 40964),
- new ExifTag("InteroperabilityIFDPointer", 40965),
- new ExifTag("FlashEnergy", 41483),
- new ExifTag("SpatialFrequencyResponse", 41484),
- new ExifTag("FocalPlaneXResolution", 41486),
- new ExifTag("FocalPlaneYResolution", 41487),
- new ExifTag("FocalPlaneResolutionUnit", 41488),
- new ExifTag("SubjectLocation", 41492),
- new ExifTag("ExposureIndex", 41493),
- new ExifTag("SensingMethod", 41495),
- new ExifTag("FileSource", 41728),
- new ExifTag("SceneType", 41729),
- new ExifTag("CFAPattern", 41730),
- new ExifTag("CustomRendered", 41985),
- new ExifTag("ExposureMode", 41986),
- new ExifTag("WhiteBalance", 41987),
- new ExifTag("DigitalZoomRatio", 41988),
- new ExifTag("FocalLengthIn35mmFilm", 41989),
- new ExifTag("SceneCaptureType", 41990),
- new ExifTag("GainControl", 41991),
- new ExifTag("Contrast", 41992),
- new ExifTag("Saturation", 41993),
- new ExifTag("Sharpness", 41994),
- new ExifTag("DeviceSettingDescription", 41995),
- new ExifTag("SubjectDistanceRange", 41996),
- new ExifTag("ImageUniqueID", 42016),
+ new ExifTag(TAG_EXPOSURE_TIME, 33434),
+ new ExifTag(TAG_F_NUMBER, 33437),
+ new ExifTag(TAG_EXPOSURE_PROGRAM, 34850),
+ new ExifTag(TAG_SPECTRAL_SENSITIVITY, 34852),
+ new ExifTag(TAG_ISO, 34855),
+ new ExifTag(TAG_OECF, 34856),
+ new ExifTag(TAG_EXIF_VERSION, 36864),
+ new ExifTag(TAG_DATETIME_ORIGINAL, 36867),
+ new ExifTag(TAG_DATETIME_DIGITIZED, 36868),
+ new ExifTag(TAG_COMPONENTS_CONFIGURATION, 37121),
+ new ExifTag(TAG_COMPRESSED_BITS_PER_PIXEL, 37122),
+ new ExifTag(TAG_SHUTTER_SPEED_VALUE, 37377),
+ new ExifTag(TAG_APERTURE_VALUE, 37378),
+ new ExifTag(TAG_BRIGHTNESS_VALUE, 37379),
+ new ExifTag(TAG_EXPOSURE_BIAS_VALUE, 37380),
+ new ExifTag(TAG_MAX_APERTURE_VALUE, 37381),
+ new ExifTag(TAG_SUBJECT_DISTANCE, 37382),
+ new ExifTag(TAG_METERING_MODE, 37383),
+ new ExifTag(TAG_LIGHT_SOURCE, 37384),
+ new ExifTag(TAG_FLASH, 37385),
+ new ExifTag(TAG_FOCAL_LENGTH, 37386),
+ new ExifTag(TAG_SUBJECT_AREA, 37396),
+ new ExifTag(TAG_MAKER_NOTE, 37500),
+ new ExifTag(TAG_USER_COMMENT, 37510),
+ new ExifTag(TAG_SUBSEC_TIME, 37520),
+ new ExifTag(TAG_SUBSEC_TIME_ORIG, 37521),
+ new ExifTag(TAG_SUBSEC_TIME_DIG, 37522),
+ new ExifTag(TAG_FLASHPIX_VERSION, 40960),
+ new ExifTag(TAG_COLOR_SPACE, 40961),
+ new ExifTag(TAG_PIXEL_X_DIMENSION, 40962),
+ new ExifTag(TAG_PIXEL_Y_DIMENSION, 40963),
+ new ExifTag(TAG_RELATED_SOUND_FILE, 40964),
+ new ExifTag(TAG_INTEROPERABILITY_IFD_POINTER, 40965),
+ new ExifTag(TAG_FLASH_ENERGY, 41483),
+ new ExifTag(TAG_SPATIAL_FREQUENCY_RESPONSE, 41484),
+ new ExifTag(TAG_FOCAL_PLANE_X_RESOLUTION, 41486),
+ new ExifTag(TAG_FOCAL_PLANE_Y_RESOLUTION, 41487),
+ new ExifTag(TAG_FOCAL_PLANE_RESOLUTION_UNIT, 41488),
+ new ExifTag(TAG_SUBJECT_LOCATION, 41492),
+ new ExifTag(TAG_EXPOSURE_INDEX, 41493),
+ new ExifTag(TAG_SENSING_METHOD, 41495),
+ new ExifTag(TAG_FILE_SOURCE, 41728),
+ new ExifTag(TAG_SCENE_TYPE, 41729),
+ new ExifTag(TAG_CFA_PATTERN, 41730),
+ new ExifTag(TAG_CUSTOM_RENDERED, 41985),
+ new ExifTag(TAG_EXPOSURE_MODE, 41986),
+ new ExifTag(TAG_WHITE_BALANCE, 41987),
+ new ExifTag(TAG_DIGITAL_ZOOM_RATIO, 41988),
+ new ExifTag(TAG_FOCAL_LENGTH_IN_35MM_FILM, 41989),
+ new ExifTag(TAG_SCENE_CAPTURE_TYPE, 41990),
+ new ExifTag(TAG_GAIN_CONTROL, 41991),
+ new ExifTag(TAG_CONTRAST, 41992),
+ new ExifTag(TAG_SATURATION, 41993),
+ new ExifTag(TAG_SHARPNESS, 41994),
+ new ExifTag(TAG_DEVICE_SETTING_DESCRIPTION, 41995),
+ new ExifTag(TAG_SUBJECT_DISTANCE_RANGE, 41996),
+ new ExifTag(TAG_IMAGE_UNIQUE_ID, 42016),
};
// Primary image IFD GPS Info tags (See JEITA CP-3451 Table 16. page 56).
private static final ExifTag[] IFD_GPS_TAGS = new ExifTag[] {
- new ExifTag("GPSVersionID", 0),
- new ExifTag("GPSLatitudeRef", 1),
- new ExifTag("GPSLatitude", 2),
- new ExifTag("GPSLongitudeRef", 3),
- new ExifTag("GPSLongitude", 4),
- new ExifTag("GPSAltitudeRef", 5),
- new ExifTag("GPSAltitude", 6),
- new ExifTag("GPSTimeStamp", 7),
- new ExifTag("GPSSatellites", 8),
- new ExifTag("GPSStatus", 9),
- new ExifTag("GPSMeasureMode", 10),
- new ExifTag("GPSDOP", 11),
- new ExifTag("GPSSpeedRef", 12),
- new ExifTag("GPSSpeed", 13),
- new ExifTag("GPSTrackRef", 14),
- new ExifTag("GPSTrack", 15),
- new ExifTag("GPSImgDirectionRef", 16),
- new ExifTag("GPSImgDirection", 17),
- new ExifTag("GPSMapDatum", 18),
- new ExifTag("GPSDestLatitudeRef", 19),
- new ExifTag("GPSDestLatitude", 20),
- new ExifTag("GPSDestLongitudeRef", 21),
- new ExifTag("GPSDestLongitude", 22),
- new ExifTag("GPSDestBearingRef", 23),
- new ExifTag("GPSDestBearing", 24),
- new ExifTag("GPSDestDistanceRef", 25),
- new ExifTag("GPSDestDistance", 26),
- new ExifTag("GPSProcessingMethod", 27),
- new ExifTag("GPSAreaInformation", 28),
- new ExifTag("GPSDateStamp", 29),
- new ExifTag("GPSDifferential", 30),
+ new ExifTag(TAG_GPS_VERSION_ID, 0),
+ new ExifTag(TAG_GPS_LATITUDE_REF, 1),
+ new ExifTag(TAG_GPS_LATITUDE, 2),
+ new ExifTag(TAG_GPS_LONGITUDE_REF, 3),
+ new ExifTag(TAG_GPS_LONGITUDE, 4),
+ new ExifTag(TAG_GPS_ALTITUDE_REF, 5),
+ new ExifTag(TAG_GPS_ALTITUDE, 6),
+ new ExifTag(TAG_GPS_TIMESTAMP, 7),
+ new ExifTag(TAG_GPS_SATELLITES, 8),
+ new ExifTag(TAG_GPS_STATUS, 9),
+ new ExifTag(TAG_GPS_MEASURE_MODE, 10),
+ new ExifTag(TAG_GPS_DOP, 11),
+ new ExifTag(TAG_GPS_SPEED_REF, 12),
+ new ExifTag(TAG_GPS_SPEED, 13),
+ new ExifTag(TAG_GPS_TRACK_REF, 14),
+ new ExifTag(TAG_GPS_TRACK, 15),
+ new ExifTag(TAG_GPS_IMG_DIRECTION_REF, 16),
+ new ExifTag(TAG_GPS_IMG_DIRECTION, 17),
+ new ExifTag(TAG_GPS_MAP_DATUM, 18),
+ new ExifTag(TAG_GPS_DEST_LATITUDE_REF, 19),
+ new ExifTag(TAG_GPS_DEST_LATITUDE, 20),
+ new ExifTag(TAG_GPS_DEST_LONGITUDE_REF, 21),
+ new ExifTag(TAG_GPS_DEST_LONGITUDE, 22),
+ new ExifTag(TAG_GPS_DEST_BEARING_REF, 23),
+ new ExifTag(TAG_GPS_DEST_BEARING, 24),
+ new ExifTag(TAG_GPS_DEST_DISTANCE_REF, 25),
+ new ExifTag(TAG_GPS_DEST_DISTANCE, 26),
+ new ExifTag(TAG_GPS_PROCESSING_METHOD, 27),
+ new ExifTag(TAG_GPS_AREA_INFORMATION, 28),
+ new ExifTag(TAG_GPS_DATESTAMP, 29),
+ new ExifTag(TAG_GPS_DIFFERENTIAL, 30),
};
// Primary image IFD Interoperability tag (See JEITA CP-3451 Table 17. page 56).
private static final ExifTag[] IFD_INTEROPERABILITY_TAGS = new ExifTag[] {
- new ExifTag("InteroperabilityIndex", 1),
+ new ExifTag(TAG_INTEROPERABILITY_INDEX, 1),
};
// IFD Thumbnail tags (See JEITA CP-3451 Table 18. page 57).
private static final ExifTag[] IFD_THUMBNAIL_TAGS = new ExifTag[] {
- new ExifTag("ThumbnailImageWidth", 256),
- new ExifTag("ThumbnailImageLength", 257),
- new ExifTag("BitsPerSample", 258),
- new ExifTag("Compression", 259),
- new ExifTag("PhotometricInterpretation", 262),
- new ExifTag("ImageDescription", 270),
- new ExifTag("Make", 271),
- new ExifTag("Model", 272),
- new ExifTag("StripOffsets", 273),
- new ExifTag("Orientation", 274),
- new ExifTag("SamplesPerPixel", 277),
- new ExifTag("RowsPerStrip", 278),
- new ExifTag("StripByteCounts", 279),
- new ExifTag("XResolution", 282),
- new ExifTag("YResolution", 283),
- new ExifTag("PlanarConfiguration", 284),
- new ExifTag("ResolutionUnit", 296),
- new ExifTag("TransferFunction", 301),
- new ExifTag("Software", 305),
- new ExifTag("DateTime", 306),
- new ExifTag("Artist", 315),
- new ExifTag("WhitePoint", 318),
- new ExifTag("PrimaryChromaticities", 319),
- new ExifTag("JPEGInterchangeFormat", 513),
- new ExifTag("JPEGInterchangeFormatLength", 514),
- new ExifTag("YCbCrCoefficients", 529),
- new ExifTag("YCbCrSubSampling", 530),
- new ExifTag("YCbCrPositioning", 531),
- new ExifTag("ReferenceBlackWhite", 532),
- new ExifTag("Copyright", 33432),
- new ExifTag("ExifIFDPointer", 34665),
- new ExifTag("GPSInfoIFDPointer", 34853),
+ new ExifTag(TAG_THUMBNAIL_IMAGE_WIDTH, 256),
+ new ExifTag(TAG_THUMBNAIL_IMAGE_LENGTH, 257),
+ new ExifTag(TAG_BITS_PER_SAMPLE, 258),
+ new ExifTag(TAG_COMPRESSION, 259),
+ new ExifTag(TAG_PHOTOMETRIC_INTERPRETATION, 262),
+ new ExifTag(TAG_IMAGE_DESCRIPTION, 270),
+ new ExifTag(TAG_MAKE, 271),
+ new ExifTag(TAG_MODEL, 272),
+ new ExifTag(TAG_STRIP_OFFSETS, 273),
+ new ExifTag(TAG_ORIENTATION, 274),
+ new ExifTag(TAG_SAMPLES_PER_PIXEL, 277),
+ new ExifTag(TAG_ROWS_PER_STRIP, 278),
+ new ExifTag(TAG_STRIP_BYTE_COUNTS, 279),
+ new ExifTag(TAG_X_RESOLUTION, 282),
+ new ExifTag(TAG_Y_RESOLUTION, 283),
+ new ExifTag(TAG_PLANAR_CONFIGURATION, 284),
+ new ExifTag(TAG_RESOLUTION_UNIT, 296),
+ new ExifTag(TAG_TRANSFER_FUNCTION, 301),
+ new ExifTag(TAG_SOFTWARE, 305),
+ new ExifTag(TAG_DATETIME, 306),
+ new ExifTag(TAG_ARTIST, 315),
+ new ExifTag(TAG_WHITE_POINT, 318),
+ new ExifTag(TAG_PRIMARY_CHROMATICITIES, 319),
+ new ExifTag(TAG_JPEG_INTERCHANGE_FORMAT, 513),
+ new ExifTag(TAG_JPEG_INTERCHANGE_FORMAT_LENGTH, 514),
+ new ExifTag(TAG_Y_CB_CR_COEFFICIENTS, 529),
+ new ExifTag(TAG_Y_CB_CR_SUB_SAMPLING, 530),
+ new ExifTag(TAG_Y_CB_CR_POSITIONING, 531),
+ new ExifTag(TAG_REFERENCE_BLACK_WHITE, 532),
+ new ExifTag(TAG_COPYRIGHT, 33432),
+ new ExifTag(TAG_EXIF_IFD_POINTER, 34665),
+ new ExifTag(TAG_GPS_INFO_IFD_POINTER, 34853),
};
// See JEITA CP-3451 Figure 5. page 9.
@@ -398,9 +581,9 @@
};
// List of tags for pointing to the other image file directory offset.
private static final ExifTag[] IFD_POINTER_TAGS = new ExifTag[] {
- new ExifTag("ExifIFDPointer", 34665),
- new ExifTag("GPSInfoPointer", 34853),
- new ExifTag("InteroperabilityIFDPointer", 40965),
+ new ExifTag(TAG_EXIF_IFD_POINTER, 34665),
+ new ExifTag(TAG_GPS_INFO_IFD_POINTER, 34853),
+ new ExifTag(TAG_INTEROPERABILITY_IFD_POINTER, 40965),
};
// List of indices of the indicated tag groups according to the IFD_POINTER_TAGS
private static final int[] IFD_POINTER_TAG_HINTS = new int[] {
@@ -408,15 +591,14 @@
};
// Tags for indicating the thumbnail offset and length
private static final ExifTag JPEG_INTERCHANGE_FORMAT_TAG =
- new ExifTag("JPEGInterchangeFormat", 513);
+ new ExifTag(TAG_JPEG_INTERCHANGE_FORMAT, 513);
private static final ExifTag JPEG_INTERCHANGE_FORMAT_LENGTH_TAG =
- new ExifTag("JPEGInterchangeFormatLength", 514);
+ new ExifTag(TAG_JPEG_INTERCHANGE_FORMAT_LENGTH, 514);
// Mappings from tag number to tag name and each item represents one IFD tag group.
private static final HashMap[] sExifTagMapsForReading = new HashMap[EXIF_TAGS.length];
- // Mapping from tag name to tag number and the corresponding tag group.
- private static final HashMap<String, Pair<Integer, Integer>> sExifTagMapForWriting =
- new HashMap<>();
+ // Mappings from tag name to tag number and each item represents one IFD tag group.
+ private static final HashMap[] sExifTagMapsForWriting = new HashMap[EXIF_TAGS.length];
// See JPEG File Interchange Format Version 1.02.
// The following values are defined for handling JPEG streams. In this implementation, we are
@@ -457,19 +639,10 @@
// Build up the hash tables to look up Exif tags for reading Exif tags.
for (int hint = 0; hint < EXIF_TAGS.length; ++hint) {
sExifTagMapsForReading[hint] = new HashMap();
+ sExifTagMapsForWriting[hint] = new HashMap();
for (ExifTag tag : EXIF_TAGS[hint]) {
sExifTagMapsForReading[hint].put(tag.number, tag.name);
- }
- }
-
- // Build up the hash tables to look up Exif tags for writing Exif tags.
- // There are some tags that have the same tag name in the different group. For that tags,
- // Primary image TIFF IFD and Exif private IFD have a higher priority to map than the other
- // tag groups. For the same tags, it writes one tag in the only one IFD group, which has the
- // higher priority group.
- for (int hint = EXIF_TAGS.length - 1; hint >= 0; --hint) {
- for (ExifTag tag : EXIF_TAGS[hint]) {
- sExifTagMapForWriting.put(tag.name, new Pair<>(tag.number, hint));
+ sExifTagMapsForWriting[hint].put(tag.name, tag.number);
}
}
}
@@ -477,8 +650,8 @@
private final String mFilename;
private final FileDescriptor mSeekableFileDescriptor;
private final AssetManager.AssetInputStream mAssetInputStream;
- private final HashMap<String, String> mAttributes = new HashMap<>();
private boolean mIsRaw;
+ private final HashMap[] mAttributes = new HashMap[EXIF_TAGS.length];
private boolean mHasThumbnail;
// The following values used for indicating a thumbnail position.
private int mThumbnailOffset;
@@ -554,7 +727,15 @@
* @param tag the name of the tag.
*/
public String getAttribute(String tag) {
- return mAttributes.get(tag);
+ // Retrieves all tag groups. The value from primary image tag group has a higher priority
+ // than the value from the thumbnail tag group if there are more than one candidates.
+ for (int i = 0; i < EXIF_TAGS.length; ++i) {
+ Object value = mAttributes[i].get(tag);
+ if (value != null) {
+ return (String) value;
+ }
+ }
+ return null;
}
/**
@@ -566,11 +747,11 @@
* @param defaultValue the value to return if the tag is not available.
*/
public int getAttributeInt(String tag, int defaultValue) {
- String value = mAttributes.get(tag);
+ String value = getAttribute(tag);
if (value == null) return defaultValue;
try {
return Integer.valueOf(value);
- } catch (NumberFormatException ex) {
+ } catch (NumberFormatException e) {
return defaultValue;
}
}
@@ -584,7 +765,7 @@
* @param defaultValue the value to return if the tag is not available.
*/
public double getAttributeDouble(String tag, double defaultValue) {
- String value = mAttributes.get(tag);
+ String value = getAttribute(tag);
if (value == null) return defaultValue;
try {
int index = value.indexOf("/");
@@ -593,7 +774,7 @@
if (denom == 0) return defaultValue;
double num = Double.parseDouble(value.substring(0, index));
return num / denom;
- } catch (NumberFormatException ex) {
+ } catch (NumberFormatException e) {
return defaultValue;
}
}
@@ -605,11 +786,11 @@
* @param value the value of the tag.
*/
public void setAttribute(String tag, String value) {
- if (value == null) {
- mAttributes.remove(tag);
- return;
+ for (int i = 0 ; i < EXIF_TAGS.length; ++i) {
+ if (sExifTagMapsForWriting[i].containsKey(tag)) {
+ mAttributes[i].put(tag, value);
+ }
}
- mAttributes.put(tag, value);
}
/**
@@ -618,6 +799,11 @@
* determine whether the image data format is JPEG or not.
*/
private void loadAttributes(@NonNull InputStream in) throws IOException {
+ // Initialize mAttributes.
+ for (int i = 0; i < EXIF_TAGS.length; ++i) {
+ mAttributes[i] = new HashMap();
+ }
+
// Process RAW input stream
if (mAssetInputStream != null) {
long asset = mAssetInputStream.getNativeAsset();
@@ -664,8 +850,7 @@
// Mark for disabling the save feature.
mIsRaw = true;
- for (Object obj : map.entrySet()) {
- Map.Entry entry = (Map.Entry) obj;
+ for (Map.Entry entry : (Set<Map.Entry>) map.entrySet()) {
String attrName = (String) entry.getKey();
switch (attrName) {
@@ -682,7 +867,7 @@
mThumbnailBytes = (byte[]) entry.getValue();
break;
default:
- mAttributes.put(attrName, (String) entry.getValue());
+ setAttribute(attrName, (String) entry.getValue());
break;
}
}
@@ -704,9 +889,11 @@
// Prints out attributes for debugging.
private void printAttributes() {
- Log.d(TAG, "The size of tags: " + mAttributes.size());
- for (Map.Entry<String, String> entry : mAttributes.entrySet()) {
- Log.d(TAG, "tagName: " + entry.getKey() + ", tagValue: " + entry.getValue());
+ for (int i = 0; i < mAttributes.length; ++i) {
+ Log.d(TAG, "The size of tag group[" + i + "]: " + mAttributes[i].size());
+ for (Map.Entry entry : (Set<Map.Entry>) mAttributes[i].entrySet()) {
+ Log.d(TAG, "tagName: " + entry.getKey() + ", tagValue: " + entry.getValue());
+ }
}
}
@@ -851,10 +1038,10 @@
* Exif tags are not available.
*/
public boolean getLatLong(float output[]) {
- String latValue = mAttributes.get(TAG_GPS_LATITUDE);
- String latRef = mAttributes.get(TAG_GPS_LATITUDE_REF);
- String lngValue = mAttributes.get(TAG_GPS_LONGITUDE);
- String lngRef = mAttributes.get(TAG_GPS_LONGITUDE_REF);
+ String latValue = getAttribute(TAG_GPS_LATITUDE);
+ String latRef = getAttribute(TAG_GPS_LATITUDE_REF);
+ String lngValue = getAttribute(TAG_GPS_LONGITUDE);
+ String lngRef = getAttribute(TAG_GPS_LONGITUDE_REF);
if (latValue != null && latRef != null && lngValue != null && lngRef != null) {
try {
@@ -892,7 +1079,7 @@
* @hide
*/
public long getDateTime() {
- String dateTimeString = mAttributes.get(TAG_DATETIME);
+ String dateTimeString = getAttribute(TAG_DATETIME);
if (dateTimeString == null
|| !sNonZeroTimePattern.matcher(dateTimeString).matches()) return -1;
@@ -904,7 +1091,7 @@
if (datetime == null) return -1;
long msecs = datetime.getTime();
- String subSecs = mAttributes.get(TAG_SUBSECTIME);
+ String subSecs = getAttribute(TAG_SUBSECTIME);
if (subSecs != null) {
try {
long sub = Long.valueOf(subSecs);
@@ -917,7 +1104,7 @@
}
}
return msecs;
- } catch (IllegalArgumentException ex) {
+ } catch (IllegalArgumentException e) {
return -1;
}
}
@@ -928,8 +1115,8 @@
* @hide
*/
public long getGpsDateTime() {
- String date = mAttributes.get(TAG_GPS_DATESTAMP);
- String time = mAttributes.get(TAG_GPS_TIMESTAMP);
+ String date = getAttribute(TAG_GPS_DATESTAMP);
+ String time = getAttribute(TAG_GPS_TIMESTAMP);
if (date == null || time == null
|| (!sNonZeroTimePattern.matcher(date).matches()
&& !sNonZeroTimePattern.matcher(time).matches())) return -1;
@@ -941,7 +1128,7 @@
Date datetime = sFormatter.parse(dateTimeString, pos);
if (datetime == null) return -1;
return datetime.getTime();
- } catch (IllegalArgumentException ex) {
+ } catch (IllegalArgumentException e) {
return -1;
}
}
@@ -1049,8 +1236,7 @@
if (dataInputStream.read(bytes) != length) {
throw new IOException("Invalid exif");
}
- mAttributes.put("UserComment",
- new String(bytes, Charset.forName("US-ASCII")));
+ setAttribute("UserComment", new String(bytes, Charset.forName("US-ASCII")));
break;
}
@@ -1068,10 +1254,9 @@
case MARKER_SOF14:
case MARKER_SOF15: {
dataInputStream.skipBytes(1);
- mAttributes.put("ImageLength",
+ setAttribute("ImageLength",
String.valueOf(dataInputStream.readUnsignedShort()));
- mAttributes.put("ImageWidth",
- String.valueOf(dataInputStream.readUnsignedShort()));
+ setAttribute("ImageWidth", String.valueOf(dataInputStream.readUnsignedShort()));
length -= 5;
break;
}
@@ -1208,39 +1393,44 @@
readImageFileDirectory(dataInputStream, IFD_TIFF_HINT);
// Process thumbnail.
- try {
- int jpegInterchangeFormat = Integer.parseInt(
- mAttributes.get(JPEG_INTERCHANGE_FORMAT_TAG.name));
- int jpegInterchangeFormatLength = Integer.parseInt(
- mAttributes.get(JPEG_INTERCHANGE_FORMAT_LENGTH_TAG.name));
- // The following code limits the size of thumbnail size not to overflow EXIF data area.
- jpegInterchangeFormatLength = Math.min(jpegInterchangeFormat
- + jpegInterchangeFormatLength, exifOffsetFromBeginning + exifBytes.length)
- - jpegInterchangeFormat;
- if (jpegInterchangeFormat > 0 && jpegInterchangeFormatLength > 0) {
- mHasThumbnail = true;
- mThumbnailOffset = exifOffsetFromBeginning + jpegInterchangeFormat;
- mThumbnailLength = jpegInterchangeFormatLength;
+ String jpegInterchangeFormatString = getAttribute(JPEG_INTERCHANGE_FORMAT_TAG.name);
+ String jpegInterchangeFormatLengthString =
+ getAttribute(JPEG_INTERCHANGE_FORMAT_LENGTH_TAG.name);
+ if (jpegInterchangeFormatString != null && jpegInterchangeFormatLengthString != null) {
+ try {
+ int jpegInterchangeFormat = Integer.parseInt(jpegInterchangeFormatString);
+ int jpegInterchangeFormatLength = Integer
+ .parseInt(jpegInterchangeFormatLengthString);
+ // The following code limits the size of thumbnail size not to overflow EXIF data area.
+ jpegInterchangeFormatLength = Math.min(jpegInterchangeFormat
+ + jpegInterchangeFormatLength, exifOffsetFromBeginning + exifBytes.length)
+ - jpegInterchangeFormat;
+ if (jpegInterchangeFormat > 0 && jpegInterchangeFormatLength > 0) {
+ mHasThumbnail = true;
+ mThumbnailOffset = exifOffsetFromBeginning + jpegInterchangeFormat;
+ mThumbnailLength = jpegInterchangeFormatLength;
- if (mFilename == null && mAssetInputStream == null
- && mSeekableFileDescriptor == null) {
- // Save the thumbnail in memory if the input doesn't support reading again.
- byte[] thumbnailBytes = new byte[jpegInterchangeFormatLength];
- dataInputStream.seek(jpegInterchangeFormat);
- dataInputStream.readFully(thumbnailBytes);
- mThumbnailBytes = thumbnailBytes;
+ if (mFilename == null && mAssetInputStream == null
+ && mSeekableFileDescriptor == null) {
+ // Save the thumbnail in memory if the input doesn't support reading again.
+ byte[] thumbnailBytes = new byte[jpegInterchangeFormatLength];
+ dataInputStream.seek(jpegInterchangeFormat);
+ dataInputStream.readFully(thumbnailBytes);
+ mThumbnailBytes = thumbnailBytes;
- if (DEBUG) {
- Bitmap bitmap = BitmapFactory.decodeByteArray(
- thumbnailBytes, 0, thumbnailBytes.length);
- Log.d(TAG, "Thumbnail offset: " + mThumbnailOffset + ", length: "
- + mThumbnailLength + ", width: " + bitmap.getWidth() + ", height: "
- + bitmap.getHeight());
+ if (DEBUG) {
+ Bitmap bitmap = BitmapFactory.decodeByteArray(
+ thumbnailBytes, 0, thumbnailBytes.length);
+ Log.d(TAG, "Thumbnail offset: " + mThumbnailOffset + ", length: "
+ + mThumbnailLength + ", width: " + bitmap.getWidth()
+ + ", height: "
+ + bitmap.getHeight());
+ }
}
}
+ } catch (NumberFormatException e) {
+ // Ignored the corrupted image.
}
- } catch (NumberFormatException e) {
- // Ignored the corrupted image.
}
// For compatibility, keep data formats as follows.
@@ -1251,7 +1441,7 @@
convertToRational(TAG_FOCAL_LENGTH);
convertToDouble(TAG_DIGITAL_ZOOM_RATIO);
convertToDouble(TAG_EXPOSURE_TIME);
- convertToDouble(TAG_APERTURE);
+ convertToDouble(TAG_F_NUMBER);
convertToDouble(TAG_SUBJECT_DISTANCE);
convertToInt(TAG_ISO);
convertToDouble(TAG_EXPOSURE_BIAS_VALUE);
@@ -1267,29 +1457,29 @@
convertToTimetamp(TAG_GPS_TIMESTAMP);
// The value of DATETIME tag has the same value of DATETIME_ORIGINAL tag.
- String valueOfDateTimeOriginal = mAttributes.get("DateTimeOriginal");
+ String valueOfDateTimeOriginal = getAttribute("DateTimeOriginal");
if (valueOfDateTimeOriginal != null) {
- mAttributes.put(TAG_DATETIME, valueOfDateTimeOriginal);
+ setAttribute(TAG_DATETIME, valueOfDateTimeOriginal);
}
// Add the default value.
- if (!mAttributes.containsKey(TAG_IMAGE_WIDTH)) {
- mAttributes.put(TAG_IMAGE_WIDTH, "0");
+ if (getAttribute(TAG_IMAGE_WIDTH) == null) {
+ setAttribute(TAG_IMAGE_WIDTH, "0");
}
- if (!mAttributes.containsKey(TAG_IMAGE_LENGTH)) {
- mAttributes.put(TAG_IMAGE_LENGTH, "0");
+ if (getAttribute(TAG_IMAGE_LENGTH) == null) {
+ setAttribute(TAG_IMAGE_LENGTH, "0");
}
- if (!mAttributes.containsKey(TAG_ORIENTATION)) {
- mAttributes.put(TAG_ORIENTATION, "0");
+ if (getAttribute(TAG_ORIENTATION) == null) {
+ setAttribute(TAG_ORIENTATION, "0");
}
- if (!mAttributes.containsKey(TAG_LIGHT_SOURCE)) {
- mAttributes.put(TAG_LIGHT_SOURCE, "0");
+ if (getAttribute(TAG_LIGHT_SOURCE) == null) {
+ setAttribute(TAG_LIGHT_SOURCE, "0");
}
}
// Converts the tag value to timestamp; Otherwise deletes the given tag.
private void convertToTimetamp(String tagName) {
- String entryValue = mAttributes.get(tagName);
+ String entryValue = getAttribute(tagName);
if (entryValue == null) return;
int dataFormat = getDataFormatOfExifEntryValue(entryValue);
String[] components = entryValue.split(",");
@@ -1309,16 +1499,16 @@
int value = numerator / denominator;
stringBuilder.append(String.format("%02d", value));
}
- mAttributes.put(tagName, stringBuilder.toString());
+ setAttribute(tagName, stringBuilder.toString());
} else if (dataFormat != IFD_FORMAT_STRING) {
- mAttributes.remove(tagName);
+ setAttribute(tagName, null);
}
}
// Checks the tag value of a given tag formatted in double type; Otherwise try to convert it to
// double type or delete it.
private void convertToDouble(String tagName) {
- String entryValue = mAttributes.get(tagName);
+ String entryValue = getAttribute(tagName);
if (entryValue == null) return;
int dataFormat = getDataFormatOfExifEntryValue(entryValue);
switch (dataFormat) {
@@ -1338,21 +1528,21 @@
}
stringBuilder.append((double) numerator / denominator);
}
- mAttributes.put(tagName, stringBuilder.toString());
+ setAttribute(tagName, stringBuilder.toString());
break;
}
case IFD_FORMAT_DOUBLE:
// Keep it as is.
break;
default:
- mAttributes.remove(tagName);
+ setAttribute(tagName, null);
break;
}
}
// Checks the tag value of a given tag formatted in int type; Otherwise deletes the tag value.
private void convertToRational(String tagName) {
- String entryValue = mAttributes.get(tagName);
+ String entryValue = getAttribute(tagName);
if (entryValue == null) return;
int dataFormat = getDataFormatOfExifEntryValue(entryValue);
switch (dataFormat) {
@@ -1367,25 +1557,25 @@
double doubleValue = Double.parseDouble(component);
stringBuilder.append((int) (doubleValue * 10000.0)).append("/").append(10000);
}
- mAttributes.put(tagName, stringBuilder.toString());
+ setAttribute(tagName, stringBuilder.toString());
break;
}
case IFD_FORMAT_SRATIONAL:
// Keep it as is.
break;
default:
- mAttributes.remove(tagName);
+ setAttribute(tagName, null);
break;
}
}
// Checks the tag value of a given tag formatted in int type; Otherwise deletes the tag value.
private void convertToInt(String tagName) {
- String entryValue = mAttributes.get(tagName);
+ String entryValue = getAttribute(tagName);
if (entryValue == null) return;
int dataFormat = getDataFormatOfExifEntryValue(entryValue);
if (dataFormat != IFD_FORMAT_SLONG) {
- mAttributes.remove(tagName);
+ setAttribute(tagName, null);
}
}
@@ -1474,7 +1664,7 @@
String entryValue = readExifEntryValue(
dataInputStream, dataFormat, numberOfComponents);
if (entryValue != null) {
- mAttributes.put(tagName, entryValue);
+ setAttribute(tagName, entryValue);
}
} else {
StringBuilder entryValueBuilder = new StringBuilder();
@@ -1485,7 +1675,7 @@
entryValueBuilder.append(readExifEntryValue(
dataInputStream, dataFormat, numberOfComponents));
}
- mAttributes.put(tagName, entryValueBuilder.toString());
+ setAttribute(tagName, entryValueBuilder.toString());
}
if (dataInputStream.peek() != nextEntryOffset) {
@@ -1560,8 +1750,6 @@
StringBuilder stringBuilder = new StringBuilder();
while (true) {
int ch = bytes[index];
- if (ch < 0)
- throw new EOFException();
if (ch == 0)
break;
if (ch >= 32)
@@ -1597,49 +1785,46 @@
int[] ifdOffsets = new int[EXIF_TAGS.length];
int[] ifdDataSizes = new int[EXIF_TAGS.length];
- // Maps to store tags per IFD tag group
- HashMap[] ifdTags = new HashMap[EXIF_TAGS.length];
- for (int i = 0; i < EXIF_TAGS.length; ++i) {
- ifdTags[i] = new HashMap();
- }
-
// Remove IFD pointer tags (we'll re-add it later.)
for (ExifTag tag : IFD_POINTER_TAGS) {
- mAttributes.remove(tag.name);
- }
-
- // Assign tags to the corresponding group
- for (Map.Entry<String, String> entry : mAttributes.entrySet()) {
- Pair<Integer, Integer> pair = sExifTagMapForWriting.get(entry.getKey());
- if (pair != null) {
- int tagNumber = pair.first;
- int hint = pair.second;
- ifdTags[hint].put(tagNumber, entry.getValue());
- }
+ setAttribute(tag.name, null);
}
// Add IFD pointer tags. The next offset of primary image TIFF IFD will have thumbnail IFD
// offset when there is one or more tags in the thumbnail IFD.
- if (!ifdTags[IFD_INTEROPERABILITY_HINT].isEmpty()) {
- ifdTags[IFD_EXIF_HINT].put(IFD_POINTER_TAGS[2].number, "0");
+ if (!mAttributes[IFD_INTEROPERABILITY_HINT].isEmpty()) {
+ mAttributes[IFD_EXIF_HINT].put(IFD_POINTER_TAGS[2].name, "0");
}
- if (!ifdTags[IFD_EXIF_HINT].isEmpty()) {
- ifdTags[IFD_TIFF_HINT].put(IFD_POINTER_TAGS[0].number, "0");
+ if (!mAttributes[IFD_EXIF_HINT].isEmpty()) {
+ mAttributes[IFD_TIFF_HINT].put(IFD_POINTER_TAGS[0].name, "0");
}
- if (!ifdTags[IFD_GPS_HINT].isEmpty()) {
- ifdTags[IFD_TIFF_HINT].put(IFD_POINTER_TAGS[1].number, "0");
+ if (!mAttributes[IFD_GPS_HINT].isEmpty()) {
+ mAttributes[IFD_TIFF_HINT].put(IFD_POINTER_TAGS[1].name, "0");
}
+ // Remove old thumbnail data
+ setAttribute(JPEG_INTERCHANGE_FORMAT_TAG.name, null);
+ setAttribute(JPEG_INTERCHANGE_FORMAT_LENGTH_TAG.name, null);
if (mHasThumbnail) {
- ifdTags[IFD_TIFF_HINT].put(JPEG_INTERCHANGE_FORMAT_TAG.number, "0");
- ifdTags[IFD_TIFF_HINT].put(JPEG_INTERCHANGE_FORMAT_LENGTH_TAG.number,
+ mAttributes[IFD_TIFF_HINT].put(JPEG_INTERCHANGE_FORMAT_TAG.name, "0");
+ mAttributes[IFD_TIFF_HINT].put(JPEG_INTERCHANGE_FORMAT_LENGTH_TAG.name,
String.valueOf(mThumbnailLength));
}
+ // Remove null value tags.
+ for (int hint = 0; hint < EXIF_TAGS.length; ++hint) {
+ for (Object obj : mAttributes[hint].entrySet().toArray()) {
+ Map.Entry entry = (Map.Entry) obj;
+ if (entry.getValue() == null) {
+ mAttributes[hint].remove(entry.getKey());
+ }
+ }
+ }
+
// Calculate IFD group data area sizes. IFD group data area is assigned to save the entry
// value which has a bigger size than 4 bytes.
for (int i = 0; i < 5; ++i) {
int sum = 0;
- for (Object entry : ifdTags[i].entrySet()) {
+ for (Map.Entry entry : (Set<Map.Entry>) mAttributes[i].entrySet()) {
String entryValue = (String) ((Map.Entry) entry).getValue();
int dataFormat = getDataFormatOfExifEntryValue(entryValue);
int size = getSizeOfExifEntryValue(dataFormat, entryValue);
@@ -1653,16 +1838,16 @@
// Calculate IFD offsets.
int position = 8;
for (int hint = 0; hint < EXIF_TAGS.length; ++hint) {
- if (!ifdTags[hint].isEmpty()) {
+ if (!mAttributes[hint].isEmpty()) {
ifdOffsets[hint] = position;
- position += 2 + ifdTags[hint].size() * 12 + 4 + ifdDataSizes[hint];
+ position += 2 + mAttributes[hint].size() * 12 + 4 + ifdDataSizes[hint];
}
}
if (mHasThumbnail) {
int thumbnailOffset = position;
- ifdTags[IFD_TIFF_HINT].put(JPEG_INTERCHANGE_FORMAT_TAG.number,
+ mAttributes[IFD_TIFF_HINT].put(JPEG_INTERCHANGE_FORMAT_TAG.name,
String.valueOf(thumbnailOffset));
- ifdTags[IFD_TIFF_HINT].put(JPEG_INTERCHANGE_FORMAT_LENGTH_TAG.number,
+ mAttributes[IFD_TIFF_HINT].put(JPEG_INTERCHANGE_FORMAT_LENGTH_TAG.name,
String.valueOf(mThumbnailLength));
mThumbnailOffset = exifOffsetFromBeginning + thumbnailOffset;
position += mThumbnailLength;
@@ -1674,21 +1859,21 @@
Log.d(TAG, "totalSize length: " + totalSize);
for (int i = 0; i < 5; ++i) {
Log.d(TAG, String.format("index: %d, offsets: %d, tag count: %d, data sizes: %d",
- i, ifdOffsets[i], ifdTags[i].size(), ifdDataSizes[i]));
+ i, ifdOffsets[i], mAttributes[i].size(), ifdDataSizes[i]));
}
}
// Update IFD pointer tags with the calculated offsets.
- if (!ifdTags[IFD_EXIF_HINT].isEmpty()) {
- ifdTags[IFD_TIFF_HINT].put(IFD_POINTER_TAGS[0].number,
+ if (!mAttributes[IFD_EXIF_HINT].isEmpty()) {
+ mAttributes[IFD_TIFF_HINT].put(IFD_POINTER_TAGS[0].name,
String.valueOf(ifdOffsets[IFD_EXIF_HINT]));
}
- if (!ifdTags[IFD_GPS_HINT].isEmpty()) {
- ifdTags[IFD_TIFF_HINT].put(IFD_POINTER_TAGS[1].number,
+ if (!mAttributes[IFD_GPS_HINT].isEmpty()) {
+ mAttributes[IFD_TIFF_HINT].put(IFD_POINTER_TAGS[1].name,
String.valueOf(ifdOffsets[IFD_GPS_HINT]));
}
- if (!ifdTags[IFD_INTEROPERABILITY_HINT].isEmpty()) {
- ifdTags[IFD_EXIF_HINT].put(IFD_POINTER_TAGS[2].number,
+ if (!mAttributes[IFD_INTEROPERABILITY_HINT].isEmpty()) {
+ mAttributes[IFD_EXIF_HINT].put(IFD_POINTER_TAGS[2].name,
String.valueOf(ifdOffsets[IFD_INTEROPERABILITY_HINT]));
}
@@ -1701,16 +1886,16 @@
// Write IFD groups. See JEITA CP-3451C Figure 7. page 12.
for (int hint = 0; hint < EXIF_TAGS.length; ++hint) {
- if (!ifdTags[hint].isEmpty()) {
+ if (!mAttributes[hint].isEmpty()) {
// See JEITA CP-3451C 4.6.2 IFD structure. page 13.
// Write entry count
- dataOutputStream.writeUnsignedShort(ifdTags[hint].size());
+ dataOutputStream.writeUnsignedShort(mAttributes[hint].size());
// Write entry info
- int dataOffset = ifdOffsets[hint] + 2 + ifdTags[hint].size() * 12 + 4;
- for (Object obj : ifdTags[hint].entrySet()) {
- Map.Entry entry = (Map.Entry) obj;
- int tagNumber = (int) entry.getKey();
+ int dataOffset = ifdOffsets[hint] + 2 + mAttributes[hint].size() * 12 + 4;
+ for (Map.Entry entry : (Set<Map.Entry>) mAttributes[hint].entrySet()) {
+ // Convert tag name to tag number.
+ int tagNumber = (int) sExifTagMapsForWriting[hint].get(entry.getKey());
String entryValue = (String) entry.getValue();
int dataFormat = getDataFormatOfExifEntryValue(entryValue);
@@ -1738,15 +1923,14 @@
// Write the next offset. It writes the offset of thumbnail IFD if there is one or
// more tags in the thumbnail IFD when the current IFD is the primary image TIFF
// IFD; Otherwise 0.
- if (hint == 0 && !ifdTags[IFD_THUMBNAIL_HINT].isEmpty()) {
+ if (hint == 0 && !mAttributes[IFD_THUMBNAIL_HINT].isEmpty()) {
dataOutputStream.writeUnsignedInt(ifdOffsets[IFD_THUMBNAIL_HINT]);
} else {
dataOutputStream.writeUnsignedInt(0);
}
// Write values of data field exceeding 4 bytes after the next offset.
- for (Object obj : ifdTags[hint].entrySet()) {
- Map.Entry entry = (Map.Entry) obj;
+ for (Map.Entry entry : (Set<Map.Entry>) mAttributes[hint].entrySet()) {
String entryValue = (String) entry.getValue();
int dataFormat = getDataFormatOfExifEntryValue(entryValue);
diff --git a/media/tests/MediaFrameworkTest/assets/volantis.jpg b/media/tests/MediaFrameworkTest/assets/volantis.jpg
new file mode 100644
index 0000000..cfe300f
--- /dev/null
+++ b/media/tests/MediaFrameworkTest/assets/volantis.jpg
Binary files differ
diff --git a/media/tests/MediaFrameworkTest/res/raw/volantis.jpg b/media/tests/MediaFrameworkTest/res/raw/volantis.jpg
new file mode 100644
index 0000000..cfe300f
--- /dev/null
+++ b/media/tests/MediaFrameworkTest/res/raw/volantis.jpg
Binary files differ
diff --git a/media/tests/MediaFrameworkTest/res/values/exifinterface.xml b/media/tests/MediaFrameworkTest/res/values/exifinterface.xml
index eb13ff37..d556ad3 100644
--- a/media/tests/MediaFrameworkTest/res/values/exifinterface.xml
+++ b/media/tests/MediaFrameworkTest/res/values/exifinterface.xml
@@ -105,4 +105,34 @@
<item>1</item>
<item />
</array>
+ <array name="volantis_jpg">
+ <item>false</item>
+ <item>0</item>
+ <item>0</item>
+ <item>true</item>
+ <item>37.423</item>
+ <item>-122.162</item>
+ <item>0.0</item>
+ <item>htc</item>
+ <item>Nexus 9</item>
+ <item>1.2904</item>
+ <item>2016:03:09 17:36:42</item>
+ <item>0.0083</item>
+ <item>64</item>
+ <item>3097/1000</item>
+ <item />
+ <item />
+ <item>2016:03:09</item>
+ <item>37/1,25/1,2291/100</item>
+ <item>N</item>
+ <item>122/1,9/1,4330/100</item>
+ <item>W</item>
+ <item />
+ <item>08:35:34</item>
+ <item>720</item>
+ <item>1280</item>
+ <item>175</item>
+ <item>1</item>
+ <item>0</item>
+ </array>
</resources>
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/ExifInterfaceTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/ExifInterfaceTest.java
index cff18cf..5bd6079 100644
--- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/ExifInterfaceTest.java
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/ExifInterfaceTest.java
@@ -51,10 +51,12 @@
private static final String EXIF_BYTE_ORDER_II_JPEG = "image_exif_byte_order_ii.jpg";
private static final String EXIF_BYTE_ORDER_MM_JPEG = "image_exif_byte_order_mm.jpg";
private static final String LG_G4_ISO_800_DNG = "lg_g4_iso_800.dng";
+ private static final String VOLANTIS_JPEG = "volantis.jpg";
private static final int[] IMAGE_RESOURCES = new int[] {
- R.raw.image_exif_byte_order_ii, R.raw.image_exif_byte_order_mm, R.raw.lg_g4_iso_800 };
+ R.raw.image_exif_byte_order_ii, R.raw.image_exif_byte_order_mm, R.raw.lg_g4_iso_800,
+ R.raw.volantis };
private static final String[] IMAGE_FILENAMES = new String[] {
- EXIF_BYTE_ORDER_II_JPEG, EXIF_BYTE_ORDER_MM_JPEG, LG_G4_ISO_800_DNG };
+ EXIF_BYTE_ORDER_II_JPEG, EXIF_BYTE_ORDER_MM_JPEG, LG_G4_ISO_800_DNG, VOLANTIS_JPEG };
private static final String[] EXIF_TAGS = {
ExifInterface.TAG_MAKE,
@@ -415,7 +417,7 @@
testExifInterfaceForRaw(LG_G4_ISO_800_DNG, R.array.lg_g4_iso_800_dng);
}
- public void testCorruptedImage() {
+ public void testCorruptedImage() throws Throwable {
byte[] bytes = new byte[1024];
try {
new ExifInterface(new ByteArrayInputStream(bytes));
@@ -424,4 +426,9 @@
// Success
}
}
+
+ public void testReadExifDataFromVolantisJpg() throws Throwable {
+ // Test if it is possible to parse the volantis generated JPEG smoothly.
+ testExifInterfaceForJpeg(VOLANTIS_JPEG, R.array.volantis_jpg);
+ }
}
diff --git a/packages/DocumentsUI/AndroidManifest.xml b/packages/DocumentsUI/AndroidManifest.xml
index 637e06e..6f38e25 100644
--- a/packages/DocumentsUI/AndroidManifest.xml
+++ b/packages/DocumentsUI/AndroidManifest.xml
@@ -40,18 +40,6 @@
</activity>
<activity
- android:name=".DownloadsActivity"
- android:theme="@style/DocumentsTheme"
- android:label="@string/downloads_label"
- android:icon="@drawable/ic_doc_text">
- <intent-filter>
- <action android:name="android.provider.action.MANAGE_ROOT" />
- <category android:name="android.intent.category.DEFAULT" />
- <data android:mimeType="vnd.android.document/root" />
- </intent-filter>
- </activity>
-
- <activity
android:name=".LauncherActivity"
android:theme="@android:style/Theme.NoDisplay"
android:icon="@drawable/ic_files_app"
@@ -72,6 +60,10 @@
<action android:name="android.intent.action.MAIN" />
</intent-filter>
<intent-filter>
+ <action android:name="android.intent.action.VIEW_DOWNLOADS" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ <intent-filter>
<action android:name="android.provider.action.BROWSE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="vnd.android.document/root" />
diff --git a/packages/DocumentsUI/src/com/android/documentsui/DocumentsActivity.java b/packages/DocumentsUI/src/com/android/documentsui/DocumentsActivity.java
index 12a4186..f8b32a0 100644
--- a/packages/DocumentsUI/src/com/android/documentsui/DocumentsActivity.java
+++ b/packages/DocumentsUI/src/com/android/documentsui/DocumentsActivity.java
@@ -95,7 +95,7 @@
}
if (mState.restored) {
- refreshCurrentRootAndDirectory(ANIM_NONE);
+ if (DEBUG) Log.d(TAG, "Stack already resolved");
} else {
// We set the activity title in AsyncTask.onPostExecute().
// To prevent talkback from reading aloud the default title, we clear it here.
@@ -108,9 +108,7 @@
// we restore the stack as last used from that app.
if (mState.action == ACTION_PICK_COPY_DESTINATION) {
if (DEBUG) Log.d(TAG, "Launching directly into Home directory.");
- Uri homeUri = DocumentsContract.buildHomeUri();
- new LoadRootTask(this, homeUri).executeOnExecutor(
- ProviderExecutor.forAuthority(homeUri.getAuthority()));
+ loadRoot(DocumentsContract.buildHomeUri());
} else {
if (DEBUG) Log.d(TAG, "Attempting to load last used stack for calling package.");
new LoadLastUsedStackTask(this).execute();
@@ -156,30 +154,6 @@
}
}
- private void onStackRestored(boolean restored, boolean external) {
- // Show drawer when no stack restored, but only when requesting
- // non-visual content. However, if we last used an external app,
- // drawer is always shown.
-
- boolean showDrawer = false;
- if (!restored) {
- showDrawer = true;
- }
- if (MimePredicate.mimeMatches(MimePredicate.VISUAL_MIMES, mState.acceptMimes)) {
- showDrawer = false;
- }
- if (external && mState.action == ACTION_GET_CONTENT) {
- showDrawer = true;
- }
- if (mState.action == ACTION_PICK_COPY_DESTINATION) {
- showDrawer = true;
- }
-
- if (showDrawer) {
- mNavigator.revealRootsDrawer(true);
- }
- }
-
public void onAppPicked(ResolveInfo info) {
final Intent intent = new Intent(getIntent());
intent.setFlags(intent.getFlags() & ~Intent.FLAG_ACTIVITY_FORWARD_RESULT);
@@ -517,8 +491,8 @@
@Override
protected void finish(Void result) {
mState.restored = true;
+ mState.external = mExternal;
mOwner.refreshCurrentRootAndDirectory(ANIM_NONE);
- mOwner.onStackRestored(mRestoredStack, mExternal);
}
}
diff --git a/packages/DocumentsUI/src/com/android/documentsui/DownloadsActivity.java b/packages/DocumentsUI/src/com/android/documentsui/DownloadsActivity.java
deleted file mode 100644
index 2f784cb..0000000
--- a/packages/DocumentsUI/src/com/android/documentsui/DownloadsActivity.java
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.documentsui;
-
-import static com.android.documentsui.State.ACTION_MANAGE;
-import static com.android.documentsui.dirlist.DirectoryFragment.ANIM_NONE;
-
-import android.app.Activity;
-import android.app.Fragment;
-import android.app.FragmentManager;
-import android.content.ActivityNotFoundException;
-import android.content.ClipData;
-import android.content.Context;
-import android.content.Intent;
-import android.net.Uri;
-import android.os.Bundle;
-import android.provider.DocumentsContract;
-import android.support.design.widget.Snackbar;
-import android.util.Log;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.widget.Toolbar;
-
-import com.android.documentsui.dirlist.DirectoryFragment;
-import com.android.documentsui.dirlist.Model;
-import com.android.documentsui.model.DocumentInfo;
-import com.android.documentsui.model.RootInfo;
-
-import java.util.Arrays;
-import java.util.List;
-
-// Let's face it. MANAGE_ROOT is used almost exclusively
-// for downloads, and is specialized for this purpose.
-// So it is now thusly christened.
-public class DownloadsActivity extends BaseActivity {
- private static final String TAG = "DownloadsActivity";
-
- public DownloadsActivity() {
- super(R.layout.downloads_activity, TAG);
- }
-
- @Override
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
-
- final Context context = this;
-
- Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
- toolbar.setTitleTextAppearance(context,
- android.R.style.TextAppearance_DeviceDefault_Widget_ActionBar_Title);
-
- if (!mState.restored) {
- // In this case, we set the activity title in AsyncTask.onPostExecute(). To prevent
- // talkback from reading aloud the default title, we clear it here.
- setTitle("");
- final Uri rootUri = getIntent().getData();
- new LoadRootTask(this, rootUri).executeOnExecutor(getExecutorForCurrentDirectory());
- } else {
- refreshCurrentRootAndDirectory(ANIM_NONE);
- }
- }
-
- @Override
- void includeState(State state) {
- state.action = ACTION_MANAGE;
- state.acceptMimes = new String[] { "*/*" };
- state.allowMultiple = true;
- state.showSize = true;
- state.excludedAuthorities = getExcludedAuthorities();
- }
-
- @Override
- protected void onPostCreate(Bundle savedInstanceState) {
- super.onPostCreate(savedInstanceState);
- mNavigator.update();
- }
-
- @Override
- public String getDrawerTitle() {
- return null; // being and nothingness
- }
-
- @Override
- public boolean onPrepareOptionsMenu(Menu menu) {
- super.onPrepareOptionsMenu(menu);
-
- final MenuItem createDir = menu.findItem(R.id.menu_create_dir);
- final MenuItem pasteFromCb = menu.findItem(R.id.menu_paste_from_clipboard);
- final MenuItem fileSize = menu.findItem(R.id.menu_file_size);
-
- createDir.setVisible(false);
- pasteFromCb.setEnabled(false);
- fileSize.setVisible(false);
-
- Menus.disableHiddenItems(menu);
- return true;
- }
-
- @Override
- void refreshDirectory(int anim) {
- final FragmentManager fm = getFragmentManager();
- final RootInfo root = getCurrentRoot();
- final DocumentInfo cwd = getCurrentDirectory();
-
- assert(!mSearchManager.isSearching());
-
- // If started in manage roots mode, there has to be a cwd (i.e. the root dir of the managed
- // root).
- assert(cwd != null);
-
- // Normal boring directory
- DirectoryFragment.showDirectory(fm, root, cwd, anim);
- }
-
- @Override
- public void onDocumentPicked(DocumentInfo doc, Model model) {
- assert(!doc.isDirectory());
-
- // First try managing the document; we expect manager to filter
- // based on authority, so we don't grant.
- final Intent manage = new Intent(DocumentsContract.ACTION_MANAGE_DOCUMENT);
- manage.setData(doc.derivedUri);
-
- try {
- startActivity(manage);
- } catch (ActivityNotFoundException ex) {
- // Fall back to viewing.
- final Intent view = new Intent(Intent.ACTION_VIEW);
- view.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
- view.setData(doc.derivedUri);
-
- try {
- startActivity(view);
- } catch (ActivityNotFoundException ex2) {
- Snackbars.makeSnackbar(this, R.string.toast_no_application, Snackbar.LENGTH_SHORT)
- .show();
- }
- }
- }
-
- @Override
- public void onDocumentsPicked(List<DocumentInfo> docs) {}
-
- @Override
- void onTaskFinished(Uri... uris) {
- Log.d(TAG, "onFinished() " + Arrays.toString(uris));
-
- final Intent intent = new Intent();
- if (uris.length == 1) {
- intent.setData(uris[0]);
- } else if (uris.length > 1) {
- final ClipData clipData = new ClipData(
- null, mState.acceptMimes, new ClipData.Item(uris[0]));
- for (int i = 1; i < uris.length; i++) {
- clipData.addItem(new ClipData.Item(uris[i]));
- }
- intent.setClipData(clipData);
- }
-
- intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION
- | Intent.FLAG_GRANT_WRITE_URI_PERMISSION
- | Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
-
- setResult(Activity.RESULT_OK, intent);
- finish();
- }
-
- public static DownloadsActivity get(Fragment fragment) {
- return (DownloadsActivity) fragment.getActivity();
- }
-}
diff --git a/packages/DocumentsUI/src/com/android/documentsui/FilesActivity.java b/packages/DocumentsUI/src/com/android/documentsui/FilesActivity.java
index c56a12f..573e4f3 100644
--- a/packages/DocumentsUI/src/com/android/documentsui/FilesActivity.java
+++ b/packages/DocumentsUI/src/com/android/documentsui/FilesActivity.java
@@ -108,10 +108,10 @@
// authority. That way a misbehaving provider won't result in an ANR.
loadRoot(uri);
} else {
- if (DEBUG) Log.d(TAG, "Launching into Home directory.");
- // If all else fails, try to load "Home" directory.
- final Uri homeUri = DocumentsContract.buildHomeUri();
- loadRoot(homeUri);
+ if (DEBUG) Log.d(TAG, "All other means skipped. Launching into default directory.");
+ Uri defaultUri = DocumentsContract.buildRootUri(
+ "com.android.providers.downloads.documents", "downloads");
+ loadRoot(defaultUri);
}
final @DialogType int dialogType = intent.getIntExtra(
diff --git a/packages/DocumentsUI/src/com/android/documentsui/Metrics.java b/packages/DocumentsUI/src/com/android/documentsui/Metrics.java
index dcaea15..afd308c 100644
--- a/packages/DocumentsUI/src/com/android/documentsui/Metrics.java
+++ b/packages/DocumentsUI/src/com/android/documentsui/Metrics.java
@@ -18,6 +18,7 @@
import static android.os.Environment.STANDARD_DIRECTORIES;
import static com.android.documentsui.Shared.DEBUG;
+
import android.annotation.IntDef;
import android.annotation.Nullable;
import android.annotation.StringDef;
@@ -58,7 +59,7 @@
private static final String COUNT_CREATE_MIME = "docsui_create_mime";
private static final String COUNT_GET_CONTENT_MIME = "docsui_get_content_mime";
private static final String COUNT_BROWSE_ROOT = "docsui_browse_root";
- private static final String COUNT_MANAGE_ROOT = "docsui_manage_root";
+ @Deprecated private static final String COUNT_MANAGE_ROOT = "docsui_manage_root";
private static final String COUNT_MULTI_WINDOW = "docsui_multi_window";
private static final String COUNT_FILEOP_SYSTEM = "docsui_fileop_system";
private static final String COUNT_FILEOP_EXTERNAL = "docsui_fileop_external";
@@ -194,7 +195,7 @@
private static final int ACTION_CREATE = 3;
private static final int ACTION_GET_CONTENT = 4;
private static final int ACTION_OPEN_TREE = 5;
- private static final int ACTION_MANAGE = 6;
+ @Deprecated private static final int ACTION_MANAGE = 6;
private static final int ACTION_BROWSE = 7;
private static final int ACTION_PICK_COPY_DESTINATION = 8;
@@ -246,9 +247,6 @@
case State.ACTION_GET_CONTENT:
logHistogram(context, COUNT_GET_CONTENT_MIME, sanitizeMime(intent.getType()));
break;
- case State.ACTION_MANAGE:
- logHistogram(context, COUNT_MANAGE_ROOT, sanitizeRoot(uri));
- break;
case State.ACTION_BROWSE:
logHistogram(context, COUNT_BROWSE_ROOT, sanitizeRoot(uri));
break;
@@ -641,8 +639,6 @@
return ACTION_GET_CONTENT;
case State.ACTION_OPEN_TREE:
return ACTION_OPEN_TREE;
- case State.ACTION_MANAGE:
- return ACTION_MANAGE;
case State.ACTION_BROWSE:
return ACTION_BROWSE;
case State.ACTION_PICK_COPY_DESTINATION:
diff --git a/packages/DocumentsUI/src/com/android/documentsui/State.java b/packages/DocumentsUI/src/com/android/documentsui/State.java
index 4f460b4..16b7660 100644
--- a/packages/DocumentsUI/src/com/android/documentsui/State.java
+++ b/packages/DocumentsUI/src/com/android/documentsui/State.java
@@ -43,13 +43,15 @@
private static final String TAG = "State";
- public static final int ACTION_OPEN = 1;
- public static final int ACTION_CREATE = 2;
- public static final int ACTION_GET_CONTENT = 3;
- public static final int ACTION_OPEN_TREE = 4;
- public static final int ACTION_MANAGE = 5;
- public static final int ACTION_BROWSE = 6;
- public static final int ACTION_PICK_COPY_DESTINATION = 8;
+ // File manager and related private picking activity.
+ public static final int ACTION_BROWSE = 1;
+ public static final int ACTION_PICK_COPY_DESTINATION = 2;
+
+ // All public picking activities
+ public static final int ACTION_OPEN = 3;
+ public static final int ACTION_CREATE = 4;
+ public static final int ACTION_GET_CONTENT = 5;
+ public static final int ACTION_OPEN_TREE = 6;
@IntDef(flag = true, value = {
MODE_UNKNOWN,
@@ -83,6 +85,10 @@
public boolean showSize;
public boolean localOnly;
public boolean restored;
+ /*
+ * Indicates handler was an external app, like photos.
+ */
+ public boolean external;
// Indicates that a copy operation (or move) includes a directory.
// Why? Directory creation isn't supported by some roots (like Downloads).
@@ -180,6 +186,7 @@
out.writeInt(showSize ? 1 : 0);
out.writeInt(localOnly ? 1 : 0);
out.writeInt(restored ? 1 : 0);
+ out.writeInt(external ? 1 : 0);
DurableUtils.writeToParcel(out, stack);
out.writeMap(dirState);
out.writeParcelable(selectedDocuments, 0);
@@ -208,6 +215,7 @@
state.showSize = in.readInt() != 0;
state.localOnly = in.readInt() != 0;
state.restored = in.readInt() != 0;
+ state.external = in.readInt() != 0;
DurableUtils.readFromParcel(in, state.stack);
in.readMap(state.dirState, loader);
state.selectedDocuments = in.readParcelable(loader);
diff --git a/packages/DocumentsUI/src/com/android/documentsui/dirlist/FragmentTuner.java b/packages/DocumentsUI/src/com/android/documentsui/dirlist/FragmentTuner.java
index adaa850..0ee7623 100644
--- a/packages/DocumentsUI/src/com/android/documentsui/dirlist/FragmentTuner.java
+++ b/packages/DocumentsUI/src/com/android/documentsui/dirlist/FragmentTuner.java
@@ -19,9 +19,9 @@
import static com.android.documentsui.State.ACTION_BROWSE;
import static com.android.documentsui.State.ACTION_CREATE;
import static com.android.documentsui.State.ACTION_GET_CONTENT;
-import static com.android.documentsui.State.ACTION_MANAGE;
import static com.android.documentsui.State.ACTION_OPEN;
import static com.android.documentsui.State.ACTION_OPEN_TREE;
+import static com.android.documentsui.State.ACTION_PICK_COPY_DESTINATION;
import android.content.Context;
import android.provider.DocumentsContract.Document;
@@ -53,8 +53,6 @@
switch (state.action) {
case ACTION_BROWSE:
return new FilesTuner(context, state);
- case ACTION_MANAGE:
- return new DownloadsTuner(context, state);
default:
return new DocumentsTuner(context, state);
}
@@ -157,8 +155,27 @@
@Override
void onModelLoaded(Model model, @ResultType int resultType, boolean isSearch) {
+ boolean showDrawer = false;
+
+ if (mState.restored) {
+ showDrawer = true;
+ }
+ if (MimePredicate.mimeMatches(MimePredicate.VISUAL_MIMES, mState.acceptMimes)) {
+ showDrawer = false;
+ }
+ if (mState.external && mState.action == ACTION_GET_CONTENT) {
+ showDrawer = true;
+ }
+ if (mState.action == ACTION_PICK_COPY_DESTINATION) {
+ showDrawer = true;
+ }
+
// When launched into empty root, open drawer.
- if (model.isEmpty() && !mState.hasInitialLocationChanged() && !isSearch) {
+ if (model.isEmpty()) {
+ showDrawer = true;
+ }
+
+ if (showDrawer && !mState.hasInitialLocationChanged() && !isSearch) {
// This noops on layouts without drawer, so no need to guard.
((BaseActivity) mContext).setRootsDrawerOpen(true);
}
@@ -171,47 +188,6 @@
}
/**
- * Provides support for Platform specific specializations of DirectoryFragment.
- */
- private static final class DownloadsTuner extends FragmentTuner {
-
- public DownloadsTuner(Context context, State state) {
- super(context, state);
- assert(state.action == ACTION_MANAGE);
- }
-
- @Override
- public void updateActionMenu(
- Menu menu, @ResultType int resultType, boolean canDelete, boolean canRename) {
- assert(resultType != DirectoryFragment.TYPE_RECENT_OPEN);
-
- MenuItem open = menu.findItem(R.id.menu_open);
- MenuItem delete = menu.findItem(R.id.menu_delete);
- MenuItem copyTo = menu.findItem(R.id.menu_copy_to);
- MenuItem moveTo = menu.findItem(R.id.menu_move_to);
- MenuItem rename = menu.findItem(R.id.menu_rename);
- MenuItem copy = menu.findItem(R.id.menu_copy_to_clipboard);
-
- open.setVisible(false);
- delete.setVisible(canDelete);
- copy.setEnabled(true); // to clipboard
- copyTo.setVisible(true);
- copyTo.setEnabled(true);
- moveTo.setVisible(true);
- moveTo.setEnabled(true);
- rename.setVisible(false);
- }
-
- @Override
- void onModelLoaded(Model model, @ResultType int resultType, boolean isSearch) {}
-
- @Override
- public boolean enableManagedMode() {
- return mState.stack.root != null && mState.stack.root.isDownloads();
- }
- }
-
- /**
* Provides support for Files activity specific specializations of DirectoryFragment.
*/
private static final class FilesTuner extends FragmentTuner {
diff --git a/packages/DocumentsUI/src/com/android/documentsui/services/CopyJob.java b/packages/DocumentsUI/src/com/android/documentsui/services/CopyJob.java
index ad48a70..9ed2abf 100644
--- a/packages/DocumentsUI/src/com/android/documentsui/services/CopyJob.java
+++ b/packages/DocumentsUI/src/com/android/documentsui/services/CopyJob.java
@@ -299,18 +299,15 @@
if ((src.flags & Document.FLAG_SUPPORTS_COPY) != 0) {
try {
if (DocumentsContract.copyDocument(getClient(src), src.derivedUri,
- dstDirInfo.derivedUri) == null) {
- throw new ResourceException("Provider side copy failed for document %s.",
- src.derivedUri);
+ dstDirInfo.derivedUri) != null) {
+ return;
}
- } catch (ResourceException e) {
- throw e;
} catch (RemoteException | RuntimeException e) {
- throw new ResourceException(
- "Provider side copy failed for document %s due to an exception.",
- src.derivedUri, e);
+ Log.e(TAG, "Provider side copy failed for: " + src.derivedUri
+ + " due to an exception: " + e);
}
- return;
+ // If optimized copy fails, then fallback to byte-by-byte copy.
+ if (DEBUG) Log.d(TAG, "Fallback to byte-by-byte copy for: " + src.derivedUri);
}
}
diff --git a/packages/DocumentsUI/src/com/android/documentsui/services/MoveJob.java b/packages/DocumentsUI/src/com/android/documentsui/services/MoveJob.java
index f1b4681..aaa7596 100644
--- a/packages/DocumentsUI/src/com/android/documentsui/services/MoveJob.java
+++ b/packages/DocumentsUI/src/com/android/documentsui/services/MoveJob.java
@@ -16,6 +16,7 @@
package com.android.documentsui.services;
+import static com.android.documentsui.Shared.DEBUG;
import static com.android.documentsui.services.FileOperationService.OPERATION_MOVE;
import android.app.Notification;
@@ -24,6 +25,7 @@
import android.os.RemoteException;
import android.provider.DocumentsContract;
import android.provider.DocumentsContract.Document;
+import android.util.Log;
import com.android.documentsui.R;
import com.android.documentsui.model.DocumentInfo;
@@ -34,6 +36,8 @@
// TODO: Stop extending CopyJob.
final class MoveJob extends CopyJob {
+ private static final String TAG = "MoveJob";
+
final DocumentInfo mSrcParent;
/**
@@ -89,16 +93,15 @@
try {
if (DocumentsContract.moveDocument(getClient(src), src.derivedUri,
srcParent != null ? srcParent.derivedUri : mSrcParent.derivedUri,
- dest.derivedUri) == null) {
- throw new ResourceException("Provider side move failed for document %s.",
- src.derivedUri);
+ dest.derivedUri) != null) {
+ return;
}
- } catch (RuntimeException | RemoteException e) {
- throw new ResourceException(
- "Provider side move failed for document %s due to an exception.",
- src.derivedUri, e);
+ } catch (RemoteException | RuntimeException e) {
+ Log.e(TAG, "Provider side move failed for: " + src.derivedUri
+ + " due to an exception: " + e);
}
- return;
+ // If optimized move fails, then fallback to byte-by-byte copy.
+ if (DEBUG) Log.d(TAG, "Fallback to byte-by-byte move for: " + src.derivedUri);
}
}
diff --git a/packages/DocumentsUI/tests/src/com/android/documentsui/DocumentsProviderHelper.java b/packages/DocumentsUI/tests/src/com/android/documentsui/DocumentsProviderHelper.java
index af478ea..16ed2d9 100644
--- a/packages/DocumentsUI/tests/src/com/android/documentsui/DocumentsProviderHelper.java
+++ b/packages/DocumentsUI/tests/src/com/android/documentsui/DocumentsProviderHelper.java
@@ -106,13 +106,15 @@
return createDocument(root.documentId, mimeType, name);
}
- public Uri createDocumentWithFlags(String documentId, String mimeType, String name, int flags)
+ public Uri createDocumentWithFlags(String documentId, String mimeType, String name, int flags,
+ String... streamTypes)
throws RemoteException {
Bundle in = new Bundle();
in.putInt(StubProvider.EXTRA_FLAGS, flags);
in.putString(StubProvider.EXTRA_PARENT_ID, documentId);
in.putString(Document.COLUMN_MIME_TYPE, mimeType);
in.putString(Document.COLUMN_DISPLAY_NAME, name);
+ in.putStringArrayList(StubProvider.EXTRA_STREAM_TYPES, Lists.newArrayList(streamTypes));
Bundle out = mClient.call("createDocumentWithFlags", null, in);
Uri uri = out.getParcelable(DocumentsContract.EXTRA_URI);
diff --git a/packages/DocumentsUI/tests/src/com/android/documentsui/DownloadsActivityUiTest.java b/packages/DocumentsUI/tests/src/com/android/documentsui/DownloadsActivityUiTest.java
deleted file mode 100644
index 79d7887..0000000
--- a/packages/DocumentsUI/tests/src/com/android/documentsui/DownloadsActivityUiTest.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.documentsui;
-
-import static com.android.documentsui.StubProvider.ROOT_0_ID;
-
-import android.content.Intent;
-import android.os.RemoteException;
-import android.provider.DocumentsContract;
-import android.support.test.uiautomator.By;
-import android.support.test.uiautomator.Until;
-import android.test.suitebuilder.annotation.LargeTest;
-
-@LargeTest
-public class DownloadsActivityUiTest extends ActivityTest<DownloadsActivity> {
-
- public DownloadsActivityUiTest() {
- super(DownloadsActivity.class);
- }
-
- @Override
- void launchActivity() {
- final Intent intent = new Intent(DocumentsContract.ACTION_MANAGE_ROOT);
- intent.setDataAndType(rootDir0.getUri(), DocumentsContract.Root.MIME_TYPE_ITEM);
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
- setActivityIntent(intent);
- getActivity(); // Launch the activity.
- }
-
- @Override
- void initTestFiles() throws RemoteException {
- mDocsHelper.createDocument(rootDir0, "text/plain", "file0.log");
- mDocsHelper.createDocument(rootDir0, "image/png", "file1.png");
- mDocsHelper.createDocument(rootDir0, "text/csv", "file2.csv");
- }
-
- public void testWindowTitle() throws Exception {
- initTestFiles();
-
- bots.main.assertWindowTitle(ROOT_0_ID);
- }
-
- public void testFilesListed() throws Exception {
- initTestFiles();
-
- bots.directory.assertDocumentsPresent("file0.log", "file1.png", "file2.csv");
- }
-
- public void testFilesList_LiveUpdate() throws Exception {
- initTestFiles();
-
- mDocsHelper.createDocument(rootDir0, "yummers/sandwich", "Ham & Cheese.sandwich");
-
- bots.directory.waitForDocument("Ham & Cheese.sandwich");
- bots.directory.assertDocumentsPresent(
- "file0.log", "file1.png", "file2.csv", "Ham & Cheese.sandwich");
- }
-
- public void testDeleteDocument() throws Exception {
- initTestFiles();
-
- bots.directory.clickDocument("file1.png");
- device.waitForIdle();
- bots.main.menuDelete().click();
-
- bots.directory.waitForDeleteSnackbar();
- bots.directory.assertDocumentsAbsent("file1.png");
-
- bots.directory.waitForDeleteSnackbarGone();
- bots.directory.assertDocumentsAbsent("file1.png");
- }
-
- public void testSupportsShare() throws Exception {
- initTestFiles();
-
- bots.directory.clickDocument("file1.png");
- device.waitForIdle();
- assertNotNull(bots.main.menuShare());
- }
-
- public void testClosesOnBack() throws Exception {
- DownloadsActivity activity = getActivity();
- device.pressBack();
- device.wait(Until.gone(By.text(ROOT_0_ID)), TIMEOUT); // wait for the window to go away
- assertTrue(activity.isDestroyed());
- }
-}
diff --git a/packages/DocumentsUI/tests/src/com/android/documentsui/FilesActivityUiTest.java b/packages/DocumentsUI/tests/src/com/android/documentsui/FilesActivityUiTest.java
index 2486209..056e6ed 100644
--- a/packages/DocumentsUI/tests/src/com/android/documentsui/FilesActivityUiTest.java
+++ b/packages/DocumentsUI/tests/src/com/android/documentsui/FilesActivityUiTest.java
@@ -72,11 +72,11 @@
bots.directory.assertDocumentsPresent("file0.log", "file1.png", "file2.csv");
}
- public void testLoadsHomeDirectoryByDefault() throws Exception {
+ public void testLoadsDownloadsDirectoryByDefault() throws Exception {
initTestFiles();
device.waitForIdle();
- bots.main.assertWindowTitle("Documents");
+ bots.main.assertWindowTitle("Downloads");
}
public void testRootClickSetsWindowTitle() throws Exception {
diff --git a/packages/DocumentsUI/tests/src/com/android/documentsui/StubProvider.java b/packages/DocumentsUI/tests/src/com/android/documentsui/StubProvider.java
index 2527650..f71ce5d 100644
--- a/packages/DocumentsUI/tests/src/com/android/documentsui/StubProvider.java
+++ b/packages/DocumentsUI/tests/src/com/android/documentsui/StubProvider.java
@@ -518,28 +518,29 @@
String rootId = extras.getString(EXTRA_PARENT_ID);
String mimeType = extras.getString(Document.COLUMN_MIME_TYPE);
String name = extras.getString(Document.COLUMN_DISPLAY_NAME);
+ List<String> streamTypes = extras.getStringArrayList(EXTRA_STREAM_TYPES);
int flags = extras.getInt(EXTRA_FLAGS);
Bundle out = new Bundle();
String documentId = null;
try {
- documentId = createDocument(rootId, mimeType, name, flags);
+ documentId = createDocument(rootId, mimeType, name, flags, streamTypes);
Uri uri = DocumentsContract.buildDocumentUri(mAuthority, documentId);
out.putParcelable(DocumentsContract.EXTRA_URI, uri);
} catch (FileNotFoundException e) {
- Log.d(TAG, "Cretaing document with flags failed" + name);
+ Log.d(TAG, "Creating document with flags failed" + name);
}
return out;
}
- public String createDocument(String parentId, String mimeType, String displayName, int flags)
- throws FileNotFoundException {
+ public String createDocument(String parentId, String mimeType, String displayName, int flags,
+ List<String> streamTypes) throws FileNotFoundException {
StubDocument parent = mStorage.get(parentId);
File file = createFile(parent, mimeType, displayName);
final StubDocument document = StubDocument.createDocumentWithFlags(file, mimeType, parent,
- flags);
+ flags, streamTypes);
mStorage.put(document.documentId, document);
Log.d(TAG, "Created document " + document.documentId);
notifyParentChanged(document.parentId);
@@ -787,8 +788,9 @@
}
public static StubDocument createDocumentWithFlags(
- File file, String mimeType, StubDocument parent, int flags) {
- return new StubDocument(file, mimeType, new ArrayList<String>(), flags, parent);
+ File file, String mimeType, StubDocument parent, int flags,
+ List<String> streamTypes) {
+ return new StubDocument(file, mimeType, streamTypes, flags, parent);
}
public static StubDocument createVirtualDocument(
diff --git a/packages/DocumentsUI/tests/src/com/android/documentsui/services/CopyJobTest.java b/packages/DocumentsUI/tests/src/com/android/documentsui/services/CopyJobTest.java
index 543396e..bb7c01a 100644
--- a/packages/DocumentsUI/tests/src/com/android/documentsui/services/CopyJobTest.java
+++ b/packages/DocumentsUI/tests/src/com/android/documentsui/services/CopyJobTest.java
@@ -16,6 +16,10 @@
package com.android.documentsui.services;
+import static com.google.common.collect.Lists.newArrayList;
+
+import android.net.Uri;
+import android.provider.DocumentsContract.Document;
import android.test.suitebuilder.annotation.MediumTest;
import com.android.documentsui.model.DocumentInfo;
@@ -38,6 +42,21 @@
runCopyVirtualNonTypedFileTest();
}
+ public void testCopy_BackendSideVirtualTypedFile_Fallback() throws Exception {
+ mDocs.assertChildCount(mDestRoot, 0);
+
+ Uri testFile = mDocs.createDocumentWithFlags(
+ mSrcRoot.documentId, "virtual/mime-type", "tokyo.sth",
+ Document.FLAG_VIRTUAL_DOCUMENT | Document.FLAG_SUPPORTS_COPY
+ | Document.FLAG_SUPPORTS_MOVE, "application/pdf");
+
+ createJob(newArrayList(testFile)).run();
+
+ mJobListener.waitForFinished();
+ mDocs.assertChildCount(mDestRoot, 1);
+ mDocs.assertHasFile(mDestRoot, "tokyo.sth.pdf"); // Copy should convert file to PDF.
+ }
+
public void testCopyEmptyDir() throws Exception {
runCopyEmptyDirTest();
}
diff --git a/packages/DocumentsUI/tests/src/com/android/documentsui/services/MoveJobTest.java b/packages/DocumentsUI/tests/src/com/android/documentsui/services/MoveJobTest.java
index 749264a..24181d6 100644
--- a/packages/DocumentsUI/tests/src/com/android/documentsui/services/MoveJobTest.java
+++ b/packages/DocumentsUI/tests/src/com/android/documentsui/services/MoveJobTest.java
@@ -59,6 +59,21 @@
mDocs.assertChildCount(mSrcRoot, 1);
}
+ public void testMove_BackendSideVirtualTypedFile_Fallback() throws Exception {
+ Uri testFile = mDocs.createDocumentWithFlags(
+ mSrcRoot.documentId, "virtual/mime-type", "tokyo.sth",
+ Document.FLAG_VIRTUAL_DOCUMENT | Document.FLAG_SUPPORTS_COPY
+ | Document.FLAG_SUPPORTS_MOVE, "application/pdf");
+
+ createJob(newArrayList(testFile)).run();
+ mJobListener.waitForFinished();
+
+ // Should have failed, source not deleted. Moving by bytes for virtual files
+ // is not supported.
+ mDocs.assertChildCount(mDestRoot, 0);
+ mDocs.assertChildCount(mSrcRoot, 1);
+ }
+
public void testMoveEmptyDir() throws Exception {
runCopyEmptyDirTest();
diff --git a/packages/SettingsLib/src/com/android/settingslib/RestrictedLockUtils.java b/packages/SettingsLib/src/com/android/settingslib/RestrictedLockUtils.java
index d0c249f..1f1a9b8 100644
--- a/packages/SettingsLib/src/com/android/settingslib/RestrictedLockUtils.java
+++ b/packages/SettingsLib/src/com/android/settingslib/RestrictedLockUtils.java
@@ -651,8 +651,11 @@
final int disabledColor = context.getColor(R.color.disabled_text_color);
sb.setSpan(new ForegroundColorSpan(disabledColor), 0, sb.length(),
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
- final ImageSpan image = new RestrictedLockImageSpan(context);
- sb.append(" ", image, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
+ textView.setCompoundDrawables(null, null, getRestrictedPadlock(context), null);
+ textView.setCompoundDrawablePadding(context.getResources().getDimensionPixelSize(
+ R.dimen.restricted_icon_padding));
+ } else {
+ textView.setCompoundDrawables(null, null, null, null);
}
textView.setText(sb);
}
diff --git a/packages/SettingsLib/src/com/android/settingslib/accessibility/AccessibilityUtils.java b/packages/SettingsLib/src/com/android/settingslib/accessibility/AccessibilityUtils.java
index 9268994..fcff305 100644
--- a/packages/SettingsLib/src/com/android/settingslib/accessibility/AccessibilityUtils.java
+++ b/packages/SettingsLib/src/com/android/settingslib/accessibility/AccessibilityUtils.java
@@ -145,11 +145,6 @@
Settings.Secure.putStringForUser(context.getContentResolver(),
Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES,
enabledServicesBuilder.toString(), userId);
-
- // Update accessibility enabled.
- Settings.Secure.putIntForUser(context.getContentResolver(),
- Settings.Secure.ACCESSIBILITY_ENABLED, accessibilityEnabled ? 1 : 0,
- userId);
}
private static Set<ComponentName> getInstalledServices(Context context) {
diff --git a/packages/SystemUI/res/values-land/dimens.xml b/packages/SystemUI/res/values-land/dimens.xml
index 26a81c8..585984c 100644
--- a/packages/SystemUI/res/values-land/dimens.xml
+++ b/packages/SystemUI/res/values-land/dimens.xml
@@ -22,6 +22,9 @@
<!-- Standard notification gravity -->
<integer name="notification_panel_layout_gravity">@integer/standard_notification_panel_layout_gravity</integer>
+ <!-- The size of the initial peek area at the bottom of the stack (above the nav bar). -->
+ <dimen name="recents_initial_bottom_peek_size">@dimen/recents_task_bar_height</dimen>
+
<dimen name="docked_divider_handle_width">2dp</dimen>
<dimen name="docked_divider_handle_height">16dp</dimen>
</resources>
diff --git a/packages/SystemUI/res/values-sw600dp/dimens.xml b/packages/SystemUI/res/values-sw600dp/dimens.xml
index 122413d..a2fa3b9 100644
--- a/packages/SystemUI/res/values-sw600dp/dimens.xml
+++ b/packages/SystemUI/res/values-sw600dp/dimens.xml
@@ -99,6 +99,9 @@
<!-- The top padding for the task stack. -->
<dimen name="recents_stack_top_padding">40dp</dimen>
+ <!-- The size of the initial peek area at the bottom of the stack (above the nav bar). -->
+ <dimen name="recents_initial_bottom_peek_size">100dp</dimen>
+
<!-- The side padding for the task stack. -->
<dimen name="recents_stack_left_right_padding">64dp</dimen>
</resources>
diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml
index 3d5c606..a7546a9 100644
--- a/packages/SystemUI/res/values/dimens.xml
+++ b/packages/SystemUI/res/values/dimens.xml
@@ -295,6 +295,9 @@
<!-- The size of the initial peek area at the top of the stack (below the status bar). -->
<dimen name="recents_initial_top_peek_size">8dp</dimen>
+ <!-- The size of the initial peek area at the bottom of the stack (above the nav bar). -->
+ <dimen name="recents_initial_bottom_peek_size">100dp</dimen>
+
<!-- The size of the peek area at the top of the stack (below the status bar). -->
<dimen name="recents_layout_focused_top_peek_size">@dimen/recents_history_button_height</dimen>
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml
index 1f239c3..7838fea 100644
--- a/packages/SystemUI/res/values/strings.xml
+++ b/packages/SystemUI/res/values/strings.xml
@@ -523,6 +523,10 @@
<string name="accessibility_quick_settings_work_mode_changed_off">Work mode turned off.</string>
<!-- Announcement made when the work mode changes to on (not shown on the screen). [CHAR LIMIT=NONE] -->
<string name="accessibility_quick_settings_work_mode_changed_on">Work mode turned on.</string>
+ <!-- Announcement made when the Data Saver changes to off (not shown on the screen). [CHAR LIMIT=NONE] -->
+ <string name="accessibility_quick_settings_data_saver_changed_off">Data Saver turned off.</string>
+ <!-- Announcement made when the Data Saver changes to on (not shown on the screen). [CHAR LIMIT=NONE] -->
+ <string name="accessibility_quick_settings_data_saver_changed_on">Data Saver turned on.</string>
<!-- Content description of the display brightness slider (not shown on the screen). [CHAR LIMIT=NONE] -->
<string name="accessibility_brightness">Display brightness</string>
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSAnimator.java b/packages/SystemUI/src/com/android/systemui/qs/QSAnimator.java
index b611ba3..f601f90 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSAnimator.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSAnimator.java
@@ -198,6 +198,7 @@
}
mNonfirstPageAnimator = new TouchAnimator.Builder()
.addFloat(mQuickQsPanel, "alpha", 1, 0)
+ .setListener(mNonFirstPageListener)
.setEndDelay(.5f)
.build();
}
@@ -267,7 +268,7 @@
private void clearAnimationState() {
final int N = mAllViews.size();
mQuickQsPanel.setAlpha(0);
- mQuickQsPanel.setVisibility(View.VISIBLE);
+ mQuickQsPanel.setVisibility(View.INVISIBLE);
for (int i = 0; i < N; i++) {
View v = mAllViews.get(i);
v.setAlpha(1);
@@ -293,6 +294,14 @@
mQsPanel.post(mUpdateAnimators);
}
+ private final TouchAnimator.Listener mNonFirstPageListener =
+ new TouchAnimator.ListenerAdapter() {
+ @Override
+ public void onAnimationStarted() {
+ mQuickQsPanel.setVisibility(View.VISIBLE);
+ }
+ };
+
private Runnable mUpdateAnimators = new Runnable() {
@Override
public void run() {
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/DataSaverTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/DataSaverTile.java
index fa235d3..74b3fdc 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/DataSaverTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/DataSaverTile.java
@@ -73,6 +73,15 @@
}
@Override
+ protected String composeChangeAnnouncement() {
+ if (mState.value) {
+ return mContext.getString(R.string.accessibility_quick_settings_data_saver_changed_on);
+ } else {
+ return mContext.getString(R.string.accessibility_quick_settings_data_saver_changed_off);
+ }
+ }
+
+ @Override
public void onDataSaverChanged(boolean isDataSaving) {
refreshState(isDataSaving);
}
diff --git a/packages/SystemUI/src/com/android/systemui/recents/Recents.java b/packages/SystemUI/src/com/android/systemui/recents/Recents.java
index da77dfd..73ce26f 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/Recents.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/Recents.java
@@ -23,7 +23,9 @@
import android.content.Intent;
import android.content.ServiceConnection;
import android.content.res.Configuration;
+import android.graphics.Point;
import android.graphics.Rect;
+import android.hardware.display.DisplayManager;
import android.os.Build;
import android.os.Handler;
import android.os.IBinder;
@@ -389,6 +391,13 @@
return false;
}
+ Point realSize = new Point();
+ if (initialBounds == null) {
+ mContext.getSystemService(DisplayManager.class).getDisplay(Display.DEFAULT_DISPLAY)
+ .getRealSize(realSize);
+ initialBounds = new Rect(0, 0, realSize.x, realSize.y);
+ }
+
int currentUser = sSystemServicesProxy.getCurrentUser();
SystemServicesProxy ssp = Recents.getSystemServices();
ActivityManager.RunningTaskInfo topTask = ssp.getTopMostTask();
diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java
index cd1a27f..473956f 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java
@@ -431,13 +431,6 @@
mIgnoreAltTabRelease = false;
mIterateTrigger.stopDozing();
-
- // Workaround for b/22542869, if the RecentsActivity is started again, but without going
- // through SystemUI, we need to reset the config launch flags to ensure that we do not
- // wait on the system to send a signal that was never queued.
- RecentsConfiguration config = Recents.getConfiguration();
- RecentsActivityLaunchState launchState = config.getLaunchState();
- launchState.reset();
}
@Override
@@ -453,6 +446,13 @@
mIsVisible = false;
EventBus.getDefault().send(new RecentsVisibilityChangedEvent(this, false));
MetricsLogger.hidden(this, MetricsEvent.OVERVIEW_ACTIVITY);
+
+ // Workaround for b/22542869, if the RecentsActivity is started again, but without going
+ // through SystemUI, we need to reset the config launch flags to ensure that we do not
+ // wait on the system to send a signal that was never queued.
+ RecentsConfiguration config = Recents.getConfiguration();
+ RecentsActivityLaunchState launchState = config.getLaunchState();
+ launchState.reset();
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsTransitionHelper.java b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsTransitionHelper.java
index dd825cb..a91bbd4 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsTransitionHelper.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsTransitionHelper.java
@@ -105,6 +105,9 @@
animStartedListener = new ActivityOptions.OnAnimationStartedListener() {
@Override
public void onAnimationStarted() {
+ // If we are launching into another task, cancel the previous task's
+ // window transition
+ EventBus.getDefault().send(new CancelEnterRecentsWindowAnimationEvent(task));
EventBus.getDefault().send(new ExitRecentsWindowFirstAnimationFrameEvent());
if (screenPinningRequested) {
@@ -119,6 +122,9 @@
animStartedListener = new ActivityOptions.OnAnimationStartedListener() {
@Override
public void onAnimationStarted() {
+ // If we are launching into another task, cancel the previous task's
+ // window transition
+ EventBus.getDefault().send(new CancelEnterRecentsWindowAnimationEvent(task));
EventBus.getDefault().send(new ExitRecentsWindowFirstAnimationFrameEvent());
}
};
@@ -146,10 +152,6 @@
animStartedListener);
}
}
-
- // If we are launching into another task, cancel the previous task's
- // window transition
- EventBus.getDefault().send(new CancelEnterRecentsWindowAnimationEvent(task));
}
/**
@@ -278,7 +280,8 @@
} else {
layoutAlgorithm.getStackTransformScreenCoordinates(task, stackScroll, mTmpTransform,
null);
- specs.add(composeAnimationSpec(taskView, mTmpTransform, true /* addHeaderBitmap */));
+ specs.add(composeAnimationSpec(stackView, taskView, mTmpTransform,
+ true /* addHeaderBitmap */));
}
return specs;
}
@@ -299,7 +302,8 @@
} else {
layoutAlgorithm.getStackTransformScreenCoordinates(t, stackScroll,
mTmpTransform, null);
- specs.add(composeAnimationSpec(tv, mTmpTransform, true /* addHeaderBitmap */));
+ specs.add(composeAnimationSpec(stackView, tv, mTmpTransform,
+ true /* addHeaderBitmap */));
}
}
}
@@ -318,8 +322,8 @@
/**
* Composes a single animation spec for the given {@link TaskView}
*/
- private static AppTransitionAnimationSpec composeAnimationSpec(TaskView taskView,
- TaskViewTransform transform, boolean addHeaderBitmap) {
+ private static AppTransitionAnimationSpec composeAnimationSpec(TaskStackView stackView,
+ TaskView taskView, TaskViewTransform transform, boolean addHeaderBitmap) {
Bitmap b = null;
if (addHeaderBitmap) {
float scale = transform.scale;
@@ -341,6 +345,10 @@
Rect taskRect = new Rect();
transform.rect.round(taskRect);
+ if (stackView.getStack().getStackFrontMostTask(false /* includeFreeformTasks */) !=
+ taskView.getTask()) {
+ taskRect.bottom = 2 * Recents.getSystemServices().getDisplayRect().height();
+ }
return new AppTransitionAnimationSpec(taskView.getTask().key.id, b, taskRect);
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsViewTouchHandler.java b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsViewTouchHandler.java
index 079d7b9..84590f2 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsViewTouchHandler.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsViewTouchHandler.java
@@ -16,6 +16,7 @@
package com.android.systemui.recents.views;
+import android.app.ActivityManager;
import android.content.res.Configuration;
import android.graphics.Point;
import android.view.MotionEvent;
@@ -149,7 +150,8 @@
mTaskView.setTranslationY(y);
mVisibleDockStates.clear();
- if (!ssp.hasDockedTask() && mRv.getTaskStack().getTaskCount() > 1) {
+ if (ActivityManager.supportsMultiWindow() &&
+ !ssp.hasDockedTask() && mRv.getTaskStack().getTaskCount() > 1) {
if (!event.task.isDockable) {
Toast.makeText(mRv.getContext(), R.string.recents_drag_non_dockable_task_message,
Toast.LENGTH_SHORT).show();
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackLayoutAlgorithm.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackLayoutAlgorithm.java
index a5ed32a..6df5884 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackLayoutAlgorithm.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackLayoutAlgorithm.java
@@ -222,9 +222,11 @@
private Range mUnfocusedRange;
private Range mFocusedRange;
- // The initial offset from the top of the stack
+ // The initial offset from the top and bottom of the stack
@ViewDebug.ExportedProperty(category="recents")
private int mInitialTopPeekHeight;
+ @ViewDebug.ExportedProperty(category="recents")
+ private int mInitialBottomPeekHeight;
// The offset from the top when scrolled to the top of the stack
@ViewDebug.ExportedProperty(category="recents")
@@ -322,6 +324,8 @@
res.getFloat(R.integer.recents_layout_unfocused_range_max));
mFocusState = getInitialFocusState();
mInitialTopPeekHeight = res.getDimensionPixelSize(R.dimen.recents_initial_top_peek_size);
+ mInitialBottomPeekHeight =
+ res.getDimensionPixelSize(R.dimen.recents_initial_bottom_peek_size);
mFocusedTopPeekHeight =
res.getDimensionPixelSize(R.dimen.recents_layout_focused_top_peek_size);
mFocusedBottomTaskPeekHeight =
@@ -508,10 +512,13 @@
float initialPeekOffsetNormX = mUnfocusedCurveInterpolator.getX(initialPeekOffsetPct);
float initialFocusedOffset = mStackRect.height() - mInitialTopPeekHeight -
(mHeaderBarHeight * 1f) + 1;
- float initialFocusedOffsetPct = (float) initialFocusedOffset / mStackRect.height();
+ float initialFocusedOffsetPct = initialFocusedOffset / mStackRect.height();
float initialFocusedNormX = mUnfocusedCurveInterpolator.getX(initialFocusedOffsetPct);
- int initialBottomOffset = mStackBottomOffset + mHeaderBarHeight;
- float initialBottomOffsetPct = (float) initialBottomOffset / mStackRect.height();
+ float initialBottomOffset = mStackBottomOffset +
+ (ssp.hasDockedTask()
+ ? mHeaderBarHeight
+ : mInitialBottomPeekHeight);
+ float initialBottomOffsetPct = initialBottomOffset / mStackRect.height();
float initialBottomNormX = mUnfocusedCurveInterpolator.getX(initialBottomOffsetPct);
/*
// If we want to offset the top card slightly
diff --git a/packages/SystemUI/src/com/android/systemui/shortcut/ShortcutKeyDispatcher.java b/packages/SystemUI/src/com/android/systemui/shortcut/ShortcutKeyDispatcher.java
index 8f8683b..69dcabe 100644
--- a/packages/SystemUI/src/com/android/systemui/shortcut/ShortcutKeyDispatcher.java
+++ b/packages/SystemUI/src/com/android/systemui/shortcut/ShortcutKeyDispatcher.java
@@ -17,18 +17,31 @@
package com.android.systemui.shortcut;
import android.accessibilityservice.AccessibilityServiceInfo;
+import android.app.ActivityManager;
+import android.app.ActivityManagerNative;
+import android.app.IActivityManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.pm.ServiceInfo;
+import android.content.res.Configuration;
import android.os.RemoteException;
+import android.util.DisplayMetrics;
import android.util.Log;
import android.view.IWindowManager;
import android.view.KeyEvent;
+import android.view.WindowManager;
import android.view.WindowManagerGlobal;
import android.view.accessibility.AccessibilityManager;
+import com.android.internal.logging.MetricsLogger;
+import com.android.internal.logging.MetricsProto.MetricsEvent;
+import com.android.internal.policy.DividerSnapAlgorithm;
import com.android.settingslib.accessibility.AccessibilityUtils;
import com.android.systemui.R;
import com.android.systemui.SystemUI;
+import com.android.systemui.recents.Recents;
+import com.android.systemui.stackdivider.Divider;
+import com.android.systemui.stackdivider.DividerView;
+import com.android.systemui.statusbar.phone.NavigationBarGestureHelper;
import java.util.List;
import java.util.Set;
@@ -42,28 +55,70 @@
private static final String TAG = "ShortcutKeyDispatcher";
private ShortcutKeyServiceProxy mShortcutKeyServiceProxy = new ShortcutKeyServiceProxy(this);
- private IWindowManager windowManagerService = WindowManagerGlobal.getWindowManagerService();
+ private IWindowManager mWindowManagerService = WindowManagerGlobal.getWindowManagerService();
+ private IActivityManager mActivityManager = ActivityManagerNative.getDefault();
protected final long META_MASK = ((long) KeyEvent.META_META_ON) << Integer.SIZE;
protected final long ALT_MASK = ((long) KeyEvent.META_ALT_ON) << Integer.SIZE;
protected final long CTRL_MASK = ((long) KeyEvent.META_CTRL_ON) << Integer.SIZE;
protected final long SHIFT_MASK = ((long) KeyEvent.META_SHIFT_ON) << Integer.SIZE;
+ protected final long SC_DOCK_LEFT = META_MASK | KeyEvent.KEYCODE_LEFT_BRACKET;
+ protected final long SC_DOCK_RIGHT = META_MASK | KeyEvent.KEYCODE_RIGHT_BRACKET;
+
/**
* Registers a shortcut key to window manager.
* @param shortcutCode packed representation of shortcut key code and meta information
*/
public void registerShortcutKey(long shortcutCode) {
try {
- windowManagerService.registerShortcutKey(shortcutCode, mShortcutKeyServiceProxy);
+ mWindowManagerService.registerShortcutKey(shortcutCode, mShortcutKeyServiceProxy);
} catch (RemoteException e) {
// Do nothing
}
}
@Override
- public void onShortcutKeyPressed(long shortcutCode) {}
+ public void onShortcutKeyPressed(long shortcutCode) {
+ int orientation = mContext.getResources().getConfiguration().orientation;
+ if ((shortcutCode == SC_DOCK_LEFT || shortcutCode == SC_DOCK_RIGHT)
+ && orientation == Configuration.ORIENTATION_LANDSCAPE) {
+ handleDockKey(shortcutCode);
+ }
+ }
@Override
- public void start() {}
+ public void start() {
+ registerShortcutKey(SC_DOCK_LEFT);
+ registerShortcutKey(SC_DOCK_RIGHT);
+ }
+
+ private void handleDockKey(long shortcutCode) {
+ try {
+ int dockSide = mWindowManagerService.getDockedStackSide();
+ if (dockSide == WindowManager.DOCKED_INVALID) {
+ // If there is no window docked, we dock the top-most window.
+ Recents recents = getComponent(Recents.class);
+ int dockMode = (shortcutCode == SC_DOCK_LEFT)
+ ? ActivityManager.DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT
+ : ActivityManager.DOCKED_STACK_CREATE_MODE_BOTTOM_OR_RIGHT;
+ recents.dockTopTask(NavigationBarGestureHelper.DRAG_MODE_NONE, dockMode, null);
+ MetricsLogger.action(mContext, MetricsEvent.WINDOW_DOCK_SHORTCUTS);
+ } else {
+ // If there is already a docked window, we respond by resizing the docking pane.
+ DividerView dividerView = getComponent(Divider.class).getView();
+ DividerSnapAlgorithm snapAlgorithm = dividerView.getSnapAlgorithm();
+ int dividerPosition = dividerView.getCurrentPosition();
+ DividerSnapAlgorithm.SnapTarget currentTarget =
+ snapAlgorithm.calculateNonDismissingSnapTarget(dividerPosition);
+ int increment = (shortcutCode == SC_DOCK_LEFT) ? -1 : 1;
+ DividerSnapAlgorithm.SnapTarget target = snapAlgorithm.cycleNonDismissTarget(
+ currentTarget, increment);
+ dividerView.startDragging(true /* animate */, false /* touching */);
+ dividerView.stopDragging(target.position, 0f, true /* avoidDismissStart */);
+ }
+ } catch (RemoteException e) {
+ Log.e(TAG, "handleDockKey() failed.");
+ }
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
index c2e1f7d..51553be 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
@@ -1349,7 +1349,7 @@
float y = event.getY();
NotificationHeaderView header = getVisibleNotificationHeader();
if (header != null) {
- return header.isInTouchRect(x, y);
+ return header.isInTouchRect(x - getTranslation(), y);
}
return super.disallowSingleClick(event);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableView.java b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableView.java
index c0e4340..91418ad 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableView.java
@@ -43,6 +43,7 @@
private boolean mWillBeGone;
private int mMinClipTopAmount = 0;
private boolean mClipToActualHeight = true;
+ private boolean mChangingPosition = false;
public ExpandableView(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -407,6 +408,14 @@
return 0;
}
+ public void setChangingPosition(boolean changingPosition) {
+ mChangingPosition = changingPosition;
+ }
+
+ public boolean isChangingPosition() {
+ return mChangingPosition;
+ }
+
/**
* A listener notifying when {@link #getActualHeight} changes.
*/
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/LockscreenWallpaper.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/LockscreenWallpaper.java
index 5b4a3f0..65e7973 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/LockscreenWallpaper.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/LockscreenWallpaper.java
@@ -105,7 +105,6 @@
if (mSelectedUser != null && mSelectedUser.getIdentifier() != mCurrentUserId) {
// When selected user is different from the current user, show the selected
// user's static wallpaper.
- mWallpaperManager.forgetLoadedWallpaper();
mCache = mWallpaperManager.getBitmapAsUser(mSelectedUser.getIdentifier());
} else {
// When there is no selected user, or it's same as the current user, show the
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
index 553d7f8..e5e3caf 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
@@ -277,7 +277,8 @@
public void updateResources() {
int panelWidth = getResources().getDimensionPixelSize(R.dimen.notification_panel_width);
int panelGravity = getResources().getInteger(R.integer.notification_panel_layout_gravity);
- FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mQsContainer.getLayoutParams();
+ FrameLayout.LayoutParams lp =
+ (FrameLayout.LayoutParams) mQsDensityContainer.getLayoutParams();
if (lp.width != panelWidth) {
lp.width = panelWidth;
lp.gravity = panelGravity;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
index 9f97c71..8cfda3f 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -1012,7 +1012,7 @@
}
}
- private void clearAllNotifications() {
+ public void clearAllNotifications() {
// animate-swipe all dismissable notifications, then animate the shade closed
int numChildren = mStackScroller.getChildCount();
@@ -1149,9 +1149,10 @@
@Override
public boolean onLongClick(View v) {
- if (mRecents == null) {
+ if (mRecents == null || !ActivityManager.supportsMultiWindow()) {
return false;
}
+
boolean initiallyDocked = WindowManagerProxy.getInstance().getDockSide()
== WindowManager.DOCKED_INVALID;
boolean dockedAtEnd = toggleSplitScreenMode();
@@ -1172,13 +1173,8 @@
}
int dockSide = WindowManagerProxy.getInstance().getDockSide();
if (dockSide == WindowManager.DOCKED_INVALID) {
- Point realSize = new Point();
- mContext.getSystemService(DisplayManager.class).getDisplay(Display.DEFAULT_DISPLAY)
- .getRealSize(realSize);
- Rect initialBounds= new Rect(0, 0, realSize.x, realSize.y);
return mRecents.dockTopTask(NavigationBarGestureHelper.DRAG_MODE_NONE,
- ActivityManager.DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT,
- initialBounds);
+ ActivityManager.DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT, null);
} else {
EventBus.getDefault().send(new UndockingTaskEvent());
return false;
@@ -1951,6 +1947,7 @@
// We are unlocking directly - no animation!
mBackdrop.setVisibility(View.GONE);
+ mBackdropBack.setImageDrawable(null);
} else {
mBackdrop.animate()
// Never let the alpha become zero - otherwise the RenderNode
@@ -1966,7 +1963,7 @@
public void run() {
mBackdrop.setVisibility(View.GONE);
mBackdropFront.animate().cancel();
- mBackdropBack.animate().cancel();
+ mBackdropBack.setImageDrawable(null);
mHandler.post(mHideBackdropFront);
}
});
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowManager.java
index fcaf050..77ece93 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowManager.java
@@ -173,7 +173,7 @@
private void applyInputFeatures(State state) {
if (state.isKeyguardShowingAndNotOccluded()
&& state.statusBarState == StatusBarState.KEYGUARD
- && !state.qsExpanded) {
+ && !state.qsExpanded && !state.forceUserActivity) {
mLpChanged.inputFeatures |=
WindowManager.LayoutParams.INPUT_FEATURE_DISABLE_USER_ACTIVITY;
} else {
@@ -265,6 +265,11 @@
apply(mCurrentState);
}
+ public void setForceUserActivity(boolean forceUserActivity) {
+ mCurrentState.forceUserActivity = forceUserActivity;
+ apply(mCurrentState);
+ }
+
public void setHeadsUpShowing(boolean showing) {
mCurrentState.headsUpShowing = showing;
apply(mCurrentState);
@@ -332,6 +337,7 @@
boolean forceStatusBarVisible;
boolean forceCollapsed;
boolean forceDozeBrightness;
+ boolean forceUserActivity;
/**
* The {@link BaseStatusBar} state from the status bar.
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java
index d9e8bd9..29b0f4b 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java
@@ -155,8 +155,21 @@
}
@Override
+ protected void onAttachedToWindow() {
+ super.onAttachedToWindow();
+ if (mEntry.row.isChangingPosition()) {
+ if (getVisibility() == VISIBLE && mEditText.isFocusable()) {
+ mEditText.requestFocus();
+ }
+ }
+ }
+
+ @Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
+ if (mEntry.row.isChangingPosition()) {
+ return;
+ }
mController.removeRemoteInput(mEntry);
}
@@ -229,6 +242,9 @@
}
private void defocusIfNeeded() {
+ if (mDefocusListener.mEntry.row.isChangingPosition()) {
+ return;
+ }
if (isFocusable() && isEnabled()) {
setInnerFocusable(false);
if (mDefocusListener != null) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
index 2ea9507..9dfe369 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
@@ -2252,8 +2252,10 @@
int currentIndex = indexOfChild(child);
if (child != null && child.getParent() == this && currentIndex != newIndex) {
mChangePositionInProgress = true;
+ ((ExpandableView)child).setChangingPosition(true);
removeView(child);
addView(child, newIndex);
+ ((ExpandableView)child).setChangingPosition(false);
mChangePositionInProgress = false;
if (mIsExpanded && mAnimationsEnabled && child.getVisibility() != View.GONE) {
mChildrenChangingPositions.add(child);
diff --git a/proto/src/metrics_constants.proto b/proto/src/metrics_constants.proto
index fb50df9..d36a1d7 100644
--- a/proto/src/metrics_constants.proto
+++ b/proto/src/metrics_constants.proto
@@ -1993,6 +1993,9 @@
// Settings -> Apps -> Gear -> Special access
SPECIAL_ACCESS = 351;
+ // Logs that the user docks window via shortcut key.
+ WINDOW_DOCK_SHORTCUTS = 352;
+
// Add new aosp constants above this line.
// END OF AOSP CONSTANTS
}
diff --git a/services/accessibility/java/com/android/server/accessibility/AccessibilityGestureDetector.java b/services/accessibility/java/com/android/server/accessibility/AccessibilityGestureDetector.java
index 284c309..3ac81f6 100644
--- a/services/accessibility/java/com/android/server/accessibility/AccessibilityGestureDetector.java
+++ b/services/accessibility/java/com/android/server/accessibility/AccessibilityGestureDetector.java
@@ -37,7 +37,8 @@
/**
* This class handles gesture detection for the Touch Explorer. It collects
- * touch events, and sends events to mListener as gestures are recognized.
+ * touch events and determines when they match a gesture, as well as when they
+ * won't match a gesture. These state changes are then surfaced to mListener.
*/
class AccessibilityGestureDetector extends GestureDetector.SimpleOnGestureListener {
@@ -46,12 +47,66 @@
// Tag for logging received events.
private static final String LOG_TAG = "AccessibilityGestureDetector";
+ /**
+ * Listener functions are called as a result of onMoveEvent(). The current
+ * MotionEvent in the context of these functions is the event passed into
+ * onMotionEvent.
+ */
public interface Listener {
- public void onDoubleTapAndHold(MotionEvent event, int policyFlags);
- public boolean onDoubleTap(MotionEvent event, int policyFlags);
- public boolean onGestureCompleted(int gestureId);
- public void onGestureStarted();
- public void onGestureCancelled(MotionEvent event, int policyFlags);
+ /**
+ * Called when the user has performed a double tap and then held down
+ * the second tap.
+ *
+ * @param event The most recent MotionEvent received.
+ * @param policyFlags The policy flags of the most recent event.
+ */
+ void onDoubleTapAndHold(MotionEvent event, int policyFlags);
+
+ /**
+ * Called when the user touches the screen on the second tap of a double
+ * tap.
+ *
+ * @return true if the event is consumed, else false
+ */
+ boolean onDoubleTapStarted();
+
+ /**
+ * Called when the user lifts their finger on the second tap of a double
+ * tap.
+ *
+ * @param event The most recent MotionEvent received.
+ * @param policyFlags The policy flags of the most recent event.
+ *
+ * @return true if the event is consumed, else false
+ */
+ boolean onDoubleTap(MotionEvent event, int policyFlags);
+
+ /**
+ * Called when the system has decided the event stream is a gesture.
+ *
+ * @return true if the event is consumed, else false
+ */
+ boolean onGestureStarted();
+
+ /**
+ * Called when an event stream is recognized as a gesture.
+ *
+ * @param gestureId ID of the gesture that was recognized.
+ *
+ * @return true if the event is consumed, else false
+ */
+ boolean onGestureCompleted(int gestureId);
+
+ /**
+ * Called when the system has decided an event stream doesn't match any
+ * known gesture.
+ *
+ * @param event The most recent MotionEvent received.
+ * @param policyFlags The policy flags of the most recent event.
+ *
+ * @return true if the event is consumed, else false
+ */
+ public boolean onGestureCancelled(MotionEvent event, int policyFlags);
}
private final Listener mListener;
@@ -145,6 +200,18 @@
context.getResources().getDisplayMetrics()) * GESTURE_CONFIRM_MM;
}
+ /**
+ * Handle a motion event. If an action is completed, the appropriate
+ * callback on mListener is called, and the return value of the callback is
+ * passed to the caller.
+ *
+ * @param event The raw motion event. It's important that this be the raw
+ * event, before any transformations have been applied, so that measurements
+ * can be made in physical units.
+ * @param policyFlags Policy flags for the event.
+ *
+ * @return true if the event is consumed, else false
+ */
public boolean onMotionEvent(MotionEvent event, int policyFlags) {
final float x = event.getX();
final float y = event.getY();
@@ -183,7 +250,7 @@
// the event.
if (!mGestureStarted) {
mGestureStarted = true;
- mListener.onGestureStarted();
+ return mListener.onGestureStarted();
}
} else {
final long timeDelta = time - mBaseTime;
@@ -195,8 +262,7 @@
// timeout, cancel gesture detection.
if (timeDelta > threshold) {
cancelGesture();
- mListener.onGestureCancelled(event, policyFlags);
- return false;
+ return mListener.onGestureCancelled(event, policyFlags);
}
}
@@ -211,16 +277,13 @@
break;
case MotionEvent.ACTION_UP:
- if (maybeFinishDoubleTap(event, policyFlags)) {
- return true;
+ if (mDoubleTapDetected) {
+ return finishDoubleTap(event, policyFlags);
}
if (mGestureStarted) {
mStrokeBuffer.add(new GesturePoint(x, y, time));
- if (!recognizeGesture()) {
- mListener.onGestureCancelled(event, policyFlags);
- }
- return true;
+ return recognizeGesture(event, policyFlags);
}
break;
@@ -244,8 +307,8 @@
case MotionEvent.ACTION_POINTER_UP:
// If we're detecting taps on the second finger, see if we
// should finish the double tap.
- if (mSecondFingerDoubleTap && maybeFinishDoubleTap(event, policyFlags)) {
- return true;
+ if (mSecondFingerDoubleTap && mDoubleTapDetected) {
+ return finishDoubleTap(event, policyFlags);
}
break;
@@ -308,7 +371,7 @@
// The processing of the double tap is deferred until the finger is
// lifted, so that we can detect a long press on the second tap.
mDoubleTapDetected = true;
- return true;
+ return mListener.onDoubleTapStarted();
}
private void maybeSendLongPress(MotionEvent event, int policyFlags) {
@@ -321,11 +384,7 @@
mListener.onDoubleTapAndHold(event, policyFlags);
}
- private boolean maybeFinishDoubleTap(MotionEvent event, int policyFlags) {
- if (!mDoubleTapDetected) {
- return false;
- }
-
+ private boolean finishDoubleTap(MotionEvent event, int policyFlags) {
clear();
return mListener.onDoubleTap(event, policyFlags);
@@ -337,7 +396,7 @@
mStrokeBuffer.clear();
}
- private boolean recognizeGesture() {
+ private boolean recognizeGesture(MotionEvent event, int policyFlags) {
Gesture gesture = new Gesture();
gesture.addStroke(new GestureStroke(mStrokeBuffer));
@@ -351,16 +410,14 @@
}
try {
final int gestureId = Integer.parseInt(bestPrediction.name);
- if (mListener.onGestureCompleted(gestureId)) {
- return true;
- }
+ return mListener.onGestureCompleted(gestureId);
} catch (NumberFormatException nfe) {
Slog.w(LOG_TAG, "Non numeric gesture id:" + bestPrediction.name);
}
}
}
- return false;
+ return mListener.onGestureCancelled(event, policyFlags);
}
private MotionEvent mapSecondPointerToFirstPointer(MotionEvent event) {
diff --git a/services/accessibility/java/com/android/server/accessibility/TouchExplorer.java b/services/accessibility/java/com/android/server/accessibility/TouchExplorer.java
index 3ecff40..cd8b792 100644
--- a/services/accessibility/java/com/android/server/accessibility/TouchExplorer.java
+++ b/services/accessibility/java/com/android/server/accessibility/TouchExplorer.java
@@ -390,6 +390,11 @@
}
@Override
+ public boolean onDoubleTapStarted() {
+ return true;
+ }
+
+ @Override
public boolean onDoubleTap(MotionEvent event, int policyFlags) {
// Ignore the event if we aren't touch exploring.
if (mCurrentState != STATE_TOUCH_EXPLORING) {
@@ -437,6 +442,20 @@
}
@Override
+ public boolean onGestureStarted() {
+ // We have to perform gesture detection, so
+ // clear the current state and try to detect.
+ mCurrentState = STATE_GESTURE_DETECTING;
+ mSendHoverEnterAndMoveDelayed.cancel();
+ mSendHoverExitDelayed.cancel();
+ mExitGestureDetectionModeDelayed.post();
+ // Send accessibility event to announce the start
+ // of gesture recognition.
+ sendAccessibilityEvent(AccessibilityEvent.TYPE_GESTURE_DETECTION_START);
+ return false;
+ }
+
+ @Override
public boolean onGestureCompleted(int gestureId) {
if (mCurrentState != STATE_GESTURE_DETECTING) {
return false;
@@ -450,36 +469,26 @@
}
@Override
- public void onGestureStarted() {
- // We have to perform gesture detection, so
- // clear the current state and try to detect.
- mCurrentState = STATE_GESTURE_DETECTING;
- mSendHoverEnterAndMoveDelayed.cancel();
- mSendHoverExitDelayed.cancel();
- mExitGestureDetectionModeDelayed.post();
- // Send accessibility event to announce the start
- // of gesture recognition.
- sendAccessibilityEvent(AccessibilityEvent.TYPE_GESTURE_DETECTION_START);
- }
+ public boolean onGestureCancelled(MotionEvent event, int policyFlags) {
+ if (mCurrentState == STATE_GESTURE_DETECTING) {
+ endGestureDetection();
+ return true;
+ } else if (mCurrentState == STATE_TOUCH_EXPLORING) {
+ // If the finger is still moving, pass the event on.
+ if (event.getActionMasked() == MotionEvent.ACTION_MOVE) {
+ final int pointerId = mReceivedPointerTracker.getPrimaryPointerId();
+ final int pointerIdBits = (1 << pointerId);
- @Override
- public void onGestureCancelled(MotionEvent event, int policyFlags) {
- if (mCurrentState == STATE_GESTURE_DETECTING) {
- endGestureDetection();
- } else if (mCurrentState == STATE_TOUCH_EXPLORING) {
- // If the finger is still moving, pass the event on.
- if (event.getActionMasked() == MotionEvent.ACTION_MOVE) {
- final int pointerId = mReceivedPointerTracker.getPrimaryPointerId();
- final int pointerIdBits = (1 << pointerId);
-
- // We have just decided that the user is touch,
- // exploring so start sending events.
- mSendHoverEnterAndMoveDelayed.addEvent(event);
- mSendHoverEnterAndMoveDelayed.forceSendAndRemove();
- mSendHoverExitDelayed.cancel();
- sendMotionEvent(event, MotionEvent.ACTION_HOVER_MOVE, pointerIdBits, policyFlags);
- }
- }
+ // We have just decided that the user is touch,
+ // exploring so start sending events.
+ mSendHoverEnterAndMoveDelayed.addEvent(event);
+ mSendHoverEnterAndMoveDelayed.forceSendAndRemove();
+ mSendHoverExitDelayed.cancel();
+ sendMotionEvent(event, MotionEvent.ACTION_HOVER_MOVE, pointerIdBits, policyFlags);
+ return true;
+ }
+ }
+ return false;
}
/**
diff --git a/services/core/java/com/android/server/am/ActivityStack.java b/services/core/java/com/android/server/am/ActivityStack.java
index d11b436..5561456 100644
--- a/services/core/java/com/android/server/am/ActivityStack.java
+++ b/services/core/java/com/android/server/am/ActivityStack.java
@@ -20,6 +20,7 @@
import static android.app.ActivityManager.StackId.FREEFORM_WORKSPACE_STACK_ID;
import static android.app.ActivityManager.StackId.FULLSCREEN_WORKSPACE_STACK_ID;
import static android.app.ActivityManager.StackId.HOME_STACK_ID;
+import static android.app.ActivityManager.StackId.INVALID_STACK_ID;
import static android.app.ActivityManager.StackId.PINNED_STACK_ID;
import static android.content.pm.ActivityInfo.CONFIG_ORIENTATION;
import static android.content.pm.ActivityInfo.CONFIG_SCREEN_LAYOUT;
@@ -1404,22 +1405,37 @@
* needed. A stack is considered translucent if it don't contain a visible or
* starting (about to be visible) activity that is fullscreen (opaque).
* @param starting The currently starting activity or null if there is none.
+ * @param stackBehindId The id of the stack directly behind this one.
*/
- private boolean isStackTranslucent(ActivityRecord starting) {
+ private boolean isStackTranslucent(ActivityRecord starting, int stackBehindId) {
for (int taskNdx = mTaskHistory.size() - 1; taskNdx >= 0; --taskNdx) {
final TaskRecord task = mTaskHistory.get(taskNdx);
final ArrayList<ActivityRecord> activities = task.mActivities;
for (int activityNdx = activities.size() - 1; activityNdx >= 0; --activityNdx) {
final ActivityRecord r = activities.get(activityNdx);
- // Conditions for an activity to obscure the stack we're
- // examining:
- // 1. Not Finishing AND (Visible or the Starting activity) AND:
- // 2. Either:
- // - Full Screen Activity OR
- // - On top of Home and our stack is NOT home
- if (!r.finishing && (r.visible || r == starting) && (r.fullscreen ||
- (!isHomeStack() && r.frontOfTask && task.isOverHomeStack()))) {
+ if (r.finishing) {
+ // We don't factor in finishing activities when determining translucency since
+ // they will be gone soon.
+ continue;
+ }
+
+ if (!r.visible && r != starting) {
+ // Also ignore invisible activities that are not the currently starting
+ // activity (about to be visible).
+ continue;
+ }
+
+ if (r.fullscreen) {
+ // Stack isn't translucent if it has at least one fullscreen activity
+ // that is visible.
+ return false;
+ }
+
+ if (!isHomeStack() && r.frontOfTask
+ && task.isOverHomeStack() && stackBehindId != HOME_STACK_ID) {
+ // Stack isn't translucent if it's top activity should have the home stack
+ // behind it and the stack currently behind it isn't the home stack.
return false;
}
}
@@ -1475,30 +1491,33 @@
: STACK_INVISIBLE;
}
- // Find the first stack below focused stack that actually got something visible.
- int belowFocusedIndex = mStacks.indexOf(focusedStack) - 1;
- while (belowFocusedIndex >= 0 &&
- mStacks.get(belowFocusedIndex).topRunningActivityLocked() == null) {
- belowFocusedIndex--;
+ // Find the first stack behind focused stack that actually got something visible.
+ int stackBehindFocusedIndex = mStacks.indexOf(focusedStack) - 1;
+ while (stackBehindFocusedIndex >= 0 &&
+ mStacks.get(stackBehindFocusedIndex).topRunningActivityLocked() == null) {
+ stackBehindFocusedIndex--;
}
if ((focusedStackId == DOCKED_STACK_ID || focusedStackId == PINNED_STACK_ID)
- && stackIndex == belowFocusedIndex) {
+ && stackIndex == stackBehindFocusedIndex) {
// Stacks directly behind the docked or pinned stack are always visible.
return STACK_VISIBLE;
}
+ final int stackBehindFocusedId = (stackBehindFocusedIndex >= 0)
+ ? mStacks.get(stackBehindFocusedIndex).mStackId : INVALID_STACK_ID;
+
if (focusedStackId == FULLSCREEN_WORKSPACE_STACK_ID
- && focusedStack.isStackTranslucent(starting)) {
+ && focusedStack.isStackTranslucent(starting, stackBehindFocusedId)) {
// Stacks behind the fullscreen stack with a translucent activity are always
// visible so they can act as a backdrop to the translucent activity.
// For example, dialog activities
- if (stackIndex == belowFocusedIndex) {
+ if (stackIndex == stackBehindFocusedIndex) {
return STACK_VISIBLE;
}
- if (belowFocusedIndex >= 0) {
- final ActivityStack stack = mStacks.get(belowFocusedIndex);
- if ((stack.mStackId == DOCKED_STACK_ID || stack.mStackId == PINNED_STACK_ID)
- && stackIndex == (belowFocusedIndex - 1)) {
+ if (stackBehindFocusedIndex >= 0) {
+ if ((stackBehindFocusedId == DOCKED_STACK_ID
+ || stackBehindFocusedId == PINNED_STACK_ID)
+ && stackIndex == (stackBehindFocusedIndex - 1)) {
// The stack behind the docked or pinned stack is also visible so we can have a
// complete backdrop to the translucent activity when the docked stack is up.
return STACK_VISIBLE;
@@ -1523,7 +1542,7 @@
return STACK_INVISIBLE;
}
- if (!stack.isStackTranslucent(starting)) {
+ if (!stack.isStackTranslucent(starting, INVALID_STACK_ID)) {
return STACK_INVISIBLE;
}
}
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
index 02c786e..516602e 100644
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -1444,16 +1444,7 @@
*/
@Override
public void unregisterListener(INotificationListener token, int userid) {
- final long identity = Binder.clearCallingIdentity();
- try {
- if(mRankerServices.checkServiceTokenLocked(token) != null) {
- mRankerServices.unregisterService(token, userid);
- } else {
- mListeners.unregisterService(token, userid);
- }
- } finally {
- Binder.restoreCallingIdentity(identity);
- }
+ mListeners.unregisterService(token, userid);
}
/**
diff --git a/services/core/java/com/android/server/pm/ShortcutService.java b/services/core/java/com/android/server/pm/ShortcutService.java
index 9d8def6..1cd0592 100644
--- a/services/core/java/com/android/server/pm/ShortcutService.java
+++ b/services/core/java/com/android/server/pm/ShortcutService.java
@@ -111,8 +111,8 @@
public class ShortcutService extends IShortcutService.Stub {
static final String TAG = "ShortcutService";
- private static final boolean DEBUG = true; // STOPSHIP if true
- private static final boolean DEBUG_LOAD = true; // STOPSHIP if true
+ static final boolean DEBUG = false; // STOPSHIP if true
+ static final boolean DEBUG_LOAD = false; // STOPSHIP if true
@VisibleForTesting
static final long DEFAULT_RESET_INTERVAL_SEC = 24 * 60 * 60; // 1 day
@@ -148,27 +148,27 @@
static final String DIRECTORY_BITMAPS = "bitmaps";
- private static final String TAG_ROOT = "root";
- private static final String TAG_PACKAGE = "package";
- private static final String TAG_LAST_RESET_TIME = "last_reset_time";
- private static final String TAG_INTENT_EXTRAS = "intent-extras";
- private static final String TAG_EXTRAS = "extras";
- private static final String TAG_SHORTCUT = "shortcut";
+ static final String TAG_ROOT = "root";
+ static final String TAG_PACKAGE = "package";
+ static final String TAG_LAST_RESET_TIME = "last_reset_time";
+ static final String TAG_INTENT_EXTRAS = "intent-extras";
+ static final String TAG_EXTRAS = "extras";
+ static final String TAG_SHORTCUT = "shortcut";
- private static final String ATTR_VALUE = "value";
- private static final String ATTR_NAME = "name";
- private static final String ATTR_DYNAMIC_COUNT = "dynamic-count";
- private static final String ATTR_CALL_COUNT = "call-count";
- private static final String ATTR_LAST_RESET = "last-reset";
- private static final String ATTR_ID = "id";
- private static final String ATTR_ACTIVITY = "activity";
- private static final String ATTR_TITLE = "title";
- private static final String ATTR_INTENT = "intent";
- private static final String ATTR_WEIGHT = "weight";
- private static final String ATTR_TIMESTAMP = "timestamp";
- private static final String ATTR_FLAGS = "flags";
- private static final String ATTR_ICON_RES = "icon-res";
- private static final String ATTR_BITMAP_PATH = "bitmap-path";
+ static final String ATTR_VALUE = "value";
+ static final String ATTR_NAME = "name";
+ static final String ATTR_DYNAMIC_COUNT = "dynamic-count";
+ static final String ATTR_CALL_COUNT = "call-count";
+ static final String ATTR_LAST_RESET = "last-reset";
+ static final String ATTR_ID = "id";
+ static final String ATTR_ACTIVITY = "activity";
+ static final String ATTR_TITLE = "title";
+ static final String ATTR_INTENT = "intent";
+ static final String ATTR_WEIGHT = "weight";
+ static final String ATTR_TIMESTAMP = "timestamp";
+ static final String ATTR_FLAGS = "flags";
+ static final String ATTR_ICON_RES = "icon-res";
+ static final String ATTR_BITMAP_PATH = "bitmap-path";
@VisibleForTesting
interface ConfigConstants {
@@ -198,7 +198,7 @@
String KEY_MAX_SHORTCUTS = "max_shortcuts";
/**
- * Key name for icom compression quality, 0-100.
+ * Key name for icon compression quality, 0-100.
*/
String KEY_ICON_QUALITY = "icon_quality";
@@ -208,7 +208,7 @@
String KEY_ICON_FORMAT = "icon_format";
}
- private final Context mContext;
+ final Context mContext;
private final Object mLock = new Object();
@@ -221,225 +221,6 @@
private long mRawLastResetTime;
/**
- * All the information relevant to shortcuts from a single package (per-user).
- *
- * TODO Move the persisting code to this class.
- *
- * Only save/load/dump should look/touch inside this class.
- */
- private static class PackageShortcuts {
- @UserIdInt
- private final int mUserId;
-
- @NonNull
- private final String mPackageName;
-
- /**
- * All the shortcuts from the package, keyed on IDs.
- */
- final private ArrayMap<String, ShortcutInfo> mShortcuts = new ArrayMap<>();
-
- /**
- * # of dynamic shortcuts.
- */
- private int mDynamicShortcutCount = 0;
-
- /**
- * # of times the package has called rate-limited APIs.
- */
- private int mApiCallCount;
-
- /**
- * When {@link #mApiCallCount} was reset last time.
- */
- private long mLastResetTime;
-
- private PackageShortcuts(int userId, String packageName) {
- mUserId = userId;
- mPackageName = packageName;
- }
-
- @GuardedBy("mLock")
- @Nullable
- public ShortcutInfo findShortcutById(String id) {
- return mShortcuts.get(id);
- }
-
- private ShortcutInfo deleteShortcut(@NonNull ShortcutService s,
- @NonNull String id) {
- final ShortcutInfo shortcut = mShortcuts.remove(id);
- if (shortcut != null) {
- s.removeIcon(mUserId, shortcut);
- shortcut.clearFlags(ShortcutInfo.FLAG_DYNAMIC | ShortcutInfo.FLAG_PINNED);
- }
- return shortcut;
- }
-
- void addShortcut(@NonNull ShortcutService s, @NonNull ShortcutInfo newShortcut) {
- deleteShortcut(s, newShortcut.getId());
- s.saveIconAndFixUpShortcut(mUserId, newShortcut);
- mShortcuts.put(newShortcut.getId(), newShortcut);
- }
-
- /**
- * Add a shortcut, or update one with the same ID, with taking over existing flags.
- *
- * It checks the max number of dynamic shortcuts.
- */
- @GuardedBy("mLock")
- public void updateShortcutWithCapping(@NonNull ShortcutService s,
- @NonNull ShortcutInfo newShortcut) {
- final ShortcutInfo oldShortcut = mShortcuts.get(newShortcut.getId());
-
- int oldFlags = 0;
- int newDynamicCount = mDynamicShortcutCount;
-
- if (oldShortcut != null) {
- oldFlags = oldShortcut.getFlags();
- if (oldShortcut.isDynamic()) {
- newDynamicCount--;
- }
- }
- if (newShortcut.isDynamic()) {
- newDynamicCount++;
- }
- // Make sure there's still room.
- s.enforceMaxDynamicShortcuts(newDynamicCount);
-
- // Okay, make it dynamic and add.
- newShortcut.addFlags(oldFlags);
-
- addShortcut(s, newShortcut);
- mDynamicShortcutCount = newDynamicCount;
- }
-
- /**
- * Remove all shortcuts that aren't pinned nor dynamic.
- */
- private void removeOrphans(@NonNull ShortcutService s) {
- ArrayList<String> removeList = null; // Lazily initialize.
-
- for (int i = mShortcuts.size() - 1; i >= 0; i--) {
- final ShortcutInfo si = mShortcuts.valueAt(i);
-
- if (si.isPinned() || si.isDynamic()) continue;
-
- if (removeList == null) {
- removeList = new ArrayList<>();
- }
- removeList.add(si.getId());
- }
- if (removeList != null) {
- for (int i = removeList.size() - 1 ; i >= 0; i--) {
- deleteShortcut(s, removeList.get(i));
- }
- }
- }
-
- @GuardedBy("mLock")
- public void deleteAllDynamicShortcuts(@NonNull ShortcutService s) {
- for (int i = mShortcuts.size() - 1; i >= 0; i--) {
- mShortcuts.valueAt(i).clearFlags(ShortcutInfo.FLAG_DYNAMIC);
- }
- removeOrphans(s);
- mDynamicShortcutCount = 0;
- }
-
- @GuardedBy("mLock")
- public void deleteDynamicWithId(@NonNull ShortcutService s, @NonNull String shortcutId) {
- final ShortcutInfo oldShortcut = mShortcuts.get(shortcutId);
-
- if (oldShortcut == null) {
- return;
- }
- if (oldShortcut.isDynamic()) {
- mDynamicShortcutCount--;
- }
- if (oldShortcut.isPinned()) {
- oldShortcut.clearFlags(ShortcutInfo.FLAG_DYNAMIC);
- } else {
- deleteShortcut(s, shortcutId);
- }
- }
-
- @GuardedBy("mLock")
- public void replacePinned(@NonNull ShortcutService s, String launcherPackage,
- List<String> shortcutIds) {
-
- // TODO Should be per launcherPackage.
-
- // First, un-pin all shortcuts
- for (int i = mShortcuts.size() - 1; i >= 0; i--) {
- mShortcuts.valueAt(i).clearFlags(ShortcutInfo.FLAG_PINNED);
- }
-
- // Then pin ALL
- for (int i = shortcutIds.size() - 1; i >= 0; i--) {
- final ShortcutInfo shortcut = mShortcuts.get(shortcutIds.get(i));
- if (shortcut != null) {
- shortcut.addFlags(ShortcutInfo.FLAG_PINNED);
- }
- }
-
- removeOrphans(s);
- }
-
- /**
- * Number of calls that the caller has made, since the last reset.
- */
- @GuardedBy("mLock")
- public int getApiCallCount(@NonNull ShortcutService s) {
- final long last = s.getLastResetTimeLocked();
-
- final long now = s.injectCurrentTimeMillis();
- if (mLastResetTime > now) {
- // Clock rewound. // TODO Test it
- mLastResetTime = now;
- }
-
- // If not reset yet, then reset.
- if (mLastResetTime < last) {
- mApiCallCount = 0;
- mLastResetTime = last;
- }
- return mApiCallCount;
- }
-
- /**
- * If the caller app hasn't been throttled yet, increment {@link #mApiCallCount}
- * and return true. Otherwise just return false.
- */
- @GuardedBy("mLock")
- public boolean tryApiCall(@NonNull ShortcutService s) {
- if (getApiCallCount(s) >= s.mMaxDailyUpdates) {
- return false;
- }
- mApiCallCount++;
- return true;
- }
-
- @GuardedBy("mLock")
- public void resetRateLimitingForCommandLine() {
- mApiCallCount = 0;
- mLastResetTime = 0;
- }
-
- /**
- * Find all shortcuts that match {@code query}.
- */
- @GuardedBy("mLock")
- public void findAll(@NonNull List<ShortcutInfo> result,
- @Nullable Predicate<ShortcutInfo> query, int cloneFlag) {
- for (int i = 0; i < mShortcuts.size(); i++) {
- final ShortcutInfo si = mShortcuts.valueAt(i);
- if (query == null || query.test(si)) {
- result.add(si.clone(cloneFlag));
- }
- }
- }
- }
-
- /**
* User ID -> package name -> list of ShortcutInfos.
*/
@GuardedBy("mLock")
@@ -454,7 +235,7 @@
/**
* Max number of updating API calls that each application can make a day.
*/
- private int mMaxDailyUpdates;
+ int mMaxDailyUpdates;
/**
* Actual throttling-reset interval. By default it's a day.
@@ -504,7 +285,7 @@
}
@Override
- public void onStartUser(int userId) {
+ public void onUnlockUser(int userId) {
synchronized (mService.mLock) {
mService.onStartUserLocked(userId);
}
@@ -622,11 +403,15 @@
// === Persisting ===
@Nullable
- private String parseStringAttribute(XmlPullParser parser, String attribute) {
+ static String parseStringAttribute(XmlPullParser parser, String attribute) {
return parser.getAttributeValue(null, attribute);
}
- private long parseLongAttribute(XmlPullParser parser, String attribute) {
+ static int parseIntAttribute(XmlPullParser parser, String attribute) {
+ return (int) parseLongAttribute(parser, attribute);
+ }
+
+ static long parseLongAttribute(XmlPullParser parser, String attribute) {
final String value = parseStringAttribute(parser, attribute);
if (TextUtils.isEmpty(value)) {
return 0;
@@ -640,7 +425,7 @@
}
@Nullable
- private ComponentName parseComponentNameAttribute(XmlPullParser parser, String attribute) {
+ static ComponentName parseComponentNameAttribute(XmlPullParser parser, String attribute) {
final String value = parseStringAttribute(parser, attribute);
if (TextUtils.isEmpty(value)) {
return null;
@@ -649,7 +434,7 @@
}
@Nullable
- private Intent parseIntentAttribute(XmlPullParser parser, String attribute) {
+ static Intent parseIntentAttribute(XmlPullParser parser, String attribute) {
final String value = parseStringAttribute(parser, attribute);
if (TextUtils.isEmpty(value)) {
return null;
@@ -662,7 +447,7 @@
}
}
- private void writeTagValue(XmlSerializer out, String tag, String value) throws IOException {
+ static void writeTagValue(XmlSerializer out, String tag, String value) throws IOException {
if (TextUtils.isEmpty(value)) return;
out.startTag(null, tag);
@@ -670,11 +455,11 @@
out.endTag(null, tag);
}
- private void writeTagValue(XmlSerializer out, String tag, long value) throws IOException {
+ static void writeTagValue(XmlSerializer out, String tag, long value) throws IOException {
writeTagValue(out, tag, Long.toString(value));
}
- private void writeTagExtra(XmlSerializer out, String tag, PersistableBundle bundle)
+ static void writeTagExtra(XmlSerializer out, String tag, PersistableBundle bundle)
throws IOException, XmlPullParserException {
if (bundle == null) return;
@@ -683,22 +468,22 @@
out.endTag(null, tag);
}
- private void writeAttr(XmlSerializer out, String name, String value) throws IOException {
+ static void writeAttr(XmlSerializer out, String name, String value) throws IOException {
if (TextUtils.isEmpty(value)) return;
out.attribute(null, name, value);
}
- private void writeAttr(XmlSerializer out, String name, long value) throws IOException {
+ static void writeAttr(XmlSerializer out, String name, long value) throws IOException {
writeAttr(out, name, String.valueOf(value));
}
- private void writeAttr(XmlSerializer out, String name, ComponentName comp) throws IOException {
+ static void writeAttr(XmlSerializer out, String name, ComponentName comp) throws IOException {
if (comp == null) return;
writeAttr(out, name, comp.flattenToString());
}
- private void writeAttr(XmlSerializer out, String name, Intent intent) throws IOException {
+ static void writeAttr(XmlSerializer out, String name, Intent intent) throws IOException {
if (intent == null) return;
writeAttr(out, name, intent.toUri(/* flags =*/ 0));
@@ -807,22 +592,7 @@
final String packageName = packages.keyAt(i);
final PackageShortcuts packageShortcuts = packages.valueAt(i);
- // TODO Move this to PackageShortcuts.
-
- out.startTag(null, TAG_PACKAGE);
-
- writeAttr(out, ATTR_NAME, packageName);
- writeAttr(out, ATTR_DYNAMIC_COUNT, packageShortcuts.mDynamicShortcutCount);
- writeAttr(out, ATTR_CALL_COUNT, packageShortcuts.mApiCallCount);
- writeAttr(out, ATTR_LAST_RESET, packageShortcuts.mLastResetTime);
-
- final ArrayMap<String, ShortcutInfo> shortcuts = packageShortcuts.mShortcuts;
- final int size = shortcuts.size();
- for (int j = 0; j < size; j++) {
- saveShortcut(out, shortcuts.valueAt(j));
- }
-
- out.endTag(null, TAG_PACKAGE);
+ packageShortcuts.saveToXml(out);
}
// Epilogue.
@@ -837,28 +607,7 @@
}
}
- private void saveShortcut(XmlSerializer out, ShortcutInfo si)
- throws IOException, XmlPullParserException {
- out.startTag(null, TAG_SHORTCUT);
- writeAttr(out, ATTR_ID, si.getId());
- // writeAttr(out, "package", si.getPackageName()); // not needed
- writeAttr(out, ATTR_ACTIVITY, si.getActivityComponent());
- // writeAttr(out, "icon", si.getIcon()); // We don't save it.
- writeAttr(out, ATTR_TITLE, si.getTitle());
- writeAttr(out, ATTR_INTENT, si.getIntentNoExtras());
- writeAttr(out, ATTR_WEIGHT, si.getWeight());
- writeAttr(out, ATTR_TIMESTAMP, si.getLastChangedTimestamp());
- writeAttr(out, ATTR_FLAGS, si.getFlags());
- writeAttr(out, ATTR_ICON_RES, si.getIconResourceId());
- writeAttr(out, ATTR_BITMAP_PATH, si.getBitmapPath());
-
- writeTagExtra(out, TAG_INTENT_EXTRAS, si.getIntentPersistableExtras());
- writeTagExtra(out, TAG_EXTRAS, si.getExtras());
-
- out.endTag(null, TAG_SHORTCUT);
- }
-
- private static IOException throwForInvalidTag(int depth, String tag) throws IOException {
+ static IOException throwForInvalidTag(int depth, String tag) throws IOException {
throw new IOException(String.format("Invalid tag '%s' found at depth %d", tag, depth));
}
@@ -868,7 +617,6 @@
if (DEBUG) {
Slog.i(TAG, "Loading from " + path);
}
- path.mkdirs();
final AtomicFile file = new AtomicFile(path);
final FileInputStream in;
@@ -880,12 +628,11 @@
}
return null;
}
- final ArrayMap<String, PackageShortcuts> ret = new ArrayMap<String, PackageShortcuts>();
+ final ArrayMap<String, PackageShortcuts> ret = new ArrayMap<>();
try {
XmlPullParser parser = Xml.newPullParser();
parser.setInput(in, StandardCharsets.UTF_8.name());
- String packageName = null;
PackageShortcuts shortcuts = null;
int type;
@@ -895,8 +642,6 @@
}
final int depth = parser.getDepth();
- // TODO Move some of this to PackageShortcuts.
-
final String tag = parser.getName();
if (DEBUG_LOAD) {
Slog.d(TAG, String.format("depth=%d type=%d name=%s",
@@ -912,27 +657,8 @@
case 2: {
switch (tag) {
case TAG_PACKAGE:
- packageName = parseStringAttribute(parser, ATTR_NAME);
- shortcuts = new PackageShortcuts(userId, packageName);
- ret.put(packageName, shortcuts);
-
- shortcuts.mDynamicShortcutCount =
- (int) parseLongAttribute(parser, ATTR_DYNAMIC_COUNT);
- shortcuts.mApiCallCount =
- (int) parseLongAttribute(parser, ATTR_CALL_COUNT);
- shortcuts.mLastResetTime = parseLongAttribute(parser,
- ATTR_LAST_RESET);
- continue;
- }
- break;
- }
- case 3: {
- switch (tag) {
- case TAG_SHORTCUT:
- final ShortcutInfo si = parseShortcut(parser, packageName);
-
- // Don't use addShortcut(), we don't need to save the icon.
- shortcuts.mShortcuts.put(si.getId(), si);
+ shortcuts = PackageShortcuts.loadFromXml(parser, userId);
+ ret.put(shortcuts.mPackageName, shortcuts);
continue;
}
break;
@@ -949,60 +675,6 @@
}
}
- private ShortcutInfo parseShortcut(XmlPullParser parser, String packgeName)
- throws IOException, XmlPullParserException {
- String id;
- ComponentName activityComponent;
- Icon icon;
- String title;
- Intent intent;
- PersistableBundle intentPersistableExtras = null;
- int weight;
- PersistableBundle extras = null;
- long lastChangedTimestamp;
- int flags;
- int iconRes;
- String bitmapPath;
-
- id = parseStringAttribute(parser, ATTR_ID);
- activityComponent = parseComponentNameAttribute(parser, ATTR_ACTIVITY);
- title = parseStringAttribute(parser, ATTR_TITLE);
- intent = parseIntentAttribute(parser, ATTR_INTENT);
- weight = (int) parseLongAttribute(parser, ATTR_WEIGHT);
- lastChangedTimestamp = (int) parseLongAttribute(parser, ATTR_TIMESTAMP);
- flags = (int) parseLongAttribute(parser, ATTR_FLAGS);
- iconRes = (int) parseLongAttribute(parser, ATTR_ICON_RES);
- bitmapPath = parseStringAttribute(parser, ATTR_BITMAP_PATH);
-
- final int outerDepth = parser.getDepth();
- int type;
- while ((type = parser.next()) != XmlPullParser.END_DOCUMENT
- && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
- if (type != XmlPullParser.START_TAG) {
- continue;
- }
- final int depth = parser.getDepth();
- final String tag = parser.getName();
- if (DEBUG_LOAD) {
- Slog.d(TAG, String.format(" depth=%d type=%d name=%s",
- depth, type, tag));
- }
- switch (tag) {
- case TAG_INTENT_EXTRAS:
- intentPersistableExtras = PersistableBundle.restoreFromXml(parser);
- continue;
- case TAG_EXTRAS:
- extras = PersistableBundle.restoreFromXml(parser);
- continue;
- }
- throw throwForInvalidTag(depth, tag);
- }
- return new ShortcutInfo(
- id, packgeName, activityComponent, /* icon =*/ null, title, intent,
- intentPersistableExtras, weight, extras, lastChangedTimestamp, flags,
- iconRes, bitmapPath);
- }
-
// TODO Actually make it async.
private void scheduleSaveBaseState() {
synchronized (mLock) {
@@ -1764,16 +1436,20 @@
@Override
public ParcelFileDescriptor getShortcutIconFd(@NonNull String callingPackage,
- @NonNull ShortcutInfo shortcut, int userId) {
- Preconditions.checkNotNull(shortcut, "shortcut");
+ @NonNull ShortcutInfo shortcutIn, int userId) {
+ Preconditions.checkNotNull(shortcutIn, "shortcut");
synchronized (mLock) {
final ShortcutInfo shortcutInfo = getPackageShortcutsLocked(
- shortcut.getPackageName(), userId).findShortcutById(shortcut.getId());
+ shortcutIn.getPackageName(), userId).findShortcutById(shortcutIn.getId());
if (shortcutInfo == null || !shortcutInfo.hasIconFile()) {
return null;
}
try {
+ if (shortcutInfo.getBitmapPath() == null) {
+ Slog.w(TAG, "null bitmap detected in getShortcutIconFd()");
+ return null;
+ }
return ParcelFileDescriptor.open(
new File(shortcutInfo.getBitmapPath()),
ParcelFileDescriptor.MODE_READ_ONLY);
@@ -1865,46 +1541,10 @@
return;
}
- pw.print(" Package: ");
- pw.print(packageName);
- pw.println();
-
- pw.print(" Calls: ");
- pw.print(packageShortcuts.getApiCallCount(this));
- pw.println();
-
- // This should be after getApiCallCount(), which may update it.
- pw.print(" Last reset: [");
- pw.print(packageShortcuts.mLastResetTime);
- pw.print("] ");
- pw.print(formatTime(packageShortcuts.mLastResetTime));
- pw.println();
-
- pw.println(" Shortcuts:");
- long totalBitmapSize = 0;
- final ArrayMap<String, ShortcutInfo> shortcuts = packageShortcuts.mShortcuts;
- final int size = shortcuts.size();
- for (int i = 0; i < size; i++) {
- final ShortcutInfo si = shortcuts.valueAt(i);
- pw.print(" ");
- pw.println(si.toInsecureString());
- if (si.hasIconFile()) {
- final long len = new File(si.getBitmapPath()).length();
- pw.print(" ");
- pw.print("bitmap size=");
- pw.println(len);
-
- totalBitmapSize += len;
- }
- }
- pw.print(" Total bitmap size: ");
- pw.print(totalBitmapSize);
- pw.print(" (");
- pw.print(Formatter.formatFileSize(mContext, totalBitmapSize));
- pw.println(")");
+ packageShortcuts.dump(this, pw, " ");
}
- private static String formatTime(long time) {
+ static String formatTime(long time) {
Time tobj = new Time();
tobj.set(time);
return tobj.format("%Y-%m-%d %H:%M:%S");
@@ -2087,4 +1727,407 @@
int getIconPersistQualityForTest() {
return mIconPersistQuality;
}
+
+ @VisibleForTesting
+ ShortcutInfo getPackageShortcutForTest(String packageName, String shortcutId, int userId) {
+ synchronized (mLock) {
+ return getPackageShortcutsLocked(packageName, userId).findShortcutById(shortcutId);
+ }
+ }
+}
+
+/**
+ * All the information relevant to shortcuts from a single package (per-user).
+ */
+class PackageShortcuts {
+ private static final String TAG = ShortcutService.TAG;
+
+ @UserIdInt
+ final int mUserId;
+
+ @NonNull
+ final String mPackageName;
+
+ /**
+ * All the shortcuts from the package, keyed on IDs.
+ */
+ final private ArrayMap<String, ShortcutInfo> mShortcuts = new ArrayMap<>();
+
+ /**
+ * # of dynamic shortcuts.
+ */
+ private int mDynamicShortcutCount = 0;
+
+ /**
+ * # of times the package has called rate-limited APIs.
+ */
+ private int mApiCallCount;
+
+ /**
+ * When {@link #mApiCallCount} was reset last time.
+ */
+ private long mLastResetTime;
+
+ PackageShortcuts(int userId, String packageName) {
+ mUserId = userId;
+ mPackageName = packageName;
+ }
+
+ @GuardedBy("mLock")
+ @Nullable
+ public ShortcutInfo findShortcutById(String id) {
+ return mShortcuts.get(id);
+ }
+
+ private ShortcutInfo deleteShortcut(@NonNull ShortcutService s,
+ @NonNull String id) {
+ final ShortcutInfo shortcut = mShortcuts.remove(id);
+ if (shortcut != null) {
+ s.removeIcon(mUserId, shortcut);
+ shortcut.clearFlags(ShortcutInfo.FLAG_DYNAMIC | ShortcutInfo.FLAG_PINNED);
+ }
+ return shortcut;
+ }
+
+ void addShortcut(@NonNull ShortcutService s, @NonNull ShortcutInfo newShortcut) {
+ deleteShortcut(s, newShortcut.getId());
+ s.saveIconAndFixUpShortcut(mUserId, newShortcut);
+ mShortcuts.put(newShortcut.getId(), newShortcut);
+ }
+
+ /**
+ * Add a shortcut, or update one with the same ID, with taking over existing flags.
+ *
+ * It checks the max number of dynamic shortcuts.
+ */
+ @GuardedBy("mLock")
+ public void updateShortcutWithCapping(@NonNull ShortcutService s,
+ @NonNull ShortcutInfo newShortcut) {
+ final ShortcutInfo oldShortcut = mShortcuts.get(newShortcut.getId());
+
+ int oldFlags = 0;
+ int newDynamicCount = mDynamicShortcutCount;
+
+ if (oldShortcut != null) {
+ oldFlags = oldShortcut.getFlags();
+ if (oldShortcut.isDynamic()) {
+ newDynamicCount--;
+ }
+ }
+ if (newShortcut.isDynamic()) {
+ newDynamicCount++;
+ }
+ // Make sure there's still room.
+ s.enforceMaxDynamicShortcuts(newDynamicCount);
+
+ // Okay, make it dynamic and add.
+ newShortcut.addFlags(oldFlags);
+
+ addShortcut(s, newShortcut);
+ mDynamicShortcutCount = newDynamicCount;
+ }
+
+ /**
+ * Remove all shortcuts that aren't pinned nor dynamic.
+ */
+ private void removeOrphans(@NonNull ShortcutService s) {
+ ArrayList<String> removeList = null; // Lazily initialize.
+
+ for (int i = mShortcuts.size() - 1; i >= 0; i--) {
+ final ShortcutInfo si = mShortcuts.valueAt(i);
+
+ if (si.isPinned() || si.isDynamic()) continue;
+
+ if (removeList == null) {
+ removeList = new ArrayList<>();
+ }
+ removeList.add(si.getId());
+ }
+ if (removeList != null) {
+ for (int i = removeList.size() - 1 ; i >= 0; i--) {
+ deleteShortcut(s, removeList.get(i));
+ }
+ }
+ }
+
+ @GuardedBy("mLock")
+ public void deleteAllDynamicShortcuts(@NonNull ShortcutService s) {
+ for (int i = mShortcuts.size() - 1; i >= 0; i--) {
+ mShortcuts.valueAt(i).clearFlags(ShortcutInfo.FLAG_DYNAMIC);
+ }
+ removeOrphans(s);
+ mDynamicShortcutCount = 0;
+ }
+
+ @GuardedBy("mLock")
+ public void deleteDynamicWithId(@NonNull ShortcutService s, @NonNull String shortcutId) {
+ final ShortcutInfo oldShortcut = mShortcuts.get(shortcutId);
+
+ if (oldShortcut == null) {
+ return;
+ }
+ if (oldShortcut.isDynamic()) {
+ mDynamicShortcutCount--;
+ }
+ if (oldShortcut.isPinned()) {
+ oldShortcut.clearFlags(ShortcutInfo.FLAG_DYNAMIC);
+ } else {
+ deleteShortcut(s, shortcutId);
+ }
+ }
+
+ @GuardedBy("mLock")
+ public void replacePinned(@NonNull ShortcutService s, String launcherPackage,
+ List<String> shortcutIds) {
+
+ // TODO Should be per launcherPackage.
+
+ // First, un-pin all shortcuts
+ for (int i = mShortcuts.size() - 1; i >= 0; i--) {
+ mShortcuts.valueAt(i).clearFlags(ShortcutInfo.FLAG_PINNED);
+ }
+
+ // Then pin ALL
+ for (int i = shortcutIds.size() - 1; i >= 0; i--) {
+ final ShortcutInfo shortcut = mShortcuts.get(shortcutIds.get(i));
+ if (shortcut != null) {
+ shortcut.addFlags(ShortcutInfo.FLAG_PINNED);
+ }
+ }
+
+ removeOrphans(s);
+ }
+
+ /**
+ * Number of calls that the caller has made, since the last reset.
+ */
+ @GuardedBy("mLock")
+ public int getApiCallCount(@NonNull ShortcutService s) {
+ final long last = s.getLastResetTimeLocked();
+
+ final long now = s.injectCurrentTimeMillis();
+ if (mLastResetTime > now) {
+ // Clock rewound. // TODO Test it
+ mLastResetTime = now;
+ }
+
+ // If not reset yet, then reset.
+ if (mLastResetTime < last) {
+ mApiCallCount = 0;
+ mLastResetTime = last;
+ }
+ return mApiCallCount;
+ }
+
+ /**
+ * If the caller app hasn't been throttled yet, increment {@link #mApiCallCount}
+ * and return true. Otherwise just return false.
+ */
+ @GuardedBy("mLock")
+ public boolean tryApiCall(@NonNull ShortcutService s) {
+ if (getApiCallCount(s) >= s.mMaxDailyUpdates) {
+ return false;
+ }
+ mApiCallCount++;
+ return true;
+ }
+
+ @GuardedBy("mLock")
+ public void resetRateLimitingForCommandLine() {
+ mApiCallCount = 0;
+ mLastResetTime = 0;
+ }
+
+ /**
+ * Find all shortcuts that match {@code query}.
+ */
+ @GuardedBy("mLock")
+ public void findAll(@NonNull List<ShortcutInfo> result,
+ @Nullable Predicate<ShortcutInfo> query, int cloneFlag) {
+ for (int i = 0; i < mShortcuts.size(); i++) {
+ final ShortcutInfo si = mShortcuts.valueAt(i);
+ if (query == null || query.test(si)) {
+ result.add(si.clone(cloneFlag));
+ }
+ }
+ }
+
+ public void dump(@NonNull ShortcutService s, @NonNull PrintWriter pw, @NonNull String prefix) {
+ pw.print(prefix);
+ pw.print("Package: ");
+ pw.print(mPackageName);
+ pw.println();
+
+ pw.print(prefix);
+ pw.print(" ");
+ pw.print("Calls: ");
+ pw.print(getApiCallCount(s));
+ pw.println();
+
+ // This should be after getApiCallCount(), which may update it.
+ pw.print(prefix);
+ pw.print(" ");
+ pw.print("Last reset: [");
+ pw.print(mLastResetTime);
+ pw.print("] ");
+ pw.print(s.formatTime(mLastResetTime));
+ pw.println();
+
+ pw.println(" Shortcuts:");
+ long totalBitmapSize = 0;
+ final ArrayMap<String, ShortcutInfo> shortcuts = mShortcuts;
+ final int size = shortcuts.size();
+ for (int i = 0; i < size; i++) {
+ final ShortcutInfo si = shortcuts.valueAt(i);
+ pw.print(" ");
+ pw.println(si.toInsecureString());
+ if (si.getBitmapPath() != null) {
+ final long len = new File(si.getBitmapPath()).length();
+ pw.print(" ");
+ pw.print("bitmap size=");
+ pw.println(len);
+
+ totalBitmapSize += len;
+ }
+ }
+ pw.print(prefix);
+ pw.print(" ");
+ pw.print("Total bitmap size: ");
+ pw.print(totalBitmapSize);
+ pw.print(" (");
+ pw.print(Formatter.formatFileSize(s.mContext, totalBitmapSize));
+ pw.println(")");
+ }
+
+ public void saveToXml(@NonNull XmlSerializer out) throws IOException, XmlPullParserException {
+ out.startTag(null, ShortcutService.TAG_PACKAGE);
+
+ ShortcutService.writeAttr(out, ShortcutService.ATTR_NAME, mPackageName);
+ ShortcutService.writeAttr(out, ShortcutService.ATTR_DYNAMIC_COUNT, mDynamicShortcutCount);
+ ShortcutService.writeAttr(out, ShortcutService.ATTR_CALL_COUNT, mApiCallCount);
+ ShortcutService.writeAttr(out, ShortcutService.ATTR_LAST_RESET, mLastResetTime);
+
+ final int size = mShortcuts.size();
+ for (int j = 0; j < size; j++) {
+ saveShortcut(out, mShortcuts.valueAt(j));
+ }
+
+ out.endTag(null, ShortcutService.TAG_PACKAGE);
+ }
+
+ private static void saveShortcut(XmlSerializer out, ShortcutInfo si)
+ throws IOException, XmlPullParserException {
+ out.startTag(null, ShortcutService.TAG_SHORTCUT);
+ ShortcutService.writeAttr(out, ShortcutService.ATTR_ID, si.getId());
+ // writeAttr(out, "package", si.getPackageName()); // not needed
+ ShortcutService.writeAttr(out, ShortcutService.ATTR_ACTIVITY, si.getActivityComponent());
+ // writeAttr(out, "icon", si.getIcon()); // We don't save it.
+ ShortcutService.writeAttr(out, ShortcutService.ATTR_TITLE, si.getTitle());
+ ShortcutService.writeAttr(out, ShortcutService.ATTR_INTENT, si.getIntentNoExtras());
+ ShortcutService.writeAttr(out, ShortcutService.ATTR_WEIGHT, si.getWeight());
+ ShortcutService.writeAttr(out, ShortcutService.ATTR_TIMESTAMP,
+ si.getLastChangedTimestamp());
+ ShortcutService.writeAttr(out, ShortcutService.ATTR_FLAGS, si.getFlags());
+ ShortcutService.writeAttr(out, ShortcutService.ATTR_ICON_RES, si.getIconResourceId());
+ ShortcutService.writeAttr(out, ShortcutService.ATTR_BITMAP_PATH, si.getBitmapPath());
+
+ ShortcutService.writeTagExtra(out, ShortcutService.TAG_INTENT_EXTRAS,
+ si.getIntentPersistableExtras());
+ ShortcutService.writeTagExtra(out, ShortcutService.TAG_EXTRAS, si.getExtras());
+
+ out.endTag(null, ShortcutService.TAG_SHORTCUT);
+ }
+
+ public static PackageShortcuts loadFromXml(XmlPullParser parser, int userId)
+ throws IOException, XmlPullParserException {
+
+ final String packageName = ShortcutService.parseStringAttribute(parser,
+ ShortcutService.ATTR_NAME);
+
+ final PackageShortcuts ret = new PackageShortcuts(userId, packageName);
+
+ ret.mDynamicShortcutCount =
+ ShortcutService.parseIntAttribute(parser, ShortcutService.ATTR_DYNAMIC_COUNT);
+ ret.mApiCallCount =
+ ShortcutService.parseIntAttribute(parser, ShortcutService.ATTR_CALL_COUNT);
+ ret.mLastResetTime =
+ ShortcutService.parseLongAttribute(parser, ShortcutService.ATTR_LAST_RESET);
+
+ final int outerDepth = parser.getDepth();
+ int type;
+ while ((type = parser.next()) != XmlPullParser.END_DOCUMENT
+ && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
+ if (type != XmlPullParser.START_TAG) {
+ continue;
+ }
+ final int depth = parser.getDepth();
+ final String tag = parser.getName();
+ switch (tag) {
+ case ShortcutService.TAG_SHORTCUT:
+ final ShortcutInfo si = parseShortcut(parser, packageName);
+
+ // Don't use addShortcut(), we don't need to save the icon.
+ ret.mShortcuts.put(si.getId(), si);
+ continue;
+ }
+ throw ShortcutService.throwForInvalidTag(depth, tag);
+ }
+ return ret;
+ }
+
+ private static ShortcutInfo parseShortcut(XmlPullParser parser, String packageName)
+ throws IOException, XmlPullParserException {
+ String id;
+ ComponentName activityComponent;
+ // Icon icon;
+ String title;
+ Intent intent;
+ PersistableBundle intentPersistableExtras = null;
+ int weight;
+ PersistableBundle extras = null;
+ long lastChangedTimestamp;
+ int flags;
+ int iconRes;
+ String bitmapPath;
+
+ id = ShortcutService.parseStringAttribute(parser, ShortcutService.ATTR_ID);
+ activityComponent = ShortcutService.parseComponentNameAttribute(parser,
+ ShortcutService.ATTR_ACTIVITY);
+ title = ShortcutService.parseStringAttribute(parser, ShortcutService.ATTR_TITLE);
+ intent = ShortcutService.parseIntentAttribute(parser, ShortcutService.ATTR_INTENT);
+ weight = (int) ShortcutService.parseLongAttribute(parser, ShortcutService.ATTR_WEIGHT);
+ lastChangedTimestamp = (int) ShortcutService.parseLongAttribute(parser,
+ ShortcutService.ATTR_TIMESTAMP);
+ flags = (int) ShortcutService.parseLongAttribute(parser, ShortcutService.ATTR_FLAGS);
+ iconRes = (int) ShortcutService.parseLongAttribute(parser, ShortcutService.ATTR_ICON_RES);
+ bitmapPath = ShortcutService.parseStringAttribute(parser, ShortcutService.ATTR_BITMAP_PATH);
+
+ final int outerDepth = parser.getDepth();
+ int type;
+ while ((type = parser.next()) != XmlPullParser.END_DOCUMENT
+ && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
+ if (type != XmlPullParser.START_TAG) {
+ continue;
+ }
+ final int depth = parser.getDepth();
+ final String tag = parser.getName();
+ if (ShortcutService.DEBUG_LOAD) {
+ Slog.d(TAG, String.format(" depth=%d type=%d name=%s",
+ depth, type, tag));
+ }
+ switch (tag) {
+ case ShortcutService.TAG_INTENT_EXTRAS:
+ intentPersistableExtras = PersistableBundle.restoreFromXml(parser);
+ continue;
+ case ShortcutService.TAG_EXTRAS:
+ extras = PersistableBundle.restoreFromXml(parser);
+ continue;
+ }
+ throw ShortcutService.throwForInvalidTag(depth, tag);
+ }
+ return new ShortcutInfo(
+ id, packageName, activityComponent, /* icon =*/ null, title, intent,
+ intentPersistableExtras, weight, extras, lastChangedTimestamp, flags,
+ iconRes, bitmapPath);
+ }
}
diff --git a/services/core/java/com/android/server/pm/UserManagerService.java b/services/core/java/com/android/server/pm/UserManagerService.java
index 5490260..8206bda 100644
--- a/services/core/java/com/android/server/pm/UserManagerService.java
+++ b/services/core/java/com/android/server/pm/UserManagerService.java
@@ -50,6 +50,7 @@
import android.os.Process;
import android.os.RemoteException;
import android.os.ResultReceiver;
+import android.os.SELinux;
import android.os.ServiceManager;
import android.os.ShellCommand;
import android.os.UserHandle;
@@ -758,23 +759,28 @@
}
@Override
- public ParcelFileDescriptor getUserIcon(int userId) {
+ public ParcelFileDescriptor getUserIcon(int targetUserId) {
String iconPath;
synchronized (mPackagesLock) {
- UserInfo info = getUserInfoNoChecks(userId);
- if (info == null || info.partial) {
- Slog.w(LOG_TAG, "getUserIcon: unknown user #" + userId);
+ UserInfo targetUserInfo = getUserInfoNoChecks(targetUserId);
+ if (targetUserInfo == null || targetUserInfo.partial) {
+ Slog.w(LOG_TAG, "getUserIcon: unknown user #" + targetUserId);
return null;
}
- int callingGroupId = getUserInfoNoChecks(UserHandle.getCallingUserId()).profileGroupId;
- if (callingGroupId == UserInfo.NO_PROFILE_GROUP_ID
- || callingGroupId != info.profileGroupId) {
+
+ final int callingUserId = UserHandle.getCallingUserId();
+ final int callingGroupId = getUserInfoNoChecks(callingUserId).profileGroupId;
+ final int targetGroupId = targetUserInfo.profileGroupId;
+ final boolean sameGroup = (callingGroupId != UserInfo.NO_PROFILE_GROUP_ID
+ && callingGroupId == targetGroupId);
+ if ((callingUserId != targetUserId) && !sameGroup) {
checkManageUsersPermission("get the icon of a user who is not related");
}
- if (info.iconPath == null) {
+
+ if (targetUserInfo.iconPath == null) {
return null;
}
- iconPath = info.iconPath;
+ iconPath = targetUserInfo.iconPath;
}
try {
@@ -1229,7 +1235,7 @@
}
FileOutputStream os;
if (bitmap.compress(Bitmap.CompressFormat.PNG, 100, os = new FileOutputStream(tmp))
- && tmp.renameTo(file)) {
+ && tmp.renameTo(file) && SELinux.restorecon(file)) {
info.iconPath = file.getAbsolutePath();
}
try {
diff --git a/services/core/jni/com_android_server_location_GnssLocationProvider.cpp b/services/core/jni/com_android_server_location_GnssLocationProvider.cpp
index 5f67b7f..e2c71a1 100644
--- a/services/core/jni/com_android_server_location_GnssLocationProvider.cpp
+++ b/services/core/jni/com_android_server_location_GnssLocationProvider.cpp
@@ -1087,8 +1087,25 @@
const char *const JavaMethodHelper<bool>::signature_ = "(Z)V";
#define SET(setter, value) object.callSetter("set" # setter, (value))
-#define SET_IF(flag, setter, value) \
- if (flags & (flag)) object.callSetter("set" # setter, (value))
+
+// If you want to check if a flag is not set, use SET_IF_NOT(FLAG, setter,
+// value) to do that. SET_IF(!FLAG, setter, value) won't compile.
+//
+// This macros generates compilation error if the provided 'flag' is not a
+// single token. For example, 'GNSS_CLOCK_HAS_BIAS' can be accepted, but
+// '!GNSS_CLOCK_HAS_DRIFT' will fail to compile.
+#define SET_IF(flag, setter, value) do { \
+ if (flags & flag) { \
+ JavaObject& name_check_##flag = object; \
+ name_check_##flag.callSetter("set" # setter, (value)); \
+ } \
+ } while (false)
+#define SET_IF_NOT(flag, setter, value) do { \
+ if (!(flags & flag)) { \
+ JavaObject& name_check_##flag = object; \
+ name_check_##flag.callSetter("set" # setter, (value)); \
+ } \
+ } while (false)
static jobject translate_gps_clock(JNIEnv* env, GpsClock* clock) {
static uint32_t discontinuity_count_to_handle_old_lock_type = 0;
@@ -1209,9 +1226,9 @@
static_cast<int32_t>(measurement->multipath_indicator));
SET_IF(GNSS_MEASUREMENT_HAS_SNR, SnrInDb, measurement->snr_db);
- SET_IF(!GPS_MEASUREMENT_HAS_UNCORRECTED_PSEUDORANGE_RATE,
- PseudorangeRateCorrected,
- true);
+ SET_IF_NOT(GPS_MEASUREMENT_HAS_UNCORRECTED_PSEUDORANGE_RATE,
+ PseudorangeRateCorrected,
+ true);
return object.get();
}
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
index 9a75dc9..ea1a569 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
@@ -1642,7 +1642,7 @@
}
if (!TextUtils.isEmpty(mInjector.systemPropertiesGet(PROPERTY_DEVICE_OWNER_PRESENT))) {
- Slog.wtf(LOG_TAG, "Trying to set ro.device_owner, but it has already been set?");
+ Slog.w(LOG_TAG, "Trying to set ro.device_owner, but it has already been set?");
} else {
if (mOwners.hasDeviceOwner()) {
mInjector.systemPropertiesSet(PROPERTY_DEVICE_OWNER_PRESENT, "true");
@@ -4862,10 +4862,10 @@
* {@link DevicePolicyManager#ENCRYPTION_STATUS_ACTIVE}.
*/
private int getEncryptionStatus() {
- if (!StorageManager.isNonDefaultBlockEncrypted()) {
- return DevicePolicyManager.ENCRYPTION_STATUS_ACTIVE_DEFAULT_KEY;
- } else if (StorageManager.isEncrypted()) {
- return DevicePolicyManager.ENCRYPTION_STATUS_ACTIVE;
+ if (StorageManager.isEncrypted()) {
+ return StorageManager.isNonDefaultBlockEncrypted() ?
+ DevicePolicyManager.ENCRYPTION_STATUS_ACTIVE
+ : DevicePolicyManager.ENCRYPTION_STATUS_ACTIVE_DEFAULT_KEY;
} else if (StorageManager.isEncryptable()) {
return DevicePolicyManager.ENCRYPTION_STATUS_INACTIVE;
} else {
diff --git a/services/tests/servicestests/src/com/android/server/pm/ShortcutManagerTest.java b/services/tests/servicestests/src/com/android/server/pm/ShortcutManagerTest.java
index 036cc66..2f4beaa 100644
--- a/services/tests/servicestests/src/com/android/server/pm/ShortcutManagerTest.java
+++ b/services/tests/servicestests/src/com/android/server/pm/ShortcutManagerTest.java
@@ -85,7 +85,7 @@
* Whether to enable dump or not. Should be only true when debugging to avoid bugs where
* dump affecting the behavior.
*/
- private static final boolean ENABLE_DUMP = true; // DO NOT SUBMIT WITH true
+ private static final boolean ENABLE_DUMP = false; // DO NOT SUBMIT WITH true
/** Context used in the client side */
private final class ClientContext extends MockContext {
@@ -145,7 +145,7 @@
@Override
int injectGetPackageUid(String packageName, int userId) {
Integer uid = mInjectedPackageUidMap.get(packageName);
- return uid != null ? uid : -1;
+ return UserHandle.getUid(getCallingUserId(), (uid != null ? uid : 0));
}
@Override
@@ -224,6 +224,9 @@
private static final String LAUNCHER_2 = "com.android.launcher.2";
private static final int LAUNCHER_UID_2 = 10012;
+ private static final int USER_10 = 10;
+ private static final int USER_11 = 11;
+
private static final long START_TIME = 1234560000000L;
private static final long INTERVAL = 10000;
@@ -282,16 +285,32 @@
}
/** Replace the current calling package */
- private void setCaller(String packageName) {
+ private void setCaller(String packageName, int userId) {
mInjectedClientPackage = packageName;
- mInjectedCallingUid = Preconditions.checkNotNull(mInjectedPackageUidMap.get(packageName),
- "Unknown package");
+ mInjectedCallingUid = UserHandle.getUid(userId,
+ Preconditions.checkNotNull(mInjectedPackageUidMap.get(packageName),
+ "Unknown package"));
+ }
+
+ private void setCaller(String packageName) {
+ setCaller(packageName, UserHandle.USER_SYSTEM);
}
private String getCallingPackage() {
return mInjectedClientPackage;
}
+ private void runWithCaller(String packageName, int userId, Runnable r) {
+ final String previousPackage = mInjectedClientPackage;
+ final int previousUid = mInjectedCallingUid;
+
+ setCaller(packageName, userId);
+
+ r.run();
+
+ setCaller(previousPackage, previousUid);
+ }
+
private int getCallingUserId() {
return UserHandle.getUserId(mInjectedCallingUid);
}
@@ -565,6 +584,15 @@
}
@NonNull
+ private List<ShortcutInfo> assertAllHaveIcon(
+ @NonNull List<ShortcutInfo> actualShortcuts) {
+ for (ShortcutInfo s : actualShortcuts) {
+ assertTrue("ID " + s.getId(), s.hasIconFile() || s.hasIconResource());
+ }
+ return actualShortcuts;
+ }
+
+ @NonNull
private List<ShortcutInfo> assertAllHaveFlags(@NonNull List<ShortcutInfo> actualShortcuts,
int shortcutFlags) {
for (ShortcutInfo s : actualShortcuts) {
@@ -635,6 +663,18 @@
}
}
+ private ShortcutInfo getPackageShortcut(String packageName, String shortcutId, int userId) {
+ return mService.getPackageShortcutForTest(packageName, shortcutId, userId);
+ }
+
+ private ShortcutInfo getPackageShortcut(String packageName, String shortcutId) {
+ return getPackageShortcut(packageName, shortcutId, getCallingUserId());
+ }
+
+ private ShortcutInfo getCallerShortcut(String shortcutId) {
+ return getPackageShortcut(getCallingPackage(), shortcutId, getCallingUserId());
+ }
+
/**
* Test for the first launch path, no settings file available.
*/
@@ -1083,7 +1123,8 @@
"res64x64",
"none");
- dumpsysOnLogcat();
+ // Re-initialize and load from the files.
+ initService();
// Load from launcher.
Bitmap bmp;
@@ -1568,35 +1609,87 @@
*/
public void testSaveAndLoadUser() {
// First, create some shortcuts and save.
- final Icon icon1 = Icon.createWithResource(mContext, R.drawable.icon1);
- final Icon icon2 = Icon.createWithBitmap(BitmapFactory.decodeResource(
- mContext.getResources(), R.drawable.icon2));
+ runWithCaller(CALLING_PACKAGE_1, UserHandle.USER_SYSTEM, () -> {
+ final Icon icon1 = Icon.createWithResource(mContext, R.drawable.black_64x16);
+ final Icon icon2 = Icon.createWithBitmap(BitmapFactory.decodeResource(
+ mContext.getResources(), R.drawable.icon2));
- final ShortcutInfo si1 = makeShortcut(
- "shortcut1",
- "Title 1",
- makeComponent(ShortcutActivity.class),
- icon1,
- makeIntent(Intent.ACTION_ASSIST, ShortcutActivity2.class,
- "key1", "val1", "nest", makeBundle("key", 123)),
- /* weight */ 10);
+ final ShortcutInfo si1 = makeShortcut(
+ "s1",
+ "title1-1",
+ makeComponent(ShortcutActivity.class),
+ icon1,
+ makeIntent(Intent.ACTION_ASSIST, ShortcutActivity2.class,
+ "key1", "val1", "nest", makeBundle("key", 123)),
+ /* weight */ 10);
- final ShortcutInfo si2 = makeShortcut(
- "shortcut2",
- "Title 2",
- /* activity */ null,
- icon2,
- makeIntent(Intent.ACTION_ASSIST, ShortcutActivity3.class),
- /* weight */ 12);
+ final ShortcutInfo si2 = makeShortcut(
+ "s2",
+ "title1-2",
+ /* activity */ null,
+ icon2,
+ makeIntent(Intent.ACTION_ASSIST, ShortcutActivity3.class),
+ /* weight */ 12);
- assertTrue(mManager.setDynamicShortcuts(Arrays.asList(si1, si2)));
+ assertTrue(mManager.setDynamicShortcuts(Arrays.asList(si1, si2)));
- assertEquals(START_TIME + INTERVAL, mManager.getRateLimitResetTime());
- assertEquals(2, mManager.getRemainingCallCount());
+ assertEquals(START_TIME + INTERVAL, mManager.getRateLimitResetTime());
+ assertEquals(2, mManager.getRemainingCallCount());
+ });
+ runWithCaller(CALLING_PACKAGE_2, UserHandle.USER_SYSTEM, () -> {
+ final Icon icon1 = Icon.createWithResource(mContext, R.drawable.black_16x64);
+ final Icon icon2 = Icon.createWithBitmap(BitmapFactory.decodeResource(
+ mContext.getResources(), R.drawable.icon2));
- Log.i(TAG, "Saved state");
- dumpsysOnLogcat();
- dumpUserFile(0);
+ final ShortcutInfo si1 = makeShortcut(
+ "s1",
+ "title2-1",
+ makeComponent(ShortcutActivity.class),
+ icon1,
+ makeIntent(Intent.ACTION_ASSIST, ShortcutActivity2.class,
+ "key1", "val1", "nest", makeBundle("key", 123)),
+ /* weight */ 10);
+
+ final ShortcutInfo si2 = makeShortcut(
+ "s2",
+ "title2-2",
+ /* activity */ null,
+ icon2,
+ makeIntent(Intent.ACTION_ASSIST, ShortcutActivity3.class),
+ /* weight */ 12);
+
+ assertTrue(mManager.setDynamicShortcuts(Arrays.asList(si1, si2)));
+
+ assertEquals(START_TIME + INTERVAL, mManager.getRateLimitResetTime());
+ assertEquals(2, mManager.getRemainingCallCount());
+ });
+ runWithCaller(CALLING_PACKAGE_1, USER_10, () -> {
+ final Icon icon1 = Icon.createWithResource(mContext, R.drawable.black_64x64);
+ final Icon icon2 = Icon.createWithBitmap(BitmapFactory.decodeResource(
+ mContext.getResources(), R.drawable.icon2));
+
+ final ShortcutInfo si1 = makeShortcut(
+ "s1",
+ "title10-1-1",
+ makeComponent(ShortcutActivity.class),
+ icon1,
+ makeIntent(Intent.ACTION_ASSIST, ShortcutActivity2.class,
+ "key1", "val1", "nest", makeBundle("key", 123)),
+ /* weight */ 10);
+
+ final ShortcutInfo si2 = makeShortcut(
+ "s2",
+ "title10-1-2",
+ /* activity */ null,
+ icon2,
+ makeIntent(Intent.ACTION_ASSIST, ShortcutActivity3.class),
+ /* weight */ 12);
+
+ assertTrue(mManager.setDynamicShortcuts(Arrays.asList(si1, si2)));
+
+ assertEquals(START_TIME + INTERVAL, mManager.getRateLimitResetTime());
+ assertEquals(2, mManager.getRemainingCallCount());
+ });
// Restore.
initService();
@@ -1610,26 +1703,40 @@
// Now it's loaded.
assertEquals(1, mService.getShortcutsForTest().size());
+ runWithCaller(CALLING_PACKAGE_1, UserHandle.USER_SYSTEM, () -> {
+ assertShortcutIds(assertAllDynamic(assertAllHaveIntents(assertAllHaveIcon(
+ mManager.getDynamicShortcuts()))), "s1", "s2");
+ assertEquals(2, mManager.getRemainingCallCount());
+
+ assertEquals("title1-1", getCallerShortcut("s1").getTitle());
+ assertEquals("title1-2", getCallerShortcut("s2").getTitle());
+ });
+ runWithCaller(CALLING_PACKAGE_2, UserHandle.USER_SYSTEM, () -> {
+ assertShortcutIds(assertAllDynamic(assertAllHaveIntents(assertAllHaveIcon(
+ mManager.getDynamicShortcuts()))), "s1", "s2");
+ assertEquals(2, mManager.getRemainingCallCount());
+
+ assertEquals("title2-1", getCallerShortcut("s1").getTitle());
+ assertEquals("title2-2", getCallerShortcut("s2").getTitle());
+ });
+
// Start another user
- mService.onStartUserLocked(10);
+ mService.onStartUserLocked(USER_10);
// Now the size is 2.
assertEquals(2, mService.getShortcutsForTest().size());
- Log.i(TAG, "Dumping the new instance");
+ runWithCaller(CALLING_PACKAGE_1, USER_10, () -> {
+ assertShortcutIds(assertAllDynamic(assertAllHaveIntents(assertAllHaveIcon(
+ mManager.getDynamicShortcuts()))), "s1", "s2");
+ assertEquals(2, mManager.getRemainingCallCount());
- List<ShortcutInfo> loaded = mManager.getDynamicShortcuts();
-
- Log.i(TAG, "Loaded state");
- dumpsysOnLogcat();
-
- assertEquals(2, loaded.size());
-
- assertEquals(START_TIME + INTERVAL, mManager.getRateLimitResetTime());
- assertEquals(2, mManager.getRemainingCallCount());
+ assertEquals("title10-1-1", getCallerShortcut("s1").getTitle());
+ assertEquals("title10-1-2", getCallerShortcut("s2").getTitle());
+ });
// Try stopping the user
- mService.onCleanupUserInner(UserHandle.USER_SYSTEM);
+ mService.onCleanupUserInner(USER_10);
// Now it's unloaded.
assertEquals(1, mService.getShortcutsForTest().size());
diff --git a/telecomm/java/android/telecom/TelecomManager.java b/telecomm/java/android/telecom/TelecomManager.java
index 605e0d3..8afb455 100644
--- a/telecomm/java/android/telecom/TelecomManager.java
+++ b/telecomm/java/android/telecom/TelecomManager.java
@@ -1442,7 +1442,7 @@
/**
* Creates the {@link Intent} which can be used with {@link Context#startActivity(Intent)} to
* launch the activity to manage blocked numbers.
- * <p> This method displays the UI to manage blocked numbers only if
+ * <p> The activity will display the UI to manage blocked numbers only if
* {@link android.provider.BlockedNumberContract#canCurrentUserBlockNumbers(Context)} returns
* {@code true} for the current user.
*/