767 Commits

Author SHA1 Message Date
Hugo Benichi
0dc1d31470 ApfFilter: more precise IPv4 broadcast filter
This patch refines the Apf IPv4 filter for interfaces with Apf
capabilities to drop packets when:
  - the multicast lock is not held
  - the packet is an IPv4 packet
  - the packet is not a DHCP packet addressed to us
  - the packet is L2 broadcast, or IPv4 multicast, or IPv4 broadcast
      - caveat: subnet broadcast address is not checked.

This allows to drop IPv4 broadcast packets whose MAC destination
address is not the L2 broadcast address but the current address of the
interface. Such packets can be received on network that rewrite L2
addresses and can put significant pressure on battery by waking up the
phone unnecessarily.

Bug: 30231088

Change-Id: I8b1785fc5ceadaa1f2881765983e502135dcbc46
2016-09-13 10:54:42 +09:00
Hugo Benichi
6708b64797 Merge "Better IPv4 multicast coverage in ApfTest" into nyc-mr1-dev 2016-09-12 03:29:15 +00:00
Winson Chung
99cf874cc3 Merge "Revert "Fixing issue with old tasks being visible in Overview"" into nyc-mr1-dev 2016-09-09 01:50:22 +00:00
Winson Chung
36f3f0337d Revert "Fixing issue with old tasks being visible in Overview"
Bug: 28908500

This reverts commit b258f6a4bd685e5efcb36c02d5817f659e10479b.

Change-Id: I9b3c04358d6ca693ed3fdcd9220af13f81eb704e
2016-09-09 01:29:18 +00:00
Hugo Benichi
961ca49fd6 Better IPv4 multicast coverage in ApfTest
This patch improves the test coverage of ApfFilter for IPv4 broadcast and
multicast traffic.

Bug: 30231088
Change-Id: I2e1d5d5a7cbae17f3d5978a4cf5f10666b5c6104
2016-09-08 14:03:46 +09:00
Winson Chung
a8c0fe6606 Merge "Fixing issue with old tasks being visible in Overview" into nyc-mr1-dev 2016-09-02 21:49:13 +00:00
Winson
b258f6a4bd Fixing issue with old tasks being visible in Overview
- This CL does two things, firstly, it ensures that all first & last
  active times are monotonically increasing and independent of the
  current system time.  This allows us to better keep track of which
  tasks are historical and should be hidden, and which are not.
  Secondly, this CL moves the tracking of the last visible active time
  into the system (per user) where it can be adjusted along with the
  task active times when they are loaded.
- Following this CL, all active times in the future will be adjusted on
  boot such that old tasks are made relative to the current boot time.
  It’s not important exactly what time they are, only that they are
  adjusted along with the last visible task active time so that we
  always keep track of what is visible.

Bug: 28908500
Change-Id: I4f789df3a6bd825517cf3a70e26fb60deff89d06
2016-08-30 15:01:49 -07:00
Lorenzo Colitti
858499b2c0 Network switch notifications: rate & daily limits
am: 84e6f1232c

Change-Id: Ibf6fa695c5f8ef11c99fe075b59a36f52c5c177b
2016-08-30 20:17:33 +00:00
Hugo Benichi
56f1281888 Network Switching Notifications: add unit tests
am: a43a095106

Change-Id: I940870a6df6a8f57966a52535ed22ec8123fb27d
2016-08-30 20:16:57 +00:00
Pankaj Kanwar
aa8263d85d Merge changes Iccb6d089,I9c50a59f into nyc-dr1-dev
* changes:
  Network switch notifications: rate & daily limits
  Network Switching Notifications: add unit tests
2016-08-30 20:11:11 +00:00
Makoto Onuki
dec5726c43 Merge "Shortcut: Improve backup & restore" into nyc-mr1-dev 2016-08-30 19:57:36 +00:00
Makoto Onuki
9480c98ddf Merge "Backport shortcut manager test utilities to DR" into nyc-dr1-dev 2016-08-30 19:54:56 +00:00
Lorenzo Colitti
84e6f1232c Network switch notifications: rate & daily limits
This patch adds a daily limit to the maximum number of notifications
shown when switching networks.

It also adds a rate limit to prevent rapid successive notifications in
flapping scenarios.

