Merge "Fix TetheringEntitlementValueListener related API"
This commit is contained in:
@@ -304,11 +304,17 @@ package android.media.tv {
|
||||
package android.net {
|
||||
|
||||
public class ConnectivityManager {
|
||||
method @Deprecated public void getLatestTetheringEntitlementValue(int, boolean, @NonNull android.net.ConnectivityManager.TetheringEntitlementValueListener, @Nullable android.os.Handler);
|
||||
method @Deprecated public boolean requestRouteToHost(int, int);
|
||||
method @Deprecated public int startUsingNetworkFeature(int, String);
|
||||
method @Deprecated public int stopUsingNetworkFeature(int, String);
|
||||
}
|
||||
|
||||
@Deprecated public abstract static class ConnectivityManager.TetheringEntitlementValueListener {
|
||||
ctor public ConnectivityManager.TetheringEntitlementValueListener();
|
||||
method public void onEntitlementResult(int);
|
||||
}
|
||||
|
||||
@Deprecated public class NetworkBadging {
|
||||
method @NonNull public static android.graphics.drawable.Drawable getWifiIcon(@IntRange(from=0, to=4) int, int, @Nullable android.content.res.Resources.Theme);
|
||||
field public static final int BADGING_4K = 30; // 0x1e
|
||||
|
||||
@@ -3098,7 +3098,7 @@ package android.net {
|
||||
method @RequiresPermission(android.Manifest.permission.PACKET_KEEPALIVE_OFFLOAD) public android.net.SocketKeepalive createSocketKeepalive(@NonNull android.net.Network, @NonNull java.net.Socket, @NonNull java.util.concurrent.Executor, @NonNull android.net.SocketKeepalive.Callback);
|
||||
method public boolean getAvoidBadWifi();
|
||||
method @RequiresPermission(android.Manifest.permission.LOCAL_MAC_ADDRESS) public String getCaptivePortalServerUrl();
|
||||
method @RequiresPermission(android.Manifest.permission.TETHER_PRIVILEGED) public void getLatestTetheringEntitlementValue(int, boolean, @NonNull android.net.ConnectivityManager.TetheringEntitlementValueListener, @Nullable android.os.Handler);
|
||||
method @RequiresPermission(android.Manifest.permission.TETHER_PRIVILEGED) public void getLatestTetheringEntitlementResult(int, boolean, @NonNull java.util.concurrent.Executor, @NonNull android.net.ConnectivityManager.OnTetheringEntitlementResultListener);
|
||||
method @RequiresPermission(anyOf={android.Manifest.permission.TETHER_PRIVILEGED, android.Manifest.permission.WRITE_SETTINGS}) public boolean isTetheringSupported();
|
||||
method @RequiresPermission(anyOf={"android.permission.NETWORK_SETTINGS", android.Manifest.permission.NETWORK_SETUP_WIZARD, "android.permission.NETWORK_STACK"}) public void setAirplaneMode(boolean);
|
||||
method @RequiresPermission(android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK) public void startCaptivePortalApp(android.net.Network, android.os.Bundle);
|
||||
@@ -3121,8 +3121,7 @@ package android.net {
|
||||
method public void onTetheringStarted();
|
||||
}
|
||||
|
||||
public abstract static class ConnectivityManager.TetheringEntitlementValueListener {
|
||||
ctor public ConnectivityManager.TetheringEntitlementValueListener();
|
||||
public static interface ConnectivityManager.OnTetheringEntitlementResultListener {
|
||||
method public void onEntitlementResult(int);
|
||||
}
|
||||
|
||||
|
||||
@@ -2681,12 +2681,39 @@ public class ConnectivityManager {
|
||||
}
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@IntDef(value = {
|
||||
TETHER_ERROR_NO_ERROR,
|
||||
TETHER_ERROR_PROVISION_FAILED,
|
||||
TETHER_ERROR_ENTITLEMENT_UNKONWN,
|
||||
})
|
||||
public @interface EntitlementResultCode {
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback for use with {@link #getLatestTetheringEntitlementValue} to find out whether
|
||||
* Callback for use with {@link #getLatestTetheringEntitlementResult} to find out whether
|
||||
* entitlement succeeded.
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
public interface OnTetheringEntitlementResultListener {
|
||||
/**
|
||||
* Called to notify entitlement result.
|
||||
*
|
||||
* @param resultCode an int value of entitlement result. It may be one of
|
||||
* {@link #TETHER_ERROR_NO_ERROR},
|
||||
* {@link #TETHER_ERROR_PROVISION_FAILED}, or
|
||||
* {@link #TETHER_ERROR_ENTITLEMENT_UNKONWN}.
|
||||
*/
|
||||
void onEntitlementResult(@EntitlementResultCode int resultCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @removed
|
||||
* @deprecated This API would be removed when all of caller has been updated.
|
||||
* */
|
||||
@Deprecated
|
||||
public abstract static class TetheringEntitlementValueListener {
|
||||
/**
|
||||
* Called to notify entitlement result.
|
||||
@@ -2712,14 +2739,43 @@ public class ConnectivityManager {
|
||||
* {@link #TETHERING_USB}, or
|
||||
* {@link #TETHERING_BLUETOOTH}.
|
||||
* @param showEntitlementUi a boolean indicating whether to run UI-based entitlement check.
|
||||
* @param listener an {@link TetheringEntitlementValueListener} which will be called to notify
|
||||
* the caller of the result of entitlement check. The listener may be called zero or
|
||||
* one time.
|
||||
* @param handler {@link Handler} to specify the thread upon which the listener will be invoked.
|
||||
* @param executor the executor on which callback will be invoked.
|
||||
* @param listener an {@link OnTetheringEntitlementResultListener} which will be called to
|
||||
* notify the caller of the result of entitlement check. The listener may be called zero
|
||||
* or one time.
|
||||
* {@hide}
|
||||
*/
|
||||
@SystemApi
|
||||
@RequiresPermission(android.Manifest.permission.TETHER_PRIVILEGED)
|
||||
public void getLatestTetheringEntitlementResult(int type, boolean showEntitlementUi,
|
||||
@NonNull @CallbackExecutor Executor executor,
|
||||
@NonNull final OnTetheringEntitlementResultListener listener) {
|
||||
Preconditions.checkNotNull(listener, "TetheringEntitlementResultListener cannot be null.");
|
||||
ResultReceiver wrappedListener = new ResultReceiver(null) {
|
||||
@Override
|
||||
protected void onReceiveResult(int resultCode, Bundle resultData) {
|
||||
Binder.withCleanCallingIdentity(() ->
|
||||
executor.execute(() -> {
|
||||
listener.onEntitlementResult(resultCode);
|
||||
}));
|
||||
}
|
||||
};
|
||||
|
||||
try {
|
||||
String pkgName = mContext.getOpPackageName();
|
||||
Log.i(TAG, "getLatestTetheringEntitlementResult:" + pkgName);
|
||||
mService.getLatestTetheringEntitlementResult(type, wrappedListener,
|
||||
showEntitlementUi, pkgName);
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @removed
|
||||
* @deprecated This API would be removed when all of caller has been updated.
|
||||
* */
|
||||
@Deprecated
|
||||
public void getLatestTetheringEntitlementValue(int type, boolean showEntitlementUi,
|
||||
@NonNull final TetheringEntitlementValueListener listener, @Nullable Handler handler) {
|
||||
Preconditions.checkNotNull(listener, "TetheringEntitlementValueListener cannot be null.");
|
||||
@@ -2733,7 +2789,7 @@ public class ConnectivityManager {
|
||||
try {
|
||||
String pkgName = mContext.getOpPackageName();
|
||||
Log.i(TAG, "getLatestTetheringEntitlementValue:" + pkgName);
|
||||
mService.getLatestTetheringEntitlementValue(type, wrappedListener,
|
||||
mService.getLatestTetheringEntitlementResult(type, wrappedListener,
|
||||
showEntitlementUi, pkgName);
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
|
||||
@@ -212,6 +212,6 @@ interface IConnectivityManager
|
||||
boolean isCallerCurrentAlwaysOnVpnApp();
|
||||
boolean isCallerCurrentAlwaysOnVpnLockdownApp();
|
||||
|
||||
void getLatestTetheringEntitlementValue(int type, in ResultReceiver receiver,
|
||||
void getLatestTetheringEntitlementResult(int type, in ResultReceiver receiver,
|
||||
boolean showEntitlementUi, String callerPkg);
|
||||
}
|
||||
|
||||
@@ -3758,10 +3758,10 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
* if it's really needed.
|
||||
*/
|
||||
@Override
|
||||
public void getLatestTetheringEntitlementValue(int type, ResultReceiver receiver,
|
||||
public void getLatestTetheringEntitlementResult(int type, ResultReceiver receiver,
|
||||
boolean showEntitlementUi, String callerPkg) {
|
||||
ConnectivityManager.enforceTetherChangePermission(mContext, callerPkg);
|
||||
mTethering.getLatestTetheringEntitlementValue(type, receiver, showEntitlementUi);
|
||||
mTethering.getLatestTetheringEntitlementResult(type, receiver, showEntitlementUi);
|
||||
}
|
||||
|
||||
// Called when we lose the default network and have no replacement yet.
|
||||
|
||||
@@ -1677,10 +1677,10 @@ public class Tethering extends BaseNetworkObserver {
|
||||
}
|
||||
|
||||
/** Get the latest value of the tethering entitlement check. */
|
||||
public void getLatestTetheringEntitlementValue(int type, ResultReceiver receiver,
|
||||
public void getLatestTetheringEntitlementResult(int type, ResultReceiver receiver,
|
||||
boolean showEntitlementUi) {
|
||||
if (receiver != null) {
|
||||
mEntitlementMgr.getLatestTetheringEntitlementValue(type, receiver, showEntitlementUi);
|
||||
mEntitlementMgr.getLatestTetheringEntitlementResult(type, receiver, showEntitlementUi);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -291,7 +291,7 @@ public class EntitlementManager {
|
||||
}
|
||||
|
||||
/** Get the last value of the tethering entitlement check. */
|
||||
public void getLatestTetheringEntitlementValue(int downstream, ResultReceiver receiver,
|
||||
public void getLatestTetheringEntitlementResult(int downstream, ResultReceiver receiver,
|
||||
boolean showEntitlementUi) {
|
||||
if (!isTetherProvisioningRequired()) {
|
||||
receiver.send(TETHER_ERROR_NO_ERROR, null);
|
||||
|
||||
@@ -226,7 +226,7 @@ public final class EntitlementManagerTest {
|
||||
mCallbacklatch.countDown();
|
||||
}
|
||||
};
|
||||
mEnMgr.getLatestTetheringEntitlementValue(TETHERING_WIFI, receiver, true);
|
||||
mEnMgr.getLatestTetheringEntitlementResult(TETHERING_WIFI, receiver, true);
|
||||
callbackTimeoutHelper(mCallbacklatch);
|
||||
assertFalse(mEnMgr.everRunUiEntitlement);
|
||||
|
||||
@@ -242,7 +242,7 @@ public final class EntitlementManagerTest {
|
||||
mCallbacklatch.countDown();
|
||||
}
|
||||
};
|
||||
mEnMgr.getLatestTetheringEntitlementValue(TETHERING_WIFI, receiver, false);
|
||||
mEnMgr.getLatestTetheringEntitlementResult(TETHERING_WIFI, receiver, false);
|
||||
callbackTimeoutHelper(mCallbacklatch);
|
||||
assertFalse(mEnMgr.everRunUiEntitlement);
|
||||
// 3. No cache value and ui entitlement check is needed.
|
||||
@@ -255,7 +255,7 @@ public final class EntitlementManagerTest {
|
||||
mCallbacklatch.countDown();
|
||||
}
|
||||
};
|
||||
mEnMgr.getLatestTetheringEntitlementValue(TETHERING_WIFI, receiver, true);
|
||||
mEnMgr.getLatestTetheringEntitlementResult(TETHERING_WIFI, receiver, true);
|
||||
mLooper.dispatchAll();
|
||||
callbackTimeoutHelper(mCallbacklatch);
|
||||
assertTrue(mEnMgr.everRunUiEntitlement);
|
||||
@@ -269,7 +269,7 @@ public final class EntitlementManagerTest {
|
||||
mCallbacklatch.countDown();
|
||||
}
|
||||
};
|
||||
mEnMgr.getLatestTetheringEntitlementValue(TETHERING_WIFI, receiver, false);
|
||||
mEnMgr.getLatestTetheringEntitlementResult(TETHERING_WIFI, receiver, false);
|
||||
callbackTimeoutHelper(mCallbacklatch);
|
||||
assertFalse(mEnMgr.everRunUiEntitlement);
|
||||
// 5. Cache value is TETHER_ERROR_PROVISION_FAILED and ui entitlement check is needed.
|
||||
@@ -282,7 +282,7 @@ public final class EntitlementManagerTest {
|
||||
mCallbacklatch.countDown();
|
||||
}
|
||||
};
|
||||
mEnMgr.getLatestTetheringEntitlementValue(TETHERING_WIFI, receiver, true);
|
||||
mEnMgr.getLatestTetheringEntitlementResult(TETHERING_WIFI, receiver, true);
|
||||
mLooper.dispatchAll();
|
||||
callbackTimeoutHelper(mCallbacklatch);
|
||||
assertTrue(mEnMgr.everRunUiEntitlement);
|
||||
@@ -296,7 +296,7 @@ public final class EntitlementManagerTest {
|
||||
mCallbacklatch.countDown();
|
||||
}
|
||||
};
|
||||
mEnMgr.getLatestTetheringEntitlementValue(TETHERING_WIFI, receiver, true);
|
||||
mEnMgr.getLatestTetheringEntitlementResult(TETHERING_WIFI, receiver, true);
|
||||
callbackTimeoutHelper(mCallbacklatch);
|
||||
assertFalse(mEnMgr.everRunUiEntitlement);
|
||||
// 7. Test get value for other downstream type.
|
||||
@@ -308,7 +308,7 @@ public final class EntitlementManagerTest {
|
||||
mCallbacklatch.countDown();
|
||||
}
|
||||
};
|
||||
mEnMgr.getLatestTetheringEntitlementValue(TETHERING_USB, receiver, false);
|
||||
mEnMgr.getLatestTetheringEntitlementResult(TETHERING_USB, receiver, false);
|
||||
callbackTimeoutHelper(mCallbacklatch);
|
||||
assertFalse(mEnMgr.everRunUiEntitlement);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user