summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--android/app/Android.bp1
-rw-r--r--android/app/src/com/android/bluetooth/vc/VolumeControlInputDescriptor.java27
-rw-r--r--android/app/src/com/android/bluetooth/vc/VolumeControlService.java7
-rw-r--r--android/app/tests/unit/src/com/android/bluetooth/vc/VolumeControlInputDescriptorTest.java12
-rw-r--r--common/Android.bp15
-rw-r--r--common/bluetooth/constants/aics/GainMode.aidl6
6 files changed, 46 insertions, 22 deletions
diff --git a/android/app/Android.bp b/android/app/Android.bp
index 2efc47100a..83de2861e9 100644
--- a/android/app/Android.bp
+++ b/android/app/Android.bp
@@ -270,6 +270,7 @@ android_app {
"bluetooth-protos-lite",
"bluetooth.change-ids",
"bluetooth.mapsapi",
+ "bluetooth_constants_java",
"com.android.obex",
"com.android.vcard",
"guava",
diff --git a/android/app/src/com/android/bluetooth/vc/VolumeControlInputDescriptor.java b/android/app/src/com/android/bluetooth/vc/VolumeControlInputDescriptor.java
index 759655cf9d..5055ee43a4 100644
--- a/android/app/src/com/android/bluetooth/vc/VolumeControlInputDescriptor.java
+++ b/android/app/src/com/android/bluetooth/vc/VolumeControlInputDescriptor.java
@@ -20,6 +20,11 @@ import android.util.Log;
import com.android.bluetooth.btservice.ProfileService;
+import bluetooth.constants.AudioInputType;
+import bluetooth.constants.aics.AudioInputStatus;
+import bluetooth.constants.aics.GainMode;
+import bluetooth.constants.aics.Mute;
+
class VolumeControlInputDescriptor {
private static final String TAG = VolumeControlInputDescriptor.class.getSimpleName();
@@ -34,23 +39,15 @@ class VolumeControlInputDescriptor {
}
private static class Descriptor {
- int mStatus = 0; // AudioInputStatus.INACTIVE;
+ int mStatus = AudioInputStatus.INACTIVE;
- int mType = 0; // AudioInputType.UNSPECIFIED;
+ int mType = AudioInputType.UNSPECIFIED;
int mGainValue = 0;
- /* See AICS 1.0 - 3.1.3. Gain_Mode field
- * The Gain_Mode field shall be set to a value that reflects whether gain modes are manual
- * or automatic.
- * - Manual Only, the server allows only manual gain.
- * - Automatic Only, the server allows only automatic gain.
- *
- * For all other Gain_Mode field values, the server allows switchable automatic/manual gain.
- */
- int mGainMode = 0;
+ int mGainMode = GainMode.MANUAL_ONLY;
- int mMute = 2; // DISABLED
+ int mMute = Mute.DISABLED;
/* See AICS 1.0
* The Gain_Setting (mGainValue) field is a signed value for which a single increment or
@@ -84,7 +81,7 @@ class VolumeControlInputDescriptor {
}
int getStatus(int id) {
- if (!isValidId(id)) return 0; // AudioInputStatus.INACTIVE;
+ if (!isValidId(id)) return AudioInputStatus.INACTIVE;
return mVolumeInputs[id].mStatus;
}
@@ -104,7 +101,7 @@ class VolumeControlInputDescriptor {
}
int getType(int id) {
- if (!isValidId(id)) return 0; // AudioInputType.UNSPECIFIED;
+ if (!isValidId(id)) return AudioInputType.UNSPECIFIED;
return mVolumeInputs[id].mType;
}
@@ -114,7 +111,7 @@ class VolumeControlInputDescriptor {
}
int getMute(int id) {
- if (!isValidId(id)) return 2; // MuteField.DISABLED
+ if (!isValidId(id)) return Mute.DISABLED;
return mVolumeInputs[id].mMute;
}
diff --git a/android/app/src/com/android/bluetooth/vc/VolumeControlService.java b/android/app/src/com/android/bluetooth/vc/VolumeControlService.java
index 4d0c44adf2..a54142899a 100644
--- a/android/app/src/com/android/bluetooth/vc/VolumeControlService.java
+++ b/android/app/src/com/android/bluetooth/vc/VolumeControlService.java
@@ -63,6 +63,9 @@ import com.android.internal.annotations.VisibleForTesting;
import libcore.util.SneakyThrow;
+import bluetooth.constants.AudioInputType;
+import bluetooth.constants.aics.AudioInputStatus;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -1056,7 +1059,7 @@ public class VolumeControlService extends ProfileService {
return;
}
- if (status != 0 && status != 1) {
+ if (status != AudioInputStatus.INACTIVE && status != AudioInputStatus.ACTIVE) {
Log.e(TAG, logInfo + ": Invalid status argument");
return;
}
@@ -1079,7 +1082,7 @@ public class VolumeControlService extends ProfileService {
return;
}
- if (type > 7) { // AudioInputType.AMBIENT) {
+ if (type > AudioInputType.AMBIENT) {
Log.e(TAG, logInfo + ": Invalid type argument");
return;
}
diff --git a/android/app/tests/unit/src/com/android/bluetooth/vc/VolumeControlInputDescriptorTest.java b/android/app/tests/unit/src/com/android/bluetooth/vc/VolumeControlInputDescriptorTest.java
index 37f52cc4fb..48487d6efc 100644
--- a/android/app/tests/unit/src/com/android/bluetooth/vc/VolumeControlInputDescriptorTest.java
+++ b/android/app/tests/unit/src/com/android/bluetooth/vc/VolumeControlInputDescriptorTest.java
@@ -24,6 +24,8 @@ import android.platform.test.flag.junit.SetFlagsRule;
import androidx.test.filters.SmallTest;
import androidx.test.runner.AndroidJUnit4;
+import bluetooth.constants.aics.Mute;
+
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -111,7 +113,7 @@ public class VolumeControlInputDescriptorTest {
public void setState_withValidIdButIncorrectSettings_valueIsNotUpdated() {
int newGainValue = 42;
int newGainMode = 42;
- int mute = 0; // NOT_MUTED
+ int mute = Mute.NOT_MUTED;
mDescriptor.setState(VALID_ID, newGainMode, newGainMode, mute);
assertThat(mDescriptor.getGain(VALID_ID)).isNotEqualTo(newGainValue);
@@ -128,12 +130,12 @@ public class VolumeControlInputDescriptorTest {
int newGainValue = 42;
int newGainMode = 42;
- int mute = 1; // MUTED
+ int mute = Mute.MUTED;
mDescriptor.setState(VALID_ID, newGainMode, newGainMode, mute);
assertThat(mDescriptor.getGain(VALID_ID)).isEqualTo(newGainValue);
// assertThat(mDescriptor.getGainMode(VALID_ID)).isNotEqualTo(newGainMode);
- assertThat(mDescriptor.getMute(VALID_ID)).isEqualTo(1); // MUTED
+ assertThat(mDescriptor.getMute(VALID_ID)).isEqualTo(mute);
}
@Test
@@ -146,12 +148,12 @@ public class VolumeControlInputDescriptorTest {
int newGainValue = 42;
int newGainMode = 42;
- int mute = 1;
+ int mute = Mute.MUTED;
mDescriptor.setState(INVALID_ID, newGainMode, newGainMode, mute);
assertThat(mDescriptor.getGain(INVALID_ID)).isNotEqualTo(newGainValue);
// assertThat(mDescriptor.getGainMode(VALID_ID)).isNotEqualTo(newGainMode);
- assertThat(mDescriptor.getMute(INVALID_ID)).isEqualTo(2); // DISABLED
+ assertThat(mDescriptor.getMute(INVALID_ID)).isEqualTo(Mute.DISABLED);
}
@Test
diff --git a/common/Android.bp b/common/Android.bp
index 9afdd9dcfc..900cc365d7 100644
--- a/common/Android.bp
+++ b/common/Android.bp
@@ -12,3 +12,18 @@ aidl_library {
],
visibility: ["//packages/modules/Bluetooth:__subpackages__"],
}
+
+// other java component doesn't know how to depend on an aidl_library
+java_library {
+ name: "bluetooth_constants_java",
+ srcs: [
+ "bluetooth/constants/AudioInputType.aidl",
+ "bluetooth/constants/aics/AudioInputStatus.aidl",
+ "bluetooth/constants/aics/GainMode.aidl",
+ "bluetooth/constants/aics/Mute.aidl",
+ ],
+ apex_available: ["com.android.btservices"],
+ min_sdk_version: "Tiramisu",
+ sdk_version: "module_current",
+ visibility: ["//packages/modules/Bluetooth:__subpackages__"],
+}
diff --git a/common/bluetooth/constants/aics/GainMode.aidl b/common/bluetooth/constants/aics/GainMode.aidl
index 97405e75d1..2f3516a290 100644
--- a/common/bluetooth/constants/aics/GainMode.aidl
+++ b/common/bluetooth/constants/aics/GainMode.aidl
@@ -18,6 +18,12 @@ package bluetooth.constants.aics;
/**
* See Audio Input Control Service 1.0 - 2.2.1.3. Gain_Mode field
+ * The Gain_Mode field shall be set to a value that reflects whether gain modes are manual
+ * or automatic.
+ * - Manual Only, the server allows only manual gain.
+ * - Automatic Only, the server allows only automatic gain.
+ *
+ * For all other Gain_Mode field values, the server allows switchable automatic/manual gain.
* {@hide}
*/
@JavaDerive(toString = true)