-2

Hi everyone is there anybody who has ever worked with Valor Wave F7020? I want to be able to use the fingerprint capability of the device but most of the stuff are in chinese. I have their sample code but I don't know how to make it work. When I run it whatever I press I get a response in chinese and the captions also are in in chinese


package com.hdsoft.fingerprint;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

import com.pwv.gpctrl.fctrl;

import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.util.Log;
//import android.util.Log;
//import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

public class LibFpDemo extends Activity {
    private static final int MSG_CMD    = 0;
    private static final int MSG_EXIT   = 1;
    private static final int MSG_INFO   = 2;
    private static final int MSG_FIND   = 3;
    private static final int MSG_CANCEL = 4;


    private boolean bContinue = true;   
    private fctrl gpctrl = new fctrl();
    private Button btOpen, btImage, btEnrol, btMatch, btEmpty, btCancel;
    private TextView tvInfo;
    private static final String TAG = "finger";
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState); 

        setContentView(R.layout.activity_main);        

        gpctrl.SetValue(32, 1);
        gpctrl.GetValue(32);
        tvInfo   = (TextView)findViewById(R.id.tvInfo); 
     //   btOpen   = (Button)findViewById(R.id.btOpen);
        btImage  = (Button)findViewById(R.id.btImage);
        btEnrol  = (Button)findViewById(R.id.btEnrol);
        btMatch  = (Button)findViewById(R.id.btMatch);
        btEmpty  = (Button)findViewById(R.id.btEmpty);
        btCancel = (Button)findViewById(R.id.btCancel);





        final ImageView iv = (ImageView)findViewById(R.id.imageView1);


        final Handler handler = new Handler() {   
            public void handleMessage(Message msg) { 
                switch (msg.what) {   
                case MSG_CMD:
                    tvInfo.setText(LibFp.GetError(msg.arg1));
                    if (msg.arg1 == LibFp.FP_OK) {
                        optFinish();
                    }
                    else if (msg.arg1 == LibFp.FP_ERROR_DRIVE) {
                        closeDrive();
                    }
                    break;
                case MSG_EXIT:
                    tvInfo.setText(LibFp.GetError(msg.arg1));
                    if (msg.arg1 == LibFp.FP_ERROR_DRIVE) {
                        closeDrive();
                    }
                    else {
                        optFinish();
                    }
                    break;
                case MSG_INFO:
                    switch (msg.arg1) {
                    case 0:
                        tvInfo.setText("¼ÈëÖ¸ÎÆ, Çë°´ÊÖÖ¸...");
                        break;
                    case 1:
                        tvInfo.setText("ÇëÒÆ¿ªÊÖÖ¸...");
                        break;
                    case 2:
                        tvInfo.setText("Ö¸ÎÆ³É¹¦Èë¿â, µØÖ·±àºÅ = " + msg.arg2 + ", Çë°´ÊÖÖ¸¼ÌÐøÂ¼Èë...");
                        break;
                    default:
                        break;
                    }
                    break;
                case MSG_FIND:
                    optFinish();
                    tvInfo.setText("Ö¸ÎÆÆ¥Åä³É¹¦, ´æ·ÅµØÖ· = " + msg.arg1 + "±È¶ÔµÃ·Ö  = " + msg.arg2);
                    break;
                case MSG_CANCEL:
                    bContinue = true;
                    optFinish();
                    switch (msg.arg1) {
                    case 0:
                        tvInfo.setText("²Ù×÷ÒÑÈ¡Ïû...");
                        break;
                    default:
                        break;
                    }
                    break;
                default: 
                    break;   
                }   
                super.handleMessage(msg);   
            }
        };

        openDrive();

