From 7f7798eb4b720054f40e0f507c0b2824cabbb405 Mon Sep 17 00:00:00 2001 From: Keith Dart Date: Thu, 14 Sep 2017 11:10:06 -0700 Subject: Add a networking snippet module. (#78) Has one method for now, Connectable, that implicitly checks TCP connectivity to a host and port. --- .../mobly/snippet/bundled/NetworkingSnippet.java | 52 ++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 src/main/java/com/google/android/mobly/snippet/bundled/NetworkingSnippet.java (limited to 'src/main/java/com/google/android/mobly/snippet/bundled/NetworkingSnippet.java') 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 new file mode 100644 index 0000000..d72205a --- /dev/null +++ b/src/main/java/com/google/android/mobly/snippet/bundled/NetworkingSnippet.java @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2017 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +package com.google.android.mobly.snippet.bundled; + +import java.net.InetAddress; +import java.net.Socket; +import java.io.IOException; +import java.net.UnknownHostException; +import com.google.android.mobly.snippet.Snippet; +import com.google.android.mobly.snippet.rpc.Rpc; +import com.google.android.mobly.snippet.util.Log; + +/** Snippet class for networking RPCs. */ +public class NetworkingSnippet implements Snippet { + + @Rpc(description = "Check if a host and port are connectable using a TCP connection attempt.") + public boolean networkIsTcpConnectable(String host, int port) { + InetAddress addr; + try { + addr = InetAddress.getByName(host); + } catch (UnknownHostException uherr) { + Log.d("Host name lookup failure: " + uherr.getMessage()); + return false; + } + + try { + Socket sock = new Socket(addr, port); + sock.close(); + } catch (IOException ioerr) { + Log.d("Did not make connection to host: " + ioerr.getMessage()); + return false; + } + return true; + } + + @Override + public void shutdown() {} +} -- cgit v1.2.3 From 2797e51535fd0906326ba8785159d6d2f96f1e7d Mon Sep 17 00:00:00 2001 From: Keith Dart Date: Thu, 28 Sep 2017 17:54:57 -0700 Subject: Add Rpcs needed to download files via HTTP. (#80) * Add an Rpc to perform an HTTP download using DownloadManager. * Add file operation Rpcs. --- .../mobly/snippet/bundled/NetworkingSnippet.java | 87 +++++++++++++++++++++- 1 file changed, 86 insertions(+), 1 deletion(-) (limited to 'src/main/java/com/google/android/mobly/snippet/bundled/NetworkingSnippet.java') 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 d72205a..f175fdd 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 @@ -16,17 +16,47 @@ package com.google.android.mobly.snippet.bundled; +import java.util.List; import java.net.InetAddress; import java.net.Socket; import java.io.IOException; import java.net.UnknownHostException; +import android.content.Intent; +import android.content.Context; +import android.content.IntentFilter; +import android.content.BroadcastReceiver; +import android.net.Uri; +import android.os.Environment; +import android.os.ParcelFileDescriptor; +import android.app.DownloadManager; +import android.support.test.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; import com.google.android.mobly.snippet.util.Log; /** Snippet class for networking RPCs. */ public class NetworkingSnippet implements Snippet { + private final Context mContext; + private final DownloadManager mDownloadManager; + private volatile boolean mIsDownloadComplete = false; + private volatile long mReqid = 0; + + public NetworkingSnippet() { + mContext = InstrumentationRegistry.getContext(); + mDownloadManager = (DownloadManager) mContext.getSystemService(Context.DOWNLOAD_SERVICE); + } + + private static class NetworkingSnippetException extends Exception { + + private static final long serialVersionUID = 8080L; + + public NetworkingSnippetException(String msg) { + super(msg); + } + } + @Rpc(description = "Check if a host and port are connectable using a TCP connection attempt.") public boolean networkIsTcpConnectable(String host, int port) { InetAddress addr; @@ -47,6 +77,61 @@ public class NetworkingSnippet implements Snippet { return true; } + @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.") + public String networkHttpDownload(String url) throws IllegalArgumentException, NetworkingSnippetException { + + Uri uri = Uri.parse(url); + List pathsegments = uri.getPathSegments(); + if (pathsegments.size() < 1) { + 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)); + mIsDownloadComplete = false; + mReqid = 0; + IntentFilter filter = new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE); + BroadcastReceiver receiver = new DownloadReceiver(); + mContext.registerReceiver(receiver, filter); + try { + mReqid = mDownloadManager.enqueue(request); + Log.d(String.format("networkHttpDownload download of %s with id %d", url, mReqid)); + if (!Utils.waitUntil(() -> mIsDownloadComplete, 30)) { + Log.d(String.format("networkHttpDownload timed out waiting for completion")); + throw new NetworkingSnippetException("networkHttpDownload timed out."); + } + } finally { + mContext.unregisterReceiver(receiver); + } + Uri resp = mDownloadManager.getUriForDownloadedFile(mReqid); + if (resp != null) { + Log.d(String.format("networkHttpDownload completed to %s", resp.toString())); + mReqid = 0; + return resp.toString(); + } else { + Log.d(String.format("networkHttpDownload Failed to download %s", uri.toString())); + throw new NetworkingSnippetException("networkHttpDownload didn't get downloaded file."); + } + } + + private class DownloadReceiver extends BroadcastReceiver { + + @Override + 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) { + mIsDownloadComplete = true; + } + } + } + @Override - public void shutdown() {} + public void shutdown() { + if (mReqid != 0) { + mDownloadManager.remove(mReqid); + } + } } -- cgit v1.2.3 From 37402446cd74da1a346469c03e09900d99673b8a Mon Sep 17 00:00:00 2001 From: Keith Dart Date: Mon, 2 Oct 2017 19:49:41 -0700 Subject: Make linter happy. (#81) * Add `presubmit` action to run formatter and lint. --- .../mobly/snippet/bundled/NetworkingSnippet.java | 57 ++++++++++++++-------- 1 file changed, 36 insertions(+), 21 deletions(-) (limited to 'src/main/java/com/google/android/mobly/snippet/bundled/NetworkingSnippet.java') 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 f175fdd..e89fc12 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 @@ -16,24 +16,24 @@ package com.google.android.mobly.snippet.bundled; -import java.util.List; -import java.net.InetAddress; -import java.net.Socket; -import java.io.IOException; -import java.net.UnknownHostException; -import android.content.Intent; +import android.app.DownloadManager; +import android.content.BroadcastReceiver; import android.content.Context; +import android.content.Intent; import android.content.IntentFilter; -import android.content.BroadcastReceiver; import android.net.Uri; import android.os.Environment; -import android.os.ParcelFileDescriptor; -import android.app.DownloadManager; import android.support.test.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; import com.google.android.mobly.snippet.util.Log; +import java.io.IOException; +import java.net.InetAddress; +import java.net.Socket; +import java.net.UnknownHostException; +import java.util.List; +import java.util.Locale; /** Snippet class for networking RPCs. */ public class NetworkingSnippet implements Snippet { @@ -77,18 +77,23 @@ public class NetworkingSnippet implements Snippet { return true; } - @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.") - public String networkHttpDownload(String url) throws IllegalArgumentException, NetworkingSnippetException { + @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." + ) + public String networkHttpDownload(String url) + throws IllegalArgumentException, NetworkingSnippetException { Uri uri = Uri.parse(url); List pathsegments = uri.getPathSegments(); if (pathsegments.size() < 1) { - throw new IllegalArgumentException(String.format("The Uri %s does not have a path.", uri.toString())); + throw new IllegalArgumentException( + String.format(Locale.US, "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); @@ -96,9 +101,16 @@ public class NetworkingSnippet implements Snippet { mContext.registerReceiver(receiver, filter); try { mReqid = mDownloadManager.enqueue(request); - Log.d(String.format("networkHttpDownload download of %s with id %d", url, mReqid)); + Log.d( + String.format( + Locale.US, + "networkHttpDownload download of %s with id %d", + url, + mReqid)); if (!Utils.waitUntil(() -> mIsDownloadComplete, 30)) { - Log.d(String.format("networkHttpDownload timed out waiting for completion")); + Log.d( + String.format( + Locale.US, "networkHttpDownload timed out waiting for completion")); throw new NetworkingSnippetException("networkHttpDownload timed out."); } } finally { @@ -106,11 +118,15 @@ public class NetworkingSnippet implements Snippet { } Uri resp = mDownloadManager.getUriForDownloadedFile(mReqid); if (resp != null) { - Log.d(String.format("networkHttpDownload completed to %s", resp.toString())); + Log.d(String.format(Locale.US, "networkHttpDownload completed to %s", resp.toString())); mReqid = 0; return resp.toString(); } else { - Log.d(String.format("networkHttpDownload Failed to download %s", uri.toString())); + Log.d( + String.format( + Locale.US, + "networkHttpDownload Failed to download %s", + uri.toString())); throw new NetworkingSnippetException("networkHttpDownload didn't get downloaded file."); } } @@ -121,8 +137,7 @@ 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; } } -- cgit v1.2.3 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. --- .../mobly/snippet/bundled/NetworkingSnippet.java | 57 ++++++++-------------- 1 file changed, 21 insertions(+), 36 deletions(-) (limited to 'src/main/java/com/google/android/mobly/snippet/bundled/NetworkingSnippet.java') 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..f175fdd 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 @@ -16,24 +16,24 @@ package com.google.android.mobly.snippet.bundled; -import android.app.DownloadManager; -import android.content.BroadcastReceiver; -import android.content.Context; +import java.util.List; +import java.net.InetAddress; +import java.net.Socket; +import java.io.IOException; +import java.net.UnknownHostException; import android.content.Intent; +import android.content.Context; import android.content.IntentFilter; +import android.content.BroadcastReceiver; import android.net.Uri; import android.os.Environment; +import android.os.ParcelFileDescriptor; +import android.app.DownloadManager; import android.support.test.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; import com.google.android.mobly.snippet.util.Log; -import java.io.IOException; -import java.net.InetAddress; -import java.net.Socket; -import java.net.UnknownHostException; -import java.util.List; -import java.util.Locale; /** Snippet class for networking RPCs. */ public class NetworkingSnippet implements Snippet { @@ -77,23 +77,18 @@ public class NetworkingSnippet implements Snippet { return true; } - @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." - ) - public String networkHttpDownload(String url) - throws IllegalArgumentException, NetworkingSnippetException { + @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.") + public String networkHttpDownload(String url) throws IllegalArgumentException, NetworkingSnippetException { Uri uri = Uri.parse(url); List 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; } } -- cgit v1.2.3 From 1bcd42813b8b60ac030d036bda2bffeeff87cf49 Mon Sep 17 00:00:00 2001 From: Keith Dart Date: Thu, 5 Oct 2017 12:14:42 -0700 Subject: Fix version warnings for gradle builds (#87) * Add a `presubmit` target to run formatter and lint. * Add dev process to README * Gradle config improvements * Changes made by linter --- .../mobly/snippet/bundled/NetworkingSnippet.java | 57 ++++++++++++++-------- 1 file changed, 36 insertions(+), 21 deletions(-) (limited to 'src/main/java/com/google/android/mobly/snippet/bundled/NetworkingSnippet.java') 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 f175fdd..e89fc12 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 @@ -16,24 +16,24 @@ package com.google.android.mobly.snippet.bundled; -import java.util.List; -import java.net.InetAddress; -import java.net.Socket; -import java.io.IOException; -import java.net.UnknownHostException; -import android.content.Intent; +import android.app.DownloadManager; +import android.content.BroadcastReceiver; import android.content.Context; +import android.content.Intent; import android.content.IntentFilter; -import android.content.BroadcastReceiver; import android.net.Uri; import android.os.Environment; -import android.os.ParcelFileDescriptor; -import android.app.DownloadManager; import android.support.test.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; import com.google.android.mobly.snippet.util.Log; +import java.io.IOException; +import java.net.InetAddress; +import java.net.Socket; +import java.net.UnknownHostException; +import java.util.List; +import java.util.Locale; /** Snippet class for networking RPCs. */ public class NetworkingSnippet implements Snippet { @@ -77,18 +77,23 @@ public class NetworkingSnippet implements Snippet { return true; } - @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.") - public String networkHttpDownload(String url) throws IllegalArgumentException, NetworkingSnippetException { + @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." + ) + public String networkHttpDownload(String url) + throws IllegalArgumentException, NetworkingSnippetException { Uri uri = Uri.parse(url); List pathsegments = uri.getPathSegments(); if (pathsegments.size() < 1) { - throw new IllegalArgumentException(String.format("The Uri %s does not have a path.", uri.toString())); + throw new IllegalArgumentException( + String.format(Locale.US, "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); @@ -96,9 +101,16 @@ public class NetworkingSnippet implements Snippet { mContext.registerReceiver(receiver, filter); try { mReqid = mDownloadManager.enqueue(request); - Log.d(String.format("networkHttpDownload download of %s with id %d", url, mReqid)); + Log.d( + String.format( + Locale.US, + "networkHttpDownload download of %s with id %d", + url, + mReqid)); if (!Utils.waitUntil(() -> mIsDownloadComplete, 30)) { - Log.d(String.format("networkHttpDownload timed out waiting for completion")); + Log.d( + String.format( + Locale.US, "networkHttpDownload timed out waiting for completion")); throw new NetworkingSnippetException("networkHttpDownload timed out."); } } finally { @@ -106,11 +118,15 @@ public class NetworkingSnippet implements Snippet { } Uri resp = mDownloadManager.getUriForDownloadedFile(mReqid); if (resp != null) { - Log.d(String.format("networkHttpDownload completed to %s", resp.toString())); + Log.d(String.format(Locale.US, "networkHttpDownload completed to %s", resp.toString())); mReqid = 0; return resp.toString(); } else { - Log.d(String.format("networkHttpDownload Failed to download %s", uri.toString())); + Log.d( + String.format( + Locale.US, + "networkHttpDownload Failed to download %s", + uri.toString())); throw new NetworkingSnippetException("networkHttpDownload didn't get downloaded file."); } } @@ -121,8 +137,7 @@ 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; } } -- cgit v1.2.3 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) --- .../android/mobly/snippet/bundled/NetworkingSnippet.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/main/java/com/google/android/mobly/snippet/bundled/NetworkingSnippet.java') 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 { -- cgit v1.2.3