500 Commits

Author SHA1 Message Date
Chad Brubaker
1f4e053aef Merge "Address API review comments for registerReceiver" into oc-dev 2017-04-20 19:52:51 +00:00
TreeHugger Robot
fb4fb03cc3 Merge "Address API council comments" into oc-dev 2017-04-20 03:53:37 +00:00
Chad Brubaker
6d6015f652 Address API review comments for registerReceiver
Bug: 37465538
Test: manual; Verified that Instant Apps can send broadcasts to
receivers still via the changed API.

Change-Id: Ib0f3d0c8ee71234288ccecd07e621554eb9b70ac
2017-04-19 15:06:35 -07:00
Chad Brubaker
0d277a7b18 Change ANDROID_ID for Instant Apps
ANDROID_ID for Instant Apps now has the following properties:
1) per-app scoped
2) reset if the user clears the Instant App
3) remains the same if the Instant App gets upgraded to an installed
app.

Note that if the user goes instant -> installed_1 -> uninstall ->
installed_2 the ANDROID_ID at installed_1 will not be the same as
installed_2. This was deemed better than the id changing on the upgrade
step.

Test: manual
Change-Id: I532975c50049c94ff80902a897e001dd35a69f9f
2017-04-19 11:10:53 -07:00
Svetoslav Ganov
345ffa5421 Address API council comments
Test: cookie CTS tests pass

bug:37327624
bug:37325276
bug:37323696

Change-Id: I52b10470759e471629ec6772e115df94482eb341
2017-04-18 16:44:43 -07:00
Christopher Tate
242ba3e997 Turn down the preliminary foreground service API
The NotificationManager.startServiceInForeground() experiment is over,
and will not ship as API, so it's time to tidy up and get rid of it.

Bug 36130212
Test: manual

Change-Id: I834d1ce059aa464ff27f69f5e5d3625cc5e61d8a
2017-04-17 14:22:18 -07:00
Todd Kennedy
801e65905b expose the instant app installer component
Bug: 35873804
Test: TreeHugger
Change-Id: I4d962927587bb10833bfe3c3db27fdceab668fc3
2017-04-14 09:49:13 -07:00
Dianne Hackborn
a47223f99b Implement issue #36590595: Add ability to associated a ClipData with JobInfo
Yum!

Also needed to have a Context.revokeUriPermission() variant that is sane,
so reasonable CTS tests can be written.

Test: new ClipDataJobTest added.

Change-Id: Ia3135ea788a6e32c971bae7dab3a844d0ef4139c
2017-03-31 10:41:50 -07:00
Christopher Tate
08992ac57e API refactor: context.startForegroundService()
Rather than require an a-priori Notification be supplied in order to
start a service directly into the foreground state, we adopt a two-stage
compound operation for undertaking ongoing service work even from a
background execution state.  Context#startForegroundService() is not
subject to background restrictions, with the requirement that the
service formally enter the foreground state via startForeground() within
5 seconds.  If the service does not do so, it is stopped by the OS and
the app is blamed with a service ANR.

We also introduce a new flavor of PendingIntent that starts a service
into this two-stage "promises to call startForeground()" sequence, so
that deferred and second-party launches can take advantage of it.

Bug 36130212
Test: CTS

Change-Id: I96d6b23fcfc27d8fa606827b7d48a093611b2345
(cherry picked from commit 79047c62b58fb0a0ddf28e2b90fe4d17e05bc528)
2017-03-30 18:31:24 +00:00
Chad Brubaker
336ae5b616 Add ACTION_EPHEMERAL_RESOLVER_SETTINGS
This Intent will be used in Settings to show the settings UI for the
Ephemeral resolver. Settings can get the correct component to send the
Intent to by calling
PackageManager.getInstantAppResolverSettingsComponent

