Merge "Fix for 2175289 : Can't get keyboard in search dialog after switching to landscape"
diff --git a/api/current.xml b/api/current.xml
index d792a41..70a4c57 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -74310,7 +74310,7 @@
  type="float"
  transient="false"
  volatile="false"
- value="0.0010f"
+ value="0.001f"
  static="true"
  final="true"
  deprecated="not deprecated"
@@ -83010,6 +83010,17 @@
  visibility="public"
 >
 </field>
+<field name="TAG_GPS_PROCESSING_METHOD"
+ type="java.lang.String"
+ transient="false"
+ volatile="false"
+ value="&quot;GPSProcessingMethod&quot;"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
 <field name="TAG_GPS_TIMESTAMP"
  type="java.lang.String"
  transient="false"
@@ -214703,7 +214714,7 @@
  deprecated="not deprecated"
  visibility="public"
 >
-<parameter name="arg0" type="T">
+<parameter name="t" type="T">
 </parameter>
 </method>
 </interface>
diff --git a/awt/org/apache/harmony/awt/gl/font/AndroidGlyphVector.java b/awt/org/apache/harmony/awt/gl/font/AndroidGlyphVector.java
index 4ce5aed..f3b2e28 100644
--- a/awt/org/apache/harmony/awt/gl/font/AndroidGlyphVector.java
+++ b/awt/org/apache/harmony/awt/gl/font/AndroidGlyphVector.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 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 org.apache.harmony.awt.gl.font;
 
 import com.android.internal.awt.AndroidGraphics2D;
diff --git a/awt/org/apache/harmony/awt/gl/image/PngDecoderJava.java b/awt/org/apache/harmony/awt/gl/image/PngDecoderJava.java
index 46545f9..bfb2b51 100644
--- a/awt/org/apache/harmony/awt/gl/image/PngDecoderJava.java
+++ b/awt/org/apache/harmony/awt/gl/image/PngDecoderJava.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 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 org.apache.harmony.awt.gl.image;
 
 // A simple PNG decoder source code in Java.
@@ -279,4 +295,4 @@
   public short getUnsignedByte(int offset) {
     return (short) (mData[offset] & 0x00ff);
   }
-}
\ No newline at end of file
+}
diff --git a/cmds/rawbu/Android.mk b/cmds/rawbu/Android.mk
new file mode 100644
index 0000000..c1be8a4
--- /dev/null
+++ b/cmds/rawbu/Android.mk
@@ -0,0 +1,19 @@
+# Copyright 2009 The Android Open Source Project
+
+ifneq ($(TARGET_SIMULATOR),true)
+
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES:= backup.cpp
+
+LOCAL_SHARED_LIBRARIES := libcutils libc
+
+LOCAL_MODULE:= rawbu
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
+LOCAL_MODULE_TAGS := debug
+
+include $(BUILD_EXECUTABLE)
+
+endif
diff --git a/cmds/rawbu/NOTICE b/cmds/rawbu/NOTICE
new file mode 100644
index 0000000..c5b1efa
--- /dev/null
+++ b/cmds/rawbu/NOTICE
@@ -0,0 +1,190 @@
+
+   Copyright (c) 2005-2008, 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.
+
+   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.
+
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
diff --git a/cmds/rawbu/backup.cpp b/cmds/rawbu/backup.cpp
new file mode 100644
index 0000000..394ce41
--- /dev/null
+++ b/cmds/rawbu/backup.cpp
@@ -0,0 +1,729 @@
+// Copyright 2009 The Android Open Source Project
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <time.h>
+#include <dirent.h>
+#include <errno.h>
+#include <assert.h>
+#include <ctype.h>
+#include <utime.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+
+#include <cutils/properties.h>
+
+#include <private/android_filesystem_config.h>
+
+#ifndef PATH_MAX
+#define PATH_MAX 4096
+#endif
+
+// First version.
+#define FILE_VERSION_1 0xffff0001
+
+// Introduces backup all option to header.
+#define FILE_VERSION_2 0xffff0002
+
+#define FILE_VERSION FILE_VERSION_2
+
+namespace android {
+
+static char nameBuffer[PATH_MAX];
+static struct stat statBuffer;
+
+static char copyBuffer[8192];
+
+static uint32_t inputFileVersion;
+
+static int opt_backupAll;
+
+#define SPECIAL_NO_TOUCH 0
+#define SPECIAL_NO_BACKUP 1
+
+struct special_dir {
+    const char* path;
+    int type;
+};
+
+/* Directory paths that we will not backup/restore */
+static const struct special_dir SKIP_PATHS[] = {
+    { "/data/misc", SPECIAL_NO_TOUCH },
+    { "/data/system/batterystats.bin", SPECIAL_NO_TOUCH },
+    { "/data/system/location", SPECIAL_NO_TOUCH },
+    { "/data/dalvik-cache", SPECIAL_NO_BACKUP },
+    { NULL, 0 },
+};
+
+/* This is just copied from the shell's built-in wipe command. */
+static int wipe (const char *path) 
+{
+    DIR *dir;
+    struct dirent *de;
+    int ret;
+    int i;
+
+    dir = opendir(path);
+
+    if (dir == NULL) {
+        fprintf (stderr, "Error opendir'ing %s: %s\n",
+                    path, strerror(errno));
+        return 0;
+    }
+
+    char *filenameOffset;
+
+    strcpy(nameBuffer, path);
+    strcat(nameBuffer, "/");
+
+    filenameOffset = nameBuffer + strlen(nameBuffer);
+
+    for (;;) {
+        de = readdir(dir);
+
+        if (de == NULL) {
+            break;
+        }
+
+        if (0 == strcmp(de->d_name, ".")
+                || 0 == strcmp(de->d_name, "..")
+                || 0 == strcmp(de->d_name, "lost+found")
+        ) {
+            continue;
+        }
+
+        strcpy(filenameOffset, de->d_name);
+        bool noBackup = false;
+        
+        /* See if this is a path we should skip. */
+        for (i = 0; SKIP_PATHS[i].path; i++) {
+            if (strcmp(SKIP_PATHS[i].path, nameBuffer) == 0) {
+                if (opt_backupAll || SKIP_PATHS[i].type == SPECIAL_NO_BACKUP) {
+                    // In this case we didn't back up the directory --
+                    // we do want to wipe its contents, but not the
+                    // directory itself, since the restore file won't
+                    // contain the directory.
+                    noBackup = true;
+                }
+                break;
+            }
+        }
+        
+        if (!noBackup && SKIP_PATHS[i].path != NULL) {
+            // This is a SPECIAL_NO_TOUCH directory.
+            continue;
+        }
+
+        ret = lstat (nameBuffer, &statBuffer);
+
+        if (ret != 0) {
+            fprintf(stderr, "warning -- stat() error on '%s': %s\n", 
+                    nameBuffer, strerror(errno));
+            continue;
+        }
+
+        if(S_ISDIR(statBuffer.st_mode)) {
+            int i;
+            char *newpath;
+
+            newpath = strdup(nameBuffer);
+            if (wipe(newpath) == 0) {
+                free(newpath);
+                closedir(dir);
+                return 0;
+            }
+            
+            if (!noBackup) {
+                ret = rmdir(newpath);
+                if (ret != 0) {
+                    fprintf(stderr, "warning -- rmdir() error on '%s': %s\n", 
+                        newpath, strerror(errno));
+                }
+            }
+
+            free(newpath);
+
+            strcpy(nameBuffer, path);
+            strcat(nameBuffer, "/");
+
+        } else {
+            ret = unlink(nameBuffer);
+
+            if (ret != 0) {
+                fprintf(stderr, "warning -- unlink() error on '%s': %s\n", 
+                    nameBuffer, strerror(errno));
+            }
+        }
+    }
+
+    closedir(dir);
+    
+    return 1;
+}
+
+static int write_int32(FILE* fh, int32_t val)
+{
+    int res = fwrite(&val, 1, sizeof(val), fh);
+    if (res != sizeof(val)) {
+        fprintf(stderr, "unable to write int32 (%d bytes): %s\n", res, strerror(errno));
+        return 0;
+    }
+    
+    return 1;
+}
+
+static int write_int64(FILE* fh, int64_t val)
+{
+    int res = fwrite(&val, 1, sizeof(val), fh); 
+    if (res != sizeof(val)) {
+        fprintf(stderr, "unable to write int64 (%d bytes): %s\n", res, strerror(errno));
+        return 0;
+    }
+    
+    return 1;
+}
+
+static int copy_file(FILE* dest, FILE* src, off_t size, const char* destName,
+        const char* srcName)
+{
+    errno = 0;
+    
+    off_t origSize = size;
+    
+    while (size > 0) {
+        int amt = size > (off_t)sizeof(copyBuffer) ? sizeof(copyBuffer) : (int)size;
+        int readLen = fread(copyBuffer, 1, amt, src);
+        if (readLen <= 0) {
+            if (srcName != NULL) {
+                fprintf(stderr, "unable to read source (%d of %ld bytes) file '%s': %s\n",
+                    amt, origSize, srcName, errno != 0 ? strerror(errno) : "unexpected EOF");
+            } else {
+                fprintf(stderr, "unable to read buffer (%d of %ld bytes): %s\n",
+                    amt, origSize, errno != 0 ? strerror(errno) : "unexpected EOF");
+            }
+            return 0;
+        }
+        int writeLen = fwrite(copyBuffer, 1, readLen, dest); 
+        if (writeLen != readLen) {
+            if (destName != NULL) {
+                fprintf(stderr, "unable to write file (%d of %d bytes) '%s': '%s'\n",
+                    writeLen, readLen, destName, strerror(errno));
+            } else {
+                fprintf(stderr, "unable to write buffer (%d of %d bytes): '%s'\n",
+                    writeLen, readLen, strerror(errno));
+            }
+            return 0;
+        }
+        size -= readLen;
+    }
+    return 1;
+}
+
+#define TYPE_END 0
+#define TYPE_DIR 1
+#define TYPE_FILE 2
+
+static int write_header(FILE* fh, int type, const char* path, const struct stat* st)
+{
+    int pathLen = strlen(path);
+    if (!write_int32(fh, type)) return 0;
+    if (!write_int32(fh, pathLen)) return 0;
+    if (fwrite(path, 1, pathLen, fh) != (size_t)pathLen) {
+        fprintf(stderr, "unable to write: %s\n", strerror(errno));
+        return 0;
+    }
+    
+    if (!write_int32(fh, st->st_uid)) return 0;
+    if (!write_int32(fh, st->st_gid)) return 0;
+    if (!write_int32(fh, st->st_mode)) return 0;
+    if (!write_int64(fh, ((int64_t)st->st_atime)*1000*1000*1000)) return 0;
+    if (!write_int64(fh, ((int64_t)st->st_mtime)*1000*1000*1000)) return 0;
+    if (!write_int64(fh, ((int64_t)st->st_ctime)*1000*1000*1000)) return 0;
+    
+    return 1;
+}
+
+static int backup_dir(FILE* fh, const char* srcPath)
+{
+    DIR *dir;
+    struct dirent *de;
+    char* fullPath = NULL;
+    int srcLen = strlen(srcPath);
+    int result = 1;
+    int i;
+    
+    dir = opendir(srcPath);
+
+    if (dir == NULL) {
+        fprintf (stderr, "error opendir'ing '%s': %s\n",
+                    srcPath, strerror(errno));
+        return 0;
+    }
+    
+    for (;;) {
+        de = readdir(dir);
+
+        if (de == NULL) {
+            break;
+        }
+
+        if (0 == strcmp(de->d_name, ".")
+                || 0 == strcmp(de->d_name, "..")
+                || 0 == strcmp(de->d_name, "lost+found")
+        ) {
+            continue;
+        }
+
+        if (fullPath == NULL) {
+            free(fullPath);
+        }
+        fullPath = (char*)malloc(srcLen + strlen(de->d_name) + 2);
+        strcpy(fullPath, srcPath);
+        fullPath[srcLen] = '/';
+        strcpy(fullPath+srcLen+1, de->d_name);
+
+        /* See if this is a path we should skip. */
+        if (!opt_backupAll) {
+            for (i = 0; SKIP_PATHS[i].path; i++) {
+                if (strcmp(SKIP_PATHS[i].path, fullPath) == 0) {
+                    break;
+                }
+            }
+            if (SKIP_PATHS[i].path != NULL) {
+                continue;
+            }
+        }
+
+        int ret = lstat(fullPath, &statBuffer);
+
+        if (ret != 0) {
+            fprintf(stderr, "stat() error on '%s': %s\n", 
+                    fullPath, strerror(errno));
+            result = 0;
+            goto done;
+        }
+
+        if(S_ISDIR(statBuffer.st_mode)) {
+            printf("Saving dir %s...\n", fullPath);
+            
+            if (write_header(fh, TYPE_DIR, fullPath, &statBuffer) == 0) {
+                result = 0;
+                goto done;
+            }
+            if (backup_dir(fh, fullPath) == 0) {
+                result = 0;
+                goto done;
+            }
+        } else {
+            printf("Saving file %s...\n", fullPath);
+            
+            if (write_header(fh, TYPE_FILE, fullPath, &statBuffer) == 0) {
+                result = 0;
+                goto done;
+            }
+            
+            off_t size = statBuffer.st_size;
+            if (!write_int64(fh, size)) {
+                result = 0;
+                goto done;
+            }
+            
+            FILE* src = fopen(fullPath, "r");
+            if (src == NULL) {
+                fprintf(stderr, "unable to open source file '%s': %s\n",
+                    fullPath, strerror(errno));
+                result = 0;
+                goto done;
+            }
+            
+            int copyres = copy_file(fh, src, size, NULL, fullPath);
+            fclose(src);
+            if (!copyres) {
+                result = 0;
+                goto done;
+            }
+        }
+    }
+
+done:
+    if (fullPath != NULL) {
+        free(fullPath);
+    }
+    
+    closedir(dir);
+    
+    return result;
+}
+
+static int backup_data(const char* destPath)
+{
+    int res = -1;
+    
+    FILE* fh = fopen(destPath, "w");
+    if (fh == NULL) {
+        fprintf(stderr, "unable to open destination '%s': %s\n",
+                destPath, strerror(errno));
+        return -1;
+    }
+    
+    printf("Backing up /data to %s...\n", destPath);
+
+    if (!write_int32(fh, FILE_VERSION)) goto done;
+    if (!write_int32(fh, opt_backupAll)) goto done;
+    if (!backup_dir(fh, "/data")) goto done;
+    if (!write_int32(fh, 0)) goto done;
+    
+    res = 0;
+    
+done:
+    if (fflush(fh) != 0) {
+        fprintf(stderr, "error flushing destination '%s': %s\n",
+            destPath, strerror(errno));
+        res = -1;
+        goto donedone;
+    }
+    if (fsync(fileno(fh)) != 0) {
+        fprintf(stderr, "error syncing destination '%s': %s\n",
+            destPath, strerror(errno));
+        res = -1;
+        goto donedone;
+    }
+    fclose(fh);
+    sync();
+
+donedone:    
+    return res;
+}
+
+static int32_t read_int32(FILE* fh, int32_t defVal)
+{
+    int32_t val;
+    if (fread(&val, 1, sizeof(val), fh) != sizeof(val)) {
+        fprintf(stderr, "unable to read: %s\n", strerror(errno));
+        return defVal;
+    }
+    
+    return val;
+}
+
+static int64_t read_int64(FILE* fh, int64_t defVal)
+{
+    int64_t val;
+    if (fread(&val, 1, sizeof(val), fh) != sizeof(val)) {
+        fprintf(stderr, "unable to read: %s\n", strerror(errno));
+        return defVal;
+    }
+    
+    return val;
+}
+
+static int read_header(FILE* fh, int* type, char** path, struct stat* st)
+{
+    *type = read_int32(fh, -1);
+    if (*type == TYPE_END) {
+        return 1;
+    }
+    
+    if (*type < 0) {
+        fprintf(stderr, "bad token %d in restore file\n", *type);
+        return 0;
+    }
+    
+    int32_t pathLen = read_int32(fh, -1);
+    if (pathLen <= 0) {
+        fprintf(stderr, "bad path length %d in restore file\n", pathLen);
+        return 0;
+    }
+    char* readPath = (char*)malloc(pathLen+1);
+    if (fread(readPath, 1, pathLen, fh) != (size_t)pathLen) {
+        fprintf(stderr, "truncated path in restore file\n");
+        free(readPath);
+        return 0;
+    }
+    readPath[pathLen] = 0;
+    *path = readPath;
+    
+    st->st_uid = read_int32(fh, -1);
+    if (st->st_uid == (uid_t)-1) {
+        fprintf(stderr, "bad uid in restore file at '%s'\n", readPath);
+        return 0;
+    }
+    st->st_gid = read_int32(fh, -1);
+    if (st->st_gid == (gid_t)-1) {
+        fprintf(stderr, "bad gid in restore file at '%s'\n", readPath);
+        return 0;
+    }
+    st->st_mode = read_int32(fh, -1);
+    if (st->st_mode == (mode_t)-1) {
+        fprintf(stderr, "bad mode in restore file at '%s'\n", readPath);
+        return 0;
+    }
+    int64_t ltime = read_int64(fh, -1);
+    if (ltime < 0) {
+        fprintf(stderr, "bad atime in restore file at '%s'\n", readPath);
+        return 0;
+    }
+    st->st_atime = (time_t)(ltime/1000/1000/1000);
+    ltime = read_int64(fh, -1);
+    if (ltime < 0) {
+        fprintf(stderr, "bad mtime in restore file at '%s'\n", readPath);
+        return 0;
+    }
+    st->st_mtime = (time_t)(ltime/1000/1000/1000);
+    ltime = read_int64(fh, -1);
+    if (ltime < 0) {
+        fprintf(stderr, "bad ctime in restore file at '%s'\n", readPath);
+        return 0;
+    }
+    st->st_ctime = (time_t)(ltime/1000/1000/1000);
+    
+    st->st_mode &= (S_IRWXU|S_IRWXG|S_IRWXO);
+    
+    return 1;
+}
+
+static int restore_data(const char* srcPath)
+{
+    int res = -1;
+    
+    FILE* fh = fopen(srcPath, "r");
+    if (fh == NULL) {
+        fprintf(stderr, "Unable to open source '%s': %s\n",
+                srcPath, strerror(errno));
+        return -1;
+    }
+    
+    inputFileVersion = read_int32(fh, 0);
+    if (inputFileVersion < FILE_VERSION_1 || inputFileVersion > FILE_VERSION) {
+        fprintf(stderr, "Restore file has bad version: 0x%x\n", inputFileVersion);
+        goto done;
+    }
+    
+    if (inputFileVersion >= FILE_VERSION_2) {
+        opt_backupAll = read_int32(fh, 0);
+    } else {
+        opt_backupAll = 0;
+    }
+    
+    printf("Wiping contents of /data...\n");
+    if (!wipe("/data")) {
+        goto done;
+    }
+
+    printf("Restoring from %s to /data...\n", srcPath);
+
+    while (1) {
+        int type;
+        char* path = NULL;
+        if (read_header(fh, &type, &path, &statBuffer) == 0) {
+            goto done;
+        }
+        if (type == 0) {
+            break;
+        }
+        
+        const char* typeName = "?";
+        
+        if (type == TYPE_DIR) {
+            typeName = "dir";
+            
+            printf("Restoring dir %s...\n", path);
+            
+            if (mkdir(path, statBuffer.st_mode) != 0) {
+                if (errno != EEXIST) {
+                    fprintf(stderr, "unable to create directory '%s': %s\n",
+                        path, strerror(errno));
+                    free(path);
+                    goto done;
+                }
+            }
+            
+        } else if (type == TYPE_FILE) {
+            typeName = "file";
+            off_t size = read_int64(fh, -1);
+            if (size < 0) {
+                fprintf(stderr, "bad file size %ld in restore file\n", size);
+                free(path);
+                goto done;
+            }
+            
+            printf("Restoring file %s...\n", path);
+            
+            FILE* dest = fopen(path, "w");
+            if (dest == NULL) {
+                fprintf(stderr, "unable to open destination file '%s': %s\n",
+                    path, strerror(errno));
+                free(path);
+                goto done;
+            }
+            
+            int copyres = copy_file(dest, fh, size, path, NULL);
+            fclose(dest);
+            if (!copyres) {
+                free(path);
+                goto done;
+            }
+        
+        } else {
+            fprintf(stderr, "unknown node type %d\n", type);
+            goto done;
+        }
+        
+        // Do this even for directories, since the dir may have already existed
+        // so we need to make sure it gets the correct mode.    
+        if (chmod(path, statBuffer.st_mode&(S_IRWXU|S_IRWXG|S_IRWXO)) != 0) {
+            fprintf(stderr, "unable to chmod destination %s '%s' to 0x%x: %s\n",
+                typeName, path, statBuffer.st_mode, strerror(errno));
+            free(path);
+            goto done;
+        }
+        
+        if (chown(path, statBuffer.st_uid, statBuffer.st_gid) != 0) {
+            fprintf(stderr, "unable to chown destination %s '%s' to uid %d / gid %d: %s\n",
+                typeName, path, (int)statBuffer.st_uid, (int)statBuffer.st_gid, strerror(errno));
+            free(path);
+            goto done;
+        }
+        
+        struct utimbuf timbuf;
+        timbuf.actime = statBuffer.st_atime;
+        timbuf.modtime = statBuffer.st_mtime;
+        if (utime(path, &timbuf) != 0) {
+            fprintf(stderr, "unable to utime destination %s '%s': %s\n",
+                typeName, path, strerror(errno));
+            free(path);
+            goto done;
+        }
+        
+        
+        free(path);
+    }
+    
+    res = 0;
+        
+done:    
+    fclose(fh);
+    
+    return res;
+}
+
+static void show_help(const char *cmd)
+{
+    fprintf(stderr,"Usage: %s COMMAND [options] [backup-file-path]\n", cmd);
+
+    fprintf(stderr, "commands are:\n"
+                    "  help            Show this help text.\n"
+                    "  backup          Perform a backup of /data.\n"
+                    "  restore         Perform a restore of /data.\n");
+    fprintf(stderr, "options include:\n"
+                    "  -h              Show this help text.\n"
+                    "  -a              Backup all files.\n");
+    fprintf(stderr, "\nThe %s command allows you to perform low-level\n"
+                    "backup and restore of the /data partition.  This is\n"
+                    "where all user data is kept, allowing for a fairly\n"
+                    "complete restore of a device's state.  Note that\n"
+                    "because this is low-level, it will only work across\n"
+                    "builds of the same (or very similar) device software.\n",
+                    cmd);
+}
+
+} /* namespace android */
+
+int main (int argc, char **argv)
+{
+    int restore = 0;
+
+    if (getuid() != AID_ROOT) {
+        fprintf(stderr, "error -- %s must run as root\n", argv[0]);
+        exit(-1);
+    }
+    
+    if (argc < 2) {
+        fprintf(stderr, "No command specified.\n");
+        android::show_help(argv[0]);
+        exit(-1);
+    }
+
+    if (0 == strcmp(argv[1], "restore")) {
+        restore = 1;
+    } else if (0 == strcmp(argv[1], "help")) {
+        android::show_help(argv[0]);
+        exit(0);
+    } else if (0 != strcmp(argv[1], "backup")) {
+        fprintf(stderr, "Unknown command: %s\n", argv[1]);
+        android::show_help(argv[0]);
+        exit(-1);
+    }
+
+    android::opt_backupAll = 0;
+                
+    optind = 2;
+    
+    for (;;) {
+        int ret;
+
+        ret = getopt(argc, argv, "ah");
+
+        if (ret < 0) {
+            break;
+        }
+
+        switch(ret) {
+            case 'a':
+                android::opt_backupAll = 1;
+                if (restore) fprintf(stderr, "Warning: -a option ignored on restore\n");
+                break;
+            case 'h':
+                android::show_help(argv[0]);
+                exit(0);
+            break;
+
+            default:
+                fprintf(stderr,"Unrecognized Option\n");
+                android::show_help(argv[0]);
+                exit(-1);
+            break;
+        }
+    }
+
+    const char* backupFile = "/sdcard/backup.dat";
+    
+    if (argc > optind) {
+        backupFile = argv[optind];
+        optind++;
+        if (argc != optind) {
+            fprintf(stderr, "Too many arguments\n");
+            android::show_help(argv[0]);
+            exit(-1);
+        }
+    }
+    
+    printf("Stopping system...\n");
+    property_set("ctl.stop", "runtime");
+    property_set("ctl.stop", "zygote");
+    sleep(1);
+    
+    int res;
+    if (restore) {
+        res = android::restore_data(backupFile);
+        if (res != 0) {
+            // Don't restart system, since the data partition is hosed.
+            return res;
+        }
+        printf("Restore complete!  Restarting system, cross your fingers...\n");
+    } else {
+        res = android::backup_data(backupFile);
+        if (res == 0) {
+            printf("Backup complete!  Restarting system...\n");
+        } else {
+            printf("Restarting system...\n");
+        }
+    }
+    
+    property_set("ctl.start", "zygote");
+    property_set("ctl.start", "runtime");
+}
diff --git a/core/java/android/accounts/AuthenticatorDescription.java b/core/java/android/accounts/AuthenticatorDescription.java
index eddf7c1..c6515672 100644
--- a/core/java/android/accounts/AuthenticatorDescription.java
+++ b/core/java/android/accounts/AuthenticatorDescription.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2009 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.accounts;
 
 import android.os.Parcelable;
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index b0a59c7..7b5b63e 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -59,6 +59,7 @@
 import android.util.DisplayMetrics;
 import android.util.EventLog;
 import android.util.Log;
+import android.util.Slog;
 import android.view.Display;
 import android.view.View;
 import android.view.ViewDebug;
@@ -542,7 +543,7 @@
                 }
                 warned = true;
                 Thread.currentThread().setContextClassLoader(getParent());
-                Log.w(TAG, "ClassLoader." + methodName + ": " +
+                Slog.w(TAG, "ClassLoader." + methodName + ": " +
                       "The class loader returned by " +
                       "Thread.getContextClassLoader() may fail for processes " +
                       "that host multiple applications. You should explicitly " +
@@ -677,7 +678,7 @@
                             "originally registered here. Are you missing a " +
                             "call to unregisterReceiver()?");
                     leak.setStackTrace(rd.getLocation().getStackTrace());
-                    Log.e(TAG, leak.getMessage(), leak);
+                    Slog.e(TAG, leak.getMessage(), leak);
                     try {
                         ActivityManagerNative.getDefault().unregisterReceiver(
                                 rd.getIIntentReceiver());
@@ -698,7 +699,7 @@
                             what + " " + who + " has leaked ServiceConnection "
                             + sd.getServiceConnection() + " that was originally bound here");
                     leak.setStackTrace(sd.getLocation().getStackTrace());
-                    Log.e(TAG, leak.getMessage(), leak);
+                    Slog.e(TAG, leak.getMessage(), leak);
                     try {
                         ActivityManagerNative.getDefault().unbindService(
                                 sd.getIServiceConnection());
@@ -823,7 +824,7 @@
                         try {
                             mgr.finishReceiver(this, resultCode, data, extras, false);
                         } catch (RemoteException e) {
-                            Log.w(TAG, "Couldn't finish broadcast to unregistered receiver");
+                            Slog.w(TAG, "Couldn't finish broadcast to unregistered receiver");
                         }
                     }
                 }
