Commit Graph

841 Commits

Author SHA1 Message Date
Yangster-mac
94e197cceb 1/ Change all "name" to id in statsD.
2/ Handle Subscription for alert.
3/ Support no_report_metric

Bug: 69522276
Test: all statsd unit tests passed.
Change-Id: I851b235f2d149b8602b0cad632d5bf541962f40a
2018-01-03 15:34:00 -08:00
TreeHugger Robot
eee29f6457 Merge "Remove settings suggestion v2 feature flag." 2018-01-03 19:31:34 +00:00
Dan Cashman
cd4cb81fba APK Signature Scheme v3: require Proof-of-rotation and signing certs to match.
Though not yet used, the Proof-of-rotation certificates are intended to be
used by the platform as equivalent to signing certificates, i.e. the presence
of a certificate in a Proof-of-rotation record should grant equivalent
capabilities as if the APK were signed by that certificate.  For this to work,
each certificate needs to be signed by the previous one indicating a transfer
of trust all the way to the signing certificate of the APK.  There is no case
in which the last certificate in the Proof-of-rotation record should not be
the one used to sign the APK, so enforce this during verification.

Bug: 64686581
Change-Id: Ia1b25a917a878fb378c8557b25a2bbfdd9da7d3d
Test: Builds, boots, passes
      android.appsecurity.cts.PkgInstallSignatureVerificationTest
2018-01-02 15:51:07 -08:00
Fan Zhang
c3aa560443 Remove settings suggestion v2 feature flag.
Change-Id: I0ef95324a643079484147caa5ecfff42d811aaff
Fixes: 68719093
Test: rebuild
2018-01-02 12:38:14 -08:00
Daniel Cashman
67096e08a7 Add APK Signature Scheme v3.
Add ApkSignatureSchemeV3Verifier to enable APKs to be signed with
the new signature scheme.  Update the ApkSignatureVerifier to process
the results, but only pass on what's needed for the existing interface.

In the process, move the ApkSignatureSchemeV2 code into a common
area for use by any scheme that makes use of the APK Signature Block.

The primary purpose of APK Signature Scheme v3 is to enable applications
to rotate their signing key.  This is accomplished by augmenting APK
Signature Scheme v2 to also include a new Proof-of-rotation struct, which
is fundamentally a singly linked list where each of the APK's signing
certificates is included in order, along with a signature over the next
certificate.  Thus, each certificate contains proof that the private key
corresponding to the previous one blessed it.  This provides evidence to
the platform that the new signing certificate should be as trusted as
the previously trusted one.  This structure also includes some flags for
each certificate to indicate to the platform how the APK itself would
like to interract/trust the old certificates.

Bug: 64686581
Test: Builds, boots, passes
      android.appsecurity.cts.PkgInstallSignatureVerificationTest
Change-Id: I0f98ff13950af78f5d9b269f80d13af8891f7a2d
2018-01-02 07:28:49 -08:00
Jake Wharton
c26b093ce5 Merge "Expose removeAt(int) for parity with other sparse collections." 2017-12-24 05:32:13 +00:00
TreeHugger Robot
d1dc3524f6 Merge "Add feature flag for security settings v2." 2017-12-22 21:49:35 +00:00
Fan Zhang
d2b4419ebd Add feature flag for security settings v2.
Bug:  32953042
Test: rebuild
Change-Id: Iabfd4705f01cf8a1ca1a3374de3d5a31850ae681
2017-12-22 10:03:00 -08:00
Jake Wharton
d77bce88d4 Expose removeAt(int) for parity with other sparse collections.
Bug: 70934959
Test: none
Change-Id: Ic26a9fba610d6361247e0485803b52569fbf4a38
2017-12-21 18:25:25 -05:00
Fan Zhang
3b8a596f05 Merge "Enable settings search v2 experiement" 2017-12-21 17:29:32 +00:00
Dan Cashman
636ea5e888 Add plsCertsNoVerifyOnlyCerts to ApkSignatureVerifier.
There are currently two conceptual operations performed by PackageParser
while parsing APKs: collecting certificates and verifying them.
ApkSignatureVerifier relies on the systemDir flag to indicate whether or
not it should do a full verification of a package, but this only applies
when verifying V1 (jar signed) APKs.  This distinction should be explicitly
made.  This creates cleaner code and also saves time when verifying V2
signed systemDir APKs.

Bug: 64686581
Test: Builds, boots, passes
android.appsecurity.cts.PkgInstallSignatureVerificationTest.

