Add SystemApi for captive portal metrics
The metrics go through NetworkMonitor in the NetworkStack so that they can be upgraded to new metrics in the future. Test: flashed, captive portal login works, metrics shown in events log Bug: 112869080 (Cherry-pick of aosp/890004) Change-Id: I4bccfbd87bae5b2d65e45c7a5918aa45ab5d76e8
This commit is contained in:
@@ -4072,6 +4072,7 @@ package android.net {
|
|||||||
|
|
||||||
public class CaptivePortal implements android.os.Parcelable {
|
public class CaptivePortal implements android.os.Parcelable {
|
||||||
ctor public CaptivePortal(android.os.IBinder);
|
ctor public CaptivePortal(android.os.IBinder);
|
||||||
|
method public void logEvent(int, String);
|
||||||
method public void useNetwork();
|
method public void useNetwork();
|
||||||
field public static final int APP_RETURN_DISMISSED = 0; // 0x0
|
field public static final int APP_RETURN_DISMISSED = 0; // 0x0
|
||||||
field public static final int APP_RETURN_UNWANTED = 1; // 0x1
|
field public static final int APP_RETURN_UNWANTED = 1; // 0x1
|
||||||
|
|||||||
@@ -799,6 +799,7 @@ package android.net {
|
|||||||
|
|
||||||
public class CaptivePortal implements android.os.Parcelable {
|
public class CaptivePortal implements android.os.Parcelable {
|
||||||
ctor public CaptivePortal(android.os.IBinder);
|
ctor public CaptivePortal(android.os.IBinder);
|
||||||
|
method public void logEvent(int, String);
|
||||||
method public void useNetwork();
|
method public void useNetwork();
|
||||||
field public static final int APP_RETURN_DISMISSED = 0; // 0x0
|
field public static final int APP_RETURN_DISMISSED = 0; // 0x0
|
||||||
field public static final int APP_RETURN_UNWANTED = 1; // 0x1
|
field public static final int APP_RETURN_UNWANTED = 1; // 0x1
|
||||||
|
|||||||
@@ -117,4 +117,17 @@ public class CaptivePortal implements Parcelable {
|
|||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log a captive portal login event.
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
@SystemApi
|
||||||
|
@TestApi
|
||||||
|
public void logEvent(int eventId, String packageName) {
|
||||||
|
try {
|
||||||
|
ICaptivePortal.Stub.asInterface(mBinder).logEvent(eventId, packageName);
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,4 +22,5 @@ package android.net;
|
|||||||
*/
|
*/
|
||||||
oneway interface ICaptivePortal {
|
oneway interface ICaptivePortal {
|
||||||
void appResponse(int response);
|
void appResponse(int response);
|
||||||
|
void logEvent(int eventId, String packageName);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,4 +26,5 @@ oneway interface INetworkMonitorCallbacks {
|
|||||||
void notifyPrivateDnsConfigResolved(in PrivateDnsConfigParcel config);
|
void notifyPrivateDnsConfigResolved(in PrivateDnsConfigParcel config);
|
||||||
void showProvisioningNotification(String action);
|
void showProvisioningNotification(String action);
|
||||||
void hideProvisioningNotification();
|
void hideProvisioningNotification();
|
||||||
|
void logCaptivePortalLoginEvent(int eventId, String packageName);
|
||||||
}
|
}
|
||||||
@@ -60,7 +60,6 @@ import android.widget.TextView;
|
|||||||
|
|
||||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||||
|
|
||||||
import com.android.internal.logging.MetricsLogger;
|
|
||||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -107,11 +106,11 @@ public class CaptivePortalLoginActivity extends Activity {
|
|||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
mCaptivePortal = getIntent().getParcelableExtra(ConnectivityManager.EXTRA_CAPTIVE_PORTAL);
|
||||||
logMetricsEvent(MetricsEvent.ACTION_CAPTIVE_PORTAL_LOGIN_ACTIVITY);
|
logMetricsEvent(MetricsEvent.ACTION_CAPTIVE_PORTAL_LOGIN_ACTIVITY);
|
||||||
|
|
||||||
mCm = ConnectivityManager.from(this);
|
mCm = ConnectivityManager.from(this);
|
||||||
mNetwork = getIntent().getParcelableExtra(ConnectivityManager.EXTRA_NETWORK);
|
mNetwork = getIntent().getParcelableExtra(ConnectivityManager.EXTRA_NETWORK);
|
||||||
mCaptivePortal = getIntent().getParcelableExtra(ConnectivityManager.EXTRA_CAPTIVE_PORTAL);
|
|
||||||
mUserAgent =
|
mUserAgent =
|
||||||
getIntent().getStringExtra(ConnectivityManager.EXTRA_CAPTIVE_PORTAL_USER_AGENT);
|
getIntent().getStringExtra(ConnectivityManager.EXTRA_CAPTIVE_PORTAL_USER_AGENT);
|
||||||
mUrl = getUrl();
|
mUrl = getUrl();
|
||||||
@@ -637,7 +636,7 @@ public class CaptivePortalLoginActivity extends Activity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void logMetricsEvent(int event) {
|
private void logMetricsEvent(int event) {
|
||||||
MetricsLogger.action(this, event, getPackageName());
|
mCaptivePortal.logEvent(event, getPackageName());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final SparseArray<String> SSL_ERRORS = new SparseArray<>();
|
private static final SparseArray<String> SSL_ERRORS = new SparseArray<>();
|
||||||
|
|||||||
@@ -689,6 +689,15 @@ public class NetworkMonitor extends StateMachine {
|
|||||||
}
|
}
|
||||||
sendMessage(CMD_CAPTIVE_PORTAL_APP_FINISHED, response);
|
sendMessage(CMD_CAPTIVE_PORTAL_APP_FINISHED, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void logEvent(int eventId, String packageName)
|
||||||
|
throws RemoteException {
|
||||||
|
mContext.enforceCallingPermission(
|
||||||
|
android.Manifest.permission.CONNECTIVITY_INTERNAL,
|
||||||
|
"CaptivePortal");
|
||||||
|
mCallback.logCaptivePortalLoginEvent(eventId, packageName);
|
||||||
|
}
|
||||||
}));
|
}));
|
||||||
final CaptivePortalProbeResult probeRes = mLastPortalProbeResult;
|
final CaptivePortalProbeResult probeRes = mLastPortalProbeResult;
|
||||||
intent.putExtra(EXTRA_CAPTIVE_PORTAL_URL, probeRes.detectUrl);
|
intent.putExtra(EXTRA_CAPTIVE_PORTAL_URL, probeRes.detectUrl);
|
||||||
|
|||||||
@@ -144,6 +144,7 @@ import com.android.internal.R;
|
|||||||
import com.android.internal.annotations.GuardedBy;
|
import com.android.internal.annotations.GuardedBy;
|
||||||
import com.android.internal.annotations.VisibleForTesting;
|
import com.android.internal.annotations.VisibleForTesting;
|
||||||
import com.android.internal.app.IBatteryStats;
|
import com.android.internal.app.IBatteryStats;
|
||||||
|
import com.android.internal.logging.MetricsLogger;
|
||||||
import com.android.internal.net.LegacyVpnInfo;
|
import com.android.internal.net.LegacyVpnInfo;
|
||||||
import com.android.internal.net.VpnConfig;
|
import com.android.internal.net.VpnConfig;
|
||||||
import com.android.internal.net.VpnInfo;
|
import com.android.internal.net.VpnInfo;
|
||||||
@@ -2683,6 +2684,11 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
EVENT_PROVISIONING_NOTIFICATION, PROVISIONING_NOTIFICATION_HIDE,
|
EVENT_PROVISIONING_NOTIFICATION, PROVISIONING_NOTIFICATION_HIDE,
|
||||||
mNai.network.netId));
|
mNai.network.netId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void logCaptivePortalLoginEvent(int eventId, String packageName) {
|
||||||
|
new MetricsLogger().action(eventId, packageName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean networkRequiresValidation(NetworkAgentInfo nai) {
|
private boolean networkRequiresValidation(NetworkAgentInfo nai) {
|
||||||
|
|||||||
Reference in New Issue
Block a user