Commit Graph

692 Commits

Author SHA1 Message Date
TreeHugger Robot
5e01870015 Merge "Unbind from service on app killed and dedup association requests" 2017-03-27 18:43:37 +00:00
Eugene Susla
a38fbf63fd Unbind from service on app killed and dedup association requests
1. Listen to calling package binder death stopping the scanning on that.
2. Don't restart scanning when a request with the same values was made.

Bug: 30932767
Test: 1.:
  - Using a test app start scanning and kill the app.
  - In debug mode ensure that DeviceDiscoveryService#stopScan gets triggered
2.:
  - Start scanning and rotate the device while device chooser is visible
  - Ensure no visible loss of state is happening
Change-Id: If126a2c963da90172a956fbd88e6b3dcd7ac8b01
2017-03-24 14:03:17 -07:00
Suprabh Shukla
0693ff6d0e Removing unused method indexOfValueByValue
The method was confusing and not used by anyone. Same functionality can
be implemented trivially in the client code.

Test: N/A

Bug: 35765468
Change-Id: Ia019088cd023c62d83760d9ebe883f7559a43375
2017-03-24 01:22:05 +00:00
Pavel Grafov
4ce59d45a7 Request logs from logd with 3s overlap to avoid missing events.
Example: If we got a batch with timestamps [1, 4, 8] and an event
with timestamp 7 was delayed and was added to the buffer later,
if we request the next batch starting from timestamp 8 or 9 that
event will be lost.

The last 3 seconds of events are kept and checked against the next
batch.

Test: afw-test-tradefed-ci run afw-do-security-logging
Change-Id: I55727cfc6143c172edc7dabfd995776f9a0f7eab
Bug: 35373582
Bug: 35026180
Bug: 35648675
2017-03-21 14:52:32 +00:00
Andrii Kulian
c1b59ed73e Merge "Separate global and override config sent to client" 2017-03-17 15:39:37 +00:00
Andrii Kulian
446079600e Separate global and override config sent to client
There is some flakiness in View#onConfigurationChanged callback -
if ViewRootImpl receives config update earlier than ActivityThread,
it may not detect the configuration change and skip inner updates.
Also now ViewRootImpl assumes that it receives the global config as
a param, but instead it gets merged config from WM. This means that
ViewRootImpl#sConfigCallbacks was sending incorrect values to the
recipients.

This CL switches to sending global and override configuration to the
client separately. Also in case if there is a corresponding activity,
it first updates it and waits for update callback to ViewRootImpl.
This way global config and override config for activity will always
be set first and resources will be updated before inner state of
ViewRootImpl is updated.

Bug: 35870157
Bug: 34164473
Test: android.server.cts.ActivityManagerDisplayTests
Test: testOnMovedToDisplayCallback
Change-Id: Ic9e7541cf25ecfac6ec90e48f7efb0ece91f657e
2017-03-16 19:13:02 -07:00
Hyunyoung Song
547010ff86 Add LauncherIcons.AdaptiveIconDrawableWithShadow class to support shadow
b/36088922

Test: Settings app
This utility class can be used to bake shadow in drawable level in
system ui surfaces such as Settings, Overview and ShareSheet.

Change-Id: Iaec867d9ce5b949380c1e5004b68269d1bbeacd4
2017-03-16 13:51:28 -07:00
Narayan Kamath
a444636d39 Merge "MathUtils: Remove static Random field." 2017-03-09 11:13:39 +00:00
Tobias Thierer
137b460e5f Merge "Don't allow MapCollections to iterate past the end." 2017-03-08 12:18:28 +00:00
Narayan Kamath
b192344234 MathUtils: Remove static Random field.
This is unsafe because the random will be seeded in the zygote, which
means all processes on the system generate the same sequence of random
numbers. Fortunately, this code is only used in tests, so get rid of it.

Note that the Random that backs Math.random() is reseeded after every
fork to avoid a similar issue.

