History log of /frameworks/base/core/java/android/content/res/ResourcesImpl.java
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
36d6a985cd0595061a2f5a9facc91aa013aea72a 26-May-2017 Tenghui Zhu <ztenghui@google.com> Merge "Create a new drawable after caching the DrawableContainer" into oc-dev
ee7e8f13ea2293e93ef9dd9f3f088186edd4864e 17-May-2017 ztenghui <ztenghui@google.com> Create a new drawable after caching the DrawableContainer

fix:37135264

Test: Add new CTS test
bit
CtsGraphicsTestCases:android.graphics.drawable.cts.DrawableContainerStateTest,
CtsGraphicsTestCases:android.graphics.drawable.cts.DrawableContainerTest,
CtsGraphicsTestCases:android.graphics.drawable.cts.Drawable_ConstantStateTest

Change-Id: I8bb868d16a944f746ec41d3e37ae4215b964d949
/frameworks/base/core/java/android/content/res/ResourcesImpl.java
2ea169a2ecbb7e589fcef78cb1486d007a8fb867 16-May-2017 Seigo Nonaka <nona@google.com> Introduce early exit path for non resource path.

Developer can specify android:fontFamily with three ways, pre-defined
font family name, e.g. "sans-serif", path to the font file in resource
directory, e.g. "res/fonts/Roboto-Regular.ttf", or path to the XML font
family file, e.g. "res/fonts/Roboto.xml".

Resources.getFont treats font files and XML files but pre-defined family
name is handled by TextView. Thus, we can early exit if the passed value
is not likely resource path.

This improves the inflation performance.
The score without this patch:
gfx-avg-frame-time-50: 6.9
gfx-avg-frame-time-90: 9.4
gfx-avg-frame-time-95: 10.4
gfx-avg-frame-time-99: 16.7

The score with this patch:
gfx-avg-frame-time-50: 7.0
gfx-avg-frame-time-90: 8.9
gfx-avg-frame-time-95: 9.7
gfx-avg-frame-time-99: 16.5

Measured on bullhead-userdebug.

The APCT perf test improves from
String FontFamily: 200,086 -> 132,561
File FontFamily : 199,256 -> 161,843
XML FontFamily : 203,681 -> 158,553

Measured on angler-userdebug.

Bug: 38232467
Test: UiBenchmark
Change-Id: Ia601ae7207ae8c60848c9efdbb9396267a57257c
/frameworks/base/core/java/android/content/res/ResourcesImpl.java
5e0aed49a874b32b135bbd8da620357764b69ad4 01-May-2017 Seigo Nonaka <nona@google.com> Fix NPE happens if no source was specified to font element.

This also fixes unexpected fallback to the old implemntation by calling
allowUnsupportedFont() which is only for backward compatibility.

This CL also remove getResourceId() method. Nobody uses this method.

Bug: 37865521
Bug: 37844248
Test: am instrument -w -e class android.content.res.cts.ResourcesTest\
android.content.cts/android.support.test.runner.AndroidJUnitRunner
Change-Id: I987448add728c53c916f24a2ea8f337be417248f
/frameworks/base/core/java/android/content/res/ResourcesImpl.java
50954d2b4ea938d787ef5021d75f6bc02826607a 15-Apr-2017 Adam Lesinski <adamlesinski@google.com> Propagate density through AdaptiveIconDrawable and BitmapDrawable

Resources#getDrawableForDensity now propagates the overridden
density through to AdaptiveIconDrawable so that the density can be
propagated to leaf BitmapDrawables correctly.

This enables AdaptiveIconDrawable to support higher resolution
foreground/background bitmaps for use in Launcher.

Bug: 36039665
Test: bit CtsContentTestCases:android.content.res.cts.ResourcesTest
Change-Id: Iaa9a5592626e38e1ff839a76f7c6cfb9e16e5dc1
/frameworks/base/core/java/android/content/res/ResourcesImpl.java
2821eeae9732002c1a4bd9d6812a45ea65b7b6a0 17-Mar-2017 Clara Bayarri <clarabayarri@google.com> Preload fonts from an array

Until now we were reusing the font tags, but it is not needed,
we can declare the list of fonts to preload with a simple
resources array.

Test: manual
Bug: 36119246
Change-Id: I39819018012c322aff62e13aa69ab35467be57ac
/frameworks/base/core/java/android/content/res/ResourcesImpl.java
a8a66ccf1c6c042a71817d61fc159f10c21f4844 20-Mar-2017 Alan Viverette <alanv@google.com> [Resources] preloaded drawables few

