76 Commits

Author SHA1 Message Date
Calvin On
dce6e5dfd4 Fix StateMachine init/quit race.
The quitNow method places the SM_QUIT_CMD at the front
of the queue. This can cause StateMachine to throw exception
if it has not yet processed the SM_INIT_CMD from start().

Bug: 67370902
Test: make checkbuild
Test: StateMachineTest unittest
Test: build/install on device, toggle bluetooth and wifi
Change-Id: I7cec7bb91e0447e3c565d33cb7c34ccf59566639
2017-10-26 14:07:31 -07:00
Lennart Wieboldt
602716ffa0 Merge "tests: remove LOCAL_CLANG" am: e77be9c610 am: 24b36003d4 am: 7599be2e67
am: 61079e7685

Change-Id: I24b5e3bec0f8c2e46e7ad1deb6f32595e5aa3566
2017-09-11 16:01:51 +00:00
Lennart Wieboldt
61079e7685 Merge "tests: remove LOCAL_CLANG" am: e77be9c610 am: 24b36003d4
am: 7599be2e67

Change-Id: I5f2388ec80aa9aad27ef264c9012e27faaece08e
2017-09-10 18:02:40 +00:00
Lennart Wieboldt
24b36003d4 Merge "tests: remove LOCAL_CLANG"
am: e77be9c610

Change-Id: Ie2b3d0c5a6c0f30e8fd768720fb6a9e4ca45e207
2017-09-10 17:42:08 +00:00
Lennart Wieboldt
9eb1bc05ac tests: remove LOCAL_CLANG
clang is the default compiler since Android nougat

Test: mma & verified it´s still build with clang
Change-Id: I9bfe0668eddf51dd56174fefc650a11002d38196
Signed-off-by: Lennart Wieboldt <lennart.1997@gmx.de>
2017-09-10 11:54:23 +02:00
Makoto Onuki
2eee04d2c2 Merge "DropBoxManagerService: Don't store redundant information" into oc-mr1-dev am: 75590ffa84
am: bb4f580494

Change-Id: I204695ecd43fe86eb6837098556aa1e7c0db354f
2017-08-10 01:33:09 +00:00
Makoto Onuki
ff94e0351a DropBoxManagerService: Don't store redundant information
Filenames can be calculated from other fields, so there's no need to
store them.

This will reduce the average EntryFile size from 160b to 28b, so in theory
it could save 132 KB for 1000 entries.

- Also switched from HashMap to ArrayMap, which should help a bit too.

- Also fixed unit tests and added more.

Bug: 20890386
Test: bit FrameworksServicesTests:com.android.server.DropBoxTest
Test: Boot, check the dropbox directory, run dumpsys dropbox, reboot and repeat.

Change-Id: If567750f478318acd621864d1d4ef2ed41f214bd
2017-08-09 12:07:40 -07:00
Julian Mancini
a83cc4582f Add support for simpler Lat/Long values
In this CL, we add two public static final Strings to MetadataReader. I
use these to put in an "extras" bundle into our highest level bundle.
Within that extras bundle is the Latitude and Longitude values, if
available.

Bug: 63906073
Test: In Place
Change-Id: I1feccb4444d6525f9bc8bddfe8cc73b098e0b90e
2017-07-27 10:21:23 -07:00
TreeHugger Robot
dc751a3867 Merge "Add provider support for metadata extraction" 2017-07-20 00:29:59 +00:00
Julian Mancini
b65051579f Add provider support for metadata extraction
In this CL, I'm adding ability to retrieve image metadata. I've added
the class MetadataRetriever that can currently retrieve Exif data from
an image. This class is used withing FileSystemProvider in order to
return a given image's exif data.

Test: Hidden API
Bug: 62621970
Change-Id: Ibb329492df4db1a65f65722c6a52582c43de8fe5
2017-07-19 15:46:23 -07:00
Christine Franks
645011f5fa Merge "Disable lock screen by default for demo users" into oc-dr1-dev am: 205585e574
am: 6b43433062

Change-Id: I9e00e9e2771ba8c2a271c12e8213debbca96b9aa
2017-07-18 23:40:43 +00:00
Christine Franks
6b43433062 Merge "Disable lock screen by default for demo users" into oc-dr1-dev
am: 205585e574

