FileDocCategorySizeDatePackage
ClientTest.javaAPI DocAndroid 5.1 API7370Thu Mar 12 22:22:42 GMT 2015com.android.smspush.unitTests

ClientTest

public class ClientTest extends android.app.Activity
WapPushManager test application

Fields Summary
private static final String
LOG_TAG
private com.android.internal.telephony.IWapPushManager
mWapPushMan
private android.content.ServiceConnection
conn
Constructors Summary
Methods Summary
public voidonCreate(android.os.Bundle savedInstanceState)
Called when the activity is first created.


            
    
        
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        Button addpbtn = (Button) findViewById(R.id.addpkg);
        Button procbtn = (Button) findViewById(R.id.procmsg);
        Button delbtn = (Button) findViewById(R.id.delpkg);

        Log.v(LOG_TAG, "activity created!!");

        addpbtn.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    EditText app_id = (EditText) findViewById(R.id.app_id);
                    EditText cont = (EditText) findViewById(R.id.cont);
                    EditText pkg = (EditText) findViewById(R.id.pkg);
                    EditText cls = (EditText) findViewById(R.id.cls);
                    RadioButton act = (RadioButton) findViewById(R.id.act);
                    CheckBox sig = (CheckBox) findViewById(R.id.sig);
                    CheckBox ftr = (CheckBox) findViewById(R.id.ftr);

                    try {
                        if (!mWapPushMan.addPackage(
                                app_id.getText().toString(),
                                cont.getText().toString(),
                                pkg.getText().toString(),
                                cls.getText().toString(),
                                act.isChecked() ? WapPushManagerParams.APP_TYPE_ACTIVITY :
                                WapPushManagerParams.APP_TYPE_SERVICE,
                                sig.isChecked(), ftr.isChecked())) {

                            Log.w(LOG_TAG, "remote add pkg failed...");
                            mWapPushMan.updatePackage(
                                    app_id.getText().toString(),
                                    cont.getText().toString(),
                                    pkg.getText().toString(),
                                    cls.getText().toString(),
                                    act.isChecked() ? WapPushManagerParams.APP_TYPE_ACTIVITY :
                                    WapPushManagerParams.APP_TYPE_SERVICE,
                                    sig.isChecked(), ftr.isChecked());
                        }
                    } catch (RemoteException e) {
                            Log.w(LOG_TAG, "remote func failed...");
                    }
                }
            });

        delbtn.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    EditText app_id = (EditText) findViewById(R.id.app_id);
                    EditText cont = (EditText) findViewById(R.id.cont);
                    EditText pkg = (EditText) findViewById(R.id.pkg);
                    EditText cls = (EditText) findViewById(R.id.cls);
                    // CheckBox delall = (CheckBox) findViewById(R.id.delall);
                    // Log.d(LOG_TAG, "button clicked");

                    try {
                        mWapPushMan.deletePackage(
                                app_id.getText().toString(),
                                cont.getText().toString(),
                                pkg.getText().toString(),
                                cls.getText().toString());
                        // delall.isChecked());
                    } catch (RemoteException e) {
                        Log.w(LOG_TAG, "remote func failed...");
                    }
                }
            });

        procbtn.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    EditText pdu = (EditText) findViewById(R.id.pdu);
                    EditText app_id = (EditText) findViewById(R.id.app_id);
                    EditText cont = (EditText) findViewById(R.id.cont);

                    // WapPushOverSms wap = new WapPushOverSms();
                    // wap.dispatchWapPdu(strToHex(pdu.getText().toString()));
                    try {
                        Intent intent = new Intent();
                        intent.putExtra("transactionId", 0);
                        intent.putExtra("pduType", 6);
                        intent.putExtra("header",
                                HexDump.hexStringToByteArray(pdu.getText().toString()));
                        intent.putExtra("data",
                                HexDump.hexStringToByteArray(pdu.getText().toString()));

                        mWapPushMan.processMessage(
                                app_id.getText().toString(),
                                cont.getText().toString(),
                                intent);
                        //HexDump.hexStringToByteArray(pdu.getText().toString()), 0, 6, 5, 5);
                    } catch (RemoteException e) {
                        Log.w(LOG_TAG, "remote func failed...");
                    }
                }
            });
    
public voidonDestroy()

        super.onDestroy();
        this.unbindService(conn);
    
public voidonStart()


    
       
        super.onStart();
        Log.v(LOG_TAG, "onStart bind WAPPushManager service "
                + IWapPushManager.class.getName());
        this.bindService(new Intent(IWapPushManager.class.getName()), conn,
                Context.BIND_AUTO_CREATE);
        Log.v(LOG_TAG, "bind service done.");