summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SettingsProvider/src/com/android/providers/settings/SettingsState.java116
-rw-r--r--packages/SettingsProvider/test/src/com/android/providers/settings/SettingsStateTest.java134
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/mediaprojection/domain/interactor/MediaProjectionChipInteractorTest.kt2
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/CastDeviceTest.kt2
-rw-r--r--services/core/java/com/android/server/am/SettingsToPropertiesMapper.java1
-rw-r--r--services/core/java/com/android/server/audio/AudioService.java4
6 files changed, 14 insertions, 245 deletions
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsState.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsState.java
index ff08403a84fd..60fae3f1fea9 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsState.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsState.java
@@ -18,10 +18,13 @@ package com.android.providers.settings;
import static android.os.Process.FIRST_APPLICATION_UID;
+import static com.android.aconfig_new_storage.Flags.enableAconfigStorageDaemon;
+
import android.aconfig.Aconfig.flag_permission;
import android.aconfig.Aconfig.flag_state;
import android.aconfig.Aconfig.parsed_flag;
import android.aconfig.Aconfig.parsed_flags;
+import android.aconfigd.AconfigdFlagInfo;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.content.Context;
@@ -65,14 +68,10 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
-import java.io.InputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.nio.file.Files;
import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.nio.file.attribute.PosixFileAttributes;
-import java.nio.file.attribute.PosixFilePermission;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
@@ -84,18 +83,6 @@ import java.util.Objects;
import java.util.Set;
import java.util.concurrent.CountDownLatch;
-// FOR ACONFIGD TEST MISSION AND ROLLOUT
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import android.util.proto.ProtoInputStream;
-import android.aconfigd.Aconfigd.StorageRequestMessage;
-import android.aconfigd.Aconfigd.StorageRequestMessages;
-import android.aconfigd.Aconfigd.StorageReturnMessage;
-import android.aconfigd.Aconfigd.StorageReturnMessages;
-import android.aconfigd.AconfigdClientSocket;
-import android.aconfigd.AconfigdFlagInfo;
-import android.aconfigd.AconfigdJavaUtils;
-import static com.android.aconfig_new_storage.Flags.enableAconfigStorageDaemon;
/**
* This class contains the state for one type of settings. It is responsible
* for saving the state asynchronously to an XML file after a mutation and
@@ -393,22 +380,6 @@ final class SettingsState {
getAllAconfigFlagsFromSettings(mAconfigDefaultFlags);
}
}
-
- if (isConfigSettingsKey(mKey)) {
- requests = handleBulkSyncToNewStorage(mAconfigDefaultFlags);
- }
- }
-
- if (enableAconfigStorageDaemon()) {
- if (isConfigSettingsKey(mKey)){
- AconfigdClientSocket localSocket = AconfigdJavaUtils.getAconfigdClientSocket();
- if (requests != null) {
- InputStream res = localSocket.send(requests.getBytes());
- if (res == null) {
- Slog.w(LOG_TAG, "Bulk sync request to acongid failed.");
- }
- }
- }
}
}
@@ -482,87 +453,6 @@ final class SettingsState {
return flag;
}
-
- // TODO(b/341764371): migrate aconfig flag push to GMS core
- @VisibleForTesting
- @GuardedBy("mLock")
- public ProtoOutputStream handleBulkSyncToNewStorage(
- Map<String, AconfigdFlagInfo> aconfigFlagMap) {
- // get marker or add marker if it does not exist
- Setting markerSetting = mSettings.get(BULK_SYNC_MARKER);
- int localCounter = 0;
- if (markerSetting == null) {
- markerSetting = new Setting(BULK_SYNC_MARKER, "0", false, "aconfig", "aconfig");
- mSettings.put(BULK_SYNC_MARKER, markerSetting);
- }
- try {
- localCounter = Integer.parseInt(markerSetting.value);
- } catch (NumberFormatException e) {
- // reset local counter
- markerSetting.value = "0";
- }
-
- if (enableAconfigStorageDaemon()) {
- Setting bulkSyncCounter = mSettings.get(BULK_SYNC_TRIGGER_COUNTER);
- int serverCounter = 0;
- if (bulkSyncCounter != null) {
- try {
- serverCounter = Integer.parseInt(bulkSyncCounter.value);
- } catch (NumberFormatException e) {
- // reset the local value of server counter
- bulkSyncCounter.value = "0";
- }
- }
-
- boolean shouldSync = localCounter < serverCounter;
- if (!shouldSync) {
- // CASE 1, flag is on, bulk sync marker true, nothing to do
- return null;
- } else {
- // CASE 2, flag is on, bulk sync marker false. Do following two tasks
- // (1) Do bulk sync here.
- // (2) After bulk sync, set marker to true.
-
- // first add storage reset request
- ProtoOutputStream requests = new ProtoOutputStream();
- AconfigdJavaUtils.writeResetStorageRequest(requests);
-
- // loop over all settings and add flag override requests
- for (AconfigdFlagInfo flag : aconfigFlagMap.values()) {
- // don't sync read_only flags
- if (!flag.getIsReadWrite()) {
- continue;
- }
-
- if (flag.getHasServerOverride()) {
- AconfigdJavaUtils.writeFlagOverrideRequest(
- requests,
- flag.getPackageName(),
- flag.getFlagName(),
- flag.getServerFlagValue(),
- StorageRequestMessage.SERVER_ON_REBOOT);
- }
-
- if (flag.getHasLocalOverride()) {
- AconfigdJavaUtils.writeFlagOverrideRequest(
- requests,
- flag.getPackageName(),
- flag.getFlagName(),
- flag.getLocalFlagValue(),
- StorageRequestMessage.LOCAL_ON_REBOOT);
- }
- }
-
- // mark sync has been done
- markerSetting.value = String.valueOf(serverCounter);
- scheduleWriteIfNeededLocked();
- return requests;
- }
- } else {
- return null;
- }
- }
-
@GuardedBy("mLock")
private void loadAconfigDefaultValuesLocked(List<String> filePaths) {
for (String fileName : filePaths) {
diff --git a/packages/SettingsProvider/test/src/com/android/providers/settings/SettingsStateTest.java b/packages/SettingsProvider/test/src/com/android/providers/settings/SettingsStateTest.java
index f798a35012db..81e1aa88c95f 100644
--- a/packages/SettingsProvider/test/src/com/android/providers/settings/SettingsStateTest.java
+++ b/packages/SettingsProvider/test/src/com/android/providers/settings/SettingsStateTest.java
@@ -30,19 +30,20 @@ import android.platform.test.annotations.RequiresFlagsEnabled;
import android.platform.test.flag.junit.CheckFlagsRule;
import android.platform.test.flag.junit.DeviceFlagsValueProvider;
import android.util.Xml;
-import android.util.proto.ProtoOutputStream;
import androidx.test.InstrumentationRegistry;
import androidx.test.runner.AndroidJUnit4;
import com.android.modules.utils.TypedXmlSerializer;
-import android.platform.test.annotations.EnableFlags;
-import android.platform.test.annotations.DisableFlags;
-import android.platform.test.flag.junit.SetFlagsRule;
-
import com.google.common.base.Strings;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
@@ -51,11 +52,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
@RunWith(AndroidJUnit4.class)
public class SettingsStateTest {
@@ -1084,124 +1080,6 @@ public class SettingsStateTest {
assertTrue(flag1.getHasLocalOverride());
}
- @Rule public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
-
- @Test
- @EnableFlags(com.android.aconfig_new_storage.Flags.FLAG_ENABLE_ACONFIG_STORAGE_DAEMON)
- public void testHandleBulkSyncWithAconfigdEnabled() {
- int configKey = SettingsState.makeKey(SettingsState.SETTINGS_TYPE_CONFIG, 0);
- Object lock = new Object();
- SettingsState settingsState =
- new SettingsState(
- InstrumentationRegistry.getContext(),
- lock,
- mSettingsFile,
- configKey,
- SettingsState.MAX_BYTES_PER_APP_PACKAGE_UNLIMITED,
- Looper.getMainLooper());
-
- Map<String, AconfigdFlagInfo> flags = new HashMap<>();
- flags.put(
- "com.android.flags/flag1",
- AconfigdFlagInfo.newBuilder()
- .setPackageName("com.android.flags")
- .setFlagName("flag1")
- .setBootFlagValue("true")
- .setIsReadWrite(true)
- .build());
-
- flags.put(
- "com.android.flags/flag2",
- AconfigdFlagInfo.newBuilder()
- .setPackageName("com.android.flags")
- .setFlagName("flag2")
- .setBootFlagValue("true")
- .setIsReadWrite(false)
- .build());
-
- String bulkSyncMarker = "aconfigd_marker/bulk_synced";
- String bulkSyncCounter =
- "core_experiments_team_internal/" +
- "BulkSyncTriggerCounterFlag__bulk_sync_trigger_counter";
-
- synchronized (lock) {
- settingsState.insertSettingLocked(bulkSyncMarker, "0", null, false, "aconfig");
- settingsState.insertSettingLocked(bulkSyncCounter, "1", null, false,
- "com.google.android.platform.core_experiments_team_internal");
-
- // first bulk sync
- ProtoOutputStream requests = settingsState.handleBulkSyncToNewStorage(flags);
- assertTrue(requests != null);
- String value = settingsState.getSettingLocked("aconfigd_marker/bulk_synced").getValue();
- assertEquals("1", value);
-
- // send time should no longer bulk sync
- requests = settingsState.handleBulkSyncToNewStorage(flags);
- assertNull(requests);
- value = settingsState.getSettingLocked("aconfigd_marker/bulk_synced").getValue();
- assertEquals("1", value);
-
- // won't sync if the marker is string
- settingsState.insertSettingLocked(bulkSyncMarker, "true", null, false, "aconfig");
- settingsState.insertSettingLocked(bulkSyncCounter, "0", null, false,
- "com.google.android.platform.core_experiments_team_internal");
- requests = settingsState.handleBulkSyncToNewStorage(flags);
- assertNull(requests);
- value = settingsState.getSettingLocked("aconfigd_marker/bulk_synced").getValue();
- assertEquals("0", value);
-
- // won't sync if the marker and counter value are the same
- settingsState.insertSettingLocked(bulkSyncMarker, "1", null, false, "aconfig");
- settingsState.insertSettingLocked(bulkSyncCounter, "1", null, false,
- "com.google.android.platform.core_experiments_team_internal");
- requests = settingsState.handleBulkSyncToNewStorage(flags);
- assertNull(requests);
- value = settingsState.getSettingLocked("aconfigd_marker/bulk_synced").getValue();
- assertEquals("1", value);
- }
- }
-
- @Test
- @DisableFlags(com.android.aconfig_new_storage.Flags.FLAG_ENABLE_ACONFIG_STORAGE_DAEMON)
- public void testHandleBulkSyncWithAconfigdDisabled() {
- int configKey = SettingsState.makeKey(SettingsState.SETTINGS_TYPE_CONFIG, 0);
- Object lock = new Object();
- SettingsState settingsState = new SettingsState(
- InstrumentationRegistry.getContext(), lock, mSettingsFile, configKey,
- SettingsState.MAX_BYTES_PER_APP_PACKAGE_UNLIMITED, Looper.getMainLooper());
-
- Map<String, AconfigdFlagInfo> flags = new HashMap<>();
- String bulkSyncMarker = "aconfigd_marker/bulk_synced";
- String bulkSyncCounter =
- "core_experiments_team_internal/" +
- "BulkSyncTriggerCounterFlag__bulk_sync_trigger_counter";
- synchronized (lock) {
- settingsState.insertSettingLocked("aconfigd_marker/bulk_synced",
- "true", null, false, "aconfig");
-
- // when aconfigd is off, should change the marker to false
- ProtoOutputStream requests = settingsState.handleBulkSyncToNewStorage(flags);
- assertNull(requests);
- String value = settingsState.getSettingLocked("aconfigd_marker/bulk_synced").getValue();
- assertEquals("0", value);
-
- // marker started with false value, after call, it should remain false
- requests = settingsState.handleBulkSyncToNewStorage(flags);
- assertNull(requests);
- value = settingsState.getSettingLocked("aconfigd_marker/bulk_synced").getValue();
- assertEquals("0", value);
-
- // won't sync
- settingsState.insertSettingLocked(bulkSyncMarker, "0", null, false, "aconfig");
- settingsState.insertSettingLocked(bulkSyncCounter, "1", null, false,
- "com.google.android.platform.core_experiments_team_internal");
- requests = settingsState.handleBulkSyncToNewStorage(flags);
- assertNull(requests);
- value = settingsState.getSettingLocked("aconfigd_marker/bulk_synced").getValue();
- assertEquals("0", value);
- }
- }
-
@Test
public void testGetAllAconfigFlagsFromSettings() throws Exception {
final Object lock = new Object();
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/mediaprojection/domain/interactor/MediaProjectionChipInteractorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/mediaprojection/domain/interactor/MediaProjectionChipInteractorTest.kt
index d0c5e7a102e0..49df1694d12b 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/mediaprojection/domain/interactor/MediaProjectionChipInteractorTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/mediaprojection/domain/interactor/MediaProjectionChipInteractorTest.kt
@@ -157,7 +157,7 @@ class MediaProjectionChipInteractorTest : SysuiTestCase() {
if (
(it.arguments[0] as Intent).`package` == CAST_TO_OTHER_DEVICES_PACKAGE
) {
- emptyList()
+ emptyList<ResolveInfo>()
} else {
listOf(mock<ResolveInfo>())
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/CastDeviceTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/CastDeviceTest.kt
index 16061df1fa89..8a5797bab33b 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/CastDeviceTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/CastDeviceTest.kt
@@ -63,7 +63,7 @@ class CastDeviceTest : SysuiTestCase() {
doAnswer {
// See Utils.isHeadlessRemoteDisplayProvider
if ((it.arguments[0] as Intent).`package` == HEADLESS_REMOTE_PACKAGE) {
- emptyList()
+ emptyList<ResolveInfo>()
} else {
listOf(mock<ResolveInfo>())
}
diff --git a/services/core/java/com/android/server/am/SettingsToPropertiesMapper.java b/services/core/java/com/android/server/am/SettingsToPropertiesMapper.java
index 8d8064fbf01b..ccc0a25633e5 100644
--- a/services/core/java/com/android/server/am/SettingsToPropertiesMapper.java
+++ b/services/core/java/com/android/server/am/SettingsToPropertiesMapper.java
@@ -113,6 +113,7 @@ public class SettingsToPropertiesMapper {
DeviceConfig.NAMESPACE_LMKD_NATIVE,
DeviceConfig.NAMESPACE_MEDIA_NATIVE,
DeviceConfig.NAMESPACE_MGLRU_NATIVE,
+ DeviceConfig.NAMESPACE_MMD_NATIVE,
DeviceConfig.NAMESPACE_NETD_NATIVE,
DeviceConfig.NAMESPACE_NNAPI_NATIVE,
DeviceConfig.NAMESPACE_PROFCOLLECT_NATIVE_BOOT,
diff --git a/services/core/java/com/android/server/audio/AudioService.java b/services/core/java/com/android/server/audio/AudioService.java
index 5b9bab7eeaf0..b09a192990c8 100644
--- a/services/core/java/com/android/server/audio/AudioService.java
+++ b/services/core/java/com/android/server/audio/AudioService.java
@@ -12506,10 +12506,10 @@ public class AudioService extends IAudioService.Stub
int uid = intent.getIntExtra(Intent.EXTRA_UID, Process.INVALID_UID);
if (intent.getBooleanExtra(EXTRA_REPLACING, false) ||
intent.getBooleanExtra(EXTRA_ARCHIVAL, false)) return;
- if (action.equals(ACTION_PACKAGE_ADDED)) {
+ if (ACTION_PACKAGE_ADDED.equals(action)) {
audioserverExecutor.execute(() ->
provider.onModifyPackageState(uid, pkgName, false /* isRemoved */));
- } else if (action.equals(ACTION_PACKAGE_REMOVED)) {
+ } else if (ACTION_PACKAGE_REMOVED.equals(action)) {
audioserverExecutor.execute(() ->
provider.onModifyPackageState(uid, pkgName, true /* isRemoved */));
}