Parcourir la source

1.修改Android Apex Driver首页刷新崩溃。
2.修改Android Apex Driver日志记录。
3.修改Android Apex Driver Setting增加调试文件查看。

Pen Li il y a 7 ans
Parent
commit
5f354a7163
19 fichiers modifiés avec 580 ajouts et 45 suppressions
  1. 33 17
      ApexDrivers/RAUtilsLibrary/src/main/AndroidManifest.xml
  2. 140 0
      ApexDrivers/RAUtilsLibrary/src/main/java/com/usai/redant/rautils/fileViewer/FileViewerActivity.java
  3. 121 0
      ApexDrivers/RAUtilsLibrary/src/main/java/com/usai/redant/rautils/fileViewer/FileViewerAdapter.java
  4. 1 1
      ApexDrivers/RAUtilsLibrary/src/main/java/com/usai/redant/rautils/receiver/AlarmReceiver.java
  5. 11 3
      ApexDrivers/RAUtilsLibrary/src/main/java/com/usai/redant/rautils/utils/FileManager.java
  6. 9 0
      ApexDrivers/RAUtilsLibrary/src/main/java/com/usai/redant/rautils/utils/RAUtil.java
  7. 5 0
      ApexDrivers/RAUtilsLibrary/src/main/res/drawable/ic_file.xml
  8. 5 0
      ApexDrivers/RAUtilsLibrary/src/main/res/drawable/ic_folder.xml
  9. 18 0
      ApexDrivers/RAUtilsLibrary/src/main/res/layout/file_viewer_activity.xml
  10. 32 0
      ApexDrivers/RAUtilsLibrary/src/main/res/layout/file_viewer_cell.xml
  11. 13 0
      ApexDrivers/apexdriversi/src/main/AndroidManifest.xml
  12. 36 0
      ApexDrivers/apexdriversi/src/main/res/xml/provider_paths.xml
  13. 9 9
      ApexDrivers/apexdriverslib/src/main/AndroidManifest.xml
  14. 11 5
      ApexDrivers/apexdriverslib/src/main/java/com/usai/redant/apexdrivers/home/HomeFragment.java
  15. 27 3
      ApexDrivers/apexdriverslib/src/main/java/com/usai/redant/apexdrivers/receiver/ApexDriverAlarmReceiver.java
  16. 37 1
      ApexDrivers/apexdriverslib/src/main/java/com/usai/redant/apexdrivers/setting/SettingActivity.java
  17. 1 0
      ApexDrivers/apexdriverslib/src/main/java/com/usai/redant/apexdrivers/setting/model/ActionModel.java
  18. 71 0
      ApexDrivers/apexdriverslib/src/main/res/raw/setting_debug.json
  19. 0 6
      ApexDrivers/apexdriverslib/src/main/res/xml/download_dir.xml

+ 33 - 17
ApexDrivers/RAUtilsLibrary/src/main/AndroidManifest.xml

@@ -1,32 +1,32 @@
 <?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
-    package="com.usai.redant.rautils">
+          package="com.usai.redant.rautils">
 
-    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
-    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
-    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
+    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
+    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
+    <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
 
     <!-- 写联系人权限 -->
-    <uses-permission android:name="android.permission.WRITE_CONTACTS" />
-    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
+    <uses-permission android:name="android.permission.WRITE_CONTACTS"/>
+    <uses-permission android:name="android.permission.GET_ACCOUNTS"/>
 
     <!--
          <uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
     <uses-permission android:name="com.android.launcher.permission.UNINSTALL_SHORTCUT" />
     -->
-    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
-    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
-    <uses-permission android:name="android.permission.INTERNET" />
-    <uses-permission android:name="android.permission.READ_CONTACTS" />
-    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
+    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
+    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
+    <uses-permission android:name="android.permission.INTERNET"/>
+    <uses-permission android:name="android.permission.READ_CONTACTS"/>
+    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
     <!-- External storage for caching. -->
     <!-- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> -->
-    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
-    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
+    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
+    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
 
-    <!--Calendar-->
-    <uses-permission android:name="android.permission.READ_CALENDAR" />
-    <uses-permission android:name="android.permission.WRITE_CALENDAR" />
+    <!-- Calendar -->
+    <uses-permission android:name="android.permission.READ_CALENDAR"/>
+    <uses-permission android:name="android.permission.WRITE_CALENDAR"/>
 
     <application
         android:allowBackup="true"
