Commit Graph

25 Commits

Author SHA1 Message Date
Chandan Nath
dae228b492 [Roboelectric] Split Robolectric frameworks services targets
1. Move all backup tests from services/robotests/src to services/robotests/backup/src
2. Copied over services/robotests/backup/config/robolectric.properties
3. Copied and modified services/robotests/backup/Android.mk

Bug: 120223382

Test: 1) atest RunFrameworksServicesRoboTests (backup + location). out: RunFrameworksServicesRoboTests: OK (615 tests)
2) atest RunBackupFrameworksServicesRoboTests (backup). out: RunBackupFrameworksServicesRoboTests: OK (582 tests)

Change-Id: I2b0c95b22e90b01f715f772c60c2179b8c0eb29b
2018-12-18 14:39:22 +00:00
Ruslan Tkhakokhov
a2fe6c5bb9 [Multi-user] Add -user param to adb backup/restore
Add an optional parameter -user to provide ID of the user for which to
run backup/restore operation. Add robolectric test to verify the
new parameter is proccessed correctly.

Bug: 119908153
Test: 1) atest BackupTest
      2) atest BackupManagerServiceTest
      3) atest TrampolineTest
      4) atest GtsBackupTestCases
      5) atest GtsBackupHostTestCases
      6) Manual:
        - Run "adb backup -all" and verify that backup is successfull
        - Run "adb restore" and verify that restore is successfull
        - Run "adb backup -all -user 10" and verify that backup faield as
          it's only currently supported for system user
        - Run "adb restore -user 10" and verify that restore failed as it's
          only currently supported for system user

Change-Id: I6dbf9c87eedd5a72da0446beff7d2551f98f2654
2018-12-17 16:48:13 +00:00
Chandan Nath
57bf7bad03 add option --user to Bmgr.java
Bug: 118480337

Test: 1) atest RunFrameworksServicesRoboTests
    2) atest BmgrTest
    3) atest CtsBackupTestCases
    4) atest CtsBackupHostTestCases
    5) atest GtsBackupTestCases
    6) atest GtsBackupHostTestCases
    UsageStatsRestoreHostSideTest fails. I verified locally that this test
    fails without this change too.
    7) flashed device and ran:adb shell bmgr --user 10 backupnow --all
    Logs and output are as expected since backupservice isnt active for user 10
    log: Bmgr    : Running backupnow for user:10
    output: Error: Could not access the Backup Manager.  Is the system running

    8) flashed device and ran:adb shell bmgr backupnow --all
    log: Bmgr    : Running backupnow for user:0
    output:
	Running incremental backup for all packages.
	Package @pm@ with result: Success
	....
	Backup finished with result: Success

Change-Id: Icfebe26f36276ea687d15c9f9c361c409313ae9d
2018-11-21 13:52:34 +00:00
Dan Shi
a12f80da7a Merge "Add missing library of services.net" am: f48f9b91b9 am: e063a8b66c
am: 29a29e452c

Change-Id: I525a01bb878eae8b73201f3b316f2a72f8c50a2a
2018-11-15 06:33:04 -08:00
Dan Shi
dc2b63107f Add missing library of services.net
Tethering.java creates an anonymous implementation of IpServer.Callback.
robotests has static link to services.core. services.core and services.net
are merged into services in services/Android.bp.

Therefore, module FrameworksServicesLib should include both services.core
and services.net as static library.

Bug: 119401516
Test: m -j MODULES-IN-frameworks-base-services-robotests
 m -j MODULES-IN-frameworks-base

Change-Id: I4bca54e01528b87375cbcc4d9caf9e5789734b9a
2018-11-14 12:52:17 -08:00
James Lemieux
38d86c2dc5 Use tip-of-tree robolectric
By adopting robolectric built-from-source, the backup tests are no
longer grafting ToT backup classes on top of SDK 26 framework classes.

Instead, all tests are executed against the SDK built from current
master which includes the backup classes under test.

Bug: 117904612
Test: make -j56 RunFrameworksServicesRoboTests
Change-Id: Iaf911db93f318df46e47b765f94701b36bacfe59
2018-11-13 11:26:43 -08:00
Tobias Thierer
482e8570d1 Merge "Update robolectric dependency to v3.6.2." am: cc54c93376 am: 9ff0f548a9
am: a81b5b481c

