Skip to content

Commit 5990422

Browse files
author
野松
committed
request update: path fix
1 parent 0a5cf55 commit 5990422

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

Android/LuaViewSDK/src/com/taobao/luaview/scriptbundle/LuaScriptManager.java

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
* @date 15/11/9
2626
*/
2727
public class LuaScriptManager {
28-
private static String PACKAGE_NAME;
2928
private static String BASE_FILECACHE_PATH;
29+
private static String BASE_PREDOWNLOAD_FILECACHE_PATH;
3030
//folders
3131
private static final String PACKAGE_NAME_DEFAULT = "luaview";
3232
public static final String FOLDER_SCRIPT = "script";
@@ -57,9 +57,15 @@ public static void init(final Context context) {
5757
initInternalFilePath(context);
5858
} else {//测试环境优先使用sd卡路径
5959
if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
60-
// PACKAGE_NAME = context.getPackageName();//改成luaview
61-
PACKAGE_NAME = PACKAGE_NAME_DEFAULT;
6260
BASE_FILECACHE_PATH = context.getExternalCacheDir() + File.separator;
61+
62+
//base predownload path
63+
final File file = context.getDir(PACKAGE_NAME_DEFAULT, Context.MODE_PRIVATE);
64+
if(file != null) {
65+
BASE_PREDOWNLOAD_FILECACHE_PATH = file.getPath() + File.separator;
66+
} else {
67+
BASE_PREDOWNLOAD_FILECACHE_PATH = context.getCacheDir() + File.separator;
68+
}
6369
} else {
6470
initInternalFilePath(context);
6571
}
@@ -75,14 +81,13 @@ public static void init(final Context context) {
7581
private static void initInternalFilePath(Context context) {
7682
final File dir = context.getDir(PACKAGE_NAME_DEFAULT, Context.MODE_PRIVATE);
7783
if (dir != null) {//优先存在 data/data/packagename/luaview
78-
PACKAGE_NAME = PACKAGE_NAME_DEFAULT;
7984
BASE_FILECACHE_PATH = dir.getPath() + File.separator;
8085
} else {
81-
PACKAGE_NAME = PACKAGE_NAME_DEFAULT;
8286
BASE_FILECACHE_PATH = context.getCacheDir() + File.separator;
8387
}
84-
}
8588

89+
BASE_PREDOWNLOAD_FILECACHE_PATH = BASE_FILECACHE_PATH;
90+
}
8691
//--------------------------------static methods for get file path------------------------------
8792

8893
/**
@@ -91,7 +96,7 @@ private static void initInternalFilePath(Context context) {
9196
* @return
9297
*/
9398
public static String getBaseFilePath() {
94-
return BASE_FILECACHE_PATH + PACKAGE_NAME + File.separator;
99+
return BASE_FILECACHE_PATH + PACKAGE_NAME_DEFAULT + File.separator;
95100
}
96101

97102
/**
@@ -100,7 +105,7 @@ public static String getBaseFilePath() {
100105
* @return
101106
*/
102107
public static String getBaseScriptFolderPath() {
103-
return BASE_FILECACHE_PATH + PACKAGE_NAME + File.separator + FOLDER_SCRIPT + File.separator;
108+
return BASE_FILECACHE_PATH + PACKAGE_NAME_DEFAULT + File.separator + FOLDER_SCRIPT + File.separator;
104109
}
105110

106111
/**
@@ -109,7 +114,7 @@ public static String getBaseScriptFolderPath() {
109114
* @return
110115
*/
111116
public static String getBasePredownloadFolderPath() {
112-
return BASE_FILECACHE_PATH + PACKAGE_NAME + File.separator + FOLDER_PRE_DOWNLOAD + File.separator;
117+
return BASE_PREDOWNLOAD_FILECACHE_PATH + PACKAGE_NAME_DEFAULT + File.separator + FOLDER_PRE_DOWNLOAD + File.separator;
113118
}
114119

115120
/**

0 commit comments

Comments
 (0)