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

Commit 33603ae9 authored by Mikhail Naganov's avatar Mikhail Naganov
Browse files

MIDI: fix building of properties for the native side

A couple of MIDI device's properties (related to ALSA) are of int type
and can't be transferred as a string. Fixed the code.

As we whitelist properties that can go into native, there is no need to
expect other type of properties besides ints and strings.

Bug: 25945784
Change-Id: I008731d0ffee60c31be0bfddb15dcd1425e4b88e
Test: using a PoC app
parent 29d5936c
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -20,6 +20,8 @@ import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;

import android.util.Log;

/**
 * This class contains information to describe a MIDI device.
 * For now we only have information that can be retrieved easily for USB devices,
@@ -352,9 +354,15 @@ public final class MidiDeviceInfo implements Parcelable {
    private Bundle getBasicProperties(String[] keys) {
        Bundle basicProperties = new Bundle();
        for (String key : keys) {
            String val = mProperties.getString(key);
            Object val = mProperties.get(key);
            if (val != null) {
                basicProperties.putString(key, val);
                if (val instanceof String) {
                    basicProperties.putString(key, (String) val);
                } else if (val instanceof Integer) {
                    basicProperties.putInt(key, (Integer) val);
                } else {
                    Log.w(TAG, "Unsupported property type: " + val.getClass().getName());
                }
            }
        }
        return basicProperties;