| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.base; | 5 package org.chromium.base; |
| 6 | 6 |
| 7 import android.content.ContentResolver; | 7 import android.content.ContentResolver; |
| 8 import android.content.Context; | 8 import android.content.Context; |
| 9 import android.database.Cursor; | 9 import android.database.Cursor; |
| 10 import android.net.Uri; | 10 import android.net.Uri; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 } | 50 } |
| 51 return null; | 51 return null; |
| 52 } | 52 } |
| 53 | 53 |
| 54 /** | 54 /** |
| 55 * Opens the content URI for reading, and returns the file descriptor to | 55 * Opens the content URI for reading, and returns the file descriptor to |
| 56 * the caller. The caller is responsible for closing the file desciptor. | 56 * the caller. The caller is responsible for closing the file desciptor. |
| 57 * | 57 * |
| 58 * @param context {@link Context} in interest | 58 * @param context {@link Context} in interest |
| 59 * @param uriString the content URI to open | 59 * @param uriString the content URI to open |
| 60 * @return file desciptor upon sucess, or -1 otherwise. | 60 * @return file desciptor upon success, or -1 otherwise. |
| 61 */ | 61 */ |
| 62 @CalledByNative | 62 @CalledByNative |
| 63 public static int openContentUriForRead(Context context, String uriString) { | 63 public static int openContentUriForRead(Context context, String uriString) { |
| 64 ParcelFileDescriptor pfd = getParcelFileDescriptor(context, uriString); | 64 ParcelFileDescriptor pfd = getParcelFileDescriptor(context, uriString); |
| 65 if (pfd != null) { | 65 if (pfd != null) { |
| 66 return pfd.detachFd(); | 66 return pfd.detachFd(); |
| 67 } | 67 } |
| 68 return -1; | 68 return -1; |
| 69 } | 69 } |
| 70 | 70 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 } catch (NullPointerException e) { | 145 } catch (NullPointerException e) { |
| 146 // Some android models don't handle the provider call correctly. | 146 // Some android models don't handle the provider call correctly. |
| 147 // see crbug.com/345393 | 147 // see crbug.com/345393 |
| 148 return ""; | 148 return ""; |
| 149 } finally { | 149 } finally { |
| 150 if (cursor != null) cursor.close(); | 150 if (cursor != null) cursor.close(); |
| 151 } | 151 } |
| 152 return ""; | 152 return ""; |
| 153 } | 153 } |
| 154 } | 154 } |
| OLD | NEW |