Merge change Ie7d26695 into eclair

* changes:
  Modify the "active chats" uri to not overlap with other uris.
diff --git a/core/java/android/pim/vcard/VCardComposer.java b/core/java/android/pim/vcard/VCardComposer.java
index e01bd3c..40b4fc4 100644
--- a/core/java/android/pim/vcard/VCardComposer.java
+++ b/core/java/android/pim/vcard/VCardComposer.java
@@ -23,6 +23,7 @@
 import android.content.Entity.NamedContentValues;
 import android.database.Cursor;
 import android.database.sqlite.SQLiteException;
+import android.net.Uri;
 import android.os.RemoteException;
 import android.provider.CallLog;
 import android.provider.CallLog.Calls;
@@ -81,7 +82,7 @@
 public class VCardComposer {
     private static final String LOG_TAG = "vcard.VCardComposer";
 
-    private final static String DEFAULT_EMAIL_TYPE = Constants.ATTR_TYPE_INTERNET;
+    private static final String DEFAULT_EMAIL_TYPE = Constants.ATTR_TYPE_INTERNET;
 
     public static final String FAILURE_REASON_FAILED_TO_GET_DATABASE_INFO =
         "Failed to get database information";
@@ -94,6 +95,14 @@
 
     public static final String NO_ERROR = "No error";
 
+    private static final Uri sDataRequestUri;
+
+    static {
+        Uri.Builder builder = RawContacts.CONTENT_URI.buildUpon();
+        builder.appendQueryParameter(Data.FOR_EXPORT_ONLY, "1");
+        sDataRequestUri = builder.build();
+    }
+
     public static interface OneEntryHandler {
         public boolean onInit(Context context);
 
@@ -116,7 +125,7 @@
         @SuppressWarnings("hiding")
         private static final String LOG_TAG = "vcard.VCardComposer.HandlerForOutputStream";
 
-        private OutputStream mOutputStream; // mWriter will close this.
+        final private OutputStream mOutputStream; // mWriter will close this.
         private Writer mWriter;
 
         private boolean mOnTerminateIsCalled = false;
@@ -301,8 +310,8 @@
 
     private boolean mIsCallLogComposer = false;
 
-    private static final String[] sRawContactsProjection = new String[] {
-        RawContacts._ID,
+    private static final String[] sContactsProjection = new String[] {
+        Contacts._ID,
     };
 
     /** The projection to use when querying the call log table */
@@ -442,7 +451,7 @@
             mCursor = mContentResolver.query(CallLog.Calls.CONTENT_URI, sCallLogProjection,
                     selection, selectionArgs, null);
         } else {
-            mCursor = mContentResolver.query(RawContacts.CONTENT_URI, sRawContactsProjection,
+            mCursor = mContentResolver.query(Contacts.CONTENT_URI, sContactsProjection,
                     selection, selectionArgs, null);
         }
 
@@ -451,7 +460,7 @@
             return false;
         }
 
-        if (mCursor.getCount() == 0 || !mCursor.moveToFirst()) {
+        if (getCount() == 0 || !mCursor.moveToFirst()) {
             try {
                 mCursor.close();
             } catch (SQLiteException e) {
@@ -604,23 +613,19 @@
     }
 
     private String createOneEntryInternal(final String contactId) {
-        final StringBuilder builder = new StringBuilder();
-        appendVCardLine(builder, VCARD_PROPERTY_BEGIN, VCARD_DATA_VCARD);
-        if (mIsV30) {
-            appendVCardLine(builder, VCARD_PROPERTY_VERSION, Constants.VERSION_V30);
-        } else {
-            appendVCardLine(builder, VCARD_PROPERTY_VERSION, Constants.VERSION_V21);
-        }
-
         final Map<String, List<ContentValues>> contentValuesListMap =
-            new HashMap<String, List<ContentValues>>();
-
-        final String selection = Data.RAW_CONTACT_ID + "=?";
+                new HashMap<String, List<ContentValues>>();
+        final String selection = Data.CONTACT_ID + "=?";
         final String[] selectionArgs = new String[] {contactId};
+        // The resolver may return the entity iterator with no data. It is possiible.
+        // e.g. If all the data in the contact of the given contact id are not exportable ones,
+        //      they are hidden from the view of this method, though contact id itself exists.
+        boolean dataExists = false;
         EntityIterator entityIterator = null;
         try {
             entityIterator = mContentResolver.queryEntities(
-                    RawContacts.CONTENT_URI, selection, selectionArgs, null);
+                    sDataRequestUri, selection, selectionArgs, null);
+            dataExists = entityIterator.hasNext();
             while (entityIterator.hasNext()) {
                 Entity entity = entityIterator.next();
                 for (NamedContentValues namedContentValues : entity
@@ -648,7 +653,18 @@
             }
         }
 
-        // TODO: consolidate order? (low priority)
+        if (!dataExists) {
+            return "";
+        }
+
+        final StringBuilder builder = new StringBuilder();
+        appendVCardLine(builder, VCARD_PROPERTY_BEGIN, VCARD_DATA_VCARD);
+        if (mIsV30) {
+            appendVCardLine(builder, VCARD_PROPERTY_VERSION, Constants.VERSION_V30);
+        } else {
+            appendVCardLine(builder, VCARD_PROPERTY_VERSION, Constants.VERSION_V21);
+        }
+
         appendStructuredNames(builder, contentValuesListMap);
         appendNickNames(builder, contentValuesListMap);
         appendPhones(builder, contentValuesListMap);
@@ -660,7 +676,7 @@
         appendOrganizations(builder, contentValuesListMap);
         appendPhotos(builder, contentValuesListMap);
         appendNotes(builder, contentValuesListMap);
-        // TODO: GroupMembership... What?
+        // TODO: GroupMembership
 
         if (mIsDoCoMo) {
             appendVCardLine(builder, VCARD_PROPERTY_X_CLASS, VCARD_DATA_PUBLIC);
diff --git a/core/java/android/provider/ContactsContract.java b/core/java/android/provider/ContactsContract.java
index c7bce0f..3a9bad8 100644
--- a/core/java/android/provider/ContactsContract.java
+++ b/core/java/android/provider/ContactsContract.java
@@ -805,6 +805,22 @@
         public static final String CONTENT_TYPE = "vnd.android.cursor.dir/data";
 
         /**
+         * If {@link #FOR_EXPORT_ONLY} is explicitly set to "1", returned Cursor toward
+         * Data.CONTENT_URI contains only exportable data.
+         *
+         * This flag is useful (currently) only for vCard exporter in Contacts app, which
+         * needs to exclude "un-exportable" data from available data to export, while
+         * Contacts app itself has priviledge to access all data including "un-expotable"
+         * ones and providers return all of them regardless of the callers' intention.
+         * <P>Type: INTEGER</p>
+         *
+         * @hide Maybe available only in Eclair and not really ready for public use.
+         * TODO: remove, or implement this feature completely. As of now (Eclair),
+         * we only use this flag in queryEntities(), not query().
+         */
+        public static final String FOR_EXPORT_ONLY = "for_export_only";
+
+        /**
          * Build a {@link android.provider.ContactsContract.Contacts#CONTENT_LOOKUP_URI}
          * style {@link Uri} for the parent {@link android.provider.ContactsContract.Contacts}
          * entry of the given {@link Data} entry.
diff --git a/core/java/android/view/HapticFeedbackConstants.java b/core/java/android/view/HapticFeedbackConstants.java
index f936f65..e1f2823 100644
--- a/core/java/android/view/HapticFeedbackConstants.java
+++ b/core/java/android/view/HapticFeedbackConstants.java
@@ -36,6 +36,18 @@
     public static final int VIRTUAL_KEY = 1;
     
     /**
+     * This is a private constant.  Feel free to renumber as desired.
+     * @hide
+     */
+    public static final int SAFE_MODE_DISABLED = 10000;
+    
+    /**
+     * This is a private constant.  Feel free to renumber as desired.
+     * @hide
+     */
+    public static final int SAFE_MODE_ENABLED = 10001;
+    
+    /**
      * Flag for {@link View#performHapticFeedback(int, int)
      * View.performHapticFeedback(int, int)}: Ignore the setting in the
      * view for whether to perform haptic feedback, do it always.
diff --git a/core/java/android/view/WindowManagerPolicy.java b/core/java/android/view/WindowManagerPolicy.java
index b3125b2..78999fa 100644
--- a/core/java/android/view/WindowManagerPolicy.java
+++ b/core/java/android/view/WindowManagerPolicy.java
@@ -813,7 +813,7 @@
             boolean displayEnabled);
     
     /**
-     * Called when the system is mostly done booting to dentermine whether
+     * Called when the system is mostly done booting to determine whether
      * the system should go into safe mode.
      */
     public boolean detectSafeMode();
diff --git a/core/java/android/widget/RemoteViews.java b/core/java/android/widget/RemoteViews.java
index 8ef65db..6771711 100644
--- a/core/java/android/widget/RemoteViews.java
+++ b/core/java/android/widget/RemoteViews.java
@@ -143,7 +143,7 @@
                                     Intent.FLAG_ACTIVITY_NEW_TASK,
                                     Intent.FLAG_ACTIVITY_NEW_TASK, 0);
                         } catch (IntentSender.SendIntentException e) {
-                            throw new ActionException(e.toString());
+                            android.util.Log.e(LOG_TAG, "Cannot send pending intent: ", e);
                         }
                     }
                 };
diff --git a/core/java/com/android/internal/widget/ContactHeaderWidget.java b/core/java/com/android/internal/widget/ContactHeaderWidget.java
index d7311c2..49cc5de 100644
--- a/core/java/com/android/internal/widget/ContactHeaderWidget.java
+++ b/core/java/com/android/internal/widget/ContactHeaderWidget.java
@@ -345,6 +345,7 @@
      */
     public void setExcludeMimes(String[] excludeMimes) {
         mExcludeMimes = excludeMimes;
+        mPhotoView.setExcludeMimes(excludeMimes);
     }
 
     /**
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index 907fd8f..498b5cf 100644
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -124,6 +124,24 @@
         <item>30</item>
     </integer-array>
 
+    <!-- Vibrator pattern for feedback about booting with safe mode disabled -->
+    <integer-array name="config_safeModeDisabledVibePattern">
+        <item>0</item>
+        <item>1</item>
+        <item>20</item>
+        <item>21</item>
+    </integer-array>
+
+    <!-- Vibrator pattern for feedback about booting with safe mode disabled -->
+    <integer-array name="config_safeModeEnabledVibePattern">
+        <item>0</item>
+        <item>1</item>
+        <item>20</item>
+        <item>21</item>
+        <item>500</item>
+        <item>600</item>
+    </integer-array>
+
     <bool name="config_use_strict_phone_number_comparation">false</bool>
 
     <!-- Display low battery warning when battery level dips to this value -->
diff --git a/opengl/tests/gl2_basic/gl2_basic.cpp b/opengl/tests/gl2_basic/gl2_basic.cpp
index 9345de5..d1090e6 100644
--- a/opengl/tests/gl2_basic/gl2_basic.cpp
+++ b/opengl/tests/gl2_basic/gl2_basic.cpp
@@ -178,21 +178,90 @@
 #if 0
 
 void PrintEGLConfig(EGLDisplay dpy, EGLConfig config) {
-	int attrib[] = {EGL_RED_SIZE, EGL_GREEN_SIZE, EGL_BLUE_SIZE, EGL_ALPHA_SIZE,
-			EGL_DEPTH_SIZE, EGL_SURFACE_TYPE, EGL_RENDERABLE_TYPE
-	};
-	for(size_t i = 0; i < sizeof(attrib)/sizeof(attrib[0]); i++) {
+    int attrib[] = {EGL_RED_SIZE, EGL_GREEN_SIZE, EGL_BLUE_SIZE, EGL_ALPHA_SIZE,
+            EGL_DEPTH_SIZE, EGL_SURFACE_TYPE, EGL_RENDERABLE_TYPE
+    };
+    for(size_t i = 0; i < sizeof(attrib)/sizeof(attrib[0]); i++) {
         int value = 0;
         int a = attrib[i];
         if (eglGetConfigAttrib(dpy, config, a, &value)) {
             printf(" 0x%04x: %d", a, value);
         }
-	}
-	printf("\n");
+    }
+    printf("\n");
 }
 
 #endif
 
+int printEGLConfigurations(EGLDisplay dpy) {
+    EGLint numConfig = 0;
+    EGLint returnVal = eglGetConfigs(dpy, NULL, 0, &numConfig);
+    checkEglError("eglGetConfigs", returnVal);
+    if (!returnVal) {
+        return false;
+    }
+
+    printf("Number of EGL configuration: %d\n", numConfig);
+
+    EGLConfig* configs = (EGLConfig*) malloc(sizeof(EGLConfig) * numConfig);
+    if (! configs) {
+        printf("Could not allocate configs.\n");
+        return false;
+    }
+
+    returnVal = eglGetConfigs(dpy, NULL, 0, &numConfig);
+    checkEglError("eglGetConfigs", returnVal);
+    if (!returnVal) {
+        free(configs);
+        return false;
+    }
+
+#define X(VAL) {VAL, #VAL}
+    struct {EGLint attribute; const char* name;} names[] = {
+    X(EGL_BUFFER_SIZE),
+    X(EGL_RED_SIZE),
+    X(EGL_GREEN_SIZE),
+    X(EGL_BLUE_SIZE),
+    X(EGL_ALPHA_SIZE),
+    X(EGL_CONFIG_CAVEAT),
+    X(EGL_CONFIG_ID),
+    X(EGL_DEPTH_SIZE),
+    X(EGL_LEVEL),
+    X(EGL_MAX_PBUFFER_WIDTH),
+    X(EGL_MAX_PBUFFER_HEIGHT),
+    X(EGL_MAX_PBUFFER_PIXELS),
+    X(EGL_NATIVE_RENDERABLE),
+    X(EGL_NATIVE_VISUAL_ID),
+    X(EGL_NATIVE_VISUAL_TYPE),
+    X(EGL_PRESERVED_RESOURCES),
+    X(EGL_SAMPLE_BUFFERS),
+    X(EGL_SAMPLES),
+    // X(EGL_STENCIL_BITS),
+    X(EGL_SURFACE_TYPE),
+    X(EGL_TRANSPARENT_TYPE),
+    // X(EGL_TRANSPARENT_RED),
+    // X(EGL_TRANSPARENT_GREEN),
+    // X(EGL_TRANSPARENT_BLUE)
+    };
+#undef X
+
+    for(int i = 0; i < numConfig; i++) {
+        printf("Configuration %d\n", i);
+        EGLConfig config = configs[i];
+        for (int j = 0; j < sizeof(names) / sizeof(names[0]); j++) {
+            EGLint value = -1;
+            returnVal = eglGetConfigAttrib(dpy, config, names[j].attribute, &value); 
+            if (returnVal) {
+                printf(" %s: %d (0x%x)", names[j].name, value, value);
+            }
+        }
+        printf("\n");
+    }
+
+    free(configs);
+    return true;
+}
+
 int main(int argc, char** argv) {
     EGLBoolean returnValue;
     EGLConfig myConfig = {0};
@@ -226,11 +295,16 @@
         return 0;
     }
 
+    if (!printEGLConfigurations(dpy)) {
+        printf("printEGLConfigurations failed\n");
+        return 0;
+    }
+
     EGLNativeWindowType window = android_createDisplaySurface();

     returnValue = EGLUtils::selectConfigForNativeWindow(dpy, s_configAttribs, window, &myConfig);
     if (returnValue) {
-    	printf("EGLUtils::selectConfigForNativeWindow() returned %d", returnValue);
-    	return 0;
+        printf("EGLUtils::selectConfigForNativeWindow() returned %d", returnValue);
+        return 0;
     }
 
     surface = eglCreateWindowSurface(dpy, myConfig, window, NULL);
diff --git a/services/java/com/android/server/DockObserver.java b/services/java/com/android/server/DockObserver.java
index a70134d..aa9c243 100644
--- a/services/java/com/android/server/DockObserver.java
+++ b/services/java/com/android/server/DockObserver.java
@@ -17,6 +17,7 @@
 package com.android.server;
 
 import android.app.Activity;
+import android.app.KeyguardManager;
 import android.content.ActivityNotFoundException;
 import android.content.BroadcastReceiver;
 import android.content.Context;
@@ -27,6 +28,8 @@
 import android.os.UEventObserver;
 import android.util.Log;
 
+import com.android.internal.widget.LockPatternUtils;
+
 import java.io.FileReader;
 import java.io.FileNotFoundException;
 
@@ -46,7 +49,11 @@
     private final Context mContext;
 
     private PowerManagerService mPowerManager;
-    
+
+    private KeyguardManager.KeyguardLock mKeyguardLock;
+    private boolean mKeyguardDisabled;
+    private LockPatternUtils mLockPatternUtils;
+
     // The broadcast receiver which receives the result of the ordered broadcast sent when
     // the dock state changes. The original ordered broadcast is sent with an initial result
     // code of RESULT_OK. If any of the registered broadcast receivers changes this value, e.g.,
@@ -88,6 +95,7 @@
     public DockObserver(Context context, PowerManagerService pm) {
         mContext = context;
         mPowerManager = pm;
+        mLockPatternUtils = new LockPatternUtils(context.getContentResolver());
         init();  // set initial status
         startObserving(DOCK_UEVENT_MATCH);
     }
@@ -130,6 +138,10 @@
 
     void systemReady() {
         synchronized (this) {
+            KeyguardManager keyguardManager =
+                    (KeyguardManager)mContext.getSystemService(Context.KEYGUARD_SERVICE);
+            mKeyguardLock = keyguardManager.newKeyguardLock(TAG);
+
             // don't bother broadcasting undocked here
             if (mDockState != Intent.EXTRA_DOCK_STATE_UNDOCKED) {
                 update();
@@ -142,10 +154,25 @@
         mHandler.sendEmptyMessage(0);
     }
 
+    private final void updateKeyguardLocked() {
+        if (!mLockPatternUtils.isLockPatternEnabled()) {
+            if (!mKeyguardDisabled && mDockState != Intent.EXTRA_DOCK_STATE_UNDOCKED) {
+                Log.d(TAG, "calling mKeyguardLock.disableKeyguard");
+                mKeyguardLock.disableKeyguard();
+                mKeyguardDisabled = true;
+            } else if (mKeyguardDisabled && mDockState == Intent.EXTRA_DOCK_STATE_UNDOCKED) {
+                Log.d(TAG, "calling mKeyguardLock.reenableKeyguard");
+                mKeyguardLock.reenableKeyguard();
+                mKeyguardDisabled = false;
+            }
+        }
+    }
+
     private final Handler mHandler = new Handler() {
         @Override
         public void handleMessage(Message msg) {
             synchronized (this) {
+                updateKeyguardLocked();
                 Log.d(TAG, "Broadcasting dock state " + mDockState);
                 // Pack up the values and broadcast them to everyone
                 mPowerManager.userActivityWithForce(SystemClock.uptimeMillis(), false, true);
diff --git a/services/java/com/android/server/KeyInputQueue.java b/services/java/com/android/server/KeyInputQueue.java
index d9f4c9c..d7b8f57 100644
--- a/services/java/com/android/server/KeyInputQueue.java
+++ b/services/java/com/android/server/KeyInputQueue.java
@@ -337,6 +337,54 @@
         }
     }
     
+    public int getScancodeState(int code) {
+        synchronized (mFirst) {
+            VirtualKey vk = mPressedVirtualKey;
+            if (vk != null) {
+                if (vk.scancode == code) {
+                    return 2;
+                }
+            }
+            return nativeGetScancodeState(code);
+        }
+    }
+    
+    public int getScancodeState(int deviceId, int code) {
+        synchronized (mFirst) {
+            VirtualKey vk = mPressedVirtualKey;
+            if (vk != null) {
+                if (vk.scancode == code) {
+                    return 2;
+                }
+            }
+            return nativeGetScancodeState(deviceId, code);
+        }
+    }
+    
+    public int getKeycodeState(int code) {
+        synchronized (mFirst) {
+            VirtualKey vk = mPressedVirtualKey;
+            if (vk != null) {
+                if (vk.lastKeycode == code) {
+                    return 2;
+                }
+            }
+            return nativeGetKeycodeState(code);
+        }
+    }
+    
+    public int getKeycodeState(int deviceId, int code) {
+        synchronized (mFirst) {
+            VirtualKey vk = mPressedVirtualKey;
+            if (vk != null) {
+                if (vk.lastKeycode == code) {
+                    return 2;
+                }
+            }
+            return nativeGetKeycodeState(deviceId, code);
+        }
+    }
+    
     public static native String getDeviceName(int deviceId);
     public static native int getDeviceClasses(int deviceId);
     public static native void addExcludedDevice(String deviceName);
@@ -344,10 +392,10 @@
             InputDevice.AbsoluteInfo outInfo);
     public static native int getSwitchState(int sw);
     public static native int getSwitchState(int deviceId, int sw);
-    public static native int getScancodeState(int sw);
-    public static native int getScancodeState(int deviceId, int sw);
-    public static native int getKeycodeState(int sw);
-    public static native int getKeycodeState(int deviceId, int sw);
+    public static native int nativeGetScancodeState(int code);
+    public static native int nativeGetScancodeState(int deviceId, int code);
+    public static native int nativeGetKeycodeState(int code);
+    public static native int nativeGetKeycodeState(int deviceId, int code);
     public static native int scancodeToKeycode(int deviceId, int scancode);
     public static native boolean hasKeys(int[] keycodes, boolean[] keyExists);
     
diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java
index b3b50e5..65b3e3f 100644
--- a/services/java/com/android/server/SystemServer.java
+++ b/services/java/com/android/server/SystemServer.java
@@ -365,8 +365,17 @@
         mContentResolver.registerContentObserver(Settings.Secure.getUriFor(Settings.Secure.ADB_ENABLED),
                 false, new AdbSettingsObserver());
 
-        // It is now time to start up the app processes...
+        // Before things start rolling, be sure we have decided whether
+        // we are in safe mode.
         final boolean safeMode = wm.detectSafeMode();
+        if (safeMode) {
+            try {
+                ActivityManagerNative.getDefault().enterSafeMode();
+            } catch (RemoteException e) {
+            }
+        }
+        
+        // It is now time to start up the app processes...
 
         if (notification != null) {
             notification.systemReady();
diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java
index 228d25e..01a4122 100644
--- a/services/java/com/android/server/WindowManagerService.java
+++ b/services/java/com/android/server/WindowManagerService.java
@@ -3965,7 +3965,7 @@
     // -------------------------------------------------------------
 
     public void disableKeyguard(IBinder token, String tag) {
-        if (mContext.checkCallingPermission(android.Manifest.permission.DISABLE_KEYGUARD)
+        if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DISABLE_KEYGUARD)
             != PackageManager.PERMISSION_GRANTED) {
             throw new SecurityException("Requires DISABLE_KEYGUARD permission");
         }
@@ -3973,7 +3973,7 @@
     }
 
     public void reenableKeyguard(IBinder token) {
-        if (mContext.checkCallingPermission(android.Manifest.permission.DISABLE_KEYGUARD)
+        if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DISABLE_KEYGUARD)
             != PackageManager.PERMISSION_GRANTED) {
             throw new SecurityException("Requires DISABLE_KEYGUARD permission");
         }
@@ -3999,7 +3999,7 @@
      * @see android.app.KeyguardManager#exitKeyguardSecurely
      */
     public void exitKeyguardSecurely(final IOnKeyguardExitResult callback) {
-        if (mContext.checkCallingPermission(android.Manifest.permission.DISABLE_KEYGUARD)
+        if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DISABLE_KEYGUARD)
             != PackageManager.PERMISSION_GRANTED) {
             throw new SecurityException("Requires DISABLE_KEYGUARD permission");
         }
@@ -4108,7 +4108,7 @@
                 "getScancodeState()")) {
             throw new SecurityException("Requires READ_INPUT_STATE permission");
         }
