Преглед изворни кода

1.修改Android RAImage上传。

Pen Li пре 7 година
родитељ
комит
8c10595afb
21 измењених фајлова са 754 додато и 2605 уклоњено
  1. 17 8
      ApexDrivers/RAUtilsLibrary/src/main/java/com/usai/redant/rautils/upload/RAUploadManager.java
  2. 295 0
      ApexDrivers/RAUtilsLibrary/src/main/java/com/usai/redant/rautils/upload/UploadListActivity.java
  3. 8 0
      ApexDrivers/RAUtilsLibrary/src/main/java/com/usai/redant/rautils/utils/RAUtil.java
  4. 23 0
      ApexDrivers/RAUtilsLibrary/src/main/res/layout/upload_list_activity.xml
  5. 11 0
      ApexDrivers/RAUtilsLibrary/src/main/res/menu/ra_upload_list_menu.xml
  6. 7 0
      ApexDrivers/RAUtilsLibrary/src/main/res/values-zh/strings.xml
  7. 8 0
      ApexDrivers/RAUtilsLibrary/src/main/res/values/strings.xml
  8. 24 42
      ApexDrivers/raimage/src/main/AndroidManifest.xml
  9. 47 0
      ApexDrivers/raimage/src/main/java/com/usai/receiver/RAImageBootCompleteReceiver.java
  10. 0 33
      ApexDrivers/raimage/src/main/java/com/usai/redant/raimage/BootReceiver.java
  11. 6 5
      ApexDrivers/raimage/src/main/java/com/usai/redant/raimage/MainActivity.java
  12. 46 20
      ApexDrivers/raimage/src/main/java/com/usai/redant/raimage/RedAntApplication.java
  13. 150 379
      ApexDrivers/raimage/src/main/java/com/usai/redant/raimage/TaskActivity.java
  14. 0 617
      ApexDrivers/raimage/src/main/java/com/usai/redant/raimage/UploadList/UploadListActivity.java
  15. 0 548
      ApexDrivers/raimage/src/main/java/com/usai/redant/raimage/UploadService.java
  16. 27 76
      ApexDrivers/raimage/src/main/java/com/usai/redant/raimage/uploadSettingActivity.java
  17. 80 0
      ApexDrivers/raimage/src/main/java/com/usai/service/RAImageBackgroundService.java
  18. 5 5
      ApexDrivers/raimage/src/main/java/com/usai/util/Network.java
  19. 0 129
      ApexDrivers/raimage/src/main/java/com/usai/util/RAOperationQueue.java
  20. 0 725
      ApexDrivers/raimage/src/main/java/com/usai/util/RAUploadManager.java
  21. 0 18
      ApexDrivers/raimage/src/main/res/layout/activity_upload_list.xml

+ 17 - 8
ApexDrivers/RAUtilsLibrary/src/main/java/com/usai/redant/rautils/upload/RAUploadManager.java