Change-Id: I05eeee1b997916e0f8fa86614aaac3d0e395a35c
2017-07-18 23:30:29 +00:00
Jeff Sharkey
9f09e6a73d Unify permissions under UPDATE_DEVICE_STATS.
The UPDATE_DEVICE_STATS permission has become the de-facto mechanism
that platform components use to shift blame for resource usage, so
it's confusing to also have a separate MODIFY_NETWORK_ACCOUNTING
permission.  So this change replaces MODIFY_NETWORK_ACCOUNTING with
UPDATE_DEVICE_STATS.

Bug: 62483389
Test: builds, boots
Exempt-From-Owner-Approval: Bug 63673347
Change-Id: I872759f02327b6d531ec2338bd876890aded60ad
2017-07-17 16:10:55 -06:00
Christine Franks
5856be889f Disable lock screen by default for demo users
Bug: 62712426
Test: frameworks/base/core/tests/utiltests/runtests.sh \
-e class com.android.internal.util.LockPatternUtilsTest
Change-Id: Ic2e00a2a73f160c27e4059f32e5a1d18ebc298a5
2017-07-17 09:37:20 -07:00
Jeff Sharkey
5ab0243330 Only require that system UIDs tag their sockets.
Apps with a normal UID are typically isolated enough to not require
socket tagging; we're mostly interested in tracking down internal
UIDs that have lots of code sharing the same UID.

Also fix up everyone doing manual string checks of Build.TYPE, since
we now have first-class fields for those.

Bug: 38126076
Test: builds, boots
Change-Id: I3a40348196bd8459289f2b9355d9783a07f1e7dd
2017-06-27 11:11:06 -06:00
Paul Duffin
4f9d89a380 Merge "Clean up Predicate related code in android.test" into oc-dev-plus-aosp
am: 50826c5f2e

Change-Id: Ica9b9b478b670ec5467732a09cf123dd63780c97
2017-06-26 13:21:28 +00:00
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
413d371991 Merge "Moved c.a.i.u.Predicate[s] into legacy-test" into oc-dev-plus-aosp
am: e5573b54cb

Change-Id: I7c86684028d38f33e062a47ca92e7db2c6a6f3cf
2017-05-15 10:52:54 +00:00
Paul Duffin
f71d5b5b18 Moved c.a.i.u.Predicate[s] into legacy-test
These classes are only used by android.test classes that are
being removed. As their name suggests they should not be in the
Android API at all so it makes sense to remove them. Especially
as there is java.lang.function.Predicate available now.

It appears as though Predicate was only added in to the API
because it was used by a method in the API as the directory in
which it and Predicates live was not on the list of classes to
explicitly index. Moving it into legacy-test meant that they are
now being indexed explicitly which means that Predicates needs
to be hidden.

Keeps running the tests as part of the existing target.

At runtime apps targeted at the API version before these are
removed will have the legacy-test library automatically added
to their classpath so they should see no effect. Apps that
target a later API will have to include those classes from the
android.legacy.test.jar which will contain all the android.test
classes that depend on it as well.

Bug: 30188076
Test: make checkbuild
Change-Id: I6f6f5f16fe93bd80227a450c6254166632fc6813
2017-05-12 15:35:11 +01:00
Hugo Benichi
ada3f6b8f1 Merge "Improve utility of IntArray and LongArray" am: 35786735df am: e718797a37 am: 4ca1cb7c10
am: 6f75cb52e8

Change-Id: I82032bf85861cfc8aebffd9e49796fb61b5a19ed
2017-04-10 01:46:36 +00:00
Hugo Benichi
6f75cb52e8 Merge "Improve utility of IntArray and LongArray" am: 35786735df am: e718797a37
am: 4ca1cb7c10

Change-Id: If206b2b4d837dbbb8d0fd0c9a75fad240bb5379e
2017-04-10 01:36:20 +00:00
Hugo Benichi
35786735df Merge "Improve utility of IntArray and LongArray" 2017-04-10 01:09:04 +00:00
Hugo Benichi
112962a6b0 Improve utility of IntArray and LongArray
This patch adds several utility methods to IntArray and LongArray to
make them more useful in the context of a Parcelable class.

More specifically, it is now possible to parcel and unparcel a
{Int, Long}Array with the following one liners:
  - mIntArray = IntArray.wrap(parcel.createIntArray());
  - parcel.writeIntArray(mIntArray.toArray());

