Merge "Have Activity Transitions activited by a new window attribute." into lmp-dev
diff --git a/api/current.txt b/api/current.txt
index 747f72f..82aad79 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -16346,10 +16346,10 @@
 package android.media.projection {
 
   public final class MediaProjection {
-    method public void addCallback(android.media.projection.MediaProjection.Callback, android.os.Handler);
     method public android.hardware.display.VirtualDisplay createVirtualDisplay(java.lang.String, int, int, int, int, android.view.Surface, android.hardware.display.VirtualDisplay.Callback, android.os.Handler);
-    method public void removeCallback(android.media.projection.MediaProjection.Callback);
+    method public void registerCallback(android.media.projection.MediaProjection.Callback, android.os.Handler);
     method public void stop();
+    method public void unregisterCallback(android.media.projection.MediaProjection.Callback);
   }
 
   public static abstract class MediaProjection.Callback {
@@ -16358,8 +16358,8 @@
   }
 
   public final class MediaProjectionManager {
+    method public android.content.Intent createScreenCaptureIntent();
     method public android.media.projection.MediaProjection getMediaProjection(int, android.content.Intent);
-    method public android.content.Intent getScreenCaptureIntent();
   }
 
 }
@@ -17538,14 +17538,12 @@
 
   public class VpnService extends android.app.Service {
     ctor public VpnService();
-    method public boolean addAddress(java.net.InetAddress, int);
     method public android.os.IBinder onBind(android.content.Intent);
     method public void onRevoke();
     method public static android.content.Intent prepare(android.content.Context);
     method public boolean protect(int);
     method public boolean protect(java.net.Socket);
     method public boolean protect(java.net.DatagramSocket);
-    method public boolean removeAddress(java.net.InetAddress, int);
     field public static final java.lang.String SERVICE_INTERFACE = "android.net.VpnService";
   }
 
@@ -28242,6 +28240,8 @@
     method public static android.telecomm.Connection createCanceledConnection();
     method public static android.telecomm.Connection createFailedConnection(int, java.lang.String);
     method public final void destroy();
+    method public final android.net.Uri getAddress();
+    method public final int getAddressPresentation();
     method public final boolean getAudioModeIsVoip();
     method public final android.telecomm.AudioState getAudioState();
     method public final int getCallCapabilities();
@@ -28251,11 +28251,9 @@
     method public final java.util.List<android.telecomm.Connection> getConferenceableConnections();
     method public final int getDisconnectCause();
     method public final java.lang.String getDisconnectMessage();
-    method public final android.net.Uri getHandle();
-    method public final int getHandlePresentation();
     method public final int getState();
     method public final android.telecomm.StatusHints getStatusHints();
-    method public final boolean isRequestingRingback();
+    method public final boolean isRingbackRequested();
     method public void onAbort();
     method public void onAnswer();
     method public void onAudioStateChanged(android.telecomm.AudioState);
@@ -28270,6 +28268,7 @@
     method public void onStopDtmfTone();
     method public void onUnhold();
     method public final void setActive();
+    method public final void setAddress(android.net.Uri, int);
     method public final void setAudioModeIsVoip(boolean);
     method public final void setCallCapabilities(int);
     method public final void setCallerDisplayName(java.lang.String, int);
@@ -28277,12 +28276,11 @@
     method public final void setConnectionService(android.telecomm.ConnectionService);
     method public final void setDialing();
     method public final void setDisconnected(int, java.lang.String);
-    method public final void setHandle(android.net.Uri, int);
     method public final void setInitialized();
     method public final void setInitializing();
     method public final void setOnHold();
     method public final void setPostDialWait(java.lang.String);
-    method public final void setRequestingRingback(boolean);
+    method public final void setRingbackRequested(boolean);
     method public final void setRinging();
     method public final void setStatusHints(android.telecomm.StatusHints);
     method public static java.lang.String stateToString(int);
