136 Commits

Author SHA1 Message Date
David Christie
9e9ce92541 Don't track LocationManager internal requests in AppOps (b/10725757).
AppOps stats are used to populate the "apps recently using location"
list in settings->location.  There is no reason to show Android OS
in that list simply because of internal location requests supporting
other clients.

Change-Id: I6908aa63deb19d22733b8d9cdae6ea5dbbea55e0
2013-09-12 13:19:53 -07:00
destradaa
839904eed8 Fix exceptions in the Flp Hal layer:
- JNI exception accessing a geofence method with wrong signature
- FlpHardwareProvider exception when the monitoring status contains no location information

Bug: 10691492
Change-Id: I1959712912af712dc9dc344f20afd1112da46efc
2013-09-11 12:42:51 -07:00
Zhentao Sun
d535ead295 Fixed b/10512887.
This is an issue caused by multi-threading. If geofence provider service
is connected and disconnected immediately, the ServiceWatcher can return a
null service handle to the private thread used by GeofenceProxy, and
this can cause NPE and system crash.
This CL also fixed a hidden race conditions bug where mGeofenceHardware
is not synchronized between two threads.

Change-Id: I824642cd638fbb1e6799a5a1220b047ebc2556a1
2013-08-29 16:56:19 -07:00
destradaa
0682809ad0 Add support in the platform for Flp Geofencing.
Change-Id: I0fb0e276d3a06322697bb5d46323779aca1f78c5
2013-08-13 16:00:04 -07:00
destradaa
64be0c617f Address Robin's code review comments in initial FlpHal submission.
Change-Id: I50889599fdc5938a19b8bff4f11e64f44bcebdbf
2013-08-09 16:56:43 -07:00
destradaa
1af4b0280a Add FlpHal layer to support Location Batching.
Change-Id: Ia3a57d869dfb3f067a1b95fa66d54f311ddcfdc3
2013-08-08 15:27:38 -07:00
Dianne Hackborn
e98f5dbe6b Make it safe to use start/stop app ops outside of system proc
We now keep track of all of the active start operations per
non-system process, so they can be cleaned up if the process
goes away.

Change-Id: I9d05f1e0281c47dbe1213de014f0491f1359685c
2013-07-17 17:25:13 -07:00
Dianne Hackborn
91268cf21e More work on process tracking.
Re-arranged code to be more flexible, now track
state of services, dump ordered list of running
processes while memory was critical and low.

Also rename battery stats service from "batteryinfo" to "batterystats".

Change-Id: I0f4f0c8d443c49d255cb84d0fc917e8ec18b152e
2013-06-14 17:30:17 -07:00
Zhentao Sun
c5fc9988f1 Made it easier to disable overlay mechanism of location components.
Fixed b/8276827

Vendor might want to provide their own implementation of "network
location", "fused location" and "geocoder" service. Location manager now
allows those service to be replaced by packages that have the same
signature as one of the packages in config_locationProviderPackageNames.
Such behavior might not be desirable on some devices. This change
make this behavior configurable by 3 boolean flags.

Details:
- Added three boolean flags in core/res/res/values/config.xml to enable
or disable NLP/FLP/Geocoder overlay
- Added 3 package name for the stock NLP/FLP/Geocoder. They are needed
  only when overlay is disabled because LocationManagerService need to
  know which package is preferred when searching for
  NLP/FLP/Geocoder service.
- Made ServiceWatcher able to handle non-overlayable services.
- Fixed an NPE isue in ServiceWatcher. mPm.queryIntentServicesAsUser
  might return null.
- Fixed an bug: justCheckThisPackage in bindBestPackageLocked is always
  ignored.

Change-Id: Id221961ac7c3aa8ad44b894f9523f04f770ae237
2013-04-22 10:02:08 -07:00
Stan Chesnutt
b34b3211e0 Merge "Re-introduce single-shot mode, set MS Assist Mode A when in single-shot mode." into jb-mr2-dev 2013-04-16 02:49:45 +00:00
Stan Chesnutt
1d72d8c33d Re-introduce single-shot mode, set MS Assist Mode A when in
single-shot mode.

Fixes bug http://b.corp.google.com/issue?id=8204392

Change-Id: I5594447c75abab6b71bd12706409666bb75736c5
2013-04-15 19:18:02 -07:00
Jaikumar Ganesh
8ce470dd4b GPS Hardware geofencing.
Add support for doing geofencing in hardware.

