2542 Commits

Author SHA1 Message Date
Jerome Gaillard
584f563e5b Ignore justified in layoutlib for the moment
In Change Icbfab2fa, a new justified alignment for text is implemented.
We make layoutlib compatible with those changes without implementing
the new alignment.

Test: layoutlib tests
Change-Id: Ic8254f0f4b2915d654124874fee72c90fd8aa6c6
2017-02-01 17:12:02 +00:00
Jerome Gaillard
0c37a9eafb Update Canvas_Delegate after Change I3edc963a
Test: layoutlib tests
Change-Id: I1f285c3baac267bd47324802c12b33d34f8b581f
2017-02-01 16:59:55 +00:00
Svetoslav Ganov
096d304ae3 Add instant cookie APIs
This change adds APIs for instant apps to store cookie data
that is presisted across instant installs and across the
upgrade from an instant to a standard app. Standard apps
can use the cookie APIs but when they are uninstalled the
cookie is also deleted. The cookies are kept longer than
the instant apps as they are much smaller - 16KB by default.
We can change the cookie size via a system setting i.e.
after we ship we can increase size if needed.

We also add internal APIs to surface information about
installed and uninstalled instant apps which should be
used for showing them in the UI. For this puporse we store
the icon, permissions, and label of uninstalled apps. If
the app is re-installed we drop this meta-data but keep
the cookie around. If we have cookie data stored and the
signing cert of the app changes when it gets re-intalled
we wipe the cookie.

Test: CTS tests pass; hiddent APIs tested manually

Change-Id: If145c0440cc61a5303e2cbb70228d235d36037a5
2017-01-30 17:52:14 -08:00
Yohei Yukawa
c2410cb9e5 Merge "Simplify stub TextServicesManager in layoutlib" 2017-01-29 02:49:35 +00:00
Paul Navin
7d0f5e8d40 Add hidden API for whether permission review mode is on. am: 7b89a7b1f7 am: 7c230c6f3c
am: dd91db5515

Change-Id: I936449f717e3c2919622181c9068ec8a48b452ad
2017-01-27 17:03:38 +00:00
Paul Navin
dd91db5515 Add hidden API for whether permission review mode is on. am: 7b89a7b1f7
am: 7c230c6f3c

Change-Id: I89c9a580a96d0f69ed30cad9ec2e4f9c215a403b
2017-01-27 16:59:33 +00:00
Paul Navin
7c230c6f3c Add hidden API for whether permission review mode is on.
am: 7b89a7b1f7

Change-Id: I925b6de9f79850dcc816a73357d1d589eeac6333
2017-01-27 16:55:03 +00:00
Yohei Yukawa
e79599ba99 Simplify stub TextServicesManager in layoutlib
As a preparation CL to work on Bug 7254002, this CL simplifies
the layoutlib mock class of TextServicesManager, which was mostly
as-is copied from the real one by a previous CL [1].

Although keeping maintaining one real class and one stub class is
still painful, it should be much better than maintaining the real
one and mostly the real one.

 [1]: I8c25f4919a2e97b56f705b59747e81cb6f45b07b
      f149ca784dd09bd97bd479ae254935ff3edaa617

Test: make layoutlib-tests layoutlib
Test: No new test failure in the following command.
      java -Dtest_res.dir=frameworks/base/tools/layoutlib/bridge/tests/res -cp .:/usr/share/java/junit4.jar:prebuilts/tools/common/m2/repository/junit/junit/4.12/junit-4.12.jar:prebuilts/tools/common/m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar:prebuilts/misc/common/tools-common/tools-common-prebuilt.jar:prebuilts/misc/common/sdk-common/sdk-common.jar:prebuilts/misc/common/layoutlib_api/layoutlib_api-prebuilt.jar:prebuilts/misc/common/kxml2/kxml2-2.3.0.jar:prebuilts/tools/common/m2/repository/com/google/guava/guava/15.0/guava-15.0.jar:out/host/linux-x86/framework/layoutlib-tests.jar:out/host/linux-x86/framework/layoutlib.jar org.junit.runner.JUnitCore com.android.layoutlib.bridge.intensive.Main