Bug: 35918998
Test: Boots
Change-Id: I0edcf85704f2c19e0ee27f91b6ef057d52e32778
(cherry picked from commit aa49cb86e6d5f23d82c97db32c848bc4ea2b81bc)
2017-03-28 20:34:55 +00:00
Todd Kennedy
ab53289c59 Add API to mark apps that have an update available
Ostensibly for instant apps, we allow play to mark an app as having
an update available. This will trigger instant app resolution even
if the instant app is already installed on device.

Bug: 35143464
Test: Manual; launch URI of installed instant app, see it runs w/o resolution. set bit. launch URI of installed instant app, see it runs resolution
Change-Id: I511df2b2a3eab39377167c770255ccbe02d5dad2
2017-03-15 07:31:09 -07:00
Chad Brubaker
816c83bf03 Enforce visibleToInstantApps for receivers
Instant apps can only send broadcasts to receivers that are declared in
the manifest with android:visibleToInstantApps=true or if the app
registers a receiver at runtime using the new methods that take
visibleToInstantApps.

Bug:33350280
Test: Manually sending broadcasts from Instant Apps only goes to
receivers with visibleToInstantApps set to true.
Test: Receiving a broadcast from within the same app does not require
visibleToInstantApps to be set.

Change-Id: I54d79a502ba9c5fd03ede3c09e08afc88fe2775f
2017-03-07 15:28:03 -08:00
David Christie
31a1655191 Create PackageManager.isInstantApp API to query whether
a given package name is an instant app.

Test: refactor existing codepaths retained

Change-Id: I6253fe8cc398d6547566d11043bffd1c4ffaa74a
2017-03-01 16:36:48 -08:00
Paul Duffin
0a4cf4b57f Merge "Deprecate TestSuiteBuilder and related classes." am: a26000b8f5 am: fd61eb1e39
am: 9dcdc8f187

Change-Id: Icbc80cc054244f2660814bde4a9dc681b501024f
2017-02-23 13:56:23 +00:00
Paul Duffin
fd61eb1e39 Merge "Deprecate TestSuiteBuilder and related classes."
am: a26000b8f5

Change-Id: Ia9d491bd72f2a9f08838e298aaf4de5de28c7d4f
2017-02-23 13:44:24 +00:00
Paul Duffin
3600f7b645 Merge "Remove conflicting package information for junit.runner and junit.textui" am: f3f4775a35 am: 9b5522f8c4
am: da4597769b

Change-Id: Ibbcb838b9d41391b559a555111ebafce437a5679
2017-02-22 15:31:55 +00:00
Paul Duffin
9b5522f8c4 Merge "Remove conflicting package information for junit.runner and junit.textui"
am: f3f4775a35

Change-Id: Ie0ca0b2b6b5f06e90f55996625f758521c9039cb
2017-02-22 15:24:27 +00:00
Paul Duffin
253ad40649 Deprecate TestSuiteBuilder and related classes.
Deprecates com.android.internal.util.Predicate in favour of
java.util.function.Predicate.

Deprecates TestMethod and TestSuiteBuilder in favour of
Android Test Support Library.

Bug: 35089332
Test: make checkbuild
Change-Id: Id8b2be55925d7ca09750fc9681817793517ceb5d
2017-02-22 15:18:19 +00:00
Paul Duffin
f845fec30c Remove conflicting package information for junit.runner and junit.textui
Removes package.html files and update package-info.java files to
use same wording as previous releases.

Bug: 35653948
Test: make docs
Change-Id: Idbede2eb4f57818f152834fad7e75dd181fe25d6
2017-02-22 12:43:57 +00:00
TreeHugger Robot
96b9832163 Merge "API for accessing preloaded files cache" 2017-02-17 21:09:28 +00:00
Fyodor Kupolov
61221290f5 API for accessing preloaded files cache
Added @SystemAPI method Context.getPreloadsFileCache.