Change-Id: I6d5015190e8d84e1f4beb1010ed977a71c1622d0
2013-04-10 15:25:07 -07:00
Jaikumar Ganesh
e11f058ee0 am d080bb07: am b9620a89: am 9434c112: Merge "Services: Adding HSPAP info in Android"
# By Arun Ravindran
# Via Android Git Automerger (2) and others
* commit 'd080bb07c88ca5ccf99f326789ed472448b50832':
  Services: Adding HSPAP info in Android
2013-02-07 11:19:59 -08:00
Jaikumar Ganesh
9434c112d1 Merge "Services: Adding HSPAP info in Android" 2013-02-07 17:54:41 +00:00
Victoria Lease
03cdd3d275 dual-mode switching single/multiuser ServiceWatcher
This changelist revises LocationManager's previous multiuser system.

Location provider services that are not multiuser-aware continue to
run as before: ServiceWatcher binds to location provider services as
the current active user. When the device switches from one user to
another, ServiceWatcher unbinds from the old user's location provider
service and binds to the new user's instance.

Now, location provider services that are multiuser-aware or
user-agnostic can declare "serviceIsMultiuser" metadata in their
AndroidManifest.xml to prevent ServiceWatcher from performing this
switching. These services will run as singleton services and will be
expected to handle user switches on their own.

With this feature in, I was able to switch FusedLocationProvider to
run in multiuser mode, sharing the system_server process instead of
running in its own process. The NetworkLocationProvider is unchanged,
still running in singleuser mode, cheerfully oblivious to the
possibility that there might be any user on the device besides the
one it services.

Bug: 8028045
Change-Id: I1a5bd032918419bab6edb46c62ff8c6811170654
2013-02-01 16:00:20 -08:00
Dianne Hackborn
b9781fe08c Merge "App ops: you can now turn off operations." 2013-01-25 19:33:11 +00:00
Dianne Hackborn
5e45ee6752 App ops: you can now turn off operations.
Also add new ops for calendar and wi-fi scans, finish
implementing rejection of content provider calls, fix
issues with rejecting location calls, fix bug in the
new pm call to retrieve apps with permissions.

Change-Id: I29d9f8600bfbbf6561abf6d491907e2bbf6af417
2013-01-25 11:25:48 -08:00
Laurent Tu
7b5aeca50b Fix GpsLocationProvider.enable/disable/isEnabled
Fix the issue where GpsLocationProvider.isEnabled() returns true when it
is really false (and the other way around), when the handler hasn't
processed the enable/disable messages yet.

This can be systematically reproduced when the caller code is using the
same thread as the thread of the handler in GpsLocationProvider.

For example, this was happening in LocationManagerService.switchUser().
It would start by disabling all the providers (with
updateProviderListenersLocked()), then re-enable them in
updateProvidersLocked() only when isEnalbed()==false, which was in the
wrong state since the GpsLocationProvider.ENABLE message hadn't been
processed yet. As a result, the GpsLocationProvider was disabled upon
startup of the phone.

This is a slight problem for the enable() contract, which specifies that
getStatus() must be handled, getStatus() will be handled but might have
slighty not-up-to-date info in this case.

Bug: 8028017

Change-Id: Iff91a11cc150e9029a6db85b64a10a926e12b0ba
2013-01-24 15:26:02 -08:00
Victoria Lease
ea78b85bb7 fix NPE in updateClientUids
Bug: 8009908
Change-Id: I54d97c587a3fa9d003f654f98fdfdbe21af791d6
2013-01-15 10:39:28 -08:00
Dianne Hackborn
002a54e229 WorkSource can now track package names.
Use this to track the package name of applications
accessing GPS.

And now the app ops service can enforce that callers
must provide valid package names.

Change-Id: I842a0abe236ea85f77926d708547f0f95c24bd49
2013-01-11 17:37:04 -08:00
Dianne Hackborn
a06de0f29b New "app ops" service.
Initial implementation, tracking use of the vibrator, GPS,
and location reports.

Also includes an update to battery stats to also keep track of
vibrator usage (since I had to be in the vibrator code anyway
to instrument it).

The service itself is only half-done.  Currently no API to
retrieve the data (which once there will allow us to show you
which apps are currently causing the GPS to run and who has
recently accessed your location), it doesn't persist its data
like it should, and no way to tell it to reject app requests
for various operations.

But hey, it's a start!

Change-Id: I05b8d76cc4a4f7f37bc758c1701f51f9e0550e15
2013-01-09 12:47:47 -08:00
Victoria Lease
5cd731a233 prevent concurrency issues during LocationManager init
systemReady() was returning before the LocationManagerService was
actually ready. Applications making LocationManager transactions
during their startup could possibly hit a race condition with the
yet-uninitialised LocationManagerService.

