am 8e9b03f9: am da133d84: Cleaning Manifest and re-adding systrace.

* commit '8e9b03f9b26f75e1293cac9e658983d2d4a6d963':
  Cleaning Manifest and re-adding systrace.
diff --git a/suite/audio_quality/lib/src/audio/AudioProtocol.cpp b/suite/audio_quality/lib/src/audio/AudioProtocol.cpp
index c3457f5..25c1422 100644
--- a/suite/audio_quality/lib/src/audio/AudioProtocol.cpp
+++ b/suite/audio_quality/lib/src/audio/AudioProtocol.cpp
@@ -18,8 +18,8 @@
 #include <sys/types.h>
 #include <sys/socket.h>
 
+#include <UniquePtr.h>
 #include <utils/StrongPointer.h>
-#include <utils/UniquePtr.h>
 
 #include "audio/Buffer.h"
 #include "Log.h"
diff --git a/tests/tests/media/src/android/media/cts/EncodeDecodeTest.java b/tests/tests/media/src/android/media/cts/EncodeDecodeTest.java
index 445814e..6f1faf6 100644
--- a/tests/tests/media/src/android/media/cts/EncodeDecodeTest.java
+++ b/tests/tests/media/src/android/media/cts/EncodeDecodeTest.java
@@ -261,6 +261,7 @@
             // Create a MediaCodec for the decoder, just based on the MIME type.  The various
             // format details will be passed through the csd-0 meta-data later on.
             decoder = MediaCodec.createDecoderByType(MIME_TYPE);
