Merge "Fix to check the incoming userid argument for RingtonePlayer" into mnc-dev
diff --git a/cmds/pm/src/com/android/commands/pm/Pm.java b/cmds/pm/src/com/android/commands/pm/Pm.java
index b39376c..9f385fe 100644
--- a/cmds/pm/src/com/android/commands/pm/Pm.java
+++ b/cmds/pm/src/com/android/commands/pm/Pm.java
@@ -19,6 +19,7 @@
 import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED;
 import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK;
 import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS;
+import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS_ASK;
 import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER;
 
 import android.app.ActivityManager;
@@ -840,7 +841,7 @@
         return Integer.toString(result);
     }
 
-    // pm set-app-link [--user USER_ID] PACKAGE {always|ask|never|undefined}
+    // pm set-app-link [--user USER_ID] PACKAGE {always|ask|always-ask|never|undefined}
     private int runSetAppLink() {
         int userId = UserHandle.USER_OWNER;
 
@@ -889,6 +890,10 @@
                 newMode = INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK;
                 break;
 
+            case "always-ask":
+                newMode = INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS_ASK;
+                break;
+
             case "never":
                 newMode = INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER;
                 break;
diff --git a/core/java/android/app/DialogFragment.java b/core/java/android/app/DialogFragment.java
index 2fb8cc2..9caf752 100644
--- a/core/java/android/app/DialogFragment.java
+++ b/core/java/android/app/DialogFragment.java
@@ -230,6 +230,15 @@
         ft.commit();
     }
 
+    /** {@hide} */
+    public void showAllowingStateLoss(FragmentManager manager, String tag) {
+        mDismissed = false;
+        mShownByMe = true;
+        FragmentTransaction ft = manager.beginTransaction();
+        ft.add(this, tag);
+        ft.commitAllowingStateLoss();
+    }
+
     /**
      * Display the dialog, adding the fragment using an existing transaction
      * and then committing the transaction.
diff --git a/core/java/android/app/IUiAutomationConnection.aidl b/core/java/android/app/IUiAutomationConnection.aidl
index 474154b..2caec369 100644
--- a/core/java/android/app/IUiAutomationConnection.aidl
+++ b/core/java/android/app/IUiAutomationConnection.aidl
@@ -43,6 +43,8 @@
     void clearWindowAnimationFrameStats();
     WindowAnimationFrameStats getWindowAnimationFrameStats();
     void executeShellCommand(String command, in ParcelFileDescriptor fd);
+    void grantRuntimePermission(String packageName, String permission, int userId);
+    void revokeRuntimePermission(String packageName, String permission, int userId);
 
     // Called from the system process.
     oneway void shutdown();
diff --git a/core/java/android/app/UiAutomation.java b/core/java/android/app/UiAutomation.java
index a8494fb..efed2e0 100644
--- a/core/java/android/app/UiAutomation.java
+++ b/core/java/android/app/UiAutomation.java
@@ -30,6 +30,7 @@
 import android.os.ParcelFileDescriptor;
 import android.os.RemoteException;
 import android.os.SystemClock;
+import android.os.UserHandle;
 import android.util.Log;
 import android.view.Display;
 import android.view.InputEvent;
@@ -846,6 +847,62 @@
     }
 
     /**
+     * Grants a runtime permission to a package for a user.
+     * @param packageName The package to which to grant.
+     * @param permission The permission to grant.
+     * @return Whether granting succeeded.
+     *
+     * @hide
+     */
+    public boolean grantRuntimePermission(String packageName, String permission,
+            UserHandle userHandle) {
+        synchronized (mLock) {
+            throwIfNotConnectedLocked();
+        }
+        try {
+            if (DEBUG) {
+                Log.i(LOG_TAG, "Granting runtime permission");
+            }
+            // Calling out without a lock held.
+            mUiAutomationConnection.grantRuntimePermission(packageName,
+                    permission, userHandle.getIdentifier());
+            // TODO: The package manager API should return boolean.
+            return true;
+        } catch (RemoteException re) {
+            Log.e(LOG_TAG, "Error granting runtime permission", re);
+        }
+        return false;
+    }
+
+    /**
+     * Revokes a runtime permission from a package for a user.
+     * @param packageName The package from which to revoke.
+     * @param permission The permission to revoke.
+     * @return Whether revoking succeeded.
+     *
+     * @hide
+     */
+    public boolean revokeRuntimePermission(String packageName, String permission,
+            UserHandle userHandle) {
+        synchronized (mLock) {
+            throwIfNotConnectedLocked();
+        }
+        try {
+            if (DEBUG) {
+                Log.i(LOG_TAG, "Revoking runtime permission");
+            }
+            // Calling out without a lock held.
+            mUiAutomationConnection.revokeRuntimePermission(packageName,
+                    permission, userHandle.getIdentifier());
+            // TODO: The package manager API should return boolean.
+            return true;
+        } catch (RemoteException re) {
+            Log.e(LOG_TAG, "Error revoking runtime permission", re);
+        }
+        return false;
+    }
+
+    /**
      * Executes a shell command. This method returs a file descriptor that points
      * to the standard output stream. The command execution is similar to running
      * "adb shell <command>" from a host connected to the device.
diff --git a/core/java/android/app/UiAutomationConnection.java b/core/java/android/app/UiAutomationConnection.java
index 39cd3bc..13e27e2 100644
--- a/core/java/android/app/UiAutomationConnection.java
+++ b/core/java/android/app/UiAutomationConnection.java
@@ -19,6 +19,7 @@
 import android.accessibilityservice.AccessibilityServiceInfo;
 import android.accessibilityservice.IAccessibilityServiceClient;
 import android.content.Context;
+import android.content.pm.IPackageManager;
 import android.graphics.Bitmap;
 import android.hardware.input.InputManager;
 import android.os.Binder;
@@ -60,6 +61,9 @@
     private final IAccessibilityManager mAccessibilityManager = IAccessibilityManager.Stub
             .asInterface(ServiceManager.getService(Service.ACCESSIBILITY_SERVICE));
 
+    private final IPackageManager mPackageManager = IPackageManager.Stub
+            .asInterface(ServiceManager.getService("package"));
+
     private final Object mLock = new Object();
 
     private final Binder mToken = new Binder();
@@ -227,6 +231,38 @@
     }
 
     @Override
+    public void grantRuntimePermission(String packageName, String permission, int userId)
+            throws RemoteException {
+        synchronized (mLock) {
+            throwIfCalledByNotTrustedUidLocked();
+            throwIfShutdownLocked();
+            throwIfNotConnectedLocked();
+        }
+        final long identity = Binder.clearCallingIdentity();
+        try {
+            mPackageManager.grantRuntimePermission(packageName, permission, userId);
+        } finally {
+            Binder.restoreCallingIdentity(identity);
+        }
+    }
+
+    @Override
+    public void revokeRuntimePermission(String packageName, String permission, int userId)
+            throws RemoteException {
+        synchronized (mLock) {
+            throwIfCalledByNotTrustedUidLocked();
+            throwIfShutdownLocked();
+            throwIfNotConnectedLocked();
+        }
+        final long identity = Binder.clearCallingIdentity();
+        try {
+            mPackageManager.revokeRuntimePermission(packageName, permission, userId);
+        } finally {
+            Binder.restoreCallingIdentity(identity);
+        }
+    }
+
+    @Override
     public void executeShellCommand(final String command, final ParcelFileDescriptor sink)
             throws RemoteException {
         synchronized (mLock) {
diff --git a/core/java/android/content/pm/IntentFilterVerificationInfo.java b/core/java/android/content/pm/IntentFilterVerificationInfo.java
index 4dbac05..953b051 100644
--- a/core/java/android/content/pm/IntentFilterVerificationInfo.java
+++ b/core/java/android/content/pm/IntentFilterVerificationInfo.java
@@ -19,6 +19,7 @@
 import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED;
 import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK;
 import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS;
+import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS_ASK;
 import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER;
 
 import android.os.Parcel;
@@ -199,6 +200,10 @@
                 sb.append("never");
                 break;
 
+            case INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS_ASK:
+                sb.append("always-ask");
+                break;
+
             case INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED:
             default:
                 sb.append("undefined");
diff --git a/core/java/android/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java
index 0f936fd..c8e9402 100644
--- a/core/java/android/content/pm/PackageManager.java
+++ b/core/java/android/content/pm/PackageManager.java
@@ -1073,6 +1073,18 @@
     public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER = 3;
 
     /**
+     * Used as the {@code status} argument for {@link PackageManager#updateIntentVerificationStatus}
+     * to indicate that this app should always be considered as an ambiguous candidate for
+     * handling the matching Intent even if there are other candidate apps in the "always"
+     * state.  Put another way: if there are any 'always ask' apps in a set of more than
+     * one candidate app, then a disambiguation is *always* presented even if there is
+     * another candidate app with the 'always' state.
+     *
+     * @hide
+     */
+    public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS_ASK = 4;
+
+    /**
      * Can be used as the {@code millisecondsToDelay} argument for
      * {@link PackageManager#extendVerificationTimeout}. This is the
      * maximum time {@code PackageManager} waits for the verification
diff --git a/core/java/com/android/internal/util/ArrayUtils.java b/core/java/com/android/internal/util/ArrayUtils.java
index 9d0636a..f190d8c 100644
--- a/core/java/com/android/internal/util/ArrayUtils.java
+++ b/core/java/com/android/internal/util/ArrayUtils.java
@@ -294,6 +294,29 @@
     }
 
     /**
+     * Removes value from given array if present, providing set-like behavior.
+     */
+    public static @Nullable String[] removeString(@Nullable String[] cur, String val) {
+        if (cur == null) {
+            return null;
+        }
+        final int N = cur.length;
+        for (int i = 0; i < N; i++) {
+            if (Objects.equals(cur[i], val)) {
+                String[] ret = new String[N - 1];
+                if (i > 0) {
+                    System.arraycopy(cur, 0, ret, 0, i);
+                }
+                if (i < (N - 1)) {
+                    System.arraycopy(cur, i + 1, ret, i, N - i - 1);
+                }
+                return ret;
+            }
+        }
+        return cur;
+    }
+
+    /**
      * Adds value to given array if not already present, providing set-like
      * behavior.
      */
