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

Commit d58d0aa4 authored by Amy's avatar Amy Committed by shubang
Browse files

Add a getPhysicalAddress api to hdmicontrolservice.

ag/5309322

This is helpful when other services need physical address to get the
index of the port according to the physical address reported from the
device connected(not necessarily directly) to the current device.

Test: local tested.
Change-Id: I224a16166e4dabccf81dc34eb479e469c29ac3a0
parent 4ad4e78c
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -431,6 +431,19 @@ public final class HdmiControlManager {
        }
    }

    /**
     * Get the physical address of the device.
     *
     * @hide
     */
    public int getPhysicalAddress() {
        try {
            return mService.getPhysicalAddress();
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Listener used to get hotplug event from HDMI port.
     */
+1 −0
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ interface IHdmiControlService {
    List<HdmiPortInfo> getPortInfo();
    boolean canChangeSystemAudioMode();
    boolean getSystemAudioMode();
    int getPhysicalAddress();
    void setSystemAudioMode(boolean enabled, IHdmiControlCallback callback);
    void addSystemAudioModeChangeListener(IHdmiSystemAudioModeChangeListener listener);
    void removeSystemAudioModeChangeListener(IHdmiSystemAudioModeChangeListener listener);
+5 −0
Original line number Diff line number Diff line
@@ -322,6 +322,11 @@ public class HdmiAudioSystemClientTest {
        @Override
        public void setSystemAudioModeOnForAudioOnlySource() {
        }

        @Override
        public int getPhysicalAddress() {
            return 0x0000;
        }
    }

}
+16 −0
Original line number Diff line number Diff line
@@ -345,6 +345,10 @@ public class HdmiControlService extends SystemService {
    @Nullable
    private Looper mIoLooper;

    // Thread safe physical address
    @GuardedBy("mLock")
    private int mPhysicalAddress = Constants.INVALID_PHYSICAL_ADDRESS;

    // Last input port before switching to the MHL port. Should switch back to this port
    // when the mobile device sends the request one touch play with off.
    // Gets invalidated if we go to other port/input.
@@ -734,6 +738,10 @@ public class HdmiControlService extends SystemService {
        assertRunOnServiceThread();
        HdmiPortInfo[] cecPortInfo = null;

        synchronized (mLock) {
            mPhysicalAddress = getPhysicalAddress();
        }

        // CEC HAL provides majority of the info while MHL does only MHL support flag for
        // each port. Return empty array if CEC HAL didn't provide the info.
        if (mCecController != null) {
@@ -1531,6 +1539,14 @@ public class HdmiControlService extends SystemService {
                    || (audioSystem != null && audioSystem.isSystemAudioActivated());
        }

        @Override
        public int getPhysicalAddress() {
            enforceAccessPermission();
            synchronized (mLock) {
                return mPhysicalAddress;
            }
        }

        @Override
        public void setSystemAudioMode(final boolean enabled, final IHdmiControlCallback callback) {
            enforceAccessPermission();