Bug: 31132499
Change-Id: Iccb6d0899646ea6df3cfad32a421922263e0eb85
2016-08-31 00:36:11 +09:00
Hugo Benichi
a43a095106 Network Switching Notifications: add unit tests
BUG: 31132499
Change-Id: I9c50a59fe48efdcb51d2517f0a756691700c3ebe
2016-08-31 00:35:16 +09:00
Felipe Leme
b79f06a476 Removed screen on/off callbacks from NPMS.
NetworkPolicyManagerService (NPMS) used to depend on screen on/off
changes to determine if a foreground activity should have network
restrictions, but such check is now redundant since ActivityManager
already changes the proper UID state (like going from TOP to
TOP_SLEEPING) when the screen status is changed.

Removing such code decreases the NPMS lock contention when the screen is
turned on in about 3-5ms.

Change-Id: I2853443efedbf14961ae9a5b2e72689d4d1a646c
BUG: 30785671
(cherry picked from commit 88f40ad9a721ee30708be82f66fb58c64f1d36b5)
(cherry picked from commit f8dd7b4e8d548274c680644a2225951b97e94a4f)
2016-08-28 02:24:42 +00:00
Fyodor Kupolov
4be496d2d0 Merge "Fix AccountManagerServiceTest" into nyc-mr1-dev 2016-08-26 16:52:07 +00:00
TreeHugger Robot
769bc6c8b1 Merge "Resolving race condition while writing recent taskids" into nyc-mr1-dev 2016-08-26 00:39:45 +00:00
Fyodor Kupolov
d954357860 Fix AccountManagerServiceTest
Unregister AccountManagerInternal before creating a new instance of
AccountManagerService, otherwise it will cause:
java.lang.IllegalStateException: Overriding service registration

Also overrode MockPm.addOnPermissionsChangeListener to be a noop and
not throw an exception.

Bug: 31071079
Change-Id: I0d24232eba655a68bf3fb38d7aa9edb92d469cea
2016-08-26 00:27:05 +00:00
Phil Weaver
1bb2cc8cc3 Merge "Revert "Dispatch a11y events in separate thread."" into nyc-mr1-dev 2016-08-25 18:05:36 +00:00
Phil Weaver
5de2feab26 Revert "Dispatch a11y events in separate thread."
This reverts commit c34649411d053185b3572c4cd924e6f14295d8cd.

Dispatching accessibility events in their own thread is causing Chrome and gmail to crash. We've identified two issues: Chrome is allocating strings natively using references that aren't valid outside of their thread, and the text is being set to values that are changed in the UI thread. 

I'm going to resolve these issues on master by making deep copies of the strings, but that change will have its own performance implications.

Since we were bit almost immediately by an unexpected result of this change, and I need to erode its benefit by making deep copies, I think it's a bad bet to push it into MR1.

Bug: 31042124
Change-Id: I6f5c225a9197036db43fd0ac6008447b22617525
2016-08-25 16:31:25 +00:00
Fyodor Kupolov
7540b79fee Update services info before returning authenticators
am: 814464894c

Change-Id: I3d7eb42ef73ad77cb44c251a493ae967bcc0f651
2016-08-25 00:08:38 +00:00
Fyodor Kupolov
814464894c Update services info before returning authenticators
Added RegisteredServicesCache.updateServices method which allows callers
to request an update to services for which package has been updated.

Added a call to updateServices in getAuthenticatorTypesInternal

Test: Manually tested update flow on test authenticator with an artificial
      delay in broadcast handling
Bug: 30979262
Change-Id: I499b2ee0be53fed01201c56068d929b6d621a78e
2016-08-24 22:47:38 +00:00
Suprabh Shukla
fd0bd4f39d Resolving race condition while writing recent taskids
There was a race condition, due to which, by the time
TaskPersister started writing the taskids to the file,
the user was stopped and its data from memory was unloaded,
resulting in a NullPointerException

Bug: 30944155
Change-Id: Iac3333b7744241c90a7769686983e3f16e6880c1
2016-08-24 15:09:09 -07:00
Makoto Onuki
0a15cd4ba0 Backport shortcut manager test utilities to DR
Bug 29612099
Bug 31033599

Change-Id: I59d4ae61fdb2245797f2d8e39beddc3b66b93fe6
2016-08-24 14:38:23 -07:00
Makoto Onuki
fc4cf2da34 Shortcut: Improve backup & restore
* Catch RuntimeException from restore, in case restoring from a
partner device with an incompatible file format.

* When a restore target app is already installed, and
- if it has allowBackup=true, we'll restore normally, so all
existing shortcuts will be replaced. (but manifest shortcuts
will be re-published anyway.) We log a warning on logcat.