diff --git a/docs/html/index.jd b/docs/html/index.jd
index c6dbbd5..eef7929 100644
--- a/docs/html/index.jd
+++ b/docs/html/index.jd
@@ -10,32 +10,31 @@
 <section class="dac-hero-carousel">
 
 <!-- <article class="dac-expand dac-hero dac-invert active" style="background-color: rgb(38, 50, 56);"> -->
-<article class="dac-expand dac-hero dac-invert active" style="background-color: #455A64;">
+<article class="dac-expand dac-hero dac-invert dac-darken mprev active" style="background-color: #75d1ff;">
 <a href="/preview/index.html">
-  <div class="wrap" style="max-width:1100px;">
+  <div class="wrap" style="max-width:1100px;margin-top:0">
     <div class="cols dac-hero-content">
-      <div class="col-10of16 col-push-6of16 dac-hero-figure">
-        <img class="dac-hero-image" src="{@docRoot}images/home/devices-hero_620px_2x.png"
-             srcset="{@docRoot}images/home/devices-hero_620px.png 1x,
-             {@docRoot}images/home/devices-hero_620px_2x.png 2x">
+      <div class="col-8of16 col-push-6of16 dac-hero-figure mprev">
       </div>
-      <div class="col-6of16 col-pull-10of16">
+      <div class="col-8of16 col-pull-7of16">
         <div class="dac-hero-tag"></div>
 
-        <h1 class="dac-hero-title">Android M Developer Preview</h1>
-        <p class="dac-hero-description">Get your apps ready for the next version
-        of Android. Test on Nexus 5, 6, 9, and Player. </p>
+        <h1 class="dac-hero-title" style="white-space:nowrap;">Android 6.0 Marshmallow</h1>
+        </div>
+        <div class="col-6of16 col-push-1of16">
+        <p class="dac-hero-description"><strong>Final SDK is now available!</strong> Get your apps ready for the next version
+        of Android. Test on Nexus 5, 6, 9, and Player.</p>
 
-        <a class="dac-hero-cta" href="{@docRoot}preview/index.html">
+        <a class="dac-hero-cta" href="/preview/index.html">
           <span class="dac-sprite dac-auto-chevron"></span>
           Get started
         </a><br>
 
-        <a class="dac-hero-cta" href="{@docRoot}preview/support.html">
+        <a class="dac-hero-cta" href="/preview/support.html">
           <span class="dac-sprite dac-auto-chevron"></span>
-          Update to Developer Preview 2
+          Update to Developer Preview 3 (final SDK)
         </a>
-
+      </div>
       </div>
     </div>
   </div>
diff --git a/docs/html/preview/download.jd b/docs/html/preview/download.jd
index 0dfabef..0b115f2 100644
--- a/docs/html/preview/download.jd
+++ b/docs/html/preview/download.jd
@@ -164,7 +164,7 @@
   <div id="qv">
     <h2>In this document</h2>
       <ol>
-        <li><a href="#sdk">Developer Preview 2 SDK</a></li>
+        <li><a href="#sdk">Developer Preview 3 SDK</a></li>
         <li><a href="#docs">Developer Documentation</a></li>
         <li><a href="#images">Hardware System Images</a></li>
       </ol>
@@ -178,13 +178,13 @@
 
 
 <p>
-  The Android M Preview SDK includes development tools, Android system files, and library files to
+  The Android M Preview SDK includes development tools, Android system images, and library files to
   help you test your app and the new APIs coming in the next release of the platform. This document
   describes how to get the downloadable components of the preview for testing your app.
 </p>
 
 
-<h2 id="sdk">Developer Preview 2 SDK</h2>
+<h2 id="sdk">Developer Preview 3 SDK</h2>
 
 <p>
   The Preview SDK is available for download through the <a href=
@@ -197,7 +197,10 @@
 <h2 id="docs">Developer Documentation</h2>
 
 <p>
-  The developer documentation download package provides detailed API reference information and an API difference report for the preview.
+	The developer documentation download package provides detailed API reference information and
+	an API difference report for the preview. Note that <a href="{@docRoot}reference/packages.html">API
+	level 23 reference</a> and <a href="{@docRoot}sdk/api_diff/23/changes.html">diffs</a> are now
+	also available online. 
 </p>
 
 <table>
@@ -206,11 +209,11 @@
     <th scope="col">Download / Checksums</th>
   </tr>
   <tr id="docs-dl">
-    <td>Android M Preview 2<br>Developer Docs</td>
+    <td>Android M Preview 3<br>Developer Docs</td>
     <td><a href="#top" onclick="onDownload(this)"
-      >m-preview-2-developer-docs.zip</a><br>
-      MD5: 1db6fff9c722b0339757e1cdf43663a8<br>
-      SHA-1: 5a4ae88d644e63824d21b0e18f8e3977a7665157
+      >m-preview-3-developer-docs.zip</a><br>
+      MD5: -<br>
+      SHA-1: -
     </td>
   </tr>
 <table>
