|
@@ -1,53 +1,67 @@
|
|
|
package com.usai.util;
|
|
package com.usai.util;
|
|
|
|
|
|
|
|
import java.io.BufferedReader;
|
|
import java.io.BufferedReader;
|
|
|
-import java.io.File;
|
|
|
|
|
-import java.io.FileNotFoundException;
|
|
|
|
|
-import java.io.FileOutputStream;
|
|
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
|
import java.io.InputStream;
|
|
import java.io.InputStream;
|
|
|
import java.io.InputStreamReader;
|
|
import java.io.InputStreamReader;
|
|
|
-import java.io.OutputStreamWriter;
|
|
|
|
|
-import java.io.UnsupportedEncodingException;
|
|
|
|
|
import java.net.HttpURLConnection;
|
|
import java.net.HttpURLConnection;
|
|
|
import java.net.MalformedURLException;
|
|
import java.net.MalformedURLException;
|
|
|
|
|
+import java.net.Socket;
|
|
|
import java.net.URL;
|
|
import java.net.URL;
|
|
|
-import java.util.HashSet;
|
|
|
|
|
|
|
+import java.net.UnknownHostException;
|
|
|
|
|
+import java.security.KeyManagementException;
|
|
|
|
|
+import java.security.KeyStore;
|
|
|
|
|
+import java.security.KeyStoreException;
|
|
|
|
|
+import java.security.NoSuchAlgorithmException;
|
|
|
|
|
+import java.security.UnrecoverableKeyException;
|
|
|
import java.util.Iterator;
|
|
import java.util.Iterator;
|
|
|
import java.util.Set;
|
|
import java.util.Set;
|
|
|
|
|
|
|
|
|
|
+import javax.net.ssl.SSLContext;
|
|
|
|
|
+import javax.net.ssl.TrustManager;
|
|
|
|
|
+import javax.net.ssl.X509TrustManager;
|
|
|
|
|
+
|
|
|
import org.apache.http.HttpEntity;
|
|
import org.apache.http.HttpEntity;
|
|
|
import org.apache.http.HttpResponse;
|
|
import org.apache.http.HttpResponse;
|
|
|
import org.apache.http.HttpStatus;
|
|
import org.apache.http.HttpStatus;
|
|
|
|
|
+import org.apache.http.HttpVersion;
|
|
|
import org.apache.http.client.HttpClient;
|
|
import org.apache.http.client.HttpClient;
|
|
|
import org.apache.http.client.methods.HttpPost;
|
|
import org.apache.http.client.methods.HttpPost;
|
|
|
|
|
+import org.apache.http.conn.ClientConnectionManager;
|
|
|
import org.apache.http.conn.ConnectTimeoutException;
|
|
import org.apache.http.conn.ConnectTimeoutException;
|
|
|
|
|
+import org.apache.http.conn.scheme.PlainSocketFactory;
|
|
|
|
|
+import org.apache.http.conn.scheme.Scheme;
|
|
|
|
|
+import org.apache.http.conn.scheme.SchemeRegistry;
|
|
|
|
|
+import org.apache.http.conn.ssl.SSLSocketFactory;
|
|
|
import org.apache.http.entity.mime.HttpMultipartMode;
|
|
import org.apache.http.entity.mime.HttpMultipartMode;
|
|
|
import org.apache.http.entity.mime.MultipartEntity;
|
|
import org.apache.http.entity.mime.MultipartEntity;
|
|
|
-import org.apache.http.entity.mime.content.FileBody;
|
|
|
|
|
import org.apache.http.entity.mime.content.StringBody;
|
|
import org.apache.http.entity.mime.content.StringBody;
|
|
|
import org.apache.http.impl.client.DefaultHttpClient;
|
|
import org.apache.http.impl.client.DefaultHttpClient;
|
|
|
|
|
+import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
|
|
|
import org.apache.http.params.BasicHttpParams;
|
|
import org.apache.http.params.BasicHttpParams;
|
|
|
import org.apache.http.params.HttpConnectionParams;
|
|
import org.apache.http.params.HttpConnectionParams;
|
|
|
-import org.json.JSONArray;
|
|
|
|
|
|
|
+import org.apache.http.params.HttpParams;
|
|
|
|
|
+import org.apache.http.params.HttpProtocolParams;
|
|
|
|
|
+import org.apache.http.protocol.HTTP;
|
|
|
import org.json.JSONException;
|
|
import org.json.JSONException;
|
|
|
import org.json.JSONObject;
|
|
import org.json.JSONObject;
|
|
|
|
|
|
|
|
import com.usai.apex.ApexTrackingApplication;
|
|
import com.usai.apex.ApexTrackingApplication;
|
|
|
-
|
|
|
|
|
-import android.R.integer;
|
|
|
|
|
-import android.R.string;
|
|
|
|
|
import android.content.Context;
|
|
import android.content.Context;
|
|
|
-import android.content.Intent;
|
|
|
|
|
import android.content.SharedPreferences.Editor;
|
|
import android.content.SharedPreferences.Editor;
|
|
|
|
|
+import android.database.DatabaseUtils.InsertHelper;
|
|
|
|
|
+import android.database.sqlite.SQLiteDatabase;
|
|
|
|
|
+import android.database.sqlite.SQLiteStatement;
|
|
|
import android.net.ConnectivityManager;
|
|
import android.net.ConnectivityManager;
|
|
|
import android.net.NetworkInfo;
|
|
import android.net.NetworkInfo;
|
|
|
import android.os.Bundle;
|
|
import android.os.Bundle;
|
|
|
-import android.os.Environment;
|
|
|
|
|
import android.util.Log;
|
|
import android.util.Log;
|
|
|
|
|
|
|
|
public class Network
|
|
public class Network
|
|
|
{
|
|
{
|
|
|
|
|
+ public static final int BEHAVIOR_SEARCH = 0;
|
|
|
|
|
+ public static final int BEHAVIOR_RESULT = 1;
|
|
|
|
|
+
|
|
|
private static final int REQUEST_TIMEOUT = 5 * 1000;// request time out 20
|
|
private static final int REQUEST_TIMEOUT = 5 * 1000;// request time out 20
|
|
|
// secs
|
|
// secs
|
|
|
private static final int SO_TIMEOUT = 5 * 1000; // so time out 20 secs;
|
|
private static final int SO_TIMEOUT = 5 * 1000; // so time out 20 secs;
|
|
@@ -87,20 +101,20 @@ public class Network
|
|
|
// "http://192.168.1.10/xampp/verify_user.php";
|
|
// "http://192.168.1.10/xampp/verify_user.php";
|
|
|
// static String URL_UPLOAD_PHOTO =
|
|
// static String URL_UPLOAD_PHOTO =
|
|
|
// "http://192.168.1.10/xampp/save_upload_file.php";
|
|
// "http://192.168.1.10/xampp/save_upload_file.php";
|
|
|
- public static String URL_VERIFY_USER = "http://192.168.23.1/xampp/apex_user.php";
|
|
|
|
|
- public static String URL_UPDATE_AUTH = "http://192.168.23.1/xampp/apex_auth.php";
|
|
|
|
|
- public static String FAKE_URL_UPDATE_AUTH = "http://192.168.23.1/xampp/auth.json";
|
|
|
|
|
- public static String FAKE_SEARCH = "http://192.168.23.1/xampp/recordset.json";
|
|
|
|
|
|
|
+// public static String URL_VERIFY_USER = "https://ra.apexshipping.com/login.php";
|
|
|
|
|
+ public static String URL_UPDATE_AUTH = "https://ra.apexshipping.com/login.php";
|
|
|
|
|
+// public static String FAKE_URL_UPDATE_AUTH = "https://192.168.23.1/xampp/auth.json";
|
|
|
|
|
+// public static String FAKE_SEARCH = "https://192.168.23.1/xampp/recordset.json";
|
|
|
|
|
|
|
|
// static String URL_UPLOAD_PHOTO =
|
|
// static String URL_UPLOAD_PHOTO =
|
|
|
// "http://192.168.23.1/xampp/save_upload_file.php";
|
|
// "http://192.168.23.1/xampp/save_upload_file.php";
|
|
|
-
|
|
|
|
|
- private static String fakegetJson(String url)
|
|
|
|
|
- {
|
|
|
|
|
- return download(url, 10000);
|
|
|
|
|
- // return null;
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ //
|
|
|
|
|
+ private static String fakegetJson(String url)
|
|
|
|
|
+ {
|
|
|
|
|
+ return download(url, 10000);
|
|
|
|
|
+ // return null;
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
public static String download(String urlStr, int timeout)
|
|
public static String download(String urlStr, int timeout)
|
|
|
{
|
|
{
|
|
@@ -169,20 +183,104 @@ public class Network
|
|
|
return sb.toString();
|
|
return sb.toString();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private static HttpClient getNewHttpClient()
|
|
|
|
|
+ {
|
|
|
|
|
+ try
|
|
|
|
|
+ {
|
|
|
|
|
+ KeyStore trustStore = KeyStore.getInstance(KeyStore
|
|
|
|
|
+ .getDefaultType());
|
|
|
|
|
+ trustStore.load(null, null);
|
|
|
|
|
+
|
|
|
|
|
+ SSLSocketFactory sf = new SSLSocketFactoryEx(trustStore);
|
|
|
|
|
+ sf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
|
|
|
|
|
+
|
|
|
|
|
+ HttpParams params = new BasicHttpParams();
|
|
|
|
|
+ HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
|
|
|
|
|
+ HttpProtocolParams.setContentCharset(params, HTTP.UTF_8);
|
|
|
|
|
+ HttpConnectionParams.setConnectionTimeout(params, REQUEST_TIMEOUT);
|
|
|
|
|
+ HttpConnectionParams.setSoTimeout(params, SO_TIMEOUT);
|
|
|
|
|
+ SchemeRegistry registry = new SchemeRegistry();
|
|
|
|
|
+ registry.register(new Scheme("http", PlainSocketFactory
|
|
|
|
|
+ .getSocketFactory(), 80));
|
|
|
|
|
+ registry.register(new Scheme("https", sf, 443));
|
|
|
|
|
+
|
|
|
|
|
+ ClientConnectionManager ccm = new ThreadSafeClientConnManager(
|
|
|
|
|
+ params, registry);
|
|
|
|
|
+
|
|
|
|
|
+ return new DefaultHttpClient(ccm, params);
|
|
|
|
|
+ }
|
|
|
|
|
+ catch (Exception e)
|
|
|
|
|
+ {
|
|
|
|
|
+ return new DefaultHttpClient();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // HttpClient getHttpsClient()
|
|
|
|
|
+ // {
|
|
|
|
|
+ // KeyStore trustStore;
|
|
|
|
|
+ // try
|
|
|
|
|
+ // {
|
|
|
|
|
+ // trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
|
|
|
|
|
+ // trustStore.load(null, null);
|
|
|
|
|
+ // SSLSocketFactory sf = new MySSLSocketFactory(trustStore);
|
|
|
|
|
+ // sf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
|
|
|
|
|
+ //
|
|
|
|
|
+ // SchemeRegistry registry = new SchemeRegistry();
|
|
|
|
|
+ // registry.register(new Scheme("http", PlainSocketFactory
|
|
|
|
|
+ // .getSocketFactory(), 80));
|
|
|
|
|
+ // registry.register(new Scheme("https", sf, 443));
|
|
|
|
|
+ //
|
|
|
|
|
+ // ClientConnectionManager ccm = new ThreadSafeClientConnManager(
|
|
|
|
|
+ // params, registry);
|
|
|
|
|
+ // }
|
|
|
|
|
+ // catch (KeyStoreException e)
|
|
|
|
|
+ // {
|
|
|
|
|
+ // // TODO Auto-generated catch block
|
|
|
|
|
+ // e.printStackTrace();
|
|
|
|
|
+ // }
|
|
|
|
|
+ // catch (NoSuchAlgorithmException e)
|
|
|
|
|
+ // {
|
|
|
|
|
+ // // TODO Auto-generated catch block
|
|
|
|
|
+ // e.printStackTrace();
|
|
|
|
|
+ // }
|
|
|
|
|
+ // catch (CertificateException e)
|
|
|
|
|
+ // {
|
|
|
|
|
+ // // TODO Auto-generated catch block
|
|
|
|
|
+ // e.printStackTrace();
|
|
|
|
|
+ // }
|
|
|
|
|
+ // catch (IOException e)
|
|
|
|
|
+ // {
|
|
|
|
|
+ // // TODO Auto-generated catch block
|
|
|
|
|
+ // e.printStackTrace();
|
|
|
|
|
+ // }
|
|
|
|
|
+ // catch (KeyManagementException e)
|
|
|
|
|
+ // {
|
|
|
|
|
+ // // TODO Auto-generated catch block
|
|
|
|
|
+ // e.printStackTrace();
|
|
|
|
|
+ // }
|
|
|
|
|
+ // catch (UnrecoverableKeyException e)
|
|
|
|
|
+ // {
|
|
|
|
|
+ // // TODO Auto-generated catch block
|
|
|
|
|
+ // e.printStackTrace();
|
|
|
|
|
+ // }
|
|
|
|
|
+ //
|
|
|
|
|
+ // }
|
|
|
|
|
+
|
|
|
public static String getJson(String url, Bundle parms)
|
|
public static String getJson(String url, Bundle parms)
|
|
|
{
|
|
{
|
|
|
String TAG = "net_dbg@GetJson";
|
|
String TAG = "net_dbg@GetJson";
|
|
|
Log.d(TAG, "entry");
|
|
Log.d(TAG, "entry");
|
|
|
|
|
|
|
|
- if (true)
|
|
|
|
|
- return fakegetJson(url);
|
|
|
|
|
|
|
+// if (true)
|
|
|
|
|
+// return fakegetJson(url);
|
|
|
try
|
|
try
|
|
|
{
|
|
{
|
|
|
- BasicHttpParams httpParams = new BasicHttpParams();
|
|
|
|
|
- HttpConnectionParams.setConnectionTimeout(httpParams,
|
|
|
|
|
- REQUEST_TIMEOUT);
|
|
|
|
|
- HttpConnectionParams.setSoTimeout(httpParams, SO_TIMEOUT);
|
|
|
|
|
- HttpClient client = new DefaultHttpClient(httpParams);
|
|
|
|
|
|
|
+ // BasicHttpParams httpParams = new BasicHttpParams();
|
|
|
|
|
+ // HttpConnectionParams.setConnectionTimeout(httpParams,
|
|
|
|
|
+ // REQUEST_TIMEOUT);
|
|
|
|
|
+ // HttpConnectionParams.setSoTimeout(httpParams, SO_TIMEOUT);
|
|
|
|
|
+ HttpClient client = getNewHttpClient();// new
|
|
|
|
|
+ // DefaultHttpClient(httpParams);
|
|
|
HttpPost post = new HttpPost(url);
|
|
HttpPost post = new HttpPost(url);
|
|
|
MultipartEntity reqEntity = new MultipartEntity(
|
|
MultipartEntity reqEntity = new MultipartEntity(
|
|
|
HttpMultipartMode.BROWSER_COMPATIBLE);
|
|
HttpMultipartMode.BROWSER_COMPATIBLE);
|
|
@@ -729,6 +827,7 @@ public class Network
|
|
|
{
|
|
{
|
|
|
|
|
|
|
|
String TAG = "net_dbg@get_Auth";
|
|
String TAG = "net_dbg@get_Auth";
|
|
|
|
|
+ Log.d(TAG,"u:"+name+";p:"+password);
|
|
|
if (!Network.NetworkIsAvailable())
|
|
if (!Network.NetworkIsAvailable())
|
|
|
{
|
|
{
|
|
|
Log.d(TAG, "network not available!");
|
|
Log.d(TAG, "network not available!");
|
|
@@ -737,11 +836,12 @@ public class Network
|
|
|
Bundle parms = new Bundle();
|
|
Bundle parms = new Bundle();
|
|
|
parms.putString("user", name);
|
|
parms.putString("user", name);
|
|
|
parms.putString("password", password);
|
|
parms.putString("password", password);
|
|
|
|
|
+ parms.putString("action", "handset_login");
|
|
|
int ver = ApexTrackingApplication.get_instance()
|
|
int ver = ApexTrackingApplication.get_instance()
|
|
|
.getSharedPreferences("Apex_auth", Context.MODE_PRIVATE)
|
|
.getSharedPreferences("Apex_auth", Context.MODE_PRIVATE)
|
|
|
.getInt("AuthInfoVer", 0);
|
|
.getInt("AuthInfoVer", 0);
|
|
|
parms.putString("auth_ver", ver + "");
|
|
parms.putString("auth_ver", ver + "");
|
|
|
- String jstr = getJson(Network.FAKE_URL_UPDATE_AUTH, parms);
|
|
|
|
|
|
|
+ String jstr = getJson(Network.URL_UPDATE_AUTH, parms);
|
|
|
/*
|
|
/*
|
|
|
* error occur while get authorization info from server. include can not
|
|
* error occur while get authorization info from server. include can not
|
|
|
* reach server , wrong parms ,server get wrong , etc.
|
|
* reach server , wrong parms ,server get wrong , etc.
|
|
@@ -752,21 +852,22 @@ public class Network
|
|
|
return Network.RESULT_NET_ERROR;
|
|
return Network.RESULT_NET_ERROR;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- return parse_authinfo(jstr);
|
|
|
|
|
|
|
+ return parse_authinfo(jstr,name);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private static int parse_authinfo(String json)
|
|
|
|
|
|
|
+ private static int parse_authinfo(String json,String user)
|
|
|
{
|
|
{
|
|
|
String TAG = "net_dbg@parse_authinfo";
|
|
String TAG = "net_dbg@parse_authinfo";
|
|
|
|
|
+ Log.d(TAG,json);
|
|
|
// JSONArray array;
|
|
// JSONArray array;
|
|
|
JSONObject jsobj;
|
|
JSONObject jsobj;
|
|
|
|
|
+ SQLiteDatabase db = null;
|
|
|
try
|
|
try
|
|
|
|
|
|
|
|
{
|
|
{
|
|
|
|
|
|
|
|
// array = new JSONArray(json);
|
|
// array = new JSONArray(json);
|
|
|
jsobj = new JSONObject(json);
|
|
jsobj = new JSONObject(json);
|
|
|
- ;
|
|
|
|
|
if (jsobj.length() > 0)
|
|
if (jsobj.length() > 0)
|
|
|
{
|
|
{
|
|
|
// JSONObject objresult = jsobj.get.getJSONObject(0);// result
|
|
// JSONObject objresult = jsobj.get.getJSONObject(0);// result
|
|
@@ -788,7 +889,7 @@ public class Network
|
|
|
// on
|
|
// on
|
|
|
// server;
|
|
// server;
|
|
|
ApexTrackingApplication.put_sessionid(objheader
|
|
ApexTrackingApplication.put_sessionid(objheader
|
|
|
- .getInt("sessionid"));
|
|
|
|
|
|
|
+ .getString("sessionid"));
|
|
|
// JSONObject objupdate = array.getJSONObject(3); // whether
|
|
// JSONObject objupdate = array.getJSONObject(3); // whether
|
|
|
// need
|
|
// need
|
|
|
// update ;
|
|
// update ;
|
|
@@ -809,21 +910,85 @@ public class Network
|
|
|
editor.putInt("AuthInfoVer", objheader.getInt("ver"));
|
|
editor.putInt("AuthInfoVer", objheader.getInt("ver"));
|
|
|
JSONObject objfuncs = jsobj.getJSONObject("functions");
|
|
JSONObject objfuncs = jsobj.getJSONObject("functions");
|
|
|
Iterator it = objfuncs.keys();
|
|
Iterator it = objfuncs.keys();
|
|
|
- while (it.hasNext())
|
|
|
|
|
|
|
+ db = dbUtil.OpenDB(ApexTrackingApplication
|
|
|
|
|
+ .get_instance(), null, true);
|
|
|
|
|
+ String sql = "insert into fields_info(name,aname,field_type,function_name,behavior,priority,show,user) values(?,?,?,?,?,?,?,?)";
|
|
|
|
|
+ db.execSQL("update fields_info set abandon = 1 where user ='"+user+"'");
|
|
|
|
|
+ SQLiteStatement stat = db.compileStatement(sql);
|
|
|
|
|
+ db.beginTransaction();
|
|
|
|
|
+ String field_name,field_type,alias_name;
|
|
|
|
|
+ while (it.hasNext()) // loop for each function
|
|
|
{
|
|
{
|
|
|
- String key = (String) it.next();
|
|
|
|
|
-
|
|
|
|
|
-// Set<String> funset = new HashSet<String>();
|
|
|
|
|
- JSONObject objfun = objfuncs.getJSONObject(key);
|
|
|
|
|
-
|
|
|
|
|
- editor.putString(key,objfun.toString());
|
|
|
|
|
|
|
+ String func_name = (String) it.next();
|
|
|
|
|
+
|
|
|
|
|
+ // Set<String> funset = new HashSet<String>();
|
|
|
|
|
+ JSONObject objfun = objfuncs.getJSONObject(func_name);
|
|
|
|
|
+ int behavior,priority=999;
|
|
|
|
|
+ int show = 1;
|
|
|
|
|
+ JSONObject objbehavior = objfun.getJSONObject("search");
|
|
|
|
|
+ Iterator itbehavior = objbehavior.keys();
|
|
|
|
|
+ behavior = BEHAVIOR_SEARCH;
|
|
|
|
|
+ while(itbehavior.hasNext()) //loop for search fields in certain function
|
|
|
|
|
+ {
|
|
|
|
|
+ String field = (String) itbehavior.next();
|
|
|
|
|
+ JSONObject field_info = objbehavior.getJSONObject(field);
|
|
|
|
|
+ field_name = field_info.getString("name");
|
|
|
|
|
+ field_type = field_info.getString("type");
|
|
|
|
|
+ alias_name = field_info.getString("alias");
|
|
|
|
|
+ int id=dbUtil.get_recordid(db, "fields_info", "name='"+field_name+"' and behavior="+behavior+" and function_name='"+func_name+"' and user='"+user+"'");
|
|
|
|
|
+ if(id>=0) // record exist;
|
|
|
|
|
+ {
|
|
|
|
|
+ db.execSQL("update fields_info set abandon = 0 where _id ="+id);
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ stat.bindString(1, field_name);
|
|
|
|
|
+ stat.bindString(2, alias_name);
|
|
|
|
|
+ stat.bindString(3, field_type);
|
|
|
|
|
+ stat.bindString(4, func_name);
|
|
|
|
|
+ stat.bindLong(5, behavior);
|
|
|
|
|
+ stat.bindLong(6, priority);
|
|
|
|
|
+ stat.bindLong(7, show);
|
|
|
|
|
+ stat.bindString(8, user);
|
|
|
|
|
+ stat.executeInsert();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ objbehavior = objfun.getJSONObject("result");
|
|
|
|
|
+ Iterator itresult = objbehavior.keys();
|
|
|
|
|
+ behavior = BEHAVIOR_RESULT;
|
|
|
|
|
+ while(itresult.hasNext()) //loop for result fields in certain function
|
|
|
|
|
+ {
|
|
|
|
|
+ String field = (String) itresult.next();
|
|
|
|
|
+ JSONObject field_info = objbehavior.getJSONObject(field);
|
|
|
|
|
+ field_name = field_info.getString("name");
|
|
|
|
|
+ field_type = field_info.getString("type");
|
|
|
|
|
+ alias_name = field_info.getString("alias");
|
|
|
|
|
+ int id=dbUtil.get_recordid(db, "fields_info", "name='"+field_name+"' and behavior="+behavior+" and function_name='"+func_name+"' and user='"+user+"'");
|
|
|
|
|
+ if(id>=0) // record exist;
|
|
|
|
|
+ {
|
|
|
|
|
+ db.execSQL("update fields_info set abandon = 0 where _id ="+id);
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ stat.bindString(1, field_name);
|
|
|
|
|
+ stat.bindString(2, alias_name);
|
|
|
|
|
+ stat.bindString(3, field_type);
|
|
|
|
|
+ stat.bindString(4, func_name);
|
|
|
|
|
+ stat.bindLong(5, behavior);
|
|
|
|
|
+ stat.bindLong(6, priority);
|
|
|
|
|
+ stat.bindLong(7, show);
|
|
|
|
|
+ stat.bindString(8, user);
|
|
|
|
|
+ stat.executeInsert();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+// editor.putString(func_name, objfun.toString());
|
|
|
// JSONArray arrfun = jsobj.get(i);
|
|
// JSONArray arrfun = jsobj.get(i);
|
|
|
// JSONObject objname = arrfun.getJSONObject(0);
|
|
// JSONObject objname = arrfun.getJSONObject(0);
|
|
|
//
|
|
//
|
|
|
-// funset.add(objfun.getString("name"));
|
|
|
|
|
-// funset.add(objfun.getJSONObject("search").toString());
|
|
|
|
|
-// funset.add(objfun.getJSONObject("result").toString());
|
|
|
|
|
-// editor.putStringSet(objfun.getString("name"), funset);
|
|
|
|
|
|
|
+ // funset.add(objfun.getString("name"));
|
|
|
|
|
+ // funset.add(objfun.getJSONObject("search").toString());
|
|
|
|
|
+ // funset.add(objfun.getJSONObject("result").toString());
|
|
|
|
|
+ // editor.putStringSet(objfun.getString("name"), funset);
|
|
|
// String value = obj.getString(key);
|
|
// String value = obj.getString(key);
|
|
|
// JSONArray array = obj.getJSONArray(key);
|
|
// JSONArray array = obj.getJSONArray(key);
|
|
|
// for (int i = 0; i < array.length(); i++)
|
|
// for (int i = 0; i < array.length(); i++)
|
|
@@ -835,22 +1000,10 @@ public class Network
|
|
|
// newArray.put(jsonobject);
|
|
// newArray.put(jsonobject);
|
|
|
// }
|
|
// }
|
|
|
}
|
|
}
|
|
|
- // while (jsobj)
|
|
|
|
|
- // for (int i = 4; i < jsobj.length(); i++) // get functions
|
|
|
|
|
- // auth
|
|
|
|
|
- // // info from server;
|
|
|
|
|
- // {
|
|
|
|
|
- // Set<String> funset = new HashSet<String>();
|
|
|
|
|
- //
|
|
|
|
|
- // JSONArray arrfun = jsobj.get(i);
|
|
|
|
|
- // JSONObject objname = arrfun.getJSONObject(0);
|
|
|
|
|
- //
|
|
|
|
|
- // funset.add(objname.getString("name"));
|
|
|
|
|
- // funset.add(jsobj.getJSONArray(1).toString());
|
|
|
|
|
- // funset.add(jsobj.getJSONArray(2).toString());
|
|
|
|
|
- // editor.putStringSet("function" + (i - 4), funset);
|
|
|
|
|
- // }
|
|
|
|
|
- editor.commit();
|
|
|
|
|
|
|
+ db.execSQL("delete from fields_info where abandon = 1");
|
|
|
|
|
+ db.setTransactionSuccessful();
|
|
|
|
|
+ db.endTransaction();
|
|
|
|
|
+ editor.commit();
|
|
|
return RESULT_TRUE;
|
|
return RESULT_TRUE;
|
|
|
}
|
|
}
|
|
|
Log.d(TAG, "json is wrong");
|
|
Log.d(TAG, "json is wrong");
|
|
@@ -862,6 +1015,10 @@ public class Network
|
|
|
e1.printStackTrace();
|
|
e1.printStackTrace();
|
|
|
Log.d(TAG, "json is wrong");
|
|
Log.d(TAG, "json is wrong");
|
|
|
}
|
|
}
|
|
|
|
|
+ finally
|
|
|
|
|
+ {
|
|
|
|
|
+ dbUtil.CloseDB(db);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
// try
|
|
// try
|
|
|
// {
|
|
// {
|
|
@@ -983,4 +1140,56 @@ public class Network
|
|
|
// + " abailable = " + bavailable + " state " + netState);
|
|
// + " abailable = " + bavailable + " state " + netState);
|
|
|
return bavailable;
|
|
return bavailable;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ public static class SSLSocketFactoryEx extends SSLSocketFactory
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ SSLContext sslContext = SSLContext.getInstance("TLS");
|
|
|
|
|
+
|
|
|
|
|
+ public SSLSocketFactoryEx(KeyStore truststore)
|
|
|
|
|
+ throws NoSuchAlgorithmException, KeyManagementException,
|
|
|
|
|
+ KeyStoreException, UnrecoverableKeyException
|
|
|
|
|
+ {
|
|
|
|
|
+ super(truststore);
|
|
|
|
|
+
|
|
|
|
|
+ TrustManager tm = new X509TrustManager()
|
|
|
|
|
+ {
|
|
|
|
|
+ public java.security.cert.X509Certificate[] getAcceptedIssuers()
|
|
|
|
|
+ {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void checkClientTrusted(
|
|
|
|
|
+ java.security.cert.X509Certificate[] chain,
|
|
|
|
|
+ String authType)
|
|
|
|
|
+ throws java.security.cert.CertificateException
|
|
|
|
|
+ {
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void checkServerTrusted(
|
|
|
|
|
+ java.security.cert.X509Certificate[] chain,
|
|
|
|
|
+ String authType)
|
|
|
|
|
+ throws java.security.cert.CertificateException
|
|
|
|
|
+ {
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+ sslContext.init(null, new TrustManager[] { tm }, null);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public Socket createSocket(Socket socket, String host, int port,
|
|
|
|
|
+ boolean autoClose) throws IOException, UnknownHostException
|
|
|
|
|
+ {
|
|
|
|
|
+ return sslContext.getSocketFactory().createSocket(socket, host,
|
|
|
|
|
+ port, autoClose);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public Socket createSocket() throws IOException
|
|
|
|
|
+ {
|
|
|
|
|
+ return sslContext.getSocketFactory().createSocket();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|