Przeglądaj źródła

Delete duplicate folder

Ray Zhang 7 lat temu
rodzic
commit
a9bb70a107
18 zmienionych plików z 0 dodań i 5161 usunięć
  1. 0 281
      ApexDrivers/RAUtilsLibrary/src/main/java/com/usai/redant/rautils/Receiver/AlarmReceiver.java
  2. 0 53
      ApexDrivers/RAUtilsLibrary/src/main/java/com/usai/redant/rautils/Receiver/BootCompleteBroadcastReceiver.java
  3. 0 21
      ApexDrivers/RAUtilsLibrary/src/main/java/com/usai/redant/rautils/Receiver/RABroadcast.java
  4. 0 50
      ApexDrivers/RAUtilsLibrary/src/main/java/com/usai/redant/rautils/Receiver/RABroadcastReceiver.java
  5. 0 793
      ApexDrivers/RAUtilsLibrary/src/main/java/com/usai/redant/rautils/Service/RAService.java
  6. 0 141
      ApexDrivers/RAUtilsLibrary/src/main/java/com/usai/redant/rautils/Upload/RAOperationQueue.java
  7. 0 742
      ApexDrivers/RAUtilsLibrary/src/main/java/com/usai/redant/rautils/Upload/RAUploadManager.java
  8. 0 10
      ApexDrivers/RAUtilsLibrary/src/main/java/com/usai/redant/rautils/Upload/UploadCallback.java
  9. 0 547
      ApexDrivers/RAUtilsLibrary/src/main/java/com/usai/redant/rautils/Upload/UploadService.java
  10. 0 327
      ApexDrivers/RAUtilsLibrary/src/main/java/com/usai/redant/rautils/Utils/AESUtil.java
  11. 0 114
      ApexDrivers/RAUtilsLibrary/src/main/java/com/usai/redant/rautils/Utils/CrashHandler.java
  12. 0 66
      ApexDrivers/RAUtilsLibrary/src/main/java/com/usai/redant/rautils/Utils/DBHelper.java
  13. 0 110
      ApexDrivers/RAUtilsLibrary/src/main/java/com/usai/redant/rautils/Utils/DBUtil.java
  14. 0 277
      ApexDrivers/RAUtilsLibrary/src/main/java/com/usai/redant/rautils/Utils/FileManager.java
  15. 0 275
      ApexDrivers/RAUtilsLibrary/src/main/java/com/usai/redant/rautils/Utils/ImageUtil.java
  16. 0 692
      ApexDrivers/RAUtilsLibrary/src/main/java/com/usai/redant/rautils/Utils/Network.java
  17. 0 386
      ApexDrivers/RAUtilsLibrary/src/main/java/com/usai/redant/rautils/Utils/RAUtil.java
  18. 0 276
      ApexDrivers/RAUtilsLibrary/src/main/java/com/usai/redant/rautils/Utils/dbgUtil.java

+ 0 - 281
ApexDrivers/RAUtilsLibrary/src/main/java/com/usai/redant/rautils/Receiver/AlarmReceiver.java

@@ -1,281 +0,0 @@
-package com.usai.redant.rautils.receiver;
-
-import android.content.Context;
-import android.content.Intent;
-import android.util.Log;
-
-public abstract class AlarmReceiver extends BootCompleteBroadcastReceiver {
-    protected  int alarm_timeInterval = 30 * 1000;
-
-//    protected static final int	SO_TIMEOUT						= 15 * 1000;
-
-    protected abstract void InitAlarm(Context context, Intent intent);
-    protected abstract void AlarmProc(Context context, Intent intent);
-
-    @Override
-    public void onReceive(Context context, Intent intent) {
-
-        super.onReceive(context,intent);
-
-        String action = intent
-                .getAction();
-
-        Log.d("AlarmReceiver", "onReceive: " + action);
-
-        if (RABroadcast.ACTION_REDANT_INIT_ALARM.equals(intent.getAction())) {
-            InitAlarm(context,intent);
-        }
-        else
-        if (RABroadcast.ACTION_REDANT_ALARM.equals(intent.getAction())) {
-
-
-            AlarmProc(context,intent);
-
-        }
-//        else
-//        if (Intent.ACTION_LOCKED_BOOT_COMPLETED.equals(intent.getAction())) {
-//
-//            InitAlarm(context,intent);
-//        }
-
-
-/*
-
-?????
-
-        Intent iAlarm = new Intent(context, AlarmReceiver.class);
-//        iAlarm.putExtra("caller", caller);
-        iAlarm.setAction("ACTION_PUSHNOTIFICATION_CHECK");
-        PendingIntent sender = PendingIntent.getBroadcast(context, 0,
-                iAlarm, PendingIntent.FLAG_UPDATE_CURRENT);
-
-
-        AlarmManager am = (AlarmManager) context.getSystemService(
-                Context.ALARM_SERVICE);
-//        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
-//            am.setExactAndAllowWhileIdle(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + pushcheck_timeInterval, sender);
-//        } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
-//            am.setExact(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + pushcheck_timeInterval, sender);
-//        }
-
-        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
-            am.setExactAndAllowWhileIdle(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + alarm_timeInterval, sender);
-        } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
-            am.setExact(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + alarm_timeInterval, sender);
-        }
-
-*/
-    }
-
-
-    @Override
-    protected void OnBootComplete(Context context, Intent intent) {
-
-        Log.d("AlarmReceiver", "OnBootComplete: SEND" + RABroadcast.ACTION_REDANT_INIT_ALARM);
-        Intent bintent = new Intent(RABroadcast.ACTION_REDANT_INIT_ALARM);
-//        bintent.putExtra("msg", msg.toString());
-
-        bintent.setClass(context, this.getClass());
-        context.sendBroadcast(bintent);
-
-    }
-
-    @Override
-    protected void OnLockedBootComplete(Context context, Intent intent) {
-
-        Log.d("AlarmReceiver", "OnLockedBootComplete: SEND" + RABroadcast.ACTION_REDANT_INIT_ALARM);
-
-        Log.d("AlarmReceiver", "OnLockedBootComplete: class" + this.getClass());
-        Intent bintent = new Intent(RABroadcast.ACTION_REDANT_INIT_ALARM);
-//        bintent.putExtra("msg", msg.toString());
-
-
-        bintent.setClass(context, this.getClass());
-        context.sendBroadcast(bintent);
-    }
-
-/*
-
-    private String getDeviceId(Context context) {
-        TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
-        if (ActivityCompat.checkSelfPermission(context, Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) {
-            // TODO: Consider calling
-            //    ActivityCompat#requestPermissions
-            // here to request the missing permissions, and then overriding
-            //   public void onRequestPermissionsResult(int requestCode, String[] permissions,
-            //                                          int[] grantResults)
-            // to handle the case where the user grants the permission. See the documentation
-            // for ActivityCompat#requestPermissions for more details.
-            return "";
-        }
-        String deviceId = telephonyManager.getDeviceId().toString();
-        return deviceId;
-    }
-
-    private void check_push(Context context)
-    {
-
-
-        String dev_id = getDeviceId(context);
-        Log.d("AlarmReceiver", "check_push: "+dev_id);
-
-
-
-        new Thread(new Runnable() {
-            @Override
-            public void run() {
-                logout();
-
-//                runOnUiThread(new Runnable() {
-//                    @Override
-//                    public void run() {
-//                        dismissProgressDialog();
-//                        ApexDriverApplication.sharedApplication().logout();
-//                        showLogin();
-//                    }
-//                });
-            }
-        }).start();
-//        return dev_id;
-    }
-
-
-
-
-    private  String getJson(String url, Bundle parms)
-    {
-        String TAG = "net_dbg@GetJson";
-        Log.d(TAG, "entry");
-        String ret=null;
-
-        HttpURLConnection connection = null;
-
-        try {
-
-
-            URL _url;
-            _url = new URL(url);
-            connection = (HttpURLConnection) _url.openConnection();
-            connection.setReadTimeout(SO_TIMEOUT);
-            connection.setConnectTimeout(SO_TIMEOUT);
-            // 设置请求方式
-            connection.setRequestMethod("POST");
-            // 设置编码格式
-            connection.setRequestProperty("Charset", "UTF-8");
-            // 传递自定义参数
-//			connection.setRequestProperty("MyProperty", "this is me!");
-
-            Set<String> keys = parms.keySet();
-            Log.d(TAG, "================parms============");
-            for (String key : keys)
-            {
-                if (key.contains("_file"))
-                {
-
-                }
-                else
-                {
-                    Log.d(TAG, "key=" + key + "    val=" + parms.get(key).toString());
-                }
-
-            }
-            Log.d(TAG, "================parms============");
-
-            Log.d(TAG,"URL: "+url);
-            // 设置容许输出
-            connection.setDoInput(true);
-            connection.setDoOutput(true);
-
-
-            OutputStream os = connection.getOutputStream();
-            BufferedWriter writer = new BufferedWriter(
-                    new OutputStreamWriter(os, "UTF-8"));
-            writer.write(createPostParameters(parms));
-
-            writer.flush();
-            writer.close();
-            os.close();
-
-            // 获取返回数据
-            if(connection.getResponseCode() == 200){
-                InputStream is = connection.getInputStream();
-
-                BufferedReader br = new BufferedReader(
-                        new InputStreamReader(is, "utf-8"), 8);
-                StringBuilder sb = new StringBuilder();
-                String line = null;
-                while ((line = br.readLine()) != null)
-                {
-                    sb.append(line + "\n");
-                }
-
-                Log.d(TAG, "Response: content begin");
-                Log.d(TAG, sb.toString());
-                Log.d(TAG, "Response: content end");
-
-                if (sb.length() <= 0)
-                {
-
-                    ret= null;
-                }
-                ret= sb.toString();
-
-            }
-
-        } catch (UnsupportedEncodingException e) {
-            e.printStackTrace();
-
-            Log.e(TAG, e.toString());
-
-        } catch (ProtocolException e) {
-            e.printStackTrace();
-
-            Log.e(TAG, e.toString());
-
-        } catch (MalformedURLException e) {
-            e.printStackTrace();
-
-            Log.e(TAG, e.toString());
-
-        } catch (IOException e) {
-            e.printStackTrace();
-
-            Log.e(TAG, e.toString());
-
-        } finally {
-
-            if(connection!=null){
-                connection.disconnect();
-            }
-        }
-        return ret;
-    }
-    private  String createPostParameters(Bundle parms) throws UnsupportedEncodingException {
-        StringBuilder result = new StringBuilder();
-        boolean first = true;
-        for(String key : parms.keySet()){
-            if (first)
-                first = false;
-            else
-                result.append("&");
-
-            result.append(URLEncoder.encode(key, "UTF-8"));
-            result.append("=");
-            result.append(URLEncoder.encode(parms.get(key).toString(), "UTF-8"));
-        }
-
-        return result.toString();
-    }
-    private static final String URL_HOST = "http://192.168.0.124:8080";
-    public static final String URL_LOGOUT = URL_HOST + "/j/mobile/loginOut.mo/";
-    public  void logout() {
-
-
-        Bundle params = new Bundle();
-        params.putString("platform","android");
-
-        getJson(URL_LOGOUT,params);
-    }
-
-    */
-}

+ 0 - 53
ApexDrivers/RAUtilsLibrary/src/main/java/com/usai/redant/rautils/Receiver/BootCompleteBroadcastReceiver.java

@@ -1,53 +0,0 @@
-package com.usai.redant.rautils.receiver;
-
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.util.Log;
-
-import com.usai.redant.rautils.utils.dbgUtil;
-
-public abstract class BootCompleteBroadcastReceiver extends BroadcastReceiver {
-
-    @Override
-    public void onReceive(Context context, Intent intent) {
-
-        dbgUtil.fileLog(context,"RAUtilsLibrary: onReceive" + intent.getAction());
-
-//        dbgUtil.fileLog(context,"RAUtilsLibrary: BootCompleteBroadcastReceiver onReceive");
-
-        if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
-
-            Log.d("BootComplete", "onReceive: ACTION_BOOT_COMPLETED");
-            OnBootComplete(context,intent);
-
-//            dbgUtil.fileLog(context,"RAUtilsLibrary: BootCompleteBroadcastReceiver ACTION_BOOT_COMPLETED redeived");
-//            // 启动完成
-//            Intent iAlarm = new Intent(context, Alarmreceiver.class);
-//            iAlarm.setAction("com.usai.apex.push");
-//            PendingIntent sender = PendingIntent.getBroadcast(context, 0,
-//            		iAlarm, 0);
-//            long firstime = SystemClock.elapsedRealtime();
-//            AlarmManager am = (AlarmManager) context
-//                    .getSystemService(Context.ALARM_SERVICE);
-//
-//            // 10秒一个周期,不停的发送广播
-//            am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, firstime,
-//                    30 * 1000, sender);
-//			Intent intentservice = new Intent();
-//			intentservice.setClass(context, ApexPushService.class);
-//			if (intent.getExtras() != null)
-//				intentservice.putExtras(intent.getExtras());
-//			intentservice.setAction(intent.getAction());
-//			context.startService(intentservice);
-//            ApexTrackingApplication.startalarm("boot completed");
-        }
-        else if (Intent.ACTION_LOCKED_BOOT_COMPLETED.equals(intent.getAction())) {
-            Log.d("BootComplete", "onReceive: ACTION_LOCKED_BOOT_COMPLETED");
-            OnLockedBootComplete(context,intent);
-        }
-    }
-
-    protected abstract void OnBootComplete(Context context, Intent intent);
-    protected abstract void OnLockedBootComplete(Context context, Intent intent);
-}

+ 0 - 21
ApexDrivers/RAUtilsLibrary/src/main/java/com/usai/redant/rautils/Receiver/RABroadcast.java

@@ -1,21 +0,0 @@
-package com.usai.redant.rautils.receiver;
-
-public class RABroadcast {
-    public static String EVENT_SILENCECOMMAND="REDANT.BROADCAST.EVENT_SILENCECOMMAND";
-    public static String EVENT_PUSHNOTIFICATION="REDANT.BROADCAST.EVENT_PUSHNOTIFICATION";
-    public static String EVENT_RETURN_LOCATION="REDANT.BROADCAST.EVENT_RETURN_LOCATION";
-
-    public static String ACTION_UPLOAD_ADD_TASK="REDANT.BROADCAST.ACTION_UPLOAD_ADD_TASK";
-    public static String ACTION_LOCATION_ENABLE_TRACING="REDANT.BROADCAST.ACTION_LOCATION_ENABLE_TRACING";
-    public static String ACTION_LOCATION_DISABLE_TRACING="REDANT.BROADCAST.ACTION_LOCATION_DISABLE_TRACING";
-    public static String ACTION_LOCATION_REQUEST_LOCATION="REDANT.BROADCAST.ACTION_LOCATION_REQUEST_LOCATION";
-    public static String ACTION_PUSHNOTIFICATION_CHECK="REDANT.BROADCAST.ACTION_PUSHNOTIFICATION_CHECK";
-
-
-    public static String ACTION_REDANT_ALARM="REDANT.BROADCAST.ACTION_REDANT_ALARM";
-    public static String ACTION_REDANT_INIT_ALARM="REDANT.BROADCAST.ACTION_REDANT_INIT_ALARM";
-
-    public static String ACTION_PUSHNOTIFICATION_ENABLE_CHECK="REDANT.BROADCAST.ACTION_PUSHNOTIFICATION_ENABLE_CHECK";
-    public static String ACTION_PUSHNOTIFICATION_DISABLE_CHECK="REDANT.BROADCAST.ACTION_PUSHNOTIFICATION_DISABLE_CHECK";
-
-}

+ 0 - 50
ApexDrivers/RAUtilsLibrary/src/main/java/com/usai/redant/rautils/Receiver/RABroadcastReceiver.java

@@ -1,50 +0,0 @@
-package com.usai.redant.rautils.receiver;
-
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-
-import com.usai.redant.rautils.utils.dbgUtil;
-
-public class RABroadcastReceiver extends BroadcastReceiver {
-
-//    PushNotificationCallback notificationCallback=null;
-//    private String receiverID = null;
-
-
-
-//    public RABroadcastReceiver(String receiverID)
-//    {
-//        if(receiverID==null)
-//            throw new IllegalArgumentException("receiverID can't be null");
-//        this.receiverID = receiverID;
-//    }
-//    public void initPushNotificationCallback(PushNotificationCallback notificationCallback)
-//    {
-//        this.notificationCallback = notificationCallback;
-//    }
-
-
-    @Override
-    public void onReceive(Context context, Intent intent) {
-        dbgUtil.fileLog(context,"RABroadcastReceiver: onReceive" + intent.getAction());
-
-//        if(!(intent.getStringExtra("receiverID").equals(receiverID)|| TextUtils.isEmpty(intent.getStringExtra("receiverID"))))
-//            return;
-//        if (RABroadcast.EVENT_PUSHNOTIFICATION.equals(intent.getAction())) {
-//            if(notificationCallback!=null)
-//                notificationCallback.onPushNotification(intent);
-//        }
-//        else if (RABroadcast.EVENT_SILENCECOMMAND.equals(intent.getAction())) {
-//            if(notificationCallback!=null)
-//                notificationCallback.onSilentCommand(intent);
-//        }
-    }
-//
-//    public interface PushNotificationCallback {
-//        public abstract void onPushNotification(Intent intent);
-//        public abstract void onSilentCommand(Intent intent);
-//    }
-
-
-}

+ 0 - 793
ApexDrivers/RAUtilsLibrary/src/main/java/com/usai/redant/rautils/Service/RAService.java

