00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 package org.openmobileis.embedded.util;
00027
00028 import org.openmobileis.common.util.exception.OpenMISException;
00029 import org.openmobileis.common.util.log.LogManager;
00030
00039 public class PPCSystemAPI implements ISystemAPI{
00040
00041 static {
00042 try {
00043 System.loadLibrary("ppcsystemapi");
00044 } catch (Throwable exi) {
00045 exi.printStackTrace();
00046 LogManager.traceError(0, exi);
00047 }
00048 }
00049
00050 public static final long HKEY_CLASSES_ROOT = 0x80000000;
00051 public static final long HKEY_CURRENT_USER = 0x80000001;
00052 public static final long HKEY_LOCAL_MACHINE = 0x80000002;
00053
00059 public native int execProgramAndWait(String path, String args) throws OpenMISException;
00060
00066 public native int execProgram (String path, String args) throws OpenMISException;
00067
00072 public native String getSystemUniqueID();
00073
00074
00075 private native Long NativeReadPPCRegistryType(long hkey,String regkey,String entity);
00076
00077 private native String NativeReadPPCRegistryString(long hkey,String regkey,String entity);
00078
00079 private native String NativeReadPPCRegistryLong(long hkey,String regkey,String entity);
00080
00081 private native Byte NativeReadPPCRegistryBin(long hkey,String regkey,String entity);
00082
00083 private native String NativeReadPPCRegistryMultiString(long hkey,String regkey,String entity);
00084
00085
00086 public Long readPPCRegistryType(long hkey,String regkey,String entity) {
00087 Long nativetype = NativeReadPPCRegistryType(hkey,regkey,entity);
00088 return nativetype;
00089 }
00090
00091 public String readPPCRegistryMultiString(long hkey,String regkey,String entity) {
00092 String nativetype = NativeReadPPCRegistryMultiString(hkey,regkey,entity);
00093 return nativetype;
00094 }
00095
00096
00097
00098 public String readPPCRegistryString(long hkey,String regkey,String entity) {
00099 String nativetype = NativeReadPPCRegistryString(hkey,regkey,entity);
00100 return nativetype;
00101 }
00102
00103
00104 public long readPPCRegistryLong(long hkey,String regkey,String entity) {
00105 String nativetype = NativeReadPPCRegistryLong(hkey,regkey,entity);
00106 char chartemp1 = nativetype.charAt(0);
00107 char chartemp2 = nativetype.charAt(1);
00108 int i1 = + chartemp1;
00109 int i2 = + chartemp2;
00110 long i3 = (i2 & 0xffffffffL)*65536;
00111 long i4 = i1 + i3;
00112 return i4;
00113 }
00114
00115
00116 public Byte readPPCRegistryBin(long hkey,String regkey,String entity) {
00117 Byte nativetype = NativeReadPPCRegistryBin(hkey,regkey,entity);
00118 return nativetype;
00119 }
00120
00121
00122
00123
00124 public String readPPCRegistryValue (String register,String regkey,String entity){
00125 String valuestring=null;
00126 long valuelong;
00127 Byte valuebyte;
00128 long hkey = 0;
00129 if(register.startsWith("HKEY_CLASSES")){
00130 hkey = HKEY_CLASSES_ROOT;
00131 }if(register.startsWith("HKEY_LOCAL")){
00132 hkey = HKEY_LOCAL_MACHINE;
00133 }if(register.startsWith("HKEY_CURRENT")){
00134 hkey = HKEY_CURRENT_USER;
00135 };
00136 Long type = readPPCRegistryType(hkey, regkey, entity);
00137
00138
00139 if((type.intValue()==1)||(type.intValue()==7)){
00140 valuestring = readPPCRegistryString(hkey, regkey, entity);
00141 }
00142
00143 if(type.intValue()==4){
00144 valuelong = readPPCRegistryLong(hkey, regkey, entity);
00145 valuestring =String.valueOf(valuelong);
00146 }
00147
00148 if(type.intValue()==3){
00149 int temp=0;
00150 valuebyte=readPPCRegistryBin(hkey, regkey, entity);
00151 valuestring = valuebyte.toString();
00152 StringBuffer buf;
00153 buf = new StringBuffer();
00154 for (int pos = 0; temp<((valuestring.length()/6)/2); pos+=6)
00155 {
00156 temp++;
00157 String substring = valuestring.substring(pos, pos+2);
00158 char c = (char) Integer.parseInt(substring, 16);
00159 buf.append(c);
00160
00161 }
00162 valuestring = buf.toString();
00163 }
00164 return valuestring;
00165 }
00166
00167
00172 public long currentTimeInMillis() {
00173 return System.currentTimeMillis();
00174 }
00175 }