From 35e1bfad098f65db344d4d6fd7abb5830d8aa7a2 Mon Sep 17 00:00:00 2001 From: Ang Li Date: Fri, 11 Jan 2019 12:51:57 -0800 Subject: Migrate to androidx packages (#105) --- src/main/AndroidManifest.xml | 2 +- .../mobly/snippet/bundled/AccountSnippet.java | 8 +-- .../mobly/snippet/bundled/AudioSnippet.java | 44 ++++++++-------- .../android/mobly/snippet/bundled/FileSnippet.java | 4 +- .../mobly/snippet/bundled/NetworkingSnippet.java | 11 ++-- .../mobly/snippet/bundled/NotificationSnippet.java | 8 ++- .../android/mobly/snippet/bundled/SmsSnippet.java | 4 +- .../mobly/snippet/bundled/TelephonySnippet.java | 11 ++-- .../mobly/snippet/bundled/WifiManagerSnippet.java | 60 ++++++++++------------ .../bundled/bluetooth/BluetoothAdapterSnippet.java | 16 +++--- .../bluetooth/profiles/BluetoothA2dpSnippet.java | 11 ++-- 11 files changed, 83 insertions(+), 96 deletions(-) (limited to 'src/main') 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 @@ + android:name="androidx.multidex.MultiDexApplication"> unremovedConfigs = mWifiManager.getConfiguredNetworks(); List 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 wifiGetConfiguredNetworks() throws JSONException { List 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 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 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); -- cgit v1.2.3