Change-Id: I5b3a002415a11a71d72e3a35a86d40a6ccf0a045
2018-10-15 21:59:32 -07:00
Tobias Thierer
ee7b412c92 Update robolectric dependency to v3.6.2.
This is required for support of v53 .class files.

Test: The following tests pass both before and after this CL:
      make RunFrameworksServicesRoboTests RunBluetoothRoboTests \
           RunCarMessengerRoboTests RunKeyChainRoboTests \
      RunManagedProvisioningRoboTests
Test: The above tests also pass when EXPERIMENTAL_USE_OPENJDK9=true
      (they didn't pass with v3.6.1).
Test: The following tests fail both before and after this CL (error
      trying to mock a final class):
      make RunStorageManagerRoboTests RunEmergencyInfoRoboTests

Bug: 116872534
Change-Id: I903a3448af1c0be55cc4af098521b3ba422c5579
2018-10-12 18:32:08 +01:00
Bram Bonné
226dfa2eda Moves all backup chunk-model related classes over to the framework.
Includes the proto definition of ChunksMetadata and related classes.

Some additional changes (apart from style) were needed:
- EncryptedChunkOrdering was modified to be a non-AutoValue class, and
tests were added.
- Protos are now read from an InputStream manually, as any protos should not
be used directly in the platform.
- Helper classes are added for reading from ProtoInputStream.

Bug: 111386661,116575321
Test: atest RunFrameworksServicesRoboTests
Change-Id: I8b74ad059d72e305be7817f79f8c61aa50f7b268
2018-09-25 16:04:32 +02:00
Bram Bonné
cf2b7c3b39 Moves first parts of backup crypto code (ChunkHash class) to the framework.
Some changes were needed to the original code:
- Guava's EqualsTester tests are replaced by regular equals tests.
- Guava's primitives.UnsignedBytes.LexicographicalComparator needed to
be copied over, as no corresponding comparator exists in the framework.

Bug: 111386661
Test: atest RunFrameworksServicesRoboTests
Change-Id: I24fef4b47f7777b9be0c2e51f0be48e45b323987
2018-09-11 19:32:25 +02:00
Annie Meng
1374690674 [FBR] Extract app metadata backup to helper
In full backup, we backup additional metadata about the app
(manifest, widget, apk, obb) not specified by the app's backup agent.
This CL extracts these methods out to their own helper (AppMetadataBackupWriter)
and adds unit tests for these methods.

** Note: The backup behavior is the same, only the structure has changed.
Behavioral changes will be done in future CLs. **

What this CL covers:
- Move the backup of this extra app data out of the FullBackupEngine to
separate agent data backup and non-agent data backup.
- Move logic of deciding what data to backup from FullBackupEngine to
FullBackupRunner (where the writer is used).
- Add unit tests for metadata backup.
- Some style fixes/clean up.

Not covered (future CLs):
- Refactoring FullBackupEngine/FullBackupRunner mechanism.
- Streaming backup data directly instead of writing to temporary files.
- Separating out and fixing apk and obb backup.

Bug: 110081582
Test: 1) atest AppDataBackupWriterTest
2) atest RunFrameworksServicesRoboTests
3) atest GtsBackupHostTestCases
4) Verify success for:
 - adb shell bmgr backupnow <full backup package>; adb restore 1 <full
backup package>
 - adb backup <full backup package>; adb restore
 - cloud backup and restore
5) Use local transport and adb backup to inspect manifest and widget data
written and file metadata consistent between runs.
6) Verify compatibility with adb backup -keyvalue manifest

Change-Id: Icb43fd2e0505c2416738ee3ef370b206363fac68
2018-09-07 14:56:45 +01:00
Annie Meng
7d3033b11f DO NOT MERGE Create a key value settings observer for backup parameters
Extracts an abstract class to observe changes in backup parameter settings that
are stored as a comma-separated key value list. This class is
responsible for registering and unregistering a content observer on the
setting and updating local references to the parameters.

Refactor BackupManagerConstants and LocalTransportParameters to use this
implementation. This will also be used for the new backup timeout
setting.

