diff options
63 files changed, 458 insertions, 214 deletions
diff --git a/api/current.txt b/api/current.txt index 9a9d5f6cd4f4..de3723cbd064 100644 --- a/api/current.txt +++ b/api/current.txt @@ -6329,7 +6329,6 @@ package android.bluetooth { method public deprecated void abortReliableWrite(android.bluetooth.BluetoothDevice); method public boolean beginReliableWrite(); method public void close(); - method public boolean configureMTU(int); method public boolean connect(); method public void disconnect(); method public boolean discoverServices(); @@ -6343,14 +6342,15 @@ package android.bluetooth { method public boolean readCharacteristic(android.bluetooth.BluetoothGattCharacteristic); method public boolean readDescriptor(android.bluetooth.BluetoothGattDescriptor); method public boolean readRemoteRssi(); - method public boolean requestConnectionParameterUpdate(int); + method public boolean requestConnectionPriority(int); + method public boolean requestMtu(int); method public boolean setCharacteristicNotification(android.bluetooth.BluetoothGattCharacteristic, boolean); method public boolean writeCharacteristic(android.bluetooth.BluetoothGattCharacteristic); method public boolean writeDescriptor(android.bluetooth.BluetoothGattDescriptor); - field public static final int GATT_CONNECTION_BALANCED = 0; // 0x0 + field public static final int CONNECTION_PRIORITY_BALANCED = 0; // 0x0 + field public static final int CONNECTION_PRIORITY_HIGH = 1; // 0x1 + field public static final int CONNECTION_PRIORITY_LOW_POWER = 2; // 0x2 field public static final int GATT_CONNECTION_CONGESTED = 143; // 0x8f - field public static final int GATT_CONNECTION_HIGH_PRIORITY = 1; // 0x1 - field public static final int GATT_CONNECTION_LOW_POWER = 2; // 0x2 field public static final int GATT_FAILURE = 257; // 0x101 field public static final int GATT_INSUFFICIENT_AUTHENTICATION = 5; // 0x5 field public static final int GATT_INSUFFICIENT_ENCRYPTION = 15; // 0xf @@ -6367,11 +6367,11 @@ package android.bluetooth { method public void onCharacteristicChanged(android.bluetooth.BluetoothGatt, android.bluetooth.BluetoothGattCharacteristic); method public void onCharacteristicRead(android.bluetooth.BluetoothGatt, android.bluetooth.BluetoothGattCharacteristic, int); method public void onCharacteristicWrite(android.bluetooth.BluetoothGatt, android.bluetooth.BluetoothGattCharacteristic, int); - method public void onConfigureMTU(android.bluetooth.BluetoothGatt, int, int); method public void onConnectionCongested(android.bluetooth.BluetoothGatt, boolean); method public void onConnectionStateChange(android.bluetooth.BluetoothGatt, int, int); method public void onDescriptorRead(android.bluetooth.BluetoothGatt, android.bluetooth.BluetoothGattDescriptor, int); method public void onDescriptorWrite(android.bluetooth.BluetoothGatt, android.bluetooth.BluetoothGattDescriptor, int); + method public void onMtuChanged(android.bluetooth.BluetoothGatt, int, int); method public void onReadRemoteRssi(android.bluetooth.BluetoothGatt, int, int); method public void onReliableWriteCompleted(android.bluetooth.BluetoothGatt, int); method public void onServicesDiscovered(android.bluetooth.BluetoothGatt, int); diff --git a/core/java/android/app/job/JobInfo.java b/core/java/android/app/job/JobInfo.java index 936e2055f67c..b7af5445cae4 100644 --- a/core/java/android/app/job/JobInfo.java +++ b/core/java/android/app/job/JobInfo.java @@ -434,6 +434,12 @@ public class JobInfo implements Parcelable { * @return The job object to hand to the JobScheduler. This object is immutable. */ public JobInfo build() { + // Allow tasks with no constraints. What am I, a database? + if (!mHasEarlyConstraint && !mHasLateConstraint && !mRequiresCharging && + !mRequiresDeviceIdle && mNetworkCapabilities == NetworkType.NONE) { + throw new IllegalArgumentException("You're trying to build a job with no " + + "constraints, this is not allowed."); + } mExtras = new PersistableBundle(mExtras); // Make our own copy. // Check that a deadline was not set on a periodic job. if (mIsPeriodic && (mMaxExecutionDelayMillis != 0L)) { diff --git a/core/java/android/app/job/JobScheduler.java b/core/java/android/app/job/JobScheduler.java index 7fe192c0b472..ca7022d31041 100644 --- a/core/java/android/app/job/JobScheduler.java +++ b/core/java/android/app/job/JobScheduler.java @@ -22,7 +22,13 @@ import android.content.Context; /** * Class for scheduling various types of jobs with the scheduling framework on the device. - * + * See {@link android.app.job.JobInfo} for more description of the types of jobs that can be run + * and how to construct them. + * The framework will be intelligent about when you receive your callbacks, and attempt to batch + * and defer them as much as possible. Typically if you don't specify a deadline on your job, it + * can be run at any moment depending on the current state of the JobScheduler's internal queue, + * however it might be deferred as long as until the next time the device is connected to a power + * source. * <p>You do not * instantiate this class directly; instead, retrieve it through * {@link android.content.Context#getSystemService diff --git a/core/java/android/bluetooth/BluetoothGatt.java b/core/java/android/bluetooth/BluetoothGatt.java index 59d7956b5429..d77a77ba4127 100644 --- a/core/java/android/bluetooth/BluetoothGatt.java +++ b/core/java/android/bluetooth/BluetoothGatt.java @@ -96,19 +96,19 @@ public final class BluetoothGatt implements BluetoothProfile { * Bluetooth SIG. This is the default value if no connection parameter update * is requested. */ - public static final int GATT_CONNECTION_BALANCED = 0; + public static final int CONNECTION_PRIORITY_BALANCED = 0; /** * Connection paramter update - Request a high priority, low latency connection. * An application should only request high priority connection paramters to transfer * large amounts of data over LE quickly. Once the transfer is complete, the application - * should request {@link BluetoothGatt#GATT_CONNECTION_BALANCED} connectoin parameters + * should request {@link BluetoothGatt#CONNECTION_PRIORITY_BALANCED} connectoin parameters * to reduce energy use. */ - public static final int GATT_CONNECTION_HIGH_PRIORITY = 1; + public static final int CONNECTION_PRIORITY_HIGH = 1; /** Connection paramter update - Request low power, reduced data rate connection parameters. */ - public static final int GATT_CONNECTION_LOW_POWER = 2; + public static final int CONNECTION_PRIORITY_LOW_POWER = 2; /** * No authentication required. @@ -601,7 +601,7 @@ public final class BluetoothGatt implements BluetoothProfile { return; } try { - mCallback.onConfigureMTU(BluetoothGatt.this, mtu, status); + mCallback.onMtuChanged(BluetoothGatt.this, mtu, status); } catch (Exception ex) { Log.w(TAG, "Unhandled exception in callback", ex); } @@ -1239,20 +1239,20 @@ public final class BluetoothGatt implements BluetoothProfile { } /** - * Configure the MTU used for a given connection. + * Request an MTU size used for a given connection. * * <p>When performing a write request operation (write without response), * the data sent is truncated to the MTU size. This function may be used - * to request a larget MTU size to be able to send more data at once. + * to request a larger MTU size to be able to send more data at once. * - * <p>A {@link BluetoothGattCallback#onConfigureMTU} callback will indicate + * <p>A {@link BluetoothGattCallback#onMtuChanged} callback will indicate * whether this operation was successful. * * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission. * * @return true, if the new MTU value has been requested successfully */ - public boolean configureMTU(int mtu) { + public boolean requestMtu(int mtu) { if (DBG) Log.d(TAG, "configureMTU() - device: " + mDevice.getAddress() + " mtu: " + mtu); if (mService == null || mClientIf == 0) return false; @@ -1274,19 +1274,19 @@ public final class BluetoothGatt implements BluetoothProfile { * remote device. * * @param connectionPriority Request a specific connection priority. Must be one of - * {@link BluetoothGatt#GATT_CONNECTION_BALANCED}, - * {@link BluetoothGatt#GATT_CONNECTION_HIGH_PRIORITY} - * or {@link BluetoothGatt#GATT_CONNECTION_LOW_POWER}. + * {@link BluetoothGatt#CONNECTION_PRIORITY_BALANCED}, + * {@link BluetoothGatt#CONNECTION_PRIORITY_HIGH} + * or {@link BluetoothGatt#CONNECTION_PRIORITY_LOW_POWER}. * @throws IllegalArgumentException If the parameters are outside of their * specified range. */ - public boolean requestConnectionParameterUpdate(int connectionPriority) { - if (connectionPriority < GATT_CONNECTION_BALANCED || - connectionPriority > GATT_CONNECTION_LOW_POWER) { + public boolean requestConnectionPriority(int connectionPriority) { + if (connectionPriority < CONNECTION_PRIORITY_BALANCED || + connectionPriority > CONNECTION_PRIORITY_LOW_POWER) { throw new IllegalArgumentException("connectionPriority not within valid range"); } - if (DBG) Log.d(TAG, "requestConnectionParameterUpdate() - params: " + connectionPriority); + if (DBG) Log.d(TAG, "requestConnectionPriority() - params: " + connectionPriority); if (mService == null || mClientIf == 0) return false; try { diff --git a/core/java/android/bluetooth/BluetoothGattCallback.java b/core/java/android/bluetooth/BluetoothGattCallback.java index 5817d6844ae1..19900ec97e5f 100644 --- a/core/java/android/bluetooth/BluetoothGattCallback.java +++ b/core/java/android/bluetooth/BluetoothGattCallback.java @@ -143,14 +143,14 @@ public abstract class BluetoothGattCallback { * Callback indicating the MTU for a given device connection has changed. * * This callback is triggered in response to the - * {@link BluetoothGatt#configureMTU} function, or in response to a connection + * {@link BluetoothGatt#requestMtu} function, or in response to a connection * event. * - * @param gatt GATT client invoked {@link BluetoothGatt#configureMTU} + * @param gatt GATT client invoked {@link BluetoothGatt#requestMtu} * @param mtu The new MTU size * @param status {@link BluetoothGatt#GATT_SUCCESS} if the MTU has been changed successfully */ - public void onConfigureMTU(BluetoothGatt gatt, int mtu, int status) { + public void onMtuChanged(BluetoothGatt gatt, int mtu, int status) { } /** diff --git a/core/java/android/bluetooth/BluetoothGattServerCallback.java b/core/java/android/bluetooth/BluetoothGattServerCallback.java index 3a1b38ee6b3a..b0ddc26ef38d 100644 --- a/core/java/android/bluetooth/BluetoothGattServerCallback.java +++ b/core/java/android/bluetooth/BluetoothGattServerCallback.java @@ -141,7 +141,7 @@ public abstract class BluetoothGattServerCallback { * notifications. * * @param device The remote device the notification has been sent to - * @param status 0 if the operation was successful + * @param status {@link BluetoothGatt#GATT_SUCCESS} if the operation was successful */ public void onNotificationSent(BluetoothDevice device, int status) { } diff --git a/core/java/android/view/RenderNodeAnimator.java b/core/java/android/view/RenderNodeAnimator.java index a56d44839b13..9433237f4516 100644 --- a/core/java/android/view/RenderNodeAnimator.java +++ b/core/java/android/view/RenderNodeAnimator.java @@ -19,6 +19,7 @@ package android.view; import android.animation.Animator; import android.animation.TimeInterpolator; import android.animation.ValueAnimator; +import android.animation.Animator.AnimatorListener; import android.graphics.Canvas; import android.graphics.CanvasProperty; import android.graphics.Paint; @@ -202,7 +203,7 @@ public class RenderNodeAnimator extends Animator { mViewTarget.mTransformationInfo.mAlpha = mFinalValue; } - final ArrayList<AnimatorListener> listeners = getListeners(); + final ArrayList<AnimatorListener> listeners = cloneListeners(); final int numListeners = listeners == null ? 0 : listeners.size(); for (int i = 0; i < numListeners; i++) { listeners.get(i).onAnimationStart(this); @@ -220,7 +221,7 @@ public class RenderNodeAnimator extends Animator { getHelper().removeDelayedAnimation(this); nEnd(mNativePtr.get()); - final ArrayList<AnimatorListener> listeners = getListeners(); + final ArrayList<AnimatorListener> listeners = cloneListeners(); final int numListeners = listeners == null ? 0 : listeners.size(); for (int i = 0; i < numListeners; i++) { listeners.get(i).onAnimationCancel(this); @@ -329,13 +330,22 @@ public class RenderNodeAnimator extends Animator { protected void onFinished() { mFinished = true; - final ArrayList<AnimatorListener> listeners = getListeners(); + final ArrayList<AnimatorListener> listeners = cloneListeners(); final int numListeners = listeners == null ? 0 : listeners.size(); for (int i = 0; i < numListeners; i++) { listeners.get(i).onAnimationEnd(this); } } + @SuppressWarnings("unchecked") + private ArrayList<AnimatorListener> cloneListeners() { + ArrayList<AnimatorListener> listeners = getListeners(); + if (listeners != null) { + listeners = (ArrayList<AnimatorListener>) listeners.clone(); + } + return listeners; + } + long getNativeAnimator() { return mNativePtr.get(); } diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 243d7d797062..551efe91ad7d 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -13090,6 +13090,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback, removeSendViewScrolledAccessibilityEventCallback(); stopNestedScroll(); + // Anything that started animating right before detach should already + // be in its final state when re-attached. + jumpDrawablesToCurrentState(); + destroyDrawingCache(); cleanupDraw(); diff --git a/core/res/res/color/switch_thumb_material_dark.xml b/core/res/res/color/switch_thumb_material_dark.xml new file mode 100644 index 000000000000..8fede70f492e --- /dev/null +++ b/core/res/res/color/switch_thumb_material_dark.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2014 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<selector xmlns:android="http://schemas.android.com/apk/res/android"> + <item android:state_enabled="false" android:color="@color/switch_thumb_disabled_material_dark"/> + <item android:color="@color/switch_thumb_normal_material_dark"/> +</selector> diff --git a/core/res/res/color/switch_thumb_material_light.xml b/core/res/res/color/switch_thumb_material_light.xml new file mode 100644 index 000000000000..1a34b741ed62 --- /dev/null +++ b/core/res/res/color/switch_thumb_material_light.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2014 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<selector xmlns:android="http://schemas.android.com/apk/res/android"> + <item android:state_enabled="false" android:color="@color/switch_thumb_disabled_material_light"/> + <item android:color="@color/switch_thumb_normal_material_light"/> +</selector> diff --git a/core/res/res/drawable-hdpi/spinner_textfield_activated_mtrl_alpha.9.png b/core/res/res/drawable-hdpi/spinner_textfield_activated_mtrl_alpha.9.png Binary files differindex 8af9ceb4bacf..5e673955bc96 100644 --- a/core/res/res/drawable-hdpi/spinner_textfield_activated_mtrl_alpha.9.png +++ b/core/res/res/drawable-hdpi/spinner_textfield_activated_mtrl_alpha.9.png diff --git a/core/res/res/drawable-hdpi/spinner_textfield_default_mtrl_alpha.9.png b/core/res/res/drawable-hdpi/spinner_textfield_default_mtrl_alpha.9.png Binary files differindex 81c78c66ac41..9c2ee13a0c1e 100644 --- a/core/res/res/drawable-hdpi/spinner_textfield_default_mtrl_alpha.9.png +++ b/core/res/res/drawable-hdpi/spinner_textfield_default_mtrl_alpha.9.png diff --git a/core/res/res/drawable-hdpi/textfield_search_activated_mtrl_alpha.9.png b/core/res/res/drawable-hdpi/textfield_search_activated_mtrl_alpha.9.png Binary files differindex 7bcebcd14147..ce577e5007f3 100644 --- a/core/res/res/drawable-hdpi/textfield_search_activated_mtrl_alpha.9.png +++ b/core/res/res/drawable-hdpi/textfield_search_activated_mtrl_alpha.9.png diff --git a/core/res/res/drawable-hdpi/textfield_search_default_mtrl_alpha.9.png b/core/res/res/drawable-hdpi/textfield_search_default_mtrl_alpha.9.png Binary files differindex eb1d94599876..7c305ab71d6b 100644 --- a/core/res/res/drawable-hdpi/textfield_search_default_mtrl_alpha.9.png +++ b/core/res/res/drawable-hdpi/textfield_search_default_mtrl_alpha.9.png diff --git a/core/res/res/drawable-mdpi/spinner_textfield_activated_mtrl_alpha.9.png b/core/res/res/drawable-mdpi/spinner_textfield_activated_mtrl_alpha.9.png Binary files differindex 22992c047c98..cb8f78a2636b 100644 --- a/core/res/res/drawable-mdpi/spinner_textfield_activated_mtrl_alpha.9.png +++ b/core/res/res/drawable-mdpi/spinner_textfield_activated_mtrl_alpha.9.png diff --git a/core/res/res/drawable-mdpi/spinner_textfield_default_mtrl_alpha.9.png b/core/res/res/drawable-mdpi/spinner_textfield_default_mtrl_alpha.9.png Binary files differindex f44a2c252deb..64d4c81eec33 100644 --- a/core/res/res/drawable-mdpi/spinner_textfield_default_mtrl_alpha.9.png +++ b/core/res/res/drawable-mdpi/spinner_textfield_default_mtrl_alpha.9.png diff --git a/core/res/res/drawable-mdpi/textfield_search_activated_mtrl_alpha.9.png b/core/res/res/drawable-mdpi/textfield_search_activated_mtrl_alpha.9.png Binary files differindex ef4ebc0f03ed..d7faacf3eb62 100644 --- a/core/res/res/drawable-mdpi/textfield_search_activated_mtrl_alpha.9.png +++ b/core/res/res/drawable-mdpi/textfield_search_activated_mtrl_alpha.9.png diff --git a/core/res/res/drawable-mdpi/textfield_search_default_mtrl_alpha.9.png b/core/res/res/drawable-mdpi/textfield_search_default_mtrl_alpha.9.png Binary files differindex 9ddbcf5e422e..0a3603991496 100644 --- a/core/res/res/drawable-mdpi/textfield_search_default_mtrl_alpha.9.png +++ b/core/res/res/drawable-mdpi/textfield_search_default_mtrl_alpha.9.png diff --git a/core/res/res/drawable-xhdpi/spinner_textfield_activated_mtrl_alpha.9.png b/core/res/res/drawable-xhdpi/spinner_textfield_activated_mtrl_alpha.9.png Binary files differindex 2d79d596cb29..8e7862f8d836 100644 --- a/core/res/res/drawable-xhdpi/spinner_textfield_activated_mtrl_alpha.9.png +++ b/core/res/res/drawable-xhdpi/spinner_textfield_activated_mtrl_alpha.9.png diff --git a/core/res/res/drawable-xhdpi/spinner_textfield_default_mtrl_alpha.9.png b/core/res/res/drawable-xhdpi/spinner_textfield_default_mtrl_alpha.9.png Binary files differindex 36f975390ef5..95cb83f035fa 100644 --- a/core/res/res/drawable-xhdpi/spinner_textfield_default_mtrl_alpha.9.png +++ b/core/res/res/drawable-xhdpi/spinner_textfield_default_mtrl_alpha.9.png diff --git a/core/res/res/drawable-xhdpi/textfield_search_activated_mtrl_alpha.9.png b/core/res/res/drawable-xhdpi/textfield_search_activated_mtrl_alpha.9.png Binary files differindex 1a2546fe8958..33c103562075 100644 --- a/core/res/res/drawable-xhdpi/textfield_search_activated_mtrl_alpha.9.png +++ b/core/res/res/drawable-xhdpi/textfield_search_activated_mtrl_alpha.9.png diff --git a/core/res/res/drawable-xhdpi/textfield_search_default_mtrl_alpha.9.png b/core/res/res/drawable-xhdpi/textfield_search_default_mtrl_alpha.9.png Binary files differindex 500ec3325637..0226f84968c6 100644 --- a/core/res/res/drawable-xhdpi/textfield_search_default_mtrl_alpha.9.png +++ b/core/res/res/drawable-xhdpi/textfield_search_default_mtrl_alpha.9.png diff --git a/core/res/res/drawable-xxhdpi/spinner_textfield_activated_mtrl_alpha.9.png b/core/res/res/drawable-xxhdpi/spinner_textfield_activated_mtrl_alpha.9.png Binary files differindex 9c0b19e0674f..eb495c6505eb 100644 --- a/core/res/res/drawable-xxhdpi/spinner_textfield_activated_mtrl_alpha.9.png +++ b/core/res/res/drawable-xxhdpi/spinner_textfield_activated_mtrl_alpha.9.png diff --git a/core/res/res/drawable-xxhdpi/spinner_textfield_default_mtrl_alpha.9.png b/core/res/res/drawable-xxhdpi/spinner_textfield_default_mtrl_alpha.9.png Binary files differindex 0edb4b8ceaa6..c2268afa89cb 100644 --- a/core/res/res/drawable-xxhdpi/spinner_textfield_default_mtrl_alpha.9.png +++ b/core/res/res/drawable-xxhdpi/spinner_textfield_default_mtrl_alpha.9.png diff --git a/core/res/res/drawable-xxhdpi/textfield_search_activated_mtrl_alpha.9.png b/core/res/res/drawable-xxhdpi/textfield_search_activated_mtrl_alpha.9.png Binary files differindex cd5b00fb2553..b6efff3096a1 100644 --- a/core/res/res/drawable-xxhdpi/textfield_search_activated_mtrl_alpha.9.png +++ b/core/res/res/drawable-xxhdpi/textfield_search_activated_mtrl_alpha.9.png diff --git a/core/res/res/drawable-xxhdpi/textfield_search_default_mtrl_alpha.9.png b/core/res/res/drawable-xxhdpi/textfield_search_default_mtrl_alpha.9.png Binary files differindex 5ee867ca2d2d..2b253fb266b1 100644 --- a/core/res/res/drawable-xxhdpi/textfield_search_default_mtrl_alpha.9.png +++ b/core/res/res/drawable-xxhdpi/textfield_search_default_mtrl_alpha.9.png diff --git a/core/res/res/drawable-xxxhdpi/spinner_textfield_activated_mtrl_alpha.9.png b/core/res/res/drawable-xxxhdpi/spinner_textfield_activated_mtrl_alpha.9.png Binary files differindex 78c5ebd597e8..fbcd7d4f29a6 100644 --- a/core/res/res/drawable-xxxhdpi/spinner_textfield_activated_mtrl_alpha.9.png +++ b/core/res/res/drawable-xxxhdpi/spinner_textfield_activated_mtrl_alpha.9.png diff --git a/core/res/res/drawable-xxxhdpi/spinner_textfield_default_mtrl_alpha.9.png b/core/res/res/drawable-xxxhdpi/spinner_textfield_default_mtrl_alpha.9.png Binary files differindex 36974b7c1508..ebc9bf7592e0 100644 --- a/core/res/res/drawable-xxxhdpi/spinner_textfield_default_mtrl_alpha.9.png +++ b/core/res/res/drawable-xxxhdpi/spinner_textfield_default_mtrl_alpha.9.png diff --git a/core/res/res/drawable/btn_borderless_material.xml b/core/res/res/drawable/btn_borderless_material.xml index 47cc455d6d54..016f0ff15683 100644 --- a/core/res/res/drawable/btn_borderless_material.xml +++ b/core/res/res/drawable/btn_borderless_material.xml @@ -15,10 +15,7 @@ --> <inset xmlns:android="http://schemas.android.com/apk/res/android" - android:insetLeft="@dimen/control_inset_material" - android:insetTop="@dimen/control_inset_material" - android:insetBottom="@dimen/control_inset_material" - android:insetRight="@dimen/control_inset_material"> + android:inset="@dimen/control_inset_material"> <ripple android:color="?attr/colorControlHighlight"> <item android:id="@id/mask" android:drawable="@drawable/btn_default_mtrl_shape" /> diff --git a/core/res/res/drawable/btn_default_material.xml b/core/res/res/drawable/btn_default_material.xml index b04d4fb2f75b..d00a34839827 100644 --- a/core/res/res/drawable/btn_default_material.xml +++ b/core/res/res/drawable/btn_default_material.xml @@ -15,10 +15,7 @@ --> <inset xmlns:android="http://schemas.android.com/apk/res/android" - android:insetLeft="@dimen/control_inset_material" - android:insetTop="@dimen/control_inset_material" - android:insetBottom="@dimen/control_inset_material" - android:insetRight="@dimen/control_inset_material"> + android:inset="@dimen/control_inset_material"> <ripple android:color="?attr/colorControlHighlight"> <item android:drawable="@drawable/btn_default_mtrl_shape" /> </ripple> diff --git a/core/res/res/drawable/btn_toggle_material.xml b/core/res/res/drawable/btn_toggle_material.xml index a9951e7188b1..9726782e0efb 100644 --- a/core/res/res/drawable/btn_toggle_material.xml +++ b/core/res/res/drawable/btn_toggle_material.xml @@ -15,10 +15,7 @@ --> <inset xmlns:android="http://schemas.android.com/apk/res/android" - android:insetLeft="@dimen/control_inset_material" - android:insetTop="@dimen/control_inset_material" - android:insetBottom="@dimen/control_inset_material" - android:insetRight="@dimen/control_inset_material"> + android:inset="@dimen/control_inset_material"> <layer-list android:paddingMode="stack"> <item> <ripple android:color="?attr/colorControlHighlight"> diff --git a/core/res/res/drawable/edit_text_material.xml b/core/res/res/drawable/edit_text_material.xml index eaf5e45d6893..bbc7301d938f 100644 --- a/core/res/res/drawable/edit_text_material.xml +++ b/core/res/res/drawable/edit_text_material.xml @@ -15,10 +15,7 @@ --> <inset xmlns:android="http://schemas.android.com/apk/res/android" - android:insetLeft="@dimen/control_inset_material" - android:insetTop="@dimen/control_inset_material" - android:insetBottom="@dimen/control_inset_material" - android:insetRight="@dimen/control_inset_material"> + android:inset="@dimen/control_inset_material"> <ripple android:color="?attr/colorControlActivated"> <item> <selector> diff --git a/core/res/res/drawable/spinner_textfield_background_material.xml b/core/res/res/drawable/spinner_textfield_background_material.xml index f818baf13089..5bdff4a59140 100644 --- a/core/res/res/drawable/spinner_textfield_background_material.xml +++ b/core/res/res/drawable/spinner_textfield_background_material.xml @@ -14,18 +14,20 @@ limitations under the License. --> -<selector xmlns:android="http://schemas.android.com/apk/res/android" - android:autoMirrored="true"> - <item android:state_checked="true"> - <nine-patch android:src="@drawable/spinner_textfield_activated_mtrl_alpha" - android:tint="?attr/colorControlActivated" /> - </item> - <item android:state_pressed="true"> - <nine-patch android:src="@drawable/spinner_textfield_activated_mtrl_alpha" - android:tint="?attr/colorControlActivated" /> - </item> - <item> - <nine-patch android:src="@drawable/spinner_textfield_default_mtrl_alpha" - android:tint="?attr/colorControlNormal" /> - </item> -</selector> +<inset xmlns:android="http://schemas.android.com/apk/res/android" + android:inset="@dimen/control_inset_material"> + <selector android:autoMirrored="true"> + <item android:state_checked="true"> + <nine-patch android:src="@drawable/spinner_textfield_activated_mtrl_alpha" + android:tint="?attr/colorControlActivated" /> + </item> + <item android:state_pressed="true"> + <nine-patch android:src="@drawable/spinner_textfield_activated_mtrl_alpha" + android:tint="?attr/colorControlActivated" /> + </item> + <item> + <nine-patch android:src="@drawable/spinner_textfield_default_mtrl_alpha" + android:tint="?attr/colorControlNormal" /> + </item> + </selector> +</inset> diff --git a/core/res/res/drawable/switch_thumb_material_anim.xml b/core/res/res/drawable/switch_thumb_material_anim.xml index 30bc88823409..0d4d78ec654a 100644 --- a/core/res/res/drawable/switch_thumb_material_anim.xml +++ b/core/res/res/drawable/switch_thumb_material_anim.xml @@ -16,22 +16,12 @@ <animated-selector xmlns:android="http://schemas.android.com/apk/res/android" android:constantSize="true"> - <item - android:state_enabled="false" - android:state_checked="true"> - <nine-patch - android:src="@drawable/btn_switch_to_on_mtrl_00012" - android:gravity="center" - android:tintMode="multiply" - android:tint="?attr/colorControlActivated" - android:alpha="?attr/disabledAlpha" /> - </item> - <item android:state_enabled="false"> + <item android:state_enabled="false" android:id="@+id/off"> <nine-patch android:src="@drawable/btn_switch_to_on_mtrl_00001" android:gravity="center" android:tintMode="multiply" - android:tint="?attr/colorButtonNormal" /> + android:tint="?attr/colorSwitchThumbNormal" /> </item> <item android:state_checked="true" @@ -47,29 +37,29 @@ android:src="@drawable/btn_switch_to_on_mtrl_00001" android:gravity="center" android:tintMode="multiply" - android:tint="?attr/colorButtonNormal" /> + android:tint="?attr/colorSwitchThumbNormal" /> </item> <transition android:fromId="@+id/off" android:toId="@+id/on"> <animation-list> <item android:duration="15"> - <nine-patch android:src="@drawable/btn_switch_to_on_mtrl_00001" android:gravity="center" android:tintMode="multiply" android:tint="?attr/colorButtonNormal" /> + <nine-patch android:src="@drawable/btn_switch_to_on_mtrl_00001" android:gravity="center" android:tintMode="multiply" android:tint="?attr/colorSwitchThumbNormal" /> </item> <item android:duration="15"> - <nine-patch android:src="@drawable/btn_switch_to_on_mtrl_00002" android:gravity="center" android:tintMode="multiply" android:tint="?attr/colorButtonNormal" /> + <nine-patch android:src="@drawable/btn_switch_to_on_mtrl_00002" android:gravity="center" android:tintMode="multiply" android:tint="?attr/colorSwitchThumbNormal" /> </item> <item android:duration="15"> - <nine-patch android:src="@drawable/btn_switch_to_on_mtrl_00003" android:gravity="center" android:tintMode="multiply" android:tint="?attr/colorButtonNormal" /> + <nine-patch android:src="@drawable/btn_switch_to_on_mtrl_00003" android:gravity="center" android:tintMode="multiply" android:tint="?attr/colorSwitchThumbNormal" /> </item> <item android:duration="15"> - <nine-patch android:src="@drawable/btn_switch_to_on_mtrl_00004" android:gravity="center" android:tintMode="multiply" android:tint="?attr/colorButtonNormal" /> + <nine-patch android:src="@drawable/btn_switch_to_on_mtrl_00004" android:gravity="center" android:tintMode="multiply" android:tint="?attr/colorSwitchThumbNormal" /> </item> <item android:duration="15"> - <nine-patch android:src="@drawable/btn_switch_to_on_mtrl_00005" android:gravity="center" android:tintMode="multiply" android:tint="?attr/colorButtonNormal" /> + <nine-patch android:src="@drawable/btn_switch_to_on_mtrl_00005" android:gravity="center" android:tintMode="multiply" android:tint="?attr/colorSwitchThumbNormal" /> </item> <item android:duration="15"> - <nine-patch android:src="@drawable/btn_switch_to_on_mtrl_00006" android:gravity="center" android:tintMode="multiply" android:tint="?attr/colorButtonNormal" /> + <nine-patch android:src="@drawable/btn_switch_to_on_mtrl_00006" android:gravity="center" android:tintMode="multiply" android:tint="?attr/colorSwitchThumbNormal" /> </item> <item android:duration="15"> <nine-patch android:src="@drawable/btn_switch_to_on_mtrl_00007" android:gravity="center" android:tintMode="multiply" android:tint="?attr/colorControlActivated" /> @@ -112,22 +102,22 @@ <nine-patch android:src="@drawable/btn_switch_to_off_mtrl_00006" android:gravity="center" android:tintMode="multiply" android:tint="?attr/colorControlActivated" /> </item> <item android:duration="15"> - <nine-patch android:src="@drawable/btn_switch_to_off_mtrl_00007" android:gravity="center" android:tintMode="multiply" android:tint="?attr/colorButtonNormal" /> + <nine-patch android:src="@drawable/btn_switch_to_off_mtrl_00007" android:gravity="center" android:tintMode="multiply" android:tint="?attr/colorSwitchThumbNormal" /> </item> <item android:duration="15"> - <nine-patch android:src="@drawable/btn_switch_to_off_mtrl_00008" android:gravity="center" android:tintMode="multiply" android:tint="?attr/colorButtonNormal" /> + <nine-patch android:src="@drawable/btn_switch_to_off_mtrl_00008" android:gravity="center" android:tintMode="multiply" android:tint="?attr/colorSwitchThumbNormal" /> </item> <item android:duration="15"> - <nine-patch android:src="@drawable/btn_switch_to_off_mtrl_00009" android:gravity="center" android:tintMode="multiply" android:tint="?attr/colorButtonNormal" /> + <nine-patch android:src="@drawable/btn_switch_to_off_mtrl_00009" android:gravity="center" android:tintMode="multiply" android:tint="?attr/colorSwitchThumbNormal" /> </item> <item android:duration="15"> - <nine-patch android:src="@drawable/btn_switch_to_off_mtrl_00010" android:gravity="center" android:tintMode="multiply" android:tint="?attr/colorButtonNormal" /> + <nine-patch android:src="@drawable/btn_switch_to_off_mtrl_00010" android:gravity="center" android:tintMode="multiply" android:tint="?attr/colorSwitchThumbNormal" /> </item> <item android:duration="15"> - <nine-patch android:src="@drawable/btn_switch_to_off_mtrl_00011" android:gravity="center" android:tintMode="multiply" android:tint="?attr/colorButtonNormal" /> + <nine-patch android:src="@drawable/btn_switch_to_off_mtrl_00011" android:gravity="center" android:tintMode="multiply" android:tint="?attr/colorSwitchThumbNormal" /> </item> <item android:duration="15"> - <nine-patch android:src="@drawable/btn_switch_to_off_mtrl_00012" android:gravity="center" android:tintMode="multiply" android:tint="?attr/colorButtonNormal" /> + <nine-patch android:src="@drawable/btn_switch_to_off_mtrl_00012" android:gravity="center" android:tintMode="multiply" android:tint="?attr/colorSwitchThumbNormal" /> </item> </animation-list> </transition> diff --git a/core/res/res/drawable/switch_track_material.xml b/core/res/res/drawable/switch_track_material.xml index 0728055463a9..1ec2f88ed0c8 100644 --- a/core/res/res/drawable/switch_track_material.xml +++ b/core/res/res/drawable/switch_track_material.xml @@ -15,10 +15,10 @@ --> <selector xmlns:android="http://schemas.android.com/apk/res/android"> - <item android:state_enabled="false" android:state_checked="true"> + <item android:state_enabled="false"> <nine-patch android:src="@drawable/switch_track_mtrl_alpha" - android:tint="?attr/colorControlActivated" - android:alpha="0.2" /> + android:tint="?attr/colorForeground" + android:alpha="0.1" /> </item> <item android:state_checked="true"> <nine-patch android:src="@drawable/switch_track_mtrl_alpha" @@ -27,7 +27,7 @@ </item> <item> <nine-patch android:src="@drawable/switch_track_mtrl_alpha" - android:tint="?attr/colorButtonNormal" + android:tint="?attr/colorForeground" android:alpha="0.3" /> </item> </selector> diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml index b00d7e841bdb..e7a833b0dc0c 100644 --- a/core/res/res/values/attrs.xml +++ b/core/res/res/values/attrs.xml @@ -1005,6 +1005,9 @@ <!-- The color applied to framework buttons in their normal state. --> <attr name="colorButtonNormal" format="color" /> + <!-- The color applied to framework switch thumbs in their normal state. --> + <attr name="colorSwitchThumbNormal" format="color" /> + <!-- ================== --> <!-- Hardware rendering --> <!-- ================== --> diff --git a/core/res/res/values/colors_material.xml b/core/res/res/values/colors_material.xml index ccbb8bced384..234895113731 100644 --- a/core/res/res/values/colors_material.xml +++ b/core/res/res/values/colors_material.xml @@ -25,6 +25,11 @@ <color name="button_material_dark">#ff5a595b</color> <color name="button_material_light">#ffd6d7d7</color> + <color name="switch_thumb_normal_material_dark">#ffbdbdbd</color> + <color name="switch_thumb_normal_material_light">#fff1f1f1</color> + <color name="switch_thumb_disabled_material_dark">#ff616161</color> + <color name="switch_thumb_disabled_material_light">#ffbdbdbd</color> + <color name="bright_foreground_material_dark">@color/white</color> <color name="bright_foreground_material_light">@color/black</color> <!-- White 50% --> diff --git a/core/res/res/values/themes.xml b/core/res/res/values/themes.xml index b36cdb9829f2..5445816e9e61 100644 --- a/core/res/res/values/themes.xml +++ b/core/res/res/values/themes.xml @@ -116,12 +116,12 @@ please see themes_device_defaults.xml. <!-- Button styles --> <item name="buttonStyle">@style/Widget.Button</item> - <item name="buttonStyleSmall">@style/Widget.Button.Small</item> <item name="buttonStyleInset">@style/Widget.Button.Inset</item> - <item name="buttonStyleToggle">@style/Widget.Button.Toggle</item> + <item name="switchStyle">@style/Widget.CompoundButton.Switch</item> + <item name="selectableItemBackground">@drawable/item_background</item> <item name="selectableItemBackgroundBorderless">?attr/selectableItemBackground</item> <item name="borderlessButtonStyle">?attr/buttonStyle</item> diff --git a/core/res/res/values/themes_material.xml b/core/res/res/values/themes_material.xml index 18170ac4fcd4..bff5ce24082a 100644 --- a/core/res/res/values/themes_material.xml +++ b/core/res/res/values/themes_material.xml @@ -379,6 +379,7 @@ please see themes_device_defaults.xml. <item name="colorControlHighlight">@color/ripple_material_dark</item> <item name="colorButtonNormal">@color/btn_default_material_dark</item> + <item name="colorSwitchThumbNormal">@color/switch_thumb_material_dark</item> </style> <!-- Material theme (light version). --> @@ -721,6 +722,7 @@ please see themes_device_defaults.xml. <item name="colorControlHighlight">@color/ripple_material_light</item> <item name="colorButtonNormal">@color/btn_default_material_light</item> + <item name="colorSwitchThumbNormal">@color/switch_thumb_material_light</item> </style> <!-- Variant of the material (light) theme that has a solid (opaque) action bar @@ -774,6 +776,7 @@ please see themes_device_defaults.xml. <item name="colorControlNormal">?attr/textColorSecondary</item> <item name="colorControlHighlight">@color/ripple_material_light</item> <item name="colorButtonNormal">@color/btn_default_material_light</item> + <item name="colorSwitchThumbNormal">@color/switch_thumb_material_light</item> </style> <!-- Theme overlay that replaces colors with their dark versions but preserves @@ -811,6 +814,7 @@ please see themes_device_defaults.xml. <item name="colorControlNormal">?attr/textColorSecondary</item> <item name="colorControlHighlight">@color/ripple_material_dark</item> <item name="colorButtonNormal">@color/btn_default_material_dark</item> + <item name="colorSwitchThumbNormal">@color/switch_thumb_material_dark</item> </style> <!-- Theme overlay that replaces the normal control color, which by default is the same as the diff --git a/docs/html/guide/components/intents-common.jd b/docs/html/guide/components/intents-common.jd index 3b52b0a078b0..af9456de47f7 100644 --- a/docs/html/guide/components/intents-common.jd +++ b/docs/html/guide/components/intents-common.jd @@ -1678,7 +1678,7 @@ android.net.Uri}s pointing to the images/videos to attach.</dd> <p><b>Example intent:</b></p> <pre> public void composeMmsMessage(String message, Uri attachment) { - Intent intent = new Intent(Intent.ACTION_SEND); + Intent intent = new Intent(Intent.ACTION_SENDTO); intent.setType(HTTP.PLAIN_TEXT_TYPE); intent.putExtra("sms_body", message); intent.putExtra(Intent.EXTRA_STREAM, attachment); diff --git a/docs/html/guide/topics/ui/declaring-layout.jd b/docs/html/guide/topics/ui/declaring-layout.jd index cb952a40afaa..ab105fd300ed 100644 --- a/docs/html/guide/topics/ui/declaring-layout.jd +++ b/docs/html/guide/topics/ui/declaring-layout.jd @@ -31,7 +31,7 @@ page.tags=view,viewgroup <li>{@link android.view.ViewGroup}</li> <li>{@link android.view.ViewGroup.LayoutParams}</li> </ol> - + <h2>See also</h2> <ol> <li><a href="{@docRoot}training/basics/firstapp/building-ui.html">Building a Simple User @@ -43,9 +43,9 @@ href="{@docRoot}guide/components/activities.html">activity</a> or <a href="{@docRoot}guide/topics/appwidgets/index.html">app widget</a>. You can declare a layout in two ways:</p> <ul> -<li><strong>Declare UI elements in XML</strong>. Android provides a straightforward XML +<li><strong>Declare UI elements in XML</strong>. Android provides a straightforward XML vocabulary that corresponds to the View classes and subclasses, such as those for widgets and layouts.</li> -<li><strong>Instantiate layout elements at runtime</strong>. Your +<li><strong>Instantiate layout elements at runtime</strong>. Your application can create View and ViewGroup objects (and manipulate their properties) programmatically. </li> </ul> @@ -55,12 +55,12 @@ application can create View and ViewGroup objects (and manipulate their properti <div class="sidebox"> <ul> <li>The <a href="{@docRoot}tools/sdk/eclipse-adt.html">ADT - Plugin for Eclipse</a> offers a layout preview of your XML — + Plugin for Eclipse</a> offers a layout preview of your XML — with the XML file opened, select the <strong>Layout</strong> tab.</li> - <li>You should also try the - <a href="{@docRoot}tools/debugging/debugging-ui.html#hierarchyViewer">Hierarchy Viewer</a> tool, - for debugging layouts — it reveals layout property values, - draws wireframes with padding/margin indicators, and full rendered views while + <li>You should also try the + <a href="{@docRoot}tools/debugging/debugging-ui.html#hierarchyViewer">Hierarchy Viewer</a> tool, + for debugging layouts — it reveals layout property values, + draws wireframes with padding/margin indicators, and full rendered views while you debug on the emulator or device.</li> <li>The <a href="{@docRoot}tools/debugging/debugging-ui.html#layoutopt">layoutopt</a> tool lets you quickly analyze your layouts and hierarchies for inefficiencies or other problems.</li> @@ -68,7 +68,7 @@ application can create View and ViewGroup objects (and manipulate their properti </div> <p>The advantage to declaring your UI in XML is that it enables you to better separate the presentation of your application from the code that controls its behavior. Your UI descriptions are external to your application code, which means that you can modify or adapt it without having to modify your source code and recompile. For example, you can create XML layouts for different screen orientations, different device screen sizes, and different languages. Additionally, declaring the layout in XML makes it easier to visualize the structure of your UI, so it's easier to debug problems. As such, this document focuses on teaching you how to declare your layout in XML. If you're -interested in instantiating View objects at runtime, refer to the {@link android.view.ViewGroup} and +interested in instantiating View objects at runtime, refer to the {@link android.view.ViewGroup} and {@link android.view.View} class references.</p> <p>In general, the XML vocabulary for declaring UI elements closely follows the structure and naming of the classes and methods, where element names correspond to class names and attribute names correspond to methods. In fact, the correspondence is often so direct that you can guess what XML attribute corresponds to a class method, or guess what class corresponds to a given XML element. However, note that not all vocabulary is identical. In some cases, there are slight naming differences. For @@ -102,7 +102,7 @@ to hold a {@link android.widget.TextView} and a {@link android.widget.Button}:</ </LinearLayout> </pre> -<p>After you've declared your layout in XML, save the file with the <code>.xml</code> extension, +<p>After you've declared your layout in XML, save the file with the <code>.xml</code> extension, in your Android project's <code>res/layout/</code> directory, so it will properly compile. </p> <p>More information about the syntax for a layout XML file is available in the <a @@ -111,11 +111,11 @@ href="{@docRoot}guide/topics/resources/layout-resource.html">Layout Resources</a <h2 id="load">Load the XML Resource</h2> <p>When you compile your application, each XML layout file is compiled into a -{@link android.view.View} resource. You should load the layout resource from your application code, in your +{@link android.view.View} resource. You should load the layout resource from your application code, in your {@link android.app.Activity#onCreate(android.os.Bundle) Activity.onCreate()} callback implementation. -Do so by calling <code>{@link android.app.Activity#setContentView(int) setContentView()}</code>, -passing it the reference to your layout resource in the form of: -<code>R.layout.<em>layout_file_name</em></code>. +Do so by calling <code>{@link android.app.Activity#setContentView(int) setContentView()}</code>, +passing it the reference to your layout resource in the form of: +<code>R.layout.<em>layout_file_name</em></code>. For example, if your XML layout is saved as <code>main_layout.xml</code>, you would load it for your Activity like so:</p> <pre> @@ -126,7 +126,7 @@ public void onCreate(Bundle savedInstanceState) { </pre> <p>The <code>onCreate()</code> callback method in your Activity is called by the Android framework when -your Activity is launched (see the discussion about lifecycles, in the +your Activity is launched (see the discussion about lifecycles, in the <a href="{@docRoot}guide/components/activities.html#Lifecycle">Activities</a> document).</p> @@ -136,18 +136,18 @@ document).</p> <p>Every View and ViewGroup object supports their own variety of XML attributes. Some attributes are specific to a View object (for example, TextView supports the <code>textSize</code> attribute), but these attributes are also inherited by any View objects that may extend this class. -Some are common to all View objects, because they are inherited from the root View class (like -the <code>id</code> attribute). And, other attributes are considered "layout parameters," which are +Some are common to all View objects, because they are inherited from the root View class (like +the <code>id</code> attribute). And, other attributes are considered "layout parameters," which are attributes that describe certain layout orientations of the View object, as defined by that object's parent ViewGroup object.</p> <h3 id="id">ID</h3> <p>Any View object may have an integer ID associated with it, to uniquely identify the View within the tree. -When the application is compiled, this ID is referenced as an integer, but the ID is typically +When the application is compiled, this ID is referenced as an integer, but the ID is typically assigned in the layout XML file as a string, in the <code>id</code> attribute. This is an XML attribute common to all View objects -(defined by the {@link android.view.View} class) and you will use it very often. +(defined by the {@link android.view.View} class) and you will use it very often. The syntax for an ID, inside an XML tag is:</p> <pre>android:id="@+id/my_button"</pre> @@ -170,7 +170,7 @@ resources class, rather than the local resources class.</p> android:text="@string/my_button_text"/> </pre> </li> - <li>Then create an instance of the view object and capture it from the layout + <li>Then create an instance of the view object and capture it from the layout (typically in the <code>{@link android.app.Activity#onCreate(Bundle) onCreate()}</code> method): <pre> Button myButton = (Button) findViewById(R.id.my_button); @@ -178,16 +178,16 @@ Button myButton = (Button) findViewById(R.id.my_button); </li> </ol> <p>Defining IDs for view objects is important when creating a {@link android.widget.RelativeLayout}. -In a relative layout, sibling views can define their layout relative to another sibling view, +In a relative layout, sibling views can define their layout relative to another sibling view, which is referenced by the unique ID.</p> <p>An ID need not be unique throughout the entire tree, but it should be -unique within the part of the tree you are searching (which may often be the entire tree, so it's best +unique within the part of the tree you are searching (which may often be the entire tree, so it's best to be completely unique when possible).</p> <h3 id="layout-params">Layout Parameters</h3> -<p>XML layout attributes named <code>layout_<em>something</em></code> define +<p>XML layout attributes named <code>layout_<em>something</em></code> define layout parameters for the View that are appropriate for the ViewGroup in which it resides.</p> <p>Every ViewGroup class implements a nested class that extends {@link @@ -201,7 +201,7 @@ view group defines layout parameters for each child view (including the child vi parameters associated with each view.</p> <p>Note that every LayoutParams subclass has its own syntax for setting -values. Each child element must define LayoutParams that are appropriate for its parent, +values. Each child element must define LayoutParams that are appropriate for its parent, though it may also define different LayoutParams for its own children. </p> <p>All view groups include a width and height (<code>layout_width</code> and @@ -236,7 +236,7 @@ Available Resources</a> document.</p> two dimensions, expressed as a width and a height. The unit for location and dimensions is the pixel. </p> - + <p> It is possible to retrieve the location of a view by invoking the methods {@link android.view.View#getLeft()} and {@link android.view.View#getTop()}. The former returns the left, or X, @@ -246,7 +246,7 @@ Available Resources</a> document.</p> when <code>getLeft()</code> returns 20, that means the view is located 20 pixels to the right of the left edge of its direct parent. </p> - + <p> In addition, several convenience methods are offered to avoid unnecessary computations, namely {@link android.view.View#getRight()} and {@link android.view.View#getBottom()}. @@ -254,14 +254,14 @@ Available Resources</a> document.</p> rectangle representing the view. For instance, calling {@link android.view.View#getRight()} is similar to the following computation: <code>getLeft() + getWidth()</code>. </p> - + <h2 id="SizePaddingMargins">Size, Padding and Margins</h2> <p> The size of a view is expressed with a width and a height. A view actually possess two pairs of width and height values. </p> - + <p> The first pair is known as <em>measured width</em> and <em>measured height</em>. These dimensions define how big a view wants to be @@ -269,16 +269,16 @@ Available Resources</a> document.</p> measured dimensions can be obtained by calling {@link android.view.View#getMeasuredWidth()} and {@link android.view.View#getMeasuredHeight()}. </p> - + <p> The second pair is simply known as <em>width</em> and <em>height</em>, or sometimes <em>drawing width</em> and <em>drawing height</em>. These dimensions define the actual size of the view on screen, at drawing time and after layout. These values may, but do not have to, be different from the measured width and height. The width and height can be obtained by calling - {@link android.view.View#getWidth()} and {@link android.view.View#getHeight()}. + {@link android.view.View#getWidth()} and {@link android.view.View#getHeight()}. </p> - + <p> To measure its dimensions, a view takes into account its padding. The padding is expressed in pixels for the left, top, right and bottom parts of the view. @@ -287,9 +287,9 @@ Available Resources</a> document.</p> 2 pixels to the right of the left edge. Padding can be set using the {@link android.view.View#setPadding(int, int, int, int)} method and queried by calling {@link android.view.View#getPaddingLeft()}, {@link android.view.View#getPaddingTop()}, - {@link android.view.View#getPaddingRight()} and {@link android.view.View#getPaddingBottom()}. + {@link android.view.View#getPaddingRight()} and {@link android.view.View#getPaddingBottom()}. </p> - + <p> Even though a view can define a padding, it does not provide any support for margins. However, view groups provide such a support. Refer to @@ -297,13 +297,13 @@ Available Resources</a> document.</p> {@link android.view.ViewGroup.MarginLayoutParams} for further information. </p> - <p>For more information about dimensions, see + <p>For more information about dimensions, see <a href="{@docRoot}guide/topics/resources/more-resources.html#Dimension">Dimension Values</a>. </p> - - - + + + <style type="text/css"> @@ -332,7 +332,7 @@ layout to acheive your UI design, you should strive to keep your layout hierarch possible. Your layout draws faster if it has fewer nested layouts (a wide view hierarchy is better than a deep view hierarchy).</p> -<!-- +<!-- <h2 id="framelayout">FrameLayout</h2> <p>{@link android.widget.FrameLayout FrameLayout} is the simplest type of layout object. It's basically a blank space on your screen that you can @@ -417,7 +417,7 @@ android.widget.TextView}. android.widget.ListView}, initialize a new {@link android.widget.ArrayAdapter} using a constructor to specify the layout for each string and the string array:</p> <pre> -ArrayAdapter adapter = new ArrayAdapter<String>(this, +ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, myStringArray); </pre> <p>The arguments for this constructor are:</p> @@ -453,14 +453,14 @@ numbers. You then create a string array specifying which columns from the {@link android.database.Cursor} you want in the layout for each result and an integer array specifying the corresponding views that each column should be placed:</p> <pre> -String[] fromColumns = {ContactsContract.Data.DISPLAY_NAME, +String[] fromColumns = {ContactsContract.Data.DISPLAY_NAME, ContactsContract.CommonDataKinds.Phone.NUMBER}; int[] toViews = {R.id.display_name, R.id.phone_number}; </pre> <p>When you instantiate the {@link android.widget.SimpleCursorAdapter}, pass the layout to use for each result, the {@link android.database.Cursor} containing the results, and these two arrays:</p> <pre> -SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, +SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, R.layout.person_name_and_number, cursor, fromColumns, toViews, 0); ListView listView = getListView(); listView.setAdapter(adapter); @@ -490,7 +490,7 @@ private OnItemClickListener mMessageClickedHandler = new OnItemClickListener() { } }; -listView.setOnItemClickListener(mMessageClickedHandler); +listView.setOnItemClickListener(mMessageClickedHandler); </pre> diff --git a/docs/html/sdk/installing/create-project.jd b/docs/html/sdk/installing/create-project.jd index c0d523acfd4d..a7c12d4e00e8 100644 --- a/docs/html/sdk/installing/create-project.jd +++ b/docs/html/sdk/installing/create-project.jd @@ -76,7 +76,7 @@ each of them, as shown in Figure 7.</p> <img src="{@docRoot}images/tools/wizard7.png" alt="" width="750" height="509"> <p class="img-caption"><strong>Figure 7.</strong> The default project structure for a mobile app.</p> -<p>Now you are ready to develop your app. Fore more information, see the following links:</p> +<p>Now you are ready to develop your app. For more information, see the following links:</p> <ul> <li><a href="{@docRoot}training/">Training Lessons</a></li> diff --git a/docs/html/training/wearables/data-layer/assets.jd b/docs/html/training/wearables/data-layer/assets.jd index 52ccbb01cf66..5dc11cb8649e 100644 --- a/docs/html/training/wearables/data-layer/assets.jd +++ b/docs/html/training/wearables/data-layer/assets.jd @@ -91,7 +91,7 @@ public void onDataChanged(DataEventBuffer dataEvents) { for (DataEvent event : dataEvents) { if (event.getType() == DataEvent.TYPE_CHANGED && event.getDataItem().getUri().getPath().equals("/image")) { - DataMapItem dataMapItem = DataMapItem.fromDataItem(dataItem); + DataMapItem dataMapItem = DataMapItem.fromDataItem(event.getDataItem()); Asset profileAsset = dataMapItem.getDataMap().getAsset("profileImage"); Bitmap bitmap = loadBitmapFromAsset(profileAsset); // Do something with the bitmap diff --git a/graphics/java/android/graphics/drawable/GradientDrawable.java b/graphics/java/android/graphics/drawable/GradientDrawable.java index 29b914153461..2c8611e794f6 100644 --- a/graphics/java/android/graphics/drawable/GradientDrawable.java +++ b/graphics/java/android/graphics/drawable/GradientDrawable.java @@ -811,6 +811,11 @@ public class GradientDrawable extends Drawable { } @Override + public ColorFilter getColorFilter() { + return mColorFilter; + } + + @Override public void setColorFilter(ColorFilter cf) { if (cf != mColorFilter) { mColorFilter = cf; diff --git a/graphics/java/android/graphics/drawable/Ripple.java b/graphics/java/android/graphics/drawable/Ripple.java index be2241bca205..063ac098773e 100644 --- a/graphics/java/android/graphics/drawable/Ripple.java +++ b/graphics/java/android/graphics/drawable/Ripple.java @@ -211,7 +211,7 @@ class Ripple { final boolean canUseHardware = c.isHardwareAccelerated(); if (mCanUseHardware != canUseHardware && mCanUseHardware) { // We've switched from hardware to non-hardware mode. Panic. - cancelHardwareAnimations(); + cancelHardwareAnimations(true); } mCanUseHardware = canUseHardware; @@ -231,7 +231,7 @@ class Ripple { final ArrayList<RenderNodeAnimator> pendingAnimations = mPendingAnimations; final int N = pendingAnimations.size(); if (N > 0) { - cancelHardwareAnimations(); + cancelHardwareAnimations(false); for (int i = 0; i < N; i++) { pendingAnimations.get(i).setTarget(c); @@ -399,6 +399,45 @@ class Ripple { invalidateSelf(); } + public void jump() { + endSoftwareAnimations(); + endHardwareAnimations(); + } + + private void endSoftwareAnimations() { + if (mAnimRadius != null) { + mAnimRadius.end(); + } + + if (mAnimOpacity != null) { + mAnimOpacity.end(); + } + + if (mAnimX != null) { + mAnimX.end(); + } + + if (mAnimY != null) { + mAnimY.end(); + } + } + + private void endHardwareAnimations() { + final ArrayList<RenderNodeAnimator> runningAnimations = mRunningAnimations; + final int N = runningAnimations.size(); + for (int i = 0; i < N; i++) { + runningAnimations.get(i).end(); + } + runningAnimations.clear(); + + // Abort any pending animations. Since we always have a completion + // listener on a pending animation, we also need to remove ourselves. + if (!mPendingAnimations.isEmpty()) { + mPendingAnimations.clear(); + removeSelf(); + } + } + private Paint getTempPaint() { if (mTempPaint == null) { mTempPaint = new Paint(); @@ -444,7 +483,7 @@ class Ripple { */ public void cancel() { cancelSoftwareAnimations(); - cancelHardwareAnimations(); + cancelHardwareAnimations(true); } private void cancelSoftwareAnimations() { @@ -468,14 +507,18 @@ class Ripple { /** * Cancels any running hardware animations. */ - private void cancelHardwareAnimations() { + private void cancelHardwareAnimations(boolean cancelPending) { final ArrayList<RenderNodeAnimator> runningAnimations = mRunningAnimations; final int N = runningAnimations.size(); for (int i = 0; i < N; i++) { runningAnimations.get(i).cancel(); } - runningAnimations.clear(); + + if (cancelPending && !mPendingAnimations.isEmpty()) { + mPendingAnimations.clear(); + removeSelf(); + } } private void removeSelf() { diff --git a/graphics/java/android/graphics/drawable/RippleBackground.java b/graphics/java/android/graphics/drawable/RippleBackground.java index 93df64874542..49862bc1ce21 100644 --- a/graphics/java/android/graphics/drawable/RippleBackground.java +++ b/graphics/java/android/graphics/drawable/RippleBackground.java @@ -203,7 +203,7 @@ class RippleBackground { final boolean canUseHardware = c.isHardwareAccelerated(); if (mCanUseHardware != canUseHardware && mCanUseHardware) { // We've switched from hardware to non-hardware mode. Panic. - cancelHardwareAnimations(); + cancelHardwareAnimations(true); } mCanUseHardware = canUseHardware; @@ -223,7 +223,7 @@ class RippleBackground { final ArrayList<RenderNodeAnimator> pendingAnimations = mPendingAnimations; final int N = pendingAnimations.size(); if (N > 0) { - cancelHardwareAnimations(); + cancelHardwareAnimations(false); for (int i = 0; i < N; i++) { pendingAnimations.get(i).setTarget(c); @@ -403,6 +403,41 @@ class RippleBackground { invalidateSelf(); } + public void jump() { + endSoftwareAnimations(); + endHardwareAnimations(); + } + + private void endSoftwareAnimations() { + if (mAnimOuterOpacity != null) { + mAnimOuterOpacity.end(); + } + + if (mAnimX != null) { + mAnimX.end(); + } + + if (mAnimY != null) { + mAnimY.end(); + } + } + + private void endHardwareAnimations() { + final ArrayList<RenderNodeAnimator> runningAnimations = mRunningAnimations; + final int N = runningAnimations.size(); + for (int i = 0; i < N; i++) { + runningAnimations.get(i).end(); + } + runningAnimations.clear(); + + // Abort any pending animations. Since we always have a completion + // listener on a pending animation, we also need to remove ourselves. + if (!mPendingAnimations.isEmpty()) { + mPendingAnimations.clear(); + removeSelf(); + } + } + private Paint getTempPaint() { if (mTempPaint == null) { mTempPaint = new Paint(); @@ -477,7 +512,7 @@ class RippleBackground { */ public void cancel() { cancelSoftwareAnimations(); - cancelHardwareAnimations(); + cancelHardwareAnimations(true); } private void cancelSoftwareAnimations() { @@ -497,7 +532,7 @@ class RippleBackground { /** * Cancels any running hardware animations. */ - private void cancelHardwareAnimations() { + private void cancelHardwareAnimations(boolean cancelPending) { final ArrayList<RenderNodeAnimator> runningAnimations = mRunningAnimations; final int N = runningAnimations.size(); for (int i = 0; i < N; i++) { @@ -505,6 +540,11 @@ class RippleBackground { } runningAnimations.clear(); + + if (cancelPending && !mPendingAnimations.isEmpty()) { + mPendingAnimations.clear(); + removeSelf(); + } } private void removeSelf() { diff --git a/graphics/java/android/graphics/drawable/RippleDrawable.java b/graphics/java/android/graphics/drawable/RippleDrawable.java index 0447e1770179..ca32751f17dd 100644 --- a/graphics/java/android/graphics/drawable/RippleDrawable.java +++ b/graphics/java/android/graphics/drawable/RippleDrawable.java @@ -199,6 +199,29 @@ public class RippleDrawable extends LayerDrawable { } @Override + public void jumpToCurrentState() { + super.jumpToCurrentState(); + + if (mRipple != null) { + mRipple.jump(); + } + + if (mBackground != null) { + mBackground.jump(); + } + + mClearingHotspots = true; + final int count = mAnimatingRipplesCount; + final Ripple[] ripples = mAnimatingRipples; + for (int i = 0; i < count; i++) { + ripples[i].jump(); + ripples[i] = null; + } + mAnimatingRipplesCount = 0; + mClearingHotspots = false; + } + + @Override public void setAlpha(int alpha) { super.setAlpha(alpha); @@ -534,18 +557,6 @@ public class RippleDrawable extends LayerDrawable { } private void clearHotspots() { - mClearingHotspots = true; - - final int count = mAnimatingRipplesCount; - final Ripple[] ripples = mAnimatingRipples; - for (int i = 0; i < count; i++) { - // Calling cancel may remove the ripple from the animating ripple - // array, so cache the reference before nulling it out. - final Ripple ripple = ripples[i]; - ripples[i] = null; - ripple.cancel(); - } - if (mRipple != null) { mRipple.cancel(); mRipple = null; @@ -556,8 +567,16 @@ public class RippleDrawable extends LayerDrawable { mBackground = null; } - mClearingHotspots = false; + mClearingHotspots = true; + final int count = mAnimatingRipplesCount; + final Ripple[] ripples = mAnimatingRipples; + for (int i = 0; i < count; i++) { + ripples[i].cancel(); + ripples[i] = null; + } mAnimatingRipplesCount = 0; + mClearingHotspots = false; + invalidateSelf(); } diff --git a/libs/hwui/DamageAccumulator.cpp b/libs/hwui/DamageAccumulator.cpp index 054a1640c59c..420e33136c0e 100644 --- a/libs/hwui/DamageAccumulator.cpp +++ b/libs/hwui/DamageAccumulator.cpp @@ -214,7 +214,7 @@ void DamageAccumulator::dirty(float left, float top, float right, float bottom) mHead->pendingDirty.join(left, top, right, bottom); } -void DamageAccumulator::peekAtDirty(SkRect* dest) { +void DamageAccumulator::peekAtDirty(SkRect* dest) const { *dest = mHead->pendingDirty; } diff --git a/libs/hwui/DamageAccumulator.h b/libs/hwui/DamageAccumulator.h index 6f0bd8c187cc..dd3365a49d78 100644 --- a/libs/hwui/DamageAccumulator.h +++ b/libs/hwui/DamageAccumulator.h @@ -50,7 +50,7 @@ public: void dirty(float left, float top, float right, float bottom); // Returns the current dirty area, *NOT* transformed by pushed transforms - void peekAtDirty(SkRect* dest); + void peekAtDirty(SkRect* dest) const; void computeCurrentTransform(Matrix4* outMatrix) const; diff --git a/libs/hwui/RenderNode.cpp b/libs/hwui/RenderNode.cpp index 0db6198e7ec2..977744f91609 100644 --- a/libs/hwui/RenderNode.cpp +++ b/libs/hwui/RenderNode.cpp @@ -179,13 +179,6 @@ void RenderNode::pushLayerUpdate(TreeInfo& info) { transformUpdateNeeded = true; } - if (transformUpdateNeeded) { - // update the transform in window of the layer to reset its origin wrt light source position - Matrix4 windowTransform; - info.damageAccumulator->computeCurrentTransform(&windowTransform); - mLayer->setWindowTransform(windowTransform); - } - SkRect dirty; info.damageAccumulator->peekAtDirty(&dirty); @@ -198,6 +191,12 @@ void RenderNode::pushLayerUpdate(TreeInfo& info) { return; } + if (transformUpdateNeeded) { + // update the transform in window of the layer to reset its origin wrt light source position + Matrix4 windowTransform; + info.damageAccumulator->computeCurrentTransform(&windowTransform); + mLayer->setWindowTransform(windowTransform); + } if (dirty.intersect(0, 0, getWidth(), getHeight())) { dirty.roundOut(); @@ -216,7 +215,10 @@ void RenderNode::prepareTreeImpl(TreeInfo& info) { if (info.mode == TreeInfo::MODE_FULL) { pushStagingPropertiesChanges(info); } - uint32_t animatorDirtyMask = mAnimatorManager.animate(info); + uint32_t animatorDirtyMask = 0; + if (CC_LIKELY(info.runAnimations)) { + animatorDirtyMask = mAnimatorManager.animate(info); + } prepareLayer(info, animatorDirtyMask); if (info.mode == TreeInfo::MODE_FULL) { pushStagingDisplayListChanges(info); @@ -231,7 +233,9 @@ void RenderNode::pushStagingPropertiesChanges(TreeInfo& info) { // Push the animators first so that setupStartValueIfNecessary() is called // before properties() is trampled by stagingProperties(), as they are // required by some animators. - mAnimatorManager.pushStaging(info); + if (CC_LIKELY(info.runAnimations)) { + mAnimatorManager.pushStaging(info); + } if (mDirtyPropertyFields) { mDirtyPropertyFields = 0; damageSelf(info); diff --git a/libs/hwui/TreeInfo.h b/libs/hwui/TreeInfo.h index 331f1574ff17..74d52a33d45f 100644 --- a/libs/hwui/TreeInfo.h +++ b/libs/hwui/TreeInfo.h @@ -65,6 +65,7 @@ public: , frameTimeMs(0) , animationHook(NULL) , prepareTextures(mode == MODE_FULL) + , runAnimations(true) , damageAccumulator(NULL) , renderState(renderState) , renderer(NULL) @@ -76,6 +77,7 @@ public: , frameTimeMs(clone.frameTimeMs) , animationHook(clone.animationHook) , prepareTextures(mode == MODE_FULL) + , runAnimations(clone.runAnimations) , damageAccumulator(clone.damageAccumulator) , renderState(clone.renderState) , renderer(clone.renderer) @@ -88,6 +90,12 @@ public: // TODO: Remove this? Currently this is used to signal to stop preparing // textures if we run out of cache space. bool prepareTextures; + // TODO: buildLayer uses this to suppress running any animations, but this + // should probably be refactored somehow. The reason this is done is + // because buildLayer is not setup for injecting the animationHook, as well + // as this being otherwise wasted work as all the animators will be + // re-evaluated when the frame is actually drawn + bool runAnimations; // Must not be null during actual usage DamageAccumulator* damageAccumulator; diff --git a/libs/hwui/renderthread/CanvasContext.cpp b/libs/hwui/renderthread/CanvasContext.cpp index 5922135f267c..4bf5a8ac764d 100644 --- a/libs/hwui/renderthread/CanvasContext.cpp +++ b/libs/hwui/renderthread/CanvasContext.cpp @@ -257,6 +257,7 @@ void CanvasContext::buildLayer(RenderNode* node) { info.frameTimeMs = mRenderThread.timeLord().frameTimeMs(); info.damageAccumulator = &mDamageAccumulator; info.renderer = mCanvas; + info.runAnimations = false; node->prepareTree(info); SkRect ignore; mDamageAccumulator.finish(&ignore); diff --git a/media/java/android/media/RemoteControlClient.java b/media/java/android/media/RemoteControlClient.java index 1c8d3ccd96ca..3c2ad0ee9c0d 100644 --- a/media/java/android/media/RemoteControlClient.java +++ b/media/java/android/media/RemoteControlClient.java @@ -389,9 +389,7 @@ import java.lang.IllegalArgumentException; public void registerWithSession(MediaSessionLegacyHelper helper) { helper.addRccListener(mRcMediaIntent, mTransportListener); mSession = helper.getSession(mRcMediaIntent); - if (mTransportControlFlags != 0) { - setTransportControlFlags(mTransportControlFlags); - } + setTransportControlFlags(mTransportControlFlags); } /** diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java index d53aa47ce68b..735fbfc21924 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java @@ -158,8 +158,9 @@ public class UserSwitcherController { picture = BitmapHelper.createCircularClip( picture, avatarSize, avatarSize); } - records.add(new UserRecord(info, picture, false /* isGuest */, isCurrent, - false /* isAddUser */, false /* isRestricted */)); + int index = isCurrent ? 0 : records.size(); + records.add(index, new UserRecord(info, picture, false /* isGuest */, + isCurrent, false /* isAddUser */, false /* isRestricted */)); } } @@ -182,7 +183,8 @@ public class UserSwitcherController { false /* isAddUser */, createIsRestricted)); } } else { - records.add(guestRecord); + int index = guestRecord.isCurrent ? 0 : records.size(); + records.add(index, guestRecord); } } diff --git a/services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java b/services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java index c6aa30b46443..f1e99fdee2e7 100644 --- a/services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java +++ b/services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java @@ -1539,7 +1539,7 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku widget.views = views; } - scheduleNotifyUpdateAppWidgetLocked(widget); + scheduleNotifyUpdateAppWidgetLocked(widget, views); } } @@ -1611,7 +1611,7 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku } } - private void scheduleNotifyUpdateAppWidgetLocked(Widget widget) { + private void scheduleNotifyUpdateAppWidgetLocked(Widget widget, RemoteViews updateViews) { if (widget == null || widget.provider == null || widget.provider.zombie || widget.host.callbacks == null || widget.host.zombie) { return; @@ -1620,7 +1620,7 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku SomeArgs args = SomeArgs.obtain(); args.arg1 = widget.host; args.arg2 = widget.host.callbacks; - args.arg3 = widget.views; + args.arg3 = updateViews; args.argi1 = widget.appWidgetId; mCallbackHandler.obtainMessage( diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index e8b1d037d707..f36f25f93d90 100755 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -1841,6 +1841,7 @@ public final class ActivityManagerService extends ActivityManagerNative BatteryStats.HistoryItem.EVENT_USER_FOREGROUND_START, Integer.toString(msg.arg1), msg.arg1); mSystemServiceManager.switchUser(msg.arg1); + mLockToAppRequest.clearPrompt(); break; } case ENTER_ANIMATION_COMPLETE_MSG: { @@ -3505,7 +3506,8 @@ public final class ActivityManagerService extends ActivityManagerNative try { int ret = mStackSupervisor.startActivityMayWait(null, targetUid, targetPackage, intent, resolvedType, null, null, resultTo, resultWho, requestCode, startFlags, - null, null, null, null, options, UserHandle.getUserId(targetUid), null); + null, null, null, null, options, UserHandle.getUserId(sourceRecord.app.uid), + null); return ret; } catch (SecurityException e) { // XXX need to figure out how to propagate to original app. diff --git a/services/core/java/com/android/server/am/LockToAppRequestDialog.java b/services/core/java/com/android/server/am/LockToAppRequestDialog.java index 5abf699e8896..a1eb31ec3fa2 100644 --- a/services/core/java/com/android/server/am/LockToAppRequestDialog.java +++ b/services/core/java/com/android/server/am/LockToAppRequestDialog.java @@ -74,11 +74,15 @@ public class LockToAppRequestDialog implements OnClickListener { return 0; } - public void showLockTaskPrompt(TaskRecord task) { + public void clearPrompt() { if (mDialog != null) { mDialog.dismiss(); mDialog = null; } + } + + public void showLockTaskPrompt(TaskRecord task) { + clearPrompt(); mRequestedTask = task; final int unlockStringId = getLockString(task.userId); @@ -97,6 +101,8 @@ public class LockToAppRequestDialog implements OnClickListener { mDialog = builder.create(); mDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); + mDialog.getWindow().getAttributes().privateFlags |= + WindowManager.LayoutParams.PRIVATE_FLAG_SHOW_FOR_ALL_USERS; mDialog.show(); if (unlockStringId != 0) { diff --git a/services/core/java/com/android/server/job/JobSchedulerService.java b/services/core/java/com/android/server/job/JobSchedulerService.java index 14457ec9c04c..6771ccece996 100644 --- a/services/core/java/com/android/server/job/JobSchedulerService.java +++ b/services/core/java/com/android/server/job/JobSchedulerService.java @@ -162,6 +162,7 @@ public class JobSchedulerService extends com.android.server.SystemService JobStatus jobStatus = new JobStatus(job, uId); cancelJob(uId, job.getId()); startTrackingJob(jobStatus); + mHandler.obtainMessage(MSG_CHECK_JOB).sendToTarget(); return JobScheduler.RESULT_SUCCESS; } @@ -507,7 +508,9 @@ public class JobSchedulerService extends com.android.server.SystemService case MSG_JOB_EXPIRED: synchronized (mJobs) { JobStatus runNow = (JobStatus) message.obj; - if (!mPendingJobs.contains(runNow)) { + // runNow can be null, which is a controller's way of indicating that its + // state is such that all ready jobs should be run immediately. + if (runNow != null && !mPendingJobs.contains(runNow)) { mPendingJobs.add(runNow); } } diff --git a/services/core/java/com/android/server/job/StateChangedListener.java b/services/core/java/com/android/server/job/StateChangedListener.java index 90c203ab646b..97dfad39fa7f 100644 --- a/services/core/java/com/android/server/job/StateChangedListener.java +++ b/services/core/java/com/android/server/job/StateChangedListener.java @@ -33,7 +33,8 @@ public interface StateChangedListener { /** * Called by the controller to notify the JobManager that regardless of the state of the task, * it must be run immediately. - * @param jobStatus The state of the task which is to be run immediately. + * @param jobStatus The state of the task which is to be run immediately. <strong>null + * indicates to the scheduler that any ready jobs should be flushed.</strong> */ public void onRunJobNow(JobStatus jobStatus); } diff --git a/services/core/java/com/android/server/job/controllers/BatteryController.java b/services/core/java/com/android/server/job/controllers/BatteryController.java index 538a2520311b..309e034de7ba 100644 --- a/services/core/java/com/android/server/job/controllers/BatteryController.java +++ b/services/core/java/com/android/server/job/controllers/BatteryController.java @@ -84,15 +84,15 @@ public class BatteryController extends StateController { @Override public void maybeStartTrackingJob(JobStatus taskStatus) { + final boolean isOnStablePower = mChargeTracker.isOnStablePower(); if (taskStatus.hasChargingConstraint()) { - final boolean isOnStablePower = mChargeTracker.isOnStablePower(); synchronized (mTrackedTasks) { mTrackedTasks.add(taskStatus); taskStatus.chargingConstraintSatisfied.set(isOnStablePower); } - if (isOnStablePower) { - mStateChangedListener.onControllerStateChanged(); - } + } + if (isOnStablePower) { + mChargeTracker.setStableChargingAlarm(); } } @@ -119,9 +119,15 @@ public class BatteryController extends StateController { } } } + // Let the scheduler know that state has changed. This may or may not result in an + // execution. if (reportChange) { mStateChangedListener.onControllerStateChanged(); } + // Also tell the scheduler that any ready jobs should be flushed. + if (stablePower) { + mStateChangedListener.onRunJobNow(null); + } } public class ChargingTracker extends BroadcastReceiver { @@ -196,9 +202,7 @@ public class BatteryController extends StateController { } // Set up an alarm for ACTION_CHARGING_STABLE - we don't want to kick off tasks // here if the user unplugs the phone immediately. - mAlarm.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, - SystemClock.elapsedRealtime() + STABLE_CHARGING_THRESHOLD_MILLIS, - mStableChargingTriggerIntent); + setStableChargingAlarm(); mCharging = true; } else if (Intent.ACTION_POWER_DISCONNECTED.equals(action)) { if (DEBUG) { @@ -211,7 +215,7 @@ public class BatteryController extends StateController { }else if (ACTION_CHARGING_STABLE.equals(action)) { // Here's where we actually do the notify for a task being ready. if (DEBUG) { - Slog.d(TAG, "Battery connected fired @ " + SystemClock.elapsedRealtime() + Slog.d(TAG, "Stable charging fired @ " + SystemClock.elapsedRealtime() + " charging: " + mCharging); } if (mCharging) { // Should never receive this intent if mCharging is false. @@ -219,6 +223,17 @@ public class BatteryController extends StateController { } } } + + void setStableChargingAlarm() { + final long alarmTriggerElapsed = + SystemClock.elapsedRealtime() + STABLE_CHARGING_THRESHOLD_MILLIS; + if (DEBUG) { + Slog.d(TAG, "Setting stable alarm to go off in " + + (STABLE_CHARGING_THRESHOLD_MILLIS / 1000) + "s"); + } + mAlarm.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, alarmTriggerElapsed, + mStableChargingTriggerIntent); + } } @Override diff --git a/services/core/java/com/android/server/pm/PackageInstallerService.java b/services/core/java/com/android/server/pm/PackageInstallerService.java index 03cb2e9f3e46..5e802de7a6b7 100644 --- a/services/core/java/com/android/server/pm/PackageInstallerService.java +++ b/services/core/java/com/android/server/pm/PackageInstallerService.java @@ -485,17 +485,22 @@ public class PackageInstallerService extends IPackageInstaller.Stub { if (params.mode == SessionParams.MODE_FULL_INSTALL) { // Brand new install, use best resolved location. This also verifies // that target has enough free space for the install. - final int resolved = PackageHelper.resolveInstallLocation(mContext, - params.appPackageName, params.installLocation, params.sizeBytes, - params.installFlags); - if (resolved == PackageHelper.RECOMMEND_INSTALL_INTERNAL) { - stageInternal = true; - } else if (resolved == PackageHelper.RECOMMEND_INSTALL_EXTERNAL) { - stageInternal = false; - } else { - throw new IOException("No storage with enough free space; res=" + resolved); + final long ident = Binder.clearCallingIdentity(); + try { + final int resolved = PackageHelper.resolveInstallLocation(mContext, + params.appPackageName, params.installLocation, params.sizeBytes, + params.installFlags); + + if (resolved == PackageHelper.RECOMMEND_INSTALL_INTERNAL) { + stageInternal = true; + } else if (resolved == PackageHelper.RECOMMEND_INSTALL_EXTERNAL) { + stageInternal = false; + } else { + throw new IOException("No storage with enough free space; res=" + resolved); + } + } finally { + Binder.restoreCallingIdentity(ident); } - } else if (params.mode == SessionParams.MODE_INHERIT_EXISTING) { // We always stage inheriting sessions on internal storage first, // since we don't want to grow containers until we're sure that diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java index b57a0909251e..32f3707bcfaf 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -5801,6 +5801,29 @@ public class WindowManagerService extends IWindowManager.Stub SystemProperties.set(StrictMode.VISUAL_PROPERTY, value); } + private static void convertCropForSurfaceFlinger(Rect crop, int rot, int dw, int dh) { + if (rot == Surface.ROTATION_90) { + final int tmp = crop.top; + crop.top = dw - crop.right; + crop.right = crop.bottom; + crop.bottom = dw - crop.left; + crop.left = tmp; + } else if (rot == Surface.ROTATION_180) { + int tmp = crop.top; + crop.top = dh - crop.bottom; + crop.bottom = dh - tmp; + tmp = crop.right; + crop.right = dw - crop.left; + crop.left = dw - tmp; + } else if (rot == Surface.ROTATION_270) { + final int tmp = crop.top; + crop.top = crop.left; + crop.left = dh - crop.bottom; + crop.bottom = crop.right; + crop.right = dh - tmp; + } + } + /** * Takes a snapshot of the screen. In landscape mode this grabs the whole screen. * In portrait mode, it grabs the upper region of the screen based on the vertical dimension @@ -5962,21 +5985,31 @@ public class WindowManagerService extends IWindowManager.Stub // Constrain frame to the screen size. frame.intersect(0, 0, dw, dh); - // Constrain thumbnail to smaller of screen width or height. Assumes aspect - // of thumbnail is the same as the screen (in landscape) or square. - scale = Math.max(width / (float) frame.width(), height / (float) frame.height()); - dw = (int)(dw * scale); - dh = (int)(dh * scale); + + // Tell surface flinger what part of the image to crop. Take the top + // right part of the application, and crop the larger dimension to fit. + Rect crop = new Rect(frame); + if (width / (float) frame.width() < height / (float) frame.height()) { + int cropWidth = (int)((float)width / (float)height * frame.height()); + crop.right = crop.left + cropWidth; + } else { + int cropHeight = (int)((float)height / (float)width * frame.width()); + crop.bottom = crop.top + cropHeight; + } // The screenshot API does not apply the current screen rotation. rot = getDefaultDisplayContentLocked().getDisplay().getRotation(); if (rot == Surface.ROTATION_90 || rot == Surface.ROTATION_270) { - final int tmp = dw; - dw = dh; - dh = tmp; + final int tmp = width; + width = height; + height = tmp; rot = (rot == Surface.ROTATION_90) ? Surface.ROTATION_270 : Surface.ROTATION_90; } + // Surfaceflinger is not aware of orientation, so convert our logical + // crop to surfaceflinger's portrait orientation. + convertCropForSurfaceFlinger(crop, rot, dw, dh); + if (DEBUG_SCREENSHOT) { Slog.i(TAG, "Screenshot: " + dw + "x" + dh + " from " + minLayer + " to " + maxLayer + " appToken=" + appToken); @@ -5995,7 +6028,7 @@ public class WindowManagerService extends IWindowManager.Stub if (DEBUG_SCREENSHOT && inRotation) Slog.v(TAG, "Taking screenshot while rotating"); - rawss = SurfaceControl.screenshot(new Rect(), dw, dh, minLayer, maxLayer, + rawss = SurfaceControl.screenshot(crop, width, height, minLayer, maxLayer, inRotation); if (rawss == null) { Slog.w(TAG, "Screenshot failure taking screenshot for (" + dw + "x" + dh @@ -6012,11 +6045,8 @@ public class WindowManagerService extends IWindowManager.Stub if (DEBUG_SCREENSHOT) { bm.eraseColor(0xFF000000); } - frame.scale(scale); Matrix matrix = new Matrix(); - ScreenRotationAnimation.createRotationMatrix(rot, dw, dh, matrix); - // TODO: Test for RTL vs. LTR and use frame.right-width instead of -frame.left - matrix.postTranslate(-FloatMath.ceil(frame.left), -FloatMath.ceil(frame.top)); + ScreenRotationAnimation.createRotationMatrix(rot, width, height, matrix); Canvas canvas = new Canvas(bm); canvas.drawBitmap(rawss, matrix, null); canvas.setBitmap(null); @@ -6042,6 +6072,7 @@ public class WindowManagerService extends IWindowManager.Stub } rawss.recycle(); + return bm; } diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DeviceOwner.java b/services/devicepolicy/java/com/android/server/devicepolicy/DeviceOwner.java index 4b60c9fce8e4..5938819e34d5 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/DeviceOwner.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/DeviceOwner.java @@ -267,6 +267,9 @@ public class DeviceOwner { if (mDeviceOwner != null) { out.startTag(null, TAG_DEVICE_OWNER); out.attribute(null, ATTR_PACKAGE, mDeviceOwner.packageName); + if (mDeviceOwner.name != null) { + out.attribute(null, ATTR_NAME, mDeviceOwner.name); + } out.endTag(null, TAG_DEVICE_OWNER); } |