To guarantee that LocationManagerService is actually ready before
returning from systemReady(), we simply do the startup work on the
thread that called systemReady(), rather than spin up a secondary
thread to do the work asynchronously.

LocationWorkerHandler still needs a thread to do its work on, so
rather than have it run on the secondary thread that was
previously used for systemReady()'s work, we create a HandlerThread
for it.

Additionally, LocationManagerService.init() really needed to grab
lock for some of the things it was doing. I moved all of the code
that could benefit from mutex protection to a single section of
systemReady() and wrapped it up with a lock while I was at it.

Bug: 7723944
Change-Id: I51d480e2781622c3a14769c3a2019a2407dcfd8a
2013-01-02 13:25:57 -08:00
Victoria Lease
eeaf165a5f am 44d927ca: am 66f3d7f3: am 446ffe00: am e6299d5a: Merge "Fires geofence if the device is already in the geofence area." into jb-mr1-dev
* commit '44d927ca837f03e99a4dda52377275da2863ecbb':
  Fires geofence if the device is already in the geofence area.
2012-11-08 06:18:31 -08:00
Victoria Lease
44d927ca83 am 66f3d7f3: am 446ffe00: am e6299d5a: Merge "Fires geofence if the device is already in the geofence area." into jb-mr1-dev
* commit '66f3d7f3c8247b59516cbc4ad13bea4e0b8c0ef9':
  Fires geofence if the device is already in the geofence area.
2012-11-08 06:13:21 -08:00
Kenny Root
7b172a49a9 am 58ed5d74: am 768d9e1a: Merge "Correct executable bit for source files"
* commit '58ed5d748c0b9b64845975ef5844ad313de7c3f6':
  Correct executable bit for source files
2012-11-07 13:08:25 -08:00
Kenny Root
58ed5d748c am 768d9e1a: Merge "Correct executable bit for source files"
* commit '768d9e1a72ceee7d4a5f608776b87b62d6ce4a04':
  Correct executable bit for source files
2012-11-07 11:52:12 -08:00
Kenny Root
3a084af2e9 Correct executable bit for source files
Many media files and source code files were marked as executable in Git.
Remove those.

Also a shell script and python script were not marked as executable.

Change-Id: Ieb51bafb46c895a21d2e83696f5a901ba752b2c5
2012-11-07 10:27:31 -08:00
Victoria Lease
4cd0a50b26 Fires geofence if the device is already in the geofence area.
Process the location of the fence as soon as it is added.

Clarified how the distance to the fence was being used.

Added more debug logs (disabled by default).

Fixed a numerical overflow in the location request if the
distance to the border of the nearest fence was greater
than about 2000Km.

Removed a useless call to request location updates passively
when the geofence manager is initialized.  We have no need
of location updates unless there are active geofences.
The effect of this call was undone the next time the location
request was updated anyhow.

Changed the location request to always request a fastest update
interval of 0 which accomplishes the goal of passively
monitoring all updates.  This does not increase the power
consumption because we are conservative about choosing
a minimum location update interval.  We're simply stating
that the geofence manager is willing to handle a higher
report rate which is very important.

Subject location to a "freshness test" - only use relatively
recent locations for geofence testing.

Run all geofence updates on the handler and avoid making
multiple redundant calls into the location manager when
updating the provider requirements.

Ensure that we update geofences correctly even if we don't
know the initial location of the device at the time the
geofence is created.

Pin update interval value to the range [1m..2hr].

Distance to fence is now distance to fence's border, not
distance to fence's centre.

Bug: 7466334
Change-Id: I28e571ecfc508d5ceb9bb2afcabaaf05abb26369
2012-11-06 10:01:33 -08:00
Victoria Lease
d50d0c31d4 don't complain about CDMA support on non-CDMA devices
GpsLocationProvider emits a message on CDMA phones, warning about
lack of CDMA support. It also emits this message on every other
non-GSM device. I've pulled the conditions in a bit for this so that
it only happens on actual CDMA devices.

Change-Id: I1a122e2599c83c730be014c61385e60ef819b5a1
2012-10-29 13:46:43 -07:00
Victoria Lease
c0c0c0e612 Merge "Multiuser love for LocationManager" into jb-mr1-dev 2012-10-09 12:22:03 -07:00
Victoria Lease
b711d57ca4 Multiuser love for LocationManager
LocationManagerService now keeps track of the current user ID and
denies location requests made by all but the foreground user.

