Merge "Use the suggested public API instead of libcore.os."

This commit is contained in:
Elliott Hughes
2014-04-24 23:52:16 +00:00
committed by Gerrit Code Review
2 changed files with 18 additions and 20 deletions

View File

@ -32,12 +32,11 @@ import android.os.UserHandle;
import android.provider.Settings; import android.provider.Settings;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.util.MutableInt;
import android.util.Slog; import android.util.Slog;
import android.view.View; import android.view.View;
import android.widget.TextView; import android.widget.TextView;
import libcore.util.MutableInt;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import com.android.internal.widget.LockPatternUtils; import com.android.internal.widget.LockPatternUtils;

View File

@ -17,14 +17,13 @@
package com.android.server.am; package com.android.server.am;
import android.app.ApplicationErrorReport.CrashInfo; import android.app.ApplicationErrorReport.CrashInfo;
import android.system.ErrnoException;
import android.system.Os;
import android.system.StructTimeval;
import android.system.StructUcred;
import android.util.Slog; import android.util.Slog;
import libcore.io.ErrnoException; import static android.system.OsConstants.*;
import libcore.io.Libcore;
import libcore.io.StructTimeval;
import libcore.io.StructUcred;
import static libcore.io.OsConstants.*;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.File; import java.io.File;
@ -77,7 +76,7 @@ final class NativeCrashListener extends Thread {
try { try {
CrashInfo ci = new CrashInfo(); CrashInfo ci = new CrashInfo();
ci.exceptionClassName = "Native crash"; ci.exceptionClassName = "Native crash";
ci.exceptionMessage = Libcore.os.strsignal(mSignal); ci.exceptionMessage = Os.strsignal(mSignal);
ci.throwFileName = "unknown"; ci.throwFileName = "unknown";
ci.throwClassName = "unknown"; ci.throwClassName = "unknown";
ci.throwMethodName = "unknown"; ci.throwMethodName = "unknown";
@ -117,22 +116,22 @@ final class NativeCrashListener extends Thread {
} }
try { try {
FileDescriptor serverFd = Libcore.os.socket(AF_UNIX, SOCK_STREAM, 0); FileDescriptor serverFd = Os.socket(AF_UNIX, SOCK_STREAM, 0);
final InetUnixAddress sockAddr = new InetUnixAddress(DEBUGGERD_SOCKET_PATH); final InetUnixAddress sockAddr = new InetUnixAddress(DEBUGGERD_SOCKET_PATH);
Libcore.os.bind(serverFd, sockAddr, 0); Os.bind(serverFd, sockAddr, 0);
Libcore.os.listen(serverFd, 1); Os.listen(serverFd, 1);
while (true) { while (true) {
InetSocketAddress peer = new InetSocketAddress(); InetSocketAddress peer = new InetSocketAddress();
FileDescriptor peerFd = null; FileDescriptor peerFd = null;
try { try {
if (MORE_DEBUG) Slog.v(TAG, "Waiting for debuggerd connection"); if (MORE_DEBUG) Slog.v(TAG, "Waiting for debuggerd connection");
peerFd = Libcore.os.accept(serverFd, peer); peerFd = Os.accept(serverFd, peer);
if (MORE_DEBUG) Slog.v(TAG, "Got debuggerd socket " + peerFd); if (MORE_DEBUG) Slog.v(TAG, "Got debuggerd socket " + peerFd);
if (peerFd != null) { if (peerFd != null) {
// Only the superuser is allowed to talk to us over this socket // Only the superuser is allowed to talk to us over this socket
StructUcred credentials = StructUcred credentials =
Libcore.os.getsockoptUcred(peerFd, SOL_SOCKET, SO_PEERCRED); Os.getsockoptUcred(peerFd, SOL_SOCKET, SO_PEERCRED);
if (credentials.uid == 0) { if (credentials.uid == 0) {
// the reporting thread may take responsibility for // the reporting thread may take responsibility for
// acking the debugger; make sure we play along. // acking the debugger; make sure we play along.
@ -146,7 +145,7 @@ final class NativeCrashListener extends Thread {
// byte written is irrelevant. // byte written is irrelevant.
if (peerFd != null) { if (peerFd != null) {
try { try {
Libcore.os.write(peerFd, ackSignal, 0, 1); Os.write(peerFd, ackSignal, 0, 1);
} catch (Exception e) { } catch (Exception e) {
/* we don't care about failures here */ /* we don't care about failures here */
if (MORE_DEBUG) { if (MORE_DEBUG) {
@ -154,7 +153,7 @@ final class NativeCrashListener extends Thread {
} }
} }
try { try {
Libcore.os.close(peerFd); Os.close(peerFd);
} catch (ErrnoException e) { } catch (ErrnoException e) {
if (MORE_DEBUG) { if (MORE_DEBUG) {
Slog.d(TAG, "Exception closing socket: " + e.getMessage()); Slog.d(TAG, "Exception closing socket: " + e.getMessage());
@ -182,7 +181,7 @@ final class NativeCrashListener extends Thread {
throws ErrnoException, InterruptedIOException { throws ErrnoException, InterruptedIOException {
int totalRead = 0; int totalRead = 0;
while (numBytes > 0) { while (numBytes > 0) {
int n = Libcore.os.read(fd, buffer, offset + totalRead, numBytes); int n = Os.read(fd, buffer, offset + totalRead, numBytes);
if (n <= 0) { if (n <= 0) {
if (DEBUG) { if (DEBUG) {
Slog.w(TAG, "Needed " + numBytes + " but saw " + n); Slog.w(TAG, "Needed " + numBytes + " but saw " + n);
@ -203,8 +202,8 @@ final class NativeCrashListener extends Thread {
try { try {
StructTimeval timeout = StructTimeval.fromMillis(SOCKET_TIMEOUT_MILLIS); StructTimeval timeout = StructTimeval.fromMillis(SOCKET_TIMEOUT_MILLIS);
Libcore.os.setsockoptTimeval(fd, SOL_SOCKET, SO_RCVTIMEO, timeout); Os.setsockoptTimeval(fd, SOL_SOCKET, SO_RCVTIMEO, timeout);
Libcore.os.setsockoptTimeval(fd, SOL_SOCKET, SO_SNDTIMEO, timeout); Os.setsockoptTimeval(fd, SOL_SOCKET, SO_SNDTIMEO, timeout);
// first, the pid and signal number // first, the pid and signal number
int headerBytes = readExactly(fd, buf, 0, 8); int headerBytes = readExactly(fd, buf, 0, 8);
@ -238,7 +237,7 @@ final class NativeCrashListener extends Thread {
int bytes; int bytes;
do { do {
// get some data // get some data
bytes = Libcore.os.read(fd, buf, 0, buf.length); bytes = Os.read(fd, buf, 0, buf.length);
if (bytes > 0) { if (bytes > 0) {
if (MORE_DEBUG) { if (MORE_DEBUG) {
String s = new String(buf, 0, bytes, "UTF-8"); String s = new String(buf, 0, bytes, "UTF-8");