FileDocCategorySizeDatePackage
GSMTestHandler.javaAPI DocAndroid 5.1 API3398Thu Mar 12 22:22:54 GMT 2015com.android.internal.telephony.gsm

GSMTestHandler

public class GSMTestHandler extends android.os.HandlerThread implements Handler.Callback
This class creates a HandlerThread which waits for the various messages.

Fields Summary
private android.os.Handler
mHandler
private android.os.Message
mCurrentMessage
private Boolean
mMsgConsumed
private com.android.internal.telephony.test.SimulatedCommands
sc
private com.android.internal.telephony.gsm.GSMPhone
mGSMPhone
private android.content.Context
mContext
private static final int
FAIL_TIMEOUT_MILLIS
Constructors Summary
public GSMTestHandler(android.content.Context context)


       
        super("GSMPhoneTest");
        mMsgConsumed = false;
        mContext = context;
   
Methods Summary
public voidcleanup()

        Looper looper = getLooper();
        if (looper != null) looper.quit();
        mHandler = null;
    
public com.android.internal.telephony.gsm.GSMPhonegetGSMPhone()

        return mGSMPhone;
    
public android.os.HandlergetHandler()

        return mHandler;
    
public com.android.internal.telephony.test.SimulatedCommandsgetSimulatedCommands()

        return sc;
    
public booleanhandleMessage(android.os.Message msg)

        synchronized (this) {
            mCurrentMessage = msg;
            this.notifyAll();
            while(!mMsgConsumed) {
                try {
                    this.wait();
                } catch (InterruptedException e) {}
            }
            mMsgConsumed = false;
        }
        return true;
    
protected voidonLooperPrepared()

        sc = new SimulatedCommands();
        mGSMPhone = new GSMPhone(mContext, sc, new TestPhoneNotifier(), true);
        mHandler = new Handler(getLooper(), this);
        synchronized (this) {
            notifyAll();
        }
    
public android.os.MessagewaitForMessage(int code)

        Message msg;
        while(true) {
            msg = null;
            synchronized (this) {
                try {
                    this.wait(FAIL_TIMEOUT_MILLIS);
                } catch (InterruptedException e) {
                }

                // Check if timeout has occurred.
                if (mCurrentMessage != null) {
                    // Consume the message
                    msg = Message.obtain();
                    msg.copyFrom(mCurrentMessage);
                    mCurrentMessage = null;
                    mMsgConsumed = true;
                    this.notifyAll();
                }
            }
            if (msg == null || code == GSMPhoneTest.ANY_MESSAGE || msg.what == code) return msg;
       }