Merge "Import revised translations.  DO NOT MERGE" into gingerbread
diff --git a/api/current.xml b/api/current.xml
index a78aa3a6..f0b0233 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -101577,17 +101577,6 @@
  visibility="public"
 >
 </field>
-<field name="TYPE_OTHER"
- type="int"
- transient="false"
- volatile="false"
- value="-1"
- static="true"
- final="true"
- deprecated="not deprecated"
- visibility="public"
->
-</field>
 <field name="TYPE_PLUS"
  type="int"
  transient="false"
@@ -101610,6 +101599,17 @@
  visibility="public"
 >
 </field>
+<field name="TYPE_UNKNOWN"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="-1"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 </class>
 <class name="MifareUltralight"
  extends="android.nfc.tech.BasicTagTechnology"
@@ -101643,7 +101643,7 @@
  visibility="public"
 >
 </method>
-<method name="readBlock"
+<method name="readPages"
  return="byte[]"
  abstract="false"
  native="false"
@@ -101653,7 +101653,7 @@
  deprecated="not deprecated"
  visibility="public"
 >
-<parameter name="page" type="int">
+<parameter name="pageOffset" type="int">
 </parameter>
 <exception name="IOException" type="java.io.IOException">
 </exception>
@@ -101683,13 +101683,24 @@
  deprecated="not deprecated"
  visibility="public"
 >
-<parameter name="page" type="int">
+<parameter name="pageOffset" type="int">
 </parameter>
 <parameter name="data" type="byte[]">
 </parameter>
 <exception name="IOException" type="java.io.IOException">
 </exception>
 </method>
+<field name="PAGE_SIZE"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="4"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="TYPE_ULTRALIGHT"
  type="int"
  transient="false"
@@ -101716,7 +101727,7 @@
  type="int"
  transient="false"
  volatile="false"
- value="10"
+ value="-1"
  static="true"
  final="true"
  deprecated="not deprecated"
diff --git a/core/java/android/net/MobileDataStateTracker.java b/core/java/android/net/MobileDataStateTracker.java
index ffbd69d..b5596013 100644
--- a/core/java/android/net/MobileDataStateTracker.java
+++ b/core/java/android/net/MobileDataStateTracker.java
@@ -149,6 +149,11 @@
         ConnectivityManager mConnectivityManager;
         public void onReceive(Context context, Intent intent) {
             synchronized(this) {
+                // update state and roaming before we set the state - only state changes are
+                // noticed
+                TelephonyManager tm = TelephonyManager.getDefault();
+                setRoamingStatus(tm.isNetworkRoaming());
+                setSubtype(tm.getNetworkType(), tm.getNetworkTypeName());
                 if (intent.getAction().equals(TelephonyIntents.
                         ACTION_ANY_DATA_CONNECTION_STATE_CHANGED)) {
                     Phone.DataState state = getMobileDataState(intent);
@@ -254,9 +259,6 @@
                             reason == null ? "" : "(" + reason + ")");
                     setDetailedState(DetailedState.FAILED, reason, apnName);
                 }
-                TelephonyManager tm = TelephonyManager.getDefault();
-                setRoamingStatus(tm.isNetworkRoaming());
-                setSubtype(tm.getNetworkType(), tm.getNetworkTypeName());
             }
         }
     }
diff --git a/core/java/android/net/NetworkStateTracker.java b/core/java/android/net/NetworkStateTracker.java
index d340a99..039dfff 100644
--- a/core/java/android/net/NetworkStateTracker.java
+++ b/core/java/android/net/NetworkStateTracker.java
@@ -302,7 +302,7 @@
     public boolean isTeardownRequested() {
         return mTeardownRequested;
     }
-    
+
     /**
      * Send a  notification that the results of a scan for network access
      * points has completed, and results are available.
@@ -327,10 +327,10 @@
     }
 
     protected void setSubtype(int subtype, String subtypeName) {
-        if (mNetworkInfo.isConnected()) {
-            int oldSubtype = mNetworkInfo.getSubtype();
-            if (subtype != oldSubtype) {
-                mNetworkInfo.setSubtype(subtype, subtypeName);
+        int oldSubtype = mNetworkInfo.getSubtype();
+        if (subtype != oldSubtype) {
+            mNetworkInfo.setSubtype(subtype, subtypeName);
+            if (mNetworkInfo.isConnected()) {
                 Message msg = mTarget.obtainMessage(
                         EVENT_NETWORK_SUBTYPE_CHANGED, oldSubtype, 0, mNetworkInfo);
                 msg.sendToTarget();
diff --git a/core/java/android/nfc/tech/MifareClassic.java b/core/java/android/nfc/tech/MifareClassic.java
index 34fd7cf..d337ead 100644
--- a/core/java/android/nfc/tech/MifareClassic.java
+++ b/core/java/android/nfc/tech/MifareClassic.java
@@ -55,14 +55,14 @@
     public static final byte[] KEY_NFC_FORUM =
             {(byte)0xD3,(byte)0xF7,(byte)0xD3,(byte)0xF7,(byte)0xD3,(byte)0xF7};
 
+    /** A Mifare Classic compatible card of unknown type */
+    public static final int TYPE_UNKNOWN = -1;
     /** A MIFARE Classic tag */
     public static final int TYPE_CLASSIC = 0;
     /** A MIFARE Plus tag */
     public static final int TYPE_PLUS = 1;
     /** A MIFARE Pro tag */
     public static final int TYPE_PRO = 2;
