diff options
37 files changed, 843 insertions, 361 deletions
diff --git a/api/current.xml b/api/current.xml index c92b018b31f1..26902dbdb4f6 100644 --- a/api/current.xml +++ b/api/current.xml @@ -3496,39 +3496,6 @@ visibility="public" > </field> -<field name="donut_resource_pad23" - type="int" - transient="false" - volatile="false" - value="16843401" - static="true" - final="true" - deprecated="not deprecated" - visibility="public" -> -</field> -<field name="donut_resource_pad24" - type="int" - transient="false" - volatile="false" - value="16843400" - static="true" - final="true" - deprecated="not deprecated" - visibility="public" -> -</field> -<field name="donut_resource_pad25" - type="int" - transient="false" - volatile="false" - value="16843399" - static="true" - final="true" - deprecated="not deprecated" - visibility="public" -> -</field> <field name="donut_resource_pad3" type="int" transient="false" @@ -6807,6 +6774,17 @@ visibility="public" > </field> +<field name="progressBarStyleInverse" + type="int" + transient="false" + volatile="false" + value="16843399" + static="true" + final="true" + deprecated="not deprecated" + visibility="public" +> +</field> <field name="progressBarStyleLarge" type="int" transient="false" @@ -6818,6 +6796,17 @@ visibility="public" > </field> +<field name="progressBarStyleLargeInverse" + type="int" + transient="false" + volatile="false" + value="16843401" + static="true" + final="true" + deprecated="not deprecated" + visibility="public" +> +</field> <field name="progressBarStyleSmall" type="int" transient="false" @@ -6829,6 +6818,17 @@ visibility="public" > </field> +<field name="progressBarStyleSmallInverse" + type="int" + transient="false" + volatile="false" + value="16843400" + static="true" + final="true" + deprecated="not deprecated" + visibility="public" +> +</field> <field name="progressBarStyleSmallTitle" type="int" transient="false" @@ -15255,6 +15255,17 @@ visibility="public" > </field> +<field name="Widget_ProgressBar_Inverse" + type="int" + transient="false" + volatile="false" + value="16973915" + static="true" + final="true" + deprecated="not deprecated" + visibility="public" +> +</field> <field name="Widget_ProgressBar_Large" type="int" transient="false" @@ -15266,6 +15277,17 @@ visibility="public" > </field> +<field name="Widget_ProgressBar_Large_Inverse" + type="int" + transient="false" + volatile="false" + value="16973916" + static="true" + final="true" + deprecated="not deprecated" + visibility="public" +> +</field> <field name="Widget_ProgressBar_Small" type="int" transient="false" @@ -15277,6 +15299,17 @@ visibility="public" > </field> +<field name="Widget_ProgressBar_Small_Inverse" + type="int" + transient="false" + volatile="false" + value="16973917" + static="true" + final="true" + deprecated="not deprecated" + visibility="public" +> +</field> <field name="Widget_RatingBar" type="int" transient="false" @@ -15508,39 +15541,6 @@ visibility="public" > </field> -<field name="donut_resource_pad20" - type="int" - transient="false" - volatile="false" - value="16973917" - static="true" - final="true" - deprecated="not deprecated" - visibility="public" -> -</field> -<field name="donut_resource_pad21" - type="int" - transient="false" - volatile="false" - value="16973916" - static="true" - final="true" - deprecated="not deprecated" - visibility="public" -> -</field> -<field name="donut_resource_pad22" - type="int" - transient="false" - volatile="false" - value="16973915" - static="true" - final="true" - deprecated="not deprecated" - visibility="public" -> -</field> <field name="donut_resource_pad3" type="int" transient="false" @@ -60403,6 +60403,47 @@ </package> <package name="android.graphics.drawable" > +<interface name="Animatable" + abstract="true" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<method name="isRunning" + return="boolean" + abstract="true" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</method> +<method name="start" + return="void" + abstract="true" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</method> +<method name="stop" + return="void" + abstract="true" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</method> +</interface> <class name="AnimationDrawable" extends="android.graphics.drawable.DrawableContainer" abstract="false" @@ -60411,6 +60452,8 @@ deprecated="not deprecated" visibility="public" > +<implements name="android.graphics.drawable.Animatable"> +</implements> <implements name="java.lang.Runnable"> </implements> <constructor name="AnimationDrawable" diff --git a/core/java/android/app/SearchDialog.java b/core/java/android/app/SearchDialog.java index 6fe4896179ab..44d1eaa30272 100644 --- a/core/java/android/app/SearchDialog.java +++ b/core/java/android/app/SearchDialog.java @@ -34,6 +34,7 @@ import android.content.res.Configuration; import android.content.res.Resources; import android.database.Cursor; import android.graphics.drawable.Drawable; +import android.graphics.drawable.Animatable; import android.net.Uri; import android.os.Bundle; import android.os.SystemClock; @@ -422,11 +423,11 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS if (working) { mSearchAutoComplete.setCompoundDrawablesWithIntrinsicBounds( null, null, mWorkingSpinner, null); -// mWorkingSpinner.start(); + ((Animatable) mWorkingSpinner).start(); } else { mSearchAutoComplete.setCompoundDrawablesWithIntrinsicBounds( null, null, null, null); -// mWorkingSpinner.stop(); + ((Animatable) mWorkingSpinner).stop(); } } diff --git a/core/java/android/widget/ProgressBar.java b/core/java/android/widget/ProgressBar.java index 441414a20de4..2c9e71e02f08 100644 --- a/core/java/android/widget/ProgressBar.java +++ b/core/java/android/widget/ProgressBar.java @@ -30,6 +30,7 @@ import android.graphics.drawable.Drawable; import android.graphics.drawable.LayerDrawable; import android.graphics.drawable.ShapeDrawable; import android.graphics.drawable.StateListDrawable; +import android.graphics.drawable.Animatable; import android.graphics.drawable.shapes.RoundRectShape; import android.graphics.drawable.shapes.Shape; import android.util.AttributeSet; @@ -683,7 +684,7 @@ public class ProgressBar extends View { return; } - if (mIndeterminateDrawable instanceof AnimationDrawable) { + if (mIndeterminateDrawable instanceof Animatable) { mShouldStartAnimationDrawable = true; mAnimation = null; } else { @@ -708,8 +709,8 @@ public class ProgressBar extends View { void stopAnimation() { mAnimation = null; mTransformation = null; - if (mIndeterminateDrawable instanceof AnimationDrawable) { - ((AnimationDrawable) mIndeterminateDrawable).stop(); + if (mIndeterminateDrawable instanceof Animatable) { + ((Animatable) mIndeterminateDrawable).stop(); mShouldStartAnimationDrawable = false; } } @@ -818,8 +819,8 @@ public class ProgressBar extends View { } d.draw(canvas); canvas.restore(); - if (mShouldStartAnimationDrawable && d instanceof AnimationDrawable) { - ((AnimationDrawable) d).start(); + if (mShouldStartAnimationDrawable && d instanceof Animatable) { + ((Animatable) d).start(); mShouldStartAnimationDrawable = false; } } diff --git a/core/jni/android_hardware_Camera.cpp b/core/jni/android_hardware_Camera.cpp index 075caaee9b8f..0420918c094b 100644 --- a/core/jni/android_hardware_Camera.cpp +++ b/core/jni/android_hardware_Camera.cpp @@ -171,6 +171,10 @@ void JNICameraContext::postData(int32_t msgType, const sp<IMemory>& dataPtr) // VM pointer will be NULL if object is released Mutex::Autolock _l(mLock); JNIEnv *env = AndroidRuntime::getJNIEnv(); + if (mCameraJObjectWeak == NULL) { + LOGW("callback on dead camera object"); + return; + } // return data based on callback type switch(msgType) { diff --git a/core/res/res/drawable/progress_large.xml b/core/res/res/drawable/progress_large.xml index 466910420e0f..4f016bcc2e83 100644 --- a/core/res/res/drawable/progress_large.xml +++ b/core/res/res/drawable/progress_large.xml @@ -1,45 +1,25 @@ <?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2007 The Android Open Source Project - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. +<!-- +/* +** +** Copyright 2009, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ --> - - -<rotate xmlns:android="http://schemas.android.com/apk/res/android" - android:pivotX="50%" android:pivotY="50%" - android:fromDegrees="0" android:toDegrees="360"> - - <shape - android:shape="ring" - android:innerRadiusRatio="3" - android:thicknessRatio="8" - android:useLevel="false"> - - <size - android:width="76dip" - android:height="76dip" - /> - - <gradient - android:type="sweep" - android:useLevel="false" - android:startColor="#4c737373" - android:centerColor="#4c737373" - android:centerY="0.50" - android:endColor="#ffffd300" - /> - - </shape> - -</rotate> - +<animated-rotate xmlns:android="http://schemas.android.com/apk/res/android" + android:drawable="@drawable/spinner_black_76" + android:pivotX="50%" + android:pivotY="50%" + android:framesCount="12" + android:frameDuration="100" /> diff --git a/core/res/res/drawable/progress_large_white.xml b/core/res/res/drawable/progress_large_white.xml new file mode 100644 index 000000000000..c690ed4e0e9a --- /dev/null +++ b/core/res/res/drawable/progress_large_white.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +** +** Copyright 2009, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ +--> +<animated-rotate xmlns:android="http://schemas.android.com/apk/res/android" + android:drawable="@drawable/spinner_white_76" + android:pivotX="50%" + android:pivotY="50%" + android:framesCount="12" + android:frameDuration="100" /> diff --git a/core/res/res/drawable/progress_medium.xml b/core/res/res/drawable/progress_medium.xml index 92aebb51a512..eb1bd50d17d7 100644 --- a/core/res/res/drawable/progress_medium.xml +++ b/core/res/res/drawable/progress_medium.xml @@ -1,43 +1,25 @@ <?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2007 The Android Open Source Project - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. +<!-- +/* +** +** Copyright 2009, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ --> - -<rotate xmlns:android="http://schemas.android.com/apk/res/android" - android:pivotX="50%" android:pivotY="50%" - android:fromDegrees="0" android:toDegrees="360"> - - <shape - android:shape="ring" - android:innerRadiusRatio="3" - android:thicknessRatio="8" - android:useLevel="false"> - - <size - android:width="48dip" - android:height="48dip" - /> - - <gradient - android:type="sweep" - android:useLevel="false" - android:startColor="#4c737373" - android:centerColor="#4c737373" - android:centerY="0.50" - android:endColor="#ffffd300" - /> - - </shape> - -</rotate> +<animated-rotate xmlns:android="http://schemas.android.com/apk/res/android" + android:drawable="@drawable/spinner_black_48" + android:pivotX="50%" + android:pivotY="50%" + android:framesCount="12" + android:frameDuration="100" /> diff --git a/core/res/res/drawable/progress_medium_white.xml b/core/res/res/drawable/progress_medium_white.xml new file mode 100644 index 000000000000..b4f9b318a902 --- /dev/null +++ b/core/res/res/drawable/progress_medium_white.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +** +** Copyright 2009, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ +--> +<animated-rotate xmlns:android="http://schemas.android.com/apk/res/android" + android:drawable="@drawable/spinner_white_48" + android:pivotX="50%" + android:pivotY="50%" + android:framesCount="12" + android:frameDuration="100" /> diff --git a/core/res/res/drawable/progress_small.xml b/core/res/res/drawable/progress_small.xml index e5b0021d59cf..e0ee5e47d830 100644 --- a/core/res/res/drawable/progress_small.xml +++ b/core/res/res/drawable/progress_small.xml @@ -1,45 +1,25 @@ <?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2007 The Android Open Source Project - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. +<!-- +/* +** +** Copyright 2009, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ --> - - -<rotate xmlns:android="http://schemas.android.com/apk/res/android" - android:pivotX="50%" android:pivotY="50%" - android:fromDegrees="0" android:toDegrees="360"> - - <!-- An extra pixel is added on both ratios for stroke --> - <shape - android:shape="ring" - android:innerRadiusRatio="3.2" - android:thicknessRatio="5.333" - android:useLevel="false"> - - <size - android:width="16dip" - android:height="16dip" - /> - - <gradient - android:type="sweep" - android:useLevel="false" - android:startColor="#4c737373" - android:centerColor="#4c737373" - android:centerY="0.50" - android:endColor="#ffffd300" - /> - - </shape> - -</rotate> +<animated-rotate xmlns:android="http://schemas.android.com/apk/res/android" + android:drawable="@drawable/spinner_black_16" + android:pivotX="50%" + android:pivotY="50%" + android:framesCount="12" + android:frameDuration="100" /> diff --git a/core/res/res/drawable/progress_small_titlebar.xml b/core/res/res/drawable/progress_small_titlebar.xml index cf8e41cb373d..8cfba864b5b2 100644 --- a/core/res/res/drawable/progress_small_titlebar.xml +++ b/core/res/res/drawable/progress_small_titlebar.xml @@ -1,45 +1,25 @@ <?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2007 The Android Open Source Project - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. +<!-- +/* +** +** Copyright 2009, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ --> - - -<rotate xmlns:android="http://schemas.android.com/apk/res/android" - android:pivotX="50%" android:pivotY="50%" - android:fromDegrees="0" android:toDegrees="360"> - - <!-- An extra pixel is added on both ratios for stroke --> - <shape - android:shape="ring" - android:innerRadiusRatio="3.2" - android:thicknessRatio="5.333" - android:useLevel="false"> - - <size - android:width="16dip" - android:height="16dip" - /> - - <gradient - android:type="sweep" - android:useLevel="false" - android:startColor="#ff666666" - android:centerColor="#ff666666" - android:centerY="0.50" - android:endColor="#ffffd300" - /> - - </shape> - -</rotate> +<animated-rotate xmlns:android="http://schemas.android.com/apk/res/android" + android:drawable="@drawable/spinner_white_16" + android:pivotX="50%" + android:pivotY="50%" + android:framesCount="12" + android:frameDuration="100" /> diff --git a/core/res/res/drawable/progress_small_white.xml b/core/res/res/drawable/progress_small_white.xml new file mode 100644 index 000000000000..8cfba864b5b2 --- /dev/null +++ b/core/res/res/drawable/progress_small_white.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +** +** Copyright 2009, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ +--> +<animated-rotate xmlns:android="http://schemas.android.com/apk/res/android" + android:drawable="@drawable/spinner_white_16" + android:pivotX="50%" + android:pivotY="50%" + android:framesCount="12" + android:frameDuration="100" /> diff --git a/core/res/res/drawable/spinner_black_16.png b/core/res/res/drawable/spinner_black_16.png Binary files differnew file mode 100644 index 000000000000..5ee33cea6fa7 --- /dev/null +++ b/core/res/res/drawable/spinner_black_16.png diff --git a/core/res/res/drawable/spinner_black_48.png b/core/res/res/drawable/spinner_black_48.png Binary files differnew file mode 100644 index 000000000000..3a681926b537 --- /dev/null +++ b/core/res/res/drawable/spinner_black_48.png diff --git a/core/res/res/drawable/spinner_black_76.png b/core/res/res/drawable/spinner_black_76.png Binary files differnew file mode 100644 index 000000000000..ec57460277a6 --- /dev/null +++ b/core/res/res/drawable/spinner_black_76.png diff --git a/core/res/res/drawable/spinner_white_16.png b/core/res/res/drawable/spinner_white_16.png Binary files differnew file mode 100644 index 000000000000..dd2e1fd7da16 --- /dev/null +++ b/core/res/res/drawable/spinner_white_16.png diff --git a/core/res/res/drawable/spinner_white_48.png b/core/res/res/drawable/spinner_white_48.png Binary files differnew file mode 100644 index 000000000000..d25a33e24534 --- /dev/null +++ b/core/res/res/drawable/spinner_white_48.png diff --git a/core/res/res/drawable/spinner_white_76.png b/core/res/res/drawable/spinner_white_76.png Binary files differnew file mode 100644 index 000000000000..f53e8ffdb193 --- /dev/null +++ b/core/res/res/drawable/spinner_white_76.png diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml index 30fee0c87f60..4c84732a24b0 100644 --- a/core/res/res/values/attrs.xml +++ b/core/res/res/values/attrs.xml @@ -350,6 +350,12 @@ <attr name="progressBarStyleSmallTitle" format="reference" /> <!-- Large ProgressBar style. This is a large circular progress bar. --> <attr name="progressBarStyleLarge" format="reference" /> + <!-- Inverse ProgressBar style. This is a medium circular progress bar. --> + <attr name="progressBarStyleInverse" format="reference" /> + <!-- Small inverse ProgressBar style. This is a small circular progress bar. --> + <attr name="progressBarStyleSmallInverse" format="reference" /> + <!-- Large inverse ProgressBar style. This is a large circular progress bar. --> + <attr name="progressBarStyleLargeInverse" format="reference" /> <!-- Default SeekBar style. --> <attr name="seekBarStyle" format="reference" /> <!-- Default RatingBar style. --> @@ -3335,5 +3341,18 @@ <attr name="accountType"/> </declare-styleable> + <!-- =============================== --> + <!-- Contacts meta-data attributes --> + <!-- =============================== --> + + <declare-styleable name="Icon"> + <attr name="icon" /> + <attr name="mimeType" /> + </declare-styleable> + + <declare-styleable name="IconDefault"> + <attr name="icon" /> + </declare-styleable> + </resources> diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml index 67277688aed7..414382dc969f 100644 --- a/core/res/res/values/public.xml +++ b/core/res/res/values/public.xml @@ -1120,11 +1120,17 @@ <public type="attr" name="smallScreens" /> <public type="attr" name="normalScreens" /> <public type="attr" name="largeScreens" /> + <public type="attr" name="progressBarStyleInverse" /> + <public type="attr" name="progressBarStyleSmallInverse" /> + <public type="attr" name="progressBarStyleLargeInverse" /> <public-padding type="attr" name="donut_resource_pad" end="0x0101029f" /> <public-padding type="id" name="donut_resource_pad" end="0x01020040" /> + <public type="style" name="Widget.ProgressBar.Inverse" id="0x0103005b" /> + <public type="style" name="Widget.ProgressBar.Large.Inverse" id="0x0103005c" /> + <public type="style" name="Widget.ProgressBar.Small.Inverse" id="0x0103005d" /> <public-padding type="style" name="donut_resource_pad" end="0x01030070" /> <public-padding type="string" name="donut_resource_pad" end="0x01040030" /> diff --git a/core/res/res/values/styles.xml b/core/res/res/values/styles.xml index 648a7dd691cd..7d235ec8d4ef 100644 --- a/core/res/res/values/styles.xml +++ b/core/res/res/values/styles.xml @@ -243,7 +243,7 @@ <style name="Widget.ProgressBar"> <item name="android:indeterminateOnly">true</item> - <item name="android:indeterminateDrawable">@android:drawable/progress_medium</item> + <item name="android:indeterminateDrawable">@android:drawable/progress_medium_white</item> <item name="android:indeterminateBehavior">repeat</item> <item name="android:indeterminateDuration">3500</item> <item name="android:minWidth">48dip</item> @@ -253,7 +253,7 @@ </style> <style name="Widget.ProgressBar.Large"> - <item name="android:indeterminateDrawable">@android:drawable/progress_large</item> + <item name="android:indeterminateDrawable">@android:drawable/progress_large_white</item> <item name="android:minWidth">76dip</item> <item name="android:maxWidth">76dip</item> <item name="android:minHeight">76dip</item> @@ -261,13 +261,25 @@ </style> <style name="Widget.ProgressBar.Small"> - <item name="android:indeterminateDrawable">@android:drawable/progress_small</item> + <item name="android:indeterminateDrawable">@android:drawable/progress_small_white</item> <item name="android:minWidth">16dip</item> <item name="android:maxWidth">16dip</item> <item name="android:minHeight">16dip</item> <item name="android:maxHeight">16dip</item> </style> + <style name="Widget.ProgressBar.Inverse"> + <item name="android:indeterminateDrawable">@android:drawable/progress_medium</item> + </style> + + <style name="Widget.ProgressBar.Large.Inverse"> + <item name="android:indeterminateDrawable">@android:drawable/progress_large</item> + </style> + + <style name="Widget.ProgressBar.Small.Inverse"> + <item name="android:indeterminateDrawable">@android:drawable/progress_small</item> + </style> + <style name="Widget.ProgressBar.Small.Title"> <item name="android:indeterminateDrawable">@android:drawable/progress_small_titlebar</item> </style> diff --git a/core/res/res/values/themes.xml b/core/res/res/values/themes.xml index f37d514e6e1d..bd6e1df10f90 100644 --- a/core/res/res/values/themes.xml +++ b/core/res/res/values/themes.xml @@ -154,6 +154,9 @@ <item name="progressBarStyleSmall">@android:style/Widget.ProgressBar.Small</item> <item name="progressBarStyleSmallTitle">@android:style/Widget.ProgressBar.Small.Title</item> <item name="progressBarStyleLarge">@android:style/Widget.ProgressBar.Large</item> + <item name="progressBarStyleInverse">@android:style/Widget.ProgressBar.Inverse</item> + <item name="progressBarStyleSmallInverse">@android:style/Widget.ProgressBar.Small.Inverse</item> + <item name="progressBarStyleLargeInverse">@android:style/Widget.ProgressBar.Large.Inverse</item> <item name="seekBarStyle">@android:style/Widget.SeekBar</item> <item name="ratingBarStyle">@android:style/Widget.RatingBar</item> <item name="ratingBarStyleIndicator">@android:style/Widget.RatingBar.Indicator</item> @@ -233,6 +236,13 @@ <item name="listViewStyle">@android:style/Widget.ListView.White</item> <item name="listDivider">@drawable/divider_horizontal_bright</item> <item name="listSeparatorTextViewStyle">@android:style/Widget.TextView.ListSeparator.White</item> + + <item name="progressBarStyle">@android:style/Widget.ProgressBar.Inverse</item> + <item name="progressBarStyleSmall">@android:style/Widget.ProgressBar.Small.Inverse</item> + <item name="progressBarStyleLarge">@android:style/Widget.ProgressBar.Large.Inverse</item> + <item name="progressBarStyleInverse">@android:style/Widget.ProgressBar</item> + <item name="progressBarStyleSmallInverse">@android:style/Widget.ProgressBar.Small</item> + <item name="progressBarStyleLargeInverse">@android:style/Widget.ProgressBar.Large</item> </style> <!-- Variant of the light theme with no title bar --> diff --git a/graphics/java/android/graphics/NinePatch.java b/graphics/java/android/graphics/NinePatch.java index 2b24ef227e33..778c90304dcb 100644 --- a/graphics/java/android/graphics/NinePatch.java +++ b/graphics/java/android/graphics/NinePatch.java @@ -57,7 +57,9 @@ public class NinePatch { mBitmap = patch.mBitmap; mChunk = patch.mChunk; mSrcName = patch.mSrcName; - mPaint = new Paint(patch.mPaint); + if (patch.mPaint != null) { + mPaint = new Paint(patch.mPaint); + } validateNinePatchChunk(mBitmap.ni(), mChunk); } @@ -120,7 +122,6 @@ public class NinePatch { public native static boolean isNinePatchChunk(byte[] chunk); - private final Rect mRect = new Rect(); private final Bitmap mBitmap; private final byte[] mChunk; private Paint mPaint; diff --git a/graphics/java/android/graphics/drawable/Animatable.java b/graphics/java/android/graphics/drawable/Animatable.java new file mode 100644 index 000000000000..9dc62c36d618 --- /dev/null +++ b/graphics/java/android/graphics/drawable/Animatable.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2009 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.graphics.drawable; + +/** + * Interface that drawables suporting animations should implement. + */ +public interface Animatable { + /** + * Starts the drawable's animation. + */ + void start(); + + /** + * Stops the drawable's animation. + */ + void stop(); + + /** + * Indicates whether the animation is running. + * + * @return True if the animation is running, false otherwise. + */ + boolean isRunning(); +} diff --git a/graphics/java/android/graphics/drawable/AnimatedRotateDrawable.java b/graphics/java/android/graphics/drawable/AnimatedRotateDrawable.java index 08d295d1820e..ac96f20bc527 100644 --- a/graphics/java/android/graphics/drawable/AnimatedRotateDrawable.java +++ b/graphics/java/android/graphics/drawable/AnimatedRotateDrawable.java @@ -35,11 +35,14 @@ import com.android.internal.R; /** * @hide */ -public class AnimatedRotateDrawable extends Drawable implements Drawable.Callback, Runnable { +public class AnimatedRotateDrawable extends Drawable implements Drawable.Callback, Runnable, + Animatable { + private AnimatedRotateState mState; private boolean mMutated; private float mCurrentDegrees; private float mIncrement; + private boolean mRunning; public AnimatedRotateDrawable() { this(null); @@ -80,10 +83,24 @@ public class AnimatedRotateDrawable extends Drawable implements Drawable.Callbac drawable.draw(canvas); canvas.restoreToCount(saveCount); - - nextFrame(); } - + + public void start() { + if (!mRunning) { + mRunning = true; + nextFrame(); + } + } + + public void stop() { + mRunning = false; + unscheduleSelf(this); + } + + public boolean isRunning() { + return mRunning; + } + private void nextFrame() { unscheduleSelf(this); scheduleSelf(this, SystemClock.uptimeMillis() + mState.mFrameDuration); @@ -96,8 +113,8 @@ public class AnimatedRotateDrawable extends Drawable implements Drawable.Callbac if (mCurrentDegrees > (360.0f - mIncrement)) { mCurrentDegrees = 0.0f; } - nextFrame(); invalidateSelf(); + nextFrame(); } @Override diff --git a/graphics/java/android/graphics/drawable/AnimationDrawable.java b/graphics/java/android/graphics/drawable/AnimationDrawable.java index bab1703fbf24..68718c9763eb 100644 --- a/graphics/java/android/graphics/drawable/AnimationDrawable.java +++ b/graphics/java/android/graphics/drawable/AnimationDrawable.java @@ -71,7 +71,7 @@ import android.util.AttributeSet; * @attr ref android.R.styleable#AnimationDrawableItem_duration * @attr ref android.R.styleable#AnimationDrawableItem_drawable */ -public class AnimationDrawable extends DrawableContainer implements Runnable { +public class AnimationDrawable extends DrawableContainer implements Runnable, Animatable { private final AnimationState mAnimationState; private int mCurFrame = -1; private boolean mMutated; diff --git a/libs/rs/RenderScript.h b/libs/rs/RenderScript.h index 734fba7ce429..5f551df6465c 100644 --- a/libs/rs/RenderScript.h +++ b/libs/rs/RenderScript.h @@ -173,6 +173,14 @@ enum RsTexEnvMode { RS_TEX_ENV_MODE_DECAL }; +enum RsPrimitive { + RS_PRIMITIVE_POINT, + RS_PRIMITIVE_LINE, + RS_PRIMITIVE_LINE_STRIP, + RS_PRIMITIVE_TRIANGLE, + RS_PRIMITIVE_TRIANGLE_STRIP, + RS_PRIMITIVE_TRIANGLE_FAN +}; #include "rsgApiFuncDecl.h" diff --git a/libs/rs/java/Film/res/raw/filmstrip.c b/libs/rs/java/Film/res/raw/filmstrip.c index a3b3d903b0f4..1687a3121068 100644 --- a/libs/rs/java/Film/res/raw/filmstrip.c +++ b/libs/rs/java/Film/res/raw/filmstrip.c @@ -31,6 +31,10 @@ int main(int index) int trans; // float int rot; // float int x; + float focusPos; // float + int focusID; + int lastFocusID; + int imgCount; float_2 = intToFloat(2); float_1 = intToFloat(1); @@ -58,15 +62,17 @@ int main(int index) //int imgId = 0; -/* - contextBindProgramFragmentStore(env->fsImages); - contextBindProgramFragment(env->fpImages); + contextBindProgramFragmentStore(NAMED_PFImages); + contextBindProgramFragment(NAMED_PFSImages); + + //focusPos = loadF(1, 2); + //focusID = 0; + //lastFocusID = loadI32(2, 0); + //imgCount = 13; + + /* disable(GL_LIGHTING); - float focusPos = loadEnvF(1, 2); - int focusID = 0; - int lastFocusID = loadEnvI32(2, 0); - int imgCount = 13; if (trans > (-.3)) { focusID = -1.0 - focusPos; diff --git a/libs/rs/java/Rollo/res/raw/rollo.c b/libs/rs/java/Rollo/res/raw/rollo.c index 56ee425d32e8..e6acc9cef44e 100644 --- a/libs/rs/java/Rollo/res/raw/rollo.c +++ b/libs/rs/java/Rollo/res/raw/rollo.c @@ -5,10 +5,58 @@ int main(void* con, int ft, int launchID) { + int rowCount; int x; + int y; + int row; + int col; + int imageID; + int tx1; + int ty1; + int tz1; + int tx2; + int ty2; + int tz2; + int rot; + int rotStep; + int tmpSin; + int tmpCos; + int iconCount; + int pressure; - renderTriangleMesh(con, NAMED_MeshCard); - renderTriangleMesh(con, NAMED_MeshTab); + + iconCount = 38;//loadI32(0, 1); + rotStep = 20 * 0x10000; + pressure = loadI32(0, 2); + + rowCount = 4; + rot = (-20 + loadI32(0, 0)) * 0x10000; + + while (iconCount) { + tmpSin = sinx(rot); + tmpCos = cosx(rot); + + tx1 = tmpSin * 8 - tmpCos; + tx2 = tx1 + tmpCos * 2; + + tz1 = tmpCos * 8 + tmpSin + pressure; + tz2 = tz1 - tmpSin * 2; + + for (y = 0; (y < rowCount) && iconCount; y++) { + ty1 = (y * 0x30000) - 0x48000; + ty2 = ty1 + 0x20000; + + drawQuad(tx1, ty1, tz1, + tx2, ty1, tz2, + tx2, ty2, tz2, + tx1, ty2, tz1); + iconCount--; + } + rot = rot + rotStep; + } + + //renderTriangleMesh(con, NAMED_MeshCard); + //renderTriangleMesh(con, NAMED_MeshTab); return 1; } diff --git a/libs/rs/java/Rollo/src/com/android/rollo/RolloRS.java b/libs/rs/java/Rollo/src/com/android/rollo/RolloRS.java index da0b146ef0ba..0f7e26b0fa0e 100644 --- a/libs/rs/java/Rollo/src/com/android/rollo/RolloRS.java +++ b/libs/rs/java/Rollo/src/com/android/rollo/RolloRS.java @@ -48,6 +48,12 @@ public class RolloRS { initRS(); } + public void setPosition(float dx, float pressure) { + mAllocStateBuf[0] += (int)(dx); + mAllocStateBuf[2] = (int)(pressure * 0x40000); + mAllocState.data(mAllocStateBuf); + } + private Resources mRes; private RenderScript mRS; @@ -63,23 +69,13 @@ public class RolloRS { private RenderScript.ProgramVertex mPV; private ProgramVertexAlloc mPVAlloc; - private RenderScript.Allocation mAllocEnv; - private RenderScript.Allocation mAllocPos; + private int[] mAllocStateBuf; private RenderScript.Allocation mAllocState; - //private RenderScript.Allocation mAllocPV; - private RenderScript.TriangleMesh mMeshCard; - private RenderScript.TriangleMesh mMeshTab; private float[] mBufferPos; //private float[] mBufferPV; private void initNamed() { - mMeshTab = RolloMesh.createTab(mRS); - mMeshTab.setName("MeshTab"); - mMeshCard = RolloMesh.createCard(mRS); - mMeshCard.setName("MeshCard"); - Log.e("rs", "Done loading strips"); - mRS.samplerBegin(); mRS.samplerSet(RenderScript.SamplerParam.FILTER_MIN, RenderScript.SamplerValue.LINEAR_MIP_LINEAR); @@ -122,6 +118,8 @@ public class RolloRS { mPV.setName("PV"); mPV.bindAllocation(0, mPVAlloc.mAlloc); + + mPVAlloc.setupProjectionNormalized(320, 480); //mPVAlloc.setupOrthoNormalized(320, 480); mRS.contextBindProgramVertex(mPV); @@ -131,6 +129,7 @@ public class RolloRS { } + private void initRS() { mRS.scriptCBegin(); mRS.scriptCSetClearColor(0.0f, 0.7f, 0.0f, 1.0f); @@ -138,6 +137,11 @@ public class RolloRS { mRS.scriptCSetRoot(true); mScript = mRS.scriptCCreate(); + mAllocStateBuf = new int[] {0, 38, 0}; + mAllocState = mRS.allocationCreatePredefSized( + RenderScript.ElementPredefined.USER_I32, mAllocStateBuf.length); + mScript.bindAllocation(mAllocState, 0); + setPosition(0, 0); mRS.contextBindRootScript(mScript); } diff --git a/libs/rs/java/Rollo/src/com/android/rollo/RolloView.java b/libs/rs/java/Rollo/src/com/android/rollo/RolloView.java index 9a30aed48e87..27d2dd67d11e 100644 --- a/libs/rs/java/Rollo/src/com/android/rollo/RolloView.java +++ b/libs/rs/java/Rollo/src/com/android/rollo/RolloView.java @@ -74,6 +74,11 @@ public class RolloView extends RSSurfaceView { if (act == ev.ACTION_UP) { ret = false; } + float x = ev.getX(); + x = (x - 180) / 40; + //Log.e("rs", Float(x).toString()); + + mRender.setPosition(x, ev.getPressure()); //mRender.newTouchPosition((int)ev.getX(), (int)ev.getY()); return ret; } diff --git a/libs/rs/rsContext.h b/libs/rs/rsContext.h index d98bfd9045b5..f5550902b69f 100644 --- a/libs/rs/rsContext.h +++ b/libs/rs/rsContext.h @@ -21,6 +21,7 @@ #include "rsMatrix.h" #include "rsAllocation.h" #include "rsTriangleMesh.h" +#include "rsMesh.h" #include "rsDevice.h" #include "rsScriptC.h" #include "rsAllocation.h" diff --git a/libs/rs/rsMesh.cpp b/libs/rs/rsMesh.cpp new file mode 100644 index 000000000000..6eb95fcfc7d6 --- /dev/null +++ b/libs/rs/rsMesh.cpp @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2009 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "rsContext.h" + +using namespace android; +using namespace android::renderscript; + +#include <GLES/gl.h> +#include <GLES/glext.h> + +Mesh::Mesh() +{ + mSources = NULL; + mPrimitives = NULL; + mPrimitiveCount = 0; +} + +Mesh::~Mesh() +{ +} + + + +MeshContext::MeshContext() +{ +} + +MeshContext::~MeshContext() +{ +} + diff --git a/libs/rs/rsMesh.h b/libs/rs/rsMesh.h new file mode 100644 index 000000000000..c6d3bc9bd61e --- /dev/null +++ b/libs/rs/rsMesh.h @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2009 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ANDROID_RS_MESH_H +#define ANDROID_RS_MESH_H + + +#include "RenderScript.h" + +// --------------------------------------------------------------------------- +namespace android { +namespace renderscript { + + +// An element is a group of Components that occupies one cell in a structure. +class Mesh : public ObjectBase +{ +public: + Mesh(); + ~Mesh(); + + struct VertexSource_t + { + const Element * mVertexElement; + void * mVertexData; + size_t mVertexDataSize; + + size_t mOffsetCoord; + size_t mOffsetTex; + size_t mOffsetNorm; + + size_t mSizeCoord; + size_t mSizeTex; + size_t mSizeNorm; + + uint32_t mBufferObject; + }; + + struct Primitive_t + { + RsPrimitive mType; + const Element * mIndexElement; + void * mVertexData; + size_t mIndexDataSize; + + uint32_t mBufferObject; + }; + + VertexSource_t * mSources; + Primitive_t * mPrimitives; + uint32_t mPrimitiveCount; + + void analyzeElement(); +protected: +}; + +class MeshContext +{ +public: + MeshContext(); + ~MeshContext(); + +}; + + +} +} +#endif //ANDROID_RS_TRIANGLE_MESH_H + + diff --git a/libs/rs/rsScriptC.cpp b/libs/rs/rsScriptC.cpp index 522ed00b79a1..9c99e2b4f8c2 100644 --- a/libs/rs/rsScriptC.cpp +++ b/libs/rs/rsScriptC.cpp @@ -307,6 +307,60 @@ extern "C" void drawRect(int32_t x1, int32_t x2, int32_t y1, int32_t y2) glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); } +extern "C" void drawQuad(int32_t x1, int32_t y1, int32_t z1, + int32_t x2, int32_t y2, int32_t z2, + int32_t x3, int32_t y3, int32_t z3, + int32_t x4, int32_t y4, int32_t z4) +{ + GET_TLS(); + //x1 = (x1 << 16); + //x2 = (x2 << 16); + //y1 = (y1 << 16); + //y2 = (y2 << 16); + + //LOGE("Quad"); + //LOGE("0x%08x, 0x%08x, 0x%08x", x1, y1, z1); + //LOGE("0x%08x, 0x%08x, 0x%08x", x2, y2, z2); + //LOGE("0x%08x, 0x%08x, 0x%08x", x3, y3, z3); + //LOGE("0x%08x, 0x%08x, 0x%08x", x4, y4, z4); + + int32_t vtx[] = {x1,y1,z1, x4,y4,z4, x3,y3,z3, x2,y2,z2}; + static const int32_t tex[] = {0,0, 0,0x10000, 0x10000,0, 0x10000,0x10000}; + + + rsc->setupCheck(); + + glBindBuffer(GL_ARRAY_BUFFER, 0); + //glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, tm->mBufferObjects[1]); + + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + glDisableClientState(GL_NORMAL_ARRAY); + glDisableClientState(GL_COLOR_ARRAY); + + glVertexPointer(3, GL_FIXED, 0, vtx); + glTexCoordPointer(2, GL_FIXED, 0, tex); + //glColorPointer(4, GL_UNSIGNED_BYTE, 12, ptr); + + glDrawArrays(GL_TRIANGLE_FAN, 0, 4); +} + +extern "C" int32_t sinx(int32_t angle) +{ + float a = ((float)angle) / 0x10000; + a *= 3.14f / 180.f; + float s = (float)sin(a); + return int32_t(s * 0x10000); +} + +extern "C" int32_t cosx(int32_t angle) +{ + float a = ((float)angle) / 0x10000; + a *= 3.14f / 180.f; + float s = (float)cos(a); + return int32_t(s * 0x10000); +} + extern "C" void pfBindTexture(RsProgramFragment vpf, uint32_t slot, RsAllocation va) { GET_TLS(); diff --git a/services/java/com/android/server/PackageManagerBackupAgent.java b/services/java/com/android/server/PackageManagerBackupAgent.java index 16f14e82e067..a1b4c26833de 100644 --- a/services/java/com/android/server/PackageManagerBackupAgent.java +++ b/services/java/com/android/server/PackageManagerBackupAgent.java @@ -59,7 +59,14 @@ public class PackageManagerBackupAgent extends BackupAgent { private List<PackageInfo> mAllPackages; private PackageManager mPackageManager; + // version & signature info of each app in a restore set private HashMap<String, Metadata> mRestoredSignatures; + // The version info of each backed-up app as read from the state file + private HashMap<String, Metadata> mStateVersions = new HashMap<String, Metadata>(); + + private final HashSet<String> mExisting = new HashSet<String>(); + private int mStoredSdkVersion; + private String mStoredIncrementalVersion; public class Metadata { public int versionCode; @@ -96,24 +103,39 @@ public class PackageManagerBackupAgent extends BackupAgent { ByteArrayOutputStream bufStream = new ByteArrayOutputStream(); // we'll reuse these DataOutputStream outWriter = new DataOutputStream(bufStream); - HashSet<String> existing = parseStateFile(oldState); + parseStateFile(oldState); + + // If the stored version string differs, we need to re-backup all + // of the metadata. We force this by removing everything from the + // "already backed up" map built by parseStateFile(). + if (mStoredIncrementalVersion == null + || !mStoredIncrementalVersion.equals(Build.VERSION.INCREMENTAL)) { + Log.i(TAG, "Previous metadata " + mStoredIncrementalVersion + " mismatch vs " + + Build.VERSION.INCREMENTAL + " - rewriting"); + mExisting.clear(); + } try { /* * Global metadata: * - * int version -- the SDK version of the OS itself on the device - * that produced this backup set. Used to reject - * backups from later OSes onto earlier ones. + * int SDKversion -- the SDK version of the OS itself on the device + * that produced this backup set. Used to reject + * backups from later OSes onto earlier ones. + * String incremental -- the incremental release name of the OS stored in + * the backup set. */ - if (!existing.contains(GLOBAL_METADATA_KEY)) { + if (!mExisting.contains(GLOBAL_METADATA_KEY)) { if (DEBUG) Log.v(TAG, "Storing global metadata key"); outWriter.writeInt(Build.VERSION.SDK_INT); + outWriter.writeUTF(Build.VERSION.INCREMENTAL); byte[] metadata = bufStream.toByteArray(); data.writeEntityHeader(GLOBAL_METADATA_KEY, metadata.length); data.writeEntityData(metadata, metadata.length); } else { if (DEBUG) Log.v(TAG, "Global metadata key already stored"); + // don't consider it to have been skipped/deleted + mExisting.remove(GLOBAL_METADATA_KEY); } // For each app we have on device, see if we've backed it up yet. If not, @@ -123,11 +145,36 @@ public class PackageManagerBackupAgent extends BackupAgent { if (packName.equals(GLOBAL_METADATA_KEY)) { // We've already handled the metadata key; skip it here continue; - } else if (!existing.contains(packName)) { - // We haven't stored this app's signatures yet, so we do that now + } else { + PackageInfo info = null; try { - PackageInfo info = mPackageManager.getPackageInfo(packName, + info = mPackageManager.getPackageInfo(packName, PackageManager.GET_SIGNATURES); + } catch (NameNotFoundException e) { + // Weird; we just found it, and now are told it doesn't exist. + // Treat it as having been removed from the device. + mExisting.add(packName); + continue; + } + + boolean doBackup = false; + if (!mExisting.contains(packName)) { + // We haven't backed up this app before + doBackup = true; + } else { + // We *have* backed this one up before. Check whether the version + // of the backup matches the version of the current app; if they + // don't match, the app has been updated and we need to store its + // metadata again. In either case, take it out of mExisting so that + // we don't consider it deleted later. + if (info.versionCode != mStateVersions.get(packName).versionCode) { + doBackup = true; + } + mExisting.remove(packName); + } + + if (doBackup) { + // We need to store this app's metadata /* * Metadata for each package: * @@ -135,7 +182,7 @@ public class PackageManagerBackupAgent extends BackupAgent { * byte[] signatures -- [len] flattened Signature[] of the package */ - // marshall the version code in a canonical form + // marshal the version code in a canonical form bufStream.reset(); outWriter.writeInt(info.versionCode); byte[] versionBuf = bufStream.toByteArray(); @@ -153,18 +200,6 @@ public class PackageManagerBackupAgent extends BackupAgent { data.writeEntityHeader(packName, versionBuf.length + sigs.length); data.writeEntityData(versionBuf, versionBuf.length); data.writeEntityData(sigs, sigs.length); - } catch (NameNotFoundException e) { - // Weird; we just found it, and now are told it doesn't exist. - // Treat it as having been removed from the device. - existing.add(packName); - } - } else { - // We've already backed up this app. Remove it from the set so - // we can tell at the end what has disappeared from the device. - // !!! TODO: take out the debugging message - if (DEBUG) Log.v(TAG, "= already backed up metadata for " + packName); - if (!existing.remove(packName)) { - Log.d(TAG, "*** failed to remove " + packName + " from package set!"); } } } @@ -172,7 +207,7 @@ public class PackageManagerBackupAgent extends BackupAgent { // At this point, the only entries in 'existing' are apps that were // mentioned in the saved state file, but appear to no longer be present // on the device. Write a deletion entity for them. - for (String app : existing) { + for (String app : mExisting) { // !!! TODO: take out this msg if (DEBUG) Log.v(TAG, "- removing metadata for deleted pkg " + app); try { @@ -215,17 +250,21 @@ public class PackageManagerBackupAgent extends BackupAgent { DataInputStream in = new DataInputStream(baStream); if (key.equals(GLOBAL_METADATA_KEY)) { - storedSystemVersion = in.readInt(); + int storedSdkVersion = in.readInt(); if (DEBUG) Log.v(TAG, " storedSystemVersion = " + storedSystemVersion); if (storedSystemVersion > Build.VERSION.SDK_INT) { // returning before setting the sig map means we rejected the restore set Log.w(TAG, "Restore set was from a later version of Android; not restoring"); return; } + mStoredSdkVersion = storedSdkVersion; + mStoredIncrementalVersion = in.readUTF(); // !!! TODO: remove this debugging output if (DEBUG) { Log.i(TAG, "Restore set version " + storedSystemVersion - + " is compatible with OS version " + Build.VERSION.SDK_INT); + + " is compatible with OS version " + Build.VERSION.SDK_INT + + " (" + mStoredIncrementalVersion + " vs " + + Build.VERSION.INCREMENTAL + ")"); } } else { // it's a file metadata record @@ -302,31 +341,45 @@ public class PackageManagerBackupAgent extends BackupAgent { } // Util: parse out an existing state file into a usable structure - private HashSet<String> parseStateFile(ParcelFileDescriptor stateFile) { - HashSet<String> set = new HashSet<String>(); + private void parseStateFile(ParcelFileDescriptor stateFile) { + mExisting.clear(); + mStateVersions.clear(); + mStoredSdkVersion = 0; + mStoredIncrementalVersion = null; + // The state file is just the list of app names we have stored signatures for + // with the exception of the metadata block, to which is also appended the + // version numbers corresponding with the last time we wrote this PM block. + // If they mismatch the current system, we'll re-store the metadata key. FileInputStream instream = new FileInputStream(stateFile.getFileDescriptor()); DataInputStream in = new DataInputStream(instream); int bufSize = 256; byte[] buf = new byte[bufSize]; try { - int nameSize = in.readInt(); - if (bufSize < nameSize) { - bufSize = nameSize + 32; - buf = new byte[bufSize]; + String pkg = in.readUTF(); + if (pkg.equals(GLOBAL_METADATA_KEY)) { + mStoredSdkVersion = in.readInt(); + mStoredIncrementalVersion = in.readUTF(); + mExisting.add(GLOBAL_METADATA_KEY); + } else { + Log.e(TAG, "No global metadata in state file!"); + return; + } + + // The global metadata was first; now read all the apps + while (true) { + pkg = in.readUTF(); + int versionCode = in.readInt(); + mExisting.add(pkg); + mStateVersions.put(pkg, new Metadata(versionCode, null)); } - in.read(buf, 0, nameSize); - String pkg = new String(buf, 0, nameSize); - set.add(pkg); } catch (EOFException eof) { // safe; we're done } catch (IOException e) { // whoops, bad state file. abort. - Log.e(TAG, "Unable to read Package Manager state file"); - return null; + Log.e(TAG, "Unable to read Package Manager state file: " + e); } - return set; } // Util: write out our new backup state file @@ -336,15 +389,14 @@ public class PackageManagerBackupAgent extends BackupAgent { try { // by the time we get here we know we've stored the global metadata record - byte[] metaNameBuf = GLOBAL_METADATA_KEY.getBytes(); - out.writeInt(metaNameBuf.length); - out.write(metaNameBuf); + out.writeUTF(GLOBAL_METADATA_KEY); + out.writeInt(Build.VERSION.SDK_INT); + out.writeUTF(Build.VERSION.INCREMENTAL); // now write all the app names too for (PackageInfo pkg : pkgs) { - byte[] pkgNameBuf = pkg.packageName.getBytes(); - out.writeInt(pkgNameBuf.length); - out.write(pkgNameBuf); + out.writeUTF(pkg.packageName); + out.writeInt(pkg.versionCode); } } catch (IOException e) { Log.e(TAG, "Unable to write package manager state file!"); diff --git a/test-runner/android/test/MoreAsserts.java b/test-runner/android/test/MoreAsserts.java index 2e746440403c..9e0d018b0afb 100644 --- a/test-runner/android/test/MoreAsserts.java +++ b/test-runner/android/test/MoreAsserts.java @@ -24,6 +24,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; +import java.util.ArrayList; import java.util.regex.MatchResult; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -316,8 +317,11 @@ public final class MoreAsserts { */ public static void assertContentsInOrder( String message, Iterable<?> actual, Object... expected) { - Assert.assertEquals(message, - Arrays.asList(expected), Lists.newArrayList(actual)); + ArrayList actualList = new ArrayList(); + for (Object o : actual) { + actualList.add(o); + } + Assert.assertEquals(message, Arrays.asList(expected), actualList); } /** diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/LoadTestsAutoTest.java b/tests/DumpRenderTree/src/com/android/dumprendertree/LoadTestsAutoTest.java index c792e8ee2249..cbcac6caa9ea 100644 --- a/tests/DumpRenderTree/src/com/android/dumprendertree/LoadTestsAutoTest.java +++ b/tests/DumpRenderTree/src/com/android/dumprendertree/LoadTestsAutoTest.java @@ -16,18 +16,15 @@ package com.android.dumprendertree; +import dalvik.system.VMRuntime; + import android.app.Instrumentation; import android.content.Intent; - -import android.util.Log; - import android.os.Bundle; import android.os.Debug; -import android.os.Debug.MemoryInfo; +import android.os.Process; import android.test.ActivityInstrumentationTestCase2; - -import com.android.dumprendertree.TestShellActivity; -import com.android.dumprendertree.TestShellCallback; +import android.util.Log; import java.io.FileOutputStream; import java.io.IOException; @@ -70,9 +67,7 @@ public class LoadTestsAutoTest extends ActivityInstrumentationTestCase2<TestShel TestShellActivity activity = (TestShellActivity) getActivity(); Log.v(LOGTAG, "About to run tests, calling gc first..."); - Runtime.getRuntime().runFinalization(); - Runtime.getRuntime().gc(); - Runtime.getRuntime().gc(); + freeMem(); // Run tests runTestAndWaitUntilDone(activity, runner.mTestPath, runner.mTimeoutInMillis); @@ -83,46 +78,73 @@ public class LoadTestsAutoTest extends ActivityInstrumentationTestCase2<TestShel activity.finish(); } + private void freeMem() { + Log.v(LOGTAG, "freeMem: calling gc/finalization..."); + final VMRuntime runtime = VMRuntime.getRuntime(); + + runtime.gcSoftReferences(); + runtime.runFinalizationSync(); + runtime.gcSoftReferences(); + runtime.runFinalizationSync(); + runtime.gcSoftReferences(); + runtime.runFinalizationSync(); + Runtime.getRuntime().runFinalization(); + Runtime.getRuntime().gc(); + Runtime.getRuntime().gc(); + + } + + private void printRow(PrintStream ps, String format, Object...objs) { + ps.println(String.format(format, objs)); + } + private void dumpMemoryInfo() { try { - Log.v(LOGTAG, "About to dump meminfo, calling gc first..."); - Runtime.getRuntime().runFinalization(); - Runtime.getRuntime().gc(); - Runtime.getRuntime().gc(); - + freeMem(); Log.v(LOGTAG, "Dumping memory information."); FileOutputStream out = new FileOutputStream(LOAD_TEST_RESULT, true); PrintStream ps = new PrintStream(out); - MemoryInfo mi = new MemoryInfo(); - Debug.getMemoryInfo(mi); - - //try to fake the dumpsys format - //this will eventually be changed to XML - String format = "%15s:%9d%9d%9d%9d"; - String pss = - String.format(format, "(Pss)", - mi.nativePss, mi.dalvikPss, mi.otherPss, - mi.nativePss + mi.dalvikPss + mi.otherPss); - String sd = - String.format(format, "(shared dirty)", - mi.nativeSharedDirty, mi.dalvikSharedDirty, mi.otherSharedDirty, - mi.nativeSharedDirty + mi.dalvikSharedDirty + mi.otherSharedDirty); - String pd = - String.format(format, "(priv dirty)", - mi.nativePrivateDirty, mi.dalvikPrivateDirty, mi.otherPrivateDirty, - mi.nativePrivateDirty + mi.dalvikPrivateDirty + mi.otherPrivateDirty); - ps.print("\n\n\n"); - ps.println("** MEMINFO in pid 0 [com.android.dumprendertree] **"); - ps.println(" native dalvik other total"); - ps.println(" size: 12060 5255 N/A 17315"); - ps.println(" allocated: 12060 5255 N/A 17315"); - ps.println(" free: 12060 5255 N/A 17315"); - ps.println(pss); - ps.println(sd); - ps.println(pd); + ps.println("** MEMINFO in pid " + Process.myPid() + + " [com.android.dumprendertree] **"); + String formatString = "%17s %8s %8s %8s %8s"; + + long nativeMax = Debug.getNativeHeapSize() / 1024; + long nativeAllocated = Debug.getNativeHeapAllocatedSize() / 1024; + long nativeFree = Debug.getNativeHeapFreeSize() / 1024; + Runtime runtime = Runtime.getRuntime(); + long dalvikMax = runtime.totalMemory() / 1024; + long dalvikFree = runtime.freeMemory() / 1024; + long dalvikAllocated = dalvikMax - dalvikFree; + + + Debug.MemoryInfo memInfo = new Debug.MemoryInfo(); + Debug.getMemoryInfo(memInfo); + + final int nativeShared = memInfo.nativeSharedDirty; + final int dalvikShared = memInfo.dalvikSharedDirty; + final int otherShared = memInfo.otherSharedDirty; + + final int nativePrivate = memInfo.nativePrivateDirty; + final int dalvikPrivate = memInfo.dalvikPrivateDirty; + final int otherPrivate = memInfo.otherPrivateDirty; + + printRow(ps, formatString, "", "native", "dalvik", "other", "total"); + printRow(ps, formatString, "size:", nativeMax, dalvikMax, "N/A", nativeMax + dalvikMax); + printRow(ps, formatString, "allocated:", nativeAllocated, dalvikAllocated, "N/A", + nativeAllocated + dalvikAllocated); + printRow(ps, formatString, "free:", nativeFree, dalvikFree, "N/A", + nativeFree + dalvikFree); + + printRow(ps, formatString, "(Pss):", memInfo.nativePss, memInfo.dalvikPss, + memInfo.otherPss, memInfo.nativePss + memInfo.dalvikPss + memInfo.otherPss); + + printRow(ps, formatString, "(shared dirty):", nativeShared, dalvikShared, otherShared, + nativeShared + dalvikShared + otherShared); + printRow(ps, formatString, "(priv dirty):", nativePrivate, dalvikPrivate, otherPrivate, + nativePrivate + dalvikPrivate + otherPrivate); ps.print("\n\n\n"); ps.flush(); ps.close(); @@ -142,7 +164,7 @@ public class LoadTestsAutoTest extends ActivityInstrumentationTestCase2<TestShel LoadTestsAutoTest.this.notifyAll(); } } - + public void timedOut(String url) { } }); |