Bug: 7254002
Change-Id: I03e95bae15dc04cc0df20c4fb7cc86c5f3c6ccde
2017-01-26 23:42:33 -08:00
Paul Navin
7b89a7b1f7 Add hidden API for whether permission review mode is on.
BUG: 34240393
Change-Id: I68e55767a7da1d457a6cedd210aac9e339fb996c
2017-01-27 03:42:32 +00:00
TreeHugger Robot
bcf3b70371 Merge "Adding an api for apps to check whether they can install apps" 2017-01-26 07:35:33 +00:00
Suprabh Shukla
aef2513c71 Adding an api for apps to check whether they can install apps
Some apps may want to check whether they are trusted to install apps on
the device, so they can prompt the user to go to settings and mark them
as trusted before they do an intensive operation like downloading an
apk.

Test: cts-tradefed run cts -m CtsExternalSourcesTestCases

Bug: 31002700
Change-Id: Icd9d04daa157e6733decba245ec251ce4acd4122
2017-01-25 17:26:02 -08:00
Vladislav Kaznacheev
3787de16d2 Implement pointer capture API
When in pointer capture mode, mouse pointer disappears and
further mouse events are dispatched to the focused view
in the window which has requested capture.

The captured events have the source SOURCE_MOUSE_RELATIVE
belonging to SOURCE_CLASS_TRACKBALL. They are
dispatched through dispatchCapturedPointerEvent /
onCapturedPointerEvent. There is also a new listener.

Pointer capture mode may only be granted to a currently
focused window, and will be canceled upon a window focus change.

Test: cts-tradefed ... --test android.view.cts.PointerCaptureTest
Bug: 30897034
Change-Id: I6e5934aa415ac2b6dda1cee173d0f23e5021af84
2017-01-25 13:13:45 -08:00
Adam Lesinski
9aa513bf95 Merge "Add support for Split APK dependcies" 2017-01-25 16:56:51 +00:00
TreeHugger Robot
68eb1ac342 Merge "Follow minikin::FontFamily constructor signature change." 2017-01-25 07:05:50 +00:00
Adam Lesinski
4e8628157a Add support for Split APK dependcies
Apps can now declare in their base APK AndroidManifest.xml
that they want to have their split APKs loaded in isolated
Contexts. This means code and resources from the split
get loaded into their own ClassLoader and AssetManager.

<manifest xmlns:android="..."
          ...
          android:isolatedSplits="true"
          ...

In order to make this more useful, splits can declare dependencies
on other splits, which will all get pulled in to the Context
and run as expected at runtime.

A split declares its dependency on another split by using the
tag <uses-split> in its AndroidManifest.xml:

<manifest xmlns:android="...">
    ...
    <uses-split android:name="feature_split_1" />
    ...

A split can have a single parent on which it depends on. This is
due to the limitation of having a single ClassLoader parent.
All splits depend on the base APK implicitly.

PackageManager verifies that no cycles exist and that each dependency
is present before allowing an installation to succeed.

The runtime will then load splits based on the dependencies.

Given the following APKs:

base <-- split A <-- split C
  ^----- split B

If an Activity defined in split C is launched, then the base,
split A, and split C will be loaded into the ClassLoader defined
for the Activity's Context. The AssetManager will similarly be loaded
with the resources of the splits.

A split can be manually loaded by creating a Context for that split, defined
by its name:

Context.createContextForSplit("my_feature_split_1");

All installed Activities, Services, Receivers, and Providers are accessible
to other apps via Intent resolution. When they are instantiated, they are
given the appropriate Context that satisfies any dependencies the split they
were defined in stipulated.