diff --git a/docs/html/preview/download_mp2.jd b/docs/html/preview/download_mp2.jd
new file mode 100644
index 0000000..0dfabef
--- /dev/null
+++ b/docs/html/preview/download_mp2.jd
@@ -0,0 +1,367 @@
+page.title=Downloads
+page.image=images/cards/card-download_16-9_2x.png
+
+@jd:body
+
+<div style="position:relative; min-height:600px">
+
+  <div class="wrap" id="tos" style="position:absolute;display:none;width:inherit;">
+
+    <p class="sdk-terms-intro">Before downloading and installing components of the Android Preview
+      SDK, you must agree to the following terms and conditions.</p>
+
+    <h2 class="norule">Terms and Conditions</h2>
+
+    <div class="sdk-terms" onfocus="this.blur()" style="width:678px">
+This is the Android SDK Preview License Agreement (the “License Agreement”).
+
+1. Introduction
+
+1.1 The Android SDK Preview (referred to in the License Agreement as the “Preview” and specifically including the Android system files, packaged APIs, and Preview library files, if and when they are made available) is licensed to you subject to the terms of the License Agreement. The License Agreement forms a legally binding contract between you and Google in relation to your use of the Preview.
+
+1.2 "Android" means the Android software stack for devices, as made available under the Android Open Source Project, which is located at the following URL: http://source.android.com/, as updated from time to time.
+
+1.3 "Google" means Google Inc., a Delaware corporation with principal place of business at 1600 Amphitheatre Parkway, Mountain View, CA 94043, United States.
+
+2. Accepting the License Agreement
+
+2.1 In order to use the Preview, you must first agree to the License Agreement. You may not use the Preview if you do not accept the License Agreement.
+
+2.2 By clicking to accept and/or using the Preview, you hereby agree to the terms of the License Agreement.
+
+2.3 You may not use the Preview and may not accept the License Agreement if you are a person barred from receiving the Preview under the laws of the United States or other countries including the country in which you are resident or from which you use the Preview.
+
+2.4 If you will use the Preview internally within your company or organization you agree to be bound by the License Agreement on behalf of your employer or other entity, and you represent and warrant that you have full legal authority to bind your employer or such entity to the License Agreement. If you do not have the requisite authority, you may not accept the License Agreement or use the Preview on behalf of your employer or other entity.
+
+3. Preview License from Google
+
+3.1 Subject to the terms of the License Agreement, Google grants you a royalty-free, non-assignable, non-exclusive, non-sublicensable, limited, revocable license to use the Preview, personally or internally within your company or organization, solely to develop applications to run on the Android platform.
+
+3.2 You agree that Google or third parties owns all legal right, title and interest in and to the Preview, including any Intellectual Property Rights that subsist in the Preview. "Intellectual Property Rights" means any and all rights under patent law, copyright law, trade secret law, trademark law, and any and all other proprietary rights. Google reserves all rights not expressly granted to you.
+
+3.3 You may not use the Preview for any purpose not expressly permitted by the License Agreement. Except to the extent required by applicable third party licenses, you may not: (a) copy (except for backup purposes), modify, adapt, redistribute, decompile, reverse engineer, disassemble, or create derivative works of the Preview or any part of the Preview; or (b) load any part of the Preview onto a mobile handset or any other hardware device except a personal computer, combine any part of the Preview with other software, or distribute any software or device incorporating a part of the Preview.
+
+3.4 You agree that you will not take any actions that may cause or result in the fragmentation of Android, including but not limited to distributing, participating in the creation of, or promoting in any way a software development kit derived from the Preview.
+
+3.5 Use, reproduction and distribution of components of the Preview licensed under an open source software license are governed solely by the terms of that open source software license and not the License Agreement. You agree to remain a licensee in good standing in regard to such open source software licenses under all the rights granted and to refrain from any actions that may terminate, suspend, or breach such rights.
+
+3.6 You agree that the form and nature of the Preview that Google provides may change without prior notice to you and that future versions of the Preview may be incompatible with applications developed on previous versions of the Preview. You agree that Google may stop (permanently or temporarily) providing the Preview (or any features within the Preview) to you or to users generally at Google's sole discretion, without prior notice to you.
+
+3.7 Nothing in the License Agreement gives you a right to use any of Google's trade names, trademarks, service marks, logos, domain names, or other distinctive brand features.
+
+3.8 You agree that you will not remove, obscure, or alter any proprietary rights notices (including copyright and trademark notices) that may be affixed to or contained within the Preview.
+
+4. Use of the Preview by You
+
+4.1 Google agrees that nothing in the License Agreement gives Google any right, title or interest from you (or your licensors) under the License Agreement in or to any software applications that you develop using the Preview, including any intellectual property rights that subsist in those applications.
+
+4.2 You agree to use the Preview and write applications only for purposes that are permitted by (a) the License Agreement, and (b) any applicable law, regulation or generally accepted practices or guidelines in the relevant jurisdictions (including any laws regarding the export of data or software to and from the United States or other relevant countries).
+
+4.3 You agree that if you use the Preview to develop applications, you will protect the privacy and legal rights of users. If users provide you with user names, passwords, or other login information or personal information, you must make the users aware that the information will be available to your application, and you must provide legally adequate privacy notice and protection for those users. If your application stores personal or sensitive information provided by users, it must do so securely. If users provide you with Google Account information, your application may only use that information to access the user's Google Account when, and for the limited purposes for which, each user has given you permission to do so.
+
+4.4 You agree that you will not engage in any activity with the Preview, including the development or distribution of an application, that interferes with, disrupts, damages, or accesses in an unauthorized manner the servers, networks, or other properties or services of Google or any third party.
+
+4.5 You agree that you are solely responsible for (and that Google has no responsibility to you or to any third party for) any data, content, or resources that you create, transmit or display through Android and/or applications for Android, and for the consequences of your actions (including any loss or damage which Google may suffer) by doing so.
+
+4.6 You agree that you are solely responsible for (and that Google has no responsibility to you or to any third party for) any breach of your obligations under the License Agreement, any applicable third party contract or Terms of Service, or any applicable law or regulation, and for the consequences (including any loss or damage which Google or any third party may suffer) of any such breach.
+
+4.7 The Preview is in development, and your testing and feedback are an important part of the development process. By using the Preview, you acknowledge that implementation of some features are still under development and that you should not rely on the Preview having the full functionality of a stable release. You agree not to publicly distribute or ship any application using this Preview as this Preview will no longer be supported after the official Android SDK is released.
+
+5. Your Developer Credentials
+
+5.1 You agree that you are responsible for maintaining the confidentiality of any developer credentials that may be issued to you by Google or which you may choose yourself and that you will be solely responsible for all applications that are developed under your developer credentials.
+
+6. Privacy and Information
+
+6.1 In order to continually innovate and improve the Preview, Google may collect certain usage statistics from the software including but not limited to a unique identifier, associated IP address, version number of the software, and information on which tools and/or services in the Preview are being used and how they are being used. Before any of this information is collected, the Preview will notify you and seek your consent. If you withhold consent, the information will not be collected.
+
+6.2 The data collected is examined in the aggregate to improve the Preview and is maintained in accordance with Google's Privacy Policy located at http://www.google.com/policies/privacy/.
+
+7. Third Party Applications
+
+7.1 If you use the Preview to run applications developed by a third party or that access data, content or resources provided by a third party, you agree that Google is not responsible for those applications, data, content, or resources. You understand that all data, content or resources which you may access through such third party applications are the sole responsibility of the person from which they originated and that Google is not liable for any loss or damage that you may experience as a result of the use or access of any of those third party applications, data, content, or resources.
+
+7.2 You should be aware the data, content, and resources presented to you through such a third party application may be protected by intellectual property rights which are owned by the providers (or by other persons or companies on their behalf). You may not modify, rent, lease, loan, sell, distribute or create derivative works based on these data, content, or resources (either in whole or in part) unless you have been specifically given permission to do so by the relevant owners.
+
+7.3 You acknowledge that your use of such third party applications, data, content, or resources may be subject to separate terms between you and the relevant third party.
+
+8. Using Google APIs
+
+8.1 Google APIs
+
+8.1.1 If you use any API to retrieve data from Google, you acknowledge that the data may be protected by intellectual property rights which are owned by Google or those parties that provide the data (or by other persons or companies on their behalf). Your use of any such API may be subject to additional Terms of Service. You may not modify, rent, lease, loan, sell, distribute or create derivative works based on this data (either in whole or in part) unless allowed by the relevant Terms of Service.
+
+8.1.2 If you use any API to retrieve a user's data from Google, you acknowledge and agree that you shall retrieve data only with the user's explicit consent and only when, and for the limited purposes for which, the user has given you permission to do so.
+
+9. Terminating the License Agreement
+
+9.1 the License Agreement will continue to apply until terminated by either you or Google as set out below.
+
+9.2 If you want to terminate the License Agreement, you may do so by ceasing your use of the Preview and any relevant developer credentials.
+
+9.3 Google may at any time, terminate the License Agreement, with or without cause, upon notice to you.
+
+9.4 The License Agreement will automatically terminate without notice or other action upon the earlier of:
+(A) when Google ceases to provide the Preview or certain parts of the Preview to users in the country in which you are resident or from which you use the service; and
+(B) Google issues a final release version of the Android SDK.
+
+9.5 When the License Agreement is terminated, the license granted to you in the License Agreement will terminate, you will immediately cease all use of the Preview, and the provisions of paragraphs 10, 11, 12 and 14 shall survive indefinitely.
+
+10. DISCLAIMERS
+
+10.1 YOU EXPRESSLY UNDERSTAND AND AGREE THAT YOUR USE OF THE PREVIEW IS AT YOUR SOLE RISK AND THAT THE PREVIEW IS PROVIDED "AS IS" AND "AS AVAILABLE" WITHOUT WARRANTY OF ANY KIND FROM GOOGLE.
+
+10.2 YOUR USE OF THE PREVIEW AND ANY MATERIAL DOWNLOADED OR OTHERWISE OBTAINED THROUGH THE USE OF THE PREVIEW IS AT YOUR OWN DISCRETION AND RISK AND YOU ARE SOLELY RESPONSIBLE FOR ANY DAMAGE TO YOUR COMPUTER SYSTEM OR OTHER DEVICE OR LOSS OF DATA THAT RESULTS FROM SUCH USE. WITHOUT LIMITING THE FOREGOING, YOU UNDERSTAND THAT THE PREVIEW IS NOT A STABLE RELEASE AND MAY CONTAIN ERRORS, DEFECTS AND SECURITY VULNERABILITIES THAT CAN RESULT IN SIGNIFICANT DAMAGE, INCLUDING THE COMPLETE, IRRECOVERABLE LOSS OF USE OF YOUR COMPUTER SYSTEM OR OTHER DEVICE.
+
+10.3 GOOGLE FURTHER EXPRESSLY DISCLAIMS ALL WARRANTIES AND CONDITIONS OF ANY KIND, WHETHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+
+11. LIMITATION OF LIABILITY
+
+11.1 YOU EXPRESSLY UNDERSTAND AND AGREE THAT GOOGLE, ITS SUBSIDIARIES AND AFFILIATES, AND ITS LICENSORS SHALL NOT BE LIABLE TO YOU UNDER ANY THEORY OF LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, CONSEQUENTIAL OR EXEMPLARY DAMAGES THAT MAY BE INCURRED BY YOU, INCLUDING ANY LOSS OF DATA, WHETHER OR NOT GOOGLE OR ITS REPRESENTATIVES HAVE BEEN ADVISED OF OR SHOULD HAVE BEEN AWARE OF THE POSSIBILITY OF ANY SUCH LOSSES ARISING.
+
+12. Indemnification
+
+12.1 To the maximum extent permitted by law, you agree to defend, indemnify and hold harmless Google, its affiliates and their respective directors, officers, employees and agents from and against any and all claims, actions, suits or proceedings, as well as any and all losses, liabilities, damages, costs and expenses (including reasonable attorneys’ fees) arising out of or accruing from (a) your use of the Preview, (b) any application you develop on the Preview that infringes any Intellectual Property Rights of any person or defames any person or violates their rights of publicity or privacy, and (c) any non-compliance by you of the License Agreement.
+
+13. Changes to the License Agreement
+
+13.1 Google may make changes to the License Agreement as it distributes new versions of the Preview. When these changes are made, Google will make a new version of the License Agreement available on the website where the Preview is made available.
+
+14. General Legal Terms
+
+14.1 the License Agreement constitutes the whole legal agreement between you and Google and governs your use of the Preview (excluding any services which Google may provide to you under a separate written agreement), and completely replaces any prior agreements between you and Google in relation to the Preview.
+
+14.2 You agree that if Google does not exercise or enforce any legal right or remedy which is contained in the License Agreement (or which Google has the benefit of under any applicable law), this will not be taken to be a formal waiver of Google's rights and that those rights or remedies will still be available to Google.
+
+14.3 If any court of law, having the jurisdiction to decide on this matter, rules that any provision of the License Agreement is invalid, then that provision will be removed from the License Agreement without affecting the rest of the License Agreement. The remaining provisions of the License Agreement will continue to be valid and enforceable.
+
+14.4 You acknowledge and agree that each member of the group of companies of which Google is the parent shall be third party beneficiaries to the License Agreement and that such other companies shall be entitled to directly enforce, and rely upon, any provision of the License Agreement that confers a benefit on (or rights in favor of) them. Other than this, no other person or company shall be third party beneficiaries to the License Agreement.
+
+14.5 EXPORT RESTRICTIONS. THE PREVIEW IS SUBJECT TO UNITED STATES EXPORT LAWS AND REGULATIONS. YOU MUST COMPLY WITH ALL DOMESTIC AND INTERNATIONAL EXPORT LAWS AND REGULATIONS THAT APPLY TO THE PREVIEW. THESE LAWS INCLUDE RESTRICTIONS ON DESTINATIONS, END USERS AND END USE.
+
+14.6 The License Agreement may not be assigned or transferred by you without the prior written approval of Google, and any attempted assignment without such approval will be void. You shall not delegate your responsibilities or obligations under the License Agreement without the prior written approval of Google.
+
+14.7 The License Agreement, and your relationship with Google under the License Agreement, shall be governed by the laws of the State of California without regard to its conflict of laws provisions. You and Google agree to submit to the exclusive jurisdiction of the courts located within the county of Santa Clara, California to resolve any legal matter arising from the License Agreement. Notwithstanding this, you agree that Google shall still be allowed to apply for injunctive remedies (or an equivalent type of urgent legal relief) in any jurisdiction.
+  </div><!-- sdk terms -->
+
+
+
+    <div id="sdk-terms-form">
+      <p>
+        <input id="agree" type="checkbox" name="agree" value="1" onclick="onAgreeChecked()" />
+        <label id="agreeLabel" for="agree">I have read and agree with the above terms and conditions</label>
+      </p>
+      <p><a href="" class="button disabled" id="downloadForRealz" onclick="return onDownloadForRealz(this);"></a></p>
+    </div>
+
+
+  </div><!-- end TOS -->
+
+
+  <div id="landing">
+
+<div id="qv-wrapper">
+  <div id="qv">
+    <h2>In this document</h2>
+      <ol>
+        <li><a href="#sdk">Developer Preview 2 SDK</a></li>
+        <li><a href="#docs">Developer Documentation</a></li>
+        <li><a href="#images">Hardware System Images</a></li>
+      </ol>
+
+     <h2>Legacy downloads</h2>
+        <ol>
+           <li><a href="{@docRoot}preview/download_mp1.html">Developer Preview Archive</a></li>
+        </ol>
+  </div>
+</div>
+
+
+<p>
+  The Android M Preview SDK includes development tools, Android system files, and library files to
+  help you test your app and the new APIs coming in the next release of the platform. This document
+  describes how to get the downloadable components of the preview for testing your app.
+</p>
+
+
+<h2 id="sdk">Developer Preview 2 SDK</h2>
+
+<p>
+  The Preview SDK is available for download through the <a href=
+  "{@docRoot}tools/help/sdk-manager.html">Android SDK Manager</a>. For more information on
+  downloading and configuring the Preview SDK, see <a href=
+  "{@docRoot}preview/setup-sdk.html#downloadSdk">Set Up the Preview SDK</a>.
+</p>
+
+
+<h2 id="docs">Developer Documentation</h2>
+
+<p>
+  The developer documentation download package provides detailed API reference information and an API difference report for the preview.
+</p>
+
+<table>
+  <tr>
+    <th scope="col">Description</th>
+    <th scope="col">Download / Checksums</th>
+  </tr>
+  <tr id="docs-dl">
+    <td>Android M Preview 2<br>Developer Docs</td>
+    <td><a href="#top" onclick="onDownload(this)"
+      >m-preview-2-developer-docs.zip</a><br>
+      MD5: 1db6fff9c722b0339757e1cdf43663a8<br>
+      SHA-1: 5a4ae88d644e63824d21b0e18f8e3977a7665157
+    </td>
+  </tr>
+<table>
+
+
+<h2 id="images">Hardware System Images</h2>
+
+<p>
+  These system images allow you to install a preview version of the platform on a physical device for
+  testing. By configuring a device with one of these images, you can install and test your app to
+  see how it performs on the next version of the platform. The process of installing a system image
+  on a device <em>removes all data from the device</em>, so you should backup your data before
+  installing a system image.
+</p>
+
+<p class="warning">
+  <b>Warning:</b> The following Android system images are previews and are subject to change. Your
+  use of these system images is governed by the Android SDK Preview License Agreement. The Android
+  preview system images are not stable releases, and may contain errors and defects that can result
+  in damage to your computer systems, devices, and data. The preview Android system images are not
+  subject to the same testing as the factory OS and can cause your phone and installed services and
+  applications to stop working.
+</p>
+
+<table>
+  <tr>
+    <th scope="col">Device</th>
+    <th scope="col">Download / Checksums</th>
+  </tr>
+  <tr id="hammerhead">
+    <td>Nexus 5 (GSM/LTE) <br>"hammerhead"</td>
+    <td><a href="#top" onclick="onDownload(this)"
+      >hammerhead-MPZ79M-preview-b1f4bde4.tgz</a><br>
+      MD5: 2ca9f18bf47a061b339bab52647ceb0d<br>
+      SHA-1: b1f4bde447eccbf8ce5d9b8b8ba954e3eac8e939
+    </td>
+  </tr>
+  <tr id="shamu">
+    <td>Nexus 6 <br>"shamu"</td>
+    <td><a href="#top" onclick="onDownload(this)"
+      >shamu-MPZ79M-preview-e1024040.tgz</a><br>
+      MD5: 24a2118da340b9afedfbdfc026f6ff81<br>
+      SHA-1: e10240408859d5188c4aae140e1c539130ba614b
+    </td>
+  </tr>
+  <tr id="volantis">
+    <td>Nexus 9 <br>"volantis"</td>
+    <td><a href="#top" onclick="onDownload(this)"
+      >volantis-MPZ79M-preview-9f305342.tgz</a><br>
+      MD5: 9edabf0a4c61b247f1cbb9dfdc0a899e<br>
+      SHA-1: 9f30534216f10899a6a75495fc7e92408ea333a7
+    </td>
+  </tr>
+
+  <tr id="fugu">
+    <td>Nexus Player <br>"fugu"</td>
+    <td><a href="#top" onclick="onDownload(this)"
+      >fugu-MPZ79N-preview-fb63af98.tgz</a><br>
+      MD5: e8d081137a20b66df595ee69523314b5<br>
+      SHA-1: fb63af98302dd97be8de9313734d389ccdcce250
+    </td>
+  </tr>
+
+</table>
+
+<h3 id="install-image">Install an Image to a Device</h3>
+
+<p>
+  In order to use a device image for testing, you must install it on a compatible device. Follow
+  the instructions below to install a system image:
+</p>
+
+<ol>
+  <li>Download and uncompress one of the system image packages listed here.</li>
+  <li>Backup any data you want to preserve from the device.</li>
+  <li>Follow the instructions at
+  <a href="https://developers.google.com/android/nexus/images#instructions">developers.google.com/android</a>
+  to flash the image onto your device.</li>
+</ol>
+
+<h3 id="update-image">Updating a Device with the Preview</h3>
+
+<p>
+  Once you have installed a preview system image on a development device, the device is upgraded
+  automatically with the next preview release through over-the-air (OTA) updates. When the update
+  is available, the device displays notification that an update is available and allows you to
+  install it. You can also manually install the next preview image by repeating the procedure in
+  the previous section.
+</p>
+
+<h3 id="revertDevice">Revert a Device to Factory Specifications</h3>
+
+<p>
+  If you want to uninstall the preview and revert the device to factory specifications, go to
+  <a href="http://developers.google.com/android/nexus/images">developers.google.com/android</a> and
+  download the image you want to flash to for your device. Follow the instructions on that page to
+  flash the image to your device.
+</p>
+
+  </div><!-- landing -->
+
+</div><!-- relative wrapper -->
+
+
+
+<script>
+  var urlRoot = "http://storage.googleapis.com/androiddevelopers/shareables/preview/";
+  function onDownload(link) {
+
+    $("#downloadForRealz").html("Download " + $(link).text());
+    $("#downloadForRealz").attr('href', urlRoot + $(link).text());
+
+    $("#tos").fadeIn('fast');
+    $("#landing").fadeOut('fast');
+
+    return true;
+  }
+
+
+  function onAgreeChecked() {
+    /* verify that the TOS is agreed */
+    if ($("input#agree").is(":checked")) {
+      /* reveal the download button */
+      $("a#downloadForRealz").removeClass('disabled');
+    } else {
+      $("a#downloadForRealz").addClass('disabled');
+    }
+  }
+
+  function onDownloadForRealz(link) {
+    if ($("input#agree").is(':checked')) {
+    /*
+      $("#tos").fadeOut('fast');
+      $("#landing").fadeIn('fast');
+    */
+
+      ga('send', 'event', 'M Preview', 'System Image', $("#downloadForRealz").html());
+
+    /*
+      location.hash = "";
+    */
+      return true;
+    } else {
+      return false;
+    }
+  }
+
+  $(window).hashchange( function(){
+    if (location.hash == "") {
+      location.reload();
+    }
+  });
+
+</script>
diff --git a/docs/html/preview/index.jd b/docs/html/preview/index.jd
index 022838b..5410e4f 100644
--- a/docs/html/preview/index.jd
+++ b/docs/html/preview/index.jd
@@ -18,6 +18,7 @@
       <div class="col-7of16 col-pull-9of16">
         <h1 class="dac-hero-title">Android M Developer Preview</h1>
         <p class="dac-hero-description">
