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

Commit ddc93ce3 authored by Eric Laurent's avatar Eric Laurent
Browse files

AudioManager: do not mandate a looper

Having a listener for audio port updates is not mandatory.
do not throw an excepion when AudioManager is contructed
from a thread without looper.

Bug: 15368707.
Change-Id: If5ce54bf4efdff8b785098649fa1cd0564861e1e
parent 58136d02
Loading
Loading
Loading
Loading
+59 −55
Original line number Diff line number Diff line
@@ -49,9 +49,10 @@ class AudioPortEventHandler {
        // find the looper for our new event handler
        Looper looper = Looper.myLooper();
        if (looper == null) {
            throw new IllegalArgumentException("Calling thread not associated with a looper");
            looper = Looper.getMainLooper();
        }

        if (looper != null) {
            mHandler = new Handler(looper) {
                @Override
                public void handleMessage(Message msg) {
@@ -116,6 +117,9 @@ class AudioPortEventHandler {
                    }
                }
            };
        } else {
            mHandler = null;
        }

        native_setup(new WeakReference<AudioPortEventHandler>(this));
    }