527 Commits

Author SHA1 Message Date
Paul Duffin
fedb4b7456 Clean up Predicate related code in android.test
Part of the work of removing JUnit and dependent android.test classes
from the Android API involves providing a static library that developers
can include in their test applications to ease migration. That library
will be built directly from the source (as opposed to android.jar which
is built from stubs) and so developers will be able to see classes and
methods that are not present in the stubs. This change is one of a
number of similar changes that cleanup the existing non-API code in
order to minimize the additional methods and classes exposed externally.
The basic approach is to remove unused classes and methods, use least
visible access modifier possible and generally minimize the amount of
publicly visible code.

The HasClassAnnotation and HasMethodAnnotation were never used
separately and only used by HasAnnotation. This merges the functionality
into a single nested class in TestPredicates, hidden behind the new
TestPredicates.hasAnnotation(). The HasAnnotationTest was renamed as
TestPredicatesTest and the HasClassAnnotationTest and
HasMethodAnnotationTest classes were removed as their tests provide no
additional coverage. The removal of the Has*Annotation.java files means
that the test-runner/src/android/test/suitebuilder/annotation/ directory
is empty apart from the package.html file so that was moved to
legacy-test to sit alongside the actual annotation classes.

The Predicates class, while part of the legacy-test module was only
ever used by the test-runner module and only its not() method was
actually used. So, the not() method and associated nested class were
moved to TestPredicates, the tests for not() were moved to
TestPredicatesTest and the Predicates* classes were removed.
That allowed for the removal of the legacy-android-tests as that is now
empty.

TestPredicates has a number of constants that were public. They were
hidden by moving them to the class that actually used them.

A minor generic issue was fixed in AssignableFrom.

Bug: 30188076
Test: make checkbuild and run FrameworkTestRunnerTests
Change-Id: I861da388a4146bb28e1e480d1b7ba9137b7b270e
2017-06-22 15:48:44 +01:00
Paul Duffin
e211119fea Merge "Ensure that android.test tests pass" am: 156775fea8
am: 34dc5a58b3

Change-Id: I546ea542d0781f825e131eb94bc54e22adadfc4e
2017-06-22 14:39:08 +00:00
Paul Duffin
2a637cf9b0 Ensure that android.test tests pass
It looks as though the tests in test-runner/tests have not actually been
run successfully for over 7 years. As a result they have degraded. This
change fixes the tests so that they will pass and provides instructions
on how to run them.

TestCaseUtilTest.testGetTestCaseNamesForTestSuiteWithSuiteMethod
    This fails because it expected 2 names to be returned but only
    returns 0. The reason for that is although TwoTestsInTestSuite has a
    Test suite() method that does create a TestSuite with two tests the
    TestCaseUtil method does not actually call suite(). Instead, because
    TwoTestsInTestSuite is a TestSuite it just calls the tests() method
    on it which returns an empty Enumeration because TwoTestsInTestSuite
    is empty.

    The support for "static Test suite() {}" is broken but fixing this
    will affect the behavior of InstrumentationTestRunner which is used
    in thousands of different places both in and outside Google and so
    could cause untold problems.

TestSuiteBuilderTest.testIncludeAllPackagesUnderHere
    Reformat the list, one per line and then add missing name
    "testPublicConstructor".

ErrorTest/FailingTest
    These tests are not meant to be run on their own, only as part of a
    separate test. The RunAsPartOfSeparateTest annotation was added to
    allow these to be excluded using notAnnotation as shown in the
    instructions for running the tests.

Bug: 30188076
Test: followed new instructions in test-runner/tests/Android.mk
Change-Id: I60e7bee9cd08a9ab7777a2578fc58da772de5c1f
2017-06-22 12:58:58 +01:00
Paul Duffin
e2744c2705 Merge "Cleanup a.t.TestGrouping" am: 01dcf54e9a
am: e6ac3a4efc

