Remove hard-coded NetworkStack package name
Have the network stack pass its package name in showProvisioningNotification instead. Bug: 124033493 Test: flashed, WiFi and captive portal works Test: atest FrameworksNetTests NetworkStackTests Change-Id: I1f3312768ba1fb34e99a827e1fcdaf7510e318a8
This commit is contained in:
@@ -24,7 +24,7 @@ oneway interface INetworkMonitorCallbacks {
|
||||
void onNetworkMonitorCreated(in INetworkMonitor networkMonitor);
|
||||
void notifyNetworkTested(int testResult, @nullable String redirectUrl);
|
||||
void notifyPrivateDnsConfigResolved(in PrivateDnsConfigParcel config);
|
||||
void showProvisioningNotification(String action);
|
||||
void showProvisioningNotification(String action, String packageName);
|
||||
void hideProvisioningNotification();
|
||||
void logCaptivePortalLoginEvent(int eventId, String packageName);
|
||||
}
|
||||
@@ -63,9 +63,6 @@ public class NetworkStack {
|
||||
public static final String 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;
|
||||
|
||||
@NonNull
|
||||
|
||||
@@ -499,7 +499,7 @@ public class NetworkMonitor extends StateMachine {
|
||||
|
||||
private void showProvisioningNotification(String action) {
|
||||
try {
|
||||
mCallback.showProvisioningNotification(action);
|
||||
mCallback.showProvisioningNotification(action, mContext.getPackageName());
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Error showing provisioning notification", e);
|
||||
}
|
||||
|
||||
@@ -482,7 +482,7 @@ public class NetworkMonitorTest {
|
||||
nm.notifyNetworkConnected();
|
||||
|
||||
verify(mCallbacks, timeout(HANDLER_TIMEOUT_MS).times(1))
|
||||
.showProvisioningNotification(any());
|
||||
.showProvisioningNotification(any(), any());
|
||||
|
||||
// Check that startCaptivePortalApp sends the expected intent.
|
||||
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.NetworkPolicyManager.RULE_NONE;
|
||||
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.NetworkParcelableUtil.toStableParcelable;
|
||||
import static android.os.Process.INVALID_UID;
|
||||
@@ -2661,9 +2660,9 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showProvisioningNotification(String action) {
|
||||
public void showProvisioningNotification(String action, String packageName) {
|
||||
final Intent intent = new Intent(action);
|
||||
intent.setPackage(NETWORKSTACK_PACKAGE_NAME);
|
||||
intent.setPackage(packageName);
|
||||
|
||||
final PendingIntent pendingIntent;
|
||||
// Only the system server can register notifications with package "android"
|
||||
|
||||
@@ -554,7 +554,7 @@ public class ConnectivityServiceTest {
|
||||
|
||||
if (mNmValidationRedirectUrl != null) {
|
||||
mNmCallbacks.showProvisioningNotification(
|
||||
"test_provisioning_notif_action");
|
||||
"test_provisioning_notif_action", "com.android.test.package");
|
||||
mNmProvNotificationRequested = true;
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
|
||||
Reference in New Issue
Block a user