@@ -1,793 +0,0 @@
-package com.usai.redant.rautils.service;
-
-import android.Manifest;
-import android.app.AlarmManager;
-import android.app.Notification;
-import android.app.NotificationChannel;
-import android.app.NotificationManager;
-import android.app.PendingIntent;
-import android.app.Service;
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.content.SharedPreferences;
-import android.content.pm.PackageManager;
-import android.location.Location;
-import android.location.LocationListener;
-import android.location.LocationManager;
-import android.net.ConnectivityManager;
-import android.net.NetworkInfo;
-import android.os.AsyncTask;
-import android.os.Binder;
-import android.os.Build;
-import android.os.Bundle;
-import android.os.IBinder;
-import android.os.SystemClock;
-import android.support.v4.app.ActivityCompat;
-import android.support.v4.app.NotificationCompat;
-import android.text.TextUtils;
-import android.util.Log;
-
-import com.usai.redant.rautils.R;
-import com.usai.redant.rautils.receiver.RABroadcast;
-import com.usai.redant.rautils.receiver.RABroadcastReceiver;
-import com.usai.redant.rautils.upload.RAUploadManager;
-import com.usai.redant.rautils.utils.Network;
-import com.usai.redant.rautils.utils.dbgUtil;
-
-import org.json.JSONException;
-import org.json.JSONObject;
-
-import java.util.ArrayList;
-
-//@Deprecated
-public abstract class RAService extends Service {
-
-    private static final String TAG = "RAService";
-
-    public static final int DEFAULT_LOCATION_TIMEINTERVAL = 60 * 1000;
-    public static final int DEFAULT_DISTANCE = 60 * 50;
-    public static final int DEFAULT_PUSHNOTIFICATION_TIMEINTERVAL = 5 * 1000;
-
-    public static final int FLAG_SERVICE_NONE = 0;
-    public static final int FLAG_SERVICE_LOCATION = 1 << 1;
-    public static final int FLAG_SERVICE_NOTIFICATION = 1 << 2;
-    public static final int FLAG_SERVICE_UPLOAD = 1 << 3;
-//    public static final int FLAG_LOCATION_SERVICE = 1<<1;
-
-    // service setup
-    protected int service_flag = FLAG_SERVICE_NONE;
-    private IntentFilter msgFilter = new IntentFilter();
-
-    protected abstract void Setup();
-
-    // sub function upload
-    public interface ServiceUpload {
-
-    }
-
-    public void initServiceUpload(ServiceUpload uploadCallback) {
-        service_flag = service_flag | FLAG_SERVICE_UPLOAD;
-//        this.upload = locationCallback;
-    }
-
-    private RAUploadManager uploadManager = null;
-
-    public RAUploadManager getUploadManager() {
-        return uploadManager;
-    }
-
-    // sub function location
-    LocationListener locationListener = null;
-    LocationManager locationManager = null;
-    int locationTracing_timeInterval = DEFAULT_LOCATION_TIMEINTERVAL;
-    int locationTracing_distance = DEFAULT_DISTANCE;
-    //    protected abstract void onLocationChanged(Location location);
-    private ServiceLocation locationCallback = null;
-
-    public interface ServiceLocation {
-
-
-        public abstract Location RequestCachedLocation();
-//        public abstract void RequestLocation_ByBroadcast(String receiverID);
-
-        public abstract void onLocationChanged(Location location);
-//        public abstract void onLogin();
-//		public abstract void onLogout();
-    }
-
-    public void initServiceLocation(ServiceLocation locationCallback) {
-        service_flag = service_flag | FLAG_SERVICE_LOCATION;
-        this.locationCallback = locationCallback;
-    }
-
-
-    // sub function Notification
-    protected String url_checknotification = null;
-    int pushcheck_timeInterval = DEFAULT_PUSHNOTIFICATION_TIMEINTERVAL;
-    protected static final int NOTIFICATION_TYPE_PUSHNOTIFICATION = 0;
-    protected static final int NOTIFICATION_TYPE_SILENCECOMMAND = 1;
-    protected boolean enable_pushNotification = false;
-
-    //    protected abstract Notification prepareNotification(JSONObject msg);
-//    protected abstract void handleSilenceMessage(JSONObject msg);
-    public interface ServicePushNotification {
-        public abstract Notification prepareNotification(JSONObject msg);
-
-        public abstract void handleSilenceMessage(JSONObject msg);
-    }
-
-    public void initServiceNotification(ServicePushNotification pushNotificationCallback, String url_checknotification) {
-        service_flag = service_flag | FLAG_SERVICE_NOTIFICATION;
-        this.url_checknotification = url_checknotification;
-        this.pushNotificationCallback = pushNotificationCallback;
-    }
-
-    private ServicePushNotification pushNotificationCallback = null;
-    private checkPushTask m_task = null;
-
-    class checkPushTask extends AsyncTask<Void, Void, Boolean> {
-        int errorcode;
-        String content = null;
-        Context mcontext;
-
-        public checkPushTask(Context context) {
-            mcontext = context;
-        }
-
-        @Override
-        protected Boolean doInBackground(Void... params) {
-            Log.d("SearchTask", "doInBackground");
-
-            if (!Network.isNetworkAvailable(getApplication()))
-
-            {
-                errorcode = Network.RESULT_NET_NOTAVAILABLE;
-                return false;
-            }
-            String jstr = "";
-            jstr = Network.check_push(mcontext, new Bundle(), url_checknotification);
-            // if (module_name.equals("Announcements"))
-            // jstr = Network.get_announcements(lastid, limit);
-            // else
-            // jstr = Network.get_marketnews(lastid, limit);
-            if (jstr == null || jstr.length() <= 0) {
-                // Log.d(TAG, "json is wrong");
-
-                errorcode = Network.RESULT_NET_ERROR;
-                return false;
-            }
-
-            content = jstr;
-            return true;
-        }
-
-        @Override
-        protected void onPostExecute(Boolean success) {
-            String tag = "onPostExec";
-            Log.i(tag, "entry");
-            m_task = null;
-
-
-            if (success) {
-                JSONObject jsobj;
-                //
-                // array = new JSONArray(json);
-                try {
-                    jsobj = new JSONObject(content);
-
-                    int count = jsobj.getInt("count");
-
-                    for (int i = 0; i < count; i++) {
-                        JSONObject msg = jsobj.getJSONObject("msg_" + i);
-                        int type = msg.getInt("type");
-                        if (type == NOTIFICATION_TYPE_SILENCECOMMAND) {
-
-                            pushNotificationCallback.handleSilenceMessage(msg);
-                            Intent intent = new Intent(RABroadcast.EVENT_SILENCECOMMAND);
-                            intent.putExtra("msg", msg.toString());
-                            sendBroadcast(intent);
-
-                        } else {
-                            pushNotification(msg);
-
-                            Intent intent = new Intent(RABroadcast.EVENT_PUSHNOTIFICATION);
-                            intent.putExtra("msg", msg.toString());
-                            sendBroadcast(intent);
-
-
-                        }
-                    }
-
-
-                } catch (JSONException e) {
-                    // TODO Auto-generated catch block
-                    e.printStackTrace();
-                }
-
-            }
-
-            super.onPostExecute(success);
-        }
-
-        @Override
-        protected void onCancelled() {
-            m_task = null;
-            // showProgress(false);
-        }
-    }
-
-
-    public void pushNotification(JSONObject msg) {
-
-        if (enable_pushNotification) {
-
-            boolean bsound = true;
-//                    mcontext.getSharedPreferences(
-//                    "setting", 0).getBoolean(
-//                    "notifications_new_message_sound", true);
-            boolean bvibrate = true;
-//            mcontext.getSharedPreferences(
-//                    "setting", 0).getBoolean(
-//                    "notifications_new_message_vibrate", true);
-            NotificationManager nManager = (NotificationManager)
-                    getSystemService(Context.NOTIFICATION_SERVICE);
-
-/*
-       此部分在虚函数 prepareNotificaiton 中实现
-            Intent intent = new Intent(mcontext,
-                    FunctionSelectActivity.class);
-            intent.putExtra("launcher", "notification");
-
-            PendingIntent pintent = PendingIntent.getActivity(
-                    this, 0, intent,
-                    PendingIntent.FLAG_UPDATE_CURRENT);
-
-
-            Notification.Builder builder = new Notification.Builder(mcontext);//新建Notification.Builder对象
-            String ntitle = "";
-            int number = ApexTrackingApplication.ncount++;
-            if (number > 1)
-                ntitle=number
-                        + " "
-                        + ApexTrackingApplication
-                        .get_instance()
-                        .getString(
-                                R.string.str_mnotification_title);
-            else
-                ntitle = ApexTrackingApplication
-                        .get_instance()
-                        .getString(
-                                R.string.str_notification_title);
-
-            builder.setContentTitle(ntitle);//设置标题
-            builder.setContentText(ApexTrackingApplication
-                    .get_instance()
-                    .getString(
-                            R.string.str_notification_text)
-                    + date);//设置内容
-            builder.setSmallIcon(R.drawable.ic_launcher);//设置图片
-            builder.setContentIntent(pintent);//执行intent
-
-
-            */
-            Notification notification = pushNotificationCallback.prepareNotification(msg);//builder.getNotification();//将builder对象转换为普通的notifications
-            notification.defaults = Notification.DEFAULT_ALL;
-
-//            if (bsound && bvibrate)
-//                notification.defaults = Notification.DEFAULT_ALL;
-//            else if (bsound)
-//                notification.defaults = Notification.DEFAULT_SOUND
-//                        | Notification.DEFAULT_LIGHTS;
-//            else if (bvibrate)
-//                notification.defaults = Notification.DEFAULT_VIBRATE
-//                        | Notification.DEFAULT_LIGHTS;
-            notification.flags = Notification.FLAG_AUTO_CANCEL;
-//            notification.number = number; //number 是不是不需要了?
-
-            nManager.notify(R.layout.support_simple_spinner_dropdown_item, notification);
-        }
-    }
-
-    public void checkpush(Context context) {
-
-        if(true)
-        return;
-        if (m_task != null) {
-            return;
-        }
-        // mStatusMessageView.setText(R.string.str_Loading);
-        // showProgress(true);
-        m_task = new checkPushTask(context);
-
-        // TextView text_page = (TextView) view_page_footer
-        // .findViewById(R.id.text_page);
-        // text_page.setText("Loading...");
-        // text_page.setEnabled(false);
-        m_task.execute();
-
-    }
-
-    public RAService() {
-    }
-
-
-    @Override
-    public IBinder onBind(Intent intent) {
-//         TODO: Return the communication channel to the service.
-//        throw new UnsupportedOperationException("Not yet implemented");
-        Log.d("", "onBind: bind service");
-        return new MyBinder();
-    }
-
-
-    public class MyBinder extends Binder {
-        /**
-         * 获取当前Service的实例
-         *
-         * @return
-         */
-        public RAService getService() {
-            return RAService.this;
-        }
-    }
-
-
-    @Override
-    public void onCreate() {
-
-        Log.d("_SERVICE", "create upload Service!!!");
-
-
-//        // 初始化异常捕获器
-//        CrashHandler.getSharedInstance().init(getApplicationContext());
-//        CrashHandler.getSharedInstance().preserver = new CrashHandler.InfoPreserver() {
-//            @Override
-//            public void saveUserInformation() {
-//                if (uploadManager != null) {
-//                    uploadManager.saveTasks();
-//                }
-//            }
-//
-//            @Override
-//            public void handleCrashInfo(String deviceInfo, String exception) {
-//                dbgUtil.fileLog(getApplicationContext(),"============================ app crash ============================");
-//                dbgUtil.fileLog(getApplicationContext(),"DEVICE");
-//                dbgUtil.fileLog(getApplicationContext(),deviceInfo);
-//                dbgUtil.fileLog(getApplicationContext(),"EXCEPTION");
-//                dbgUtil.fileLog(getApplicationContext(),exception);
-//                dbgUtil.fileLog(getApplicationContext(),"=============================== end ===============================");
-//                Log.d("_SERVICE", "Device Info: " + deviceInfo);
-//                Log.d("_SERVICE", "Crash Info: " + exception);
-//            }
-//        };
-
-
-        Setup();
-
-        msgFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
-
-        if ((service_flag & FLAG_SERVICE_UPLOAD) == FLAG_SERVICE_UPLOAD) {
-            uploadManager = new RAUploadManager(getApplicationContext());
-//            msgFilter.addAction("REDANT.POP.RESET_LOCATION");
-//            msgFilter.addAction("REDANT.POP.QUERY_UPLOAD_STATE");
-            msgFilter.addAction("REDANT.BROADCAST.ACTION_UPLOAD_ADD_TASK");
-//            msgFilter.addAction("REDANT.BROADCAST.UPLOAD_MODIFY_QUEUE");
-//            msgFilter.addAction("REDANT.BROADCAST.UPLOAD_RETRY_UPLOAD");
-        }
-        if ((service_flag & FLAG_SERVICE_LOCATION) == FLAG_SERVICE_LOCATION) {
-
-
-            msgFilter.addAction(RABroadcast.ACTION_LOCATION_ENABLE_TRACING);
-            msgFilter.addAction(RABroadcast.ACTION_LOCATION_DISABLE_TRACING);
-            msgFilter.addAction(RABroadcast.ACTION_LOCATION_REQUEST_LOCATION);
-//            msgFilter.addAction("REDANT.BROADCAST.RESET_LOCATION");
-            locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
-
-            locationListener = new LocationListener() {
-
-                // Provider的状态在可用、暂时不可用和无服务三个状态直接切换时触发此函数
-                @Override
-                public void onStatusChanged(String provider, int status,
-                                            Bundle extras) {
-
-                }
-
-                // Provider被enable时触发此函数,比如GPS被打开
-                @Override
-                public void onProviderEnabled(String provider) {
-
-                }
-
-                // Provider被disable时触发此函数,比如GPS被关闭
-                @Override
-                public void onProviderDisabled(String provider) {
-
-                }
-
-                // 当坐标改变时触发此函数,如果Provider传进相同的坐标,它就不会被触发
-                @Override
-                public void onLocationChanged(Location location) {
-                    locationCallback.onLocationChanged(location);
-
-                }
-            };
-
-
-            enable_locationTracing(locationTracing_timeInterval, locationTracing_distance);
-
-
-//          msgFilter.addAction("REDANT.POP.GPS_ON");
-//		    msgFilter.addAction("REDANT.POP.GPS_OFF");
-//		    msgFilter.addAction("REDANT.POP.REQUEST_LOCATION");
-        }
-        if ((service_flag & FLAG_SERVICE_NOTIFICATION) == FLAG_SERVICE_NOTIFICATION) {
-
-            if (TextUtils.isEmpty(url_checknotification)) {
-                Log.e(TAG, "onCreate: setup FLAG_SERVICE_NOTIFICATION without url_checknotification");
-            }
-
-            msgFilter.addAction(RABroadcast.ACTION_PUSHNOTIFICATION_CHECK);
-
-        }
-
-        registerReceiver(uploadReceiver, msgFilter);
-
-        super.onCreate();
-
-        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
-            String CHANNEL_ID = "apex & driver";
-            String CHANNEL_NAME = "Background Service";
-
-            NotificationChannel channel = new NotificationChannel(CHANNEL_ID,
-                    CHANNEL_NAME, NotificationManager.IMPORTANCE_NONE);
-            ((NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE)).createNotificationChannel(channel);
-
-            Notification notification = new NotificationCompat.Builder(this, CHANNEL_ID)
-                    .setCategory(Notification.CATEGORY_SERVICE).setSmallIcon(R.drawable.ic_launcher_foreground).setPriority(1000).build();
-
-            startForeground(101, notification);
-        }
-
-//        SharedPreferences pref = getSharedPreferences("Apex & Drivers", 0);
-//        boolean notification = pref.getBoolean("enable_notification", false);
-//        notification = true;
-//        if (notification == true)
-            startalarm();
-
-
-    }
-
-
-    @Override
-    public void onDestroy() {
-        Log.e("_SERVICE", "onDestroy: ");
-        if (uploadManager != null)
-            uploadManager.saveTasks();
-
-        unregisterReceiver(uploadReceiver);
-        super.onDestroy();
-    }
-
-    private BroadcastReceiver uploadReceiver = new RABroadcastReceiver() {
-
-        public void onReceive(Context context, Intent intent) {
-            String action = intent
-                    .getAction();
-
-            Log.d(TAG, "onReceive: " + action);
-            dbgUtil.fileLog(context,TAG+"   RABroadcastReceiver: onReceive  " + action);
-            // 如果捕捉到的action是ACTION_BATTERY_CHANGED
-
-            if (RABroadcast.ACTION_UPLOAD_ADD_TASK.equals(action)) {
-
-                ArrayList<Bundle> tasks = intent.getParcelableArrayListExtra("tasks");
-
-
-                uploadManager.addTasks(tasks);
-            }
-//            else if ("REDANT.RAImage.SAVE_TASK".equals(action)) {
-//                uploadManager.stopAllTasks();
-//            }
-            else if (intent
-                    .getAction()
-                    .equals(ConnectivityManager.CONNECTIVITY_ACTION)) {
-
-                ConnectivityManager connManager = (ConnectivityManager) context
-                        .getSystemService(Context.CONNECTIVITY_SERVICE);
-
-                NetworkInfo networkInfo = connManager.getActiveNetworkInfo();
-                if (networkInfo == null) {
-                    dbgUtil.Logd(
-                            "Current Network info",
-                            "can not get Active NetworkInfo!");
-                    return;
-                }
-                NetworkInfo.State netState = networkInfo
-                        .getState();
-                if (netState != NetworkInfo.State.CONNECTED) {
-                    dbgUtil.Logd(
-                            "Current Network info",
-                            "not Connected!State="
-                                    + netState);
-                    return;
-                } else {
-
-                    int iconntype = -1;
-                    iconntype = networkInfo
-                            .getType();
-                    SharedPreferences pref = getApplication()
-                            .getSharedPreferences(
-                                    "UploadManager",
-                                    0);
-
-
-                    boolean wifi_only = pref.getBoolean("wifi_only", false);
-
-                    if (wifi_only == true && iconntype != ConnectivityManager.TYPE_WIFI && iconntype != 9/* earthnet */) {
-                        uploadManager.stopAllTasks();
-//															 dbgUtil.Log(Log.DEBUG,
-//															 "Current Network info",
-//															 "not allowed!Connection type="
-//															 +
-//															 networkInfo.getTypeName());
-                        return;
-                    }
-                }
-
-
-            } else if (RABroadcast.ACTION_LOCATION_ENABLE_TRACING.equals(action)) {
-                enable_locationTracing(locationTracing_timeInterval, locationTracing_distance);
-            } else if (RABroadcast.ACTION_LOCATION_DISABLE_TRACING
-                    .equals(action)) {
-
-                disable_locationTracing();
-            } else if (RABroadcast.ACTION_LOCATION_REQUEST_LOCATION
-                    .equals(action)) {
-
-
-                String receiverID = intent.getStringExtra("receiverID");
-//                locationManager.requestSingleUpdate();
-                request_location(receiverID);
-//                locationCallback.onLocationChanged();
-            } else if (RABroadcast.ACTION_PUSHNOTIFICATION_CHECK.equals(action)) {
-
-                // 重复定时任务
-
-//                Intent iAlarm = new Intent(RAService.this, RABroadcastReceiver.class);
-//        iAlarm.putExtra("caller", caller);
-                Intent iAlarm = new Intent(RABroadcast.ACTION_PUSHNOTIFICATION_CHECK);
-//                iAlarm.setAction(RABroadcast.ACTION_PUSHNOTIFICATION_CHECK);
-                PendingIntent sender = PendingIntent.getBroadcast(RAService.this, 0,
-                        iAlarm, PendingIntent.FLAG_UPDATE_CURRENT);
-
-
-
-                AlarmManager am = (AlarmManager) RAService.this.getSystemService(
-                        Context.ALARM_SERVICE);
-
-
-                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
-                    am.setExactAndAllowWhileIdle(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + pushcheck_timeInterval, sender);
-                } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
-                    am.setExact(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + pushcheck_timeInterval, sender);
-                }
-
-//                Log.d(TAG, "onReceive: " + RABroadcast.ACTION_PUSHNOTIFICATION_CHECK);
-                checkpush(context);
-            } else if (RABroadcast.ACTION_PUSHNOTIFICATION_ENABLE_CHECK
-                    .equals(action)) {
-
-                String tag = "onReceive@Alarmreceiver";
-//                Log.i( tag, "receive alarm broadcast caller =="
-//                        + intent.getStringExtra("caller"));
-
-                startalarm();
-
-//                checkpush(context);
-
-//                if (SystemClock.elapsedRealtime()
-//                        - ApexTrackingApplication.getLastCheckMessageTime() > 120000)
-//                {
-//                    Log.i(tag, "check messsage");
-//                    ApexTrackingApplication.UpdateLastCheckMessageTime();
-//                    checkpush(context);
-//
-//                }
-            } else if (RABroadcast.ACTION_PUSHNOTIFICATION_DISABLE_CHECK
-                    .equals(action)) {
-                if (m_task != null)
-                    m_task.cancel(true);
-//                NotificationManager nManager = (NotificationManager) context
-//                        .getSystemService(Context.NOTIFICATION_SERVICE);
-//                nManager.cancel(R.layout.activity_apex);
-                cancelalarm();
-                // ApexTrackingApplication.put_password("");
-                // ApexTrackingApplication.put_sessionid("");
-                // ApexTrackingApplication.put_user("");
-//                ApexTrackingApplication.logout();
-            }
-        }
-    };
-
-    private void startalarm()
-
-    {
-        Log.d(TAG, "startalarm: ");
-
-
-        // 启动完成
-//        Intent iAlarm = new Intent(this, RABroadcastReceiver.class);
-//        iAlarm.putExtra("caller", caller);
-        Intent iAlarm = new Intent(RABroadcast.ACTION_PUSHNOTIFICATION_CHECK);
-//        iAlarm.setAction(RABroadcast.ACTION_PUSHNOTIFICATION_CHECK);
-        PendingIntent sender = PendingIntent.getBroadcast(this, 0,
-                iAlarm, PendingIntent.FLAG_UPDATE_CURRENT);
-
-        long firstime = SystemClock.elapsedRealtime();
-//		UpdateLastAlermTime();
-        AlarmManager am = (AlarmManager) this.getSystemService(
-                Context.ALARM_SERVICE);
-
-//        // 30秒一个周期,不停的发送广播
-//        am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, firstime,
-//                pushcheck_timeInterval, sender);
-
-
-
-
-        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
-            am.setExactAndAllowWhileIdle(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime(), sender);
-        } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
-            am.setExact(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime(), sender);
-        } else {
-            am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime(), pushcheck_timeInterval, sender);
-        }
-
-//        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
-//            am.setExactAndAllowWhileIdle(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime(), sender);
-//        } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
-//            am.setExact(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime(), sender);
-//        } else {
-//            am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime(), pushcheck_timeInterval, sender);
-//        }
-    }
-
-    private void cancelalarm() {
-
-        // 启动完成
-        Intent iAlarm = new Intent(this, RABroadcastReceiver.class);
-        iAlarm.setAction(RABroadcast.ACTION_PUSHNOTIFICATION_CHECK);
-        PendingIntent sender = PendingIntent.getBroadcast(this, 0,
-                iAlarm, PendingIntent.FLAG_UPDATE_CURRENT);
-
-        AlarmManager am = (AlarmManager) getSystemService(
-                Context.ALARM_SERVICE);
-
-        am.cancel(sender);
-//        SharedPreferences pref = getSharedPreferences("Apex & Drivers", 0);
-//        SharedPreferences.Editor editor = pref.edit();
-//
-//        editor.putBoolean("enable_notification", false);
-//        editor.commit();
-
-
-    }
-
-//    void registerReceiver() {
-//
-//    }
-
-
-    void disable_locationTracing() {
-        locationManager.removeUpdates(locationListener);
-    }
-
-
-    void enable_locationTracing(int timeInterval, int distance) {
-
-        if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
-            // TODO: Consider calling
-            //    ActivityCompat#requestPermissions
-            // here to request the missing permissions, and then overriding
-            //   public void onRequestPermissionsResult(int requestCode, String[] permissions,
-            //                                          int[] grantResults)
-            // to handle the case where the user grants the permission. See the documentation
-            // for ActivityCompat#requestPermissions for more details.
-            return;
-        }
-
-
-        locationManager.requestLocationUpdates(
-                "fused", timeInterval, distance,
-                locationListener);
-//        if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
-//
-//
-//
-//
-//        } else if (locationManager
-//                .isProviderEnabled(LocationManager.NETWORK_PROVIDER)) {
-//
-//
-//            locationManager.requestLocationUpdates(
-//                    LocationManager.NETWORK_PROVIDER, timeInterval, distance,
-//                    locationListener);
-//
-//        }
-    }
-
-    protected Location request_cachedlocation() {
-        if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
-
-            return null;
-        }
-
-
-        //使用GPS获取上一次的地址,这样获取到的信息需要多次,才能够显示出来,所以后面有动态的判断
-        Location location = locationManager.getLastKnownLocation("fused");
-        return location;
-
-    }
-
-    protected void request_location(final String receiverID) {
-        if (receiverID == null)
-            throw new IllegalArgumentException("receiverID can't be null");
-
-//        Criteria criteria = new Criteria();
-//        criteria.setAccuracy(Criteria.ACCURACY_COARSE);//低精度,如果设置为高精度,依然获取不了location。
-//        criteria.setAltitudeRequired(false);//不要求海拔
-//        criteria.setBearingRequired(false);//不要求方位
-//        criteria.setCostAllowed(true);//允许有花费
-//        criteria.setPowerRequirement(Criteria.POWER_LOW);//低功耗
-//
-//        //从可用的位置提供器中,匹配以上标准的最佳提供器
-//        String locationProvider = locationManager.getBestProvider(criteria, true);
-
-
-        if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
-            // TODO: Consider calling
-            //    ActivityCompat#requestPermissions
-            // here to request the missing permissions, and then overriding
-            //   public void onRequestPermissionsResult(int requestCode, String[] permissions,
-            //                                          int[] grantResults)
-            // to handle the case where the user grants the permission. See the documentation
-            // for ActivityCompat#requestPermissions for more details.
-            return;
-        }
-
-        LocationListener singleListener = new LocationListener() {
-            @Override
-            public void onLocationChanged(Location location) {
-
-                Intent Bintent = new Intent(RABroadcast.EVENT_RETURN_LOCATION);
-                Bintent.putExtra("location", location);
-                Bintent.putExtra("receiverID", receiverID);
-                sendBroadcast(Bintent);
-
-
-            }
-
-            @Override
-            public void onStatusChanged(String s, int i, Bundle bundle) {
-
-            }
-
-            @Override
-            public void onProviderEnabled(String s) {
-
-            }
-
-            @Override
-            public void onProviderDisabled(String s) {
-
-            }
-        };
-
-
-        locationManager.requestSingleUpdate("fused", singleListener, null);
-
-
-    }
-}