+          <strong>Final SDK is now available!</strong> 
           Get ready for the next version of Android. Test your apps on Nexus 5, 6, 9, and
           Player. Explore what's new &mdash; <strong>runtime permissions</strong>,
           <strong>Doze</strong> and <strong>App Standby</strong> power-saving features, new
@@ -30,7 +31,7 @@
         </a><br>
         <a class="dac-hero-cta" href="{@docRoot}preview/support.html">
           <span class="dac-sprite dac-auto-chevron"></span>
-          Update to Developer Preview 2
+          Update to Developer Preview 3 (final SDK)
         </a><br>
       </div>
     </div>
diff --git a/docs/html/preview/overview.jd b/docs/html/preview/overview.jd
index 009e268..9793592 100644
--- a/docs/html/preview/overview.jd
+++ b/docs/html/preview/overview.jd
@@ -6,20 +6,21 @@
 @jd:body
 
 <div class="cols" style=
-"background-color:#ffebc3; padding: 5px 0;margin-bottom:1em; text-align:center;">
+"background-color:#f2daf5; padding: 5px 0;margin-bottom:1em; text-align:center;">
 <h3>
-    Developer Preview 2 is now available
+    Developer Preview 3 is now available
   </h3>
-
+  <p>Includes final SDK and near-final system images</p>
+   <div style="margin:auto 1em">
  <ul class="dac-section-links">
     <li class="dac-section-link">