Change-Id: Id41ba23de38e5131460cad283fd5d7bea66d2156
2017-06-21 09:18:01 +00:00
Treehugger Robot
01dcf54e9a Merge "Cleanup a.t.TestGrouping" 2017-06-21 09:03:29 +00:00
Paul Duffin
b4621a4072 Merge "Remove unused a.t.InstrumentationUtils" am: 0e4f1358d6
am: 08c12d21f5

Change-Id: I46ab06228623aa4e350b1285761e062e1d7393c0
2017-06-21 08:16:42 +00:00
Paul Duffin
4d7e8fb79e Merge "Cleanup a.t.InstrumentationTestRunner" am: 9d5576e081
am: 66b8ef6615

Change-Id: I3ca3f23c2f8a741daf867aad08f57bac373e5d91
2017-06-21 08:13:05 +00:00
Paul Duffin
28600f2cae Merge "Remove unused a.t.s.InstrumentationTestSuiteBuilder" am: 1935dce8eb
am: a4d2464189

Change-Id: I88278d5cfd8fc3466cce39de3de54e34d67cbe0f
2017-06-21 08:07:14 +00:00
Paul Duffin
f18dd720d3 Merge "Remove unused android.test.DatabaseTestUtils" am: 3724e7e5e9
am: e6e0601862

Change-Id: I2c5e4c7af30893d9183ee35326814fcb4506d0e8
2017-06-21 08:03:56 +00:00
Paul Duffin
0e4f1358d6 Merge "Remove unused a.t.InstrumentationUtils" 2017-06-21 07:46:41 +00:00
Paul Duffin
9d5576e081 Merge "Cleanup a.t.InstrumentationTestRunner" 2017-06-21 07:46:05 +00:00
Paul Duffin
1935dce8eb Merge "Remove unused a.t.s.InstrumentationTestSuiteBuilder" 2017-06-21 07:46:03 +00:00
Paul Duffin
3724e7e5e9 Merge "Remove unused android.test.DatabaseTestUtils" 2017-06-21 07:46:00 +00:00
Paul Duffin
b3be07bc77 Merge "Remove unused a.t.InstrumentationCoreTestRunner" am: 1bfccadc81
am: dfc6939ed5

Change-Id: I5ccdb58bbcde73a33bdce9b65d95aad2bf7b931f
2017-06-20 15:05:46 +00:00
Paul Duffin
e2e557976f Cleanup a.t.TestGrouping
TestGrouping is not part of the API but is used by classes that are and
so will need to be included in the static library we ship as part of the
SDK. As that library will be built directly from the source (as opposed
to android.jar which is built from stubs) developers will be able to see
classes and methods that are hidden and so not present in the stubs.

This change makes TestGrouping and its members as inaccessible as
possible. Unused methods and fields were removed and the TestGrouping
class was simplified by passing the ClassLoader into the constructor,
initializing the classLoader, making the classLoader field final,
and removing the setClassLoader(ClassLoader) method.

Bug: 30188076
Test: make checkbuild
Change-Id: Ie0545b1a61b74cdbc78667417f360b5197e2e128
2017-06-20 15:29:57 +01:00
Paul Duffin
44c717386d Remove unused a.t.InstrumentationUtils
Bug: 30188076
Test: make checkbuild
Change-Id: Ia06e4ae77f2c0ca341ef7c04f5f32bdd6a06d59c
2017-06-20 15:02:57 +01:00
Paul Duffin
575f9da647 Cleanup a.t.InstrumentationTestRunner
ARGUMENT_TEST_CLASS, ARGUMENT_TEST_PACKAGE, ARGUMENT_TEST_SIZE_PREDICATE
and ARGUMENT_DELAY_MSEC were made package private because they are not
part of the API and are only used from within the same package.

The JavaDoc comment was changed to a multi-line comment because it is
not and should not be associated with any member.

Fixed a couple of minor JavaDoc issues.

