Merge "Protect early access before tethering ready" am: 4cd05d9fdc am: ede35e955d am: 0bec442453
Change-Id: I7837cdd4cd18d3925f9198a5864a601df745039c
This commit is contained in:
@@ -17,6 +17,7 @@ package android.net;
|
|||||||
|
|
||||||
import static android.Manifest.permission.NETWORK_STACK;
|
import static android.Manifest.permission.NETWORK_STACK;
|
||||||
import static android.net.ConnectivityManager.TETHER_ERROR_NO_ERROR;
|
import static android.net.ConnectivityManager.TETHER_ERROR_NO_ERROR;
|
||||||
|
import static android.net.ConnectivityManager.TETHER_ERROR_SERVICE_UNAVAIL;
|
||||||
|
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
@@ -175,6 +176,10 @@ public class TetheringManager {
|
|||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public int tether(@NonNull String iface) {
|
public int tether(@NonNull String iface) {
|
||||||
|
if (mConnector == null) {
|
||||||
|
Slog.wtf(TAG, "Tethering not ready yet");
|
||||||
|
return TETHER_ERROR_SERVICE_UNAVAIL;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
mConnector.tether(iface);
|
mConnector.tether(iface);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
@@ -191,6 +196,10 @@ public class TetheringManager {
|
|||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public int untether(@NonNull String iface) {
|
public int untether(@NonNull String iface) {
|
||||||
|
if (mConnector == null) {
|
||||||
|
Slog.wtf(TAG, "Tethering not ready yet");
|
||||||
|
return TETHER_ERROR_SERVICE_UNAVAIL;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
mConnector.untether(iface);
|
mConnector.untether(iface);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
@@ -210,6 +219,10 @@ public class TetheringManager {
|
|||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public int setUsbTethering(boolean enable) {
|
public int setUsbTethering(boolean enable) {
|
||||||
|
if (mConnector == null) {
|
||||||
|
Slog.wtf(TAG, "Tethering not ready yet");
|
||||||
|
return TETHER_ERROR_SERVICE_UNAVAIL;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
mConnector.setUsbTethering(enable);
|
mConnector.setUsbTethering(enable);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
@@ -227,6 +240,10 @@ public class TetheringManager {
|
|||||||
// TODO: improve the usage of ResultReceiver, b/145096122
|
// TODO: improve the usage of ResultReceiver, b/145096122
|
||||||
public void startTethering(int type, @NonNull ResultReceiver receiver,
|
public void startTethering(int type, @NonNull ResultReceiver receiver,
|
||||||
boolean showProvisioningUi) {
|
boolean showProvisioningUi) {
|
||||||
|
if (mConnector == null) {
|
||||||
|
Slog.wtf(TAG, "Tethering not ready yet");
|
||||||
|
return;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
mConnector.startTethering(type, receiver, showProvisioningUi);
|
mConnector.startTethering(type, receiver, showProvisioningUi);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
@@ -241,6 +258,10 @@ public class TetheringManager {
|
|||||||
* {@hide}
|
* {@hide}
|
||||||
*/
|
*/
|
||||||
public void stopTethering(int type) {
|
public void stopTethering(int type) {
|
||||||
|
if (mConnector == null) {
|
||||||
|
Slog.wtf(TAG, "Tethering not ready yet");
|
||||||
|
return;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
mConnector.stopTethering(type);
|
mConnector.stopTethering(type);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
@@ -258,6 +279,10 @@ public class TetheringManager {
|
|||||||
// TODO: improve the usage of ResultReceiver, b/145096122
|
// TODO: improve the usage of ResultReceiver, b/145096122
|
||||||
public void requestLatestTetheringEntitlementResult(int type, @NonNull ResultReceiver receiver,
|
public void requestLatestTetheringEntitlementResult(int type, @NonNull ResultReceiver receiver,
|
||||||
boolean showEntitlementUi) {
|
boolean showEntitlementUi) {
|
||||||
|
if (mConnector == null) {
|
||||||
|
Slog.wtf(TAG, "Tethering not ready yet");
|
||||||
|
return;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
mConnector.requestLatestTetheringEntitlementResult(type, receiver, showEntitlementUi);
|
mConnector.requestLatestTetheringEntitlementResult(type, receiver, showEntitlementUi);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user