Additionally, location settings are now user-specific, rather than
global to the device. Location provider services now run as specific
users, and when the device's foreground user changes, we rebind to
appropriately-owned providers.

Bug: 6926385
Bug: 7247203
Change-Id: I346074959e96e52bcc77eeb188dffe322b690879
2012-10-08 17:19:43 -07:00
Laurent Tu
60ec50a850 Last position improvements for GeofenceManager
Use LocationManager.getLastPosition() in GeofenceManager instead of
keeping track of it manually. Keeping track of it in GeofenceManager
doesn't handle the case where we install a fence, and cross it just
after that based on the last position before we installed the fence.

Also shuffle around some code in LocationManagerService to remember the
last position even if there are no UpdateRecords. This is useful in the
GeofenceManager for example.

Bug: 7047435
Change-Id: Ia8acc32e357ecc2e1bd689432a5beb1ea7dcd1c7
2012-10-04 17:23:12 -07:00
Victoria Lease
83762d22c9 multiuser support for LocationBlacklist
This allows primary/secondary users to have different "Google
Location Services" preferences. It also reenables LocationBlacklist,
which is fixed elsewhere.

Bug: 7213502
Bug: 7248239
Change-Id: I94837682f95920c225c00b7da2de6dd1418a673e
2012-10-04 09:46:52 -07:00
Victoria Lease
5c24fd0342 Avoid NPE in GpsLocationProvider
Oops, looks like we were spinning up a secondary thread to run some
tasks that will just happen on the main thread regardless. Removed
the secondary thread and fixed up initialisation order regarding
mHandler and things that post to it. Also reordered GPS and
PASSIVE provider initialisation order since GPS depends on PASSIVE.

This should be both safer and easier to read.

Bug: 7248029
Change-Id: I8630caf0a7bd1b2c401603075676f13dda5be4fa
2012-10-01 12:04:37 -07:00
Victoria Lease
b319d5de19 temporarily disable blacklisting
Bug: 7248239
Change-Id: I2ef28fa0d6890a127fc424e58a148fe1fb15b683
2012-09-27 18:24:27 -07:00
Philip Milne
4118012da9 Fix for bug: #7173350. elapsedRealtimeNano() -> elapsedRealtimeNanos()
Change-Id: Ie38952bbaace080e81e41e61350cda172951d548
2012-09-26 11:29:25 -07:00
Jeff Brown
bf6f6f9de7 Update references to migrated global settings.
Fixed one setting that was migrated but not marked deprecated.

Removed a hidden setting that is no longer used by the new
power manager service.

Bug: 7231172
Change-Id: I332f020f876a18d519a1a20598a172f1c98036f7
2012-09-25 15:27:51 -07:00
Philip Milne
bc391d58c8 Merge "Revert "Fix for bug: #7173350. elapsedRealtimeNano() -> elapsedRealtimeNanos()"" into jb-mr1-dev 2012-09-24 11:41:53 -07:00
Philip Milne
53fe756772 Revert "Fix for bug: #7173350. elapsedRealtimeNano() -> elapsedRealtimeNanos()"
This reverts commit 2f6d8829524dfca3a77e9a57c3b9c3862209877d

Change-Id: Id5af767a09fc319127c4ebef837c5b7a7f75cb01
2012-09-24 11:38:29 -07:00
Philip Milne
b00df8e929 Merge "Fix for bug: #7173350. elapsedRealtimeNano() -> elapsedRealtimeNanos()" into jb-mr1-dev 2012-09-24 11:02:31 -07:00
Philip Milne
2f6d882952 Fix for bug: #7173350. elapsedRealtimeNano() -> elapsedRealtimeNanos()
Change-Id: I71c24ea10093ece07a0780e97bc641ff548c1a44
2012-09-21 15:54:41 -07:00
Victoria Lease
09016ab4dd Do not use passive GPS data for COARSE only apps.
FusionEngine now attaches a secondary location that has never seen
GPS data to its result. LocationFudger uses the GPS-less location so
that COARSE apps never see data from the GPS provider.

When the previous location is updated, the previous GPS-less location
is carried over if the location update was GPS-only.

Additionally, apps without FINE permission are not notified when GPS
location changes, and any attempt to use GPS_PROVIDER without FINE
permission is met by a stern SecurityException.

Bug: 7153659
Change-Id: I12f26725782892038ce1133561e1908d91378a4a
2012-09-21 13:45:41 -07:00
Victoria Lease
df9ec6171f Secure setting for LocationFudger's accuracy
This replaces the ACCURACY_METERS constant and all derived values with
a secure setting. This value defaults to 2km and has a hardcoded floor
of 500m.