Test: WIP (CTS tests to come)
Change-Id: I8989712b241b7bc84381f2919d88455fcad62161
2017-01-24 18:34:08 -08:00
Wale Ogunwale
1666e317dc Added StackWindowContainerController
For linking ActivityStack in AMS to TaskStack window container in WMS.

Change-Id: I8b9eaef49e62854d59b22d27f80f5935a5a4d7fc
Bug: 30060889
Test: bit FrameworksServicesTests:com.android.server.wm.StackWindowContainerControllerTests
Test: bit FrameworksServicesTests:com.android.server.wm.TaskWindowContainerControllerTests
Test: Existing test pass and manual testing.
2017-01-24 15:23:37 -08:00
Seigo Nonaka
8b48e62445 Follow minikin::FontFamily constructor signature change.
This is 2nd attempt of Id10ca97f6f6f5bbe4999c1ad2736423a204d6e87.
The root caus of crash is due touching null pointer in nUnrefFamily.
After above change, native object may not be created on error case.
In that case, nUnrefFamily can not be called. In addition to this issue
there is also memory leak on error case. This fixes it by introducing
abortCreation method.

Also this contains fix of layout lib breakage done by jgaillard@.
Originally submitted by Ic8872a43993bcb0a157c5e3f0ce423af9b47f606

Here is original commit message of reverted change.

minikin::FontFamily no longer has addFont function, instead it accept
vector of Fonts in its constructor. To follow this signature change,
holding minikin::Font instance in native and build minikin::FontFamily
instance in FontFamily.freeze() method.

Bug: 34042446
Bug: 28119474
Bug: 34378805
Test: hwui test has passed
Test: m layoutlib layoutlib-tests
Change-Id: Ic34ebaa8191273d4c9f49c43124f15a1da5f7b78
2017-01-24 15:10:29 +09:00
Clara Bayarri
04d72abde1 Expose fonts.xml via public API with a service
This change creates a new FontManagerService, in charge of providing
font management data. It exposes a public API to retrieve the
information in fonts.xml without accessing it directly. To do this,
it also refactors FontListParser's internal classes into a new public
FontConfig class holding all the font data.

getSystemFonts() returns all the available information in fonts.xml
as well as file descriptors for all the fonts. This allows us to
share the memory consumed by these files between all clients.

Bug: 34190490
Test: See attached CTS change in topic
Change-Id: I0e922f8bcc9a197a1988d04071eb485328d66fb7
2017-01-23 15:02:23 +00:00
Svet Ganov
6788212d17 Platform support for static shared libraries
This change adds support for static shared libraries that
emulate static linking allowing apps that statically link
against the same library version to share a common
implementation. A library is hosed by a package in a standard
APK.

Static shared libraries have a name and a version declared
by a dedicated manifest tag. A client uses also a new tag
to refer to the static library it uses by specifying the
lib name, version, and the hash of the signing certificate.
This allows two apps to rely on two different library versions
and prevents impersonation of the shared library by a side-loaded
app with the same package name.

Internally apps providing static libs use synthetic package
name generated from the manifest package name and the library
version. This allows having different "versions" of the same
package installed at the same time.

An application cannot be installed if a static shared lib it
depends on is missing. A used shared library cannot be uninstalled.
Shared libraries can rotate certificates like normal apps. The
versions of these libs should be ordered similarly to the version
codes of the hosting package. Such libs cannot use shared user
id, cannot be ephemeral, cannot declare other libraries, cannot
rename their package, cannot declare child-packages. They must
target O SDK. Also they cannot be suspended or hidden or their
uninstall blocked. Generally, speaking policy regarding code in
static shared libs should be applied to the packages using the
library as it could have just statically linked the code.

We now have APIs to query information about the shared libraries
on the device in general. To clients static shared libraries are
presented as multiple versions of the same package which is how
they are declared and published. Therefore, one can have two
versions of the same package which means we need way to query
for and uninstall a specific version of a package. Also static
shared libs can depend on other static shared libs which are
versioned packages. To ease representation we add the concept
of a versioned package which should be used in the case of
static shared libs.