//        btOpen.setOnClickListener(new View.OnClickListener() 
//      {
//          @Override
//          public void onClick(View v) 
//          {               
//              int nRet = LibFp.FpOpenEx((short)0x2109, (short)0x7638);
//              Toast.makeText(LibFpDemo.this,nRet+"111", Toast.LENGTH_SHORT).show();
//              if (nRet == LibFp.FP_ERROR_OPEN) {
//                  LibFp.GetRootRight();
//                  Toast.makeText(LibFpDemo.this,nRet+"22222222", Toast.LENGTH_SHORT).show();
//                  nRet = LibFp.FpOpenEx((short)0x2109, (short)0x7638);        
//                  Toast.makeText(LibFpDemo.this,nRet+"444444444444444444", Toast.LENGTH_SHORT).show();
//              }
//              Toast.makeText(LibFpDemo.this,nRet+"5555555555555555555555555555555", Toast.LENGTH_SHORT).show();
//              if (nRet == LibFp.FP_OK) {
//                  openDrive();
//              }
//              else {
//                  System.out.println(nRet+"444444444444444444");
//                  tvInfo.setText(LibFp.GetError(nRet));
//              }           
//          }
//      });
        btImage.setOnClickListener(new View.OnClickListener() 
        {
            @Override
            public void onClick(View v) 
            {

                open();     
                optStart();

                bContinue = true;
                new Thread(new Runnable() {
                    public void run() {
                        byte bmpData[] = new byte[256*288+1078];
                        int  bmpSize[] = new int[1];
                        while (bContinue) {                     
                            int nRet = LibFp.FpGetImage(0xffffffff, 10000);
                            if (nRet == LibFp.FP_OK) {
                                if ((nRet = LibFp.FpUpBMP(0xffffffff, bmpData, 256*288 + 1078, bmpSize, 10000)) == LibFp.FP_OK) {
                                    final Bitmap bm = BitmapFactory.decodeByteArray(bmpData, 0, 256*288 + 1078);
                                    iv.post(new Runnable() {
                                        public void run() {
                                            iv.setImageBitmap(bm);
                                        }
                                    });
                                }
                            }
                            else{
                                sendInfo(handler, MSG_CMD, 2);
                            }
//                          if (nRet == LibFp.FP_NO_FINGER) {
//                              try {
//                                  Thread.sleep(150);
//                              } catch (InterruptedException e) {
//                              }
//                          }
//                          else {
//                              return;
//                          }

                        }
                        sendInfo(handler, MSG_CANCEL, 0);

                    }}).start();
            }
        });
        btEnrol.setOnClickListener(new View.OnClickListener() 
        {
            @Override
            public void onClick(View v) 
            {
                 open();        
                optStart();
                bContinue = true;
                new Thread(new Runnable() {
                    public void run() {
                        byte nBufferId = 1;
                        byte bmpData[] = new byte[256*288+1078];
                        int  bmpSize[] = new int[1];
                        short nPageId[] = new short[1];
                        if (LibFp.FpValidTempleteNum(0xffffffff, nPageId, 10000) != LibFp.FP_OK) return;
                        sendInfo(handler, MSG_INFO, 0);
                        while (bContinue) {
                            int nRet = LibFp.FpGetImage(0xffffffff, 10000);
                            if (nRet == LibFp.FP_OK) {
                                if ((nRet = LibFp.FpGenChar(0xffffffff, nBufferId, 10000)) == LibFp.FP_OK) {                                    
                                    if ((nRet = LibFp.FpGetImage(0xffffffff, 10000)) == LibFp.FP_OK) {
                                        if ((nRet = LibFp.FpUpBMP(0xffffffff, bmpData, 256*288 + 1078, bmpSize, 10000)) == LibFp.FP_OK) {
                                            final Bitmap bm = BitmapFactory.decodeByteArray(bmpData, 0, 256*288 + 1078);
                                            iv.post(new Runnable() {
                                                public void run() {
                                                    iv.setImageBitmap(bm);
                                                }
                                            });                                     
                                            sendInfo(handler, MSG_INFO, 1);                                         
                                            while ((nRet = LibFp.FpGetImage(0xffffffff, 10000)) != LibFp.FP_NO_FINGER) {
                                                if (nRet != LibFp.FP_OK) {
                                                    sendInfo(handler, MSG_EXIT, nRet);
                                                    return;
                                                }
                                                if (!bContinue) {
                                                    sendInfo(handler, MSG_CANCEL, 0);
                                                    return;
                                                }
                                                try {
                                                    Thread.sleep(150);
                                                } catch (InterruptedException e) {
                                                }
                                            }
                                        }
                                    }
                                    if (nBufferId == 2) {
                                        if ((nRet = LibFp.FpRegModel(0xffffffff, 10000))== LibFp.FP_OK) {                                           
                                            if ((nRet = LibFp.FpStoreChar(0xffffffff, nBufferId, nPageId[0], 10000)) == LibFp.FP_OK) {
                                                sendInfo(handler, MSG_INFO, 2, nPageId[0]);
                                                nBufferId = 1;
                                                nPageId[0] += 1;
                                            }
                                        }
                                        if (nRet != LibFp.FP_OK) {      
                                            sendInfo(handler, MSG_EXIT, nRet);
                                            return;
                                        }                                       
                                    }
                                    else {
                                        nBufferId = 2;
                                        sendInfo(handler, MSG_INFO, 0);
                                    }                                   
                                }
                            }
                            if (nRet != LibFp.FP_OK && nRet != LibFp.FP_NO_FINGER) {
                                sendInfo(handler, MSG_EXIT, nRet);
                                return;
                            }
                        }
                        sendInfo(handler, MSG_CANCEL, 0);
                    }
                }).start();
            }
        });
        btMatch.setOnClickListener(new View.OnClickListener() 
        {
            @Override
            public void onClick(View v) 
            {
                 open();        
                optStart();
                bContinue = true;
                new Thread(new Runnable() {
                    public void run() {
                        byte bmpData[] = new byte[256*288+1078];
                        int  bmpSize[] = new int[1];
                        short nNum[] = new short[1];
                        short nAddr[] = new short[1];
                        short nScore[] = new short[1];
                        if (LibFp.FpValidTempleteNum(0xffffffff, nNum, 10000) != LibFp.FP_OK) return;
                        while (bContinue) {
                            int nRet = LibFp.FpGetImage(0xffffffff, 10000);
                            if (nRet == LibFp.FP_OK) {
                                if ((nRet = LibFp.FpGenChar(0xffffffff, (byte)1, 10000)) == LibFp.FP_OK) {                                  
                                    if ((nRet = LibFp.FpGetImage(0xffffffff, 10000)) == LibFp.FP_OK) {
                                        if ((nRet = LibFp.FpUpBMP(0xffffffff, bmpData, 256*288 + 1078, bmpSize, 10000)) == LibFp.FP_OK) {
                                            final Bitmap bm = BitmapFactory.decodeByteArray(bmpData, 0, 256*288 + 1078);
                                            iv.post(new Runnable() {
                                                public void run() {
                                                    iv.setImageBitmap(bm);
                                                }
                                            }); 
                                            if ((nRet = LibFp.FpSearch(0xffffffff, (byte)1, (short)0, nNum[0], nAddr, nScore, 10000)) == LibFp.FP_OK) {                                         
                                                sendInfo(handler, MSG_FIND, nAddr[0], nScore[0]);
                                            }
                                            else {
                                                sendInfo(handler, MSG_EXIT, nRet);
                                            }
                                            return;
                                        }
                                    }
                                }                               
                            }
                            if (nRet == LibFp.FP_NO_FINGER) {
                                sendInfo(handler, MSG_CMD, nRet);
                            }
                            else if (nRet != LibFp.FP_OK) {
                                sendInfo(handler, MSG_EXIT, nRet);
                                return;
                            }
                        }
                        sendInfo(handler, MSG_CANCEL, 0);
                    }
                }).start();
            }
        });
        btEmpty.setOnClickListener(new View.OnClickListener() 
        {
            @Override
            public void onClick(View v) 
            {
                 open();        
                short nNum[] = new short[1];
                int nRet =  LibFp.FpValidTempleteNum(0xffffffff, nNum, 10000);
                if (nRet == LibFp.FP_OK) {                  
                    if ((nRet = LibFp.FpEmpty(0xffffffff, 10000)) == LibFp.FP_OK) {
                        tvInfo.setText("Çå¿ÕÖ¸ÎÆ¿âÍê³É£¬×ܹ²Çå¿ÕÖ¸ÎÆ " + nNum[0]+ " Ïî");
                        return;
                    }
                }
                tvInfo.setText(LibFp.GetError(nRet));               
            }
        });
        btCancel.setOnClickListener(new View.OnClickListener() 
        {
            @Override
            public void onClick(View v) 
            {
                bContinue = false;  
            }
        });
    }
    @Override

    public void onDestroy() {
        super.onDestroy();
        System.out.println("onDestroy");
    }
    @Override
    protected void onResume()
    {   
        super.onResume();

    }
    @Override
    public void onPause()
    {
        bContinue = false;
        try {
            Thread.sleep(600);
        } catch (InterruptedException e) {
        }
        closeDrive();
        super.onPause();
        LibFp.FpClose();

    }

    private void sendInfo(Handler handler, int nMsg, int arg1){
        Message msg = handler.obtainMessage();
        msg.what = nMsg;
        msg.arg1 = arg1;
        handler.sendMessage(msg);
        System.out.println("sendInfo1");
    }

    private void sendInfo(Handler handler, int nMsg, int arg1, int arg2){
        Message msg = handler.obtainMessage();
        msg.what = nMsg;
        msg.arg1 = arg1;
        msg.arg2 = arg2;
        handler.sendMessage(msg);
        System.out.println("sendInfo2");
    }
    private void optStart() {
        btImage.setEnabled(false);
        btEnrol.setEnabled(false);
        btMatch.setEnabled(false);
        btEmpty.setEnabled(false);
        btCancel.setEnabled(true);
    }
    private void optFinish() {
        btImage.setEnabled(true);
        btEnrol.setEnabled(true);
        btMatch.setEnabled(true);
        btEmpty.setEnabled(true);
        btCancel.setEnabled(false);
    }
    private void openDrive() {
        //btOpen.setEnabled(false);
        btImage.setEnabled(true);
        btEnrol.setEnabled(true);
        btMatch.setEnabled(true);
        btEmpty.setEnabled(true);
        btCancel.setEnabled(false);
        tvInfo.setText("É豸ÒÑ´ò¿ª...");
    }
    private void closeDrive() {
        //btOpen.setEnabled(true);
        btImage.setEnabled(false);
        btEnrol.setEnabled(false);
        btMatch.setEnabled(false);
        btEmpty.setEnabled(false);
        btCancel.setEnabled(false);
        tvInfo.setText("ÒѹرÕÉ豸£¬ÇëÖØÐ´ò¿ª...");
    }
    public void onBackPressed() {
        // TODO Auto-generated method stub
        super.onBackPressed();
        gpctrl.SetValue(32, 0);
        gpctrl.GetValue(32);
        this.finish();
    }

    public void open(){
        int nRet = LibFp.FpOpenEx((short)0x2109, (short)0x7638);
        if (nRet == LibFp.FP_ERROR_OPEN) {
            LibFp.GetRootRight();
            nRet = LibFp.FpOpenEx((short)0x2109, (short)0x7638);    
        }
        if (nRet == LibFp.FP_OK) {
        }
        else {

            tvInfo.setText(LibFp.GetError(nRet));
        }
    }
  }