@@ -1721,7 +1722,7 @@
             try {
                 Process.setProcessGroup(Process.myPid(), group);
             } catch (Exception e) {
-                Log.w(TAG, "Failed setting process group to " + group, e);
+                Slog.w(TAG, "Failed setting process group to " + group, e);
             }
         }
 
@@ -2833,7 +2834,7 @@
         String classname = data.appInfo.backupAgentName;
         if (classname == null) {
             if (data.backupMode == IApplicationThread.BACKUP_MODE_INCREMENTAL) {
-                Log.e(TAG, "Attempted incremental backup but no defined agent for "
+                Slog.e(TAG, "Attempted incremental backup but no defined agent for "
                         + packageName);
                 return;
             }
@@ -2860,7 +2861,7 @@
             } catch (Exception e) {
                 // If this is during restore, fail silently; otherwise go
                 // ahead and let the user see the crash.
-                Log.e(TAG, "Agent threw during creation: " + e);
+                Slog.e(TAG, "Agent threw during creation: " + e);
                 if (data.backupMode != IApplicationThread.BACKUP_MODE_RESTORE) {
                     throw e;
                 }
@@ -2890,12 +2891,12 @@
             try {
                 agent.onDestroy();
             } catch (Exception e) {
-                Log.w(TAG, "Exception thrown in onDestroy by backup agent of " + data.appInfo);
+                Slog.w(TAG, "Exception thrown in onDestroy by backup agent of " + data.appInfo);
                 e.printStackTrace();
             }
             mBackupAgents.remove(packageName);
         } else {
-            Log.w(TAG, "Attempt to destroy unknown backup agent " + data);
+            Slog.w(TAG, "Attempt to destroy unknown backup agent " + data);
         }
     }
 
@@ -3284,7 +3285,7 @@
             RuntimeException e = new RuntimeException(
                     "Performing pause of activity that is not resumed: "
                     + r.intent.getComponent().toShortString());
-            Log.e(TAG, e.getMessage(), e);
+            Slog.e(TAG, e.getMessage(), e);
         }
         Bundle state = null;
         if (finished) {
@@ -3353,7 +3354,7 @@
                 RuntimeException e = new RuntimeException(
                         "Performing stop of activity that is not resumed: "
                         + r.intent.getComponent().toShortString());
-                Log.e(TAG, e.getMessage(), e);
+                Slog.e(TAG, e.getMessage(), e);
             }
 
             if (info != null) {
@@ -3998,13 +3999,13 @@
                 Debug.startMethodTracing(pcd.path, pcd.fd.getFileDescriptor(),
                         8 * 1024 * 1024, 0);
             } catch (RuntimeException e) {
-                Log.w(TAG, "Profiling failed on path " + pcd.path
+                Slog.w(TAG, "Profiling failed on path " + pcd.path
                         + " -- can the process access this path?");
             } finally {
                 try {
                     pcd.fd.close();
                 } catch (IOException e) {
-                    Log.w(TAG, "Failure closing profile fd", e);
+                    Slog.w(TAG, "Failure closing profile fd", e);
                 }
             }
         } else {
@@ -4249,7 +4250,7 @@
         } catch (RemoteException ex) {
         }
         if (holder == null) {
-            Log.e(TAG, "Failed to find provider info for " + name);
+            Slog.e(TAG, "Failed to find provider info for " + name);
             return null;
         }
         if (holder.permissionFailure != null) {
@@ -4419,7 +4420,7 @@
                 }
             }
             if (c == null) {
-                Log.w(TAG, "Unable to get context for package " +
+                Slog.w(TAG, "Unable to get context for package " +
                       ai.packageName +
                       " while loading content provider " +
                       info.name);
@@ -4431,7 +4432,7 @@
                     loadClass(info.name).newInstance();
                 provider = localProvider.getIContentProvider();
                 if (provider == null) {
-                    Log.e(TAG, "Failed to instantiate class " +
+                    Slog.e(TAG, "Failed to instantiate class " +
                           info.name + " from sourceDir " +
                           info.applicationInfo.sourceDir);
                     return null;
diff --git a/core/java/android/app/Dialog.java b/core/java/android/app/Dialog.java
index 981c237..f364def 100644
--- a/core/java/android/app/Dialog.java
+++ b/core/java/android/app/Dialog.java
@@ -27,7 +27,6 @@
 import android.os.Bundle;
 import android.os.Handler;
 import android.os.Message;
-import android.util.Log;
 import android.view.ContextMenu;
 import android.view.ContextThemeWrapper;
 import android.view.Gravity;
@@ -271,14 +270,16 @@
             return;
         }
 
-        mWindowManager.removeView(mDecor);
-
-        mDecor = null;
-        mWindow.closeAllPanels();
-        onStop();
-        mShowing = false;
-        
-        sendDismissMessage();
+        try {
+            mWindowManager.removeView(mDecor);
+        } finally {
+            mDecor = null;
+            mWindow.closeAllPanels();
+            onStop();
+            mShowing = false;
+            
+            sendDismissMessage();
+        }
     }
 
     private void sendDismissMessage() {
diff --git a/core/java/android/app/FullBackupAgent.java b/core/java/android/app/FullBackupAgent.java
index dcfa63f..acd20bd 100644
--- a/core/java/android/app/FullBackupAgent.java
+++ b/core/java/android/app/FullBackupAgent.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2009 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.app;
 
 import android.app.backup.BackupAgent;
diff --git a/core/java/android/app/IntentService.java b/core/java/android/app/IntentService.java
index 3fd36a37..1d6c125 100644
--- a/core/java/android/app/IntentService.java
+++ b/core/java/android/app/IntentService.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2008 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.app;
 
 import android.content.Intent;
diff --git a/core/java/android/app/UiModeManager.java b/core/java/android/app/UiModeManager.java
index defe421..82da983 100644
--- a/core/java/android/app/UiModeManager.java
+++ b/core/java/android/app/UiModeManager.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2010 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.app;
 
 import android.content.Context;
@@ -71,9 +87,9 @@
     public static String ACTION_ENTER_DESK_MODE = "android.app.action.ENTER_DESK_MODE";
     
     /**
-     * Broadcast sent when the device's UI has switch away from car mode back
-     * to normal mode.  Typically used by a car mode app, to dismiss itself
-     * when the user exits car mode.
+     * Broadcast sent when the device's UI has switched away from desk mode back
+     * to normal mode.  Typically used by a desk mode app, to dismiss itself
+     * when the user exits desk mode.
      */
     public static String ACTION_EXIT_DESK_MODE = "android.app.action.EXIT_DESK_MODE";
     
diff --git a/core/java/android/appwidget/AppWidgetHost.java b/core/java/android/appwidget/AppWidgetHost.java
index 03e8623..456ceb6 100644
--- a/core/java/android/appwidget/AppWidgetHost.java
+++ b/core/java/android/appwidget/AppWidgetHost.java
@@ -1,4 +1,5 @@
 /*
+ * Copyright (C) 2009 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.
diff --git a/core/java/android/appwidget/AppWidgetManager.java b/core/java/android/appwidget/AppWidgetManager.java
index 3660001..d4ce6a1 100644
--- a/core/java/android/appwidget/AppWidgetManager.java
+++ b/core/java/android/appwidget/AppWidgetManager.java
@@ -183,6 +183,16 @@
      * @see AppWidgetProviderInfo
      */
     public static final String META_DATA_APPWIDGET_PROVIDER = "android.appwidget.provider";
+    
+    /**
+     * Field for the manifest meta-data tag used to indicate any previous name for the
+     * app widget receiver.
+     *
+     * @see AppWidgetProviderInfo
+     * 
+     * @hide Pending API approval
+     */
+    public static final String META_DATA_APPWIDGET_OLD_NAME = "android.appwidget.oldName";
 
     static WeakHashMap<Context, WeakReference<AppWidgetManager>> sManagerCache = new WeakHashMap();
     static IAppWidgetService sService;
diff --git a/core/java/android/appwidget/AppWidgetProviderInfo.java b/core/java/android/appwidget/AppWidgetProviderInfo.java
index a2e0ba0a..cee2865 100644
--- a/core/java/android/appwidget/AppWidgetProviderInfo.java
+++ b/core/java/android/appwidget/AppWidgetProviderInfo.java
@@ -98,6 +98,18 @@
      * the <code>&lt;receiver&gt;</code> element in the AndroidManifest.xml file.
      */
     public int icon;
+    
+    
+    /**
+     * The previous name, if any, of the app widget receiver. If not supplied, it will be
+     * ignored.
+     *
+     * <p>This field corresponds to the <code>&lt;meta-data /&gt;</code> with the name
+     * <code>android.appwidget.oldName</code>.
+     * 
+     * @hide Pending API approval
+     */
+    public String oldName;
 
     public AppWidgetProviderInfo() {
     }
diff --git a/core/java/android/bluetooth/BluetoothAudioGateway.java b/core/java/android/bluetooth/BluetoothAudioGateway.java
index abd7723..bc32060 100644
--- a/core/java/android/bluetooth/BluetoothAudioGateway.java
+++ b/core/java/android/bluetooth/BluetoothAudioGateway.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 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 android.bluetooth;
 
 import java.lang.Thread;
diff --git a/core/java/android/content/CursorEntityIterator.java b/core/java/android/content/CursorEntityIterator.java
index 0c66646..54619a3 100644
--- a/core/java/android/content/CursorEntityIterator.java
+++ b/core/java/android/content/CursorEntityIterator.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2009 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.content;
 
 import android.database.Cursor;
diff --git a/core/java/android/content/SyncOperation.java b/core/java/android/content/SyncOperation.java
index 3b3f9c1..ec601de 100644
--- a/core/java/android/content/SyncOperation.java
+++ b/core/java/android/content/SyncOperation.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2010 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.content;
 
 import android.accounts.Account;
diff --git a/core/java/android/content/SyncQueue.java b/core/java/android/content/SyncQueue.java
index bb21488..432277f 100644
--- a/core/java/android/content/SyncQueue.java
+++ b/core/java/android/content/SyncQueue.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2010 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.content;
 
 import com.google.android.collect.Maps;
diff --git a/core/java/android/content/SyncResult.java b/core/java/android/content/SyncResult.java
index 3fbe847..18abebe 100644
--- a/core/java/android/content/SyncResult.java
+++ b/core/java/android/content/SyncResult.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2008 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.content;
 
 import android.os.Parcel;
diff --git a/core/java/android/content/pm/ActivityInfo.java b/core/java/android/content/pm/ActivityInfo.java
index 91b2be7..238b840 100644
--- a/core/java/android/content/pm/ActivityInfo.java
+++ b/core/java/android/content/pm/ActivityInfo.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 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 android.content.pm;
 
 import android.os.Parcel;
diff --git a/core/java/android/content/pm/ApplicationInfo.java b/core/java/android/content/pm/ApplicationInfo.java
index 423f4bc..ca2887a 100644
--- a/core/java/android/content/pm/ApplicationInfo.java
+++ b/core/java/android/content/pm/ApplicationInfo.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 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 android.content.pm;
 
 import android.os.Parcel;
diff --git a/core/java/android/content/pm/FeatureInfo.java b/core/java/android/content/pm/FeatureInfo.java
index 57d61fd..89394f9 100644
--- a/core/java/android/content/pm/FeatureInfo.java
+++ b/core/java/android/content/pm/FeatureInfo.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2009 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.content.pm;
 
 import android.os.Parcel;
diff --git a/core/java/android/content/pm/InstrumentationInfo.java b/core/java/android/content/pm/InstrumentationInfo.java
index 30ca002..3e868a7 100644
--- a/core/java/android/content/pm/InstrumentationInfo.java
+++ b/core/java/android/content/pm/InstrumentationInfo.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 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 android.content.pm;
 
 import android.os.Parcel;
diff --git a/core/java/android/content/pm/LabeledIntent.java b/core/java/android/content/pm/LabeledIntent.java
index d70a698..68b0046 100644
--- a/core/java/android/content/pm/LabeledIntent.java
+++ b/core/java/android/content/pm/LabeledIntent.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2009 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.content.pm;
 
 import android.content.Intent;
diff --git a/core/java/android/content/pm/PackageInfo.java b/core/java/android/content/pm/PackageInfo.java
index 0964425..e9a9f31 100644
--- a/core/java/android/content/pm/PackageInfo.java
+++ b/core/java/android/content/pm/PackageInfo.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 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 android.content.pm;
 
 import android.os.Parcel;
diff --git a/core/java/android/content/pm/PackageInfoLite.java b/core/java/android/content/pm/PackageInfoLite.java
index 2f38ece..da97fde0 100644
--- a/core/java/android/content/pm/PackageInfoLite.java
+++ b/core/java/android/content/pm/PackageInfoLite.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 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 android.content.pm;
 
 import android.os.Parcel;
@@ -60,4 +76,4 @@
         recommendedInstallLocation = source.readInt();
         installLocation = source.readInt();
     }
-}
\ No newline at end of file
+}
diff --git a/core/java/android/content/pm/PackageItemInfo.java b/core/java/android/content/pm/PackageItemInfo.java
index 8043dae..0e5ce3f 100644
--- a/core/java/android/content/pm/PackageItemInfo.java
+++ b/core/java/android/content/pm/PackageItemInfo.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 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 android.content.pm;
 
 import android.content.res.XmlResourceParser;
diff --git a/core/java/android/content/pm/PackageStats.java b/core/java/android/content/pm/PackageStats.java
index 66c6efd..9464321 100755
--- a/core/java/android/content/pm/PackageStats.java
+++ b/core/java/android/content/pm/PackageStats.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2008 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.content.pm;
 
 import android.os.Parcel;
diff --git a/core/java/android/content/pm/RegisteredServicesCacheListener.java b/core/java/android/content/pm/RegisteredServicesCacheListener.java
index 2bc0942..7095229 100644
--- a/core/java/android/content/pm/RegisteredServicesCacheListener.java
+++ b/core/java/android/content/pm/RegisteredServicesCacheListener.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2009 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.content.pm;
 
 import android.os.Parcelable;
diff --git a/core/java/android/content/pm/ResolveInfo.java b/core/java/android/content/pm/ResolveInfo.java
index 380db65..b6f4acc 100644
--- a/core/java/android/content/pm/ResolveInfo.java
+++ b/core/java/android/content/pm/ResolveInfo.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 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 android.content.pm;
 
 import android.content.IntentFilter;
diff --git a/core/java/android/content/pm/ServiceInfo.java b/core/java/android/content/pm/ServiceInfo.java
index 51d2a4d..087a4fe 100644
--- a/core/java/android/content/pm/ServiceInfo.java
+++ b/core/java/android/content/pm/ServiceInfo.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 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 android.content.pm;
 
 import android.os.Parcel;
diff --git a/core/java/android/content/pm/XmlSerializerAndParser.java b/core/java/android/content/pm/XmlSerializerAndParser.java
index 33598f0..935fc02 100644
--- a/core/java/android/content/pm/XmlSerializerAndParser.java
+++ b/core/java/android/content/pm/XmlSerializerAndParser.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2009 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.content.pm;
 
 import org.xmlpull.v1.XmlSerializer;
diff --git a/core/java/android/content/res/Configuration.java b/core/java/android/content/res/Configuration.java
index 61e3004..54fc044 100644
--- a/core/java/android/content/res/Configuration.java
+++ b/core/java/android/content/res/Configuration.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2008 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.content.res;
 
 import android.content.pm.ActivityInfo;
diff --git a/core/java/android/content/res/TypedArray.java b/core/java/android/content/res/TypedArray.java
index 09fdf8d..b0c149d 100644
--- a/core/java/android/content/res/TypedArray.java
+++ b/core/java/android/content/res/TypedArray.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2008 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.content.res;
 
 import android.graphics.drawable.Drawable;
@@ -723,4 +739,4 @@
     public String toString() {
         return Arrays.toString(mData);
     }
-}
\ No newline at end of file
+}
diff --git a/core/java/android/database/sqlite/SQLiteCompiledSql.java b/core/java/android/database/sqlite/SQLiteCompiledSql.java
index 18cc1d5..816f8a8 100644
--- a/core/java/android/database/sqlite/SQLiteCompiledSql.java
+++ b/core/java/android/database/sqlite/SQLiteCompiledSql.java
@@ -93,6 +93,9 @@
         // Note that native_finalize() checks to make sure that nStatement is
         // non-null before destroying it.
         if (nStatement != 0) {
+            if (SQLiteDebug.DEBUG_ACTIVE_CURSOR_FINALIZATION) {
+                Log.v(TAG, "closed and deallocated DbObj (id#" + nStatement +")");
+            }
             try {
                 mDatabase.lock();
                 native_finalize();
@@ -112,10 +115,16 @@
             return false;
         }
         mInUse = true;
+        if (SQLiteDebug.DEBUG_ACTIVE_CURSOR_FINALIZATION) {
+            Log.v(TAG, "Acquired DbObj (id#" + nStatement + ") from DB cache");
+        }
         return true;
     }
 
     /* package */ synchronized void release() {
+        if (SQLiteDebug.DEBUG_ACTIVE_CURSOR_FINALIZATION) {
+            Log.v(TAG, "Released DbObj (id#" + nStatement + ") back to DB cache");
+        }
         mInUse = false;
     }
 
@@ -127,6 +136,9 @@
         try {
             if (nStatement == 0) return;
             // finalizer should NEVER get called
+            if (SQLiteDebug.DEBUG_ACTIVE_CURSOR_FINALIZATION) {
+                Log.v(TAG, "** warning ** Finalized DbObj (id#" + nStatement + ")");
+            }
             Log.w(TAG, "finalizer should never be called on sql: " + mSqlStmt, mStackTrace);
             releaseSqlStatement();
         } finally {
diff --git a/core/java/android/database/sqlite/SQLiteProgram.java b/core/java/android/database/sqlite/SQLiteProgram.java
index 5b4516d..66ce3b0 100644
--- a/core/java/android/database/sqlite/SQLiteProgram.java
+++ b/core/java/android/database/sqlite/SQLiteProgram.java
@@ -16,11 +16,15 @@
 
 package android.database.sqlite;
 
+import android.util.Log;
+
 /**
  * A base class for compiled SQLite programs.
  */
 public abstract class SQLiteProgram extends SQLiteClosable {
 
+    private static final String TAG = "SQLiteProgram";
+
     /** The database this program is compiled against.
      * @deprecated do not use this
      */
@@ -80,16 +84,26 @@
             // make sure it is acquired by me.
             mCompiledSql.acquire();
             db.addToCompiledQueries(sql, mCompiledSql);
+            if (SQLiteDebug.DEBUG_ACTIVE_CURSOR_FINALIZATION) {
+                Log.v(TAG, "Created DbObj (id#" + mCompiledSql.nStatement +
+                        ") for sql: " + sql);
+            }
         } else {
             // it is already in compiled-sql cache.
             // try to acquire the object.
             if (!mCompiledSql.acquire()) {
+                int last = mCompiledSql.nStatement;
                 // the SQLiteCompiledSql in cache is in use by some other SQLiteProgram object.
                 // we can't have two different SQLiteProgam objects can't share the same
                 // CompiledSql object. create a new one.
                 // finalize it when I am done with it in "this" object.
                 mCompiledSql = new SQLiteCompiledSql(db, sql);
-
+                if (SQLiteDebug.DEBUG_ACTIVE_CURSOR_FINALIZATION) {
+                    Log.v(TAG, "** possible bug ** Created NEW DbObj (id#" +
+                            mCompiledSql.nStatement +
+                            ") because the previously created DbObj (id#" + last +
+                            ") was not released for sql:" + sql);
+                }
                 // since it is not in the cache, no need to acquire() it.
             }
         }
@@ -124,7 +138,7 @@
                 // it is in compiled-sql cache. reset its CompiledSql#mInUse flag
                 mCompiledSql.release();
             }
-        }
+        } 
     }
 
     /**
diff --git a/core/java/android/database/sqlite/SQLiteTransactionListener.java b/core/java/android/database/sqlite/SQLiteTransactionListener.java
index e97ece8..f03b580 100644
--- a/core/java/android/database/sqlite/SQLiteTransactionListener.java
+++ b/core/java/android/database/sqlite/SQLiteTransactionListener.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2009 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.database.sqlite;
 
 /**
diff --git a/core/java/android/hardware/Camera.java b/core/java/android/hardware/Camera.java
index 3484d55..4dddfd8 100644
--- a/core/java/android/hardware/Camera.java
+++ b/core/java/android/hardware/Camera.java
@@ -1331,7 +1331,7 @@
         }
 
         /**
-         * Sets GPS processing method. It will store up to 100 characters
+         * Sets GPS processing method. It will store up to 32 characters
          * in JPEG EXIF header.
          *
          * @param processing_method The processing method to get this location.
diff --git a/core/java/android/inputmethodservice/ExtractButton.java b/core/java/android/inputmethodservice/ExtractButton.java
index d6fe38d..f91cd4e 100644
--- a/core/java/android/inputmethodservice/ExtractButton.java
+++ b/core/java/android/inputmethodservice/ExtractButton.java
@@ -1,10 +1,26 @@
+/*
+ * Copyright (C) 2009 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.inputmethodservice;
 
 import android.content.Context;
 import android.util.AttributeSet;
 import android.widget.Button;
 
-/***
+/**
  * Specialization of {@link Button} that ignores the window not being focused.
  */
 class ExtractButton extends Button {
diff --git a/core/java/android/inputmethodservice/ExtractEditText.java b/core/java/android/inputmethodservice/ExtractEditText.java
index 0295f69..b7d53e2 100644
--- a/core/java/android/inputmethodservice/ExtractEditText.java
+++ b/core/java/android/inputmethodservice/ExtractEditText.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2008 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.inputmethodservice;
 
 import android.content.Context;
diff --git a/core/java/android/inputmethodservice/IInputMethodSessionWrapper.java b/core/java/android/inputmethodservice/IInputMethodSessionWrapper.java
index 6cf90d6..80e9865 100644
--- a/core/java/android/inputmethodservice/IInputMethodSessionWrapper.java
+++ b/core/java/android/inputmethodservice/IInputMethodSessionWrapper.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2008 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.inputmethodservice;
 
 import com.android.internal.os.HandlerCaller;
diff --git a/core/java/android/inputmethodservice/IInputMethodWrapper.java b/core/java/android/inputmethodservice/IInputMethodWrapper.java
index 20a05a5..bfa82ee 100644
--- a/core/java/android/inputmethodservice/IInputMethodWrapper.java
+++ b/core/java/android/inputmethodservice/IInputMethodWrapper.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2008 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.inputmethodservice;
 
 import com.android.internal.os.HandlerCaller;
diff --git a/core/java/android/os/BatteryStats.java b/core/java/android/os/BatteryStats.java
index 56a05ee..d114bff 100644
--- a/core/java/android/os/BatteryStats.java
+++ b/core/java/android/os/BatteryStats.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2008 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.os;
 
 import java.io.PrintWriter;
diff --git a/core/java/android/os/RecoverySystem.java b/core/java/android/os/RecoverySystem.java
index b827af8..1b103aa 100644
--- a/core/java/android/os/RecoverySystem.java
+++ b/core/java/android/os/RecoverySystem.java
@@ -70,7 +70,7 @@
     private static File LOG_FILE = new File(RECOVERY_DIR, "log");
 
     // Length limits for reading files.
-    private static int LOG_FILE_MAX_LENGTH = 8 * 1024;
+    private static int LOG_FILE_MAX_LENGTH = 64 * 1024;
 
     /**
      * Interface definition for a callback to be invoked regularly as
diff --git a/core/java/android/provider/Calendar.java b/core/java/android/provider/Calendar.java
index 4dbeef9..1c5fca3 100644
--- a/core/java/android/provider/Calendar.java
+++ b/core/java/android/provider/Calendar.java
@@ -33,11 +33,9 @@
 import android.net.Uri;
 import android.os.RemoteException;
 import android.pim.ICalendar;
-import android.pim.RecurrenceSet;
 import android.text.TextUtils;
 import android.text.format.DateUtils;
 import android.text.format.Time;
-import android.util.Config;
 import android.util.Log;
 
 /**
@@ -289,6 +287,13 @@
          * <P>Type: String</P>
          */
         public static final String OWNER_ACCOUNT = "ownerAccount";
+
+        /**
+         * Can the organizer respond to the event?  If no, the status of the
+         * organizer should not be shown by the UI.  Defaults to 1
+         * <P>Type: INTEGER (boolean)</P>
+         */
+        public static final String ORGANIZER_CAN_RESPOND = "organizerCanRespond";
     }
 
     public interface AttendeesColumns {
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index 4995cac..873e1a6f 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -1034,6 +1034,24 @@
         public static final String END_BUTTON_BEHAVIOR = "end_button_behavior";
 
         /**
+         * END_BUTTON_BEHAVIOR value for "go home".
+         * @hide
+         */
+        public static final int END_BUTTON_BEHAVIOR_HOME = 0x1;
+
+        /**
+         * END_BUTTON_BEHAVIOR value for "go to sleep".
+         * @hide
+         */
+        public static final int END_BUTTON_BEHAVIOR_SLEEP = 0x2;
+
+        /**
+         * END_BUTTON_BEHAVIOR default value.
+         * @hide
+         */
+        public static final int END_BUTTON_BEHAVIOR_DEFAULT = END_BUTTON_BEHAVIOR_SLEEP;
+
+        /**
          * Whether Airplane Mode is on.
          */
         public static final String AIRPLANE_MODE_ON = "airplane_mode_on";
@@ -3191,6 +3209,36 @@
         public static final String VOICE_RECOGNITION_SERVICE = "voice_recognition_service";
 
         /**
+         * What happens when the user presses the Power button while in-call
+         * and the screen is on.<br/>
+         * <b>Values:</b><br/>
+         * 1 - The Power button turns off the screen and locks the device. (Default behavior)<br/>
+         * 2 - The Power button hangs up the current call.<br/>
+         *
+         * @hide
+         */
+        public static final String INCALL_POWER_BUTTON_BEHAVIOR = "incall_power_button_behavior";
+
+        /**
+         * INCALL_POWER_BUTTON_BEHAVIOR value for "turn off screen".
+         * @hide
+         */
+        public static final int INCALL_POWER_BUTTON_BEHAVIOR_SCREEN_OFF = 0x1;
+
+        /**
+         * INCALL_POWER_BUTTON_BEHAVIOR value for "hang up".
+         * @hide
+         */
+        public static final int INCALL_POWER_BUTTON_BEHAVIOR_HANGUP = 0x2;
+
+        /**
+         * INCALL_POWER_BUTTON_BEHAVIOR default value.
+         * @hide
+         */
+        public static final int INCALL_POWER_BUTTON_BEHAVIOR_DEFAULT =
+                INCALL_POWER_BUTTON_BEHAVIOR_SCREEN_OFF;
+
+        /**
          * @hide
          */
         public static final String[] SETTINGS_TO_BACKUP = {
diff --git a/core/java/android/provider/Telephony.java b/core/java/android/provider/Telephony.java
index 0de1868..bf9e854 100644
--- a/core/java/android/provider/Telephony.java
+++ b/core/java/android/provider/Telephony.java
@@ -164,6 +164,12 @@
          * <P>Type: INTEGER</P>
          */
         public static final String ERROR_CODE = "error_code";
+
+        /**
+         * Meta data used externally.
+         * <P>Type: TEXT</P>
+         */
+        public static final String META_DATA = "meta_data";
 }
 
     /**
@@ -1064,6 +1070,12 @@
          * <P>Type: INTEGER (boolean)</P>
          */
         public static final String LOCKED = "locked";
+
+        /**
+         * Meta data used externally.
+         * <P>Type: TEXT</P>
+         */
+        public static final String META_DATA = "meta_data";
     }
 
     /**
diff --git a/core/java/android/text/style/UpdateAppearance.java b/core/java/android/text/style/UpdateAppearance.java
index 198e4fa..7112347 100644
--- a/core/java/android/text/style/UpdateAppearance.java
+++ b/core/java/android/text/style/UpdateAppearance.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2008 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.text.style;
 
 /**
diff --git a/core/java/android/view/RawInputEvent.java b/core/java/android/view/RawInputEvent.java
index 8b3cdd4..3bbfea8 100644
--- a/core/java/android/view/RawInputEvent.java
+++ b/core/java/android/view/RawInputEvent.java
@@ -1,6 +1,19 @@
-/**
- * 
+/*
+ * Copyright (C) 2008 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.view;
 
 /**
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 7a0c445..54c805f 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -2078,8 +2078,14 @@
                                         mHandler = getContext().getClass().getMethod(handlerName,
                                                 View.class);
                                     } catch (NoSuchMethodException e) {
+                                        int id = getId();
+                                        String idText = id == NO_ID ? "" : " with id '"
+                                                + getContext().getResources().getResourceEntryName(
+                                                    id) + "'";
                                         throw new IllegalStateException("Could not find a method " +
-                                                handlerName + "(View) in the activity", e);
+                                                handlerName + "(View) in the activity "
+                                                + getContext().getClass() + " for onClick handler"
+                                                + " on view " + View.this.getClass() + idText, e);
                                     }
                                 }
 
@@ -4350,6 +4356,7 @@
                         mPendingCheckForTap = new CheckForTap();
                     }
                     mPrivateFlags |= PREPRESSED;
+                    mHasPerformedLongPress = false;
                     postDelayed(mPendingCheckForTap, ViewConfiguration.getTapTimeout());
                     break;
 
diff --git a/core/java/android/view/inputmethod/EditorInfo.java b/core/java/android/view/inputmethod/EditorInfo.java
index 3da18d6..b98dcd2 100644
--- a/core/java/android/view/inputmethod/EditorInfo.java
+++ b/core/java/android/view/inputmethod/EditorInfo.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2008 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.view.inputmethod;
 
 import android.os.Bundle;
diff --git a/core/java/android/view/inputmethod/ExtractedText.java b/core/java/android/view/inputmethod/ExtractedText.java
index c2851d6..662ba3f 100644
--- a/core/java/android/view/inputmethod/ExtractedText.java
+++ b/core/java/android/view/inputmethod/ExtractedText.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2008 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.view.inputmethod;
 
 import android.os.Parcel;
diff --git a/core/java/android/view/inputmethod/ExtractedTextRequest.java b/core/java/android/view/inputmethod/ExtractedTextRequest.java
index e84b094..f658b87 100644
--- a/core/java/android/view/inputmethod/ExtractedTextRequest.java
+++ b/core/java/android/view/inputmethod/ExtractedTextRequest.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2008 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.view.inputmethod;
 
 import android.os.Parcel;
diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java
index a1c3fa2..5bded0b 100644
--- a/core/java/android/widget/AbsListView.java
+++ b/core/java/android/widget/AbsListView.java
@@ -381,12 +381,12 @@
     /**
      * Maximum distance to overscroll by
      */
