Merge commit 'b873a17ce7be0a9771c24999adca6964431728f6' into HEAD
Change-Id: I938755073e70602cc8f51ce9bd420fdcf870cecd
diff --git a/cmds/bootanimation/BootAnimation.cpp b/cmds/bootanimation/BootAnimation.cpp
index ad4e4c8..0f610e9 100644
--- a/cmds/bootanimation/BootAnimation.cpp
+++ b/cmds/bootanimation/BootAnimation.cpp
@@ -159,8 +159,8 @@
SkBitmap bitmap;
SkMemoryStream stream(buffer, len);
SkImageDecoder* codec = SkImageDecoder::Factory(&stream);
- codec->setDitherImage(false);
if (codec) {
+ codec->setDitherImage(false);
codec->decode(&stream, &bitmap,
SkBitmap::kARGB_8888_Config,
SkImageDecoder::kDecodePixels_Mode);
@@ -270,7 +270,7 @@
mAndroidAnimation = true;
- // If the device has encryption turned on or is in process
+ // If the device has encryption turned on or is in process
// of being encrypted we show the encrypted boot animation.
char decrypt[PROPERTY_VALUE_MAX];
property_get("vold.decrypt", decrypt, "");
diff --git a/core/java/android/inputmethodservice/IInputMethodSessionWrapper.java b/core/java/android/inputmethodservice/IInputMethodSessionWrapper.java
index 726dcec..bbea8ff 100644
--- a/core/java/android/inputmethodservice/IInputMethodSessionWrapper.java
+++ b/core/java/android/inputmethodservice/IInputMethodSessionWrapper.java
@@ -75,7 +75,15 @@
@Override
public void executeMessage(Message msg) {
if (mInputMethodSession == null) {
- // The session has been finished.
+ // The session has been finished. Args needs to be recycled
+ // for cases below.
+ switch (msg.what) {
+ case DO_UPDATE_SELECTION:
+ case DO_APP_PRIVATE_COMMAND: {
+ SomeArgs args = (SomeArgs)msg.obj;
+ args.recycle();
+ }
+ }
return;
}
diff --git a/core/java/android/net/EthernetDataTracker.java b/core/java/android/net/EthernetDataTracker.java
index 501484c..cc8c771 100644
--- a/core/java/android/net/EthernetDataTracker.java
+++ b/core/java/android/net/EthernetDataTracker.java
@@ -402,7 +402,7 @@
* for this network.
*/
public String getTcpBufferSizesPropName() {
- return "net.tcp.buffersize.wifi";
+ return "net.tcp.buffersize.ethernet";
}
public void setDependencyMet(boolean met) {
diff --git a/core/java/android/net/ProxyProperties.java b/core/java/android/net/ProxyProperties.java
index 78ac75f..44cfa94 100644
--- a/core/java/android/net/ProxyProperties.java
+++ b/core/java/android/net/ProxyProperties.java
@@ -139,6 +139,16 @@
return false;
}
+ public boolean isValid() {
+ try {
+ Proxy.validate(mHost == null ? "" : mHost, mPort == 0 ? "" : Integer.toString(mPort),
+ mExclusionList == null ? "" : mExclusionList);
+ } catch (IllegalArgumentException e) {
+ return false;
+ }
+ return true;
+ }
+
public java.net.Proxy makeProxy() {
java.net.Proxy proxy = java.net.Proxy.NO_PROXY;
if (mHost != null) {
diff --git a/core/java/android/net/SSLCertificateSocketFactory.java b/core/java/android/net/SSLCertificateSocketFactory.java
index 208b212..b0278d3 100644
--- a/core/java/android/net/SSLCertificateSocketFactory.java
+++ b/core/java/android/net/SSLCertificateSocketFactory.java
@@ -533,7 +533,7 @@
@Override
public String[] getDefaultCipherSuites() {
- return getDelegate().getSupportedCipherSuites();
+ return getDelegate().getDefaultCipherSuites();
}
@Override
diff --git a/core/java/android/os/BatteryStats.java b/core/java/android/os/BatteryStats.java
index dbaa325..bc98a0b 100644
--- a/core/java/android/os/BatteryStats.java
+++ b/core/java/android/os/BatteryStats.java
@@ -450,7 +450,7 @@
public byte batteryHealth;
public byte batteryPlugType;
- public char batteryTemperature;
+ public short batteryTemperature;
public char batteryVoltage;
// Constants from SCREEN_BRIGHTNESS_*
@@ -527,7 +527,7 @@
batteryHealth = (byte)((bat>>20)&0xf);
batteryPlugType = (byte)((bat>>24)&0xf);
bat = src.readInt();
- batteryTemperature = (char)(bat&0xffff);
+ batteryTemperature = (short)(bat&0xffff);
batteryVoltage = (char)((bat>>16)&0xffff);
states = src.readInt();
}
@@ -596,7 +596,7 @@
if (DEBUG) Slog.i(TAG, "WRITE DELTA: batteryToken=0x"
+ Integer.toHexString(batteryLevelInt)
+ " batteryLevel=" + batteryLevel
- + " batteryTemp=" + (int)batteryTemperature
+ + " batteryTemp=" + batteryTemperature
+ " batteryVolt=" + (int)batteryVoltage);
}
if (stateIntChanged) {
@@ -611,8 +611,8 @@
}
private int buildBatteryLevelInt() {
- return ((((int)batteryLevel)<<24)&0xff000000)
- | ((((int)batteryTemperature)<<14)&0x00ffc000)
+ return ((((int)batteryLevel)<<25)&0xfe000000)
+ | ((((int)batteryTemperature)<<14)&0x01ffc000)
| (((int)batteryVoltage)&0x00003fff);
}
@@ -648,13 +648,13 @@
if ((firstToken&DELTA_BATTERY_LEVEL_FLAG) != 0) {
int batteryLevelInt = src.readInt();
- batteryLevel = (byte)((batteryLevelInt>>24)&0xff);
- batteryTemperature = (char)((batteryLevelInt>>14)&0x3ff);
+ batteryLevel = (byte)((batteryLevelInt>>25)&0x7f);
+ batteryTemperature = (short)((batteryLevelInt<<7)>>21);
batteryVoltage = (char)(batteryLevelInt&0x3fff);
if (DEBUG) Slog.i(TAG, "READ DELTA: batteryToken=0x"
+ Integer.toHexString(batteryLevelInt)
+ " batteryLevel=" + batteryLevel
- + " batteryTemp=" + (int)batteryTemperature
+ + " batteryTemp=" + batteryTemperature
+ " batteryVolt=" + (int)batteryVoltage);
}
diff --git a/core/java/android/os/Bundle.java b/core/java/android/os/Bundle.java
index 5a919fb..5de365f 100644
--- a/core/java/android/os/Bundle.java
+++ b/core/java/android/os/Bundle.java
@@ -362,7 +362,7 @@
SparseArray<? extends Parcelable> array =
(SparseArray<? extends Parcelable>) obj;
for (int n = array.size() - 1; n >= 0; n--) {
- if ((array.get(n).describeContents()
+ if ((array.valueAt(n).describeContents()
& Parcelable.CONTENTS_FILE_DESCRIPTOR) != 0) {
fdFound = true;
break;
diff --git a/core/java/com/android/internal/os/BatteryStatsImpl.java b/core/java/com/android/internal/os/BatteryStatsImpl.java
index e0a154c..f85b353 100644
--- a/core/java/com/android/internal/os/BatteryStatsImpl.java
+++ b/core/java/com/android/internal/os/BatteryStatsImpl.java
@@ -4721,7 +4721,7 @@
mHistoryCur.batteryStatus = (byte)status;
mHistoryCur.batteryHealth = (byte)health;
mHistoryCur.batteryPlugType = (byte)plugType;
- mHistoryCur.batteryTemperature = (char)temp;
+ mHistoryCur.batteryTemperature = (short)temp;
mHistoryCur.batteryVoltage = (char)volt;
setOnBatteryLocked(onBattery, oldStatus, level);
} else {
@@ -4744,7 +4744,7 @@
}
if (temp >= (mHistoryCur.batteryTemperature+10)
|| temp <= (mHistoryCur.batteryTemperature-10)) {
- mHistoryCur.batteryTemperature = (char)temp;
+ mHistoryCur.batteryTemperature = (short)temp;
changed = true;
}
if (volt > (mHistoryCur.batteryVoltage+20)
diff --git a/core/java/com/android/internal/os/ZygoteConnection.java b/core/java/com/android/internal/os/ZygoteConnection.java
index 3381959..4f3b5b3 100644
--- a/core/java/com/android/internal/os/ZygoteConnection.java
+++ b/core/java/com/android/internal/os/ZygoteConnection.java
@@ -197,10 +197,14 @@
try {
parsedArgs = new Arguments(args);
+ if (parsedArgs.permittedCapabilities != 0 || parsedArgs.effectiveCapabilities != 0) {
+ throw new ZygoteSecurityException("Client may not specify capabilities: " +
+ "permitted=0x" + Long.toHexString(parsedArgs.permittedCapabilities) +
+ ", effective=0x" + Long.toHexString(parsedArgs.effectiveCapabilities));
+ }
applyUidSecurityPolicy(parsedArgs, peer, peerSecurityContext);
applyRlimitSecurityPolicy(parsedArgs, peer, peerSecurityContext);
- applyCapabilitiesSecurityPolicy(parsedArgs, peer, peerSecurityContext);
applyInvokeWithSecurityPolicy(parsedArgs, peer, peerSecurityContext);
applyseInfoSecurityPolicy(parsedArgs, peer, peerSecurityContext);
@@ -703,71 +707,6 @@
}
/**
- * Applies zygote security policy per bug #1042973. A root peer may
- * spawn an instance with any capabilities. All other uids may spawn
- * instances with any of the capabilities in the peer's permitted set
- * but no more.
- *
- * @param args non-null; zygote spawner arguments
- * @param peer non-null; peer credentials
- * @throws ZygoteSecurityException
- */
- private static void applyCapabilitiesSecurityPolicy(
- Arguments args, Credentials peer, String peerSecurityContext)
- throws ZygoteSecurityException {
-
- if (args.permittedCapabilities == 0
- && args.effectiveCapabilities == 0) {
- // nothing to check
- return;
- }
-
- boolean allowed = SELinux.checkSELinuxAccess(peerSecurityContext,
- peerSecurityContext,
- "zygote",
- "specifycapabilities");
- if (!allowed) {
- throw new ZygoteSecurityException(
- "Peer may not specify capabilities");
- }
-
- if (peer.getUid() == 0) {
- // root may specify anything
- return;
- }
-
- long permittedCaps;
-
- try {
- permittedCaps = ZygoteInit.capgetPermitted(peer.getPid());
- } catch (IOException ex) {
- throw new ZygoteSecurityException(
- "Error retrieving peer's capabilities.");
- }
-
- /*
- * Ensure that the client did not specify an effective set larger
- * than the permitted set. The kernel will enforce this too, but we
- * do it here to make the following check easier.
- */
- if (((~args.permittedCapabilities) & args.effectiveCapabilities) != 0) {
- throw new ZygoteSecurityException(
- "Effective capabilities cannot be superset of "
- + " permitted capabilities" );
- }
-
- /*
- * Ensure that the new permitted (and thus the new effective) set is
- * a subset of the peer process's permitted set
- */
-
- if (((~permittedCaps) & args.permittedCapabilities) != 0) {
- throw new ZygoteSecurityException(
- "Peer specified unpermitted capabilities" );
- }
- }
-
- /**
* Applies zygote security policy.
* Based on the credentials of the process issuing a zygote command:
* <ol>
diff --git a/core/java/com/android/internal/os/ZygoteInit.java b/core/java/com/android/internal/os/ZygoteInit.java
index 73d34c3..25118e8 100644
--- a/core/java/com/android/internal/os/ZygoteInit.java
+++ b/core/java/com/android/internal/os/ZygoteInit.java
@@ -301,6 +301,8 @@
count++;
} catch (ClassNotFoundException e) {
Log.w(TAG, "Class not found for preloading: " + line);
+ } catch (UnsatisfiedLinkError e) {
+ Log.w(TAG, "Problem preloading " + line + ": " + e);
} catch (Throwable t) {
Log.e(TAG, "Error preloading " + line + ".", t);
if (t instanceof Error) {
@@ -720,15 +722,6 @@
throws IOException;
/**
- * Retrieves the permitted capability set from another process.
- *
- * @param pid >=0 process ID or 0 for this process
- * @throws IOException on error
- */
- static native long capgetPermitted(int pid)
- throws IOException;
-
- /**
* Invokes select() on the provider array of file descriptors (selecting
* for readability only). Array elements of null are ignored.
*
diff --git a/core/jni/android/graphics/Graphics.cpp b/core/jni/android/graphics/Graphics.cpp
index 8cb152d..0a8eeab 100644
--- a/core/jni/android/graphics/Graphics.cpp
+++ b/core/jni/android/graphics/Graphics.cpp
@@ -174,6 +174,12 @@
static jfieldID gRegion_nativeInstanceID;
static jmethodID gRegion_constructorMethodID;
+static jclass gByte_class;
+static jobject gVMRuntime;
+static jclass gVMRuntime_class;
+static jmethodID gVMRuntime_newNonMovableArray;
+static jmethodID gVMRuntime_addressOf;
+
///////////////////////////////////////////////////////////////////////////////
void GraphicsJNI::get_jrect(JNIEnv* env, jobject obj, int* L, int* T, int* R, int* B)
@@ -529,8 +535,6 @@
///////////////////////////////////////////////////////////////////////////////
-extern "C" jbyte* jniGetNonMovableArrayElements(C_JNIEnv* env, jarray arrayObj);
-
jbyteArray GraphicsJNI::allocateJavaPixelRef(JNIEnv* env, SkBitmap* bitmap,
SkColorTable* ctable) {
Sk64 size64 = bitmap->getSize64();
@@ -539,12 +543,12 @@
"bitmap size exceeds 32bits");
return NULL;
}
-
size_t size = size64.get32();
- jbyteArray arrayObj = env->NewByteArray(size);
+ jbyteArray arrayObj = (jbyteArray) env->CallObjectMethod(gVMRuntime,
+ gVMRuntime_newNonMovableArray,
+ gByte_class, size);
if (arrayObj) {
- // TODO: make this work without jniGetNonMovableArrayElements
- jbyte* addr = jniGetNonMovableArrayElements(&env->functions, arrayObj);
+ jbyte* addr = (jbyte*) env->CallLongMethod(gVMRuntime, gVMRuntime_addressOf, arrayObj);
if (addr) {
SkPixelRef* pr = new AndroidPixelRef(env, (void*) addr, size, arrayObj, ctable);
bitmap->setPixelRef(pr)->unref();
@@ -601,7 +605,7 @@
{
jclass c = env->FindClass(classname);
SkASSERT(c);
- return (jclass)env->NewGlobalRef(c);
+ return (jclass) env->NewGlobalRef(c);
}
static jfieldID getFieldIDCheck(JNIEnv* env, jclass clazz,
@@ -663,5 +667,16 @@
gRegion_constructorMethodID = env->GetMethodID(gRegion_class, "<init>",
"(II)V");
+ c = env->FindClass("java/lang/Byte");
+ gByte_class = (jclass) env->NewGlobalRef(
+ env->GetStaticObjectField(c, env->GetStaticFieldID(c, "TYPE", "Ljava/lang/Class;")));
+
+ gVMRuntime_class = make_globalref(env, "dalvik/system/VMRuntime");
+ m = env->GetStaticMethodID(gVMRuntime_class, "getRuntime", "()Ldalvik/system/VMRuntime;");
+ gVMRuntime = env->NewGlobalRef(env->CallStaticObjectMethod(gVMRuntime_class, m));
+ gVMRuntime_newNonMovableArray = env->GetMethodID(gVMRuntime_class, "newNonMovableArray",
+ "(Ljava/lang/Class;I)Ljava/lang/Object;");
+ gVMRuntime_addressOf = env->GetMethodID(gVMRuntime_class, "addressOf", "(Ljava/lang/Object;)J");
+
return 0;
}
diff --git a/core/jni/android_os_Debug.cpp b/core/jni/android_os_Debug.cpp
index 054ee4f..a041693 100644
--- a/core/jni/android_os_Debug.cpp
+++ b/core/jni/android_os_Debug.cpp
@@ -675,6 +675,7 @@
// loop until we have the block that represents this process
do {
if (fgets(line, 1024, fp) == 0) {
+ fclose(fp);
return -1;
}
} while (strncmp(compare, line, len));
@@ -684,13 +685,16 @@
do {
if (fgets(line, 1024, fp) == 0) {
+ fclose(fp);
return -1;
}
} while (strncmp(compare, line, len));
// we have the line, now increment the line ptr to the value
char* ptr = line + len;
- return atoi(ptr);
+ jint result = atoi(ptr);
+ fclose(fp);
+ return result;
}
static jint android_os_Debug_getBinderSentTransactions(JNIEnv *env, jobject clazz)
diff --git a/core/jni/android_util_Process.cpp b/core/jni/android_util_Process.cpp
index 8325217..601975a 100644
--- a/core/jni/android_util_Process.cpp
+++ b/core/jni/android_util_Process.cpp
@@ -422,7 +422,7 @@
return *((const jint*)v1) - *((const jint*)v2);
}
-static jlong getFreeMemoryImpl(const char* const sums[], const int sumsLen[], int num)
+static jlong getFreeMemoryImpl(const char* const sums[], const size_t sumsLen[], size_t num)
{
int fd = open("/proc/meminfo", O_RDONLY);
@@ -441,7 +441,7 @@
}
buffer[len] = 0;
- int numFound = 0;
+ size_t numFound = 0;
jlong mem = 0;
char* p = buffer;
@@ -473,14 +473,14 @@
static jlong android_os_Process_getFreeMemory(JNIEnv* env, jobject clazz)
{
static const char* const sums[] = { "MemFree:", "Cached:", NULL };
- static const int sumsLen[] = { strlen("MemFree:"), strlen("Cached:"), 0 };
+ static const size_t sumsLen[] = { strlen("MemFree:"), strlen("Cached:"), 0 };
return getFreeMemoryImpl(sums, sumsLen, 2);
}
static jlong android_os_Process_getTotalMemory(JNIEnv* env, jobject clazz)
{
static const char* const sums[] = { "MemTotal:", NULL };
- static const int sumsLen[] = { strlen("MemTotal:"), 0 };
+ static const size_t sumsLen[] = { strlen("MemTotal:"), 0 };
return getFreeMemoryImpl(sums, sumsLen, 1);
}
@@ -745,7 +745,7 @@
jsize end = -1;
if ((mode&PROC_PARENS) != 0) {
- while (buffer[i] != ')' && i < endIndex) {
+ while (i < endIndex && buffer[i] != ')') {
i++;
}
end = i;
@@ -757,7 +757,7 @@
end = i;
i++;
}
- while (buffer[i] != term && i < endIndex) {
+ while (i < endIndex && buffer[i] != term) {
i++;
}
if (end < 0) {
@@ -767,7 +767,7 @@
if (i < endIndex) {
i++;
if ((mode&PROC_COMBINE) != 0) {
- while (buffer[i] == term && i < endIndex) {
+ while (i < endIndex && buffer[i] == term) {
i++;
}
}
diff --git a/core/jni/com_android_internal_os_ZygoteInit.cpp b/core/jni/com_android_internal_os_ZygoteInit.cpp
index 44452f0..2233ee3 100644
--- a/core/jni/com_android_internal_os_ZygoteInit.cpp
+++ b/core/jni/com_android_internal_os_ZygoteInit.cpp
@@ -159,29 +159,6 @@
}
}
-static jlong com_android_internal_os_ZygoteInit_capgetPermitted (JNIEnv *env,
- jobject clazz, jint pid)
-{
- struct __user_cap_header_struct capheader;
- struct __user_cap_data_struct capdata;
- int err;
-
- memset (&capheader, 0, sizeof(capheader));
- memset (&capdata, 0, sizeof(capdata));
-
- capheader.version = _LINUX_CAPABILITY_VERSION;
- capheader.pid = pid;
-
- err = capget (&capheader, &capdata);
-
- if (err < 0) {
- jniThrowIOException(env, errno);
- return 0;
- }
-
- return (jlong) capdata.permitted;
-}
-
static jint com_android_internal_os_ZygoteInit_selectReadable (
JNIEnv *env, jobject clazz, jobjectArray fds)
{
@@ -274,8 +251,6 @@
(void *) com_android_internal_os_ZygoteInit_reopenStdio},
{ "setCloseOnExec", "(Ljava/io/FileDescriptor;Z)V",
(void *) com_android_internal_os_ZygoteInit_setCloseOnExec},
- { "capgetPermitted", "(I)J",
- (void *) com_android_internal_os_ZygoteInit_capgetPermitted },
{ "selectReadable", "([Ljava/io/FileDescriptor;)I",
(void *) com_android_internal_os_ZygoteInit_selectReadable },
{ "createFileDescriptor", "(I)Ljava/io/FileDescriptor;",
diff --git a/docs/html/guide/topics/ui/drag-drop.jd b/docs/html/guide/topics/ui/drag-drop.jd
index e989374..9a6b0e9 100644
--- a/docs/html/guide/topics/ui/drag-drop.jd
+++ b/docs/html/guide/topics/ui/drag-drop.jd
@@ -873,7 +873,7 @@
...
-protected class myDragEventListener implements View.OnDragEventListener {
+protected class myDragEventListener implements View.OnDragListener {
// This is the method that the system calls when it dispatches a drag event to the
// listener.
@@ -899,18 +899,15 @@
v.invalidate();
// returns true to indicate that the View can accept the dragged data.
- return(true);
+ return true;
- } else {
+ }
- // Returns false. During the current drag and drop operation, this View will
- // not receive events again until ACTION_DRAG_ENDED is sent.
- return(false);
+ // Returns false. During the current drag and drop operation, this View will
+ // not receive events again until ACTION_DRAG_ENDED is sent.
+ return false;
- }
- break;
-
- case DragEvent.ACTION_DRAG_ENTERED: {
+ case DragEvent.ACTION_DRAG_ENTERED:
// Applies a green tint to the View. Return true; the return value is ignored.
@@ -919,79 +916,70 @@
// Invalidate the view to force a redraw in the new tint
v.invalidate();
- return(true);
+ return true;
- break;
-
- case DragEvent.ACTION_DRAG_LOCATION:
+ case DragEvent.ACTION_DRAG_LOCATION:
// Ignore the event
- return(true);
+ return true;
+ case DragEvent.ACTION_DRAG_EXITED:
+
+ // Re-sets the color tint to blue. Returns true; the return value is ignored.
+ v.setColorFilter(Color.BLUE);
+
+ // Invalidate the view to force a redraw in the new tint
+ v.invalidate();
+
+ return true;
+
+ case DragEvent.ACTION_DROP:
+
+ // Gets the item containing the dragged data
+ ClipData.Item item = event.getClipData().getItemAt(0);
+
+ // Gets the text data from the item.
+ dragData = item.getText();
+
+ // Displays a message containing the dragged data.
+ Toast.makeText(this, "Dragged data is " + dragData, Toast.LENGTH_LONG);
+
+ // Turns off any color tints
+ v.clearColorFilter();
+
+ // Invalidates the view to force a redraw
+ v.invalidate();
+
+ // Returns true. DragEvent.getResult() will return true.
+ return true;
+
+ case DragEvent.ACTION_DRAG_ENDED:
+
+ // Turns off any color tinting
+ v.clearColorFilter();
+
+ // Invalidates the view to force a redraw
+ v.invalidate();
+
+ // Does a getResult(), and displays what happened.
+ if (event.getResult()) {
+ Toast.makeText(this, "The drop was handled.", Toast.LENGTH_LONG);
+
+ } else {
+ Toast.makeText(this, "The drop didn't work.", Toast.LENGTH_LONG);
+
+ }
+
+ // returns true; the value is ignored.
+ return true;
+
+ // An unknown action type was received.
+ default:
+ Log.e("DragDrop Example","Unknown action type received by OnDragListener.");
break;
-
- case DragEvent.ACTION_DRAG_EXITED:
-
- // Re-sets the color tint to blue. Returns true; the return value is ignored.
- v.setColorFilter(Color.BLUE);
-
- // Invalidate the view to force a redraw in the new tint
- v.invalidate();
-
- return(true);
-
- break;
-
- case DragEvent.ACTION_DROP:
-
- // Gets the item containing the dragged data
- ClipData.Item item = event.getClipData().getItemAt(0);
-
- // Gets the text data from the item.
- dragData = item.getText();
-
- // Displays a message containing the dragged data.
- Toast.makeText(this, "Dragged data is " + dragData, Toast.LENGTH_LONG);
-
- // Turns off any color tints
- v.clearColorFilter();
-
- // Invalidates the view to force a redraw
- v.invalidate();
-
- // Returns true. DragEvent.getResult() will return true.
- return(true);
-
- break;
-
- case DragEvent.ACTION_DRAG_ENDED:
-
- // Turns off any color tinting
- v.clearColorFilter();
-
- // Invalidates the view to force a redraw
- v.invalidate();
-
- // Does a getResult(), and displays what happened.
- if (event.getResult()) {
- Toast.makeText(this, "The drop was handled.", Toast.LENGTH_LONG);
-
- } else {
- Toast.makeText(this, "The drop didn't work.", Toast.LENGTH_LONG);
-
- };
-
- // returns true; the value is ignored.
- return(true);
-
- break;
-
- // An unknown action type was received.
- default:
- Log.e("DragDrop Example","Unknown action type received by OnDragListener.");
-
- break;
- };
- };
+ }
+
+ return false;
+ }
};
</pre>
diff --git a/docs/html/training/articles/perf-tips.jd b/docs/html/training/articles/perf-tips.jd
index 7ff6c5c..1660b7f 100644
--- a/docs/html/training/articles/perf-tips.jd
+++ b/docs/html/training/articles/perf-tips.jd
@@ -16,7 +16,6 @@
<li><a href="#AvoidFloat">Avoid Using Floating-Point</a></li>
<li><a href="#UseLibraries">Know and Use the Libraries</a></li>
<li><a href="#NativeMethods">Use Native Methods Carefully</a></li>
- <li><a href="#library">Know And Use The Libraries</a></li>
<li><a href="#native_methods">Use Native Methods Judiciously</a></li>
<li><a href="#closing_notes">Closing Notes</a></li>
</ol>
diff --git a/libs/androidfw/AssetManager.cpp b/libs/androidfw/AssetManager.cpp
index 6667daf..1066715 100644
--- a/libs/androidfw/AssetManager.cpp
+++ b/libs/androidfw/AssetManager.cpp
@@ -432,7 +432,7 @@
delete[] mLocale;
}
mLocale = strdupNew(locale);
-
+
updateResourceParamsLocked();
}
@@ -675,7 +675,7 @@
mZipSet.setZipResourceTableAsset(ap.path, ass);
}
}
-
+
if (i == 0 && ass != NULL) {
// If this is the first resource table in the asset
// manager, then we are going to cache it so that we
@@ -689,7 +689,7 @@
}
} else {
ALOGV("loading resource table %s\n", ap.path.string());
- Asset* ass = const_cast<AssetManager*>(this)->
+ ass = const_cast<AssetManager*>(this)->
openNonAssetInPathLocked("resources.arsc",
Asset::ACCESS_BUFFER,
ap);
@@ -891,7 +891,7 @@
/* look at the filesystem on disk */
String8 path(createPathNameLocked(ap, locale, vendor));
path.appendPath(fileName);
-
+
String8 excludeName(path);
excludeName.append(kExcludeExtension);
if (::getFileType(excludeName.string()) != kFileTypeNonexistent) {
@@ -899,28 +899,28 @@
//printf("+++ excluding '%s'\n", (const char*) excludeName);
return kExcludedAsset;
}
-
+
pAsset = openAssetFromFileLocked(path, mode);
-
+
if (pAsset == NULL) {
/* try again, this time with ".gz" */
path.append(".gz");
pAsset = openAssetFromFileLocked(path, mode);
}
-
+
if (pAsset != NULL)
pAsset->setAssetSource(path);
} else {
/* find in cache */
String8 path(createPathNameLocked(ap, locale, vendor));
path.appendPath(fileName);
-
+
AssetDir::FileInfo tmpInfo;
bool found = false;
-
+
String8 excludeName(path);
excludeName.append(kExcludeExtension);
-
+
if (mCache.indexOf(excludeName) != NAME_NOT_FOUND) {
/* go no farther */
//printf("+++ Excluding '%s'\n", (const char*) excludeName);
@@ -1739,7 +1739,7 @@
// XXX This is broken -- the filename cache needs to hold the base
// asset path separately from its filename.
-
+
partialPath = createPathNameLocked(ap, locale, vendor);
if (dirName[0] != '\0') {
partialPath.appendPath(dirName);
diff --git a/libs/androidfw/ObbFile.cpp b/libs/androidfw/ObbFile.cpp
index 21e06c8..ec59f06 100644
--- a/libs/androidfw/ObbFile.cpp
+++ b/libs/androidfw/ObbFile.cpp
@@ -133,7 +133,7 @@
{
lseek64(fd, fileLength - kFooterTagSize, SEEK_SET);
- char *footer = new char[kFooterTagSize];
+ char footer[kFooterTagSize];
actual = TEMP_FAILURE_RETRY(read(fd, footer, kFooterTagSize));
if (actual != kFooterTagSize) {
ALOGW("couldn't read footer signature: %s\n", strerror(errno));
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp
index 35fc804..4d76bed 100644
--- a/libs/hwui/OpenGLRenderer.cpp
+++ b/libs/hwui/OpenGLRenderer.cpp
@@ -1076,7 +1076,13 @@
}
} else if (!rect.isEmpty()) {
dirtyLayer(rect.left, rect.top, rect.right, rect.bottom);
+
+ save(0);
+ // the layer contains screen buffer content that shouldn't be alpha modulated
+ // (and any necessary alpha modulation was handled drawing into the layer)
+ mSnapshot->alpha = 1.0f;
composeLayerRect(layer, rect, true);
+ restore();
}
dirtyClip();
diff --git a/media/jni/android_media_MediaPlayer.cpp b/media/jni/android_media_MediaPlayer.cpp
index d134667..4be9cd6 100644
--- a/media/jni/android_media_MediaPlayer.cpp
+++ b/media/jni/android_media_MediaPlayer.cpp
@@ -115,6 +115,7 @@
nativeParcel->setData(obj->data(), obj->dataSize());
env->CallStaticVoidMethod(mClass, fields.post_event, mObject,
msg, ext1, ext2, jParcel);
+ env->DeleteLocalRef(jParcel);
}
} else {
env->CallStaticVoidMethod(mClass, fields.post_event, mObject,
diff --git a/services/input/EventHub.cpp b/services/input/EventHub.cpp
index 4d70d5f..fc64656 100644
--- a/services/input/EventHub.cpp
+++ b/services/input/EventHub.cpp
@@ -1254,6 +1254,12 @@
// Enable wake-lock behavior on kernels that support it.
// TODO: Only need this for devices that can really wake the system.
+#ifndef EVIOCSSUSPENDBLOCK
+ // uapi headers don't include EVIOCSSUSPENDBLOCK, and future kernels
+ // will use an epoll flag instead, so as long as we want to support
+ // this feature, we need to be prepared to define the ioctl ourselves.
+#define EVIOCSSUSPENDBLOCK _IOW('E', 0x91, int)
+#endif
bool usingSuspendBlockIoctl = !ioctl(fd, EVIOCSSUSPENDBLOCK, 1);
// Tell the kernel that we want to use the monotonic clock for reporting timestamps
diff --git a/services/input/InputReader.cpp b/services/input/InputReader.cpp
index feed31c..03852a5 100644
--- a/services/input/InputReader.cpp
+++ b/services/input/InputReader.cpp
@@ -2135,12 +2135,11 @@
}
}
- bool metaStateChanged = false;
int32_t oldMetaState = mMetaState;
int32_t newMetaState = updateMetaState(keyCode, down, oldMetaState);
- if (oldMetaState != newMetaState) {
+ bool metaStateChanged = oldMetaState != newMetaState;
+ if (metaStateChanged) {
mMetaState = newMetaState;
- metaStateChanged = true;
updateLedState(false);
}
@@ -2932,7 +2931,6 @@
int32_t rawHeight = mRawPointerAxes.y.maxValue - mRawPointerAxes.y.minValue + 1;
// Get associated display dimensions.
- bool viewportChanged = false;
DisplayViewport newViewport;
if (mParameters.hasAssociatedDisplay) {
if (!mConfig.getDisplayInfo(mParameters.associatedDisplayIsExternal, &newViewport)) {
@@ -2946,9 +2944,9 @@
} else {
newViewport.setNonDisplayViewport(rawWidth, rawHeight);
}
- if (mViewport != newViewport) {
+ bool viewportChanged = mViewport != newViewport;
+ if (viewportChanged) {
mViewport = newViewport;
- viewportChanged = true;
if (mDeviceMode == DEVICE_MODE_DIRECT || mDeviceMode == DEVICE_MODE_POINTER) {
// Convert rotated viewport to natural surface coordinates.
@@ -3017,9 +3015,8 @@
}
// If moving between pointer modes, need to reset some state.
- bool deviceModeChanged;
- if (mDeviceMode != oldDeviceMode) {
- deviceModeChanged = true;
+ bool deviceModeChanged = mDeviceMode != oldDeviceMode;
+ if (deviceModeChanged) {
mOrientedRanges.clear();
}
diff --git a/services/java/com/android/server/ConnectivityService.java b/services/java/com/android/server/ConnectivityService.java
index b5f0697..a9b4f19 100644
--- a/services/java/com/android/server/ConnectivityService.java
+++ b/services/java/com/android/server/ConnectivityService.java
@@ -1561,9 +1561,12 @@
return false;
}
NetworkStateTracker tracker = mNetTrackers[networkType];
- DetailedState netState = tracker.getNetworkInfo().getDetailedState();
+ DetailedState netState = DetailedState.DISCONNECTED;
+ if (tracker != null) {
+ netState = tracker.getNetworkInfo().getDetailedState();
+ }
- if (tracker == null || (netState != DetailedState.CONNECTED &&
+ if ((netState != DetailedState.CONNECTED &&
netState != DetailedState.CAPTIVE_PORTAL_CHECK) ||
tracker.isTeardownRequested()) {
if (VDBG) {
@@ -3374,6 +3377,11 @@
String pacFileUrl = "";
if (proxyProperties != null && (!TextUtils.isEmpty(proxyProperties.getHost()) ||
!TextUtils.isEmpty(proxyProperties.getPacFileUrl()))) {
+ if (!proxyProperties.isValid()) {
+ if (DBG)
+ log("Invalid proxy properties, ignoring: " + proxyProperties.toString());
+ return;
+ }
mGlobalProxy = new ProxyProperties(proxyProperties);
host = mGlobalProxy.getHost();
port = mGlobalProxy.getPort();
@@ -3417,6 +3425,11 @@
} else {
proxyProperties = new ProxyProperties(host, port, exclList);
}
+ if (!proxyProperties.isValid()) {
+ if (DBG) log("Invalid proxy properties, ignoring: " + proxyProperties.toString());
+ return;
+ }
+
synchronized (mProxyLock) {
mGlobalProxy = proxyProperties;
}
@@ -3441,6 +3454,10 @@
synchronized (mProxyLock) {
if (mDefaultProxy != null && mDefaultProxy.equals(proxy)) return;
if (mDefaultProxy == proxy) return; // catches repeated nulls
+ if (!proxy.isValid()) {
+ if (DBG) log("Invalid proxy properties, ignoring: " + proxy.toString());
+ return;
+ }
mDefaultProxy = proxy;
if (mGlobalProxy != null) return;
diff --git a/services/java/com/android/server/DevicePolicyManagerService.java b/services/java/com/android/server/DevicePolicyManagerService.java
index 8cc80f7..b0fe6a7 100644
--- a/services/java/com/android/server/DevicePolicyManagerService.java
+++ b/services/java/com/android/server/DevicePolicyManagerService.java
@@ -55,6 +55,7 @@
import android.content.pm.Signature;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.ResolveInfo;
+import android.net.ProxyProperties;
import android.content.pm.UserInfo;
import android.net.Uri;
import android.os.AsyncTask;
@@ -2463,6 +2464,12 @@
}
exclusionList = exclusionList.trim();
ContentResolver res = mContext.getContentResolver();
+
+ ProxyProperties proxyProperties = new ProxyProperties(data[0], proxyPort, exclusionList);
+ if (!proxyProperties.isValid()) {
+ Slog.e(TAG, "Invalid proxy properties, ignoring: " + proxyProperties.toString());
+ return;
+ }
Settings.Global.putString(res, Settings.Global.GLOBAL_HTTP_PROXY_HOST, data[0]);
Settings.Global.putInt(res, Settings.Global.GLOBAL_HTTP_PROXY_PORT, proxyPort);
Settings.Global.putString(res, Settings.Global.GLOBAL_HTTP_PROXY_EXCLUSION_LIST,
diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java
index cfb10a0..15bf8c8 100644
--- a/services/java/com/android/server/wm/WindowManagerService.java
+++ b/services/java/com/android/server/wm/WindowManagerService.java
@@ -5595,8 +5595,7 @@
// We keep on including windows until we go past a full-screen
// window.
- boolean fullscreen = ws.isFullscreen(dw, dh);
- including = !ws.mIsImWindow && !fullscreen;
+ including = !ws.mIsImWindow && !ws.isFullscreen(dw, dh);
final WindowStateAnimator winAnim = ws.mWinAnimator;
if (maxLayer < winAnim.mSurfaceLayer) {
@@ -5622,11 +5621,6 @@
ws.isDisplayedLw()) {
screenshotReady = true;
}
-
- if (fullscreen) {
- // No point in continuing down through windows.
- break;
- }
}
if (appToken != null && appWin == null) {
diff --git a/telephony/java/android/telephony/ServiceState.java b/telephony/java/android/telephony/ServiceState.java
index 6c4bd66..606fcb4 100644
--- a/telephony/java/android/telephony/ServiceState.java
+++ b/telephony/java/android/telephony/ServiceState.java
@@ -693,7 +693,7 @@
mOperatorNumeric = m.getString("operator-numeric");
mIsManualNetworkSelection = m.getBoolean("manual");
mRilVoiceRadioTechnology = m.getInt("radioTechnology");
- mRilVoiceRadioTechnology = m.getInt("dataRadioTechnology");
+ mRilDataRadioTechnology = m.getInt("dataRadioTechnology");
mCssIndicator = m.getBoolean("cssIndicator");
mNetworkId = m.getInt("networkId");
mSystemId = m.getInt("systemId");
diff --git a/tools/aapt/Images.cpp b/tools/aapt/Images.cpp
index b2cbf49..25a948d 100644
--- a/tools/aapt/Images.cpp
+++ b/tools/aapt/Images.cpp
@@ -452,10 +452,11 @@
int maxSizeXDivs = W * sizeof(int32_t);
int maxSizeYDivs = H * sizeof(int32_t);
- int32_t* xDivs = (int32_t*) malloc(maxSizeXDivs);
- int32_t* yDivs = (int32_t*) malloc(maxSizeYDivs);
- uint8_t numXDivs = 0;
- uint8_t numYDivs = 0;
+ int32_t* xDivs = image->info9Patch.xDivs = (int32_t*) malloc(maxSizeXDivs);
+ int32_t* yDivs = image->info9Patch.yDivs = (int32_t*) malloc(maxSizeYDivs);
+ uint8_t numXDivs = 0;
+ uint8_t numYDivs = 0;
+
int8_t numColors;
int numRows;
int numCols;
@@ -510,6 +511,10 @@
goto getout;
}
+ // Copy patch size data into image...
+ image->info9Patch.numXDivs = numXDivs;
+ image->info9Patch.numYDivs = numYDivs;
+
// Find left and right of padding area...
if (get_horizontal_ticks(image->rows[H-1], W, transparent, false, &image->info9Patch.paddingLeft,
&image->info9Patch.paddingRight, &errorMsg, NULL, false) != NO_ERROR) {
@@ -545,12 +550,6 @@
image->layoutBoundsRight, image->layoutBoundsBottom));
}
- // Copy patch data into image
- image->info9Patch.numXDivs = numXDivs;
- image->info9Patch.numYDivs = numYDivs;
- image->info9Patch.xDivs = xDivs;
- image->info9Patch.yDivs = yDivs;
-
// If padding is not yet specified, take values from size.
if (image->info9Patch.paddingLeft < 0) {
image->info9Patch.paddingLeft = xDivs[0];
@@ -957,7 +956,7 @@
gg = *row++;
bb = *row++;
aa = *row++;
-
+
if (isGrayscale) {
*out++ = rr;
} else {
diff --git a/tools/aapt/Resource.cpp b/tools/aapt/Resource.cpp
index 08ad7a0..386888b 100644
--- a/tools/aapt/Resource.cpp
+++ b/tools/aapt/Resource.cpp
@@ -469,7 +469,7 @@
value.data);
return ATTR_NOT_FOUND;
}
-
+
pool = table.getTableStringBlock(strIdx);
#if 0
if (pool != NULL) {
@@ -705,7 +705,7 @@
// don't stop the build.
return true;
}
-
+
node->addAttribute(ns, attr, String16(value));
return true;
}
@@ -756,7 +756,7 @@
bundle->getVersionName(), errorOnFailedInsert)) {
return UNKNOWN_ERROR;
}
-
+
if (bundle->getMinSdkVersion() != NULL
|| bundle->getTargetSdkVersion() != NULL
|| bundle->getMaxSdkVersion() != NULL) {
@@ -765,7 +765,7 @@
vers = XMLNode::newElement(root->getFilename(), String16(), String16("uses-sdk"));
root->insertChildAt(vers, 0);
}
-
+
if (!addTagAttribute(vers, RESOURCES_ANDROID_NAMESPACE, "minSdkVersion",
bundle->getMinSdkVersion(), errorOnFailedInsert)) {
return UNKNOWN_ERROR;
@@ -840,7 +840,7 @@
}
}
}
-
+
return NO_ERROR;
}
@@ -924,7 +924,7 @@
// --------------------------------------------------------------
// resType -> leafName -> group
- KeyedVector<String8, sp<ResourceTypeSet> > *resources =
+ KeyedVector<String8, sp<ResourceTypeSet> > *resources =
new KeyedVector<String8, sp<ResourceTypeSet> >;
collect_files(assets, resources);
@@ -956,7 +956,7 @@
// now go through any resource overlays and collect their files
sp<AaptAssets> current = assets->getOverlay();
while(current.get()) {
- KeyedVector<String8, sp<ResourceTypeSet> > *resources =
+ KeyedVector<String8, sp<ResourceTypeSet> > *resources =
new KeyedVector<String8, sp<ResourceTypeSet> >;
current->setResources(resources);
collect_files(current, resources);
@@ -1059,7 +1059,7 @@
// compile resources
current = assets;
while(current.get()) {
- KeyedVector<String8, sp<ResourceTypeSet> > *resources =
+ KeyedVector<String8, sp<ResourceTypeSet> > *resources =
current->getResources();
ssize_t index = resources->indexOfKey(String8("values"));
@@ -1068,7 +1068,7 @@
ssize_t res;
while ((res=it.next()) == NO_ERROR) {
sp<AaptFile> file = it.getFile();
- res = compileResourceFile(bundle, assets, file, it.getParams(),
+ res = compileResourceFile(bundle, assets, file, it.getParams(),
(current!=assets), &table);
if (res != NO_ERROR) {
hasErrors = true;
@@ -1253,7 +1253,7 @@
if (table.validateLocalizations()) {
hasErrors = true;
}
-
+
if (hasErrors) {
return UNKNOWN_ERROR;
}
@@ -1286,7 +1286,7 @@
ResTable finalResTable;
sp<AaptFile> resFile;
-
+
if (table.hasResources()) {
sp<AaptSymbols> symbols = assets->getSymbolsFor(String8("R"));
err = table.addSymbols(symbols);
@@ -1318,10 +1318,10 @@
table.writePublicDefinitions(String16(assets->getPackage()), fp);
fclose(fp);
}
-
+
// Read resources back in,
finalResTable.add(resFile->getData(), resFile->getSize(), NULL);
-
+
#if 0
NOISY(
printf("Generated resources:\n");
@@ -1329,7 +1329,7 @@
)
#endif
}
-
+
// Perform a basic validation of the manifest file. This time we
// parse it with the comments intact, so that we can use them to
// generate java docs... so we are not going to write this one
@@ -1424,7 +1424,7 @@
ssize_t index = block.indexOfAttribute(RESOURCES_ANDROID_NAMESPACE, "name");
const uint16_t* id = block.getAttributeStringValue(index, &len);
if (id == NULL) {
- fprintf(stderr, "%s:%d: missing name attribute in element <%s>.\n",
+ fprintf(stderr, "%s:%d: missing name attribute in element <%s>.\n",
manifestPath.string(), block.getLineNumber(),
String8(block.getElementName(&len)).string());
hasErrors = true;
@@ -1582,7 +1582,7 @@
return err;
}
}
-
+
return err;
}
@@ -1704,7 +1704,7 @@
NA = idents.size();
bool deprecated = false;
-
+
String16 comment = symbols->getComment(realClassName);
fprintf(fp, "%s/** ", indentStr);
if (comment.size() > 0) {
@@ -1787,7 +1787,7 @@
if (deprecated) {
fprintf(fp, "%s@Deprecated\n", indentStr);
}
-
+
fprintf(fp,
"%spublic static final int[] %s = {\n"
"%s",
@@ -1832,9 +1832,9 @@
//printf("%s:%s/%s: 0x%08x\n", String8(package16).string(),
// String8(attr16).string(), String8(name16).string(), typeSpecFlags);
const bool pub = (typeSpecFlags&ResTable_typeSpec::SPEC_PUBLIC) != 0;
-
+
bool deprecated = false;
-
+
fprintf(fp, "%s/**\n", indentStr);
if (comment.size() > 0) {
String8 cmt(comment);
@@ -2219,10 +2219,10 @@
status_t err = writeSymbolClass(fp, assets, includePrivate, symbols,
className, 0, bundle->getNonConstantId());
+ fclose(fp);
if (err != NO_ERROR) {
return err;
}
- fclose(fp);
if (textSymbolsDest != NULL && R == className) {
String8 textDest(textSymbolsDest);
@@ -2241,10 +2241,10 @@
status_t err = writeTextSymbolClass(fp, assets, includePrivate, symbols,
className);
+ fclose(fp);
if (err != NO_ERROR) {
return err;
}
- fclose(fp);
}
// If we were asked to generate a dependency file, we'll go ahead and add this R.java
diff --git a/tools/aidl/aidl.cpp b/tools/aidl/aidl.cpp
index b8a4803..a84d743 100644
--- a/tools/aidl/aidl.cpp
+++ b/tools/aidl/aidl.cpp
@@ -207,7 +207,7 @@
p = strchr(name->data, '.');
len = p ? p-name->data : strlen(name->data);
expected.append(name->data, len);
-
+
expected += ".aidl";
len = fn.length();
@@ -473,7 +473,7 @@
err = 1;
goto next;
}
-
+
if (!(kind == INTERFACE_TYPE_BINDER ? t->CanWriteToParcel() : t->CanWriteToRpcData())) {
fprintf(stderr, "%s:%d parameter %d: '%s %s' can't be marshalled.\n",
filename, m->type.type.lineno, index,
@@ -536,7 +536,7 @@
filename, m->name.lineno, index, arg->name.data);
err = 1;
}
-
+
next:
index++;
arg = arg->next;
@@ -797,7 +797,7 @@
//printf("%s:%d:...%s...%s...%s...\n", filename.c_str(), lineno,
// type, packagename, classname);
document_item_type* doc;
-
+
if (0 == strcmp("parcelable", type)) {
user_data_type* parcl = (user_data_type*)malloc(
sizeof(user_data_type));
@@ -847,6 +847,7 @@
else {
fprintf(stderr, "%s:%d: bad type in line: %s\n",
filename.c_str(), lineno, line);
+ fclose(f);
return 1;
}
err = gather_types(filename.c_str(), doc);
@@ -1103,13 +1104,13 @@
}
// write preprocessed file
- int fd = open( options.outputFileName.c_str(),
+ int fd = open( options.outputFileName.c_str(),
O_RDWR|O_CREAT|O_TRUNC|O_BINARY,
#ifdef HAVE_MS_C_RUNTIME
_S_IREAD|_S_IWRITE);
-#else
+#else
S_IRUSR|S_IWUSR|S_IRGRP);
-#endif
+#endif
if (fd == -1) {
fprintf(stderr, "aidl: could not open file for write: %s\n",
options.outputFileName.c_str());