Merge "Framework: Prefer android.system.Os over libcore.io.Libcore.os" am: 5f04db96b3

am: 07efe116b1

Change-Id: I1c9f25ea1ac00037cc90dfe4c8c2552f90a33ecd
This commit is contained in:
Tobias Thierer
2017-10-19 14:34:36 +00:00
committed by android-build-merger
9 changed files with 24 additions and 26 deletions

View File

@@ -17,6 +17,7 @@
package android.util.apk;
import android.system.ErrnoException;
import android.system.Os;
import android.system.OsConstants;
import android.util.ArrayMap;
import android.util.Pair;
@@ -59,9 +60,6 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import libcore.io.Libcore;
import libcore.io.Os;
/**
* APK Signature Scheme v2 verifier.
*
@@ -994,8 +992,7 @@ public class ApkSignatureSchemeV2Verifier {
* {@link DataSource#feedIntoMessageDigests(MessageDigest[], long, int) feedIntoMessageDigests}.
*/
private static final class MemoryMappedFileDataSource implements DataSource {
private static final Os OS = Libcore.os;
private static final long MEMORY_PAGE_SIZE_BYTES = OS.sysconf(OsConstants._SC_PAGESIZE);
private static final long MEMORY_PAGE_SIZE_BYTES = Os.sysconf(OsConstants._SC_PAGESIZE);
private final FileDescriptor mFd;
private final long mFilePosition;
@@ -1041,7 +1038,7 @@ public class ApkSignatureSchemeV2Verifier {
long mmapRegionSize = size + dataStartOffsetInMmapRegion;
long mmapPtr = 0;
try {
mmapPtr = OS.mmap(
mmapPtr = Os.mmap(
0, // let the OS choose the start address of the region in memory
mmapRegionSize,
OsConstants.PROT_READ,
@@ -1066,7 +1063,7 @@ public class ApkSignatureSchemeV2Verifier {
} finally {
if (mmapPtr != 0) {
try {
OS.munmap(mmapPtr, mmapRegionSize);
Os.munmap(mmapPtr, mmapRegionSize);
} catch (ErrnoException ignored) {}
}
}

View File

@@ -15,13 +15,12 @@
*/
package com.android.internal.os;
import android.system.Os;
import android.text.TextUtils;
import android.os.StrictMode;
import android.system.OsConstants;
import android.util.Slog;
import libcore.io.Libcore;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
@@ -53,7 +52,7 @@ public class KernelCpuSpeedReader {
cpuNumber);
mLastSpeedTimes = new long[numSpeedSteps];
mDeltaSpeedTimes = new long[numSpeedSteps];
long jiffyHz = Libcore.os.sysconf(OsConstants._SC_CLK_TCK);
long jiffyHz = Os.sysconf(OsConstants._SC_CLK_TCK);
mJiffyMillis = 1000/jiffyHz;
}

View File

@@ -22,6 +22,7 @@ import android.os.FileUtils;
import android.os.Process;
import android.os.StrictMode;
import android.os.SystemClock;
import android.system.Os;
import android.system.OsConstants;
import android.util.Slog;
@@ -294,7 +295,7 @@ public class ProcessCpuTracker {
public ProcessCpuTracker(boolean includeThreads) {
mIncludeThreads = includeThreads;
long jiffyHz = Libcore.os.sysconf(OsConstants._SC_CLK_TCK);
long jiffyHz = Os.sysconf(OsConstants._SC_CLK_TCK);
mJiffyMillis = 1000/jiffyHz;
}

View File

@@ -23,6 +23,7 @@ import android.graphics.Point;
import android.graphics.Rect;
import android.os.ParcelFileDescriptor;
import android.system.ErrnoException;
import android.system.Os;
import android.system.OsConstants;
import dalvik.system.CloseGuard;
import libcore.io.IoUtils;
@@ -72,8 +73,8 @@ public final class PdfEditor {
final long size;
try {
Libcore.os.lseek(input.getFileDescriptor(), 0, OsConstants.SEEK_SET);
size = Libcore.os.fstat(input.getFileDescriptor()).st_size;
Os.lseek(input.getFileDescriptor(), 0, OsConstants.SEEK_SET);
size = Os.fstat(input.getFileDescriptor()).st_size;
} catch (ErrnoException ee) {
throw new IllegalArgumentException("file descriptor not seekable");
}

View File

@@ -26,10 +26,10 @@ import android.graphics.Point;
import android.graphics.Rect;
import android.os.ParcelFileDescriptor;
import android.system.ErrnoException;
import android.system.Os;
import android.system.OsConstants;
import com.android.internal.util.Preconditions;
import dalvik.system.CloseGuard;
import libcore.io.Libcore;
import java.io.IOException;
import java.lang.annotation.Retention;
@@ -154,8 +154,8 @@ public final class PdfRenderer implements AutoCloseable {
final long size;
try {
Libcore.os.lseek(input.getFileDescriptor(), 0, OsConstants.SEEK_SET);
size = Libcore.os.fstat(input.getFileDescriptor()).st_size;
Os.lseek(input.getFileDescriptor(), 0, OsConstants.SEEK_SET);
size = Os.fstat(input.getFileDescriptor()).st_size;
} catch (ErrnoException ee) {
throw new IllegalArgumentException("file descriptor not seekable");
}

View File

@@ -39,6 +39,7 @@ import android.os.PowerManager;
import android.os.SystemProperties;
import android.provider.Settings;
import android.system.ErrnoException;
import android.system.Os;
import android.system.OsConstants;
import android.util.Log;
import android.util.Pair;
@@ -60,7 +61,6 @@ import android.media.SyncParams;
import com.android.internal.util.Preconditions;
import libcore.io.IoBridge;
import libcore.io.Libcore;
import libcore.io.Streams;
import java.io.ByteArrayOutputStream;
@@ -2829,7 +2829,7 @@ public class MediaPlayer extends PlayerBase
final FileDescriptor dupedFd;
try {
dupedFd = Libcore.os.dup(fd);
dupedFd = Os.dup(fd);
} catch (ErrnoException ex) {
Log.e(TAG, ex.getMessage(), ex);
throw new RuntimeException(ex);
@@ -2867,7 +2867,7 @@ public class MediaPlayer extends PlayerBase
private int addTrack() {
final ByteArrayOutputStream bos = new ByteArrayOutputStream();
try {
Libcore.os.lseek(dupedFd, offset2, OsConstants.SEEK_SET);
Os.lseek(dupedFd, offset2, OsConstants.SEEK_SET);
byte[] buffer = new byte[4096];
for (long total = 0; total < length2;) {
int bytesToRead = (int) Math.min(buffer.length, length2 - total);
@@ -2891,7 +2891,7 @@ public class MediaPlayer extends PlayerBase
return MEDIA_INFO_TIMED_TEXT_ERROR;
} finally {
try {
Libcore.os.close(dupedFd);
Os.close(dupedFd);
} catch (ErrnoException e) {
Log.e(TAG, e.getMessage(), e);
}

View File

@@ -78,7 +78,6 @@ import com.android.server.pm.Installer.InstallerException;
import com.android.server.pm.PackageInstallerService.PackageInstallObserverAdapter;
import libcore.io.IoUtils;
import libcore.io.Libcore;
import java.io.File;
import java.io.FileDescriptor;
@@ -469,7 +468,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
// TODO: this should delegate to DCS so the system process avoids
// holding open FDs into containers.
final FileDescriptor targetFd = Libcore.os.open(target.getAbsolutePath(),
final FileDescriptor targetFd = Os.open(target.getAbsolutePath(),
O_CREAT | O_WRONLY, 0644);
Os.chmod(target.getAbsolutePath(), 0644);
@@ -481,7 +480,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
}
if (offsetBytes > 0) {
Libcore.os.lseek(targetFd, offsetBytes, OsConstants.SEEK_SET);
Os.lseek(targetFd, offsetBytes, OsConstants.SEEK_SET);
}
if (PackageInstaller.ENABLE_REVOCABLE_FD) {
@@ -516,7 +515,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
}
final File target = new File(resolveStageDir(), name);
final FileDescriptor targetFd = Libcore.os.open(target.getAbsolutePath(), O_RDONLY, 0);
final FileDescriptor targetFd = Os.open(target.getAbsolutePath(), O_RDONLY, 0);
return new ParcelFileDescriptor(targetFd);
} catch (ErrnoException e) {

View File

@@ -30,6 +30,7 @@ import android.os.Build;
import android.os.RemoteException;
import android.os.UserHandle;
import android.system.ErrnoException;
import android.system.Os;
import android.util.ArraySet;
import android.util.Log;
import android.util.Slog;
@@ -190,7 +191,7 @@ public class PackageManagerServiceUtils {
*/
public static String realpath(File path) throws IOException {
try {
return Libcore.os.realpath(path.getAbsolutePath());
return Os.realpath(path.getAbsolutePath());
} catch (ErrnoException ee) {
throw ee.rethrowAsIOException();
}

View File

@@ -96,7 +96,7 @@ public class NetlinkSocket implements Closeable {
mDescriptor = Os.socket(
OsConstants.AF_NETLINK, OsConstants.SOCK_DGRAM, nlProto);
Libcore.os.setsockoptInt(
Os.setsockoptInt(
mDescriptor, OsConstants.SOL_SOCKET,
OsConstants.SO_RCVBUF, SOCKET_RECV_BUFSIZE);
}