-    private int mOverscrollMax;
+    int mOverscrollMax;
     
     /**
      * Content height divided by this is the overscroll limit.
      */
-    private static final int OVERSCROLL_LIMIT_DIVISOR = 3;
+    static final int OVERSCROLL_LIMIT_DIVISOR = 3;
 
     /**
      * Used to request a layout when we changed touch mode
@@ -2390,7 +2390,7 @@
         awakenScrollBars();
     }
     
-    private int getOverscrollMax() {
+    int getOverscrollMax() {
         final int childCount = getChildCount();
         if (childCount > 0) {
             return Math.min(mOverscrollMax,
@@ -3155,7 +3155,10 @@
         }
 
         if (!inTouchMode && mSelectedPosition != INVALID_POSITION) {
-            positionSelector(getChildAt(mSelectedPosition - mFirstPosition));
+            final int childIndex = mSelectedPosition - mFirstPosition;
+            if (childIndex >= 0 && childIndex < getChildCount()) {
+                positionSelector(getChildAt(childIndex));
+            }
         }
 
         mBlockLayoutRequests = false;
diff --git a/core/java/android/widget/ListView.java b/core/java/android/widget/ListView.java
index 0594844..27700fd 100644
--- a/core/java/android/widget/ListView.java
+++ b/core/java/android/widget/ListView.java
@@ -1250,10 +1250,19 @@
     int findMotionRow(int y) {
         int childCount = getChildCount();
         if (childCount > 0) {
-            for (int i = 0; i < childCount; i++) {
-                View v = getChildAt(i);
-                if (y <= v.getBottom()) {
-                    return mFirstPosition + i;
+            if (!mStackFromBottom) {
+                for (int i = 0; i < childCount; i++) {
+                    View v = getChildAt(i);
+                    if (y <= v.getBottom()) {
+                        return mFirstPosition + i;
+                    }
+                }
+            } else {
+                for (int i = childCount - 1; i >= 0; i--) {
+                    View v = getChildAt(i);
+                    if (y >= v.getTop()) {
+                        return mFirstPosition + i;
+                    }
                 }
             }
         }
@@ -3682,6 +3691,20 @@
             mCheckedIdStates.clear();
         }
     }
+    
+    @Override
+    int getOverscrollMax() {
+        if (mStackFromBottom) {
+            final int childCount = getChildCount();
+            if (childCount > 0) {
+                return Math.min(mOverscrollMax,
+                        (getHeight() - getChildAt(0).getTop()) / OVERSCROLL_LIMIT_DIVISOR);
+            } else {
+                return mOverscrollMax;
+            }
+        }
+        return super.getOverscrollMax();
+    }
 
     static class SavedState extends BaseSavedState {
         SparseBooleanArray checkState;
diff --git a/core/java/com/android/internal/backup/LocalTransport.java b/core/java/com/android/internal/backup/LocalTransport.java
index be83eb9..9e4b606 100644
--- a/core/java/com/android/internal/backup/LocalTransport.java
+++ b/core/java/com/android/internal/backup/LocalTransport.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2009 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.backup;
 
 import android.app.backup.BackupDataInput;
diff --git a/core/java/com/android/internal/content/PackageMonitor.java b/core/java/com/android/internal/content/PackageMonitor.java
index 343041f..32d86413 100644
--- a/core/java/com/android/internal/content/PackageMonitor.java
+++ b/core/java/com/android/internal/content/PackageMonitor.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2010 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.content;
 
 import android.app.Activity;
diff --git a/core/java/com/android/internal/os/HandlerCaller.java b/core/java/com/android/internal/os/HandlerCaller.java
index 35b9251..a94fb1e 100644
--- a/core/java/com/android/internal/os/HandlerCaller.java
+++ b/core/java/com/android/internal/os/HandlerCaller.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2008 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.os;
 
 import android.content.Context;
diff --git a/core/java/com/android/internal/os/PkgUsageStats.java b/core/java/com/android/internal/os/PkgUsageStats.java
index e847878..1ac191b 100755
--- a/core/java/com/android/internal/os/PkgUsageStats.java
+++ b/core/java/com/android/internal/os/PkgUsageStats.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2009 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.os;
 
 import android.os.Parcel;
diff --git a/core/java/com/android/internal/os/RuntimeInit.java b/core/java/com/android/internal/os/RuntimeInit.java
index c134d88..599a7fe 100644
--- a/core/java/com/android/internal/os/RuntimeInit.java
+++ b/core/java/com/android/internal/os/RuntimeInit.java
@@ -18,26 +18,19 @@
 
 import android.app.ActivityManagerNative;
 import android.app.ApplicationErrorReport;
-import android.app.IActivityManager;
 import android.os.Build;
 import android.os.Debug;
 import android.os.IBinder;
 import android.os.Process;
-import android.os.RemoteException;
-import android.os.ServiceManager;
 import android.os.SystemProperties;
 import android.util.Config;
 import android.util.Log;
+import android.util.Slog;
 
 import com.android.internal.logging.AndroidConfig;
 
 import dalvik.system.VMRuntime;
 
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
 import java.util.concurrent.atomic.AtomicInteger;
@@ -74,9 +67,9 @@
                 mCrashing = true;
 
                 if (mApplicationObject == null) {
-                    Log.e(TAG, "*** FATAL EXCEPTION IN SYSTEM PROCESS: " + t.getName(), e);
+                    Slog.e(TAG, "*** FATAL EXCEPTION IN SYSTEM PROCESS: " + t.getName(), e);
                 } else {
-                    Log.e(TAG, "FATAL EXCEPTION: " + t.getName(), e);
+                    Slog.e(TAG, "FATAL EXCEPTION: " + t.getName(), e);
                 }
 
                 // Bring up crash dialog, wait for it to be dismissed
@@ -84,9 +77,9 @@
                         mApplicationObject, new ApplicationErrorReport.CrashInfo(e));
             } catch (Throwable t2) {
                 try {
-                    Log.e(TAG, "Error reporting crash", t2);
+                    Slog.e(TAG, "Error reporting crash", t2);
                 } catch (Throwable t3) {
-                    // Even Log.e() fails!  Oh well.
+                    // Even Slog.e() fails!  Oh well.
                 }
             } finally {
                 // Try everything to make sure this process goes away.
@@ -97,14 +90,14 @@
     }
 
     private static final void commonInit() {
-        if (Config.LOGV) Log.d(TAG, "Entered RuntimeInit!");
+        if (Config.LOGV) Slog.d(TAG, "Entered RuntimeInit!");
 
         /* set default handler; this applies to all threads in the VM */
         Thread.setDefaultUncaughtExceptionHandler(new UncaughtHandler());
 
         int hasQwerty = getQwertyKeyboard();
 
-        if (Config.LOGV) Log.d(TAG, ">>>>> qwerty keyboard = " + hasQwerty);
+        if (Config.LOGV) Slog.d(TAG, ">>>>> qwerty keyboard = " + hasQwerty);
         if (hasQwerty == 1) {
             System.setProperty("qwerty", "1");
         }
@@ -144,7 +137,7 @@
          */
         String trace = SystemProperties.get("ro.kernel.android.tracing");
         if (trace.equals("1")) {
-            Log.i(TAG, "NOTE: emulator trace profiling enabled");
+            Slog.i(TAG, "NOTE: emulator trace profiling enabled");
             Debug.enableEmulatorTraceOutput();
         }
 
@@ -241,7 +234,7 @@
          */
         finishInit();
 
-        if (Config.LOGV) Log.d(TAG, "Leaving RuntimeInit!");
+        if (Config.LOGV) Slog.d(TAG, "Leaving RuntimeInit!");
     }
 
     public static final native void finishInit();
@@ -286,7 +279,7 @@
         }
 
         if (curArg == argv.length) {
-            Log.e(TAG, "Missing classname argument to RuntimeInit!");
+            Slog.e(TAG, "Missing classname argument to RuntimeInit!");
             // let the process exit
             return;
         }
@@ -334,7 +327,7 @@
                 System.exit(10);
             }
         } catch (Throwable t2) {
-            Log.e(TAG, "Error reporting WTF", t2);
+            Slog.e(TAG, "Error reporting WTF", t2);
         }
     }
 
diff --git a/core/java/com/android/internal/os/SamplingProfilerIntegration.java b/core/java/com/android/internal/os/SamplingProfilerIntegration.java
index 51d9570..5f5c7a4 100644
--- a/core/java/com/android/internal/os/SamplingProfilerIntegration.java
+++ b/core/java/com/android/internal/os/SamplingProfilerIntegration.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2009 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.os;
 
 import dalvik.system.SamplingProfiler;
diff --git a/core/java/com/android/internal/service/wallpaper/ImageWallpaper.java b/core/java/com/android/internal/service/wallpaper/ImageWallpaper.java
index 251ecbc..e961116 100644
--- a/core/java/com/android/internal/service/wallpaper/ImageWallpaper.java
+++ b/core/java/com/android/internal/service/wallpaper/ImageWallpaper.java
@@ -16,12 +16,15 @@
 
 package com.android.internal.service.wallpaper;
 
+import com.android.internal.view.WindowManagerPolicyThread;
+
 import android.app.WallpaperManager;
 import android.graphics.Canvas;
 import android.graphics.Rect;
 import android.graphics.Region.Op;
 import android.graphics.drawable.Drawable;
 import android.os.HandlerThread;
+import android.os.Looper;
 import android.os.Process;
 import android.service.wallpaper.WallpaperService;
 import android.util.Log;