This patch also
  - adds unit tests for IntArray and LongArray.
  - adds a method for setting a field at a given index.
  - adds a method for changing the effective array length.
  - adds missing bound checks for negative index values.

Test: added test coverage
Bug: 34901696
Change-Id: Ia0febf4dae048b0a45c75310b5d90b56499320da
2017-04-07 13:18:16 +09:00
Dan Shi
1fee398b88 Change test type from InstrumentationTest to AndroidJUnitTest
Details about test configs changes are tracked in doc
https://docs.google.com/document/d/1EWUjJ7fjy8ge_Nk0YQbFdRp8DSHo3z6GU0R8jLgrAcw/edit#

Bug: 35882476
Test: local test

Change-Id: Ic3c4c7a9d29ef9d32a407f31cfc93c5e43650297
2017-03-31 16:02:33 -07:00
Mukesh Agrawal
d194a1877a Merge changes I5c16c650,I3151fb6b am: 55efea25f3 am: ad2684ca3d
am: 6b29b1c256

Change-Id: I08019c46a433b5ea64a561d374df445d50400d45
2017-03-29 18:41:16 +00:00
Mukesh Agrawal
ad2684ca3d Merge changes I5c16c650,I3151fb6b
am: 55efea25f3

Change-Id: Ifaaae29780d905ffe9f82645d6d17dad478ba6a9
2017-03-29 18:30:00 +00:00
mukesh agrawal
47e1c7a005 StateMachine: make toString() terser
The current implementation of the toString()
method calls dump(). This causes two problems:

1. toString() may return a large string. This
   is at odds with the advice in the documentation
   for Object.toString(), which says that the
   returned String should be concise, and easy
   to read.
2. The dump() method is overriden by many of the
   StateMachine subclasses. Some of those subclasses
   have dump() implementations that are expensive,
   and/or have dependencies on other objects.

To resolve these problems, we simpify
StateMachine.toString().

Along the way: remove a stale comment about
implementing dump() using toString().

Note: only ran the StateMachine tests, since some
other tests are already failing.

Bug: 36661851
Test: tests/utiltests/runtests.sh \
      -e class com.android.internal.util.StateMachineTest
Change-Id: I5c16c650f01178c4d018b6a65e4aa95fb905aff6
2017-03-28 18:21:36 -07:00
mukesh agrawal
28882ed5d5 utiltests: add script to run tests
Make it easier to run the tests, so that more people
will run them.

Bug: 36698401
Test: tests/utiltests/runtests.sh \
      -e class com.android.internal.util.StateMachineTest

Change-Id: I3151fb6b2f609f45c7d8154b51f13cce58ccdc13
2017-03-28 18:21:35 -07:00
Dan Shi
7f2afd2dff Add test configs to apct tests under frameworks/base
TouchLatency is needed by test TouchLatencyJankTestWear
UiBench is needed by test UiBenchJankTests

Details about test configs changes are tracked in doc
https://docs.google.com/document/d/1EWUjJ7fjy8ge_Nk0YQbFdRp8DSHo3z6GU0R8jLgrAcw/edit#

Bug: 35882476
Test: local test
make -j32 TouchLatency TouchLatencyJankTestWear  && \
tradefed.sh run template/local --template:map test=TouchLatencyJankTestWear \
      --test-tag testname --log-level-display VERBOSE
make -j32 UiBenchJankTests UiBench  && \
tradefed.sh run template/local --template:map test=UiBenchJankTests \
      --test-tag testname --log-level-display VERBOSE

Change-Id: I63f23e3a21ad1343607953958fb7bb0a5fb8c343
2017-03-21 00:05:14 -07: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
The Android Automerger
53095bb5bd Merge commit 'a19056c35d16ddb5a6c1d3343729701b8939f1e1' into nyc-mr1-dev-plus-aosp
* commit 'a19056c35d16ddb5a6c1d3343729701b8939f1e1': (35 commits)
  NetworkMonitor: send one DNS probe per web probe
  NetworkMonitor metrics: add first validation information
  APF: also drop any ICMPv6 RSs
  ConnectivityServiceTest: fix testAvoidBadWifiSettings
  Fix ConnectivityServiceTest testRequestBenchmark
  Switch over to new "time.android.com" NTP pool.
  Define API for metering network stats buckets.
  Refactored NetworkStatsServiceTest to use Mockito instead of EasyMock.
  Use @Ignore to explicitly disable a @Test method.
  Fixed NetworkStatsServiceTest and converted it to JUnit4.
  VPN network stat accounting changes.
  ConnectivityThread: use lazy holder idiom
  ConnectivityManager: use ConnectivityThread looper
  ConnectivityManager: a simpler CallbackHandler
  Indicate the NsdServiceInfo attributes are only filled in for a resolved service.
  Add a null check for the OnStartTetheringCallback.
  TokenBucket for rate-limiting and throttling
  IpConnectivityMetrics reads buffer size in settings
  CaptivePortalLogin: set mixed content policy to compatibility.
  Add IP conn metrics to dumpsys and bug reports
  ...