Bug: 35918685
Test: HwAccelerationTest
Change-Id: Ice79aa25bb9017f7a0b91659afe04112850cb74b
2017-03-08 10:07:03 +00:00
Eugene Susla
915b42bd95 Merge "Record app<->device association to xml file" 2017-03-08 02:16:13 +00:00
Andreas Gampe
19f1844e7e Merge "Framework: Ensure image heap string literals for Patterns" am: d0f092af84 am: 838851364b
am: 5fe3eb7696

Change-Id: Ia0bf25c740eedee436436e573241a59685db2fbd
2017-03-07 17:08:43 +00:00
Andreas Gampe
838851364b Merge "Framework: Ensure image heap string literals for Patterns"
am: d0f092af84

Change-Id: I69886924b3aca6c050239069c00e166142e2e522
2017-03-07 16:59:12 +00:00
Tobias Thierer
093572cd1b Don't allow MapCollections to iterate past the end.
Prior to this CL, MapCollections such as ArrayMap's entrySet,
keySet and values, exhibited unusual Iterator behavior:
 - instead of throwing NoSuchElementException once the end of
   the Collection was reached, Iterator.next() instead returned
   a null key / a null value / an entry with a null key and value.
 - however, remove() removed the last actual element of the
   Collection; successive calls of next(), remove() would
   result in successive elements being removed, in reverse
   iteration order.
 - Once the Collection had been cleared through calls to remove(),
   ArrayIndexOutOfBoundsException was thrown from iterator.next()
   (for keySet and values) or from iterator.remove (for entrySet).

This CL fixes those Collections' Iterators to let next() throw
NoSuchElementException when hasNext() would have returned false.
Since the new behavior was already guaranteed by the Iterator
documentation, any app compatibility effect from this CL is both
unlikely, and unlikely to be negative.

Bug: 19853326
Test: make cts && cts-tradefed run cts -m CtsUtilTestCases
Change-Id: Ie3f0594f434dd5625799791829bd94fbaef94906
2017-03-07 16:38:43 +00:00
Eugene Susla
47aafbe033 Record app<->device association to xml file
Bug: 30932767
Test: Ensure file not exists -> query associations -> ensure result is empty list
  Associate device -> cat xml file -> ensure record appears as extected
  Disassociate device -> cat xml file -> ensure record is no longer present
Change-Id: Ibe456a6d9292e05e2391f5138e43fdaa37f87e1b
2017-03-06 16:53:32 -08:00
Andreas Gampe
7f8466fab4 Framework: Ensure image heap string literals for Patterns
Do not use Pattern.toString to construct complex patterns. Instead,
make the string literals explicit so they can be compile-time
allocated, thus ending up as clean memory in the image heap.

Bug: 34956610
Test: m
Test: Device boots
Change-Id: I20d45c31243af00168553c218f75fb0795b55149
2017-03-03 09:38:58 -08:00
Romain Guy
95b52fd187 Make Half look like and behave like a boxed instance
Bug: 35765416
Test: HalfTest
Change-Id: I7ef52428f8b4e2c05b91d7eb37cc4cb5ecc5c6b9
2017-02-26 09:37:52 -08:00
Andy Hung
50fb1aebd7 Spline: Fix monotonicity constraint
Test: comparison of code to formula
Change-Id: Ie7c8b3a2a6bc64ea3c837a6674b55c07fe49e12b
2017-02-10 13:53:43 -08:00
TreeHugger Robot
b66cfe8a88 Merge "Added support to authentication." 2017-01-26 01:35:39 +00:00
Dianne Hackborn
c5d458930c Merge "Add some new experiment constants for activity and power manager." 2017-01-25 21:12:12 +00:00
Felipe Leme
436ab6a91d Added support to authentication.
AutoFillService can now require user authentication, both at
FillResponse and Dataset levels;
- FillResponse authentication is typically used when the user data
  need to be unlocked before the first use.
- Dataset authentication is typically used to unlock sensitive data
  such as credit card info.

The authentication can be handled by the service itself (for example,
when it uses the credit card CVV to unlock it) or by the Android
system (when the service asks for fingerprint authentication).

Bug: 31001899