Bug: 31008665
Test: manual
Change-Id: Id61ab5e1b78d8bfbd40f61985406a8de4082b30f
2017-02-17 10:40:54 -08:00
Andrii Kulian
b047b8bd7e Report move to display for activities that handle config changes
When activity that is moved between displays handles all configuration
changes, it won't be restarted. This CL adds a callback to the client
to notify it about display change. Usually it will be followed by
onConfigurationChanged, except when configuration didn't actually change.
When activity is recreated, it won't receive onMovedToDisplay.

Bug: 34862802
Test: android.server.cts.ActivityManagerDisplayTests
Test: #testOnMovedToDisplayCallback
Change-Id: I9a9501cab788623ada15a31efb53e4b2378639fe
2017-02-16 17:33:59 -08:00
Todd Kennedy
9106c64bf3 Add API to track package changes
After any package install, removal or update, save the changed
package and update a global sequence number. At any point, apps
can query for the packages changed since a particular sequence
number.

If a package is changed multiple times, it is only included once
in the change list.

Bug: 33865505
Test: Create sample app to query for changes and see which packages are changed after performing certain operations
Change-Id: Ia4646035362b16a97110e05f3f909ce385b48428
2017-02-14 12:44:50 -08:00
Paul Duffin
6cd440c574 Merge "Partial Revert "Replace com.android.internal.util.Predicate with java.util.function.Predicate"" am: 621ebe692f am: a2c92b0b88 am: c1a93884dc
am: 8faed45024

Change-Id: I9d047f2e7bd8dfb14bf7b1f8c82ce6721e105198
2017-02-09 20:02:25 +00:00
Paul Duffin
c1a93884dc Merge "Partial Revert "Replace com.android.internal.util.Predicate with java.util.function.Predicate"" am: 621ebe692f
am: a2c92b0b88

Change-Id: I605588603280ff0b4ebc1088c6c1f1c933c1e657
2017-02-09 19:32:58 +00:00
Paul Duffin
57e490cf8c Partial Revert "Replace com.android.internal.util.Predicate with java.util.function.Predicate"
This partially reverts commit 3e5fbca0c57742f28f5c7e6bda6c3500b9471b47.

Bug: 35187548
Bug: 30188076
Bug: 35089332
Test: make checkbuild
Change-Id: I7ab4279aab604e3d56003b0a59867948aebabd28
2017-02-09 14:52:43 +00:00
Paul Duffin
9250814fd2 Merge "Replace com.android.internal.util.Predicate with java.util.function.Predicate" am: 78a20be77a
am: 9e99b9ee45

Change-Id: I289950cff0cdc6b5ad301936c7b55eadee5fd0f8
2017-02-08 18:30:17 +00:00
Paul Duffin
ca4964ccbe Replace com.android.internal.util.Predicate with java.util.function.Predicate
Bug: 35089332
Bug: 30188076
Test: make checkbuild
Change-Id: I0a5b4bf520fc39b59d8d790b01e9cff0d54e6d21
2017-02-08 11:55:39 +00:00
Paul Duffin
3e5fbca0c5 Replace com.android.internal.util.Predicate with java.util.function.Predicate
Bug: 35089332
Bug: 30188076
Test: make checkbuild
Merged-In: I0a5b4bf520fc39b59d8d790b01e9cff0d54e6d21
Change-Id: I58e4e35e7b7315033d893748f7c79e1ba6732f39
2017-02-07 16:57:54 +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
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
7c230c6f3c Add hidden API for whether permission review mode is on.
am: 7b89a7b1f7

Change-Id: I925b6de9f79850dcc816a73357d1d589eeac6333
2017-01-27 16:55:03 +00: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
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
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
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
Paul Duffin
ccb0445027 Prepare for removal of legacy-test from default targets
In preparation for removing junit classes from the Android API
the legacy-test target will be removed from the
TARGET_DEFAULT_JAVA_LIBRARIES. This change adds explicit
dependencies on junit and/or legacy-android-test to ensure that
modules will compile properly once it is removed.