-      <a href="{@docRoot}preview/support.html#preview2-notes">
+      <a href="{@docRoot}preview/support.html#preview3-notes">
       <span class="dac-sprite dac-auto-chevron"></span>
       Read the Notes</a>
     </li>
 
     <li class="dac-section-link">
-      <a href="{@docRoot}preview/support.html#preview2-get">
+      <a href="{@docRoot}preview/support.html#preview3-get">
       <span class="dac-sprite dac-auto-chevron"></span>
       Get the Update</a>
     </li>
@@ -30,6 +31,7 @@
       Report Issues</a>
     </li>
   </ul>
+  </div>
 </div>
 
 <p>
@@ -143,14 +145,13 @@
 <img src="{@docRoot}preview/images/m-preview-timeline-crop.png" alt=
 "Preview program timeline" id="timeline">
 <p>
-  The M Developer Preview runs from May 28 until the final Android M SDK, which
-  we’ll release shortly before the public release during Q3
+  The M Developer Preview runs from May 28 until the final Android M public release planned for Q3
   2015.
 </p>
 
 <p>
   At key development milestones, we’ll deliver updates for your test devices.
-  The tentative milestones are
+  The milestones are
 </p>
 
 <ul>
@@ -163,12 +164,12 @@
   </li>
 
   <li>
-    <strong>Preview&nbsp;3</strong> (near final, late July).
+    <strong>Preview&nbsp;3</strong> (final APIs and SDK, now available).
   </li>
 </ul>
 
 <p>
-  These updates culminate in the <strong>final SDK</strong> (later in Q3),
+  These updates culminate in the <strong>final SDK</strong> (available now),
   which delivers the official APIs for the new version of Android, as well
   as the final system behaviors and features.
 </p>
@@ -181,8 +182,10 @@
   providing system images that you can download and flash manually.
 </p>
 <p class="note">
-  <strong>Note:</strong> The final SDK and system images can not be delivered
-  by OTA, but will instead need to be <strong>flashed manually</strong> to
+  <strong>Note:</strong> Developer Preview 3 includes final APIs and near-final
+  system images available by both download and OTA. At the full public release of
+  Android M later in Q3, final system images will be available by download only,
+  so you'll need to <strong>flash manually</strong> to
   your test devices.</strong>
 </p>
 
@@ -316,40 +319,29 @@
 
 
 <h2 id="preview_apis_and_publishing">
-  Targeting, preview APIs, and publishing
+  Final SDK, targeting, and publishing
 </h2>
 
 <p>
-  The Android M Developer Preview is a development-only release and
-  <strong>does not have a standard API level</strong>. If you want to opt out
+   <p>With Developer Preview 3, the platform APIs are now official (API level 23) and the
+   <strong>final SDK is now available</strong>.  We recommend updating your environment
+   right away through Android Studio. Once you've updated your environment, you can target
+   the new API level, compile against the new platform, and publish at your convenience
+   to Google Play (including alpha, beta, or release channels).
+
+  <p>If you want to opt out
   of compatibility behaviors to test your app (which is strongly recommended),
   you can target the M Developer Preview by setting your app's <code><a href=
   "/guide/topics/manifest/uses-sdk-element.html">targetSdkVersion</a></code>
   to <code>“MNC”</code>.
 </p>
 
-<p>
-  The Android M Developer Preview delivers <strong>preview APIs</strong>
-  &mdash; the APIs will not be official until the final SDK is released,
-  currently planned for the third quarter of 2015. This means that you can
-  <strong>expect minor API changes</strong> over time, especially during
-  initial weeks of the program. We’ll provide a summary of changes to you with
-  each update of the Android M Developer Preview.
-</p>
-
-<p class="note">
-  Note that although preview APIs may change, underlying system behaviors such
-  as runtime permissions and power-saving features are stable and ready for
-  testing right away.
-</p>
-
-<p>
-  In terms of publishing, Google Play <strong>prevents publishing of apps
-  targeting the M Developer Preview</strong>. When the Android M final SDK is
-  available, you’ll be able to target the official Android M API level and
-  publish your app to Google Play. Meanwhile, if you want to distribute an app
-  targeting Android M to testers, you can do so via email or by direct download
-  from your site.
+  <p>Before releasing your app targeting Android M, we strongly recommend distributing it
+  to a group of testers through the new <a
+  href="http://android-developers.blogspot.com/2015/07/iterate-faster-on-google-play-with.html"> 
+  beta testing features available in the Google Play Developer Console. See the
+  <a href="https://support.google.com/googleplay/android-developer/answer/3131213">Help
+  Center article</a> for more information. 
 </p>
 
 <h2 id="get_started">
@@ -357,7 +349,7 @@
 </h2>
 
 <p>
-  To get started testing your app:
+  To get started testing your app with Android M:
 </p>
 
 <ol>
@@ -379,7 +371,7 @@
     Preview updates will be delivered through over-the-air (OTA) updates.</a>
   </li>
 
-  <li>Download the <a href="{@docRoot}preview/download.html#docs">M Preview API
+  <li>Review the <a href="{@docRoot}reference/packages.html">API
   Reference</a> and <a href="{@docRoot}preview/samples.html">M Preview
   samples</a> to gain more insight into new API features and how to use them in
   your app.
diff --git a/docs/html/preview/support.jd b/docs/html/preview/support.jd
index d908f77..9ad9ac0 100644
--- a/docs/html/preview/support.jd
+++ b/docs/html/preview/support.jd
@@ -5,20 +5,21 @@
 @jd:body
 
 <div class="cols" style=