Test: manual verification
Test: CtsAutoFillServiceTestCases passes

Change-Id: If62f42f697ab5ef0d14d991ff1077d1c38808e61
2017-01-25 13:03:32 -08:00
Mark Rathjen
8bd8564a18 Merge "Resolve Android security comments for Android ID migration." 2017-01-25 20:20:29 +00:00
Dianne Hackborn
0ef403e53e Add some new experiment constants for activity and power manager.
Activity manager now has constants, starting with two: bg check
and process limit.

Power manager now has constants, starting with one: controlling
disabling of wake locks from cached processes.

Test: manual

Change-Id: I05db42e2104e9d31584f85251412df2d5efb34b6
2017-01-24 18:23:45 -08:00
Mark Rathjen
7599f1366e Resolve Android security comments for Android ID migration.
- Use 32 byte key instead of 16 byte.
- Use HMAC-SHA256 instead of SHA256 for ssaid generation.
- Update HMAC with all package signatures.
- Use delimiter in between digest arguments.

This change will cause the ssaid of non-legacy installed apps (apps installed
post Android ID migration OTA) to change after an uninstall and reinstall sequence.

Bug: 34395671
Test: Unit tests, CTS tests, Manual tests
Change-Id: I19dec57947368ee5000c2c630b1e4030d46a4ab3
2017-01-23 19:06:41 -08:00
TreeHugger Robot
ec30d6e12f Merge "add a signaled reader to the eventlog" 2017-01-23 18:18:30 +00:00
Chris Wren
d09bf8271e add a signaled reader to the eventlog
Test: manual using a logspammer app
Change-Id: I89e3dda82d4d1d3fc6d343b634642687e550f70a
2017-01-23 11:40:52 -05:00
Jeff Sharkey
f5d2c7278e Merge "Add Binder support for Parcelable exceptions." am: a2ef6b5741 am: c3fbf32011 am: 4a0a4664b9
am: 7bb9ccc1e5

Change-Id: I9346a576d57c9f7093b875c4a43134f2ef095018
2017-01-20 23:12:19 +00:00
Jeff Sharkey
4a0a4664b9 Merge "Add Binder support for Parcelable exceptions." am: a2ef6b5741
am: c3fbf32011

Change-Id: Ibd977a017ce48f0791520af3500969aec0c132e5
2017-01-20 22:56:45 +00:00
Mark Rathjen
c45df0d7c1 Merge "Roll forward SSAID Migration to be Per App/User Unique Values." 2017-01-19 04:21:47 +00:00
Mark Rathjen
d891f01d96 Roll forward SSAID Migration to be Per App/User Unique Values.
SSAID is currently shared across all applications for each
user on the device, giving developers the ability to track
users across multiple applications. Using SSAID for tracking
is an abuse of the original intention of the SSAID and has
inherent privacy concerns.

This change will make the SSAID unique per application, per
user on a device. To not affect applications installed prior
to this change they will retain the legacy SSAID value until
uninstalled and reinstalled again.

Across subsequent installations the application will receive
the same SSAID as long as the package name and signature remain
consistent.

Tested manually the following cases:
  - App retains the legacy sssaid after OTA.
  - App gets a new ssaid upon post-OTA installation.
  - App retrieves same ssaid across post-OTA unistall/reinstalls.
  - Different Apps receive different ssaids.
  - Factory reset removes ssaid data and generates a different
    ssaid after App install.
  - System retains legacy ssaid.

Bug: 34395671
Test: CTS tests passed, Manual testing passed

This reverts commit be43257005.

Change-Id: Ibf20e7949304c30d65bb8aa24cdbbe6e104b1002
2017-01-19 04:10:37 +00:00
Mark Rathjen
5256e0556b Merge "Revert "SSAID Migration to be Per App/User Unique Values."" 2017-01-19 00:25:50 +00:00
Mark Rathjen
be43257005 Revert "SSAID Migration to be Per App/User Unique Values."
This reverts commit 5514fb7aba.