Bug: 6982024
Change-Id: Ibf97ab57145abf28c4a9747444f40250adddf23c
2012-09-12 17:06:07 -07:00
Christopher Tate
c09cdce1b0 Update airplane-mode manipulation for the new Settings namespace
Quick Settings and global actions (aka longpress-Power) toggles are
included in this CL.  The Settings app manipulations are updated in
a different CL because that's a different git package.

Bug 7132230

Change-Id: I50838f5e8d7b25a750d2bcae90bf384b09816dbb
2012-09-10 16:50:57 -07:00
Arun Ravindran
58d46126e4 Services: Adding HSPAP info in Android
HSPA+ management is missing in GPS Loc service.

Change-Id: If828c1b078d5989f501c3eb917a573a6db773453
Author: Arun Ravindran <arun.ravindran@intel.com>
Signed-off-by: Arun Ravindran <arun.ravindran@intel.com>
Signed-off-by: Regnier, PhilippeX <philippex.regnier@intel.com>
Signed-off-by: Shuo Gao <shuo.gao@intel.com>
Signed-off-by: Bruce Beare <bruce.j.beare@intel.com>
Signed-off-by: Jack Ren <jack.ren@intel.com>
Author-tracking-BZ: 41786
2012-09-05 14:50:45 +08:00
Dianne Hackborn
5ac72a2959 Improve multi-user broadcasts.
You can now use ALL and CURRENT when sending broadcasts, to specify
where the broadcast goes.

Sticky broadcasts are now correctly separated per user, and registered
receivers are filtered based on the requested target user.

New Context APIs for more kinds of sending broadcasts as users.

Updating a bunch of system code that sends broadcasts to explicitly
specify which user the broadcast goes to.

Made a single version of the code for interpreting the requested
target user ID that all entries to activity manager (start activity,
send broadcast, start service) use.

Change-Id: Ie29f02dd5242ef8c8fa56c54593a315cd2574e1c
2012-08-30 14:33:22 -07:00
Jeff Brown
028872fe07 Fix GpsLocationProvider wake lock book keeping.
The GpsLocationProvider typically acquires a wake lock
before sending a message to its handler then releases it
after the message has been handled.

There were two cases where messages might be removed from
the handler, resulting in the wake lock being released.

There were also two cases where background tasks were being
started while not holding a wake lock for the duration.

Fixed these issues and marked the GpsLocationProvider handler
as asynchronous too so that it doesn't accidentally get
blocked by traversals if it happens to share a thread with some UI.

Bug: 7057752
Change-Id: I8e12fc91ae943e84db068c08ec809879537503c6
2012-08-25 13:40:28 -07:00
Kevin Tang
40e1bafc37 Fix GPS provider thread blocked by NTP and XTRA
Currently, the NTP and XTRA downloads block on the GPS provider thread.
This could potentially block the next tasks for over a minute of time.
If the upcoming task happens to be AGPS, AGPS will time out.

Placed the NTP and XTRA downloads in separate threads.

Bug: 6980618

Change-Id: I57a6aaf5348212bc1246813f6d941da7d5b19136
2012-08-24 14:06:47 -07:00
Brian Muramatsu
b94b41f516 Listen for CONNECTIVITY_ACTION in GPS Provider
Bug: 7020678

The broadcast receiver in GpsLocationProvider now listens for
CONNECTIVITY_ACTION changes. Set the intent filter so that
it catches those actions and updates the network state.

Change-Id: I7efd393dfe2aa8b172dd6701d42ff9ed687648a2
2012-08-21 16:30:57 -07:00
Nick Pelly
4035f5a7c1 Port location blacklist code to MR1.
I had to re-do this change for MR1 because LocationManagerService changed
so much. Here is the original change description:

Add package-name-prefix blacklist for location updates.

The Settings.Secure value locationPackagePrefixBlacklist and
locationPackagePrefixWhitelist contains comma seperated package-name
prefixes.

Location & geo-fence updates are silently dropped if the receiving
package name has a prefix on the blacklist. Status updates are
not affected. All other API's work as before.

A content observer is used so run-time updates to the blacklist
apply immediately. There is both a blacklist and a whitelist.
The blacklist applies first, and then exemptions are allowed
from the whitelist. In other words, if your package name prefix
matches both the black AND white list, then it is allowed.

Bug: 6986553
Change-Id: I1e151e08bd7143e47db005bc3fe9795076398df7
2012-08-17 15:25:16 -07:00