Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dde2691e authored by Teja Yerukalapudi's avatar Teja Yerukalapudi Committed by Android (Google) Code Review
Browse files

Merge "Rollout computer_control namespace" into main

parents 29a710e4 92783fc1
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -58,7 +58,7 @@ per-file *Oom* = file:/OOM_ADJUSTER_OWNERS
per-file ProcessStateController* = file:/OOM_ADJUSTER_OWNERS

# Miscellaneous
per-file SettingsToPropertiesMapper.java = dzshen@google.com, zhidou@google.com, marybethfair@google.com
per-file SettingsToPropertiesMapper.java = file:platform/packages/modules/ConfigInfrastructure:/OWNERS
per-file CarUserSwitchingDialog.java = file:platform/packages/services/Car:/OWNERS

# Activity Security
+16 −1
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import static com.android.aconfig_new_storage.Flags.enableAconfigStorageDaemon;
import static com.android.aconfig_new_storage.Flags.enableAconfigdFromMainline;
import static com.android.aconfig_new_storage.Flags.supportClearLocalOverridesImmediately;
import static com.android.aconfig_new_storage.Flags.supportImmediateLocalOverrides;
import static com.android.server.am.Flags.rolloutComputerControl;

import static java.util.concurrent.Executors.newSingleThreadScheduledExecutor;

@@ -52,6 +53,7 @@ import java.io.DataOutputStream;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashSet;

/**
@@ -94,6 +96,9 @@ public class SettingsToPropertiesMapper {
    private static final String NAMESPACE_TETHERING_U_OR_LATER_NATIVE =
            "tethering_u_or_later_native";

    private static final String NAMESPACE_COMPUTER_CONTROL =
            "computer_control";

    // All the flags under the listed DeviceConfig scopes will be synced to native level.
    //
    // NOTE: please grant write permission system property prefix
@@ -447,7 +452,7 @@ public class SettingsToPropertiesMapper {
        SettingsToPropertiesMapper mapper =  new SettingsToPropertiesMapper(
                contentResolver,
                sGlobalSettings,
                sDeviceConfigScopes);
                getDeviceConfigScopes());
        mapper.updatePropertiesFromSettings();
        return mapper;
    }
@@ -613,4 +618,14 @@ public class SettingsToPropertiesMapper {
        String settingValue = Settings.Global.getString(mContentResolver, settingName);
        setProperty(propName, settingValue);
    }

    @VisibleForTesting
    static String[] getDeviceConfigScopes() {
        String[] deviceConfigScopes = sDeviceConfigScopes;
        if (rolloutComputerControl()) {
            deviceConfigScopes = Arrays.copyOf(sDeviceConfigScopes, sDeviceConfigScopes.length + 1);
            deviceConfigScopes[sDeviceConfigScopes.length] = NAMESPACE_COMPUTER_CONTROL;
        }
        return deviceConfigScopes;
    }
}
+10 −0
Original line number Diff line number Diff line
@@ -262,3 +262,13 @@ flag {
        purpose: PURPOSE_BUGFIX
    }
}

flag {
    name: "rollout_computer_control"
    namespace: "core_experiments_team_internal"
    description: "Rolls out the computer_control namespace."
    bug: "436480687"
    metadata {
        purpose: PURPOSE_BUGFIX
    }
}
 No newline at end of file
+1 −0
Original line number Diff line number Diff line
@@ -6,3 +6,4 @@ per-file BaseBroadcastQueueTest.java = file:/BROADCASTS_OWNERS
per-file MockingOomAdjusterTests.java = file:/OOM_ADJUSTER_OWNERS
per-file *Activity* = file:/ACTIVITY_MANAGER_OWNERS
per-file *Service* = file:/ACTIVITY_MANAGER_OWNERS
per-file SettingsToPropertiesMapperTest.java = file:platform/packages/modules/ConfigInfrastructure:/OWNERS
 No newline at end of file
+38 −6
Original line number Diff line number Diff line
@@ -20,11 +20,15 @@ import static com.android.dx.mockito.inline.extended.ExtendedMockito.any;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.anyString;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.doAnswer;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn;
import static com.android.server.am.Flags.FLAG_ROLLOUT_COMPUTER_CONTROL;

import static org.mockito.Mockito.verify;

import android.content.ContentResolver;
import android.os.SystemProperties;
import android.platform.test.annotations.DisableFlags;
import android.platform.test.annotations.EnableFlags;
import android.platform.test.flag.junit.SetFlagsRule;
import android.provider.DeviceConfig;
import android.provider.Settings;
import android.text.TextUtils;
@@ -35,6 +39,7 @@ import com.android.dx.mockito.inline.extended.ExtendedMockito;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.mockito.Answers;
import org.mockito.Mock;
@@ -52,6 +57,9 @@ import java.util.List;
 * Test SettingsToPropertiesMapper.
 */
public class SettingsToPropertiesMapperTest {
    @Rule
    public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();

    private static final String NAME_VALID_CHARACTERS_REGEX = "^[\\w\\-@:]*$";
    private static final String[] TEST_MAPPING = new String[]{
            Settings.Global.SQLITE_COMPATIBILITY_WAL_FLAGS
@@ -153,7 +161,7 @@ public class SettingsToPropertiesMapperTest {
    @Test
    public void validateRegisteredDeviceConfigScopes() {
        HashSet<String> hashSet = new HashSet<>();
        for (String deviceConfigScope : SettingsToPropertiesMapper.sDeviceConfigScopes) {
        for (String deviceConfigScope : SettingsToPropertiesMapper.getDeviceConfigScopes()) {
            if (hashSet.contains(deviceConfigScope)) {
                Assert.fail("deviceConfigScope "
                        + deviceConfigScope
@@ -171,6 +179,30 @@ public class SettingsToPropertiesMapperTest {
        }
    }

    @Test
    @EnableFlags(FLAG_ROLLOUT_COMPUTER_CONTROL)
    public void validateComputerControlPresent() {
        HashSet<String> hashSet = new HashSet<>(
                Arrays.asList(SettingsToPropertiesMapper.getDeviceConfigScopes()));
        if (!hashSet.contains("computer_control")) {
            Assert.fail(
                    "validateComputerControlPresent: computer_control isn't present in "
                            + "sDeviceConfigScopes");
        }
    }

    @Test
    @DisableFlags(FLAG_ROLLOUT_COMPUTER_CONTROL)
    public void validateComputerControlNotPresent() {
        HashSet<String> hashSet = new HashSet<>(
                Arrays.asList(SettingsToPropertiesMapper.getDeviceConfigScopes()));
        if (hashSet.contains("computer_control")) {
            Assert.fail(
                    "validateComputerControlPresent: computer_control is present in "
                            + "sDeviceConfigScopes");
        }
    }

    @Test
    public void testUpdatePropertiesFromSettings() {
        mGlobalSettingsMap.put(Settings.Global.SQLITE_COMPATIBILITY_WAL_FLAGS, "testValue");