-    /** A Mifare Classic compatible card that does not match the other types */
-    public static final int TYPE_OTHER = -1;
 
     /** The tag contains 16 sectors, each holding 4 blocks. */
     public static final int SIZE_1K = 1024;
@@ -360,12 +360,6 @@
         transceive(cmd.array(), false);
     }
 
-    private void validateValueOperand(int value) {
-        if (value < 0) {
-            throw new IllegalArgumentException("value operand negative");
-        }
-    }
-
     /**
      * Copy from temporary memory to value block.
      * @param blockIndex
@@ -410,7 +404,7 @@
         return transceive(data, true);
     }
 
-    private void validateSector(int sector) {
+    private static void validateSector(int sector) {
         // Do not be too strict on upper bounds checking, since some cards
         // have more addressable memory than they report. For example,
         // Mifare Plus 2k cards will appear as Mifare Classic 1k cards when in
@@ -423,10 +417,16 @@
         }
     }
 
-    private void validateBlock(int block) {
+    private static void validateBlock(int block) {
         // Just looking for obvious out of bounds...
         if (block < 0 || block >= MAX_BLOCK_COUNT) {
             throw new IndexOutOfBoundsException("block out of bounds: " + block);
         }
     }
+
+    private static void validateValueOperand(int value) {
+        if (value < 0) {
+            throw new IllegalArgumentException("value operand negative");
+        }
+    }
 }
diff --git a/core/java/android/nfc/tech/MifareUltralight.java b/core/java/android/nfc/tech/MifareUltralight.java
index f096298..b514f1c 100644
--- a/core/java/android/nfc/tech/MifareUltralight.java
+++ b/core/java/android/nfc/tech/MifareUltralight.java
@@ -21,24 +21,43 @@
 
 import java.io.IOException;
 
+//TOOD: Ultralight C 3-DES authentication, one-way counter
+
 /**
  * Technology class representing MIFARE Ultralight and MIFARE Ultralight C tags.
  *
  * <p>Support for this technology type is optional. If the NFC stack doesn't support this technology
  * MIFARE Ultralight class tags will still be scanned, but will only show the NfcA technology.
  *
- * <p>MIFARE Ultralight class tags have a series of 4 bytes pages that can be individually written
- * and read in chunks of 4 for a total read of 16 bytes.
+ * <p>MIFARE Ultralight compatible tags have 4 byte pages. The read command
+ * returns 4 pages (16 bytes) at a time, for speed. The write command operates
+ * on a single page (4 bytes) to minimize EEPROM write cycles.
+ *
+ * <p>The original MIFARE Ultralight consists of a 64 byte EEPROM. The first
+ * 4 pages are for the OTP area, manufacturer data, and locking bits. They are
+ * readable and some bits are writable. The final 12 pages are the user
+ * read/write area. For more information see the NXP data sheet MF0ICU1.
+ *
+ * <p>The MIFARE Ultralight C consists of a 192 byte EEPROM. The first 4 pages
+ * are for OTP, manufacturer data, and locking bits. The next 36 pages are the
+ * user read/write area. The next 4 pages are additional locking bits, counters
+ * and authentication configuration and are readable. The final 4 pages are for
+ * the authentication key and are not readable. For more information see the
+ * NXP data sheet MF0ICU2.
  */
 public final class MifareUltralight extends BasicTagTechnology {
+    /** A MIFARE Ultralight compatible tag of unknown type */
+    public static final int TYPE_UNKNOWN = -1;
     /** A MIFARE Ultralight tag */
     public static final int TYPE_ULTRALIGHT = 1;
     /** A MIFARE Ultralight C tag */
     public static final int TYPE_ULTRALIGHT_C = 2;
-    /** The tag type is unknown */
-    public static final int TYPE_UNKNOWN = 10;
+
+    /** Size of a MIFARE Ultralight page in bytes */
+    public static final int PAGE_SIZE = 4;
 
     private static final int NXP_MANUFACTURER_ID = 0x04;
+    private static final int MAX_PAGE_COUNT = 256;
 
     private int mType;
 
@@ -68,48 +87,62 @@
 
         if (a.getSak() == 0x00 && tag.getId()[0] == NXP_MANUFACTURER_ID) {
             // could be UL or UL-C
+            //TODO: stack should use NXP AN1303 procedure to make a best guess
+            // attempt at classifying Ultralight vs Ultralight C.
             mType = TYPE_ULTRALIGHT;
         }
     }
 
