Commit Graph

4646 Commits

Author SHA1 Message Date
TreeHugger Robot
b34b70b067 Merge "incidentd: Dumping batterystats system data to proto." 2017-10-11 17:56:34 +00:00
David Chen
de70169109 UID mapping to provide app name and version.
The UID map is updated by StatsCompanionService, which listens to broadcast
updates indicating that an app was updated/installed or removed. Also,
the entire map is updated when statsd first connects to the companion
service. Also, there is a way for metrics producers to subscribe to
updates, so that they can know when an app was upgraded.

Test: Created new unit-test for mapping and manually tested for install
and remove. Did not manually test the app upgrade.

Change-Id: I6676ae5c93b75c72d9badabb36aa9c40006db07d
2017-10-10 14:33:23 -07:00
Charles He
af60534c97 Merge "Add user restriction to suppress error dialogs." 2017-10-10 19:45:12 +00:00
Andreas Gampe
e2ce9017cd Merge "Parcel: Avoid NPE in finalization" am: b085deece9 am: cb34bdf55c am: 7934a7f828
am: 77de886b55

Change-Id: If5a797b8780765be8cc658d1e09bf4dea69dd923
2017-10-10 18:18:17 +00:00
Andreas Gampe
77de886b55 Merge "Parcel: Avoid NPE in finalization" am: b085deece9 am: cb34bdf55c
am: 7934a7f828

Change-Id: I5c2819892170855c4d009261785f9e8d26f9ad5e
2017-10-10 18:01:22 +00:00
Andreas Gampe
7934a7f828 Merge "Parcel: Avoid NPE in finalization" am: b085deece9
am: cb34bdf55c

Change-Id: Idd444cd9dfe78d4200f67a4fe6b3c4fb13767f29
2017-10-10 17:52:50 +00:00
Andreas Gampe
cb34bdf55c Merge "Parcel: Avoid NPE in finalization"
am: b085deece9

Change-Id: I646baf55627a3874a10775846458af5f1dcd5d8c
2017-10-10 17:35:55 +00:00
Andreas Gampe
009b852133 Parcel: Avoid NPE in finalization
Check whether the guard is null to avoid:

 Uncaught exception thrown by finalizer
 java.lang.NullPointerException: Attempt to invoke virtual method 'void dalvik.system.CloseGuard.close()' on a null object reference
      at android.os.ParcelFileDescriptor.closeWithStatus(ParcelFileDescriptor.java:740)
      at android.os.ParcelFileDescriptor.finalize(ParcelFileDescriptor.java:990)
      at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:250)
      at java.lang.Daemons$FinalizerDaemon.runInternal(Daemons.java:237)
      at java.lang.Daemons$Daemon.run(Daemons.java:103)
      at java.lang.Thread.run(Thread.java:764)

Follow-up to commit da5a3e12f4.

Bug: 7426029
Bug: 10330121
Test: m
Change-Id: I903f1545ab784008727ff23bb95fe182bd95b62a
2017-10-10 08:06:42 -07:00
Kweku Adams
87b19ecf9b incidentd: Dumping batterystats system data to proto.
Also a little code cleanup as I was going through to understand the
dumping code.

Bug: 65750808
Test: flash device and inspect incident.proto output
Change-Id: Ib850db408c98d6a96dc028296e96c75087258904
2017-10-09 14:29:40 -07:00
TreeHugger Robot
c7b36eb77b Merge "Adding initial protos for batterystats dump." 2017-10-07 01:02:11 +00:00
Charles He
22ff6f9df0 Add user restriction to suppress error dialogs.
Bug: 66125576
Test: cts-tradefed run cts-dev --module DevicePolicyManager -t com.android.cts.devicepolicy.UserRestrictionsTest
Test: bit FrameworksServicesTests:com.android.server.pm.UserRestrictionsUtilsTest
Change-Id: I1c4cf4a107f47e9b5543607e57b76dd2e5acfba5
2017-10-07 00:23:31 +01:00
Kweku Adams
2f73ecdf52 Adding initial protos for batterystats dump.
Timer is the basic stat tracking object that's used for a lot of the
data in batterystats.
ControllerActivity data is tracked both per uid and for the entire
system, so it makes sense to define it now independently.
For the BatteryStatsHelper change: there's a small window of time after
boot where getSystemService will return null. I ran into it.

BUG: 65750808
Test: flash device and check incident proto output
Change-Id: I15e7d046a43f76d5f53d05b5138ea40f42e19d59
2017-10-06 14:52:26 -07:00
TreeHugger Robot
67e48e878c Merge "Added apis for changing the system whitelist" 2017-10-06 21:13:22 +00:00
Mike Ma
8cb8bdf657 Merge "Add AOD metrics in batterystats" into oc-mr1-dev
am: 6204a60c53

