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

Commit 20137dc1 authored by Glenn Kasten's avatar Glenn Kasten
Browse files

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
parent 02adf09e
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -49,7 +49,7 @@ public class AlsaCardsParser {

        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 @@ public class AlsaCardsParser {
    //
    // 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 @@ public class AlsaCardsParser {
        }
    }

    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) {
+1 −1
Original line number Diff line number Diff line
@@ -284,7 +284,7 @@ public class AlsaDevicesParser {
    //
    // Loging
    //
    public void Log(String heading) {
    private void Log(String heading) {
        if (DEBUG) {
            Slog.i(TAG, heading);
            for (AlsaDeviceRecord deviceRecord : mDeviceRecords) {
+4 −5
Original line number Diff line number Diff line
@@ -189,10 +189,10 @@ public final class UsbAlsaManager {
                        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 @@ public final class UsbAlsaManager {
                        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 @@ public final class UsbAlsaManager {
        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*/);

+13 −3
Original line number Diff line number Diff line
@@ -36,8 +36,8 @@ public final class UsbAudioDevice {
    // 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 @@ public final class UsbAudioDevice {
    }

    // 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;
    }

}