+            if (VERBOSE) Log.d(TAG, "got decoder: " + decoder.getName());
 
             doEncodeDecodeVideoFromBuffer(encoder, colorFormat, decoder, toSurface);
         } finally {
@@ -321,7 +322,7 @@
             // Create a MediaCodec for the decoder, just based on the MIME type.  The various
             // format details will be passed through the csd-0 meta-data later on.
             decoder = MediaCodec.createDecoderByType(MIME_TYPE);
-            MediaFormat decoderFormat = MediaFormat.createVideoFormat(MIME_TYPE, mWidth, mHeight);
+            if (VERBOSE) Log.d(TAG, "got decoder: " + decoder.getName());
             decoder.configure(format, outputSurface.getSurface(), null, 0);
             decoder.start();
 
@@ -910,7 +911,7 @@
         // Set to zero.  In YUV this is a dull green.
         Arrays.fill(frameData, (byte) 0);
 
-        int startX, startY, countX, countY;
+        int startX, startY;
 
         frameIndex %= 8;
         //frameIndex = (frameIndex / 8) % 8;    // use this instead for debug -- easier to see
diff --git a/tests/tests/media/src/android/media/cts/InputSurface.java b/tests/tests/media/src/android/media/cts/InputSurface.java
index 5d72979..157ed88 100644
--- a/tests/tests/media/src/android/media/cts/InputSurface.java
+++ b/tests/tests/media/src/android/media/cts/InputSurface.java
@@ -35,7 +35,6 @@
  */
 class InputSurface {
     private static final String TAG = "InputSurface";
-    private static final boolean VERBOSE = false;
 
     private static final int EGL_RECORDABLE_ANDROID = 0x3142;
 
diff --git a/tests/tests/permission/src/android/permission/cts/FileSystemPermissionTest.java b/tests/tests/permission/src/android/permission/cts/FileSystemPermissionTest.java
index f047e28..8edf1d0 100644
--- a/tests/tests/permission/src/android/permission/cts/FileSystemPermissionTest.java
+++ b/tests/tests/permission/src/android/permission/cts/FileSystemPermissionTest.java
@@ -730,6 +730,13 @@
                 new File("/dev/alarm"),      // b/9035217
                 new File("/dev/ashmem"),
                 new File("/dev/binder"),
+                new File("/dev/felica"),
+                new File("/dev/felica_ant"),
+                new File("/dev/felica_cen"),
+                new File("/dev/felica_pon"),
+                new File("/dev/felica_rfs"),
+                new File("/dev/felica_rws"),
+                new File("/dev/felica_uicc"),
                 new File("/dev/full"),
                 new File("/dev/genlock"),    // b/9035217
                 new File("/dev/hw_random"),  // b/9191279
@@ -749,6 +756,10 @@
                 new File("/dev/ptmx"),        // b/9088251
                 new File("/dev/pvrsrvkm"),    // b/9108170
                 new File("/dev/random"),
+                new File("/dev/snfc_cen"),
+                new File("/dev/snfc_hsel"),
+                new File("/dev/snfc_intu_poll"),
+                new File("/dev/snfc_rfs"),
                 new File("/dev/tiler"),       // b/9108170
                 new File("/dev/tty"),
                 new File("/dev/urandom"),
diff --git a/tests/tests/security/jni/Android.mk b/tests/tests/security/jni/Android.mk
index 58bab14..64b6962 100644
--- a/tests/tests/security/jni/Android.mk
+++ b/tests/tests/security/jni/Android.mk
@@ -27,9 +27,10 @@
 		android_security_cts_LinuxRngTest.cpp \
 		android_security_cts_LoadEffectLibraryTest.cpp \
 		android_security_cts_NativeCodeTest.cpp \
+		android_security_cts_SELinuxTest.cpp
 
 LOCAL_C_INCLUDES := $(JNI_H_INCLUDE)
 
-LOCAL_SHARED_LIBRARIES := libnativehelper liblog libbinder libutils libmedia
+LOCAL_SHARED_LIBRARIES := libnativehelper liblog libbinder libutils libmedia libselinux
 
 include $(BUILD_SHARED_LIBRARY)
diff --git a/tests/tests/security/jni/CtsSecurityJniOnLoad.cpp b/tests/tests/security/jni/CtsSecurityJniOnLoad.cpp
index b9aeaf5..d6179e8 100644
--- a/tests/tests/security/jni/CtsSecurityJniOnLoad.cpp
+++ b/tests/tests/security/jni/CtsSecurityJniOnLoad.cpp
@@ -21,6 +21,7 @@
 extern int register_android_security_cts_LinuxRngTest(JNIEnv*);
 extern int register_android_security_cts_NativeCodeTest(JNIEnv*);
 extern int register_android_security_cts_LoadEffectLibraryTest(JNIEnv*);
+extern int register_android_security_cts_SELinuxTest(JNIEnv*);
 
 jint JNI_OnLoad(JavaVM *vm, void *reserved) {
     JNIEnv *env = NULL;
@@ -45,5 +46,9 @@
         return JNI_ERR;
     }
 
+    if (register_android_security_cts_SELinuxTest(env)) {
+        return JNI_ERR;
+    }
+
     return JNI_VERSION_1_4;
 }
diff --git a/tests/tests/security/jni/android_security_cts_SELinuxTest.cpp b/tests/tests/security/jni/android_security_cts_SELinuxTest.cpp
new file mode 100644
index 0000000..3bee3a5
--- /dev/null
+++ b/tests/tests/security/jni/android_security_cts_SELinuxTest.cpp
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2013 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.
+ */
+
+#include <jni.h>
+#include <selinux/selinux.h>
+#include <JNIHelp.h>
+#include <ScopedUtfChars.h>
+
+/*
+ * Function: checkSELinuxAccess
+ * Purpose: Check permissions between two security contexts.
+ * Parameters: subjectContextStr: subject security context as a string
+ *             objectContextStr: object security context as a string
+ *             objectClassStr: object's security class name as a string
+ *             permissionStr: permission name as a string
+ * Returns: boolean: (true) if permission was granted, (false) otherwise
+ * Exceptions: NullPointerException if any argument is NULL
+ */
+static jboolean android_security_cts_SELinuxTest_checkSELinuxAccess(JNIEnv *env, jobject, jstring subjectContextStr,
+        jstring objectContextStr, jstring objectClassStr, jstring permissionStr, jstring auxStr) {
+    if (subjectContextStr == NULL || objectContextStr == NULL || objectClassStr == NULL
+            || permissionStr == NULL || auxStr == NULL) {
+        jniThrowNullPointerException(env, NULL);
+        return false;
+    }
+
+    ScopedUtfChars subjectContext(env, subjectContextStr);
+    ScopedUtfChars objectContext(env, objectContextStr);
+    ScopedUtfChars objectClass(env, objectClassStr);
+    ScopedUtfChars permission(env, permissionStr);
+    ScopedUtfChars aux(env, auxStr);
+
+    char *tmp1 = const_cast<char *>(subjectContext.c_str());
+    char *tmp2 = const_cast<char *>(objectContext.c_str());
+    char *tmp3 = const_cast<char *>(aux.c_str());
+    int accessGranted = selinux_check_access(tmp1, tmp2, objectClass.c_str(), permission.c_str(), tmp3);
+    return (accessGranted == 0) ? true : false;
+}
+
+
+static JNINativeMethod gMethods[] = {
+    {  "checkSELinuxAccess", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Z",
+            (void *) android_security_cts_SELinuxTest_checkSELinuxAccess },
+};
+
+int register_android_security_cts_SELinuxTest(JNIEnv* env)
+{
+    jclass clazz = env->FindClass("android/security/cts/SELinuxTest");
+    return env->RegisterNatives(clazz, gMethods,
+            sizeof(gMethods) / sizeof(JNINativeMethod));
+}
diff --git a/tests/tests/security/src/android/security/cts/BannedFilesTest.java b/tests/tests/security/src/android/security/cts/BannedFilesTest.java
index f1db0cb..0b16380 100644
--- a/tests/tests/security/src/android/security/cts/BannedFilesTest.java
+++ b/tests/tests/security/src/android/security/cts/BannedFilesTest.java
@@ -85,6 +85,14 @@
         assertNotSetugid("/vendor/bin/tcpdump-arm");
     }
 
