Merge "Remove hard-coded NetworkStack package name"

am: e765e8b7aa

Change-Id: I0e67a5e857d4f5ba2af1f0928be6d97c0f4ce94f
This commit is contained in:
Remi NGUYEN VAN
2019-02-11 20:22:40 -08:00
committed by android-build-merger
6 changed files with 6 additions and 10 deletions

View File

@@ -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);
} }

View File

@@ -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

View File

@@ -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);
} }

View File

@@ -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();

View File

@@ -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"

View File

@@ -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) {