summaryrefslogtreecommitdiff
path: root/Tethering/common/TetheringLib/src/android/net/TetheringManager.java
diff options
context:
space:
mode:
authorAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-03-03 12:51:02 +0000
committerMark Chien <markchien@google.com>2020-03-09 02:42:28 +0000
commit1adfc1cbf10dc841a0909d8f9e5f54f1f51c3bbc (patch)
tree01fd99d64ff68af83291ea9f79c7e6e2e19b2acf /Tethering/common/TetheringLib/src/android/net/TetheringManager.java
parent1131b744f0df3c4bb292612e3653e3d1b28579d0 (diff)
Tethering: add isTetheringSupported with callerPkg parameter
BT tethering need to know whether tethering is supported for its caller that call isTetheringSupported in binder thread under BT's process. Current isTetheringSupported API is getting callerPkg inside TetheringManager that would be BT's package name for bt tethering case. Provide isTetheringSupported(String callerPkg) for caller to pass its caller's package name if the use case is under binder IPC. Bug: 146915889 Test: -boot, flash, boot Change-Id: I01646fe045772c57b4e39a5e129531f8a2cea89f Merged-In: I01646fe045772c57b4e39a5e129531f8a2cea89f Merged-In: I2a35e1b6851e7a799c343be0dd60da23514768ba (cherry picked from commit e09a92fabe7956692f34e94c198d9763bf76e53d)
Diffstat (limited to 'Tethering/common/TetheringLib/src/android/net/TetheringManager.java')
-rw-r--r--Tethering/common/TetheringLib/src/android/net/TetheringManager.java19
1 files changed, 19 insertions, 0 deletions
diff --git a/Tethering/common/TetheringLib/src/android/net/TetheringManager.java b/Tethering/common/TetheringLib/src/android/net/TetheringManager.java
index fd9f7137c8..79242c5da3 100644
--- a/Tethering/common/TetheringLib/src/android/net/TetheringManager.java
+++ b/Tethering/common/TetheringLib/src/android/net/TetheringManager.java
@@ -1131,6 +1131,25 @@ public class TetheringManager {
public boolean isTetheringSupported() {
final String callerPkg = mContext.getOpPackageName();
+ return isTetheringSupported(callerPkg);
+ }
+
+ /**
+ * Check if the device allows for tethering. It may be disabled via {@code ro.tether.denied}
+ * system property, Settings.TETHER_SUPPORTED or due to device configuration. This is useful
+ * for system components that query this API on behalf of an app. In particular, Bluetooth
+ * has @UnsupportedAppUsage calls that will let apps turn on bluetooth tethering if they have
+ * the right permissions, but such an app needs to know whether it can (permissions as well
+ * as support from the device) turn on tethering in the first place to show the appropriate UI.
+ *
+ * @param callerPkg The caller package name, if it is not matching the calling uid,
+ * SecurityException would be thrown.
+ * @return a boolean - {@code true} indicating Tethering is supported.
+ * @hide
+ */
+ @SystemApi(client = MODULE_LIBRARIES)
+ public boolean isTetheringSupported(@NonNull final String callerPkg) {
+
final RequestDispatcher dispatcher = new RequestDispatcher();
final int ret = dispatcher.waitForResult((connector, listener) -> {
try {