Symptom: preloaded drawables few
Root Cause: all Java-side usages of config flags Must use Java flags
Solution: all Java-side usages of config flags Must use Java flags
Project: N70
Note:
Test: No

Fixes: 36448068
Change-Id: Iba4ac0067405bf1605cb1a98aa4dfc6263bbe5f8
/frameworks/base/core/java/android/content/res/ResourcesImpl.java
ac873c9f25d2a687c9195226b9d680f51c91fa30 08-Mar-2017 Seigo Nonaka <nona@google.com> Clean up public FontConfig APIs

This CL contains following clean up:

- Hide unnecessary constructors.
- Change List<XX> to XX[] since actually all fields are immutable.
- Change font's variant type from String to int.
- Decouple resource related members to FontResourcesParser.
- Add NonNull/Nullable to all fields.

Test: ran android.content.res.FontResourcesParserTest

Change-Id: If456266ffff86d41342572a19662cc8f3cd13181
/frameworks/base/core/java/android/content/res/ResourcesImpl.java
4b5a4d221f377686a730182a3bffb8c6f190e313 27-Jan-2017 Clara Bayarri <clarabayarri@google.com> Declarative downloadable fonts

Implement support for downloadable font requests in xml. Given the
xml fonts feature in O, this adds support to not only declare
local font files as font resources, but also Downloadable fonts
from a fonts provider.

A provider returns a font family (of one or more files) given a
query, so the new attributes are added to the font-family tag.

Additionally, add support to pre-declare downloadable font resources
in the Android Manifest. These will then be fetched at app startup
time so they are available to use from the Typeface cache asap.

When retrieving downloadable fonts via resources, the cache is
checked to see if the font is already there and is used, otherwise
a request is sent to the provider and the default font is returned
as we need a result synchronously.

To do this, the developer declares an additional fonts xml resource
file with the list of fonts to preload and links it in the manifest
with a meta-data tag.

E.g.:

res/font/mydownloadedfont.xml

<font-family xmlns:android="http://schemas.android.com/apk/res/android"
android:fontProviderAuthority="com.example.test.fontprovider"
android:fontProviderQuery="myrequestedfont">
</font-family>

res/font/preloaded_fonts.xml

<?xml version="1.0" encoding="utf-8"?>
<font-family xmlns:android="http://schemas.android.com/apk/res/android">
<font android:font="@font/mydownloadedfont" />
</font-family>

and in the AndroidManifest.xml

<meta-data android:name="preloaded_fonts"
android:resource="@font/preloaded_fonts" />

Bug: 34660500, 34658116
Test: WIP, need to add more
Change-Id: I1d92555e115e241bf23b59e6f5c6cca6c7361de7
/frameworks/base/core/java/android/content/res/ResourcesImpl.java
b12397e57e79c5dd9e8b2cb3839f5cd30b5d515f 27-Jan-2017 Clara Bayarri <clarabayarri@google.com> Cache Downloaded Fonts in Typeface

If the requested Typeface is already loaded into memory, return
from the cache.

Test: none, optimization
Change-Id: I32422c47c68502ba83b7d976f6e05f70dda5daed
/frameworks/base/core/java/android/content/res/ResourcesImpl.java
fe98ad919bebaf41191b7fdf0a1d841198d4f46a 30-Jan-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Implement .xml font resource support"
0ee455a8997c14ff0f8cd99f11c80e1e3c236de3 27-Jan-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Convert native changing config flags to Java flags"
ed00bfdfae5d5cbc9e13f4e8affdece48f4c5b7f 20-Jan-2017 Clara Bayarri <clarabayarri@google.com> Implement .xml font resource support

This change implements the loading and parsing
of xml type font resources, and makes sure it is
used properly by TextView styles.

Test: run cts -m CtsContentTestCases -t android.content.res.cts.ResourcesTest
run cts -m CtsWidgetTestCases -t android.widget.cts.TextViewTest#testFontResources*

Change-Id: I5a2930b3ba7dad67d9607e9036a5dde6bab0c5a4
/frameworks/base/core/java/android/content/res/ResourcesImpl.java
9ad386b37c4c4ebe1176caa8eeab131387fc93ed 26-Jan-2017 Alan Viverette <alanv@google.com> Convert native changing config flags to Java flags