Change-Id: Ife567f987a1585cb1108725db6ad63516a8dc67a
2017-10-06 07:17:25 +00:00
Mike Ma
1ce1d3a42c Add AOD metrics in batterystats
Fixes: 64899521
Test: manual - flash build, reset batteryStats, use device > 1 hr
with alternating pattern between screen on/off/AOD. Dump stats, check
all screen related stats look normal, esp. record matches actual time
spent in each screen state. In raw bugreport:
Search "amount discharged" for % discharge;
Search "Screen on/off/doze discharge" for mAh discharge;
Search "time on battery" for up/real time in each state.

Test: Added two unit tests for note AOD screen state

Merged-In: I7193a36751124dd380818b2b665303c0f0d8c984
Change-Id: I51cead7f92abd9e4c620f7dfde393993cdad494e
2017-10-06 00:50:03 +00:00
Mike Ma
c2f518a9dd Add AOD metrics in batterystats
Fixes: 64899521
Test: manual - flash build, reset batteryStats, use device > 1 hr
with alternating pattern between screen on/off/AOD. Dump stats, check
all screen related stats look normal, esp. record matches actual time
spent in each screen state. In raw bugreport:
Search "amount discharged" for % discharge;
Search "Screen on/off/doze discharge" for mAh discharge;
Search "time on battery" for up/real time in each state.

Test: Added two unit tests for note AOD screen state
Change-Id: I7193a36751124dd380818b2b665303c0f0d8c984
2017-10-05 15:28:55 -07:00
TreeHugger Robot
e0fa2c0408 Merge changes I616184fa,Ibc1500f5
* changes:
  Move mPermissions from package settings
  Move DefaultPermissionGrantPolicy
2017-10-05 18:30:33 +00:00
Todd Kennedy
0eb9738d17 Move mPermissions from package settings
Create a settings class only for use with permissions. It's
subservient [and should only be accessed directly by] package
settings or the permission manager. The rest of the permission
related data needs to be moved to permission settings. At
which point we can start pulling the permission methods out of
the package manager service and into the permission manager.

We still have a somewhat tight relationship between package
manager and the permission manager. It's unclear how far we need
to separate them and if relying entirely on an internal
interface is sufficient.

Bug: 63539144
Test: Manual. Builds and runs
Test: cts-tradefed run commandAndExit cts-dev -m CtsAppSecurityHostTestCases -t android.appsecurity.cts.PermissionsHostTest
Test: cts-tradefed run commandAndExit cts-dev -m CtsPermissionTestCases
Test: cts-tradefed run commandAndExit cts-dev -m CtsPermission2TestCases
Test: bit FrameworksServicesTests:com.android.server.pm.PackageManagerSettingsTests
Change-Id: I616184fa2135a11687e4ce615884f861466fdebe
2017-10-05 07:18:10 -07:00
Henrik Baard
8d475ca058 Prevent WakeLock count ending up in an incorrect state
WakeLock can end up in a bad state if the following sequence
is executed:

1. mWakeLock =  mPowerManager.newWakeLock(...)
2. mWakeLock.acquire(TIMEOUT_MS);
3. timeout TIMEOUT_MS occurs before release() is called
4. release is called()

[1] mInternalCount = mExternalCount = 0
[2] mInternalCount = 1, mExternalCount = 1
[3] mInternalCount = 0, mExternalCount = 1
[4] mInternalCount = -1, mExternalCount = 0

If acquireLocked is called on the same object after this sequence,
mInternalCount is incremented to 0 which results in no wakelock
being requested from PowerManagerService.

Bug: 64676694
Test: cts-tradefed run commandAndExit cts-dev -m CtsOsTestCases -t android.os.cts.PowerManager_WakeLockTest
Change-Id: I133812aefb5d92eec2e2dde1a36f81dc9ffd7625
2017-10-03 14:45:34 -06:00
TreeHugger Robot
6214ad9f5f Merge "Statsd can pull kernel wakelock data" 2017-10-02 18:22:53 +00:00
Bookatz
c68a9d21b4 Statsd can pull kernel wakelock data
When statsd is told that it is time to poll data, it asks
StatsCompanionService to pull kernel wakelock data, receives the result
(as a string), and outputs it to screen.

Still to do:
1. don't use a string; use a parcel instead
2. don't output it to screen; do something useful instead
3. do more than just kernel wakelocks
4. pull data on demand, in addition to just on periodic pulling

Test: added setPollingAlarms to statsd.main and confirmed that kernel
wakelock information was written to screen
Change-Id: I35f5164420699dea1a00c9e530b938904f1d3055
2017-09-29 15:10:47 -07:00
Suprabh Shukla
081056475e Added apis for changing the system whitelist
We want the user to be able to remove apps that are added in the system
whitelist. The user can restore them back later if they want.