2017-01-27 06:39:05 +00:00
Lorenzo Colitti
c869089383 Move FakeSettingsProvider to a common location.
(cherry picked from commit 7df1a82802cdf842d07a86a80383c7d5ea7ae53a)

Test: runtest frameworks-util -c com.android.internal.util.test.FakeSettingsProviderTest
Test: runtest frameworks-services -c com.android.server.ConnectivityServiceTest
Test: runtest frameworks-services -c com.android.server.retaildemo.PreloadAppsInstallerTest
Test: runtest frameworks-services -c com.android.server.retaildemo.RetailDemoModeServiceTest
Bug: 31479480
Change-Id: I8d4d4de2937012dd33924f53e68f96241a9b2b4f
2017-01-26 18:50:48 +09: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
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
43966dafb3 Revert "Fix vulnerability in MemoryIntArray am: a97171ec49"
This reverts commit fb12dd509f8e106d034f67c2e404845128128994.

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
Svetoslav Ganov
fb12dd509f Fix vulnerability in MemoryIntArray
am: a97171ec49

Change-Id: Ifa2221a9b8ca705ef0239d61772938ac11761ce2
2016-12-08 21:37:33 +00:00
Svetoslav Ganov
a97171ec49 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: I1004579181ff7a223ef659e85c46100c47ab2409
2016-12-08 11:51:26 -08:00
Lorenzo Colitti
b8df76e413 DO NOT MERGE: Move FakeSettingsProvider to a common location.
(cherry picked from commit 7df1a82802cdf842d07a86a80383c7d5ea7ae53a)

Test: runtest frameworks-util -c com.android.internal.util.test.FakeSettingsProviderTest
Test: runtest frameworks-services -c com.android.server.ConnectivityServiceTest
Test: runtest frameworks-services -c com.android.server.retaildemo.PreloadAppsInstallerTest
Test: runtest frameworks-services -c com.android.server.retaildemo.RetailDemoModeServiceTest
Bug: 31479480
Change-Id: I8d4d4de2937012dd33924f53e68f96241a9b2b4f
2016-12-08 17:13:34 +09:00
Svetoslav Ganov
fe9fc973bd Revert "Fix vulnerability in MemoryIntArray" am: 1f06508bc6 am: 64b5725900 am: 60357eb6bd
am: 590b77da13

Change-Id: Ida195bcbaf3c3fad184865938dfff9f475879c16
2016-12-08 02:40:55 +00:00
Svetoslav Ganov
64b5725900 Revert "Fix vulnerability in MemoryIntArray"
am: 1f06508bc6

Change-Id: Id387817495b1857f304203c8487da3db49bdd0e4
2016-12-08 02:29:00 +00:00
Svetoslav Ganov
1f06508bc6 Revert "Fix vulnerability in MemoryIntArray"
This reverts commit 4694cad51122c20880d00389ef95833d7a14b358.

Change-Id: I235ea3c4bd86d90bf97bc1a2d023f4780251e570
2016-12-08 02:17:40 +00:00
Svetoslav Ganov
638134c1d8 Fix vulnerability in MemoryIntArray am: 4694cad511 am: ec40a70ffb am: 138a541eaa
am: 557858b9c0

Change-Id: I872df5965848ccd935c43473168e1e5aea40aad1
2016-12-08 02:08:26 +00:00
Aart Bik
7eb917d5eb Revert "Fix vulnerability in MemoryIntArray" am: 29139a8ae5 am: 86699f980f am: 65cf055ad9
am: 278cad4793

Change-Id: Ib58a5a1e7506327b690df9c1a98c2fa8b895d216
2016-12-08 02:01:06 +00:00