Merge "Fewer warnings in aidl generated code."
diff --git a/CleanSpec.mk b/CleanSpec.mk
index 0d8a7cd..61e5b4c 100644
--- a/CleanSpec.mk
+++ b/CleanSpec.mk
@@ -133,6 +133,7 @@
 $(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src/core/java/android/accessibilityservice/IAccessibilityServiceClientCallback.P)
 $(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src/core/java/android/accessibilityservice/IAccessibilityServiceClient.P)
 $(call add-clean-step, rm -f $(PRODUCT_OUT)/system/media/video/Disco*)
+$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/framework_intermediates)
 # ************************************************
 # NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
 # ************************************************
diff --git a/core/java/android/net/MobileDataStateTracker.java b/core/java/android/net/MobileDataStateTracker.java
index 5612943..82cb74b 100644
--- a/core/java/android/net/MobileDataStateTracker.java
+++ b/core/java/android/net/MobileDataStateTracker.java
@@ -329,6 +329,9 @@
         case TelephonyManager.NETWORK_TYPE_HSPA:
             networkTypeStr = "hspa";
             break;
+        case TelephonyManager.NETWORK_TYPE_HSPAP:
+            networkTypeStr = "hspap";
+            break;
         case TelephonyManager.NETWORK_TYPE_CDMA:
             networkTypeStr = "cdma";
             break;
diff --git a/keystore/java/android/security/KeyStore.java b/keystore/java/android/security/KeyStore.java
index a32e469..f49c429 100644
--- a/keystore/java/android/security/KeyStore.java
+++ b/keystore/java/android/security/KeyStore.java
@@ -22,8 +22,9 @@
 import java.io.InputStream;
 import java.io.IOException;
 import java.io.OutputStream;
-import java.io.UnsupportedEncodingException;
+import java.io.UTFDataFormatException;
 import java.nio.charset.Charsets;
+import java.nio.charset.ModifiedUtf8;
 import java.util.ArrayList;
 
 /**
@@ -75,7 +76,7 @@
     }
 
     public byte[] get(String key) {
-        return get(getBytes(key));
+        return get(getKeyBytes(key));
     }
 
     private boolean put(byte[] key, byte[] value) {
@@ -84,7 +85,7 @@
     }
 
     public boolean put(String key, byte[] value) {
-        return put(getBytes(key), value);
+        return put(getKeyBytes(key), value);
     }
 
     private boolean delete(byte[] key) {
@@ -93,7 +94,7 @@
     }
 
     public boolean delete(String key) {
-        return delete(getBytes(key));
+        return delete(getKeyBytes(key));
     }
 
     private boolean contains(byte[] key) {
@@ -102,7 +103,7 @@
     }
 
     public boolean contains(String key) {
-        return contains(getBytes(key));
+        return contains(getKeyBytes(key));
     }
 
     public byte[][] saw(byte[] prefix) {
@@ -111,13 +112,13 @@
     }
 
     public String[] saw(String prefix) {
-        byte[][] values = saw(getBytes(prefix));
+        byte[][] values = saw(getKeyBytes(prefix));
         if (values == null) {
             return null;
         }
         String[] strings = new String[values.length];
         for (int i = 0; i < values.length; ++i) {
-            strings[i] = toString(values[i]);
+            strings[i] = toKeyString(values[i]);
         }
         return strings;
     }
@@ -133,7 +134,7 @@
     }
 
     public boolean password(String password) {
-        return password(getBytes(password));
+        return password(getPasswordBytes(password));
     }
 
     public boolean lock() {
@@ -147,7 +148,7 @@
     }
 
     public boolean unlock(String password) {
-        return unlock(getBytes(password));
+        return unlock(getPasswordBytes(password));
     }
 
     public boolean isEmpty() {
@@ -161,7 +162,7 @@
     }
 
     public boolean generate(String key) {
-        return generate(getBytes(key));
+        return generate(getKeyBytes(key));
     }
 
     private boolean importKey(byte[] keyName, byte[] key) {
@@ -170,7 +171,7 @@
     }
 
     public boolean importKey(String keyName, byte[] key) {
-        return importKey(getBytes(keyName), key);
+        return importKey(getKeyBytes(keyName), key);
     }
 
     private byte[] getPubkey(byte[] key) {
@@ -179,7 +180,7 @@
     }
 
     public byte[] getPubkey(String key) {
-        return getPubkey(getBytes(key));
+        return getPubkey(getKeyBytes(key));
     }
 
     private boolean delKey(byte[] key) {
@@ -188,7 +189,7 @@
     }
 
     public boolean delKey(String key) {
-        return delKey(getBytes(key));
+        return delKey(getKeyBytes(key));
     }
 
     private byte[] sign(byte[] keyName, byte[] data) {
@@ -197,7 +198,7 @@
     }
 
     public byte[] sign(String key, byte[] data) {
-        return sign(getBytes(key), data);
+        return sign(getKeyBytes(key), data);
     }
 
     private boolean verify(byte[] keyName, byte[] data, byte[] signature) {
@@ -206,7 +207,7 @@
     }
 
     public boolean verify(String key, byte[] data, byte[] signature) {
-        return verify(getBytes(key), data, signature);
+        return verify(getKeyBytes(key), data, signature);
     }
 
     private boolean grant(byte[] key, byte[] uid) {
@@ -215,7 +216,7 @@
     }
 
     public boolean grant(String key, int uid) {
-        return grant(getBytes(key), Integer.toString(uid).getBytes());
+         return grant(getKeyBytes(key), getUidBytes(uid));
     }
 
     private boolean ungrant(byte[] key, byte[] uid) {
@@ -224,7 +225,7 @@
     }
 
     public boolean ungrant(String key, int uid) {
-        return ungrant(getBytes(key), Integer.toString(uid).getBytes());
+        return ungrant(getKeyBytes(key), getUidBytes(uid));
     }
 
     public int getLastError() {
@@ -291,11 +292,34 @@
         return null;
     }
 
-    private static byte[] getBytes(String string) {
-        return string.getBytes(Charsets.UTF_8);
+    /**
+     * ModifiedUtf8 is used for key encoding to match the
+     * implementation of NativeCrypto.ENGINE_load_private_key.
+     */
+    private static byte[] getKeyBytes(String string) {
+        try {
+            int utfCount = (int) ModifiedUtf8.countBytes(string, false);
+            byte[] result = new byte[utfCount];
+            ModifiedUtf8.encode(result, 0, string);
+            return result;
+        } catch (UTFDataFormatException e) {
+            throw new RuntimeException(e);
+        }
     }
 
