|
|
@@ -2,15 +2,12 @@ package com.usai.redant.rautils.Utils;
|
|
|
|
|
|
import android.app.Application;
|
|
|
import android.content.Context;
|
|
|
-import android.database.Cursor;
|
|
|
-import android.database.sqlite.SQLiteDatabase;
|
|
|
import android.graphics.Bitmap;
|
|
|
import android.graphics.BitmapFactory;
|
|
|
import android.net.ConnectivityManager;
|
|
|
import android.net.NetworkInfo;
|
|
|
import android.os.Bundle;
|
|
|
import android.os.Environment;
|
|
|
-import android.text.TextUtils;
|
|
|
import android.util.Log;
|
|
|
|
|
|
import org.json.JSONException;
|
|
|
@@ -561,110 +558,113 @@ public class Network {
|
|
|
}
|
|
|
public static String check_push(Context c,Bundle params)
|
|
|
{
|
|
|
-// if(true)
|
|
|
-// return null;
|
|
|
- String TAG = "net_dbg@check_push";
|
|
|
- if(params==null)
|
|
|
- params = new Bundle();
|
|
|
- params.putString("action", "handset_search");
|
|
|
- params.putString("module_name", "Pull Message");
|
|
|
- params.putString("uuid", RAUtil.getDUID(c.getApplicationContext()));
|
|
|
-// String sessionid = ApexTrackingApplication.get_sessionid();
|
|
|
- // if (TextUtils.isEmpty(sessionid))
|
|
|
- // {
|
|
|
- //
|
|
|
- // Log.d(TAG, "no sessionid return!");
|
|
|
- // return null;
|
|
|
- //
|
|
|
- // }
|
|
|
- String user = ApexTrackingApplication.get_user();
|
|
|
- if (TextUtils.isEmpty(user))
|
|
|
- {
|
|
|
|
|
|
- Log.d(TAG, "no user name return!");
|
|
|
+ if(true)
|
|
|
return null;
|
|
|
|
|
|
- }
|
|
|
- // parms.putString("sessionid", sessionid);
|
|
|
- parms.putString("user", user);
|
|
|
- SQLiteDatabase db = dbUtil.OpenDB(
|
|
|
- ApexTrackingApplication.get_instance(), null, false);
|
|
|
- Cursor cursor = db.query("push_message", new String[] { "MAX(e_id)" },
|
|
|
- "user = '" + ApexTrackingApplication.get_user() + "'", null,
|
|
|
- null, null, null, null);
|
|
|
- if (cursor.moveToNext())
|
|
|
- {
|
|
|
- String maxid = cursor.getString(0);
|
|
|
- if (!TextUtils.isEmpty(maxid))
|
|
|
- parms.putString("id", maxid);
|
|
|
- }
|
|
|
- dbUtil.CloseCursor(cursor);
|
|
|
- dbUtil.CloseDB(db);
|
|
|
-
|
|
|
- String jstr = getJson(Network.URL_PUSH, parms);
|
|
|
- if (jstr == null || jstr.length() <= 0)
|
|
|
- {
|
|
|
- Log.d(TAG, "json is wrong");
|
|
|
- return null;
|
|
|
- }
|
|
|
- JSONObject jsobj;
|
|
|
- //
|
|
|
- // array = new JSONArray(json);
|
|
|
- try
|
|
|
- {
|
|
|
- jsobj = new JSONObject(jstr);
|
|
|
- if (jsobj.length() > 0)
|
|
|
- {
|
|
|
- int iresult = jsobj.getInt("result");
|
|
|
- if (iresult == Network.AP_SESSION_EXPIRED)
|
|
|
- {
|
|
|
- Log.e(TAG, "AP_SESSION_EXPIRED");
|
|
|
- String pass;
|
|
|
-
|
|
|
- pass = ApexTrackingApplication.get_pass();
|
|
|
- Network.get_Auth(user, pass);
|
|
|
- jstr = getJson(Network.URL_PUSH, parms);
|
|
|
- jsobj = new JSONObject(jstr);
|
|
|
- iresult = jsobj.getInt("result");
|
|
|
- }
|
|
|
- if (iresult != Network.AP_MESSAGE_NEW)
|
|
|
- {
|
|
|
- // session expired
|
|
|
- Log.d(TAG,
|
|
|
- "DOSE NOT GET NEW MESSAGE CODE="
|
|
|
- + jsobj.getInt("result"));
|
|
|
- return null;
|
|
|
- // if (get_Auth(name, password) == RESULT_TRUE)
|
|
|
- // {
|
|
|
- // return get_records(name, password, parms);
|
|
|
- //
|
|
|
- // }
|
|
|
- // else
|
|
|
- // {
|
|
|
- //
|
|
|
- // Log.d(TAG,
|
|
|
- // "USER NOT AUTHORIZED CODE="
|
|
|
- // + jsobj.getInt("result"));
|
|
|
- // return null;
|
|
|
- // }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- return jstr;
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- Log.d(TAG, "json is wrong");
|
|
|
- return null;
|
|
|
- }
|
|
|
- }
|
|
|
- catch (JSONException e)
|
|
|
- {
|
|
|
- // TODO Auto-generated catch block
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
return null;
|
|
|
+// String TAG = "net_dbg@check_push";
|
|
|
+// if(params==null)
|
|
|
+// params = new Bundle();
|
|
|
+// params.putString("action", "handset_search");
|
|
|
+// params.putString("module_name", "Pull Message");
|
|
|
+// params.putString("uuid", RAUtil.getDUID(c.getApplicationContext()));
|
|
|
+//// String sessionid = ApexTrackingApplication.get_sessionid();
|
|
|
+// // if (TextUtils.isEmpty(sessionid))
|
|
|
+// // {
|
|
|
+// //
|
|
|
+// // Log.d(TAG, "no sessionid return!");
|
|
|
+// // return null;
|
|
|
+// //
|
|
|
+// // }
|
|
|
+// String user = ApexTrackingApplication.get_user();
|
|
|
+// if (TextUtils.isEmpty(user))
|
|
|
+// {
|
|
|
+//
|
|
|
+// Log.d(TAG, "no user name return!");
|
|
|
+// return null;
|
|
|
+//
|
|
|
+// }
|
|
|
+// // parms.putString("sessionid", sessionid);
|
|
|
+// parms.putString("user", user);
|
|
|
+// SQLiteDatabase db = dbUtil.OpenDB(
|
|
|
+// ApexTrackingApplication.get_instance(), null, false);
|
|
|
+// Cursor cursor = db.query("push_message", new String[] { "MAX(e_id)" },
|
|
|
+// "user = '" + ApexTrackingApplication.get_user() + "'", null,
|
|
|
+// null, null, null, null);
|
|
|
+// if (cursor.moveToNext())
|
|
|
+// {
|
|
|
+// String maxid = cursor.getString(0);
|
|
|
+// if (!TextUtils.isEmpty(maxid))
|
|
|
+// parms.putString("id", maxid);
|
|
|
+// }
|
|
|
+// dbUtil.CloseCursor(cursor);
|
|
|
+// dbUtil.CloseDB(db);
|
|
|
+//
|
|
|
+// String jstr = getJson(Network.URL_PUSH, parms);
|
|
|
+// if (jstr == null || jstr.length() <= 0)
|
|
|
+// {
|
|
|
+// Log.d(TAG, "json is wrong");
|
|
|
+// return null;
|
|
|
+// }
|
|
|
+// JSONObject jsobj;
|
|
|
+// //
|
|
|
+// // array = new JSONArray(json);
|
|
|
+// try
|
|
|
+// {
|
|
|
+// jsobj = new JSONObject(jstr);
|
|
|
+// if (jsobj.length() > 0)
|
|
|
+// {
|
|
|
+// int iresult = jsobj.getInt("result");
|
|
|
+// if (iresult == Network.AP_SESSION_EXPIRED)
|
|
|
+// {
|
|
|
+// Log.e(TAG, "AP_SESSION_EXPIRED");
|
|
|
+// String pass;
|
|
|
+//
|
|
|
+// pass = ApexTrackingApplication.get_pass();
|
|
|
+// Network.get_Auth(user, pass);
|
|
|
+// jstr = getJson(Network.URL_PUSH, parms);
|
|
|
+// jsobj = new JSONObject(jstr);
|
|
|
+// iresult = jsobj.getInt("result");
|
|
|
+// }
|
|
|
+// if (iresult != Network.AP_MESSAGE_NEW)
|
|
|
+// {
|
|
|
+// // session expired
|
|
|
+// Log.d(TAG,
|
|
|
+// "DOSE NOT GET NEW MESSAGE CODE="
|
|
|
+// + jsobj.getInt("result"));
|
|
|
+// return null;
|
|
|
+// // if (get_Auth(name, password) == RESULT_TRUE)
|
|
|
+// // {
|
|
|
+// // return get_records(name, password, parms);
|
|
|
+// //
|
|
|
+// // }
|
|
|
+// // else
|
|
|
+// // {
|
|
|
+// //
|
|
|
+// // Log.d(TAG,
|
|
|
+// // "USER NOT AUTHORIZED CODE="
|
|
|
+// // + jsobj.getInt("result"));
|
|
|
+// // return null;
|
|
|
+// // }
|
|
|
+// }
|
|
|
+// else
|
|
|
+// {
|
|
|
+// return jstr;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// else
|
|
|
+// {
|
|
|
+// Log.d(TAG, "json is wrong");
|
|
|
+// return null;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// catch (JSONException e)
|
|
|
+// {
|
|
|
+// // TODO Auto-generated catch block
|
|
|
+// e.printStackTrace();
|
|
|
+// }
|
|
|
+// return null;
|
|
|
|
|
|
// return RESULT_ERROR;
|
|
|
}
|