Also adds more annotations.

Bug: 33080269
Test: ResourcesTest#testChangingConfiguration
Change-Id: I08d438821b96e3d74da1c1c34009673c77caf27e
/frameworks/base/core/java/android/content/res/ResourcesImpl.java
408afbf06040ea29d1a9d60e9dc50d1923068de4 25-Jan-2017 Romain Guy <romainguy@google.com> Change configuration's color mode based on the display's color mode

Bug: 32984164
Test: CtsContentTestCases

Change-Id: Iedc7d1cc488b80718576082667b6e96956c4f847
/frameworks/base/core/java/android/content/res/ResourcesImpl.java
18e9f9f3778318918c44d944489cb50daaf45d1c 19-Dec-2016 Clara Bayarri <clarabayarri@google.com> Expose Resources.getFont

Based on the work already done in aapt2, load a Font from a
resource id.

Test: WIP
Change-Id: Idc06bfbfd16452a328bfcc6ea9dcfb723b633f0c
/frameworks/base/core/java/android/content/res/ResourcesImpl.java
f32adf447511d54c2aa0948d3c1ef44d461538ac 23-Nov-2016 John Reck <jreck@google.com> Clean up ApplyStyle JNI

Bug: 32573798

Mark input uint32_t[] as const. Use Read-only JNI
array access for input as it's faster than critical access.

Use non-movable arrays for TypedArray so that the address can
be resolved and stored, avoiding the need to do JNI array
access for the output.

Indicies is always non-null, so remove the optional checks.

Eliminate unused return value.

Benchmark results:
twelveKeyInflate 4963us -> 4713us
simpleViewInflate 73us -> 60us

Test: Device boots, benchmarks show faster

Change-Id: Ic3bde5aee31407d8903913f97f2218daf074499a
/frameworks/base/core/java/android/content/res/ResourcesImpl.java
58857c8b2bd64272d2320f62fd860783bb671da8 29-Oct-2016 Alan Viverette <alanv@google.com> Always propagate changingConfigurations to newly-created drawables

Bug: 32395972
Test: ResourcesTest#testChangingConfigurations
Change-Id: I555f3271854bdb6026db15f855847714c4986af3
/frameworks/base/core/java/android/content/res/ResourcesImpl.java
bad43fcae487a19865c174483c11829379817c8a 19-Jul-2016 Adam Lesinski <adamlesinski@google.com> Fix undefined fontScale issue in Configuration

When using a Configuration object as a delta for use
as an update to an existing Configuration object,
the fontScale property is always defaulted to 1.0, which
is not considered "undefined". That means that fontScale will
always get overridden to 1.0.

This changes the undefined value of fontScale to 0.0, which is
set when the Configuration object is constructed. Thankfully,
the documentation for Configuration states that until
Configuration#setToDefaults() is called, the Configuration is in
an invalid state. That means that apps can not rely on fontScale == 1.0
without calling setToDefaults().

Bug:29924927
Change-Id: I19342c55f7057423f1ca8c5d8dce1dff07617d90
/frameworks/base/core/java/android/content/res/ResourcesImpl.java
8e8d23214a71d8813ebd3676b192924c530cb913 24-Jun-2016 Adam Lesinski <adamlesinski@google.com> Update DisplayMetrics when resizing

Previously the DisplayMetrics passed to a new ResourcesImpl
object would be generated from the default DisplayAdjustments.
We now use the correct DisplayAdjustments for the ResourcesImpl
and make sure to update them for things like rotation changes.

Bug:29619314
Change-Id: If2ba0d7670a4554dcd3fde9766e2337f20a191fd
/frameworks/base/core/java/android/content/res/ResourcesImpl.java
4ece3d6bb18a609afcd0e82f0340b7d36ba24eea 17-Jun-2016 Adam Lesinski <adamlesinski@google.com> ContextImpl: Keep DisplayAdjustments and Display in sync

Make sure that when our Resources get updated, that DisplayAdjustment
and Display properly reflect the potentially new screen dimensions.

Bug:28388969
Change-Id: I340550ea094ece87abc8790dd46aaa60ab3cedd3
/frameworks/base/core/java/android/content/res/ResourcesImpl.java
f135b271bfaa5a23f3af5a15ce59fd4ffb44a6be 28-May-2016 Christopher Tate <ctate@google.com> Don't call .toString() on potentially null CharSequence

