From 79ebe4fb71575632098a9f1e322d795a8ae886e8 Mon Sep 17 00:00:00 2001 From: paulhu Date: Fri, 6 Dec 2019 16:45:38 +0800 Subject: [PATCH] Add CONNECTIVITY_INTERNAL to bt tethering related APIs temporarily Some NetworkManagementService APIs are still called by bluetooth tethering. But it's not good to give bluetooth app NETWORK_STACK due to NETWORK_STACK is extremly powerful permission that can access most of all networking functions. So add CONNECTIVITY_INTERNAL to those APIs which are called by bluetooth tethering temporarily. Bug: 32963470 Test: atest FrameworksNetTests Change-Id: Ib3a4acf3018a52ef38e78d9e2a702af3fef026d4 --- .../android/server/NetworkManagementService.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/services/core/java/com/android/server/NetworkManagementService.java b/services/core/java/com/android/server/NetworkManagementService.java index e79a2897d86a4..840b7af19890c 100644 --- a/services/core/java/com/android/server/NetworkManagementService.java +++ b/services/core/java/com/android/server/NetworkManagementService.java @@ -16,6 +16,7 @@ package com.android.server; +import static android.Manifest.permission.CONNECTIVITY_INTERNAL; import static android.Manifest.permission.NETWORK_SETTINGS; import static android.Manifest.permission.OBSERVE_NETWORK_POLICY; import static android.Manifest.permission.SHUTDOWN; @@ -737,7 +738,9 @@ public class NetworkManagementService extends INetworkManagementService.Stub { // @Override public String[] listInterfaces() { - NetworkStack.checkNetworkStackPermission(mContext); + // TODO: Remove CONNECTIVITY_INTERNAL after bluetooth tethering has no longer called these + // APIs. + NetworkStack.checkNetworkStackPermissionOr(mContext, CONNECTIVITY_INTERNAL); try { return mNetdService.interfaceGetList(); } catch (RemoteException | ServiceSpecificException e) { @@ -787,7 +790,9 @@ public class NetworkManagementService extends INetworkManagementService.Stub { @Override public InterfaceConfiguration getInterfaceConfig(String iface) { - NetworkStack.checkNetworkStackPermission(mContext); + // TODO: Remove CONNECTIVITY_INTERNAL after bluetooth tethering has no longer called these + // APIs. + NetworkStack.checkNetworkStackPermissionOr(mContext, CONNECTIVITY_INTERNAL); final InterfaceConfigurationParcel result; try { result = mNetdService.interfaceGetCfg(iface); @@ -805,7 +810,9 @@ public class NetworkManagementService extends INetworkManagementService.Stub { @Override public void setInterfaceConfig(String iface, InterfaceConfiguration cfg) { - NetworkStack.checkNetworkStackPermission(mContext); + // TODO: Remove CONNECTIVITY_INTERNAL after bluetooth tethering has no longer called these + // APIs. + NetworkStack.checkNetworkStackPermissionOr(mContext, CONNECTIVITY_INTERNAL); LinkAddress linkAddr = cfg.getLinkAddress(); if (linkAddr == null || linkAddr.getAddress() == null) { throw new IllegalStateException("Null LinkAddress given");