+ 0 - 141
ApexDrivers/RAUtilsLibrary/src/main/java/com/usai/redant/rautils/Upload/RAOperationQueue.java

@@ -1,141 +0,0 @@
-package com.usai.redant.rautils.upload;
-
-import android.content.Context;
-import android.content.Intent;
-import android.os.Bundle;
-import android.util.Log;
-
-import java.util.concurrent.ConcurrentLinkedQueue;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ThreadPoolExecutor;
-
-/**
- * Created by ray on 28/06/2017.
- */
-
-public class RAOperationQueue {
-
-    public interface OperationCallback {
-        /**
-            每个具体任务执行的回调
-         */
-        public Boolean operate(Bundle taskinfo);
-        public void operateFinish(Bundle taskinfo);
-    }
-
-//    private Application mApp;
-//    public void setApplication(Application application) {
-//        mApp = application;
-//    }
-
-
-    public RAOperationQueue(Context applicationContext)
-    {
-        if(applicationContext==null)
-            throw new IllegalArgumentException("applicationContext can't be null");
-        this.applicationContext = applicationContext;
-    }
-    Context applicationContext;
-    OperationCallback execCallback;
-    public void setCallback(OperationCallback callback)
-    {
-        execCallback=callback;
-    }
-    //并发队列
-    private ConcurrentLinkedQueue<Bundle> queue = new ConcurrentLinkedQueue<Bundle>();
-    // 最大并发数
-    public int MaxThread = 3;
-    //线程池
-    private ExecutorService es = Executors.newCachedThreadPool();
-
-
-//    public RAOperation runThread;
-    public void addOperation(final Bundle taskinfo)
-    {
-
-
-        queue.offer(taskinfo);
-        while (((ThreadPoolExecutor)es).getActiveCount()< MaxThread) {
-
-
-            es.submit(new Runnable() {
-                boolean wrong = false;
-                @Override
-                public void run() {
-
-                    while (!queue.isEmpty()) {
-                        Bundle task=queue.poll();
-
-                        System.out.println("running  tid="+Thread.currentThread().getId());
-                        task.putLong("tid",Thread.currentThread().getId());
-//                        int min=1000;
-//                        int max=5000;
-//                        int sleep=new Random().nextInt(max)%(max-min+1) + min;
-//                        try{
-//                            Thread.currentThread().sleep(sleep);
-//                        }catch(InterruptedException ie){
-//                            ie.printStackTrace();
-//                        }
-                        boolean retry=execCallback.operate(task);
-                        if(retry)
-                            queue.offer(task);
-                        else
-                        {
-                            task.remove("tid");
-                            execCallback.operateFinish(task);
-
-                            RAUploadManager.TaskStatus status= RAUploadManager.TaskStatus.values()[task.getInt("status",0)];
-
-                            if (status== RAUploadManager.TaskStatus.TaskStatusError)
-                                wrong=true;
-
-                        }
-                        System.out.println("     finish  tid="+Thread.currentThread().getId());
-                    }
-
-                    synchronized (this)
-                    {
-                        if(((ThreadPoolExecutor) es).getActiveCount()==1)
-                        {
-
-
-                            Intent intent = new Intent("REDANT.RAImage.UPLOAD_COMPLETE");
-
-
-
-
-                            if(wrong)
-                            {
-                                intent.putExtra("result","error");
-                            }
-                            else
-                            {
-                                intent.putExtra("result","finish");
-                            }
-
-                            applicationContext.sendBroadcast(intent);
-
-                            //getApplicationContext()
-                            Log.e("Finish_msg", "run: -----------task finish" );
-
-//                                                        Toast toast = Toast.makeText(getApplicationContext(),
-//                                    "Piid must be a number",
-//                                    Toast.LENGTH_LONG);
-//                            toast.setGravity(Gravity.CENTER, 0, 0);
-//                            toast.show();;
-
-                        }
-                    }
-
-                }
-            });
-
-        }
-    }
-    public void stopQueue()
-    {
-        queue.clear();
-        es.shutdown();
-    }
-}

+ 0 - 742
ApexDrivers/RAUtilsLibrary/src/main/java/com/usai/redant/rautils/Upload/RAUploadManager.java

@@ -1,742 +0,0 @@
-package com.usai.redant.rautils.upload;
-
-import android.content.Context;
-import android.content.SharedPreferences;
-import android.net.ConnectivityManager;
-import android.net.NetworkInfo;
-import android.os.Bundle;
-import android.util.Base64;
-import android.util.Log;
-
-import com.usai.redant.rautils.utils.ImageUtil;
-import com.usai.redant.rautils.utils.Network;
-import com.usai.redant.rautils.utils.RAUtil;
-import com.usai.redant.rautils.utils.dbgUtil;
-
-import org.json.JSONException;
-import org.json.JSONObject;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Created by ray on 13/06/2017.
- */
-
-public class RAUploadManager {
-
-    public int maxThread = 3;
-    public int activeThread;
-    public int maxRetry = 5;
-    public int retryWaiting = 300;
-
-
-    public Boolean wifiOnly = false;
-    //    public Boolean autoStart=true;
-//    public Boolean removeFinish=true;
-//    public Boolean removeError=false;
-    public QueueStatus queue_status;
-
-
-    public static final int RESULT_BARCODE_ERROR = -50;
-
-    public TaskStatus newtaskStatus = TaskStatus.TaskStatusWait;
-    private ArrayList<Bundle> arr_queue;
-
-    public ArrayList<Bundle> get_arr_queue() {
-        return arr_queue;
-    }
-
-    //    private List<Bundle> operation_queue;
-//    private ExecutorService es = Executors.newFixedThreadPool(3);//
-    // .newFixedThreadPool();
-//    private CountDownLatch latch = new CountDownLatch(maxThread);
-    private RAOperationQueue operation_queue;
-
-    public enum QueueStatus {
-        QueueStatusDefault,
-        QueueStatusAdd,
-        QueueStatusError,
-        QueueStatusFinishWithError,
-        QueueStatusFinish
-    }
-
-    public enum TaskStatus {
-        TaskStatusStop,
-        TaskStatusStart,
-        TaskStatusError,
-        TaskStatusWait,
-        TaskStatusFinish,
-        //TaskStatusCancel,
-    }
-
-//    public RAUploadManager(Context applicationContext)
-//    {
-//        if(applicationContext==null)
-//            throw new IllegalArgumentException("applicationContext can't be null");
-//        this.applicationContext = applicationContext;
-//    }
-    public UIUpdateListener uiUpdateListener;
-
-//    private Application mApp;
-    private Context applicationContext;
-//    public void setApplication(Application application) {
-//        mApp = application;
-//    }
-
-    public interface UIUpdateListener {
-        //        void onProgress(long index, double percentage);
-        void updateCell(long index, Bundle taskinfo);
-//        void updateList();
-
-        void updateList(ArrayList<Bundle> newlist);
-//        void addTasks(ArrayList<Bundle> tasks);
-//        void RemoveTasks(ArrayList<Bundle> tasks);
-
-//        void onFinish(int code, String res/*, HashMap<String, List<String>> headers*/);
-    }
-
-
-//    class Poll implements Runnable {
-//        public void run() {
-//            // while (queue.size()>0) {
-//            while (!operation_queue.isEmpty()) {
-//                System.out.println(operation_queue.poll());
-//            }
-//            latch.countDown();
-//        }
-//    }
-
-    public RAUploadManager(Context appCtx) {
-
-        if(appCtx==null)
-            throw new IllegalArgumentException("applicationContext can't be null");
-        this.applicationContext = appCtx;
-
-        queue_status = QueueStatus.QueueStatusDefault;
-
-
-        SharedPreferences UMSetting = applicationContext.getSharedPreferences("UploadManager", 0);
-
-        if (UMSetting != null) {
-//            autoStart = UMSetting.getBoolean("auto_upload",false);
-//            removeFinish = UMSetting.getBoolean("auto_rm_finish",false);
-//            removeError = UMSetting.getBoolean("auto_rm_error",false);
-            maxRetry = UMSetting.getInt("retry_count", 5);
-            newtaskStatus = TaskStatus.values()[UMSetting.getInt("newtask_status", TaskStatus.TaskStatusWait.ordinal())];
-
-            maxThread = UMSetting.getInt("max_thread", 3);
-
-            wifiOnly = UMSetting.getBoolean("wifi_only", false);
-
-        }
-        operation_queue = new RAOperationQueue(applicationContext);
-//        operation_queue.setApplication(mApp);
-        operation_queue.setCallback(new RAOperationQueue.OperationCallback() {
-            @Override
-            public Boolean operate(final Bundle taskinfo) {
-
-
-//
-//                ConnectivityManager connManager = (ConnectivityManager) context
-//                        .getSystemService(Context.CONNECTIVITY_SERVICE);
-//
-//                NetworkInfo networkInfo = connManager
-//                        .getActiveNetworkInfo();
-//                if (networkInfo == null)
-//                {
-//                    dbgUtil.Logd(
-//                            "Current Network info",
-//                            "can not get Active NetworkInfo!");
-//                    false;
-//                }
-//                NetworkInfo.State netState = networkInfo
-//                        .getState();
-//                if (netState != NetworkInfo.State.CONNECTED)
-//                {
-//                    dbgUtil.Logd(
-//                            "Current Network info",
-//                            "not Connected!State="
-//                                    + netState);
-//                    return;
-//                }
-//                int iconntype = -1;
-//                iconntype = networkInfo
-//                        .getType();
-//                SharedPreferences pref = RedAntApplication
-//                        .getInstance()
-//                        .getSharedPreferences(
-//                                "UploadManager",
-//                                0);
-//
-////															String aa = pref
-////																	.getString(
-////																			"aa",
-////																			null);
-////															String ea = pref
-////																	.getString(
-////																			"ea",
-////																			null);
-////															if (iconntype == ConnectivityManager.TYPE_WIFI)
-////															{
-////																if (!TextUtils
-////																		.isEmpty(aa))
-////																	RedAntApplication.active_address = aa;
-////															}
-////															else
-////															{
-////																if (!TextUtils
-////																		.isEmpty(ea))
-////																	RedAntApplication.active_address = ea;
-////															}
-//                boolean
-//                        wifi_only
-//                        =pref.getBoolean("wifi_only",
-//                        true);
-//
-//                if
-//                        (wifi_only
-//                        == true
-//                        && iconntype !=
-//                        ConnectivityManager.TYPE_WIFI
-//                        && iconntype !=
-//                        9/* earthnet */)
-//
-
-                boolean ret = false;
-                String path = taskinfo.getString("path");
-                taskinfo.putInt("status", TaskStatus.TaskStatusStart.ordinal());
-                String url = taskinfo.getString("url");
-
-                int waiting = taskinfo.getInt("retry_waiting", 0);
-
-                int newwaiting = waiting;
-                if (newwaiting / 60.0 < 20)
-                    newwaiting += retryWaiting;
-                if (newwaiting > 1200)
-                    newwaiting = 1200;
-                taskinfo.putInt("retry_waiting", newwaiting);
-
-                //                try{
-                try {
-                    Thread.currentThread().sleep(waiting * 1000);
-                } catch (InterruptedException e) {
-                    e.printStackTrace();
-                }
-//                }catch(InterruptedException ie){
-//                    ie.printStackTrace();
-//                }
-                JSONObject result = Network.uploadFileJSON(path, url, taskinfo.getBundle("params"), new Network.FileUploadListener() {
-                    @Override
-                    public double percent_step() {
-                        //进度刷新步进 3%
-                        return 3.0;
-                    }
-
-                    @Override
-                    public boolean interupt() {
-//                        if(taskinfo.getBoolean("iscancel",false))
-//                            return false;
-                        return taskinfo.getBoolean("iscancel", false);
-                    }
-
-                    @Override
-                    public void onProgress(long pro, double percentage) {
-
-
-                        synchronized (this) {
-                            Log.d("_synchronized", "UploadImage onProgress: " + percentage);
-                            long timeStart = System.currentTimeMillis();
-                            taskinfo.putDouble("progress", percentage);
-                            if (uiUpdateListener != null) {
-                                int index = arr_queue.indexOf(taskinfo);
-//                            uiUpdateListener.onProgress(index,percentage);
-
-                                uiUpdateListener.updateCell(index, taskinfo);
-                            }
-                            Log.d("_synchronized", "UploadImage onProgress: end" + (System.currentTimeMillis() - timeStart));
-                        }
-
-
-                    }
-
-                    @Override
-                    public void onFinish(int code, String res) {
-                        Log.d("", "onFinish: ");
-
-                    }
-                });
-
-                int r = 0;
-                try {
-                    r = result.getInt("result");
-
-
-                    if (r == 2 || r == RESULT_BARCODE_ERROR) {
-                        taskinfo.putInt("status", TaskStatus.TaskStatusFinish.ordinal());
-                        if (r == 2)
-                            taskinfo.putString("msg", "upload successful");
-                        else {
-                            String rmsg = result.getString("msg");
-                            taskinfo.putString("msg", "warning: " + rmsg);
-                        }
-                    } else {
-                        if (taskinfo.getInt("retry", 0) >= maxRetry) {
-                            taskinfo.putInt("status", TaskStatus.TaskStatusError.ordinal());
-                            taskinfo.putDouble("progress", 0.0);
-                            String rmsg = result.getString("msg");
-                            taskinfo.putString("msg", rmsg);
-                        } else {
-                            taskinfo.putInt("retry", taskinfo.getInt("retry", 0) + 1);
-                            taskinfo.putInt("status", TaskStatus.TaskStatusWait.ordinal());
-                            taskinfo.putDouble("progress", 0.0);
-                            taskinfo.putString("msg", "connection lost, retry...");
-                            ret = true;
-
-                        }
-                    }
-
-
-                } catch (JSONException e) {
-//                    String rmsg=result.getString("msg");
-                    taskinfo.putInt("status", TaskStatus.TaskStatusError.ordinal());
-                    taskinfo.putDouble("progress", 0.0);
-                    taskinfo.putString("msg", "can not upload, please contact administrator.");
-                    e.printStackTrace();
-                } finally {
-                    synchronized (this) {
-                        Log.d("_synchronized", "UploadImage finally ");
-
-                        long timeStart = System.currentTimeMillis();
-                        if (uiUpdateListener != null) {
-                            int index = arr_queue.indexOf(taskinfo);
-
-                            uiUpdateListener.updateCell(index, taskinfo);
-                        }
-                        Log.d("_synchronized", "UploadImage finally finish" + (System.currentTimeMillis() - timeStart));
-
-                    }
-                }
-
-                return ret;
-//                int a=0;
-//                System.out.println(a+"running  tid="+Thread.currentThread().getId());
-//                int min=1000;
-//                int max=5000;
-//                int sleep=new Random().nextInt(max)%(max-min+1) + min;
-//                try{
-//                    Thread.currentThread().sleep(sleep);
-//                }catch(InterruptedException ie){
-//                    ie.printStackTrace();
-//                }
-//                System.out.println(a+"   "+sleep+"     finish  tid="+Thread.currentThread().getId());
-
-            }
-
-            @Override
-            public void operateFinish(Bundle taskinfo) {
-
-                TaskStatus status = TaskStatus.values()[taskinfo.getInt("status", 0)];
-
-                //新增逻辑,对于成功上传的图片,从书记删除
-                //taskinfo.getString("msg").indexOf("warning:")<0 没有匹配错误
-                String path = filePath(taskinfo);
-                File file = new File(path);
-                //只有finish的task 可以删除图片
-
-                if (file.exists() && taskinfo.getInt("status") == TaskStatus.TaskStatusFinish.ordinal() && taskinfo.getString("msg").indexOf("warning:") < 0) {
-                    String filepath = file.getAbsolutePath();
-                    file.delete();
-                    ImageUtil.updateGallery(applicationContext,filepath);
-                }
-                ///////////////////////////////////////////////
-
-                boolean removefromlist = false;
-//                if (status==TaskStatus.TaskStatusFinish&&removeFinish)
-//                    removefromlist=true;
-//                else if (status==TaskStatus.TaskStatusError&&removeError)
-//                    removefromlist=true;
-
-                synchronized (this) {
-
-                    Log.d("_synchronized", "OperationCallback operateFinish: ");
-                    long timeStart = System.currentTimeMillis();
-                    if (removefromlist) {
-
-                        removeTask(taskinfo);
-//                            arr_queue.remove(taskinfo);
-//                        if(uiUpdateListener!=null)
-//                            uiUpdateListener.updateList();
-
-
-                    } else {
-                        saveTasks();
-                    }
-
-                    Log.d("_synchronized", "OperationCallback operateFinish: end" + (System.currentTimeMillis() - timeStart));
-
-
-//                        saveTasks();
-
-
-                }
-
-
-            }
-        });
-
-        //            operation_queue = new List<Bundle>() {};
-
-        loadTask();
-
-    }
-
-    private void loadTask() {
-        stopAllTasks();
-        arr_queue = new ArrayList<Bundle>();
-
-
-        Log.d("_RAIMAGE", "saveTasks: RAUploadManager");
-
-        SharedPreferences pref = applicationContext.getSharedPreferences("RA Image", 0);
-        try {
-            String tasksBase64 = pref.getString("task_list", "");
-
-
-//            ArrayList<String> wrap_arr = new ArrayList<String>();
-//            for( Bundle b:arr_queue)
-//            {
-//                String sjson=RAUtil.Bundle2Json(b).toString();
-//                Log.d("_RAIMAGE", "saveTasks: "+sjson);
-//                wrap_arr.add(sjson);
-//            }
-//
-//            ByteArrayOutputStream baos = new ByteArrayOutputStream();
-//            ObjectOutputStream oos = new ObjectOutputStream(baos);
-//            oos.writeObject(wrap_arr);
-//
-//            String tasksBase64 = android.util.Base64.encodeToString(baos.toByteArray(), android.util.Base64.DEFAULT);//new String(Base64.encodeBase64(baos.toByteArray()));
-//
-//
-//            editor.putString("task_list", tasksBase64);
-//
-//
-//            editor.commit();
-
-            if (tasksBase64.length() > 0) {
-                byte[] decode = Base64.decode(tasksBase64, Base64.DEFAULT);
-                ByteArrayInputStream bais = new ByteArrayInputStream(decode);
-
-                ObjectInputStream ois = null;
-
-                ois = new ObjectInputStream(bais);
-
-                ArrayList<String> arr_load = (ArrayList<String>) ois.readObject();
-                for (String s : arr_load) {
-                    Log.d("_RAIMAGE", "loadTask: " + s);
-                    JSONObject jsobj = new JSONObject(s);
-                    Bundle b = RAUtil.Json2Bundle(jsobj);
-                    arr_queue.add(b);
-//                                String sjson=RAUtil.Bundle2Json(b).toString();
-
-//                wrap_arr.add(sjson);
-                }
-            }
-
-
-        } catch (IOException e) {
-            e.printStackTrace();
-        } catch (ClassNotFoundException e) {
-            e.printStackTrace();
-        } catch (JSONException e) {
-            e.printStackTrace();
-        }
-        for (Bundle b : arr_queue) {
-
-            TaskStatus status = TaskStatus.values()[b.getInt("status", 0)];
-
-            if (status != TaskStatus.TaskStatusFinish && status != TaskStatus.TaskStatusError)
-                startTask(b);
-        }
-//            int a = 0;
-        // 此处缺少读取持久话保存任务队列的实现。
-    }
-
-    public void addTask(Bundle task) {
-
-        synchronized (this) {
-            Log.d("_synchronized", "addTask: ");
-            long timeStart = System.currentTimeMillis();
-            arr_queue.add(task);
-            saveTasks();
-            Log.d("_synchronized", "addTask: end" + (System.currentTimeMillis() - timeStart));
-        }
-        if (newtaskStatus == TaskStatus.TaskStatusWait) {
-            startTask(task);
-        }
-    }
-
-    ;
-
-    public void addTasks(ArrayList<Bundle> tasks) {
-
-        synchronized (this) {
-            Log.d("_synchronized", "addTasks: ");
-            long timeStart = System.currentTimeMillis();
-            arr_queue.addAll(tasks);
-            saveTasks();
-
-            Log.d("_synchronized", "addTasks: end" + (System.currentTimeMillis() - timeStart));
-
-        }
-        if (newtaskStatus == TaskStatus.TaskStatusWait) {
-            for (Bundle task : tasks) {
-                startTask(task);
-            }
-
-        }
-
-    }
-
-    ;
-
-    public void startTask(Bundle task) {
-
-        task.putBoolean("iscancel", false);
-
-
-        boolean canstart = true;
-
-        ConnectivityManager connManager = (ConnectivityManager) applicationContext.getSystemService(Context.CONNECTIVITY_SERVICE);
-
-        NetworkInfo networkInfo = connManager
-                .getActiveNetworkInfo();
-        if (networkInfo == null) {
-            dbgUtil.Logd(
-                    "Current Network info",
-                    "can not get Active NetworkInfo!");
-            canstart = false;
-        } else {
-            NetworkInfo.State netState = networkInfo
-                    .getState();
-            if (netState != NetworkInfo.State.CONNECTED) {
-                dbgUtil.Logd(
-                        "Current Network info",
-                        "not Connected!State="
-                                + netState);
-                canstart = false;
-            }
-            int iconntype = -1;
-            iconntype = networkInfo
-                    .getType();
-
-            if (wifiOnly == true
-                    && iconntype !=
-                    ConnectivityManager.TYPE_WIFI
-                    && iconntype !=
-                    9/* earthnet */) {
-                canstart = false;
-            }
-        }
-
-        if (canstart) {
-
-            task.putInt("retry_waiting", 0);
-            task.putInt("status", TaskStatus.TaskStatusWait.ordinal());
-            operation_queue.addOperation(task);
-        } else {
-            task.putInt("status", TaskStatus.TaskStatusStop.ordinal());
-            if (uiUpdateListener != null) {
-                int index = arr_queue.indexOf(task);
-//                            uiUpdateListener.onProgress(index,percentage);
-
-                uiUpdateListener.updateCell(index, task);
-            }
-
-        }
-
-
-    }
-
-    ;
-
-    public void clearTask() {
-        ArrayList<Bundle> remove = new ArrayList<Bundle>();
-        for (Bundle b : arr_queue) {
-//            if(TaskStatus.values()[b.getInt("status",0)]==TaskStatus.TaskStatusStart||TaskStatus.values()[b.getInt("status",0)]==TaskStatus.TaskStatusWait)
-//                continue;
-
-            if (TaskStatus.values()[b.getInt("status", 0)] == TaskStatus.TaskStatusFinish || TaskStatus.values()[b.getInt("status", 0)] == TaskStatus.TaskStatusError)
-                remove.add(b);
-//            removeTask(b);
-        }
-        removeTasks(remove);
-
-
-    }
-
-    public void removeTask(Bundle task) {
-
-
-        synchronized (this) {
-            Log.d("_synchronized", "removeTask");
-            long timeStart = System.currentTimeMillis();
-            arr_queue.remove(task);
-            saveTasks();
-
-
-            String path = filePath(task);
-            File file = new File(path);
-            //只有finish的task 可以删除图片
-            if (file.exists() && task.getInt("status") == TaskStatus.TaskStatusFinish.ordinal()) {
-                String filepath = file.getAbsolutePath();
-                file.delete();
-                ImageUtil.updateGallery(applicationContext,filepath);
-            }
-
-            if (uiUpdateListener != null)
-                uiUpdateListener.updateList(arr_queue);
-
-            Log.d("_synchronized", "removeTask: end" + (System.currentTimeMillis() - timeStart));
-        }
-
-
-    }
-
-    ;
-
-    public void removeTasks(List<Bundle> tasks) {
-
-        synchronized (this) {
-            Log.d("_synchronized", "removeTasks: ");
-            long timeStart = System.currentTimeMillis();
-            arr_queue.removeAll(tasks);
-            saveTasks();
-            for (Bundle task : tasks) {
-
-                String path = filePath(task);
-                File file = new File(path);
-                if (file.exists() && task.getInt("status") == TaskStatus.TaskStatusFinish.ordinal()) {
-                    String filepath = file.getAbsolutePath();
-                    file.delete();
-                    ImageUtil.updateGallery(applicationContext,filepath);
-                }
-            }
-            if (uiUpdateListener != null)
-                uiUpdateListener.updateList(arr_queue);
-
-
-            Log.d("_synchronized", "removeTasks: end" + (System.currentTimeMillis() - timeStart));
-        }
-
-    }
-
-    ;
-
-    public void stopAllTasks() {
-        if (arr_queue == null)
-            return;
-        for (Bundle task : arr_queue) {
-            stopTask(task);
-        }
-    }
-
-    ;
-
-    public void stopTask(Bundle task) {
-        if (task.getInt("status") != TaskStatus.TaskStatusStart.ordinal() && task.getInt("status") != TaskStatus.TaskStatusWait.ordinal())
-            return;
-
-        task.putBoolean("iscancel", true);
-//        long tid=task.getLong("tid",-1);
-//        if(tid>0)
-//        {
-//
-//
-//        }
-//        task.tet("tid",Thread.currentThread().getId());
-
-//        RAUploadOperation
-
-
-    }
-
-    public void saveTasks() {
-
-        Log.d("_RAIMAGE", "saveTasks: RAUploadManager");
-
-        SharedPreferences pref = applicationContext.getSharedPreferences("RA Image", 0);
-        SharedPreferences.Editor editor = pref.edit();
-
-        try {
-
-            ArrayList<String> wrap_arr = new ArrayList<String>();
-            for (Bundle b : arr_queue) {
-                String sjson = RAUtil.Bundle2Json(b).toString();
-                Log.d("_RAIMAGE", "saveTasks: " + sjson);
-                wrap_arr.add(sjson);
-            }
-
-            ByteArrayOutputStream baos = new ByteArrayOutputStream();
-            ObjectOutputStream oos = new ObjectOutputStream(baos);
-            oos.writeObject(wrap_arr);
-
-            String tasksBase64 = Base64.encodeToString(baos.toByteArray(), Base64.DEFAULT);//new String(Base64.encodeBase64(baos.toByteArray()));
-
-
-            editor.putString("task_list", tasksBase64);
-
-
-            editor.commit();
-
-//            byte[] decode=Base64.decode(personBase64,Base64.DEFAULT);
-//            ByteArrayInputStream bais= new ByteArrayInputStream(decode);
-//
-//            ObjectInputStream ois = new ObjectInputStream(bais);
-//            ArrayList<String> arr_load=(ArrayList<String>)ois.readObject();
-//            int a = 0;
-
-        } catch (Exception e) {
-            e.printStackTrace();
-
-        }
-
-
-//        if (m_swSave.isChecked()&&!TextUtils.isEmpty(encryptPass)&&!TextUtils.isEmpty(encryptUser))
-//        {
-//            editor.putString("user", encryptUser);
-//            editor.putString("password", encryptPass);
-//            editor.putBoolean("kepppass", true);
-//        }
-//        else
-//        {
-//            editor.putString("user", null);
-//            editor.putString("password", null);
-//            editor.putBoolean("kepppass", false);
-//        }
-//
-//        editor.puts
-//
-//        editor.commit();
-
-    }
-
-    ;
-
-
-    private String filePath(Bundle task) {
-//        String path = Environment.getExternalStorageDirectory().getPath();
-//        path+="/"+task.getString("path");
-//        path+="/"+task.getString("file");
-
-        return task.getString("path", "");
-    }
-
-
-}