-"background-color:#ffebc3; padding: 5px 0;margin-bottom:1em; text-align:center;">
+"background-color:#f2daf5; padding: 5px 0;margin-bottom:1em; text-align:center;">
 <h3>
-    Developer Preview 2 is now available
+    Developer Preview 3 is now available
   </h3>
-
+  <p>Includes final SDK and near-final system images</p>
+   <div style="margin:auto 1em">
  <ul class="dac-section-links">
     <li class="dac-section-link">
-      <a href="#preview2-notes">
+      <a href="#preview3-notes">
       <span class="dac-sprite dac-auto-chevron"></span>
       Read the Notes</a>
     </li>
 
     <li class="dac-section-link">
-      <a href="#preview2-get">
+      <a href="#preview3-get">
       <span class="dac-sprite dac-auto-chevron"></span>
       Get the Update</a>
     </li>
@@ -29,6 +30,7 @@
       Report Issues</a>
     </li>
   </ul>
+  </div>
 </div>
 
 <p>
@@ -46,6 +48,191 @@
   community</a>.
 </p>
 
+<h2 id="preview3-notes">
+  Developer Preview 3
+</h2>
+
+<div class="wrap">
+  <div class="cols">
+    <div class="col-9of16">
+      <p>
+        <em>Date: August 2015<br>
+        Builds: XXXXXX (Nexus 5, 6, 9), MPZ79N (Nexus Player)<br>
+        Hardware support: Nexus 5, 6, 9, Player<br>
+        Emulator support: x86 &amp; ARM 32/64-bit<br>
+        Google Play services: 7.8</em>
+      </p>
+    </div>
+  </div>
+</div>
+
+<p>
+  Android M Developer Preview 3 is the <strong>final incremental update</strong>
+  to the Android M preview platform that was originally released in May 2015.
+  The update includes <strong>final APIs and final SDK</strong>, as well as
+  <strong>near-final system images</strong> for testing your apps. The
+  updated system images include a variety of fixes and enhancements across
+  the system, including those related to issues reported by developers
+  through the external issue tracker.
+</p>
+
+<p>
+  If you are currently developing or testing on Android M, you should <strong>update
+  your environment to Developer Preview 3</strong> as soon as possible, so that
+  you can begin <strong>final compatibility testing</strong> in preparation for the public
+  release to device manufacturers.</p>
+
+<p class="important">Updating to Developer Preview 3 ensures that
+   you are building against final platform APIs and testing against
+   the final behaviors. If you are just getting started with the Android
+   M Developer Preview SDK, follow the instructions in <a href=
+  "/preview/setup-sdk.html">Set up the Preview SDK</a>, then update your
+  environment for Developer Preview 3.
+</p>
+
+<h3>
+  What's included
+</h3>
+
+<p>
+  Developer Preview 3 includes an updated SDK and system images,
+  documentation, and samples for developing against the final Android M
+  development platform.
+</p>
+
+<ul>
+  <li>
+    <strong>SDK platform</strong> and <strong>system images</strong> (Nexus and
+    emulator) for building and testing. You can download the updated tools from
+    the SDK Manager, and the system images are available by over-the-air (OTA)
+    update or download (see below).
+  </li>
+
+  <li>
+    <strong>Updated documentation</strong>. The <a href=
+    "/preview/behavior-changes.html">Behavior Changes</a>, <a href=
+    "/preview/api-overview.html">API Overview</a>, and <a href=
+    "/preview/features/runtime-permissions.html">Permissions</a> documents have
+    been updated to reflect the latest changes in the platform. An updated
+    <a href="/preview/download.html">Developer Documentation download
+    package</a> is available, including full reference docs and API diff
+    reports.
+  </li>
+
+  <li>
+    <strong>Translations</strong> of the documentation are now available. Use
+    the language selector at the bottom right corner of any page to switch
+    languages. Note that some of the translated docs are not yet updated for
+    Developer Preview 3 (coming soon).
+  </li>
+
+  <li>The <a href="/preview/samples.html">Android M code samples</a> are also
+  updated to account for API and behavior changes:
+    <ul>
+      <li>
+        <a href=
+        "https://github.com/googlesamples/android-RuntimePermissions">RuntimePermissions</a>
+        / <a href=
+        "https://github.com/googlesamples/android-RuntimePermissionsBasic">RuntimePermissionsBasic</a>
+        are updated to reflect latest permissions API changes, including
+        <code>shouldShowRequestPermissionRationale()</code>.
+      </li>
+      <li>
+        <a href=
+        "https://github.com/googlesamples/android-FingerprintDialog">FingerprintDialog</a>
+        adds a flow to ask for passwords when new fingerprints are added as
+        well as a preference if the app will use fingerprints as a method of
+        authentication.
+      </li>
+    </ul>
+  </li>
+</ul>
+
+<h3 id="changes">
+  Key changes
+</h3>
+
+<ul>
+  <li>Add here
+    <ul>
+      <li>
+      </li>
+    </ul>
+  </li>
+
+  <li>Other changes
+    <ul>
+      <li>
+      </li>
+    </ul>
+  </li>
+</ul>
+
+<p>
+  For a complete list of changes, including renamed and removed APIs, please
+  refer to the API Diff reports below:</p>
+  <ul>
+  <li><a href="@docRoot"sdk/api_diff/mnc-preview-3/changes.html">API Differences: Preview 2 to Preview 3 (API level 23)</a></li>
+  <li><a href="@docRoot"sdk/api_diff/23/changes.html">API Differences: API level 22 to API level 23</a></li>
+  </ul>
+
+<h3 id="ki">
+  Known issues
+</h3>
+
+<ul>
+  <li>General issues:
+    <ul>
+      <li>Add
+      </li>
+    </ul>
+  </li>
+</ul>
+
+<p>
+  For a complete list of reported issues, please refer to the <a href=
+  "https://code.google.com/p/android/issues/list">open issues list</a> on the
+  Developer Preview <a href=
+  "https://code.google.com/p/android-developer-preview/">issue tracker</a>.
+</p>
+
+<h3 id="preview3-get">
+  Get Developer Preview 3
+</h3>
+
+<p>
+  You can download the Developer Preview 3 final SDK platform and
+  emulator images from the SDK Manager. 
+</p>
+
+<p>
+  Developer Preview 3 system images for supported Nexus devices are available
+  by download and by over-the-air (OTA) update. The OTA update is available
+  only to supported devices that are currently running a Developer Preview build.
+  If your device is running a Developer Preview build, you should automatically receive
+  the OTA update within a few days of availability.
+</p>
+
+<p>
+  If you are just getting started with Android M Developer Preview and want
+  to receive Developer Preview 3 via OTA, download the 
+  Developer Preview 2 <a href="{@docRoot}preview/download_mp2.html#images">
+  system image</a>, and flash it to your device. Then,
+  leave the device powered on for several hours. It registers with the
+  OTA service, and receives Developer Preview 3 by OTA.
+</p>
+
+<p>
+  For instructions on how to download and flash your device to the Developer
+  Preview, see the links and instructions on the <a href=
+  "/preview/download.html">Downloads</a> page.
+</p>
+
+<p>
+  For instructions on how to start developing and testing with Android M, read
+  <a href="/preview/setup-sdk.html">Setting up the SDK</a>.
+</p>
+
 <h2 id="preview2-notes">
   Developer Preview 2
 </h2>
@@ -164,8 +351,8 @@
       </li>
 
       <li>Remote Bluetooth/Wi-Fi MAC's now require either the
