Loading core/java/android/os/ParcelFileDescriptor.java +10 −2 Original line number Diff line number Diff line Loading @@ -230,7 +230,11 @@ public class ParcelFileDescriptor implements Parcelable { @Override public void close() throws IOException { try { mFd.close(); } finally { super.close(); } } } Loading @@ -249,7 +253,11 @@ public class ParcelFileDescriptor implements Parcelable { @Override public void close() throws IOException { try { mFd.close(); } finally { super.close(); } } } Loading core/java/android/os/StrictMode.java +37 −6 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import android.util.Printer; import com.android.internal.os.RuntimeInit; import dalvik.system.BlockGuard; import dalvik.system.CloseGuard; import java.io.PrintWriter; import java.io.StringWriter; Loading Loading @@ -70,6 +71,7 @@ import java.util.HashMap; * .build()); * StrictMode.setVmPolicy(new {@link VmPolicy.Builder StrictMode.VmPolicy.Builder}() * .detectLeakedSqlLiteObjects() * .detectLeakedClosableObjects() * .penaltyLog() * .penaltyDeath() * .build()); Loading Loading @@ -139,6 +141,12 @@ public final class StrictMode { */ public static final int DETECT_VM_CURSOR_LEAKS = 0x200; // for ProcessPolicy /** * Note, a "VM_" bit, not thread. * @hide */ public static final int DETECT_VM_CLOSABLE_LEAKS = 0x400; // for ProcessPolicy /** * @hide */ Loading Loading @@ -450,12 +458,12 @@ public final class StrictMode { /** * Detect everything that's potentially suspect. * * <p>As of the Gingerbread release this only includes * SQLite cursor leaks but will likely expand in future * releases. * <p>In the Honeycomb release this includes leaks of * SQLite cursors and other closable objects but will * likely expand in future releases. */ public Builder detectAll() { return enable(DETECT_VM_CURSOR_LEAKS); return enable(DETECT_VM_CURSOR_LEAKS | DETECT_VM_CLOSABLE_LEAKS); } /** Loading @@ -471,6 +479,18 @@ public final class StrictMode { return enable(DETECT_VM_CURSOR_LEAKS); } /** * Detect when an {@link java.io.Closeable} or other * object with a explict termination method is finalized * without having been closed. * * <p>You always want to explicitly close such objects to * avoid unnecessary resources leaks. */ public Builder detectLeakedClosableObjects() { return enable(DETECT_VM_CLOSABLE_LEAKS); } /** * Crashes the whole process on violation. This penalty runs at * the end of all enabled penalties so yo you'll still get Loading Loading @@ -671,6 +691,7 @@ public final class StrictMode { StrictMode.DETECT_NETWORK | StrictMode.PENALTY_DROPBOX); sVmPolicyMask = StrictMode.DETECT_VM_CURSOR_LEAKS | StrictMode.DETECT_VM_CLOSABLE_LEAKS | StrictMode.PENALTY_DROPBOX | StrictMode.PENALTY_LOG; return true; Loading Loading @@ -1030,6 +1051,7 @@ public final class StrictMode { */ public static void setVmPolicy(final VmPolicy policy) { sVmPolicyMask = policy.mask; CloseGuard.setEnabled(vmClosableObjectLeaksEnabled()); } /** Loading @@ -1043,8 +1065,9 @@ public final class StrictMode { * Enable the recommended StrictMode defaults, with violations just being logged. * * <p>This catches disk and network access on the main thread, as * well as leaked SQLite cursors. This is simply a wrapper around * {@link #setVmPolicy} and {@link #setThreadPolicy}. * well as leaked SQLite cursors and unclosed resources. This is * simply a wrapper around {@link #setVmPolicy} and {@link * #setThreadPolicy}. */ public static void enableDefaults() { StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder() Loading @@ -1053,6 +1076,7 @@ public final class StrictMode { .build()); StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder() .detectLeakedSqlLiteObjects() .detectLeakedClosableObjects() .penaltyLog() .build()); } Loading @@ -1064,6 +1088,13 @@ public final class StrictMode { return (sVmPolicyMask & DETECT_VM_CURSOR_LEAKS) != 0; } /** * @hide */ public static boolean vmClosableObjectLeaksEnabled() { return (sVmPolicyMask & DETECT_VM_CLOSABLE_LEAKS) != 0; } /** * @hide */ Loading core/java/com/android/internal/content/NativeLibraryHelper.java +1 −0 Original line number Diff line number Diff line Loading @@ -259,6 +259,7 @@ public class NativeLibraryHelper { File destFile = new File(sharedLibraryDir, entry.second); copyNativeBinaryLI(zipFile, entry.first, sharedLibraryDir, destFile); } zipFile.close(); } catch (ZipException e) { Slog.w(TAG, "Failed to extract data from package file", e); return PackageManager.INSTALL_FAILED_INVALID_APK; Loading services/java/com/android/server/DockObserver.java +1 −0 Original line number Diff line number Diff line Loading @@ -102,6 +102,7 @@ class DockObserver extends UEventObserver { try { FileReader file = new FileReader(DOCK_STATE_PATH); int len = file.read(buffer, 0, 1024); file.close(); mPreviousDockState = mDockState = Integer.valueOf((new String(buffer, 0, len)).trim()); } catch (FileNotFoundException e) { Slog.w(TAG, "This kernel does not have dock station support"); Loading services/java/com/android/server/InputManager.java +3 −1 Original line number Diff line number Diff line Loading @@ -493,7 +493,9 @@ public class InputManager { CALIBRATION_DIR_PATH + deviceName + ".idc"); if (calibrationFile.exists()) { try { properties.load(new FileInputStream(calibrationFile)); FileInputStream fis = new FileInputStream(calibrationFile); properties.load(fis); fis.close(); } catch (IOException ex) { Slog.w(TAG, "Error reading input device calibration properties for device " + deviceName + " from " + calibrationFile + ".", ex); Loading Loading
core/java/android/os/ParcelFileDescriptor.java +10 −2 Original line number Diff line number Diff line Loading @@ -230,7 +230,11 @@ public class ParcelFileDescriptor implements Parcelable { @Override public void close() throws IOException { try { mFd.close(); } finally { super.close(); } } } Loading @@ -249,7 +253,11 @@ public class ParcelFileDescriptor implements Parcelable { @Override public void close() throws IOException { try { mFd.close(); } finally { super.close(); } } } Loading
core/java/android/os/StrictMode.java +37 −6 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import android.util.Printer; import com.android.internal.os.RuntimeInit; import dalvik.system.BlockGuard; import dalvik.system.CloseGuard; import java.io.PrintWriter; import java.io.StringWriter; Loading Loading @@ -70,6 +71,7 @@ import java.util.HashMap; * .build()); * StrictMode.setVmPolicy(new {@link VmPolicy.Builder StrictMode.VmPolicy.Builder}() * .detectLeakedSqlLiteObjects() * .detectLeakedClosableObjects() * .penaltyLog() * .penaltyDeath() * .build()); Loading Loading @@ -139,6 +141,12 @@ public final class StrictMode { */ public static final int DETECT_VM_CURSOR_LEAKS = 0x200; // for ProcessPolicy /** * Note, a "VM_" bit, not thread. * @hide */ public static final int DETECT_VM_CLOSABLE_LEAKS = 0x400; // for ProcessPolicy /** * @hide */ Loading Loading @@ -450,12 +458,12 @@ public final class StrictMode { /** * Detect everything that's potentially suspect. * * <p>As of the Gingerbread release this only includes * SQLite cursor leaks but will likely expand in future * releases. * <p>In the Honeycomb release this includes leaks of * SQLite cursors and other closable objects but will * likely expand in future releases. */ public Builder detectAll() { return enable(DETECT_VM_CURSOR_LEAKS); return enable(DETECT_VM_CURSOR_LEAKS | DETECT_VM_CLOSABLE_LEAKS); } /** Loading @@ -471,6 +479,18 @@ public final class StrictMode { return enable(DETECT_VM_CURSOR_LEAKS); } /** * Detect when an {@link java.io.Closeable} or other * object with a explict termination method is finalized * without having been closed. * * <p>You always want to explicitly close such objects to * avoid unnecessary resources leaks. */ public Builder detectLeakedClosableObjects() { return enable(DETECT_VM_CLOSABLE_LEAKS); } /** * Crashes the whole process on violation. This penalty runs at * the end of all enabled penalties so yo you'll still get Loading Loading @@ -671,6 +691,7 @@ public final class StrictMode { StrictMode.DETECT_NETWORK | StrictMode.PENALTY_DROPBOX); sVmPolicyMask = StrictMode.DETECT_VM_CURSOR_LEAKS | StrictMode.DETECT_VM_CLOSABLE_LEAKS | StrictMode.PENALTY_DROPBOX | StrictMode.PENALTY_LOG; return true; Loading Loading @@ -1030,6 +1051,7 @@ public final class StrictMode { */ public static void setVmPolicy(final VmPolicy policy) { sVmPolicyMask = policy.mask; CloseGuard.setEnabled(vmClosableObjectLeaksEnabled()); } /** Loading @@ -1043,8 +1065,9 @@ public final class StrictMode { * Enable the recommended StrictMode defaults, with violations just being logged. * * <p>This catches disk and network access on the main thread, as * well as leaked SQLite cursors. This is simply a wrapper around * {@link #setVmPolicy} and {@link #setThreadPolicy}. * well as leaked SQLite cursors and unclosed resources. This is * simply a wrapper around {@link #setVmPolicy} and {@link * #setThreadPolicy}. */ public static void enableDefaults() { StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder() Loading @@ -1053,6 +1076,7 @@ public final class StrictMode { .build()); StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder() .detectLeakedSqlLiteObjects() .detectLeakedClosableObjects() .penaltyLog() .build()); } Loading @@ -1064,6 +1088,13 @@ public final class StrictMode { return (sVmPolicyMask & DETECT_VM_CURSOR_LEAKS) != 0; } /** * @hide */ public static boolean vmClosableObjectLeaksEnabled() { return (sVmPolicyMask & DETECT_VM_CLOSABLE_LEAKS) != 0; } /** * @hide */ Loading
core/java/com/android/internal/content/NativeLibraryHelper.java +1 −0 Original line number Diff line number Diff line Loading @@ -259,6 +259,7 @@ public class NativeLibraryHelper { File destFile = new File(sharedLibraryDir, entry.second); copyNativeBinaryLI(zipFile, entry.first, sharedLibraryDir, destFile); } zipFile.close(); } catch (ZipException e) { Slog.w(TAG, "Failed to extract data from package file", e); return PackageManager.INSTALL_FAILED_INVALID_APK; Loading
services/java/com/android/server/DockObserver.java +1 −0 Original line number Diff line number Diff line Loading @@ -102,6 +102,7 @@ class DockObserver extends UEventObserver { try { FileReader file = new FileReader(DOCK_STATE_PATH); int len = file.read(buffer, 0, 1024); file.close(); mPreviousDockState = mDockState = Integer.valueOf((new String(buffer, 0, len)).trim()); } catch (FileNotFoundException e) { Slog.w(TAG, "This kernel does not have dock station support"); Loading
services/java/com/android/server/InputManager.java +3 −1 Original line number Diff line number Diff line Loading @@ -493,7 +493,9 @@ public class InputManager { CALIBRATION_DIR_PATH + deviceName + ".idc"); if (calibrationFile.exists()) { try { properties.load(new FileInputStream(calibrationFile)); FileInputStream fis = new FileInputStream(calibrationFile); properties.load(fis); fis.close(); } catch (IOException ex) { Slog.w(TAG, "Error reading input device calibration properties for device " + deviceName + " from " + calibrationFile + ".", ex); Loading