Change-Id: Ie8a0f8cad3dd8f70da791f2f1f4516e84e2ae4d0
2017-12-20 16:02:51 -08:00
Fan Zhang
b0a15b6d18 Enable settings search v2 experiement
Test: FeatureFlagUtilsTest
Change-Id: I6008cdbf4e0ba2e0351e5859dd178fe7a5a83200
2017-12-20 11:07:49 -08:00
TreeHugger Robot
c9d65a29ed Merge "Returns signing version from ApkSignatureVerifier" 2017-12-18 20:58:13 +00:00
Patrick Baumann
9ff55740c2 Returns signing version from ApkSignatureVerifier
This is a first step at a larger goal of moving instant app
verifications from parsing logic into install logic.

Test: manual - install v1 and v2 instant app and static lib
Test: android.appsecurity.cts.PkgInstallSignatureVerificationTest passes.
Change-Id: Iab50b91a6fb8ef014b573bb9f733d30c1aa6022f
Bug: 68860689
2017-12-18 09:58:22 -08:00
TreeHugger Robot
6831a2646f Merge "Adds API for apps to push events to statsd." 2017-12-16 00:03:53 +00:00
jackqdyulei
65fe45522f Turn on connected device by default
Bug: 69926683
Test: Build
Change-Id: Ia3389f459e7c9c6de3f549c60470bf12660d7a87
2017-12-15 10:59:15 -08:00
David Chen
0a368b2c39 Adds API for apps to push events to statsd.
This API allows app to construct custom metrics based on labels
chosen by the app developers. Also added some buttons to manually
test this functionality in the dogfood app.

Test: Verified that Android can be built and tested with custom app.
Bug: 69522276
Change-Id: Ifb7abea4c1d62fb435a9cb6f32df12bc2234d82f
2017-12-14 16:19:29 -08:00
Dan Cashman
e92f8428dd Refactor PackageParser.collectCerts() to hide signature scheme.
PackageParser shoudln't really need to know the gory details of APK
verification, it should just get back the blobs it needs to do its
job.  Move the package verification into its own class which is
*almost* exclusively responsible for verifying app signatures. This
is in preparation for adding APK signature scheme v3, which will add
yet another way to do this.

Bug: 64686581
Test: Builds 'n' boots without issue.
Test: android.appsecurity.cts.PkgInstallSignatureVerificationTest passes.
Change-Id: Ieb76b2353bd44ffdb83e7b894e5ad720d1697dc7
2017-12-13 12:20:21 -08:00
jackqdyulei
ee0e2e9d23 Add default value for battery app list flag
Bug: 3331576
Test: Build
Change-Id: I3396802c03cf2120f5d1ff5ab9120b7d8949d943
2017-12-08 09:45:23 -08:00
TreeHugger Robot
32db7edec3 Merge "Make a static list of flags." 2017-12-08 05:50:59 +00:00
Fan Zhang
3080636f88 Make a static list of flags.
Bug: 36222960
Test: atest
Change-Id: I356a0c9826fd9f5a9e5520227be4e5cb4d3e04c1
2017-12-07 12:54:11 -08:00
Chris Wren
4170751a68 add integer array values to KeyValueListParser
Test: atest NotificationSnoozeTest KeyValueListParserTest AlwaysOnDisplayPolicyTest
Change-Id: Ia26cd38258c2cf83558a9a39a6b1c2ec6dedfcb1
2017-12-07 01:06:31 -05:00
TreeHugger Robot
1523386d85 Merge "PooledLambda" 2017-12-05 20:38:25 +00:00
Eugene Susla
2f5ee71ec8 PooledLambda
This introduces PooledLambda - a way of obtaining lambdas without the
allocations overhead.

See PooledLambda javadoc for a guide and PooledLambdaSample for code samples
of useful usages.

Test: ensure samples of PooledLambdaSample work as described.
Change-Id: I46f8ad27bc1de07e19f6e39f89d2cafe4238497a
2017-12-05 10:46:59 -08:00
David Chen
2e8f380737 Adds new API to retrieve statsd metadata.
This API can be used by clients to gather stats about statsd, eg.
memory usage, number of metrics/matchers, etc. This data can be used
to debug if devices are not providing expected metrics. The metadata
will be for all configurations, but will not contain the actual
collected metrics since those might have privacy implications.

Test: Tests that statsd and Android still build.
Bug: 69522276
Change-Id: I8e0fedc142f5deed7be6e6309f9444e67d8369ce
2017-12-04 10:23:28 -08:00
TreeHugger Robot
4573e9b880 Merge "Converts exceptions to log messages in StatsManager." 2017-11-18 04:36:47 +00:00
David Chen
c562bfb68f Converts exceptions to log messages in StatsManager.
We log if the statsd is not available instead of throwing an
exception. This helps prevent a crash when calling this API since
statsd is not a system service and can potentially be down.

