FileDocCategorySizeDatePackage
UEventObserver.javaAPI DocAndroid 1.5 API6738Wed May 06 22:41:56 BST 2009android.os

UEventObserver

public abstract class UEventObserver extends Object
UEventObserver is an abstract class that receives UEvent's from the kernel.

Subclass UEventObserver, implementing onUEvent(UEvent event), then call startObserving() with a match string. The UEvent thread will then call your onUEvent() method when a UEvent occurs that contains your match string.

Call stopObserving() to stop receiving UEvent's.

There is only one UEvent thread per process, even if that process has multiple UEventObserver subclass instances. The UEvent thread starts when the startObserving() is called for the first time in that process. Once started the UEvent thread will not stop (although it can stop notifying UEventObserver's via stopObserving()).

hide

Fields Summary
private static final String
TAG
private static UEventThread
sThread
private static boolean
sThreadStarted
Constructors Summary
Methods Summary
private static final synchronized voidensureThreadStarted()

        if (sThreadStarted == false) {
            sThread = new UEventThread();
            sThread.start();
            sThreadStarted = true;
        }
    
protected voidfinalize()

        try {
            stopObserving();
        } finally {
            super.finalize();
        }
    
private static native voidnative_setup()

private static native intnext_event(byte[] buffer)

public abstract voidonUEvent(android.os.UEventObserver$UEvent event)
Subclasses of UEventObserver should override this method to handle UEvents.

public final synchronized voidstartObserving(java.lang.String match)
Begin observation of UEvent's.

This method will cause the UEvent thread to start if this is the first invocation of startObserving in this process.

Once called, the UEvent thread will call onUEvent() when an incoming UEvent matches the specified string.

This method can be called multiple times to register multiple matches. Only one call to stopObserving is required even with multiple registered matches.

param
match A substring of the UEvent to match. Use "" to match all UEvent's

        ensureThreadStarted();
        sThread.addObserver(match, this);
    
public final synchronized voidstopObserving()
End observation of UEvent's.

This process's UEvent thread will never call onUEvent() on this UEventObserver after this call. Repeated calls have no effect.

        sThread.removeObserver(this);