Test: cts-tradefed run cts-dev -m CtsDeviceIdleHostTestCases

Bug: 63528174
Change-Id: Ia2f908c5fac84e28772d85b303be68b70efac8ba
2017-09-28 18:04:27 -07:00
Jeff Sharkey
f8bb2445ff Finish removing ASEC.
Awhile back we explicitly blocked any new ASEC installs, with the
expectation that we'd eventually remove the logic entirely.  We've
had them disabled for about a week now without incident, so let's
rip out the remaining code.

Test: bit FrameworksCoreTests:android.content.pm.PackageHelperTests
Test: bit FrameworksCoreTests:android.content.pm.PackageManagerTests
Bug: 32913676
Change-Id: I1ecc35487420731f5c4bdf03bca5751548ce51b3
2017-09-28 11:32:57 -06:00
Jeff Sharkey
187b437818 Merge "Only construct real Throwable objects." into oc-dev am: 0868533760 am: f0278f30da
am: 08415b47b0

Change-Id: I6fac18c8ba18f387b9b864055985b2a6bd12de68
2017-09-28 00:35:12 +00:00
Jeff Sharkey
08415b47b0 Merge "Only construct real Throwable objects." into oc-dev am: 0868533760
am: f0278f30da

Change-Id: Id23ee02fb7cfd4b4ab9782066a085ee000fb8a70
2017-09-28 00:23:50 +00:00
Jeff Sharkey
2c56bb54be Merge "Only construct real Throwable objects." into oc-dev am: 0868533760
am: f0278f30da

Change-Id: I3a7cbb7cad2c9663e4f7aa2e583ef5707cf6bbc2
2017-09-28 00:23:46 +00:00
Jeff Sharkey
f0278f30da Merge "Only construct real Throwable objects." into oc-dev
am: 0868533760

Change-Id: I260dc1d1c903f1c1c2828d68049f9f202daa0869
2017-09-28 00:15:18 +00:00
Lorenzo Colitti
6fb1658fbb Merge "Delete the legacy framework code for manipulating ND offload." am: d1ae268081 am: 53eb9d359a am: bb21618a86
am: c34d05691d

Change-Id: Ie442b73e9130aaeb5b46d4e2789521a508df6221
2017-09-27 11:13:15 +00:00
Lorenzo Colitti
c34d05691d Merge "Delete the legacy framework code for manipulating ND offload." am: d1ae268081 am: 53eb9d359a
am: bb21618a86

Change-Id: I07d9753e214af311d3dcab6f8016442f60388700
2017-09-27 11:05:29 +00:00
Lorenzo Colitti
53eb9d359a Merge "Delete the legacy framework code for manipulating ND offload."
am: d1ae268081

Change-Id: I060bd7632b809d89224d250c697ac9d2e89d5c2d
2017-09-27 10:53:05 +00:00
Lorenzo Colitti
59da962b9f Delete the legacy framework code for manipulating ND offload.
This only worked on broadcom devices, and was superseded in
M by a wifi HAL call made by IpManager.

Test: bullhead builds, boots
Change-Id: I711cae7dafe171c2c8b4e84a229adbcad27f3d14
2017-09-27 16:47:36 +09:00
TreeHugger Robot
f3149fd352 Merge "Pass dumpsys priority to IServiceManager" 2017-09-26 19:01:10 +00:00
Hans Boehm
6f0d970b2e Merge "Naming fix and add comments" am: 3c03d5bd2b am: 24b9851605 am: 4a901144fe
am: c9532e8ac6

Change-Id: Ibe7d825b3b491cd9e5fb1ef07adaa9f71719e0dd
2017-09-26 13:03:11 +00:00
Hans Boehm
c9532e8ac6 Merge "Naming fix and add comments" am: 3c03d5bd2b am: 24b9851605
am: 4a901144fe

Change-Id: I1e2446f67e0505d30edb230f2dde70855c9fe00c
2017-09-26 12:42:41 +00:00
Hans Boehm
24b9851605 Merge "Naming fix and add comments"
am: 3c03d5bd2b

Change-Id: Ib35c874f56f87757904553ceeffb4d363eff196e
2017-09-26 11:12:19 +00:00
Sudheer Shanka
f39df68b71 Merge "Add shutdown reason as extra when triggering ACTION_REQUEST_SHUTDOWN." 2017-09-25 20:42:52 +00:00
Sudheer Shanka
292637f51a Add shutdown reason as extra when triggering ACTION_REQUEST_SHUTDOWN.
When BatteryService triggers ACTION_REQUEST_SHUTDOWN intent, add the reason
for shutdown as extra to indicate low battery or critical battery
thermal state.

