From 212c2df7eb4a4938069be9061c88170b160058e8 Mon Sep 17 00:00:00 2001 From: Ang Li Date: Wed, 4 Oct 2017 13:43:36 -0700 Subject: Revert "Make linter happy. (#81)" (#85) This reverts commit 37402446cd74da1a346469c03e09900d99673b8a. --- src/main/AndroidManifest.xml | 4 +- .../mobly/snippet/bundled/AccountSnippet.java | 2 - .../android/mobly/snippet/bundled/FileSnippet.java | 13 +++-- .../mobly/snippet/bundled/NetworkingSnippet.java | 57 ++++++++-------------- .../mobly/snippet/bundled/WifiManagerSnippet.java | 8 ++- .../android/mobly/snippet/bundled/utils/Utils.java | 12 +++-- 6 files changed, 38 insertions(+), 58 deletions(-) (limited to 'src') diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml index 0a0dad3..dc5d0af 100644 --- a/src/main/AndroidManifest.xml +++ b/src/main/AndroidManifest.xml @@ -3,8 +3,6 @@ xmlns:android="http://schemas.android.com/apk/res/android" package="com.google.android.mobly.snippet.bundled"> - - @@ -27,7 +25,7 @@ - + pathsegments = uri.getPathSegments(); if (pathsegments.size() < 1) { - throw new IllegalArgumentException( - String.format(Locale.US, "The Uri %s does not have a path.", uri.toString())); + throw new IllegalArgumentException(String.format("The Uri %s does not have a path.", uri.toString())); } DownloadManager.Request request = new DownloadManager.Request(uri); - request.setDestinationInExternalPublicDir( - Environment.DIRECTORY_DOWNLOADS, pathsegments.get(pathsegments.size() - 1)); + request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, + pathsegments.get(pathsegments.size() - 1)); mIsDownloadComplete = false; mReqid = 0; IntentFilter filter = new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE); @@ -101,16 +96,9 @@ public class NetworkingSnippet implements Snippet { mContext.registerReceiver(receiver, filter); try { mReqid = mDownloadManager.enqueue(request); - Log.d( - String.format( - Locale.US, - "networkHttpDownload download of %s with id %d", - url, - mReqid)); + Log.d(String.format("networkHttpDownload download of %s with id %d", url, mReqid)); if (!Utils.waitUntil(() -> mIsDownloadComplete, 30)) { - Log.d( - String.format( - Locale.US, "networkHttpDownload timed out waiting for completion")); + Log.d(String.format("networkHttpDownload timed out waiting for completion")); throw new NetworkingSnippetException("networkHttpDownload timed out."); } } finally { @@ -118,15 +106,11 @@ public class NetworkingSnippet implements Snippet { } Uri resp = mDownloadManager.getUriForDownloadedFile(mReqid); if (resp != null) { - Log.d(String.format(Locale.US, "networkHttpDownload completed to %s", resp.toString())); + Log.d(String.format("networkHttpDownload completed to %s", resp.toString())); mReqid = 0; return resp.toString(); } else { - Log.d( - String.format( - Locale.US, - "networkHttpDownload Failed to download %s", - uri.toString())); + Log.d(String.format("networkHttpDownload Failed to download %s", uri.toString())); throw new NetworkingSnippetException("networkHttpDownload didn't get downloaded file."); } } @@ -137,7 +121,8 @@ public class NetworkingSnippet implements Snippet { public void onReceive(Context context, Intent intent) { String action = intent.getAction(); long gotid = (long) intent.getExtras().get("extra_download_id"); - if (DownloadManager.ACTION_DOWNLOAD_COMPLETE.equals(action) && gotid == mReqid) { + if (DownloadManager.ACTION_DOWNLOAD_COMPLETE.equals(action) + && gotid == mReqid) { mIsDownloadComplete = true; } } 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 83a42f6..6614904 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 @@ -57,9 +57,7 @@ public class WifiManagerSnippet implements Snippet { public WifiManagerSnippet() { mContext = InstrumentationRegistry.getContext(); - mWifiManager = - (WifiManager) - mContext.getApplicationContext().getSystemService(Context.WIFI_SERVICE); + mWifiManager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE); } @Rpc( @@ -198,8 +196,8 @@ public class WifiManagerSnippet implements Snippet { String SSID = wifiConfig.SSID; // Return directly if network is already connected. WifiInfo connectionInfo = mWifiManager.getConnectionInfo(); - if (connectionInfo.getNetworkId() != -1 - && connectionInfo.getSSID().equals(wifiConfig.SSID)) { + if (connectionInfo.getNetworkId() != -1 && connectionInfo.getSSID().equals(wifiConfig.SSID)) + { Log.d("Network " + connectionInfo.getSSID() + " is already connected."); return; } diff --git a/src/main/java/com/google/android/mobly/snippet/bundled/utils/Utils.java b/src/main/java/com/google/android/mobly/snippet/bundled/utils/Utils.java index 376bcb5..e4c0dbd 100644 --- a/src/main/java/com/google/android/mobly/snippet/bundled/utils/Utils.java +++ b/src/main/java/com/google/android/mobly/snippet/bundled/utils/Utils.java @@ -30,7 +30,7 @@ import java.util.concurrent.TimeoutException; public final class Utils { - private static final char[] hexArray = "0123456789abcdef".toCharArray(); + private final static char[] hexArray = "0123456789abcdef".toCharArray(); private Utils() {} @@ -194,20 +194,22 @@ public final class Utils { } /** - * Convert a byte array (binary data) to a hexadecimal string (ASCII) representation. - * - *

[\x01\x02] -> "0102" + * Convert a byte array (binary data) to a hexadecimal string (ASCII) + * representation. + + * [\x01\x02] -> "0102" * * @param bytes The array of byte to convert. * @return a String with the ASCII hex representation. */ public static String bytesToHexString(byte[] bytes) { char[] hexChars = new char[bytes.length * 2]; - for (int j = 0; j < bytes.length; j++) { + for ( int j = 0; j < bytes.length; j++ ) { int v = bytes[j] & 0xFF; hexChars[j * 2] = hexArray[v >>> 4]; hexChars[j * 2 + 1] = hexArray[v & 0x0F]; } return new String(hexChars); } + } -- cgit v1.2.3