A client can see only the static shared libs it depends on and
more specifically only the versions it depends would be retrieved
by using the standard package manager APIs. There is a new
dedicated API to get info about all shared libraries which
would provide data about all static shared lib versions. Also
these libraries must use v2 signing scheme.

Test: CTS tests pass

bug:30974070

Change-Id: I4f3d537ee7a81f880950377b996e1d9d4813da5c
2017-01-22 14:05:15 -08:00
Colin Cross
f552a6f90d Merge "Revert "Update layoutlib following Change Id10ca97f on FontFamily"" 2017-01-20 04:04:31 +00:00
Siyamed Sinir
cc3c55afdc Revert "Update layoutlib following Change Id10ca97f on FontFamily"
Reason: The changes that this CL depends on, had to be reverted.

This reverts commit 7a1cab2c9606ca5aab0f030c0022b864d5c05888.

Bug: 34378805
Change-Id: I6bd05082060199c1907743b9f72d4c2438371aa6
2017-01-20 02:51:36 +00:00
Christopher Tate
42a386b771 Enable background restrictions
Apps that target O+ are always subject to background restrictions.
Legacy apps' background restriction is subject to the OP_RUN_IN_BACKGROUND
app op.

Apps with these properties are exempted from background restrictions:
  - persistent process
  - currently on the idle battery whitelist
  - global whitelist for things like bluetooth services

Bug 30953212

Change-Id: Icc19b2fbc05f40dcf8c3fc4abf718c373dc8d4f6
2017-01-19 16:23:02 -08:00
Chris Tate
9e83cbbc10 Revert "Enable background restrictions"
This reverts commit 21f778060badb1e78bffde05e8de7662d275003d.

Change-Id: I65586f9739da84fb32b51b0ea166b8288c41d1b3
2017-01-19 01:12:19 +00:00
Christopher Tate
21f778060b Enable background restrictions
Apps that target O+ are always subject to background restrictions.
Legacy apps' background restriction is subject to the OP_RUN_IN_BACKGROUND
app op.

Apps with these properties are exempted from background restrictions:
  - persistent process
  - currently on the idle battery whitelist
  - global whitelist for things like bluetooth services

Bug 30953212

Change-Id: Ib444829a2d222125f64ff19e8218823fa78373f9
2017-01-18 11:30:41 -08:00
Diego Perez
373259f296 Adds test to collect performance metrics
Test: Adds performance tests
Change-Id: I7d112ddad4efb2c1c84ac177d230225cc031f7f3
2017-01-16 18:14:34 +00:00
Diego Perez
66dc364046 Add Main back to run in buildbot
Main is now a Suite that contains all the test needed for CI

Test: No new tests needed
Change-Id: I4374faacfa38f00d404151276580de636984638c
2017-01-16 18:13:54 +00:00
Diego Perez
27c2ce3c40 Refactor tests structure
Move all the render test utility methods to a separate class and leave
only tests in RenderTests class (old Main).
The idea is to improve the organization to allow to create a set of
performance tests and also to allow the tests to grow more structured.

Test: Just moved tests around
Change-Id: I3b773d0745700dd2a52f937b9b668a2d374b8686
2017-01-16 18:13:44 +00:00
Jerome Gaillard
1ea5da6d70 Update Config.getTime method after the N release
And update the relevant golden files as the time in the status bar
is changed.

Test: Run layoutlib tests
Change-Id: I421b5495291f2d62091366bc0c066e77e0f3e107
2017-01-16 18:13:35 +00:00
Diego Perez
74f50acfc4 Merge changes Ia7a8a27f,I0646aab6,Ia324f18d,I38c6c6df,Ic9214929, ...
* changes:
  Add missing attributes to old themes
  Fix plurals support in layoutlib
  Do not log errors while loading string arrays
  Hack to deal with android:pointerIcon in layoutlib
  Force animateFirstValue to false
  Avoid passing antialias when measuring scaled text
  Catch all exceptions in NativeAllocationRegistry free
