Loading android/app/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -270,6 +270,7 @@ android_app { "bluetooth-protos-lite", "bluetooth.change-ids", "bluetooth.mapsapi", "bluetooth_constants_java", "com.android.obex", "com.android.vcard", "guava", Loading android/app/src/com/android/bluetooth/vc/VolumeControlInputDescriptor.java +12 −15 Original line number Diff line number Diff line Loading @@ -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(); Loading @@ -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 Loading Loading @@ -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; } Loading @@ -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; } Loading @@ -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; } Loading android/app/src/com/android/bluetooth/vc/VolumeControlService.java +5 −2 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; } Loading @@ -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; } Loading android/app/tests/unit/src/com/android/bluetooth/vc/VolumeControlInputDescriptorTest.java +7 −5 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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); Loading @@ -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 Loading @@ -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 Loading common/Android.bp +15 −0 Original line number Diff line number Diff line Loading @@ -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__"], } Loading
android/app/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -270,6 +270,7 @@ android_app { "bluetooth-protos-lite", "bluetooth.change-ids", "bluetooth.mapsapi", "bluetooth_constants_java", "com.android.obex", "com.android.vcard", "guava", Loading
android/app/src/com/android/bluetooth/vc/VolumeControlInputDescriptor.java +12 −15 Original line number Diff line number Diff line Loading @@ -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(); Loading @@ -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 Loading Loading @@ -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; } Loading @@ -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; } Loading @@ -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; } Loading
android/app/src/com/android/bluetooth/vc/VolumeControlService.java +5 −2 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; } Loading @@ -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; } Loading
android/app/tests/unit/src/com/android/bluetooth/vc/VolumeControlInputDescriptorTest.java +7 −5 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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); Loading @@ -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 Loading @@ -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 Loading
common/Android.bp +15 −0 Original line number Diff line number Diff line Loading @@ -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__"], }