-        return KeyInputQueue.getScancodeState(sw);
+        return mQueue.getScancodeState(sw);
     }
 
     public int getScancodeStateForDevice(int devid, int sw) {
@@ -4116,7 +4116,7 @@
                 "getScancodeStateForDevice()")) {
             throw new SecurityException("Requires READ_INPUT_STATE permission");
         }
-        return KeyInputQueue.getScancodeState(devid, sw);
+        return mQueue.getScancodeState(devid, sw);
     }
 
     public int getKeycodeState(int sw) {
@@ -4124,7 +4124,7 @@
                 "getKeycodeState()")) {
             throw new SecurityException("Requires READ_INPUT_STATE permission");
         }
-        return KeyInputQueue.getKeycodeState(sw);
+        return mQueue.getKeycodeState(sw);
     }
 
     public int getKeycodeStateForDevice(int devid, int sw) {
@@ -4132,7 +4132,7 @@
                 "getKeycodeStateForDevice()")) {
             throw new SecurityException("Requires READ_INPUT_STATE permission");
         }
-        return KeyInputQueue.getKeycodeState(devid, sw);
+        return mQueue.getKeycodeState(devid, sw);
     }
 
     public boolean hasKeys(int[] keycodes, boolean[] keyExists) {
diff --git a/services/jni/com_android_server_KeyInputQueue.cpp b/services/jni/com_android_server_KeyInputQueue.cpp
index f27596c..c92f8df 100644
--- a/services/jni/com_android_server_KeyInputQueue.cpp
+++ b/services/jni/com_android_server_KeyInputQueue.cpp
@@ -280,13 +280,13 @@
         (void*) android_server_KeyInputQueue_getSwitchState },
     { "getSwitchState", "(II)I",
         (void*) android_server_KeyInputQueue_getSwitchStateDevice },
-    { "getScancodeState", "(I)I",
+    { "nativeGetScancodeState", "(I)I",
         (void*) android_server_KeyInputQueue_getScancodeState },
-    { "getScancodeState", "(II)I",
+    { "nativeGetScancodeState", "(II)I",
         (void*) android_server_KeyInputQueue_getScancodeStateDevice },
-    { "getKeycodeState", "(I)I",
+    { "nativeGetKeycodeState", "(I)I",
         (void*) android_server_KeyInputQueue_getKeycodeState },
-    { "getKeycodeState", "(II)I",
+    { "nativeGetKeycodeState", "(II)I",
         (void*) android_server_KeyInputQueue_getKeycodeStateDevice },
     { "hasKeys", "([I[Z)Z",
         (void*) android_server_KeyInputQueue_hasKeys },