packages/providers/DownloadProvider
Revision | a900a7676b770b6f4120d6dca25443d9e26e4a8b (tree) |
---|---|
Zeit | 2010-04-16 19:58:05 |
Autor | Yi Sun <beyounn@gmai...> |
Commiter | 黃志偉 |
change the permission of the download directory.
@@ -27,6 +27,7 @@ import android.net.ConnectivityManager; | ||
27 | 27 | import android.net.NetworkInfo; |
28 | 28 | import android.net.Uri; |
29 | 29 | import android.os.Environment; |
30 | +import android.os.FileUtils; | |
30 | 31 | import android.os.StatFs; |
31 | 32 | import android.os.SystemClock; |
32 | 33 | import android.provider.Downloads; |
@@ -180,12 +181,20 @@ public class Helpers { | ||
180 | 181 | if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { |
181 | 182 | String root = Environment.getExternalStorageDirectory().getPath(); |
182 | 183 | base = new File(root + Constants.DEFAULT_DL_SUBDIR); |
183 | - if (!base.isDirectory() && !base.mkdir()) { | |
184 | - if (Config.LOGD) { | |
185 | - Log.d(Constants.TAG, "download aborted - can't create base directory " | |
186 | - + base.getPath()); | |
184 | + if (!base.isDirectory()) { | |
185 | + if (base.mkdir()) { | |
186 | + /* | |
187 | + * Make sure the download directory is accessible | |
188 | + */ | |
189 | + FileUtils.setPermissions(base.getPath(), | |
190 | + FileUtils.S_IRWXU|FileUtils.S_IXGRP|FileUtils.S_IXOTH, -1, -1); | |
191 | + } else { | |
192 | + if (Config.LOGD) { | |
193 | + Log.d(Constants.TAG, "download aborted - can't create base directory " | |
194 | + + base.getPath()); | |
195 | + } | |
196 | + return new DownloadFileInfo(null, null, Downloads.STATUS_FILE_ERROR); | |
187 | 197 | } |
188 | - return new DownloadFileInfo(null, null, Downloads.STATUS_FILE_ERROR); | |
189 | 198 | } |
190 | 199 | stat = new StatFs(base.getPath()); |
191 | 200 | } else { |