|
|
@@ -57,8 +57,7 @@ import android.net.NetworkInfo;
|
|
|
import android.os.Bundle;
|
|
|
import android.util.Log;
|
|
|
|
|
|
-public class Network
|
|
|
-{
|
|
|
+public class Network {
|
|
|
public static final int BEHAVIOR_SEARCH = 0;
|
|
|
public static final int BEHAVIOR_RESULT = 1;
|
|
|
|
|
|
@@ -86,11 +85,10 @@ public class Network
|
|
|
public static String URL_UPDATE_AUTH = "https://ra.apexshipping.com/login.php";
|
|
|
public static String URL_REQUEST_COUNT = "https://ra.apexshipping.com/main.php";
|
|
|
public static String URL_REQUEST_RECORDS = "https://ra.apexshipping.com/main.php";
|
|
|
+ public static String URL_RETRIEVE_PASS = "https://ra.apexshipping.com/main.php";
|
|
|
|
|
|
- private static HttpClient getNewHttpClient()
|
|
|
- {
|
|
|
- try
|
|
|
- {
|
|
|
+ private static HttpClient getNewHttpClient() {
|
|
|
+ try {
|
|
|
KeyStore trustStore = KeyStore.getInstance(KeyStore
|
|
|
.getDefaultType());
|
|
|
trustStore.load(null, null);
|
|
|
@@ -112,22 +110,110 @@ public class Network
|
|
|
params, registry);
|
|
|
|
|
|
return new DefaultHttpClient(ccm, params);
|
|
|
- }
|
|
|
- catch (Exception e)
|
|
|
- {
|
|
|
+ } catch (Exception e) {
|
|
|
return new DefaultHttpClient();
|
|
|
}
|
|
|
}
|
|
|
+ public static int change_pass(String oldpass, String newpass , String user) {
|
|
|
+ String TAG = "net_dbg@change_pass";
|
|
|
+ Log.d(TAG, "old:" + oldpass + ";new:" + newpass);
|
|
|
+ if (!Network.NetworkIsAvailable()) {
|
|
|
+ Log.d(TAG, "network not available!");
|
|
|
+ return Network.RESULT_NET_NOTAVAILABLE; // network not available
|
|
|
+ }
|
|
|
+ Bundle parms = new Bundle();
|
|
|
+ parms.putString("user", user);
|
|
|
+ parms.putString("oldpass", oldpass);
|
|
|
+ parms.putString("newpass", newpass);
|
|
|
+ parms.putString("module_name", "Change Password");
|
|
|
+ parms.putString("sessionid", ApexTrackingApplication.get_sessionid());
|
|
|
+ parms.putString("action", "handset_search");
|
|
|
+ String jstr = getJson(Network.URL_RETRIEVE_PASS, parms);
|
|
|
+ /*
|
|
|
+ * error occur while get authorization info from server. include can not
|
|
|
+ * reach server , wrong parms ,server get wrong , etc.
|
|
|
+ */
|
|
|
+ if (jstr == null || jstr.length() <= 0) {
|
|
|
+ Log.d(TAG, "json is wrong");
|
|
|
+ return Network.RESULT_NET_ERROR;
|
|
|
+ }
|
|
|
+ JSONObject jsobj;
|
|
|
|
|
|
- public static String getJson(String url, Bundle parms)
|
|
|
- {
|
|
|
+ try {
|
|
|
+ jsobj = new JSONObject(jstr);
|
|
|
+ if (jsobj.length() > 0)
|
|
|
+ {
|
|
|
+ if (jsobj.getInt("result") != Network.AP_USER_AUTH)
|
|
|
+ {
|
|
|
+ // user not authorized return
|
|
|
+ Log.d(TAG, "USER NOT AUTHORIZED CODE=" + jsobj.getInt("result"));
|
|
|
+ return RESULT_FALSE;
|
|
|
+ }
|
|
|
+ return RESULT_TRUE;
|
|
|
+
|
|
|
+ }
|
|
|
+ return RESULT_NET_ERROR;
|
|
|
+ } catch (JSONException e) {
|
|
|
+ // TODO Auto-generated catch block
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ return RESULT_NET_ERROR;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static int retrieve_pass(String user, String email) {
|
|
|
+ String TAG = "net_dbg@retrieve_pass";
|
|
|
+ Log.d(TAG, "u:" + user + ";e:" + email);
|
|
|
+ if (!Network.NetworkIsAvailable()) {
|
|
|
+ Log.d(TAG, "network not available!");
|
|
|
+ return Network.RESULT_NET_NOTAVAILABLE; // network not available
|
|
|
+ }
|
|
|
+ Bundle parms = new Bundle();
|
|
|
+ parms.putString("user", user);
|
|
|
+ parms.putString("email", email);
|
|
|
+ parms.putString("module_name", "Retrieve Password");
|
|
|
+ parms.putString("action", "handset_search");
|
|
|
+ String jstr = getJson(Network.URL_RETRIEVE_PASS, parms);
|
|
|
+ /*
|
|
|
+ * error occur while get authorization info from server. include can not
|
|
|
+ * reach server , wrong parms ,server get wrong , etc.
|
|
|
+ */
|
|
|
+ if (jstr == null || jstr.length() <= 0) {
|
|
|
+ Log.d(TAG, "json is wrong");
|
|
|
+ return Network.RESULT_NET_ERROR;
|
|
|
+ }
|
|
|
+ JSONObject jsobj;
|
|
|
+
|
|
|
+ // array = new JSONArray(json);
|
|
|
+ try {
|
|
|
+ jsobj = new JSONObject(jstr);
|
|
|
+ if (jsobj.length() > 0)
|
|
|
+ {
|
|
|
+ if (jsobj.getInt("result") != Network.AP_USER_AUTH)
|
|
|
+ {
|
|
|
+ // user not authorized return
|
|
|
+ Log.d(TAG, "USER NOT AUTHORIZED CODE=" + jsobj.getInt("result"));
|
|
|
+ return RESULT_FALSE;
|
|
|
+ }
|
|
|
+ return RESULT_TRUE;
|
|
|
+
|
|
|
+ }
|
|
|
+ return RESULT_NET_ERROR;
|
|
|
+ } catch (JSONException e) {
|
|
|
+ // TODO Auto-generated catch block
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ return RESULT_NET_ERROR;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static String getJson(String url, Bundle parms) {
|
|
|
String TAG = "net_dbg@GetJson";
|
|
|
Log.d(TAG, "entry");
|
|
|
|
|
|
// if (true)
|
|
|
// return fakegetJson(url);
|
|
|
- try
|
|
|
- {
|
|
|
+ try {
|
|
|
// BasicHttpParams httpParams = new BasicHttpParams();
|
|
|
// HttpConnectionParams.setConnectionTimeout(httpParams,
|
|
|
// REQUEST_TIMEOUT);
|
|
|
@@ -140,13 +226,10 @@ public class Network
|
|
|
|
|
|
Set<String> keys = parms.keySet();
|
|
|
Log.d(TAG, "================parms============");
|
|
|
- for (String key : keys)
|
|
|
- {
|
|
|
- if (key.contains("_file"))
|
|
|
- {
|
|
|
+ for (String key : keys) {
|
|
|
+ if (key.contains("_file")) {
|
|
|
;
|
|
|
- }
|
|
|
- else
|
|
|
+ } else
|
|
|
reqEntity.addPart(key, new StringBody(parms.get(key)
|
|
|
.toString()));
|
|
|
Log.d(TAG, "key=" + key + " val="
|
|
|
@@ -157,24 +240,20 @@ public class Network
|
|
|
post.setEntity(reqEntity);
|
|
|
HttpResponse response = client.execute(post);
|
|
|
int statucode = response.getStatusLine().getStatusCode();
|
|
|
- if (statucode == HttpStatus.SC_OK)
|
|
|
- {
|
|
|
+ if (statucode == HttpStatus.SC_OK) {
|
|
|
HttpEntity resEntity = response.getEntity();
|
|
|
- if (resEntity != null)
|
|
|
- {
|
|
|
+ if (resEntity != null) {
|
|
|
Log.d(TAG,
|
|
|
"Response: content len==>"
|
|
|
+ resEntity.getContentLength());
|
|
|
InputStream is = resEntity.getContent();
|
|
|
- try
|
|
|
- {
|
|
|
+ try {
|
|
|
|
|
|
BufferedReader br = new BufferedReader(
|
|
|
new InputStreamReader(is, "utf-8"), 8);
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
String line = null;
|
|
|
- while ((line = br.readLine()) != null)
|
|
|
- {
|
|
|
+ while ((line = br.readLine()) != null) {
|
|
|
sb.append(line + "\n");
|
|
|
}
|
|
|
|
|
|
@@ -182,29 +261,22 @@ public class Network
|
|
|
Log.d(TAG, sb.toString());
|
|
|
Log.d(TAG, "Response: content end");
|
|
|
|
|
|
- if (sb.length() <= 0)
|
|
|
- {
|
|
|
+ if (sb.length() <= 0) {
|
|
|
|
|
|
return null;
|
|
|
}
|
|
|
return sb.toString();
|
|
|
|
|
|
- }
|
|
|
- catch (Exception e)
|
|
|
- {
|
|
|
+ } catch (Exception e) {
|
|
|
Log.e(TAG, e.toString());
|
|
|
return null;
|
|
|
// TODO: handle exception
|
|
|
- }
|
|
|
- finally
|
|
|
- {
|
|
|
+ } finally {
|
|
|
is.close();
|
|
|
|
|
|
}
|
|
|
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
+ } else {
|
|
|
/*
|
|
|
* resEntity is null
|
|
|
*/
|
|
|
@@ -212,28 +284,23 @@ public class Network
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
+ } else {
|
|
|
/*
|
|
|
* Http error; out put error code;
|
|
|
*/
|
|
|
Log.d(TAG, "HTTP " + statucode);
|
|
|
|
|
|
HttpEntity resEntity = response.getEntity();
|
|
|
- if (resEntity != null)
|
|
|
- {
|
|
|
+ if (resEntity != null) {
|
|
|
|
|
|
InputStream is = resEntity.getContent();
|
|
|
- try
|
|
|
- {
|
|
|
+ try {
|
|
|
|
|
|
BufferedReader br = new BufferedReader(
|
|
|
new InputStreamReader(is, "utf-8"), 8);
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
String line = null;
|
|
|
- while ((line = br.readLine()) != null)
|
|
|
- {
|
|
|
+ while ((line = br.readLine()) != null) {
|
|
|
sb.append(line + "\n");
|
|
|
}
|
|
|
|
|
|
@@ -241,22 +308,16 @@ public class Network
|
|
|
Log.d(TAG, sb.toString());
|
|
|
Log.d(TAG, "Response: content end");
|
|
|
return null;
|
|
|
- }
|
|
|
- catch (Exception e)
|
|
|
- {
|
|
|
+ } catch (Exception e) {
|
|
|
Log.e(TAG, e.toString());
|
|
|
return null;
|
|
|
// TODO: handle exception
|
|
|
- }
|
|
|
- finally
|
|
|
- {
|
|
|
+ } finally {
|
|
|
is.close();
|
|
|
|
|
|
}
|
|
|
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
+ } else {
|
|
|
/*
|
|
|
* resEntity is null
|
|
|
*/
|
|
|
@@ -265,44 +326,35 @@ public class Network
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- }
|
|
|
- catch (ConnectTimeoutException e)
|
|
|
- {
|
|
|
+ } catch (ConnectTimeoutException e) {
|
|
|
Log.d(TAG, "request time out");
|
|
|
return null;
|
|
|
|
|
|
- }
|
|
|
- catch (Exception e)
|
|
|
- {
|
|
|
+ } catch (Exception e) {
|
|
|
Log.d(TAG, e.toString());
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
- public static int get_recordcount(String name, String password, Bundle parms)
|
|
|
- {
|
|
|
+ public static int get_recordcount(String name, String password, Bundle parms) {
|
|
|
String TAG = "net_dbg@get_recordcount";
|
|
|
|
|
|
parms.putString("action", "handset_search_count");
|
|
|
parms.putString("sessionid", ApexTrackingApplication.get_sessionid());
|
|
|
Log.d(TAG, "sessionid=" + ApexTrackingApplication.get_sessionid());
|
|
|
String jstr = getJson(Network.URL_REQUEST_COUNT, parms);
|
|
|
- if (jstr == null || jstr.length() <= 0)
|
|
|
- {
|
|
|
+ if (jstr == null || jstr.length() <= 0) {
|
|
|
Log.d(TAG, "json is wrong");
|
|
|
return Network.RESULT_NET_ERROR;
|
|
|
}
|
|
|
JSONObject jsobj;
|
|
|
|
|
|
// array = new JSONArray(json);
|
|
|
- try
|
|
|
- {
|
|
|
+ try {
|
|
|
jsobj = new JSONObject(jstr);
|
|
|
- if (jsobj.length() > 0)
|
|
|
- {
|
|
|
- if (jsobj.getInt("result") != Network.AP_USER_AUTH)
|
|
|
- {
|
|
|
+ if (jsobj.length() > 0) {
|
|
|
+ if (jsobj.getInt("result") != Network.AP_USER_AUTH) {
|
|
|
// session expired
|
|
|
Log.d(TAG,
|
|
|
"USER NOT AUTHORIZED CODE="
|
|
|
@@ -321,20 +373,14 @@ public class Network
|
|
|
// + jsobj.getInt("result"));
|
|
|
// return RESULT_SESSION_EXPIRED;
|
|
|
// }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
+ } else {
|
|
|
return jsobj.getInt("count");
|
|
|
}
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
+ } else {
|
|
|
Log.d(TAG, "json is wrong");
|
|
|
return Network.RESULT_NET_ERROR;
|
|
|
}
|
|
|
- }
|
|
|
- catch (JSONException e)
|
|
|
- {
|
|
|
+ } catch (JSONException e) {
|
|
|
// TODO Auto-generated catch block
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
@@ -342,8 +388,7 @@ public class Network
|
|
|
return RESULT_ERROR;
|
|
|
}
|
|
|
|
|
|
- public static String get_records(String name, String password, Bundle parms)
|
|
|
- {
|
|
|
+ public static String get_records(String name, String password, Bundle parms) {
|
|
|
String TAG = "net_dbg@get_records";
|
|
|
// parms.putString("user", name);
|
|
|
// parms.putString("password", password);
|
|
|
@@ -355,21 +400,17 @@ public class Network
|
|
|
parms.putString("action", "handset_search");
|
|
|
parms.putString("sessionid", ApexTrackingApplication.get_sessionid());
|
|
|
String jstr = getJson(Network.URL_REQUEST_RECORDS, parms);
|
|
|
- if (jstr == null || jstr.length() <= 0)
|
|
|
- {
|
|
|
+ if (jstr == null || jstr.length() <= 0) {
|
|
|
Log.d(TAG, "json is wrong");
|
|
|
return null;
|
|
|
}
|
|
|
JSONObject jsobj;
|
|
|
//
|
|
|
// array = new JSONArray(json);
|
|
|
- try
|
|
|
- {
|
|
|
+ try {
|
|
|
jsobj = new JSONObject(jstr);
|
|
|
- if (jsobj.length() > 0)
|
|
|
- {
|
|
|
- if (jsobj.getInt("result") != Network.AP_USER_AUTH)
|
|
|
- {
|
|
|
+ if (jsobj.length() > 0) {
|
|
|
+ if (jsobj.getInt("result") != Network.AP_USER_AUTH) {
|
|
|
// session expired
|
|
|
Log.d(TAG,
|
|
|
"USER NOT AUTHORIZED CODE="
|
|
|
@@ -388,20 +429,14 @@ public class Network
|
|
|
// + jsobj.getInt("result"));
|
|
|
// return null;
|
|
|
// }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
+ } else {
|
|
|
return jstr;
|
|
|
}
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
+ } else {
|
|
|
Log.d(TAG, "json is wrong");
|
|
|
return null;
|
|
|
}
|
|
|
- }
|
|
|
- catch (JSONException e)
|
|
|
- {
|
|
|
+ } catch (JSONException e) {
|
|
|
// TODO Auto-generated catch block
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
@@ -409,27 +444,23 @@ public class Network
|
|
|
|
|
|
// return RESULT_ERROR;
|
|
|
}
|
|
|
- public static String get_detail( Bundle parms)
|
|
|
- {
|
|
|
+
|
|
|
+ public static String get_detail(Bundle parms) {
|
|
|
String TAG = "net_dbg@get_detail";
|
|
|
parms.putString("action", "handset_search");
|
|
|
parms.putString("sessionid", ApexTrackingApplication.get_sessionid());
|
|
|
String jstr = getJson(Network.URL_REQUEST_RECORDS, parms);
|
|
|
- if (jstr == null || jstr.length() <= 0)
|
|
|
- {
|
|
|
+ if (jstr == null || jstr.length() <= 0) {
|
|
|
Log.d(TAG, "json is wrong");
|
|
|
return null;
|
|
|
}
|
|
|
JSONObject jsobj;
|
|
|
//
|
|
|
// array = new JSONArray(json);
|
|
|
- try
|
|
|
- {
|
|
|
+ try {
|
|
|
jsobj = new JSONObject(jstr);
|
|
|
- if (jsobj.length() > 0)
|
|
|
- {
|
|
|
- if (jsobj.getInt("result") != Network.AP_USER_AUTH)
|
|
|
- {
|
|
|
+ if (jsobj.length() > 0) {
|
|
|
+ if (jsobj.getInt("result") != Network.AP_USER_AUTH) {
|
|
|
// session expired
|
|
|
Log.d(TAG,
|
|
|
"USER NOT AUTHORIZED CODE="
|
|
|
@@ -448,35 +479,27 @@ public class Network
|
|
|
// + jsobj.getInt("result"));
|
|
|
// return null;
|
|
|
// }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
+ } else {
|
|
|
return jstr;
|
|
|
}
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
+ } else {
|
|
|
Log.d(TAG, "json is wrong");
|
|
|
return null;
|
|
|
}
|
|
|
- }
|
|
|
- catch (JSONException e)
|
|
|
- {
|
|
|
+ } catch (JSONException e) {
|
|
|
// TODO Auto-generated catch block
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
return null;
|
|
|
-
|
|
|
+
|
|
|
// return RESULT_ERROR;
|
|
|
}
|
|
|
|
|
|
- public static int get_Auth(String name, String password)
|
|
|
- {
|
|
|
+ public static int get_Auth(String name, String password) {
|
|
|
|
|
|
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!");
|
|
|
return Network.RESULT_NET_NOTAVAILABLE; // network not available
|
|
|
}
|
|
|
@@ -493,17 +516,15 @@ public class Network
|
|
|
* error occur while get authorization info from server. include can not
|
|
|
* reach server , wrong parms ,server get wrong , etc.
|
|
|
*/
|
|
|
- if (jstr == null || jstr.length() <= 0)
|
|
|
- {
|
|
|
+ if (jstr == null || jstr.length() <= 0) {
|
|
|
Log.d(TAG, "json is wrong");
|
|
|
return Network.RESULT_NET_ERROR;
|
|
|
}
|
|
|
|
|
|
- return parse_authinfo(jstr, name);
|
|
|
+ return parse_authinfo(jstr, name,password);
|
|
|
}
|
|
|
|
|
|
- private static int parse_authinfo(String json, String user)
|
|
|
- {
|
|
|
+ private static int parse_authinfo(String json, String user,String pass) {
|
|
|
String TAG = "net_dbg@parse_authinfo";
|
|
|
Log.d(TAG, json);
|
|
|
// JSONArray array;
|
|
|
@@ -515,14 +536,12 @@ public class Network
|
|
|
|
|
|
// array = new JSONArray(json);
|
|
|
jsobj = new JSONObject(json);
|
|
|
- if (jsobj.length() > 0)
|
|
|
- {
|
|
|
+ if (jsobj.length() > 0) {
|
|
|
// JSONObject objresult = jsobj.get.getJSONObject(0);// result
|
|
|
// the
|
|
|
// server result
|
|
|
// ;
|
|
|
- if (jsobj.getInt("result") != Network.AP_USER_AUTH)
|
|
|
- {
|
|
|
+ if (jsobj.getInt("result") != Network.AP_USER_AUTH) {
|
|
|
// user not authorized return
|
|
|
Log.d(TAG,
|
|
|
"USER NOT AUTHORIZED CODE="
|
|
|
@@ -537,12 +556,13 @@ public class Network
|
|
|
// server;
|
|
|
ApexTrackingApplication.put_sessionid(objheader
|
|
|
.getString("sessionid"));
|
|
|
+ ApexTrackingApplication.put_user(user);
|
|
|
+ ApexTrackingApplication.put_password(pass);
|
|
|
Log.d(TAG, "sessionid=" + objheader.getString("sessionid"));
|
|
|
// JSONObject objupdate = array.getJSONObject(3); // whether
|
|
|
// need
|
|
|
// update ;
|
|
|
- if (objheader.getBoolean("update") == false)
|
|
|
- {
|
|
|
+ if (objheader.getBoolean("update") == false) {
|
|
|
// no update on the server;
|
|
|
return RESULT_TRUE;
|
|
|
}
|
|
|
@@ -591,6 +611,11 @@ public class Network
|
|
|
field_name = field_info.getString("name");
|
|
|
field_type = field_info.getString("type");
|
|
|
alias_name = field_info.getString("alias");
|
|
|
+ priority = field_info.getInt("priority");
|
|
|
+ if (priority == 999)
|
|
|
+ show = 0;
|
|
|
+ else
|
|
|
+ show = 1;
|
|
|
int id = dbUtil.get_recordid(db, "fields_info",
|
|
|
"name='" + field_name + "' and behavior="
|
|
|
+ behavior + " and function_name='"
|
|
|
@@ -600,9 +625,7 @@ public class Network
|
|
|
{
|
|
|
db.execSQL("update fields_info set abandon = 0 where _id ="
|
|
|
+ id);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
+ } else {
|
|
|
stat.bindString(1, field_name);
|
|
|
stat.bindString(2, alias_name);
|
|
|
stat.bindString(3, field_type);
|
|
|
@@ -636,9 +659,7 @@ public class Network
|
|
|
{
|
|
|
db.execSQL("update fields_info set abandon = 0 where _id ="
|
|
|
+ id);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
+ } else {
|
|
|
stat.bindString(1, field_name);
|
|
|
stat.bindString(2, alias_name);
|
|
|
stat.bindString(3, field_type);
|
|
|
@@ -660,18 +681,15 @@ public class Network
|
|
|
String actionname = (String) itactions.next();
|
|
|
int action_priority = objbehavior.getInt(actionname);
|
|
|
|
|
|
-
|
|
|
int id = dbUtil.get_recordid(db, "actions_info",
|
|
|
"name='" + actionname + "' and function_name='"
|
|
|
+ func_name + "' and user='" + user
|
|
|
+ "'");
|
|
|
if (id >= 0) // record exist;
|
|
|
{
|
|
|
- db.execSQL("update actions_info set abandon = 0 , priority="+action_priority+" where _id ="
|
|
|
- + id);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
+ db.execSQL("update actions_info set abandon = 0 , priority="
|
|
|
+ + action_priority + " where _id =" + id);
|
|
|
+ } else {
|
|
|
stat1.bindString(1, actionname);
|
|
|
stat1.bindString(2, func_name);
|
|
|
stat1.bindString(3, user);
|
|
|
@@ -690,15 +708,11 @@ public class Network
|
|
|
}
|
|
|
Log.d(TAG, "json is wrong");
|
|
|
return RESULT_USERAUTH_ERROR;
|
|
|
- }
|
|
|
- catch (JSONException e1)
|
|
|
- {
|
|
|
+ } catch (JSONException e1) {
|
|
|
// TODO Auto-generated catch block
|
|
|
e1.printStackTrace();
|
|
|
Log.d(TAG, "json is wrong");
|
|
|
- }
|
|
|
- finally
|
|
|
- {
|
|
|
+ } finally {
|
|
|
dbUtil.CloseDB(db);
|
|
|
}
|
|
|
|
|
|
@@ -783,16 +797,14 @@ public class Network
|
|
|
// .getSystemService(Context.CONNECTIVITY_SERVICE);
|
|
|
|
|
|
NetworkInfo networkInfo = connManager.getActiveNetworkInfo();
|
|
|
- if (networkInfo == null)
|
|
|
- {
|
|
|
+ if (networkInfo == null) {
|
|
|
Log.d(TAG, "can not get Active NetworkInfo!");
|
|
|
// dbgUtil.Log(Log.DEBUG, "Current Network info",
|
|
|
// "can not get Active NetworkInfo!");
|
|
|
return false;
|
|
|
}
|
|
|
NetworkInfo.State netState = networkInfo.getState();
|
|
|
- if (netState != NetworkInfo.State.CONNECTED)
|
|
|
- {
|
|
|
+ if (netState != NetworkInfo.State.CONNECTED) {
|
|
|
Log.d(TAG, "not Connected!State=" + netState);
|
|
|
// dbgUtil.Log(Log.DEBUG, "Current Network info",
|
|
|
// "not Connected!State=" + netState);
|
|
|
@@ -823,21 +835,17 @@ public class Network
|
|
|
return bavailable;
|
|
|
}
|
|
|
|
|
|
- public static class SSLSocketFactoryEx extends SSLSocketFactory
|
|
|
- {
|
|
|
+ public static class SSLSocketFactoryEx extends SSLSocketFactory {
|
|
|
|
|
|
SSLContext sslContext = SSLContext.getInstance("TLS");
|
|
|
|
|
|
public SSLSocketFactoryEx(KeyStore truststore)
|
|
|
throws NoSuchAlgorithmException, KeyManagementException,
|
|
|
- KeyStoreException, UnrecoverableKeyException
|
|
|
- {
|
|
|
+ KeyStoreException, UnrecoverableKeyException {
|
|
|
super(truststore);
|
|
|
|
|
|
- TrustManager tm = new X509TrustManager()
|
|
|
- {
|
|
|
- public java.security.cert.X509Certificate[] getAcceptedIssuers()
|
|
|
- {
|
|
|
+ TrustManager tm = new X509TrustManager() {
|
|
|
+ public java.security.cert.X509Certificate[] getAcceptedIssuers() {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
@@ -845,16 +853,14 @@ public class Network
|
|
|
public void checkClientTrusted(
|
|
|
java.security.cert.X509Certificate[] chain,
|
|
|
String authType)
|
|
|
- throws java.security.cert.CertificateException
|
|
|
- {
|
|
|
+ throws java.security.cert.CertificateException {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void checkServerTrusted(
|
|
|
java.security.cert.X509Certificate[] chain,
|
|
|
String authType)
|
|
|
- throws java.security.cert.CertificateException
|
|
|
- {
|
|
|
+ throws java.security.cert.CertificateException {
|
|
|
}
|
|
|
};
|
|
|
sslContext.init(null, new TrustManager[] { tm }, null);
|
|
|
@@ -862,15 +868,13 @@ public class Network
|
|
|
|
|
|
@Override
|
|
|
public Socket createSocket(Socket socket, String host, int port,
|
|
|
- boolean autoClose) throws IOException, UnknownHostException
|
|
|
- {
|
|
|
+ boolean autoClose) throws IOException, UnknownHostException {
|
|
|
return sslContext.getSocketFactory().createSocket(socket, host,
|
|
|
port, autoClose);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Socket createSocket() throws IOException
|
|
|
- {
|
|
|
+ public Socket createSocket() throws IOException {
|
|
|
return sslContext.getSocketFactory().createSocket();
|
|
|
}
|
|
|
}
|