@@ -41,12 +41,28 @@
         <!-- android:enabled="true" -->
         <!-- android:exported="true" /> -->
 
+        <!--Android 7.0 以后文件操作-->
+        <!--<provider-->
+            <!--android:name="android.support.v4.content.FileProvider"-->
+            <!--android:authorities="com.usai.apex.driver.fileprovider"-->
+            <!--android:exported="false"-->
+            <!--android:grantUriPermissions="true">-->
+
+            <!--<meta-data-->
+                <!--android:name="android.support.FILE_PROVIDER_PATHS"-->
+                <!--android:resource="@xml/paths"/>-->
+
+        <!--</provider>-->
+
         <receiver
             android:name=".receiver.RABroadcastReceiver"
             android:enabled="true"
             android:exported="false">
-
         </receiver>
+
+        <activity android:name=".fileViewer.FileViewerActivity">
+        </activity>
+
     </application>
 
 </manifest>

+ 140 - 0
ApexDrivers/RAUtilsLibrary/src/main/java/com/usai/redant/rautils/fileViewer/FileViewerActivity.java

@@ -0,0 +1,140 @@
+package com.usai.redant.rautils.fileViewer;
+
+import android.content.Context;
+import android.content.Intent;
+import android.net.Uri;
+import android.support.v7.app.ActionBar;
+import android.support.v7.app.AppCompatActivity;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.MenuItem;
+import android.view.View;
+import android.widget.AdapterView;
+import android.widget.ListView;
+
+import com.usai.redant.rautils.R;
+import com.usai.redant.rautils.utils.FileManager;
+import com.usai.redant.rautils.utils.RAUtil;
+
+import java.io.File;
+
+public class FileViewerActivity extends AppCompatActivity {
+
+    final static String TAG = "FileViewer";
+
+    private final static String File_Key = "File_Key";
+    public static void start(Context context, File file) {
+        if (context == null) {
+            Log.d(TAG, "start fileviewer context is null");
+            return;
+        }
+        if (file == null || !file.exists() || file.isFile()) {
+            Log.d(TAG, "start fileviewer file is null or file not exist or file is not a directory ");
+            return;
+        }
+
+        Intent intent = new Intent(context, FileViewerActivity.class);
+        intent.putExtra(File_Key, file.getAbsolutePath());
+
+        context.startActivity(intent);
+    }
+
+    private ListView mListView;
+    private File mFile;
+    private FileViewerAdapter mAdapter;
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.file_viewer_activity);
+
+        ActionBar actionBar = getSupportActionBar();
+        if (actionBar != null) {
+            actionBar.setHomeButtonEnabled(true);
+            actionBar.setDisplayHomeAsUpEnabled(true);
+        }
+
+        Intent intent = getIntent();
+        if (intent != null) {
+            String filePath = intent.getStringExtra(File_Key);
+            if (filePath != null) {
+                mFile = new File(filePath);
+            }
+        }
+
+        if (savedInstanceState != null) {
+            String filePath = savedInstanceState.getString(File_Key);
+            if (filePath != null) {
+                mFile = new File(filePath);
+            }
+        }
+
+        mAdapter = new FileViewerAdapter(this,mFile);
+
+        mListView = findViewById(R.id.file_list_view);
+        mListView.setAdapter(mAdapter);
+        mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
+            @Override
+            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
+
+                File file = (File) mAdapter.getItem(position);
+                clickFileCell(file);
+            }
+        });
+    }
+
+    @Override
+    protected void onSaveInstanceState(Bundle outState) {
+        super.onSaveInstanceState(outState);
+
+        if (mFile != null) {
+            outState.putString(File_Key, mFile.getAbsolutePath());
+        }
+    }
+
+    @Override
+    public boolean onOptionsItemSelected(MenuItem item) {
+        switch (item.getItemId()) {
+            case android.R.id.home: {
+                finish();
+                return true;
+            }
+        }
+        return super.onOptionsItemSelected(item);
+    }
+
+    private void clickFileCell(File file) {
+        if (file != null && file.exists()) {
+
+            if (file.isDirectory()) {
+
+                start(this,file);
+
+            } else {
+
+                viewFile(file);
+            }
+        }
+    }
+
+    private void viewFile(File file) {
+        if (file != null && file.exists() && file.isFile()) {
+
+            String name = file.getName();
+            String oldPath = file.getAbsolutePath();
+            String newDir = FileManager.SDCardRoot() + RAUtil.getApplicationName(getApplicationContext());
+            File dirF = new File(newDir);
+            if (!dirF.exists()) {
+                dirF.mkdirs();
+            }
+
+            String newPath = newDir  + File.separator + name;
+            FileManager.copyFile(oldPath, newPath);
+
+            FileManager.openFile(getApplicationContext(), "com.usai.apex.apexdriversi.fileprovider", new File(newPath));
+
+        }
+    }
+
+
+}