Bug: 63736262
Test: 1/ adb shell cmd battery unplug && adb shell cmd battery set level 0
      2/ Power on the device
      3/ Verify sys.boot.reason == shutdown,battery
Test: 1/ adb shell cmd battery set temp 700
      2/ Power on the device
      3/ Verify sys.boot.reason == shutdown,thermal,battery

Change-Id: If20a36ef53f8bcbfae4114df08f741ec1dcd7df9
2017-09-25 11:20:37 -07:00
Vishnu Nair
0576819519 Pass dumpsys priority to IServiceManager
Modify IServiceManager to accept supported dumpsys priority as a bitmask
with NORMAL being the default priority. Change listServices to return
a list of services filtered by the priority or all services when the
priority is set to ALL.

BUG:27429130

Test: manual verification

Change-Id: If367ace2f37f918043f1b330568d8560676d9b78
2017-09-25 10:25:26 -07:00
TreeHugger Robot
8672d81355 Merge "Fixing method asymmetry in Parcel" 2017-09-23 04:18:46 +00:00
Hans Boehm
eb6d62cd33 Naming fix and add comments
Also fix up imports to make repohooks happy and some whitespace issues.

A very small step towards making this code more understandable.

Bug: 65760710

Test: Builds.
Change-Id: I0396c06bb303e0b06ad0cbbbff4fdc1ac527ac6c
2017-09-22 15:49:48 -07:00
Kurt Nelson
9a94faca7a Merge "Make StrictMode constants visible for testing" 2017-09-22 19:35:18 +00:00
Sunny Goyal
0e60f22d2d Fixing method asymmetry in Parcel
Test: manually
Change-Id: I2a8321023b40cc74b7026eb0fb32a9cc5f5543a9
2017-09-21 21:41:14 -07:00
Kurt Nelson
cf8c4faa09 Make StrictMode constants visible for testing
All detector bits should be the same visibility.
Extract some error messages into constants.

Bug: 65966451
Test: CTS builds
Change-Id: Ib8ed80042c8d490d18ddd0054db8870e09c2b19d
2017-09-21 12:49:45 -07:00
Jeff Sharkey
930e352d94 Merge "Only construct real Throwable objects." 2017-09-21 15:39:08 +00:00
Jeff Sharkey
8e151bf899 Only construct real Throwable objects.
Without this test, someone could trick us into constructing other
shady classes.

Test: builds, boots
Bug: 65281159
Change-Id: If678d0681708d1b0dcf056aa1133830ad3dbce31
2017-09-20 23:39:20 +00:00
Jeff Sharkey
020ed6aed6 Only construct real Throwable objects.
Without this test, someone could trick us into constructing other
shady classes.

Test: builds, boots
Bug: 65281159
Change-Id: If678d0681708d1b0dcf056aa1133830ad3dbce31
2017-09-20 16:14:52 -06:00
Bookatz
b487b5533e statsd & statscompanion communication more robust
If statsd or statsdcompanion crashes, or if one loads
before the other, the other will be able to accomodate.

When statsd loads, it will attempt to tell statscompanion that it's
alive, and then get on to its business, while assuming that
statscompanion is not alive. Only when statscompanion tells statsd
that it is alive, statsd will then start to use it.

When statscompanion loads, it will attempt to tell statsd that it's
alive and then do nothing (since it has nothing to do). When statsd
tells statscompanion that statsd is alive, statscompanion will respond,
telling statsd that it is alive and, if that binder call returns, will
get to work.

This way, if statsd loads first, it can work unobstructed until
statscompanion informs statsd that it is alive, at which point they
shake hands and work. Conversely, if statscompanion loads first, it will
do nothing until statsd contacts it, at which point they will shake
hands and work.

Test: manual
Change-Id: I969ad47fb8060e27814d05ad37433a02711cfa6a
2017-09-20 14:13:44 -07:00
Bookatz
1b0b114abc StatsCompanionService sends messages to statsd
StatsCompanionService can now inform statsd that an alarm (for anomaly
alerting and for polling) has fired, so that statsd can act accordingly.

Test: manual created an alarm from statsd.main and checked logcat that
statsd received the broadcast that it fired
Change-Id: I1d33dfbee0d3e213c91dd6973d2622ecacc890c8
2017-09-20 07:51:53 -07:00
Adam Bookatz
43b272e20c Merge changes I82fe220e,Iff324c73,I3bd73acd
* changes:
  indexed priority queue for AnomalyMonitor
  StatsCompanionService connection to Statsd
  Set up StatsCompanionService.java
2017-09-20 14:01:49 +00:00
Kurt Nelson
5fe738da3b Merge "Improve StrictMode CTS Testing" 2017-09-18 21:40:33 +00:00