Bug: 74346317
Test: 1) m -j RunFrameworksServicesRoboTests ROBOTEST_FILTER=BackupManagerConstantsTest
2) gts-tradefed run commandAndExit gts-dev -m GtsBackupHostTestCases -t com.google.android.gts.backup.TransportFlagsHostSideTest

Change-Id: Id4c50fbcf7479c925515887e3fa70e166dd9955c
2018-03-13 18:47:46 +00:00
Annie Meng
48b2ecae52 Create a key value settings observer for backup parameters
Extracts an abstract class to observe changes in backup parameter settings that
are stored as a comma-separated key value list. This class is
responsible for registering and unregistering a content observer on the
setting and updating local references to the parameters.

Refactor BackupManagerConstants and LocalTransportParameters to use this
implementation. This will also be used for the new backup timeout
setting.

Bug: 74346317
Test: 1) m -j RunFrameworksServicesRoboTests ROBOTEST_FILTER=BackupManagerConstantsTest
2) gts-tradefed run commandAndExit gts-dev -m GtsBackupHostTestCases -t com.google.android.gts.backup.TransportFlagsHostSideTest

Change-Id: Id4c50fbcf7479c925515887e3fa70e166dd9955c
(cherry picked from commit 16ef6ffb3cbea77637ad99c2b0c79cbfd8f03c9a)
2018-03-13 18:24:12 +00:00
Anton Hansson
d137c872cd frameworks/base: Set LOCAL_SDK_VERSION where possible.
This change sets LOCAL_SDK_VERSION for all packages where
this is possible without breaking the build, and
LOCAL_PRIVATE_PLATFORM_APIS := true otherwise.

Setting one of these two will be made required soon, and this
is a change in preparation for that. Not setting LOCAL_SDK_VERSION
makes the app implicitly depend on the bootclasspath, which is
often not required. This change effectively makes depending on
private apis opt-in rather than opt-out.

Test: make relevant packages
Bug: 73535841
Exempt-From-Owner-Approval: Global cleanup
Change-Id: I26458e41ecb84de91ac9a356a5d4bafb44f463c1
2018-03-07 11:42:04 +00:00
Michal Karpinski
b5e0931dcd Extend XML parser to allow optional requiredFlags attribute
for <include /> rules in <full-backup-content> specification

Give an app developer the option to include files based on the
transport flags exposed by the transport. This allows conditionally
including files as long as the transport identifies itself as
for instance encrypted or device-to-device.

Extend the parsing mechanism to read optional requiredFlags
attributes, and extend existing structures to encompass
that data for BackupAgent to retrieve and act on it
based on FullBackupDataOutput#getTransportFlags().

-- Changes in robotests/

The old version of this CL (that already got reverted) broke our Robolectric
suite because it added an inner class to FullBackup and a dependency on it from
BackupAgent. FullBackup wasn't being built from Android tree (instead it was in
a prebuilt Robolectric snapshot jar of the framework) but BackupAgent was,
which resulted in not finding the inner class.

So, also in this CL. Changing our tests to include everything under
platform/base/core/java/android/app/backup from Android tree.
`m -j RunFrameworksServicesRoboTests` is green now

Bug: 72484288
Test: m -j RunFrameworksServicesRoboTests
Test: runtest frameworks-core -c android.app.backup.FullBackupTest
Test: make cts -j40 && cts-tradefed run cts -m CtsBackupHostTestCases -t android.cts.backup.FullbackupRulesHostSideTest
Change-Id: Ideaed59f8337257aa6a882ff0ce80c170b17d55e
2018-02-22 13:18:02 +00:00
Robert Berry
39194c0582 Add #getTransportFlags to BackupDataOutput
This allows a BackupAgent to check whether the transport has client-side
encryption enabled. It can then use this information to decide whether
to back up more sensitive data.

Bug: 72299360
Test: Manually verified full & kv backup agents receive transport flags
Test: m -j RunFrameworksServicesRoboTests
Change-Id: Ibd9b5f9479815e1721e9d6b7663d892b9ab3fcae
2018-01-25 09:28:55 +00:00
James Lemieux
0f5bba003b Adopt robolectric 3.6.1
Bug: 71596155
Test: make RunSettingsLibRoboTests
Change-Id: I0f8e538238c42fed89bc4778a6a717f2eddac9b7
2018-01-06 00:28:25 -08:00
Bernardo Rufino
2447687352 Use testng for utilities in tests
Frameworks services tests and cts already use it.