+ 0 - 10
ApexDrivers/RAUtilsLibrary/src/main/java/com/usai/redant/rautils/Upload/UploadCallback.java

@@ -1,10 +0,0 @@
-package com.usai.redant.rautils.upload;
-
-public interface UploadCallback {
-
-
-//    private boolean queue_changed = false;
-
-//    public RAUploadManager uploadManager = new RAUploadManager();
-
-}

+ 0 - 547
ApexDrivers/RAUtilsLibrary/src/main/java/com/usai/redant/rautils/Upload/UploadService.java

@@ -1,547 +0,0 @@
-package com.usai.redant.rautils.upload;
-
-import android.app.Service;
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.content.SharedPreferences;
-import android.net.ConnectivityManager;
-import android.net.NetworkInfo;
-import android.os.Binder;
-import android.os.Bundle;
-import android.os.IBinder;
-import android.util.Log;
-
-import com.usai.redant.rautils.utils.CrashHandler;
-import com.usai.redant.rautils.utils.dbgUtil;
-
-import java.util.ArrayList;
-
-@Deprecated
-public class UploadService extends Service
-{
-
-//	private UploadThread	uploadThread;
-
-    private boolean queue_changed = false;
-//	LocationManager			locationManager;
-//	LocationListener		locationListener;
-
-    public RAUploadManager uploadManager = new RAUploadManager(getApplicationContext());
-
-    // private boolean location_changed = false;
-
-    @Override
-    public IBinder onBind(Intent intent) {
-        // TODO Auto-generated method stub
-        Log.d("", "onBind: bind service");
-        return new MyBinder();
-    }
-
-
-    public class MyBinder extends Binder {
-        /**
-         * 获取当前Service的实例
-         *
-         * @return
-         */
-        public UploadService getService() {
-            return UploadService.this;
-        }
-    }
-
-    @Override
-    public void onCreate() {
-
-        Log.d("_SERVICE", "create upload Service!!!");
-//		if (uploadThread == null)
-//		{
-//			uploadThread = new UploadThread();
-//			Log.d("", "create upload thread!!!");
-//			// upleadThread.start();
-//
-//		}
-
-
-        // 初始化异常捕获器
-        CrashHandler.getSharedInstance().init(getApplicationContext());
-        CrashHandler.getSharedInstance().preserver = new CrashHandler.InfoPreserver() {
-            @Override
-            public void saveUserInformation() {
-                if (uploadManager != null) {
-                    uploadManager.saveTasks();
-                }
-            }
-
-            @Override
-            public void handleCrashInfo(String deviceInfo, String exception) {
-                dbgUtil.fileLog(getApplicationContext(),"============================ app crash ============================");
-                dbgUtil.fileLog(getApplicationContext(),"DEVICE");
-                dbgUtil.fileLog(getApplicationContext(),deviceInfo);
-                dbgUtil.fileLog(getApplicationContext(),"EXCEPTION");
-                dbgUtil.fileLog(getApplicationContext(),exception);
-                dbgUtil.fileLog(getApplicationContext(),"=============================== end ===============================");
-                Log.d("_SERVICE", "Device Info: " + deviceInfo);
-                Log.d("_SERVICE", "Crash Info: " + exception);
-            }
-        };
-
-        IntentFilter msgFilter = new IntentFilter();
-
-        msgFilter.addAction("REDANT.POP.MODIFY_QUEUE");
-//		msgFilter.addAction("REDANT.POP.GPS_ON");
-//		msgFilter.addAction("REDANT.POP.GPS_OFF");
-//		msgFilter.addAction("REDANT.POP.REQUEST_LOCATION");
-        msgFilter.addAction("REDANT.POP.RESET_LOCATION");
-        msgFilter.addAction("REDANT.POP.QUERY_UPLOAD_STATE");
-        msgFilter.addAction("REDANT.RAImage.ADD_TASK");
-        msgFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
-        msgFilter.addAction("REDANT.POP.RETRY_UPLOAD");
-
-        registerReceiver(uploadReceiver, msgFilter);
-        // registerReceiver(uploadReceiver,
-        // new IntentFilter("modify upload queue"));
-
-//		locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
-
-//		locationListener = new LocationListener()
-//		{
-//
-//			// Provider的状态在可用、暂时不可用和无服务三个状态直接切换时触发此函数
-//			@Override
-//			public void onStatusChanged(String provider, int status,
-//					Bundle extras)
-//			{
-//
-//			}
-//
-//			// Provider被enable时触发此函数,比如GPS被打开
-//			@Override
-//			public void onProviderEnabled(String provider)
-//			{
-//
-//			}
-//
-//			// Provider被disable时触发此函数,比如GPS被关闭
-//			@Override
-//			public void onProviderDisabled(String provider)
-//			{
-//
-//			}
-//
-//			// 当坐标改变时触发此函数,如果Provider传进相同的坐标,它就不会被触发
-//			@Override
-//			public void onLocationChanged(Location location)
-//			{
-//				// if (location != null)
-//				// {
-//				// location_changed = true;
-//				// Log.d("Map",
-//				// "Location changed : Lat: " + location.getLatitude()
-//				// + " Lng: " + location.getLongitude());
-//				// }
-//			}
-//		};
-
-        super.onCreate();
-
-    }
-
-    @Override
-    public void onDestroy() {
-        Log.e("_SERVICE", "onDestroy: ");
-        uploadManager.saveTasks();
-    }
-//	void gps_off()
-//	{
-//		locationManager.removeUpdates(locationListener);
-//	}
-//
-//	void gps_on()
-//	{
-//		if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER))
-//		{
-//
-////            RedAntApplication.getInstance()
-//
-////            if(!RAUtil.checkPermission(this.getApplicationContext(),"android.permission.ACCESS_FINE_LOCATION"))
-////                return;
-//
-//
-//
-//			locationManager.requestLocationUpdates(
-//					LocationManager.GPS_PROVIDER, 60 * 1000, 50,
-//					locationListener);
-//
-//		}
-//		else if (locationManager
-//				.isProviderEnabled(LocationManager.NETWORK_PROVIDER))
-//		{
-//
-//			locationManager.requestLocationUpdates(
-//					LocationManager.NETWORK_PROVIDER, 30 * 1000, 50,
-//					locationListener);
-//
-//		}
-//	}
-
-//	void update_location()
-//	{
-//
-//		Location location = null;
-//		if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER))
-//		{
-//
-//			location = locationManager
-//					.getLastKnownLocation(LocationManager.GPS_PROVIDER);
-//
-//		}
-//		else if (locationManager
-//				.isProviderEnabled(LocationManager.NETWORK_PROVIDER))
-//		{
-//
-//			location = locationManager
-//					.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
-//
-//		}
-//
-//		SharedPreferences pref = RedAntApplication.getInstance()
-//				.getSharedPreferences("RA Image", 0);
-//
-//		SharedPreferences.Editor editor = pref.edit();
-//		if (location != null)
-//		{
-//
-//			editor.putFloat("Lat", (float) location.getLatitude());
-//			editor.putFloat("Lon", (float) location.getLongitude());
-//
-//		}
-//		editor.commit();
-//
-//	}
-//
-//	void check_location()
-//	{
-//
-//		Location location = null;
-//		if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER))
-//		{
-//
-//			location = locationManager
-//					.getLastKnownLocation(LocationManager.GPS_PROVIDER);
-//
-//		}
-//		else if (locationManager
-//				.isProviderEnabled(LocationManager.NETWORK_PROVIDER))
-//		{
-//
-//			location = locationManager
-//					.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
-//
-//		}
-//
-//		SharedPreferences pref = RedAntApplication.getInstance()
-//				.getSharedPreferences("RA Image", 0);
-//		double lat = pref.getFloat("Lat", 9999);
-//		double lon = pref.getFloat("Lon", 9999);
-//
-//		// SharedPreferences.Editor editor = pref.edit();
-//		if (location != null)
-//		{
-//			float[] result = new float[1];
-//			if (lat != 9999 && lon != 9999)
-//			{
-//				Location.distanceBetween(lat, lon, location.getLatitude(),
-//						location.getLongitude(), result);
-//				if (result[0] > 1000)
-//				{
-//					sendBroadcast(new Intent("REDANT.POP.STATION_CHANGE"));
-//					return;
-//				}
-//				else
-//				{
-//					sendBroadcast(new Intent("REDANT.POP.STATION_NOT_CHANGE"));
-//					return;
-//				}
-//			}
-//			sendBroadcast(new Intent("REDANT.POP.STATION_NOT_CHANGE"));
-//			return;
-//			// new Location();
-//			//
-//			// Location.distanceBetween(lat, lon, endLatitude, endLongitude,
-//			// results)
-//			//
-//			// editor.putFloat("Lat", (float) location.getLatitude());
-//			// editor.putFloat("Lon", (float) location.getLongitude());
-//
-//		}
-//		else
-//		{
-//			sendBroadcast(new Intent("REDANT.POP.STATION_NOT_CHANGE"));
-//			return;
-//		}
-//		// editor.commit();
-//
-//		// Log.d("location:", "lat:" + latitude + "lon:" + longitude);
-//	}
-
-    // void loadlist()
-    // {
-    //
-    // }
-
-//	public class UploadThread extends Thread
-//	{
-//		@Override
-//		public void run()
-//		{
-//
-//			Log.d("", "upload thread running");
-//
-//			super.run();
-//			doupload();
-//			Log.d("", "upload thread stop");
-//
-//		}
-//
-//		private void doupload()
-//		{
-//			boolean error = false;
-//			boolean didupload = false;
-//			// int verifyresult = Network.VerifyUser(RedAntApplication.user,
-//			// RedAntApplication.password);
-//			// if (verifyresult == Network.RESULT_TRUE)
-//			// {
-//			SQLiteDatabase dbr = dbUtil.OpenDB(UploadService.this, null, false);
-//			Cursor cursor = dbr.query("pics", new String[] { "_id", "pid",
-//					"local_path", "picker", "server" }, "err_code!="
-//					+ Network.AP_UPLOAD_SUCCESS+" and err_code!="+ Network.RESULT_LOCALFILE_ERROR+" and try_count<3 ", null, null, null, "_id", null);
-//			while (cursor.moveToNext())
-//			{
-//				didupload = true;
-//				if (queue_changed)
-//				{
-//					queue_changed = false;
-//					dbUtil.CloseCursor(cursor);
-//					cursor = dbr.query("pics", new String[] { "_id", "pid",
-//							"local_path", "picker", "server" }, "err_code!="
-//							+ Network.AP_UPLOAD_SUCCESS+" and err_code!="+ Network.RESULT_LOCALFILE_ERROR +" and try_count<3 ", null, null, null,
-//							"_id", null);
-//					if (!cursor.moveToNext())
-//						break;
-//
-//				}
-//				int _id = cursor.getInt(0);
-//				String pid = cursor.getString(1);
-//				String path = cursor.getString(2);
-//				String picker = cursor.getString(3);
-//				String server = cursor.getString(4);
-//
-//				String encryptUser = "";
-//
-//				try
-//				{
-//					encryptUser = AES.encrypt("apexu", picker);
-//
-//				}
-//				catch (Exception e1)
-//				{
-//					// TODO Auto-generated catch block
-//					e1.printStackTrace();
-//				}
-//
-//				Cursor cursor_user = dbr.query("users",
-//						new String[] { "pass" }, "name='" + encryptUser + "'",
-//						null, null, null, "_id", null);
-//				String pass = "";
-//				if (cursor_user.moveToNext())
-//					pass = cursor_user.getString(0);
-//				try
-//				{
-//					pass = AES.decrypt("apexp", pass);
-//				}
-//				catch (Exception e)
-//				{
-//					// TODO Auto-generated catch block
-//					e.printStackTrace();
-//				}
-//
-//				int uploadresult = Network.UploadImage(path, picker, pass, pid,
-//						server);
-//				if (uploadresult == Network.RESULT_TRUE)
-//				{
-//
-//					RedAntApplication.writeLock.lock();
-//
-//					// write sql process
-//					SQLiteDatabase dbw = dbUtil.OpenDB(UploadService.this,
-//							null, true);
-//					// String sql = "update pics set err_code ="
-//					// + Network.AP_UPLOAD_SUCCESS + " where _id="
-//					// + _id;
-//					String sql = "delete from pics  where _id=" + _id;
-//					dbw.execSQL(sql);
-//
-//					String timeStamp = new SimpleDateFormat("yyyy_MM_dd")
-//							.format(new Date());
-//
-//					File storageDir = new File(Environment
-//							.getExternalStorageDirectory().getPath()
-//							+ "/redant/pop/done/" + timeStamp);
-//
-//					if (!storageDir.exists())
-//						storageDir.mkdirs();
-//
-//					File pic = new File(path);
-//					// pic.delete();
-//
-//					dbUtil.CloseDB(dbw);
-//					RedAntApplication.writeLock.unlock();
-//					dbgUtil.fileLog("upload success move file "
-//							+ pic.getName()
-//							+ " to "
-//							+ Environment.getExternalStorageDirectory()
-//									.getPath() + "/redant/pop/done/"
-//							+ timeStamp + File.separator);
-//					pic.renameTo(new File(Environment
-//							.getExternalStorageDirectory().getPath()
-//							+ "/redant/pop/done/"
-//							+ timeStamp
-//							+ File.separator
-//							+ pic.getName()));
-//
-//
-//				}
-//				else
-//				{
-//					error = true;
-//					RedAntApplication.writeLock.lock();
-//
-//					{
-//						// write sql process
-//						SQLiteDatabase dbw = dbUtil.OpenDB(UploadService.this,
-//								null, true);
-//						String sql = "update pics set err_code ="
-//								+ uploadresult + ", try_count = try_count+1 where _id=" + _id;
-//
-//						dbw.execSQL(sql);
-//						dbUtil.CloseDB(dbw);
-//					}
-//					RedAntApplication.writeLock.unlock();
-//					dbgUtil.fileLog("upload failed pid:" + pid + " file:"
-//							+ path + " server:" + server + " err_code:"
-//							+ uploadresult);
-//
-//				}
-//
-//				sendBroadcast(new Intent("REDANT.POP.UPDATE_QUEUE_VIEW"));
-//			}
-//
-//			dbUtil.CloseCursor(cursor);
-//			dbUtil.CloseDB(dbr);
-//
-//			// }
-//			// else
-//			// {
-//			// Log.d("upload thread", "user check failed!");
-//			//
-//			// sendBroadcast(new Intent("REDANT.POP.USER_CHECK_FAILED"));
-//			// }
-//
-//			if (queue_changed)
-//			{
-//				queue_changed = false;
-//				doupload();
-//			}
-//			if (didupload)
-//			{
-//				if (error)
-//				{
-//					sendBroadcast(new Intent(
-//							"REDANT.POP.FINISH_UPLOAD_QUEUE_WITH_ERROR"));
-//					RedAntApplication.startalarm();
-//				}
-//				else
-//				{
-//					sendBroadcast(new Intent("REDANT.POP.FINISH_UPLOAD_QUEUE"));
-//					RedAntApplication.cancelalarm();
-//				}
-//			}
-//		}
-//	}
-
-    private BroadcastReceiver uploadReceiver = new BroadcastReceiver() {
-
-        public void onReceive(Context context, Intent intent) {
-            String action = intent
-                    .getAction();
-            // 如果捕捉到的action是ACTION_BATTERY_CHANGED
-
-            if ("REDANT.RAImage.ADD_TASK".equals(action)) {
-
-                ArrayList<Bundle> tasks = intent.getParcelableArrayListExtra("tasks");
-
-
-                uploadManager.addTasks(tasks);
-            } else if ("REDANT.RAImage.SAVE_TASK".equals(action)) {
-                uploadManager.stopAllTasks();
-            } else if (intent
-                    .getAction()
-                    .equals(ConnectivityManager.CONNECTIVITY_ACTION)) {
-
-                ConnectivityManager connManager = (ConnectivityManager) context
-                        .getSystemService(Context.CONNECTIVITY_SERVICE);
-
-                NetworkInfo networkInfo = connManager.getActiveNetworkInfo();
-                if (networkInfo == null) {
-                    dbgUtil.Logd(
-                            "Current Network info",
-                            "can not get Active NetworkInfo!");
-                    return;
-                }
-                NetworkInfo.State netState = networkInfo
-                        .getState();
-                if (netState != NetworkInfo.State.CONNECTED) {
-                    dbgUtil.Logd(
-                            "Current Network info",
-                            "not Connected!State="
-                                    + netState);
-                    return;
-                } else {
-                    int iconntype = -1;
-                    iconntype = networkInfo
-                            .getType();
-                    SharedPreferences pref = getApplication()
-                            .getSharedPreferences(
-                                    "UploadManager",
-                                    0);
-
-
-                    boolean
-                            wifi_only
-                            = pref.getBoolean("wifi_only",
-                            false);
-
-                    if
-                            (wifi_only
-                            == true
-                            && iconntype !=
-                            ConnectivityManager.TYPE_WIFI
-                            && iconntype !=
-                            9/* earthnet */) {
-                        uploadManager.stopAllTasks();
-//															 dbgUtil.Log(Log.DEBUG,
-//															 "Current Network info",
-//															 "not allowed!Connection type="
-//															 +
-//															 networkInfo.getTypeName());
-                        return;
-                    }
-                }
-
-
-            }
-        }
-    };
-}

