Merge "Remove hard-coded NetworkStack package name" am: e765e8b7aa
am: d49230d8df
Change-Id: If82997f9f46a34014e797f10a71c34bfb4150585
This commit is contained in:
@@ -24,7 +24,7 @@ oneway interface INetworkMonitorCallbacks {
|
|||||||
void onNetworkMonitorCreated(in INetworkMonitor networkMonitor);
|
void onNetworkMonitorCreated(in INetworkMonitor networkMonitor);
|
||||||
void notifyNetworkTested(int testResult, @nullable String redirectUrl);
|
void notifyNetworkTested(int testResult, @nullable String redirectUrl);
|
||||||
void notifyPrivateDnsConfigResolved(in PrivateDnsConfigParcel config);
|
void notifyPrivateDnsConfigResolved(in PrivateDnsConfigParcel config);
|
||||||
void showProvisioningNotification(String action);
|
void showProvisioningNotification(String action, String packageName);
|
||||||
void hideProvisioningNotification();
|
void hideProvisioningNotification();
|
||||||
void logCaptivePortalLoginEvent(int eventId, String packageName);
|
void logCaptivePortalLoginEvent(int eventId, String packageName);
|
||||||
}
|
}
|
||||||
@@ -63,9 +63,6 @@ public class NetworkStack {
|
|||||||
public static final String PERMISSION_MAINLINE_NETWORK_STACK =
|
public static final String PERMISSION_MAINLINE_NETWORK_STACK =
|
||||||
"android.permission.MAINLINE_NETWORK_STACK";
|
"android.permission.MAINLINE_NETWORK_STACK";
|
||||||
|
|
||||||
/** @hide */
|
|
||||||
public static final String NETWORKSTACK_PACKAGE_NAME = "com.android.mainline.networkstack";
|
|
||||||
|
|
||||||
private static final int NETWORKSTACK_TIMEOUT_MS = 10_000;
|
private static final int NETWORKSTACK_TIMEOUT_MS = 10_000;
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
|
|||||||
@@ -500,7 +500,7 @@ public class NetworkMonitor extends StateMachine {
|
|||||||
|
|
||||||
private void showProvisioningNotification(String action) {
|
private void showProvisioningNotification(String action) {
|
||||||
try {
|
try {
|
||||||
mCallback.showProvisioningNotification(action);
|
mCallback.showProvisioningNotification(action, mContext.getPackageName());
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.e(TAG, "Error showing provisioning notification", e);
|
Log.e(TAG, "Error showing provisioning notification", e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -482,7 +482,7 @@ public class NetworkMonitorTest {
|
|||||||
nm.notifyNetworkConnected();
|
nm.notifyNetworkConnected();
|
||||||
|
|
||||||
verify(mCallbacks, timeout(HANDLER_TIMEOUT_MS).times(1))
|
verify(mCallbacks, timeout(HANDLER_TIMEOUT_MS).times(1))
|
||||||
.showProvisioningNotification(any());
|
.showProvisioningNotification(any(), any());
|
||||||
|
|
||||||
// Check that startCaptivePortalApp sends the expected intent.
|
// Check that startCaptivePortalApp sends the expected intent.
|
||||||
nm.launchCaptivePortalApp();
|
nm.launchCaptivePortalApp();
|
||||||
|
|||||||
@@ -38,7 +38,6 @@ import static android.net.NetworkCapabilities.NET_CAPABILITY_VALIDATED;
|
|||||||
import static android.net.NetworkCapabilities.TRANSPORT_VPN;
|
import static android.net.NetworkCapabilities.TRANSPORT_VPN;
|
||||||
import static android.net.NetworkPolicyManager.RULE_NONE;
|
import static android.net.NetworkPolicyManager.RULE_NONE;
|
||||||
import static android.net.NetworkPolicyManager.uidRulesToString;
|
import static android.net.NetworkPolicyManager.uidRulesToString;
|
||||||
import static android.net.NetworkStack.NETWORKSTACK_PACKAGE_NAME;
|
|
||||||
import static android.net.shared.NetworkMonitorUtils.isValidationRequired;
|
import static android.net.shared.NetworkMonitorUtils.isValidationRequired;
|
||||||
import static android.net.shared.NetworkParcelableUtil.toStableParcelable;
|
import static android.net.shared.NetworkParcelableUtil.toStableParcelable;
|
||||||
import static android.os.Process.INVALID_UID;
|
import static android.os.Process.INVALID_UID;
|
||||||
@@ -2666,9 +2665,9 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void showProvisioningNotification(String action) {
|
public void showProvisioningNotification(String action, String packageName) {
|
||||||
final Intent intent = new Intent(action);
|
final Intent intent = new Intent(action);
|
||||||
intent.setPackage(NETWORKSTACK_PACKAGE_NAME);
|
intent.setPackage(packageName);
|
||||||
|
|
||||||
final PendingIntent pendingIntent;
|
final PendingIntent pendingIntent;
|
||||||
// Only the system server can register notifications with package "android"
|
// Only the system server can register notifications with package "android"
|
||||||
|
|||||||
@@ -554,7 +554,7 @@ public class ConnectivityServiceTest {
|
|||||||
|
|
||||||
if (mNmValidationRedirectUrl != null) {
|
if (mNmValidationRedirectUrl != null) {
|
||||||
mNmCallbacks.showProvisioningNotification(
|
mNmCallbacks.showProvisioningNotification(
|
||||||
"test_provisioning_notif_action");
|
"test_provisioning_notif_action", "com.android.test.package");
|
||||||
mNmProvNotificationRequested = true;
|
mNmProvNotificationRequested = true;
|
||||||
}
|
}
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user