+ 121 - 0
ApexDrivers/RAUtilsLibrary/src/main/java/com/usai/redant/rautils/fileViewer/FileViewerAdapter.java

@@ -0,0 +1,121 @@
+package com.usai.redant.rautils.fileViewer;
+
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.BaseAdapter;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import com.usai.redant.rautils.R;
+
+import java.io.File;
+import java.lang.ref.WeakReference;
+
+public class FileViewerAdapter extends BaseAdapter {
+
+    private WeakReference<FileViewerActivity> mActivity;
+    private File[] mFileList;
+
+    public FileViewerAdapter(FileViewerActivity activity, File file) {
+        if (activity == null) {
+            mActivity = null;
+        } else {
+            mActivity = new WeakReference<>(activity);
+        }
+
+        if (file == null) {
+            mFileList = null;
+        } else {
+            mFileList = file.listFiles();
+        }
+    }
+
+    private FileViewerActivity getActivity() {
+        if (mActivity == null) {
+            return null;
+        }
+        return mActivity.get();
+    }
+
+    private int getFileCount() {
+        if (mFileList == null || getActivity() == null) {
+            return 0;
+        }
+        return mFileList.length;
+    }
+
+    private File getFile(int index) {
+        int count = getFileCount();
+        if (index >= count || index < 0) {
+            return null;
+        }
+        return mFileList[index];
+    }
+
+    @Override
+    public int getCount() {
+        return getFileCount();
+    }
+
+    @Override
+    public Object getItem(int position) {
+        return getFile(position);
+    }
+
+    @Override
+    public long getItemId(int position) {
+        return position;
+    }
+
+    @Override
+    public View getView(int position, View convertView, ViewGroup parent) {
+
+        FileCellHolder holder;
+        if (convertView == null) {
+
+            convertView = LayoutInflater.from(getActivity()).inflate(R.layout.file_viewer_cell,null);
+            holder = new FileCellHolder(convertView);
+
+        } else {
+
+            holder = (FileCellHolder)convertView.getTag();
+        }
+
+        File file = getFile(position);
+        holder.setFile(file);
+
+        return convertView;
+    }
+
+    private class FileCellHolder {
+
+        private ImageView iconView;
+        private TextView  nameTv;
+        public FileCellHolder(View view) {
+            view.setTag(this);
+
+            iconView = view.findViewById(R.id.file_cell_icon);
+            nameTv = view.findViewById(R.id.file_cell_name_tv);
+        }
+
+        public void setFile(File f) {
+            if (f == null) {
+                iconView.setImageDrawable(null);
+                nameTv.setText(null);
+            } else {
+
+                FileViewerActivity activity = getActivity();
+                if (activity != null) {
+                    if (f.isFile()) {
+                        iconView.setImageDrawable(activity.getDrawable(R.drawable.ic_file));
+                    } else {
+                        iconView.setImageDrawable(activity.getDrawable(R.drawable.ic_folder));
+                    }
+                }
+
+                nameTv.setText(f.getName());
+            }
+        }
+    }
+}

+ 1 - 1
ApexDrivers/RAUtilsLibrary/src/main/java/com/usai/redant/rautils/receiver/AlarmReceiver.java