(cherry picked from 6387604f9e672ece85e07c4bcbd7be396867f06f)

Bug: 30188076
Test: make checkbuild
Merged-In: I13e88297731253420e4e5f5291d503f13a39a156
Change-Id: I58446eb8c45d8ac2bcdbc9fa40d1321e811bdd4b
2017-01-19 09:43:05 +00:00
Paul Duffin
8aeb59ebcd Prepare for removal of legacy-test from default targets
In preparation for removing junit classes from the Android API
the legacy-test target will be removed from the
TARGET_DEFAULT_JAVA_LIBRARIES. This change adds explicit
dependencies on junit and/or legacy-android-test to ensure that
modules will compile properly once it is removed.

Bug: 30188076
Test: make checkbuild
Change-Id: I13e88297731253420e4e5f5291d503f13a39a156
2017-01-18 16:39:34 +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
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
Tony Mak
bf9928de18 Make sure ServiceConnection callback is called in main thread
Fix: 33568999

Test: cts-tradefed run cts --module CtsDevicePolicyManagerTestCases
--test com.android.cts.devicepolicy.DeviceOwnerPlusManagedProfileTest

Change-Id: I14c8b5b1f78192429e68a3057430406245a909c8
2016-12-29 14:07:46 +00:00
Paul Duffin
ed7d67a920 Copy junit-runner files into test-runner. am: eef35dd29a am: b46cecb6c4 am: b6421ce031
am: 50c1bb82b1

Change-Id: I7be2758511183480d9ba948ed1e0958e2e7a97c5
2016-12-14 13:56:44 +00:00
Paul Duffin
eef35dd29a Copy junit-runner files into test-runner.
The android.test.runner target forms part of the Android API and
so must maintain backwards compatibility. The junit classes that
belong in there are copied here to ensure that they do not
change when external/junit is upgraded.

Bug: 30188076
Test: make checkbuild and checked android.test.runner contents
Change-Id: I947144c47ae1c3eb361a43c39bdd03dc11b9575f
2016-12-14 10:41:05 +00:00
Steve McKay
ea93fe7539 Replace ContentProvider SQL args w/ Bundle & Constants.
Test: cts-tradefed run cts-dev -m CtsContentTestCases
Bug: 30927484
Change-Id: Idb9dbc2b80896e9f8474a0db71353b7a3810d597
2016-12-09 12:31:44 -08:00
Paul Duffin
4a7cda98fc Merge "Replace core-junit with junit" am: 6ac5293751 am: a4d7100a3b am: 9cb5f2815d
am: b6961ffa53

Change-Id: Id397baf01c8285b0843a66afd544ddf89abf451f
2016-12-07 13:24:14 +00:00
Paul Duffin
9249205d1b Replace core-junit with junit
Bug: 30188076
Test: make checkbuild
Change-Id: I0cb6f89907eb099714b54bac57b51c4be186c3e0
2016-12-06 14:32:41 +00:00
Kenny Guy
02c8990bd6 Allow overriding max profile in debugable builds.
Support a system property on debugable builds to
override the max number of managed profiles to
allow easier dogfooding of multiple profiles.
Support 3 different badge colours for managed profiles.

Bug: 30473760
Test: runtest -c com.android.server.pm.UserManagerServiceCreateProfileTest frameworks-services
Test: runtest -c com.android.server.pm.UserManagerServiceUserInfoTest frameworks-services
Test: manual - attempting to create 2 profiles with adb fails, passes once I set the property.
Change-Id: Ie7fb19048a04a01572666f229283152254d0ffc3
2016-11-29 14:09:37 +00:00
Paul Duffin
d5fd01c89a Move JUnit classes from here into external/junit am: 0342ab5b94 am: b9e33cd549 am: f99687ee83
am: e3b757a4bf

Change-Id: Ib11a330ca65e9c2d2904993cbd67e604b2b80d5d
2016-11-24 14:08:54 +00:00