Merge "Framework: Prefer android.system.Os over libcore.io.Libcore.os"
This commit is contained in:
committed by
Android (Google) Code Review
commit
208f0970d5
@@ -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) {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
mLastSpeedTimesMs = new long[numSpeedSteps];
|
||||
mDeltaSpeedTimesMs = new long[numSpeedSteps];
|
||||
long jiffyHz = Libcore.os.sysconf(OsConstants._SC_CLK_TCK);
|
||||
long jiffyHz = Os.sysconf(OsConstants._SC_CLK_TCK);
|
||||
mJiffyMillis = 1000/jiffyHz;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
@@ -26,12 +26,12 @@ 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.IoUtils;
|
||||
import libcore.io.Libcore;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.annotation.Retention;
|
||||
@@ -156,8 +156,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");
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -2843,7 +2843,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);
|
||||
@@ -2881,7 +2881,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);
|
||||
@@ -2905,7 +2905,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);
|
||||
}
|
||||
|
||||
@@ -95,7 +95,6 @@ import com.android.server.pm.Installer.InstallerException;
|
||||
import com.android.server.pm.PackageInstallerService.PackageInstallObserverAdapter;
|
||||
|
||||
import libcore.io.IoUtils;
|
||||
import libcore.io.Libcore;
|
||||
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
@@ -613,7 +612,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);
|
||||
|
||||
@@ -625,7 +624,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) {
|
||||
@@ -661,7 +660,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
|
||||
throw new IllegalArgumentException("Invalid name: " + name);
|
||||
}
|
||||
final File target = new File(resolveStageDirLocked(), 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) {
|
||||
throw e.rethrowAsIOException();
|
||||
|
||||
@@ -35,6 +35,7 @@ import android.os.Process;
|
||||
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;
|
||||
@@ -232,7 +233,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();
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user