- if it has allowBackup=false, we don't touch any of the
existing shortcuts.

Bug 31057974
Bug 30766177

Change-Id: Ic3f7e860e7ea0d086fc589d8cbed8c4cebdd4bc6
2016-08-24 13:52:02 -07:00
Makoto Onuki
8664df3d76 Merge "Backporting shortcut manager test utils to mr1" into nyc-mr1-dev 2016-08-23 23:44:06 +00:00
Makoto Onuki
a49bafad6b Backporting shortcut manager test utils to mr1
Bug 29612099

Change-Id: I33641b2c95f8fe859fa3256b491c039ab273fff5
2016-08-22 17:41:24 -07:00
Makoto Onuki
3366328245 Do not scan system apps unless after OTA
Bug 30956231

Change-Id: I4af34cdd39cfaf0b8712b9ded1ef119efa3e04b0
2016-08-22 17:38:46 -07:00
Makoto Onuki
8b47748b9c Merge "Off-load unlocking users onto a worker thread" into nyc-mr1-dev 2016-08-22 17:15:03 +00:00
Phil Weaver
afe9ccf17e Merge "Dispatch a11y events in separate thread." into nyc-mr1-dev 2016-08-19 22:38:53 +00:00
Makoto Onuki
085a05cd86 Off-load unlocking users onto a worker thread
Bug 29645168

(cherry picked from commit 3107ff78454d54c0494911bf69ca952152af7cf0)

Change-Id: I3f8e768f6afeb6386a08ba9ac48e0e206395da2b
2016-08-19 15:19:42 -07:00
Phil Weaver
c34649411d Dispatch a11y events in separate thread.
Moves the IPCs into a separate thread, where they should affect
jank a lot less.

Bug: 30183085
Change-Id: Ib76159d158e7a867e76cdd5c8ea3a318949fcc5b
2016-08-19 09:22:10 -07:00
Felipe Leme
f8dd7b4e8d Removed screen on/off callbacks from NPMS.
NetworkPolicyManagerService (NPMS) used to depend on screen on/off
changes to determine if a foreground activity should have network
restrictions, but such check is now redundant since ActivityManager
already changes the proper UID state (like going from TOP to
TOP_SLEEPING) when the screen status is changed.

Removing such code decreases the NPMS lock contention when the screen is
turned on in about 3-5ms.

Change-Id: I2853443efedbf14961ae9a5b2e72689d4d1a646c
BUG: 30785671
(cherry picked from commit 88f40ad9a721ee30708be82f66fb58c64f1d36b5)
2016-08-18 09:57:11 -07:00
Adam Lesinski
f2d87eba75 AppIdleHistory: Only write screen on durations during regular sync
Stop writing to disk every time the display goes off. Only write to
disk periodically.

Consequences

Previously, if the device rebooted after the screen duration was written
to disk, apps would appear more stale than they actually were.

Now apps will always look fresher, which is a better scenario.

Bug:30807864
Change-Id: Ia69a2e51fc9e397789215b449fae56fa3e29c74a
2016-08-17 16:42:46 -07:00
TreeHugger Robot
fc13448507 Merge "Fix two shortcut manager issues" into nyc-mr1-dev 2016-08-10 19:14:56 +00:00
Makoto Onuki
1e1732399a Fix two shortcut manager issues
- isUserUnlocked check is still racy
We used a local copy of each user state in mUnlockedUsers, and updated
it in the service lifecycle events. However because
SystemService.onUnlockUser() is called on Handler, there was a brief
window between when the user was actually unlocked and the shortcut
manager thought the user was unlocked.
So now check with activity manager for the latest state too.  We still
check with the local copy first, because we want to consider STOPPING
as "unlocked".

- Messenger loses all bitmap icons.
Because we delay-save the shortcuts.xml file, if the device shut down
before we save the XML file but after removing the bitmap files,
we'd lose the bitmaps.

(Apparently SystemService.onCleanupUser() may not be called even when
a device is cleanly shutting down.)

So don't remove bitmap files synchronously, ever, and instead after
saving the XML just run the dangling file cleanup.

Bug 30784267
Bug 30730471