-    /** Returns the type of the tag */
+    /** Returns the type of the tag.
+     * <p>It is very hard to always accurately classify a MIFARE Ultralight
+     * compatible tag as Ultralight original or Ultralight C. So consider
+     * {@link #getType} a hint. */
     public int getType() {
         return mType;
     }
 
     // Methods that require connect()
     /**
-     * Reads a single 16 byte block from the given page offset.
+     * Read 4 pages (16 bytes).
+     * <p>The MIFARE Ultralight protocol always reads 4 pages at a time.
+     * <p>If the read spans past the last readable block, then the tag will
+     * return pages that have been wrapped back to the first blocks. MIFARE
+     * Ultralight tags have readable blocks 0x00 through 0x0F. So a read to
+     * block offset 0x0E would return blocks 0x0E, 0x0F, 0x00, 0x01. MIFARE
+     * Ultralight C tags have readable blocks 0x00 through 0x2B. So a read to
+     * block 0x2A would return blocks 0x2A, 0x2B, 0x00, 0x01.
+     * <p>This requires that the tag be connected.
      *
-     * <p>This requires a that the tag be connected.
-     *
+     * @return 4 pages (16 bytes)
      * @throws IOException
      */
-    public byte[] readBlock(int page) throws IOException {
+    public byte[] readPages(int pageOffset) throws IOException {
+        validatePageOffset(pageOffset);
         checkConnected();
 
-        byte[] blockread_cmd = { 0x30, (byte) page}; // phHal_eMifareRead
-        return transceive(blockread_cmd, false);
+        byte[] cmd = { 0x30, (byte) pageOffset};
+        return transceive(cmd, false);
     }
 
     /**
-     * Writes a 4 byte page to the tag.
+     * Write 1 page (4 bytes).
+     * <p>The MIFARE Ultralight protocol always writes 1 page at a time.
+     * <p>This requires that the tag be connected.
      *
-     * <p>This requires a that the tag be connected.
-     *
-     * @param page The offset of the page to write
+     * @param pageOffset The offset of the page to write
      * @param data The data to write
      * @throws IOException
      */
-    public void writePage(int page, byte[] data) throws IOException {
+    public void writePage(int pageOffset, byte[] data) throws IOException {
+        validatePageOffset(pageOffset);
         checkConnected();
 
-        byte[] pagewrite_cmd = new byte[data.length + 2];
-        pagewrite_cmd[0] = (byte) 0xA2;
-        pagewrite_cmd[1] = (byte) page;
-        System.arraycopy(data, 0, pagewrite_cmd, 2, data.length);
+        byte[] cmd = new byte[data.length + 2];
+        cmd[0] = (byte) 0xA2;
+        cmd[1] = (byte) pageOffset;
+        System.arraycopy(data, 0, cmd, 2, data.length);
 
-        transceive(pagewrite_cmd, false);
+        transceive(cmd, false);
     }
 
     /**
@@ -127,4 +160,15 @@
     public byte[] transceive(byte[] data) throws IOException {
         return transceive(data, true);
     }
+
+    private static void validatePageOffset(int pageOffset) {
+        // Do not be too strict on upper bounds checking, since some cards
+        // may have more addressable memory than they report.
+        // Note that issuing a command to an out-of-bounds block is safe - the
+        // tag will wrap the read to an addressable area. This validation is a
+        // helper to guard against obvious programming mistakes.
+        if (pageOffset < 0 || pageOffset >= MAX_PAGE_COUNT) {
+            throw new IndexOutOfBoundsException("page out of bounds: " + pageOffset);
+        }
+    }
 }
diff --git a/docs/html/sdk/eclipse-adt.jd b/docs/html/sdk/eclipse-adt.jd
index 62e27d3..78d2ccd 100644
--- a/docs/html/sdk/eclipse-adt.jd
+++ b/docs/html/sdk/eclipse-adt.jd
@@ -1,6 +1,6 @@
 page.title=ADT Plugin for Eclipse
 adt.zip.version=9.0.0
-adt.zip.download=ADT-9.0.0.zip
+adt.zip.download=ADT_9.0.0.zip
 adt.zip.bytes=4433536
 adt.zip.checksum=bc2757f2a5a11d131390ce547bae154b
 
diff --git a/docs/html/sdk/tools-notes.jd b/docs/html/sdk/tools-notes.jd
index 7d39e67..d188bc5 100644
--- a/docs/html/sdk/tools-notes.jd
+++ b/docs/html/sdk/tools-notes.jd
@@ -103,8 +103,10 @@
     <li>The LogCat view in DDMS now properly displays UTF-8 characters.</li>
     <li>The SDK Manager is more reliable on Windows. For details on the improvements, see the
     <a href="http://tools.android.com/recent/sdkmanagerfixes">Android Tools Project Site</a>. </li>
-    <li>If you enabled snapshots for an AVD, they are automatically captured. The emulator also now restores to the state when
-     it last closed almost instantly.</li>
+    <li>Early look at the new snapshot feature: To improve startup time for the emulator, you can
+enable snapshots for the system state. The emulator will then restore to the state when it last
+closed almost instantly. <strong>Note:</strong> The snapshot feature is still under active
+development and might not always perform as expected.</li>
     <li>Fixed the missing JAR file error that prevented <code>draw9patch</code> from running.</li>
     <li>Fixed the Windows launch scripts <code>hierarchyviewer</code> and <code>ddms</code> to support
     the new location of <code>adb</code>.</li>