@@ -28390,7 +28388,6 @@
   }
 
   public final class RemoteConference {
-    method public final void addCallback(android.telecomm.RemoteConference.Callback);
     method public void disconnect();
     method public final int getCallCapabilities();
     method public final java.util.List<android.telecomm.RemoteConnection> getConnections();
@@ -28398,9 +28395,10 @@
     method public java.lang.String getDisconnectMessage();
     method public final int getState();
     method public void hold();
-    method public final void removeCallback(android.telecomm.RemoteConference.Callback);
+    method public final void registerCallback(android.telecomm.RemoteConference.Callback);
     method public void separate(android.telecomm.RemoteConnection);
     method public void unhold();
+    method public final void unregisterCallback(android.telecomm.RemoteConference.Callback);
   }
 
   public static abstract class RemoteConference.Callback {
@@ -28415,52 +28413,48 @@
 
   public final class RemoteConnection {
     method public void abort();
-    method public void addListener(android.telecomm.RemoteConnection.Listener);
     method public void answer();
     method public void disconnect();
-    method public boolean getAudioModeIsVoip();
+    method public android.net.Uri getAddress();
+    method public int getAddressPresentation();
     method public int getCallCapabilities();
-    method public java.lang.String getCallerDisplayName();
+    method public java.lang.CharSequence getCallerDisplayName();
     method public int getCallerDisplayNamePresentation();
-    method public java.util.List<android.telecomm.RemoteConnection> getChildren();
     method public android.telecomm.RemoteConference getConference();
     method public java.util.List<android.telecomm.RemoteConnection> getConferenceableConnections();
     method public int getDisconnectCauseCode();
     method public java.lang.String getDisconnectCauseMessage();
     method public int getFailureCode();
     method public java.lang.String getFailureMessage();
-    method public android.net.Uri getHandle();
-    method public int getHandlePresentation();
-    method public android.telecomm.RemoteConnection getParent();
     method public int getState();
     method public android.telecomm.StatusHints getStatusHints();
     method public void hold();
-    method public boolean isRequestingRingback();
+    method public boolean isRingbackRequested();
+    method public boolean isVoipAudioMode();
     method public void playDtmfTone(char);
     method public void postDialContinue(boolean);
+    method public void registerCallback(android.telecomm.RemoteConnection.Callback);
     method public void reject();
-    method public void removeListener(android.telecomm.RemoteConnection.Listener);
     method public void setAudioState(android.telecomm.AudioState);
     method public void stopDtmfTone();
     method public void unhold();
+    method public void unregisterCallback(android.telecomm.RemoteConnection.Callback);
   }
 
-  public static abstract class RemoteConnection.Listener {
-    ctor public RemoteConnection.Listener();
-    method public void onAudioModeIsVoipChanged(android.telecomm.RemoteConnection, boolean);
+  public static abstract class RemoteConnection.Callback {
+    ctor public RemoteConnection.Callback();
+    method public void onAddressChanged(android.telecomm.RemoteConnection, android.net.Uri, int);
     method public void onCallCapabilitiesChanged(android.telecomm.RemoteConnection, int);
     method public void onCallerDisplayNameChanged(android.telecomm.RemoteConnection, java.lang.String, int);
-    method public void onChildrenChanged(android.telecomm.RemoteConnection, java.util.List<android.telecomm.RemoteConnection>);
     method public void onConferenceChanged(android.telecomm.RemoteConnection, android.telecomm.RemoteConference);
     method public void onConferenceableConnectionsChanged(android.telecomm.RemoteConnection, java.util.List<android.telecomm.RemoteConnection>);
     method public void onDestroyed(android.telecomm.RemoteConnection);
     method public void onDisconnected(android.telecomm.RemoteConnection, int, java.lang.String);
-    method public void onHandleChanged(android.telecomm.RemoteConnection, android.net.Uri, int);
-    method public void onParentChanged(android.telecomm.RemoteConnection, android.telecomm.RemoteConnection);
     method public void onPostDialWait(android.telecomm.RemoteConnection, java.lang.String);
-    method public void onRequestingRingback(android.telecomm.RemoteConnection, boolean);
+    method public void onRingbackRequested(android.telecomm.RemoteConnection, boolean);
     method public void onStateChanged(android.telecomm.RemoteConnection, int);
     method public void onStatusHintsChanged(android.telecomm.RemoteConnection, android.telecomm.StatusHints);
+    method public void onVoipAudioChanged(android.telecomm.RemoteConnection, boolean);
   }
 
   public final class StatusHints implements android.os.Parcelable {
@@ -28478,7 +28472,7 @@
   public class TelecommManager {
     method public void addNewIncomingCall(android.telecomm.PhoneAccountHandle, android.os.Bundle);
     method public void cancelMissedCallsNotification();
-    method public void clearAccounts(java.lang.String);
+    method public void clearAccounts();
     method public android.telecomm.PhoneAccountHandle getConnectionManager();
     method public android.telecomm.PhoneAccountHandle getDefaultOutgoingPhoneAccount(java.lang.String);
     method public java.util.List<android.telecomm.PhoneAccountHandle> getEnabledPhoneAccounts();
@@ -28501,6 +28495,8 @@
     field public static final java.lang.String EXTRA_CONNECTION_SERVICE = "android.telecomm.extra.CONNECTION_SERVICE";
     field public static final java.lang.String EXTRA_PHONE_ACCOUNT_HANDLE = "android.telecomm.extra.PHONE_ACCOUNT_HANDLE";
     field public static final java.lang.String EXTRA_START_CALL_WITH_SPEAKERPHONE = "android.telecomm.extra.START_CALL_WITH_SPEAKERPHONE";
+    field public static final java.lang.String GATEWAY_ORIGINAL_ADDRESS = "android.telecomm.extra.GATEWAY_ORIGINAL_ADDRESS";
+    field public static final java.lang.String GATEWAY_PROVIDER_PACKAGE = "android.telecomm.extra.GATEWAY_PROVIDER_PACKAGE";
     field public static final int PRESENTATION_ALLOWED = 1; // 0x1
     field public static final int PRESENTATION_PAYPHONE = 4; // 0x4
     field public static final int PRESENTATION_RESTRICTED = 2; // 0x2
diff --git a/core/java/android/hardware/camera2/legacy/LegacyMetadataMapper.java b/core/java/android/hardware/camera2/legacy/LegacyMetadataMapper.java
index 3c0e0e4..c36b63a 100644
--- a/core/java/android/hardware/camera2/legacy/LegacyMetadataMapper.java
+++ b/core/java/android/hardware/camera2/legacy/LegacyMetadataMapper.java
@@ -165,6 +165,12 @@
 
     private static void mapCharacteristicsFromParameters(CameraMetadataNative m,
             Camera.Parameters p) {
+
+        /*
+         * colorCorrection.*
+         */
+        m.set(COLOR_CORRECTION_AVAILABLE_ABERRATION_MODES,
+                new int[] { COLOR_CORRECTION_ABERRATION_MODE_FAST });
         /*
          * control.ae*
          */
@@ -196,6 +202,12 @@
         mapJpeg(m, p);
 
         /*
+         * noiseReduction.*
+         */
+        m.set(NOISE_REDUCTION_AVAILABLE_NOISE_REDUCTION_MODES,
+                new int[] { NOISE_REDUCTION_MODE_FAST });
+
+        /*
          * scaler.*
          */
         mapScaler(m, p);
@@ -626,6 +638,7 @@
             // Note: We only list public keys. Native HALs should list ALL keys regardless of visibility.
 
             Key<?> availableKeys[] = new Key<?>[] {
+                    CameraCharacteristics.COLOR_CORRECTION_AVAILABLE_ABERRATION_MODES     ,
                     CameraCharacteristics.CONTROL_AE_AVAILABLE_ANTIBANDING_MODES          ,
                     CameraCharacteristics.CONTROL_AE_AVAILABLE_MODES                      ,
                     CameraCharacteristics.CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES          ,
@@ -642,6 +655,7 @@
                     CameraCharacteristics.JPEG_AVAILABLE_THUMBNAIL_SIZES                  ,
                     CameraCharacteristics.LENS_FACING                                     ,
                     CameraCharacteristics.LENS_INFO_AVAILABLE_FOCAL_LENGTHS               ,
+                    CameraCharacteristics.NOISE_REDUCTION_AVAILABLE_NOISE_REDUCTION_MODES ,
                     CameraCharacteristics.REQUEST_AVAILABLE_CAPABILITIES                  ,
                     CameraCharacteristics.REQUEST_MAX_NUM_OUTPUT_STREAMS                  ,
                     CameraCharacteristics.REQUEST_PARTIAL_RESULT_COUNT                    ,
@@ -653,6 +667,7 @@
                     CameraCharacteristics.SENSOR_INFO_ACTIVE_ARRAY_SIZE                   ,
                     CameraCharacteristics.SENSOR_INFO_PHYSICAL_SIZE                       ,
                     CameraCharacteristics.SENSOR_INFO_PIXEL_ARRAY_SIZE                    ,
+                    CameraCharacteristics.SENSOR_INFO_TIMESTAMP_SOURCE                    ,
                     CameraCharacteristics.SENSOR_ORIENTATION                              ,
                     CameraCharacteristics.STATISTICS_INFO_AVAILABLE_FACE_DETECT_MODES     ,
                     CameraCharacteristics.STATISTICS_INFO_MAX_FACE_COUNT                  ,
@@ -676,6 +691,7 @@
          */
         {
             CaptureRequest.Key<?> defaultAvailableKeys[] = new CaptureRequest.Key<?>[] {
+                    CaptureRequest.COLOR_CORRECTION_ABERRATION_MODE,
                     CaptureRequest.CONTROL_AE_ANTIBANDING_MODE,
                     CaptureRequest.CONTROL_AE_EXPOSURE_COMPENSATION,
                     CaptureRequest.CONTROL_AE_LOCK,
@@ -699,6 +715,7 @@
                     CaptureRequest.JPEG_THUMBNAIL_QUALITY,
                     CaptureRequest.JPEG_THUMBNAIL_SIZE,
                     CaptureRequest.LENS_FOCAL_LENGTH,
+                    CaptureRequest.NOISE_REDUCTION_MODE,
                     CaptureRequest.SCALER_CROP_REGION,
                     CaptureRequest.STATISTICS_FACE_DETECT_MODE,
             };
@@ -723,6 +740,7 @@
          */
         {
             CaptureResult.Key<?> defaultAvailableKeys[] = new CaptureResult.Key<?>[] {
+                    CaptureResult.COLOR_CORRECTION_ABERRATION_MODE                 ,
                     CaptureResult.CONTROL_AE_ANTIBANDING_MODE                      ,
                     CaptureResult.CONTROL_AE_EXPOSURE_COMPENSATION                 ,
                     CaptureResult.CONTROL_AE_LOCK                                  ,
@@ -740,6 +758,7 @@
                     CaptureResult.JPEG_QUALITY                                     ,
                     CaptureResult.JPEG_THUMBNAIL_QUALITY                           ,
                     CaptureResult.LENS_FOCAL_LENGTH                                ,
+                    CaptureResult.NOISE_REDUCTION_MODE                             ,
                     CaptureResult.REQUEST_PIPELINE_DEPTH                           ,
                     CaptureResult.SCALER_CROP_REGION                               ,
                     CaptureResult.SENSOR_TIMESTAMP                                 ,
@@ -844,6 +863,13 @@
 
             m.set(SENSOR_INFO_PHYSICAL_SIZE, new SizeF(width, height)); // in mm
         }
+
+        /*
+         * sensor.info.timestampSource
+         */
+        {
+            m.set(SENSOR_INFO_TIMESTAMP_SOURCE, SENSOR_INFO_TIMESTAMP_SOURCE_UNKNOWN);
+        }
     }
 
     private static void mapStatistics(CameraMetadataNative m, Parameters p) {
diff --git a/core/java/android/hardware/camera2/legacy/LegacyRequestMapper.java b/core/java/android/hardware/camera2/legacy/LegacyRequestMapper.java
index 42ee4fa..42fe897 100644
--- a/core/java/android/hardware/camera2/legacy/LegacyRequestMapper.java
+++ b/core/java/android/hardware/camera2/legacy/LegacyRequestMapper.java
@@ -80,6 +80,20 @@
             }
         }
 
+        /*
+         * colorCorrection.*
+         */
+        // colorCorrection.aberrationMode
+        {
+            int aberrationMode = ParamsUtils.getOrDefault(request,
+                    COLOR_CORRECTION_ABERRATION_MODE,
+                    /*defaultValue*/COLOR_CORRECTION_ABERRATION_MODE_FAST);
+
+            if (aberrationMode != COLOR_CORRECTION_ABERRATION_MODE_FAST) {
+                Log.w(TAG, "convertRequestToMetadata - Ignoring unsupported " +
+                        "colorCorrection.aberrationMode = " + aberrationMode);
+            }
+        }
 
         /*
          * control.ae*
@@ -419,6 +433,21 @@
                 }
             }
         }
+
+        /*
+         * noiseReduction.*
+         */
+        // noiseReduction.mode
+        {
+            int mode = ParamsUtils.getOrDefault(request,
+                    NOISE_REDUCTION_MODE,
+                    /*defaultValue*/NOISE_REDUCTION_MODE_FAST);
+
+            if (mode != NOISE_REDUCTION_MODE_FAST) {
+                Log.w(TAG, "convertRequestToMetadata - Ignoring unsupported " +
+                        "noiseReduction.mode = " + mode);
+            }
+        }
     }
 
     private static boolean checkForCompleteGpsData(Location location) {
diff --git a/core/java/android/hardware/camera2/legacy/LegacyResultMapper.java b/core/java/android/hardware/camera2/legacy/LegacyResultMapper.java
index ddaa6ee..bad1d28a 100644
--- a/core/java/android/hardware/camera2/legacy/LegacyResultMapper.java
+++ b/core/java/android/hardware/camera2/legacy/LegacyResultMapper.java
@@ -28,14 +28,12 @@
 import android.hardware.camera2.params.MeteringRectangle;
 import android.hardware.camera2.utils.ListUtils;
 import android.hardware.camera2.utils.ParamsUtils;
-import android.location.Location;
 import android.util.Log;
 import android.util.Size;
 
 import java.util.ArrayList;
 import java.util.List;
 
-import static com.android.internal.util.Preconditions.*;
 import static android.hardware.camera2.CaptureResult.*;
 
 /**
@@ -73,7 +71,7 @@
             result = new CameraMetadataNative(mCachedResult);
             cached = true;
         } else {
-            result = convertResultMetadata(legacyRequest, timestamp);
+            result = convertResultMetadata(legacyRequest);
             cached = false;
 
             // Always cache a *copy* of the metadata result,
@@ -106,12 +104,9 @@
      * Generate capture result metadata from the legacy camera request.
      *
      * @param legacyRequest a non-{@code null} legacy request containing the latest parameters
-     * @param timestamp the timestamp to use for this result in nanoseconds.
-     *
      * @return a {@link CameraMetadataNative} object containing result metadata.
      */
-    private static CameraMetadataNative convertResultMetadata(LegacyRequest legacyRequest,
-                                                      long timestamp) {
+    private static CameraMetadataNative convertResultMetadata(LegacyRequest legacyRequest) {
         CameraCharacteristics characteristics = legacyRequest.characteristics;
         CaptureRequest request = legacyRequest.captureRequest;
         Size previewSize = legacyRequest.previewSize;
@@ -125,6 +120,15 @@
                 request.get(CaptureRequest.SCALER_CROP_REGION), previewSize, params);
 
         /*
+         * colorCorrection
+         */
+        // colorCorrection.aberrationMode
+        {
+            // Always hardcoded to FAST
+            result.set(COLOR_CORRECTION_ABERRATION_MODE, COLOR_CORRECTION_ABERRATION_MODE_FAST);
+        }
+
+        /*
          * control
          */
 
@@ -274,7 +278,12 @@
             Log.w(TAG, "Null thumbnail size received from parameters.");
         }
 
-        // TODO: Remaining result metadata tags conversions.
+        /*
+         * noiseReduction.*
+         */
+        // noiseReduction.mode
+        result.set(NOISE_REDUCTION_MODE, NOISE_REDUCTION_MODE_FAST);
+
         return result;
     }
 
diff --git a/core/java/android/net/VpnService.java b/core/java/android/net/VpnService.java
index 050be40..e6f5e32 100644
--- a/core/java/android/net/VpnService.java
+++ b/core/java/android/net/VpnService.java
@@ -212,6 +212,8 @@
      *
      * @return {@code true} on success.
      * @see Builder#addAddress
+     *
+     * @hide
      */
     public boolean addAddress(InetAddress address, int prefixLength) {
         check(address, prefixLength);
@@ -240,6 +242,8 @@
      * @param prefixLength The prefix length of the address.
      *
      * @return {@code true} on success.
+     *
+     * @hide
      */
     public boolean removeAddress(InetAddress address, int prefixLength) {
         check(address, prefixLength);
diff --git a/core/java/android/view/HardwareRenderer.java b/core/java/android/view/HardwareRenderer.java
index edb3798..d23e115 100644
--- a/core/java/android/view/HardwareRenderer.java
+++ b/core/java/android/view/HardwareRenderer.java
@@ -339,7 +339,8 @@
      * @param attachInfo AttachInfo tied to the specified view.
      * @param callbacks Callbacks invoked when drawing happens.
      */
-    abstract void draw(View view, View.AttachInfo attachInfo, HardwareDrawCallbacks callbacks);
+    abstract void draw(View view, View.AttachInfo attachInfo, HardwareDrawCallbacks callbacks,
+            boolean isStartingWindow);
 
     /**
      * Creates a new hardware layer. A hardware layer built by calling this
diff --git a/core/java/android/view/ThreadedRenderer.java b/core/java/android/view/ThreadedRenderer.java
index 5d2822d..3d1332c 100644
--- a/core/java/android/view/ThreadedRenderer.java
+++ b/core/java/android/view/ThreadedRenderer.java
@@ -16,6 +16,7 @@
 
 package android.view;
 
+import android.graphics.Color;
 import com.android.internal.R;
 
 import android.content.Context;
@@ -267,7 +268,8 @@
         view.mRecreateDisplayList = false;
     }
 
-    private void updateRootDisplayList(View view, HardwareDrawCallbacks callbacks) {
+    private void updateRootDisplayList(View view, HardwareDrawCallbacks callbacks,
+            boolean isStartingWindow) {
         Trace.traceBegin(Trace.TRACE_TAG_VIEW, "getDisplayList");
         updateViewTreeDisplayList(view);
 
@@ -279,6 +281,12 @@
                 callbacks.onHardwarePreDraw(canvas);
 
                 canvas.insertReorderBarrier();
+                if (isStartingWindow) {
+                    // Compensate for some situations in which a hw-accelerated surface
+                    // will not be filled with anything by default; this is equivalent
+                    // to the old behavior when the system process was not hw-accelerated
+                    canvas.drawColor(Color.BLACK);
+                }
                 canvas.drawRenderNode(view.getDisplayList());
                 canvas.insertInorderBarrier();
 
@@ -298,7 +306,8 @@
     }
 
     @Override
-    void draw(View view, AttachInfo attachInfo, HardwareDrawCallbacks callbacks) {
+    void draw(View view, AttachInfo attachInfo, HardwareDrawCallbacks callbacks,
+            boolean isStartingWindow) {
         attachInfo.mIgnoreDirtyState = true;
         long frameTimeNanos = mChoreographer.getFrameTimeNanos();
         attachInfo.mDrawingTime = frameTimeNanos / TimeUtils.NANOS_PER_MS;
@@ -308,7 +317,7 @@
             recordDuration = System.nanoTime();
         }
 
-        updateRootDisplayList(view, callbacks);
+        updateRootDisplayList(view, callbacks, isStartingWindow);
 
         if (mProfilingEnabled) {
             recordDuration = System.nanoTime() - recordDuration;
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index 43ab4ef..ae6e4e7 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -711,17 +711,10 @@
             // can be used by code on the system process to escape that and enable
             // HW accelerated drawing.  (This is basically for the lock screen.)
 
-            final boolean fakeHwAccelerated = (attrs.privateFlags &
-                    WindowManager.LayoutParams.PRIVATE_FLAG_FAKE_HARDWARE_ACCELERATED) != 0;
             final boolean forceHwAccelerated = (attrs.privateFlags &
                     WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_HARDWARE_ACCELERATED) != 0;
 
-            if (fakeHwAccelerated) {
-                // This is exclusively for the preview windows the window manager
-                // shows for launching applications, so they will look more like
-                // the app being launched.
-                mAttachInfo.mHardwareAccelerationRequested = true;
-            } else if (!HardwareRenderer.sRendererDisabled
+            if (!HardwareRenderer.sRendererDisabled
                     || (HardwareRenderer.sSystemRendererDisabled && forceHwAccelerated)) {
                 if (mAttachInfo.mHardwareRenderer != null) {
                     mAttachInfo.mHardwareRenderer.destroy();
@@ -2486,7 +2479,8 @@
                 dirty.setEmpty();
 
                 mBlockResizeBuffer = false;
-                mAttachInfo.mHardwareRenderer.draw(mView, mAttachInfo, this);
+                mAttachInfo.mHardwareRenderer.draw(mView, mAttachInfo, this,
+                        params.type == WindowManager.LayoutParams.TYPE_APPLICATION_STARTING);
             } else {
                 // If we get here with a disabled & requested hardware renderer, something went
                 // wrong (an invalidate posted right before we destroyed the hardware surface
diff --git a/core/java/android/view/WindowManager.java b/core/java/android/view/WindowManager.java
index 47ee52e..273ec9d 100644
--- a/core/java/android/view/WindowManager.java
+++ b/core/java/android/view/WindowManager.java
@@ -1024,26 +1024,6 @@
         public int flags;
 
         /**
-         * If the window has requested hardware acceleration, but this is not
-         * allowed in the process it is in, then still render it as if it is
-         * hardware accelerated.  This is used for the starting preview windows
-         * in the system process, which don't need to have the overhead of
-         * hardware acceleration (they are just a static rendering), but should
-         * be rendered as such to match the actual window of the app even if it
-         * is hardware accelerated.
-         * Even if the window isn't hardware accelerated, still do its rendering
-         * as if it was.
-         * Like {@link #FLAG_HARDWARE_ACCELERATED} except for trusted system windows
-         * that need hardware acceleration (e.g. LockScreen), where hardware acceleration
-         * is generally disabled. This flag must be specified in addition to 
-         * {@link #FLAG_HARDWARE_ACCELERATED} to enable hardware acceleration for system
-         * windows.
-         * 
-         * @hide
-         */
-        public static final int PRIVATE_FLAG_FAKE_HARDWARE_ACCELERATED = 0x00000001;
-
-        /**
          * In the system process, we globally do not use hardware acceleration
          * because there are many threads doing UI there and they conflict.
          * If certain parts of the UI that really do want to use hardware
diff --git a/core/jni/android/graphics/Path.cpp b/core/jni/android/graphics/Path.cpp
index 6ef1d2c..9d3e74b 100644
--- a/core/jni/android/graphics/Path.cpp
+++ b/core/jni/android/graphics/Path.cpp
@@ -435,19 +435,32 @@
         std::vector<float> lengths;
         float errorSquared = acceptableError * acceptableError;
 
-        while ((verb = pathIter.next(points)) != SkPath::kDone_Verb) {
+        while ((verb = pathIter.next(points, false)) != SkPath::kDone_Verb) {
             createVerbSegments(verb, points, segmentPoints, lengths, errorSquared);
         }
 
         if (segmentPoints.empty()) {
-            return NULL;
+            int numVerbs = path->countVerbs();
+            if (numVerbs == 1) {
+                addMove(segmentPoints, lengths, path->getPoint(0));
+            } else {
+                // Invalid or empty path. Fall back to point(0,0)
+                addMove(segmentPoints, lengths, SkPoint());
+            }
+        }
+
+        float totalLength = lengths.back();
+        if (totalLength == 0) {
+            // Lone Move instructions should still be able to animate at the same value.
+            segmentPoints.push_back(segmentPoints.back());
+            lengths.push_back(1);
+            totalLength = 1;
         }
 
         size_t numPoints = segmentPoints.size();
         size_t approximationArraySize = numPoints * 3;
 
         float* approximation = new float[approximationArraySize];
-        float totalLength = lengths.back();
 
         int approximationIndex = 0;
         for (size_t i = 0; i < numPoints; i++) {
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index ee699ed..3907fc5 100644
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -360,6 +360,9 @@
     <!-- Boolean indicating associated network selection is allowed -->
     <bool translatable="false" name="config_wifi_framework_enable_associated_network_selection">true</bool>
 
+    <!-- Boolean indicating that wifi only link configuratios that have exact same credentials (i.e PSK) -->
+    <bool translatable="false" name="config_wifi_only_link_same_credential_configurations">true</bool>
+
     <!-- Wifi driver stop delay, in milliseconds.
          Default value is 2 minutes. -->
     <integer translatable="false" name="config_wifi_driver_stop_delay">120000</integer>
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index c578263..7fc522f 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -296,7 +296,7 @@
   <java-symbol type="bool" name="config_windowEnableCircularEmulatorDisplayOverlay" />
   <java-symbol type="bool" name="config_wifi_framework_enable_associated_autojoin_scan" />
   <java-symbol type="bool" name="config_wifi_framework_enable_associated_network_selection" />
-
+  <java-symbol type="bool" name="config_wifi_only_link_same_credential_configurations" />
   <java-symbol type="integer" name="config_bluetooth_max_advertisers" />
   <java-symbol type="integer" name="config_bluetooth_max_scan_filters" />
   <java-symbol type="integer" name="config_cursorWindowSize" />
diff --git a/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/WifiAssociationTestRunner.java b/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/WifiAssociationTestRunner.java
index 2354484..f4ea6f2 100644
--- a/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/WifiAssociationTestRunner.java
+++ b/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/WifiAssociationTestRunner.java
@@ -16,17 +16,12 @@
 
 package com.android.connectivitymanagertest;
 
-import android.content.Context;
-import android.net.wifi.WifiManager;
-import android.os.Bundle;
 import android.test.InstrumentationTestRunner;
 import android.test.InstrumentationTestSuite;
-import android.util.Log;
 
 import com.android.connectivitymanagertest.functional.WifiAssociationTest;
 
 import junit.framework.TestSuite;
-import junit.framework.Assert;
 
 /**
  * Instrumentation Test Runner for wifi association test.
@@ -39,8 +34,6 @@
  * -w com.android.connectivitymanagertest/.WifiAssociationTestRunner"
  */
 public class WifiAssociationTestRunner extends InstrumentationTestRunner {
-    private static final String TAG = "WifiAssociationTestRunner";
-    public int mBand;
 
     @Override
     public TestSuite getAllTests() {
@@ -53,35 +46,4 @@
     public ClassLoader getLoader() {
         return WifiAssociationTestRunner.class.getClassLoader();
     }
-
-    @Override
-    public void onCreate(Bundle icicle) {
-        super.onCreate(icicle);
-        String mFrequencyBand = icicle.getString("frequency-band");
-        if (mFrequencyBand != null) {
-            setFrequencyBand(mFrequencyBand);
-        }
-    }
-
-    private void setFrequencyBand(String band) {
-        WifiManager mWifiManager = (WifiManager)getContext().getSystemService(Context.WIFI_SERVICE);
-        if (band.equals("2.4")) {
-            Log.v(TAG, "set frequency band to 2.4");
-            mBand = WifiManager.WIFI_FREQUENCY_BAND_2GHZ;
-        } else if (band.equals("5.0")) {
-            Log.v(TAG, "set frequency band to 5.0");
-            mBand = WifiManager.WIFI_FREQUENCY_BAND_5GHZ;
-        } else if (band.equals("auto")) {
-            Log.v(TAG, "set frequency band to auto");
-            mBand = WifiManager.WIFI_FREQUENCY_BAND_AUTO;
-        } else {
-            Assert.fail("invalid frequency band");
-        }
-        int currentFreq = mWifiManager.getFrequencyBand();
-        if (mBand == currentFreq) {
-            Log.v(TAG, "frequency band has been set");
-            return;
-        }
-        mWifiManager.setFrequencyBand(mBand, true);
-    }
 }
diff --git a/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/functional/WifiAssociationTest.java b/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/functional/WifiAssociationTest.java
index c2b80dc..68f3179 100644
--- a/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/functional/WifiAssociationTest.java
+++ b/core/tests/ConnectivityManagerTest/src/com/android/connectivitymanagertest/functional/WifiAssociationTest.java
@@ -16,14 +16,13 @@
 
 package com.android.connectivitymanagertest.functional;
 
-import android.net.ConnectivityManager;
-import android.net.NetworkInfo.State;
 import android.net.wifi.WifiConfiguration;
 import android.net.wifi.WifiConfiguration.AuthAlgorithm;
 import android.net.wifi.WifiConfiguration.GroupCipher;
 import android.net.wifi.WifiConfiguration.PairwiseCipher;
 import android.net.wifi.WifiConfiguration.Protocol;
 import android.net.wifi.WifiInfo;
+import android.net.wifi.WifiManager;
 import android.os.Bundle;
 import android.test.suitebuilder.annotation.LargeTest;
 
@@ -39,13 +38,7 @@
  * -w com.android.connectivitymanagertest/.WifiAssociationTestRunner"
  */
 public class WifiAssociationTest extends ConnectivityManagerTestBase {
-    private String mSsid = null;
-    private String mPassword = null;
-    private String mSecurityType = null;
-    private String mFrequencyBand = null;
-    private int mBand;
-
-    enum SECURITY_TYPE {
+    private enum SecurityType {
         OPEN, WEP64, WEP128, WPA_TKIP, WPA2_AES
     }
 
@@ -53,86 +46,106 @@
         super(WifiAssociationTest.class.getSimpleName());
     }
 
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-        WifiAssociationTestRunner runner = (WifiAssociationTestRunner)getInstrumentation();
-        Bundle arguments = runner.getArguments();
-        mSecurityType = arguments.getString("security-type");
-        mSsid = arguments.getString("ssid");
-        mPassword = arguments.getString("password");
-        mFrequencyBand = arguments.getString("frequency-band");
-        mBand = runner.mBand;
-        assertNotNull("security type is empty", mSecurityType);
-        assertNotNull("ssid is empty", mSsid);
-        validateFrequencyBand();
-
-        // enable wifi and verify wpa_supplicant is started
-        assertTrue("enable Wifi failed", enableWifi());
-        assertTrue("wifi not connected", waitForNetworkState(
-                ConnectivityManager.TYPE_WIFI, State.CONNECTED, LONG_TIMEOUT));
-        WifiInfo wi = mWifiManager.getConnectionInfo();
-        assertNotNull("no active wifi info", wi);
-        assertTrue("failed to ping wpa_supplicant ", mWifiManager.pingSupplicant());
-    }
-
-    private void validateFrequencyBand() {
-        if (mFrequencyBand != null) {
-            int currentFreq = mWifiManager.getFrequencyBand();
-            logv("read frequency band: " + currentFreq);
-            assertEquals("specified frequency band does not match operational band of WifiManager",
-                    currentFreq, mBand);
-         }
-    }
-
+    /**
+     * Test that the wifi can associate with a given access point.
+     */
     @LargeTest
     public void testWifiAssociation() {
-        assertNotNull("no test ssid", mSsid);
+        WifiAssociationTestRunner runner = (WifiAssociationTestRunner) getInstrumentation();
+        Bundle arguments = runner.getArguments();
+
+        String ssid = arguments.getString("ssid");
+        assertNotNull("ssid is empty", ssid);
+
+        String securityTypeStr = arguments.getString("security-type");
+        assertNotNull("security-type is empty", securityTypeStr);
+        SecurityType securityType = SecurityType.valueOf(securityTypeStr);
+
+        String password = arguments.getString("password");
+
+        String freqStr = arguments.getString("frequency-band");
+        if (freqStr != null) {
+            setFrequencyBand(freqStr);
+        }
+
+        assertTrue("enable Wifi failed", enableWifi());
+        WifiInfo wi = mWifiManager.getConnectionInfo();
+        logv("%s", wi);
+        assertNotNull("no active wifi info", wi);
+
+        WifiConfiguration config = getConfig(ssid, securityType, password);
+
+        logv("Network config: %s", config.toString());
+        connectToWifi(config);
+    }
+
+    /**
+     * Set the frequency band and verify that it has been set.
+     */
+    private void setFrequencyBand(String frequencyBandStr) {
+        int frequencyBand = -1;
+        if ("2.4".equals(frequencyBandStr)) {
+            frequencyBand = WifiManager.WIFI_FREQUENCY_BAND_2GHZ;
+        } else if ("5.0".equals(frequencyBandStr)) {
+            frequencyBand = WifiManager.WIFI_FREQUENCY_BAND_5GHZ;
+        } else if ("auto".equals(frequencyBandStr)) {
+            frequencyBand = WifiManager.WIFI_FREQUENCY_BAND_AUTO;
+        } else {
+            fail("Invalid frequency-band");
+        }
+        if (mWifiManager.getFrequencyBand() != frequencyBand) {
+            logv("Set frequency band to %s", frequencyBandStr);
+            mWifiManager.setFrequencyBand(frequencyBand, true);
+        }
+        assertEquals("Specified frequency band does not match operational band",
+                frequencyBand, mWifiManager.getFrequencyBand());
+    }
+
+    /**
+     * Get the {@link WifiConfiguration} based on ssid, security, and password.
+     */
+    private WifiConfiguration getConfig(String ssid, SecurityType securityType, String password) {
+        logv("Security type is %s", securityType.toString());
+
         WifiConfiguration config = null;
-        SECURITY_TYPE security = SECURITY_TYPE.valueOf(mSecurityType);
-        logv("Security type is " + security.toString());
-        switch (security) {
-            // set network configurations
+        switch (securityType) {
             case OPEN:
-                config = WifiConfigurationHelper.createOpenConfig(mSsid);
+                config = WifiConfigurationHelper.createOpenConfig(ssid);
                 break;
             case WEP64:
-                assertNotNull("password is empty", mPassword);
+                assertNotNull("password is empty", password);
                 // always use hex pair for WEP-40
-                assertTrue(WifiConfigurationHelper.isHex(mPassword, 10));
-                config = WifiConfigurationHelper.createWepConfig(mSsid, mPassword);
+                assertTrue(WifiConfigurationHelper.isHex(password, 10));
+                config = WifiConfigurationHelper.createWepConfig(ssid, password);
                 config.allowedGroupCiphers.set(GroupCipher.WEP40);
                 break;
             case WEP128:
-                assertNotNull("password is empty", mPassword);
+                assertNotNull("password is empty", password);
                 // always use hex pair for WEP-104
-                assertTrue(WifiConfigurationHelper.isHex(mPassword, 26));
-                config = WifiConfigurationHelper.createWepConfig(mSsid, mPassword);
+                assertTrue(WifiConfigurationHelper.isHex(password, 26));
+                config = WifiConfigurationHelper.createWepConfig(ssid, password);
                 config.allowedGroupCiphers.set(GroupCipher.WEP104);
                 break;
             case WPA_TKIP:
-                assertNotNull("password is empty", mPassword);
-                config = WifiConfigurationHelper.createPskConfig(mSsid, mPassword);
+                assertNotNull("password is empty", password);
+                config = WifiConfigurationHelper.createPskConfig(ssid, password);
                 config.allowedAuthAlgorithms.set(AuthAlgorithm.OPEN);
                 config.allowedProtocols.set(Protocol.WPA);
                 config.allowedPairwiseCiphers.set(PairwiseCipher.TKIP);
                 config.allowedGroupCiphers.set(GroupCipher.TKIP);
                 break;
             case WPA2_AES:
-                assertNotNull("password is empty", mPassword);
-                config = WifiConfigurationHelper.createPskConfig(mSsid, mPassword);
+                assertNotNull("password is empty", password);
+                config = WifiConfigurationHelper.createPskConfig(ssid, password);
                 config.allowedAuthAlgorithms.set(AuthAlgorithm.OPEN);
                 config.allowedProtocols.set(Protocol.RSN);
                 config.allowedPairwiseCiphers.set(PairwiseCipher.CCMP);
                 config.allowedGroupCiphers.set(GroupCipher.CCMP);
                 break;
             default:
-                fail("Not a valid security type: " + mSecurityType);
+                fail("Not a valid security type: " + securityType);
                 break;
         }
-        logv("network config: %s", config.toString());
-        connectToWifi(config);
-        // verify that connection actually works
-        assertTrue("no network connectivity at end of test", checkNetworkConnectivity());
+        return config;
     }
 }
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp
index dbd273d..31cc1c8 100755
--- a/libs/hwui/OpenGLRenderer.cpp
+++ b/libs/hwui/OpenGLRenderer.cpp
@@ -54,10 +54,6 @@
 namespace android {
 namespace uirenderer {
 
-///////////////////////////////////////////////////////////////////////////////
-// Defines
-///////////////////////////////////////////////////////////////////////////////
-
 static GLenum getFilter(const SkPaint* paint) {
     if (!paint || paint->getFilterLevel() != SkPaint::kNone_FilterLevel) {
         return GL_LINEAR;
@@ -3044,21 +3040,35 @@
 }
 
 void OpenGLRenderer::setupPaintFilter(int clearBits, int setBits) {
+    // TODO: don't bother with boolean, it's redundant with clear/set bits
     mDrawModifiers.mHasDrawFilter = true;
     mDrawModifiers.mPaintFilterClearBits = clearBits & SkPaint::kAllFlags;
     mDrawModifiers.mPaintFilterSetBits = setBits & SkPaint::kAllFlags;
 }
 
 const SkPaint* OpenGLRenderer::filterPaint(const SkPaint* paint) {
+    // TODO: use CompatFlagsDrawFilter here, and combine logic with android/graphics/DrawFilter.cpp
+    // to avoid clobbering 0x02 paint flag
+
+    // Equivalent to the Java Paint's FILTER_BITMAP_FLAG.
+    static const uint32_t sFilterBitmapFlag = 0x02;
+
     if (CC_LIKELY(!mDrawModifiers.mHasDrawFilter || !paint)) {
         return paint;
     }
 
-    uint32_t flags = paint->getFlags();
+    const uint32_t clearBits = mDrawModifiers.mPaintFilterClearBits;
+    const uint32_t setBits = mDrawModifiers.mPaintFilterSetBits;
 
+    const uint32_t flags = (paint->getFlags() & ~clearBits) | setBits;
     mFilteredPaint = *paint;
-    mFilteredPaint.setFlags((flags & ~mDrawModifiers.mPaintFilterClearBits) |
-            mDrawModifiers.mPaintFilterSetBits);
+    mFilteredPaint.setFlags(flags);
+
+    // check if paint filter trying to override bitmap filter
+    if ((clearBits | setBits) & sFilterBitmapFlag) {
+        mFilteredPaint.setFilterLevel(flags & sFilterBitmapFlag
+                ? SkPaint::kLow_FilterLevel : SkPaint::kNone_FilterLevel);
+    }
 
     return &mFilteredPaint;
 }
diff --git a/libs/hwui/TessellationCache.cpp b/libs/hwui/TessellationCache.cpp
index 9e62f36..1e38f9e 100644
--- a/libs/hwui/TessellationCache.cpp
+++ b/libs/hwui/TessellationCache.cpp
@@ -216,7 +216,7 @@
 
     // tessellate caster outline into a 2d polygon
     Vector<Vertex> casterVertices2d;
-    const float casterRefinementThresholdSquared = 20.0f; // TODO: experiment with this value
+    const float casterRefinementThresholdSquared = 4.0f;
     PathTessellator::approximatePathOutlineVertices(*casterPerimeter,
             casterRefinementThresholdSquared, casterVertices2d);
     if (!ShadowTessellator::isClockwisePath(*casterPerimeter)) {
diff --git a/media/java/android/media/projection/IMediaProjection.aidl b/media/java/android/media/projection/IMediaProjection.aidl
index 3d25aa6..19fc052 100644
--- a/media/java/android/media/projection/IMediaProjection.aidl
+++ b/media/java/android/media/projection/IMediaProjection.aidl
@@ -26,6 +26,6 @@
     boolean canProjectVideo();
     boolean canProjectSecureVideo();
     int applyVirtualDisplayFlags(int flags);
-    void addCallback(IMediaProjectionCallback callback);
-    void removeCallback(IMediaProjectionCallback callback);
+    void registerCallback(IMediaProjectionCallback callback);
+    void unregisterCallback(IMediaProjectionCallback callback);
 }
diff --git a/media/java/android/media/projection/MediaProjection.java b/media/java/android/media/projection/MediaProjection.java
index 3a74d93..e6dadf9 100644
--- a/media/java/android/media/projection/MediaProjection.java
+++ b/media/java/android/media/projection/MediaProjection.java
@@ -40,7 +40,7 @@
  *
  * <p>
  * A screen capture session can be started through {@link
- * MediaProjectionManager#getScreenCaptureIntent}. This grants the ability to
+ * MediaProjectionManager#createScreenCaptureIntent}. This grants the ability to
  * capture screen contents, but not system audio.
  * </p>
  */
@@ -70,9 +70,9 @@
      * @param handler The handler on which the callback should be invoked, or
      * null if the callback should be invoked on the calling thread's looper.
      *
-     * @see #removeCallback
+     * @see #unregisterCallback
      */
-    public void addCallback(Callback callback, Handler handler) {
+    public void registerCallback(Callback callback, Handler handler) {
         if (callback == null) {
             throw new IllegalArgumentException("callback should not be null");
         }
@@ -83,9 +83,9 @@
      *
      * @param callback The callback to unregister.
      *
-     * @see #addCallback
+     * @see #registerCallback
      */
-    public void removeCallback(Callback callback) {
+    public void unregisterCallback(Callback callback) {
         if (callback == null) {
             throw new IllegalArgumentException("callback should not be null");
         }
diff --git a/media/java/android/media/projection/MediaProjectionManager.java b/media/java/android/media/projection/MediaProjectionManager.java
index 50d66c6..a1cfc35 100644
--- a/media/java/android/media/projection/MediaProjectionManager.java
+++ b/media/java/android/media/projection/MediaProjectionManager.java
@@ -75,7 +75,7 @@
      * the user whether to allow screen capture.  The result of this
      * activity should be passed to getMediaProjection.
      */
-    public Intent getScreenCaptureIntent() {
+    public Intent createScreenCaptureIntent() {
         Intent i = new Intent();
         i.setClassName("com.android.systemui",
                 "com.android.systemui.media.MediaProjectionPermissionActivity");
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
index 16bb00b..9daa190 100644
--- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
@@ -1826,8 +1826,6 @@
             params.packageName = packageName;
             params.windowAnimations = win.getWindowStyle().getResourceId(
                     com.android.internal.R.styleable.Window_windowAnimationStyle, 0);
-            params.privateFlags |=
-                    WindowManager.LayoutParams.PRIVATE_FLAG_FAKE_HARDWARE_ACCELERATED;
             params.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_SHOW_FOR_ALL_USERS;
 
             if (!compatInfo.supportsScreen()) {
diff --git a/services/core/java/com/android/server/AlarmManagerService.java b/services/core/java/com/android/server/AlarmManagerService.java
index e9419ad..b04cc19 100644
--- a/services/core/java/com/android/server/AlarmManagerService.java
+++ b/services/core/java/com/android/server/AlarmManagerService.java
@@ -1535,7 +1535,7 @@
         for (int i=0; i<triggerList.size(); i++) {
             Alarm alarm = triggerList.get(i);
             try {
-                if (localLOGV) Slog.v(TAG, "sending alarm " + alarm);
+                Slog.v(TAG, "sending alarm " + alarm);
                 alarm.operation.send(getContext(), 0,
                         mBackgroundIntent.putExtra(
                                 Intent.EXTRA_ALARM_COUNT, alarm.count),
diff --git a/services/core/java/com/android/server/display/VirtualDisplayAdapter.java b/services/core/java/com/android/server/display/VirtualDisplayAdapter.java
index f6399a3..a6a9a89 100644
--- a/services/core/java/com/android/server/display/VirtualDisplayAdapter.java
+++ b/services/core/java/com/android/server/display/VirtualDisplayAdapter.java
@@ -69,7 +69,7 @@
 
         try {
             if (projection != null) {
-                projection.addCallback(new MediaProjectionCallback(appToken));
+                projection.registerCallback(new MediaProjectionCallback(appToken));
             }
             appToken.linkToDeath(device, 0);
         } catch (RemoteException ex) {
diff --git a/services/core/java/com/android/server/media/projection/MediaProjectionManagerService.java b/services/core/java/com/android/server/media/projection/MediaProjectionManagerService.java
index 8ec9b254..8a1f3ad 100644
--- a/services/core/java/com/android/server/media/projection/MediaProjectionManagerService.java
+++ b/services/core/java/com/android/server/media/projection/MediaProjectionManagerService.java
@@ -389,7 +389,7 @@
                     throw new IllegalStateException(
                             "Cannot start already started MediaProjection");
                 }
-                addCallback(callback);
+                registerCallback(callback);
                 try {
                     mToken = callback.asBinder();
                     mDeathEater = new IBinder.DeathRecipient() {
@@ -424,7 +424,7 @@
         }
 
         @Override
-        public void addCallback(IMediaProjectionCallback callback) {
+        public void registerCallback(IMediaProjectionCallback callback) {
             if (callback == null) {
                 throw new IllegalArgumentException("callback must not be null");
             }
@@ -432,7 +432,7 @@
         }
 
         @Override
-        public void removeCallback(IMediaProjectionCallback callback) {
+        public void unregisterCallback(IMediaProjectionCallback callback) {
             if (callback == null) {
                 throw new IllegalArgumentException("callback must not be null");
             }
diff --git a/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java b/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java
index e1ade63..a8245e7 100644
--- a/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java
+++ b/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java
@@ -843,7 +843,7 @@
             }
             File file = new File(dir, WALLPAPER);
             ParcelFileDescriptor fd = ParcelFileDescriptor.open(file,
-                    MODE_CREATE|MODE_READ_WRITE);
+                    MODE_CREATE|MODE_READ_WRITE|MODE_TRUNCATE);
             if (!SELinux.restorecon(file)) {
                 return null;
             }
diff --git a/telecomm/java/android/telecomm/Connection.java b/telecomm/java/android/telecomm/Connection.java
index 729686d..2f25dcf 100644
--- a/telecomm/java/android/telecomm/Connection.java
+++ b/telecomm/java/android/telecomm/Connection.java
@@ -68,13 +68,13 @@
     /** @hide */
     public abstract static class Listener {
         public void onStateChanged(Connection c, int state) {}
-        public void onHandleChanged(Connection c, Uri newHandle, int presentation) {}
+        public void onAddressChanged(Connection c, Uri newAddress, int presentation) {}
         public void onCallerDisplayNameChanged(
                 Connection c, String callerDisplayName, int presentation) {}
         public void onVideoStateChanged(Connection c, int videoState) {}
         public void onDisconnected(Connection c, int cause, String message) {}
         public void onPostDialWait(Connection c, String remaining) {}
-        public void onRequestingRingback(Connection c, boolean ringback) {}
+        public void onRingbackRequested(Connection c, boolean ringback) {}
         public void onDestroyed(Connection c) {}
         public void onCallCapabilitiesChanged(Connection c, int callCapabilities) {}
         public void onVideoProviderChanged(
@@ -464,11 +464,11 @@
 
     private int mState = STATE_NEW;
     private AudioState mAudioState;
-    private Uri mHandle;
-    private int mHandlePresentation;
+    private Uri mAddress;
+    private int mAddressPresentation;
     private String mCallerDisplayName;
     private int mCallerDisplayNamePresentation;
-    private boolean mRequestingRingback = false;
+    private boolean mRingbackRequested = false;
     private int mCallCapabilities;
     private VideoProvider mVideoProvider;
     private boolean mAudioModeIsVoip;
@@ -485,18 +485,18 @@
     public Connection() {}
 
     /**
-     * @return The handle (e.g., phone number) to which this Connection is currently communicating.
+     * @return The address (e.g., phone number) to which this Connection is currently communicating.
      */
-    public final Uri getHandle() {
-        return mHandle;
+    public final Uri getAddress() {
+        return mAddress;
     }
 
     /**
-     * @return The presentation requirements for the handle.
+     * @return The presentation requirements for the address.
      *         See {@link TelecommManager} for valid values.
      */
-    public final int getHandlePresentation() {
-        return mHandlePresentation;
+    public final int getAddressPresentation() {
+        return mAddressPresentation;
     }
 
     /**
@@ -556,8 +556,8 @@
      * Returns whether this connection is requesting that the system play a ringback tone
      * on its behalf.
      */
-    public final boolean isRequestingRingback() {
-        return mRequestingRingback;
+    public final boolean isRingbackRequested() {
+        return mRingbackRequested;
     }
 
     /**
@@ -662,18 +662,18 @@
     }
 
     /**
-     * Sets the value of the {@link #getHandle()} property.
+     * Sets the value of the {@link #getAddress()} property.
      *
-     * @param handle The new handle.
-     * @param presentation The presentation requirements for the handle.
+     * @param address The new address.
+     * @param presentation The presentation requirements for the address.
      *        See {@link TelecommManager} for valid values.
      */
-    public final void setHandle(Uri handle, int presentation) {
-        Log.d(this, "setHandle %s", handle);
-        mHandle = handle;
-        mHandlePresentation = presentation;
+    public final void setAddress(Uri address, int presentation) {
+        Log.d(this, "setAddress %s", address);
+        mAddress = address;
+        mAddressPresentation = presentation;
         for (Listener l : mListeners) {
-            l.onHandleChanged(this, handle, presentation);
+            l.onAddressChanged(this, address, presentation);
         }
     }
 
@@ -716,7 +716,7 @@
      * communicate).
      */
     public final void setActive() {
-        setRequestingRingback(false);
+        setRingbackRequested(false);
         setState(STATE_ACTIVE);
     }
 
@@ -804,11 +804,11 @@
      *
      * @param ringback Whether the ringback tone is to be played.
      */
-    public final void setRequestingRingback(boolean ringback) {
-        if (mRequestingRingback != ringback) {
-            mRequestingRingback = ringback;
+    public final void setRingbackRequested(boolean ringback) {
+        if (mRingbackRequested != ringback) {
+            mRingbackRequested = ringback;
             for (Listener l : mListeners) {
-                l.onRequestingRingback(this, ringback);
+                l.onRingbackRequested(this, ringback);
             }
         }
     }
diff --git a/telecomm/java/android/telecomm/ConnectionService.java b/telecomm/java/android/telecomm/ConnectionService.java
index 76e208b..036d397 100644
--- a/telecomm/java/android/telecomm/ConnectionService.java
+++ b/telecomm/java/android/telecomm/ConnectionService.java
@@ -414,9 +414,9 @@
         }
 
         @Override
-        public void onHandleChanged(Connection c, Uri handle, int presentation) {
+        public void onAddressChanged(Connection c, Uri address, int presentation) {
             String id = mIdByConnection.get(c);
-            mAdapter.setHandle(id, handle, presentation);
+            mAdapter.setAddress(id, address, presentation);
         }
 
         @Override
@@ -439,10 +439,10 @@
         }
 
         @Override
-        public void onRequestingRingback(Connection c, boolean ringback) {
+        public void onRingbackRequested(Connection c, boolean ringback) {
             String id = mIdByConnection.get(c);
             Log.d(this, "Adapter onRingback %b", ringback);
-            mAdapter.setRequestingRingback(id, ringback);
+            mAdapter.setRingbackRequested(id, ringback);
         }
 
         @Override
@@ -462,7 +462,7 @@
         @Override
         public void onAudioModeIsVoipChanged(Connection c, boolean isVoip) {
             String id = mIdByConnection.get(c);
-            mAdapter.setAudioModeIsVoip(id, isVoip);
+            mAdapter.setIsVoipAudioMode(id, isVoip);
         }
 
         @Override
@@ -523,8 +523,8 @@
             addConnection(callId, connection);
         }
 
-        Uri handle = connection.getHandle();
-        String number = handle == null ? "null" : handle.getSchemeSpecificPart();
+        Uri address = connection.getAddress();
+        String number = address == null ? "null" : address.getSchemeSpecificPart();
         Log.v(this, "createConnection, number: %s, state: %s, capabilities: %s",
                 Connection.toLogSafePhoneNumber(number),
                 Connection.stateToString(connection.getState()),
@@ -538,14 +538,14 @@
                         request.getAccountHandle(),
                         connection.getState(),
                         connection.getCallCapabilities(),
-                        connection.getHandle(),
-                        connection.getHandlePresentation(),
+                        connection.getAddress(),
+                        connection.getAddressPresentation(),
                         connection.getCallerDisplayName(),
                         connection.getCallerDisplayNamePresentation(),
                         connection.getVideoProvider() == null ?
                                 null : connection.getVideoProvider().getInterface(),
                         connection.getVideoState(),
-                        connection.isRequestingRingback(),
+                        connection.isRingbackRequested(),
                         connection.getAudioModeIsVoip(),
                         connection.getStatusHints(),
                         connection.getDisconnectCause(),
diff --git a/telecomm/java/android/telecomm/ConnectionServiceAdapter.java b/telecomm/java/android/telecomm/ConnectionServiceAdapter.java
index e3dc713..19f42d6 100644
--- a/telecomm/java/android/telecomm/ConnectionServiceAdapter.java
+++ b/telecomm/java/android/telecomm/ConnectionServiceAdapter.java
@@ -168,10 +168,10 @@
      * @param callId The unique ID of the call whose ringback is being changed.
      * @param ringback Whether Telecomm should start playing a ringback tone.
      */
-    void setRequestingRingback(String callId, boolean ringback) {
+    void setRingbackRequested(String callId, boolean ringback) {
         for (IConnectionServiceAdapter adapter : mAdapters) {
             try {
-                adapter.setRequestingRingback(callId, ringback);
+                adapter.setRingbackRequested(callId, ringback);
             } catch (RemoteException e) {
             }
         }
@@ -280,10 +280,10 @@
      * @param callId The unique ID of the call to set with the given call video provider.
      * @param isVoip True if the audio mode is VOIP.
      */
-    void setAudioModeIsVoip(String callId, boolean isVoip) {
+    void setIsVoipAudioMode(String callId, boolean isVoip) {
         for (IConnectionServiceAdapter adapter : mAdapters) {
             try {
-                adapter.setAudioModeIsVoip(callId, isVoip);
+                adapter.setIsVoipAudioMode(callId, isVoip);
             } catch (RemoteException e) {
             }
         }
@@ -298,10 +298,10 @@
         }
     }
 
-    void setHandle(String callId, Uri handle, int presentation) {
+    void setAddress(String callId, Uri address, int presentation) {
         for (IConnectionServiceAdapter adapter : mAdapters) {
             try {
-                adapter.setHandle(callId, handle, presentation);
+                adapter.setAddress(callId, address, presentation);
             } catch (RemoteException e) {
             }
         }
diff --git a/telecomm/java/android/telecomm/ConnectionServiceAdapterServant.java b/telecomm/java/android/telecomm/ConnectionServiceAdapterServant.java
index 21e99db..2aac7fc 100644
--- a/telecomm/java/android/telecomm/ConnectionServiceAdapterServant.java
+++ b/telecomm/java/android/telecomm/ConnectionServiceAdapterServant.java
@@ -44,7 +44,7 @@
     private static final int MSG_SET_DIALING = 4;
     private static final int MSG_SET_DISCONNECTED = 5;
     private static final int MSG_SET_ON_HOLD = 6;
-    private static final int MSG_SET_REQUESTING_RINGBACK = 7;
+    private static final int MSG_SET_RINGBACK_REQUESTED = 7;
     private static final int MSG_SET_CALL_CAPABILITIES = 8;
     private static final int MSG_SET_IS_CONFERENCED = 9;
     private static final int MSG_ADD_CONFERENCE_CALL = 10;
@@ -53,9 +53,9 @@
     private static final int MSG_QUERY_REMOTE_CALL_SERVICES = 13;
     private static final int MSG_SET_VIDEO_STATE = 14;
     private static final int MSG_SET_VIDEO_CALL_PROVIDER = 15;
-    private static final int MSG_SET_AUDIO_MODE_IS_VOIP = 16;
+    private static final int MSG_SET_IS_VOIP_AUDIO_MODE = 16;
     private static final int MSG_SET_STATUS_HINTS = 17;
-    private static final int MSG_SET_HANDLE = 18;
+    private static final int MSG_SET_ADDRESS = 18;
     private static final int MSG_SET_CALLER_DISPLAY_NAME = 19;
     private static final int MSG_SET_CONFERENCEABLE_CONNECTIONS = 20;
 
@@ -107,8 +107,8 @@
                 case MSG_SET_ON_HOLD:
                     mDelegate.setOnHold((String) msg.obj);
                     break;
-                case MSG_SET_REQUESTING_RINGBACK:
-                    mDelegate.setRequestingRingback((String) msg.obj, msg.arg1 == 1);
+                case MSG_SET_RINGBACK_REQUESTED:
+                    mDelegate.setRingbackRequested((String) msg.obj, msg.arg1 == 1);
                     break;
                 case MSG_SET_CALL_CAPABILITIES:
                     mDelegate.setCallCapabilities((String) msg.obj, msg.arg1);
@@ -160,8 +160,8 @@
                     }
                     break;
                 }
-                case MSG_SET_AUDIO_MODE_IS_VOIP:
-                    mDelegate.setAudioModeIsVoip((String) msg.obj, msg.arg1 == 1);
+                case MSG_SET_IS_VOIP_AUDIO_MODE:
+                    mDelegate.setIsVoipAudioMode((String) msg.obj, msg.arg1 == 1);
                     break;
                 case MSG_SET_STATUS_HINTS: {
                     SomeArgs args = (SomeArgs) msg.obj;
@@ -172,10 +172,10 @@
                     }
                     break;
                 }
-                case MSG_SET_HANDLE: {
+                case MSG_SET_ADDRESS: {
                     SomeArgs args = (SomeArgs) msg.obj;
                     try {
-                        mDelegate.setHandle((String) args.arg1, (Uri) args.arg2, args.argi1);
+                        mDelegate.setAddress((String) args.arg1, (Uri) args.arg2, args.argi1);
                     } finally {
                         args.recycle();
                     }
@@ -249,8 +249,8 @@
         }
 
         @Override
-        public void setRequestingRingback(String connectionId, boolean ringback) {
-            mHandler.obtainMessage(MSG_SET_REQUESTING_RINGBACK, ringback ? 1 : 0, 0, connectionId)
+        public void setRingbackRequested(String connectionId, boolean ringback) {
+            mHandler.obtainMessage(MSG_SET_RINGBACK_REQUESTED, ringback ? 1 : 0, 0, connectionId)
                     .sendToTarget();
         }
 
@@ -308,8 +308,8 @@
         }
 
         @Override
-        public final void setAudioModeIsVoip(String connectionId, boolean isVoip) {
-            mHandler.obtainMessage(MSG_SET_AUDIO_MODE_IS_VOIP, isVoip ? 1 : 0, 0,
+        public final void setIsVoipAudioMode(String connectionId, boolean isVoip) {
+            mHandler.obtainMessage(MSG_SET_IS_VOIP_AUDIO_MODE, isVoip ? 1 : 0, 0,
                     connectionId).sendToTarget();
         }
 
@@ -322,12 +322,12 @@
         }
 
         @Override
-        public final void setHandle(String connectionId, Uri handle, int presentation) {
+        public final void setAddress(String connectionId, Uri address, int presentation) {
             SomeArgs args = SomeArgs.obtain();
             args.arg1 = connectionId;
-            args.arg2 = handle;
+            args.arg2 = address;
             args.argi1 = presentation;
-            mHandler.obtainMessage(MSG_SET_HANDLE, args).sendToTarget();
+            mHandler.obtainMessage(MSG_SET_ADDRESS, args).sendToTarget();
         }
 
         @Override
diff --git a/telecomm/java/android/telecomm/ParcelableConnection.java b/telecomm/java/android/telecomm/ParcelableConnection.java
index 2e21d37..cadcd85 100644
--- a/telecomm/java/android/telecomm/ParcelableConnection.java
+++ b/telecomm/java/android/telecomm/ParcelableConnection.java
@@ -35,14 +35,14 @@
     private final PhoneAccountHandle mPhoneAccount;
     private final int mState;
     private final int mCapabilities;
-    private final Uri mHandle;
-    private final int mHandlePresentation;
+    private final Uri mAddress;
+    private final int mAddressPresentation;
     private final String mCallerDisplayName;
     private final int mCallerDisplayNamePresentation;
     private final IVideoProvider mVideoProvider;
     private final int mVideoState;
-    private final boolean mRequestingRingback;
-    private final boolean mAudioModeIsVoip;
+    private final boolean mRingbackRequested;
+    private final boolean mIsVoipAudioMode;
     private final StatusHints mStatusHints;
     private final int mDisconnectCause;
     private final String mDisconnectMessage;
@@ -53,14 +53,14 @@
             PhoneAccountHandle phoneAccount,
             int state,
             int capabilities,
-            Uri handle,
-            int handlePresentation,
+            Uri address,
+            int addressPresentation,
             String callerDisplayName,
             int callerDisplayNamePresentation,
             IVideoProvider videoProvider,
             int videoState,
-            boolean requestingRingback,
-            boolean audioModeIsVoip,
+            boolean ringbackRequested,
+            boolean isVoipAudioMode,
             StatusHints statusHints,
             int disconnectCause,
             String disconnectMessage,
@@ -68,14 +68,14 @@
         mPhoneAccount = phoneAccount;
         mState = state;
         mCapabilities = capabilities;
-        mHandle = handle;
-        mHandlePresentation = handlePresentation;
+        mAddress = address;
+        mAddressPresentation = addressPresentation;
         mCallerDisplayName = callerDisplayName;
         mCallerDisplayNamePresentation = callerDisplayNamePresentation;
         mVideoProvider = videoProvider;
         mVideoState = videoState;
-        mRequestingRingback = requestingRingback;
-        mAudioModeIsVoip = audioModeIsVoip;
+        mRingbackRequested = ringbackRequested;
+        mIsVoipAudioMode = isVoipAudioMode;
         mStatusHints = statusHints;
         mDisconnectCause = disconnectCause;
         mDisconnectMessage = disconnectMessage;
@@ -96,11 +96,11 @@
     }
 
     public Uri getHandle() {
-        return mHandle;
+        return mAddress;
     }
 
     public int getHandlePresentation() {
-        return mHandlePresentation;
+        return mAddressPresentation;
     }
 
     public String getCallerDisplayName() {
@@ -119,12 +119,12 @@
         return mVideoState;
     }
 
-    public boolean isRequestingRingback() {
-        return mRequestingRingback;
+    public boolean isRingbackRequested() {
+        return mRingbackRequested;
     }
 
-    public boolean getAudioModeIsVoip() {
-        return mAudioModeIsVoip;
+    public boolean getIsVoipAudioMode() {
+        return mIsVoipAudioMode;
     }
 
     public final StatusHints getStatusHints() {
@@ -164,14 +164,14 @@
             PhoneAccountHandle phoneAccount = source.readParcelable(classLoader);
             int state = source.readInt();
             int capabilities = source.readInt();
-            Uri handle = source.readParcelable(classLoader);
-            int handlePresentation = source.readInt();
+            Uri address = source.readParcelable(classLoader);
+            int addressPresentation = source.readInt();
             String callerDisplayName = source.readString();
             int callerDisplayNamePresentation = source.readInt();
             IVideoProvider videoCallProvider =
                     IVideoProvider.Stub.asInterface(source.readStrongBinder());
             int videoState = source.readInt();
-            boolean requestingRingback = source.readByte() == 1;
+            boolean ringbackRequested = source.readByte() == 1;
             boolean audioModeIsVoip = source.readByte() == 1;
             StatusHints statusHints = source.readParcelable(classLoader);
             int disconnectCauseCode = source.readInt();
@@ -183,13 +183,13 @@
                     phoneAccount,
                     state,
                     capabilities,
-                    handle,
-                    handlePresentation,
+                    address,
+                    addressPresentation,
                     callerDisplayName,
                     callerDisplayNamePresentation,
                     videoCallProvider,
                     videoState,
-                    requestingRingback,
+                    ringbackRequested,
                     audioModeIsVoip,
                     statusHints,
                     disconnectCauseCode,
@@ -215,15 +215,15 @@
         destination.writeParcelable(mPhoneAccount, 0);
         destination.writeInt(mState);
         destination.writeInt(mCapabilities);
-        destination.writeParcelable(mHandle, 0);
-        destination.writeInt(mHandlePresentation);
+        destination.writeParcelable(mAddress, 0);
+        destination.writeInt(mAddressPresentation);
         destination.writeString(mCallerDisplayName);
         destination.writeInt(mCallerDisplayNamePresentation);
         destination.writeStrongBinder(
                 mVideoProvider != null ? mVideoProvider.asBinder() : null);
         destination.writeInt(mVideoState);
-        destination.writeByte((byte) (mRequestingRingback ? 1 : 0));
-        destination.writeByte((byte) (mAudioModeIsVoip ? 1 : 0));
+        destination.writeByte((byte) (mRingbackRequested ? 1 : 0));
+        destination.writeByte((byte) (mIsVoipAudioMode ? 1 : 0));
         destination.writeParcelable(mStatusHints, 0);
         destination.writeInt(mDisconnectCause);
         destination.writeString(mDisconnectMessage);
diff --git a/telecomm/java/android/telecomm/RemoteConference.java b/telecomm/java/android/telecomm/RemoteConference.java
index b073827..dbff079 100644
--- a/telecomm/java/android/telecomm/RemoteConference.java
+++ b/telecomm/java/android/telecomm/RemoteConference.java
@@ -188,11 +188,11 @@
         return mDisconnectMessage;
     }
 
-    public final void addCallback(Callback callback) {
+    public final void registerCallback(Callback callback) {
         mCallbacks.add(callback);
     }
 
-    public final void removeCallback(Callback callback) {
+    public final void unregisterCallback(Callback callback) {
         mCallbacks.remove(callback);
     }
 }
diff --git a/telecomm/java/android/telecomm/RemoteConnection.java b/telecomm/java/android/telecomm/RemoteConnection.java
index 68367f0..f3a6085 100644
--- a/telecomm/java/android/telecomm/RemoteConnection.java
+++ b/telecomm/java/android/telecomm/RemoteConnection.java
@@ -42,7 +42,7 @@
  */
 public final class RemoteConnection {
 
-    public static abstract class Listener {
+    public static abstract class Callback {
         /**
          * Invoked when the state of this {@code RemoteConnection} has changed. See
          * {@link #getState()}.
@@ -53,25 +53,6 @@
         public void onStateChanged(RemoteConnection connection, int state) {}
 
         /**
-         * Invoked when the parent of this {@code RemoteConnection} has changed. See
-         * {@link #getParent()}.
-         *
-         * @param connection The {@code RemoteConnection} invoking this method.
-         * @param parent The new parent of the {@code RemoteConnection}.
-         */
-        public void onParentChanged(RemoteConnection connection, RemoteConnection parent) {}
-
-        /**
-         * Invoked when the children of this {@code RemoteConnection} have changed. See
-         * {@link #getChildren()}.
-         *
-         * @param connection The {@code RemoteConnection} invoking this method.
-         * @param children The new children of the {@code RemoteConnection}.
-         */
-        public void onChildrenChanged(
-                RemoteConnection connection, List<RemoteConnection> children) {}
-
-        /**
          * Invoked when this {@code RemoteConnection} is disconnected.
          *
          * @param connection The {@code RemoteConnection} invoking this method.
@@ -87,12 +68,12 @@
 
         /**
          * Invoked when this {@code RemoteConnection} is requesting ringback. See
-         * {@link #isRequestingRingback()}.
+         * {@link #isRingbackRequested()}.
          *
          * @param connection The {@code RemoteConnection} invoking this method.
          * @param ringback Whether the {@code RemoteConnection} is requesting ringback.
          */
-        public void onRequestingRingback(RemoteConnection connection, boolean ringback) {}
+        public void onRingbackRequested(RemoteConnection connection, boolean ringback) {}
 
         /**
          * Indicates that the call capabilities of this {@code RemoteConnection} have changed.
@@ -116,12 +97,12 @@
 
         /**
          * Indicates that the VOIP audio status of this {@code RemoteConnection} has changed.
-         * See {@link #getAudioModeIsVoip()}.
+         * See {@link #isVoipAudioMode()}.
          *
          * @param connection The {@code RemoteConnection} invoking this method.
          * @param isVoip Whether the new audio state of the {@code RemoteConnection} is VOIP.
          */
-        public void onAudioModeIsVoipChanged(RemoteConnection connection, boolean isVoip) {}
+        public void onVoipAudioChanged(RemoteConnection connection, boolean isVoip) {}
 
         /**
          * Indicates that the status hints of this {@code RemoteConnection} have changed. See
@@ -133,15 +114,15 @@
         public void onStatusHintsChanged(RemoteConnection connection, StatusHints statusHints) {}
 
         /**
-         * Indicates that the handle (e.g., phone number) of this {@code RemoteConnection} has
-         * changed. See {@link #getHandle()} and {@link #getHandlePresentation()}.
+         * Indicates that the address (e.g., phone number) of this {@code RemoteConnection} has
+         * changed. See {@link #getAddress()} and {@link #getAddressPresentation()}.
          *
          * @param connection The {@code RemoteConnection} invoking this method.
-         * @param handle The new handle of the {@code RemoteConnection}.
-         * @param presentation The presentation requirements for the handle.
+         * @param address The new address of the {@code RemoteConnection}.
+         * @param presentation The presentation requirements for the address.
          *        See {@link TelecommManager} for valid values.
          */
-        public void onHandleChanged(RemoteConnection connection, Uri handle, int presentation) {}
+        public void onAddressChanged(RemoteConnection connection, Uri address, int presentation) {}
 
         /**
          * Indicates that the caller display name of this {@code RemoteConnection} has changed.
@@ -396,8 +377,8 @@
      * load factor before resizing, 1 means we only expect a single thread to
      * access the map so make only a single shard
      */
-    private final Set<Listener> mListeners = Collections.newSetFromMap(
-            new ConcurrentHashMap<Listener, Boolean>(8, 0.9f, 1));
+    private final Set<Callback> mCallbacks = Collections.newSetFromMap(
+            new ConcurrentHashMap<Callback, Boolean>(8, 0.9f, 1));
     private final List<RemoteConnection> mConferenceableConnections = new ArrayList<>();
     private final List<RemoteConnection> mUnmodifiableconferenceableConnections =
             Collections.unmodifiableList(mConferenceableConnections);
@@ -405,15 +386,15 @@
     private int mState = Connection.STATE_NEW;
     private int mDisconnectCauseCode = DisconnectCause.NOT_VALID;
     private String mDisconnectCauseMessage;
-    private boolean mRequestingRingback;
+    private boolean mRingbackRequested;
     private boolean mConnected;
     private int mCallCapabilities;
     private int mVideoState;
     private VideoProvider mVideoProvider;
-    private boolean mAudioModeIsVoip;
+    private boolean mIsVoipAudioMode;
     private StatusHints mStatusHints;
-    private Uri mHandle;
-    private int mHandlePresentation;
+    private Uri mAddress;
+    private int mAddressPresentation;
     private String mCallerDisplayName;
     private int mCallerDisplayNamePresentation;
     private int mFailureCode;
@@ -450,42 +431,26 @@
     }
 
     /**
-     * Adds a listener to this {@code RemoteConnection}.
+     * Adds a callback to this {@code RemoteConnection}.
      *
-     * @param listener A {@code Listener}.
+     * @param callback A {@code Callback}.
      */
-    public void addListener(Listener listener) {
-        mListeners.add(listener);
+    public void registerCallback(Callback callback) {
+        mCallbacks.add(callback);
     }
 
     /**
-     * Removes a listener from this {@code RemoteConnection}.
+     * Removes a callback from this {@code RemoteConnection}.
      *
-     * @param listener A {@code Listener}.
+     * @param callback A {@code Callback}.
      */
-    public void removeListener(Listener listener) {
-        if (listener != null) {
-            mListeners.remove(listener);
+    public void unregisterCallback(Callback callback) {
+        if (callback != null) {
+            mCallbacks.remove(callback);
         }
     }
 
     /**
-     * Obtains the parent of this {@code RemoteConnection} in a conference, if any.
-     *
-     * @return The parent {@code RemoteConnection}, or {@code null} if this {@code RemoteConnection}
-     * is not a child of any conference {@code RemoteConnection}s.
-     */
-    public RemoteConnection getParent() { return null; }
-
-    /**
-     * Obtains the children of this conference {@code RemoteConnection}, if any.
-     *
-     * @return The children of this {@code RemoteConnection} if this {@code RemoteConnection} is
-     * a conference, or an empty {@code List} otherwise.
-     */
-    public List<RemoteConnection> getChildren() { return new ArrayList<>(); }
-
-    /**
      * Obtains the state of this {@code RemoteConnection}.
      *
      * @return A state value, chosen from the {@code STATE_*} constants.
@@ -522,8 +487,8 @@
     /**
      * @return {@code true} if the {@code RemoteConnection}'s current audio mode is VOIP.
      */
-    public boolean getAudioModeIsVoip() {
-        return mAudioModeIsVoip;
+    public boolean isVoipAudioMode() {
+        return mIsVoipAudioMode;
     }
 
     /**
@@ -535,25 +500,25 @@
     }
 
     /**
-     * @return The handle (e.g., phone number) to which the {@code RemoteConnection} is currently
+     * @return The address (e.g., phone number) to which the {@code RemoteConnection} is currently
      * connected.
      */
-    public Uri getHandle() {
-        return mHandle;
+    public Uri getAddress() {
+        return mAddress;
     }
 
     /**
-     * @return The presentation requirements for the handle. See
-     * {@link TelecommManager} for valid values.
+     * @return The presentation requirements for the address. See {@link TelecommManager} for valid
+     * values.
      */
-    public int getHandlePresentation() {
-        return mHandlePresentation;
+    public int getAddressPresentation() {
+        return mAddressPresentation;
     }
 
     /**
      * @return The display name for the caller.
      */
-    public String getCallerDisplayName() {
+    public CharSequence getCallerDisplayName() {
         return mCallerDisplayName;
     }
 
@@ -601,7 +566,7 @@
      * @return Whether the {@code RemoteConnection} is requesting that the framework play a
      * ringback tone on its behalf.
      */
-    public boolean isRequestingRingback() {
+    public boolean isRingbackRequested() {
         return false;
     }
 
@@ -738,8 +703,8 @@
      * of time.
      *
      * If the DTMF string contains a {@link TelecommManager#DTMF_CHARACTER_WAIT} symbol, this
-     * {@code RemoteConnection} will pause playing the tones and notify listeners via
-     * {@link Listener#onPostDialWait(RemoteConnection, String)}. At this point, the in-call app
+     * {@code RemoteConnection} will pause playing the tones and notify callbackss via
+     * {@link Callback#onPostDialWait(RemoteConnection, String)}. At this point, the in-call app
      * should display to the user an indication of this state and an affordance to continue
      * the postdial sequence. When the user decides to continue the postdial sequence, the in-call
      * app should invoke the {@link #postDialContinue(boolean)} method.
@@ -806,8 +771,8 @@
     void setState(int state) {
         if (mState != state) {
             mState = state;
-            for (Listener l: mListeners) {
-                l.onStateChanged(this, state);
+            for (Callback c: mCallbacks) {
+                c.onStateChanged(this, state);
             }
         }
     }
@@ -821,8 +786,8 @@
             mDisconnectCauseCode = cause;
             mDisconnectCauseMessage = message;
 
-            for (Listener l : mListeners) {
-                l.onDisconnected(this, cause, message);
+            for (Callback c : mCallbacks) {
+                c.onDisconnected(this, cause, message);
             }
         }
     }
@@ -830,11 +795,11 @@
     /**
      * @hide
      */
-    void setRequestingRingback(boolean ringback) {
-        if (mRequestingRingback != ringback) {
-            mRequestingRingback = ringback;
-            for (Listener l : mListeners) {
-                l.onRequestingRingback(this, ringback);
+    void setRingbackRequested(boolean ringback) {
+        if (mRingbackRequested != ringback) {
+            mRingbackRequested = ringback;
+            for (Callback c : mCallbacks) {
+                c.onRingbackRequested(this, ringback);
             }
         }
     }
@@ -844,8 +809,8 @@
      */
     void setCallCapabilities(int callCapabilities) {
         mCallCapabilities = callCapabilities;
-        for (Listener l : mListeners) {
-            l.onCallCapabilitiesChanged(this, callCapabilities);
+        for (Callback c : mCallbacks) {
+            c.onCallCapabilitiesChanged(this, callCapabilities);
         }
     }
 
@@ -853,16 +818,16 @@
      * @hide
      */
     void setDestroyed() {
-        if (!mListeners.isEmpty()) {
-            // Make sure that the listeners are notified that the call is destroyed first.
+        if (!mCallbacks.isEmpty()) {
+            // Make sure that the callbacks are notified that the call is destroyed first.
             if (mState != Connection.STATE_DISCONNECTED) {
                 setDisconnected(DisconnectCause.ERROR_UNSPECIFIED, "Connection destroyed.");
             }
 
-            for (Listener l : mListeners) {
-                l.onDestroyed(this);
+            for (Callback c : mCallbacks) {
+                c.onDestroyed(this);
             }
-            mListeners.clear();
+            mCallbacks.clear();
 
             mConnected = false;
         }
@@ -872,8 +837,8 @@
      * @hide
      */
     void setPostDialWait(String remainingDigits) {
-        for (Listener l : mListeners) {
-            l.onPostDialWait(this, remainingDigits);
+        for (Callback c : mCallbacks) {
+            c.onPostDialWait(this, remainingDigits);
         }
     }
 
@@ -882,8 +847,8 @@
      */
     void setVideoState(int videoState) {
         mVideoState = videoState;
-        for (Listener l : mListeners) {
-            l.onVideoStateChanged(this, videoState);
+        for (Callback c : mCallbacks) {
+            c.onVideoStateChanged(this, videoState);
         }
     }
 
@@ -892,33 +857,33 @@
      */
     void setVideoProvider(VideoProvider videoProvider) {
         mVideoProvider = videoProvider;
-        for (Listener l : mListeners) {
-            l.onVideoProviderChanged(this, videoProvider);
+        for (Callback c : mCallbacks) {
+            c.onVideoProviderChanged(this, videoProvider);
         }
     }
 
     /** @hide */
-    void setAudioModeIsVoip(boolean isVoip) {
-        mAudioModeIsVoip = isVoip;
-        for (Listener l : mListeners) {
-            l.onAudioModeIsVoipChanged(this, isVoip);
+    void setIsVoipAudioMode(boolean isVoip) {
+        mIsVoipAudioMode = isVoip;
+        for (Callback c : mCallbacks) {
+            c.onVoipAudioChanged(this, isVoip);
         }
     }
 
     /** @hide */
     void setStatusHints(StatusHints statusHints) {
         mStatusHints = statusHints;
-        for (Listener l : mListeners) {
-            l.onStatusHintsChanged(this, statusHints);
+        for (Callback c : mCallbacks) {
+            c.onStatusHintsChanged(this, statusHints);
         }
     }
 
     /** @hide */
-    void setHandle(Uri handle, int presentation) {
-        mHandle = handle;
-        mHandlePresentation = presentation;
-        for (Listener l : mListeners) {
-            l.onHandleChanged(this, handle, presentation);
+    void setAddress(Uri address, int presentation) {
+        mAddress = address;
+        mAddressPresentation = presentation;
+        for (Callback c : mCallbacks) {
+            c.onAddressChanged(this, address, presentation);
         }
     }
 
@@ -926,8 +891,8 @@
     void setCallerDisplayName(String callerDisplayName, int presentation) {
         mCallerDisplayName = callerDisplayName;
         mCallerDisplayNamePresentation = presentation;
-        for (Listener l : mListeners) {
-            l.onCallerDisplayNameChanged(this, callerDisplayName, presentation);
+        for (Callback c : mCallbacks) {
+            c.onCallerDisplayNameChanged(this, callerDisplayName, presentation);
         }
     }
 
@@ -935,8 +900,8 @@
     void setConferenceableConnections(List<RemoteConnection> conferenceableConnections) {
         mConferenceableConnections.clear();
         mConferenceableConnections.addAll(conferenceableConnections);
-        for (Listener l : mListeners) {
-            l.onConferenceableConnectionsChanged(this, mUnmodifiableconferenceableConnections);
+        for (Callback c : mCallbacks) {
+            c.onConferenceableConnectionsChanged(this, mUnmodifiableconferenceableConnections);
         }
     }
 
@@ -944,8 +909,8 @@
     void setConference(RemoteConference conference) {
         if (mConference != conference) {
             mConference = conference;
-            for (Listener l : mListeners) {
-                l.onConferenceChanged(this, conference);
+            for (Callback c : mCallbacks) {
+                c.onConferenceChanged(this, conference);
             }
         }
     }
diff --git a/telecomm/java/android/telecomm/RemoteConnectionService.java b/telecomm/java/android/telecomm/RemoteConnectionService.java
index 8b8e8eb..d4dd9af 100644
--- a/telecomm/java/android/telecomm/RemoteConnectionService.java
+++ b/telecomm/java/android/telecomm/RemoteConnectionService.java
@@ -61,7 +61,7 @@
                 mPendingConnections.remove(connection);
                 // Unconditionally initialize the connection ...
                 connection.setCallCapabilities(parcel.getCapabilities());
-                connection.setHandle(
+                connection.setAddress(
                         parcel.getHandle(), parcel.getHandlePresentation());
                 connection.setCallerDisplayName(
                         parcel.getCallerDisplayName(),
@@ -131,9 +131,9 @@
         }
 
         @Override
-        public void setRequestingRingback(String callId, boolean ringing) {
-            findConnectionForAction(callId, "setRequestingRingback")
-                    .setRequestingRingback(ringing);
+        public void setRingbackRequested(String callId, boolean ringing) {
+            findConnectionForAction(callId, "setRingbackRequested")
+                    .setRingbackRequested(ringing);
         }
 
         @Override
@@ -192,7 +192,7 @@
             conference.setState(parcel.getState());
             conference.setCallCapabilities(parcel.getCapabilities());
             mConferenceById.put(callId, conference);
-            conference.addCallback(new RemoteConference.Callback() {
+            conference.registerCallback(new RemoteConference.Callback() {
                 @Override
                 public void onDestroyed(RemoteConference c) {
                     mConferenceById.remove(callId);
@@ -238,9 +238,9 @@
         }
 
         @Override
-        public void setAudioModeIsVoip(String callId, boolean isVoip) {
-            findConnectionForAction(callId, "setAudioModeIsVoip")
-                    .setAudioModeIsVoip(isVoip);
+        public void setIsVoipAudioMode(String callId, boolean isVoip) {
+            findConnectionForAction(callId, "setIsVoipAudioMode")
+                    .setIsVoipAudioMode(isVoip);
         }
 
         @Override
@@ -250,9 +250,9 @@
         }
 
         @Override
-        public void setHandle(String callId, Uri handle, int presentation) {
-            findConnectionForAction(callId, "setHandle")
-                    .setHandle(handle, presentation);
+        public void setAddress(String callId, Uri address, int presentation) {
+            findConnectionForAction(callId, "setAddress")
+                    .setAddress(address, presentation);
         }
 
         @Override
@@ -343,7 +343,7 @@
                     id,
                     newRequest,
                     isIncoming);
-            connection.addListener(new RemoteConnection.Listener() {
+            connection.registerCallback(new RemoteConnection.Callback() {
                 @Override
                 public void onDestroyed(RemoteConnection connection) {
                     mConnectionById.remove(id);
diff --git a/telecomm/java/android/telecomm/TelecommManager.java b/telecomm/java/android/telecomm/TelecommManager.java
index 9b8c536..a19f51b 100644
--- a/telecomm/java/android/telecomm/TelecommManager.java
+++ b/telecomm/java/android/telecomm/TelecommManager.java
@@ -142,6 +142,30 @@
             "android.telecomm.extra.CONNECTION_SERVICE";
 
     /**
+     * An optional {@link android.content.Intent#ACTION_CALL} intent extra denoting the
+     * package name of the app specifying an alternative gateway for the call.
+     * The value is a string.
+     *
+     * (The following comment corresponds to the all GATEWAY_* extras)
+     * An app which sends the {@link android.content.Intent#ACTION_CALL} intent can specify an
+     * alternative address to dial which is different from the one specified and displayed to
+     * the user. This alternative address is referred to as the gateway address.
+     */
+    public static final String GATEWAY_PROVIDER_PACKAGE =
+            "android.telecomm.extra.GATEWAY_PROVIDER_PACKAGE";
+
+    /**
+     * An optional {@link android.content.Intent#ACTION_CALL} intent extra corresponding to the
+     * original address to dial for the call. This is used when an alternative gateway address is
+     * provided to recall the original address.
+     * The value is a {@link android.net.Uri}.
+     *
+     * (See {@link #GATEWAY_PROVIDER_PACKAGE} for details)
+     */
+    public static final String GATEWAY_ORIGINAL_ADDRESS =
+            "android.telecomm.extra.GATEWAY_ORIGINAL_ADDRESS";
+
+    /**
      * The number which the party on the other side of the line will see (and use to return the
      * call).
      * <p>
@@ -288,7 +312,7 @@
      * <p>
      * Apps must be prepared for this method to return {@code null}, indicating that there currently
      * exists no user-chosen default {@code PhoneAccount}. In this case, apps wishing to initiate a
-     * phone call must either create their {@link android.content .Intent#ACTION_CALL} or
+     * phone call must either create their {@link android.content.Intent#ACTION_CALL} or
      * {@link android.content.Intent#ACTION_DIAL} {@code Intent} with no
      * {@link TelecommManager#EXTRA_PHONE_ACCOUNT_HANDLE}, or present the user with an affordance to
      * select one of the elements of {@link #getEnabledPhoneAccounts()}.
@@ -579,15 +603,13 @@
     }
 
     /**
-     * Remove all Accounts for a given package from the system.
-     *
-     * @param packageName A package name that may have registered Accounts.
+     * Remove all Accounts that belong to the calling package from the system.
      */
     @SystemApi
-    public void clearAccounts(String packageName) {
+    public void clearAccounts() {
         try {
             if (isServiceConnected()) {
-                getTelecommService().clearAccounts(packageName);
+                getTelecommService().clearAccounts(mContext.getPackageName());
             }
         } catch (RemoteException e) {
             Log.e(TAG, "Error calling ITelecommService#clearAccounts", e);
diff --git a/telecomm/java/com/android/internal/telecomm/IConnectionServiceAdapter.aidl b/telecomm/java/com/android/internal/telecomm/IConnectionServiceAdapter.aidl
index 610178e..4b636d1 100644
--- a/telecomm/java/com/android/internal/telecomm/IConnectionServiceAdapter.aidl
+++ b/telecomm/java/com/android/internal/telecomm/IConnectionServiceAdapter.aidl
@@ -49,7 +49,7 @@
 
     void setOnHold(String callId);
 
-    void setRequestingRingback(String callId, boolean ringing);
+    void setRingbackRequested(String callId, boolean ringing);
 
     void setCallCapabilities(String callId, int callCapabilities);
 
@@ -67,11 +67,11 @@
 
     void setVideoState(String callId, int videoState);
 
-    void setAudioModeIsVoip(String callId, boolean isVoip);
+    void setIsVoipAudioMode(String callId, boolean isVoip);
 
     void setStatusHints(String callId, in StatusHints statusHints);
 
-    void setHandle(String callId, in Uri handle, int presentation);
+    void setAddress(String callId, in Uri address, int presentation);
 
     void setCallerDisplayName(String callId, String callerDisplayName, int presentation);
 
diff --git a/telephony/java/android/telephony/SubscriptionManager.java b/telephony/java/android/telephony/SubscriptionManager.java
index d0f355e..fe68263 100644
--- a/telephony/java/android/telephony/SubscriptionManager.java
+++ b/telephony/java/android/telephony/SubscriptionManager.java
@@ -930,13 +930,20 @@
 
     /** @hide */
     public static boolean isValidSlotId(int slotId) {
-        return slotId > INVALID_SLOT_ID && slotId < TelephonyManager.getDefault().getSimCount();
+        // We are testing INVALID_SLOT_ID and slotId >= 0 independently because we should
+        // not assume that INVALID_SLOT_ID will always be a negative value.  Any negative
+        // value is invalid.
+        return slotId != INVALID_SLOT_ID && slotId >= 0 &&
+                slotId < TelephonyManager.getDefault().getSimCount();
     }
 
     /** @hide */
     public static boolean isValidPhoneId(int phoneId) {
-        return phoneId > INVALID_PHONE_ID
-                && phoneId < TelephonyManager.getDefault().getPhoneCount();
+        // We are testing INVALID_PHONE_ID and phoneId >= 0 independently because we should
+        // not assume that INVALID_PHONE_ID will always be a negative value.  Any negative
+        // value is invalid.
+        return phoneId != INVALID_PHONE_ID && phoneId >= 0 &&
+                phoneId < TelephonyManager.getDefault().getPhoneCount();
     }
 
     /** @hide */