We're building an exception message string, but by explicitly invoking
.toString() we're accidentally triggering an NPE rather than the typed
exception we want to throw. Build the string in a way that will be
safe and sensical even if the CharSequence is null.

Bug 29009255

Change-Id: I1813260f0b36fd44506b8327f997dd20c2d6c8bf
/frameworks/base/core/java/android/content/res/ResourcesImpl.java
b61e405397200f78b1c652143cba7c751df05a00 20-May-2016 Adam Lesinski <adamlesinski@google.com> Improve performance of LocaleList with Resources

We allow each individual Resources object to select the best
Locale for the given APK. This allows one update to the configuration
instead of multiple updates, once the locale is chosen.

The Java locale is selected from the app context's locale.

Bug:28625993
Bug:27325465
Change-Id: I99e1e53f522e560f3b80bbd1e1c605f552dbdff0
/frameworks/base/core/java/android/content/res/ResourcesImpl.java
23cbe85610f780134cc77dd4a54732a22ed6e86e 18-May-2016 Yohei Yukawa <yukawa@google.com> Move LocaleList to avoid layering violation.

Since LocaleList needs to depend on android.os.Parcelable, we cannot let
that class belong to "android.util" package, which causes layering
violation.

Bug: 28819696
Change-Id: Ia8de2ee9df3dd0a42b1fe84574439519b680fe18
/frameworks/base/core/java/android/content/res/ResourcesImpl.java
991357fe25b3addabf85b871df3f4098fc4b833b 10-May-2016 Adam Lesinski <adamlesinski@google.com> BluetoothManager: Make requestControllerActivityInfo one call

Instead of making multiple calls into the Bluetooth service,
make one call that can timeout. This helps prevent cases
when the Bluetooth process hangs and the system_server is calling into
it and causes a WATCHDOG restart.

Bug:28658141
Change-Id: I37778b7b6e508be420a21bdf23593ae89b38f5b8
/frameworks/base/core/java/android/content/res/ResourcesImpl.java
0b9295d06750dc6da032a2b2092e2c500c65393f 10-Mar-2016 Alan Viverette <alanv@google.com> Push flags from top-level TypedValue into ComplexColor changing configs

Previously a ComplexColor that was defined within varying configs would
not push the flags into its changing configs, so it wouldn't get reloaded.

This implementation follows the Drawable implementation, where the base
changing configs are stored in the superclass.

Bug: 27573177
Change-Id: I1da5ee6ab998d8296f8860c1a99d3e1399438543
/frameworks/base/core/java/android/content/res/ResourcesImpl.java
ac85f90466dd60d2af8ffc3942d503a0de606726 11-Mar-2016 Alan Viverette <alanv@google.com> Ensure all Java-side usages of config flags are using Java flags

Previously we were using native config flags in some places that expected
Java flags, and vice-versa. All usages of config flags are now annotated
to ensure we're using the right type.

Cleans up annotations on most methods that were touched.

Bug: 21161798
Change-Id: Ifd87dfb12199fc8258915d8a510e03ddb681ca89
/frameworks/base/core/java/android/content/res/ResourcesImpl.java
082614c6a57a115ee0c5975e3579bf34a178c0f8 04-Mar-2016 Adam Lesinski <adamlesinski@google.com> Cache per-Activity Resources objects

Each Activity has a Resources object whose underlying state changes
when a configuration change occurs, both global and for that activity only (multi-window).
Views and other clients of the Resources object can safely cache it knowing that
they always have a reference to the most up-to-date resources.

This applies to Resources.Theme objects as well.

Bug:26854894
Change-Id: Ifd3da5a1086e17f747dfc265a447fe92a3a5c692
/frameworks/base/core/java/android/content/res/ResourcesImpl.java
fb302ccd8e0610a09691ea5503ff8111dc7a2e41 01-Mar-2016 Adam Lesinski <adamlesinski@google.com> Move the guts of Resources to ResourcesImpl

In order to satisfy the requirement that clients can
cache a Resources object when a configuration change happens,
we move the caches and all other method bodies to ResourcesImpl.
These can then be swapped out for the correct version when needed,
while allowing clients to keep holding the existing Resources references.

This is part 1 of 2 CLs. The next one will do the actual switching of implementations
based on configuration changes for multiwindow.

Bug:26854894
Change-Id: I41156194a3541e59053b4048c3a15981c7d8a506
/frameworks/base/core/java/android/content/res/ResourcesImpl.java