2017-01-16 18:05:51 +00:00
Jerome Gaillard
e92b15ca06 Merge "Call layout when doing an only-measure pass" 2017-01-16 17:40:16 +00:00
Diego Perez
0c864fde58 Add missing attributes to old themes
Because we always use the latest framework code, some resources might
fail to resolve when using old themes (they haven't been backported).
Since this is an artifact caused by us using always the latest code, we
check for some of those values and replace them here.

Bug: http://b.android.com/225105
Test: Included new testActivityOnOldTheme
Change-Id: Ia7a8a27fb81fe0b4a1e0c9610a2033a87720864d
2017-01-16 15:37:12 +00:00
Diego Perez
37f9ddb1c4 Fix plurals support in layoutlib
Bug: http://b.android.com/213000
Test: Manually tested on Android Studio. Adding tests for this specific
case requires bringing a new sdk-common prebuilt to the the maintenance
branch so it's not really practical.

Change-Id: I0646aab656d5d5769355c6cc026e877b8784d173
2017-01-16 15:37:04 +00:00
Diego Perez
df0c47e566 Do not log errors while loading string arrays
When arrays contain references, if we can not resolve them, just return
the reference string. This matches the behaviour of resource resolution
in BridgeTypeArray.

Bug: http://b.android.com/228620
Test: Updates existing tests
Change-Id: Ia324f18d9128b8abf2ba676a83d4b424914e2c88
2017-01-16 15:36:41 +00:00
Jerome Gaillard
7d7ef8400d Hack to deal with android:pointerIcon in layoutlib
android:pointerIcon is a View attribute that can be an enum or a
reference. Layoutlib cannot easily deal with the way that is handled
in the platform. As the property would not have any impact on the
result in layoutlib, that property is bypassed.

Test: Main.testAllWidgets
Change-Id: I38c6c6df45c1836d44b4f80245a453fb432ea251
2017-01-16 15:35:15 +00:00
Diego Perez
6782b0e74a Force animateFirstValue to false
This CL forces both animateFirstValue and animateLayoutChanges to false
in themes when running layoutlib. This helps with the rendering of some
widgets so they do not rely on animations.

Test: Test as part of testActivity
Change-Id: Ic9214929d3582bc3e0a196d198cc4fb36347c782
2017-01-16 15:34:58 +00:00
Diego Perez
f31c1e98d4 Avoid passing antialias when measuring scaled text
This is a workaround for a JDK bug that crashes the VM when
measuring scaled antialsed text.
This disables antialiasing when measuring scaled text in a specific
version of the VM.

Bug: http://b.android.com/211659
Change-Id: I637ed03cf827b65c993550998ac55d42869237ad
2017-01-16 15:34:00 +00:00
Diego Perez
c5708ef76d Catch all exceptions in NativeAllocationRegistry free
The NativeAllocationRegistry delegate free calls might run in the
context of the finalizer thread. If a crash happens during the free
call, it might bring down the finalizer thread and the VM.

Bug: http://b.android.com/213927
Change-Id: I8d4b8ab5b8d0532aad46f27d039a943894e021a0
2017-01-16 15:33:50 +00:00
Jerome Gaillard
57415885f0 Delete Canvas_Delegate.nClipRegion after Change I71f9bd68
Test: layoutlib tests
Change-Id: I9c04fa258cdaf06972b205e5dd5d3b505e5bea17
2017-01-16 15:22:42 +00:00
Diego Perez
e6052ae443 Call layout when doing an only-measure pass
Test: Modified testScrolled to check the only-measure behaviour
Change-Id: Ie86c329e0f7d9135d53274977e24f431f5edc201
(cherry picked from commit 2d657bc344717281e470430b05adaa32fbd0af00)
2017-01-16 14:29:56 +00:00
Jerome Gaillard
02d091aa2a Merge "Update layoutlib following Change Id10ca97f on FontFamily" 2017-01-16 14:24:57 +00:00
Jerome Gaillard
8dd288f420 Merge "Add measure only call to layoutlib" 2017-01-16 14:24:15 +00:00
Jerome Gaillard
1a376e2df4 Merge "Create a mock Display Mode" 2017-01-16 14:20:51 +00:00
Bartosz Fabianowski
a34f53f61b Add install reason
This CL allows a reason to be specified when installing a package. The
install reason is a sticky piece of metadata: When a package is e.g.
installed via enterprise policy and an update is then manually
installed or sideloaded, the install reason will remain "policy."
The install reason is tracked separately for each user.

With this CL, two install reasons exist: "policy" and "unknown." Other
install reasons will likely be supported in the future.

Bug: 32692748
Bug: 33415829
Test: Tested manually with "adb install" / "adb uninstall"

Change-Id: I0c9b9e1b8eb666bb6962564f6efd97e41703cd86
2017-01-13 16:51:28 +01:00
TreeHugger Robot
d96cc6e250 Merge changes I2ff9bd44,I946e681e,If72df07b
* changes:
  Handle content insets for snapshots
  Always remove starting window in performShow
  Initial implementation of snapshots
2017-01-12 17:39:15 +00:00
Jeff Sharkey
9bc89af3f1 Add API for apps to declare their "category".
Upcoming platform features need to cluster apps together into broad
categories to help summarize information to users.  (For example,
when presenting battery, network, and disk usage.)

We are tightly limiting the set of categories to keep them easily
presentable to users when summarizing information.  This feature is
not designed to be a general-purpose taxonomy, nor should it be
allowed to become one.

Older apps may not have defined a category in their manifests, so
allow the installing app to define a category on their behalf.

Test: builds, boots
Bug: 33815939
Change-Id: I785b882ee7c18072ef47d56e0fc19ad72888e1b7
2017-01-12 09:53:44 -07:00
Jorim Jaggi
e2c77f9035 Handle content insets for snapshots
Pass information about content insets of a snapshotted task to
SystemUI and use it there to correctly offset the snapshot
when drawing.

Test: Open app, go to recents, make sure app aligns before
and after the animation.
Bug: 31339431
Change-Id: I2ff9bd44534bd8f66b591385da1e1e3aec40b6c5
2017-01-12 16:28:19 +01:00
Jorim Jaggi
02886a82d8 Initial implementation of snapshots
All this functionality is hidden behind a flag. If this flag is
active, we disable the regular screenshots.

Instead, we take a screenshot when an app transition for which a
task is disappearing is starting. The screenshot gets stored
into a gralloc buffer. SystemUI uses a new method to retrieve
a snapshot gralloc buffer and then draws it using GraphicBuffer.
createHardwareBitmap().

When starting an existing activity in an existing tasks, or when
bringing an existing tasks to front from recents, we add a new
snapshot starting window. For that, we reuse the existing
starting window, but when creating the window, we use a fake
window that draws the contents of the starting window.

Test: runtest frameworks-services -c
com.android.server.wm.TaskSnapshotControllerTest
Bug: 31339431
Change-Id: If72df07b3e56f30413db5029d0887b8c9665aaf4
2017-01-12 16:28:01 +01:00
Jerome Gaillard
7a1cab2c96 Update layoutlib following Change Id10ca97f on FontFamily
Test: layoutlib tests

Change-Id: Ic8872a43993bcb0a157c5e3f0ce423af9b47f606
2017-01-12 15:06:46 +00:00
Phil Weaver
9fa89381bf Merge "Add flag and listener for a11y volume requests." 2017-01-11 21:57:09 +00:00
Diego Perez
54ffb4358c Add measure only call to layoutlib
Change-Id: Ie36a5218a0356f394356fce2b327f35f57a26951
(cherry picked from commit 7a6d487f9254aaa175976e5832cea78a1a79c9e7)
2017-01-11 20:12:14 +00:00