Change-Id: Ie58656efba2dca2b00582e145613bc56266a091e
2016-08-10 10:56:08 -07:00
TreeHugger Robot
521e27d652 Merge "Fixing admins not being removed from DpmMockContext" into nyc-mr1-dev 2016-08-10 02:23:55 +00:00
Suprabh Shukla
3cb2b49f44 Fixing admins not being removed from DpmMockContext
We were not calling setActiveAdmin before calling setDeviceOwner or
setProfileOwner in these tests. They were passing because the admins
were not being properly removed in the first place. The admin is
actually removed from the admin list inside onReceive of the receiver
passed in sendOrderedBroadcastForUser, which was not overridden to call
onReceive in DpmMockContext.

Bug: 30726135
Change-Id: I08cab5821228738196b229a8f885f7488aaafa34
2016-08-09 17:52:54 -07:00
Makoto Onuki
377b7970ad Rescan apps after restore and re-publish manifest shortcuts
Originally when I wrote backup & restore for ShortcutManager,
there was no manifest shortcuts, so there was no need to
handle preintalled apps specially.

However, now we have manifest shortcuts, which are published
when the user is unlocked, by the time restore happens preinstalled
apps may already have manifest shortcuts, which will be overwritten
by the restored shortcuts.

So we need to re-publish manifest shortcuts after restore.

Bug 30746028

Change-Id: I6afbae7790c9ed38483637f33c381ecb6f854677
2016-08-09 14:43:55 -07:00
Makoto Onuki
64183d5188 ShortcutManager improve app udpate check
- Don't use lastUpdateTime for system apps since it's not reliable.

- Scan downgraded apps too.

Bug 30708050
Bug 30734178
Change-Id: I98253f4c635466197548385275ab08c5e3a1a10b
2016-08-08 14:40:32 -07:00
Makoto Onuki
33525d2f1a ShortcutManager: Update foreground check.
- When the cached UID state says a UID is in the background,
check with AM and get the latest state, since the state
might just have been changed.

Bug 30640208

Change-Id: If448f6f21f290fa0fc13550d9c740f56aa8bfce0
2016-08-03 16:36:38 -07:00
Makoto Onuki
02f338e23d LauncherApps should also throw when user is locked
otherwise it'd be racy.

Bug 30406401

Change-Id: I953eb6ae58e029d254d9fdbd5d05a0090b8d2391
2016-08-01 18:15:47 -07:00
TreeHugger Robot
1b4bd22f41 Merge "IpConnectivityMetrics: no metrics upload in tests" into nyc-mr1-dev 2016-07-29 09:23:28 +00:00
Hugo Benichi
f9fdf87af2 IpConnectivityMetrics: no metrics upload in tests
Similarly to ApfTest, this patch changes ConnectivityServiceTest to use
a mock object instead of IpConnectivityLog so that running
ConnectivityServiceTest does not generate android.net.metrics events.

Bug: 30450301
Change-Id: Ibc0479f381f26e60baefbae15407c62aecbf6666
2016-07-29 16:58:35 +09:00
Makoto Onuki
a210ccfab7 Fix timeout in a test utility method
Bug 29612099

Change-Id: Ic09a280de33dd58569f5b57242f27ece6d74c120
2016-07-27 14:08:48 -07:00
Makoto Onuki
9c850012ca Prevent shortcut access when user is locked
Also add some test utility methods that'll be used by CTS.

Bug 30406401

Change-Id: I9396acebbdb3cbe64f6e85877ee62a2131cd6e61
2016-07-27 12:01:46 -07:00
Makoto Onuki
7e5c3e8542 Fix intent flags
Bug 30307198

Change-Id: If127001320dcabdc53ee73860dbb9983cb25b611
2016-07-22 11:57:05 -07:00
Makoto Onuki
3fa345b5c2 Merge "Unit tests for "cmd shortcut"" into nyc-mr1-dev 2016-07-21 22:11:52 +00:00
Makoto Onuki
0eed441c0c Follow-up to multiple intents support
- More unit tests
 - LauncherApps.startShortcut() now supports sourceBounds
 (again)
- Updated the javadoc.

Bug 30218829

Change-Id: Iae208ffd4911d149246ccfd0c4380544c2aafffc
2016-07-21 11:33:37 -07:00
Makoto Onuki
440a1ea8e2 Support multiple intents in ShortcutInfo
Also fix b/30230996.

TODO: Support the sourceBounds argument to LauncherApps.
startShortcut().

Bug 30218829
Bug 30230996

Change-Id: Ibb6c59d5b7c0a320c21d09436d016d0eac94644f
2016-07-20 14:46:48 -07:00