******************* activity_main.xml ****************

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

  <!--  <LinearLayout
        android:id="@+id/linearLayout1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

        <Button
            android:id="@+id/btOpen"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/a1" />
    </LinearLayout>
 --> 
    <LinearLayout
        android:id="@+id/linearLayout2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/linearLayout1"
        android:orientation="horizontal" >

        <Button
            android:id="@+id/btImage"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:enabled="false"
            android:text="@string/a2" />

        <Button
            android:id="@+id/btEnrol"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:enabled="false"
            android:text="@string/a3" />
        <Button
            android:id="@+id/btMatch"
             android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:enabled="false"
            android:text="@string/a4" />

        <Button
            android:id="@+id/btEmpty"
             android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:enabled="false"
            android:text="@string/a5" />

        <Button
            android:id="@+id/btCancel"
             android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:enabled="false"
            android:text="@string/a6" />

    </LinearLayout>

    <TextView
        android:id="@+id/tvInfo"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/linearLayout2"
        android:layout_marginTop="29dp"
        android:text="@string/hello_world"
        tools:context=".MainActivity" />

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/tvInfo"
        android:layout_marginLeft="58dp"
        android:layout_marginTop="22dp"/>
        <!-- android:src="@drawable/logo" --> 

</RelativeLayout>

***************** strings.xml *****************

<resources>

    <string name="app_name">fingerprint</string>
    <string name="hello_world">Demo程序, 仅供参考!</string>
    <string name="menu_settings">Settings</string>
    <string name="title_activity_main">MainActivity</string>
    <string name="a1">打开设备</string>
    <string name="a2">获取图像</string>
    <string name="a3">录入指纹</string>
    <string name="a4">指纹匹配</string>
    <string name="a5">清空指纹库</string>
    <string name="a6">取消操作</string>

</resources>
Freeman
  • 17
  • 5
  • As it stands, the answer to your question can only be YES. Has anybody ever worked with that device ? Probably. Is that a programming question ? Certainly not. – 2Dee Aug 13 '15 at 08:23

1 Answers1

0

Here are the translations of the UI captions in the code snippet you posted.

A1 Open Device 打开设备 A2 Get Image 获取图像 A3 Fingerprint Entry 录入指纹 A4 Fingerprint Matching 指纹匹配 A5 Empty Fingerprint Database 清空指纹库 A6 Cancel 取消操作 Demo Program 程序 Hello world For reference only 仅供参考