Test: Not applicable.

Change-Id: I776efede4a01c751924fa9a8abd0eec0c4c1306b
2017-11-17 17:46:58 -08:00
TreeHugger Robot
52418b56f0 Merge "Implement Activity Manager Dumpsys --service option" 2017-11-17 23:24:04 +00:00
TreeHugger Robot
344072e2f6 Merge "Check Settings.Global before sysprop in FeatureFlagUtils." 2017-11-17 22:20:11 +00:00
Yi Jin
6b51414154 Implement Activity Manager Dumpsys --service option
Bug: 66729158
Test: out/host/linux-x86/bin/incident_report -w amservices
Change-Id: I72015b9744bc8028001306283f169fca4797c700
2017-11-17 11:58:06 -08:00
Fan Zhang
aa1387c6de Check Settings.Global before sysprop in FeatureFlagUtils.
Bug: 36222960
Test: atest
Change-Id: I731cb93596ca80e9b1a02478a8582d6488750f00
2017-11-17 11:23:00 -08:00
Tobias Thierer
46e3f0a285 Merge "Move Mutable{Int,Long} from libcore to framework." 2017-11-17 18:25:24 +00:00
Fyodor Kupolov
c1b14f8a61 Merge "Provide remote stack trace information" 2017-11-17 00:51:39 +00:00
TreeHugger Robot
a786f00f06 Merge "Refactor battery saver logic + add "per device" setting" 2017-11-15 21:32:50 +00:00
Makoto Onuki
66a7812bc9 Refactor battery saver logic + add "per device" setting
- Extract the battery saver mode transition logic to BatterySaverController.

This now also supports running different code when screen turns on and off.

- BatterySaverPolicy now takes a "per-device configuration" from config.xml,
which can be overwritten via a global setting. We'll use this to set up
max CPU frequencies.

- The actual part to write max CPU frequencies is not finished yet.

Test: atest BatterySaverPolicyTest
Bug: 68769804
Change-Id: Ife38c2cd94ac9902911b005dbbca8b0d0a62e6d7
2017-11-15 08:34:57 -08:00
TreeHugger Robot
ac23dfc91f Merge "Extend FeatureFlagUtils to take a context object." 2017-11-15 03:43:30 +00:00
Fan Zhang
93d87e6964 Extend FeatureFlagUtils to take a context object.
It's not used by anything yet, but will eventually be used to query
feature override from different data sources (such as Settings.Global)

Bug: 36222960
Test: atest
Change-Id: Ie32f7c59b4a27199da72d8c9fbfdd1aeee6c0b34
2017-11-14 17:05:14 -08:00
Fyodor Kupolov
a81b8c0932 Provide remote stack trace information
The stack is truncated up to 5 lines at parcel time. When unparceling,
a separate RemoteException will be created and set as a cause of the
exception being thrown.

Performance results(in nanoseconds):
timeWriteExceptionWithStackTraceParceling  4168
timeWriteException                         2201
timeReadException                         15878
timeReadExceptionWithStackTraceParceling  23805

Test: manual + ParcelPerfTest
Bug: 36561158
Change-Id: I18b64a6c39c24ab067115874ddb5bd71f556a601
2017-11-14 14:31:32 -08:00
David Chen
adaf8b344e Adds client API for interacting with statsd.
This API will primarily be used by GmsCore to send updated configs.
Also, sending a config will implicitly notify the StatsD that this
client wants to know when it should request data for this config.

We send a broadcast so that all interested subscribers can know if
data needs to be pulled.

Test: Manually tested that sending broadcast works via new adb
command added in StatsService.

Change-Id: I23cdd1df706036e14b32c3d01af30c3d4af819fa
2017-11-13 19:37:12 -08:00
Tobias Thierer
232f1eb387 Move Mutable{Int,Long} from libcore to framework.
No libcore dependencies on these classes remain, so they
can now move to framework which already has all of the
other classes from android.util.

After this CL topic, libcore and framework no longer have
any classes from the same package.

Bug: 67901714
Test: make droid
Test: Treehugger

