Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1621)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/omnibox/geo/GeolocationHeader.java

Issue 1626403003: Work around a location-related crash on OnePlus2 devices. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/omnibox/geo/GeolocationHeader.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/omnibox/geo/GeolocationHeader.java b/chrome/android/java/src/org/chromium/chrome/browser/omnibox/geo/GeolocationHeader.java
index 13b0c92e45f939ab3e0237c1b7d10ac15ed7460e..9c05f23e87f16defad71d8203870f0149f20357a 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/omnibox/geo/GeolocationHeader.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/omnibox/geo/GeolocationHeader.java
@@ -9,6 +9,7 @@ import android.content.Context;
import android.content.pm.PackageManager;
import android.location.Location;
import android.net.Uri;
+import android.os.Build;
import android.os.Process;
import android.util.Base64;
@@ -145,9 +146,23 @@ public class GeolocationHeader {
}
static boolean hasGeolocationPermission(Context context) {
- return context.checkPermission(
- Manifest.permission.ACCESS_COARSE_LOCATION, Process.myPid(), Process.myUid())
- == PackageManager.PERMISSION_GRANTED;
+ int pid = Process.myPid();
+ int uid = Process.myUid();
+ if (context.checkPermission(Manifest.permission.ACCESS_COARSE_LOCATION, pid, uid)
+ != PackageManager.PERMISSION_GRANTED) {
+ return false;
+ }
+
+ // Work around a bug in OnePlus2 devices running Lollipop, where the NETWORK_PROVIDER
+ // incorrectly requires FINE_LOCATION permission (it should only require COARSE_LOCATION
+ // permission). http://crbug.com/580733
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M
+ && context.checkPermission(Manifest.permission.ACCESS_FINE_LOCATION, pid, uid)
+ != PackageManager.PERMISSION_GRANTED) {
+ return false;
+ }
+
+ return true;
}
/**
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698