Test: m -j RunFrameworksServicesRoboTests
Change-Id: Ib613997e9a7278f6b424cd4ce4aa16c112756564
2017-12-21 11:46:00 +00:00
Bernardo Rufino
90a8802328 Update Roboletric to 3.5.1
To be able to migrate Robolectric and bump SDK we have to load our classes from
the system class loader instead of the android jars. This wasn't a
problem before because the classes weren't in the jars correspondent to the old
SDK that the tests were using. To be able to do this I created a custom test
runner and a custom annotation to be used in tests to load the specified
classes from the system class loader. Check comments on file. Also, made changes
to be compatible with new Robolectric version and bumped SDK.

Bug: 69254249
Test: m -j RunFrameworksServicesRoboTests
Change-Id: I538ef70cfae8ebeea047f275b9920cb2e814f4da
2017-12-13 20:23:31 +00:00
Maurice Lam
d42f99c520 Specify the version for Robolectric version
The previous default version was 3.1.1, so specifying all existing
projects to that. Please migrate to new version (3.4.2 as of today)
at your convenience.

See robolectric.org/migrating for instructions on migrating.

Test: m RunFrameworksServicesRoboTests RunCarMessengerRoboTests \
    RunStorageManagerRoboTests RunCarSettingsRoboTests \
    RunEmergencyInfoRoboTests RunManagedProvisioningRoboTests \
    RunTurboRoboTests RunStorageManagerGoogleRoboTests \
    RunBluetoothRoboTests

Change-Id: Ife5a39b81206ec475bba5c4042258a37ad24707d
2017-11-14 13:10:36 -08:00
Bernardo Rufino
b7e9ac8f2c Explicit Roboletric version for runner
* Our test target uses default roboletric target
(platform-robolectric-prebuilt), which is 3.1.1.
* Runner was updated to 3.4.2 recently (ag/3181301).
* `make RunFrameworksServicesRoboTests` broke because
org.robolectric.res.builder.DefaultPackageManager doesn't exist in new
verion (http://robolectric.org/migrating/#packagemanager-1).

Hardcoded version in our target until we migrate to new version (I tried
but there were some other errors)

Test: make RunFrameworksServicesRoboTests
Change-Id: Ie934dedec3340620611f3d72b75e5eefba430f35
2017-11-13 18:21:07 +00:00
Bernardo Rufino
58dd6c376e Adjust services robotest makefile
In preparation for transport-related tests needed to make those fixes so
that Mockito annotations would work.

1. Switched from mockito-target-minus-junit4 to
mockito-robolectric-prebuilt. Otherwise we would get dexcache == null
error (similar to
https://groups.google.com/a/google.com/forum/#!topic/robolectric-users/gV0_59Kj2ME/discussion)

2. Removed unused frameworks-base-testutils because it included the
ill-suited mockito dependency (as per 1).

3. Tidied up by moving test dependencies to actual test target.

Test: make RunFrameworksServicesRoboTests
Change-Id: Idd4f13a9aa0327d74b58361ad02aa3313d30ac99
2017-11-10 11:21:52 +00:00
Maurice Lam
458d6a87d3 Remove dependency on platform-system-robolectric
Dependency on platform-system-robolectric is not needed when mockito
is not necessary.
If mockito is needed, add a static dependency on
mockito-robolectric-prebuilt.

Test: m RunFrameworksServicesRoboTests
Bug: 38456058
Change-Id: I60ac070125cf157225247561336288dfe97789c6
2017-09-06 14:38:07 -07:00
Artem Iglikov
bd476eae4b Update TransportManager tests.
This applies changes that disappeared for some reason from ag/2314382

Bug: 37616038
Test: make RunFrameworksServicesRoboTests
Change-Id: Iabfafd8c6afaac7304194f7645d08ef9e6f3b3aa
2017-09-01 11:03:03 +01:00
Artem Iglikov
5ed1dab192 Add a test for TransportManager#onPackageAdded().
Also set up robolectric tests for framework services.

Bug: 37616038
Test: make RunFrameworksServicesRoboTests
Change-Id: Ia27a58365a0826ec5bc9f8a7544024b52cfbb3ec
2017-08-31 16:59:28 +01:00