Change-Id: I65871516b762d8a53ebe01697e4d92f94903bfd3
2017-11-13 16:56:12 +00:00
Jeff Sharkey
29862ccde0 Merge "Extend JobInfo to support NetworkRequest." 2017-11-10 00:11:58 +00:00
Jeff Sharkey
d0fff2eac4 Extend JobInfo to support NetworkRequest.
The current JobInfo.NETWORK_TYPE values offer basic network selection
ability, but more precise requirements continue to come up.  Instead
of creating more NETWORK_TYPE constants, add support for the existing
NetworkRequest object, which is the idiomatic way for an app to
express the type of network they'd like to use.

Move the implementation details of NETWORK_TYPE constants to use this
new NetworkRequest functionality.  Deprecate NETWORK_TYPE_METERED,
since the lack of the NOT_METERED capability doesn't imply that the
connection is metered.  (Apps using this API to get to a cellular
network should use TRANSPORT_CELLULAR instead.)

Add new SystemClock APIs that return java.time.Clock instances for
various Android-specific clocks.  This gives us a clean interface
(with negligible overhead) for swapping in artificial clocks for
testing purposes.

Improve JobStoreTest to validate new NetworkRequest features, and
add one last sanity check to assertTasksEqual() to compare raw
bits-on-wire, to catch people who forget to check new fields.  Watch
for IoThread to go idle to run tests faster.

Test: bit FrameworksServicesTests:com.android.server.job.
Bug: 67040695
Change-Id: I189e7602132a0ec26d2f0cc6dadc188664961a47
2017-11-09 13:23:31 -07:00
Victor Hsieh
def64f26c3 Optimizations to reduce verity verification time
Test: with CPU locked to low freq, verification time of a 400 MB apk is
      reduced from about 2528 ms to 1942 ms, vs 915 ms of the old
      algorithm.  Writing directly into ByteBuffer's backing array saves
      around 100 ms but it does not work for DirectByteBuffer, thus I
      didn't implement this optimization.
Bug: 30972906
Change-Id: I00cf782e18a8351569eaf4593188c1ce6796a634
2017-11-08 15:19:41 -08:00
Victor Hsieh
4385fe4a46 Add missed finish() call
Note this is for code correctness and has no effect in current case.

Test: build
Bug: 30972906
Change-Id: I1dad13e75492da546c1d3717bbe2d23b9e5d9c90
2017-11-08 10:44:20 -08:00
TreeHugger Robot
b7eac6f0a5 Merge "Add ApkVerityBuilder to contruct the verity tree" 2017-11-03 01:06:14 +00:00
Victor Hsieh
3271d0452a Add ApkVerityBuilder to contruct the verity tree
Test: Locally add some code in PackageManagerService to generate the
      verity tree.  Root hash and the tree is consistent with the output
      of apksig.
Test: With local mod, with apk size of 400/100/20/5 MB, verification
      time is about the same for the existing algorithm before and after
      the refactoring.
Test: With local mod, with a 400 MB apk, verification time of the new
      algorithm is slower (2s) than the 1MB-based algorithm (600ms).
Bug: 30972906

Change-Id: Ie429cf9b80884e56a8e0882e1c125c8a3f8feab4
2017-11-02 15:35:03 -07:00
Yi Jin
f9ed04b3d9 Remove the extra mapping of field types in ProtoOutputStream
It is very unlikely the protobuf changes the value in descriptor.h,
and if defines an extra mapping, there are several places to maintain:
1. java-stream,
2. cpp-stream,
3. ProtoOutputStream.java
4. ProtoOutputStream.cpp
5. Privacy.h (GetFieldId)
6. StatsLog to generate field id (type << 32 + field number)

Therefore use the current value in descriptor.h seems reasonable unless
they change that, very very unlikely, they probably will just add new
types, and deprect the existing ones like Group.

Test: test output of dumpsys proto
Change-Id: I6e150ab427851dd3b5dd55d3b273deeed7a0963c
2017-11-01 17:49:42 +00:00
Tobias Thierer
c848d8968a Merge "Move most android.util.Mutable* classes to framework." am: cd06caf10e am: 4719440f3f am: 23c2a6578b
am: d6e61836ac

Change-Id: Ifec5c8457aa144a909dd694de15d66c550cd7fdc
2017-10-19 17:26:09 +00:00
Tobias Thierer
d6e61836ac Merge "Move most android.util.Mutable* classes to framework." am: cd06caf10e am: 4719440f3f
am: 23c2a6578b

Change-Id: I990ecf36ee6d2cd1d55c7cb1e652a8998ff84f35
2017-10-19 16:42:50 +00:00
Tobias Thierer
4719440f3f Merge "Move most android.util.Mutable* classes to framework."
am: cd06caf10e

Change-Id: I25fd01bd4bc8c582e6cb79a03de47847b46bcb83
2017-10-19 16:18:44 +00:00