@@ -36,7 +36,7 @@ public class RAUploadManager {
 
 
     private int retryWaiting = 300;
-    public int activeThread;
+//    public int activeThread;
 
     public int maxThread = 3;
     private int maxRetry = 5;
@@ -89,10 +89,9 @@ public class RAUploadManager {
         public boolean removeError=false;
         public boolean wifiOnly = false;
         public boolean monitorNetwork = false;///<网络断开,停止所有任务。网络恢复重启任务,除了Error状态下的任务
-
         public int maxRetry = 5;
         public int maxThread = 3;
-
+        public int retryWaiting = 300;
         public TaskStatus newtaskStatus = TaskStatus.TaskStatusWait;
 
 
@@ -104,7 +103,7 @@ public class RAUploadManager {
                 return;
             }
 
-            SharedPreferences UMSetting = RAUtil.sharedPreferences(applicationContext,"UploadManager");
+            SharedPreferences UMSetting = RAUtil.unProtectedPreferences(applicationContext,"UploadManager");
 
             if (UMSetting != null) {
 
@@ -116,6 +115,7 @@ public class RAUploadManager {
 
                 maxRetry = UMSetting.getInt("retry_count", 5);
                 maxThread = UMSetting.getInt("max_thread", 3);
+                retryWaiting = UMSetting.getInt("retry_waiting", 300);
 
                 newtaskStatus = TaskStatus.values()[UMSetting.getInt("newtask_status", TaskStatus.TaskStatusWait.ordinal())];
 
@@ -126,7 +126,7 @@ public class RAUploadManager {
 
             if (appContext != null) {
 
-                SharedPreferences UMSetting = RAUtil.sharedPreferences(appContext,"UploadManager");
+                SharedPreferences UMSetting = RAUtil.unProtectedPreferences(appContext,"UploadManager");
                 if (UMSetting != null) {
 
                     SharedPreferences.Editor editor = UMSetting.edit();
@@ -137,6 +137,7 @@ public class RAUploadManager {
                     editor.putBoolean("monitor_network",monitorNetwork);
                     editor.putInt("retry_count",maxRetry);
                     editor.putInt("max_thread",maxThread);
+                    editor.putInt("retry_waiting",retryWaiting);
                     editor.putInt("newtask_status",newtaskStatus.ordinal());
 
                     editor.apply();
@@ -153,6 +154,7 @@ public class RAUploadManager {
                 RAUploadManager.instance.monitorNetwork = monitorNetwork;
                 RAUploadManager.instance.maxRetry = maxRetry;
                 RAUploadManager.instance.maxThread = maxThread;
+                RAUploadManager.instance.retryWaiting = retryWaiting;
                 RAUploadManager.instance.newtaskStatus = newtaskStatus;
             }
         }
@@ -176,6 +178,13 @@ public class RAUploadManager {
 
     }
 
+    public static RAUploadManagerConfigure configure(Context applicationContext) {
+        if (applicationContext == null) {
+            return null;
+        }
+        return new RAUploadManagerConfigure(applicationContext);
+    }
+
 
     public UIUpdateListener uiUpdateListener;
     private Context applicationContext;
@@ -298,7 +307,7 @@ public class RAUploadManager {
         queue_status = QueueStatus.QueueStatusDefault;
 
 
-        SharedPreferences UMSetting = RAUtil.sharedPreferences(applicationContext,"UploadManager");
+        SharedPreferences UMSetting = RAUtil.unProtectedPreferences(applicationContext,"UploadManager");
 
         if (UMSetting != null) {
             autoStart = UMSetting.getBoolean("auto_upload",false);
@@ -535,7 +544,7 @@ public class RAUploadManager {
 
         Log.d("_RAIMAGE", "saveTasks: RAUploadManager");
 
-        SharedPreferences pref = RAUtil.sharedPreferences(applicationContext,"UploadManager");
+        SharedPreferences pref = RAUtil.unProtectedPreferences(applicationContext,"UploadManager");
         try {
             String tasksBase64 = pref.getString("task_list", "");
 
@@ -787,7 +796,7 @@ public class RAUploadManager {
 
         Log.d("_RAIMAGE", "saveTasks: RAUploadManager");
 
-        SharedPreferences pref = RAUtil.sharedPreferences(applicationContext,"UploadManager");//applicationContext.getSharedPreferences("RA Image", 0);
+        SharedPreferences pref = RAUtil.unProtectedPreferences(applicationContext,"UploadManager");//applicationContext.getSharedPreferences("RA Image", 0);
         SharedPreferences.Editor editor = pref.edit();
 
         try {

+ 295 - 0
ApexDrivers/RAUtilsLibrary/src/main/java/com/usai/redant/rautils/upload/UploadListActivity.java

@@ -0,0 +1,295 @@
+package com.usai.redant.rautils.upload;
+
+import android.content.BroadcastReceiver;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.content.ServiceConnection;
+import android.os.Bundle;
+import android.os.IBinder;
+import android.support.annotation.LayoutRes;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.support.v7.app.ActionBar;
+import android.support.v7.app.AlertDialog;
+import android.support.v7.app.AppCompatActivity;
+import android.util.Log;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+import android.widget.ListView;
+
+import com.usai.redant.rautils.R;
+import com.usai.redant.rautils.service.RAService;
+
+import java.util.ArrayList;
+import java.util.Collections;
+
+import static com.usai.redant.rautils.upload.RAUploadManager.UPLOAD_COUNT_CHANGED_NOTIFICATION;
+
+public class UploadListActivity extends AppCompatActivity {
+
+    ArrayList<Bundle> task_arr= new ArrayList<>();
+    ListView taskList;
+
+
+    private RAUploadManager uploadManager;
+    private RAService.MyBinder binder;
+    private RAService uploadService;
+    private ServiceConnection serviceConnection;
+    boolean serviceConnectionFlag;
+
+    private int mUploadCellResID;
+    private Context mCtx = this;
+    private Class mServiceCls;
+
+    private BroadcastReceiver uploadReceiver = new BroadcastReceiver() {
+        @Override
+        public void onReceive(Context context, Intent intent) {
+
+            String action = intent.getAction();
+            if (action.equals(UPLOAD_COUNT_CHANGED_NOTIFICATION)) {
+
+                runOnUiThread(new Runnable() {
+                    @Override
+                    public void run() {
+                        notifyDataChanged();
+                    }
+                });
+            }
+        }
+    };
+
+    public void notifyDataChanged() {
+
+        if (uploadManager != null && taskList != null) {
+            task_arr = (ArrayList<Bundle>) uploadManager.get_arr_queue().clone(); //uploadManager.arr_queue;
+            TaskAdapter adapter = (TaskAdapter) taskList.getAdapter();
+            if (adapter != null) {
+                adapter.notifyDataSetChanged();
+            }
+        }
+    }
+
+    private void registerBroadcastReceiver() {
+
+        IntentFilter intentFilter = new IntentFilter();
+        intentFilter.addAction(UPLOAD_COUNT_CHANGED_NOTIFICATION);
+
+        registerReceiver(uploadReceiver,intentFilter);
+    }
+
+
+
+    /**
+     * subClass invoke
+     * */
+
+    public Bundle getItem(int position) {
+        Bundle item = task_arr.get(position);
+        return item;
+    }
+
+    public void startTask(Bundle task) {
+        if (task != null && uploadManager != null) {
+            uploadManager.startTask(task);
+        }
+    }
+
+    public void registerCellResourceId(int resId) {
+        mUploadCellResID = resId;
+    }
+
+    public void setServiceClass(Class cls) {
+        mServiceCls = cls;
+    }
+
+    public View dequeueCell(final int position, @Nullable View convertView, @NonNull ViewGroup parent) {
+        return null;
+    }
+
+    /***/
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.upload_list_activity);
+
+        //设置返回键
+        ActionBar mActionBar = getSupportActionBar();
+        mActionBar.setHomeButtonEnabled(true);
+        mActionBar.setDisplayHomeAsUpEnabled(true);
+        mActionBar.setTitle(getString(R.string.ra_upload_title));
+
+        taskList = (ListView)findViewById(R.id.task_list);
+        taskList.setAdapter(new TaskAdapter(this,mUploadCellResID));
+
+        serviceConnection = new ServiceConnection() {
+            @Override
+            public void onServiceConnected(ComponentName name, IBinder service) {
+
+
+                Log.d("_LIST","-------connected service  tid="+Thread.currentThread().getId());
+                serviceConnectionFlag = true;
+
+                binder = (RAService.MyBinder)service;
+                uploadService = (RAService)binder.getService();
+
+                uploadManager = uploadService.getUploadManager();
+                if (uploadManager == null) {
+                    return;
+                }
+
+
+                task_arr = (ArrayList<Bundle>) uploadManager.get_arr_queue().clone(); //uploadManager.arr_queue;
+
+                Collections.reverse(task_arr);
+                final TaskAdapter adapter = (TaskAdapter) taskList.getAdapter();
+
+                adapter.notifyDataSetChanged();
+
+
+                uploadManager.uiUpdateListener = new RAUploadManager.UIUpdateListener() {
+                    @Override
+                    public void updateCell(long index, Bundle taskinfo) {
+                        if(true) {
+
+                            runOnUiThread(new Runnable() {
+                                @Override
+                                public void run() {
+
+                                    adapter.notifyDataSetChanged();
+                                }
+                            });
+
+                            return;
+                        }
+
+                    }
+
+                    @Override
+                    public void updateList(final ArrayList<Bundle> newlist) {
+                        if(true) {
+
+                            runOnUiThread(new Runnable() {
+                                @Override
+                                public void run() {
+                                    task_arr = (ArrayList<Bundle>) newlist.clone();
+                                    Collections.reverse(task_arr);
+                                    adapter.notifyDataSetChanged();
+                                }
+                            });
+
+                            return;
+                        }
+
+                    }
+                };
+            }
+
+            @Override
+            public void onServiceDisconnected(ComponentName name) {
+                serviceConnectionFlag = false;
+                uploadManager.uiUpdateListener = null;
+            }
+        };
+
+        bindService();
+
+        registerBroadcastReceiver();
+    }
+
+    @Override
+    protected void onDestroy() {
+
+        unbindService(serviceConnection);
+
+        unregisterReceiver(uploadReceiver);
+
+        super.onDestroy();
+    }
+
+
+    private void bindService() {
+        if (mServiceCls != null) {
+            Intent intent = new Intent(mCtx, mServiceCls);
+
+            bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE);
+        }
+    }
+    @Override
+    public boolean onCreateOptionsMenu(Menu menu) {
+        getMenuInflater().inflate(R.menu.ra_upload_list_menu,menu);
+        return true;
+    }
+
+    @Override
+    public boolean onOptionsItemSelected(MenuItem item) {
+        int i = item.getItemId();
+        if (i == android.R.id.home) {
+            finish();
+
+        } else if (i == R.id.clear_upload_list_btn) {
+            clearUploadList();
+
+        }
+        return true;
+    }
+
+    private void clearUploadList() {
+        if (task_arr.size() == 0) {
+            new AlertDialog.Builder(this)
+                    .setTitle(getString(R.string.ra_title_warning))
+                    .setMessage(getString(R.string.ra_upload_empty))
+                    .setPositiveButton(getString(R.string.ra_btn_ok),null)
+                    .show();
+            return;
+        }
+
+        new AlertDialog.Builder(this)
+                .setTitle(getString(R.string.ra_clear_title))
+                .setMessage(getString(R.string.ra_clear_ask))
+                .setPositiveButton(getString(R.string.ra_btn_ok), new DialogInterface.OnClickListener() {
+                    @Override
+                    public void onClick(DialogInterface dialog, int which) {
+                        // clear
+                        if (serviceConnectionFlag == true && uploadService != null) {
+                            uploadManager.clearTask();
+//                            adapter.notifyDataSetChanged();
+                        }
+
+                    }
+                })
+                .setNegativeButton(getString(R.string.ra_btn_cancel), new DialogInterface.OnClickListener() {
+                    @Override
+                    public void onClick(DialogInterface dialog, int which) {
+
+                    }
+                })
+                .show();
+
+    }
+
+    class TaskAdapter extends ArrayAdapter
+    {
+
+        public TaskAdapter(@NonNull Context context, @LayoutRes int resource/*, @NonNull ArrayList<Bundle> objects*/) {
+            super(context, resource/*, objects*/);
+        }
+
+        @Override
+        public int getCount() {
+            return task_arr.size();
+        }
+
+        @Override
+        public View getView(final int position, @Nullable View convertView, @NonNull ViewGroup parent) {
+
+            return dequeueCell(position, convertView, parent);
+        }
+    }
+}

+ 8 - 0
ApexDrivers/RAUtilsLibrary/src/main/java/com/usai/redant/rautils/utils/RAUtil.java

@@ -59,6 +59,14 @@ public class RAUtil {
         }
         return pref;
     }
+
+    public static SharedPreferences unProtectedPreferences(Context context, String key) {
+        if (context == null || key == null) {
+            return null;
+        }
+        return context.getSharedPreferences(key, 0);
+    }
+
     public static String getApplicationName(Context context) {
 
         PackageManager packageManager = null;

+ 23 - 0
ApexDrivers/RAUtilsLibrary/src/main/res/layout/upload_list_activity.xml

@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    tools:context=".upload.TaskActivity">
+
+    <ListView
+        android:id="@+id/task_list"
+        android:layout_width="0dp"
+        android:layout_height="0dp"
+        android:layout_marginBottom="8dp"
+        android:layout_marginLeft="8dp"
+        android:layout_marginRight="8dp"
+        android:layout_marginTop="8dp"
+        app:layout_constraintBottom_toBottomOf="parent"
+        app:layout_constraintLeft_toLeftOf="parent"
+        app:layout_constraintRight_toRightOf="parent"
+        app:layout_constraintTop_toTopOf="parent"
+        android:layout_marginStart="8dp"
+        android:layout_marginEnd="8dp" />
+</android.support.constraint.ConstraintLayout>

+ 11 - 0
ApexDrivers/RAUtilsLibrary/src/main/res/menu/ra_upload_list_menu.xml

@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+<menu xmlns:android="http://schemas.android.com/apk/res/android"
+      xmlns:app="http://schemas.android.com/apk/res-auto">
+
+    <item
+        android:id="@+id/clear_upload_list_btn"
+        app:showAsAction="always"
+        android:title="@string/ra_upload_menu_clear"
+        />
+
+</menu>

+ 7 - 0
ApexDrivers/RAUtilsLibrary/src/main/res/values-zh/strings.xml

@@ -58,4 +58,11 @@
     <string name="pdf_preview_open">打开</string>
     <string name="pdf_preview_share">分享</string>
 
+    <!--Upload List-->
+    <string name="ra_upload_title">上传列表</string>
+    <string name="ra_upload_menu_clear">清除</string>
+    <string name="ra_upload_empty">上传列表为空</string>
+    <string name="ra_clear_title">清空上传列表</string>
+    <string name="ra_clear_ask">你确定要删除所有出错和完成的任务吗?</string>
+
 </resources>

+ 8 - 0
ApexDrivers/RAUtilsLibrary/src/main/res/values/strings.xml

@@ -58,4 +58,12 @@
     <string name="pdf_preview_open">Open</string>
     <string name="pdf_preview_share">Share</string>
 
+
+    <!--Upload List-->
+    <string name="ra_upload_title">Upload List</string>
+    <string name="ra_upload_menu_clear">Clear</string>
+    <string name="ra_upload_empty">Upload list is empty.</string>
+    <string name="ra_clear_title">Clear upload list</string>
+    <string name="ra_clear_ask">Are you sure remove all error/finish task?</string>
+
 </resources>

+ 24 - 42
ApexDrivers/raimage/src/main/AndroidManifest.xml

@@ -12,7 +12,11 @@
     <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
     <uses-permission android:name="android.permission.INTERNET"/>
     <!-- <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> -->
-    <uses-permission android:name="android.permission.CHANGE_CONFIGURATION"/>
+    <!--<uses-permission android:name="android.permission.CHANGE_CONFIGURATION"/>-->
+
+    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
+    <uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS"/>
+    <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
 
     <application
         android:name=".RedAntApplication"
@@ -22,24 +26,27 @@
         android:theme="@style/AppTheme"
         >
 
-        <!-- <activity -->
-        <!-- android:name=".MainActivity" -->
-        <!-- android:configChanges="orientation|keyboardHidden" -->
-        <!-- android:label="@string/app_name" -->
-        <!-- android:screenOrientation="sensorLandscape" -->
-        <!-- android:stateNotNeeded="true" -->
-        <!-- android:theme="@style/CaptureTheme"> -->
-
+        <service
+            android:name="com.usai.service.RAImageBackgroundService"
+            android:enabled="true"
+            android:exported="true"
+            android:label="ApexDrivers background service">
 
-        <!-- &lt;!&ndash; -->
-        <!-- <intent-filter> -->
-        <!-- <action android:name="android.intent.action.MAIN" /> -->
+        </service>
 
+        <receiver
+            android:name="com.usai.receiver.RAImageBootCompleteReceiver"
+            android:directBootAware="true"
+            android:enabled="true"
+            android:exported="false"
+            android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
+            <intent-filter>
+                <action android:name="android.intent.action.BOOT_COMPLETED"/>
+                <action android:name="android.intent.action.LOCKED_BOOT_COMPLETED"/>
+            </intent-filter>
+        </receiver>
 
-        <!-- <category android:name="android.intent.category.LAUNCHER" /> -->
-        <!-- </intent-filter> -->
-        <!-- &ndash;&gt; -->
-        <!-- </activity> -->
+        <!--Activity-->
 
         <activity
             android:name=".MainActivity"
@@ -47,13 +54,6 @@
             android:stateNotNeeded="true"
             android:theme="@style/Theme.AppCompat.Light">
 
-            <!--
-                 <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
-
-                <category android:name="android.intent.category.LAUNCHER" />
-            </intent-filter>
-            -->
         </activity>
 
         <activity
@@ -67,21 +67,6 @@
             android:screenOrientation="sensorLandscape"
             android:windowSoftInputMode="stateHidden|adjustResize"/>
 
-        <receiver android:name=".BootReceiver">
-            <intent-filter android:priority="2147483647">
-                <action android:name="android.intent.action.BOOT_COMPLETED"/>
-                <action android:name="android.net.conn.CONNECTIVITY_CHANGE"/>
-            </intent-filter>
-        </receiver>
-
-        <service
-            android:name=".UploadService"
-            android:label="usai upload service">
-            <intent-filter>
-                <action android:name="com.usai.raimage.uploadservice"/>
-            </intent-filter>
-        </service>
-
         <activity
             android:name=".AboutActivity"
             android:label="@string/title_activity_about"
@@ -136,9 +121,6 @@
         <activity
             android:name=".Model.ManufactureListActivity"
             android:theme="@style/Theme.AppCompat.Light"/>
-        <activity
-            android:name=".UploadList.UploadListActivity"
-            android:theme="@style/Theme.AppCompat.Light"/>
         <activity
             android:name=".TaskActivity"
             android:theme="@style/Theme.AppCompat.Light"/>
@@ -148,7 +130,7 @@
             android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN"/>
-
+                <action android:name="android.intent.action.VIEW"/>
                 <category android:name="android.intent.category.LAUNCHER"/>
             </intent-filter>
         </activity>

+ 47 - 0
ApexDrivers/raimage/src/main/java/com/usai/receiver/RAImageBootCompleteReceiver.java

@@ -0,0 +1,47 @@
+package com.usai.receiver;
+
+import android.content.Context;
+import android.content.Intent;
+import android.os.Build;
+
+import com.usai.redant.rautils.receiver.BootCompleteBroadcastReceiver;
+import com.usai.redant.rautils.utils.dbgUtil;
+import com.usai.service.RAImageBackgroundService;
+
+public class RAImageBootCompleteReceiver extends BootCompleteBroadcastReceiver {
+
+    @Override
+    protected void OnBootComplete(Context context, Intent intent) {
+
+        dbgUtil.fileLog(context,"ApexDriver: OnBootComplete");
+
+        startService(context, intent);
+    }
+
+	@Override
+	protected void OnLockedBootComplete(Context context, Intent intent) {
+
+		dbgUtil.fileLog(context,"ApexDriver: OnLockedBootComplete");
+
+		startService(context, intent);
+	}
+
+	private void startService(Context context, Intent intent) {
+
+		Intent intentService = new Intent();
+		intentService.setClass(context, RAImageBackgroundService.class);
+		if (intent.getExtras() != null) {
+			intentService.putExtras(intent.getExtras());
+		}
+
+		intentService.setAction(intent.getAction());
+
+		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
+
+			context.startForegroundService(intentService);
+		} else {
+
+			context.startService(intentService);
+		}
+	}
+}

+ 0 - 33
ApexDrivers/raimage/src/main/java/com/usai/redant/raimage/BootReceiver.java

@@ -1,33 +0,0 @@
-package com.usai.redant.raimage;
-
-
-
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-
-public class BootReceiver extends BroadcastReceiver {
-
-	// Context
-	public void UnlockReceiver(Context context) {
-
-	}
-
-	@Override
-	public void onReceive(Context context, Intent intent) {
-		// TODO Auto-generated method stub
-		if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
-			
-			Intent intentservice = new Intent();
-			intentservice.setClass(context, UploadService.class);
-			if (intent.getExtras() != null)
-				intentservice.putExtras(intent.getExtras());
-			intentservice.setAction(intent.getAction());
-			context.startService(intentservice);
-			
-			
-			// Log.e("hg","�յ��㲥");
-		} 
-	}
-
-}

+ 6 - 5
ApexDrivers/raimage/src/main/java/com/usai/redant/raimage/MainActivity.java

@@ -36,6 +36,7 @@ import android.widget.TextView;
 
 import com.usai.redant.raimage.Model.ManufactureListActivity;
 import com.usai.redant.raimage.PhotoList.PhotoGridActivity;
+import com.usai.redant.rautils.receiver.RABroadcast;
 import com.usai.redant.rautils.signature.SignatureActivity;
 import com.usai.redant.rautils.zxing.codescanner.CaptureActivity;
 import com.usai.util.AES;
@@ -359,7 +360,7 @@ public class MainActivity extends AppCompatActivity
                 //验证成功
 
 
-                Intent intent = new Intent("REDANT.RAImage.ADD_TASK");
+                Intent intent = new Intent(RABroadcast.ACTION_UPLOAD_ADD_TASK);
 
                 ArrayList<Bundle> taskArr = new ArrayList<Bundle>();
 //                String name = "POP";
@@ -378,7 +379,7 @@ public class MainActivity extends AppCompatActivity
 
                     task.putString("path",path);
                     task.putString("file",RAUtil.lastPathComponent(path));
-                    task.putString("url",RedAntApplication.active_address);
+                    task.putString("url",RedAntApplication.active_address + Network.URL_UPLOAD);
 
                     String md5 = MD5.md5sum(path);
 
@@ -416,7 +417,7 @@ public class MainActivity extends AppCompatActivity
 
                         task.putString("path",signature);
                         task.putString("file",RAUtil.lastPathComponent(signature));
-                        task.putString("url",RedAntApplication.active_address);
+                        task.putString("url",RedAntApplication.active_address + Network.URL_UPLOAD);
 
                         String md5 = MD5.md5sum(signature);
 
@@ -540,7 +541,7 @@ public class MainActivity extends AppCompatActivity
                                     public void onClick(DialogInterface dialog, int which)             {
 
 
-                                        Intent intent = new Intent("REDANT.RAImage.ADD_TASK");
+                                        Intent intent = new Intent(RABroadcast.ACTION_UPLOAD_ADD_TASK);
 
                                         ArrayList<Bundle> taskArr = new ArrayList<Bundle>();
 
@@ -549,7 +550,7 @@ public class MainActivity extends AppCompatActivity
 
                                             task.putString("path",path);
                                             task.putString("file",RAUtil.lastPathComponent(path));
-                                            task.putString("url",RedAntApplication.active_address);
+                                            task.putString("url",RedAntApplication.active_address + Network.URL_UPLOAD);
 
                                             String md5 = MD5.md5sum(path);
                                             String encryptUser = AES.encrypt("usai",RedAntApplication.user);

+ 46 - 20
ApexDrivers/raimage/src/main/java/com/usai/redant/raimage/RedAntApplication.java

@@ -3,14 +3,20 @@ package com.usai.redant.raimage;
 import android.app.AlarmManager;
 import android.app.Application;
 import android.app.PendingIntent;
+import android.content.ComponentName;
 import android.content.Context;
 import android.content.Intent;
+import android.content.ServiceConnection;
 import android.content.SharedPreferences;
+import android.os.Build;
+import android.os.IBinder;
 import android.os.SystemClock;
 import android.provider.Settings;
 import android.text.TextUtils;
 import android.util.Log;
 
+import com.usai.service.RAImageBackgroundService;
+
 import org.json.JSONObject;
 
 import java.util.concurrent.locks.Lock;
@@ -19,6 +25,10 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
 
 public class RedAntApplication extends Application
 {
+
+	public static  String CHANNEL_ID = "RAImage";
+	public static  String CHANNEL_NAME = "RAImage";
+
     private static RedAntApplication instance;  
     public static ReadWriteLock lock = new ReentrantReadWriteLock(true);  
     public static ReadWriteLock loglock = new ReentrantReadWriteLock(true);  
@@ -31,6 +41,9 @@ public class RedAntApplication extends Application
 	public static String device_id;
 	public static JSONObject server_info;
 
+	private ServiceConnection mServiceConnection;
+	private RAImageBackgroundService mService;
+
     public static RedAntApplication getInstance() {  
         return instance;  
     }  
@@ -69,6 +82,7 @@ public class RedAntApplication extends Application
 		am.cancel(sender);
 		Log.d("redant pop","cancel alarm");
 	}
+
     @Override  
     public void onCreate() {  
         // TODO Auto-generated method stub
@@ -77,17 +91,9 @@ public class RedAntApplication extends Application
         instance = this;
 
 
-
-//		TelephonyManager tm = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
-//		String DEVICE_ID = tm.getDeviceId();
-//		if(TextUtils.isEmpty(RedAntApplication.user))
-//			DEVICE_ID= Settings.System.getString(getContentResolver(), Settings.System.ANDROID_ID);
-
-
 		device_id=Settings.Secure.getString(getContentResolver(),Settings.Secure.ANDROID_ID);
         
-		SharedPreferences pref = RedAntApplication.getInstance()
-				.getSharedPreferences("RA Image", 0);
+		SharedPreferences pref = RedAntApplication.getInstance().getSharedPreferences("RA Image", 0);
 
 		String aa = pref.getString("aa", null);
 		String name = pref.getString("station name", null);
@@ -95,27 +101,47 @@ public class RedAntApplication extends Application
 			active_address = aa;
 		if(!TextUtils.isEmpty(name))
 			station_name = name;
-        
-        
-		Intent intentservice = new Intent();
-		intentservice.setClass( this, UploadService.class);
-//		if (intent.getExtras() != null)
-//			intentservice.putExtras(intent.getExtras());
-//		intentservice.setAction(intent.getAction());
-		startService(intentservice);
-		
 
+		/** Service */
+		mServiceConnection = new ServiceConnection() {
+			@Override
+			public void onServiceConnected(ComponentName name, IBinder service) {
+
+				RAImageBackgroundService.MyBinder binder = (RAImageBackgroundService.MyBinder)service;
+				mService = (RAImageBackgroundService)binder.getService();
+
+			}
+
+			@Override
+			public void onServiceDisconnected(ComponentName name) {
+
+				mService = null;
+			}
+		};
 
+		Intent serviceIntent = new Intent();
+		serviceIntent.setClass(this, RAImageBackgroundService.class);
 
+		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
 
-		
-		
+			this.startForegroundService(serviceIntent);
+		} else {
+
+			this.startService(serviceIntent);
+		}
+
+		Intent intent = new Intent(getApplicationContext(),RAImageBackgroundService.class);
+		bindService(intent,mServiceConnection, Context.BIND_AUTO_CREATE);
+
+		/***/
     }
 
 	@Override
 	public void onTerminate() {
 		Log.d("_RAIMAGE", "onTerminate: RedAntApplication");
 		super.onTerminate();
+
+		unbindService(mServiceConnection);
 	}
 
 	@Override

+ 150 - 379
ApexDrivers/raimage/src/main/java/com/usai/redant/raimage/TaskActivity.java

@@ -1,443 +1,214 @@
 package com.usai.redant.raimage;
 
-import android.content.ComponentName;
 import android.content.Context;
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.content.ServiceConnection;
+
 import android.content.SharedPreferences;
 import android.net.ConnectivityManager;
 import android.net.NetworkInfo;
 import android.os.Bundle;
-import android.os.IBinder;
-import android.support.annotation.LayoutRes;
 import android.support.annotation.NonNull;
 import android.support.annotation.Nullable;
-import android.support.v7.app.ActionBar;
-import android.support.v7.app.AlertDialog;
-import android.support.v7.app.AppCompatActivity;
 import android.util.Log;
 import android.view.Gravity;
-import android.view.Menu;
-import android.view.MenuItem;
 import android.view.View;
 import android.view.ViewGroup;
-import android.widget.ArrayAdapter;
 import android.widget.ImageButton;
-import android.widget.ListView;
 import android.widget.ProgressBar;
 import android.widget.TextView;
 import android.widget.Toast;
 
-import com.usai.util.RAUploadManager;
+import com.usai.redant.rautils.upload.RAUploadManager;
+import com.usai.redant.rautils.upload.UploadListActivity;
+import com.usai.service.RAImageBackgroundService;
 import com.usai.util.dbgUtil;
 
-import java.util.ArrayList;
-import java.util.Collections;
-
-//import android.support.v7.widget.ListViewCompat;
-
-public class TaskActivity extends AppCompatActivity {
-
-    ArrayList<Bundle> task_arr= new ArrayList<>();
-    ListView tasklist;
-
-
-    private RAUploadManager uploadManager;
 
+public class TaskActivity extends UploadListActivity {
 
-    private UploadService.MyBinder binder;
-    private UploadService uploadServiceservice;
-    private ServiceConnection serviceConnection;
 
-    boolean serviceConnectionFlag;
     @Override
     protected void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-        setContentView(R.layout.activity_task);
-
-
-//设置返回键
-        ActionBar mActionBar = getSupportActionBar();
-        mActionBar.setHomeButtonEnabled(true);
-        mActionBar.setDisplayHomeAsUpEnabled(true);
-        mActionBar.setTitle("RA Image");
-
-
-
-
-
-        tasklist = (ListView)findViewById(R.id.task_list);
-
-        tasklist.setAdapter(new TaskAdapter(this,R.layout.upload_list_cell/*,task_arr*/));
-
-
-
-
-        serviceConnection = new ServiceConnection() {
-            @Override
-            public void onServiceConnected(ComponentName name, IBinder service) {
-
-
-                Log.d("_LIST","-------connected service  tid="+Thread.currentThread().getId());
-                serviceConnectionFlag = true;
-
-                binder = (UploadService.MyBinder)service;
-                uploadServiceservice = binder.getService();
-
-                uploadManager = uploadServiceservice.uploadManager;
-                task_arr = (ArrayList<Bundle>) uploadManager.get_arr_queue().clone(); //uploadManager.arr_queue;
-
-                Collections.reverse(task_arr);
-                final TaskAdapter adapter = (TaskAdapter)tasklist.getAdapter();
-
-                adapter.notifyDataSetChanged();
-
-
-                uploadManager.uiUpdateListener = new RAUploadManager.UIUpdateListener() {
-                    @Override
-                    public void updateCell(long index, Bundle taskinfo) {
-                        if(true) {
-
-                            runOnUiThread(new Runnable() {
-                                @Override
-                                public void run() {
-
-                                    adapter.notifyDataSetChanged();
-                                }
-                            });
-
-                            return;
-                        }
-
-                    }
-
-                    @Override
-                    public void updateList(final ArrayList<Bundle> newlist) {
-                        if(true) {
-
-                            runOnUiThread(new Runnable() {
-                                @Override
-                                public void run() {
-                                    task_arr = (ArrayList<Bundle>) newlist.clone();
-                                    Collections.reverse(task_arr);
-                                    adapter.notifyDataSetChanged();
-                                }
-                            });
-
-                            return;
-                        }
-
-                    }
-                };
-
-
-//                tasklist.getAdapter().no.notifyDataSetChanged();
-//                runOnUiThread(new Runnable() {
-//                    @Override
-//                    public void run() {
-//                        adapter = new uploadAdapter(R.layout.upload_list_cell);
-//                        uploadList.setAdapter(adapter);
-//                    }
-//                });
-            }
-
-            @Override
-            public void onServiceDisconnected(ComponentName name) {
-                serviceConnectionFlag = false;
-                uploadManager.uiUpdateListener = null;
-            }
-        };
-
-        bindService();
 
-    }
-
-    @Override
-    protected void onDestroy() {
+        registerCellResourceId(R.layout.upload_list_cell);
+        setServiceClass(RAImageBackgroundService.class);
 
-        unbindService(serviceConnection);
-
-        super.onDestroy();
+        super.onCreate(savedInstanceState);
     }
 
-
-    private void bindService() {
-        Intent intent = new Intent(TaskActivity.this, UploadService.class);
-
-        bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE);
-    }
     @Override
-    public boolean onCreateOptionsMenu(Menu menu) {
-        getMenuInflater().inflate(R.menu.upload_list_menu,menu);
-        return true;
-    }
+    public View dequeueCell(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
 
-    @Override
-    public boolean onOptionsItemSelected(MenuItem item) {
-        switch (item.getItemId()) {
-            case android.R.id.home: {
-                finish();
-            }
-            break;
-            case R.id.clear_upload_list_btn: {
-//                for(int i=0;i<10;i++)
-//                runOnUiThread(new Runnable() {
-//                    @Override
-//                    public void run() {
-//
-//                        Log.d("_LIST","running  tid="+Thread.currentThread().getId());
-//                        Log.d("_LIST", "uploadlist UI  size:  "+ displaylist.size());
-//                        long timeStart = System.currentTimeMillis();
-////                        displaylist = (ArrayList<Bundle>) newlist.clone();
-//                        adapter.notifyDataSetChanged();
-//
-//
-//                        Log.d("_LIST", "uploadlist UI: COST" + (System.currentTimeMillis() - timeStart));
-//                    }
-//                });
-                clearUploadList();
-            }
-            break;
-        }
-        return true;
+        return getView(position, convertView, parent);
     }
 
-    private void clearUploadList() {
-        if (task_arr.size() == 0) {
-            new AlertDialog.Builder(this)
-                    .setTitle("Warning")
-                    .setMessage("Upload list is empty.")
-                    .setPositiveButton("OK",null)
-                    .show();
-            return;
+    private View getView(final int position, @Nullable View convertView, @NonNull ViewGroup parent) {
+
+        final Bundle item = getItem(position);
+
+        RAUploadManager.TaskStatus istatus = RAUploadManager.TaskStatus.values()[item.getInt("status",0)];
+        String status="";
+        switch(istatus)
+        {
+            case TaskStatusStart:
+                status="uploading";
+                break;
+            case TaskStatusStop:
+                status="stop";
+                break;
+            case TaskStatusError:
+                status="warning";
+                break;
+            case TaskStatusWait:
+                status="waiting";
+                break;
+            case TaskStatusFinish:
+                status="finish";
+                break;
+
+            default:
+                status="warning";
+                break;
         }
-
-        new AlertDialog.Builder(this)
-                .setTitle("Clear upload list")
-                .setMessage("Are you sure remove all error/finish task?")
-                .setPositiveButton("YES", new DialogInterface.OnClickListener() {
-                    @Override
-                    public void onClick(DialogInterface dialog, int which) {
-                        // clear
-                        if (serviceConnectionFlag == true && uploadServiceservice != null) {
-                            uploadManager.clearTask();
-//                            adapter.notifyDataSetChanged();
-                        }
-
-                    }
-                })
-                .setNegativeButton("NO", new DialogInterface.OnClickListener() {
-                    @Override
-                    public void onClick(DialogInterface dialog, int which) {
-
-                    }
-                })
-                .show();
-
-    }
-    class TaskAdapter extends ArrayAdapter
-    {
-
-        public TaskAdapter(@NonNull Context context, @LayoutRes int resource/*, @NonNull ArrayList<Bundle> objects*/) {
-            super(context, resource/*, objects*/);
+        double percent = item.getDouble("progress",(double)item.getInt("progress",0));
+        String err = item.getString("msg");
+        String name = item.getString("file","");
+
+        View cell;
+        ViewHolder holder;
+        if (convertView != null) {
+
+            cell = convertView;
+            holder = (ViewHolder)cell.getTag();
+            Log.d("_LIST", "getView: " + holder);
+
+        } else {
+
+            cell = View.inflate(getApplicationContext(), R.layout.upload_list_cell, null);
+            holder = new ViewHolder();
+            holder.name_tv = (TextView) cell.findViewById(R.id.upload_name_tv);
+            holder.progressBar = (ProgressBar) cell.findViewById(R.id.upload_progressBar);
+            holder.state_tv = (TextView) cell.findViewById(R.id.upload_state_tv);
+            holder.progress_tv = (TextView) cell.findViewById(R.id.upload_progress_tv);
+            holder.err_tv = (TextView) cell.findViewById(R.id.upload_err_tv);
+            holder.btn_reload = (ImageButton) cell.findViewById(R.id.btn_reload);
+            cell.setTag(holder);
         }
-
-        @Override
-        public int getCount() {
-            return task_arr.size();
+        holder.btn_reload.setImageResource(R.drawable.ic_action_reload);
+        if(istatus!= RAUploadManager.TaskStatus.TaskStatusError&& istatus!= RAUploadManager.TaskStatus.TaskStatusStop)
+        {
+            holder.btn_reload.setVisibility(View.GONE);
         }
-
-        @Override
-        public View getView(final int position, @Nullable View convertView, @NonNull ViewGroup parent) {
-
-            Log.d("_LIST","running  tid="+Thread.currentThread().getId());
-            long timeStart = System.currentTimeMillis();
-
-            final Bundle item = task_arr.get(position);
-//            Bundle taskinfo = item.getBundle("params");
-//            String barcode = taskinfo.getString("barcode");
-
-            RAUploadManager.TaskStatus istatus = RAUploadManager.TaskStatus.values()[item.getInt("status",0)];
-            String status="";
-            switch(istatus)
-            {
-                case TaskStatusStart:
-                    status="uploading";
-                    break;
-                case TaskStatusStop:
-                    status="stop";
-                    break;
-                case TaskStatusError:
-                    status="warning";
-                    break;
-                case TaskStatusWait:
-                    status="waiting";
-                    break;
-                case TaskStatusFinish:
-                    status="finish";
-                    break;
-
-                default:
-                    status="warning";
-                    break;
-            }
-            double percent = item.getDouble("progress",(double)item.getInt("progress",0));
-            String err = item.getString("msg");
-            String name = item.getString("file","");
-
-            View cell;
-            ViewHolder holder;
-            if (convertView != null) {
-
-                cell = convertView;
-                holder = (ViewHolder)cell.getTag();
-                Log.d("_LIST", "getView: " + holder);
-
-            } else {
-//                cell = LayoutInflater.from(getApplicationContext()).inflate(resourceId,null);
-                cell = View.inflate(getApplicationContext(), R.layout.upload_list_cell, null);
-                holder = new ViewHolder();
-                holder.name_tv = (TextView) cell.findViewById(R.id.upload_name_tv);
-                holder.progressBar = (ProgressBar) cell.findViewById(R.id.upload_progressBar);
-                holder.state_tv = (TextView) cell.findViewById(R.id.upload_state_tv);
-                holder.progress_tv = (TextView) cell.findViewById(R.id.upload_progress_tv);
-                holder.err_tv = (TextView) cell.findViewById(R.id.upload_err_tv);
-                holder.btn_reload = (ImageButton) cell.findViewById(R.id.btn_reload);
-                cell.setTag(holder);
-            }
-                holder.btn_reload.setImageResource(R.drawable.ic_action_reload);
-                if(istatus!= RAUploadManager.TaskStatus.TaskStatusError&& istatus!= RAUploadManager.TaskStatus.TaskStatusStop)
-                {
-                    holder.btn_reload.setVisibility(View.GONE);
-                }
-                else
-                {
-                    holder.btn_reload.setVisibility(View.VISIBLE);
-                    Log.d("_LIST", "new listener: position" + position);
-                    holder.btn_reload.setOnClickListener(new View.OnClickListener() {
-                        @Override
-                        public void onClick(View v) {
+        else
+        {
+            holder.btn_reload.setVisibility(View.VISIBLE);
+            Log.d("_LIST", "new listener: position" + position);
+            holder.btn_reload.setOnClickListener(new View.OnClickListener() {
+                @Override
+                public void onClick(View v) {
 
 
-                            Bundle task = task_arr.get(position);
+                    Bundle task = getItem(position);
 
-                            Log.d("_LIST", "retry: " + task.getString("file","file is null") +"position" + position);
+                    Log.d("_LIST", "retry: " + task.getString("file","file is null") +"position" + position);
 
 
+                    ConnectivityManager connManager = (ConnectivityManager) RedAntApplication.getInstance().getSystemService(Context.CONNECTIVITY_SERVICE);
 
-//                            boolean canstart = true;
-
-                            ConnectivityManager connManager = (ConnectivityManager) RedAntApplication.getInstance()
-                                    .getSystemService(Context.CONNECTIVITY_SERVICE);
+                    NetworkInfo networkInfo = connManager.getActiveNetworkInfo();
+                    if (networkInfo == null)
+                    {
+                        dbgUtil.Logd(
+                                "Current Network info",
+                                "can not get Active NetworkInfo!");
+//                                canstart = false;
+                        Toast toast = Toast.makeText(getApplicationContext(),
+                                "No available network. Please try upload manually later.",
+                                Toast.LENGTH_LONG);
+                        toast.setGravity(Gravity.CENTER, 0, 0);
+                        toast.show();
+                        return;
+                    }
+                    else
+                    {
+                        NetworkInfo.State netState = networkInfo
+                                .getState();
+                        if (netState != NetworkInfo.State.CONNECTED)
+                        {
+                            dbgUtil.Logd(
+                                    "Current Network info",
+                                    "not Connected!State="
+                                            + netState);
+//                                    canstart = false;
 
-                            NetworkInfo networkInfo = connManager
-                                    .getActiveNetworkInfo();
-                            if (networkInfo == null)
+                            Toast toast = Toast.makeText(getApplicationContext(),
+                                    "App network connection. Please try upload manually later.",
+                                    Toast.LENGTH_LONG);
+                            toast.setGravity(Gravity.CENTER, 0, 0);
+                            toast.show();
+                            return;
+                        }
+                        else
+                        {
+                            int iconntype = -1;
+                            iconntype = networkInfo
+                                    .getType();
+
+                            SharedPreferences pref = RedAntApplication
+                                    .getInstance()
+                                    .getSharedPreferences(
+                                            "UploadManager",
+                                            0);
+                            boolean
+                                    wifi_only
+                                    =pref.getBoolean("wifi_only",
+                                    false);
+                            if(wifi_only == true
+                                    && iconntype !=
+                                    ConnectivityManager.TYPE_WIFI
+                                    && iconntype !=
+                                    9/* earthnet */)
                             {
-                                dbgUtil.Logd(
-                                        "Current Network info",
-                                        "can not get Active NetworkInfo!");
-//                                canstart = false;
+//                                    canstart = false;
+
                                 Toast toast = Toast.makeText(getApplicationContext(),
-                                        "No available network. Please try upload manually later.",
+                                        "App is set to upload via WIFI only. Please change your setting or try upload manually later.",
                                         Toast.LENGTH_LONG);
                                 toast.setGravity(Gravity.CENTER, 0, 0);
                                 toast.show();
                                 return;
                             }
-                            else
-                            {
-                                NetworkInfo.State netState = networkInfo
-                                        .getState();
-                                if (netState != NetworkInfo.State.CONNECTED)
-                                {
-                                    dbgUtil.Logd(
-                                            "Current Network info",
-                                            "not Connected!State="
-                                                    + netState);
-//                                    canstart = false;
-
-                                    Toast toast = Toast.makeText(getApplicationContext(),
-                                            "App network connection. Please try upload manually later.",
-                                            Toast.LENGTH_LONG);
-                                    toast.setGravity(Gravity.CENTER, 0, 0);
-                                    toast.show();
-                                    return;
-                                }
-                                else
-                                {
-                                    int iconntype = -1;
-                                    iconntype = networkInfo
-                                            .getType();
-
-                                    SharedPreferences pref = RedAntApplication
-                                            .getInstance()
-                                            .getSharedPreferences(
-                                                    "UploadManager",
-                                                    0);
-                                    boolean
-                                            wifi_only
-                                            =pref.getBoolean("wifi_only",
-                                            false);
-                                    if(wifi_only == true
-                                            && iconntype !=
-                                            ConnectivityManager.TYPE_WIFI
-                                            && iconntype !=
-                                            9/* earthnet */)
-                                    {
-//                                    canstart = false;
-
-                                        Toast toast = Toast.makeText(getApplicationContext(),
-                                                "App is set to upload via WIFI only. Please change your setting or try upload manually later.",
-                                                Toast.LENGTH_LONG);
-                                        toast.setGravity(Gravity.CENTER, 0, 0);
-                                        toast.show();
-                                        return;
-                                    }
-                                }
+                        }
 
-                            }
-//                            if(!canstart)
-//                            {
-//                                Toast toast = Toast.makeText(getApplicationContext(),
-//                                        "App is set to upload via WIFI only. Please change your setting or try upload manually later.",
-//                                        Toast.LENGTH_LONG);
-//                                toast.setGravity(Gravity.CENTER, 0, 0);
-//                                toast.show();
-//                                return;
-//                            }
-
-                            v.setVisibility(View.GONE);
-                            uploadManager.startTask(task);
+                    }
 
-                        }
-                    });
+                    v.setVisibility(View.GONE);
+                    startTask(task);
                 }
+            });
+        }
 
 
 
-            holder.name_tv.setText(name);
+        holder.name_tv.setText(name);
 //            holder.progressBar.setProgress(100 *(int)percent);
-            holder.progressBar.setProgress((int) (100 * percent));
-            holder.state_tv.setText(status);
+        holder.progressBar.setProgress((int) (100 * percent));
+        holder.state_tv.setText(status);
 //            holder.progress_tv.setText(100*percent+"%");
-            holder.progress_tv.setText(String.format("%.2f%%",100*percent));
-            holder.err_tv.setText(err);
+        holder.progress_tv.setText(String.format("%.2f%%",100*percent));
+        holder.err_tv.setText(err);
 
 
 
-            Log.d("_LIST", "getView(): POSITION   "+position+" file   " + item.getString("file","no file"));
-            return cell;
-        }
+        Log.d("_LIST", "getView(): POSITION   "+position+" file   " + item.getString("file","no file"));
+        return cell;
+    }
 
-        private class ViewHolder {
-            public TextView name_tv;
-            public ProgressBar progressBar;
-            public TextView state_tv;
-            public TextView progress_tv;
-            public TextView err_tv;
-            public ImageButton btn_reload;
-        }
+    private class ViewHolder {
+        public TextView name_tv;
+        public ProgressBar progressBar;
+        public TextView state_tv;
+        public TextView progress_tv;
+        public TextView err_tv;
+        public ImageButton btn_reload;
     }
 }

+ 0 - 617
ApexDrivers/raimage/src/main/java/com/usai/redant/raimage/UploadList/UploadListActivity.java

@@ -1,617 +0,0 @@
-package com.usai.redant.raimage.UploadList;
-
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.content.ServiceConnection;
-import android.os.Bundle;
-import android.os.IBinder;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import android.support.v7.app.ActionBar;
-import android.support.v7.app.AlertDialog;
-import android.support.v7.app.AppCompatActivity;
-import android.util.Log;
-import android.util.TypedValue;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.BaseAdapter;
-import android.widget.ImageButton;
-import android.widget.ListView;
-import android.widget.ProgressBar;
-import android.widget.TextView;
-
-import com.usai.redant.raimage.R;
-import com.usai.redant.raimage.UploadService;
-import com.usai.util.RAUploadManager;
-
-import java.util.ArrayList;
-
-//import com.usai.redant.raimage.UploadList.swipemenulistview.SwipeMenu;
-//import com.usai.redant.raimage.UploadList.swipemenulistview.SwipeMenuCreator;
-//import com.usai.redant.raimage.UploadList.swipemenulistview.SwipeMenuItem;
-//import com.usai.redant.raimage.UploadList.swipemenulistview.SwipeMenuListView;
-
-public class UploadListActivity extends AppCompatActivity {
-
-
-    private ArrayList<Bundle> displaylist = new ArrayList<Bundle>();
-
-    //    private SwipeMenuListView uploadList;
-    private ListView uploadList;
-    private uploadAdapter adapter;
-//    private ArrayList<Bundle> arr;
-
-    private RAUploadManager uploadManager;
-    private UploadService.MyBinder binder;
-    private UploadService uploadServiceservice;
-    private boolean serviceConnectionFlag = false; // 绑定服务标识
-    private ServiceConnection serviceConnection;
-    private RAUploadManager.UIUpdateListener uiUpdateListener = new RAUploadManager.UIUpdateListener() {
-//        @Override
-//        public void onProgress(long index, double percentage) {
-//
-//
-//            if(true)
-//            return;
-//
-//            final int position = (int)index;
-//            final double progress = percentage;
-//            runOnUiThread(new Runnable() {
-//                @Override
-//                public void run() {
-//                    Log.d("_LIST", "UploadImage onProgress: " + progress);
-//                    long timeStart = System.currentTimeMillis();
-////            Object item = uploadList.getItemAtPosition((int) index);
-//                    int startShowIndex = uploadList.getFirstVisiblePosition();
-//                    int lastShowIndex = uploadList.getLastVisiblePosition();
-//
-//                    if (position >= startShowIndex && position <= lastShowIndex) {
-//                        View cell = uploadList.getChildAt((int)position - startShowIndex);
-//                        uploadAdapter.ViewHolder holder= (uploadAdapter.ViewHolder)cell.getTag();
-//                        holder.progressBar.setProgress((int) (100 * progress));
-//                        holder.progress_tv.setText(String.format("%.1f%%",progress * 100));
-//                    }
-//
-//                    Log.d("_LIST", "UploadImage onProgress: end" + (System.currentTimeMillis() - timeStart));
-//                }
-//            });
-//
-//        }
-
-        @Override
-        public void updateCell(long index, final Bundle taskinfo)
-        {
-            if(true)
-                return;
-
-            if(true) {
-
-                runOnUiThread(new Runnable() {
-                    @Override
-                    public void run() {
-
-                        adapter.notifyDataSetChanged();
-                    }
-                });
-
-                return;
-            }
-
-            final int position = (int)index;
-//            final double progress = arr.get(position).getDouble("progress");
-            runOnUiThread(new Runnable() {
-                @Override
-                public void run() {
-
-                    double percent = taskinfo.getDouble("progress",0);
-
-//                    Log.d("_synchronized", "UploadImage onProgress: " + percent);
-                    long timeStart = System.currentTimeMillis();
-
-//            Object item = uploadList.getItemAtPosition((int) index);
-                    int startShowIndex = uploadList.getFirstVisiblePosition();
-                    int lastShowIndex = uploadList.getLastVisiblePosition();
-
-                    if (position >= startShowIndex && position <= lastShowIndex) {
-                        View cell = uploadList.getChildAt((int)position - startShowIndex);
-                        uploadAdapter.ViewHolder holder= (uploadAdapter.ViewHolder)cell.getTag();
-//                        holder.progressBar.setProgress((int) (100 * progress));
-//                        holder.progress_tv.setText(String.format("%.1f%%",progress * 100));
-
-
-                        RAUploadManager.TaskStatus istatus = RAUploadManager.TaskStatus.values()[taskinfo.getInt("status",0)];
-                        String status="";
-                        switch(istatus)
-                        {
-                            case TaskStatusStart:
-                                status="uploading";
-                                break;
-                            case TaskStatusStop:
-                                status="stop";
-                                break;
-                            case TaskStatusError:
-                                status="warning";
-                                break;
-                            case TaskStatusWait:
-                                status="waiting";
-                                break;
-                            case TaskStatusFinish:
-                                status="finish";
-                                break;
-
-                            default:
-                                status="warning";
-                                break;
-                        }
-
-
-                        Log.d("_LIST", "uploadlist UI update POSITION"+position +"    PROGRESS"+ percent*100);
-
-                        String err = taskinfo.getString("msg");
-                        String name = taskinfo.getString("file","");
-                        holder.name_tv.setText(name);
-                        holder.progressBar.setProgress((int)(100 *percent));
-                        holder.state_tv.setText(status);
-
-                        holder.progress_tv.setText(String.format("%.2f%%",100*percent));
-                        holder.err_tv.setText(err);
-                    }
-
-                    Log.d("_LIST", "uploadlist UI: COST" + (System.currentTimeMillis() - timeStart));
-                }
-            });
-        }
-        @Override
-//        public void updateList()
-        public void updateList(final ArrayList<Bundle> newlist)
-        {
-
-
-            runOnUiThread(new Runnable() {
-                @Override
-                public void run() {
-
-                    Log.d("_LIST","running  tid="+Thread.currentThread().getId());
-                    Log.d("_LIST", "uploadlist UI  size:  "+ newlist.size());
-                    long timeStart = System.currentTimeMillis();
-                    displaylist = (ArrayList<Bundle>) newlist.clone();
-                    adapter.notifyDataSetChanged();
-
-
-                    Log.d("_LIST", "uploadlist UI: COST" + (System.currentTimeMillis() - timeStart));
-                }
-            });
-
-        }
-    };
-
-    @Override
-    protected void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-        setContentView(R.layout.activity_upload_list);
-
-        ActionBar mActionBar = getSupportActionBar();
-        mActionBar.setHomeButtonEnabled(true);
-        mActionBar.setDisplayHomeAsUpEnabled(true);
-        mActionBar.setTitle("RA Image");
-
-
-        // 初始化视图
-//        uploadList = (SwipeMenuListView)findViewById(R.id.upload_list);
-        uploadList = (ListView)findViewById(R.id.upload_list);
-        adapter = new uploadAdapter(R.layout.upload_list_cell);
-        uploadList.setAdapter(adapter);
-        serviceConnection = new ServiceConnection() {
-            @Override
-            public void onServiceConnected(ComponentName name, IBinder service) {
-                serviceConnectionFlag = true;
-
-                binder = (UploadService.MyBinder)service;
-                uploadServiceservice = binder.getService();
-
-
-
-
-                uploadManager = uploadServiceservice.uploadManager;
-                uploadManager.uiUpdateListener = uiUpdateListener;
-                displaylist = (ArrayList<Bundle>) uploadManager.get_arr_queue().clone(); //uploadManager.arr_queue;
-
-
-
-//                adapter.notifyDataSetChanged();
-//                runOnUiThread(new Runnable() {
-//                    @Override
-//                    public void run() {
-//                        adapter = new uploadAdapter(R.layout.upload_list_cell);
-//                        uploadList.setAdapter(adapter);
-//                    }
-//                });
-            }
-
-            @Override
-            public void onServiceDisconnected(ComponentName name) {
-                serviceConnectionFlag = false;
-                uploadManager.uiUpdateListener = null;
-            }
-        };
-
-        bindService();
-
-//        SwipeMenuCreator creator = new SwipeMenuCreator() {
-//
-//            @Override
-//            public void create(SwipeMenu menu) {
-//                // Create different menus depending on the view type
-//                switch (menu.getViewType()) {
-//                    case 0: {
-//                        createRemoveMenuItem(menu);
-//                    }
-//                    break;
-//                    case 1: {
-//                        createStartMenuItem(menu);
-//                        createRemoveMenuItem(menu);
-//                    }
-//                    break;
-//                    case 2: {
-//                        createStartMenuItem(menu);
-//                    }
-//                    break;
-//                    case 3: {
-//
-//                    }
-//                    break;
-//                }
-//            }
-//        };
-//
-//        uploadList.setMenuCreator(creator);
-//
-//        uploadList.setOnMenuItemClickListener(new SwipeMenuListView.OnMenuItemClickListener() {
-//            @Override
-//            public boolean onMenuItemClick(int position, SwipeMenu menu, int index) {
-//                // action
-//                Bundle item = arr.get(position);
-//                int type = taskSwipeType(position);
-//                switch (type) {
-//                    case 0: {
-//                        if (index == 0) {
-//                            // remove
-//                            if (serviceConnectionFlag == true && uploadServiceservice != null) {
-//                                uploadManager.removeTask(item);
-//                            }
-//
-//                        }
-//                    }
-//                    break;
-//                    case 1: {
-//                        if (index == 0) {
-//                            // start
-//                            if (serviceConnectionFlag == true && uploadServiceservice != null) {
-//                                uploadManager.startTask(item);
-//                            }
-//
-//                        } else if (index == 1) {
-//                            // remove
-//                            if (serviceConnectionFlag == true && uploadServiceservice != null) {
-//                                uploadManager.removeTask(item);
-//                            }
-//
-//                        }
-//                    }
-//                    break;
-//                    case 2: {
-//                        if (index == 0) {
-//                            // start
-//                            if (serviceConnectionFlag == true && uploadServiceservice != null) {
-//                                uploadManager.startTask(item);
-//                            }
-//
-//                        }
-//                    }
-//                    break;
-//                    case 3: {
-//
-//                    }
-//                    break;
-//                }
-//
-//                return false;
-//            }
-//        });
-    }
-
-//    private void createRemoveMenuItem(SwipeMenu menu) {
-//        SwipeMenuItem openItem = new SwipeMenuItem(getApplicationContext());
-//        // set item background
-//        openItem.setBackground(new ColorDrawable(Color.rgb(0x9b, 0xbf,0x5a)));
-//        // set item width
-//        openItem.setWidth(dp2px(90));
-//        // set item title
-//        openItem.setTitle("Remove");
-//        // set item title fontsize
-//        openItem.setTitleSize(18);
-//        // set item title font color
-//        openItem.setTitleColor(Color.WHITE);
-//        // add to menu
-//        menu.addMenuItem(openItem);
-//    }
-//
-//    private void createStartMenuItem(SwipeMenu menu) {
-//        SwipeMenuItem openItem = new SwipeMenuItem(getApplicationContext());
-//        // set item background
-//        openItem.setBackground(new ColorDrawable(Color.rgb(0xff, 0x99,0x33)));
-//        // set item width
-//        openItem.setWidth(dp2px(90));
-//        // set item title
-//        openItem.setTitle("Restart");
-//        // set item title fontsize
-//        openItem.setTitleSize(18);
-//        // set item title font color
-//        openItem.setTitleColor(Color.WHITE);
-//        // add to menu
-//        menu.addMenuItem(openItem);
-//    }
-
-    @Override
-    protected void onDestroy() {
-
-        unbindService(serviceConnection);
-
-        super.onDestroy();
-    }
-
-    @Override
-    public boolean onCreateOptionsMenu(Menu menu) {
-        getMenuInflater().inflate(R.menu.upload_list_menu,menu);
-        return true;
-    }
-
-    @Override
-    public boolean onOptionsItemSelected(MenuItem item) {
-        switch (item.getItemId()) {
-            case android.R.id.home: {
-                finish();
-            }
-            break;
-            case R.id.clear_upload_list_btn: {
-//                for(int i=0;i<10;i++)
-//                runOnUiThread(new Runnable() {
-//                    @Override
-//                    public void run() {
-//
-//                        Log.d("_LIST","running  tid="+Thread.currentThread().getId());
-//                        Log.d("_LIST", "uploadlist UI  size:  "+ displaylist.size());
-//                        long timeStart = System.currentTimeMillis();
-////                        displaylist = (ArrayList<Bundle>) newlist.clone();
-//                        adapter.notifyDataSetChanged();
-//
-//
-//                        Log.d("_LIST", "uploadlist UI: COST" + (System.currentTimeMillis() - timeStart));
-//                    }
-//                });
-                clearUploadList();
-            }
-            break;
-        }
-        return true;
-    }
-
-    private void clearUploadList() {
-        if (displaylist.size() == 0) {
-            new AlertDialog.Builder(this)
-                    .setTitle("Warning")
-                    .setMessage("Upload list is empty.")
-                    .setPositiveButton("OK",null)
-                    .show();
-            return;
-        }
-
-        new AlertDialog.Builder(this)
-                .setTitle("Clear upload list")
-                .setMessage("Are you sure remove all error/finish task?")
-                .setPositiveButton("YES", new DialogInterface.OnClickListener() {
-                    @Override
-                    public void onClick(DialogInterface dialog, int which) {
-                        // clear
-                        if (serviceConnectionFlag == true && uploadServiceservice != null) {
-                            uploadManager.clearTask();
-//                            adapter.notifyDataSetChanged();
-                        }
-
-                    }
-                })
-                .setNegativeButton("NO", new DialogInterface.OnClickListener() {
-                    @Override
-                    public void onClick(DialogInterface dialog, int which) {
-
-                    }
-                })
-                .show();
-
-    }
-
-//
-//    private int taskSwipeType(int position) {
-//        Bundle item = arr.get(position);
-////        Bundle taskinfo = item.getBundle("params");
-//        RAUploadManager.TaskStatus istatus = RAUploadManager.TaskStatus.values()[item.getInt("status",0)];
-//        int type = 3;
-//        switch(istatus)
-//        {
-//            case TaskStatusWait:
-//            case TaskStatusStart:
-//                type = 3;
-//                break;
-//            case TaskStatusStop:
-//                type = 2;
-//                break;
-//            case TaskStatusError:
-//                type = 1;
-//                break;
-//            case TaskStatusFinish:
-//                type = 0;
-//                break;
-//            default:
-//                type = 3;
-//                break;
-//        }
-//        return type;
-//    }
-
-    private class uploadAdapter extends BaseAdapter {
-        private int resourceId;
-        public uploadAdapter(int resourceID) {
-
-            resourceId = resourceID;
-        }
-
-        @Override
-        public int getCount() {
-            return displaylist.size();
-        }
-
-        @Override
-        public Bundle getItem(int position) {
-            return displaylist.get(position);
-        }
-
-        @Override
-        public long getItemId(int position) {
-            return position;
-        }
-
-//        @Override
-//        public int getViewTypeCount() {
-//            return 4;
-//        }
-//
-//        @Override
-//        public int getItemViewType(int position) {
-//            /**
-//             * 0. <finish>      remove              </finish>
-//             * 1. <error>       start  remove       </error>
-//             * 2. <stop>        start               </stop>
-//             * 3. <start\wait>  none                </start\wait>
-//             * */
-//            return taskSwipeType(position);
-//        }
-
-        @NonNull
-        @Override
-        public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
-
-            Log.d("_LIST","running  tid="+Thread.currentThread().getId());
-            long timeStart = System.currentTimeMillis();
-
-            final Bundle item = displaylist.get(position);
-//            Bundle taskinfo = item.getBundle("params");
-//            String barcode = taskinfo.getString("barcode");
-
-            RAUploadManager.TaskStatus istatus = RAUploadManager.TaskStatus.values()[item.getInt("status",0)];
-            String status="";
-            switch(istatus)
-            {
-                case TaskStatusStart:
-                    status="uploading";
-                    break;
-                case TaskStatusStop:
-                    status="stop";
-                    break;
-                case TaskStatusError:
-                    status="warning";
-                    break;
-                case TaskStatusWait:
-                    status="waiting";
-                    break;
-                case TaskStatusFinish:
-                    status="finish";
-                    break;
-
-                default:
-                    status="warning";
-                    break;
-            }
-            double percent = item.getDouble("progress",0);
-            String err = item.getString("msg");
-            String name = item.getString("file","");
-
-            View cell;
-            ViewHolder holder;
-            if (convertView != null) {
-
-                cell = convertView;
-                holder = (ViewHolder)cell.getTag();
-                Log.d("_LIST", "getView: " + holder);
-
-            } else  {
-//                cell = LayoutInflater.from(getApplicationContext()).inflate(resourceId,null);
-                cell = View.inflate(getApplicationContext(),resourceId,null);
-                holder = new ViewHolder();
-                holder.name_tv = (TextView)cell.findViewById(R.id.upload_name_tv);
-                holder.progressBar = (ProgressBar)cell.findViewById(R.id.upload_progressBar);
-                holder.state_tv = (TextView)cell.findViewById(R.id.upload_state_tv);
-                holder.progress_tv = (TextView)cell.findViewById(R.id.upload_progress_tv);
-                holder.err_tv = (TextView)cell.findViewById(R.id.upload_err_tv);
-                holder.btn_reload=(ImageButton) cell.findViewById(R.id.btn_reload);
-
-
-                holder.btn_reload.setImageResource(R.drawable.ic_action_reload);
-                if(istatus!= RAUploadManager.TaskStatus.TaskStatusError)
-                {
-                    holder.btn_reload.setVisibility(View.GONE);
-                }
-                else
-                {
-                    holder.btn_reload.setVisibility(View.VISIBLE);
-                    holder.btn_reload.setOnClickListener(new View.OnClickListener() {
-                        @Override
-                        public void onClick(View v) {
-
-                            uploadManager.startTask(item);
-
-                        }
-                    });
-                }
-                cell.setTag(holder);
-            }
-
-            holder.name_tv.setText(name);
-//            holder.progressBar.setProgress(100 *(int)percent);
-            holder.progressBar.setProgress((int) (100 * percent));
-            holder.state_tv.setText(status);
-//            holder.progress_tv.setText(100*percent+"%");
-            holder.progress_tv.setText(String.format("%.2f%%",100*percent));
-            holder.err_tv.setText(err);
-
-
-
-            Log.d("_LIST", "getView(): POSITION   "+position+" COST   " + (System.currentTimeMillis() - timeStart));
-            return cell;
-        }
-
-        private class ViewHolder {
-            public TextView name_tv;
-            public ProgressBar progressBar;
-            public TextView state_tv;
-            public TextView progress_tv;
-            public TextView err_tv;
-            public ImageButton btn_reload;
-        }
-    }
-
-
-    /** Service */
-    private void bindService() {
-        Intent intent = new Intent(UploadListActivity.this, UploadService.class);
-
-        bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE);
-    }
-
-    private int dp2px(int dp) {
-        return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp,getResources().getDisplayMetrics());
-    }
-}

+ 0 - 548
ApexDrivers/raimage/src/main/java/com/usai/redant/raimage/UploadService.java

@@ -1,548 +0,0 @@
-package com.usai.redant.raimage;
-
-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.util.RAUploadManager;
-import com.usai.util.dbgUtil;
-
-import java.util.ArrayList;
-
-public class UploadService extends Service
-{
-
-//	private UploadThread	uploadThread;
-
-    private boolean queue_changed = false;
-//	LocationManager			locationManager;
-//	LocationListener		locationListener;
-
-    public RAUploadManager uploadManager = new RAUploadManager();
-
-    // 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("============================ app crash ============================");
-                dbgUtil.fileLog("DEVICE");
-                dbgUtil.fileLog(deviceInfo);
-                dbgUtil.fileLog("EXCEPTION");
-                dbgUtil.fileLog(exception);
-                dbgUtil.fileLog("=============================== 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 = RedAntApplication
-                            .getInstance()
-                            .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;
-                    }
-                }
-
-
-            }
-        }
-    };
-}

+ 27 - 76
ApexDrivers/raimage/src/main/java/com/usai/redant/raimage/uploadSettingActivity.java

@@ -1,12 +1,7 @@
 package com.usai.redant.raimage;
 
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.content.ServiceConnection;
 import android.content.SharedPreferences;
 import android.os.Bundle;
-import android.os.IBinder;
 import android.support.v7.app.ActionBar;
 import android.support.v7.app.AppCompatActivity;
 import android.view.Menu;
@@ -14,48 +9,41 @@ import android.view.MenuItem;
 import android.widget.EditText;
 import android.widget.Switch;
 
-import com.usai.util.RAUploadManager;
+import com.usai.redant.rautils.upload.RAUploadManager;
 
 public class uploadSettingActivity extends AppCompatActivity {
 
 //    private Switch auto_start_swt;
 //    private Switch auto_rm_fs_swt;
+
 //    private Switch auto_rm_er_swt;
     private Switch compress_swt;
     private Switch sw_wifiOnly;
     private EditText retry_count_et;
     private EditText retry_waiting_et;
 
-    private ServiceConnection serviceConnection;
-    private boolean serviceConnectionFlag = false; // 绑定服务标识
-    private UploadService.MyBinder binder;
-    private UploadService uploadServiceservice;
 
     public void initSetting() {
+
+
+
 //        boolean auto_upload = true;
 //        boolean auto_rm_fs = true;
 //        boolean auto_rm_er = false;
         boolean compress = true;
-
         boolean wifionly = false;
         int retry_count = 5;
-
         int retry_waiting = 300;
-//        SharedPreferences preferences = getSharedPreferences("uploadSetting", Context.MODE_PRIVATE);
-        SharedPreferences preferences = RedAntApplication.getInstance().getSharedPreferences("UploadManager", 0);
-        if (preferences != null) {
 
-//            auto_upload = preferences.getBoolean("auto_upload",true);
-//            auto_rm_fs = preferences.getBoolean("auto_rm_finish",true);
-//            auto_rm_er = preferences.getBoolean("auto_rm_error",false);
-
-            wifionly = preferences.getBoolean("wifi_only",false);
-            compress = preferences.getBoolean("compress",true);
-            retry_count = preferences.getInt("retry_count",5);
-            retry_waiting = preferences.getInt("retry_waiting",300);
+        RAUploadManager.RAUploadManagerConfigure configure = RAUploadManager.configure(getApplicationContext());
 
-        } else  {
+        wifionly = configure.wifiOnly;
+        retry_count = configure.maxRetry;
+        retry_waiting = configure.retryWaiting;
 
+        SharedPreferences preferences = RedAntApplication.getInstance().getSharedPreferences("UploadManager", 0);
+        if (preferences != null) {
+            compress = preferences.getBoolean("compress",true);
         }
 
 
@@ -73,48 +61,35 @@ public class uploadSettingActivity extends AppCompatActivity {
         retry_waiting_et.setSelection(retry_waiting_et.getText().length());
     }
 
-    /** Service */
-    private void bindService() {
-        Intent intent = new Intent(uploadSettingActivity.this, UploadService.class);
-
-        bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE);
-    }
 
     public void saveSetting() {
 
-//        SharedPreferences preferences = getSharedPreferences("uploadSetting",Context.MODE_PRIVATE);
-        SharedPreferences preferences = RedAntApplication.getInstance().getSharedPreferences("UploadManager", 0);
-        SharedPreferences.Editor editor = preferences.edit();
 
 //        final boolean auto_upload = auto_start_swt.isChecked();
 //        final boolean auto_rm_fs = auto_rm_fs_swt.isChecked();
 //        final boolean auto_rm_er = auto_rm_er_swt.isChecked();
 
-        final boolean wifi_only = sw_wifiOnly.isChecked();
         boolean compress = compress_swt.isChecked();
+        final boolean wifi_only = sw_wifiOnly.isChecked();
         final int retry_count = Integer.parseInt(retry_count_et.getText().toString());
         final int retry_waiting = Integer.parseInt(retry_waiting_et.getText().toString());
 
-//        editor.putBoolean("auto_upload",auto_upload);
-//        editor.putBoolean("auto_rm_finish",auto_rm_fs);
-//        editor.putBoolean("auto_rm_error",auto_rm_er);
+
+        SharedPreferences preferences = RedAntApplication.getInstance().getSharedPreferences("UploadManager", 0);
+        SharedPreferences.Editor editor = preferences.edit();
+
         editor.putBoolean("compress",compress);
-        editor.putInt("retry_count",retry_count);
-        editor.putInt("retry_waiting",retry_waiting);
-        editor.putBoolean("wifi_only",wifi_only);
-
-        editor.commit();
-
-        if (serviceConnectionFlag == true && uploadServiceservice != null) {
-            RAUploadManager uploadManager = uploadServiceservice.uploadManager;
-//            uploadManager.autoStart = auto_upload;
-//            uploadManager.removeFinish = auto_rm_fs;
-//            uploadManager.removeError = auto_rm_er;
-            uploadManager.maxRetry = retry_count;
-            uploadManager.retryWaiting = retry_waiting;
-            uploadManager.wifiOnly = wifi_only;
-        }
+        editor.apply();
 
+        RAUploadManager.configureUploadManager(getApplicationContext(), new RAUploadManager.configureBlock() {
+            @Override
+            public void configure(RAUploadManager.RAUploadManagerConfigure configure) {
+
+                configure.wifiOnly = wifi_only;
+                configure.maxRetry = retry_count;
+                configure.retryWaiting = retry_waiting;
+            }
+        });
     }
 
     @Override
@@ -122,24 +97,6 @@ public class uploadSettingActivity extends AppCompatActivity {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.activity_upload_setting);
 
-        // 同时修改 Upload Manager
-        serviceConnection = new ServiceConnection() {
-            @Override
-            public void onServiceConnected(ComponentName name, IBinder service) {
-                serviceConnectionFlag = true;
-
-                binder = (UploadService.MyBinder)service;
-                uploadServiceservice = binder.getService();
-
-            }
-
-            @Override
-            public void onServiceDisconnected(ComponentName name) {
-                serviceConnectionFlag = false;
-            }
-        };
-
-        bindService();
 
 
         sw_wifiOnly = (Switch)findViewById(R.id.sw_wifyonly);
@@ -158,12 +115,6 @@ public class uploadSettingActivity extends AppCompatActivity {
         mActionBar.setTitle("RA Image");
     }
 
-    @Override
-    protected void onDestroy() {
-        unbindService(serviceConnection);
-        super.onDestroy();
-    }
-
     @Override
     public boolean onSupportNavigateUp() {
         return super.onSupportNavigateUp();

+ 80 - 0
ApexDrivers/raimage/src/main/java/com/usai/service/RAImageBackgroundService.java

@@ -0,0 +1,80 @@
+package com.usai.service;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.net.NetworkInfo;
+
+import com.usai.redant.raimage.RedAntApplication;
+
+import com.usai.redant.rautils.service.RAService;
+import com.usai.redant.rautils.upload.RAUploadManager;
+import com.usai.redant.rautils.utils.dbgUtil;
+
+
+public class RAImageBackgroundService extends RAService implements RAService.ServiceUpload{
+
+    public RAImageBackgroundService() {
+
+    }
+
+    private BroadcastReceiver serviceReceiver = new BroadcastReceiver() {
+        @Override
+        public void onReceive(Context context, Intent intent) {
+
+            String action = intent.getAction();
+            if (action.equals(RAUploadManager.UPLOAD_COUNT_CHANGED_NOTIFICATION)) {
+
+                sendUploadCountChangeNotification();
+
+            } else if (action.equals(RAUploadManager.UPLOAD_FINISH_TASK_NOTIFICATION)) {
+
+                sendUploadCountChangeNotification();
+            }
+        }
+    };
+
+    private void sendUploadCountChangeNotification() {
+
+    }
+
+    public int getUploadCount() {
+
+        return getUploadManager().get_arr_queue().size();
+    }
+
+    @Override
+    protected void Setup() {
+
+        CHANNEL_ID = RedAntApplication.CHANNEL_ID;
+        CHANNEL_NAME = RedAntApplication.CHANNEL_NAME;
+
+        RAUploadManager.configureUploadManager(getApplicationContext(), new RAUploadManager.configureBlock() {
+            @Override
+            public void configure(RAUploadManager.RAUploadManagerConfigure configure) {
+
+                configure.removeFinish = true;
+            }
+        });
+
+        initServiceUpload(this);
+        initServiceNetworkReachability(new ServiceNetworkReachabilityCallback() {
+            @Override
+            public void networkStateChanged(NetworkInfo networkInfo) {
+
+            }
+        });
+
+        dbgUtil.fileLog(this,"RAImageBackgroundService Setup()");
+
+        IntentFilter intentFilter = new IntentFilter();
+        intentFilter.addAction(RAUploadManager.UPLOAD_COUNT_CHANGED_NOTIFICATION);
+        intentFilter.addAction(RAUploadManager.UPLOAD_FINISH_TASK_NOTIFICATION);
+
+        registerReceiver(serviceReceiver,intentFilter);
+    }
+
+
+
+}

+ 5 - 5
ApexDrivers/raimage/src/main/java/com/usai/util/Network.java

@@ -113,11 +113,11 @@ public class Network
 	public static final int		STATUS_WAIT						= -17;
 	static String				URL_UPLOAD_PHOTO				= "handset.php";
 	@Deprecated
-	static String				URL_VERIFY_USER					= "handset_login.php";
-	static String				URL_LOGIN					= "index.php?_action=handset_new";
-	static String				URL_UPLOAD					= "index.php?_action=handset_new";
-	static String				URL_VERIFY_CODE					= "index.php?_action=handset_new";
-	static String				URL_QUERY_MANUFACTURER				= "index.php?_action=handset_new";
+	public static final String				URL_VERIFY_USER					= "handset_login.php";
+	public static final String				URL_LOGIN					= "index.php?_action=handset_new";
+	public static final String				URL_UPLOAD					= "index.php?_action=handset_new";
+	public static final String				URL_VERIFY_CODE					= "index.php?_action=handset_new";
+	public static final String				URL_QUERY_MANUFACTURER				= "index.php?_action=handset_new";
 	public static class SSLSocketFactoryEx extends SSLSocketFactory
 	{
 

+ 0 - 129
ApexDrivers/raimage/src/main/java/com/usai/util/RAOperationQueue.java

@@ -1,129 +0,0 @@
-package com.usai.util;
-
-import android.content.Intent;
-import android.os.Bundle;
-import android.util.Log;
-
-import com.usai.redant.raimage.RedAntApplication;
-
-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);
-    }
-
-    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");
-                            }
-
-                            RedAntApplication.getInstance().getApplicationContext().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 - 725
ApexDrivers/raimage/src/main/java/com/usai/util/RAUploadManager.java

@@ -1,725 +0,0 @@
-package com.usai.util;
-
-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.raimage.RedAntApplication;
-
-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;
-
-import static com.usai.util.Network.URL_UPLOAD;
-
-/**
- * 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 UIUpdateListener uiUpdateListener;
-
-    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() {
-        queue_status = QueueStatus.QueueStatusDefault;
-
-
-        SharedPreferences UMSetting = RedAntApplication.getInstance()
-                .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();
-        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") + "" + URL_UPLOAD;
-
-                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.UploadImage(path, taskinfo.getBundle("params"), url, 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();
-                    RAUtil.updateGallery(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 = RedAntApplication.getInstance()
-                .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) RedAntApplication.getInstance()
-                .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();
-                RAUtil.updateGallery(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();
-                    RAUtil.updateGallery(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 = RedAntApplication.getInstance()
-                .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 = android.util.Base64.encodeToString(baos.toByteArray(), android.util.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 - 18
ApexDrivers/raimage/src/main/res/layout/activity_upload_list.xml

@@ -1,18 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:tools="http://schemas.android.com/tools"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    tools:context="com.usai.redant.raimage.UploadList.UploadListActivity">
-
-    <ListViewCompat
-        android:id="@+id/upload_list"
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        >
-
-    </ListViewCompat>
-
-
-
-</RelativeLayout>