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

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

Issue 2847523002: Android: Remove GetApplicationContext part 4 (Closed)
Patch Set: Rebase and fix build Created 3 years, 7 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.annotation.TargetApi; 7 import android.annotation.TargetApi;
8 import android.bluetooth.BluetoothDevice; 8 import android.bluetooth.BluetoothDevice;
9 import android.content.Context;
10 import android.os.Build; 9 import android.os.Build;
11 10
11 import org.chromium.base.ContextUtils;
12 import org.chromium.base.Log; 12 import org.chromium.base.Log;
13 import org.chromium.base.annotations.CalledByNative; 13 import org.chromium.base.annotations.CalledByNative;
14 import org.chromium.base.annotations.JNINamespace; 14 import org.chromium.base.annotations.JNINamespace;
15 import org.chromium.base.metrics.RecordHistogram; 15 import org.chromium.base.metrics.RecordHistogram;
16 16
17 import java.util.HashMap; 17 import java.util.HashMap;
18 18
19 /** 19 /**
20 * Exposes android.bluetooth.BluetoothDevice as necessary for C++ 20 * Exposes android.bluetooth.BluetoothDevice as necessary for C++
21 * device::BluetoothDeviceAndroid. 21 * device::BluetoothDeviceAndroid.
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 } 93 }
94 94
95 // Implements BluetoothDeviceAndroid::IsPaired. 95 // Implements BluetoothDeviceAndroid::IsPaired.
96 @CalledByNative 96 @CalledByNative
97 private boolean isPaired() { 97 private boolean isPaired() {
98 return mDevice.getBondState() == BluetoothDevice.BOND_BONDED; 98 return mDevice.getBondState() == BluetoothDevice.BOND_BONDED;
99 } 99 }
100 100
101 // Implements BluetoothDeviceAndroid::CreateGattConnectionImpl. 101 // Implements BluetoothDeviceAndroid::CreateGattConnectionImpl.
102 @CalledByNative 102 @CalledByNative
103 private void createGattConnectionImpl(Context context) { 103 private void createGattConnectionImpl() {
104 Log.i(TAG, "connectGatt"); 104 Log.i(TAG, "connectGatt");
105 105
106 if (mBluetoothGatt != null) mBluetoothGatt.close(); 106 if (mBluetoothGatt != null) mBluetoothGatt.close();
107 107
108 // autoConnect set to false as under experimentation using autoConnect f ailed to complete 108 // autoConnect set to false as under experimentation using autoConnect f ailed to complete
109 // connections. 109 // connections.
110 mBluetoothGatt = 110 mBluetoothGatt = mDevice.connectGatt(ContextUtils.getApplicationContext( ),
111 mDevice.connectGatt(context, false /* autoConnect */, mBluetooth GattCallbackImpl, 111 false /* autoConnect */, mBluetoothGattCallbackImpl,
112 // Prefer LE for dual-mode devices due to lower energy c onsumption. 112 // Prefer LE for dual-mode devices due to lower energy consumpti on.
113 BluetoothDevice.TRANSPORT_LE); 113 BluetoothDevice.TRANSPORT_LE);
114 } 114 }
115 115
116 // Implements BluetoothDeviceAndroid::DisconnectGatt. 116 // Implements BluetoothDeviceAndroid::DisconnectGatt.
117 @CalledByNative 117 @CalledByNative
118 private void disconnectGatt() { 118 private void disconnectGatt() {
119 Log.i(TAG, "BluetoothGatt.disconnect"); 119 Log.i(TAG, "BluetoothGatt.disconnect");
120 if (mBluetoothGatt != null) mBluetoothGatt.disconnect(); 120 if (mBluetoothGatt != null) mBluetoothGatt.disconnect();
121 } 121 }
122 122
123 // Implements callbacks related to a GATT connection. 123 // Implements callbacks related to a GATT connection.
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 long nativeBluetoothDeviceAndroid, int status, boolean connected); 313 long nativeBluetoothDeviceAndroid, int status, boolean connected);
314 314
315 // Binds to BluetoothDeviceAndroid::CreateGattRemoteService. 315 // Binds to BluetoothDeviceAndroid::CreateGattRemoteService.
316 // TODO(http://crbug.com/505554): Replace 'Object' with specific type when J NI fixed. 316 // TODO(http://crbug.com/505554): Replace 'Object' with specific type when J NI fixed.
317 private native void nativeCreateGattRemoteService(long nativeBluetoothDevice Android, 317 private native void nativeCreateGattRemoteService(long nativeBluetoothDevice Android,
318 String instanceId, Object bluetoothGattServiceWrapper); 318 String instanceId, Object bluetoothGattServiceWrapper);
319 319
320 // Binds to BluetoothDeviceAndroid::GattServicesDiscovered. 320 // Binds to BluetoothDeviceAndroid::GattServicesDiscovered.
321 private native void nativeOnGattServicesDiscovered(long nativeBluetoothDevic eAndroid); 321 private native void nativeOnGattServicesDiscovered(long nativeBluetoothDevic eAndroid);
322 } 322 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698