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

Side by Side Diff: device/bluetooth/android/java/src/org/chromium/device/bluetooth/Wrappers.java

Issue 2038753004: Add a LocationUtils class to give all Chromium Android code access to location helpers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkcr
Patch Set: Adjust DEPS. Created 4 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.device.bluetooth; 5 package org.chromium.device.bluetooth;
6 6
7 import android.Manifest; 7 import android.Manifest;
8 import android.annotation.TargetApi; 8 import android.annotation.TargetApi;
9 import android.bluetooth.BluetoothAdapter; 9 import android.bluetooth.BluetoothAdapter;
10 import android.bluetooth.BluetoothDevice; 10 import android.bluetooth.BluetoothDevice;
11 import android.bluetooth.BluetoothGatt; 11 import android.bluetooth.BluetoothGatt;
12 import android.bluetooth.BluetoothGattCallback; 12 import android.bluetooth.BluetoothGattCallback;
13 import android.bluetooth.BluetoothGattCharacteristic; 13 import android.bluetooth.BluetoothGattCharacteristic;
14 import android.bluetooth.BluetoothGattDescriptor; 14 import android.bluetooth.BluetoothGattDescriptor;
15 import android.bluetooth.BluetoothGattService; 15 import android.bluetooth.BluetoothGattService;
16 import android.bluetooth.le.BluetoothLeScanner; 16 import android.bluetooth.le.BluetoothLeScanner;
17 import android.bluetooth.le.ScanCallback; 17 import android.bluetooth.le.ScanCallback;
18 import android.bluetooth.le.ScanFilter; 18 import android.bluetooth.le.ScanFilter;
19 import android.bluetooth.le.ScanResult; 19 import android.bluetooth.le.ScanResult;
20 import android.bluetooth.le.ScanSettings; 20 import android.bluetooth.le.ScanSettings;
21 import android.content.BroadcastReceiver; 21 import android.content.BroadcastReceiver;
22 import android.content.Context; 22 import android.content.Context;
23 import android.content.Intent; 23 import android.content.Intent;
24 import android.content.IntentFilter; 24 import android.content.IntentFilter;
25 import android.content.pm.PackageManager; 25 import android.content.pm.PackageManager;
26 import android.os.Build; 26 import android.os.Build;
27 import android.os.ParcelUuid; 27 import android.os.ParcelUuid;
28 import android.os.Process;
29 28
30 import org.chromium.base.Log; 29 import org.chromium.base.Log;
31 import org.chromium.base.annotations.CalledByNative; 30 import org.chromium.base.annotations.CalledByNative;
32 import org.chromium.base.annotations.JNINamespace; 31 import org.chromium.base.annotations.JNINamespace;
32 import org.chromium.components.location.LocationUtils;
33 33
34 import java.util.ArrayList; 34 import java.util.ArrayList;
35 import java.util.HashMap; 35 import java.util.HashMap;
36 import java.util.List; 36 import java.util.List;
37 import java.util.UUID; 37 import java.util.UUID;
38 38
39 /** 39 /**
40 * Wrapper classes around android.bluetooth.* classes that provide an 40 * Wrapper classes around android.bluetooth.* classes that provide an
41 * indirection layer enabling fake implementations when running tests. 41 * indirection layer enabling fake implementations when running tests.
42 * 42 *
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 /** 155 /**
156 * Wraps android.content.Context. 156 * Wraps android.content.Context.
157 */ 157 */
158 static class ContextWrapper { 158 static class ContextWrapper {
159 private final Context mContext; 159 private final Context mContext;
160 160
161 public ContextWrapper(Context context) { 161 public ContextWrapper(Context context) {
162 mContext = context; 162 mContext = context;
163 } 163 }
164 164
165 public boolean checkPermission(String permission) { 165 public boolean hasAndroidLocationPermission() {
scheib 2016/06/22 19:36:50 The wrappers were designed to be the thinnest prac
ortuno 2016/06/27 21:05:53 Follow up patch here: http://crrev.com/2100313003
166 return mContext.checkPermission(permission, Process.myPid(), Process .myUid()) 166 return LocationUtils.getInstance().hasAndroidLocationPermission(mCon text);
167 == PackageManager.PERMISSION_GRANTED;
168 } 167 }
169 168
170 public Intent registerReceiver(BroadcastReceiver receiver, IntentFilter filter) { 169 public Intent registerReceiver(BroadcastReceiver receiver, IntentFilter filter) {
171 return mContext.registerReceiver(receiver, filter); 170 return mContext.registerReceiver(receiver, filter);
172 } 171 }
173 172
174 public void unregisterReceiver(BroadcastReceiver receiver) { 173 public void unregisterReceiver(BroadcastReceiver receiver) {
175 mContext.unregisterReceiver(receiver); 174 mContext.unregisterReceiver(receiver);
176 } 175 }
177 } 176 }
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 579
581 public byte[] getValue() { 580 public byte[] getValue() {
582 return mDescriptor.getValue(); 581 return mDescriptor.getValue();
583 } 582 }
584 583
585 public boolean setValue(byte[] value) { 584 public boolean setValue(byte[] value) {
586 return mDescriptor.setValue(value); 585 return mDescriptor.setValue(value);
587 } 586 }
588 } 587 }
589 } 588 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698