+ 0 - 327
ApexDrivers/RAUtilsLibrary/src/main/java/com/usai/redant/rautils/Utils/AESUtil.java

@@ -1,327 +0,0 @@
-package com.usai.redant.rautils.utils;
-
-import android.util.Base64;
-import android.util.Log;
-
-import org.bouncycastle.jce.provider.BouncyCastleProvider;
-
-import java.io.UnsupportedEncodingException;
-import java.security.InvalidAlgorithmParameterException;
-import java.security.InvalidKeyException;
-import java.security.Key;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.security.Security;
-import java.util.Arrays;
-
-import javax.crypto.BadPaddingException;
-import javax.crypto.Cipher;
-import javax.crypto.IllegalBlockSizeException;
-import javax.crypto.NoSuchPaddingException;
-import javax.crypto.spec.IvParameterSpec;
-import javax.crypto.spec.SecretKeySpec;
-
-import static android.content.ContentValues.TAG;
-
-public class AESUtil {
-
-    // 算法名称
-    final static String KEY_ALGORITHM = "AES";
-    // 加解密算法/模式/填充方式
-    final static String algorithmStr = "AES/CBC/PKCS7Padding";
-    //
-//    private Key key;
-//    private Cipher cipher;
-//    boolean isInited = false;
-
-    static byte[] iv = new byte[16];//{ 0x30, 0x31, 0x30, 0x32, 0x30, 0x33, 0x30, 0x34, 0x30, 0x35, 0x30, 0x36, 0x30, 0x37, 0x30, 0x38 };
-//    private static void init(byte[] keyBytes) {
-//
-//        // 如果密钥不足16位,那么就补足.  这个if 中的内容很重要
-//        int base = 16;
-//        if (keyBytes.length % base != 0) {
-//            int groups = keyBytes.length / base + (keyBytes.length % base != 0 ? 1 : 0);
-//            byte[] temp = new byte[groups * base];
-//            Arrays.fill(temp, (byte) 0);
-//            System.arraycopy(keyBytes, 0, temp, 0, keyBytes.length);
-//            keyBytes = temp;
-//        }
-//        // 初始化
-//        Security.addProvider(new BouncyCastleProvider());
-//        // 转化成JAVA的密钥格式
-//        key = new SecretKeySpec(keyBytes, KEY_ALGORITHM);
-//        try {
-//            // 初始化cipher
-//            cipher = Cipher.getInstance(algorithmStr, "BC");
-//        } catch (NoSuchAlgorithmException e) {
-//            // TODO Auto-generated catch block
-//            e.printStackTrace();
-//        } catch (NoSuchPaddingException e) {
-//            // TODO Auto-generated catch block
-//            e.printStackTrace();
-//        } catch (NoSuchProviderException e) {
-//            // TODO Auto-generated catch block
-//            e.printStackTrace();
-//        }
-//    }
-
-    private static String toHex(byte[] buf)
-    {
-        if (buf == null)
-            return "";
-        StringBuffer result = new StringBuffer(2 * buf.length);
-        for (int i = 0; i < buf.length; i++)
-        {
-            appendHex(result, buf[i]);
-        }
-        return result.toString();
-    }
-    private static void appendHex(StringBuffer sb, byte b)
-    {
-        sb.append(HEX.charAt((b >> 4) & 0x0f)).append(HEX.charAt(b & 0x0f));
-    }
-    private final static String HEX = "0123456789ABCDEF";
-
-    public static String encrypt128(String keystring,String content)
-    {
-
-        try {
-
-            Key key= null;
-            key = createKey128(keystring);
-            byte[] result=encrypt(content.getBytes(),key);
-            Log.d(TAG, "encrypt: "+toHex(result));
-            return Base64.encodeToString(result,Base64.DEFAULT);
-        } catch (UnsupportedEncodingException e) {
-            e.printStackTrace();
-        } catch (NoSuchAlgorithmException e) {
-            e.printStackTrace();
-        }
-        return null;
-
-    }
-
-    public static String decrypt128(String keystring,String content)
-    {
-
-
-
-        try {
-
-            byte[] buffer =Base64.decode(content, Base64.DEFAULT);
-
-
-            Key key= null;
-            key = createKey128(keystring);
-
-            byte[] result = decrypt(buffer,key);
-
-            return new String(result);
-        } catch (UnsupportedEncodingException e) {
-            e.printStackTrace();
-        } catch (NoSuchAlgorithmException e) {
-            e.printStackTrace();
-        }
-        return null;
-    }
-    public static String encrypt256(String keystring,String content)
-    {
-
-        try {
-
-            Key key= null;
-            key = createKey256(keystring);
-            byte[] result=encrypt(content.getBytes(),key);
-            Log.d(TAG, "encrypt: "+toHex(result));
-            return Base64.encodeToString(result,Base64.DEFAULT);
-        } catch (UnsupportedEncodingException e) {
-            e.printStackTrace();
-        } catch (NoSuchAlgorithmException e) {
-            e.printStackTrace();
-        }
-        return null;
-
-    }
-
-    public static String decrypt256(String keystring,String content)
-    {
-
-
-
-        try {
-
-            byte[] buffer =Base64.decode(content, Base64.DEFAULT);
-
-
-            Key key= null;
-            key = createKey256(keystring);
-
-            byte[] result = decrypt(buffer,key);
-
-            return new String(result);
-        } catch (UnsupportedEncodingException e) {
-            e.printStackTrace();
-        } catch (NoSuchAlgorithmException e) {
-            e.printStackTrace();
-        }
-        return null;
-    }
-    /**
-     * 加密方法
-     *
-     * @param content
-     *            要加密的字符串
-     * @param key
-     *            加密密钥
-     * @return
-     */
-    private static byte[] encrypt(byte[] content,  Key key) {
-        byte[] encryptedText = null;
-//        init(keyBytes);
-
-
-        Cipher cipher;
-
-
-
-        // 初始化
-        Security.addProvider(new BouncyCastleProvider());
-        try {
-            // 初始化cipher
-            cipher = Cipher.getInstance(algorithmStr, "BC");
-
-
-            cipher.init(Cipher.ENCRYPT_MODE, key, new IvParameterSpec(iv));
-            encryptedText = cipher.doFinal(content);
-
-        } catch (NoSuchAlgorithmException e) {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
-        } catch (NoSuchPaddingException e) {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
-        } catch (NoSuchProviderException e) {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
-        } catch (BadPaddingException e) {
-            e.printStackTrace();
-        } catch (InvalidKeyException e) {
-            e.printStackTrace();
-        } catch (IllegalBlockSizeException e) {
-            e.printStackTrace();
-        } catch (InvalidAlgorithmParameterException e) {
-            e.printStackTrace();
-        }
-
-
-//        System.out.println("IV:" + new String(iv));
-//        try {
-//
-//        } catch (Exception e) {
-//            // TODO Auto-generated catch block
-//            e.printStackTrace();
-//        }
-        return encryptedText;
-    }
-    /**
-     * 解密方法
-     *
-     * @param encryptedData
-     *            要解密的字符串
-     * @param key
-     *            解密密钥
-     * @return
-     */
-    private static byte[] decrypt(byte[] encryptedData, Key key) {
-        byte[] encryptedText = null;
-//        init(keyBytes);
-
-//        Key key;
-        Cipher cipher;
-        // 如果密钥不足16位,那么就补足.  这个if 中的内容很重要
-        int base = 16;
-//        if (keyBytes.length % base != 0) {
-//            int groups = keyBytes.length / base + (keyBytes.length % base != 0 ? 1 : 0);
-//            byte[] temp = new byte[groups * base];
-//            Arrays.fill(temp, (byte) 0);
-//            System.arraycopy(keyBytes, 0, temp, 0, keyBytes.length);
-//            keyBytes = temp;
-//        }
-        // 初始化
-        Security.addProvider(new BouncyCastleProvider());
-        // 转化成JAVA的密钥格式
-//        key = new SecretKeySpec(keyBytes, KEY_ALGORITHM);
-        try {
-            // 初始化cipher
-            cipher = Cipher.getInstance(algorithmStr, "BC");
-            cipher.init(Cipher.DECRYPT_MODE, key, new IvParameterSpec(iv));
-            encryptedText = cipher.doFinal(encryptedData);
-        } catch (NoSuchAlgorithmException e) {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
-        } catch (NoSuchPaddingException e) {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
-        } catch (NoSuchProviderException e) {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
-        } catch (BadPaddingException e) {
-            e.printStackTrace();
-        } catch (InvalidKeyException e) {
-            e.printStackTrace();
-        } catch (IllegalBlockSizeException e) {
-            e.printStackTrace();
-        } catch (InvalidAlgorithmParameterException e) {
-            e.printStackTrace();
-        }
-
-//        System.out.println("IV:" + new String(iv));
-//        try {
-//
-//        } catch (Exception e) {
-//            // TODO Auto-generated catch block
-//            e.printStackTrace();
-//        }
-
-        return encryptedText;
-    }
-
-
-    private static Key createKey128(String keystring) throws UnsupportedEncodingException, NoSuchAlgorithmException {
-
-
-        byte[] keyBytes=keystring.getBytes();
-        Key key;
-        // 如果密钥不足16位,那么就补足.  这个if 中的内容很重要
-        int base = 16;
-        if (keyBytes.length % base != 0) {
-            int groups = keyBytes.length / base + (keyBytes.length % base != 0 ? 1 : 0);
-            byte[] temp = new byte[groups * base];
-            Arrays.fill(temp, (byte) 0);
-            System.arraycopy(keyBytes, 0, temp, 0, keyBytes.length);
-            keyBytes = temp;
-        }
-
-        // 转化成JAVA的密钥格式
-        key = new SecretKeySpec(keyBytes, KEY_ALGORITHM);
-        return key;
-    }
-
-
-    private static Key createKey256(String key) throws UnsupportedEncodingException, NoSuchAlgorithmException {
-        MessageDigest digest = MessageDigest.getInstance("SHA-256");
-        byte[] keyBytes = digest.digest(key.getBytes("UTF-8"));
-
-        int base = 16;
-        if (keyBytes.length % base != 0) {
-            Log.d(TAG, "createKey256: "+"key is too short, expanded");
-            int groups = keyBytes.length / base + (keyBytes.length % base != 0 ? 1 : 0);
-            byte[] temp = new byte[groups * base];
-            Arrays.fill(temp, (byte) 0);
-            System.arraycopy(keyBytes, 0, temp, 0, keyBytes.length);
-            keyBytes = temp;
-        }
-        return new SecretKeySpec(keyBytes, KEY_ALGORITHM);
-    }
-}

+ 0 - 114
ApexDrivers/RAUtilsLibrary/src/main/java/com/usai/redant/rautils/Utils/CrashHandler.java