@@ -43,9 +46,14 @@
     public void onCreate() {
         super.onCreate();
         mWallpaperManager = (WallpaperManager) getSystemService(WALLPAPER_SERVICE);
-        mThread = new HandlerThread("Wallpaper", Process.THREAD_PRIORITY_FOREGROUND);
-        mThread.start();
-        setCallbackLooper(mThread.getLooper());
+        Looper looper = WindowManagerPolicyThread.getLooper();
+        if (looper != null) {
+            setCallbackLooper(looper);
+        } else {
+            mThread = new HandlerThread("Wallpaper", Process.THREAD_PRIORITY_FOREGROUND);
+            mThread.start();
+            setCallbackLooper(mThread.getLooper());
+        }
     }
 
     public Engine onCreateEngine() {
@@ -55,7 +63,9 @@
     @Override
     public void onDestroy() {
         super.onDestroy();
-        mThread.quit();
+        if (mThread != null) {
+            mThread.quit();
+        }
     }
 
     class DrawableEngine extends Engine {
diff --git a/core/java/com/android/internal/util/HierarchicalStateMachine.java b/core/java/com/android/internal/util/HierarchicalStateMachine.java
index 1289d36..bebf051 100644
--- a/core/java/com/android/internal/util/HierarchicalStateMachine.java
+++ b/core/java/com/android/internal/util/HierarchicalStateMachine.java
@@ -550,7 +550,8 @@
         private class QuittingState extends HierarchicalState {
             @Override
             public boolean processMessage(Message msg) {
-                throw new RuntimeException("QuitingState: processMessage called should not happen");
+                // Ignore
+                return false;
             }
         }
 
@@ -960,7 +961,7 @@
      * @param looper for this state machine
      * @param name of the state machine
      */
-    private void initStateMachine(Looper looper, String name) {
+    private void initStateMachine(String name, Looper looper) {
         mName = name;
         mHsmHandler = new HsmHandler(looper, this);
     }
@@ -975,7 +976,7 @@
         mHsmThread.start();
         Looper looper = mHsmThread.getLooper();
 
-        initStateMachine(looper, name);
+        initStateMachine(name, looper);
     }
 
     /**
@@ -983,8 +984,8 @@
      *
      * @param name of the state machine
      */
-    protected HierarchicalStateMachine(Looper looper, String name) {
-        initStateMachine(looper, name);
+    protected HierarchicalStateMachine(String name, Looper looper) {
+        initStateMachine(name, looper);
     }
 
     /**
diff --git a/core/java/com/android/internal/view/BaseIWindow.java b/core/java/com/android/internal/view/BaseIWindow.java
index 22c6e79..b13d656 100644
--- a/core/java/com/android/internal/view/BaseIWindow.java
+++ b/core/java/com/android/internal/view/BaseIWindow.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2009 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.view;
 
 import android.content.res.Configuration;
diff --git a/core/java/com/android/internal/view/BaseSurfaceHolder.java b/core/java/com/android/internal/view/BaseSurfaceHolder.java
index 2823689..e0d3a5f 100644
--- a/core/java/com/android/internal/view/BaseSurfaceHolder.java
+++ b/core/java/com/android/internal/view/BaseSurfaceHolder.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2009 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.view;
 
 import android.graphics.Canvas;
diff --git a/core/java/com/android/internal/view/IInputConnectionWrapper.java b/core/java/com/android/internal/view/IInputConnectionWrapper.java
index 106392d..a765e38 100644
--- a/core/java/com/android/internal/view/IInputConnectionWrapper.java
+++ b/core/java/com/android/internal/view/IInputConnectionWrapper.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2008 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.view;
 
 import android.os.Bundle;
diff --git a/core/java/com/android/internal/view/InputConnectionWrapper.java b/core/java/com/android/internal/view/InputConnectionWrapper.java
index b92cb45..3c44e58 100644
--- a/core/java/com/android/internal/view/InputConnectionWrapper.java
+++ b/core/java/com/android/internal/view/InputConnectionWrapper.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2008 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.view;
 
 import com.android.internal.view.IInputContext;
diff --git a/core/java/com/android/internal/view/WindowManagerPolicyThread.java b/core/java/com/android/internal/view/WindowManagerPolicyThread.java
new file mode 100644
index 0000000..c8c38bb
--- /dev/null
+++ b/core/java/com/android/internal/view/WindowManagerPolicyThread.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2010 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.view;
+
+import android.os.Looper;
+
+/**
+ * Static storage of the thread running the window manager policy, to
+ * share with others.
+ */
+public class WindowManagerPolicyThread {
+    static Thread mThread;
+    static Looper mLooper;
+
+    public static void set(Thread thread, Looper looper) {
+        mThread = thread;
+        mLooper = looper;
+    }
+
+    public static Thread getThread() {
+        return mThread;
+    }
+
+    public static Looper getLooper() {
+        return mLooper;
+    }
+}
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index 3fb9607..584fe25 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -2078,11 +2078,11 @@
     <string name="usb_storage_stop_error_message">There was a problem turning off USB storage. Check to make sure you have unmounted the USB host, then try again.</string>
 
     <!-- USB_STORAGE_KILL_STORAGE_USERS dialog  -->
-    <string name="dlg_confirm_kill_storage_users_title">Enable Mass Storage</string>
+    <string name="dlg_confirm_kill_storage_users_title">Turn on USB storage</string>
     <!-- USB_STORAGE_KILL_STORAGE_USERS dialog message text -->
-    <string name="dlg_confirm_kill_storage_users_text">Some processes accessing data on sdcard will be killed. Do you want to continue?</string>
+    <string name="dlg_confirm_kill_storage_users_text">If you turn on USB storage, some applications you are using will stop and may be unavailable until you turn off USB storage.</string>
     <!-- USB_STORAGE_ERROR dialog  dialog-->
-    <string name="dlg_error_title">UMS operation failed</string>
+    <string name="dlg_error_title">USB operation failed</string>
     <!-- USB_STORAGE_ERROR dialog  ok button-->
     <string name="dlg_ok">OK</string>
 
diff --git a/core/tests/coretests/src/android/os/HierarchicalStateMachineTest.java b/core/tests/coretests/src/android/os/HierarchicalStateMachineTest.java
index 3f4bc04..20c55c2 100644
--- a/core/tests/coretests/src/android/os/HierarchicalStateMachineTest.java
+++ b/core/tests/coretests/src/android/os/HierarchicalStateMachineTest.java
@@ -1204,8 +1204,8 @@
      * complete.
      */
     class StateMachineSharedThread extends HierarchicalStateMachine {
-        StateMachineSharedThread(Looper looper, String name, int maxCount) {
-            super(looper, name);
+        StateMachineSharedThread(String name, Looper looper, int maxCount) {
+            super(name, looper);
             mMaxCount = maxCount;
             setDbg(DBG);
 
@@ -1254,7 +1254,7 @@
         // Create the state machines
         StateMachineSharedThread sms[] = new StateMachineSharedThread[10];
         for (int i = 0; i < sms.length; i++) {
-            sms[i] = new StateMachineSharedThread(smThread.getLooper(), "sm", sms.length);
+            sms[i] = new StateMachineSharedThread("sm", smThread.getLooper(), sms.length);
             sms[i].start();
         }
 
diff --git a/core/tests/coretests/src/android/widget/ListViewTest.java b/core/tests/coretests/src/android/widget/ListViewTest.java
index d09a16f..94b19f0 100644
--- a/core/tests/coretests/src/android/widget/ListViewTest.java
+++ b/core/tests/coretests/src/android/widget/ListViewTest.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 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 android.widget;
 
 import com.google.android.collect.Lists;
@@ -16,20 +32,6 @@
 
 import java.util.List;
 
-/**
- * Copyright (C) 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.
- */
-
 public class ListViewTest extends InstrumentationTestCase {
 
     /**
diff --git a/core/tests/coretests/src/android/widget/expandablelistview/PositionTesterContextMenuListener.java b/core/tests/coretests/src/android/widget/expandablelistview/PositionTesterContextMenuListener.java
index 7036c30..b482005 100644
--- a/core/tests/coretests/src/android/widget/expandablelistview/PositionTesterContextMenuListener.java
+++ b/core/tests/coretests/src/android/widget/expandablelistview/PositionTesterContextMenuListener.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2010 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.widget.expandablelistview;
 
 import android.view.ContextMenu;
diff --git a/include/surfaceflinger/Surface.h b/include/surfaceflinger/Surface.h
index 9808832..0279d84 100644
--- a/include/surfaceflinger/Surface.h
+++ b/include/surfaceflinger/Surface.h
@@ -210,9 +210,16 @@
 
     status_t dequeueBuffer(sp<GraphicBuffer>* buffer);
 
+    void dispatch_setUsage(va_list args);
+    int  dispatch_connect(va_list args);
+    int  dispatch_disconnect(va_list args);
     
     void setUsage(uint32_t reqUsage);
+    int  connect(int api);
+    int  disconnect(int api);
+
     uint32_t getUsage() const;
+    int      getConnectedApi() const;
     
     // constants
     sp<SurfaceComposerClient>   mClient;
@@ -227,6 +234,7 @@
     // protected by mSurfaceLock
     Rect                        mSwapRectangle;
     uint32_t                    mUsage;
+    int                         mConnected;
     
     // protected by mSurfaceLock. These are also used from lock/unlock
     // but in that case, they must be called form the same thread.
diff --git a/include/ui/egl/android_natives.h b/include/ui/egl/android_natives.h
index 3740db5..773fd93 100644
--- a/include/ui/egl/android_natives.h
+++ b/include/ui/egl/android_natives.h
@@ -69,7 +69,14 @@
 
 /* valid operations for the (*perform)() hook */
 enum {
-    NATIVE_WINDOW_SET_USAGE = 0
+    NATIVE_WINDOW_SET_USAGE  = 0,
+    NATIVE_WINDOW_CONNECT    = 1,
+    NATIVE_WINDOW_DISCONNECT = 2
+};
+
+/* parameter for NATIVE_WINDOW_[DIS]CONNECT */
+enum {
+    NATIVE_WINDOW_API_EGL = 1
 };
 
 typedef struct android_native_window_t 
@@ -157,8 +164,13 @@
      * This hook should not be called directly, instead use the helper functions
      * defined below.
      * 
+     *  (*perform)() returns -ENOENT if the 'what' parameter is not supported
+     *  by the surface's implementation.
+     *
      * The valid operations are:
      *     NATIVE_WINDOW_SET_USAGE
+     *     NATIVE_WINDOW_CONNECT
+     *     NATIVE_WINDOW_DISCONNECT
      *  
      */
     
@@ -185,6 +197,30 @@
     return window->perform(window, NATIVE_WINDOW_SET_USAGE, usage);
 }
 
+/*
+ * native_window_connect(..., NATIVE_WINDOW_API_EGL) must be called
+ * by EGL when the window is made current.
+ * Returns -EINVAL if for some reason the window cannot be connected, which
+ * can happen if it's connected to some other API.
+ */
+static inline int native_window_connect(
+        android_native_window_t* window, int api)
+{
+    return window->perform(window, NATIVE_WINDOW_CONNECT, api);
+}
+
+/*
+ * native_window_disconnect(..., NATIVE_WINDOW_API_EGL) must be called
+ * by EGL when the window is made not current.
+ * An error is returned if for instance the window wasn't connected in the
+ * first place.
+ */
+static inline int native_window_disconnect(
+        android_native_window_t* window, int api)
+{
+    return window->perform(window, NATIVE_WINDOW_DISCONNECT, api);
+}
+
 
 // ---------------------------------------------------------------------------
 
diff --git a/libs/surfaceflinger/LayerBase.cpp b/libs/surfaceflinger/LayerBase.cpp
index fdf6627..140f10c 100644
--- a/libs/surfaceflinger/LayerBase.cpp
+++ b/libs/surfaceflinger/LayerBase.cpp
@@ -54,7 +54,7 @@
       mOrientation(0),
       mLeft(0), mTop(0),
       mTransactionFlags(0),
-      mPremultipliedAlpha(true),
+      mPremultipliedAlpha(true), mDebug(false),
       mInvalidate(0)
 {
     const DisplayHardware& hw(flinger->graphicPlane(0).displayHardware());
@@ -65,6 +65,14 @@
 {
 }
 
+void LayerBase::setName(const String8& name) {
+    mName = name;
+}
+
+String8 LayerBase::getName() const {
+    return mName;
+}
+
 const GraphicPlane& LayerBase::graphicPlane(int dpy) const
 { 
     return mFlinger->graphicPlane(dpy);
@@ -698,8 +706,7 @@
 
 LayerBaseClient::LayerBaseClient(SurfaceFlinger* flinger, DisplayID display,
         const sp<Client>& client, int32_t i)
-    : LayerBase(flinger, display), lcblk(NULL), client(client),
-      mDebug(false), mIndex(i),
+    : LayerBase(flinger, display), lcblk(NULL), client(client), mIndex(i),
       mIdentity(uint32_t(android_atomic_inc(&sIdentity)))
 {
     lcblk = new SharedBufferServer(
@@ -724,14 +731,6 @@
     delete lcblk;
 }
 
-void LayerBaseClient::setName(const String8& name) {
-    mName = name;
-}
-
-String8 LayerBaseClient::getName() const {
-    return mName;
-}
-
 int32_t LayerBaseClient::serverIndex() const 
 {
     sp<Client> client(this->client.promote());
diff --git a/libs/surfaceflinger/LayerBase.h b/libs/surfaceflinger/LayerBase.h
index 852b9f9..a6e5644 100644
--- a/libs/surfaceflinger/LayerBase.h
+++ b/libs/surfaceflinger/LayerBase.h
@@ -101,6 +101,9 @@
                 Region          transparentRegion;
             };
 
+            void setName(const String8& name);
+            String8 getName() const;
+
             // modify current state
             bool setPosition(int32_t x, int32_t y);
             bool setLayer(uint32_t z);
@@ -121,7 +124,7 @@
             void drawRegion(const Region& reg) const;
 
             void invalidate();
-            
+
     /**
      * draw - performs some global clipping optimizations
      * and calls onDraw().
@@ -287,6 +290,9 @@
 
                 // don't change, don't need a lock
                 bool            mPremultipliedAlpha;
+                String8         mName;
+    mutable     bool            mDebug;
+
 
                 // atomic
     volatile    int32_t         mInvalidate;
@@ -320,8 +326,6 @@
             const sp<Client>& client, int32_t i);
     virtual ~LayerBaseClient();
     virtual void onFirstRef();
-    void setName(const String8& name);
-    String8 getName() const;
 
     const wp<Client>    client;
 
@@ -369,15 +373,11 @@
 
     friend class Surface;
 
-protected:
-    mutable     bool            mDebug;
-
 private:
                 int32_t         mIndex;
     mutable     Mutex           mLock;
     mutable     wp<Surface>     mClientSurface;
     // only read
-                String8         mName;
     const       uint32_t        mIdentity;
     static      int32_t         sIdentity;
 };
diff --git a/libs/surfaceflinger/Transform.cpp b/libs/surfaceflinger/Transform.cpp
index b2d5856..175f989 100644
--- a/libs/surfaceflinger/Transform.cpp
+++ b/libs/surfaceflinger/Transform.cpp
@@ -65,17 +65,14 @@
 Transform::~Transform() {
 }
 
-
-bool Transform::absIsOne(float f) {
-    return fabs(f) == 1.0f;
-}
+static const float EPSILON = 0.0f;
 
 bool Transform::isZero(float f) {
-    return fabs(f) == 0.0f;
+    return fabs(f) <= EPSILON;
 }
 
-bool Transform::absEqual(float a, float b) {
-    return fabs(a) == fabs(b);
+bool Transform::absIsOne(float f) {
+    return isZero(fabs(f) - 1.0f);
 }
 
 Transform Transform::operator * (const Transform& rhs) const
@@ -154,8 +151,14 @@
     mType = UNKNOWN_TYPE;
 }
 
-void Transform::set(uint32_t flags, float w, float h)
+status_t Transform::set(uint32_t flags, float w, float h)
 {
+    if (flags & ROT_INVALID) {
+        // that's not allowed!
+        reset();
+        return BAD_VALUE;
+    }
+
     mType = flags << 8;
     float sx = (flags & FLIP_H) ? -1 : 1;
     float sy = (flags & FLIP_V) ? -1 : 1;
@@ -205,6 +208,8 @@
     M[0][0] = a;    M[1][0] = b;    M[2][0] = x;
     M[0][1] = c;    M[1][1] = d;    M[2][1] = y;
     M[0][2] = 0;    M[1][2] = 0;    M[2][2] = 1;
+
+    return NO_ERROR;
 }
 
 Transform::vec2 Transform::transform(const vec2& v) const {
@@ -295,25 +300,17 @@
         bool scale = false;
         uint32_t flags = ROT_0;
         if (isZero(b) && isZero(c)) {
-            if (absEqual(a, d)) {
-                if (a<0)    flags |= FLIP_H;
-                if (d<0)    flags |= FLIP_V;
-                if (!absIsOne(a) || !absIsOne(d)) {
-                    scale = true;
-                }
-            } else {
-                flags = ROT_INVALID;
+            if (a<0)    flags |= FLIP_H;
+            if (d<0)    flags |= FLIP_V;
+            if (!absIsOne(a) || !absIsOne(d)) {
+                scale = true;
             }
         } else if (isZero(a) && isZero(d)) {
-            if (absEqual(b, c)) {
-                flags |= ROT_90;
-                if (b>0)    flags |= FLIP_H;
-                if (c<0)    flags |= FLIP_V;
-                if (!absIsOne(b) || !absIsOne(c)) {
-                    scale = true;
-                }
-            } else {
-                flags = ROT_INVALID;
+            flags |= ROT_90;
+            if (b>0)    flags |= FLIP_H;
+            if (c<0)    flags |= FLIP_V;
+            if (!absIsOne(b) || !absIsOne(c)) {
+                scale = true;
             }
         } else {
             flags = ROT_INVALID;
@@ -361,15 +358,22 @@
     const mat33& m(mMatrix);
     uint32_t orient = mType >> 8;
 
-    if (orient&ROT_INVALID)
+    if (orient&ROT_INVALID) {
         flags.append("ROT_INVALID ");
-    if (orient&ROT_90)
-        flags.append("ROT_90 ");
-    if (orient&FLIP_V)
-        flags.append("FLIP_V ");
-    if (orient&FLIP_H)
-        flags.append("FLIP_H ");
+    } else {
+        if (orient&ROT_90) {
+            flags.append("ROT_90 ");
+        } else {
+            flags.append("ROT_0 ");
+        }
+        if (orient&FLIP_V)
+            flags.append("FLIP_V ");
+        if (orient&FLIP_H)
+            flags.append("FLIP_H ");
+    }
 
+    if (!(mType&(SCALE|ROTATE|TRANSLATE)))
+        type.append("IDENTITY ");
     if (mType&SCALE)
         type.append("SCALE ");
     if (mType&ROTATE)
@@ -377,10 +381,10 @@
     if (mType&TRANSLATE)
         type.append("TRANSLATE ");
 
-    LOGD("%s (%s, %s)", name, flags.string(), type.string());
-    LOGD("%.2f  %.2f  %.2f", m[0][0], m[1][0], m[2][0]);
-    LOGD("%.2f  %.2f  %.2f", m[0][1], m[1][1], m[2][1]);
-    LOGD("%.2f  %.2f  %.2f", m[0][2], m[1][2], m[2][2]);
+    LOGD("%s 0x%08x (%s, %s)", name, mType, flags.string(), type.string());
+    LOGD("%.4f  %.4f  %.4f", m[0][0], m[1][0], m[2][0]);
+    LOGD("%.4f  %.4f  %.4f", m[0][1], m[1][1], m[2][1]);
+    LOGD("%.4f  %.4f  %.4f", m[0][2], m[1][2], m[2][2]);
 }
 
 // ---------------------------------------------------------------------------
diff --git a/libs/surfaceflinger/Transform.h b/libs/surfaceflinger/Transform.h
index 51d3e3f..2e5b893 100644
--- a/libs/surfaceflinger/Transform.h
+++ b/libs/surfaceflinger/Transform.h
@@ -69,10 +69,10 @@
             int     ty() const;
 
             // modify the transform
-            void    reset();
-            void    set(float tx, float ty);
-            void    set(float a, float b, float c, float d);
-            void    set(uint32_t flags, float w, float h);
+            void        reset();
+            void        set(float tx, float ty);
+            void        set(float a, float b, float c, float d);
+            status_t    set(uint32_t flags, float w, float h);
 
             // transform data
             Rect    makeBounds(int w, int h) const;
@@ -80,6 +80,9 @@
             Region  transform(const Region& reg) const;
             Transform operator * (const Transform& rhs) const;
 
+            // for debugging
+            void dump(const char* name) const;
+
 private:
     struct vec3 {
         float v[3];
@@ -113,11 +116,8 @@
     Rect transform(const Rect& bounds) const;
     uint32_t type() const;
     static bool absIsOne(float f);
-    static bool absEqual(float a, float b);
     static bool isZero(float f);
 
-    void dump(const char* name) const;
-
     mat33               mMatrix;
     mutable uint32_t    mType;
 };
diff --git a/libs/surfaceflinger_client/Surface.cpp b/libs/surfaceflinger_client/Surface.cpp
index eb3457b..5dd75c3 100644
--- a/libs/surfaceflinger_client/Surface.cpp
+++ b/libs/surfaceflinger_client/Surface.cpp
@@ -353,6 +353,7 @@
     const_cast<uint32_t&>(android_native_window_t::flags) = 0;
     // be default we request a hardware surface
     mUsage = GRALLOC_USAGE_HW_RENDER;
+    mConnected = 0;
     mNeedFullUpdate = false;
 }
 
@@ -579,28 +580,93 @@
 {
     int res = NO_ERROR;
     switch (operation) {
-        case NATIVE_WINDOW_SET_USAGE:
-            setUsage( va_arg(args, int) );
-            break;
-        default:
-            res = NAME_NOT_FOUND;
-            break;
+    case NATIVE_WINDOW_SET_USAGE:
+        dispatch_setUsage( args );
+        break;
+    case NATIVE_WINDOW_CONNECT:
+        res = dispatch_connect( args );
+        break;
+    case NATIVE_WINDOW_DISCONNECT:
+        res = dispatch_disconnect( args );
+        break;
+    default:
+        res = NAME_NOT_FOUND;
+        break;
     }
     return res;
 }
 
+void Surface::dispatch_setUsage(va_list args) {
+    int usage = va_arg(args, int);
+    setUsage( usage );
+}
+int Surface::dispatch_connect(va_list args) {
+    int api = va_arg(args, int);
+    return connect( api );
+}
+int Surface::dispatch_disconnect(va_list args) {
+    int api = va_arg(args, int);
+    return disconnect( api );
+}
+
+
 void Surface::setUsage(uint32_t reqUsage)
 {
     Mutex::Autolock _l(mSurfaceLock);
     mUsage = reqUsage;
 }
 
+int Surface::connect(int api)
+{
+    Mutex::Autolock _l(mSurfaceLock);
+    int err = NO_ERROR;
+    switch (api) {
+        case NATIVE_WINDOW_API_EGL:
+            if (mConnected) {
+                err = -EINVAL;
+            } else {
+                mConnected = api;
+            }
+            break;
+        default:
+            err = -EINVAL;
+            break;
+    }
+    return err;
+}
+
+int Surface::disconnect(int api)
+{
+    Mutex::Autolock _l(mSurfaceLock);
+    int err = NO_ERROR;
+    switch (api) {
+        case NATIVE_WINDOW_API_EGL:
+            if (mConnected == api) {
+                mConnected = 0;
+            } else {
+                err = -EINVAL;
+            }
+            break;
+        default:
+            err = -EINVAL;
+            break;
+    }
+    return err;
+}
+
 uint32_t Surface::getUsage() const
 {
     Mutex::Autolock _l(mSurfaceLock);
     return mUsage;
 }
 
+int Surface::getConnectedApi() const
+{
+    Mutex::Autolock _l(mSurfaceLock);
+    return mConnected;
+}
+
+
 // ----------------------------------------------------------------------------
 
 status_t Surface::lock(SurfaceInfo* info, bool blocking) {
@@ -609,11 +675,20 @@
 
 status_t Surface::lock(SurfaceInfo* other, Region* dirtyIn, bool blocking) 
 {
+    if (getConnectedApi()) {
+        LOGE("Surface::lock(%p) failed. Already connected to another API",
+                (android_native_window_t*)this);
+        CallStack stack;
+        stack.update();
+        stack.dump("");
+        return INVALID_OPERATION;
+    }
+
     if (mApiLock.tryLock() != NO_ERROR) {
         LOGE("calling Surface::lock from different threads!");
         CallStack stack;
         stack.update();
-        stack.dump("Surface::lock called from different threads");
+        stack.dump("");
         return WOULD_BLOCK;
     }
 
diff --git a/libs/ui/FramebufferNativeWindow.cpp b/libs/ui/FramebufferNativeWindow.cpp
index 1fa2c68..52380a0 100644
--- a/libs/ui/FramebufferNativeWindow.cpp
+++ b/libs/ui/FramebufferNativeWindow.cpp
@@ -250,6 +250,8 @@
 {
     switch (operation) {
         case NATIVE_WINDOW_SET_USAGE:
+        case NATIVE_WINDOW_CONNECT:
+        case NATIVE_WINDOW_DISCONNECT:
             break;
         default:
             return NAME_NOT_FOUND;
diff --git a/media/java/android/media/ExifInterface.java b/media/java/android/media/ExifInterface.java
index 4292754..b26906d 100644
--- a/media/java/android/media/ExifInterface.java
+++ b/media/java/android/media/ExifInterface.java
@@ -59,6 +59,8 @@
     public static final String TAG_WHITE_BALANCE = "WhiteBalance";
     /** Type is rational. */
     public static final String TAG_FOCAL_LENGTH = "FocalLength";
+    /** Type is String. Name of GPS processing method used for location finding. */
+    public static final String TAG_GPS_PROCESSING_METHOD = "GPSProcessingMethod";
 
     // Constants used for the Orientation Exif tag.
     public static final int ORIENTATION_UNDEFINED = 0;
diff --git a/media/libmedia/MediaScannerClient.cpp b/media/libmedia/MediaScannerClient.cpp
index bb3717f..bd3596e 100644
--- a/media/libmedia/MediaScannerClient.cpp
+++ b/media/libmedia/MediaScannerClient.cpp
@@ -64,26 +64,28 @@
 
 bool MediaScannerClient::addStringTag(const char* name, const char* value)
 {
-    // don't bother caching strings that are all ASCII.
-    // call handleStringTag directly instead.
-    // check to see if value (which should be utf8) has any non-ASCII characters
-    bool nonAscii = false;
-    const char* chp = value;
-    char ch;
-    while ((ch = *chp++)) {
-        if (ch & 0x80) {
-            nonAscii = true;
-            break;
+    if (mLocaleEncoding != kEncodingNone) {
+        // don't bother caching strings that are all ASCII.
+        // call handleStringTag directly instead.
+        // check to see if value (which should be utf8) has any non-ASCII characters
+        bool nonAscii = false;
+        const char* chp = value;
+        char ch;
+        while ((ch = *chp++)) {
+            if (ch & 0x80) {
+                nonAscii = true;
+                break;
+            }
         }
-    }
 
-    if (nonAscii) {
-        // save the strings for later so they can be used for native encoding detection
-        mNames->push_back(name);
-        mValues->push_back(value);
-        return true;
+        if (nonAscii) {
+            // save the strings for later so they can be used for native encoding detection
+            mNames->push_back(name);
+            mValues->push_back(value);
+            return true;
+        }
+        // else fall through
     }
-    // else fall through
 
     // autodetection is not necessary, so no need to cache the values
     // pass directly to the client instead
@@ -196,29 +198,23 @@
 
 void MediaScannerClient::endFile()
 {
-    int size = mNames->size();
-    uint32_t encoding = kEncodingAll;
+    if (mLocaleEncoding != kEncodingNone) {
+        int size = mNames->size();
+        uint32_t encoding = kEncodingAll;
 
-    // compute a bit mask containing all possible encodings
-    for (int i = 0; i < mNames->size(); i++)
-        encoding &= possibleEncodings(mValues->getEntry(i));
+        // compute a bit mask containing all possible encodings
+        for (int i = 0; i < mNames->size(); i++)
+            encoding &= possibleEncodings(mValues->getEntry(i));
 
-    // If one of the possible encodings matches the locale encoding, use that.
-    // Otherwise, if there is only one possible encoding, use that.
-    if (encoding & mLocaleEncoding)
-        convertValues(mLocaleEncoding);
-    else if ((encoding & (encoding - 1)) == 0)
-        convertValues(encoding);
-    else {
-        // TODO: try harder to disambiguate the encoding, perhaps by looking at
-        // other files by same artist, or even the user's entire collection.
-        // For now, fall through and insert the strings as they are.
-    }
+        // if the locale encoding matches, then assume we have a native encoding.
+        if (encoding & mLocaleEncoding)
+            convertValues(mLocaleEncoding);
 
-    // finally, push all name/value pairs to the client
-    for (int i = 0; i < mNames->size(); i++) {
-        if (!handleStringTag(mNames->getEntry(i), mValues->getEntry(i)))
-            break;
+        // finally, push all name/value pairs to the client
+        for (int i = 0; i < mNames->size(); i++) {
+            if (!handleStringTag(mNames->getEntry(i), mValues->getEntry(i)))
+                break;
+        }
     }
     // else addStringTag() has done all the work so we have nothing to do
 
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaProfileReader.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaProfileReader.java
index d7cf069..056537d 100644
--- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaProfileReader.java
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaProfileReader.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2009 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.mediaframeworktest;
 
 import android.media.MediaRecorder;
diff --git a/opengl/java/android/opengl/EGLLogWrapper.java b/opengl/java/android/opengl/EGLLogWrapper.java
index 521fc8c..6c0fdb3 100644
--- a/opengl/java/android/opengl/EGLLogWrapper.java
+++ b/opengl/java/android/opengl/EGLLogWrapper.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2008 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.opengl;
 
 import java.io.IOException;
diff --git a/opengl/tests/gldual/src/com/android/gldual/TriangleRenderer.java b/opengl/tests/gldual/src/com/android/gldual/TriangleRenderer.java
index 098c4d2..a082d47 100644
--- a/opengl/tests/gldual/src/com/android/gldual/TriangleRenderer.java
+++ b/opengl/tests/gldual/src/com/android/gldual/TriangleRenderer.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2009 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.gldual;
 
 import java.nio.ByteBuffer;
diff --git a/opengl/tools/glgen/src/CFunc.java b/opengl/tools/glgen/src/CFunc.java
index a89e1c5..4847694 100644
--- a/opengl/tools/glgen/src/CFunc.java
+++ b/opengl/tools/glgen/src/CFunc.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright (C) 2006 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.
+ */
 
 import java.util.*;
 
diff --git a/opengl/tools/glgen/src/CType.java b/opengl/tools/glgen/src/CType.java
index d49e9ef..e0f0ca6 100644
--- a/opengl/tools/glgen/src/CType.java
+++ b/opengl/tools/glgen/src/CType.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright (C) 2006 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.
+ */
 
 public class CType {
 
diff --git a/opengl/tools/glgen/src/CodeEmitter.java b/opengl/tools/glgen/src/CodeEmitter.java
index ebb9727..3a4834e 100644
--- a/opengl/tools/glgen/src/CodeEmitter.java
+++ b/opengl/tools/glgen/src/CodeEmitter.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright (C) 2006 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.
+ */
 
 public interface CodeEmitter {
 
diff --git a/opengl/tools/glgen/src/GLESCodeEmitter.java b/opengl/tools/glgen/src/GLESCodeEmitter.java
index b303503..d138250 100644
--- a/opengl/tools/glgen/src/GLESCodeEmitter.java
+++ b/opengl/tools/glgen/src/GLESCodeEmitter.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2009 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.
+ */
+
 import java.io.PrintStream;
 
 /**
diff --git a/opengl/tools/glgen/src/GenerateGL.java b/opengl/tools/glgen/src/GenerateGL.java
index 3715a96..500cf0b 100644
--- a/opengl/tools/glgen/src/GenerateGL.java
+++ b/opengl/tools/glgen/src/GenerateGL.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright (C) 2006 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.
+ */
 
 import java.io.BufferedReader;
 import java.io.File;
diff --git a/opengl/tools/glgen/src/GenerateGLES.java b/opengl/tools/glgen/src/GenerateGLES.java
index 08063f3..6468957 100644
--- a/opengl/tools/glgen/src/GenerateGLES.java
+++ b/opengl/tools/glgen/src/GenerateGLES.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright (C) 2009 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.
+ */
 
 import java.io.BufferedReader;
 import java.io.File;
diff --git a/opengl/tools/glgen/src/JFunc.java b/opengl/tools/glgen/src/JFunc.java
index 63c045b..e3d73b6 100644
--- a/opengl/tools/glgen/src/JFunc.java
+++ b/opengl/tools/glgen/src/JFunc.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright (C) 2006 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.
+ */
 
 import java.util.ArrayList;
 import java.util.List;
diff --git a/opengl/tools/glgen/src/JType.java b/opengl/tools/glgen/src/JType.java
index 32d9fe7..deb2f01 100644
--- a/opengl/tools/glgen/src/JType.java
+++ b/opengl/tools/glgen/src/JType.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright (C) 2006 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.
+ */
 
 import java.util.HashMap;
 
diff --git a/opengl/tools/glgen/src/JniCodeEmitter.java b/opengl/tools/glgen/src/JniCodeEmitter.java
index 2db4e8d..ebaca90 100644
--- a/opengl/tools/glgen/src/JniCodeEmitter.java
+++ b/opengl/tools/glgen/src/JniCodeEmitter.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2006 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.
+ */
+
 import java.io.PrintStream;
 import java.util.ArrayList;
 import java.util.HashSet;
diff --git a/opengl/tools/glgen/src/Jsr239CodeEmitter.java b/opengl/tools/glgen/src/Jsr239CodeEmitter.java
index 335d226..c10efe3 100644
--- a/opengl/tools/glgen/src/Jsr239CodeEmitter.java
+++ b/opengl/tools/glgen/src/Jsr239CodeEmitter.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2009 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.
+ */
+
 import java.io.PrintStream;
 
 /**
diff --git a/opengl/tools/glgen/src/ParameterChecker.java b/opengl/tools/glgen/src/ParameterChecker.java
index df26acd..bff6d86 100644
--- a/opengl/tools/glgen/src/ParameterChecker.java
+++ b/opengl/tools/glgen/src/ParameterChecker.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright (C) 2006 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.
+ */
 
 import java.io.BufferedReader;
 import java.util.HashMap;
diff --git a/opengl/tools/glgen/stubs/gles11/glGetProgramInfoLog.java b/opengl/tools/glgen/stubs/gles11/glGetProgramInfoLog.java
index 19504f2..762df39 100644
--- a/opengl/tools/glgen/stubs/gles11/glGetProgramInfoLog.java
+++ b/opengl/tools/glgen/stubs/gles11/glGetProgramInfoLog.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2009 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.
+ */
+
     // C function void glGetProgramInfoLog( GLuint program, GLsizei maxLength, GLsizei * length,
  	//     GLchar * infoLog);
 
diff --git a/opengl/tools/glgen/stubs/gles11/glGetShaderInfoLog.java b/opengl/tools/glgen/stubs/gles11/glGetShaderInfoLog.java
index 1fac6be..af529c0 100644
--- a/opengl/tools/glgen/stubs/gles11/glGetShaderInfoLog.java
+++ b/opengl/tools/glgen/stubs/gles11/glGetShaderInfoLog.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2009 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.
+ */
+
     // C function void glGetShaderInfoLog( GLuint shader, GLsizei maxLength, GLsizei * length,
  	//     GLchar * infoLog);
 
diff --git a/opengl/tools/glgen/stubs/gles11/glGetString.java b/opengl/tools/glgen/stubs/gles11/glGetString.java
index fba249b..d44a6dd 100644
--- a/opengl/tools/glgen/stubs/gles11/glGetString.java
+++ b/opengl/tools/glgen/stubs/gles11/glGetString.java
@@ -1,3 +1,19 @@
+/*

+ * Copyright (C) 2009 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.

+ */

+

     // C function const GLubyte * glGetString ( GLenum name )

 

     public static native String glGetString(

diff --git a/opengl/tools/glgen/stubs/gles11/glShaderSource.java b/opengl/tools/glgen/stubs/gles11/glShaderSource.java
index a9c338a..e9fcef3 100644
--- a/opengl/tools/glgen/stubs/gles11/glShaderSource.java
+++ b/opengl/tools/glgen/stubs/gles11/glShaderSource.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2009 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.
+ */
+
     // C function void glShaderSource ( GLuint shader, GLsizei count, const GLchar ** string, const GLint* length )
 
     public static native void glShaderSource(
diff --git a/packages/DefaultContainerService/src/com/android/defcontainer/DefaultContainerService.java b/packages/DefaultContainerService/src/com/android/defcontainer/DefaultContainerService.java
index 7714911..c6b617d 100644
--- a/packages/DefaultContainerService/src/com/android/defcontainer/DefaultContainerService.java
+++ b/packages/DefaultContainerService/src/com/android/defcontainer/DefaultContainerService.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2010 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.defcontainer;
 
 import com.android.internal.app.IMediaContainerService;
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
index ba66dc5..fb39ac0 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
@@ -902,6 +902,7 @@
         vibrate = AudioService.getValueForVibrateSetting(vibrate,
                 AudioManager.VIBRATE_TYPE_RINGER, AudioManager.VIBRATE_SETTING_OFF);
         loadSetting(stmt, Settings.System.VIBRATE_ON, vibrate);
+        stmt.close();
     }
 
     private void loadSettings(SQLiteDatabase db) {
diff --git a/services/java/com/android/server/AppWidgetService.java b/services/java/com/android/server/AppWidgetService.java
index 5de68f9..24526af 100644
--- a/services/java/com/android/server/AppWidgetService.java
+++ b/services/java/com/android/server/AppWidgetService.java
@@ -524,10 +524,11 @@
     }
 
     Provider lookupProviderLocked(ComponentName provider) {
+        final String className = provider.getClassName();
         final int N = mInstalledProviders.size();
         for (int i=0; i<N; i++) {
             Provider p = mInstalledProviders.get(i);
-            if (p.info.provider.equals(provider)) {
+            if (p.info.provider.equals(provider) || className.equals(p.info.oldName)) {
                 return p;
             }
         }
@@ -706,6 +707,10 @@
 
             p = new Provider();
             AppWidgetProviderInfo info = p.info = new AppWidgetProviderInfo();
+            // If metaData was null, we would have returned earlier when getting
+            // the parser No need to do the check here
+            info.oldName = activityInfo.metaData.getString(
+                    AppWidgetManager.META_DATA_APPWIDGET_OLD_NAME);
 
             info.provider = component;
             p.uid = activityInfo.applicationInfo.uid;
@@ -935,6 +940,16 @@
                         // as before?
                         String pkg = parser.getAttributeValue(null, "pkg");
                         String cl = parser.getAttributeValue(null, "cl");
+
+                        final PackageManager packageManager = mContext.getPackageManager();
+                        try {
+                            packageManager.getReceiverInfo(new ComponentName(pkg, cl), 0);
+                        } catch (PackageManager.NameNotFoundException e) {
+                            String[] pkgs = packageManager.currentToCanonicalPackageNames(
+                                    new String[] { pkg });
+                            pkg = pkgs[0];
+                        }
+
                         Provider p = lookupProviderLocked(new ComponentName(pkg, cl));
                         if (p == null && mSafeMode) {
                             // if we're in safe mode, make a temporary one
diff --git a/services/java/com/android/server/BootReceiver.java b/services/java/com/android/server/BootReceiver.java
index eeb91fa..15aad0e 100644
--- a/services/java/com/android/server/BootReceiver.java
+++ b/services/java/com/android/server/BootReceiver.java
@@ -49,19 +49,7 @@
     private static FileObserver sTombstoneObserver = null;
 
     @Override
-    public void onReceive(Context context, Intent intent) {
-        try {
-            logBootEvents(context);
-        } catch (Exception e) {
-            Slog.e(TAG, "Can't log boot events", e);
-        }
-
-        try {
-            RecoverySystem.handleAftermath();
-        } catch (Exception e) {
-            Slog.e(TAG, "Can't handle recovery aftermath", e);
-        }
-
+    public void onReceive(final Context context, Intent intent) {
         try {
             // Start the load average overlay, if activated
             ContentResolver res = context.getContentResolver();
@@ -72,44 +60,59 @@
         } catch (Exception e) {
             Slog.e(TAG, "Can't start load average service", e);
         }
+
+        // Log boot events in the background to avoid blocking the main thread with I/O
+        new Thread() {
+            @Override
+            public void run() {
+                try {
+                    logBootEvents(context);
+                } catch (Exception e) {
+                    Slog.e(TAG, "Can't log boot events", e);
+                }
+            }
+        }.start();
     }
 
     private void logBootEvents(Context ctx) throws IOException {
         final DropBoxManager db = (DropBoxManager) ctx.getSystemService(Context.DROPBOX_SERVICE);
         final SharedPreferences prefs = ctx.getSharedPreferences("log_files", Context.MODE_PRIVATE);
-        final String props = new StringBuilder()
+        final String headers = new StringBuilder(512)
             .append("Build: ").append(Build.FINGERPRINT).append("\n")
             .append("Hardware: ").append(Build.BOARD).append("\n")
             .append("Bootloader: ").append(Build.BOOTLOADER).append("\n")
             .append("Radio: ").append(Build.RADIO).append("\n")
             .append("Kernel: ")
             .append(FileUtils.readTextFile(new File("/proc/version"), 1024, "...\n"))
-            .toString();
+            .append("\n").toString();
 
-        if (db == null || prefs == null) return;
+        String recovery = RecoverySystem.handleAftermath();
+        if (recovery != null && db != null) {
+            db.addText("SYSTEM_RECOVERY_LOG", headers + recovery);
+        }
 
         if (SystemProperties.getLong("ro.runtime.firstboot", 0) == 0) {
             String now = Long.toString(System.currentTimeMillis());
             SystemProperties.set("ro.runtime.firstboot", now);
-            db.addText("SYSTEM_BOOT", props);
+            if (db != null) db.addText("SYSTEM_BOOT", headers);
 
             // Negative sizes mean to take the *tail* of the file (see FileUtils.readTextFile())
-            addFileToDropBox(db, prefs, props, "/proc/last_kmsg",
+            addFileToDropBox(db, prefs, headers, "/proc/last_kmsg",
                     -LOG_SIZE, "SYSTEM_LAST_KMSG");
-            addFileToDropBox(db, prefs, props, "/cache/recovery/log",
+            addFileToDropBox(db, prefs, headers, "/cache/recovery/log",
                     -LOG_SIZE, "SYSTEM_RECOVERY_LOG");
-            addFileToDropBox(db, prefs, props, "/data/dontpanic/apanic_console",
+            addFileToDropBox(db, prefs, headers, "/data/dontpanic/apanic_console",
                     -LOG_SIZE, "APANIC_CONSOLE");
-            addFileToDropBox(db, prefs, props, "/data/dontpanic/apanic_threads",
+            addFileToDropBox(db, prefs, headers, "/data/dontpanic/apanic_threads",
                     -LOG_SIZE, "APANIC_THREADS");
         } else {
-            db.addText("SYSTEM_RESTART", props);
+            if (db != null) db.addText("SYSTEM_RESTART", headers);
         }
 
         // Scan existing tombstones (in case any new ones appeared)
         File[] tombstoneFiles = TOMBSTONE_DIR.listFiles();
         for (int i = 0; tombstoneFiles != null && i < tombstoneFiles.length; i++) {
-            addFileToDropBox(db, prefs, props, tombstoneFiles[i].getPath(),
+            addFileToDropBox(db, prefs, headers, tombstoneFiles[i].getPath(),
                     LOG_SIZE, "SYSTEM_TOMBSTONE");
         }
 
@@ -120,7 +123,7 @@
             public void onEvent(int event, String path) {
                 try {
                     String filename = new File(TOMBSTONE_DIR, path).getPath();
-                    addFileToDropBox(db, prefs, props, filename, LOG_SIZE, "SYSTEM_TOMBSTONE");
+                    addFileToDropBox(db, prefs, headers, filename, LOG_SIZE, "SYSTEM_TOMBSTONE");
                 } catch (IOException e) {
                     Slog.e(TAG, "Can't log tombstone", e);
                 }
@@ -133,19 +136,19 @@
     private static void addFileToDropBox(
             DropBoxManager db, SharedPreferences prefs,
             String headers, String filename, int maxSize, String tag) throws IOException {
-        if (!db.isTagEnabled(tag)) return;  // Slog.ing disabled
+        if (db == null || !db.isTagEnabled(tag)) return;  // Logging disabled
 
         File file = new File(filename);
         long fileTime = file.lastModified();
         if (fileTime <= 0) return;  // File does not exist
 
-        long lastTime = prefs.getLong(filename, 0);
-        if (lastTime == fileTime) return;  // Already logged this particular file
-        prefs.edit().putLong(filename, fileTime).commit();
+        if (prefs != null) {
+            long lastTime = prefs.getLong(filename, 0);
+            if (lastTime == fileTime) return;  // Already logged this particular file
+            prefs.edit().putLong(filename, fileTime).commit();
+        }
 
-        StringBuilder report = new StringBuilder(headers).append("\n");
-        report.append(FileUtils.readTextFile(file, maxSize, "[[TRUNCATED]]\n"));
-        db.addText(tag, report.toString());
-        Slog.i(TAG, "Slog.ing " + filename + " to DropBox (" + tag + ")");
+        Slog.i(TAG, "Copying " + filename + " to DropBox (" + tag + ")");
+        db.addText(tag, headers + FileUtils.readTextFile(file, maxSize, "[[TRUNCATED]]\n"));
     }
 }
diff --git a/services/java/com/android/server/ConnectivityService.java b/services/java/com/android/server/ConnectivityService.java
index fa06244..fc20d96 100644
--- a/services/java/com/android/server/ConnectivityService.java
+++ b/services/java/com/android/server/ConnectivityService.java
@@ -320,7 +320,7 @@
             }
         }
 
-        mTethering = new Tethering(mContext);
+        mTethering = new Tethering(mContext, mHandler.getLooper());
         mTetheringConfigValid = (((mNetTrackers[ConnectivityManager.TYPE_MOBILE_DUN] != null) ||
                                   !mTethering.isDunRequired()) &&
                                  (mTethering.getTetherableUsbRegexs().length != 0 ||
diff --git a/services/java/com/android/server/LocationManagerService.java b/services/java/com/android/server/LocationManagerService.java
index 7aa092a..ef57056 100644
--- a/services/java/com/android/server/LocationManagerService.java
+++ b/services/java/com/android/server/LocationManagerService.java
@@ -1341,7 +1341,7 @@
 
     private Bundle _getProviderInfoLocked(String provider) {
         LocationProviderInterface p = mProvidersByName.get(provider);
-        if (p == null || !p.isEnabled()) {
+        if (p == null) {
             return null;
         }
 
diff --git a/services/java/com/android/server/MountService.java b/services/java/com/android/server/MountService.java
index 713358d..d4d5336 100644
--- a/services/java/com/android/server/MountService.java
+++ b/services/java/com/android/server/MountService.java
@@ -566,6 +566,7 @@
         Intent in = null;
 
         if (oldState == VolumeState.Shared && newState != oldState) {
+            if (LOCAL_LOGD) Log.d(TAG, "Sending ACTION_MEDIA_UNSHARED intent");
             mContext.sendBroadcast(new Intent(Intent.ACTION_MEDIA_UNSHARED,
                                                 Uri.parse("file://" + path)));
         }
@@ -607,6 +608,7 @@
 
             updatePublicVolumeState(path, Environment.MEDIA_SHARED);
             in = new Intent(Intent.ACTION_MEDIA_SHARED, Uri.parse("file://" + path));
+            if (LOCAL_LOGD) Log.d(TAG, "Sending ACTION_MEDIA_SHARED intent");
         } else if (newState == VolumeState.SharedMnt) {
             Log.e(TAG, "Live shared mounts not supported yet!");
             return;
@@ -798,6 +800,29 @@
         } else {
             mSendUmsConnectedOnBoot = avail;
         }
+
+        final String path = Environment.getExternalStorageDirectory().getPath();
+        if (avail == false && getVolumeState(path).equals(Environment.MEDIA_SHARED)) {
+            /*
+             * USB mass storage disconnected while enabled
+             */
+            new Thread() {
+                public void run() {
+                    try {
+                        int rc;
+                        Log.w(TAG, "Disabling UMS after cable disconnect");
+                        doShareUnshareVolume(path, "ums", false);
+                        if ((rc = doMountVolume(path)) != StorageResultCode.OperationSucceeded) {
+                            Log.e(TAG, String.format(
+                                    "Failed to remount {%s} on UMS enabled-disconnect (%d)",
+                                            path, rc));
+                        }
+                    } catch (Exception ex) {
+                        Log.w(TAG, "Failed to mount media on UMS enabled-disconnect", ex);
+                    }
+                }
+            }.start();
+        }
     }
 
     private void sendUmsIntent(boolean c) {
diff --git a/services/java/com/android/server/PackageManagerService.java b/services/java/com/android/server/PackageManagerService.java
index 63afabc..139c05f 100644
--- a/services/java/com/android/server/PackageManagerService.java
+++ b/services/java/com/android/server/PackageManagerService.java
@@ -408,7 +408,7 @@
                         // If this is the only one pending we might
                         // have to bind to the service again.
                         if (!connectToService()) {
-                            Log.e(TAG, "Failed to bind to media container service");
+                            Slog.e(TAG, "Failed to bind to media container service");
                             params.serviceError();
                             return;
                         } else {
@@ -433,7 +433,7 @@
                     }
                     if (mContainerService == null) {
                         // Something seriously wrong. Bail out
-                        Log.e(TAG, "Cannot bind to media container service");
+                        Slog.e(TAG, "Cannot bind to media container service");
                         for (HandlerParams params : mPendingInstalls) {
                             mPendingInstalls.remove(0);
                             // Indicate service bind error
@@ -447,7 +447,7 @@
                         }
                     } else {
                         // Should never happen ideally.
-                        Log.w(TAG, "Empty queue");
+                        Slog.w(TAG, "Empty queue");
                     }
                     break;
                 }
@@ -458,7 +458,7 @@
                             disconnectService();
                         }
                         if (!connectToService()) {
-                            Log.e(TAG, "Failed to bind to media container service");
+                            Slog.e(TAG, "Failed to bind to media container service");
                             for (HandlerParams params : mPendingInstalls) {
                                 mPendingInstalls.remove(0);
                                 // Indicate service bind error
@@ -582,11 +582,11 @@
                             try {
                                 args.observer.packageInstalled(res.name, res.returnCode);
                             } catch (RemoteException e) {
-                                Log.i(TAG, "Observer no longer exists.");
+                                Slog.i(TAG, "Observer no longer exists.");
                             }
                         }
                     } else {
-                        Log.e(TAG, "Bogus post-install token " + msg.arg1);
+                        Slog.e(TAG, "Bogus post-install token " + msg.arg1);
                     }
                 } break;
             }
@@ -641,7 +641,7 @@
                 SystemClock.uptimeMillis());
 
         if (mSdkVersion <= 0) {
-            Log.w(TAG, "**** ro.build.version.sdk not set!");
+            Slog.w(TAG, "**** ro.build.version.sdk not set!");
         }
 
         mContext = context;
@@ -665,11 +665,11 @@
             if ("*".equals(separateProcesses)) {
                 mDefParseFlags = PackageParser.PARSE_IGNORE_PROCESSES;
                 mSeparateProcesses = null;
-                Log.w(TAG, "Running with debug.separate_processes: * (ALL)");
+                Slog.w(TAG, "Running with debug.separate_processes: * (ALL)");
             } else {
                 mDefParseFlags = 0;
                 mSeparateProcesses = separateProcesses.split(",");
-                Log.w(TAG, "Running with debug.separate_processes: "
+                Slog.w(TAG, "Running with debug.separate_processes: "
                         + separateProcesses);
             }
         } else {
@@ -725,7 +725,7 @@
             // scanning install directories.
             int scanMode = SCAN_MONITOR | SCAN_NO_PATHS;
             if (mNoDexOpt) {
-                Log.w(TAG, "Running ENG build: no pre-dexopt!");
+                Slog.w(TAG, "Running ENG build: no pre-dexopt!");
                 scanMode |= SCAN_NO_DEX;
             }
 
@@ -752,13 +752,13 @@
                                 didDexOpt = true;
                             }
                         } catch (FileNotFoundException e) {
-                            Log.w(TAG, "Boot class path not found: " + paths[i]);
+                            Slog.w(TAG, "Boot class path not found: " + paths[i]);
                         } catch (IOException e) {
-                            Log.w(TAG, "Exception reading boot class path: " + paths[i], e);
+                            Slog.w(TAG, "Exception reading boot class path: " + paths[i], e);
                         }
                     }
                 } else {
-                    Log.w(TAG, "No BOOTCLASSPATH found!");
+                    Slog.w(TAG, "No BOOTCLASSPATH found!");
                 }
 
                 /**
@@ -775,9 +775,9 @@
                                 didDexOpt = true;
                             }
                         } catch (FileNotFoundException e) {
-                            Log.w(TAG, "Library not found: " + lib);
+                            Slog.w(TAG, "Library not found: " + lib);
                         } catch (IOException e) {
-                            Log.w(TAG, "Exception reading library: " + lib, e);
+                            Slog.w(TAG, "Exception reading library: " + lib, e);
                         }
                     }
                 }
@@ -810,9 +810,9 @@
                                 didDexOpt = true;
                             }
                         } catch (FileNotFoundException e) {
-                            Log.w(TAG, "Jar not found: " + path);
+                            Slog.w(TAG, "Jar not found: " + path);
                         } catch (IOException e) {
-                            Log.w(TAG, "Exception reading jar: " + path, e);
+                            Slog.w(TAG, "Exception reading jar: " + path, e);
                         }
                     }
                 }
@@ -829,7 +829,7 @@
                             String fn = files[i];
                             if (fn.startsWith("data@app@")
                                     || fn.startsWith("data@app-private@")) {
-                                Log.i(TAG, "Pruning dalvik file: " + fn);
+                                Slog.i(TAG, "Pruning dalvik file: " + fn);
                                 (new File(mDalvikCacheDir, fn)).delete();
                             }
                         }
@@ -905,7 +905,7 @@
 
             EventLog.writeEvent(EventLogTags.BOOT_PROGRESS_PMS_SCAN_END,
                     SystemClock.uptimeMillis());
-            Log.i(TAG, "Time to scan packages: "
+            Slog.i(TAG, "Time to scan packages: "
                     + ((SystemClock.uptimeMillis()-startTime)/1000f)
                     + " seconds");
 
@@ -931,19 +931,19 @@
             return super.onTransact(code, data, reply, flags);
         } catch (RuntimeException e) {
             if (!(e instanceof SecurityException) && !(e instanceof IllegalArgumentException)) {
-                Log.e(TAG, "Package Manager Crash", e);
+                Slog.e(TAG, "Package Manager Crash", e);
             }
             throw e;
         }
     }
 
     void cleanupInstallFailedPackage(PackageSetting ps) {
-        Log.i(TAG, "Cleaning up incompletely installed app: " + ps.name);
+        Slog.i(TAG, "Cleaning up incompletely installed app: " + ps.name);
         if (mInstaller != null) {
             boolean useSecureFS = useEncryptedFilesystemForPackage(ps.pkg);
             int retCode = mInstaller.remove(ps.name, useSecureFS);
             if (retCode < 0) {
-                Log.w(TAG, "Couldn't remove app data directory for package: "
+                Slog.w(TAG, "Couldn't remove app data directory for package: "
                            + ps.name + ", retcode=" + retCode);
             }
         } else {
@@ -954,12 +954,12 @@
         }
         if (ps.codePath != null) {
             if (!ps.codePath.delete()) {
-                Log.w(TAG, "Unable to remove old code file: " + ps.codePath);
+                Slog.w(TAG, "Unable to remove old code file: " + ps.codePath);
             }
         }
         if (ps.resourcePath != null) {
             if (!ps.resourcePath.delete() && !ps.resourcePath.equals(ps.codePath)) {
-                Log.w(TAG, "Unable to remove old code file: " + ps.resourcePath);
+                Slog.w(TAG, "Unable to remove old code file: " + ps.resourcePath);
             }
         }
         mSettings.removePackageLP(ps.name);
@@ -969,11 +969,11 @@
         // Read permissions from .../etc/permission directory.
         File libraryDir = new File(Environment.getRootDirectory(), "etc/permissions");
         if (!libraryDir.exists() || !libraryDir.isDirectory()) {
-            Log.w(TAG, "No directory " + libraryDir + ", skipping");
+            Slog.w(TAG, "No directory " + libraryDir + ", skipping");
             return;
         }
         if (!libraryDir.canRead()) {
-            Log.w(TAG, "Directory " + libraryDir + " cannot be read");
+            Slog.w(TAG, "Directory " + libraryDir + " cannot be read");
             return;
         }
 
@@ -985,11 +985,11 @@
             }
 
             if (!f.getPath().endsWith(".xml")) {
-                Log.i(TAG, "Non-xml file " + f + " in " + libraryDir + " directory, ignoring");
+                Slog.i(TAG, "Non-xml file " + f + " in " + libraryDir + " directory, ignoring");
                 continue;
             }
             if (!f.canRead()) {
-                Log.w(TAG, "Permissions library file " + f + " cannot be read");
+                Slog.w(TAG, "Permissions library file " + f + " cannot be read");
                 continue;
             }
 
@@ -1028,7 +1028,7 @@
         try {
             permReader = new FileReader(permFile);
         } catch (FileNotFoundException e) {
-            Log.w(TAG, "Couldn't find or open permissions file " + permFile);
+            Slog.w(TAG, "Couldn't find or open permissions file " + permFile);
             return;
         }
 
@@ -1051,7 +1051,7 @@
                         int gid = Integer.parseInt(gidStr);
                         mGlobalGids = appendInt(mGlobalGids, gid);
                     } else {
-                        Log.w(TAG, "<group> without gid at "
+                        Slog.w(TAG, "<group> without gid at "
                                 + parser.getPositionDescription());
                     }
 
@@ -1060,7 +1060,7 @@
                 } else if ("permission".equals(name)) {
                     String perm = parser.getAttributeValue(null, "name");
                     if (perm == null) {
-                        Log.w(TAG, "<permission> without name at "
+                        Slog.w(TAG, "<permission> without name at "
                                 + parser.getPositionDescription());
                         XmlUtils.skipCurrentTag(parser);
                         continue;
@@ -1071,21 +1071,21 @@
                 } else if ("assign-permission".equals(name)) {
                     String perm = parser.getAttributeValue(null, "name");
                     if (perm == null) {
-                        Log.w(TAG, "<assign-permission> without name at "
+                        Slog.w(TAG, "<assign-permission> without name at "
                                 + parser.getPositionDescription());
                         XmlUtils.skipCurrentTag(parser);
                         continue;
                     }
                     String uidStr = parser.getAttributeValue(null, "uid");
                     if (uidStr == null) {
-                        Log.w(TAG, "<assign-permission> without uid at "
+                        Slog.w(TAG, "<assign-permission> without uid at "
                                 + parser.getPositionDescription());
                         XmlUtils.skipCurrentTag(parser);
                         continue;
                     }
                     int uid = Process.getUidForName(uidStr);
                     if (uid < 0) {
-                        Log.w(TAG, "<assign-permission> with unknown uid \""
+                        Slog.w(TAG, "<assign-permission> with unknown uid \""
                                 + uidStr + "\" at "
                                 + parser.getPositionDescription());
                         XmlUtils.skipCurrentTag(parser);
@@ -1104,10 +1104,10 @@
                     String lname = parser.getAttributeValue(null, "name");
                     String lfile = parser.getAttributeValue(null, "file");
                     if (lname == null) {
-                        Log.w(TAG, "<library> without name at "
+                        Slog.w(TAG, "<library> without name at "
                                 + parser.getPositionDescription());
                     } else if (lfile == null) {
-                        Log.w(TAG, "<library> without file at "
+                        Slog.w(TAG, "<library> without file at "
                                 + parser.getPositionDescription());
                     } else {
                         //Log.i(TAG, "Got library " + lname + " in " + lfile);
@@ -1119,7 +1119,7 @@
                 } else if ("feature".equals(name)) {
                     String fname = parser.getAttributeValue(null, "name");
                     if (fname == null) {
-                        Log.w(TAG, "<feature> without name at "
+                        Slog.w(TAG, "<feature> without name at "
                                 + parser.getPositionDescription());
                     } else {
                         //Log.i(TAG, "Got feature " + fname);
@@ -1137,9 +1137,9 @@
 
             }
         } catch (XmlPullParserException e) {
-            Log.w(TAG, "Got execption parsing permissions.", e);
+            Slog.w(TAG, "Got execption parsing permissions.", e);
         } catch (IOException e) {
-            Log.w(TAG, "Got execption parsing permissions.", e);
+            Slog.w(TAG, "Got execption parsing permissions.", e);
         }
     }
 
@@ -1170,7 +1170,7 @@
                     int gid = Process.getGidForName(gidStr);
                     bp.gids = appendInt(bp.gids, gid);
                 } else {
-                    Log.w(TAG, "<group> without gid at "
+                    Slog.w(TAG, "<group> without gid at "
                             + parser.getPositionDescription());
                 }
             }
@@ -1400,14 +1400,14 @@
                 if (mInstaller != null) {
                     retCode = mInstaller.freeCache(freeStorageSize);
                     if (retCode < 0) {
-                        Log.w(TAG, "Couldn't clear application caches");
+                        Slog.w(TAG, "Couldn't clear application caches");
                     }
                 } //end if mInstaller
                 if (observer != null) {
                     try {
                         observer.onRemoveCompleted(null, (retCode >= 0));
                     } catch (RemoteException e) {
-                        Log.w(TAG, "RemoveException when invoking call back");
+                        Slog.w(TAG, "RemoveException when invoking call back");
                     }
                 }
             }
@@ -1425,7 +1425,7 @@
                 if (mInstaller != null) {
                     retCode = mInstaller.freeCache(freeStorageSize);
                     if (retCode < 0) {
-                        Log.w(TAG, "Couldn't clear application caches");
+                        Slog.w(TAG, "Couldn't clear application caches");
                     }
                 }
                 if(pi != null) {
@@ -1435,7 +1435,7 @@
                         pi.sendIntent(null, code, null,
                                 null, null);
                     } catch (SendIntentException e1) {
-                        Log.i(TAG, "Failed to send pending intent");
+                        Slog.i(TAG, "Failed to send pending intent");
                     }
                 }
             }
@@ -1540,16 +1540,9 @@
         synchronized (mPackages) {
             Object obj = mSettings.getUserIdLP(uid);
             if (obj != null) {
-                if (obj instanceof SharedUserSetting) {
-                    SharedUserSetting sus = (SharedUserSetting)obj;
-                    if (sus.grantedPermissions.contains(permName)) {
-                        return PackageManager.PERMISSION_GRANTED;
-                    }
-                } else if (obj instanceof PackageSetting) {
-                    PackageSetting ps = (PackageSetting)obj;
-                    if (ps.grantedPermissions.contains(permName)) {
-                        return PackageManager.PERMISSION_GRANTED;
-                    }
+                GrantedPermissions gp = (GrantedPermissions)obj;
+                if (gp.grantedPermissions.contains(permName)) {
+                    return PackageManager.PERMISSION_GRANTED;
                 }
             } else {
                 HashSet<String> perms = mSystemPermissions.get(uid);
@@ -1849,7 +1842,7 @@
                             // was created, we need to clear it and re-ask the
                             // user their preference.
                             if (!pa.sameSet(query, priority)) {
-                                Log.i(TAG, "Result set changed, dropping preferred activity for "
+                                Slog.i(TAG, "Result set changed, dropping preferred activity for "
                                         + intent + " type " + resolvedType);
                                 mSettings.mPreferredActivities.removeFilter(pa);
                                 return null;
@@ -2316,7 +2309,7 @@
             if (pkg == null && (flags & PackageParser.PARSE_IS_SYSTEM) == 0 &&
                     mLastScanError == PackageManager.INSTALL_FAILED_INVALID_APK) {
                 // Delete the apk
-                Log.w(TAG, "Cleaning up failed install of " + file);
+                Slog.w(TAG, "Cleaning up failed install of " + file);
                 file.delete();
             }
         }
@@ -2344,7 +2337,7 @@
                     -1, -1);
         } catch (java.io.IOException e) {
         }
-        Log.println(priority, TAG, msg);
+        Slog.println(priority, TAG, msg);
     }
 
     private boolean collectCertificatesLI(PackageParser pp, PackageSetting ps,
@@ -2424,7 +2417,7 @@
                         // Just remove the loaded entries from package lists.
                         mPackages.remove(ps.name);
                     }
-                    Log.w(TAG, "Package " + ps.name + " at " + scanFile
+                    Slog.w(TAG, "Package " + ps.name + " at " + scanFile
                             + "reverting from " + ps.codePathString
                             + ": new version " + pkg.mVersionCode
                             + " better than installed " + ps.versionCode);
@@ -2440,7 +2433,7 @@
         }
         // Verify certificates against what was last scanned
         if (!collectCertificatesLI(pp, ps, pkg, scanFile, parseFlags)) {
-            Log.i(TAG, "Failed verifying certificates for package:" + pkg.packageName);
+            Slog.w(TAG, "Failed verifying certificates for package:" + pkg.packageName);
             return null;
         }
         // The apk is forward locked (not public) if its code and resources
@@ -2457,7 +2450,7 @@
                 resPath = ps.resourcePathString;
             } else {
                 // Should not happen at all. Just log an error.
-                Log.e(TAG, "Resource path not set for pkg : " + pkg.packageName);
+                Slog.e(TAG, "Resource path not set for pkg : " + pkg.packageName);
             }
         } else {
             resPath = pkg.mScanPath;
@@ -2489,7 +2482,7 @@
         if (pkg.mSignatures != null) {
             if (!pkgSetting.signatures.updateSignatures(pkg.mSignatures,
                     updateSignature)) {
-                Log.e(TAG, "Package " + pkg.packageName
+                Slog.e(TAG, "Package " + pkg.packageName
                         + " signatures do not match the previously installed version; ignoring!");
                 mLastScanError = PackageManager.INSTALL_FAILED_UPDATE_INCOMPATIBLE;
                 return false;
@@ -2498,7 +2491,7 @@
             if (pkgSetting.sharedUser != null) {
                 if (!pkgSetting.sharedUser.signatures.mergeSignatures(
                         pkg.mSignatures, updateSignature)) {
-                    Log.e(TAG, "Package " + pkg.packageName
+                    Slog.e(TAG, "Package " + pkg.packageName
                             + " has no signatures that match those in shared user "
                             + pkgSetting.sharedUser.name + "; ignoring!");
                     mLastScanError = PackageManager.INSTALL_FAILED_SHARED_USER_INCOMPATIBLE;
@@ -2545,10 +2538,10 @@
                     performed = true;
                 }
             } catch (FileNotFoundException e) {
-                Log.w(TAG, "Apk not found for dexopt: " + path);
+                Slog.w(TAG, "Apk not found for dexopt: " + path);
                 ret = -1;
             } catch (IOException e) {
-                Log.w(TAG, "Exception reading apk: " + path, e);
+                Slog.w(TAG, "Exception reading apk: " + path, e);
                 ret = -1;
             }
             if (ret < 0) {
@@ -2567,12 +2560,12 @@
     
     private boolean verifyPackageUpdate(PackageSetting oldPkg, PackageParser.Package newPkg) {
         if ((oldPkg.pkgFlags&ApplicationInfo.FLAG_SYSTEM) == 0) {
-            Log.w(TAG, "Unable to update from " + oldPkg.name
+            Slog.w(TAG, "Unable to update from " + oldPkg.name
                     + " to " + newPkg.packageName
                     + ": old package not in system partition");
             return false;
         } else if (mPackages.get(oldPkg.name) != null) {
-            Log.w(TAG, "Unable to update from " + oldPkg.name
+            Slog.w(TAG, "Unable to update from " + oldPkg.name
                     + " to " + newPkg.packageName
                     + ": old package still exists");
             return false;
@@ -2597,7 +2590,7 @@
         if (scanFile == null || pkg.applicationInfo.sourceDir == null ||
                 pkg.applicationInfo.publicSourceDir == null) {
             // Bail out. The resource and code paths haven't been set.
-            Log.w(TAG, " Code and resource paths haven't been set correctly");
+            Slog.w(TAG, " Code and resource paths haven't been set correctly");
             mLastScanError = PackageManager.INSTALL_FAILED_INVALID_APK;
             return null;
         }
@@ -2614,10 +2607,10 @@
         if (pkg.packageName.equals("android")) {
             synchronized (mPackages) {
                 if (mAndroidApplication != null) {
-                    Log.w(TAG, "*************************************************");
-                    Log.w(TAG, "Core android package being redefined.  Skipping.");
-                    Log.w(TAG, " file=" + mScanningPath);
-                    Log.w(TAG, "*************************************************");
+                    Slog.w(TAG, "*************************************************");
+                    Slog.w(TAG, "Core android package being redefined.  Skipping.");
+                    Slog.w(TAG, " file=" + mScanningPath);
+                    Slog.w(TAG, "*************************************************");
                     mLastScanError = PackageManager.INSTALL_FAILED_DUPLICATE_PACKAGE;
                     return null;
                 }
@@ -2649,10 +2642,10 @@
                 TAG, "Scanning package " + pkg.packageName);
         if (mPackages.containsKey(pkg.packageName)
                 || mSharedLibraries.containsKey(pkg.packageName)) {
-            Log.w(TAG, "*************************************************");
-            Log.w(TAG, "Application package " + pkg.packageName
+            Slog.w(TAG, "*************************************************");
+            Slog.w(TAG, "Application package " + pkg.packageName
                     + " already installed.  Skipping duplicate.");
-            Log.w(TAG, "*************************************************");
+            Slog.w(TAG, "*************************************************");
             mLastScanError = PackageManager.INSTALL_FAILED_DUPLICATE_PACKAGE;
             return null;
         }
@@ -2685,7 +2678,7 @@
                 for (int i=0; i<N; i++) {
                     String file = mSharedLibraries.get(pkg.usesLibraries.get(i));
                     if (file == null) {
-                        Log.e(TAG, "Package " + pkg.packageName
+                        Slog.e(TAG, "Package " + pkg.packageName
                                 + " requires unavailable shared library "
                                 + pkg.usesLibraries.get(i) + "; failing!");
                         mLastScanError = PackageManager.INSTALL_FAILED_MISSING_SHARED_LIBRARY;
@@ -2698,7 +2691,7 @@
                 for (int i=0; i<N; i++) {
                     String file = mSharedLibraries.get(pkg.usesOptionalLibraries.get(i));
                     if (file == null) {
-                        Log.w(TAG, "Package " + pkg.packageName
+                        Slog.w(TAG, "Package " + pkg.packageName
                                 + " desires unavailable shared library "
                                 + pkg.usesOptionalLibraries.get(i) + "; ignoring!");
                     } else {
@@ -2723,7 +2716,7 @@
 
                         if (fi.name != null) {
                             if (mAvailableFeatures.get(fi.name) == null) {
-                                Log.e(TAG, "Package " + pkg.packageName
+                                Slog.e(TAG, "Package " + pkg.packageName
                                         + " requires unavailable feature "
                                         + fi.name + "; failing!");
                                 mLastScanError = PackageManager.INSTALL_FAILED_MISSING_FEATURE;
@@ -2738,7 +2731,7 @@
                 suid = mSettings.getSharedUserLP(pkg.mSharedUserId,
                         pkg.applicationInfo.flags, true);
                 if (suid == null) {
-                    Log.w(TAG, "Creating application package " + pkg.packageName
+                    Slog.w(TAG, "Creating application package " + pkg.packageName
                             + " for shared user failed");
                     mLastScanError = PackageManager.INSTALL_FAILED_INSUFFICIENT_STORAGE;
                     return null;
@@ -2791,7 +2784,7 @@
                             } else if (origPackage.sharedUser != null) {
                                 // Make sure uid is compatible between packages.
                                 if (!origPackage.sharedUser.name.equals(pkg.mSharedUserId)) {
-                                    Log.w(TAG, "Unable to migrate data from " + origPackage.name
+                                    Slog.w(TAG, "Unable to migrate data from " + origPackage.name
                                             + " to " + pkg.packageName + ": old uid "
                                             + origPackage.sharedUser.name
                                             + " differs from " + pkg.mSharedUserId);
@@ -2809,7 +2802,7 @@
             }
             
             if (mTransferedPackages.contains(pkg.packageName)) {
-                Log.w(TAG, "Package " + pkg.packageName
+                Slog.w(TAG, "Package " + pkg.packageName
                         + " was transferred to another, but its .apk remains");
             }
             
@@ -2818,7 +2811,7 @@
             pkgSetting = mSettings.getPackageLP(pkg, origPackage, realName, suid, destCodeFile,
                             destResourceFile, pkg.applicationInfo.flags, true, false);
             if (pkgSetting == null) {
-                Log.w(TAG, "Creating application package " + pkg.packageName + " failed");
+                Slog.w(TAG, "Creating application package " + pkg.packageName + " failed");
                 mLastScanError = PackageManager.INSTALL_FAILED_INSUFFICIENT_STORAGE;
                 return null;
             }
@@ -2892,7 +2885,7 @@
                         for (int j = 0; j < names.length; j++) {
                             if (mProviders.containsKey(names[j])) {
                                 PackageParser.Provider other = mProviders.get(names[j]);
-                                Log.w(TAG, "Can't install because provider name " + names[j] +
+                                Slog.w(TAG, "Can't install because provider name " + names[j] +
                                         " (in package " + pkg.applicationInfo.packageName +
                                         ") is already used by "
                                         + ((other != null && other.getComponentName() != null)
@@ -2920,7 +2913,7 @@
                     return null;
                 }
             }
-            Log.w(TAG, "System package " + pkg.packageName
+            Slog.w(TAG, "System package " + pkg.packageName
                     + " signature changed: existing data removed.");
             mLastScanError = PackageManager.INSTALL_SUCCEEDED;
         }
@@ -2933,7 +2926,7 @@
                 PackageSetting orig = mSettings.peekPackageLP(origName);
                 if (orig != null) {
                     if (verifyPackageUpdate(orig, pkg)) {
-                        Log.i(TAG, "Adopting permissions from "
+                        Slog.i(TAG, "Adopting permissions from "
                                 + origName + " to " + pkg.packageName);
                         mSettings.transferPermissions(origName, pkg.packageName);
                     }
@@ -3043,7 +3036,7 @@
                 if (dataPath.exists()) {
                     pkg.applicationInfo.dataDir = dataPath.getPath();
                 } else {
-                    Log.w(TAG, "Unable to create data directory: " + dataPath);
+                    Slog.w(TAG, "Unable to create data directory: " + dataPath);
                     pkg.applicationInfo.dataDir = null;
                 }
             }
@@ -3136,7 +3129,7 @@
                                         ", isSyncable = " + p.info.isSyncable);
                         } else {
                             PackageParser.Provider other = mProviders.get(names[j]);
-                            Log.w(TAG, "Skipping provider name " + names[j] +
+                            Slog.w(TAG, "Skipping provider name " + names[j] +
                                     " (in package " + pkg.applicationInfo.packageName +
                                     "): name already used by "
                                     + ((other != null && other.getComponentName() != null)
@@ -3233,7 +3226,7 @@
                         r.append(pg.info.name);
                     }
                 } else {
-                    Log.w(TAG, "Permission group " + pg.info.name + " from package "
+                    Slog.w(TAG, "Permission group " + pg.info.name + " from package "
                             + pg.info.packageName + " ignored: original from "
                             + cur.info.packageName);
                     if ((parseFlags&PackageParser.PARSE_CHATTY) != 0) {
@@ -3283,13 +3276,13 @@
                                     r.append(p.info.name);
                                 }
                             } else {
-                                Log.w(TAG, "Permission " + p.info.name + " from package "
+                                Slog.w(TAG, "Permission " + p.info.name + " from package "
                                         + p.info.packageName + " ignored: base tree "
                                         + tree.name + " is from package "
                                         + tree.sourcePackage);
                             }
                         } else {
-                            Log.w(TAG, "Permission " + p.info.name + " from package "
+                            Slog.w(TAG, "Permission " + p.info.name + " from package "
                                     + p.info.packageName + " ignored: original from "
                                     + bp.sourcePackage);
                         }
@@ -3303,7 +3296,7 @@
                         r.append(p.info.name);
                     }
                 } else {
-                    Log.w(TAG, "Permission " + p.info.name + " from package "
+                    Slog.w(TAG, "Permission " + p.info.name + " from package "
                             + p.info.packageName + " ignored: no group "
                             + p.group);
                 }
@@ -3546,7 +3539,7 @@
                 }
 
                 if (result == PACKAGE_INSTALL_NATIVE_ABI_MISMATCH) {
-                    Log.w(TAG,"Native ABI mismatch from package file");
+                    Slog.w(TAG,"Native ABI mismatch from package file");
                     return PackageManager.INSTALL_FAILED_INVALID_APK;
                 }
 
@@ -3565,10 +3558,10 @@
                 }
             }
         } catch (ZipException e) {
-            Log.w(TAG, "Failed to extract data from package file", e);
+            Slog.w(TAG, "Failed to extract data from package file", e);
             return PackageManager.INSTALL_FAILED_INVALID_APK;
         } catch (IOException e) {
-            Log.w(TAG, "Failed to cache package shared libs", e);
+            Slog.w(TAG, "Failed to cache package shared libs", e);
             return PackageManager.INSTALL_FAILED_INSUFFICIENT_STORAGE;
         }
         return PackageManager.INSTALL_SUCCEEDED;
@@ -3781,7 +3774,7 @@
         while (it.hasNext()) {
             BasePermission bp = it.next();
             if (bp.perm == null) {
-                Log.w(TAG, "Removing dangling permission tree: " + bp.name
+                Slog.w(TAG, "Removing dangling permission tree: " + bp.name
                         + " from package " + bp.sourcePackage);
                 it.remove();
             }
@@ -3808,7 +3801,7 @@
                 }
             }
             if (bp.perm == null) {
-                Log.w(TAG, "Removing dangling permission: " + bp.name
+                Slog.w(TAG, "Removing dangling permission: " + bp.name
                         + " from package " + bp.sourcePackage);
                 it.remove();
             }
@@ -3920,19 +3913,19 @@
                             gp.gids = appendInts(gp.gids, bp.gids);
                         }
                     } else {
-                        Log.w(TAG, "Not granting permission " + perm
+                        Slog.w(TAG, "Not granting permission " + perm
                                 + " to package " + pkg.packageName
                                 + " because it was previously installed without");
                     }
                 } else {
-                    Log.w(TAG, "Not granting permission " + perm
+                    Slog.w(TAG, "Not granting permission " + perm
                             + " to package " + pkg.packageName
                             + " (protectionLevel=" + p.info.protectionLevel
                             + " flags=0x" + Integer.toHexString(pkg.applicationInfo.flags)
                             + ")");
                 }
             } else {
-                Log.w(TAG, "Unknown permission " + name
+                Slog.w(TAG, "Unknown permission " + name
                         + " in package " + pkg.packageName);
             }
         }
@@ -4501,11 +4494,11 @@
                         } catch (RemoteException e) {
                             // can't happen; the backup manager is local
                         } catch (Exception e) {
-                            Log.e(TAG, "Exception trying to enqueue restore", e);
+                            Slog.e(TAG, "Exception trying to enqueue restore", e);
                             doRestore = false;
                         }
                     } else {
-                        Log.e(TAG, "Backup Manager not found!");
+                        Slog.e(TAG, "Backup Manager not found!");
                         doRestore = false;
                     }
                 }
@@ -4529,7 +4522,7 @@
                 if (DEBUG_SD_INSTALL) Log.i(TAG, "startCopy");
                 retry++;
                 if (retry > MAX_RETRIES) {
-                    Log.w(TAG, "Failed to invoke remote methods on default container service. Giving up");
+                    Slog.w(TAG, "Failed to invoke remote methods on default container service. Giving up");
                     mHandler.sendEmptyMessage(MCS_GIVE_UP);
                     handleServiceError();
                     return;
@@ -4582,7 +4575,7 @@
                         // Check for updated system application.
                         if ((pkg.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
                             if (onSd) {
-                                Log.w(TAG, "Cannot install update to system app on sdcard");
+                                Slog.w(TAG, "Cannot install update to system app on sdcard");
                                 return PackageHelper.RECOMMEND_FAILED_INVALID_LOCATION;
                             }
                             return PackageHelper.RECOMMEND_INSTALL_INTERNAL;
@@ -4626,7 +4619,7 @@
             boolean onSd = (flags & PackageManager.INSTALL_EXTERNAL) != 0;
             // Dont need to invoke getInstallLocation for forward locked apps.
             if (fwdLocked && onSd) {
-                Log.w(TAG, "Cannot install fwd locked apps on sdcard");
+                Slog.w(TAG, "Cannot install fwd locked apps on sdcard");
                 ret = PackageManager.INSTALL_FAILED_INVALID_INSTALL_LOCATION;
             } else {
                 // Remote call to find out default install location
@@ -4847,7 +4840,7 @@
                         return PackageManager.INSTALL_FAILED_INSUFFICIENT_STORAGE;
                     }
                 } catch (IOException e) {
-                   Log.w(TAG, "Failed to create file " + codeFile);
+                   Slog.w(TAG, "Failed to create file " + codeFile);
                    return PackageManager.INSTALL_FAILED_INSUFFICIENT_STORAGE;
                 }
             }
@@ -4856,7 +4849,7 @@
             out = ParcelFileDescriptor.open(codeFile,
                     ParcelFileDescriptor.MODE_READ_WRITE);
             } catch (FileNotFoundException e) {
-                Log.e(TAG, "Failed to create file descritpor for : " + codeFileName);
+                Slog.e(TAG, "Failed to create file descritpor for : " + codeFileName);
                 return PackageManager.INSTALL_FAILED_INSUFFICIENT_STORAGE;
             }
             // Copy the resource now
@@ -4930,7 +4923,7 @@
             if (sourceDir != null) {
                 File sourceFile = new File(sourceDir);
                 if (!sourceFile.exists()) {
-                    Log.w(TAG, "Package source " + sourceDir + " does not exist.");
+                    Slog.w(TAG, "Package source " + sourceDir + " does not exist.");
                     ret = false;
                 }
                 // Delete application's code and resources
@@ -4939,7 +4932,7 @@
             if (publicSourceDir != null && !publicSourceDir.equals(sourceDir)) {
                 final File publicSourceFile = new File(publicSourceDir);
                 if (!publicSourceFile.exists()) {
-                    Log.w(TAG, "Package public source " + publicSourceFile + " does not exist.");
+                    Slog.w(TAG, "Package public source " + publicSourceFile + " does not exist.");
                 }
                 if (publicSourceFile.exists()) {
                     publicSourceFile.delete();
@@ -4953,7 +4946,7 @@
             if (cleanUp() && mInstaller != null) {
                 int retCode = mInstaller.rmdex(sourceDir);
                 if (retCode < 0) {
-                    Log.w(TAG, "Couldn't remove dex file for package: "
+                    Slog.w(TAG, "Couldn't remove dex file for package: "
                             +  " at location "
                             + sourceDir + ", retcode=" + retCode);
                     // we don't consider this to be a failure of the core package deletion
@@ -4969,7 +4962,7 @@
                     |FileUtils.S_IROTH;
                 int retCode = FileUtils.setPermissions(getCodePath(), filePermissions, -1, -1);
                 if (retCode != 0) {
-                    Log.e(TAG, "Couldn't set new package file permissions for " +
+                    Slog.e(TAG, "Couldn't set new package file permissions for " +
                             getCodePath()
                             + ". The return code was: " + retCode);
                     // TODO Define new internal error
@@ -5064,23 +5057,23 @@
             if (PackageHelper.isContainerMounted(cid)) {
                 // Unmount the container
                 if (!PackageHelper.unMountSdDir(cid)) {
-                    Log.i(TAG, "Failed to unmount " + cid + " before renaming");
+                    Slog.i(TAG, "Failed to unmount " + cid + " before renaming");
                     return false;
                 }
             }
             if (!PackageHelper.renameSdDir(cid, newCacheId)) {
-                Log.e(TAG, "Failed to rename " + cid + " to " + newCacheId);
+                Slog.e(TAG, "Failed to rename " + cid + " to " + newCacheId);
                 return false;
             }
             if (!PackageHelper.isContainerMounted(newCacheId)) {
-                Log.w(TAG, "Mounting container " + newCacheId);
+                Slog.w(TAG, "Mounting container " + newCacheId);
                 newCachePath = PackageHelper.mountSdDir(newCacheId,
                         getEncryptKey(), Process.SYSTEM_UID);
             } else {
                 newCachePath = PackageHelper.getSdDir(newCacheId);
             }
             if (newCachePath == null) {
-                Log.w(TAG, "Failed to get cache path for  " + newCacheId);
+                Slog.w(TAG, "Failed to get cache path for  " + newCacheId);
                 return false;
             }
             Log.i(TAG, "Succesfully renamed " + cid +
@@ -5115,7 +5108,7 @@
             if (mInstaller != null) {
                 int retCode = mInstaller.rmdex(sourceFile.toString());
                 if (retCode < 0) {
-                    Log.w(TAG, "Couldn't remove dex file for package: "
+                    Slog.w(TAG, "Couldn't remove dex file for package: "
                             + " at location "
                             + sourceFile.toString() + ", retcode=" + retCode);
                     // we don't consider this to be a failure of the core package deletion
@@ -5218,7 +5211,7 @@
         if (eidx == -1) {
             eidx = codePath.length();
         } else if (eidx == 0) {
-            Log.w(TAG, " Invalid code path, "+ codePath + " Not a valid apk name");
+            Slog.w(TAG, " Invalid code path, "+ codePath + " Not a valid apk name");
             return null;
         }
         return codePath.substring(sidx+1, eidx);
@@ -5247,7 +5240,7 @@
         synchronized(mPackages) {
             if (mPackages.containsKey(pkgName) || mAppDirs.containsKey(pkg.mPath)) {
                 // Don't allow installation over an existing package with the same name.
-                Log.w(TAG, "Attempt to re-install " + pkgName
+                Slog.w(TAG, "Attempt to re-install " + pkgName
                         + " without first uninstalling.");
                 res.returnCode = PackageManager.INSTALL_FAILED_ALREADY_EXISTS;
                 return;
@@ -5256,7 +5249,7 @@
         mLastScanError = PackageManager.INSTALL_SUCCEEDED;
         PackageParser.Package newPackage = scanPackageLI(pkg, parseFlags, scanMode);
         if (newPackage == null) {
-            Log.w(TAG, "Package couldn't be installed in " + pkg.mPath);
+            Slog.w(TAG, "Package couldn't be installed in " + pkg.mPath);
             if ((res.returnCode=mLastScanError) == PackageManager.INSTALL_SUCCEEDED) {
                 res.returnCode = PackageManager.INSTALL_FAILED_INVALID_APK;
             }
@@ -5329,7 +5322,7 @@
             mLastScanError = PackageManager.INSTALL_SUCCEEDED;
             newPackage = scanPackageLI(pkg, parseFlags, scanMode);
             if (newPackage == null) {
-                Log.w(TAG, "Package couldn't be installed in " + pkg.mPath);
+                Slog.w(TAG, "Package couldn't be installed in " + pkg.mPath);
                 if ((res.returnCode=mLastScanError) == PackageManager.INSTALL_SUCCEEDED) {
                     res.returnCode = PackageManager.INSTALL_FAILED_INVALID_APK;
                 }
@@ -5370,7 +5363,7 @@
             if(deletedPkg) {
                 File restoreFile = new File(deletedPackage.mPath);
                 if (restoreFile == null) {
-                    Log.e(TAG, "Failed allocating storage when restoring pkg : " + pkgName);
+                    Slog.e(TAG, "Failed allocating storage when restoring pkg : " + pkgName);
                     return;
                 }
                 PackageInstalledInfo restoreRes = new PackageInstalledInfo();
@@ -5383,7 +5376,7 @@
                     mSettings.writeLP();
                 }
                 if (restoreRes.returnCode != PackageManager.INSTALL_SUCCEEDED) {
-                    Log.e(TAG, "Failed restoring pkg : " + pkgName + " after failed upgrade");
+                    Slog.e(TAG, "Failed restoring pkg : " + pkgName + " after failed upgrade");
                 }
             }
         }
@@ -5400,7 +5393,7 @@
         String packageName = deletedPackage.packageName;
         res.returnCode = PackageManager.INSTALL_FAILED_REPLACE_COULDNT_DELETE;
         if (packageName == null) {
-            Log.w(TAG, "Attempt to delete null packageName.");
+            Slog.w(TAG, "Attempt to delete null packageName.");
             return;
         }
         PackageParser.Package oldPkg;
@@ -5410,7 +5403,7 @@
             oldPkgSetting = mSettings.mPackages.get(packageName);
             if((oldPkg == null) || (oldPkg.applicationInfo == null) ||
                     (oldPkgSetting == null)) {
-                Log.w(TAG, "Couldn't find package:"+packageName+" information");
+                Slog.w(TAG, "Couldn't find package:"+packageName+" information");
                 return;
             }
         }
@@ -5427,7 +5420,7 @@
         pkg.applicationInfo.flags |= ApplicationInfo.FLAG_UPDATED_SYSTEM_APP;
         newPackage = scanPackageLI(pkg, parseFlags, scanMode);
         if (newPackage == null) {
-            Log.w(TAG, "Package couldn't be installed in " + pkg.mPath);
+            Slog.w(TAG, "Package couldn't be installed in " + pkg.mPath);
             if ((res.returnCode=mLastScanError) == PackageManager.INSTALL_SUCCEEDED) {
                 res.returnCode = PackageManager.INSTALL_FAILED_INVALID_APK;
             }
@@ -5472,7 +5465,7 @@
         if ((newPackage.applicationInfo.flags&ApplicationInfo.FLAG_HAS_CODE) != 0) {
             retCode = mInstaller.movedex(newPackage.mScanPath, newPackage.mPath);
             if (retCode != 0) {
-                Log.e(TAG, "Couldn't rename dex file: " + newPackage.mPath);
+                Slog.e(TAG, "Couldn't rename dex file: " + newPackage.mPath);
                 return PackageManager.INSTALL_FAILED_INSUFFICIENT_STORAGE;
             }
         }
@@ -5590,7 +5583,7 @@
 
         if (systemApp && onSd) {
             // Disable updates to system apps on sdcard
-            Log.w(TAG, "Cannot install updates to system apps on sdcard");
+            Slog.w(TAG, "Cannot install updates to system apps on sdcard");
             res.returnCode = PackageManager.INSTALL_FAILED_INVALID_INSTALL_LOCATION;
             return;
         }
@@ -5621,7 +5614,7 @@
             try {
                 extractPublicFiles(newPackage, destResourceFile);
             } catch (IOException e) {
-                Log.e(TAG, "Couldn't create a new zip file for the public parts of a" +
+                Slog.e(TAG, "Couldn't create a new zip file for the public parts of a" +
                            " forward-locked app.");
                 return PackageManager.INSTALL_FAILED_INSUFFICIENT_STORAGE;
             } finally {
@@ -5642,7 +5635,7 @@
         }
 
         if (retCode != 0) {
-            Log.e(TAG, "Couldn't set new package file permissions for " +
+            Slog.e(TAG, "Couldn't set new package file permissions for " +
                     newPackage.mPath
                        + ". The return code was: " + retCode);
             // TODO Define new internal error
@@ -5734,7 +5727,7 @@
         try {
             tmpPackageFile = File.createTempFile("vmdl", ".tmp", installDir);
         } catch (IOException e) {
-            Log.e(TAG, "Couldn't create temp file for downloaded package file.");
+            Slog.e(TAG, "Couldn't create temp file for downloaded package file.");
             return null;
         }
         try {
@@ -5742,7 +5735,7 @@
                     tmpPackageFile.getCanonicalPath(), FileUtils.S_IRUSR|FileUtils.S_IWUSR,
                     -1, -1);
         } catch (IOException e) {
-            Log.e(TAG, "Trouble getting the canoncical path for a temp file.");
+            Slog.e(TAG, "Trouble getting the canoncical path for a temp file.");
             return null;
         }
         return tmpPackageFile;
@@ -5792,7 +5785,7 @@
                 ServiceManager.getService(Context.DEVICE_POLICY_SERVICE));
         try {
             if (dpm != null && dpm.packageHasActiveAdmins(packageName)) {
-                Log.w(TAG, "Not removing package " + packageName + ": has active device admin");
+                Slog.w(TAG, "Not removing package " + packageName + ": has active device admin");
                 return false;
             }
         } catch (RemoteException e) {
@@ -5876,7 +5869,7 @@
             if (mInstaller != null) {
                 int retCode = mInstaller.remove(packageName, useEncryptedFSDir);
                 if (retCode < 0) {
-                    Log.w(TAG, "Couldn't remove app data or cache directory for package: "
+                    Slog.w(TAG, "Couldn't remove app data or cache directory for package: "
                                + packageName + ", retcode=" + retCode);
                     // we don't consider this to be a failure of the core package deletion
                 }
@@ -5923,7 +5916,7 @@
         ApplicationInfo applicationInfo = p.applicationInfo;
         //applicable for non-partially installed applications only
         if (applicationInfo == null) {
-            Log.w(TAG, "Package " + p.packageName + " has no applicationInfo.");
+            Slog.w(TAG, "Package " + p.packageName + " has no applicationInfo.");
             return false;
         }
         PackageSetting ps = null;
@@ -5934,7 +5927,7 @@
             ps = mSettings.getDisabledSystemPkg(p.packageName);
         }
         if (ps == null) {
-            Log.w(TAG, "Attempt to delete system package "+ p.packageName);
+            Slog.w(TAG, "Attempt to delete system package "+ p.packageName);
             return false;
         } else {
             Log.i(TAG, "Deleting system pkg from data partition");
@@ -5968,7 +5961,7 @@
                 SCAN_MONITOR | SCAN_NO_PATHS);
 
         if (newPkg == null) {
-            Log.w(TAG, "Failed to restore system package:"+p.packageName+" with error:" + mLastScanError);
+            Slog.w(TAG, "Failed to restore system package:"+p.packageName+" with error:" + mLastScanError);
             return false;
         }
         synchronized (mPackages) {
@@ -5982,7 +5975,7 @@
             boolean deleteCodeAndResources, int flags, PackageRemovedInfo outInfo) {
         ApplicationInfo applicationInfo = p.applicationInfo;
         if (applicationInfo == null) {
-            Log.w(TAG, "Package " + p.packageName + " has no applicationInfo.");
+            Slog.w(TAG, "Package " + p.packageName + " has no applicationInfo.");
             return false;
         }
         if (outInfo != null) {
@@ -6011,7 +6004,7 @@
     private boolean deletePackageLI(String packageName,
             boolean deleteCodeAndResources, int flags, PackageRemovedInfo outInfo) {
         if (packageName == null) {
-            Log.w(TAG, "Attempt to delete null packageName.");
+            Slog.w(TAG, "Attempt to delete null packageName.");
             return false;
         }
         PackageParser.Package p;
@@ -6023,14 +6016,14 @@
                 dataOnly = true;
                 PackageSetting ps = mSettings.mPackages.get(packageName);
                 if (ps == null) {
-                    Log.w(TAG, "Package named '" + packageName +"' doesn't exist.");
+                    Slog.w(TAG, "Package named '" + packageName +"' doesn't exist.");
                     return false;
                 }
                 p = ps.pkg;
             }
         }
         if (p == null) {
-            Log.w(TAG, "Package named '" + packageName +"' doesn't exist.");
+            Slog.w(TAG, "Package named '" + packageName +"' doesn't exist.");
             return false;
         }
 
@@ -6041,7 +6034,7 @@
         }
         // At this point the package should have ApplicationInfo associated with it
         if (p.applicationInfo == null) {
-            Log.w(TAG, "Package " + p.packageName + " has no applicationInfo.");
+            Slog.w(TAG, "Package " + p.packageName + " has no applicationInfo.");
             return false;
         }
         boolean ret = false;
@@ -6092,7 +6085,7 @@
 
     private boolean clearApplicationUserDataLI(String packageName) {
         if (packageName == null) {
-            Log.w(TAG, "Attempt to delete null packageName.");
+            Slog.w(TAG, "Attempt to delete null packageName.");
             return false;
         }
         PackageParser.Package p;
@@ -6103,7 +6096,7 @@
                 dataOnly = true;
                 PackageSetting ps = mSettings.mPackages.get(packageName);
                 if((ps == null) || (ps.pkg == null)) {
-                    Log.w(TAG, "Package named '" + packageName +"' doesn't exist.");
+                    Slog.w(TAG, "Package named '" + packageName +"' doesn't exist.");
                     return false;
                 }
                 p = ps.pkg;
@@ -6114,12 +6107,12 @@
         if(!dataOnly) {
             //need to check this only for fully installed applications
             if (p == null) {
-                Log.w(TAG, "Package named '" + packageName +"' doesn't exist.");
+                Slog.w(TAG, "Package named '" + packageName +"' doesn't exist.");
                 return false;
             }
             final ApplicationInfo applicationInfo = p.applicationInfo;
             if (applicationInfo == null) {
-                Log.w(TAG, "Package " + packageName + " has no applicationInfo.");
+                Slog.w(TAG, "Package " + packageName + " has no applicationInfo.");
                 return false;
             }
             useEncryptedFSDir = useEncryptedFilesystemForPackage(p);
@@ -6127,7 +6120,7 @@
         if (mInstaller != null) {
             int retCode = mInstaller.clearUserData(packageName, useEncryptedFSDir);
             if (retCode < 0) {
-                Log.w(TAG, "Couldn't remove cache files for package: "
+                Slog.w(TAG, "Couldn't remove cache files for package: "
                         + packageName);
                 return false;
             }
@@ -6160,7 +6153,7 @@
 
     private boolean deleteApplicationCacheFilesLI(String packageName) {
         if (packageName == null) {
-            Log.w(TAG, "Attempt to delete null packageName.");
+            Slog.w(TAG, "Attempt to delete null packageName.");
             return false;
         }
         PackageParser.Package p;
@@ -6168,19 +6161,19 @@
             p = mPackages.get(packageName);
         }
         if (p == null) {
-            Log.w(TAG, "Package named '" + packageName +"' doesn't exist.");
+            Slog.w(TAG, "Package named '" + packageName +"' doesn't exist.");
             return false;
         }
         final ApplicationInfo applicationInfo = p.applicationInfo;
         if (applicationInfo == null) {
-            Log.w(TAG, "Package " + packageName + " has no applicationInfo.");
+            Slog.w(TAG, "Package " + packageName + " has no applicationInfo.");
             return false;
         }
         boolean useEncryptedFSDir = useEncryptedFilesystemForPackage(p);
         if (mInstaller != null) {
             int retCode = mInstaller.deleteCacheFiles(packageName, useEncryptedFSDir);
             if (retCode < 0) {
-                Log.w(TAG, "Couldn't remove cache files for package: "
+                Slog.w(TAG, "Couldn't remove cache files for package: "
                            + packageName);
                 return false;
             }
@@ -6214,7 +6207,7 @@
 
     private boolean getPackageSizeInfoLI(String packageName, PackageStats pStats) {
         if (packageName == null) {
-            Log.w(TAG, "Attempt to get size of null packageName.");
+            Slog.w(TAG, "Attempt to get size of null packageName.");
             return false;
         }
         PackageParser.Package p;
@@ -6225,7 +6218,7 @@
                 dataOnly = true;
                 PackageSetting ps = mSettings.mPackages.get(packageName);
                 if((ps == null) || (ps.pkg == null)) {
-                    Log.w(TAG, "Package named '" + packageName +"' doesn't exist.");
+                    Slog.w(TAG, "Package named '" + packageName +"' doesn't exist.");
                     return false;
                 }
                 p = ps.pkg;
@@ -6235,7 +6228,7 @@
         if(!dataOnly) {
             final ApplicationInfo applicationInfo = p.applicationInfo;
             if (applicationInfo == null) {
-                Log.w(TAG, "Package " + packageName + " has no applicationInfo.");
+                Slog.w(TAG, "Package " + packageName + " has no applicationInfo.");
                 return false;
             }
             publicSrcDir = isForwardLocked(p) ? applicationInfo.publicSourceDir : null;
@@ -6257,26 +6250,61 @@
     public void addPackageToPreferred(String packageName) {
         mContext.enforceCallingOrSelfPermission(
                 android.Manifest.permission.SET_PREFERRED_APPLICATIONS, null);
-        Log.w(TAG, "addPackageToPreferred: no longer implemented");
+        Slog.w(TAG, "addPackageToPreferred: no longer implemented");
     }
 
     public void removePackageFromPreferred(String packageName) {
         mContext.enforceCallingOrSelfPermission(
                 android.Manifest.permission.SET_PREFERRED_APPLICATIONS, null);
-        Log.w(TAG, "removePackageFromPreferred: no longer implemented");
+        Slog.w(TAG, "removePackageFromPreferred: no longer implemented");
     }
 
     public List<PackageInfo> getPreferredPackages(int flags) {
         return new ArrayList<PackageInfo>();
     }
 
+    int getUidTargetSdkVersionLockedLP(int uid) {
+        Object obj = mSettings.getUserIdLP(uid);
+        if (obj instanceof SharedUserSetting) {
+            SharedUserSetting sus = (SharedUserSetting)obj;
+            final int N = sus.packages.size();
+            int vers = Build.VERSION_CODES.CUR_DEVELOPMENT;
+            Iterator<PackageSetting> it = sus.packages.iterator();
+            int i=0;
+            while (it.hasNext()) {
+                PackageSetting ps = it.next();
+                if (ps.pkg != null) {
+                    int v = ps.pkg.applicationInfo.targetSdkVersion;
+                    if (v < vers) vers = v;
+                }
+            }
+            return vers;
+        } else if (obj instanceof PackageSetting) {
+            PackageSetting ps = (PackageSetting)obj;
+            if (ps.pkg != null) {
+                return ps.pkg.applicationInfo.targetSdkVersion;
+            }
+        }
+        return Build.VERSION_CODES.CUR_DEVELOPMENT;
+    }
+    
     public void addPreferredActivity(IntentFilter filter, int match,
             ComponentName[] set, ComponentName activity) {
-        mContext.enforceCallingOrSelfPermission(
-                android.Manifest.permission.SET_PREFERRED_APPLICATIONS, null);
-
         synchronized (mPackages) {
-            Log.i(TAG, "Adding preferred activity " + activity + ":");
+            if (mContext.checkCallingOrSelfPermission(
+                    android.Manifest.permission.SET_PREFERRED_APPLICATIONS)
+                    != PackageManager.PERMISSION_GRANTED) {
+                if (getUidTargetSdkVersionLockedLP(Binder.getCallingUid())
+                        < Build.VERSION_CODES.FROYO) {
+                    Slog.w(TAG, "Ignoring addPreferredActivity() from uid "
+                            + Binder.getCallingUid());
+                    return;
+                }
+                mContext.enforceCallingOrSelfPermission(
+                        android.Manifest.permission.SET_PREFERRED_APPLICATIONS, null);
+            }
+            
+            Slog.i(TAG, "Adding preferred activity " + activity + ":");
             filter.dump(new LogPrinter(Log.INFO, TAG), "  ");
             mSettings.mPreferredActivities.addFilter(
                     new PreferredActivity(filter, match, set, activity));
@@ -6286,8 +6314,6 @@
 
     public void replacePreferredActivity(IntentFilter filter, int match,
             ComponentName[] set, ComponentName activity) {
-        mContext.enforceCallingOrSelfPermission(
-                android.Manifest.permission.SET_PREFERRED_APPLICATIONS, null);
         if (filter.countActions() != 1) {
             throw new IllegalArgumentException(
                     "replacePreferredActivity expects filter to have only 1 action.");
@@ -6305,6 +6331,19 @@
                     "paths, schemes or types.");
         }
         synchronized (mPackages) {
+            if (mContext.checkCallingOrSelfPermission(
+                    android.Manifest.permission.SET_PREFERRED_APPLICATIONS)
+                    != PackageManager.PERMISSION_GRANTED) {
+                if (getUidTargetSdkVersionLockedLP(Binder.getCallingUid())
+                        < Build.VERSION_CODES.FROYO) {
+                    Slog.w(TAG, "Ignoring replacePreferredActivity() from uid "
+                            + Binder.getCallingUid());
+                    return;
+                }
+                mContext.enforceCallingOrSelfPermission(
+                        android.Manifest.permission.SET_PREFERRED_APPLICATIONS, null);
+            }
+            
             Iterator<PreferredActivity> it = mSettings.mPreferredActivities.filterIterator();
             String action = filter.getAction(0);
             String category = filter.getCategory(0);
@@ -6324,9 +6363,19 @@
         synchronized (mPackages) {
             int uid = Binder.getCallingUid();
             PackageParser.Package pkg = mPackages.get(packageName);
-            if (pkg.applicationInfo.uid != uid) {
-                mContext.enforceCallingOrSelfPermission(
-                        android.Manifest.permission.SET_PREFERRED_APPLICATIONS, null);
+            if (pkg == null || pkg.applicationInfo.uid != uid) {
+                if (mContext.checkCallingOrSelfPermission(
+                        android.Manifest.permission.SET_PREFERRED_APPLICATIONS)
+                        != PackageManager.PERMISSION_GRANTED) {
+                    if (getUidTargetSdkVersionLockedLP(Binder.getCallingUid())
+                            < Build.VERSION_CODES.FROYO) {
+                        Slog.w(TAG, "Ignoring clearPackagePreferredActivities() from uid "
+                                + Binder.getCallingUid());
+                        return;
+                    }
+                    mContext.enforceCallingOrSelfPermission(
+                            android.Manifest.permission.SET_PREFERRED_APPLICATIONS, null);
+                }
             }
 
             if (clearPackagePreferredActivitiesLP(packageName)) {
@@ -6433,7 +6482,7 @@
                     pkgSetting.restoreComponentLP(className);
                     break;
                 default:
-                    Log.e(TAG, "Invalid new component state: " + newState);
+                    Slog.e(TAG, "Invalid new component state: " + newState);
                     return;
                 }
             }
@@ -7669,12 +7718,12 @@
                         // This is an updated system app with versions in both system
                         // and data partition. Just let the most recent version
                         // take precedence.
-                        Log.w(TAG, "Trying to update system app code path from " +
+                        Slog.w(TAG, "Trying to update system app code path from " +
                                 p.codePathString + " to " + codePath.toString());
                     } else {
                         // Just a change in the code path is not an issue, but
                         // let's log a message about it.
-                        Log.i(TAG, "Package " + name + " codePath changed from " + p.codePath
+                        Slog.i(TAG, "Package " + name + " codePath changed from " + p.codePath
                                 + " to " + codePath + "; Retaining data and using new");
                     }
                 }
@@ -7707,7 +7756,11 @@
                             resourcePath, vc, pkgFlags);
                     if (DEBUG_UPGRADE) Log.v(TAG, "Package " + name
                             + " is adopting original package " + origPackage.name);
+                    // Note that we will retain the new package's signature so
+                    // that we can keep its data.
+                    PackageSignatures s = p.signatures;
                     p.copyFrom(origPackage);
+                    p.signatures = s;
                     p.sharedUser = origPackage.sharedUser;
                     p.userId = origPackage.userId;
                     p.origPackage = origPackage;
@@ -7769,14 +7822,14 @@
             String resourcePath = pkg.applicationInfo.publicSourceDir;
             // Update code path if needed
             if (!codePath.equalsIgnoreCase(p.codePathString)) {
-                Log.w(TAG, "Code path for pkg : " + p.pkg.packageName +
+                Slog.w(TAG, "Code path for pkg : " + p.pkg.packageName +
                         " changing from " + p.codePathString + " to " + codePath);
                 p.codePath = new File(codePath);
                 p.codePathString = codePath;
             }
             //Update resource path if needed
             if (!resourcePath.equalsIgnoreCase(p.resourcePathString)) {
-                Log.w(TAG, "Resource path for pkg : " + p.pkg.packageName +
+                Slog.w(TAG, "Resource path for pkg : " + p.pkg.packageName +
                         " changing from " + p.resourcePathString + " to " + resourcePath);
                 p.resourcePath = new File(resourcePath);
                 p.resourcePathString = resourcePath;
@@ -7824,7 +7877,7 @@
          */
         private void updateSharedUserPermsLP(PackageSetting deletedPs, int[] globalGids) {
             if ( (deletedPs == null) || (deletedPs.pkg == null)) {
-                Log.i(TAG, "Trying to update info for null package. Just ignoring");
+                Slog.i(TAG, "Trying to update info for null package. Just ignoring");
                 return;
             }
             // No sharedUserId
@@ -7956,11 +8009,11 @@
                 // might have been corrupted.
                 if (!mBackupSettingsFilename.exists()) {
                     if (!mSettingsFilename.renameTo(mBackupSettingsFilename)) {
-                        Log.w(TAG, "Unable to backup package manager settings, current changes will be lost at reboot");
+                        Slog.w(TAG, "Unable to backup package manager settings, current changes will be lost at reboot");
                         return;
                     }
                 } else {
-                    Log.w(TAG, "Preserving older settings backup");
+                    Slog.w(TAG, "Preserving older settings backup");
                 }
             }
 
@@ -8111,9 +8164,9 @@
                 return;
 
             } catch(XmlPullParserException e) {
-                Log.w(TAG, "Unable to write package manager settings, current changes will be lost at reboot", e);
+                Slog.w(TAG, "Unable to write package manager settings, current changes will be lost at reboot", e);
             } catch(java.io.IOException e) {
-                Log.w(TAG, "Unable to write package manager settings, current changes will be lost at reboot", e);
+                Slog.w(TAG, "Unable to write package manager settings, current changes will be lost at reboot", e);
             }
             // Clean up partially written files
             if (mSettingsFilename.exists()) {
@@ -8301,7 +8354,7 @@
                         // If both the backup and settings file exist, we
                         // ignore the settings since it might have been
                         // corrupted.
-                        Log.w(TAG, "Cleaning up settings file " + mSettingsFilename);
+                        Slog.w(TAG, "Cleaning up settings file " + mSettingsFilename);
                         mSettingsFilename.delete();
                     }
                 } catch (java.io.IOException e) {
@@ -8315,7 +8368,7 @@
                 if (str == null) {
                     if (!mSettingsFilename.exists()) {
                         mReadMessages.append("No settings file found\n");
-                        Log.i(TAG, "No current settings file!");
+                        Slog.i(TAG, "No current settings file!");
                         return false;
                     }
                     str = new FileInputStream(mSettingsFilename);
@@ -8331,7 +8384,7 @@
 
                 if (type != XmlPullParser.START_TAG) {
                     mReadMessages.append("No start tag found in settings file\n");
-                    Log.e(TAG, "No start tag found in package manager settings");
+                    Slog.e(TAG, "No start tag found in package manager settings");
                     return false;
                 }
 
@@ -8371,7 +8424,7 @@
                             mRenamedPackages.put(nname, oname);
                         }
                     } else {
-                        Log.w(TAG, "Unknown element under <packages>: "
+                        Slog.w(TAG, "Unknown element under <packages>: "
                               + parser.getName());
                         XmlUtils.skipCurrentTag(parser);
                     }
@@ -8381,11 +8434,11 @@
 
             } catch(XmlPullParserException e) {
                 mReadMessages.append("Error reading: " + e.toString());
-                Log.e(TAG, "Error reading package manager settings", e);
+                Slog.e(TAG, "Error reading package manager settings", e);
 
             } catch(java.io.IOException e) {
                 mReadMessages.append("Error reading: " + e.toString());
-                Log.e(TAG, "Error reading package manager settings", e);
+                Slog.e(TAG, "Error reading package manager settings", e);
 
             }
 
@@ -8398,7 +8451,7 @@
                             (SharedUserSetting)idObj, pp.codePath, pp.resourcePath,
                             pp.versionCode, pp.pkgFlags, true, true);
                     if (p == null) {
-                        Log.w(TAG, "Unable to create application package for "
+                        Slog.w(TAG, "Unable to create application package for "
                                 + pp.name);
                         continue;
                     }
@@ -8408,13 +8461,13 @@
                             + " has shared uid " + pp.sharedId
                             + " that is not a shared uid\n";
                     mReadMessages.append(msg);
-                    Log.e(TAG, msg);
+                    Slog.e(TAG, msg);
                 } else {
                     String msg = "Bad package setting: package " + pp.name
                             + " has shared uid " + pp.sharedId
                             + " that is not defined\n";
                     mReadMessages.append(msg);
-                    Log.e(TAG, msg);
+                    Slog.e(TAG, msg);
                 }
             }
             mPendingPackages.clear();
@@ -8996,13 +9049,13 @@
                 sdEncKey = SystemKeyStore.getInstance().
                         generateNewKeyHexString(128, mSdEncryptAlg, mSdEncryptKey);
                 if (sdEncKey == null) {
-                    Log.e(TAG, "Failed to create encryption keys");
+                    Slog.e(TAG, "Failed to create encryption keys");
                     return null;
                 }
             }
             return sdEncKey;
         } catch (NoSuchAlgorithmException nsae) {
-            Log.e(TAG, "Failed to create encryption keys with exception: " + nsae);
+            Slog.e(TAG, "Failed to create encryption keys with exception: " + nsae);
             return null;
         }
     }
@@ -9199,13 +9252,13 @@
                // Make sure there are no container errors first.
                if (args.doPreInstall(PackageManager.INSTALL_SUCCEEDED)
                        != PackageManager.INSTALL_SUCCEEDED) {
-                   Log.e(TAG, "Failed to mount cid : " + args.cid +
+                   Slog.e(TAG, "Failed to mount cid : " + args.cid +
                    " when installing from sdcard");
                    continue;
                }
                // Check code path here.
                if (codePath == null || !codePath.equals(args.getCodePath())) {
-                   Log.e(TAG, "Container " + args.cid + " cachepath " + args.getCodePath()+
+                   Slog.e(TAG, "Container " + args.cid + " cachepath " + args.getCodePath()+
                            " does not match one in settings " + codePath);
                    continue;
                }
@@ -9220,7 +9273,7 @@
                doGc = true;
                // Check for parse errors
                if (pkg == null) {
-                   Log.e(TAG, "Parse error when installing install pkg : "
+                   Slog.e(TAG, "Parse error when installing install pkg : "
                            + args.cid + " from " + args.cachePath);
                    continue;
                }
@@ -9239,7 +9292,7 @@
                            args.doPostInstall(PackageManager.INSTALL_SUCCEEDED);
                        }
                    } else {
-                       Log.i(TAG, "Failed to install pkg: " +
+                       Slog.i(TAG, "Failed to install pkg: " +
                                pkg.packageName + " from sdcard");
                    }
                }
@@ -9285,7 +9338,7 @@
                if (res) {
                    pkgList.add(pkgName);
                } else {
-                   Log.e(TAG, "Failed to delete pkg  from sdcard : " + pkgName);
+                   Slog.e(TAG, "Failed to delete pkg  from sdcard : " + pkgName);
                    failedList.add(args);
                }
            }
@@ -9322,17 +9375,17 @@
            // Disable moving fwd locked apps and system packages
            if (pkg.applicationInfo != null &&
                    (pkg.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
-               Log.w(TAG, "Cannot move system application");
+               Slog.w(TAG, "Cannot move system application");
                returnCode = PackageManager.MOVE_FAILED_SYSTEM_PACKAGE;
            } else if (pkg.applicationInfo != null &&
                    (pkg.applicationInfo.flags & ApplicationInfo.FLAG_FORWARD_LOCK) != 0) {
-               Log.w(TAG, "Cannot move forward locked app.");
+               Slog.w(TAG, "Cannot move forward locked app.");
                returnCode = PackageManager.MOVE_FAILED_FORWARD_LOCKED;
            } else {
                // Find install location first
                if ((flags & PackageManager.MOVE_EXTERNAL_MEDIA) != 0 &&
                        (flags & PackageManager.MOVE_INTERNAL) != 0) {
-                   Log.w(TAG, "Ambigous flags specified for move location.");
+                   Slog.w(TAG, "Ambigous flags specified for move location.");
                    returnCode = PackageManager.MOVE_FAILED_INVALID_LOCATION;
                } else {
                    newFlags = (flags & PackageManager.MOVE_EXTERNAL_MEDIA) != 0 ?
@@ -9340,7 +9393,7 @@
                    currFlags = (pkg.applicationInfo.flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) != 0 ?
                            PackageManager.INSTALL_EXTERNAL : 0;
                    if (newFlags == currFlags) {
-                       Log.w(TAG, "No move required. Trying to move to same location");
+                       Slog.w(TAG, "No move required. Trying to move to same location");
                        returnCode = PackageManager.MOVE_FAILED_INVALID_LOCATION;
                    }
                }
diff --git a/services/java/com/android/server/WallpaperManagerService.java b/services/java/com/android/server/WallpaperManagerService.java
index 1b51741..f4bdd1f 100644
--- a/services/java/com/android/server/WallpaperManagerService.java
+++ b/services/java/com/android/server/WallpaperManagerService.java
@@ -340,6 +340,12 @@
         final long ident = Binder.clearCallingIdentity();
         try {
             bindWallpaperComponentLocked(null);
+        } catch (IllegalArgumentException e) {
+            // This can happen if the default wallpaper component doesn't
+            // exist.  This should be a system configuration problem, but
+            // let's not let it crash the system and just live with no
+            // wallpaper.
+            Slog.e(TAG, "Default wallpaper component not found!", e);
         } finally {
             Binder.restoreCallingIdentity(ident);
         }
diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java
index 989fe2a..b27736a 100644
--- a/services/java/com/android/server/WindowManagerService.java
+++ b/services/java/com/android/server/WindowManagerService.java
@@ -47,6 +47,7 @@
 import com.android.internal.view.IInputContext;
 import com.android.internal.view.IInputMethodClient;
 import com.android.internal.view.IInputMethodManager;
+import com.android.internal.view.WindowManagerPolicyThread;
 import com.android.server.KeyInputQueue.QueuedEvent;
 import com.android.server.am.BatteryStatsService;
 
@@ -135,6 +136,7 @@
     static final boolean DEBUG_FOCUS = false;
     static final boolean DEBUG_ANIM = false;
     static final boolean DEBUG_LAYOUT = false;
+    static final boolean DEBUG_RESIZE = false;
     static final boolean DEBUG_LAYERS = false;
     static final boolean DEBUG_INPUT = false;
     static final boolean DEBUG_INPUT_METHOD = false;
@@ -558,6 +560,8 @@
 
         public void run() {
             Looper.prepare();
+            WindowManagerPolicyThread.set(this, Looper.myLooper());
+            
             //Looper.myLooper().setMessageLogging(new LogPrinter(
             //        Log.VERBOSE, "WindowManagerPolicy", Log.LOG_ID_SYSTEM));
             android.os.Process.setThreadPriority(
@@ -6911,6 +6915,12 @@
         final Rect mLastShownFrame = new Rect();
 
         /**
+         * Set when we have changed the size of the surface, to know that
+         * we must tell them application to resize (and thus redraw itself).
+         */
+        boolean mSurfaceResized;
+        
+        /**
          * Insets that determine the actually visible area
          */
         final Rect mVisibleInsets = new Rect();
@@ -10066,6 +10076,20 @@
                 final int attrFlags = attrs.flags;
 
                 if (w.mSurface != null) {
+                    // XXX NOTE: The logic here could be improved.  We have
+                    // the decision about whether to resize a window separated
+                    // from whether to hide the surface.  This can cause us to
+                    // resize a surface even if we are going to hide it.  You
+                    // can see this by (1) holding device in landscape mode on
+                    // home screen; (2) tapping browser icon (device will rotate
+                    // to landscape; (3) tap home.  The wallpaper will be resized
+                    // in step 2 but then immediately hidden, causing us to
+                    // have to resize and then redraw it again in step 3.  It
+                    // would be nice to figure out how to avoid this, but it is
+                    // difficult because we do need to resize surfaces in some
+                    // cases while they are hidden such as when first showing a
+                    // window.
+                    
                     w.computeShownFrameLocked();
                     if (localLOGV) Slog.v(
                             TAG, "Placing surface #" + i + " " + w.mSurface
@@ -10112,6 +10136,7 @@
                                         + w.mShownFrame.top + " SIZE "
                                         + w.mShownFrame.width() + "x"
                                         + w.mShownFrame.height(), null);
+                                w.mSurfaceResized = true;
                                 w.mSurface.setSize(width, height);
                                 w.mSurface.setPosition(w.mShownFrame.left,
                                         w.mShownFrame.top);
@@ -10144,6 +10169,7 @@
                         if (!w.mLastFrame.equals(w.mFrame)
                                 || w.mContentInsetsChanged
                                 || w.mVisibleInsetsChanged
+                                || w.mSurfaceResized
                                 || configChanged) {
                             w.mLastFrame.set(w.mFrame);
                             w.mLastContentInsets.set(w.mContentInsets);
@@ -10180,7 +10206,7 @@
                                     w.mAppToken.allDrawn = false;
                                 }
                             }
-                            if (DEBUG_ORIENTATION) Slog.v(TAG,
+                            if (DEBUG_RESIZE || DEBUG_ORIENTATION) Slog.v(TAG,
                                     "Resizing window " + w + " to " + w.mFrame);
                             mResizingWindows.add(w);
                         } else if (w.mOrientationChanging) {
@@ -10479,14 +10505,14 @@
                 i--;
                 WindowState win = mResizingWindows.get(i);
                 try {
-                    if (DEBUG_ORIENTATION) Slog.v(TAG, "Reporting new frame to "
-                            + win + ": " + win.mFrame);
+                    if (DEBUG_RESIZE || DEBUG_ORIENTATION) Slog.v(TAG,
+                            "Reporting new frame to " + win + ": " + win.mFrame);
                     boolean configChanged =
                         win.mConfiguration != mCurConfiguration
                         && (win.mConfiguration == null
                                 || mCurConfiguration.diff(win.mConfiguration) != 0);
                     win.mConfiguration = mCurConfiguration;
-                    if (DEBUG_ORIENTATION && configChanged) {
+                    if ((DEBUG_RESIZE || DEBUG_ORIENTATION) && configChanged) {
                         Slog.i(TAG, "Sending new config to window " + win + ": "
                                 + win.mFrame.width() + "x" + win.mFrame.height()
                                 + " / " + win.mConfiguration);
@@ -10497,6 +10523,7 @@
                             configChanged ? win.mConfiguration : null);
                     win.mContentInsetsChanged = false;
                     win.mVisibleInsetsChanged = false;
+                    win.mSurfaceResized = false;
                 } catch (RemoteException e) {
                     win.mOrientationChanging = false;
                 }
diff --git a/services/java/com/android/server/connectivity/Tethering.java b/services/java/com/android/server/connectivity/Tethering.java
index ebd3314..25f123c 100644
--- a/services/java/com/android/server/connectivity/Tethering.java
+++ b/services/java/com/android/server/connectivity/Tethering.java
@@ -36,6 +36,7 @@
 import android.os.Environment;
 import android.os.IBinder;
 import android.os.INetworkManagementService;
+import android.os.Looper;
 import android.os.Message;
 import android.os.RemoteException;
 import android.os.ServiceManager;
@@ -73,6 +74,8 @@
     private String[] mTetherableWifiRegexs;
     private String[] mUpstreamIfaceRegexs;
 
+    private Looper mLooper; // given to us at construction time..
+
     private HashMap<String, TetherInterfaceSM> mIfaces; // all tethered/tetherable ifaces
 
     private BroadcastReceiver mStateReceiver;
@@ -101,9 +104,10 @@
     private boolean mUsbMassStorageOff;  // track the status of USB Mass Storage
     private boolean mUsbConnected;       // track the status of USB connection
 
-    public Tethering(Context context) {
+    public Tethering(Context context, Looper looper) {
         Log.d(TAG, "Tethering starting");
         mContext = context;
+        mLooper = looper;
 
         // register for notifications from NetworkManagement Service
         IBinder b = ServiceManager.getService(Context.NETWORKMANAGEMENT_SERVICE);
@@ -116,7 +120,7 @@
 
         mIfaces = new HashMap<String, TetherInterfaceSM>();
 
-        mTetherMasterSM = new TetherMasterSM("TetherMaster");
+        mTetherMasterSM = new TetherMasterSM("TetherMaster", mLooper);
         mTetherMasterSM.start();
 
         // TODO - remove this hack after real USB connections are detected.
@@ -175,7 +179,7 @@
             TetherInterfaceSM sm = mIfaces.get(iface);
             if (link) {
                 if (sm == null) {
-                    sm = new TetherInterfaceSM(iface, usb);
+                    sm = new TetherInterfaceSM(iface, mLooper, usb);
                     mIfaces.put(iface, sm);
                     sm.start();
                 }
@@ -225,7 +229,7 @@
                 Log.e(TAG, "active iface (" + iface + ") reported as added, ignoring");
                 return;
             }
-            sm = new TetherInterfaceSM(iface, usb);
+            sm = new TetherInterfaceSM(iface, mLooper, usb);
             mIfaces.put(iface, sm);
             sm.start();
         }
@@ -639,8 +643,8 @@
         String mIfaceName;
         boolean mUsb;
 
-        TetherInterfaceSM(String name, boolean usb) {
-            super(name);
+        TetherInterfaceSM(String name, Looper looper, boolean usb) {
+            super(name, looper);
             mIfaceName = name;
             mUsb = usb;
             setLastError(ConnectivityManager.TETHER_ERROR_NO_ERROR);
@@ -1023,8 +1027,8 @@
         private static final int CELL_DISABLE_DUN_TIMEOUT_MS = 3000;
         private static final int CELL_DUN_RENEW_MS           = 40000;
 
-        TetherMasterSM(String name) {
-            super(name);
+        TetherMasterSM(String name, Looper looper) {
+            super(name, looper);
 
             //Add states
             mInitialState = new InitialState();
diff --git a/services/java/com/android/server/status/AnimatedImageView.java b/services/java/com/android/server/status/AnimatedImageView.java
index cd581c4..97df065 100644
--- a/services/java/com/android/server/status/AnimatedImageView.java
+++ b/services/java/com/android/server/status/AnimatedImageView.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2008 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.server.status;
 
 import android.content.Context;
diff --git a/services/java/com/android/server/status/CloseDragHandle.java b/services/java/com/android/server/status/CloseDragHandle.java
index fabf2ba5..ad1ac4d 100644
--- a/services/java/com/android/server/status/CloseDragHandle.java
+++ b/services/java/com/android/server/status/CloseDragHandle.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2008 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.server.status;
 
 import android.content.Context;
diff --git a/services/java/com/android/server/status/DateView.java b/services/java/com/android/server/status/DateView.java
index 3e54a6d..c04fb45 100644
--- a/services/java/com/android/server/status/DateView.java
+++ b/services/java/com/android/server/status/DateView.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2008 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.server.status;
 
 import android.content.BroadcastReceiver;
diff --git a/services/java/com/android/server/status/ExpandedView.java b/services/java/com/android/server/status/ExpandedView.java
index 7e66810..cb37f90 100644
--- a/services/java/com/android/server/status/ExpandedView.java
+++ b/services/java/com/android/server/status/ExpandedView.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2008 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.server.status;
 
 import android.content.Context;
diff --git a/services/java/com/android/server/status/FixedSizeDrawable.java b/services/java/com/android/server/status/FixedSizeDrawable.java
index 69a09d7..dbfcb2c 100644
--- a/services/java/com/android/server/status/FixedSizeDrawable.java
+++ b/services/java/com/android/server/status/FixedSizeDrawable.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2008 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.server.status;
 
 import android.graphics.drawable.Drawable;
diff --git a/services/java/com/android/server/status/IconData.java b/services/java/com/android/server/status/IconData.java
index adca375..fd226f9 100644
--- a/services/java/com/android/server/status/IconData.java
+++ b/services/java/com/android/server/status/IconData.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2008 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.server.status;
 
 import android.util.Slog;
diff --git a/services/java/com/android/server/status/IconMerger.java b/services/java/com/android/server/status/IconMerger.java
index 5b80638..aa702ae 100644
--- a/services/java/com/android/server/status/IconMerger.java
+++ b/services/java/com/android/server/status/IconMerger.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2008 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.server.status;
 
 import android.content.Context;
diff --git a/services/java/com/android/server/status/LatestItemView.java b/services/java/com/android/server/status/LatestItemView.java
index 6e7a9ce..fe8d164 100644
--- a/services/java/com/android/server/status/LatestItemView.java
+++ b/services/java/com/android/server/status/LatestItemView.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2008 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.server.status;
 
 import android.content.Context;
diff --git a/services/java/com/android/server/status/NotificationData.java b/services/java/com/android/server/status/NotificationData.java
index 784b781..71f01ca 100644
--- a/services/java/com/android/server/status/NotificationData.java
+++ b/services/java/com/android/server/status/NotificationData.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2008 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.server.status;
 
 import android.app.PendingIntent;
diff --git a/services/java/com/android/server/status/NotificationLinearLayout.java b/services/java/com/android/server/status/NotificationLinearLayout.java
index ac2e44d..2fdf956 100644
--- a/services/java/com/android/server/status/NotificationLinearLayout.java
+++ b/services/java/com/android/server/status/NotificationLinearLayout.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2008 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.server.status;
 
 import android.content.Context;
diff --git a/services/java/com/android/server/status/NotificationViewList.java b/services/java/com/android/server/status/NotificationViewList.java
index b9865a4..1598b68 100644
--- a/services/java/com/android/server/status/NotificationViewList.java
+++ b/services/java/com/android/server/status/NotificationViewList.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2008 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.server.status;
 
 import android.os.IBinder;
diff --git a/services/java/com/android/server/status/StatusBarException.java b/services/java/com/android/server/status/StatusBarException.java
index 8e93ca7..be58f59 100644
--- a/services/java/com/android/server/status/StatusBarException.java
+++ b/services/java/com/android/server/status/StatusBarException.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2008 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.server.status;
 
 public class StatusBarException extends RuntimeException {
diff --git a/services/java/com/android/server/status/StatusBarIcon.java b/services/java/com/android/server/status/StatusBarIcon.java
index c9e3b78..6f8b8a8 100644
--- a/services/java/com/android/server/status/StatusBarIcon.java
+++ b/services/java/com/android/server/status/StatusBarIcon.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2008 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.server.status;
 
 import android.content.Context;
diff --git a/services/java/com/android/server/status/StatusBarNotification.java b/services/java/com/android/server/status/StatusBarNotification.java
index 4636cba..e5773f7 100644
--- a/services/java/com/android/server/status/StatusBarNotification.java
+++ b/services/java/com/android/server/status/StatusBarNotification.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2008 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.server.status;
 
 import android.os.IBinder;
diff --git a/services/java/com/android/server/status/StatusBarView.java b/services/java/com/android/server/status/StatusBarView.java
index d12a3cf..2dd564e 100644
--- a/services/java/com/android/server/status/StatusBarView.java
+++ b/services/java/com/android/server/status/StatusBarView.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2008 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.server.status;
 
 import android.content.Context;
diff --git a/services/java/com/android/server/status/Ticker.java b/services/java/com/android/server/status/Ticker.java
index 6626c86..e47185b 100644
--- a/services/java/com/android/server/status/Ticker.java
+++ b/services/java/com/android/server/status/Ticker.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2008 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.server.status;
 
 import com.android.internal.R;
diff --git a/services/java/com/android/server/status/TickerView.java b/services/java/com/android/server/status/TickerView.java
index 349c7f4..099dffb 100644
--- a/services/java/com/android/server/status/TickerView.java
+++ b/services/java/com/android/server/status/TickerView.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright (C) 2008 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.server.status;
 
diff --git a/services/java/com/android/server/status/TrackingView.java b/services/java/com/android/server/status/TrackingView.java
index 886d66d..8ec39c0 100644
--- a/services/java/com/android/server/status/TrackingView.java
+++ b/services/java/com/android/server/status/TrackingView.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2008 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.server.status;
 
 import android.content.Context;
diff --git a/telephony/java/android/telephony/CellLocation.java b/telephony/java/android/telephony/CellLocation.java
index f763d3f..2edfc23 100644
--- a/telephony/java/android/telephony/CellLocation.java
+++ b/telephony/java/android/telephony/CellLocation.java
@@ -79,6 +79,11 @@
     public abstract void fillInNotifierBundle(Bundle bundle);
 
     /**
+     * @hide
+     */
+    public abstract boolean isEmpty();
+
+    /**
      * Return a new CellLocation object representing an unknown
      * location, or null for unknown/none phone radio types.
      *
diff --git a/telephony/java/android/telephony/PhoneStateListener.java b/telephony/java/android/telephony/PhoneStateListener.java
index 4f9cb2e4..830af47 100644
--- a/telephony/java/android/telephony/PhoneStateListener.java
+++ b/telephony/java/android/telephony/PhoneStateListener.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2008 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.telephony;
 
 import android.os.Bundle;
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index 6685c18..a6b1d93 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -203,7 +203,10 @@
     public CellLocation getCellLocation() {
         try {
             Bundle bundle = getITelephony().getCellLocation();
-            return CellLocation.newFromBundle(bundle);
+            CellLocation cl = CellLocation.newFromBundle(bundle);
+            if (cl.isEmpty())
+                return null;
+            return cl;
         } catch (RemoteException ex) {
             return null;
         } catch (NullPointerException ex) {
diff --git a/telephony/java/android/telephony/cdma/CdmaCellLocation.java b/telephony/java/android/telephony/cdma/CdmaCellLocation.java
index 2a0f8cd..84db830 100644
--- a/telephony/java/android/telephony/cdma/CdmaCellLocation.java
+++ b/telephony/java/android/telephony/cdma/CdmaCellLocation.java
@@ -204,6 +204,18 @@
         bundleToFill.putInt("networkId", this.mNetworkId);
     }
 
+    /**
+     * @hide
+     */
+    public boolean isEmpty() {
+        return (this.mBaseStationId == -1 &&
+                this.mBaseStationLatitude == INVALID_LAT_LONG &&
+                this.mBaseStationLongitude == INVALID_LAT_LONG &&
+                this.mSystemId == -1 &&
+                this.mNetworkId == -1);
+    }
+
+
 }
 
 
diff --git a/telephony/java/android/telephony/gsm/GsmCellLocation.java b/telephony/java/android/telephony/gsm/GsmCellLocation.java
index 0d4e0be..fa1f985 100644
--- a/telephony/java/android/telephony/gsm/GsmCellLocation.java
+++ b/telephony/java/android/telephony/gsm/GsmCellLocation.java
@@ -119,4 +119,11 @@
         m.putInt("lac", mLac);
         m.putInt("cid", mCid);
     }
+
+    /**
+     * @hide
+     */
+    public boolean isEmpty() {
+        return (mLac == -1 && mCid == -1);
+    }
 }
diff --git a/telephony/java/com/android/internal/telephony/TelephonyIntents.java b/telephony/java/com/android/internal/telephony/TelephonyIntents.java
index 2216ec4..3355e8a 100644
--- a/telephony/java/com/android/internal/telephony/TelephonyIntents.java
+++ b/telephony/java/com/android/internal/telephony/TelephonyIntents.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2008 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;
 
 /**
diff --git a/telephony/java/com/android/internal/telephony/gsm/SpnOverride.java b/telephony/java/com/android/internal/telephony/gsm/SpnOverride.java
index 9ea30101..918c2d2 100644
--- a/telephony/java/com/android/internal/telephony/gsm/SpnOverride.java
+++ b/telephony/java/com/android/internal/telephony/gsm/SpnOverride.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2009 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.gsm;
 
 import java.io.File;
diff --git a/tests/BrowserPowerTest/src/com/android/browserpowertest/PowerMeasurement.java b/tests/BrowserPowerTest/src/com/android/browserpowertest/PowerMeasurement.java
index 32763b3..5acadb4 100644
--- a/tests/BrowserPowerTest/src/com/android/browserpowertest/PowerMeasurement.java
+++ b/tests/BrowserPowerTest/src/com/android/browserpowertest/PowerMeasurement.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2009 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.browserpowertest;
 
 import android.content.Intent;
diff --git a/tests/BrowserPowerTest/src/com/android/browserpowertest/PowerTestActivity.java b/tests/BrowserPowerTest/src/com/android/browserpowertest/PowerTestActivity.java
index e750ac8..1b72486 100644
--- a/tests/BrowserPowerTest/src/com/android/browserpowertest/PowerTestActivity.java
+++ b/tests/BrowserPowerTest/src/com/android/browserpowertest/PowerTestActivity.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2009 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.browserpowertest;
 
 import android.app.Activity;
diff --git a/tests/BrowserPowerTest/src/com/android/browserpowertest/PowerTestRunner.java b/tests/BrowserPowerTest/src/com/android/browserpowertest/PowerTestRunner.java
index 4857209..3392475 100644
--- a/tests/BrowserPowerTest/src/com/android/browserpowertest/PowerTestRunner.java
+++ b/tests/BrowserPowerTest/src/com/android/browserpowertest/PowerTestRunner.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2009 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.browserpowertest;
 
 import android.test.InstrumentationTestRunner;
diff --git a/tests/BrowserTestPlugin/src/com/android/testplugin/TestPlugin.java b/tests/BrowserTestPlugin/src/com/android/testplugin/TestPlugin.java
index 94a18fd..7bb4c35 100644
--- a/tests/BrowserTestPlugin/src/com/android/testplugin/TestPlugin.java
+++ b/tests/BrowserTestPlugin/src/com/android/testplugin/TestPlugin.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2009 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.testplugin;
 
 import android.app.Service;
diff --git a/tests/FrameworkTest/src/com/android/frameworktest/FrameworkTestApplication.java b/tests/FrameworkTest/src/com/android/frameworktest/FrameworkTestApplication.java
index e76f387..c57b9973 100644
--- a/tests/FrameworkTest/src/com/android/frameworktest/FrameworkTestApplication.java
+++ b/tests/FrameworkTest/src/com/android/frameworktest/FrameworkTestApplication.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 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.frameworktest;
 
 import android.app.LauncherActivity;
diff --git a/tests/FrameworkTest/src/com/android/frameworktest/performance/InvalidateCycle.java b/tests/FrameworkTest/src/com/android/frameworktest/performance/InvalidateCycle.java
index 8663f06..22bb46f 100644
--- a/tests/FrameworkTest/src/com/android/frameworktest/performance/InvalidateCycle.java
+++ b/tests/FrameworkTest/src/com/android/frameworktest/performance/InvalidateCycle.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2008 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.frameworktest.performance;
 
 import android.app.Activity;
diff --git a/tests/ImfTest/src/com/android/imftest/samples/AutoCompleteTextViewActivityLandscape.java b/tests/ImfTest/src/com/android/imftest/samples/AutoCompleteTextViewActivityLandscape.java
index 9638d34a..b659135 100644
--- a/tests/ImfTest/src/com/android/imftest/samples/AutoCompleteTextViewActivityLandscape.java
+++ b/tests/ImfTest/src/com/android/imftest/samples/AutoCompleteTextViewActivityLandscape.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2009 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.imftest.samples;
 
 import android.app.Activity;
diff --git a/tests/ImfTest/src/com/android/imftest/samples/AutoCompleteTextViewActivityPortrait.java b/tests/ImfTest/src/com/android/imftest/samples/AutoCompleteTextViewActivityPortrait.java
index 58651e1..5bfe456 100644
--- a/tests/ImfTest/src/com/android/imftest/samples/AutoCompleteTextViewActivityPortrait.java
+++ b/tests/ImfTest/src/com/android/imftest/samples/AutoCompleteTextViewActivityPortrait.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2009 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.imftest.samples;
 
 import android.app.Activity;
diff --git a/tests/ImfTest/src/com/android/imftest/samples/BigEditTextActivityNonScrollablePanScan.java b/tests/ImfTest/src/com/android/imftest/samples/BigEditTextActivityNonScrollablePanScan.java
index 21734a6..033082f 100644
--- a/tests/ImfTest/src/com/android/imftest/samples/BigEditTextActivityNonScrollablePanScan.java
+++ b/tests/ImfTest/src/com/android/imftest/samples/BigEditTextActivityNonScrollablePanScan.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2009 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.imftest.samples;
 
 import com.android.imftest.R;
diff --git a/tests/ImfTest/src/com/android/imftest/samples/BigEditTextActivityNonScrollableResize.java b/tests/ImfTest/src/com/android/imftest/samples/BigEditTextActivityNonScrollableResize.java
index 48287fb..8a16dea 100644
--- a/tests/ImfTest/src/com/android/imftest/samples/BigEditTextActivityNonScrollableResize.java
+++ b/tests/ImfTest/src/com/android/imftest/samples/BigEditTextActivityNonScrollableResize.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2009 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.imftest.samples;
 
 import com.android.imftest.R;
diff --git a/tests/ImfTest/src/com/android/imftest/samples/BigEditTextActivityScrollablePanScan.java b/tests/ImfTest/src/com/android/imftest/samples/BigEditTextActivityScrollablePanScan.java
index 48e1359..b4fdc4c 100644
--- a/tests/ImfTest/src/com/android/imftest/samples/BigEditTextActivityScrollablePanScan.java
+++ b/tests/ImfTest/src/com/android/imftest/samples/BigEditTextActivityScrollablePanScan.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2009 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.imftest.samples;
 
 import com.android.imftest.R;
diff --git a/tests/ImfTest/src/com/android/imftest/samples/BigEditTextActivityScrollableResize.java b/tests/ImfTest/src/com/android/imftest/samples/BigEditTextActivityScrollableResize.java
index d51e8a7..757b6b5 100644
--- a/tests/ImfTest/src/com/android/imftest/samples/BigEditTextActivityScrollableResize.java
+++ b/tests/ImfTest/src/com/android/imftest/samples/BigEditTextActivityScrollableResize.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2009 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.imftest.samples;
 
 import com.android.imftest.R;
diff --git a/tests/ImfTest/src/com/android/imftest/samples/BottomEditTextActivityPanScan.java b/tests/ImfTest/src/com/android/imftest/samples/BottomEditTextActivityPanScan.java
index 51f5045..91a329d 100644
--- a/tests/ImfTest/src/com/android/imftest/samples/BottomEditTextActivityPanScan.java
+++ b/tests/ImfTest/src/com/android/imftest/samples/BottomEditTextActivityPanScan.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2009 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.imftest.samples;
 
 import android.app.Activity;
@@ -43,4 +59,4 @@
     public View getDefaultFocusedView() {
         return mDefaultFocusedView;
     }
-}
\ No newline at end of file
+}
diff --git a/tests/ImfTest/src/com/android/imftest/samples/BottomEditTextActivityResize.java b/tests/ImfTest/src/com/android/imftest/samples/BottomEditTextActivityResize.java
index eb94b4f..c4c41bc 100644
--- a/tests/ImfTest/src/com/android/imftest/samples/BottomEditTextActivityResize.java
+++ b/tests/ImfTest/src/com/android/imftest/samples/BottomEditTextActivityResize.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2009 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.imftest.samples;
 
 import android.app.Activity;
@@ -43,4 +59,4 @@
     public View getDefaultFocusedView() {
         return mDefaultFocusedView;
     }
-}
\ No newline at end of file
+}
diff --git a/tests/ImfTest/src/com/android/imftest/samples/ButtonActivity.java b/tests/ImfTest/src/com/android/imftest/samples/ButtonActivity.java
index 1191f19..854a3f4 100644
--- a/tests/ImfTest/src/com/android/imftest/samples/ButtonActivity.java
+++ b/tests/ImfTest/src/com/android/imftest/samples/ButtonActivity.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2009 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.imftest.samples;
 
 import android.app.Activity;
diff --git a/tests/ImfTest/src/com/android/imftest/samples/DialogActivity.java b/tests/ImfTest/src/com/android/imftest/samples/DialogActivity.java
index f65e1fd..3ed0386 100644
--- a/tests/ImfTest/src/com/android/imftest/samples/DialogActivity.java
+++ b/tests/ImfTest/src/com/android/imftest/samples/DialogActivity.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2009 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.imftest.samples;
 
 import android.app.Activity;
diff --git a/tests/ImfTest/src/com/android/imftest/samples/EditTextActivityDialog.java b/tests/ImfTest/src/com/android/imftest/samples/EditTextActivityDialog.java
index d4726fc..2591b7c 100644
--- a/tests/ImfTest/src/com/android/imftest/samples/EditTextActivityDialog.java
+++ b/tests/ImfTest/src/com/android/imftest/samples/EditTextActivityDialog.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2009 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.imftest.samples;
 
 import com.android.imftest.R;
diff --git a/tests/ImfTest/src/com/android/imftest/samples/ManyEditTextActivityNoScrollPanScan.java b/tests/ImfTest/src/com/android/imftest/samples/ManyEditTextActivityNoScrollPanScan.java
index 54ab57a..646e480 100644
--- a/tests/ImfTest/src/com/android/imftest/samples/ManyEditTextActivityNoScrollPanScan.java
+++ b/tests/ImfTest/src/com/android/imftest/samples/ManyEditTextActivityNoScrollPanScan.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2009 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.imftest.samples;
 
 import android.app.Activity;
diff --git a/tests/ImfTest/src/com/android/imftest/samples/ManyEditTextActivityScrollPanScan.java b/tests/ImfTest/src/com/android/imftest/samples/ManyEditTextActivityScrollPanScan.java
index b228d34..0387e1e 100644
--- a/tests/ImfTest/src/com/android/imftest/samples/ManyEditTextActivityScrollPanScan.java
+++ b/tests/ImfTest/src/com/android/imftest/samples/ManyEditTextActivityScrollPanScan.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2009 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.imftest.samples;
 
 import android.app.Activity;
@@ -49,4 +65,4 @@
     public View getRootView() {
         return mRootView;
     }
-}
\ No newline at end of file
+}
diff --git a/tests/ImfTest/src/com/android/imftest/samples/ManyEditTextActivityScrollResize.java b/tests/ImfTest/src/com/android/imftest/samples/ManyEditTextActivityScrollResize.java
index 777fbae..7793b55 100644
--- a/tests/ImfTest/src/com/android/imftest/samples/ManyEditTextActivityScrollResize.java
+++ b/tests/ImfTest/src/com/android/imftest/samples/ManyEditTextActivityScrollResize.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2009 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.imftest.samples;
 
 import android.app.Activity;
@@ -42,4 +58,4 @@
     public View getRootView() {
         return mRootView;
     } 
-}
\ No newline at end of file
+}
diff --git a/tests/ImfTest/src/com/android/imftest/samples/OneEditTextActivityNotSelected.java b/tests/ImfTest/src/com/android/imftest/samples/OneEditTextActivityNotSelected.java
index 88a3447..c4be21c 100644
--- a/tests/ImfTest/src/com/android/imftest/samples/OneEditTextActivityNotSelected.java
+++ b/tests/ImfTest/src/com/android/imftest/samples/OneEditTextActivityNotSelected.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2009 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.imftest.samples;
 
 import android.app.Activity;
diff --git a/tests/ImfTest/src/com/android/imftest/samples/OneEditTextActivitySelected.java b/tests/ImfTest/src/com/android/imftest/samples/OneEditTextActivitySelected.java
index 1b80263..f313a90 100644
--- a/tests/ImfTest/src/com/android/imftest/samples/OneEditTextActivitySelected.java
+++ b/tests/ImfTest/src/com/android/imftest/samples/OneEditTextActivitySelected.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2009 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.imftest.samples;
 
 import android.app.Activity;
diff --git a/tests/framework-tests/src/android/test/FrameworkTests.java b/tests/framework-tests/src/android/test/FrameworkTests.java
index 623e294..cb3f493 100644
--- a/tests/framework-tests/src/android/test/FrameworkTests.java
+++ b/tests/framework-tests/src/android/test/FrameworkTests.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 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 android.test;
 
 import com.android.internal.os.LoggingPrintStreamTest;
diff --git a/tests/framework-tests/src/com/android/internal/http/multipart/MultipartTest.java b/tests/framework-tests/src/com/android/internal/http/multipart/MultipartTest.java
index 8b48ed0..32e13a7 100644
--- a/tests/framework-tests/src/com/android/internal/http/multipart/MultipartTest.java
+++ b/tests/framework-tests/src/com/android/internal/http/multipart/MultipartTest.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2008 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.http.multipart;
 
 import junit.framework.TestCase;
diff --git a/tests/permission/src/com/android/framework/permission/tests/ActivityManagerPermissionTests.java b/tests/permission/src/com/android/framework/permission/tests/ActivityManagerPermissionTests.java
index c782045..fec3671 100644
--- a/tests/permission/src/com/android/framework/permission/tests/ActivityManagerPermissionTests.java
+++ b/tests/permission/src/com/android/framework/permission/tests/ActivityManagerPermissionTests.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2009 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.framework.permission.tests;
 
 import android.app.ActivityManagerNative;
diff --git a/tests/permission/src/com/android/framework/permission/tests/ServiceManagerPermissionTests.java b/tests/permission/src/com/android/framework/permission/tests/ServiceManagerPermissionTests.java
index 3f1e27e..4dfe0fe 100644
--- a/tests/permission/src/com/android/framework/permission/tests/ServiceManagerPermissionTests.java
+++ b/tests/permission/src/com/android/framework/permission/tests/ServiceManagerPermissionTests.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2009 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.framework.permission.tests;
 
 import com.android.internal.os.BinderInternal;
diff --git a/tests/permission/src/com/android/framework/permission/tests/WindowManagerPermissionTests.java b/tests/permission/src/com/android/framework/permission/tests/WindowManagerPermissionTests.java
index 8ab2a10..4464236 100644
--- a/tests/permission/src/com/android/framework/permission/tests/WindowManagerPermissionTests.java
+++ b/tests/permission/src/com/android/framework/permission/tests/WindowManagerPermissionTests.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2009 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.framework.permission.tests;
 
 import android.content.res.Configuration;
diff --git a/tools/layoutlib/bridge/tests/com/android/layoutlib/bridge/NinePatchTest.java b/tools/layoutlib/bridge/tests/com/android/layoutlib/bridge/NinePatchTest.java
index d5993db..23351ab 100644
--- a/tools/layoutlib/bridge/tests/com/android/layoutlib/bridge/NinePatchTest.java
+++ b/tools/layoutlib/bridge/tests/com/android/layoutlib/bridge/NinePatchTest.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2008 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.layoutlib.bridge;
 
 import com.android.ninepatch.NinePatch;