Merge "Add API for NetworkStack to start captive portal"
This commit is contained in:
@@ -3906,6 +3906,25 @@ public class ConnectivityManager {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests that the system open the captive portal app with the specified extras.
|
||||
*
|
||||
* <p>This endpoint is exclusively for use by the NetworkStack and is protected by the
|
||||
* corresponding permission.
|
||||
* @param appExtras Extras to include in the app start intent.
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
@TestApi
|
||||
@RequiresPermission(NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK)
|
||||
public void startCaptivePortalApp(Bundle appExtras) {
|
||||
try {
|
||||
mService.startCaptivePortalAppInternal(appExtras);
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the device is configured to avoid bad wifi.
|
||||
* @hide
|
||||
|
||||
@@ -27,6 +27,7 @@ import android.net.NetworkQuotaInfo;
|
||||
import android.net.NetworkRequest;
|
||||
import android.net.NetworkState;
|
||||
import android.net.ProxyInfo;
|
||||
import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
import android.os.Messenger;
|
||||
import android.os.ParcelFileDescriptor;
|
||||
@@ -167,6 +168,7 @@ interface IConnectivityManager
|
||||
void setAcceptUnvalidated(in Network network, boolean accept, boolean always);
|
||||
void setAvoidUnvalidated(in Network network);
|
||||
void startCaptivePortalApp(in Network network);
|
||||
void startCaptivePortalAppInternal(in Bundle appExtras);
|
||||
|
||||
boolean getAvoidBadWifi();
|
||||
int getMultipathPreference(in Network Network);
|
||||
|
||||
@@ -3230,6 +3230,25 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* NetworkStack endpoint to start the captive portal app. The NetworkStack needs to use this
|
||||
* endpoint as it does not have INTERACT_ACROSS_USERS_FULL itself.
|
||||
* @param appExtras Bundle to use as intent extras for the captive portal application.
|
||||
* Must be treated as opaque to avoid preventing the captive portal app to
|
||||
* update its arguments.
|
||||
*/
|
||||
@Override
|
||||
public void startCaptivePortalAppInternal(Bundle appExtras) {
|
||||
mContext.checkCallingOrSelfPermission(NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK);
|
||||
|
||||
final Intent appIntent = new Intent(ConnectivityManager.ACTION_CAPTIVE_PORTAL_SIGN_IN);
|
||||
appIntent.putExtras(appExtras);
|
||||
appIntent.setFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
|
||||
Binder.withCleanCallingIdentity(() ->
|
||||
mContext.startActivityAsUser(appIntent, UserHandle.CURRENT));
|
||||
}
|
||||
|
||||
public boolean avoidBadWifi() {
|
||||
return mMultinetworkPolicyTracker.getAvoidBadWifi();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user