@@ -1,114 +0,0 @@
-package com.usai.redant.rautils.utils;
-
-import android.content.Context;
-import android.content.pm.PackageInfo;
-import android.content.pm.PackageManager;
-import android.os.Build;
-
-import java.io.IOException;
-import java.io.LineNumberReader;
-import java.io.PrintWriter;
-import java.io.StringReader;
-import java.io.StringWriter;
-
-
-public class CrashHandler implements Thread.UncaughtExceptionHandler{
-
-    public interface InfoPreserver {
-        public void saveUserInformation();
-        public void handleCrashInfo(String deviceInfo, String exception);
-    }
-    // 当前应用上下文
-    private Context ctx;
-
-    // 系统默认UncaughtException处理类
-    private Thread.UncaughtExceptionHandler mDefaultHandler;
-
-    private static CrashHandler sharedInstance;
-    public InfoPreserver preserver;
-
-    private CrashHandler() {
-
-    }
-
-    public static synchronized CrashHandler getSharedInstance() {
-        if (sharedInstance == null) {
-            sharedInstance = new CrashHandler();
-        }
-        return sharedInstance;
-    }
-
-    public void init(Context ctx) {
-        this.ctx = ctx;
-        mDefaultHandler = Thread.getDefaultUncaughtExceptionHandler();
-        Thread.setDefaultUncaughtExceptionHandler(this);
-    }
-
-
-    @Override
-    public void uncaughtException(Thread t, Throwable e) {
-        // 如果不能处理异常,并且系统处理器不为空,则交给系统处理
-        if (!handleException(e) && mDefaultHandler != null) {
-            mDefaultHandler.uncaughtException(t,e);
-        } else {
-            android.os.Process.killProcess(android.os.Process.myPid());
-            System.exit(1);
-        }
-    }
-
-    private boolean handleException(Throwable e) {
-
-        if (e == null) {
-            return false;
-        }
-
-        if (preserver != null) {
-            preserver.saveUserInformation();
-            preserver.handleCrashInfo(getDeviceInfo(),getThrowableStackString(e));
-        }
-
-
-        return true;
-    }
-
-    private String getDeviceInfo() {
-        try {
-            PackageManager pm = ctx.getPackageManager();
-            PackageInfo pi = pm.getPackageInfo(ctx.getPackageName(), PackageManager.GET_ACTIVITIES);
-            String appVer = "App Version: " + pi.versionName + "_" + pi.versionCode + "\n";
-            String osVer = "OS Version: " + Build.VERSION.RELEASE + "_" + Build.VERSION.SDK_INT + "\n";
-            String manufacture = "Manufacturer: " + Build.MANUFACTURER + "\n";
-            String model = "Model: " + Build.MODEL;
-            return appVer + osVer + manufacture + model;
-        } catch (PackageManager.NameNotFoundException e) {
-            e.printStackTrace();
-            return null;
-        }
-
-    }
-
-    private String getThrowableStackString(Throwable throwable) {
-        if (throwable == null) {
-            return null;
-        }
-        StringWriter sw = new StringWriter();
-        PrintWriter pw = new PrintWriter(sw);
-        throwable.printStackTrace(pw);
-        pw.flush();
-        LineNumberReader reader = new LineNumberReader(new StringReader(sw.toString()));
-        StringBuffer lines = new StringBuffer();
-        try {
-            String line = reader.readLine();
-            while (line != null) {
-                lines.append(line + "\n");
-                line = reader.readLine();
-            }
-        } catch (IOException ex) {
-            lines.append(ex.toString() + "\n");
-        }
-
-        return lines.toString();
-    }
-
-
-}

+ 0 - 66
ApexDrivers/RAUtilsLibrary/src/main/java/com/usai/redant/rautils/Utils/DBHelper.java

@@ -1,66 +0,0 @@
-package com.usai.redant.rautils.utils;
-
-import android.content.Context;
-import android.database.DatabaseErrorHandler;
-import android.database.sqlite.SQLiteDatabase;
-import android.database.sqlite.SQLiteOpenHelper;
-
-import java.util.ArrayList;
-
-public class DBHelper extends SQLiteOpenHelper {
-
-    public interface DBHelperListener {
-
-        ArrayList<String> prepareInitialForDBCreate();
-        ArrayList<String> prepareUpgrade(int oldVersion, int newVersion);
-
-    }
-
-    private DBHelperListener mListener;
-
-    public DBHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
-        super(context, name, factory, version);
-    }
-
-    public DBHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version, DatabaseErrorHandler errorHandler) {
-        super(context, name, factory, version, errorHandler);
-    }
-
-    public void setListener(DBHelperListener listener) {
-        mListener = listener;
-    }
-
-    @Override
-    public void onCreate(SQLiteDatabase db) {
-
-        if (mListener != null) {
-            ArrayList<String> tableArr = mListener.prepareInitialForDBCreate();
-            for (int i = 0; i < tableArr.size(); i++) {
-                String sql = tableArr.get(i);
-                db.execSQL(sql);
-            }
-        }
-
-    }
-
-    @Override
-    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
-
-        if (mListener != null) {
-            ArrayList<String> tableArr = mListener.prepareUpgrade(oldVersion, newVersion);
-            for (int i = 0; i < tableArr.size(); i++) {
-                String sql = tableArr.get(i);
-                db.execSQL(sql);
-            }
-        }
-
-    }
-
-    public SQLiteDatabase openDataBase(boolean writable) {
-        if (writable) {
-            return getWritableDatabase();
-        } else  {
-            return getReadableDatabase();
-        }
-    }
-}

+ 0 - 110
ApexDrivers/RAUtilsLibrary/src/main/java/com/usai/redant/rautils/Utils/DBUtil.java

@@ -1,110 +0,0 @@
-package com.usai.redant.rautils.utils;
-
-import android.content.ContentValues;
-import android.content.Context;
-import android.database.Cursor;
-import android.database.sqlite.SQLiteDatabase;
-
-import java.util.ArrayList;
-
-public class DBUtil implements DBHelper.DBHelperListener{
-
-    private static DBUtil dbUtil;
-    private SQLiteDatabase db;
-
-    public interface DBInitialBlock {
-        ArrayList<String> prepareDatabaseInitial();
-    }
-
-    public interface DBUpgradeBlock {
-        ArrayList<String> prepareDatabaseUpgrade();
-    }
-
-    private DBInitialBlock mInitialBlock;
-    @Override
-    public ArrayList<String> prepareInitialForDBCreate() {
-        if (mInitialBlock != null) {
-            return mInitialBlock.prepareDatabaseInitial();
-        }
-        return null;
-    }
-
-    private DBUpgradeBlock mUpgradeBlock;
-    @Override
-    public ArrayList<String> prepareUpgrade(int oldVersion, int newVersion) {
-        if (mUpgradeBlock != null) {
-            return mUpgradeBlock.prepareDatabaseUpgrade();
-        }
-        return null;
-    }
-
-
-    public static DBUtil sharedDBUtil() {
-        synchronized (DBUtil.class) {
-            if (dbUtil == null) {
-                dbUtil = new DBUtil();
-            }
-        }
-        return dbUtil;
-    }
-
-    public void openDatabase(Context ctx, String path, int version, boolean wirtable,DBInitialBlock initialBlk, DBUpgradeBlock upgradeBlk) {
-
-        DBHelper openHandler = new DBHelper(ctx,path,null,version);
-
-        mInitialBlock = initialBlk;
-        mUpgradeBlock = upgradeBlk;
-
-        openHandler.setListener(this);
-
-        db = openHandler.openDataBase(wirtable);
-    }
-
-    public void insert(String table,ContentValues values) {
-        db.insert(table,null,values);
-    }
-
-    public void execute(ArrayList<String> sqlArr) {
-        try {
-            db.beginTransaction(); // 开启事务
-            for (int i = 0; i < sqlArr.size(); i++) {
-                String sql = sqlArr.get(i);
-                db.execSQL(sql);
-            }
-            db.setTransactionSuccessful(); // 设置事务完成
-        } finally {
-            db.endTransaction(); // 结束事务
-        }
-    }
-
-    public void execSQL(String sql) {
-
-        db.execSQL(sql);
-    }
-
-    public Cursor query(String sql,String[] args) {
-        Cursor cur = db.rawQuery(sql,args);
-        cur.moveToFirst();
-        return cur;
-    }
-
-    public void closeDatabase() {
-        if (db == null) {
-            return;
-        }
-        if (db.isOpen() == false)
-            return;
-        db.close();
-    }
-
-    public void closeCursor(Cursor cursor) {
-
-        if (cursor == null)
-            return;
-        if (cursor.isClosed())
-            return;
-        cursor.close();
-    }
-
-
-}

+ 0 - 277
ApexDrivers/RAUtilsLibrary/src/main/java/com/usai/redant/rautils/Utils/FileManager.java

@@ -1,277 +0,0 @@
-package com.usai.redant.rautils.utils;
-
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.PackageManager;
-import android.net.Uri;
-import android.os.Build;
-import android.os.Environment;
-import android.support.v4.content.FileProvider;
-import android.util.Log;
-import android.webkit.MimeTypeMap;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
-import java.security.MessageDigest;
-
-public class FileManager {
-
-    private static final char HEX_DIGITS[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
-    public static String toHexString(byte[] b) {
-        StringBuilder sb = new StringBuilder(b.length * 2);
-        for (int i = 0; i < b.length; i++) {
-            sb.append(HEX_DIGITS[(b[i] & 0xf0) >>> 4]);
-            sb.append(HEX_DIGITS[b[i] & 0x0f]);
-        }
-        return sb.toString();
-    }
-
-    public static String md5sum(String filename) {
-        InputStream fis;
-        byte[] buffer = new byte[1024];
-        int numRead = 0;
-        MessageDigest md5;
-        try{
-            fis = new FileInputStream(filename);
-            md5 = MessageDigest.getInstance("MD5");
-            while((numRead=fis.read(buffer)) > 0) {
-                md5.update(buffer,0,numRead);
-            }
-            fis.close();
-            return toHexString(md5.digest());
-        } catch (Exception e) {
-            System.out.println("error");
-            return null;
-        }
-    }
-
-
-    public static String SDCardRoot() {
-        return Environment.getExternalStorageDirectory()+ File.separator;
-    }
-
-    public static File createSDDir(String dir)throws IOException {
-        File dirFile=new File(SDCardRoot()+dir);
-        dirFile.mkdir();//mkdir()只能创建一层文件目录,mkdirs()可以创建多层文件目录
-        return dirFile;
-    }
-
-    //在SD卡上创建文件
-    public static File createFileInSDCard(String fileName,String dir) throws IOException {
-        File file=new File(SDCardRoot()+dir+File.separator+fileName);
-        file.createNewFile();
-        return file;
-    }
-
-    public static boolean isFileExist(String fileName,String dir){
-        File file=new File(SDCardRoot()+dir+File.separator+fileName);
-        return file.exists();
-    }
-
-    public static File createFileInDir(String fileName,String dir) throws IOException {
-        File file=new File(dir+File.separator+fileName);
-        file.createNewFile();
-        return file;
-    }
-
-    //将一个InoutStream里面的数据写入到SD卡中
-    public static File write2SDFromInput(String fileName,String dir,InputStream input){
-        File file=null;
-        OutputStream output=null;
-        try {
-//            //创建目录
-//            createSDDir(dir);
-            //创建文件
-            file=createFileInDir(fileName,dir);
-            //写数据流
-            output=new FileOutputStream(file);
-            byte buffer[]=new byte[4*1024];//每次存4K
-            int temp;
-            //写入数据
-            while((temp=input.read(buffer))!=-1){
-                output.write(buffer,0,temp);
-            }
-            output.flush();
-        } catch (Exception e) {
-            System.out.println("写数据异常:"+e);
-        }
-        finally{
-            try {
-                output.close();
-            } catch (Exception e2) {
-                System.out.println(e2);
-            }
-        }
-        return file;
-    }
-
-    public static String getMimeType(String filePath) {
-        String ext = MimeTypeMap.getFileExtensionFromUrl(filePath);
-        String mime = MimeTypeMap.getSingleton().getMimeTypeFromExtension(ext);
-        if (mime == null || mime.isEmpty()) {
-            mime = "text/plain";
-        }
-        return mime;
-    }
-
-    /**
-     * 复制单个文件
-     * @param oldPath String 原文件路径 如:c:/fqf.txt
-     * @param newPath String 复制后路径 如:f:/fqf.txt
-     * @return boolean
-     */
-    public static boolean copyFile(String oldPath, String newPath) {
-        try {
-            int bytesum = 0;
-            int byteread = 0;
-            File oldfile = new File(oldPath);
-            if (oldfile.exists()) { //文件存在时
-                InputStream inStream = new FileInputStream(oldPath); //读入原文件
-                FileOutputStream fs = new FileOutputStream(newPath);
-                byte[] buffer = new byte[4*1024];
-                int length;
-                while ( (byteread = inStream.read(buffer)) != -1) {
-                    bytesum += byteread; //字节数 文件大小
-                    System.out.println(bytesum);
-                    fs.write(buffer, 0, byteread);
-                }
-                inStream.close();
-            }
-        }
-        catch (Exception e) {
-            System.out.println("复制单个文件操作出错");
-            e.printStackTrace();
-            return false;
-
-        }
-        return true;
-
-    }
-
-    public static void openFile(Context context, File file) {
-
-        if (context == null || file == null || !file.exists()) {
-            return;
-        }
-
-        Uri uri = null;
-        String type = getMimeType(file.getPath());
-
-        // type "application/pdf"
-        Intent intent = new Intent(Intent.ACTION_VIEW);
-
-        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
-
-            // "com.usai.apex.fileprovider"即是在Manifest文件中配置的authorities
-            uri = FileProvider.getUriForFile(context, "com.usai.apex.fileprovider", file);
-            // 给目标应用一个临时授权
-            intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
-        } else {
-            uri = Uri.fromFile(file);
-        }
-
-        intent.setDataAndType(uri, type);
-
-        if (context.getPackageManager().resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY) != null) {
-            // someone knows how to handle this mime type with this scheme, don't download.
-            try {
-                context.startActivity(intent);
-                return;
-            } catch (Exception ex) {
-                Log.d("Open File", "activity not found for " + type + " over " + uri, ex);
-            }
-
-        } else {
-            Log.d("Open File", "openFileAtPath: " + "No App " + uri);
-            try {
-                shareFile(context,uri,type);
-            } catch (Exception e) {
-                Log.e("Show Dialog Error", "openFileAtPath: ", e);
-            }
-        }
-
-    }
-
-    public static void shareFile(Context context,Uri uri, String type) {
-
-        Intent shareIntent = new Intent();
-        shareIntent.setAction(Intent.ACTION_SEND);
-        shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
-        shareIntent.setType(type);
-        context.startActivity(Intent.createChooser(shareIntent, "Share"));
-    }
-
-    public static void writeJson(String json, String filePath) {
-
-        Writer writer = null;
-        try {
-
-            OutputStream out = new FileOutputStream(new File(filePath));
-            writer = new OutputStreamWriter(out);
-            writer.write(json);
-
-        } catch (Exception e) {
-            e.printStackTrace();
-        } finally {
-            if (writer != null) {
-                try {
-                    writer.close();
-                } catch (Exception e) {
-                    e.printStackTrace();
-                }
-            }
-        }
-
-    }
-
-    public static String readJson(String filePath) {
-        BufferedReader reader = null;
-        StringBuilder jsonString = null;
-        try {
-            InputStream in = new FileInputStream(new File(filePath));
-            reader = new BufferedReader(new InputStreamReader(in));
-            jsonString = new StringBuilder();
-            String line = null;
-            while ((line = reader.readLine()) != null) {
-                jsonString.append(line);
-            }
-
-        } catch (Exception e) {
-            e.printStackTrace();
-        } finally {
-            if (reader != null) {
-                try {
-                    reader.close();
-                } catch (Exception e) {
-                    e.printStackTrace();
-                }
-            }
-        }
-        if (jsonString != null) {
-            return jsonString.toString();
-        } else {
-            return null;
-        }
-    }
-
-    public static String lastPathComponent(String path){
-
-        int start=path.lastIndexOf("/");
-        int end=path.lastIndexOf(".");
-        if(start!=-1 && end!=-1){
-            return path.substring(start+1,end);
-        }else{
-            return null;
-        }
-
-    }
-
-}

+ 0 - 275
ApexDrivers/RAUtilsLibrary/src/main/java/com/usai/redant/rautils/Utils/ImageUtil.java

@@ -1,275 +0,0 @@
-package com.usai.redant.rautils.utils;
-
-import android.content.Context;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.graphics.Matrix;
-import android.media.ExifInterface;
-import android.media.MediaScannerConnection;
-import android.net.Uri;
-import android.os.Build;
-import android.support.v4.content.FileProvider;
-import android.util.Log;
-
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.net.URI;
-
-public class ImageUtil {
-
-    public static File routeBitmap(Context context, File sourceFile, String file_name)
-    {
-        /**
-         * 获取图片的旋转角度,有些系统把拍照的图片旋转了,有的没有旋转
-         */
-        int degree = readPictureDegree(sourceFile.getAbsolutePath());
-
-        BitmapFactory.Options opts=new BitmapFactory.Options();//获取缩略图显示到屏幕上
-        opts.inSampleSize=1;
-        Bitmap cbitmap=BitmapFactory.decodeFile(sourceFile.getAbsolutePath(),opts);
-
-        /**
-         * 把图片旋转为正的方向
-         */
-        Bitmap newbitmap = rotaingImageView(degree, cbitmap);
-
-        //sourceFile.get
-        String routedPath = "";
-        if(file_name==null) {
-            String path = sourceFile.getPath();
-
-            routedPath=path.replace(".jpg", "_routed.jpg");
-        }
-        else
-        {
-            String path = sourceFile.getParent();
-            routedPath = path+"/"+file_name;
-        }
-        File routedFile = new File(routedPath);
-        try {
-
-            FileOutputStream outputStream = new FileOutputStream(routedFile);
-            newbitmap.compress(Bitmap.CompressFormat.JPEG, 100, outputStream);
-
-            outputStream.flush();
-            outputStream.close();
-
-            String filepath = sourceFile.getAbsolutePath();
-            sourceFile.delete();
-            updateGallery(context,filepath);
-
-            return routedFile;
-
-        } catch (IOException e) {
-            e.printStackTrace();
-            return null;
-        }
-
-    }
-    /**
-     * 读取图片属性:旋转的角度
-     * @param path 图片绝对路径
-     * @return degree旋转的角度
-     */
-    public static int readPictureDegree(String path) {
-        int degree  = 0;
-        try {
-            ExifInterface exifInterface = new ExifInterface(path);
-            int orientation = exifInterface.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
-            switch (orientation) {
-                case ExifInterface.ORIENTATION_ROTATE_90:
-                    degree = 90;
-                    break;
-                case ExifInterface.ORIENTATION_ROTATE_180:
-                    degree = 180;
-                    break;
-                case ExifInterface.ORIENTATION_ROTATE_270:
-                    degree = 270;
-                    break;
-            }
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
-        return degree;
-    }
-    /*
-     * 旋转图片
-     * @param angle
-     * @param bitmap
-     * @return Bitmap
-     */
-    public static Bitmap rotaingImageView(int angle , Bitmap bitmap) {
-        //旋转图片 动作
-        Matrix matrix = new Matrix();;
-        matrix.postRotate(angle);
-        System.out.println("angle2=" + angle);
-        // 创建新的图片
-        Bitmap resizedBitmap = Bitmap.createBitmap(bitmap, 0, 0,
-                bitmap.getWidth(), bitmap.getHeight(), matrix, true);
-        return resizedBitmap;
-    }
-
-    /**
-     * @param context ApplicationContext
-     * */
-    public static void updateGallery(Context context, String filename)//filename是我们的文件全名,包括后缀哦
-    {
-        if (context == null) {
-            return;
-        }
-
-//        Context context = getApplication().getApplicationContext();
-        MediaScannerConnection.scanFile(context, new String[] { filename }, null, new MediaScannerConnection.OnScanCompletedListener() {
-                    public void onScanCompleted(String path, Uri uri) {
-                        Log.i("ExternalStorage", "Scanned " + path + ":");
-                        Log.i("ExternalStorage", "-> uri=" + uri);
-                    }
-                });
-    }
-
-    public static Bitmap loadImageFromURL(Context context, URI uri) {
-        if (uri == null) {
-            return null;
-        }
-
-        String scheme = uri.getScheme();
-        if (scheme == null) {
-            File file = new File(uri);
-            return loadImageFromFile(context,file);
-        }
-
-        String md5 = RAUtil.stringToMD5(uri.toString());
-
-        Bitmap bitmap = null;
-        if (context == null) {
-            bitmap = Network.getImageFromLink(uri.toString());
-            return bitmap;
-        } else {
-
-            String appDir = appCacheDir(context);
-
-            String imgDir = appDir + File.separator + "ra_image";
-
-//            File dir = new File(imgDir);
-//            if (!dir.exists()) {
-//                dir.mkdirs();
-//            }
-
-
-            File imgFile = new File(imgDir,md5);
-            File parentFile = new File(imgDir);
-
-            if (!parentFile.exists()) {
-                parentFile.mkdirs();
-            }
-
-            if (imgFile.exists()) {
-
-                bitmap = loadImageFromFile(context,imgFile);
-            }
-
-            if (bitmap == null) {
-
-                bitmap = Network.getImageFromLink(uri.toString());
-                if (bitmap != null) {
-                    try {
-                        if (!imgFile.exists()) {
-                            imgFile.createNewFile();
-                        }
-                        savePhotoToFile(bitmap,imgFile);
-
-                    } catch (IOException e) {
-                        e.printStackTrace();
-                    }
-                }
-
-            }
-
-            return bitmap;
-        }
-    }
-
-    public static String appCacheDir(Context context) {
-        String root = FileManager.SDCardRoot();
-        String appName = RAUtil.getApplicationName(context);
-        return root + appName;
-    }
-
-    public static Bitmap loadImageFromFile(Context context, File file) {
-        if (file == null) {
-            return null;
-        }
-        if (!file.exists() || file.isDirectory()) {
-            return null;
-        }
-        final BitmapFactory.Options options = new BitmapFactory.Options();
-        options.inJustDecodeBounds = true;
-        BitmapFactory.decodeFile(file.getAbsolutePath(), options);
-
-        // Decode bitmap with inSampleSize set
-        options.inJustDecodeBounds = false;
-        //避免出现内存溢出的情况,进行相应的属性设置。
-        options.inPreferredConfig = Bitmap.Config.RGB_565;
-        options.inDither = true;
-
-//        //置入一个不设防的VmPolicy,否则7.0文件读取会失败
-//        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
-//            StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder();
-//            StrictMode.setVmPolicy(builder.build());
-//        }
-
-        try {
-
-            Uri uri = Uri.fromFile(file);
-
-            // 7.0 以后文件读取
-            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
-                uri = FileProvider.getUriForFile(context, "com.usai.apex.driver.fileprovider", file);
-            }
-
-            return BitmapFactory.decodeStream(context.getContentResolver().openInputStream(uri));
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
-        return null;
-
-//        return BitmapFactory.decodeFile(file.getAbsolutePath(), options);
-    }
-
-    public static void savePhotoToFile(Bitmap bitmap, File photoFile) {
-        if (photoFile == null || bitmap == null) {
-            return;
-        }
-        try {
-
-            BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(photoFile));
-            bitmap.compress(Bitmap.CompressFormat.PNG, 100, bos); // 使用JPG保存,若背景透明的PNG原图,读取出来后背景是黑色的
-            bos.flush();
-            bos.close();
-
-        } catch (IOException e) {
-            e.printStackTrace();
-
-        }
-    }
-
-    public static void saveJPGToFile(Bitmap bitmap, File photoFile) {
-        if (photoFile == null || bitmap == null) {
-            return;
-        }
-        try {
-
-            BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(photoFile));
-            bitmap.compress(Bitmap.CompressFormat.JPEG, 100, bos);
-            bos.flush();
-            bos.close();
-
-        } catch (IOException e) {
-            e.printStackTrace();
-
-        }
-    }
-
-}

