aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build.gradle22
-rw-r--r--gradle.properties2
-rw-r--r--gradle/wrapper/gradle-wrapper.properties4
-rw-r--r--src/main/AndroidManifest.xml2
-rw-r--r--src/main/java/com/google/android/mobly/snippet/bundled/AccountSnippet.java8
-rw-r--r--src/main/java/com/google/android/mobly/snippet/bundled/AudioSnippet.java44
-rw-r--r--src/main/java/com/google/android/mobly/snippet/bundled/FileSnippet.java4
-rw-r--r--src/main/java/com/google/android/mobly/snippet/bundled/NetworkingSnippet.java11
-rw-r--r--src/main/java/com/google/android/mobly/snippet/bundled/NotificationSnippet.java8
-rw-r--r--src/main/java/com/google/android/mobly/snippet/bundled/SmsSnippet.java4
-rw-r--r--src/main/java/com/google/android/mobly/snippet/bundled/TelephonySnippet.java11
-rw-r--r--src/main/java/com/google/android/mobly/snippet/bundled/WifiManagerSnippet.java60
-rw-r--r--src/main/java/com/google/android/mobly/snippet/bundled/bluetooth/BluetoothAdapterSnippet.java16
-rw-r--r--src/main/java/com/google/android/mobly/snippet/bundled/bluetooth/profiles/BluetoothA2dpSnippet.java11
14 files changed, 98 insertions, 109 deletions
diff --git a/build.gradle b/build.gradle
index efbf5e7..d83033a 100644
--- a/build.gradle
+++ b/build.gradle
@@ -6,14 +6,14 @@ buildscript {
google()
}
dependencies {
- classpath 'com.android.tools.build:gradle:3.1.4'
+ classpath 'com.android.tools.build:gradle:3.2.1'
// NOTE: Do not place your application dependencies here.
}
}
plugins {
- id "com.github.sherter.google-java-format" version "0.6"
+ id "com.github.sherter.google-java-format" version "0.8"
}
repositories {
@@ -32,7 +32,7 @@ allprojects {
}
android {
- compileSdkVersion 24
+ compileSdkVersion 28
defaultConfig {
applicationId "com.google.android.mobly.snippet.bundled"
@@ -54,7 +54,7 @@ android {
warningsAsErrors true
disable 'HardwareIds','MissingApplicationIcon','GoogleAppIndexingWarning','InvalidPackage','OldTargetApi'
}
- buildToolsVersion '27.0.3'
+ buildToolsVersion '28.0.3'
}
// Produces a jar of source files. Needed for compliance reasons.
@@ -74,15 +74,15 @@ artifacts {
}
dependencies {
- implementation 'com.android.support.test:runner:1.0.2'
+ implementation 'androidx.test:runner:1.1.1'
implementation 'com.google.android.mobly:mobly-snippet-lib:1.2.0'
- implementation 'com.google.code.gson:gson:2.8.4'
- implementation 'com.google.guava:guava:24.1.1-android'
- implementation 'com.google.errorprone:error_prone_annotations:2.3.1'
+ implementation 'com.google.code.gson:gson:2.8.5'
+ implementation 'com.google.guava:guava:27.0.1-android'
+ implementation 'com.google.errorprone:error_prone_annotations:2.3.2'
- testImplementation 'com.google.errorprone:error_prone_annotations:2.3.1'
- testImplementation 'com.google.guava:guava:24.1.1-android'
- testImplementation 'com.google.truth:truth:0.40'
+ testImplementation 'com.google.errorprone:error_prone_annotations:2.3.2'
+ testImplementation 'com.google.guava:guava:27.0.1-android'
+ testImplementation 'com.google.truth:truth:0.42'
testImplementation 'junit:junit:4.12'
}
diff --git a/gradle.properties b/gradle.properties
index 320e584..f8cd742 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,2 +1,4 @@
org.gradle.jvmargs=-Xmx1536M
android.enableD8.desugaring=true
+android.useAndroidX=true
+android.enableJetifier=true
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index d5a4fc0..63e095c 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Mon May 21 15:55:23 PDT 2018
+#Thu Jan 10 15:04:39 PST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml
index 3d4537d..3310f4c 100644
--- a/src/main/AndroidManifest.xml
+++ b/src/main/AndroidManifest.xml
@@ -28,7 +28,7 @@
<uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" />
<uses-permission android:name="android.permission.SEND_SMS" />
<application android:allowBackup="false"
- android:name="android.support.multidex.MultiDexApplication">
+ android:name="androidx.multidex.MultiDexApplication">
<meta-data
android:name="mobly-snippets"
android:value="com.google.android.mobly.snippet.bundled.AccountSnippet,
diff --git a/src/main/java/com/google/android/mobly/snippet/bundled/AccountSnippet.java b/src/main/java/com/google/android/mobly/snippet/bundled/AccountSnippet.java
index f8499b4..c7f576b 100644
--- a/src/main/java/com/google/android/mobly/snippet/bundled/AccountSnippet.java
+++ b/src/main/java/com/google/android/mobly/snippet/bundled/AccountSnippet.java
@@ -24,7 +24,7 @@ import android.content.ContentResolver;
import android.content.Context;
import android.content.SyncAdapterType;
import android.os.Bundle;
-import android.support.test.InstrumentationRegistry;
+import androidx.test.platform.app.InstrumentationRegistry;
import com.google.android.mobly.snippet.Snippet;
import com.google.android.mobly.snippet.rpc.Rpc;
import com.google.android.mobly.snippet.util.Log;
@@ -68,7 +68,7 @@ public class AccountSnippet implements Snippet {
private final ReentrantReadWriteLock mLock;
public AccountSnippet() {
- Context context = InstrumentationRegistry.getContext();
+ Context context = InstrumentationRegistry.getInstrumentation().getContext();
mAccountManager = AccountManager.get(context);
mSyncStatusObserverHandles = new LinkedList<>();
mSyncWhitelist = new HashMap<>();
@@ -86,8 +86,8 @@ public class AccountSnippet implements Snippet {
* @param password Password of the account to add.
*/
@Rpc(
- description = "Add a Google (GMail) account to the device, with account data sync disabled."
- )
+ description =
+ "Add a Google (GMail) account to the device, with account data sync disabled.")
public void addAccount(String username, String password)
throws AccountSnippetException, AccountsException, IOException {
// Check for existing account. If we try to re-add an existing account, Android throws an
diff --git a/src/main/java/com/google/android/mobly/snippet/bundled/AudioSnippet.java b/src/main/java/com/google/android/mobly/snippet/bundled/AudioSnippet.java
index e435a72..fbdb5d0 100644
--- a/src/main/java/com/google/android/mobly/snippet/bundled/AudioSnippet.java
+++ b/src/main/java/com/google/android/mobly/snippet/bundled/AudioSnippet.java
@@ -18,7 +18,7 @@ package com.google.android.mobly.snippet.bundled;
import android.content.Context;
import android.media.AudioManager;
-import android.support.test.InstrumentationRegistry;
+import androidx.test.platform.app.InstrumentationRegistry;
import com.google.android.mobly.snippet.Snippet;
import com.google.android.mobly.snippet.rpc.Rpc;
import java.lang.reflect.Method;
@@ -29,7 +29,7 @@ public class AudioSnippet implements Snippet {
private final AudioManager mAudioManager;
public AudioSnippet() {
- Context context = InstrumentationRegistry.getContext();
+ Context context = InstrumentationRegistry.getInstrumentation().getContext();
mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
}
@@ -44,7 +44,7 @@ public class AudioSnippet implements Snippet {
}
@Rpc(description = "Gets the music stream volume.")
- public int getMusicVolume() {
+ public Integer getMusicVolume() {
return mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
}
@@ -54,17 +54,16 @@ public class AudioSnippet implements Snippet {
}
@Rpc(
- description =
- "Sets the music stream volume. The minimum value is 0. Use 'getMusicMaxVolume'"
- + " to determine the maximum."
- )
+ description =
+ "Sets the music stream volume. The minimum value is 0. Use 'getMusicMaxVolume'"
+ + " to determine the maximum.")
public void setMusicVolume(Integer value) {
mAudioManager.setStreamVolume(
AudioManager.STREAM_MUSIC, value, 0 /* flags, 0 = no flags */);
}
@Rpc(description = "Gets the ringer volume.")
- public int getRingVolume() {
+ public Integer getRingVolume() {
return mAudioManager.getStreamVolume(AudioManager.STREAM_RING);
}
@@ -74,16 +73,15 @@ public class AudioSnippet implements Snippet {
}
@Rpc(
- description =
- "Sets the ringer stream volume. The minimum value is 0. Use 'getRingMaxVolume'"
- + " to determine the maximum."
- )
+ description =
+ "Sets the ringer stream volume. The minimum value is 0. Use 'getRingMaxVolume'"
+ + " to determine the maximum.")
public void setRingVolume(Integer value) {
mAudioManager.setStreamVolume(AudioManager.STREAM_RING, value, 0 /* flags, 0 = no flags */);
}
-
+
@Rpc(description = "Gets the voice call volume.")
- public int getVoiceCallVolume() {
+ public Integer getVoiceCallVolume() {
return mAudioManager.getStreamVolume(AudioManager.STREAM_VOICE_CALL);
}
@@ -93,13 +91,12 @@ public class AudioSnippet implements Snippet {
}
@Rpc(
- description =
- "Sets the voice call stream volume. The minimum value is 0. Use"
- + " 'getVoiceCallMaxVolume' to determine the maximum."
- )
+ description =
+ "Sets the voice call stream volume. The minimum value is 0. Use"
+ + " 'getVoiceCallMaxVolume' to determine the maximum.")
public void setVoiceCallVolume(Integer value) {
- mAudioManager.setStreamVolume(AudioManager.STREAM_VOICE_CALL,
- value, 0 /* flags, 0 = no flags */);
+ mAudioManager.setStreamVolume(
+ AudioManager.STREAM_VOICE_CALL, value, 0 /* flags, 0 = no flags */);
}
@Rpc(description = "Silences all audio streams.")
@@ -115,10 +112,9 @@ public class AudioSnippet implements Snippet {
}
@Rpc(
- description =
- "Puts the ringer volume at the lowest setting, but does not set it to "
- + "DO NOT DISTURB; the phone will vibrate when receiving a call."
- )
+ description =
+ "Puts the ringer volume at the lowest setting, but does not set it to "
+ + "DO NOT DISTURB; the phone will vibrate when receiving a call.")
public void muteRing() {
setRingVolume(0);
}
diff --git a/src/main/java/com/google/android/mobly/snippet/bundled/FileSnippet.java b/src/main/java/com/google/android/mobly/snippet/bundled/FileSnippet.java
index f6b6918..a1e9d83 100644
--- a/src/main/java/com/google/android/mobly/snippet/bundled/FileSnippet.java
+++ b/src/main/java/com/google/android/mobly/snippet/bundled/FileSnippet.java
@@ -19,7 +19,7 @@ package com.google.android.mobly.snippet.bundled;
import android.content.Context;
import android.net.Uri;
import android.os.ParcelFileDescriptor;
-import android.support.test.InstrumentationRegistry;
+import androidx.test.platform.app.InstrumentationRegistry;
import com.google.android.mobly.snippet.Snippet;
import com.google.android.mobly.snippet.bundled.utils.Utils;
import com.google.android.mobly.snippet.rpc.Rpc;
@@ -34,7 +34,7 @@ public class FileSnippet implements Snippet {
private final Context mContext;
public FileSnippet() {
- mContext = InstrumentationRegistry.getContext();
+ mContext = InstrumentationRegistry.getInstrumentation().getContext();
}
private static class FileSnippetException extends Exception {
diff --git a/src/main/java/com/google/android/mobly/snippet/bundled/NetworkingSnippet.java b/src/main/java/com/google/android/mobly/snippet/bundled/NetworkingSnippet.java
index e89fc12..636c0fd 100644
--- a/src/main/java/com/google/android/mobly/snippet/bundled/NetworkingSnippet.java
+++ b/src/main/java/com/google/android/mobly/snippet/bundled/NetworkingSnippet.java
@@ -23,7 +23,7 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.net.Uri;
import android.os.Environment;
-import android.support.test.InstrumentationRegistry;
+import androidx.test.platform.app.InstrumentationRegistry;
import com.google.android.mobly.snippet.Snippet;
import com.google.android.mobly.snippet.bundled.utils.Utils;
import com.google.android.mobly.snippet.rpc.Rpc;
@@ -44,7 +44,7 @@ public class NetworkingSnippet implements Snippet {
private volatile long mReqid = 0;
public NetworkingSnippet() {
- mContext = InstrumentationRegistry.getContext();
+ mContext = InstrumentationRegistry.getInstrumentation().getContext();
mDownloadManager = (DownloadManager) mContext.getSystemService(Context.DOWNLOAD_SERVICE);
}
@@ -78,10 +78,9 @@ public class NetworkingSnippet implements Snippet {
}
@Rpc(
- description =
- "Download a file using HTTP. Return content Uri (file remains on device). "
- + "The Uri should be treated as an opaque handle for further operations."
- )
+ description =
+ "Download a file using HTTP. Return content Uri (file remains on device). "
+ + "The Uri should be treated as an opaque handle for further operations.")
public String networkHttpDownload(String url)
throws IllegalArgumentException, NetworkingSnippetException {
diff --git a/src/main/java/com/google/android/mobly/snippet/bundled/NotificationSnippet.java b/src/main/java/com/google/android/mobly/snippet/bundled/NotificationSnippet.java
index a07b231..1c34264 100644
--- a/src/main/java/com/google/android/mobly/snippet/bundled/NotificationSnippet.java
+++ b/src/main/java/com/google/android/mobly/snippet/bundled/NotificationSnippet.java
@@ -16,8 +16,8 @@
package com.google.android.mobly.snippet.bundled;
-import android.support.test.InstrumentationRegistry;
import android.widget.Toast;
+import androidx.test.platform.app.InstrumentationRegistry;
import com.google.android.mobly.snippet.Snippet;
import com.google.android.mobly.snippet.rpc.Rpc;
import com.google.android.mobly.snippet.rpc.RunOnUiThread;
@@ -28,7 +28,11 @@ public class NotificationSnippet implements Snippet {
@RunOnUiThread
@Rpc(description = "Make a toast on screen.")
public void makeToast(String message) {
- Toast.makeText(InstrumentationRegistry.getContext(), message, Toast.LENGTH_LONG).show();
+ Toast.makeText(
+ InstrumentationRegistry.getInstrumentation().getContext(),
+ message,
+ Toast.LENGTH_LONG)
+ .show();
}
@Override
diff --git a/src/main/java/com/google/android/mobly/snippet/bundled/SmsSnippet.java b/src/main/java/com/google/android/mobly/snippet/bundled/SmsSnippet.java
index ec6d470..be41e9e 100644
--- a/src/main/java/com/google/android/mobly/snippet/bundled/SmsSnippet.java
+++ b/src/main/java/com/google/android/mobly/snippet/bundled/SmsSnippet.java
@@ -26,9 +26,9 @@ import android.content.IntentFilter;
import android.os.Build;
import android.os.Bundle;
import android.provider.Telephony.Sms.Intents;
-import android.support.test.InstrumentationRegistry;
import android.telephony.SmsManager;
import android.telephony.SmsMessage;
+import androidx.test.platform.app.InstrumentationRegistry;
import com.google.android.mobly.snippet.Snippet;
import com.google.android.mobly.snippet.bundled.utils.Utils;
import com.google.android.mobly.snippet.event.EventCache;
@@ -62,7 +62,7 @@ public class SmsSnippet implements Snippet {
private final SmsManager mSmsManager;
public SmsSnippet() {
- this.mContext = InstrumentationRegistry.getContext();
+ this.mContext = InstrumentationRegistry.getInstrumentation().getContext();
this.mSmsManager = SmsManager.getDefault();
}
diff --git a/src/main/java/com/google/android/mobly/snippet/bundled/TelephonySnippet.java b/src/main/java/com/google/android/mobly/snippet/bundled/TelephonySnippet.java
index 431456d..fbb3041 100644
--- a/src/main/java/com/google/android/mobly/snippet/bundled/TelephonySnippet.java
+++ b/src/main/java/com/google/android/mobly/snippet/bundled/TelephonySnippet.java
@@ -17,8 +17,8 @@
package com.google.android.mobly.snippet.bundled;
import android.content.Context;
-import android.support.test.InstrumentationRegistry;
import android.telephony.TelephonyManager;
+import androidx.test.platform.app.InstrumentationRegistry;
import com.google.android.mobly.snippet.Snippet;
import com.google.android.mobly.snippet.rpc.Rpc;
@@ -28,7 +28,7 @@ public class TelephonySnippet implements Snippet {
private final TelephonyManager mTelephonyManager;
public TelephonySnippet() {
- Context context = InstrumentationRegistry.getContext();
+ Context context = InstrumentationRegistry.getInstrumentation().getContext();
mTelephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
}
@@ -43,10 +43,9 @@ public class TelephonySnippet implements Snippet {
}
@Rpc(
- description =
- "Gets the call state for the default subscription. Call state values are"
- + "0: IDLE, 1: RINGING, 2: OFFHOOK"
- )
+ description =
+ "Gets the call state for the default subscription. Call state values are"
+ + "0: IDLE, 1: RINGING, 2: OFFHOOK")
public int getTelephonyCallState() {
return mTelephonyManager.getCallState();
}
diff --git a/src/main/java/com/google/android/mobly/snippet/bundled/WifiManagerSnippet.java b/src/main/java/com/google/android/mobly/snippet/bundled/WifiManagerSnippet.java
index 768fb4c..3d96e4d 100644
--- a/src/main/java/com/google/android/mobly/snippet/bundled/WifiManagerSnippet.java
+++ b/src/main/java/com/google/android/mobly/snippet/bundled/WifiManagerSnippet.java
@@ -25,8 +25,8 @@ import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.os.Build;
-import android.support.annotation.Nullable;
-import android.support.test.InstrumentationRegistry;
+import androidx.annotation.Nullable;
+import androidx.test.platform.app.InstrumentationRegistry;
import com.google.android.mobly.snippet.Snippet;
import com.google.android.mobly.snippet.bundled.utils.JsonDeserializer;
import com.google.android.mobly.snippet.bundled.utils.JsonSerializer;
@@ -57,17 +57,16 @@ public class WifiManagerSnippet implements Snippet {
private volatile boolean mIsScanResultAvailable = false;
public WifiManagerSnippet() {
- mContext = InstrumentationRegistry.getContext();
+ mContext = InstrumentationRegistry.getInstrumentation().getContext();
mWifiManager =
(WifiManager)
mContext.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
}
@Rpc(
- description =
- "Clears all configured networks. This will only work if all configured "
- + "networks were added through this MBS instance"
- )
+ description =
+ "Clears all configured networks. This will only work if all configured "
+ + "networks were added through this MBS instance")
public void wifiClearConfiguredNetworks() throws WifiManagerSnippetException {
List<WifiConfiguration> unremovedConfigs = mWifiManager.getConfiguredNetworks();
List<WifiConfiguration> failedConfigs = new ArrayList<>();
@@ -148,9 +147,8 @@ public class WifiManagerSnippet implements Snippet {
}
@Rpc(
- description =
- "Get Wi-Fi scan results, which is a list of serialized WifiScanResult objects."
- )
+ description =
+ "Get Wi-Fi scan results, which is a list of serialized WifiScanResult objects.")
public JSONArray wifiGetCachedScanResults() throws JSONException {
JSONArray results = new JSONArray();
for (ScanResult result : mWifiManager.getScanResults()) {
@@ -160,10 +158,9 @@ public class WifiManagerSnippet implements Snippet {
}
@Rpc(
- description =
- "Start scan, wait for scan to complete, and return results, which is a list of "
- + "serialized WifiScanResult objects."
- )
+ description =
+ "Start scan, wait for scan to complete, and return results, which is a list of "
+ + "serialized WifiScanResult objects.")
public JSONArray wifiScanAndGetResults()
throws InterruptedException, JSONException, WifiManagerSnippetException {
mContext.registerReceiver(
@@ -179,10 +176,9 @@ public class WifiManagerSnippet implements Snippet {
}
@Rpc(
- description =
- "Connects to a Wi-Fi network. This covers the common network types like open and "
- + "WPA2."
- )
+ description =
+ "Connects to a Wi-Fi network. This covers the common network types like open and "
+ + "WPA2.")
public void wifiConnectSimple(String ssid, @Nullable String password)
throws InterruptedException, JSONException, WifiManagerSnippetException {
JSONObject config = new JSONObject();
@@ -277,10 +273,9 @@ public class WifiManagerSnippet implements Snippet {
}
@Rpc(
- description =
- "Forget a configured Wi-Fi network by its network ID, which is part of the"
- + " WifiConfiguration."
- )
+ description =
+ "Forget a configured Wi-Fi network by its network ID, which is part of the"
+ + " WifiConfiguration.")
public void wifiRemoveNetwork(Integer networkId) throws WifiManagerSnippetException {
if (!mWifiManager.removeNetwork(networkId)) {
throw new WifiManagerSnippetException("Failed to remove network of ID: " + networkId);
@@ -288,10 +283,9 @@ public class WifiManagerSnippet implements Snippet {
}
@Rpc(
- description =
- "Get the list of configured Wi-Fi networks, each is a serialized "
- + "WifiConfiguration object."
- )
+ description =
+ "Get the list of configured Wi-Fi networks, each is a serialized "
+ + "WifiConfiguration object.")
public List<JSONObject> wifiGetConfiguredNetworks() throws JSONException {
List<JSONObject> networks = new ArrayList<>();
for (WifiConfiguration config : mWifiManager.getConfiguredNetworks()) {
@@ -307,19 +301,17 @@ public class WifiManagerSnippet implements Snippet {
}
@Rpc(
- description =
- "Get the information about the active Wi-Fi connection, which is a serialized "
- + "WifiInfo object."
- )
+ description =
+ "Get the information about the active Wi-Fi connection, which is a serialized "
+ + "WifiInfo object.")
public JSONObject wifiGetConnectionInfo() throws JSONException {
return mJsonSerializer.toJson(mWifiManager.getConnectionInfo());
}
@Rpc(
- description =
- "Get the info from last successful DHCP request, which is a serialized DhcpInfo "
- + "object."
- )
+ description =
+ "Get the info from last successful DHCP request, which is a serialized DhcpInfo "
+ + "object.")
public JSONObject wifiGetDhcpInfo() throws JSONException {
return mJsonSerializer.toJson(mWifiManager.getDhcpInfo());
}
diff --git a/src/main/java/com/google/android/mobly/snippet/bundled/bluetooth/BluetoothAdapterSnippet.java b/src/main/java/com/google/android/mobly/snippet/bundled/bluetooth/BluetoothAdapterSnippet.java
index 37e7c5f..14393be 100644
--- a/src/main/java/com/google/android/mobly/snippet/bundled/bluetooth/BluetoothAdapterSnippet.java
+++ b/src/main/java/com/google/android/mobly/snippet/bundled/bluetooth/BluetoothAdapterSnippet.java
@@ -23,7 +23,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
-import android.support.test.InstrumentationRegistry;
+import androidx.test.platform.app.InstrumentationRegistry;
import com.google.android.mobly.snippet.Snippet;
import com.google.android.mobly.snippet.bundled.utils.JsonSerializer;
import com.google.android.mobly.snippet.bundled.utils.Utils;
@@ -55,7 +55,7 @@ public class BluetoothAdapterSnippet implements Snippet {
private volatile boolean mIsDiscoveryFinished = false;
public BluetoothAdapterSnippet() {
- mContext = InstrumentationRegistry.getContext();
+ mContext = InstrumentationRegistry.getInstrumentation().getContext();
}
/**
@@ -138,9 +138,8 @@ public class BluetoothAdapterSnippet implements Snippet {
}
@Rpc(
- description =
- "Get bluetooth discovery results, which is a list of serialized BluetoothDevice objects."
- )
+ description =
+ "Get bluetooth discovery results, which is a list of serialized BluetoothDevice objects.")
public ArrayList<Bundle> btGetCachedScanResults() {
return mJsonSerializer.serializeBluetoothDeviceList(mDiscoveryResults.values());
}
@@ -168,10 +167,9 @@ public class BluetoothAdapterSnippet implements Snippet {
}
@Rpc(
- description =
- "Start discovery, wait for discovery to complete, and return results, which is a list of "
- + "serialized BluetoothDevice objects."
- )
+ description =
+ "Start discovery, wait for discovery to complete, and return results, which is a list of "
+ + "serialized BluetoothDevice objects.")
public List<Bundle> btDiscoverAndGetResults()
throws InterruptedException, BluetoothAdapterSnippetException {
IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND);
diff --git a/src/main/java/com/google/android/mobly/snippet/bundled/bluetooth/profiles/BluetoothA2dpSnippet.java b/src/main/java/com/google/android/mobly/snippet/bundled/bluetooth/profiles/BluetoothA2dpSnippet.java
index b218723..ec148ca 100644
--- a/src/main/java/com/google/android/mobly/snippet/bundled/bluetooth/profiles/BluetoothA2dpSnippet.java
+++ b/src/main/java/com/google/android/mobly/snippet/bundled/bluetooth/profiles/BluetoothA2dpSnippet.java
@@ -9,7 +9,7 @@ import android.content.Context;
import android.content.IntentFilter;
import android.os.Build;
import android.os.Bundle;
-import android.support.test.InstrumentationRegistry;
+import androidx.test.platform.app.InstrumentationRegistry;
import com.google.android.mobly.snippet.Snippet;
import com.google.android.mobly.snippet.bundled.bluetooth.BluetoothAdapterSnippet;
import com.google.android.mobly.snippet.bundled.bluetooth.PairingBroadcastReceiver;
@@ -34,7 +34,7 @@ public class BluetoothA2dpSnippet implements Snippet {
private final JsonSerializer mJsonSerializer = new JsonSerializer();
public BluetoothA2dpSnippet() {
- mContext = InstrumentationRegistry.getContext();
+ mContext = InstrumentationRegistry.getInstrumentation().getContext();
BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
bluetoothAdapter.getProfileProxy(
mContext, new A2dpServiceListener(), BluetoothProfile.A2DP);
@@ -55,10 +55,9 @@ public class BluetoothA2dpSnippet implements Snippet {
@TargetApi(Build.VERSION_CODES.KITKAT)
@RpcMinSdk(Build.VERSION_CODES.KITKAT)
@Rpc(
- description =
- "Connects to a paired or discovered device with A2DP profile."
- + "If a device has been discovered but not paired, this will pair it."
- )
+ description =
+ "Connects to a paired or discovered device with A2DP profile."
+ + "If a device has been discovered but not paired, this will pair it.")
public void btA2dpConnect(String deviceAddress) throws Throwable {
BluetoothDevice device = BluetoothAdapterSnippet.getKnownDeviceByAddress(deviceAddress);
IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_PAIRING_REQUEST);