am 8dd0bce6: am 4e65a05f: am ac5f9628: am 7df411d0: Merge "Clear calling identity before getting the current user." into mnc-dev
* commit '8dd0bce6174ffff075e8c780a5245b5c4a5df2a7':
Clear calling identity before getting the current user.
diff --git a/Android.mk b/Android.mk
index 18d9c69..7df1bd7 100644
--- a/Android.mk
+++ b/Android.mk
@@ -710,6 +710,7 @@
bouncycastle \
okhttp \
ext \
+ icu4j \
framework \
telephony-common \
voip-common
@@ -763,7 +764,8 @@
$(foreach lib,$(FRAMEWORKS_SUPPORT_JAVA_LIBRARIES),$(call intermediates-dir-for,JAVA_LIBRARIES,$(lib)-res,,COMMON))
framework_docs_LOCAL_ADDITIONAL_DEPENDENCIES := \
- frameworks/base/docs/knowntags.txt
+ frameworks/base/docs/knowntags.txt \
+ libcore/Docs.mk
samples_dir := development/samples/browseable
diff --git a/cmds/am/src/com/android/commands/am/Am.java b/cmds/am/src/com/android/commands/am/Am.java
index 96c0dbd..d64e270 100644
--- a/cmds/am/src/com/android/commands/am/Am.java
+++ b/cmds/am/src/com/android/commands/am/Am.java
@@ -106,7 +106,7 @@
"usage: am [subcommand] [options]\n" +
"usage: am start [-D] [-W] [-P <FILE>] [--start-profiler <FILE>]\n" +
" [--sampling INTERVAL] [-R COUNT] [-S] [--opengl-trace]\n" +
- " [--user <USER_ID> | current] <INTENT>\n" +
+ " [--track-allocation] [--user <USER_ID> | current] <INTENT>\n" +
" am startservice [--user <USER_ID> | current] <INTENT>\n" +
" am stopservice [--user <USER_ID> | current] <INTENT>\n" +
" am force-stop [--user <USER_ID> | all | current] <PACKAGE>\n" +
@@ -162,6 +162,7 @@
" the top activity will be finished.\n" +
" -S: force stop the target app before starting the activity\n" +
" --opengl-trace: enable tracing of OpenGL functions\n" +
+ " --track-allocation: enable tracking of object allocations\n" +
" --user <USER_ID> | current: Specify which user to run as; if not\n" +
" specified then run as the current user.\n" +
"\n" +
@@ -691,6 +692,8 @@
mStopOption = true;
} else if (opt.equals("--opengl-trace")) {
mStartFlags |= ActivityManager.START_FLAG_OPENGL_TRACES;
+ } else if (opt.equals("--track-allocation")) {
+ mStartFlags |= ActivityManager.START_FLAG_TRACK_ALLOCATION;
} else if (opt.equals("--user")) {
mUserId = parseUserArg(nextArgRequired());
} else if (opt.equals("--receiver-permission")) {
diff --git a/cmds/app_process/Android.mk b/cmds/app_process/Android.mk
index 7ce0846..51bbb81 100644
--- a/cmds/app_process/Android.mk
+++ b/cmds/app_process/Android.mk
@@ -65,7 +65,7 @@
LOCAL_MODULE_STEM_32 := app_process32
LOCAL_MODULE_STEM_64 := app_process64
-LOCAL_ADDRESS_SANITIZER := true
+LOCAL_SANITIZE := address
LOCAL_CLANG := true
LOCAL_MODULE_PATH := $(TARGET_OUT_EXECUTABLES)/asan
diff --git a/cmds/input/src/com/android/commands/input/Input.java b/cmds/input/src/com/android/commands/input/Input.java
index 2a7c79b..754d3f5 100644
--- a/cmds/input/src/com/android/commands/input/Input.java
+++ b/cmds/input/src/com/android/commands/input/Input.java
@@ -234,6 +234,18 @@
InputManager.INJECT_INPUT_EVENT_MODE_WAIT_FOR_FINISH);
}
+ private int getInputDeviceId(int inputSource) {
+ final int DEFAULT_DEVICE_ID = 0;
+ int[] devIds = InputDevice.getDeviceIds();
+ for (int devId : devIds) {
+ InputDevice inputDev = InputDevice.getDevice(devId);
+ if (inputDev.supportsSource(inputSource)) {
+ return devId;
+ }
+ }
+ return DEFAULT_DEVICE_ID;
+ }
+
/**
* Builds a MotionEvent and injects it into the event stream.
*
@@ -249,11 +261,10 @@
final int DEFAULT_META_STATE = 0;
final float DEFAULT_PRECISION_X = 1.0f;
final float DEFAULT_PRECISION_Y = 1.0f;
- final int DEFAULT_DEVICE_ID = 0;
final int DEFAULT_EDGE_FLAGS = 0;
MotionEvent event = MotionEvent.obtain(when, when, action, x, y, pressure, DEFAULT_SIZE,
- DEFAULT_META_STATE, DEFAULT_PRECISION_X, DEFAULT_PRECISION_Y, DEFAULT_DEVICE_ID,
- DEFAULT_EDGE_FLAGS);
+ DEFAULT_META_STATE, DEFAULT_PRECISION_X, DEFAULT_PRECISION_Y,
+ getInputDeviceId(inputSource), DEFAULT_EDGE_FLAGS);
event.setSource(inputSource);
Log.i(TAG, "injectMotionEvent: " + event);
InputManager.getInstance().injectInputEvent(event,
diff --git a/cmds/svc/src/com/android/commands/svc/PowerCommand.java b/cmds/svc/src/com/android/commands/svc/PowerCommand.java
index 2754f2d..6ce29cb 100644
--- a/cmds/svc/src/com/android/commands/svc/PowerCommand.java
+++ b/cmds/svc/src/com/android/commands/svc/PowerCommand.java
@@ -93,7 +93,7 @@
} else if ("shutdown".equals(args[1])) {
try {
// no confirm, wait till device is off
- pm.shutdown(false, true);
+ pm.shutdown(false, null, true);
} catch (RemoteException e) {
System.err.println("Failed to shutdown.");
}
diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java
index 87c9efc2..ec262e5 100644
--- a/core/java/android/app/ActivityManager.java
+++ b/core/java/android/app/ActivityManager.java
@@ -210,6 +210,13 @@
public static final int START_FLAG_OPENGL_TRACES = 1<<2;
/**
+ * Flag for IActivityManaqer.startActivity: launch the app for
+ * allocation tracking.
+ * @hide
+ */
+ public static final int START_FLAG_TRACK_ALLOCATION = 1<<3;
+
+ /**
* Result for IActivityManaqer.broadcastIntent: success!
* @hide
*/
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index da21eaf..890b754 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -132,6 +132,7 @@
import dalvik.system.CloseGuard;
import dalvik.system.VMDebug;
import dalvik.system.VMRuntime;
+import org.apache.harmony.dalvik.ddmc.DdmVmInternal;
final class RemoteServiceException extends AndroidRuntimeException {
public RemoteServiceException(String msg) {
@@ -445,6 +446,7 @@
IUiAutomationConnection instrumentationUiAutomationConnection;
int debugMode;
boolean enableOpenGlTrace;
+ boolean trackAllocation;
boolean restrictedBackupMode;
boolean persistent;
Configuration config;
@@ -769,9 +771,9 @@
ProfilerInfo profilerInfo, Bundle instrumentationArgs,
IInstrumentationWatcher instrumentationWatcher,
IUiAutomationConnection instrumentationUiConnection, int debugMode,
- boolean enableOpenGlTrace, boolean isRestrictedBackupMode, boolean persistent,
- Configuration config, CompatibilityInfo compatInfo, Map<String, IBinder> services,
- Bundle coreSettings) {
+ boolean enableOpenGlTrace, boolean trackAllocation, boolean isRestrictedBackupMode,
+ boolean persistent, Configuration config, CompatibilityInfo compatInfo,
+ Map<String, IBinder> services, Bundle coreSettings) {
if (services != null) {
// Setup the service cache in the ServiceManager
@@ -827,6 +829,7 @@
data.instrumentationUiAutomationConnection = instrumentationUiConnection;
data.debugMode = debugMode;
data.enableOpenGlTrace = enableOpenGlTrace;
+ data.trackAllocation = trackAllocation;
data.restrictedBackupMode = isRestrictedBackupMode;
data.persistent = persistent;
data.config = config;
@@ -988,7 +991,7 @@
long nativeFree = Debug.getNativeHeapFreeSize() / 1024;
Runtime runtime = Runtime.getRuntime();
-
+ runtime.gc(); // Do GC since countInstancesOfClass counts unreachable objects.
long dalvikMax = runtime.totalMemory() / 1024;
long dalvikFree = runtime.freeMemory() / 1024;
long dalvikAllocated = dalvikMax - dalvikFree;
@@ -4428,6 +4431,10 @@
}
private void handleBindApplication(AppBindData data) {
+ if (data.trackAllocation) {
+ DdmVmInternal.enableRecentAllocations(true);
+ }
+
mBoundApplication = data;
mConfiguration = new Configuration(data.config);
mCompatConfiguration = new Configuration(data.config);
diff --git a/core/java/android/app/AlarmManager.java b/core/java/android/app/AlarmManager.java
index 330d730..fb03b62 100644
--- a/core/java/android/app/AlarmManager.java
+++ b/core/java/android/app/AlarmManager.java
@@ -823,7 +823,7 @@
}
/**
- * Returns an intent intent that can be used to show or edit details of the alarm clock in
+ * Returns an intent that can be used to show or edit details of the alarm clock in
* the application that scheduled it.
*
* <p class="note">Beware that any application can retrieve and send this intent,
diff --git a/core/java/android/app/ApplicationThreadNative.java b/core/java/android/app/ApplicationThreadNative.java
index e178087..b9ebd9f 100644
--- a/core/java/android/app/ApplicationThreadNative.java
+++ b/core/java/android/app/ApplicationThreadNative.java
@@ -292,6 +292,7 @@
IUiAutomationConnection.Stub.asInterface(binder);
int testMode = data.readInt();
boolean openGlTrace = data.readInt() != 0;
+ boolean trackAllocation = data.readInt() != 0;
boolean restrictedBackupMode = (data.readInt() != 0);
boolean persistent = (data.readInt() != 0);
Configuration config = Configuration.CREATOR.createFromParcel(data);
@@ -299,7 +300,7 @@
HashMap<String, IBinder> services = data.readHashMap(null);
Bundle coreSettings = data.readBundle();
bindApplication(packageName, info, providers, testName, profilerInfo, testArgs,
- testWatcher, uiAutomationConnection, testMode, openGlTrace,
+ testWatcher, uiAutomationConnection, testMode, openGlTrace, trackAllocation,
restrictedBackupMode, persistent, config, compatInfo, services, coreSettings);
return true;
}
@@ -987,13 +988,14 @@
data.recycle();
}
+ @Override
public final void bindApplication(String packageName, ApplicationInfo info,
List<ProviderInfo> providers, ComponentName testName, ProfilerInfo profilerInfo,
Bundle testArgs, IInstrumentationWatcher testWatcher,
IUiAutomationConnection uiAutomationConnection, int debugMode,
- boolean openGlTrace, boolean restrictedBackupMode, boolean persistent,
- Configuration config, CompatibilityInfo compatInfo, Map<String, IBinder> services,
- Bundle coreSettings) throws RemoteException {
+ boolean openGlTrace, boolean trackAllocation, boolean restrictedBackupMode,
+ boolean persistent, Configuration config, CompatibilityInfo compatInfo,
+ Map<String, IBinder> services, Bundle coreSettings) throws RemoteException {
Parcel data = Parcel.obtain();
data.writeInterfaceToken(IApplicationThread.descriptor);
data.writeString(packageName);
@@ -1016,6 +1018,7 @@
data.writeStrongInterface(uiAutomationConnection);
data.writeInt(debugMode);
data.writeInt(openGlTrace ? 1 : 0);
+ data.writeInt(trackAllocation ? 1 : 0);
data.writeInt(restrictedBackupMode ? 1 : 0);
data.writeInt(persistent ? 1 : 0);
config.writeToParcel(data, 0);
diff --git a/core/java/android/app/IApplicationThread.java b/core/java/android/app/IApplicationThread.java
index 185578f..e204d50 100644
--- a/core/java/android/app/IApplicationThread.java
+++ b/core/java/android/app/IApplicationThread.java
@@ -95,8 +95,9 @@
void bindApplication(String packageName, ApplicationInfo info, List<ProviderInfo> providers,
ComponentName testName, ProfilerInfo profilerInfo, Bundle testArguments,
IInstrumentationWatcher testWatcher, IUiAutomationConnection uiAutomationConnection,
- int debugMode, boolean openGlTrace, boolean restrictedBackupMode, boolean persistent,
- Configuration config, CompatibilityInfo compatInfo, Map<String, IBinder> services,
+ int debugMode, boolean openGlTrace, boolean trackAllocation,
+ boolean restrictedBackupMode, boolean persistent, Configuration config,
+ CompatibilityInfo compatInfo, Map<String, IBinder> services,
Bundle coreSettings) throws RemoteException;
void scheduleExit() throws RemoteException;
void scheduleSuicide() throws RemoteException;
diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java
index ec443cd..3e7c89d 100644
--- a/core/java/android/content/Intent.java
+++ b/core/java/android/content/Intent.java
@@ -2191,7 +2191,9 @@
/**
* Activity Action: Start this activity to request system shutdown.
* The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
- * to request confirmation from the user before shutting down.
+ * to request confirmation from the user before shutting down. The optional boolean
+ * extra field {@link #EXTRA_USER_REQUESTED_SHUTDOWN} can be set to true to
+ * indicate that the shutdown is requested by the user.
*
* <p class="note">This is a protected intent that can only be sent
* by the system.
@@ -3505,6 +3507,15 @@
public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
/**
+ * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to indicate that the shutdown is
+ * requested by the user.
+ *
+ * {@hide}
+ */
+ public static final String EXTRA_USER_REQUESTED_SHUTDOWN =
+ "android.intent.extra.USER_REQUESTED_SHUTDOWN";
+
+ /**
* Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
* {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
* of restarting the application.
diff --git a/core/java/android/content/res/Resources.java b/core/java/android/content/res/Resources.java
index 731903c..788aee9 100644
--- a/core/java/android/content/res/Resources.java
+++ b/core/java/android/content/res/Resources.java
@@ -20,6 +20,7 @@
import android.annotation.ColorInt;
import android.annotation.StyleRes;
import android.annotation.StyleableRes;
+import android.icu.text.PluralRules;
import com.android.internal.util.GrowingArrayUtils;
import com.android.internal.util.XmlUtils;
@@ -68,8 +69,6 @@
import java.lang.ref.WeakReference;
import java.util.Locale;
-import libcore.icu.NativePluralRules;
-
/**
* Class for accessing an application's resources. This sits on top of the
* asset manager of the application (accessible through {@link #getAssets}) and
@@ -154,7 +153,7 @@
final DisplayMetrics mMetrics = new DisplayMetrics();
private final Configuration mConfiguration = new Configuration();
- private NativePluralRules mPluralRule;
+ private PluralRules mPluralRule;
private CompatibilityInfo mCompatibilityInfo = CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO;
@@ -335,9 +334,9 @@
*/
public CharSequence getQuantityText(@PluralsRes int id, int quantity)
throws NotFoundException {
- NativePluralRules rule = getPluralRule();
+ PluralRules rule = getPluralRule();
CharSequence res = mAssets.getResourceBagText(id,
- attrForQuantityCode(rule.quantityForInt(quantity)));
+ attrForQuantityCode(rule.select(quantity)));
if (res != null) {
return res;
}
@@ -347,40 +346,29 @@
}
throw new NotFoundException("Plural resource ID #0x" + Integer.toHexString(id)
+ " quantity=" + quantity
- + " item=" + stringForQuantityCode(rule.quantityForInt(quantity)));
+ + " item=" + rule.select(quantity));
}
- private NativePluralRules getPluralRule() {
+ private PluralRules getPluralRule() {
synchronized (sSync) {
if (mPluralRule == null) {
- mPluralRule = NativePluralRules.forLocale(mConfiguration.locale);
+ mPluralRule = PluralRules.forLocale(mConfiguration.locale);
}
return mPluralRule;
}
}
- private static int attrForQuantityCode(int quantityCode) {
+ private static int attrForQuantityCode(String quantityCode) {
switch (quantityCode) {
- case NativePluralRules.ZERO: return 0x01000005;
- case NativePluralRules.ONE: return 0x01000006;
- case NativePluralRules.TWO: return 0x01000007;
- case NativePluralRules.FEW: return 0x01000008;
- case NativePluralRules.MANY: return 0x01000009;
+ case PluralRules.KEYWORD_ZERO: return 0x01000005;
+ case PluralRules.KEYWORD_ONE: return 0x01000006;
+ case PluralRules.KEYWORD_TWO: return 0x01000007;
+ case PluralRules.KEYWORD_FEW: return 0x01000008;
+ case PluralRules.KEYWORD_MANY: return 0x01000009;
default: return ID_OTHER;
}
}
- private static String stringForQuantityCode(int quantityCode) {
- switch (quantityCode) {
- case NativePluralRules.ZERO: return "zero";
- case NativePluralRules.ONE: return "one";
- case NativePluralRules.TWO: return "two";
- case NativePluralRules.FEW: return "few";
- case NativePluralRules.MANY: return "many";
- default: return "other";
- }
- }
-
/**
* Return the string value associated with a particular resource ID. It
* will be stripped of any styled text information.
@@ -2059,7 +2047,7 @@
}
synchronized (sSync) {
if (mPluralRule != null) {
- mPluralRule = NativePluralRules.forLocale(config.locale);
+ mPluralRule = PluralRules.forLocale(config.locale);
}
}
}
diff --git a/core/java/android/net/LocalSocketImpl.java b/core/java/android/net/LocalSocketImpl.java
index fa9f479..b83fb26 100644
--- a/core/java/android/net/LocalSocketImpl.java
+++ b/core/java/android/net/LocalSocketImpl.java
@@ -25,6 +25,9 @@
import android.system.ErrnoException;
import android.system.Os;
import android.system.OsConstants;
+import android.system.StructLinger;
+import android.system.StructTimeval;
+import android.util.MutableInt;
/**
* Socket implementation used for android.net.LocalSocket and
@@ -59,7 +62,13 @@
FileDescriptor myFd = fd;
if (myFd == null) throw new IOException("socket closed");
- return available_native(myFd);
+ MutableInt avail = new MutableInt(0);
+ try {
+ Os.ioctlInt(myFd, OsConstants.FIONREAD, avail);
+ } catch (ErrnoException e) {
+ throw e.rethrowAsIOException();
+ }
+ return avail.value;
}
/** {@inheritDoc} */
@@ -156,18 +165,31 @@
public void flush() throws IOException {
FileDescriptor myFd = fd;
if (myFd == null) throw new IOException("socket closed");
- while(pending_native(myFd) > 0) {
+
+ // Loop until the output buffer is empty.
+ MutableInt pending = new MutableInt(0);
+ while (true) {
+ try {
+ // See linux/net/unix/af_unix.c
+ Os.ioctlInt(myFd, OsConstants.TIOCOUTQ, pending);
+ } catch (ErrnoException e) {
+ throw e.rethrowAsIOException();
+ }
+
+ if (pending.value <= 0) {
+ // The output buffer is empty.
+ break;
+ }
+
try {
Thread.sleep(10);
} catch (InterruptedException ie) {
- return;
+ break;
}
}
}
}
- private native int pending_native(FileDescriptor fd) throws IOException;
- private native int available_native(FileDescriptor fd) throws IOException;
private native int read_native(FileDescriptor fd) throws IOException;
private native int readba_native(byte[] b, int off, int len,
FileDescriptor fd) throws IOException;
@@ -179,28 +201,8 @@
int namespace) throws IOException;
private native void bindLocal(FileDescriptor fd, String name, int namespace)
throws IOException;
- private native void listen_native(FileDescriptor fd, int backlog)
- throws IOException;
- private native void shutdown(FileDescriptor fd, boolean shutdownInput);
private native Credentials getPeerCredentials_native(
FileDescriptor fd) throws IOException;
- private native int getOption_native(FileDescriptor fd, int optID)
- throws IOException;
- private native void setOption_native(FileDescriptor fd, int optID,
- int b, int value) throws IOException;
-
-// private native LocalSocketAddress getSockName_native
-// (FileDescriptor fd) throws IOException;
-
- /**
- * Accepts a connection on a server socket.
- *
- * @param fd file descriptor of server socket
- * @param s socket implementation that will become the new socket
- * @return file descriptor of new socket
- */
- private native FileDescriptor accept
- (FileDescriptor fd, LocalSocketImpl s) throws IOException;
/**
* Create a new instance.
@@ -232,7 +234,7 @@
* or {@link LocalSocket#SOCKET_SEQPACKET}
* @throws IOException
*/
- public void create (int sockType) throws IOException {
+ public void create(int sockType) throws IOException {
// no error if socket already created
// need this for LocalServerSocket.accept()
if (fd == null) {
@@ -311,8 +313,11 @@
if (fd == null) {
throw new IOException("socket not created");
}
-
- listen_native(fd, backlog);
+ try {
+ Os.listen(fd, backlog);
+ } catch (ErrnoException e) {
+ throw e.rethrowAsIOException();
+ }
}
/**
@@ -322,14 +327,17 @@
* @param s a socket that will be used to represent the new connection.
* @throws IOException
*/
- protected void accept(LocalSocketImpl s) throws IOException
- {
+ protected void accept(LocalSocketImpl s) throws IOException {
if (fd == null) {
throw new IOException("socket not created");
}
- s.fd = accept(fd, s);
- s.mFdCreatedInternally = true;
+ try {
+ s.fd = Os.accept(fd, null /* address */);
+ s.mFdCreatedInternally = true;
+ } catch (ErrnoException e) {
+ throw e.rethrowAsIOException();
+ }
}
/**
@@ -396,7 +404,11 @@
throw new IOException("socket not created");
}
- shutdown(fd, true);
+ try {
+ Os.shutdown(fd, OsConstants.SHUT_RD);
+ } catch (ErrnoException e) {
+ throw e.rethrowAsIOException();
+ }
}
/**
@@ -410,7 +422,11 @@
throw new IOException("socket not created");
}
- shutdown(fd, false);
+ try {
+ Os.shutdown(fd, OsConstants.SHUT_WR);
+ } catch (ErrnoException e) {
+ throw e.rethrowAsIOException();
+ }
}
protected FileDescriptor getFileDescriptor()
@@ -434,24 +450,49 @@
throw new IOException("socket not created");
}
- if (optID == SocketOptions.SO_TIMEOUT) {
- return 0;
- }
-
- int value = getOption_native(fd, optID);
- switch (optID)
- {
- case SocketOptions.SO_RCVBUF:
- case SocketOptions.SO_SNDBUF:
- return value;
- case SocketOptions.SO_REUSEADDR:
- default:
- return value;
+ try {
+ Object toReturn;
+ switch (optID) {
+ case SocketOptions.SO_TIMEOUT:
+ StructTimeval timeval = Os.getsockoptTimeval(fd, OsConstants.SOL_SOCKET,
+ OsConstants.SO_SNDTIMEO);
+ toReturn = (int) timeval.toMillis();
+ break;
+ case SocketOptions.SO_RCVBUF:
+ case SocketOptions.SO_SNDBUF:
+ case SocketOptions.SO_REUSEADDR:
+ int osOpt = javaSoToOsOpt(optID);
+ toReturn = Os.getsockoptInt(fd, OsConstants.SOL_SOCKET, osOpt);
+ break;
+ case SocketOptions.SO_LINGER:
+ StructLinger linger=
+ Os.getsockoptLinger(fd, OsConstants.SOL_SOCKET, OsConstants.SO_LINGER);
+ if (!linger.isOn()) {
+ toReturn = -1;
+ } else {
+ toReturn = linger.l_linger;
+ }
+ break;
+ case SocketOptions.TCP_NODELAY:
+ toReturn = Os.getsockoptInt(fd, OsConstants.IPPROTO_TCP,
+ OsConstants.TCP_NODELAY);
+ break;
+ default:
+ throw new IOException("Unknown option: " + optID);
+ }
+ return toReturn;
+ } catch (ErrnoException e) {
+ throw e.rethrowAsIOException();
}
}
public void setOption(int optID, Object value)
throws IOException {
+
+ if (fd == null) {
+ throw new IOException("socket not created");
+ }
+
/*
* Boolean.FALSE is used to disable some options, so it
* is important to distinguish between FALSE and unset.
@@ -460,11 +501,6 @@
*/
int boolValue = -1;
int intValue = 0;
-
- if (fd == null) {
- throw new IOException("socket not created");
- }
-
if (value instanceof Integer) {
intValue = (Integer)value;
} else if (value instanceof Boolean) {
@@ -473,7 +509,39 @@
throw new IOException("bad value: " + value);
}
- setOption_native(fd, optID, boolValue, intValue);
+ try {
+ switch (optID) {
+ case SocketOptions.SO_LINGER:
+ StructLinger linger = new StructLinger(boolValue, intValue);
+ Os.setsockoptLinger(fd, OsConstants.SOL_SOCKET, OsConstants.SO_LINGER, linger);
+ break;
+ case SocketOptions.SO_TIMEOUT:
+ /*
+ * SO_TIMEOUT from the core library gets converted to
+ * SO_SNDTIMEO, but the option is supposed to set both
+ * send and receive timeouts. Note: The incoming timeout
+ * value is in milliseconds.
+ */
+ StructTimeval timeval = StructTimeval.fromMillis(intValue);
+ Os.setsockoptTimeval(fd, OsConstants.SOL_SOCKET, OsConstants.SO_SNDTIMEO,
+ timeval);
+ break;
+ case SocketOptions.SO_RCVBUF:
+ case SocketOptions.SO_SNDBUF:
+ case SocketOptions.SO_REUSEADDR:
+ int osOpt = javaSoToOsOpt(optID);
+ Os.setsockoptInt(fd, OsConstants.SOL_SOCKET, osOpt, intValue);
+ break;
+ case SocketOptions.TCP_NODELAY:
+ Os.setsockoptInt(fd, OsConstants.IPPROTO_TCP, OsConstants.TCP_NODELAY,
+ intValue);
+ break;
+ default:
+ throw new IOException("Unknown option: " + optID);
+ }
+ } catch (ErrnoException e) {
+ throw e.rethrowAsIOException();
+ }
}
/**
@@ -517,8 +585,7 @@
* @return non-null; peer credentials
* @throws IOException
*/
- public Credentials getPeerCredentials() throws IOException
- {
+ public Credentials getPeerCredentials() throws IOException {
return getPeerCredentials_native(fd);
}
@@ -528,15 +595,26 @@
* @return non-null; socket name
* @throws IOException on failure
*/
- public LocalSocketAddress getSockAddress() throws IOException
- {
+ public LocalSocketAddress getSockAddress() throws IOException {
+ // This method has never been implemented.
return null;
- //TODO implement this
- //return getSockName_native(fd);
}
@Override
protected void finalize() throws IOException {
close();
}
+
+ private static int javaSoToOsOpt(int optID) {
+ switch (optID) {
+ case SocketOptions.SO_SNDBUF:
+ return OsConstants.SO_SNDBUF;
+ case SocketOptions.SO_RCVBUF:
+ return OsConstants.SO_RCVBUF;
+ case SocketOptions.SO_REUSEADDR:
+ return OsConstants.SO_REUSEADDR;
+ default:
+ throw new UnsupportedOperationException("Unknown option: " + optID);
+ }
+ }
}
diff --git a/core/java/android/os/IPowerManager.aidl b/core/java/android/os/IPowerManager.aidl
index 0f37ac7..c4f62ba 100644
--- a/core/java/android/os/IPowerManager.aidl
+++ b/core/java/android/os/IPowerManager.aidl
@@ -46,7 +46,7 @@
boolean isDeviceIdleMode();
void reboot(boolean confirm, String reason, boolean wait);
- void shutdown(boolean confirm, boolean wait);
+ void shutdown(boolean confirm, String reason, boolean wait);
void crash(String message);
void setStayOnSetting(int val);
diff --git a/core/java/android/os/PowerManager.java b/core/java/android/os/PowerManager.java
index 9a1a03e..69974fa 100644
--- a/core/java/android/os/PowerManager.java
+++ b/core/java/android/os/PowerManager.java
@@ -387,7 +387,13 @@
* @hide
*/
public static final String REBOOT_RECOVERY = "recovery";
-
+
+ /**
+ * The value to pass as the 'reason' argument to android_reboot().
+ * @hide
+ */
+ public static final String SHUTDOWN_USER_REQUESTED = "userrequested";
+
final Context mContext;
final IPowerManager mService;
final Handler mHandler;
@@ -926,13 +932,14 @@
* Turn off the device.
*
* @param confirm If true, shows a shutdown confirmation dialog.
+ * @param reason code to pass to android_reboot() (e.g. "userrequested"), or null.
* @param wait If true, this call waits for the shutdown to complete and does not return.
*
* @hide
*/
- public void shutdown(boolean confirm, boolean wait) {
+ public void shutdown(boolean confirm, String reason, boolean wait) {
try {
- mService.shutdown(confirm, wait);
+ mService.shutdown(confirm, reason, wait);
} catch (RemoteException e) {
}
}
diff --git a/core/java/android/os/StrictMode.java b/core/java/android/os/StrictMode.java
index f10b982..87ce12c 100644
--- a/core/java/android/os/StrictMode.java
+++ b/core/java/android/os/StrictMode.java
@@ -1574,7 +1574,8 @@
*/
public static void conditionallyCheckInstanceCounts() {
VmPolicy policy = getVmPolicy();
- if (policy.classInstanceLimit.size() == 0) {
+ int policySize = policy.classInstanceLimit.size();
+ if (policySize == 0) {
return;
}
@@ -1583,15 +1584,17 @@
System.gc();
// Note: classInstanceLimit is immutable, so this is lock-free
- for (Map.Entry<Class, Integer> entry : policy.classInstanceLimit.entrySet()) {
- Class klass = entry.getKey();
- int limit = entry.getValue();
- long instances = VMDebug.countInstancesOfClass(klass, false);
- if (instances <= limit) {
- continue;
+ // Create the classes array.
+ Class[] classes = policy.classInstanceLimit.keySet().toArray(new Class[policySize]);
+ long[] instanceCounts = VMDebug.countInstancesOfClasses(classes, false);
+ for (int i = 0; i < classes.length; ++i) {
+ Class klass = classes[i];
+ int limit = policy.classInstanceLimit.get(klass);
+ long instances = instanceCounts[i];
+ if (instances > limit) {
+ Throwable tr = new InstanceCountViolation(klass, instances, limit);
+ onVmPolicyViolation(tr.getMessage(), tr);
}
- Throwable tr = new InstanceCountViolation(klass, instances, limit);
- onVmPolicyViolation(tr.getMessage(), tr);
}
}
diff --git a/core/java/android/os/Trace.java b/core/java/android/os/Trace.java
index 31b5849..4da88ee 100644
--- a/core/java/android/os/Trace.java
+++ b/core/java/android/os/Trace.java
@@ -75,6 +75,8 @@
public static final long TRACE_TAG_BIONIC = 1L << 16;
/** @hide */
public static final long TRACE_TAG_POWER = 1L << 17;
+ /** @hide */
+ public static final long TRACE_TAG_PACKAGE_MANAGER = 1L << 18;
private static final long TRACE_TAG_NOT_READY = 1L << 63;
private static final int MAX_SECTION_NAME_LEN = 127;
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 3b7f6aa..b3e3ecb 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -19006,7 +19006,7 @@
/**
* Returns the suggested minimum width that the view should use. This
- * returns the maximum of the view's minimum width)
+ * returns the maximum of the view's minimum width
* and the background's minimum width
* ({@link android.graphics.drawable.Drawable#getMinimumWidth()}).
* <p>
diff --git a/core/java/android/view/accessibility/AccessibilityEvent.java b/core/java/android/view/accessibility/AccessibilityEvent.java
index a04c4f1..2cde03d 100644
--- a/core/java/android/view/accessibility/AccessibilityEvent.java
+++ b/core/java/android/view/accessibility/AccessibilityEvent.java
@@ -372,7 +372,6 @@
* <li>{@link #getClassName()} - The class name of the source.</li>
* <li>{@link #getPackageName()} - The package name of the source.</li>
* <li>{@link #getEventTime()} - The event time.</li>
- * <li>{@link #getText()} - The text of the source's sub-tree.</li>
* <li>{@link #getParcelableData()} - The posted {@link android.app.Notification}.</li>
* <li>{@link #getText()} - Text for providing more context.</li>
* </ul>
diff --git a/core/java/android/webkit/WebViewClient.java b/core/java/android/webkit/WebViewClient.java
index de8ccc1..f2bb55a 100644
--- a/core/java/android/webkit/WebViewClient.java
+++ b/core/java/android/webkit/WebViewClient.java
@@ -415,7 +415,7 @@
* Notify the host application that the scale applied to the WebView has
* changed.
*
- * @param view he WebView that is initiating the callback.
+ * @param view The WebView that is initiating the callback.
* @param oldScale The old scale factor
* @param newScale The new scale factor
*/
diff --git a/core/java/android/widget/Adapter.java b/core/java/android/widget/Adapter.java
index 88b54bf..518718f 100644
--- a/core/java/android/widget/Adapter.java
+++ b/core/java/android/widget/Adapter.java
@@ -130,8 +130,7 @@
* type of View for all items, this method should return 1.
* </p>
* <p>
- * This method will only be called when when the adapter is set on the
- * the {@link AdapterView}.
+ * This method will only be called when the adapter is set on the {@link AdapterView}.
* </p>
*
* @return The number of types of Views that will be created by this adapter
@@ -148,4 +147,3 @@
*/
boolean isEmpty();
}
-
diff --git a/core/java/com/android/internal/app/ProcessStats.java b/core/java/com/android/internal/app/ProcessStats.java
index 27aec4e..17ca904d 100644
--- a/core/java/com/android/internal/app/ProcessStats.java
+++ b/core/java/com/android/internal/app/ProcessStats.java
@@ -3366,10 +3366,11 @@
+ pkgList.keyAt(index) + "/" + proc.mUid
+ " for multi-proc " + proc.mName + " version " + proc.mVersion);
}
+ String savedName = proc.mName;
proc = pkg.mProcesses.get(proc.mName);
if (proc == null) {
throw new IllegalStateException("Didn't create per-package process "
- + proc.mName + " in pkg " + pkg.mPackageName + "/" + pkg.mUid);
+ + savedName + " in pkg " + pkg.mPackageName + "/" + pkg.mUid);
}
holder.state = proc;
}
diff --git a/core/java/com/android/internal/app/ShutdownActivity.java b/core/java/com/android/internal/app/ShutdownActivity.java
index 97521cf..745d28f 100644
--- a/core/java/com/android/internal/app/ShutdownActivity.java
+++ b/core/java/com/android/internal/app/ShutdownActivity.java
@@ -21,6 +21,7 @@
import android.content.Intent;
import android.os.Bundle;
import android.os.IPowerManager;
+import android.os.PowerManager;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.util.Slog;
@@ -30,6 +31,7 @@
private static final String TAG = "ShutdownActivity";
private boolean mReboot;
private boolean mConfirm;
+ private boolean mUserRequested;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -38,6 +40,7 @@
Intent intent = getIntent();
mReboot = Intent.ACTION_REBOOT.equals(intent.getAction());
mConfirm = intent.getBooleanExtra(Intent.EXTRA_KEY_CONFIRM, false);
+ mUserRequested = intent.getBooleanExtra(Intent.EXTRA_USER_REQUESTED_SHUTDOWN, false);
Slog.i(TAG, "onCreate(): confirm=" + mConfirm);
Thread thr = new Thread("ShutdownActivity") {
@@ -49,7 +52,9 @@
if (mReboot) {
pm.reboot(mConfirm, null, false);
} else {
- pm.shutdown(mConfirm, false);
+ pm.shutdown(mConfirm,
+ mUserRequested ? PowerManager.SHUTDOWN_USER_REQUESTED : null,
+ false);
}
} catch (RemoteException e) {
}
diff --git a/core/java/com/android/internal/util/WithFramework.java b/core/java/com/android/internal/util/WithFramework.java
deleted file mode 100644
index 7d8596f..0000000
--- a/core/java/com/android/internal/util/WithFramework.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.internal.util;
-
-import java.lang.reflect.Method;
-
-/**
- * Binds native framework methods and then invokes a main class with the
- * remaining arguments.
- */
-class WithFramework {
-
- /**
- * Invokes main(String[]) method on class in args[0] with args[1..n].
- */
- public static void main(String[] args) throws Exception {
- if (args.length == 0) {
- printUsage();
- return;
- }
-
- Class<?> mainClass = Class.forName(args[0]);
-
- System.loadLibrary("android_runtime");
- if (registerNatives() < 0) {
- throw new RuntimeException("Error registering natives.");
- }
-
- String[] newArgs = new String[args.length - 1];
- System.arraycopy(args, 1, newArgs, 0, newArgs.length);
- Method mainMethod = mainClass.getMethod("main", String[].class);
- mainMethod.invoke(null, new Object[] { newArgs });
- }
-
- private static void printUsage() {
- System.err.println("Usage: dalvikvm " + WithFramework.class.getName()
- + " [main class] [args]");
- }
-
- /**
- * Registers native functions. See AndroidRuntime.cpp.
- */
- static native int registerNatives();
-}
diff --git a/core/jni/AndroidRuntime.cpp b/core/jni/AndroidRuntime.cpp
index a3d5b8a..0028efe 100644
--- a/core/jni/AndroidRuntime.cpp
+++ b/core/jni/AndroidRuntime.cpp
@@ -1469,20 +1469,10 @@
}
/**
- * Used by WithFramework to register native functions.
+ * Used by surface flinger's DdmConnection to register native methods from
+ * the framework.
*/
-extern "C"
-jint Java_com_android_internal_util_WithFramework_registerNatives(
- JNIEnv* env, jclass clazz) {
+extern "C" jint registerFrameworkNatives(JNIEnv* env) {
return register_jni_procs(gRegJNI, NELEM(gRegJNI), env);
}
-
-/**
- * Used by LoadClass to register native functions.
- */
-extern "C"
-jint Java_LoadClass_registerNatives(JNIEnv* env, jclass clazz) {
- return register_jni_procs(gRegJNI, NELEM(gRegJNI), env);
-}
-
} // namespace android
diff --git a/core/jni/android_net_LocalSocketImpl.cpp b/core/jni/android_net_LocalSocketImpl.cpp
index 97abe6b..c137b17 100644
--- a/core/jni/android_net_LocalSocketImpl.cpp
+++ b/core/jni/android_net_LocalSocketImpl.cpp
@@ -112,317 +112,6 @@
}
}
-/* private native void listen_native(int fd, int backlog) throws IOException; */
-static void
-socket_listen (JNIEnv *env, jobject object, jobject fileDescriptor, jint backlog)
-{
- int ret;
- int fd;
-
- fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
-
- if (env->ExceptionCheck()) {
- return;
- }
-
- ret = listen(fd, backlog);
-
- if (ret < 0) {
- jniThrowIOException(env, errno);
- return;
- }
-}
-
-/* private native FileDescriptor
-** accept (FileDescriptor fd, LocalSocketImpl s)
-** throws IOException;
-*/
-static jobject
-socket_accept (JNIEnv *env, jobject object, jobject fileDescriptor, jobject s)
-{
- union {
- struct sockaddr address;
- struct sockaddr_un un_address;
- } sa;
-
- int ret;
- int retFD;
- int fd;
- socklen_t addrlen;
-
- if (s == NULL) {
- jniThrowNullPointerException(env, NULL);
- return NULL;
- }
-
- fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
-
- if (env->ExceptionCheck()) {
- return NULL;
- }
-
- do {
- addrlen = sizeof(sa);
- ret = accept(fd, &(sa.address), &addrlen);
- } while (ret < 0 && errno == EINTR);
-
- if (ret < 0) {
- jniThrowIOException(env, errno);
- return NULL;
- }
-
- retFD = ret;
-
- return jniCreateFileDescriptor(env, retFD);
-}
-
-/* private native void shutdown(FileDescriptor fd, boolean shutdownInput) */
-
-static void
-socket_shutdown (JNIEnv *env, jobject object, jobject fileDescriptor,
- jboolean shutdownInput)
-{
- int ret;
- int fd;
-
- fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
-
- if (env->ExceptionCheck()) {
- return;
- }
-
- ret = shutdown(fd, shutdownInput ? SHUT_RD : SHUT_WR);
-
- if (ret < 0) {
- jniThrowIOException(env, errno);
- return;
- }
-}
-
-static bool
-java_opt_to_real(int optID, int* opt, int* level)
-{
- switch (optID)
- {
- case 4098:
- *opt = SO_RCVBUF;
- *level = SOL_SOCKET;
- return true;
- case 4097:
- *opt = SO_SNDBUF;
- *level = SOL_SOCKET;
- return true;
- case 4102:
- *opt = SO_SNDTIMEO;
- *level = SOL_SOCKET;
- return true;
- case 128:
- *opt = SO_LINGER;
- *level = SOL_SOCKET;
- return true;
- case 1:
- *opt = TCP_NODELAY;
- *level = IPPROTO_TCP;
- return true;
- case 4:
- *opt = SO_REUSEADDR;
- *level = SOL_SOCKET;
- return true;
-
- }
- return false;
-}
-
-static jint
-socket_getOption(JNIEnv *env, jobject object, jobject fileDescriptor, jint optID)
-{
- int ret, value;
- int opt, level;
- int fd;
-
- socklen_t size = sizeof(int);
-
- if (!java_opt_to_real(optID, &opt, &level)) {
- jniThrowIOException(env, -1);
- return 0;
- }
-
- fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
-
- if (env->ExceptionCheck()) {
- return 0;
- }
-
- switch (opt)
- {
- case SO_LINGER:
- {
- struct linger lingr;
- size = sizeof(lingr);
- ret = getsockopt(fd, level, opt, &lingr, &size);
- if (!lingr.l_onoff) {
- value = -1;
- } else {
- value = lingr.l_linger;
- }
- break;
- }
- default:
- ret = getsockopt(fd, level, opt, &value, &size);
- break;
- }
-
-
- if (ret != 0) {
- jniThrowIOException(env, errno);
- return 0;
- }
-
- return value;
-}
-
-static void socket_setOption(
- JNIEnv *env, jobject object, jobject fileDescriptor, jint optID,
- jint boolValue, jint intValue) {
- int ret;
- int optname;
- int level;
- int fd;
-
- if (!java_opt_to_real(optID, &optname, &level)) {
- jniThrowIOException(env, -1);
- return;
- }
-
- fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
-
- if (env->ExceptionCheck()) {
- return;
- }
-
- switch (optname) {
- case SO_LINGER: {
- /*
- * SO_LINGER is special because it needs to use a special
- * "linger" struct as well as use the incoming boolean
- * argument specially.
- */
- struct linger lingr;
- lingr.l_onoff = boolValue ? 1 : 0; // Force it to be 0 or 1.
- lingr.l_linger = intValue;
- ret = setsockopt(fd, level, optname, &lingr, sizeof(lingr));
- break;
- }
- case SO_SNDTIMEO: {
- /*
- * SO_TIMEOUT from the core library gets converted to
- * SO_SNDTIMEO, but the option is supposed to set both
- * send and receive timeouts. Note: The incoming timeout
- * value is in milliseconds.
- */
- struct timeval timeout;
- timeout.tv_sec = intValue / 1000;
- timeout.tv_usec = (intValue % 1000) * 1000;
-
- ret = setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO,
- (void *)&timeout, sizeof(timeout));
-
- if (ret == 0) {
- ret = setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO,
- (void *)&timeout, sizeof(timeout));
- }
-
- break;
- }
- default: {
- /*
- * In all other cases, the translated option level and
- * optname may be used directly for a call to setsockopt().
- */
- ret = setsockopt(fd, level, optname, &intValue, sizeof(intValue));
- break;
- }
- }
-
- if (ret != 0) {
- jniThrowIOException(env, errno);
- return;
- }
-}
-static jint socket_pending (JNIEnv *env, jobject object,
- jobject fileDescriptor)
-{
- int fd;
-
- fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
-
- if (env->ExceptionCheck()) {
- return (jint)-1;
- }
-
- int pending;
- int ret = ioctl(fd, TIOCOUTQ, &pending);
-
- // If this were a non-socket fd, there would be other cases to worry
- // about...
-
- //ALOGD("socket_pending, ioctl ret:%d, pending:%d", ret, pending);
- if (ret < 0) {
- jniThrowIOException(env, errno);
- return (jint) 0;
- }
-
- return (jint)pending;
-}
-static jint socket_available (JNIEnv *env, jobject object,
- jobject fileDescriptor)
-{
- int fd;
-
- fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
-
- if (env->ExceptionCheck()) {
- return (jint)-1;
- }
-
-#if 1
- int avail;
- int ret = ioctl(fd, FIONREAD, &avail);
-
- // If this were a non-socket fd, there would be other cases to worry
- // about...
-
- if (ret < 0) {
- jniThrowIOException(env, errno);
- return (jint) 0;
- }
-
- return (jint)avail;
-#else
-// there appears to be a bionic bug that prevents this version from working.
-
- ssize_t ret;
- struct msghdr msg;
-
- memset(&msg, 0, sizeof(msg));
-
- do {
- ret = recvmsg(fd, &msg, MSG_PEEK | MSG_DONTWAIT | MSG_NOSIGNAL);
- } while (ret < 0 && errno == EINTR);
-
-
- // MSG_PEEK returns 0 on EOF and EWOULDBLOCK on none available
- if (ret < 0 && errno == EWOULDBLOCK) {
- return 0;
- } if (ret < 0) {
- jniThrowIOException(env, errno);
- return -1;
- }
-
- return (jint)ret;
-#endif
-}
-
/**
* Processes ancillary data, handling only
* SCM_RIGHTS. Creates appropriate objects and sets appropriate
@@ -803,72 +492,14 @@
creds.pid, creds.uid, creds.gid);
}
-#if 0
-//TODO change this to return an instance of LocalSocketAddress
-static jobject socket_getSockName(JNIEnv *env,
- jobject object, jobject fileDescriptor)
-{
- int err;
- int fd;
-
- if (fileDescriptor == NULL) {
- jniThrowNullPointerException(env, NULL);
- return NULL;
- }
-
- fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
-
- if (env->ExceptionCheck()) {
- return NULL;
- }
-
- union {
- struct sockaddr address;
- struct sockaddr_un un_address;
- } sa;
-
- memset(&sa, 0, sizeof(sa));
-
- socklen_t namelen = sizeof(sa);
- err = getsockname(fd, &(sa.address), &namelen);
-
- if (err < 0) {
- jniThrowIOException(env, errno);
- return NULL;
- }
-
- if (sa.address.sa_family != AF_UNIX) {
- // We think we're an impl only for AF_UNIX, so this should never happen.
-
- jniThrowIOException(env, EINVAL);
- return NULL;
- }
-
- if (sa.un_address.sun_path[0] == '\0') {
- } else {
- }
-
-
-
-
-}
-#endif
-
/*
* JNI registration.
*/
static JNINativeMethod gMethods[] = {
/* name, signature, funcPtr */
- {"getOption_native", "(Ljava/io/FileDescriptor;I)I", (void*)socket_getOption},
- {"setOption_native", "(Ljava/io/FileDescriptor;III)V", (void*)socket_setOption},
{"connectLocal", "(Ljava/io/FileDescriptor;Ljava/lang/String;I)V",
(void*)socket_connect_local},
{"bindLocal", "(Ljava/io/FileDescriptor;Ljava/lang/String;I)V", (void*)socket_bind_local},
- {"listen_native", "(Ljava/io/FileDescriptor;I)V", (void*)socket_listen},
- {"accept", "(Ljava/io/FileDescriptor;Landroid/net/LocalSocketImpl;)Ljava/io/FileDescriptor;", (void*)socket_accept},
- {"shutdown", "(Ljava/io/FileDescriptor;Z)V", (void*)socket_shutdown},
- {"available_native", "(Ljava/io/FileDescriptor;)I", (void*) socket_available},
- {"pending_native", "(Ljava/io/FileDescriptor;)I", (void*) socket_pending},
{"read_native", "(Ljava/io/FileDescriptor;)I", (void*) socket_read},
{"readba_native", "([BIILjava/io/FileDescriptor;)I", (void*) socket_readba},
{"writeba_native", "([BIILjava/io/FileDescriptor;)V", (void*) socket_writeba},
@@ -876,9 +507,6 @@
{"getPeerCredentials_native",
"(Ljava/io/FileDescriptor;)Landroid/net/Credentials;",
(void*) socket_get_peer_credentials}
- //,{"getSockName_native", "(Ljava/io/FileDescriptor;)Ljava/lang/String;",
- // (void *) socket_getSockName}
-
};
int register_android_net_LocalSocketImpl(JNIEnv *env)
diff --git a/core/jni/android_os_Debug.cpp b/core/jni/android_os_Debug.cpp
index e8acd97..b969477 100644
--- a/core/jni/android_os_Debug.cpp
+++ b/core/jni/android_os_Debug.cpp
@@ -34,10 +34,7 @@
#include <errno.h>
#include <assert.h>
#include <ctype.h>
-
-#ifdef HAVE_MALLOC_H
#include <malloc.h>
-#endif
namespace android
{
@@ -128,32 +125,20 @@
static jlong android_os_Debug_getNativeHeapSize(JNIEnv *env, jobject clazz)
{
-#ifdef HAVE_MALLOC_H
struct mallinfo info = mallinfo();
return (jlong) info.usmblks;
-#else
- return -1;
-#endif
}
static jlong android_os_Debug_getNativeHeapAllocatedSize(JNIEnv *env, jobject clazz)
{
-#ifdef HAVE_MALLOC_H
struct mallinfo info = mallinfo();
return (jlong) info.uordblks;
-#else
- return -1;
-#endif
}
static jlong android_os_Debug_getNativeHeapFreeSize(JNIEnv *env, jobject clazz)
{
-#ifdef HAVE_MALLOC_H
struct mallinfo info = mallinfo();
return (jlong) info.fordblks;
-#else
- return -1;
-#endif
}
// Container used to retrieve graphics memory pss
diff --git a/core/jni/android_os_Parcel.cpp b/core/jni/android_os_Parcel.cpp
index 0f5ba83f..a14afa0 100644
--- a/core/jni/android_os_Parcel.cpp
+++ b/core/jni/android_os_Parcel.cpp
@@ -451,15 +451,11 @@
jniThrowNullPointerException(env, NULL);
return NULL;
}
- const jchar* str = env->GetStringCritical(name, 0);
- if (str == NULL) {
- // Whatever, whatever.
- jniThrowException(env, "java/lang/IllegalStateException", NULL);
+ ScopedUtfChars name8(env, name);
+ if (name8.c_str() == NULL) {
return NULL;
}
- String8 name8(reinterpret_cast<const char16_t*>(str),
- env->GetStringLength(name));
- env->ReleaseStringCritical(name, str);
+
int flags=0;
switch (mode&0x30000000) {
case 0:
@@ -482,7 +478,7 @@
if (mode&0x00000001) realMode |= S_IROTH;
if (mode&0x00000002) realMode |= S_IWOTH;
- int fd = open(name8.string(), flags, realMode);
+ int fd = open(name8.c_str(), flags, realMode);
if (fd < 0) {
jniThrowException(env, "java/io/FileNotFoundException", strerror(errno));
return NULL;
diff --git a/core/tests/overlaytests/testrunner.py b/core/tests/overlaytests/testrunner.py
index 3703f4a..2aa25ad 100755
--- a/core/tests/overlaytests/testrunner.py
+++ b/core/tests/overlaytests/testrunner.py
@@ -301,7 +301,7 @@
return self.path
def execute(self):
- returncode, stdout, stderr = _adb_shell('md5 %s' % self.path)
+ returncode, stdout, stderr = _adb_shell('md5sum %s' % self.path)
if returncode != 0:
return returncode, stdout, stderr
actual_md5 = stdout.split()[0]
diff --git a/data/keyboards/Android.mk b/data/keyboards/Android.mk
index 898efe8..4616838 100644
--- a/data/keyboards/Android.mk
+++ b/data/keyboards/Android.mk
@@ -32,7 +32,7 @@
$(hide) mkdir -p $(dir $@) && touch $@
# Run validatekeymaps uncondionally for platform build.
-droidcore all_modules : $(LOCAL_BUILT_MODULE)
+droidcore : $(LOCAL_BUILT_MODULE)
# Reset temp vars.
validatekeymaps :=
diff --git a/docs/html/guide/topics/renderscript/reference/overview.jd b/docs/html/guide/topics/renderscript/reference/overview.jd
index f85b843..169b320 100644
--- a/docs/html/guide/topics/renderscript/reference/overview.jd
+++ b/docs/html/guide/topics/renderscript/reference/overview.jd
@@ -43,7 +43,7 @@
</p>
<p> To create vector literals, use the vector type followed by the values enclosed
-between parentheses, e.g. <code>(float3)(1.0f, 2.0f, 3.0f)</code>.
+between curly braces, e.g. <code>(float3){1.0f, 2.0f, 3.0f}</code>.
</p>
<p> Entries of a vector can be accessed using different naming styles.
diff --git a/docs/html/tools/debugging/debugging-log.jd b/docs/html/tools/debugging/debugging-log.jd
index d2baaf26..e222b2a 100644
--- a/docs/html/tools/debugging/debugging-log.jd
+++ b/docs/html/tools/debugging/debugging-log.jd
@@ -284,22 +284,8 @@
<h2 id="viewingStd">Viewing stdout and stderr</h2>
<p>By default, the Android system sends <code>stdout</code> and <code>stderr</code>
- (<code>System.out</code> and <code>System.err</code>) output to <code>/dev/null</code>. In
- processes that run the Dalvik VM, you can have the system write a copy of the output to the log
- file. In this case, the system writes the messages to the log using the log tags
- <code>stdout</code> and <code>stderr</code>, both with priority <code>I</code>.</p>
-
- <p>To route the output in this way, you stop a running emulator/device instance and then use the
- shell command <code>setprop</code> to enable the redirection of output. Here's how you do it:</p>
- <pre>
-$ adb shell stop
-$ adb shell setprop log.redirect-stdio true
-$ adb shell start
-</pre>
-
- <p>The system retains this setting until you terminate the emulator/device instance. To use the
- setting as a default on the emulator/device instance, you can add an entry to
- <code>/data/local.prop</code> on the device.</p>
+ output to <code>/dev/null</code>. (The Java <code>System.out</code> and <code>System.err</code>
+ streams go to the log.)
<h2 id="DebuggingWebPages">Debugging Web Apps</h2>
<p>
diff --git a/docs/knowntags.txt b/docs/knowntags.txt
index 5bebabb..3b7c8c7 100644
--- a/docs/knowntags.txt
+++ b/docs/knowntags.txt
@@ -15,7 +15,6 @@
#
# The grandfathered list. We should get rid of these if possible.
#
-@ToBeFixed
@stable
@com.intel.drl.spec_ref
@ar.org.fitc.spec_ref
diff --git a/libs/androidfw/AssetManager.cpp b/libs/androidfw/AssetManager.cpp
index 2dc1c96..623ea89 100644
--- a/libs/androidfw/AssetManager.cpp
+++ b/libs/androidfw/AssetManager.cpp
@@ -34,7 +34,7 @@
#include <utils/String8.h>
#include <utils/threads.h>
#include <utils/Timers.h>
-#ifdef HAVE_ANDROID_OS
+#ifdef __ANDROID__
#include <cutils/trace.h>
#endif
@@ -54,7 +54,7 @@
_rc; })
#endif
-#ifdef HAVE_ANDROID_OS
+#ifdef __ANDROID__
#define MY_TRACE_BEGIN(x) ATRACE_BEGIN(x)
#define MY_TRACE_END() ATRACE_END()
#else
@@ -229,7 +229,7 @@
*cookie = static_cast<int32_t>(mAssetPaths.size());
}
-#ifdef HAVE_ANDROID_OS
+#ifdef __ANDROID__
// Load overlays, if any
asset_path oap;
for (size_t idx = 0; mZipSet.getOverlay(ap.path, idx, &oap); idx++) {
@@ -657,7 +657,7 @@
ALOGV("Creating shared resources for %s", ap.path.string());
sharedRes = new ResTable();
sharedRes->add(ass, idmap, nextEntryIdx + 1, false);
-#ifdef HAVE_ANDROID_OS
+#ifdef __ANDROID__
const char* data = getenv("ANDROID_DATA");
LOG_ALWAYS_FATAL_IF(data == NULL, "ANDROID_DATA not set");
String8 overlaysListPath(data);
@@ -1545,7 +1545,7 @@
*/
int dirNameLen = dirName.length();
void *iterationCookie;
- if (!pZip->startIteration(&iterationCookie)) {
+ if (!pZip->startIteration(&iterationCookie, dirName.string(), NULL)) {
ALOGW("ZipFileRO::startIteration returned false");
return false;
}
@@ -1560,9 +1560,7 @@
continue;
}
//printf("Comparing %s in %s?\n", nameBuf, dirName.string());
- if (dirNameLen == 0 ||
- (strncmp(nameBuf, dirName.string(), dirNameLen) == 0 &&
- nameBuf[dirNameLen] == '/'))
+ if (dirNameLen == 0 || nameBuf[dirNameLen] == '/')
{
const char* cp;
const char* nextSlash;
diff --git a/libs/androidfw/ResourceTypes.cpp b/libs/androidfw/ResourceTypes.cpp
index 62aabb1..806eeda 100644
--- a/libs/androidfw/ResourceTypes.cpp
+++ b/libs/androidfw/ResourceTypes.cpp
@@ -47,7 +47,7 @@
namespace android {
-#ifdef HAVE_WINSOCK
+#if defined(_WIN32)
#undef nhtol
#undef htonl
#define ntohl(x) ( ((x) << 24) | (((x) >> 24) & 255) | (((x) << 8) & 0xff0000) | (((x) >> 8) & 0xff00) )
@@ -727,7 +727,7 @@
AutoMutex lock(mDecodeLock);
if (mCache == NULL) {
-#ifndef HAVE_ANDROID_OS
+#ifndef __ANDROID__
if (kDebugStringPoolNoisy) {
ALOGI("CREATING STRING CACHE OF %zu bytes",
mHeader->stringCount*sizeof(char16_t**));
diff --git a/libs/androidfw/ZipFileRO.cpp b/libs/androidfw/ZipFileRO.cpp
index a6f6d8c..49fe8a2 100644
--- a/libs/androidfw/ZipFileRO.cpp
+++ b/libs/androidfw/ZipFileRO.cpp
@@ -39,7 +39,7 @@
class _ZipEntryRO {
public:
ZipEntry entry;
- ZipEntryName name;
+ ZipString name;
void *cookie;
_ZipEntryRO() : cookie(NULL) {}
@@ -80,7 +80,7 @@
{
_ZipEntryRO* data = new _ZipEntryRO;
- data->name = ZipEntryName(entryName);
+ data->name = ZipString(entryName);
const int32_t error = FindEntry(mHandle, data->name, &(data->entry));
if (error) {
@@ -133,8 +133,8 @@
bool ZipFileRO::startIteration(void** cookie, const char* prefix, const char* suffix)
{
_ZipEntryRO* ze = new _ZipEntryRO;
- ZipEntryName pe(prefix ? prefix : "");
- ZipEntryName se(suffix ? suffix : "");
+ ZipString pe(prefix ? prefix : "");
+ ZipString se(suffix ? suffix : "");
int32_t error = StartIteration(mHandle, &(ze->cookie),
prefix ? &pe : NULL,
suffix ? &se : NULL);
diff --git a/libs/hwui/AnimatorManager.cpp b/libs/hwui/AnimatorManager.cpp
index 0dababd..cd30b18 100644
--- a/libs/hwui/AnimatorManager.cpp
+++ b/libs/hwui/AnimatorManager.cpp
@@ -124,8 +124,6 @@
}
void AnimatorManager::animateNoDamage(TreeInfo& info) {
- if (!mAnimators.size()) return;
-
animateCommon(info);
}
@@ -169,7 +167,7 @@
};
void AnimatorManager::endAllActiveAnimators() {
- ALOGD("endAllStagingAnimators on %p (%s) with handle %p",
+ ALOGD("endAllActiveAnimators on %p (%s) with handle %p",
&mParent, mParent.getName(), mAnimationHandle);
EndActiveAnimatorsFunctor functor(mAnimationHandle->context());
for_each(mAnimators.begin(), mAnimators.end(), functor);
diff --git a/libs/hwui/Extensions.cpp b/libs/hwui/Extensions.cpp
index 2a82216..d96775a 100644
--- a/libs/hwui/Extensions.cpp
+++ b/libs/hwui/Extensions.cpp
@@ -58,6 +58,7 @@
mHasTiledRendering = hasGlExtension("GL_QCOM_tiled_rendering");
mHas1BitStencil = hasGlExtension("GL_OES_stencil1");
mHas4BitStencil = hasGlExtension("GL_OES_stencil4");
+ mHasUnpackSubImage = hasGlExtension("GL_EXT_unpack_subimage");
// Query EGL extensions
findExtensions(eglQueryString(eglGetCurrentDisplay(), EGL_EXTENSIONS), mEglExtensionList);
diff --git a/libs/hwui/Extensions.h b/libs/hwui/Extensions.h
index e7d317d..a4eef0f 100644
--- a/libs/hwui/Extensions.h
+++ b/libs/hwui/Extensions.h
@@ -44,7 +44,7 @@
inline bool has1BitStencil() const { return mHas1BitStencil; }
inline bool has4BitStencil() const { return mHas4BitStencil; }
inline bool hasNvSystemTime() const { return mHasNvSystemTime; }
- inline bool hasUnpackRowLength() const { return mVersionMajor >= 3; }
+ inline bool hasUnpackRowLength() const { return mVersionMajor >= 3 || mHasUnpackSubImage; }
inline bool hasPixelBufferObjects() const { return mVersionMajor >= 3; }
inline bool hasOcclusionQueries() const { return mVersionMajor >= 3; }
inline bool hasFloatTextures() const { return mVersionMajor >= 3; }
@@ -71,6 +71,7 @@
bool mHas1BitStencil;
bool mHas4BitStencil;
bool mHasNvSystemTime;
+ bool mHasUnpackSubImage;
int mVersionMajor;
int mVersionMinor;
diff --git a/libs/hwui/FontRenderer.cpp b/libs/hwui/FontRenderer.cpp
index 35051b7..9c2c119 100644
--- a/libs/hwui/FontRenderer.cpp
+++ b/libs/hwui/FontRenderer.cpp
@@ -474,7 +474,6 @@
if (!mFunctor) return;
bool first = true;
- bool forceRebind = false;
for (uint32_t i = 0; i < cacheTextures.size(); i++) {
CacheTexture* texture = cacheTextures[i];
if (texture->canDraw()) {
@@ -487,7 +486,6 @@
mFunctor->draw(*texture, mLinearFiltering);
texture->resetMesh();
- forceRebind = false;
}
}
}
diff --git a/media/java/android/media/MediaMetadataRetriever.java b/media/java/android/media/MediaMetadataRetriever.java
index a3ff080..7dd70d4 100644
--- a/media/java/android/media/MediaMetadataRetriever.java
+++ b/media/java/android/media/MediaMetadataRetriever.java
@@ -64,9 +64,7 @@
throw new IllegalArgumentException();
}
- FileInputStream is = null;
- try {
- is = new FileInputStream(path);
+ try (FileInputStream is = new FileInputStream(path)) {
FileDescriptor fd = is.getFD();
setDataSource(fd, 0, 0x7ffffffffffffffL);
} catch (FileNotFoundException fileEx) {
@@ -74,12 +72,6 @@
} catch (IOException ioEx) {
throw new IllegalArgumentException();
}
-
- try {
- if (is != null) {
- is.close();
- }
- } catch (Exception e) {}
}
/**
diff --git a/media/java/android/media/MediaPlayer.java b/media/java/android/media/MediaPlayer.java
index 13b2878..bbd4c30 100644
--- a/media/java/android/media/MediaPlayer.java
+++ b/media/java/android/media/MediaPlayer.java
@@ -793,7 +793,7 @@
* <li> {@link #VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING}
* </ul>
*
- * @param mode target video scaling mode. Most be one of the supported
+ * @param mode target video scaling mode. Must be one of the supported
* video scaling modes; otherwise, IllegalArgumentException will be thrown.
*
* @see MediaPlayer#VIDEO_SCALING_MODE_SCALE_TO_FIT
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/MediaInserterTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/MediaInserterTest.java
index eb1a589..05df014 100644
--- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/MediaInserterTest.java
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/MediaInserterTest.java
@@ -27,12 +27,9 @@
import android.test.InstrumentationTestCase;
import android.test.suitebuilder.annotation.SmallTest;
-import dalvik.annotation.TestTargetClass;
-
import org.easymock.EasyMock;
import org.easymock.IArgumentMatcher;
-@TestTargetClass(MediaInserter.class)
public class MediaInserterTest extends InstrumentationTestCase {
private MediaInserter mMediaInserter;
diff --git a/packages/InputDevices/Android.mk b/packages/InputDevices/Android.mk
index f537022..e7190dc 100644
--- a/packages/InputDevices/Android.mk
+++ b/packages/InputDevices/Android.mk
@@ -42,7 +42,7 @@
$(hide) mkdir -p $(dir $@) && touch $@
# Run validatekeymaps unconditionally for platform build.
-droidcore all_modules : $(LOCAL_BUILT_MODULE)
+droidcore : $(LOCAL_BUILT_MODULE)
# Reset temp vars.
validatekeymaps :=
diff --git a/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java b/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java
index 8556afc..5a6f3c9 100644
--- a/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java
+++ b/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java
@@ -236,7 +236,9 @@
Log.d(TAG, "Visibility changed to visible=" + visible);
}
mVisible = visible;
- drawFrame();
+ if (visible) {
+ drawFrame();
+ }
}
}
diff --git a/rs/java/android/renderscript/Allocation.java b/rs/java/android/renderscript/Allocation.java
index 0a50593..a4876b9 100644
--- a/rs/java/android/renderscript/Allocation.java
+++ b/rs/java/android/renderscript/Allocation.java
@@ -1505,7 +1505,7 @@
}
final byte[] data = fp.getData();
- int data_length = fp.getPos();
+ int data_length = data.length;
int eSize = mType.mElement.mElements[component_number].getBytesSize();
eSize *= mType.mElement.mArraySizes[component_number];
diff --git a/rs/java/android/renderscript/RenderScript.java b/rs/java/android/renderscript/RenderScript.java
index 8b1a032..a2967e8 100644
--- a/rs/java/android/renderscript/RenderScript.java
+++ b/rs/java/android/renderscript/RenderScript.java
@@ -30,6 +30,8 @@
import android.os.Trace;
import java.util.ArrayList;
+// TODO: Clean up the whitespace that separates methods in this class.
+
/**
* This class provides access to a RenderScript context, which controls RenderScript
* initialization, resource management, and teardown. An instance of the RenderScript
@@ -88,6 +90,21 @@
*/
public static final int CREATE_FLAG_LOW_POWER = 0x0004;
+ /**
+ * @hide
+ * Context creation flag which instructs the implementation to wait for
+ * a debugger to be attached before continuing execution.
+ */
+ public static final int CREATE_FLAG_WAIT_FOR_ATTACH = 0x0008;
+
+ /**
+ * @hide
+ * Context creation flag which specifies that optimization level 0 is
+ * passed to the device compiler upon execution of the RenderScript kernel.
+ * The default optimization level is 3.
+ */
+ public static final int CREATE_FLAG_OPT_LEVEL_0 = 0x0010;
+
/*
* Detect the bitness of the VM to allow FieldPacker to do the right thing.
*/
@@ -726,6 +743,14 @@
rsnScriptForEach(mContext, id, slot, ains, aout, params, limits);
}
+ native void rsnScriptReduce(long con, long id, int slot, long ain,
+ long aout, int[] limits);
+ synchronized void nScriptReduce(long id, int slot, long ain, long aout,
+ int[] limits) {
+ validate();
+ rsnScriptReduce(mContext, id, slot, ain, aout, limits);
+ }
+
native void rsnScriptInvokeV(long con, long id, int slot, byte[] params);
synchronized void nScriptInvokeV(long id, int slot, byte[] params) {
validate();
@@ -1356,7 +1381,8 @@
return null;
}
- if ((flags & ~(CREATE_FLAG_LOW_LATENCY | CREATE_FLAG_LOW_POWER)) != 0) {
+ if ((flags & ~(CREATE_FLAG_LOW_LATENCY | CREATE_FLAG_LOW_POWER |
+ CREATE_FLAG_WAIT_FOR_ATTACH | CREATE_FLAG_OPT_LEVEL_0)) != 0) {
throw new RSIllegalArgumentException("Invalid flags passed.");
}
diff --git a/rs/java/android/renderscript/Script.java b/rs/java/android/renderscript/Script.java
index 7cd6d09..ed4c6c7 100644
--- a/rs/java/android/renderscript/Script.java
+++ b/rs/java/android/renderscript/Script.java
@@ -283,6 +283,35 @@
mRS.nScriptForEach(getID(mRS), slot, in_ids, out_id, params, limits);
}
+ /**
+ * Only intended for use by generated reflected code.
+ *
+ * @hide
+ */
+ protected void reduce(int slot, Allocation ain, Allocation aout, LaunchOptions sc) {
+ mRS.validate();
+ mRS.validateObject(ain);
+ mRS.validateObject(aout);
+
+ if (ain == null || aout == null) {
+ throw new RSIllegalArgumentException(
+ "Both ain and aout are required to be non-null.");
+ }
+
+ long in_id = ain.getID(mRS);
+ long out_id = aout.getID(mRS);
+
+ int[] limits = null;
+ if (sc != null) {
+ limits = new int[2];
+
+ limits[0] = sc.xstart;
+ limits[1] = sc.xend;
+ }
+
+ mRS.nScriptReduce(getID(mRS), slot, in_id, out_id, limits);
+ }
+
long[] mInIdsBuffer;
Script(long id, RenderScript rs) {
@@ -291,7 +320,6 @@
mInIdsBuffer = new long[1];
}
-
/**
* Only intended for use by generated reflected code.
*
diff --git a/rs/java/android/renderscript/ScriptIntrinsicBlend.java b/rs/java/android/renderscript/ScriptIntrinsicBlend.java
index 6b09bb7..fdcd61b 100644
--- a/rs/java/android/renderscript/ScriptIntrinsicBlend.java
+++ b/rs/java/android/renderscript/ScriptIntrinsicBlend.java
@@ -406,6 +406,8 @@
/**
* Sets dst = {src.r ^ dst.r, src.g ^ dst.g, src.b ^ dst.b, src.a ^ dst.a}
*
+ * <b>Note:</b> this is NOT the Porter/Duff XOR mode; this is a bitwise xor.
+ *
* @param ain The source buffer
* @param aout The destination buffer
* @param opt LaunchOptions for clipping
diff --git a/rs/jni/android_renderscript_RenderScript.cpp b/rs/jni/android_renderscript_RenderScript.cpp
index ffc4fd8..0419d33 100644
--- a/rs/jni/android_renderscript_RenderScript.cpp
+++ b/rs/jni/android_renderscript_RenderScript.cpp
@@ -1452,7 +1452,7 @@
rsAllocationElementRead((RsContext)con, (RsAllocation)alloc,
xoff, yoff, zoff,
lod, ptr, sizeBytes, compIdx);
- _env->ReleaseByteArrayElements(data, ptr, JNI_ABORT);
+ _env->ReleaseByteArrayElements(data, ptr, 0);
}
// Copies from the Allocation pointed to by _alloc into the Java object data.
@@ -1948,6 +1948,59 @@
}
}
+static void
+nScriptReduce(JNIEnv *_env, jobject _this, jlong con, jlong script, jint slot,
+ jlong ain, jlong aout, jintArray limits)
+{
+ if (kLogApi) {
+ ALOGD("nScriptReduce, con(%p), s(%p), slot(%i) ain(%" PRId64 ") aout(%" PRId64 ")", (RsContext)con, (void *)script, slot, ain, aout);
+ }
+
+ RsScriptCall sc, *sca = nullptr;
+ uint32_t sc_size = 0;
+
+ jint limit_len = 0;
+ jint *limit_ptr = nullptr;
+
+ // If the caller passed limits, reflect them in the RsScriptCall.
+ if (limits != nullptr) {
+ limit_len = _env->GetArrayLength(limits);
+ limit_ptr = _env->GetIntArrayElements(limits, nullptr);
+
+ // We expect to be passed an array [x1, x2] which specifies
+ // the sub-range for a 1-dimensional reduction.
+ assert(limit_len == 2);
+ UNUSED(limit_len); // As the assert might not be compiled.
+
+ sc.xStart = limit_ptr[0];
+ sc.xEnd = limit_ptr[1];
+ sc.yStart = 0;
+ sc.yEnd = 0;
+ sc.zStart = 0;
+ sc.zEnd = 0;
+ sc.strategy = RS_FOR_EACH_STRATEGY_DONT_CARE;
+ sc.arrayStart = 0;
+ sc.arrayEnd = 0;
+ sc.array2Start = 0;
+ sc.array2End = 0;
+ sc.array3Start = 0;
+ sc.array3End = 0;
+ sc.array4Start = 0;
+ sc.array4End = 0;
+
+ sca = ≻
+ sc_size = sizeof(sc);
+ }
+
+ rsScriptReduce((RsContext)con, (RsScript)script, slot,
+ (RsAllocation)ain, (RsAllocation)aout,
+ sca, sc_size);
+
+ if (limits != nullptr) {
+ _env->ReleaseIntArrayElements(limits, limit_ptr, JNI_ABORT);
+ }
+}
+
// -----------------------------------
static jlong
@@ -2531,6 +2584,7 @@
{"rsnScriptInvokeV", "(JJI[B)V", (void*)nScriptInvokeV },
{"rsnScriptForEach", "(JJI[JJ[B[I)V", (void*)nScriptForEach },
+{"rsnScriptReduce", "(JJIJJ[I)V", (void*)nScriptReduce },
{"rsnScriptSetVarI", "(JJII)V", (void*)nScriptSetVarI },
{"rsnScriptGetVarI", "(JJI)I", (void*)nScriptGetVarI },
diff --git a/services/core/java/com/android/server/AlarmManagerService.java b/services/core/java/com/android/server/AlarmManagerService.java
index d58d3721..4288fa2 100644
--- a/services/core/java/com/android/server/AlarmManagerService.java
+++ b/services/core/java/com/android/server/AlarmManagerService.java
@@ -516,10 +516,10 @@
public int compare(Batch b1, Batch b2) {
long when1 = b1.start;
long when2 = b2.start;
- if (when1 - when2 > 0) {
+ if (when1 > when2) {
return 1;
}
- if (when1 - when2 < 0) {
+ if (when1 < when2) {
return -1;
}
return 0;
@@ -1932,10 +1932,10 @@
public int compare(Alarm a1, Alarm a2) {
long when1 = a1.whenElapsed;
long when2 = a2.whenElapsed;
- if (when1 - when2 > 0) {
+ if (when1 > when2) {
return 1;
}
- if (when1 - when2 < 0) {
+ if (when1 < when2) {
return -1;
}
return 0;
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index 3d523d9..b60c22d 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -1204,6 +1204,7 @@
String mMemWatchDumpFile;
int mMemWatchDumpPid;
int mMemWatchDumpUid;
+ String mTrackAllocationApp = null;
final long[] mTmpLong = new long[1];
@@ -4715,15 +4716,6 @@
File tracesFile = new File(tracesPath);
try {
- File tracesDir = tracesFile.getParentFile();
- if (!tracesDir.exists()) {
- tracesDir.mkdirs();
- if (!SELinux.restorecon(tracesDir)) {
- return null;
- }
- }
- FileUtils.setPermissions(tracesDir.getPath(), 0775, -1, -1); // drwxrwxr-x
-
if (clearTraces && tracesFile.exists()) tracesFile.delete();
tracesFile.createNewFile();
FileUtils.setPermissions(tracesFile.getPath(), 0666, -1, -1); // -rw-rw-rw-
@@ -4826,14 +4818,6 @@
final File tracesDir = tracesFile.getParentFile();
final File tracesTmp = new File(tracesDir, "__tmp__");
try {
- if (!tracesDir.exists()) {
- tracesDir.mkdirs();
- if (!SELinux.restorecon(tracesDir.getPath())) {
- return;
- }
- }
- FileUtils.setPermissions(tracesDir.getPath(), 0775, -1, -1); // drwxrwxr-x
-
if (tracesFile.exists()) {
tracesTmp.delete();
tracesFile.renameTo(tracesTmp);
@@ -6065,6 +6049,11 @@
enableOpenGlTrace = true;
mOpenGlTraceApp = null;
}
+ boolean enableTrackAllocation = false;
+ if (mTrackAllocationApp != null && mTrackAllocationApp.equals(processName)) {
+ enableTrackAllocation = true;
+ mTrackAllocationApp = null;
+ }
// If the app is being launched for restore or full backup, set it up specially
boolean isRestrictedBackupMode = false;
@@ -6093,7 +6082,7 @@
thread.bindApplication(processName, appInfo, providers, app.instrumentationClass,
profilerInfo, app.instrumentationArguments, app.instrumentationWatcher,
app.instrumentationUiAutomationConnection, testMode, enableOpenGlTrace,
- isRestrictedBackupMode || !normalMode, app.persistent,
+ enableTrackAllocation, isRestrictedBackupMode || !normalMode, app.persistent,
new Configuration(mConfiguration), app.compat,
getCommonServicesLocked(app.isolated),
mCoreSettingsObserver.getCoreSettingsLocked());
@@ -10539,7 +10528,7 @@
synchronized (this) {
boolean isDebuggable = "1".equals(SystemProperties.get(SYSTEM_DEBUGGABLE, "0"));
if (!isDebuggable) {
- if ((app.flags&ApplicationInfo.FLAG_DEBUGGABLE) == 0) {
+ if ((app.flags & ApplicationInfo.FLAG_DEBUGGABLE) == 0) {
throw new SecurityException("Process not debuggable: " + app.packageName);
}
}
@@ -10548,11 +10537,24 @@
}
}
+ void setTrackAllocationApp(ApplicationInfo app, String processName) {
+ synchronized (this) {
+ boolean isDebuggable = "1".equals(SystemProperties.get(SYSTEM_DEBUGGABLE, "0"));
+ if (!isDebuggable) {
+ if ((app.flags & ApplicationInfo.FLAG_DEBUGGABLE) == 0) {
+ throw new SecurityException("Process not debuggable: " + app.packageName);
+ }
+ }
+
+ mTrackAllocationApp = processName;
+ }
+ }
+
void setProfileApp(ApplicationInfo app, String processName, ProfilerInfo profilerInfo) {
synchronized (this) {
boolean isDebuggable = "1".equals(SystemProperties.get(SYSTEM_DEBUGGABLE, "0"));
if (!isDebuggable) {
- if ((app.flags&ApplicationInfo.FLAG_DEBUGGABLE) == 0) {
+ if ((app.flags & ApplicationInfo.FLAG_DEBUGGABLE) == 0) {
throw new SecurityException("Process not debuggable: " + app.packageName);
}
}
@@ -13614,6 +13616,15 @@
pw.println(" mOpenGlTraceApp=" + mOpenGlTraceApp);
}
}
+ if (mTrackAllocationApp != null) {
+ if (dumpPackage == null || dumpPackage.equals(mTrackAllocationApp)) {
+ if (needSep) {
+ pw.println();
+ needSep = false;
+ }
+ pw.println(" mTrackAllocationApp=" + mTrackAllocationApp);
+ }
+ }
if (mProfileApp != null || mProfileProc != null || mProfileFile != null
|| mProfileFd != null) {
if (dumpPackage == null || dumpPackage.equals(mProfileApp)) {
diff --git a/services/core/java/com/android/server/am/ActivityStackSupervisor.java b/services/core/java/com/android/server/am/ActivityStackSupervisor.java
index 7c79661..c1cfc75 100644
--- a/services/core/java/com/android/server/am/ActivityStackSupervisor.java
+++ b/services/core/java/com/android/server/am/ActivityStackSupervisor.java
@@ -884,20 +884,20 @@
aInfo.applicationInfo.packageName, aInfo.name));
// Don't debug things in the system process
- if ((startFlags&ActivityManager.START_FLAG_DEBUG) != 0) {
- if (!aInfo.processName.equals("system")) {
+ if (!aInfo.processName.equals("system")) {
+ if ((startFlags & ActivityManager.START_FLAG_DEBUG) != 0) {
mService.setDebugApp(aInfo.processName, true, false);
}
- }
- if ((startFlags&ActivityManager.START_FLAG_OPENGL_TRACES) != 0) {
- if (!aInfo.processName.equals("system")) {
+ if ((startFlags & ActivityManager.START_FLAG_OPENGL_TRACES) != 0) {
mService.setOpenGlTraceApp(aInfo.applicationInfo, aInfo.processName);
}
- }
- if (profilerInfo != null) {
- if (!aInfo.processName.equals("system")) {
+ if ((startFlags & ActivityManager.START_FLAG_TRACK_ALLOCATION) != 0) {
+ mService.setTrackAllocationApp(aInfo.applicationInfo, aInfo.processName);
+ }
+
+ if (profilerInfo != null) {
mService.setProfileApp(aInfo.applicationInfo, aInfo.processName, profilerInfo);
}
}
diff --git a/services/core/java/com/android/server/am/NativeCrashListener.java b/services/core/java/com/android/server/am/NativeCrashListener.java
index d42d415..d0973d5 100644
--- a/services/core/java/com/android/server/am/NativeCrashListener.java
+++ b/services/core/java/com/android/server/am/NativeCrashListener.java
@@ -21,6 +21,7 @@
import android.system.Os;
import android.system.StructTimeval;
import android.system.StructUcred;
+import android.system.UnixSocketAddress;
import android.util.Slog;
import static android.system.OsConstants.*;
@@ -30,7 +31,6 @@
import java.io.FileDescriptor;
import java.io.InterruptedIOException;
import java.net.InetSocketAddress;
-import java.net.InetUnixAddress;
/**
* Set up a Unix domain socket that debuggerd will connect() to in
@@ -117,16 +117,16 @@
try {
FileDescriptor serverFd = Os.socket(AF_UNIX, SOCK_STREAM, 0);
- final InetUnixAddress sockAddr = new InetUnixAddress(DEBUGGERD_SOCKET_PATH);
- Os.bind(serverFd, sockAddr, 0);
+ final UnixSocketAddress sockAddr = UnixSocketAddress.createFileSystem(
+ DEBUGGERD_SOCKET_PATH);
+ Os.bind(serverFd, sockAddr);
Os.listen(serverFd, 1);
while (true) {
- InetSocketAddress peer = new InetSocketAddress();
FileDescriptor peerFd = null;
try {
if (MORE_DEBUG) Slog.v(TAG, "Waiting for debuggerd connection");
- peerFd = Os.accept(serverFd, peer);
+ peerFd = Os.accept(serverFd, null /* peerAddress */);
if (MORE_DEBUG) Slog.v(TAG, "Got debuggerd socket " + peerFd);
if (peerFd != null) {
// Only the superuser is allowed to talk to us over this socket
diff --git a/services/core/java/com/android/server/job/JobServiceContext.java b/services/core/java/com/android/server/job/JobServiceContext.java
index bb4e388..d26319b 100644
--- a/services/core/java/com/android/server/job/JobServiceContext.java
+++ b/services/core/java/com/android/server/job/JobServiceContext.java
@@ -73,7 +73,7 @@
private static final long OP_TIMEOUT_MILLIS = 8 * 1000;
private static final String[] VERB_STRINGS = {
- "VERB_BINDING", "VERB_STARTING", "VERB_EXECUTING", "VERB_STOPPING"
+ "VERB_BINDING", "VERB_STARTING", "VERB_EXECUTING", "VERB_STOPPING", "VERB_FINISHED"
};
// States that a job occupies while interacting with the client.
@@ -81,6 +81,7 @@
static final int VERB_STARTING = 1;
static final int VERB_EXECUTING = 2;
static final int VERB_STOPPING = 3;
+ static final int VERB_FINISHED = 4;
// Messages that result from interactions with the client service.
/** System timed out waiting for a response. */
@@ -172,6 +173,7 @@
mRunningJob = null;
mParams = null;
mExecutionStartTimeElapsed = 0L;
+ mVerb = VERB_FINISHED;
removeOpTimeOut();
return false;
}
@@ -307,8 +309,8 @@
break;
case MSG_CALLBACK:
if (DEBUG) {
- Slog.d(TAG, "MSG_CALLBACK of : " + mRunningJob + " v:" +
- (mVerb >= 0 ? VERB_STRINGS[mVerb] : "[invalid]"));
+ Slog.d(TAG, "MSG_CALLBACK of : " + mRunningJob
+ + " v:" + VERB_STRINGS[mVerb]);
}
removeOpTimeOut();
@@ -524,8 +526,12 @@
* we want to clean up internally.
*/
private void closeAndCleanupJobH(boolean reschedule) {
- final JobStatus completedJob = mRunningJob;
+ final JobStatus completedJob;
synchronized (mLock) {
+ if (mVerb == VERB_FINISHED) {
+ return;
+ }
+ completedJob = mRunningJob;
try {
mBatteryStats.noteJobFinish(mRunningJob.getName(), mRunningJob.getUid());
} catch (RemoteException e) {
@@ -538,7 +544,7 @@
mWakeLock = null;
mRunningJob = null;
mParams = null;
- mVerb = -1;
+ mVerb = VERB_FINISHED;
mCancelled.set(false);
service = null;
mAvailable = true;
diff --git a/services/core/java/com/android/server/job/JobStore.java b/services/core/java/com/android/server/job/JobStore.java
index 24d4f15..11e7605 100644
--- a/services/core/java/com/android/server/job/JobStore.java
+++ b/services/core/java/com/android/server/job/JobStore.java
@@ -457,7 +457,7 @@
while (eventType != XmlPullParser.START_TAG &&
eventType != XmlPullParser.END_DOCUMENT) {
eventType = parser.next();
- Slog.d(TAG, parser.getName());
+ Slog.d(TAG, "Start tag: " + parser.getName());
}
if (eventType == XmlPullParser.END_DOCUMENT) {
if (DEBUG) {
diff --git a/services/core/java/com/android/server/power/PowerManagerService.java b/services/core/java/com/android/server/power/PowerManagerService.java
index b920f97..7ebb7f8 100644
--- a/services/core/java/com/android/server/power/PowerManagerService.java
+++ b/services/core/java/com/android/server/power/PowerManagerService.java
@@ -2269,7 +2269,7 @@
public void run() {
synchronized (this) {
if (shutdown) {
- ShutdownThread.shutdown(mContext, confirm);
+ ShutdownThread.shutdown(mContext, reason, confirm);
} else {
ShutdownThread.reboot(mContext, reason, confirm);
}
@@ -2546,9 +2546,14 @@
/**
* Low-level function turn the device off immediately, without trying
* to be clean. Most people should use {@link ShutdownThread} for a clean shutdown.
+ *
+ * @param reason code to pass to android_reboot() (e.g. "userrequested"), or null.
*/
- public static void lowLevelShutdown() {
- SystemProperties.set("sys.powerctl", "shutdown");
+ public static void lowLevelShutdown(String reason) {
+ if (reason == null) {
+ reason = "";
+ }
+ SystemProperties.set("sys.powerctl", "shutdown," + reason);
}
/**
@@ -3277,12 +3282,12 @@
* @param wait If true, this call waits for the shutdown to complete and does not return.
*/
@Override // Binder call
- public void shutdown(boolean confirm, boolean wait) {
+ public void shutdown(boolean confirm, String reason, boolean wait) {
mContext.enforceCallingOrSelfPermission(android.Manifest.permission.REBOOT, null);
final long ident = Binder.clearCallingIdentity();
try {
- shutdownOrRebootInternal(true, confirm, null, wait);
+ shutdownOrRebootInternal(true, confirm, reason, wait);
} finally {
Binder.restoreCallingIdentity(ident);
}
diff --git a/services/core/java/com/android/server/power/ShutdownThread.java b/services/core/java/com/android/server/power/ShutdownThread.java
index dd8648d..ac6a28e 100644
--- a/services/core/java/com/android/server/power/ShutdownThread.java
+++ b/services/core/java/com/android/server/power/ShutdownThread.java
@@ -88,7 +88,7 @@
private static boolean mReboot;
private static boolean mRebootSafeMode;
private static boolean mRebootUpdate;
- private static String mRebootReason;
+ private static String mReason;
// Provides shutdown assurance in case the system_server is killed
public static final String SHUTDOWN_ACTION_PROPERTY = "sys.shutdown.requested";
@@ -124,11 +124,13 @@
* is shown.
*
* @param context Context used to display the shutdown progress dialog.
+ * @param reason code to pass to android_reboot() (e.g. "userrequested"), or null.
* @param confirm true if user confirmation is needed before shutting down.
*/
- public static void shutdown(final Context context, boolean confirm) {
+ public static void shutdown(final Context context, String reason, boolean confirm) {
mReboot = false;
mRebootSafeMode = false;
+ mReason = reason;
shutdownInner(context, confirm);
}
@@ -212,7 +214,7 @@
mReboot = true;
mRebootSafeMode = false;
mRebootUpdate = false;
- mRebootReason = reason;
+ mReason = reason;
shutdownInner(context, confirm);
}
@@ -232,7 +234,7 @@
mReboot = true;
mRebootSafeMode = true;
mRebootUpdate = false;
- mRebootReason = null;
+ mReason = null;
shutdownInner(context, confirm);
}
@@ -249,18 +251,18 @@
ProgressDialog pd = new ProgressDialog(context);
// Path 1: Reboot to recovery and install the update
- // Condition: mRebootReason == REBOOT_RECOVERY and mRebootUpdate == True
+ // Condition: mReason == REBOOT_RECOVERY and mRebootUpdate == True
// (mRebootUpdate is set by checking if /cache/recovery/uncrypt_file exists.)
// UI: progress bar
//
// Path 2: Reboot to recovery for factory reset
- // Condition: mRebootReason == REBOOT_RECOVERY
+ // Condition: mReason == REBOOT_RECOVERY
// UI: spinning circle only (no progress bar)
//
// Path 3: Regular reboot / shutdown
// Condition: Otherwise
// UI: spinning circle only (no progress bar)
- if (PowerManager.REBOOT_RECOVERY.equals(mRebootReason)) {
+ if (PowerManager.REBOOT_RECOVERY.equals(mReason)) {
mRebootUpdate = new File(UNCRYPT_PACKAGE_FILE).exists();
if (mRebootUpdate) {
pd.setTitle(context.getText(com.android.internal.R.string.reboot_to_update_title));
@@ -349,7 +351,7 @@
* the beginning of the SystemServer startup.
*/
{
- String reason = (mReboot ? "1" : "0") + (mRebootReason != null ? mRebootReason : "");
+ String reason = (mReboot ? "1" : "0") + (mReason != null ? mReason : "");
SystemProperties.set(SHUTDOWN_ACTION_PROPERTY, reason);
}
@@ -473,7 +475,7 @@
uncrypt();
}
- rebootOrShutdown(mContext, mReboot, mRebootReason);
+ rebootOrShutdown(mContext, mReboot, mReason);
}
private void setRebootProgress(final int progress, final CharSequence message) {
@@ -616,13 +618,14 @@
*
* @param context Context used to vibrate or null without vibration
* @param reboot true to reboot or false to shutdown
- * @param reason reason for reboot
+ * @param reason reason for reboot/shutdown
*/
public static void rebootOrShutdown(final Context context, boolean reboot, String reason) {
if (reboot) {
Log.i(TAG, "Rebooting, reason: " + reason);
PowerManagerService.lowLevelReboot(reason);
Log.e(TAG, "Reboot failed, will attempt shutdown instead");
+ reason = null;
} else if (SHUTDOWN_VIBRATE_MS > 0 && context != null) {
// vibrate before shutting down
Vibrator vibrator = new SystemVibrator(context);
@@ -642,7 +645,7 @@
// Shutdown power
Log.i(TAG, "Performing low-level shutdown...");
- PowerManagerService.lowLevelShutdown();
+ PowerManagerService.lowLevelShutdown(reason);
}
private void uncrypt() {
diff --git a/services/core/java/com/android/server/updates/SELinuxPolicyInstallReceiver.java b/services/core/java/com/android/server/updates/SELinuxPolicyInstallReceiver.java
index 4e53687..c81398f 100644
--- a/services/core/java/com/android/server/updates/SELinuxPolicyInstallReceiver.java
+++ b/services/core/java/com/android/server/updates/SELinuxPolicyInstallReceiver.java
@@ -36,7 +36,7 @@
private static final String TAG = "SELinuxPolicyInstallReceiver";
private static final String sepolicyPath = "sepolicy";
- private static final String fileContextsPath = "file_contexts";
+ private static final String fileContextsPath = "file_contexts.bin";
private static final String propertyContextsPath = "property_contexts";
private static final String seappContextsPath = "seapp_contexts";
private static final String versionPath = "selinux_version";
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index da2042c..00dba5b 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -5653,7 +5653,7 @@
// Called by window manager policy. Not exposed externally.
@Override
public void shutdown(boolean confirm) {
- ShutdownThread.shutdown(mContext, confirm);
+ ShutdownThread.shutdown(mContext, PowerManager.SHUTDOWN_USER_REQUESTED, confirm);
}
// Called by window manager policy. Not exposed externally.
diff --git a/services/core/jni/com_android_server_PersistentDataBlockService.cpp b/services/core/jni/com_android_server_PersistentDataBlockService.cpp
index e842eeb..4ccfa56 100644
--- a/services/core/jni/com_android_server_PersistentDataBlockService.cpp
+++ b/services/core/jni/com_android_server_PersistentDataBlockService.cpp
@@ -17,6 +17,7 @@
#include <android_runtime/AndroidRuntime.h>
#include <JNIHelp.h>
#include <jni.h>
+#include <ScopedUtfChars.h>
#include <utils/misc.h>
#include <sys/ioctl.h>
@@ -77,8 +78,8 @@
static jlong com_android_server_PersistentDataBlockService_getBlockDeviceSize(JNIEnv *env, jclass, jstring jpath)
{
- const char *path = env->GetStringUTFChars(jpath, 0);
- int fd = open(path, O_RDONLY);
+ ScopedUtfChars path(env, jpath);
+ int fd = open(path.c_str(), O_RDONLY);
if (fd < 0)
return 0;
@@ -87,8 +88,8 @@
}
static int com_android_server_PersistentDataBlockService_wipe(JNIEnv *env, jclass, jstring jpath) {
- const char *path = env->GetStringUTFChars(jpath, 0);
- int fd = open(path, O_WRONLY);
+ ScopedUtfChars path(env, jpath);
+ int fd = open(path.c_str(), O_WRONLY);
if (fd < 0)
return 0;
diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java
index 7dd16d1..7a8d4ef 100644
--- a/services/java/com/android/server/SystemServer.java
+++ b/services/java/com/android/server/SystemServer.java
@@ -515,7 +515,7 @@
// TODO: Use a more reliable check to see if this product should
// support Bluetooth - see bug 988521
if (isEmulator) {
- Slog.i(TAG, "No Bluetooh Service (emulator)");
+ Slog.i(TAG, "No Bluetooth Service (emulator)");
} else if (mFactoryTestMode == FactoryTest.FACTORY_TEST_LOW_LEVEL) {
Slog.i(TAG, "No Bluetooth Service (factory test)");
} else if (!context.getPackageManager().hasSystemFeature
diff --git a/test-runner/src/android/test/InstrumentationCoreTestRunner.java b/test-runner/src/android/test/InstrumentationCoreTestRunner.java
index 036a2275..655a65c 100644
--- a/test-runner/src/android/test/InstrumentationCoreTestRunner.java
+++ b/test-runner/src/android/test/InstrumentationCoreTestRunner.java
@@ -21,12 +21,6 @@
import java.lang.reflect.Modifier;
import java.util.List;
-import com.android.internal.util.Predicate;
-import com.android.internal.util.Predicates;
-
-import dalvik.annotation.BrokenTest;
-import dalvik.annotation.SideEffect;
-
import junit.framework.AssertionFailedError;
import junit.framework.Test;
import junit.framework.TestCase;
@@ -192,19 +186,4 @@
return runner;
}
-
- @Override
- List<Predicate<TestMethod>> getBuilderRequirements() {
- List<Predicate<TestMethod>> builderRequirements =
- super.getBuilderRequirements();
- Predicate<TestMethod> brokenTestPredicate =
- Predicates.not(new HasAnnotation(BrokenTest.class));
- builderRequirements.add(brokenTestPredicate);
- if (!singleTest) {
- Predicate<TestMethod> sideEffectPredicate =
- Predicates.not(new HasAnnotation(SideEffect.class));
- builderRequirements.add(sideEffectPredicate);
- }
- return builderRequirements;
- }
}
diff --git a/tests/CoreTests/run_core_test.sh b/tests/CoreTests/run_core_test.sh
deleted file mode 100755
index ffa31ed..0000000
--- a/tests/CoreTests/run_core_test.sh
+++ /dev/null
@@ -1,6 +0,0 @@
-framework=/system/framework
-bpath=$framework/core.jar:$framework/ext.jar:$framework/framework.jar:$framework/android.test.runner.jar
-adb shell exec dalvikvm -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=3001 \
- -Xbootclasspath:$bpath -cp /data/app/android.core.apk \
- -Djava.io.tmpdir=/sdcard/tmp \
- com.android.internal.util.WithFramework junit.textui.TestRunner $*
diff --git a/tests/CoreTests/run_junit.sh b/tests/CoreTests/run_junit.sh
deleted file mode 100755
index b77794d..0000000
--- a/tests/CoreTests/run_junit.sh
+++ /dev/null
@@ -1,9 +0,0 @@
-# runs unit tests over adb shell using dalvikvm. The value added is setting the classpath for you
-# and pointing to the junit textui test runner.
-#
-# the normal usage might be:
-# (make MoreJavaTests)
-# $ adb sync
-# $ java/tests/run_junit.sh android.util.MyTest
-
-adb shell exec dalvikvm -cp system/app/MoreTests.apk junit.textui.TestRunner $*
diff --git a/tools/aapt/Android.mk b/tools/aapt/Android.mk
index d551c8e..94a74c4 100644
--- a/tools/aapt/Android.mk
+++ b/tools/aapt/Android.mk
@@ -53,11 +53,6 @@
tests/Pseudolocales_test.cpp \
tests/ResourceFilter_test.cpp
-aaptCIncludes := \
- system/core/base/include \
- external/libpng \
- external/zlib
-
aaptHostLdLibs :=
aaptHostStaticLibs := \
libandroidfw \
@@ -69,7 +64,7 @@
libziparchive-host \
libbase
-aaptCFlags := -DAAPT_VERSION=\"$(BUILD_NUMBER)\"
+aaptCFlags := -DAAPT_VERSION=\"$(BUILD_NUMBER_FROM_FILE)\"
aaptCFlags += -Wall -Werror
ifeq ($(HOST_OS),linux)
@@ -96,8 +91,8 @@
ifeq (darwin,$(HOST_OS))
LOCAL_CFLAGS += -D_DARWIN_UNLIMITED_STREAMS
endif
-LOCAL_C_INCLUDES += $(aaptCIncludes)
LOCAL_SRC_FILES := $(aaptSources)
+LOCAL_STATIC_LIBRARIES += $(aaptHostStaticLibs)
include $(BUILD_HOST_STATIC_LIBRARY)
diff --git a/tools/aapt/Command.cpp b/tools/aapt/Command.cpp
index 8a0a39c..d12ab3b 100644
--- a/tools/aapt/Command.cpp
+++ b/tools/aapt/Command.cpp
@@ -215,7 +215,7 @@
goto bail;
}
-#ifdef HAVE_ANDROID_OS
+#ifdef __ANDROID__
static const bool kHaveAndroidOs = true;
#else
static const bool kHaveAndroidOs = false;
@@ -633,7 +633,7 @@
Asset* asset = NULL;
if (strcmp("resources", option) == 0) {
-#ifndef HAVE_ANDROID_OS
+#ifndef __ANDROID__
res.print(bundle->getValues());
#endif
diff --git a/tools/aapt/CrunchCache.cpp b/tools/aapt/CrunchCache.cpp
index 6c39d1d..0d574cf 100644
--- a/tools/aapt/CrunchCache.cpp
+++ b/tools/aapt/CrunchCache.cpp
@@ -5,6 +5,7 @@
// This file defines functions laid out and documented in
// CrunchCache.h
+#include <utils/Compat.h>
#include <utils/Vector.h>
#include <utils/String8.h>
diff --git a/tools/aapt/Main.cpp b/tools/aapt/Main.cpp
index f832c60..bcf0d5e 100644
--- a/tools/aapt/Main.cpp
+++ b/tools/aapt/Main.cpp
@@ -6,6 +6,7 @@
#include "Main.h"
#include "Bundle.h"
+#include <utils/Compat.h>
#include <utils/Log.h>
#include <utils/threads.h>
#include <utils/List.h>
diff --git a/tools/aapt/StringPool.h b/tools/aapt/StringPool.h
index dbe8c85..4b0d920 100644
--- a/tools/aapt/StringPool.h
+++ b/tools/aapt/StringPool.h
@@ -20,8 +20,6 @@
#include <ctype.h>
#include <errno.h>
-#include <libexpat/expat.h>
-
using namespace android;
#define PRINT_STRING_METRICS 0
diff --git a/tools/aapt/XMLNode.h b/tools/aapt/XMLNode.h
index 3161f65..b9e5cd5 100644
--- a/tools/aapt/XMLNode.h
+++ b/tools/aapt/XMLNode.h
@@ -10,6 +10,8 @@
#include "StringPool.h"
#include "ResourceTable.h"
+#include <expat.h>
+
class XMLNode;
extern const char* const RESOURCES_ROOT_NAMESPACE;
diff --git a/tools/aapt2/Android.mk b/tools/aapt2/Android.mk
index 10f8150..e5c42d5 100644
--- a/tools/aapt2/Android.mk
+++ b/tools/aapt2/Android.mk
@@ -82,10 +82,6 @@
XmlDom_test.cpp \
XmlFlattener_test.cpp
-cIncludes := \
- external/libpng \
- external/libz
-
hostLdLibs :=
hostStaticLibs := \
@@ -114,7 +110,7 @@
LOCAL_MODULE := libaapt2
LOCAL_SRC_FILES := $(sources)
-LOCAL_C_INCLUDES += $(cIncludes)
+LOCAL_STATIC_LIBRARIES += $(hostStaticLibs)
LOCAL_CFLAGS += $(cFlags)
LOCAL_CPPFLAGS += $(cppFlags)
@@ -130,7 +126,6 @@
LOCAL_SRC_FILES := $(testSources)
-LOCAL_C_INCLUDES += $(cIncludes)
LOCAL_STATIC_LIBRARIES += libaapt2 $(hostStaticLibs)
LOCAL_LDLIBS += $(hostLdLibs)
LOCAL_CFLAGS += $(cFlags)
@@ -146,7 +141,6 @@
LOCAL_SRC_FILES := $(main)
-LOCAL_C_INCLUDES += $(cIncludes)
LOCAL_STATIC_LIBRARIES += libaapt2 $(hostStaticLibs)
LOCAL_LDLIBS += $(hostLdLibs)
LOCAL_CFLAGS += $(cFlags)
diff --git a/tools/aapt2/SourceXmlPullParser.h b/tools/aapt2/SourceXmlPullParser.h
index 15936d6..d8ed459 100644
--- a/tools/aapt2/SourceXmlPullParser.h
+++ b/tools/aapt2/SourceXmlPullParser.h
@@ -20,7 +20,7 @@
#include "XmlPullParser.h"
#include <istream>
-#include <libexpat/expat.h>
+#include <expat.h>
#include <queue>
#include <stack>
#include <string>
diff --git a/tools/aapt2/XmlDom.h b/tools/aapt2/XmlDom.h
index 6931884..035e7c4 100644
--- a/tools/aapt2/XmlDom.h
+++ b/tools/aapt2/XmlDom.h
@@ -21,7 +21,7 @@
#include "StringPiece.h"
#include <istream>
-#include <libexpat/expat.h>
+#include <expat.h>
#include <memory>
#include <string>
#include <vector>
diff --git a/tools/aidl/aidl.cpp b/tools/aidl/aidl.cpp
index 14c9f95..368e73d 100644
--- a/tools/aidl/aidl.cpp
+++ b/tools/aidl/aidl.cpp
@@ -1,6 +1,7 @@
#include "aidl_language.h"
#include "options.h"
+#include "os.h"
#include "search_path.h"
#include "Type.h"
#include "generate_java.h"
@@ -177,7 +178,7 @@
char cwd[MAXPATHLEN];
bool valid = false;
-#ifdef HAVE_WINDOWS_PATHS
+#ifdef _WIN32
if (isalpha(filename[0]) && filename[1] == ':'
&& filename[2] == OS_PATH_SEPARATOR) {
#else
@@ -217,7 +218,7 @@
if (valid) {
p = fn.c_str() + (len - expected.length());
-#ifdef HAVE_WINDOWS_PATHS
+#ifdef _WIN32
if (OS_PATH_SEPARATOR != '/') {
// Input filename under cygwin most likely has / separators
// whereas the expected string uses \\ separators. Adjust
@@ -675,6 +676,10 @@
fprintf(to, "\n");
+ // Output "<input_aidl_file>: " so make won't fail if the input .aidl file
+ // has been deleted, moved or renamed in incremental build.
+ fprintf(to, "%s :\n", options.inputFileName.c_str());
+
// Output "<imported_file>: " so make won't fail if the imported file has
// been deleted, moved or renamed in incremental build.
import = g_imports;
diff --git a/tools/aidl/os.h b/tools/aidl/os.h
new file mode 100644
index 0000000..79d2c35
--- /dev/null
+++ b/tools/aidl/os.h
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2015, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _FRAMEWORKS_BASE_TOOLS_AIDL_OS_SEP_H_
+#define _FRAMEWORKS_BASE_TOOLS_AIDL_OS_SEP_H_
+
+#if defined(_WIN32)
+#define OS_PATH_SEPARATOR '\\'
+#else
+#define OS_PATH_SEPARATOR '/'
+#endif
+
+#endif
diff --git a/tools/aidl/search_path.cpp b/tools/aidl/search_path.cpp
index ffb6cb2..29dbe26 100644
--- a/tools/aidl/search_path.cpp
+++ b/tools/aidl/search_path.cpp
@@ -1,6 +1,7 @@
#include <unistd.h>
#include "search_path.h"
#include "options.h"
+#include "os.h"
#include <string.h>
#ifdef HAVE_MS_C_RUNTIME
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgePowerManager.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgePowerManager.java
index 895f9c9..a410c53 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgePowerManager.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgePowerManager.java
@@ -86,7 +86,7 @@
}
@Override
- public void shutdown(boolean confirm, boolean wait) {
+ public void shutdown(boolean confirm, String reason, boolean wait) {
// pass for now.
}