+ 0 - 692
ApexDrivers/RAUtilsLibrary/src/main/java/com/usai/redant/rautils/Utils/Network.java

@@ -1,692 +0,0 @@
-package com.usai.redant.rautils.utils;
-
-import android.app.Application;
-import android.content.Context;
-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.util.Log;
-
-import org.json.JSONException;
-import org.json.JSONObject;
-
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.DataOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.UnsupportedEncodingException;
-import java.net.HttpURLConnection;
-import java.net.MalformedURLException;
-import java.net.ProtocolException;
-import java.net.URL;
-import java.net.URLEncoder;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.UUID;
-
-public class Network {
-
-    private static final int	REQUEST_TIMEOUT					= 15 * 1000;			// request
-
-    private static final int	SO_TIMEOUT						= 15 * 1000;			// so
-
-
-    private static final int	UPLOAD_TIMEOUT						= 30 * 1000;
-    public static int			AP_USER_AUTH					= 1;
-    public static int			AP_USER_NOT_AUTH				= 2;
-    public static int			AP_USER_NOT_EXIST				= 3;
-    public static int			AP_UPLOAD_SUCCESS				= 4;
-    public static int			AP_UPLOAD_FAIL					= 5;
-
-
-    public static final int		RESULT_FALSE					= 0;
-    public static final int		RESULT_TRUE						= 2;
-    public static final int		RESULT_NET_ERROR				= -3;
-    public static final int		RESULT_NET_NOTAVAILABLE			= -4;
-    public static final int		RESULT_ERROR					= -5;
-    public static final int		RESULT_LOCALFILE_ERROR			= -7;
-    public static final int		RESULT_USERAUTH_ERROR			= -9;
-    public static final int		RESULT_UPDATE_USERAUTH_ERROR	= -11;
-    public static final int		RESULT_SESSION_EXPIRED			= -13;
-    public static final int		RESULT_VER_LOW					= -15;
-
-    public static String getJson(String url, Bundle parms)
-    {
-        String TAG = "net_dbg@GetJson";
-        Log.d(TAG, "entry");
-        String ret=null;
-
-        HttpURLConnection connection = null;
-
-        try {
-
-
-            URL _url;
-            _url = new URL(url);
-            connection = (HttpURLConnection) _url.openConnection();
-            connection.setReadTimeout(SO_TIMEOUT);
-            connection.setConnectTimeout(SO_TIMEOUT);
-            // 设置请求方式
-            connection.setRequestMethod("POST");
-            // 设置编码格式
-            connection.setRequestProperty("Charset", "UTF-8");
-            // 传递自定义参数
-//			connection.setRequestProperty("MyProperty", "this is me!");
-
-            Set<String> keys = parms.keySet();
-            Log.d(TAG, "================parms============");
-            for (String key : keys)
-            {
-                if (key.contains("_file"))
-                {
-
-                }
-                else
-                {
-                    Log.d(TAG, "key=" + key + "    val=" + parms.get(key).toString());
-                }
-
-            }
-            Log.d(TAG, "================parms============");
-
-            Log.d(TAG,"URL: "+url);
-            // 设置容许输出
-            connection.setDoInput(true);
-            connection.setDoOutput(true);
-
-
-            OutputStream os = connection.getOutputStream();
-            BufferedWriter writer = new BufferedWriter(
-                    new OutputStreamWriter(os, "UTF-8"));
-            writer.write(createPostParameters(parms));
-
-            writer.flush();
-            writer.close();
-            os.close();
-
-            // 获取返回数据
-            if(connection.getResponseCode() == 200){
-                InputStream is = connection.getInputStream();
-
-                BufferedReader br = new BufferedReader(
-                        new InputStreamReader(is, "utf-8"), 8);
-                StringBuilder sb = new StringBuilder();
-                String line = null;
-                while ((line = br.readLine()) != null)
-                {
-                    sb.append(line + "\n");
-                }
-
-                Log.d(TAG, "Response: content begin");
-                Log.d(TAG, sb.toString());
-                Log.d(TAG, "Response: content end");
-
-                if (sb.length() <= 0)
-                {
-
-                    ret= null;
-                }
-                ret= sb.toString();
-
-            }
-
-        } catch (UnsupportedEncodingException e) {
-            e.printStackTrace();
-
-            Log.e(TAG, e.toString());
-
-        } catch (ProtocolException e) {
-            e.printStackTrace();
-
-            Log.e(TAG, e.toString());
-
-        } catch (MalformedURLException e) {
-            e.printStackTrace();
-
-            Log.e(TAG, e.toString());
-
-        } catch (IOException e) {
-            e.printStackTrace();
-
-            Log.e(TAG, e.toString());
-
-        } finally {
-
-            if(connection!=null){
-                connection.disconnect();
-            }
-        }
-        return ret;
-    }
-
-    private static String createPostParameters(Bundle parms) throws UnsupportedEncodingException {
-        StringBuilder result = new StringBuilder();
-        boolean first = true;
-        for(String key : parms.keySet()){
-            if (first)
-                first = false;
-            else
-                result.append("&");
-
-            result.append(URLEncoder.encode(key, "UTF-8"));
-            result.append("=");
-            result.append(URLEncoder.encode(parms.get(key).toString(), "UTF-8"));
-        }
-
-        return result.toString();
-    }
-
-    public static boolean isNetworkAvailable(Application application)// Context context)
-    {
-        String TAG = "net_dbg@CheckNetwork";
-        ConnectivityManager connManager = (ConnectivityManager) application.getSystemService(Context.CONNECTIVITY_SERVICE);
-
-        NetworkInfo networkInfo = connManager.getActiveNetworkInfo();
-        if (networkInfo == null)
-        {
-            Log.d(TAG, "can not get Active NetworkInfo!");
-            return false;
-        }
-        NetworkInfo.State netState = networkInfo.getState();
-        if (netState != NetworkInfo.State.CONNECTED)
-        {
-            Log.d(TAG, "not Connected!State=" + netState);
-            return false;
-        }
-
-        boolean bavailable = networkInfo.isAvailable();
-        String strtype = networkInfo.getTypeName();
-
-        Log.d(TAG, " type = " + strtype + " abailable = " + bavailable + " state " + netState);
-
-        return bavailable;
-    }
-
-    public interface FileUploadListener {
-
-        double percent_step();
-
-        boolean interupt();
-
-        void onProgress(long pro, double percentage);
-
-        void onFinish(int code, String res);
-    }
-
-    public static JSONObject uploadFileJSON(String path ,String host,Bundle params,FileUploadListener listener) {
-
-        String jstr = uploadFile(path,host, params,listener);
-
-        String TAG = "net_dbg@UploadFile";
-        if (jstr == null || jstr.length() <= 0)
-        {
-            Log.d(TAG, "json is null");
-            try {
-                return new JSONObject("{result:" + Network.RESULT_NET_ERROR+ "}");
-            } catch (JSONException e) {
-                e.printStackTrace();
-            }
-
-        }
-        Log.d(TAG, "json string:"+jstr);
-        JSONObject jsobj;
-        try
-        {
-            jsobj = new JSONObject(jstr);
-            if (jsobj.length() > 0)
-            {
-                return jsobj;
-            }
-            try {
-                return new JSONObject("{result:" + Network.RESULT_NET_ERROR+ "}");
-            } catch (JSONException e) {
-                e.printStackTrace();
-            }
-
-        }
-        catch (JSONException e)
-        {
-            // TODO Auto-generated catch block
-            Log.d(TAG, "json format wrong:"+jstr);
-            e.printStackTrace();
-
-            return null;
-        }
-        return null;
-    }
-
-    public static String uploadFile(String path ,String host,Bundle params,FileUploadListener listener){
-
-
-        File file = new File(path);
-        if(!file.exists())
-        {
-            String result="{\"result\":0,\"msg\":\"file does not exist\"}";
-            if (listener != null) {
-                listener.onFinish(200,result);
-            }
-
-            return result;
-        }
-        String TAG = "net_dbg@UploadFile";
-        String CHARSET = "utf-8"; //设置编码
-        String PREFIX = "--";
-        String LINE_END = "\r\n";
-        String BOUNDARY = UUID.randomUUID().toString(); //边界标识 随机生成 String PREFIX = "--" , LINE_END = "\r\n";
-        String CONTENT_TYPE = "multipart/form-data"; //内容类型
-
-        HttpURLConnection conn = null;
-        try {
-            URL url = new URL(host);
-            conn = (HttpURLConnection) url.openConnection();
-            conn.setReadTimeout(UPLOAD_TIMEOUT);
-            conn.setConnectTimeout(UPLOAD_TIMEOUT);
-            conn.setRequestMethod("POST"); //请求方式
-            conn.setRequestProperty("Charset", "utf-8");//设置编码
-            conn.setRequestProperty("connection", "keep-alive");
-            conn.setRequestProperty("Content-Type", CONTENT_TYPE + ";boundary=" + BOUNDARY);
-            conn.setDoInput(true); //允许输入流
-            conn.setDoOutput(true); //允许输出流
-            conn.setUseCaches(false); //不允许使用缓存
-            if(file!=null) {
-                /** * 当文件不为空,把文件包装并且上传 */
-                OutputStream outputSteam=conn.getOutputStream();
-                DataOutputStream dos = new DataOutputStream(outputSteam);
-                StringBuffer sb = new StringBuffer();
-                sb.append(LINE_END);
-                if(params!=null){//根据格式,开始拼接文本参数
-
-
-                    Set<String> keys = params.keySet();
-                    Log.d(TAG, "================parms============");
-                    for (String key : keys)
-                    {
-
-                        sb.append(PREFIX).append(BOUNDARY).append(LINE_END);//分界符
-                        sb.append("Content-Disposition: form-data; name=\"" + key + "\"" + LINE_END);
-                        sb.append("Content-Type: text/plain; charset=" + CHARSET + LINE_END);
-                        sb.append("Content-Transfer-Encoding: 8bit" + LINE_END);
-                        sb.append(LINE_END);
-                        sb.append(params.get(key).toString());
-                        sb.append(LINE_END);//换行!
-
-//					connection.setRequestProperty(key, parms.get(key).toString());
-                        Log.d(TAG, "key=" + key + "    val="
-                                + params.get(key).toString());
-
-//					reqEntity.addPart(key, new StringBody());
-
-                    }
-
-                    Log.d(TAG, "================parms============");
-
-                }
-                sb.append(PREFIX);//开始拼接文件参数
-                sb.append(BOUNDARY); sb.append(LINE_END);
-                /**
-                 * 这里重点注意:
-                 * name里面的值为服务器端需要key 只有这个key 才可以得到对应的文件
-                 * filename是文件的名字,包含后缀名的 比如:abc.png
-                 */
-                sb.append("Content-Disposition: form-data; name=\"upfile\"; filename=\""+file.getName()+"\""+LINE_END);
-                sb.append("Content-Type: application/octet-stream; charset="+CHARSET+LINE_END);
-                sb.append(LINE_END);
-                //写入文件数据
-                dos.write(sb.toString().getBytes());
-                InputStream is = new FileInputStream(file);
-                byte[] bytes = new byte[1024];
-                long totalbytes = file.length();
-                long curbytes = 0;
-                Log.i("cky","total="+totalbytes);
-                int len = 0;
-                double oldprogress=0.0;
-                while((len=is.read(bytes))!=-1){
-
-                    // 上传进度/ 上传过程中取消
-                    if (listener != null) {
-
-                        if(listener.interupt())
-                        {
-                            is.close();
-                            if(conn!=null)
-                                conn.disconnect();
-                            String result="{\"result\":"+0+",\"msg\":\"user cancel\"}";
-                            listener.onFinish(200,result);
-
-                            return result;
-                        }
-
-                    }
-
-
-                    curbytes += len;
-                    dos.write(bytes, 0, len);
-                    double newprogress =1.0d*curbytes/totalbytes;
-
-
-                    if (listener != null) {
-                        if(newprogress-oldprogress>=listener.percent_step()/100.0||newprogress>=1.0)
-                        {
-                            listener.onProgress(curbytes,newprogress);
-                            oldprogress = newprogress;
-                        }
-                        else
-                        {
-//						Log.d(TAG, "UploadFile: skiped "+newprogress);
-                        }
-                    }
-
-                }
-                is.close();
-                dos.write(LINE_END.getBytes());//一定还有换行
-                byte[] end_data = (PREFIX+BOUNDARY+PREFIX+LINE_END).getBytes();
-                dos.write(end_data);
-                dos.flush();
-                /**
-                 * 获取响应码 200=成功
-                 * 当响应成功,获取响应的流
-                 */
-                int code = conn.getResponseCode();
-                sb.setLength(0);
-                BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
-                String line;
-                while((line=br.readLine())!=null){
-
-                    // 获取返回
-                    if (listener != null) {
-
-                        if(listener.interupt())
-                        {
-
-                            if(conn!=null)
-                                conn.disconnect();
-//						br.close();
-                            String result="{\"result\":"+0+",\"msg\":\"user cancel\"}";
-                            listener.onFinish(200,result);
-                            return result;
-                        }
-                    }
-
-                    sb.append(line);
-                }
-                if(conn!=null)
-                    conn.disconnect();
-
-                if (listener != null) {
-                    listener.onFinish(code,sb.toString()/*,conn.getHeaderFields()*/);
-                }
-                return sb.toString();
-            }
-        } catch (MalformedURLException e) {
-            e.printStackTrace();
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
-        finally {
-            if(conn!=null){
-                conn.disconnect();
-            }
-        }
-
-        Log.e(TAG, "UploadFile: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" );
-        return null;
-    }
-
-    public static Bitmap getImageFromLink(String link) {
-        HttpURLConnection connection = null;
-        Bitmap img = null;
-        try {
-
-            URL url = new URL(link);
-            connection = (HttpURLConnection)url.openConnection();
-            connection.setRequestMethod("GET");
-            img = BitmapFactory.decodeStream(connection.getInputStream());
-
-        } catch (IOException e) {
-            e.printStackTrace();
-        } finally {
-            if (connection != null) {
-                connection.disconnect();
-            }
-        }
-        return img;
-    }
-
-    //读取响应头
-    public static JSONObject getResponseHeader(HttpURLConnection conn) {
-        Map<String, List<String>> responseHeaderMap = conn.getHeaderFields();
-        int size = responseHeaderMap.size();
-        try {
-            JSONObject responseHeader = new JSONObject();
-            for(int i = 0; i < size; i++){
-                String responseHeaderKey = conn.getHeaderFieldKey(i);
-                String responseHeaderValue = conn.getHeaderField(i);
-                if (responseHeaderKey != null && !responseHeaderKey.isEmpty() && responseHeaderValue != null) {
-                    responseHeader.put(responseHeaderKey,responseHeaderValue);
-                }
-            }
-            return responseHeader;
-        } catch (JSONException e) {
-            e.printStackTrace();
-            return null;
-        }
-    }
-
-    public static String getResponsesuggestedFilename(JSONObject response) {
-
-        if (response == null) {
-            return null;
-        }
-
-        try {
-            String key = "Content-Disposition";
-            String content_disposition = response.getString(key);
-            if (content_disposition != null) {
-                String[] components = content_disposition.split(";");
-                if (components[1] != null) {
-                    String fileName = components[1].split("=")[1];
-                    fileName = fileName.replace("\"","");
-                    return fileName;
-                }
-            }
-
-        } catch (JSONException e) {
-            e.printStackTrace();
-        }
-
-
-        return null;
-    }
-
-    public static File downloadFile(Bundle params, String download_url,String dir) {
-
-        if (params == null) {
-            params = new Bundle();
-        }
-
-        HttpURLConnection connection = null;
-
-        File returnFile = null;
-        try {
-
-            String fileName = UUID.randomUUID().toString();
-            if (dir == null) {
-                dir = Environment.getExternalStorageDirectory() + File.separator + "download";
-            }
-
-            if (FileManager.isFileExist(fileName,dir)) {
-                returnFile = new File(dir + File.separator + fileName);
-            } else {
-                // 创建一个URL对象
-                URL url=new URL(download_url);
-                // 创建一个HTTP链接
-                connection=(HttpURLConnection)url.openConnection();
-                connection.setRequestMethod("POST");
-
-                // 拼参数
-                if (params != null && params.keySet().size() > 0) {
-                    OutputStream os = connection.getOutputStream();
-                    BufferedWriter writer = new BufferedWriter(
-                            new OutputStreamWriter(os, "UTF-8"));
-                    writer.write(createPostParameters(params));
-
-                    writer.flush();
-                    writer.close();
-                    os.close();
-                }
-
-                // 获取响应
-                JSONObject responseHeader = getResponseHeader(connection);
-                String suggestedFileName = getResponsesuggestedFilename(responseHeader);
-                Log.d("Download", "download_query: " + suggestedFileName);
-                if (suggestedFileName != null && !suggestedFileName.isEmpty()) {
-                    fileName = suggestedFileName;
-                }
-
-                // 使用IO流获取数据
-                InputStream inputStream=connection.getInputStream();
-                // 写文件
-                File downloadFile = FileManager.write2SDFromInput(fileName,dir,inputStream);
-
-                if (downloadFile == null) {
-                    returnFile = null;
-                } else {
-                    returnFile = downloadFile;
-                }
-            }
-
-        } catch (IOException e) {
-            e.printStackTrace();
-        } finally {
-            if (connection != null) {
-                connection.disconnect();
-            }
-        }
-
-
-
-        return returnFile;
-    }
-    public static String check_push(Context c,Bundle params,String url)
-    {
-
-        if(true)
-            return null;
-
-        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;
-    }
-}

+ 0 - 386
ApexDrivers/RAUtilsLibrary/src/main/java/com/usai/redant/rautils/Utils/RAUtil.java

@@ -1,386 +0,0 @@
-package com.usai.redant.rautils.utils;
-
-import android.Manifest;
-import android.app.Activity;
-import android.app.Application;
-import android.content.Context;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.PackageManager;
-import android.os.Build;
-import android.os.Bundle;
-import android.provider.Settings;
-import android.support.v4.app.ActivityCompat;
-import android.support.v4.content.PermissionChecker;
-import android.telephony.TelephonyManager;
-import android.text.TextUtils;
-import android.util.Log;
-
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-
-import java.io.UnsupportedEncodingException;
-import java.lang.reflect.Array;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-import java.util.UUID;
-import java.util.concurrent.atomic.AtomicInteger;
-
-public class RAUtil {
-    public static void LibTest1() {
-        dbgUtil.Logd("RAUtilsLibrary", "LibTest1 aar update successful");
-    }
-
-    public static void LibTest() {
-        dbgUtil.Logd("RAUtilsLibrary", "LibTest aar update successful");
-    }
-
-    public static String getApplicationName(Context context) {
-
-        PackageManager packageManager = null;
-        ApplicationInfo applicationInfo = null;
-        try {
-            packageManager = context.getPackageManager();
-            applicationInfo = packageManager.getApplicationInfo(context.getPackageName(), 0);
-        } catch (PackageManager.NameNotFoundException e) {
-            applicationInfo = null;
-        }
-        String applicationName = (String) packageManager.getApplicationLabel(applicationInfo);
-        return applicationName;
-    }
-
-    public static boolean isNumeric(String str) {
-        for (int i = 0; i < str.length(); i++) {
-            System.out.println(str.charAt(i));
-            if (!Character.isDigit(str.charAt(i))) {
-                return false;
-            }
-        }
-        return true;
-    }
-
-    public static JSONObject Bundle2Json(Bundle bundle) {
-        JSONObject json = new JSONObject();
-        Set<String> keys = bundle.keySet();
-        for (String key : keys) {
-            try {
-                Log.d("", "Bundle2Json: key:" + key + "  val: " + wrap(bundle.get(key)));
-                json.put(key, wrap(bundle.get(key))); //see edit below
-//                json.put(key, JSONObject.wrap(bundle.get(key)));
-            } catch (JSONException e) {
-                //Handle exception here
-            }
-        }
-        return json;
-    }
-
-    private static Object wrap(Object o) {
-        if (o == null) {
-            return JSONObject.NULL;
-        }
-        if (o instanceof JSONArray || o instanceof JSONObject) {
-            return o;
-        }
-        if (o.equals(JSONObject.NULL)) {
-            return o;
-        }
-        try {
-            if (o instanceof Bundle) {
-                return Bundle2Json((Bundle) o);
-
-            }
-            if (o instanceof Collection) {
-                return new JSONArray((Collection) o);
-            } else if (o.getClass().isArray()) {
-                return toJSONArray(o);
-            }
-            if (o instanceof Map) {
-                return new JSONObject((Map) o);
-            }
-            if (o instanceof Boolean ||
-                    o instanceof Byte ||
-                    o instanceof Character ||
-                    o instanceof Double ||
-                    o instanceof Float ||
-                    o instanceof Integer ||
-                    o instanceof Long ||
-                    o instanceof Short ||
-                    o instanceof String) {
-                return o;
-            }
-            if (o.getClass().getPackage().getName().startsWith("java.")) {
-                return o.toString();
-            }
-        } catch (Exception ignored) {
-        }
-        return null;
-    }
-
-    private static JSONArray toJSONArray(Object array) throws JSONException {
-        JSONArray result = new JSONArray();
-        if (!array.getClass().isArray()) {
-            throw new JSONException("Not a primitive array: " + array.getClass());
-        }
-        final int length = Array.getLength(array);
-        for (int i = 0; i < length; ++i) {
-            result.put(wrap(Array.get(array, i)));
-        }
-        return result;
-    }
-
-    public static Bundle Json2Bundle(JSONObject s) {
-        Bundle bundle = new Bundle();
-
-        for (Iterator<String> it = s.keys(); it.hasNext(); ) {
-            String key = it.next();
-            try {
-                Object o = s.get(key);
-
-
-                if (o == null) {
-                    continue;
-                } else if (o instanceof JSONObject) {
-                    bundle.putBundle(key, Json2Bundle((JSONObject) o));
-                } else if (o instanceof JSONArray) {
-                    throw new JSONException("Json2Bundle does not support Json array: " + o.getClass());// bundle.putarr
-                } else if (o.equals(JSONObject.NULL)) {
-                    continue;
-                } else if (o instanceof Boolean) {
-                    bundle.putBoolean(key, ((Boolean) o).booleanValue());
-                } else if (o instanceof Byte) {
-                    bundle.putByte(key, ((Byte) o).byteValue());
-                } else if (o instanceof Character) {
-                    bundle.putChar(key, ((Character) o).charValue());
-                } else if (o instanceof Double) {
-                    bundle.putDouble(key, ((Double) o).doubleValue());
-                } else if (o instanceof Float) {
-                    bundle.putFloat(key, ((Float) o).floatValue());
-                } else if (o instanceof Integer) {
-                    bundle.putInt(key, ((Integer) o).intValue());
-                } else if (o instanceof Long) {
-                    bundle.putLong(key, ((Long) o).longValue());
-                } else if (o instanceof Short) {
-                    bundle.putShort(key, ((Short) o).shortValue());
-                } else if (o instanceof String) {
-                    bundle.putString(key, o.toString());
-                }
-
-//                ArrayList<Parcelable> a = new ArrayList<>();
-//                a.add("");
-//                a.add(1);
-//                bundle.putParcelableArrayList("arr", a);
-
-
-            } catch (JSONException e) {
-                e.printStackTrace();
-            }
-        }
-        return bundle;
-    }
-
-
-    public static final int MY_PERMISSIONS_REQUEST = 1;
-
-    public static Boolean checkPermissions(Activity activity, String[] permissions) {
-        if (Build.VERSION.SDK_INT >= 23) {
-            return checkPermissions_23(activity, permissions);
-        } else {
-            return false;
-        }
-    }
-
-    public static Boolean checkPermissions_23(Activity activity, String[] permissions) {
-        Log.d("_RAIMAGE", "checkPermissions23:==================================== ");
-
-        ArrayList<String> request_list = new ArrayList<String>();
-        for (String permission : permissions) {
-            boolean bshow = ActivityCompat.shouldShowRequestPermissionRationale(activity, permission);
-
-            boolean pc = PermissionChecker.checkSelfPermission(activity, permission) == PermissionChecker.PERMISSION_GRANTED;
-
-            if (!pc)
-                request_list.add(permission);
-        }
-        Log.d("_RAIMAGE", "checkPermissions23:==================================== ");
-
-
-        if (request_list.isEmpty())
-            return false;
-        ActivityCompat.requestPermissions(activity, request_list.toArray(new String[0]), MY_PERMISSIONS_REQUEST);
-
-
-        return true;
-
-    }
-
-    public static Boolean checkPermissions_23(Context applicationContext, String[] permissions) {
-        if (applicationContext == null) {
-            return false;
-        }
-
-
-        ArrayList<String> request_list = new ArrayList<String>();
-        Context context = applicationContext;
-        for (String permission : permissions) {
-
-            boolean pc = PermissionChecker.checkSelfPermission(context, permission) == PermissionChecker.PERMISSION_GRANTED;
-            if (!pc) {
-                Log.d("RAUtilsLibrary", "checkPermissions23:==================================== ");
-                Log.d("RAUtilsLibrary", "checkPermissions23: permission" + permission + " denied");
-                Log.d("RAUtilsLibrary", "checkPermissions23:==================================== ");
-                return false;
-            }
-        }
-//        Log.d("RAUtilsLibrary", "checkPermissions23:==================================== ");
-
-
-        return true;
-
-    }
-
-    public static Boolean checkPermissions_24(Activity activity, String[] permissions) {
-
-        if (permissions.length == 0)
-            return true;
-        ActivityCompat.requestPermissions(activity, permissions, MY_PERMISSIONS_REQUEST);
-
-
-        return true;
-    }
-
-    public static int iconName2Rid(Context context, String name) {
-
-        if (context == null) {
-            return 0;
-        }
-
-        if (context == null || TextUtils.isEmpty(name)) {
-            return 0;
-        }
-
-        int iconid = context.getResources().getIdentifier(name, "drawable", context.getPackageName());
-
-        return iconid;
-    }
-
-    private static final AtomicInteger sNextGeneratedId = new AtomicInteger(1);
-
-    /**
-
-     * This value will not collide with ID values generated at build time by aapt for R.id.
-     *
-     * @return a generated ID value
-     */
-    public static int generateViewId() {
-        for (; ; ) {
-            final int result = sNextGeneratedId.get();
-            // aapt-generated IDs have the high byte nonzero; clamp to the range under that.
-            int newValue = result + 1;
-            if (newValue > 0x00FFFFFF) newValue = 1; // Roll over to 1, not 0.
-            if (sNextGeneratedId.compareAndSet(result, newValue)) {
-                return result;
-            }
-        }
-    }
-
-    public static String getDUID(Application application) {
-
-        if (application == null) {
-            return null;
-        }
-
-        final TelephonyManager tm = (TelephonyManager) application.getBaseContext().getSystemService(Context.TELEPHONY_SERVICE);
-        final String tmDevice, tmSerial, androidId;
-        String uniqueId;
-        try {
-            if (ActivityCompat.checkSelfPermission(application, Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) {
-                // TODO: Consider calling
-                //    ActivityCompat#requestPermissions
-                // here to request the missing permissions, and then overriding
-                //   public void onRequestPermissionsResult(int requestCode, String[] permissions,
-                //                                          int[] grantResults)
-                // to handle the case where the user grants the permission. See the documentation
-                // for ActivityCompat#requestPermissions for more details.
-                return null;
-            }
-            tmDevice = "" + tm.getDeviceId();
-            tmSerial = "" + tm.getSimSerialNumber();
-            androidId = "" + android.provider.Settings.Secure.getString(application.getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);
-            UUID deviceUuid = new UUID(androidId.hashCode(), ((long) tmDevice.hashCode() << 32) | tmSerial.hashCode());
-            uniqueId = deviceUuid.toString();
-            Log.d("debug", "uuid=" + uniqueId);
-
-        } catch (Exception e) {
-            uniqueId = null;
-        }
-        return uniqueId;
-    }
-
-    public static int px2dp(Context context, float pxValue) {
-        float scale = context.getResources().getDisplayMetrics().density;
-        return (int) (pxValue / scale + 0.5f);
-    }
-
-    public static int dp2px(Context context, float dpValue) {
-        float scale = context.getResources().getDisplayMetrics().density;
-        return (int) (dpValue * scale + 0.5f);
-    }
-
-    public static int px2sp(Context context, float pxValue) {
-        float fontScale = context.getResources().getDisplayMetrics().scaledDensity;
-        return (int) (pxValue / fontScale + 0.5f);
-    }
-
-    public static int sp2px(Context context, float spValue) {
-        float fontScale = context.getResources().getDisplayMetrics().scaledDensity;
-        return (int) (spValue * fontScale + 0.5f);
-    }
-
-
-    public static String getDeviceId(Context context) {
-        TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
-        if (ActivityCompat.checkSelfPermission(context, Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) {
-            // TODO: Consider calling
-            //    ActivityCompat#requestPermissions
-            // here to request the missing permissions, and then overriding
-            //   public void onRequestPermissionsResult(int requestCode, String[] permissions,
-            //                                          int[] grantResults)
-            // to handle the case where the user grants the permission. See the documentation
-            // for ActivityCompat#requestPermissions for more details.
-            return "";
-        }
-        String deviceId = telephonyManager.getDeviceId().toString();
-        return deviceId;
-    }
-    public static String getAndroidId(Context context) {
-        return Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
-    }
-    public static String stringToMD5(String string) {
-        byte[] hash;
-
-        try {
-            hash = MessageDigest.getInstance("MD5").digest(string.getBytes("UTF-8"));
-        } catch (NoSuchAlgorithmException e) {
-            e.printStackTrace();
-            return null;
-        } catch (UnsupportedEncodingException e) {
-            e.printStackTrace();
-            return null;
-        }
-
-        StringBuilder hex = new StringBuilder(hash.length * 2);
-        for (byte b : hash) {
-            if ((b & 0xFF) < 0x10)
-                hex.append("0");
-            hex.append(Integer.toHexString(b & 0xFF));
-        }
-
-        return hex.toString();
-    }
-
-}

+ 0 - 276
ApexDrivers/RAUtilsLibrary/src/main/java/com/usai/redant/rautils/Utils/dbgUtil.java

@@ -1,276 +0,0 @@
-package com.usai.redant.rautils.utils;
-
-import android.Manifest;
-import android.content.Context;
-import android.database.Cursor;
-import android.os.Environment;
-import android.util.Log;
-
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.concurrent.locks.ReadWriteLock;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
-
-//import java.util.Calendar;
-
-public class dbgUtil
-{
-
-
-	private static ReadWriteLock loglock = new ReentrantReadWriteLock(true);
-
-	// static boolean ENABLE_DEBUG = true;
-	// static boolean ENABLE_SQL_DEBUG = true;
-	// final int DEBUG_LEVEL_NONE = 8;
-	// static int DEBUG_LEVEL = Log.VERBOSE;
-
-	// private static boolean m_dbgFlag = true;
-	/*
-	 * public dbgUtil(Context context) {
-	 * 
-	 * m_dbgFlag = Boolean.parseBoolean(context.getString(R.string.flag_debug));
-	 * 
-	 * }
-	 * 
-	 * public dbgUtil(Context context) { m_dbgFlag =
-	 * Boolean.parseBoolean(context.getString(R.string.flag_debug)); return
-	 * this; }
-	 */
-
-	public static void fileLog(Context appContext, String content)
-	{
-
-
-		String[] permissions = {
-				Manifest.permission.WRITE_EXTERNAL_STORAGE,
-				Manifest.permission.READ_EXTERNAL_STORAGE,
-		};
-
-
-
-		boolean result= RAUtil.checkPermissions_23(appContext, permissions);
-
-		if(!result) {
-			Log.d("Apex Drivers", "fileLog: no external storage permission");
-			return;
-		}
-		File dir = new File(Environment.getExternalStorageDirectory().getPath()
-				+ "/redant/pop");
-		if (!dir.exists())
-			dir.mkdirs();
-
-		Calendar c = Calendar.getInstance();
-//		c.add(Calendar.DAY_OF_WEEK, -1);
-
-		String newtime = new SimpleDateFormat("yyyy-MM-dd").format(c
-				.getTimeInMillis());
-
-		File[] f = dir.listFiles();
-		if(f==null) {
-			Log.d("Apex Drivers", "fileLog: list file failed");
-			Log.d("Apex Drivers", Environment.getExternalStorageDirectory().getPath());
-			return;
-		}
-		for (int i = 0; i < f.length; i++)
-		{
-			if(!f[i].isFile())
-				continue;
-			String n = f[i].getName();
-			if ((n != null) && (n.length() > 0))
-			{
-				int dot = n.lastIndexOf('.');
-				if ((dot > -1) && (dot < (n.length())))
-				{
-					n = n.substring(0, dot);
-				}
-				if(newtime.compareTo(n)>0)
-					f[i].delete();
-				
-
-
-			}
-		}
-
-		// dir.listfiles
-
-		String file = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
-		String timeStamp = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
-				.format(new Date());
-
-		FileOutputStream outputStream = null;
-		// try
-		// {
-
-		// dir.createNewFile()
-		File logfile = new File(Environment.getExternalStorageDirectory()
-				.getPath() + "/redant/pop/" + file + ".log");
-
-		// int mode = Application.MODE_APPEND;
-		if (!logfile.exists())
-		{
-			// mode = Application.MODE_PRIVATE;
-			try
-			{
-				logfile.createNewFile();
-			}
-			catch (IOException e)
-			{
-				// TODO Auto-generated catch block
-				e.printStackTrace();
-			}
-		}
-		// outputStream
-		// =RedAntApplication.getInstance().openFileOutput("pop.log", mode);
-
-		String logtextString = timeStamp + "   " + content;
-
-		FileWriter fw = null;
-		BufferedWriter bw = null;
-		String datetime = "";
-
-
-		try
-		{
-			Log.d("Apex Drivers", "fileLog: begin write "+ content);
-			loglock.writeLock().lock();
-
-			fw = new FileWriter(Environment.getExternalStorageDirectory()
-					.getPath() + "/redant/pop/" + file + ".log", true);//
-			// 创建FileWriter对象,用来写入字符流
-			bw = new BufferedWriter(fw); // 将缓冲对文件的输出
-			// String myreadline = datetime + "[]" + str;
-
-			bw.write(logtextString + "\n"); // 写入文件
-			bw.newLine();
-			bw.flush(); // 刷新该流的缓冲
-			bw.close();
-			fw.close();
-			Log.d("Apex Drivers", "fileLog: end write");
-
-		}
-		catch (IOException e)
-		{
-			// TODO Auto-generated catch block
-			e.printStackTrace();
-			try
-			{
-				bw.close();
-				fw.close();
-			}
-			catch (IOException e1)
-			{
-				// TODO Auto-generated catch block
-			}
-		}
-		finally {
-
-			loglock.writeLock().unlock();
-		}
-
-	}
-
-	public static void Logd(String tag, String msg)
-	{
-		String pos = getTracePos();
-		Log.d(tag, msg + pos);
-	}
-
-	// public static void Log(int type, String tag, String msg)
-	// {
-	// // if (ENABLE_DEBUG == false)
-	// // return;
-	// // if (type < DEBUG_LEVEL)
-	// // return;
-	// String pos= getTracePos();
-	// switch (type)
-	// {
-	// case Log.ASSERT:
-	// Log.wtf(tag, msg+pos);
-	// break;
-	// case Log.DEBUG:
-	// Log.d(tag, msg+pos);
-	// break;
-	// case Log.ERROR:
-	// Log.e(tag, msg+pos);
-	// break;
-	// case Log.INFO:
-	// Log.i(tag, msg+pos);
-	// break;
-	// case Log.VERBOSE:
-	// Log.v(tag, msg+pos);
-	// break;
-	// case Log.WARN:
-	// Log.w(tag, msg+pos);
-	// break;
-	// default:
-	// Log.wtf("dbgUtil", "LOG TYPE ERROR!"+pos);
-	// break;
-	// }
-	//
-	// }
-
-	private static String getTracePos()
-	{
-		// StackTraceElement[] elements =
-		// Thread.currentThread().getStackTrace();
-		StackTraceElement element = Thread.currentThread().getStackTrace()[4];
-
-		return " at " + element.getClassName() + "." + element.getMethodName()
-				+ "(" + element.getFileName() + ":" + element.getLineNumber()
-				+ ")";
-	}
-
-	public static void dbgCursorInfo(Cursor cursor, Context context/*
-																	 * , String
-																	 * TracePos
-																	 */)
-	{
-		// if (ENABLE_SQL_DEBUG == false)
-		// return;
-
-		// ----------------------debug cursor-----------------------------------
-		Log.d("sql_dbg@dbgCursorInfo",
-				getTracePos() + "Cursor size:	" + cursor.getCount()
-						+ ";	columns count:	" + cursor.getColumnCount() + ";");
-		// dbgUtil.Log(Log.DEBUG,"sql_dbg", getTracePos() + "Cursor size:	" +
-		// cursor.getCount()
-		// + ";	columns count:	" + cursor.getColumnCount() + ";");
-		for (int i = 0; i < cursor.getColumnCount(); i++)
-		{
-			Log.d("sql_dbg@dbgCursorInfo", "column idx:	" + i
-					+ ";		column name:	" + cursor.getColumnName(i) + ";");
-			// dbgUtil.Log(Log.DEBUG,"sql_dbg",
-			// "column idx:	" + i + ";		column name:	"
-			// + cursor.getColumnName(i) + ";");
-		}
-		// ----------------------debug cursor-----------------------------------
-
-	}
-	// public static void dbgCursorMoreInfo(Cursor cursor /*, String TracePos*/)
-	// {
-	// if(Boolean.parseBoolean(context.getString(R.string.flag_debug))==false)
-	// return;
-	//
-	//
-	// //----------------------debug cursor-----------------------------------
-	// dbgUtil.Log(Log.DEBUG,"sql_dbg",Log.getStackTraceString(new Throwable())
-	// +"Cursor size:	"+cursor.getCount()
-	// +";	columns count:	"+cursor.getColumnCount()
-	// +";");
-	// for (int i =0;i<cursor.getColumnCount();i++)
-	// {
-	// dbgUtil.Log(Log.DEBUG,"sql_dbg","column idx:	"+i
-	// +";		column name:	"+cursor.getColumnName(i)
-	// +";");
-	// }
-	// //----------------------debug cursor-----------------------------------
-	//
-	// }
-}