+    /**
+     * Test if /dev/diag exists.
+     */
+    public void testNoDevDiag(){
+        File file = new File("/dev/diag");
+        assertFalse("File \"" + file.getAbsolutePath() + "\" exists", file.exists());
+    }
+
     private static void assertNotSetugid(String file) {
         FileUtils.FileStatus fs = new FileUtils.FileStatus();
         if (!FileUtils.getFileStatus(file, fs, false)) {
diff --git a/tests/tests/security/src/android/security/cts/SELinuxTest.java b/tests/tests/security/src/android/security/cts/SELinuxTest.java
new file mode 100644
index 0000000..838eb8a
--- /dev/null
+++ b/tests/tests/security/src/android/security/cts/SELinuxTest.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2013 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 android.security.cts;
+
+import junit.framework.TestCase;
+
+/**
+ * Verify that the SELinux configuration is sane.
+ */
+public class SELinuxTest extends TestCase {
+
+    static {
+        System.loadLibrary("ctssecurity_jni");
+    }
+
+    public void testMyJni() {
+        try {
+            checkSELinuxAccess(null, null, null, null, null);
+            fail("should have thrown");
+        } catch (NullPointerException e) {
+            // expected
+        }
+    }
+
+
+    public void testCheckAccessSane() {
+        assertFalse(checkSELinuxAccess("a", "b", "c", "d", "e"));
+    }
+
+    public void testRild() {
+        assertTrue(checkSELinuxAccess("u:r:rild:s0", "u:object_r:rild_prop:s0", "property_service", "set", "ril.ecclist"));
+    }
+
+    public void testZygote() {
+        assertFalse(checkSELinuxAccess("u:r:zygote:s0", "u:object_r:runas_exec:s0", "file", "getattr", "/system/bin/run-as"));
+        // Also check init, just as a sanity check (init is unconfined, so it should pass)
+        assertTrue(checkSELinuxAccess("u:r:init:s0", "u:object_r:runas_exec:s0", "file", "getattr", "/system/bin/run-as"));
+    }
+
+    private static native boolean checkSELinuxAccess(String scon, String tcon, String tclass, String perm, String extra);
+}
diff --git a/tests/tests/security/src/android/security/cts/VoldExploitTest.java b/tests/tests/security/src/android/security/cts/VoldExploitTest.java
index 74d0f68..486d5f0 100644
--- a/tests/tests/security/src/android/security/cts/VoldExploitTest.java
+++ b/tests/tests/security/src/android/security/cts/VoldExploitTest.java
@@ -222,7 +222,7 @@
         Set<Integer> retval = new HashSet<Integer>();
         for (List<String> i : netlink) {
             // The PID is in column 3
-            int pid = Integer.decode(i.get(2));
+            int pid = Long.decode(i.get(2)).intValue();
             if (new File("/proc/" + pid + "/cmdline").exists()) {
                 retval.add(pid);
             }
diff --git a/tools/dasm/src/dasm/DAsm.java b/tools/dasm/src/dasm/DAsm.java
index d298689..72436ac 100644
--- a/tools/dasm/src/dasm/DAsm.java
+++ b/tools/dasm/src/dasm/DAsm.java
@@ -403,8 +403,11 @@
         regs_count = 1;
 
         method_nat = new CstNat(new CstString(name), new CstString(descriptor));
-        if (method_nat.isClassInit()) access |= AccessFlags.ACC_STATIC;
-        if (method_nat.isInstanceInit()) access |= AccessFlags.ACC_CONSTRUCTOR;
+        if (method_nat.isClassInit()) {
+            access |= (AccessFlags.ACC_CONSTRUCTOR | AccessFlags.ACC_STATIC);
+        } else if (method_nat.isInstanceInit()) {
+            access |= AccessFlags.ACC_CONSTRUCTOR;
+        }
 
         method_acc = access;
     }