Change-Id: I0d6b9b9ef3ecda3b7ec1b7160c492ec16c65b125
2017-01-18 23:08:48 +00:00
Mark Rathjen
8bd15d1df2 Merge "SSAID Migration to be Per App/User Unique Values." 2017-01-17 23:57:17 +00:00
Jeff Sharkey
e628b7d446 Add Binder support for Parcelable exceptions.
If an Exception thrown by a Binder call implements the Parcelable
interface, then parcel it and rethrow back at the caller.  There is
strict requirement that these Parcelable exceptions must be defined
by the system (as determined by checking the ClassLoader).  We prefix
the Parcelable contents with a length so that native code can skip
over the blobs.

Define a new ParcelableException class that can be used to transport
exceptions that cannot be modified to add Parcelable behavior, and
switch ExceptionUtils to use this new class for sending IOExceptions.

Test: builds, boots, wrapped exceptions work
Bug: 33749182
Change-Id: I1352ea1566ddf01120d9d0e819ba6f70fc407e11
2017-01-17 14:22:07 -07:00
Mark Rathjen
5514fb7aba SSAID Migration to be Per App/User Unique Values.
SSAID is currently shared across all applications for each
user on the device, giving developers the ability to track
users across multiple applications. Using SSAID for tracking
is an abuse of the original intention of the SSAID and has
inherent privacy concerns.

This change will make the SSAID unique per application, per
user on a device. To not affect applications installed prior
to this change they will retain the legacy SSAID value until
uninstalled and reinstalled again.

Across subsequent installations the application will receive
the same SSAID as long as the package name and signature remain
consistent.

Tested manually the following cases:
  - App retains the legacy sssaid after OTA.
  - App gets a new ssaid upon post-OTA installation.
  - App retrieves same ssaid across post-OTA unistall/reinstalls.
  - Different Apps receive different ssaids.
  - Factory reset removes ssaid data and generates a different
    ssaid after App install.
  - System retains legacy ssaid.

Bug: 30979321
Test: CTS tests passed, Manual testing passed
Change-Id: I4acc190c14ec249e6365e05e7943148ed6f17f71
2017-01-17 11:22:07 -08:00
Makoto Onuki
3453194360 Deprecate all inconvenient methods
Test: builds fine
Change-Id: I52a26d160cff44b2fa0f3a807d23a6ed586d16ce
2017-01-17 11:20:41 -08:00
Mark Salyzyn
db15537e6e resolve merge conflicts of 082a1721b5 to master
Test: compile
Bug: 26552300
Bug: 31289077
Change-Id: I17f178f425975c1c0dbd48091d25b101956d505e
2017-01-11 08:30:17 -08:00
Mark Salyzyn
ef8ccc8510 Merge "Replace cutils/log.h and log/logger.h with log/log.h" am: e7fcbcb991
am: 6143cbf1e5

Change-Id: Id192d8dd973fe9e70acab72bae9856bc8a62ac75
2017-01-11 15:40:24 +00:00
Mark Salyzyn
52eb4e01a4 Replace cutils/log.h and log/logger.h with log/log.h
Test: compile
Bug: 26552300
Bug: 31289077
Change-Id: I578b15b48f0fc2807a92abbc69a377c3d2191496
2017-01-09 14:31:34 -08:00
Alex Klyubin
aa34861b34 Merge "Permit 65535 byte ZIP comments and empty Central Directory" am: f420b91e26 am: be81b50b6e am: e1bc33228e
am: 9c280d1566

Change-Id: I45452e71df0779b69b77e2dd1691a6fa27868e74
2016-12-20 21:17:17 +00:00
Alex Klyubin
e1bc33228e Merge "Permit 65535 byte ZIP comments and empty Central Directory" am: f420b91e26
am: be81b50b6e

Change-Id: I1275903e7fda6bdd9c1012bc7cfb6c42f6b43304
2016-12-20 20:45:59 +00:00
Alex Klyubin
9694657967 Permit 65535 byte ZIP comments and empty Central Directory
This fixes two cosmetic issues in APK Signature Scheme v2 signature
verifier in Android Package Manager:
* Accept APKs with ZIP End of Central Directory comment of length
  65535. Previously, only comments of length 65534 were accepted due
  to a off by one bug.
