Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - disable HDMI

Tags:

android

hdmi

One of my Android projects needs to switch between 2 HDMI inputs from time to time, possibly once a minute. One HDMI input is from an android device's HDMI output and one is from an external, uncontrollable source.

I found an HDMI switch that automatically switches between 2 sources when the signal becomes available. My question is, is there a way to temporarily (one minute for example) cut HDMI output of my Android device so that the switch can automatically use the second HDMI input? Then, I need to restore the HDMI output so that the switch will show my device's HDMI output.

I found this question but I am not sure I need to disable HDMI output but rather redirect the display in some way and restore it back after 1 minute.

UPDATE

I want to start a bounty so I will clarify my request a bit: I have an HDMI-enabled TV with 2 ports. My android device is connected on port 1, another device is connected on port 2. The TV automatically switches to the next HDMI port that has signal.

For example, if HDMI1 and HDMI2 have signals, I put my TV on HDMI1. When the first device "closes" its HDMI output, the TV will switch to HDMI2. After a while (5 minutes) the first devices "re-opens" HDMI1 (meaning the first device enables its HDMI output) and the second device "closes" its HDMI output so the TV will switch back to HDMI1. This way I can make a mix of videos.

The technical difficulty I am facing is how to control the HDMI output in Android systems. My Android device only has HDMI interface for displaying, it doesn't have a dedicated screen.

The only stuff close enough to what I need is this SO post, but it doesn't really help in my case.

like image 793
Adi Avatar asked Apr 01 '14 06:04

Adi


People also ask

Can HDMI ports be turned off?

If you just want to disable it permanent your answer is in the computer BIOS. You have to access your computers BIOS and set the HDMI Device state to Disabled of Off.


1 Answers

The best approach is to use to use the set of commands related to DisplayID, that allows you to listen for displays to be added, changed or removed.

Here is a quick example how it goes to change your display/HDMI:

    private final DisplayManager.DisplayListener mDisplayListener =
            new DisplayManager.DisplayListener() {
        @Override
        public void onDisplayAdded(int displayId) {
            Log.d(TAG, "Display #" + displayId + " added.");
            mDisplayListAdapter.updateContents();
        }

        @Override
        public void onDisplayChanged(int displayId) {
            Log.d(TAG, "Display #" + displayId + " changed.");
            mDisplayListAdapter.updateContents();
        }

        @Override
        public void onDisplayRemoved(int displayId) {
            Log.d(TAG, "Display #" + displayId + " removed.");
            mDisplayListAdapter.updateContents();
        }
    };

And here how to get all your HDMI/display devices available to connect:

    protected void onResume() {
        // Be sure to call the super class.
        super.onResume();

        // Update our list of displays on resume.
        mDisplayListAdapter.updateContents();

        // Restore presentations from before the activity was paused.
        final int numDisplays = mDisplayListAdapter.getCount();
        for (int i = 0; i < numDisplays; i++) {
            final Display display = mDisplayListAdapter.getItem(i);
            final PresentationContents contents =
                    mSavedPresentationContents.get(display.getDisplayId());
            if (contents != null) {
                showPresentation(display, contents);
            }
        }
        mSavedPresentationContents.clear();

        // Register to receive events from the display manager.
        mDisplayManager.registerDisplayListener(mDisplayListener, null);
    }

To unregister you use:

//unregisterDisplayListener(DisplayManager.DisplayListener);
@Override
protected void onPause() {
    // Be sure to call the super class.
    super.onPause();

    // Unregister from the display manager.
    mDisplayManager.unregisterDisplayListener(mDisplayListener);

    // Dismiss all of our presentations but remember their contents.
    Log.d(TAG, "Activity is being paused.  Dismissing all active presentation.");
    for (int i = 0; i < mActivePresentations.size(); i++) {
        DemoPresentation presentation = mActivePresentations.valueAt(i);
        int displayId = mActivePresentations.keyAt(i);
        mSavedPresentationContents.put(displayId, presentation.mContents);
        presentation.dismiss();
    }
    mActivePresentations.clear();
}

About "invalidate" HDMI output, if it eventually occurs, just redraw it. This should solve any "invalidate", in case it happens.

You might find useful to check further documentation.

like image 122
Avanz Avatar answered Oct 12 '22 10:10

Avanz