USB audio: increase protection of member fields
Replace public by private or package access in field declarations,
and add getters and setters as needed.
Test: compiles OK
Change-Id: Ief3fffb6a21d2e4d05153839f444617ea5e70846
diff --git a/core/java/com/android/internal/alsa/AlsaCardsParser.java b/core/java/com/android/internal/alsa/AlsaCardsParser.java
index 17e8c9c..5b92a17 100644
--- a/core/java/com/android/internal/alsa/AlsaCardsParser.java
+++ b/core/java/com/android/internal/alsa/AlsaCardsParser.java
@@ -49,7 +49,7 @@
public AlsaCardRecord() {}
- public boolean parse(String line, int lineIndex) {
+ private boolean parse(String line, int lineIndex) {
int tokenIndex = 0;
int delimIndex = 0;
@@ -258,7 +258,7 @@
//
// Logging
//
- public void Log(String heading) {
+ private void Log(String heading) {
if (DEBUG) {
Slog.i(TAG, heading);
for (AlsaCardRecord cardRec : mCardRecords) {
@@ -267,7 +267,7 @@
}
}
- static public void LogDevices(String caption, ArrayList<AlsaCardRecord> deviceList) {
+ static private void LogDevices(String caption, ArrayList<AlsaCardRecord> deviceList) {
Slog.d(TAG, caption + " ----------------");
int listIndex = 0;
for (AlsaCardRecord device : deviceList) {
diff --git a/core/java/com/android/internal/alsa/AlsaDevicesParser.java b/core/java/com/android/internal/alsa/AlsaDevicesParser.java
index 758d32d..7cdd897 100644
--- a/core/java/com/android/internal/alsa/AlsaDevicesParser.java
+++ b/core/java/com/android/internal/alsa/AlsaDevicesParser.java
@@ -284,7 +284,7 @@
//
// Loging
//
- public void Log(String heading) {
+ private void Log(String heading) {
if (DEBUG) {
Slog.i(TAG, heading);
for (AlsaDeviceRecord deviceRecord : mDeviceRecords) {
diff --git a/services/usb/java/com/android/server/usb/UsbAlsaManager.java b/services/usb/java/com/android/server/usb/UsbAlsaManager.java
index f13fe33..d315b18 100644
--- a/services/usb/java/com/android/server/usb/UsbAlsaManager.java
+++ b/services/usb/java/com/android/server/usb/UsbAlsaManager.java
@@ -189,10 +189,10 @@
AudioSystem.DEVICE_OUT_USB_DEVICE);
if (DEBUG) {
Slog.i(TAG, "pre-call device:0x" + Integer.toHexString(device) +
- " addr:" + address + " name:" + audioDevice.mDeviceName);
+ " addr:" + address + " name:" + audioDevice.getDeviceName());
}
mAudioService.setWiredDeviceConnectionState(
- device, state, address, audioDevice.mDeviceName, TAG);
+ device, state, address, audioDevice.getDeviceName(), TAG);
}
// Capture Device
@@ -201,7 +201,7 @@
AudioSystem.DEVICE_IN_USB_ACCESSORY :
AudioSystem.DEVICE_IN_USB_DEVICE);
mAudioService.setWiredDeviceConnectionState(
- device, state, address, audioDevice.mDeviceName, TAG);
+ device, state, address, audioDevice.getDeviceName(), TAG);
}
} catch (RemoteException e) {
Slog.e(TAG, "RemoteException in setWiredDeviceConnectionState");
@@ -329,8 +329,7 @@
UsbAudioDevice audioDevice =
new UsbAudioDevice(card, device, hasPlayback, hasCapture, deviceClass);
AlsaCardsParser.AlsaCardRecord cardRecord = mCardsParser.getCardRecordFor(card);
- audioDevice.mDeviceName = cardRecord.mCardName;
- audioDevice.mDeviceDescription = cardRecord.mCardDescription;
+ audioDevice.setDeviceNameAndDescription(cardRecord.mCardName, cardRecord.mCardDescription);
notifyDeviceState(audioDevice, true /*enabled*/);
diff --git a/services/usb/java/com/android/server/usb/UsbAudioDevice.java b/services/usb/java/com/android/server/usb/UsbAudioDevice.java
index c4c8e83..4b17dfe 100644
--- a/services/usb/java/com/android/server/usb/UsbAudioDevice.java
+++ b/services/usb/java/com/android/server/usb/UsbAudioDevice.java
@@ -36,8 +36,8 @@
// This member is a combination of the above bit-flags
public final int mDeviceClass;
- public String mDeviceName = "";
- public String mDeviceDescription = "";
+ private String mDeviceName = "";
+ private String mDeviceDescription = "";
public UsbAudioDevice(int card, int device,
boolean hasPlayback, boolean hasCapture, int deviceClass) {
@@ -60,8 +60,18 @@
}
// called by logDevices
- public String toShortString() {
+ String toShortString() {
return "[card:" + mCard + " device:" + mDevice + " " + mDeviceName + "]";
}
+
+ String getDeviceName() {
+ return mDeviceName;
+ }
+
+ void setDeviceNameAndDescription(String deviceName, String deviceDescription) {
+ mDeviceName = deviceName;
+ mDeviceDescription = deviceDescription;
+ }
+
}