-      <code>android.permission.LOCATION_FINE</code> or
-      <code>android.permission.LOCATION_COARSE</code> permission.
+      <code>android.permission.ACCESS_COARSE_LOCATION</code> or
+      <code>android.permission.ACCESS_FINE_LOCATION</code> permission.
       </li>
 
       <li>Some accounts and identity permissions are moved to
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
index c1df788..a1c8b1a 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
@@ -1564,6 +1564,7 @@
     private void handleNotifyScreenTurningOn(IKeyguardDrawnCallback callback) {
         synchronized (KeyguardViewMediator.this) {
             if (DEBUG) Log.d(TAG, "handleNotifyScreenTurningOn");
+            mStatusBarKeyguardViewManager.onScreenTurningOn();
             if (callback != null) {
                 if (mWakeAndUnlocking) {
                     mDrawnCallback = callback;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
index 17fd7a7..373abe5 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
@@ -2226,7 +2226,7 @@
         }
     };
 
-    public void onScreenTurnedOn() {
+    public void onScreenTurningOn() {
         mKeyguardStatusView.refreshTime();
     }
 
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
index efd72a7..18cf95b 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -3834,11 +3834,14 @@
     public void onScreenTurnedOn() {
         mScreenOnFromKeyguard = true;
         mStackScroller.setAnimationsEnabled(true);
-        mNotificationPanel.onScreenTurnedOn();
         mNotificationPanel.setTouchDisabled(false);
         updateVisibleToUser();
     }
 
+    public void onScreenTurningOn() {
+        mNotificationPanel.onScreenTurningOn();
+    }
+
     /**
      * This handles long-press of both back and recents.  They are
      * handled together to capture them both being long-pressed
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java
index 44aa780..7dd3e7c 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java
@@ -172,6 +172,10 @@
         mPhoneStatusBar.onScreenTurnedOn();
     }
 
+    public void onScreenTurningOn() {
+        mPhoneStatusBar.onScreenTurningOn();
+    }
+
     public void onScreenTurnedOn() {
         mScreenTurnedOn = true;
         mWakeAndUnlocking = false;
diff --git a/services/core/java/com/android/server/content/ContentService.java b/services/core/java/com/android/server/content/ContentService.java
index c13401f..b766894 100644
--- a/services/core/java/com/android/server/content/ContentService.java
+++ b/services/core/java/com/android/server/content/ContentService.java
@@ -157,7 +157,7 @@
         mFactoryTest = factoryTest;
 
         // Let the package manager query for the sync adapters for a given authority
-        // as we grant default permissions to sync adapters for specifix authorities.
+        // as we grant default permissions to sync adapters for specific authorities.
         PackageManagerInternal packageManagerInternal = LocalServices.getService(
                 PackageManagerInternal.class);
         packageManagerInternal.setSyncAdapterPackagesprovider(
diff --git a/services/core/java/com/android/server/pm/BasePermission.java b/services/core/java/com/android/server/pm/BasePermission.java
index 18407c9..52d0928 100644
--- a/services/core/java/com/android/server/pm/BasePermission.java
+++ b/services/core/java/com/android/server/pm/BasePermission.java
@@ -88,4 +88,10 @@
         return (protectionLevel & PermissionInfo.PROTECTION_MASK_BASE)
                 == PermissionInfo.PROTECTION_DANGEROUS;
     }
+
+    public boolean isDevelopment() {
+        return (protectionLevel & PermissionInfo.PROTECTION_MASK_BASE)
+                == PermissionInfo.PROTECTION_SIGNATURE
+                && (protectionLevel & PermissionInfo.PROTECTION_FLAG_DEVELOPMENT) != 0;
+    }
 }
diff --git a/services/core/java/com/android/server/pm/DefaultPermissionGrantPolicy.java b/services/core/java/com/android/server/pm/DefaultPermissionGrantPolicy.java
index 71a2d59..d2a70df 100644
--- a/services/core/java/com/android/server/pm/DefaultPermissionGrantPolicy.java
+++ b/services/core/java/com/android/server/pm/DefaultPermissionGrantPolicy.java
@@ -296,7 +296,7 @@
             PackageParser.Package storagePackage = getDefaultProviderAuthorityPackageLPr(
                     "com.android.externalstorage.documents", userId);
             if (storagePackage != null) {
-                grantRuntimePermissionsLPw(storagePackage, STORAGE_PERMISSIONS, userId);
+                grantRuntimePermissionsLPw(storagePackage, STORAGE_PERMISSIONS, true, userId);
             }
 
             // CertInstaller
@@ -360,7 +360,7 @@
             PackageParser.Package cbrPackage =
                     getDefaultSystemHandlerActivityPackageLPr(cbrIntent, userId);
             if (cbrPackage != null && doesPackageSupportRuntimePermissions(cbrPackage)) {
-                grantRuntimePermissionsLPw(cbrPackage, SMS_PERMISSIONS, false, userId);
+                grantRuntimePermissionsLPw(cbrPackage, SMS_PERMISSIONS, userId);
             }
 
             // Calendar
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index 21e256e8..f67f3f3 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -56,6 +56,7 @@
 import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK;
 import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER;
 import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED;
+import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS_ASK;
 import static android.content.pm.PackageManager.MATCH_ALL;
 import static android.content.pm.PackageManager.MOVE_FAILED_DOESNT_EXIST;
 import static android.content.pm.PackageManager.MOVE_FAILED_INTERNAL_ERROR;
@@ -3432,14 +3433,14 @@
         }
     }
 
-    private static void enforceDeclaredAsUsedAndRuntimePermission(PackageParser.Package pkg,
+    private static void enforceDeclaredAsUsedAndRuntimeOrDevelopmentPermission(PackageParser.Package pkg,
             BasePermission bp) {
         int index = pkg.requestedPermissions.indexOf(bp.name);
         if (index == -1) {
             throw new SecurityException("Package " + pkg.packageName
                     + " has not requested permission " + bp.name);
         }
-        if (!bp.isRuntime()) {
+        if (!bp.isRuntime() && !bp.isDevelopment()) {
             throw new SecurityException("Permission " + bp.name
                     + " is not a changeable permission type");
         }
@@ -3473,7 +3474,7 @@
                 throw new IllegalArgumentException("Unknown permission: " + name);
             }
 
-            enforceDeclaredAsUsedAndRuntimePermission(pkg, bp);
+            enforceDeclaredAsUsedAndRuntimeOrDevelopmentPermission(pkg, bp);
 
             uid = UserHandle.getUid(userId, pkg.applicationInfo.uid);
             sb = (SettingBase) pkg.mExtras;
@@ -3489,6 +3490,16 @@
                         + name + " for package: " + packageName);
             }
 
+            if (bp.isDevelopment()) {
+                // Development permissions must be handled specially, since they are not
+                // normal runtime permissions.  For now they apply to all users.
+                if (permissionsState.grantInstallPermission(bp) !=
+                        PermissionsState.PERMISSION_OPERATION_FAILURE) {
+                    scheduleWriteSettingsLocked();
+                }
+                return;
+            }
+
             final int result = permissionsState.grantRuntimePermission(bp, userId);
             switch (result) {
                 case PermissionsState.PERMISSION_OPERATION_FAILURE: {
@@ -3557,7 +3568,7 @@
                 throw new IllegalArgumentException("Unknown permission: " + name);
             }
 
-            enforceDeclaredAsUsedAndRuntimePermission(pkg, bp);
+            enforceDeclaredAsUsedAndRuntimeOrDevelopmentPermission(pkg, bp);
 
             SettingBase sb = (SettingBase) pkg.mExtras;
             if (sb == null) {
@@ -3572,6 +3583,16 @@
                         + name + " for package: " + packageName);
             }
 
+            if (bp.isDevelopment()) {
+                // Development permissions must be handled specially, since they are not
+                // normal runtime permissions.  For now they apply to all users.
+                if (permissionsState.revokeInstallPermission(bp) !=
+                        PermissionsState.PERMISSION_OPERATION_FAILURE) {
+                    scheduleWriteSettingsLocked();
+                }
+                return;
+            }
+
             if (permissionsState.revokeRuntimePermission(bp, userId) ==
                     PermissionsState.PERMISSION_OPERATION_FAILURE) {
                 return;
@@ -3799,21 +3820,6 @@
         return (flags & PackageManager.FLAG_PERMISSION_USER_SET) != 0;
     }
 
-    void grantInstallPermissionLPw(String permission, PackageParser.Package pkg) {
-        BasePermission bp = mSettings.mPermissions.get(permission);
-        if (bp == null) {
-            throw new SecurityException("Missing " + permission + " permission");
-        }
-
-        SettingBase sb = (SettingBase) pkg.mExtras;
-        PermissionsState permissionsState = sb.getPermissionsState();
-
-        if (permissionsState.grantInstallPermission(bp) !=
-                PermissionsState.PERMISSION_OPERATION_FAILURE) {
-            scheduleWriteSettingsLocked();
-        }
-    }
-
     @Override
     public void addOnPermissionsChangeListener(IOnPermissionsChangeListener listener) {
         mContext.enforceCallingOrSelfPermission(
@@ -4701,6 +4707,7 @@
         ArrayList<ResolveInfo> result = new ArrayList<ResolveInfo>();
         ArrayList<ResolveInfo> alwaysList = new ArrayList<ResolveInfo>();
         ArrayList<ResolveInfo> undefinedList = new ArrayList<ResolveInfo>();
+        ArrayList<ResolveInfo> alwaysAskList = new ArrayList<ResolveInfo>();
         ArrayList<ResolveInfo> neverList = new ArrayList<ResolveInfo>();
         ArrayList<ResolveInfo> matchAllList = new ArrayList<ResolveInfo>();
 
@@ -4737,6 +4744,11 @@
                             Slog.i(TAG, "  + never: " + info.activityInfo.packageName);
                         }
                         neverList.add(info);
+                    } else if (status == INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS_ASK) {
+                        if (DEBUG_DOMAIN_VERIFICATION) {
+                            Slog.i(TAG, "  + always-ask: " + info.activityInfo.packageName);
+                        }
+                        alwaysAskList.add(info);
                     } else if (status == INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED ||
                             status == INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK) {
                         if (DEBUG_DOMAIN_VERIFICATION) {
@@ -4746,6 +4758,10 @@
                     }
                 }
             }
+
+            // We'll want to include browser possibilities in a few cases
+            boolean includeBrowser = false;
+
             // First try to add the "always" resolution(s) for the current user, if any
             if (alwaysList.size() > 0) {
                 result.addAll(alwaysList);
@@ -4754,7 +4770,7 @@
                     == INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS) {
                 result.add(xpDomainInfo.resolveInfo);
             } else {
-                // Add all undefined Apps as we want them to appear in the Disambiguation dialog.
+                // Add all undefined apps as we want them to appear in the disambiguation dialog.
                 result.addAll(undefinedList);
                 if (xpDomainInfo != null && (
                         xpDomainInfo.bestDomainVerificationStatus
@@ -4763,7 +4779,25 @@
                         == INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK)) {
                     result.add(xpDomainInfo.resolveInfo);
                 }
-                // Also add Browsers (all of them or only the default one)
+                includeBrowser = true;
+            }
+
+            // The presence of any 'always ask' alternatives means we'll also offer browsers.
+            // If there were 'always' entries their preferred order has been set, so we also
+            // back that off to make the alternatives equivalent
+            if (alwaysAskList.size() > 0) {
+                for (ResolveInfo i : result) {
+                    i.preferredOrder = 0;
+                }
+                result.addAll(alwaysAskList);
+                includeBrowser = true;
+            }
+
+            if (includeBrowser) {
+                // Also add browsers (all of them or only the default one)
+                if (DEBUG_DOMAIN_VERIFICATION) {
+                    Slog.v(TAG, "   ...including browsers in candidate set");
+                }
                 if ((matchFlags & MATCH_ALL) != 0) {
                     result.addAll(matchAllList);
                 } else {
@@ -14764,6 +14798,7 @@
                 pw.println("    version: print database version info");
                 pw.println("    write: write current settings now");
                 pw.println("    installs: details about install sessions");
+                pw.println("    check-permission <permission> <package> [<user>]: does pkg hold perm?");
                 pw.println("    <package.name>: info about given package");
                 return;
             } else if ("--checkin".equals(opt)) {
@@ -14785,6 +14820,31 @@
                 // When dumping a single package, we always dump all of its
                 // filter information since the amount of data will be reasonable.
                 dumpState.setOptionEnabled(DumpState.OPTION_SHOW_FILTERS);
+            } else if ("check-permission".equals(cmd)) {
+                if (opti >= args.length) {
+                    pw.println("Error: check-permission missing permission argument");
+                    return;
+                }
+                String perm = args[opti];
+                opti++;
+                if (opti >= args.length) {
+                    pw.println("Error: check-permission missing package argument");
+                    return;
+                }
+                String pkg = args[opti];
+                opti++;
+                int user = UserHandle.getUserId(Binder.getCallingUid());
+                if (opti < args.length) {
+                    try {
+                        user = Integer.parseInt(args[opti]);
+                    } catch (NumberFormatException e) {
+                        pw.println("Error: check-permission user argument is not a number: "
+                                + args[opti]);
+                        return;
+                    }
+                }
+                pw.println(checkPermission(perm, pkg, user));
+                return;
             } else if ("l".equals(cmd) || "libraries".equals(cmd)) {
                 dumpState.setDump(DumpState.DUMP_LIBS);
             } else if ("f".equals(cmd) || "features".equals(cmd)) {
diff --git a/services/core/java/com/android/server/pm/Settings.java b/services/core/java/com/android/server/pm/Settings.java
index 00d0fe1..a762014 100644
--- a/services/core/java/com/android/server/pm/Settings.java
+++ b/services/core/java/com/android/server/pm/Settings.java
@@ -3949,7 +3949,7 @@
 
     void dumpPackageLPr(PrintWriter pw, String prefix, String checkinTag,
             ArraySet<String> permissionNames, PackageSetting ps, SimpleDateFormat sdf,
-            Date date, List<UserInfo> users) {
+            Date date, List<UserInfo> users, boolean dumpAll) {
         if (checkinTag != null) {
             pw.print(checkinTag);
             pw.print(",");
@@ -4151,7 +4151,7 @@
                     pw.print(", COSTS_MONEY");
                 }
                 if ((perm.info.flags&PermissionInfo.FLAG_HIDDEN) != 0) {
-                    pw.print(", COSTS_HIDDEN");
+                    pw.print(", HIDDEN");
                 }
                 if ((perm.info.flags&PermissionInfo.FLAG_INSTALLED) != 0) {
                     pw.print(", INSTALLED");
@@ -4160,7 +4160,21 @@
             }
         }
 
-        if (ps.sharedUser == null || permissionNames != null) {
+        if ((permissionNames != null || dumpAll) && ps.pkg.requestedPermissions != null
+                && ps.pkg.requestedPermissions.size() > 0) {
+            final ArrayList<String> perms = ps.pkg.requestedPermissions;
+            pw.print(prefix); pw.println("  requested permissions:");
+            for (int i=0; i<perms.size(); i++) {
+                String perm = perms.get(i);
+                if (permissionNames != null
+                        && !permissionNames.contains(perm)) {
+                    continue;
+                }
+                pw.print(prefix); pw.print("    "); pw.println(perm);
+            }
+        }
+
+        if (ps.sharedUser == null || permissionNames != null || dumpAll) {
             PermissionsState permissionsState = ps.getPermissionsState();
             dumpInstallPermissionsLPr(pw, prefix + "  ", permissionNames, permissionsState);
         }
@@ -4187,7 +4201,7 @@
                 PermissionsState permissionsState = ps.getPermissionsState();
                 dumpGidsLPr(pw, prefix + "    ", permissionsState.computeGids(user.id));
                 dumpRuntimePermissionsLPr(pw, prefix + "    ", permissionNames, permissionsState
-                        .getRuntimePermissionStates(user.id));
+                        .getRuntimePermissionStates(user.id), dumpAll);
             }
 
             if (permissionNames == null) {
@@ -4235,11 +4249,12 @@
                 pw.println("Packages:");
                 printedSomething = true;
             }
-            dumpPackageLPr(pw, "  ", checkin ? "pkg" : null, permissionNames, ps, sdf, date, users);
+            dumpPackageLPr(pw, "  ", checkin ? "pkg" : null, permissionNames, ps, sdf, date, users,
+                    packageName != null);
         }
 
         printedSomething = false;
-        if (!checkin && mRenamedPackages.size() > 0 && permissionNames == null) {
+        if (mRenamedPackages.size() > 0 && permissionNames == null) {
             for (final Map.Entry<String, String> e : mRenamedPackages.entrySet()) {
                 if (packageName != null && !packageName.equals(e.getKey())
                         && !packageName.equals(e.getValue())) {
@@ -4276,7 +4291,7 @@
                     printedSomething = true;
                 }
                 dumpPackageLPr(pw, "  ", checkin ? "dis" : null, permissionNames, ps, sdf, date,
-                        users);
+                        users, packageName != null);
             }
         }
     }
@@ -4361,7 +4376,8 @@
                     if (!ArrayUtils.isEmpty(gids) || !permissions.isEmpty()) {
                         pw.print(prefix); pw.print("User "); pw.print(userId); pw.println(": ");
                         dumpGidsLPr(pw, prefix + "  ", gids);
-                        dumpRuntimePermissionsLPr(pw, prefix + "  ", permissionNames, permissions);
+                        dumpRuntimePermissionsLPr(pw, prefix + "  ", permissionNames, permissions,
+                                packageName != null);
                     }
                 }
             } else {
@@ -4407,8 +4423,8 @@
     }
 
     void dumpRuntimePermissionsLPr(PrintWriter pw, String prefix, ArraySet<String> permissionNames,
-            List<PermissionState> permissionStates) {
-        if (!permissionStates.isEmpty()) {
+            List<PermissionState> permissionStates, boolean dumpAll) {
+        if (!permissionStates.isEmpty() || dumpAll) {
             pw.print(prefix); pw.println("runtime permissions:");
             for (PermissionState permissionState : permissionStates) {
                 if (permissionNames != null
diff --git a/telecomm/java/android/telecom/DefaultDialerManager.java b/telecomm/java/android/telecom/DefaultDialerManager.java
index 3d49308..5852b8e 100644
--- a/telecomm/java/android/telecom/DefaultDialerManager.java
+++ b/telecomm/java/android/telecom/DefaultDialerManager.java
@@ -97,7 +97,7 @@
      * @hide
      * */
     public static String getDefaultDialerApplication(Context context) {
-        return getDefaultDialerApplication(context, ActivityManager.getCurrentUser());
+        return getDefaultDialerApplication(context, context.getUserId());
     }
 
     /**
diff --git a/tests/VoiceInteraction/AndroidManifest.xml b/tests/VoiceInteraction/AndroidManifest.xml
index 36d5d98..fe17c6e 100644
--- a/tests/VoiceInteraction/AndroidManifest.xml
+++ b/tests/VoiceInteraction/AndroidManifest.xml
@@ -2,6 +2,7 @@
         package="com.android.test.voiceinteraction">
 
     <uses-permission android:name="android.permission.PACKAGE_USAGE_STATS" />
+    <uses-permission android:name="android.permission.READ_LOGS" />
 
     <application>
         <activity android:name="VoiceInteractionMain" android:label="Voice Interaction"