* Accept APKs with empty ZIP Central Directory.

These issues should not affect actual APKs because they cannot have an
empty ZIP Central Directory (they must contain at least the
AndroidManifest.xml entry) and shouldn't contain any comments in ZIP
End of Central Directory.

Test: cts-tradefed run singleCommand cts --skip-device-info --skip-preconditions --skip-connectivity-check --abi arm64-v8a --module CtsAppSecurityHostTestCases -t android.appsecurity.cts.PkgInstallSignatureVerificationTest
Change-Id: I461c43472fa97c04e7579d129a6053e44233adb7
2016-12-19 12:53:32 -08:00
Chris Wren
d9f3d9edc0 Don't WTF when reading empty data from the eventlog
Bug: 33446064
Fixes: 33446064
Test: run cts -m CtsUtilTestCases -t android.util.cts.EventLogTest
Change-Id: I4951202cd7d6ca441700b7122cfa3aae2167c7b0
2016-12-19 12:51:34 -05:00
Svetoslav Ganov
69b9db8c5d Fix vulnerability in MemoryIntArray am: 1181f448c1 am: d08cf2b071
am: 385277305e

Change-Id: I3d7222359d095d5e53f3e6fbfeda10352fa43f76
2016-12-09 01:52:56 +00:00
Svetoslav Ganov
d08cf2b071 Fix vulnerability in MemoryIntArray
am: 1181f448c1

Change-Id: I4217066be49bb9525e945f110c22eb864ec6c212
2016-12-09 01:43:52 +00:00
Svetoslav Ganov
1181f448c1 Fix vulnerability in MemoryIntArray
MemoryIntArray was using the size of the undelying
ashmem region to mmap the data but the ashmem size
can be changed until the former is memory mapped.
Since we use the ashmem region size for boundary
checking and memory unmapping if it does not match
the size used while mapping an attacker can force
the system to unmap memory or to access undefined
memory and crash.

Also we were passing the memory address where the
ashmem region is mapped in the owner process to
support cases where the client can pass back the
MemoryIntArray instance. This allows an attacker
to put invalid address and cause arbitrary memory
to be freed.

Now we no longer support passing back the instance
to the owner process (the passed back instance is
read only), so no need to pass the memory adress
of the owner's mapping, thus not allowing freeing
arbitrary memory.

Further, we now check the memory mapped size against
the size of the underlying ashmem region after we do
the memory mapping (to fix the ahsmem size) and if
an attacker changed the size under us we throw.

Tests: Updated the tests and they pass.

bug:33039926
bug:33042690

Change-Id: Ibf56827209a9b791aa83ae679219baf829ffc2ac
2016-12-09 00:08:33 +00:00
Bill Napier
1c47e9e8f0 Revert "Fix vulnerability in MemoryIntArray am: a97171ec49" am: 43966dafb3 am: 498547ec6c
am: ef435f6780

Change-Id: I6b879ca7e2c7c48885dcdbf791afcd914869df24
2016-12-08 22:40:09 +00:00
Bill Napier
498547ec6c Revert "Fix vulnerability in MemoryIntArray am: a97171ec49"
am: 43966dafb3

Change-Id: I01bc83edd411dc39cb696e64ea35b5d4a8497fbf
2016-12-08 22:30:02 +00:00
Bill Napier
43966dafb3 Revert "Fix vulnerability in MemoryIntArray am: a97171ec49"
This reverts commit fb12dd509f.

Change-Id: I9e1b22b8df0e754095541a758096cba279a81ab1
2016-12-08 22:22:38 +00:00
Svetoslav Ganov
e812cd0379 Fix vulnerability in MemoryIntArray am: a97171ec49 am: fb12dd509f am: a5ee109029
am: 5250d90637

Change-Id: I20c20bee05321d722e83ee47ad6d13e308178e02
2016-12-08 21:51:05 +00:00