Loading core/java/android/util/MemoryIntArray.java +25 −27 Original line number Diff line number Diff line Loading @@ -58,7 +58,7 @@ public final class MemoryIntArray implements Parcelable, Closeable { private final int mOwnerPid; private final boolean mClientWritable; private final long mMemoryAddr; private ParcelFileDescriptor mFd; private int mFd; /** * Creates a new instance. Loading @@ -75,23 +75,24 @@ public final class MemoryIntArray implements Parcelable, Closeable { mOwnerPid = Process.myPid(); mClientWritable = clientWritable; final String name = UUID.randomUUID().toString(); mFd = ParcelFileDescriptor.adoptFd(nativeCreate(name, size)); mMemoryAddr = nativeOpen(mFd.getFd(), true, clientWritable); mFd = nativeCreate(name, size); mMemoryAddr = nativeOpen(mFd, true, clientWritable); mCloseGuard.open("close"); } private MemoryIntArray(Parcel parcel) throws IOException { mOwnerPid = parcel.readInt(); mClientWritable = (parcel.readInt() == 1); mFd = parcel.readParcelable(null); if (mFd == null) { ParcelFileDescriptor pfd = parcel.readParcelable(null); if (pfd == null) { throw new IOException("No backing file descriptor"); } mFd = pfd.detachFd(); final long memoryAddress = parcel.readLong(); if (isOwner()) { mMemoryAddr = memoryAddress; } else { mMemoryAddr = nativeOpen(mFd.getFd(), false, mClientWritable); mMemoryAddr = nativeOpen(mFd, false, mClientWritable); } mCloseGuard.open("close"); } Loading @@ -114,7 +115,7 @@ public final class MemoryIntArray implements Parcelable, Closeable { public int get(int index) throws IOException { enforceNotClosed(); enforceValidIndex(index); return nativeGet(mFd.getFd(), mMemoryAddr, index, isOwner()); return nativeGet(mFd, mMemoryAddr, index, isOwner()); } /** Loading @@ -130,7 +131,7 @@ public final class MemoryIntArray implements Parcelable, Closeable { enforceNotClosed(); enforceWritable(); enforceValidIndex(index); nativeSet(mFd.getFd(), mMemoryAddr, index, value, isOwner()); nativeSet(mFd, mMemoryAddr, index, value, isOwner()); } /** Loading @@ -140,7 +141,7 @@ public final class MemoryIntArray implements Parcelable, Closeable { */ public int size() throws IOException { enforceNotClosed(); return nativeSize(mFd.getFd()); return nativeSize(mFd); } /** Loading @@ -151,9 +152,8 @@ public final class MemoryIntArray implements Parcelable, Closeable { @Override public void close() throws IOException { if (!isClosed()) { ParcelFileDescriptor pfd = mFd; mFd = null; nativeClose(pfd.getFd(), mMemoryAddr, isOwner()); nativeClose(mFd, mMemoryAddr, isOwner()); mFd = -1; mCloseGuard.close(); } } Loading @@ -162,7 +162,7 @@ public final class MemoryIntArray implements Parcelable, Closeable { * @return Whether this array is closed and shouldn't be used. */ public boolean isClosed() { return mFd == null; return mFd == -1; } @Override Loading @@ -182,11 +182,16 @@ public final class MemoryIntArray implements Parcelable, Closeable { @Override public void writeToParcel(Parcel parcel, int flags) { ParcelFileDescriptor pfd = ParcelFileDescriptor.adoptFd(mFd); try { parcel.writeInt(mOwnerPid); parcel.writeInt(mClientWritable ? 1 : 0); // Don't let writing to a parcel to close our fd - plz parcel.writeParcelable(mFd, flags & ~Parcelable.PARCELABLE_WRITE_RETURN_VALUE); parcel.writeParcelable(pfd, flags & ~Parcelable.PARCELABLE_WRITE_RETURN_VALUE); parcel.writeLong(mMemoryAddr); } finally { pfd.detachFd(); } } @Override Loading @@ -201,19 +206,12 @@ public final class MemoryIntArray implements Parcelable, Closeable { return false; } MemoryIntArray other = (MemoryIntArray) obj; if (mFd == null) { if (other.mFd != null) { return false; } } else if (mFd.getFd() != other.mFd.getFd()) { return false; } return true; return mFd == other.mFd; } @Override public int hashCode() { return mFd != null ? mFd.hashCode() : 1; return mFd; } private boolean isOwner() { Loading core/jni/android_util_MemoryIntArray.cpp +6 −0 Original line number Diff line number Diff line Loading @@ -180,6 +180,7 @@ static jint android_util_MemoryIntArray_size(JNIEnv* env, jobject clazz, jint fd return -1; } <<<<<<< HEAD if (!ashmem_valid(fd)) { jniThrowIOException(env, errno); return -1; Loading @@ -187,6 +188,11 @@ static jint android_util_MemoryIntArray_size(JNIEnv* env, jobject clazz, jint fd int ashmemSize = ashmem_get_size_region(fd); if (ashmemSize < 0) { ======= int ashmemSize = ashmem_get_size_region(fd); if (ashmemSize < 0) { // Some other error, throw exception >>>>>>> a2c1196dc25bfefe094c5d1757f8e2fd22500222 jniThrowIOException(env, errno); return -1; } Loading services/core/java/com/android/server/net/NetworkPolicyManagerService.java +1 −1 Original line number Diff line number Diff line Loading @@ -282,7 +282,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { private static final long TIME_CACHE_MAX_AGE = DAY_IN_MILLIS; private static final int MSG_RULES_CHANGED = 1; Mem private static final int MSG_RULES_CHANGED = 1; private static final int MSG_METERED_IFACES_CHANGED = 2; private static final int MSG_LIMIT_REACHED = 5; private static final int MSG_RESTRICT_BACKGROUND_CHANGED = 6; Loading Loading
core/java/android/util/MemoryIntArray.java +25 −27 Original line number Diff line number Diff line Loading @@ -58,7 +58,7 @@ public final class MemoryIntArray implements Parcelable, Closeable { private final int mOwnerPid; private final boolean mClientWritable; private final long mMemoryAddr; private ParcelFileDescriptor mFd; private int mFd; /** * Creates a new instance. Loading @@ -75,23 +75,24 @@ public final class MemoryIntArray implements Parcelable, Closeable { mOwnerPid = Process.myPid(); mClientWritable = clientWritable; final String name = UUID.randomUUID().toString(); mFd = ParcelFileDescriptor.adoptFd(nativeCreate(name, size)); mMemoryAddr = nativeOpen(mFd.getFd(), true, clientWritable); mFd = nativeCreate(name, size); mMemoryAddr = nativeOpen(mFd, true, clientWritable); mCloseGuard.open("close"); } private MemoryIntArray(Parcel parcel) throws IOException { mOwnerPid = parcel.readInt(); mClientWritable = (parcel.readInt() == 1); mFd = parcel.readParcelable(null); if (mFd == null) { ParcelFileDescriptor pfd = parcel.readParcelable(null); if (pfd == null) { throw new IOException("No backing file descriptor"); } mFd = pfd.detachFd(); final long memoryAddress = parcel.readLong(); if (isOwner()) { mMemoryAddr = memoryAddress; } else { mMemoryAddr = nativeOpen(mFd.getFd(), false, mClientWritable); mMemoryAddr = nativeOpen(mFd, false, mClientWritable); } mCloseGuard.open("close"); } Loading @@ -114,7 +115,7 @@ public final class MemoryIntArray implements Parcelable, Closeable { public int get(int index) throws IOException { enforceNotClosed(); enforceValidIndex(index); return nativeGet(mFd.getFd(), mMemoryAddr, index, isOwner()); return nativeGet(mFd, mMemoryAddr, index, isOwner()); } /** Loading @@ -130,7 +131,7 @@ public final class MemoryIntArray implements Parcelable, Closeable { enforceNotClosed(); enforceWritable(); enforceValidIndex(index); nativeSet(mFd.getFd(), mMemoryAddr, index, value, isOwner()); nativeSet(mFd, mMemoryAddr, index, value, isOwner()); } /** Loading @@ -140,7 +141,7 @@ public final class MemoryIntArray implements Parcelable, Closeable { */ public int size() throws IOException { enforceNotClosed(); return nativeSize(mFd.getFd()); return nativeSize(mFd); } /** Loading @@ -151,9 +152,8 @@ public final class MemoryIntArray implements Parcelable, Closeable { @Override public void close() throws IOException { if (!isClosed()) { ParcelFileDescriptor pfd = mFd; mFd = null; nativeClose(pfd.getFd(), mMemoryAddr, isOwner()); nativeClose(mFd, mMemoryAddr, isOwner()); mFd = -1; mCloseGuard.close(); } } Loading @@ -162,7 +162,7 @@ public final class MemoryIntArray implements Parcelable, Closeable { * @return Whether this array is closed and shouldn't be used. */ public boolean isClosed() { return mFd == null; return mFd == -1; } @Override Loading @@ -182,11 +182,16 @@ public final class MemoryIntArray implements Parcelable, Closeable { @Override public void writeToParcel(Parcel parcel, int flags) { ParcelFileDescriptor pfd = ParcelFileDescriptor.adoptFd(mFd); try { parcel.writeInt(mOwnerPid); parcel.writeInt(mClientWritable ? 1 : 0); // Don't let writing to a parcel to close our fd - plz parcel.writeParcelable(mFd, flags & ~Parcelable.PARCELABLE_WRITE_RETURN_VALUE); parcel.writeParcelable(pfd, flags & ~Parcelable.PARCELABLE_WRITE_RETURN_VALUE); parcel.writeLong(mMemoryAddr); } finally { pfd.detachFd(); } } @Override Loading @@ -201,19 +206,12 @@ public final class MemoryIntArray implements Parcelable, Closeable { return false; } MemoryIntArray other = (MemoryIntArray) obj; if (mFd == null) { if (other.mFd != null) { return false; } } else if (mFd.getFd() != other.mFd.getFd()) { return false; } return true; return mFd == other.mFd; } @Override public int hashCode() { return mFd != null ? mFd.hashCode() : 1; return mFd; } private boolean isOwner() { Loading
core/jni/android_util_MemoryIntArray.cpp +6 −0 Original line number Diff line number Diff line Loading @@ -180,6 +180,7 @@ static jint android_util_MemoryIntArray_size(JNIEnv* env, jobject clazz, jint fd return -1; } <<<<<<< HEAD if (!ashmem_valid(fd)) { jniThrowIOException(env, errno); return -1; Loading @@ -187,6 +188,11 @@ static jint android_util_MemoryIntArray_size(JNIEnv* env, jobject clazz, jint fd int ashmemSize = ashmem_get_size_region(fd); if (ashmemSize < 0) { ======= int ashmemSize = ashmem_get_size_region(fd); if (ashmemSize < 0) { // Some other error, throw exception >>>>>>> a2c1196dc25bfefe094c5d1757f8e2fd22500222 jniThrowIOException(env, errno); return -1; } Loading
services/core/java/com/android/server/net/NetworkPolicyManagerService.java +1 −1 Original line number Diff line number Diff line Loading @@ -282,7 +282,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub { private static final long TIME_CACHE_MAX_AGE = DAY_IN_MILLIS; private static final int MSG_RULES_CHANGED = 1; Mem private static final int MSG_RULES_CHANGED = 1; private static final int MSG_METERED_IFACES_CHANGED = 2; private static final int MSG_LIMIT_REACHED = 5; private static final int MSG_RESTRICT_BACKGROUND_CHANGED = 6; Loading