Merge "Add WRITE_ALLOWLISTED_DEVICE_CONFIG perm when modifying DeviceConfig" into main am: 5380288dd7
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/3363808 Change-Id: I797f9160ca0b9f58991c58fe6b3e251085086f5c Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
e68acbb469
9 changed files with 26 additions and 11 deletions
|
|
@ -18,6 +18,7 @@ package android.nearby.cts;
|
|||
|
||||
import static android.Manifest.permission.BLUETOOTH_PRIVILEGED;
|
||||
import static android.Manifest.permission.READ_DEVICE_CONFIG;
|
||||
import static android.Manifest.permission.WRITE_ALLOWLISTED_DEVICE_CONFIG;
|
||||
import static android.Manifest.permission.WRITE_DEVICE_CONFIG;
|
||||
import static android.nearby.PresenceCredential.IDENTITY_TYPE_PRIVATE;
|
||||
import static android.nearby.ScanCallback.ERROR_UNSUPPORTED;
|
||||
|
|
@ -121,7 +122,7 @@ public class NearbyManagerTest {
|
|||
@Before
|
||||
public void setUp() {
|
||||
mUiAutomation.adoptShellPermissionIdentity(READ_DEVICE_CONFIG, WRITE_DEVICE_CONFIG,
|
||||
BLUETOOTH_PRIVILEGED);
|
||||
WRITE_ALLOWLISTED_DEVICE_CONFIG, BLUETOOTH_PRIVILEGED);
|
||||
String nameSpace = SdkLevel.isAtLeastU() ? DeviceConfig.NAMESPACE_NEARBY
|
||||
: DeviceConfig.NAMESPACE_TETHERING;
|
||||
DeviceConfig.setProperty(nameSpace,
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ package com.android.server.nearby;
|
|||
|
||||
import static android.Manifest.permission.READ_DEVICE_CONFIG;
|
||||
import static android.Manifest.permission.WRITE_DEVICE_CONFIG;
|
||||
import static android.Manifest.permission.WRITE_ALLOWLISTED_DEVICE_CONFIG;
|
||||
|
||||
import static com.android.server.nearby.NearbyConfiguration.NEARBY_ENABLE_PRESENCE_BROADCAST_LEGACY;
|
||||
import static com.android.server.nearby.NearbyConfiguration.NEARBY_MAINLINE_NANO_APP_MIN_VERSION;
|
||||
|
|
@ -42,7 +43,8 @@ public final class NearbyConfigurationTest {
|
|||
@Before
|
||||
public void setUp() {
|
||||
InstrumentationRegistry.getInstrumentation().getUiAutomation()
|
||||
.adoptShellPermissionIdentity(WRITE_DEVICE_CONFIG, READ_DEVICE_CONFIG);
|
||||
.adoptShellPermissionIdentity(WRITE_DEVICE_CONFIG, WRITE_ALLOWLISTED_DEVICE_CONFIG,
|
||||
READ_DEVICE_CONFIG);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ package com.android.server.nearby;
|
|||
import static android.Manifest.permission.BLUETOOTH_PRIVILEGED;
|
||||
import static android.Manifest.permission.READ_DEVICE_CONFIG;
|
||||
import static android.Manifest.permission.WRITE_DEVICE_CONFIG;
|
||||
import static android.Manifest.permission.WRITE_ALLOWLISTED_DEVICE_CONFIG;
|
||||
|
||||
import static com.android.server.nearby.NearbyConfiguration.NEARBY_SUPPORT_TEST_APP;
|
||||
|
||||
|
|
@ -71,7 +72,8 @@ public final class NearbyServiceTest {
|
|||
when(mScanListener.asBinder()).thenReturn(mIBinder);
|
||||
|
||||
mUiAutomation.adoptShellPermissionIdentity(
|
||||
READ_DEVICE_CONFIG, WRITE_DEVICE_CONFIG, BLUETOOTH_PRIVILEGED);
|
||||
READ_DEVICE_CONFIG, WRITE_DEVICE_CONFIG, WRITE_ALLOWLISTED_DEVICE_CONFIG,
|
||||
BLUETOOTH_PRIVILEGED);
|
||||
mContext = InstrumentationRegistry.getInstrumentation().getContext();
|
||||
mService = new NearbyService(mContext);
|
||||
mScanRequest = createScanRequest();
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ package com.android.server.nearby.managers;
|
|||
|
||||
import static android.Manifest.permission.READ_DEVICE_CONFIG;
|
||||
import static android.Manifest.permission.WRITE_DEVICE_CONFIG;
|
||||
import static android.Manifest.permission.WRITE_ALLOWLISTED_DEVICE_CONFIG;
|
||||
|
||||
import static com.android.server.nearby.NearbyConfiguration.NEARBY_ENABLE_PRESENCE_BROADCAST_LEGACY;
|
||||
import static com.android.server.nearby.NearbyConfiguration.NEARBY_SUPPORT_TEST_APP;
|
||||
|
|
@ -88,7 +89,8 @@ public class BroadcastProviderManagerTest {
|
|||
@Before
|
||||
public void setUp() {
|
||||
when(mBroadcastListener.asBinder()).thenReturn(mBinder);
|
||||
mUiAutomation.adoptShellPermissionIdentity(WRITE_DEVICE_CONFIG, READ_DEVICE_CONFIG);
|
||||
mUiAutomation.adoptShellPermissionIdentity(WRITE_DEVICE_CONFIG,
|
||||
WRITE_ALLOWLISTED_DEVICE_CONFIG, READ_DEVICE_CONFIG);
|
||||
DeviceConfig.setProperty(
|
||||
NAMESPACE, NEARBY_ENABLE_PRESENCE_BROADCAST_LEGACY, "true", false);
|
||||
DeviceConfig.setProperty(
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ package com.android.server.nearby.provider;
|
|||
|
||||
import static android.Manifest.permission.READ_DEVICE_CONFIG;
|
||||
import static android.Manifest.permission.WRITE_DEVICE_CONFIG;
|
||||
import static android.Manifest.permission.WRITE_ALLOWLISTED_DEVICE_CONFIG;
|
||||
|
||||
import static com.android.server.nearby.NearbyConfiguration.NEARBY_MAINLINE_NANO_APP_MIN_VERSION;
|
||||
import static com.android.server.nearby.provider.ChreCommunication.INVALID_NANO_APP_VERSION;
|
||||
|
|
@ -76,7 +77,8 @@ public class ChreCommunicationTest {
|
|||
@Before
|
||||
public void setUp() {
|
||||
InstrumentationRegistry.getInstrumentation().getUiAutomation()
|
||||
.adoptShellPermissionIdentity(WRITE_DEVICE_CONFIG, READ_DEVICE_CONFIG);
|
||||
.adoptShellPermissionIdentity(WRITE_DEVICE_CONFIG, WRITE_ALLOWLISTED_DEVICE_CONFIG,
|
||||
READ_DEVICE_CONFIG);
|
||||
DeviceConfig.setProperty(
|
||||
NAMESPACE, NEARBY_MAINLINE_NANO_APP_MIN_VERSION, "1", false);
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ package com.android.server.nearby.provider;
|
|||
|
||||
import static android.Manifest.permission.READ_DEVICE_CONFIG;
|
||||
import static android.Manifest.permission.WRITE_DEVICE_CONFIG;
|
||||
import static android.Manifest.permission.WRITE_ALLOWLISTED_DEVICE_CONFIG;
|
||||
|
||||
import static com.android.server.nearby.NearbyConfiguration.NEARBY_SUPPORT_TEST_APP;
|
||||
|
||||
|
|
@ -84,7 +85,8 @@ public class ChreDiscoveryProviderTest {
|
|||
@Before
|
||||
public void setUp() {
|
||||
InstrumentationRegistry.getInstrumentation().getUiAutomation()
|
||||
.adoptShellPermissionIdentity(WRITE_DEVICE_CONFIG, READ_DEVICE_CONFIG);
|
||||
.adoptShellPermissionIdentity(WRITE_DEVICE_CONFIG, WRITE_ALLOWLISTED_DEVICE_CONFIG,
|
||||
READ_DEVICE_CONFIG);
|
||||
|
||||
MockitoAnnotations.initMocks(this);
|
||||
Context context = InstrumentationRegistry.getInstrumentation().getContext();
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ package com.android.testutils
|
|||
|
||||
import android.Manifest.permission.READ_DEVICE_CONFIG
|
||||
import android.Manifest.permission.WRITE_DEVICE_CONFIG
|
||||
import android.Manifest.permission.WRITE_ALLOWLISTED_DEVICE_CONFIG
|
||||
import android.provider.DeviceConfig
|
||||
import android.util.Log
|
||||
import com.android.modules.utils.build.SdkLevel
|
||||
|
|
@ -87,7 +88,7 @@ class DeviceConfigRule @JvmOverloads constructor(
|
|||
}
|
||||
throw e
|
||||
} cleanupStep {
|
||||
runAsShell(WRITE_DEVICE_CONFIG) {
|
||||
runAsShell(WRITE_DEVICE_CONFIG, WRITE_ALLOWLISTED_DEVICE_CONFIG) {
|
||||
originalConfig.forEach { (key, value) ->
|
||||
Log.i(TAG, "Resetting config \"${key.second}\" to \"$value\"")
|
||||
DeviceConfig.setProperty(
|
||||
|
|
@ -116,7 +117,8 @@ class DeviceConfigRule @JvmOverloads constructor(
|
|||
*/
|
||||
fun setConfig(namespace: String, key: String, value: String?): String? {
|
||||
Log.i(TAG, "Setting config \"$key\" to \"$value\"")
|
||||
val readWritePermissions = arrayOf(READ_DEVICE_CONFIG, WRITE_DEVICE_CONFIG)
|
||||
val readWritePermissions =
|
||||
arrayOf(READ_DEVICE_CONFIG, WRITE_DEVICE_CONFIG, WRITE_ALLOWLISTED_DEVICE_CONFIG)
|
||||
|
||||
val keyPair = Pair(namespace, key)
|
||||
val existingValue = runAsShell(*readWritePermissions) {
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import static android.Manifest.permission.MANAGE_TEST_NETWORKS;
|
|||
import static android.Manifest.permission.NETWORK_SETTINGS;
|
||||
import static android.Manifest.permission.READ_DEVICE_CONFIG;
|
||||
import static android.Manifest.permission.WRITE_DEVICE_CONFIG;
|
||||
import static android.Manifest.permission.WRITE_ALLOWLISTED_DEVICE_CONFIG;
|
||||
import static android.content.Context.RECEIVER_EXPORTED;
|
||||
import static android.content.pm.PackageManager.FEATURE_TELEPHONY;
|
||||
import static android.content.pm.PackageManager.FEATURE_WIFI;
|
||||
|
|
@ -1209,7 +1210,7 @@ public class VpnTest {
|
|||
AUTOMATIC_ON_OFF_KEEPALIVE_VERSION,
|
||||
AUTOMATIC_ON_OFF_KEEPALIVE_ENABLED, false /* makeDefault */);
|
||||
return mode;
|
||||
}, READ_DEVICE_CONFIG, WRITE_DEVICE_CONFIG);
|
||||
}, READ_DEVICE_CONFIG, WRITE_DEVICE_CONFIG, WRITE_ALLOWLISTED_DEVICE_CONFIG);
|
||||
|
||||
final IpSecManager ipSec = mTargetContext.getSystemService(IpSecManager.class);
|
||||
SocketKeepalive kp = null;
|
||||
|
|
@ -1249,7 +1250,7 @@ public class VpnTest {
|
|||
AUTOMATIC_ON_OFF_KEEPALIVE_VERSION,
|
||||
origMode, false);
|
||||
mCM.setTestLowTcpPollingTimerForKeepalive(0);
|
||||
}, WRITE_DEVICE_CONFIG, NETWORK_SETTINGS);
|
||||
}, WRITE_DEVICE_CONFIG, WRITE_ALLOWLISTED_DEVICE_CONFIG, NETWORK_SETTINGS);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
package android.net.cts
|
||||
|
||||
import android.Manifest.permission.WRITE_DEVICE_CONFIG
|
||||
import android.Manifest.permission.WRITE_ALLOWLISTED_DEVICE_CONFIG
|
||||
import android.provider.DeviceConfig
|
||||
import android.provider.DeviceConfig.NAMESPACE_CONNECTIVITY
|
||||
import com.android.net.module.util.NetworkStackConstants
|
||||
|
|
@ -33,7 +34,7 @@ internal object NetworkValidationTestUtil {
|
|||
* Clear the test network validation URLs.
|
||||
*/
|
||||
@JvmStatic fun clearValidationTestUrlsDeviceConfig() {
|
||||
runAsShell(WRITE_DEVICE_CONFIG) {
|
||||
runAsShell(WRITE_DEVICE_CONFIG, WRITE_ALLOWLISTED_DEVICE_CONFIG) {
|
||||
DeviceConfig.setProperty(NAMESPACE_CONNECTIVITY,
|
||||
NetworkStackConstants.TEST_CAPTIVE_PORTAL_HTTPS_URL, null, false)
|
||||
DeviceConfig.setProperty(NAMESPACE_CONNECTIVITY,
|
||||
|
|
|
|||
Loading…
Reference in a new issue