@@ -5,7 +5,7 @@ import android.content.Intent;
 import android.util.Log;
 
 public abstract class AlarmReceiver extends BootCompleteBroadcastReceiver {
-    protected  int normal_alarm_timeInterval = 120 * 1000;
+    protected  int normal_alarm_timeInterval = 20 * 1000;
     protected  int aggressive_alarm_timeInterval = 15 * 1000;
 
 //    protected static final int	SO_TIMEOUT						= 15 * 1000;

+ 11 - 3
ApexDrivers/RAUtilsLibrary/src/main/java/com/usai/redant/rautils/utils/FileManager.java

@@ -208,7 +208,7 @@ public class FileManager {
         String ext = MimeTypeMap.getFileExtensionFromUrl(filePath);
         String mime = MimeTypeMap.getSingleton().getMimeTypeFromExtension(ext);
         if (mime == null || mime.isEmpty()) {
-            mime = "text/plain";
+            mime = "*/*";
         }
         return mime;
     }
@@ -247,7 +247,8 @@ public class FileManager {
 
     }
 
-    public static void openFile(Context context, File file) {
+    public static void openFile(Context context, String authority, File file) {
+
 
         if (context == null || file == null || !file.exists()) {
             return;
@@ -262,7 +263,7 @@ public class FileManager {
         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
 
             // "com.usai.apex.fileprovider"即是在Manifest文件中配置的authorities
-            uri = FileProvider.getUriForFile(context, "com.usai.apex.fileprovider", file);
+            uri = FileProvider.getUriForFile(context, authority, file);
             // 给目标应用一个临时授权
             intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
         } else {
@@ -291,6 +292,13 @@ public class FileManager {
 
     }
 
+    public static void openFile(Context context, File file) {
+
+        String authority = "com.usai.apex.fileprovider";
+
+        openFile(context, "", file);
+    }
+
     public static void shareFile(Context context,Uri uri, String type) {
 
         Intent shareIntent = new Intent();

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

@@ -396,4 +396,13 @@ public class RAUtil {
         return hex.toString();
     }
 
+    public static boolean isDebugMode(Context context) {
+        try {
+            ApplicationInfo info = context.getApplicationInfo();
+            return (info.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;
+        } catch (Exception e) {
+            return false;
+        }
+    }
+
 }

+ 5 - 0
ApexDrivers/RAUtilsLibrary/src/main/res/drawable/ic_file.xml

@@ -0,0 +1,5 @@
+<vector android:height="50dp" android:tint="#3CE6FF"
+    android:viewportHeight="24.0" android:viewportWidth="24.0"
+    android:width="50dp" xmlns:android="http://schemas.android.com/apk/res/android">
+    <path android:fillColor="#FF000000" android:pathData="M6,2c-1.1,0 -1.99,0.9 -1.99,2L4,20c0,1.1 0.89,2 1.99,2L18,22c1.1,0 2,-0.9 2,-2L20,8l-6,-6L6,2zM13,9L13,3.5L18.5,9L13,9z"/>
+</vector>

+ 5 - 0
ApexDrivers/RAUtilsLibrary/src/main/res/drawable/ic_folder.xml

@@ -0,0 +1,5 @@
+<vector android:height="50dp" android:tint="#3CE6FF"
+    android:viewportHeight="24.0" android:viewportWidth="24.0"
+    android:width="50dp" xmlns:android="http://schemas.android.com/apk/res/android">
+    <path android:fillColor="#FF000000" android:pathData="M10,4H4c-1.1,0 -1.99,0.9 -1.99,2L2,18c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2V8c0,-1.1 -0.9,-2 -2,-2h-8l-2,-2z"/>
+</vector>

+ 18 - 0
ApexDrivers/RAUtilsLibrary/src/main/res/layout/file_viewer_activity.xml

@@ -0,0 +1,18 @@
+<?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=".fileViewer.FileViewerActivity">
+
+    <ListView
+        android:id="@+id/file_list_view"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:layout_margin="0dp"
+        />
+
+
+</android.support.constraint.ConstraintLayout>

+ 32 - 0
ApexDrivers/RAUtilsLibrary/src/main/res/layout/file_viewer_cell.xml

@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                android:layout_width="match_parent"
+                android:layout_height="80dp">
+
+    <RelativeLayout
+        android:layout_width="match_parent"
+        android:layout_height="80dp"
+        />
+
+    <ImageView
+        android:id="@+id/file_cell_icon"
+        android:layout_width="50dp"
+        android:layout_height="50dp"
+        android:layout_centerVertical="true"
+        android:layout_marginLeft="10dp"
+        />
+    
+    <TextView
+        android:id="@+id/file_cell_name_tv"
+        android:layout_width="match_parent"
+        android:layout_height="50dp"
+        android:layout_toEndOf="@id/file_cell_icon"
+        android:layout_marginLeft="5dp"
+        android:layout_marginRight="10dp"
+        android:layout_centerVertical="true"
+        android:textColor="#000000"
+        android:textSize="20sp"
+        android:gravity="left|center_vertical"
+        />
+
+</RelativeLayout>

+ 13 - 0
ApexDrivers/apexdriversi/src/main/AndroidManifest.xml

@@ -12,6 +12,19 @@
         android:supportsRtl="true"
 
         tools:replace="android:name">
+
+
+        <provider
+            android:name="android.support.v4.content.FileProvider"
+            android:authorities="com.usai.apex.apexdriversi.fileprovider"
+            android:exported="false"
+            android:grantUriPermissions="true">
+            <meta-data
+                android:name="android.support.FILE_PROVIDER_PATHS"
+                android:resource="@xml/provider_paths" />
+        </provider>
+
+
         <activity android:name=".MainActivityI"
                   android:launchMode="singleTop"
                   android:screenOrientation="portrait"

+ 36 - 0
ApexDrivers/apexdriversi/src/main/res/xml/provider_paths.xml

@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="utf-8"?>
+<paths xmlns:android="http://schemas.android.com/apk/res/android">
+
+        <external-path
+            name="external"
+            path="."
+            />
+
+        <files-path
+            name="files"
+            path="."
+            />
+
+        <cache-path
+            name="caches"
+            path="."
+            />
+
+        <external-files-path
+            name="ex_f"
+            path="."
+            />
+
+        <external-cache-path
+            name="ex_c"
+            path="."
+            />
+
+        <!--<files-path path="offline" name="ra_files_offline"/>-->
+        <!--<files-path path="Photo" name="ra_files_photo"/>-->
+        <!--<files-path path="Signature" name="ra_files_signature"/>-->
+
+        <!--<cache-path path="Log" name="ra_cache_log"/>-->
+        <!--<cache-path path="ImageCache" name="ra_cache_images"/>-->
+
+</paths>

+ 9 - 9
ApexDrivers/apexdriverslib/src/main/AndroidManifest.xml

@@ -37,15 +37,15 @@
         android:supportsRtl="true"
         android:theme="@style/ApexDriverTheme"
         tools:replace="android:theme,android:icon">
-        <provider
-            android:name="android.support.v4.content.FileProvider"
-            android:authorities="com.usai.apex.driver.fileprovider"
-            android:exported="false"
-            android:grantUriPermissions="true">
-            <meta-data
-                android:name="android.support.FILE_PROVIDER_PATHS"
-                android:resource="@xml/download_dir"/>
-        </provider>
+        <!--<provider-->
+            <!--android:name="android.support.v4.content.FileProvider"-->
+            <!--android:authorities="com.usai.apex.driver.fileprovider"-->
+            <!--android:exported="false"-->
+            <!--android:grantUriPermissions="true">-->
+            <!--<meta-data-->
+                <!--android:name="android.support.FILE_PROVIDER_PATHS"-->
+                <!--android:resource="@xml/download_dir"/>-->
+        <!--</provider>-->
 
         <activity
             android:name=".MainActivity"

+ 11 - 5
ApexDrivers/apexdriverslib/src/main/java/com/usai/redant/apexdrivers/home/HomeFragment.java

@@ -358,8 +358,15 @@ public class HomeFragment extends Fragment implements HomeHeaderView.HomeHeaderD
 
     private void handleJson(JSONObject json) {
 
-        if (json != null) {
+        Message msg = new Message();
+        msg.what = HomeHandler.HomeActionReloadData;
+        msg.obj = json;
+        mHandler.sendMessage(msg);
+    }
 
+    private void handleJsonOnUI(JSONObject json) {
+
+        if (json != null) {
             try {
                 JSONArray sectionArr = json.optJSONArray("sections");
                 if (sectionArr != null) {
@@ -387,9 +394,7 @@ public class HomeFragment extends Fragment implements HomeHeaderView.HomeHeaderD
             }
         }
 
-        Message msg = new Message();
-        msg.what = HomeHandler.HomeActionReloadData;
-        mHandler.sendMessage(msg);
+        changeData();
     }
 
     private void loadData() {
@@ -586,7 +591,8 @@ public class HomeFragment extends Fragment implements HomeHeaderView.HomeHeaderD
             switch (msg.what) {
                 case HomeActionReloadData: {
 
-                    fragment.changeData();
+                    JSONObject json = (JSONObject)msg.obj;
+                    fragment.handleJsonOnUI(json);
                 }
                 break;
                 case HomeActionError: {

+ 27 - 3
ApexDrivers/apexdriverslib/src/main/java/com/usai/redant/apexdrivers/receiver/ApexDriverAlarmReceiver.java

@@ -14,6 +14,7 @@ import com.usai.redant.rautils.receiver.AlarmReceiver;
 import com.usai.redant.rautils.receiver.RABroadcast;
 import com.usai.redant.rautils.utils.Network;
 import com.usai.redant.rautils.utils.RAUtil;
+import com.usai.redant.rautils.utils.dbgUtil;
 
 import org.json.JSONArray;
 import org.json.JSONObject;
@@ -24,6 +25,7 @@ import static com.usai.redant.rautils.utils.Network.RESULT_TRUE;
 public class ApexDriverAlarmReceiver extends AlarmReceiver {
     //负责通过alarm 从后台取notification 列表
 
+    final static String TAG = "Apex Driver Alarm Receiver";
 
 //    protected static final int	SO_TIMEOUT						= 15 * 1000;
     @Override
@@ -51,8 +53,10 @@ public class ApexDriverAlarmReceiver extends AlarmReceiver {
                 Context.ALARM_SERVICE);
 
 
-        if(am==null)
+        if(am==null) {
+            dbgUtil.Logd(TAG, "init alarm Alarm Manager am == null");
             return;
+        }
 
         am.cancel(sender);
 
@@ -61,10 +65,18 @@ public class ApexDriverAlarmReceiver extends AlarmReceiver {
         Log.d("ApexDriverAlarmReceiver", "setup up alarm");
         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
             am.setExactAndAllowWhileIdle(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime(), sender);
+
+            dbgUtil.Logd(TAG, "init alarm Alarm Manager am.setExactAndAllowWhileIdle");
+
         } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
             am.setExact(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime(), sender);
+
+            dbgUtil.Logd(TAG, "init alarm Alarm Manager am.setExact");
+
         } else {
             am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime(), alarm_timeInterval, sender);
+
+            dbgUtil.Logd(TAG, "init alarm Alarm Manager am.setRepeating");
         }
 
     }
@@ -133,12 +145,22 @@ public class ApexDriverAlarmReceiver extends AlarmReceiver {
 
         AlarmManager am = (AlarmManager) context.getSystemService(
                 Context.ALARM_SERVICE);
-        if(am==null)
+        if(am==null) {
+            dbgUtil.Logd(TAG, "Alarm Process Alarm Manager am == null");
             return;
+        }
         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
             am.setExactAndAllowWhileIdle(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + alarm_timeInterval, sender);
+
+            dbgUtil.Logd(TAG, "Alarm Process am.setExactAndAllowWhileIdle");
+
         } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
             am.setExact(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + alarm_timeInterval, sender);
+
+            dbgUtil.Logd(TAG, "Alarm Process am.setExact");
+        } else {
+
+            dbgUtil.Logd(TAG, "Alarm Process else");
         }
     }
 
@@ -154,7 +176,7 @@ public class ApexDriverAlarmReceiver extends AlarmReceiver {
     private void check_push(final Context context)
     {
 
-
+        dbgUtil.Logd(TAG, "Check Push");
 //        String dev_id = RAUtil.getDeviceId(context);
         new Thread(new Runnable() {
             @Override
@@ -164,6 +186,8 @@ public class ApexDriverAlarmReceiver extends AlarmReceiver {
 
                     JSONObject json = com.usai.redant.apexdrivers.network.Network.pullNotification();
 
+                    dbgUtil.Logd(TAG, "Get Push " + (json == null ? "null" : json.toString()));
+
                     if (json != null) {
 
                         int result = json.optInt("result",0);

+ 37 - 1
ApexDrivers/apexdriverslib/src/main/java/com/usai/redant/apexdrivers/setting/SettingActivity.java

@@ -30,8 +30,10 @@ import com.usai.redant.apexdrivers.setting.model.OptionModel;
 import com.usai.redant.apexdrivers.setting.model.SectionModel;
 import com.usai.redant.apexdrivers.setting.option.OptionActivity;
 import com.usai.redant.apexdrivers.utils.OperationQueue;
+import com.usai.redant.rautils.fileViewer.FileViewerActivity;
 import com.usai.redant.rautils.utils.FileManager;
 import com.usai.redant.rautils.utils.ImageUtil;
+import com.usai.redant.rautils.utils.RAUtil;
 
 import org.json.JSONArray;
 import org.json.JSONObject;
@@ -228,7 +230,15 @@ public class SettingActivity extends BasicActivity implements SettingAdapter.Set
 
         mSections.clear();
 
-        JSONObject json = Network.loadFakeData(mCtx,R.raw.setting);
+
+        JSONObject json = null;
+
+        if (RAUtil.isDebugMode(ApexDriverApplication.sharedApplication())) {
+            json = Network.loadFakeData(mCtx,R.raw.setting_debug);
+        } else {
+            json = Network.loadFakeData(mCtx,R.raw.setting);
+        }
+
         if (json != null) {
             JSONArray sections = json.optJSONArray("sections");
             if (sections != null) {
@@ -274,10 +284,36 @@ public class SettingActivity extends BasicActivity implements SettingAdapter.Set
                 cleanDisk(model);
             }
             break;
+            case ActionModel.ActionTypeViewFile: {
+                viewFile();
+            }
+            break;
         }
 
     }
 
+    private void viewFile() {
+
+        new AlertDialog.Builder(this)
+                .setTitle("Select Directory")
+                .setSingleChoiceItems(new String[]{"Files", "Cache"}, -1, new DialogInterface.OnClickListener() {
+                    @Override
+                    public void onClick(DialogInterface dialog, int which) {
+
+                        String path;
+                        if (which == 0) {
+                            path = FileManager.internalStorageFileDir(mCtx);
+                        } else {
+                            path = FileManager.internalStorageTempDir(mCtx);
+                        }
+
+                        File file = new File(path);
+                        FileViewerActivity.start(mCtx,file);
+                    }
+                })
+                .show();
+    }
+
     private void cleanDisk(final ActionModel model) {
 
         if (model == null) {

+ 1 - 0
ApexDrivers/apexdriverslib/src/main/java/com/usai/redant/apexdrivers/setting/model/ActionModel.java

@@ -10,6 +10,7 @@ public class ActionModel extends BaseModel {
 
     public static final int ActionTypeCleanCache = 0;
     public static final int ActionTypeChangePassword = 1;
+    public static final int ActionTypeViewFile = 2;
 
 
     public int actionType;

+ 71 - 0
ApexDrivers/apexdriverslib/src/main/res/raw/setting_debug.json

@@ -0,0 +1,71 @@
+{
+  "sections": [
+    {
+      "settings": [
+        {
+          "type": 0,
+          "keyPath": "backgroundReportType",
+          "title": "Response Location Request",
+          "options": [
+            {
+              "option": 1,
+              "title": "Reject"
+            },
+            {
+              "option": 2,
+              "title": "Always ask"
+            },
+            {
+              "option": 3,
+              "title": "Allow"
+            }
+          ]
+        }
+      ]
+    },
+    {
+      "settings": [
+        {
+          "type": 2,
+          "actionType": 1,
+          "title": "Change Password"
+        }
+      ]
+    },
+    {
+      "settings": [
+        {
+          "type": 2,
+          "actionType": 0,
+          "title": "Clean Cache"
+        }
+      ]
+    },
+    {
+      "settings": [
+        {
+          "type": 2,
+          "actionType": 2,
+          "title": "View File"
+        }
+      ]
+    },
+    {
+      "settings": [
+        {
+          "type": 4,
+          "title": "Privacy Policy",
+          "link": "https://ra.apexshipping.com/t/privacyPolicy.html"
+        }
+      ]
+    },
+    {
+      "settings": [
+        {
+          "type": 3,
+          "title": "About"
+        }
+      ]
+    }
+  ]
+}

+ 0 - 6
ApexDrivers/apexdriverslib/src/main/res/xml/download_dir.xml

@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<paths>
-    <!--path:需要临时授权访问的路径(.代表所有路径)-->
-    <!--name:就是你给这个访问路径起个名字-->
-    <external-path path="." name="external_storage_download"/>
-</paths>