-    private static String toString(byte[] bytes) {
-        return new String(bytes, Charsets.UTF_8);
+    private static String toKeyString(byte[] bytes) {
+        try {
+            return ModifiedUtf8.decode(bytes, new char[bytes.length], 0, bytes.length);
+        } catch (UTFDataFormatException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    private static byte[] getPasswordBytes(String password) {
+        return password.getBytes(Charsets.UTF_8);
+    }
+
+    private static byte[] getUidBytes(int uid) {
+        return Integer.toString(uid).getBytes(Charsets.UTF_8);
     }
 }
diff --git a/keystore/tests/src/android/security/KeyStoreTest.java b/keystore/tests/src/android/security/KeyStoreTest.java
index 008d682..32cd6e2 100755
--- a/keystore/tests/src/android/security/KeyStoreTest.java
+++ b/keystore/tests/src/android/security/KeyStoreTest.java
@@ -35,9 +35,9 @@
 public class KeyStoreTest extends ActivityUnitTestCase<Activity> {
     private static final String TEST_PASSWD = "12345678";
     private static final String TEST_PASSWD2 = "87654321";
-    private static final String TEST_KEYNAME = "testkey";
-    private static final String TEST_KEYNAME1 = "testkey1";
-    private static final String TEST_KEYNAME2 = "testkey2";
+    private static final String TEST_KEYNAME = "test-key";
+    private static final String TEST_KEYNAME1 = "test-key.1";
+    private static final String TEST_KEYNAME2 = "test-key\02";
     private static final byte[] TEST_KEYVALUE = "test value".getBytes(Charsets.UTF_8);
 
     // "Hello, World" in Chinese
@@ -45,10 +45,12 @@
     private static final byte[] TEST_I18N_VALUE = TEST_I18N_KEY.getBytes(Charsets.UTF_8);
 
     // Test vector data for signatures
-    private static final byte[] TEST_DATA = {
-            (byte) 0x00, (byte) 0xA0, (byte) 0xFF, (byte) 0x0A, (byte) 0x00, (byte) 0xFF,
-            (byte) 0xAA, (byte) 0x55, (byte) 0x05, (byte) 0x5A,
-    };
+    private static final byte[] TEST_DATA =  new byte[256];
+    static {
+        for (int i = 0; i < TEST_DATA.length; i++) {
+            TEST_DATA[i] = (byte) i;
+        }
+    }
 
     private KeyStore mKeyStore = null;
 
@@ -155,9 +157,9 @@
     }
 
     public void testDelete() throws Exception {
-        assertTrue(mKeyStore.delete(TEST_KEYNAME));
+        assertFalse(mKeyStore.delete(TEST_KEYNAME));
         mKeyStore.password(TEST_PASSWD);
-        assertTrue(mKeyStore.delete(TEST_KEYNAME));
+        assertFalse(mKeyStore.delete(TEST_KEYNAME));
 
         mKeyStore.put(TEST_KEYNAME, TEST_KEYVALUE);
         assertTrue(Arrays.equals(TEST_KEYVALUE, mKeyStore.get(TEST_KEYNAME)));
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java
index 4d22f33..751764c 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java
@@ -568,18 +568,26 @@
                     }
                     break;
                 case TelephonyManager.NETWORK_TYPE_CDMA:
-                    // display 1xRTT for IS95A/B
-                    mDataIconList = TelephonyIcons.DATA_1X[mInetCondition];
-                    mDataTypeIconId = R.drawable.stat_sys_data_connected_1x;
-                    mContentDescriptionDataType = mContext.getString(
-                            R.string.accessibility_data_connection_cdma);
-                    break;
+                    if (!mShowAtLeastThreeGees) {
+                        // display 1xRTT for IS95A/B
+                        mDataIconList = TelephonyIcons.DATA_1X[mInetCondition];
+                        mDataTypeIconId = R.drawable.stat_sys_data_connected_1x;
+                        mContentDescriptionDataType = mContext.getString(
+                                R.string.accessibility_data_connection_cdma);
+                        break;
+                    } else {
+                        // fall through
+                    }
                 case TelephonyManager.NETWORK_TYPE_1xRTT:
-                    mDataIconList = TelephonyIcons.DATA_1X[mInetCondition];
-                    mDataTypeIconId = R.drawable.stat_sys_data_connected_1x;
-                    mContentDescriptionDataType = mContext.getString(
-                            R.string.accessibility_data_connection_cdma);
-                    break;
+                    if (!mShowAtLeastThreeGees) {
+                        mDataIconList = TelephonyIcons.DATA_1X[mInetCondition];
+                        mDataTypeIconId = R.drawable.stat_sys_data_connected_1x;
+                        mContentDescriptionDataType = mContext.getString(
+                                R.string.accessibility_data_connection_cdma);
+                        break;
+                    } else {
+                        // fall through
+                    }
                 case TelephonyManager.NETWORK_TYPE_EVDO_0: //fall through
                 case TelephonyManager.NETWORK_TYPE_EVDO_A:
                 case TelephonyManager.NETWORK_TYPE_EVDO_B:
diff --git a/policy/src/com/android/internal/policy/impl/Policy.java b/policy/src/com/android/internal/policy/impl/Policy.java
index a490729..153ef0f 100644
--- a/policy/src/com/android/internal/policy/impl/Policy.java
+++ b/policy/src/com/android/internal/policy/impl/Policy.java
@@ -41,7 +41,7 @@
         "com.android.internal.policy.impl.PhoneLayoutInflater",
         "com.android.internal.policy.impl.PhoneWindow",
         "com.android.internal.policy.impl.PhoneWindow$1",
-        "com.android.internal.policy.impl.PhoneWindow$ContextMenuCallback",
+        "com.android.internal.policy.impl.PhoneWindow$DialogMenuCallback",
         "com.android.internal.policy.impl.PhoneWindow$DecorView",
         "com.android.internal.policy.impl.PhoneWindow$PanelFeatureState",
         "com.android.internal.policy.impl.PhoneWindow$PanelFeatureState$SavedState",
diff --git a/telephony/java/com/android/internal/telephony/AdnRecord.aidl b/telephony/java/com/android/internal/telephony/AdnRecord.aidl
deleted file mode 100644
index b4a1a29..0000000
--- a/telephony/java/com/android/internal/telephony/AdnRecord.aidl
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
-** Copyright 2007, 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.telephony;
-
-parcelable AdnRecord;
-