Bug: 30188076
Test: make checkbuild
Change-Id: If28460aec2fd0080e0f5346a83abae393b7a9fb2
2017-06-20 15:02:38 +01:00
Paul Duffin
4f1dbfed97 Remove unused a.t.s.InstrumentationTestSuiteBuilder
Bug: 30188076
Test: make checkbuild
Change-Id: I30514123c077e6047227f888f5f1a20e71ee1988
2017-06-20 15:01:36 +01:00
Paul Duffin
57d5b8d02d Remove unused a.t.InstrumentationCoreTestRunner
The only usage of this was in the unused
cts/tests/vm-tests-tf/AndroidManifest.xml which was deleted in
https://android-review.googlesource.com/#/c/418900/.

Bug: 30188076
Test: make checkbuild
Change-Id: I96f3586a7017f4cd14fa31207e0fff19c92f0de4
2017-06-20 14:58:33 +01:00
Paul Duffin
20fb642a5c Remove unused android.test.DatabaseTestUtils
Bug: 30188076
Test: make checkbuild
Change-Id: I11b1a3b90b9d17af9278ec8b28483eee01b75e81
2017-06-20 14:00:03 +01:00
Paul Duffin
2fa69bdfce Merge "Added android.test.mock and android.test.mock.sdk targets" am: 46f8d427c4 am: de30ee2d40
am: e468747115

Change-Id: I50e3ae83eabe75cb87e0dd25acd05eee811c25ce
2017-06-06 08:13:12 +00:00
Paul Duffin
4823935a84 Added android.test.mock and android.test.mock.sdk targets
The android.test.mock will be used for any targets that require
android.test.mock classes but which do not already depend on the
sdk. It is also the library that will be added to the classpath
at runtime when an app has the following in their manifest.
    <uses-library android:name="android.test.mock"/>

The android.test.mock.sdk will be used by targets that require
android.test.mock classes and which build against the SDK. It
contains stub classes (like android.jar). It is also the library
that will be copied into the optional directory of the SDK.

(cherry picked from f74752293d1d25633aebc42c600717d0296a0820)

Bug: 30188076
Test: make checkbuild
Change-Id: If199180e1136da1927a9e7c7bcafbcfb29cf1274
Merged-In: Ia3fcd47c644b8e5a573f891571a7b3772eac63f9
2017-06-05 13:49:50 +01:00
Sunny Goyal
1e0a89055d Merge "Setting Session commited broadcast when an existing apk is enabled for a different user" into oc-dev
am: fc157e702f

Change-Id: I4cabbad8bac8fb24c86506a89c29d0a34b90a564
2017-05-12 21:16:32 +00:00
Sunny Goyal
a31a74b993 Setting Session commited broadcast when an existing apk is enabled for
a different user

Test: Manual tests and CTS
Bug: 38204385
Change-Id: Ic3bddbc2e6070c11b11f0685077db7737f2b8849
2017-05-12 10:00:30 -07:00
Paul Duffin
943041abd2 Merge changes I4c0e7fdd,I9ea3827a am: c876eece68 am: 557996e1d0
am: a158b3cb15

Change-Id: Ia76a1e34c541c64d4b226b9492ca6f05d30fc5a4
2017-05-12 13:03:29 +00:00
Paul Duffin
2231eb42ec Remove dependency on internal FileUtils class
In preparation for building android.legacy.test library against
the test API this removes a dependency on internal classes.

Bug: 30188076
Test: make checkbuild cts-tradefed run cts -m CtsContentTestCases -t android.content.cts.SyncStorageEngineTest
Change-Id: I4c0e7fdd368e96459c8404ff7cea8738683d0ec1
2017-05-11 12:42:33 +01:00
Paul Duffin
8c5a24d169 Remove dependency on com.google.android.collect classes
In preparation for building android.legacy.test library against
the SDK this removes a dependency on internal classes.

Bug: 30188076
Test: make checkbuild
Change-Id: I9ea3827ab5db167c8cbddad25f0815c942681092
2017-05-11 12:41:31 +01:00
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