Merge changes from topic "int32ref"

* changes:
  [Mainline] android.system package APIs migration
  Use public android.system.Int64Ref instead of Int32Ref which is hidden (CorePlatformApi) type of libcore
This commit is contained in:
Roland Levillain
2021-02-11 12:05:36 +00:00
committed by Gerrit Code Review
3 changed files with 10 additions and 17 deletions

View File

@@ -64,7 +64,7 @@ import android.os.ServiceManager;
import android.os.SystemClock; import android.os.SystemClock;
import android.os.UserHandle; import android.os.UserHandle;
import android.os.storage.StorageManager; import android.os.storage.StorageManager;
import android.system.Int32Ref; import android.system.Int64Ref;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.EventLog; import android.util.EventLog;
import android.util.Log; import android.util.Log;
@@ -4040,7 +4040,7 @@ public abstract class ContentResolver implements ContentInterface {
// Convert to Point, since that's what the API is defined as // Convert to Point, since that's what the API is defined as
final Bundle opts = new Bundle(); final Bundle opts = new Bundle();
opts.putParcelable(EXTRA_SIZE, Point.convert(size)); opts.putParcelable(EXTRA_SIZE, Point.convert(size));
final Int32Ref orientation = new Int32Ref(0); final Int64Ref orientation = new Int64Ref(0);
Bitmap bitmap = ImageDecoder.decodeBitmap(ImageDecoder.createSource(() -> { Bitmap bitmap = ImageDecoder.decodeBitmap(ImageDecoder.createSource(() -> {
final AssetFileDescriptor afd = content.openTypedAssetFile(uri, "image/*", opts, final AssetFileDescriptor afd = content.openTypedAssetFile(uri, "image/*", opts,

View File

@@ -19,7 +19,6 @@ package android.net;
import android.compat.annotation.UnsupportedAppUsage; import android.compat.annotation.UnsupportedAppUsage;
import android.os.Build; import android.os.Build;
import android.system.ErrnoException; import android.system.ErrnoException;
import android.system.Int32Ref;
import android.system.Os; import android.system.Os;
import android.system.OsConstants; import android.system.OsConstants;
import android.system.StructLinger; import android.system.StructLinger;
@@ -65,14 +64,11 @@ class LocalSocketImpl
public int available() throws IOException { public int available() throws IOException {
FileDescriptor myFd = fd; FileDescriptor myFd = fd;
if (myFd == null) throw new IOException("socket closed"); if (myFd == null) throw new IOException("socket closed");
Int32Ref avail = new Int32Ref(0);
try { try {
Os.ioctlInt(myFd, OsConstants.FIONREAD, avail); return Os.ioctlInt(myFd, OsConstants.FIONREAD);
} catch (ErrnoException e) { } catch (ErrnoException e) {
throw e.rethrowAsIOException(); throw e.rethrowAsIOException();
} }
return avail.value;
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@@ -134,7 +130,7 @@ class LocalSocketImpl
public void write (byte[] b) throws IOException { public void write (byte[] b) throws IOException {
write(b, 0, b.length); write(b, 0, b.length);
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public void write (byte[] b, int off, int len) throws IOException { public void write (byte[] b, int off, int len) throws IOException {
@@ -255,7 +251,7 @@ class LocalSocketImpl
/** note timeout presently ignored */ /** note timeout presently ignored */
protected void connect(LocalSocketAddress address, int timeout) protected void connect(LocalSocketAddress address, int timeout)
throws IOException throws IOException
{ {
if (fd == null) { if (fd == null) {
throw new IOException("socket not created"); throw new IOException("socket not created");
} }
@@ -339,7 +335,7 @@ class LocalSocketImpl
* @throws IOException if socket has been closed or cannot be created. * @throws IOException if socket has been closed or cannot be created.
*/ */
protected OutputStream getOutputStream() throws IOException protected OutputStream getOutputStream() throws IOException
{ {
if (fd == null) { if (fd == null) {
throw new IOException("socket not created"); throw new IOException("socket not created");
} }

View File

@@ -41,7 +41,6 @@ import android.os.Handler;
import android.os.MessageQueue; import android.os.MessageQueue;
import android.os.Messenger; import android.os.Messenger;
import android.system.ErrnoException; import android.system.ErrnoException;
import android.system.Int32Ref;
import android.system.Os; import android.system.Os;
import android.util.Log; import android.util.Log;
import android.util.SparseArray; import android.util.SparseArray;
@@ -306,9 +305,8 @@ public class TcpKeepaliveController {
private static boolean isReceiveQueueEmpty(FileDescriptor fd) private static boolean isReceiveQueueEmpty(FileDescriptor fd)
throws ErrnoException { throws ErrnoException {
Int32Ref result = new Int32Ref(-1); final int result = Os.ioctlInt(fd, SIOCINQ);
Os.ioctlInt(fd, SIOCINQ, result); if (result != 0) {
if (result.value != 0) {
Log.e(TAG, "Read queue has data"); Log.e(TAG, "Read queue has data");
return false; return false;
} }
@@ -317,9 +315,8 @@ public class TcpKeepaliveController {
private static boolean isSendQueueEmpty(FileDescriptor fd) private static boolean isSendQueueEmpty(FileDescriptor fd)
throws ErrnoException { throws ErrnoException {
Int32Ref result = new Int32Ref(-1); final int result = Os.ioctlInt(fd, SIOCOUTQ);
Os.ioctlInt(fd, SIOCOUTQ, result); if (result != 0) {
if (result.value != 0) {
Log.e(TAG, "Write queue has data"); Log.e(TAG, "Write queue has data");
return false; return false;
} }