summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorChalard Jean <jchalard@google.com>2017-09-27 02:12:24 +0000
committerandroid-build-merger <android-build-merger@google.com>2017-09-27 02:12:24 +0000
commit47cfcef09c53b1670a25c145a463ab61d499e3fa (patch)
treec2b802514204bf91c59b4fa8d4a568a2f22217c0 /core/java
parenteb1e7bc82ca1ab6594759deac93b787aec03369a (diff)
parente545f00e101d1306829e7949e02d1002e40ab66b (diff)
Merge "Do not throw on call to isTetheringSupported w/o permission" into oc-mr1-dev
am: e545f00e10 Change-Id: Ib5b17a7f68c1327f47fe1f54c0454c51f4226907
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/net/ConnectivityManager.java18
1 files changed, 16 insertions, 2 deletions
diff --git a/core/java/android/net/ConnectivityManager.java b/core/java/android/net/ConnectivityManager.java
index 744ee8ed0e74..d7ecc81ffdba 100644
--- a/core/java/android/net/ConnectivityManager.java
+++ b/core/java/android/net/ConnectivityManager.java
@@ -2078,16 +2078,30 @@ public class ConnectivityManager {
* {@code ro.tether.denied} system property, Settings.TETHER_SUPPORTED or
* due to device configuration.
*
+ * <p>If this app does not have permission to use this API, it will always
+ * return false rather than throw an exception.</p>
+ *
+ * <p>If the device has a hotspot provisioning app, the caller is required to hold the
+ * {@link android.Manifest.permission.TETHER_PRIVILEGED} permission.</p>
+ *
+ * <p>Otherwise, this method requires the caller to hold the ability to modify system
+ * settings as determined by {@link android.provider.Settings.System#canWrite}.</p>
+ *
* @return a boolean - {@code true} indicating Tethering is supported.
*
* {@hide}
*/
@SystemApi
- @RequiresPermission(android.Manifest.permission.TETHER_PRIVILEGED)
+ @RequiresPermission(anyOf = {android.Manifest.permission.TETHER_PRIVILEGED,
+ android.Manifest.permission.WRITE_SETTINGS})
public boolean isTetheringSupported() {
+ String pkgName = mContext.getOpPackageName();
try {
- String pkgName = mContext.getOpPackageName();
return mService.isTetheringSupported(pkgName);
+ } catch (SecurityException e) {
+ // This API is not available to this caller, but for backward-compatibility
+ // this will just return false instead of throwing.
+ return false;
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}