diff options
49 files changed, 1234 insertions, 754 deletions
@@ -2721,6 +2721,17 @@ visibility="public" > </field> +<field name="calendarViewStyle" + type="int" + transient="false" + volatile="false" + value="16843613" + static="true" + final="true" + deprecated="not deprecated" + visibility="public" +> +</field> <field name="candidatesTextStyleSpans" type="int" transient="false" @@ -3282,6 +3293,17 @@ visibility="public" > </field> +<field name="datePickerStyle" + type="int" + transient="false" + volatile="false" + value="16843612" + static="true" + final="true" + deprecated="not deprecated" + visibility="public" +> +</field> <field name="dateTextAppearance" type="int" transient="false" @@ -8727,17 +8749,6 @@ visibility="public" > </field> -<field name="solidColor" - type="int" - transient="false" - volatile="false" - value="16843594" - static="true" - final="true" - deprecated="not deprecated" - visibility="public" -> -</field> <field name="soundEffectsEnabled" type="int" transient="false" @@ -10905,6 +10916,17 @@ visibility="public" > </field> +<field name="windowCloseOnTouchOutside" + type="int" + transient="false" + volatile="false" + value="16843611" + static="true" + final="true" + deprecated="not deprecated" + visibility="public" +> +</field> <field name="windowContentOverlay" type="int" transient="false" @@ -15982,7 +16004,7 @@ type="int" transient="false" volatile="false" - value="16974069" + value="16974060" static="true" final="true" deprecated="not deprecated" @@ -16033,44 +16055,44 @@ visibility="public" > </field> -<field name="Widget_DropDownItem" +<field name="Widget_DatePicker" type="int" transient="false" volatile="false" - value="16973867" + value="16974063" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> -<field name="Widget_DropDownItem_Spinner" +<field name="Widget_DropDownItem" type="int" transient="false" volatile="false" - value="16973868" + value="16973867" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> -<field name="Widget_EditText" +<field name="Widget_DropDownItem_Spinner" type="int" transient="false" volatile="false" - value="16973859" + value="16973868" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> -<field name="Widget_EditText_NumberPickerInputText" +<field name="Widget_EditText" type="int" transient="false" volatile="false" - value="16974061" + value="16973859" static="true" final="true" deprecated="not deprecated" @@ -16268,7 +16290,7 @@ type="int" transient="false" volatile="false" - value="16974070" + value="16974061" static="true" final="true" deprecated="not deprecated" @@ -16308,44 +16330,44 @@ visibility="public" > </field> -<field name="Widget_Holo_DropDownItem" +<field name="Widget_Holo_DatePicker" type="int" transient="false" volatile="false" - value="16973995" + value="16974064" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> -<field name="Widget_Holo_DropDownItem_Spinner" +<field name="Widget_Holo_DropDownItem" type="int" transient="false" volatile="false" - value="16973996" + value="16973995" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> -<field name="Widget_Holo_EditText" +<field name="Widget_Holo_DropDownItem_Spinner" type="int" transient="false" volatile="false" - value="16973972" + value="16973996" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> -<field name="Widget_Holo_EditText_NumberPickerInputText" +<field name="Widget_Holo_EditText" type="int" transient="false" volatile="false" - value="16974064" + value="16973972" static="true" final="true" deprecated="not deprecated" @@ -16396,28 +16418,6 @@ visibility="public" > </field> -<field name="Widget_Holo_ImageButton_NumberPickerDownButton" - type="int" - transient="false" - volatile="false" - value="16974065" - static="true" - final="true" - deprecated="not deprecated" - visibility="public" -> -</field> -<field name="Widget_Holo_ImageButton_NumberPickerUpButton" - type="int" - transient="false" - volatile="false" - value="16974063" - static="true" - final="true" - deprecated="not deprecated" - visibility="public" -> -</field> <field name="Widget_Holo_Light" type="int" transient="false" @@ -16543,7 +16543,7 @@ type="int" transient="false" volatile="false" - value="16974071" + value="16974062" static="true" final="true" deprecated="not deprecated" @@ -16616,17 +16616,6 @@ visibility="public" > </field> -<field name="Widget_Holo_Light_EditText_NumberPickerInputText" - type="int" - transient="false" - volatile="false" - value="16974067" - static="true" - final="true" - deprecated="not deprecated" - visibility="public" -> -</field> <field name="Widget_Holo_Light_ExpandableListView" type="int" transient="false" @@ -16671,28 +16660,6 @@ visibility="public" > </field> -<field name="Widget_Holo_Light_ImageButton_NumberPickerDownButton" - type="int" - transient="false" - volatile="false" - value="16974068" - static="true" - final="true" - deprecated="not deprecated" - visibility="public" -> -</field> -<field name="Widget_Holo_Light_ImageButton_NumberPickerUpButton" - type="int" - transient="false" - volatile="false" - value="16974066" - static="true" - final="true" - deprecated="not deprecated" - visibility="public" -> -</field> <field name="Widget_Holo_Light_ListPopupWindow" type="int" transient="false" @@ -17221,28 +17188,6 @@ visibility="public" > </field> -<field name="Widget_ImageButton_NumberPickerDownButton" - type="int" - transient="false" - volatile="false" - value="16974062" - static="true" - final="true" - deprecated="not deprecated" - visibility="public" -> -</field> -<field name="Widget_ImageButton_NumberPickerUpButton" - type="int" - transient="false" - volatile="false" - value="16974060" - static="true" - final="true" - deprecated="not deprecated" - visibility="public" -> -</field> <field name="Widget_ImageWell" type="int" transient="false" @@ -24311,6 +24256,19 @@ <parameter name="uri" type="android.net.Uri"> </parameter> </method> +<method name="setFinishOnTouchOutside" + return="void" + abstract="false" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<parameter name="finish" type="boolean"> +</parameter> +</method> <method name="setIntent" return="void" abstract="false" @@ -136099,6 +136057,17 @@ visibility="public" > </method> +<method name="getPreserveEGLContextOnPause" + return="boolean" + abstract="false" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</method> <method name="getRenderMode" return="int" abstract="false" @@ -136270,6 +136239,19 @@ <parameter name="glWrapper" type="android.opengl.GLSurfaceView.GLWrapper"> </parameter> </method> +<method name="setPreserveEGLContextOnPause" + return="void" + abstract="false" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<parameter name="preserveOnPause" type="boolean"> +</parameter> +</method> <method name="setRenderMode" return="void" abstract="false" @@ -146702,6 +146684,16 @@ visibility="public" > </constructor> +<constructor name="StrictMode.VmPolicy.Builder" + type="android.os.StrictMode.VmPolicy.Builder" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<parameter name="base" type="android.os.StrictMode.VmPolicy"> +</parameter> +</constructor> <method name="build" return="android.os.StrictMode.VmPolicy" abstract="false" @@ -146779,6 +146771,21 @@ visibility="public" > </method> +<method name="setClassInstanceLimit" + return="android.os.StrictMode.VmPolicy.Builder" + abstract="false" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<parameter name="klass" type="java.lang.Class"> +</parameter> +<parameter name="instanceLimit" type="int"> +</parameter> +</method> </class> <class name="SystemClock" extends="java.lang.Object" @@ -219396,6 +219403,14 @@ <parameter name="view" type="android.view.View"> </parameter> </constructor> +<constructor name="View.DragShadowBuilder" + type="android.view.View.DragShadowBuilder" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</constructor> <method name="getView" return="android.view.View" abstract="false" @@ -236046,6 +236061,48 @@ </parameter> </method> </class> +<class name="WebStorage.Origin" + extends="java.lang.Object" + abstract="false" + static="true" + final="false" + deprecated="not deprecated" + visibility="public" +> +<method name="getOrigin" + return="java.lang.String" + abstract="false" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</method> +<method name="getQuota" + return="long" + abstract="false" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</method> +<method name="getUsage" + return="long" + abstract="false" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</method> +</class> <interface name="WebStorage.QuotaUpdater" abstract="true" static="true" @@ -252338,21 +252395,6 @@ deprecated="not deprecated" visibility="public" > -<parameter name="viewId" type="int"> -</parameter> -<parameter name="intent" type="android.content.Intent"> -</parameter> -</method> -<method name="setRemoteAdapter" - return="void" - abstract="false" - native="false" - synchronized="false" - static="false" - final="false" - deprecated="not deprecated" - visibility="public" -> <parameter name="appWidgetId" type="int"> </parameter> <parameter name="viewId" type="int"> diff --git a/api/current.xml b/api/current.xml index b85c57b..69276d6 100644 --- a/api/current.xml +++ b/api/current.xml @@ -2721,6 +2721,17 @@ visibility="public" > </field> +<field name="calendarViewStyle" + type="int" + transient="false" + volatile="false" + value="16843613" + static="true" + final="true" + deprecated="not deprecated" + visibility="public" +> +</field> <field name="candidatesTextStyleSpans" type="int" transient="false" @@ -3282,6 +3293,17 @@ visibility="public" > </field> +<field name="datePickerStyle" + type="int" + transient="false" + volatile="false" + value="16843612" + static="true" + final="true" + deprecated="not deprecated" + visibility="public" +> +</field> <field name="dateTextAppearance" type="int" transient="false" @@ -8727,17 +8749,6 @@ visibility="public" > </field> -<field name="solidColor" - type="int" - transient="false" - volatile="false" - value="16843594" - static="true" - final="true" - deprecated="not deprecated" - visibility="public" -> -</field> <field name="soundEffectsEnabled" type="int" transient="false" @@ -15993,7 +16004,7 @@ type="int" transient="false" volatile="false" - value="16974069" + value="16974060" static="true" final="true" deprecated="not deprecated" @@ -16044,44 +16055,44 @@ visibility="public" > </field> -<field name="Widget_DropDownItem" +<field name="Widget_DatePicker" type="int" transient="false" volatile="false" - value="16973867" + value="16974063" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> -<field name="Widget_DropDownItem_Spinner" +<field name="Widget_DropDownItem" type="int" transient="false" volatile="false" - value="16973868" + value="16973867" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> -<field name="Widget_EditText" +<field name="Widget_DropDownItem_Spinner" type="int" transient="false" volatile="false" - value="16973859" + value="16973868" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> -<field name="Widget_EditText_NumberPickerInputText" +<field name="Widget_EditText" type="int" transient="false" volatile="false" - value="16974061" + value="16973859" static="true" final="true" deprecated="not deprecated" @@ -16279,7 +16290,7 @@ type="int" transient="false" volatile="false" - value="16974070" + value="16974061" static="true" final="true" deprecated="not deprecated" @@ -16319,44 +16330,44 @@ visibility="public" > </field> -<field name="Widget_Holo_DropDownItem" +<field name="Widget_Holo_DatePicker" type="int" transient="false" volatile="false" - value="16973995" + value="16974064" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> -<field name="Widget_Holo_DropDownItem_Spinner" +<field name="Widget_Holo_DropDownItem" type="int" transient="false" volatile="false" - value="16973996" + value="16973995" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> -<field name="Widget_Holo_EditText" +<field name="Widget_Holo_DropDownItem_Spinner" type="int" transient="false" volatile="false" - value="16973972" + value="16973996" static="true" final="true" deprecated="not deprecated" visibility="public" > </field> -<field name="Widget_Holo_EditText_NumberPickerInputText" +<field name="Widget_Holo_EditText" type="int" transient="false" volatile="false" - value="16974064" + value="16973972" static="true" final="true" deprecated="not deprecated" @@ -16407,28 +16418,6 @@ visibility="public" > </field> -<field name="Widget_Holo_ImageButton_NumberPickerDownButton" - type="int" - transient="false" - volatile="false" - value="16974065" - static="true" - final="true" - deprecated="not deprecated" - visibility="public" -> -</field> -<field name="Widget_Holo_ImageButton_NumberPickerUpButton" - type="int" - transient="false" - volatile="false" - value="16974063" - static="true" - final="true" - deprecated="not deprecated" - visibility="public" -> -</field> <field name="Widget_Holo_Light" type="int" transient="false" @@ -16554,7 +16543,7 @@ type="int" transient="false" volatile="false" - value="16974071" + value="16974062" static="true" final="true" deprecated="not deprecated" @@ -16627,17 +16616,6 @@ visibility="public" > </field> -<field name="Widget_Holo_Light_EditText_NumberPickerInputText" - type="int" - transient="false" - volatile="false" - value="16974067" - static="true" - final="true" - deprecated="not deprecated" - visibility="public" -> -</field> <field name="Widget_Holo_Light_ExpandableListView" type="int" transient="false" @@ -16682,28 +16660,6 @@ visibility="public" > </field> -<field name="Widget_Holo_Light_ImageButton_NumberPickerDownButton" - type="int" - transient="false" - volatile="false" - value="16974068" - static="true" - final="true" - deprecated="not deprecated" - visibility="public" -> -</field> -<field name="Widget_Holo_Light_ImageButton_NumberPickerUpButton" - type="int" - transient="false" - volatile="false" - value="16974066" - static="true" - final="true" - deprecated="not deprecated" - visibility="public" -> -</field> <field name="Widget_Holo_Light_ListPopupWindow" type="int" transient="false" @@ -17232,28 +17188,6 @@ visibility="public" > </field> -<field name="Widget_ImageButton_NumberPickerDownButton" - type="int" - transient="false" - volatile="false" - value="16974062" - static="true" - final="true" - deprecated="not deprecated" - visibility="public" -> -</field> -<field name="Widget_ImageButton_NumberPickerUpButton" - type="int" - transient="false" - volatile="false" - value="16974060" - static="true" - final="true" - deprecated="not deprecated" - visibility="public" -> -</field> <field name="Widget_ImageWell" type="int" transient="false" @@ -252494,21 +252428,6 @@ deprecated="not deprecated" visibility="public" > -<parameter name="viewId" type="int"> -</parameter> -<parameter name="intent" type="android.content.Intent"> -</parameter> -</method> -<method name="setRemoteAdapter" - return="void" - abstract="false" - native="false" - synchronized="false" - static="false" - final="false" - deprecated="not deprecated" - visibility="public" -> <parameter name="appWidgetId" type="int"> </parameter> <parameter name="viewId" type="int"> diff --git a/build/phone-hdpi-512-dalvik-heap.mk b/build/phone-hdpi-512-dalvik-heap.mk index afc45ee..a7f9d32 100644 --- a/build/phone-hdpi-512-dalvik-heap.mk +++ b/build/phone-hdpi-512-dalvik-heap.mk @@ -19,5 +19,4 @@ PRODUCT_PROPERTY_OVERRIDES += \ dalvik.vm.heapstartsize=5m \ - dalvik.vm.smallheapsize=32m \ dalvik.vm.heapsize=32m diff --git a/build/phone-hdpi-dalvik-heap.mk b/build/phone-hdpi-dalvik-heap.mk index ee30b92..ab33b96 100644 --- a/build/phone-hdpi-dalvik-heap.mk +++ b/build/phone-hdpi-dalvik-heap.mk @@ -18,5 +18,4 @@ PRODUCT_PROPERTY_OVERRIDES += \ dalvik.vm.heapstartsize=5m \ - dalvik.vm.smallheapsize=32m \ dalvik.vm.heapsize=32m diff --git a/build/tablet-dalvik-heap.mk b/build/tablet-dalvik-heap.mk index 9cb2f6b..37c3ec5 100644 --- a/build/tablet-dalvik-heap.mk +++ b/build/tablet-dalvik-heap.mk @@ -18,5 +18,5 @@ PRODUCT_PROPERTY_OVERRIDES += \ dalvik.vm.heapstartsize=5m \ - dalvik.vm.smallheapsize=48m \ - dalvik.vm.heapsize=48m + dalvik.vm.growthlimit=48m \ + dalvik.vm.heapsize=256m diff --git a/core/java/android/accounts/AccountManagerService.java b/core/java/android/accounts/AccountManagerService.java index e6eaf71..2c99f14 100644 --- a/core/java/android/accounts/AccountManagerService.java +++ b/core/java/android/accounts/AccountManagerService.java @@ -722,6 +722,9 @@ public class AccountManagerService final String[] argsAccountId = {String.valueOf(accountId)}; db.update(TABLE_ACCOUNTS, values, ACCOUNTS_ID + "=?", argsAccountId); db.delete(TABLE_AUTHTOKENS, AUTHTOKENS_ACCOUNTS_ID + "=?", argsAccountId); + synchronized (mCacheLock) { + mAuthTokenCache.remove(account); + } db.setTransactionSuccessful(); } } finally { @@ -1812,6 +1815,11 @@ public class AccountManagerService try { db.execSQL("DELETE from " + TABLE_AUTHTOKENS); db.execSQL("UPDATE " + TABLE_ACCOUNTS + " SET " + ACCOUNTS_PASSWORD + " = ''"); + + synchronized (mCacheLock) { + mAuthTokenCache = new HashMap<Account, HashMap<String, String>>(); + } + db.setTransactionSuccessful(); } finally { db.endTransaction(); diff --git a/core/java/android/os/Environment.java b/core/java/android/os/Environment.java index 904b2e9..ec5030c 100644 --- a/core/java/android/os/Environment.java +++ b/core/java/android/os/Environment.java @@ -416,6 +416,7 @@ public class Environment { * <p>See {@link #getExternalStorageDirectory()} for more information. */ public static boolean isExternalStorageRemovable() { + if (isExternalStorageEmulated()) return false; return Resources.getSystem().getBoolean( com.android.internal.R.bool.config_externalStorageRemovable); } diff --git a/core/java/android/view/GLES20Canvas.java b/core/java/android/view/GLES20Canvas.java index 99b686e..f480554 100644 --- a/core/java/android/view/GLES20Canvas.java +++ b/core/java/android/view/GLES20Canvas.java @@ -452,11 +452,14 @@ class GLES20Canvas extends HardwareCanvas { @Override public int saveLayer(float left, float top, float right, float bottom, Paint paint, int saveFlags) { - boolean hasColorFilter = paint != null && setupColorFilter(paint); - final int nativePaint = paint == null ? 0 : paint.mNativePaint; - int count = nSaveLayer(mRenderer, left, top, right, bottom, nativePaint, saveFlags); - if (hasColorFilter) nResetModifiers(mRenderer); - return count; + if (left < right && top < bottom) { + boolean hasColorFilter = paint != null && setupColorFilter(paint); + final int nativePaint = paint == null ? 0 : paint.mNativePaint; + int count = nSaveLayer(mRenderer, left, top, right, bottom, nativePaint, saveFlags); + if (hasColorFilter) nResetModifiers(mRenderer); + return count; + } + return save(saveFlags); } private native int nSaveLayer(int renderer, float left, float top, float right, float bottom, @@ -471,7 +474,10 @@ class GLES20Canvas extends HardwareCanvas { @Override public int saveLayerAlpha(float left, float top, float right, float bottom, int alpha, int saveFlags) { - return nSaveLayerAlpha(mRenderer, left, top, right, bottom, alpha, saveFlags); + if (left < right && top < bottom) { + return nSaveLayerAlpha(mRenderer, left, top, right, bottom, alpha, saveFlags); + } + return save(saveFlags); } private native int nSaveLayerAlpha(int renderer, float left, float top, float right, diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 270ea76..2447f8c 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -58,7 +58,6 @@ import android.util.PoolableManager; import android.util.Pools; import android.util.SparseArray; import android.view.ContextMenu.ContextMenuInfo; -import android.view.View.MeasureSpec; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityEventSource; import android.view.accessibility.AccessibilityManager; diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java index d1781cc..115431e 100644 --- a/core/java/android/view/ViewGroup.java +++ b/core/java/android/view/ViewGroup.java @@ -935,15 +935,17 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager } break; case DragEvent.ACTION_DRAG_ENDED: { - // If a child was notified about an ongoing drag, it's told that it's over - for (View child : mDragNotifiedChildren) { - child.dispatchDragEvent(event); - } - // Release the bookkeeping now that the drag lifecycle has ended - mDragNotifiedChildren.clear(); - mCurrentDrag.recycle(); - mCurrentDrag = null; + if (mDragNotifiedChildren != null) { + for (View child : mDragNotifiedChildren) { + // If a child was notified about an ongoing drag, it's told that it's over + child.dispatchDragEvent(event); + } + + mDragNotifiedChildren.clear(); + mCurrentDrag.recycle(); + mCurrentDrag = null; + } // We consider drag-ended to have been handled if one of our children // had offered to handle the drag. diff --git a/core/java/android/view/ViewRoot.java b/core/java/android/view/ViewRoot.java index 961b633..1f15628 100644 --- a/core/java/android/view/ViewRoot.java +++ b/core/java/android/view/ViewRoot.java @@ -2803,6 +2803,7 @@ public final class ViewRoot extends Handler implements ViewParent, // Report the drop result when we're done if (what == DragEvent.ACTION_DROP) { + mDragDescription = null; try { Log.i(TAG, "Reporting drop result: " + result); sWindowSession.reportDropResult(mWindow, result); diff --git a/core/java/android/view/VolumePanel.java b/core/java/android/view/VolumePanel.java index e21824e..e447dbb 100644 --- a/core/java/android/view/VolumePanel.java +++ b/core/java/android/view/VolumePanel.java @@ -284,10 +284,11 @@ public class VolumePanel extends Handler synchronized (this) { ToneGenerator toneGen = getOrCreateToneGenerator(streamType); - toneGen.startTone(ToneGenerator.TONE_PROP_BEEP); + if (toneGen != null) { + toneGen.startTone(ToneGenerator.TONE_PROP_BEEP); + sendMessageDelayed(obtainMessage(MSG_STOP_SOUNDS), BEEP_DURATION); + } } - - sendMessageDelayed(obtainMessage(MSG_STOP_SOUNDS), BEEP_DURATION); } protected void onStopSounds() { @@ -319,10 +320,16 @@ public class VolumePanel extends Handler private ToneGenerator getOrCreateToneGenerator(int streamType) { synchronized (this) { if (mToneGenerators[streamType] == null) { - return mToneGenerators[streamType] = new ToneGenerator(streamType, MAX_VOLUME); - } else { - return mToneGenerators[streamType]; + try { + mToneGenerators[streamType] = new ToneGenerator(streamType, MAX_VOLUME); + } catch (RuntimeException e) { + if (LOGD) { + Log.d(TAG, "ToneGenerator constructor failed with " + + "RuntimeException: " + e); + } + } } + return mToneGenerators[streamType]; } } diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java index 9e09c28..7b3ea74 100644 --- a/core/java/android/webkit/WebView.java +++ b/core/java/android/webkit/WebView.java @@ -408,10 +408,13 @@ public class WebView extends AbsoluteLayout PluginFullScreenHolder mFullScreenHolder; /** - * Position of the last touch event. + * Position of the last touch event in pixels. + * Use integer to prevent loss of dragging delta calculation accuracy; + * which was done in float and converted to integer, and resulted in gradual + * and compounding touch position and view dragging mismatch. */ - private float mLastTouchX; - private float mLastTouchY; + private int mLastTouchX; + private int mLastTouchY; /** * Time of the last touch event. @@ -2218,8 +2221,8 @@ public class WebView extends AbsoluteLayout if (type == HitTestResult.UNKNOWN_TYPE || type == HitTestResult.SRC_ANCHOR_TYPE) { // Now check to see if it is an image. - int contentX = viewToContentX((int) mLastTouchX + mScrollX); - int contentY = viewToContentY((int) mLastTouchY + mScrollY); + int contentX = viewToContentX(mLastTouchX + mScrollX); + int contentY = viewToContentY(mLastTouchY + mScrollY); String text = nativeImageURI(contentX, contentY); if (text != null) { result.setType(type == HitTestResult.UNKNOWN_TYPE ? @@ -2256,8 +2259,8 @@ public class WebView extends AbsoluteLayout if (hrefMsg == null) { return; } - int contentX = viewToContentX((int) mLastTouchX + mScrollX); - int contentY = viewToContentY((int) mLastTouchY + mScrollY); + int contentX = viewToContentX(mLastTouchX + mScrollX); + int contentY = viewToContentY(mLastTouchY + mScrollY); mWebViewCore.sendMessage(EventHub.REQUEST_CURSOR_HREF, contentX, contentY, hrefMsg); } @@ -2271,8 +2274,8 @@ public class WebView extends AbsoluteLayout */ public void requestImageRef(Message msg) { if (0 == mNativeClass) return; // client isn't initialized - int contentX = viewToContentX((int) mLastTouchX + mScrollX); - int contentY = viewToContentY((int) mLastTouchY + mScrollY); + int contentX = viewToContentX(mLastTouchX + mScrollX); + int contentY = viewToContentY(mLastTouchY + mScrollY); String ref = nativeImageURI(contentX, contentY); Bundle data = msg.getData(); data.putString("url", ref); @@ -3856,8 +3859,8 @@ public class WebView extends AbsoluteLayout * @hide pending API council approval */ public boolean selectText() { - int x = viewToContentX((int) mLastTouchX + mScrollX); - int y = viewToContentY((int) mLastTouchY + mScrollY); + int x = viewToContentX(mLastTouchX + mScrollX); + int y = viewToContentY(mLastTouchY + mScrollY); return selectText(x, y); } @@ -4858,8 +4861,8 @@ public class WebView extends AbsoluteLayout mSelectX = contentToViewX(rect.left); mSelectY = contentToViewY(rect.top); } else if (mLastTouchY > getVisibleTitleHeight()) { - mSelectX = mScrollX + (int) mLastTouchX; - mSelectY = mScrollY + (int) mLastTouchY; + mSelectX = mScrollX + mLastTouchX; + mSelectY = mScrollY + mLastTouchY; } else { mSelectX = mScrollX + getViewWidth() / 2; mSelectY = mScrollY + getViewHeightWithTitle() / 2; @@ -5235,7 +5238,7 @@ public class WebView extends AbsoluteLayout if (event.getAction() == KeyEvent.ACTION_DOWN) { mGotKeyDown = true; } else { - if (!mGotKeyDown) { + if (!mGotKeyDown && event.getAction() != KeyEvent.ACTION_MULTIPLE) { /* * We got a key up for which we were not the recipient of * the original key down. Don't give it to the view. @@ -5357,7 +5360,7 @@ public class WebView extends AbsoluteLayout return true; } - return handleTouchEventCommon(ev, ev.getX(), ev.getY()); + return handleTouchEventCommon(ev, Math.round(ev.getX()), Math.round(ev.getY())); } /* @@ -5365,7 +5368,7 @@ public class WebView extends AbsoluteLayout * (x, y) denotes current focus point, which is the touch point for single touch * and the middle point for multi-touch. */ - private boolean handleTouchEventCommon(MotionEvent ev, float x, float y) { + private boolean handleTouchEventCommon(MotionEvent ev, int x, int y) { int action = ev.getAction(); long eventTime = ev.getEventTime(); @@ -5377,12 +5380,10 @@ public class WebView extends AbsoluteLayout x = Math.min(x, getViewWidth() - 1); y = Math.min(y, getViewHeightWithTitle() - 1); - float fDeltaX = mLastTouchX - x; - float fDeltaY = mLastTouchY - y; - int deltaX = (int) fDeltaX; - int deltaY = (int) fDeltaY; - int contentX = viewToContentX((int) x + mScrollX); - int contentY = viewToContentY((int) y + mScrollY); + int deltaX = mLastTouchX - x; + int deltaY = mLastTouchY - y; + int contentX = viewToContentX(x + mScrollX); + int contentY = viewToContentY(y + mScrollY); switch (action) { case MotionEvent.ACTION_DOWN: { @@ -5607,8 +5608,6 @@ public class WebView extends AbsoluteLayout mTouchMode = TOUCH_DRAG_MODE; mLastTouchX = x; mLastTouchY = y; - fDeltaX = 0.0f; - fDeltaY = 0.0f; deltaX = 0; deltaY = 0; @@ -5619,9 +5618,7 @@ public class WebView extends AbsoluteLayout // do pan boolean done = false; boolean keepScrollBarsVisible = false; - if (Math.abs(fDeltaX) < 1.0f && Math.abs(fDeltaY) < 1.0f) { - mLastTouchX = x; - mLastTouchY = y; + if (deltaX == 0 && deltaY == 0) { keepScrollBarsVisible = done = true; } else { if (mSnapScrollMode == SNAP_X || mSnapScrollMode == SNAP_Y) { @@ -5670,12 +5667,6 @@ public class WebView extends AbsoluteLayout mLastTouchY = y; } mHeldMotionless = MOTIONLESS_FALSE; - } else { - // keep the scrollbar on the screen even there is no - // scroll - mLastTouchX = x; - mLastTouchY = y; - keepScrollBarsVisible = true; } mLastTouchTime = eventTime; mUserScroll = true; @@ -5937,8 +5928,8 @@ public class WebView extends AbsoluteLayout action = MotionEvent.ACTION_DOWN; } else if (action == MotionEvent.ACTION_POINTER_UP) { // set mLastTouchX/Y to the remaining point - mLastTouchX = x; - mLastTouchY = y; + mLastTouchX = Math.round(x); + mLastTouchY = Math.round(y); } else if (action == MotionEvent.ACTION_MOVE) { // negative x or y indicate it is on the edge, skip it. if (x < 0 || y < 0) { @@ -5946,7 +5937,7 @@ public class WebView extends AbsoluteLayout } } - return handleTouchEventCommon(ev, x, y); + return handleTouchEventCommon(ev, Math.round(x), Math.round(y)); } private void cancelWebCoreTouchEvent(int x, int y, boolean removeEvents) { @@ -5967,8 +5958,8 @@ public class WebView extends AbsoluteLayout private void startTouch(float x, float y, long eventTime) { // Remember where the motion event started - mLastTouchX = x; - mLastTouchY = y; + mLastTouchX = Math.round(x); + mLastTouchY = Math.round(y); mLastTouchTime = eventTime; mVelocityTracker = VelocityTracker.obtain(); mSnapScrollMode = SNAP_NONE; @@ -6598,8 +6589,8 @@ public class WebView extends AbsoluteLayout return; } // mLastTouchX and mLastTouchY are the point in the current viewport - int contentX = viewToContentX((int) mLastTouchX + mScrollX); - int contentY = viewToContentY((int) mLastTouchY + mScrollY); + int contentX = viewToContentX(mLastTouchX + mScrollX); + int contentY = viewToContentY(mLastTouchY + mScrollY); Rect rect = new Rect(contentX - mNavSlop, contentY - mNavSlop, contentX + mNavSlop, contentY + mNavSlop); nativeSelectBestAt(rect); @@ -6630,8 +6621,8 @@ public class WebView extends AbsoluteLayout if (!inEditingMode()) { return; } - mLastTouchX = x + (float) (mWebTextView.getLeft() - mScrollX); - mLastTouchY = y + (float) (mWebTextView.getTop() - mScrollY); + mLastTouchX = Math.round(x + mWebTextView.getLeft() - mScrollX); + mLastTouchY = Math.round(y + mWebTextView.getTop() - mScrollY); mLastTouchTime = eventTime; if (!mScroller.isFinished()) { abortAnimation(); @@ -6690,8 +6681,8 @@ public class WebView extends AbsoluteLayout mTouchMode = TOUCH_DONE_MODE; switchOutDrawHistory(); // mLastTouchX and mLastTouchY are the point in the current viewport - int contentX = viewToContentX((int) mLastTouchX + mScrollX); - int contentY = viewToContentY((int) mLastTouchY + mScrollY); + int contentX = viewToContentX(mLastTouchX + mScrollX); + int contentY = viewToContentY(mLastTouchY + mScrollY); if (getSettings().supportTouchOnly()) { removeTouchHighlight(false); WebViewCore.TouchUpData touchUpData = new WebViewCore.TouchUpData(); @@ -7052,8 +7043,8 @@ public class WebView extends AbsoluteLayout || (msg.arg1 == MotionEvent.ACTION_MOVE && mPreventDefault == PREVENT_DEFAULT_NO_FROM_TOUCH_DOWN)) { cancelWebCoreTouchEvent( - viewToContentX((int) mLastTouchX + mScrollX), - viewToContentY((int) mLastTouchY + mScrollY), + viewToContentX(mLastTouchX + mScrollX), + viewToContentY(mLastTouchY + mScrollY), true); } break; @@ -7104,8 +7095,8 @@ public class WebView extends AbsoluteLayout ted.mIds = new int[1]; ted.mIds[0] = 0; ted.mPoints = new Point[1]; - ted.mPoints[0] = new Point(viewToContentX((int) mLastTouchX + mScrollX), - viewToContentY((int) mLastTouchY + mScrollY)); + ted.mPoints[0] = new Point(viewToContentX(mLastTouchX + mScrollX), + viewToContentY(mLastTouchY + mScrollY)); // metaState for long press is tricky. Should it be the // state when the press started or when the press was // released? Or some intermediary key state? For diff --git a/core/java/android/widget/DatePicker.java b/core/java/android/widget/DatePicker.java index 2c53005..af5de8a 100644 --- a/core/java/android/widget/DatePicker.java +++ b/core/java/android/widget/DatePicker.java @@ -129,27 +129,30 @@ public class DatePicker extends FrameLayout { } public DatePicker(Context context, AttributeSet attrs) { - this(context, attrs, 0); + this(context, attrs, R.attr.datePickerStyle); } public DatePicker(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); - TypedArray attributesArray = context.obtainStyledAttributes(attrs, R.styleable.DatePicker); + TypedArray attributesArray = context.obtainStyledAttributes(attrs, R.styleable.DatePicker, + defStyle, 0); boolean spinnersShown = attributesArray.getBoolean(R.styleable.DatePicker_spinnersShown, DEFAULT_SPINNERS_SHOWN); boolean calendarViewShown = attributesArray.getBoolean( R.styleable.DatePicker_calendarViewShown, DEFAULT_CALENDAR_VIEW_SHOWN); - int startYear = attributesArray - .getInt(R.styleable.DatePicker_startYear, DEFAULT_START_YEAR); + int startYear = attributesArray.getInt(R.styleable.DatePicker_startYear, + DEFAULT_START_YEAR); int endYear = attributesArray.getInt(R.styleable.DatePicker_endYear, DEFAULT_END_YEAR); String minDate = attributesArray.getString(R.styleable.DatePicker_minDate); String maxDate = attributesArray.getString(R.styleable.DatePicker_maxDate); + int layoutResourceId = attributesArray.getResourceId(R.styleable.DatePicker_layout, + R.layout.date_picker); attributesArray.recycle(); LayoutInflater inflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); - inflater.inflate(R.layout.date_picker, this, true); + inflater.inflate(layoutResourceId, this, true); OnValueChangedListener onChangeListener = new OnValueChangedListener() { public void onValueChange(NumberPicker picker, int oldVal, int newVal) { diff --git a/core/java/android/widget/NumberPicker.java b/core/java/android/widget/NumberPicker.java index 63dbfbf..ba1c0ec 100644 --- a/core/java/android/widget/NumberPicker.java +++ b/core/java/android/widget/NumberPicker.java @@ -62,8 +62,6 @@ import android.view.inputmethod.InputMethodManager; * <p> * For an example of using this widget, see {@link android.widget.TimePicker}. * </p> - * - * @attr ref android.R.styleable#NumberPicker_solidColor */ @Widget public class NumberPicker extends LinearLayout { @@ -325,6 +323,11 @@ public class NumberPicker extends LinearLayout { private final int mSolidColor; /** + * Flag indicating if this widget supports flinging. + */ + private final boolean mFlingable; + + /** * Reusable {@link Rect} instance. */ private final Rect mTempRect = new Rect(); @@ -427,9 +430,8 @@ public class NumberPicker extends LinearLayout { // process style attributes TypedArray attributesArray = context.obtainStyledAttributes(attrs, R.styleable.NumberPicker, defStyle, 0); - int orientation = attributesArray.getInt(R.styleable.NumberPicker_orientation, VERTICAL); - setOrientation(orientation); mSolidColor = attributesArray.getColor(R.styleable.NumberPicker_solidColor, 0); + mFlingable = attributesArray.getBoolean(R.styleable.NumberPicker_flingable, true); attributesArray.recycle(); // By default Linearlayout that we extend is not drawn. This is @@ -563,7 +565,7 @@ public class NumberPicker extends LinearLayout { @Override public boolean onInterceptTouchEvent(MotionEvent event) { - if (!isEnabled()) { + if (!isEnabled() || !mFlingable) { return false; } switch (event.getActionMasked()) { diff --git a/core/java/android/widget/RemoteViews.java b/core/java/android/widget/RemoteViews.java index c336ccb..482ce56 100644 --- a/core/java/android/widget/RemoteViews.java +++ b/core/java/android/widget/RemoteViews.java @@ -1277,18 +1277,6 @@ public class RemoteViews implements Parcelable, Filter { /** * Equivalent to calling {@link android.widget.AbsListView#setRemoteViewsAdapter(Intent)}. * - * @param viewId The id of the view whose text should change - * @param intent The intent of the service which will be - * providing data to the RemoteViewsAdapter - */ - public void setRemoteAdapter(int viewId, Intent intent) { - // Do nothing. This method will be removed after all widgets have been updated to the - // new API. - } - - /** - * Equivalent to calling {@link android.widget.AbsListView#setRemoteViewsAdapter(Intent)}. - * * @param appWidgetId The id of the app widget which contains the specified view * @param viewId The id of the view whose text should change * @param intent The intent of the service which will be diff --git a/core/java/android/widget/TimePicker.java b/core/java/android/widget/TimePicker.java index 8f3442e..26fbbbd 100644 --- a/core/java/android/widget/TimePicker.java +++ b/core/java/android/widget/TimePicker.java @@ -20,6 +20,7 @@ import com.android.internal.R; import android.annotation.Widget; import android.content.Context; +import android.content.res.TypedArray; import android.os.Parcel; import android.os.Parcelable; import android.util.AttributeSet; @@ -31,50 +32,55 @@ import java.text.DateFormatSymbols; import java.util.Calendar; /** - * A view for selecting the time of day, in either 24 hour or AM/PM mode. - * - * The hour, each minute digit, and AM/PM (if applicable) can be conrolled by - * vertical spinners. - * - * The hour can be entered by keyboard input. Entering in two digit hours - * can be accomplished by hitting two digits within a timeout of about a - * second (e.g. '1' then '2' to select 12). - * - * The minutes can be entered by entering single digits. - * - * Under AM/PM mode, the user can hit 'a', 'A", 'p' or 'P' to pick. - * - * For a dialog using this view, see {@link android.app.TimePickerDialog}. - * - * <p>See the <a href="{@docRoot}resources/tutorials/views/hello-timepicker.html">Time Picker - * tutorial</a>.</p> + * A view for selecting the time of day, in either 24 hour or AM/PM mode. The + * hour, each minute digit, and AM/PM (if applicable) can be conrolled by + * vertical spinners. The hour can be entered by keyboard input. Entering in two + * digit hours can be accomplished by hitting two digits within a timeout of + * about a second (e.g. '1' then '2' to select 12). The minutes can be entered + * by entering single digits. Under AM/PM mode, the user can hit 'a', 'A", 'p' + * or 'P' to pick. For a dialog using this view, see + * {@link android.app.TimePickerDialog}. + *<p> + * See the <a href="{@docRoot} + * resources/tutorials/views/hello-timepicker.html">Time Picker tutorial</a>. + * </p> */ @Widget public class TimePicker extends FrameLayout { private static final boolean DEFAULT_ENABLED_STATE = true; + private static final int HOURS_IN_HALF_DAY = 12; + /** - * A no-op callback used in the constructor to avoid null checks - * later in the code. + * A no-op callback used in the constructor to avoid null checks later in + * the code. */ private static final OnTimeChangedListener NO_OP_CHANGE_LISTENER = new OnTimeChangedListener() { public void onTimeChanged(TimePicker view, int hourOfDay, int minute) { } }; - + // state - private int mCurrentHour = 0; // 0-23 - private int mCurrentMinute = 0; // 0-59 - private Boolean mIs24HourView = false; + private boolean mIs24HourView; + private boolean mIsAm; // ui components private final NumberPicker mHourSpinner; + private final NumberPicker mMinuteSpinner; + private final NumberPicker mAmPmSpinner; + private final TextView mDivider; + // Note that the legacy implementation of the TimePicker is + // using a button for toggling between AM/PM while the new + // version uses a NumberPicker spinner. Therefore the code + // accommodates these two cases to be backwards compatible. + private final Button mAmPmButton; + private final String[] mAmPmStrings; private boolean mIsEnabled = DEFAULT_ENABLED_STATE; @@ -98,45 +104,51 @@ public class TimePicker extends FrameLayout { public TimePicker(Context context) { this(context, null); } - + public TimePicker(Context context, AttributeSet attrs) { - this(context, attrs, 0); + this(context, attrs, R.attr.timePickerStyle); } public TimePicker(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); - LayoutInflater inflater = - (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); - inflater.inflate(R.layout.time_picker, - this, // we are the parent - true); + // process style attributes + TypedArray attributesArray = context.obtainStyledAttributes( + attrs, R.styleable.TimePicker, defStyle, 0); + int layoutResourceId = attributesArray.getResourceId( + R.styleable.TimePicker_layout, R.layout.time_picker); + attributesArray.recycle(); + + LayoutInflater inflater = (LayoutInflater) context.getSystemService( + Context.LAYOUT_INFLATER_SERVICE); + inflater.inflate(layoutResourceId, this, true); // hour mHourSpinner = (NumberPicker) findViewById(R.id.hour); mHourSpinner.setOnValueChangedListener(new NumberPicker.OnValueChangedListener() { public void onValueChange(NumberPicker spinner, int oldVal, int newVal) { - mCurrentHour = newVal; - if (!mIs24HourView) { - // adjust from [1-12] to [0-11] internally, with the times - // written "12:xx" being the start of the half-day - if (mCurrentHour == 12) { - mCurrentHour = 0; - } - if (!mIsAm) { - // PM means 12 hours later than nominal - mCurrentHour += 12; + if (!is24HourView()) { + int minValue = mHourSpinner.getMinValue(); + int maxValue = mHourSpinner.getMaxValue(); + // toggle AM/PM if the spinner has wrapped and not in 24 + // format + if ((oldVal == maxValue && newVal == minValue) + || (oldVal == minValue && newVal == maxValue)) { + mIsAm = !mIsAm; + updateAmPmControl(); } } onTimeChanged(); } }); - // divider + // divider (only for the new widget style) mDivider = (TextView) findViewById(R.id.divider); - mDivider.setText(R.string.time_picker_separator); + if (mDivider != null) { + mDivider.setText(R.string.time_picker_separator); + } - // digits of minute + // minute mMinuteSpinner = (NumberPicker) findViewById(R.id.minute); mMinuteSpinner.setMinValue(0); mMinuteSpinner.setMaxValue(59); @@ -144,28 +156,25 @@ public class TimePicker extends FrameLayout { mMinuteSpinner.setFormatter(NumberPicker.TWO_DIGIT_FORMATTER); mMinuteSpinner.setOnValueChangedListener(new NumberPicker.OnValueChangedListener() { public void onValueChange(NumberPicker spinner, int oldVal, int newVal) { - mCurrentMinute = newVal; - onTimeChanged(); - } - }); - - // am/pm - mAmPmSpinner = (NumberPicker) findViewById(R.id.amPm); - mAmPmSpinner.setOnValueChangedListener(new OnValueChangedListener() { - public void onValueChange(NumberPicker picker, int oldVal, int newVal) { - picker.requestFocus(); - if (mIsAm) { - // Currently AM switching to PM - if (mCurrentHour < 12) { - mCurrentHour += 12; + int minValue = mMinuteSpinner.getMinValue(); + int maxValue = mMinuteSpinner.getMaxValue(); + if (oldVal == maxValue && newVal == minValue) { + int currentHour = mHourSpinner.getValue(); + // toggle AM/PM if the spinner is about to wrap + if (!is24HourView() && currentHour == mHourSpinner.getMaxValue()) { + mIsAm = !mIsAm; + updateAmPmControl(); } - } else { - // Currently PM switching to AM - if (mCurrentHour >= 12) { - mCurrentHour -= 12; + mHourSpinner.setValue(currentHour + 1); + } else if (oldVal == minValue && newVal == maxValue) { + int currentHour = mHourSpinner.getValue(); + // toggle AM/PM if the spinner is about to wrap + if (!is24HourView() && currentHour == mHourSpinner.getMinValue()) { + mIsAm = !mIsAm; + updateAmPmControl(); } + mHourSpinner.setValue(currentHour - 1); } - mIsAm = !mIsAm; onTimeChanged(); } }); @@ -173,17 +182,44 @@ public class TimePicker extends FrameLayout { /* Get the localized am/pm strings and use them in the spinner */ mAmPmStrings = new DateFormatSymbols().getAmPmStrings(); - // now that the hour/minute picker objects have been initialized, set - // the hour range properly based on the 12/24 hour display mode. - configurePickerRanges(); + // am/pm + View amPmView = findViewById(R.id.amPm); + if (amPmView instanceof Button) { + mAmPmSpinner = null; + mAmPmButton = (Button) amPmView; + mAmPmButton.setOnClickListener(new OnClickListener() { + public void onClick(View button) { + button.requestFocus(); + mIsAm = !mIsAm; + updateAmPmControl(); + } + }); + } else { + mAmPmButton = null; + mAmPmSpinner = (NumberPicker) amPmView; + mAmPmSpinner.setMinValue(0); + mAmPmSpinner.setMaxValue(1); + mAmPmSpinner.setDisplayedValues(mAmPmStrings); + mAmPmSpinner.setOnValueChangedListener(new OnValueChangedListener() { + public void onValueChange(NumberPicker picker, int oldVal, int newVal) { + picker.requestFocus(); + mIsAm = !mIsAm; + updateAmPmControl(); + } + }); + } + + // update controls to initial state + updateHourControl(); + updateAmPmControl(); // initialize to current time - Calendar cal = Calendar.getInstance(); + Calendar calendar = Calendar.getInstance(); setOnTimeChangedListener(NO_OP_CHANGE_LISTENER); - // by default we're not in 24 hour mode - setCurrentHour(cal.get(Calendar.HOUR_OF_DAY)); - setCurrentMinute(cal.get(Calendar.MINUTE)); + // set to current time + setCurrentHour(calendar.get(Calendar.HOUR_OF_DAY)); + setCurrentMinute(calendar.get(Calendar.MINUTE)); if (!isEnabled()) { setEnabled(false); @@ -197,9 +233,15 @@ public class TimePicker extends FrameLayout { } super.setEnabled(enabled); mMinuteSpinner.setEnabled(enabled); - mDivider.setEnabled(enabled); + if (mDivider != null) { + mDivider.setEnabled(enabled); + } mHourSpinner.setEnabled(enabled); - mAmPmSpinner.setEnabled(enabled); + if (mAmPmSpinner != null) { + mAmPmSpinner.setEnabled(enabled); + } else { + mAmPmButton.setEnabled(enabled); + } mIsEnabled = enabled; } @@ -214,6 +256,7 @@ public class TimePicker extends FrameLayout { private static class SavedState extends BaseSavedState { private final int mHour; + private final int mMinute; private SavedState(Parcelable superState, int hour, int minute) { @@ -221,7 +264,7 @@ public class TimePicker extends FrameLayout { mHour = hour; mMinute = minute; } - + private SavedState(Parcel in) { super(in); mHour = in.readInt(); @@ -244,8 +287,7 @@ public class TimePicker extends FrameLayout { } @SuppressWarnings("unused") - public static final Parcelable.Creator<SavedState> CREATOR - = new Creator<SavedState>() { + public static final Parcelable.Creator<SavedState> CREATOR = new Creator<SavedState>() { public SavedState createFromParcel(Parcel in) { return new SavedState(in); } @@ -259,7 +301,7 @@ public class TimePicker extends FrameLayout { @Override protected Parcelable onSaveInstanceState() { Parcelable superState = super.onSaveInstanceState(); - return new SavedState(superState, mCurrentHour, mCurrentMinute); + return new SavedState(superState, getCurrentHour(), getCurrentMinute()); } @Override @@ -272,6 +314,7 @@ public class TimePicker extends FrameLayout { /** * Set the callback that indicates the time has been adjusted by the user. + * * @param onTimeChangedListener the callback, should not be null. */ public void setOnTimeChangedListener(OnTimeChangedListener onTimeChangedListener) { @@ -279,30 +322,58 @@ public class TimePicker extends FrameLayout { } /** - * @return The current hour (0-23). + * @return The current hour in the range (0-23). */ public Integer getCurrentHour() { - return mCurrentHour; + int currentHour = mHourSpinner.getValue(); + if (is24HourView() || mIsAm) { + return currentHour; + } else { + return (currentHour == HOURS_IN_HALF_DAY) ? 0 : currentHour + HOURS_IN_HALF_DAY; + } } /** * Set the current hour. */ public void setCurrentHour(Integer currentHour) { - this.mCurrentHour = currentHour; - updateHourDisplay(); + // why was Integer used in the first place? + if (currentHour == null || currentHour == getCurrentHour()) { + return; + } + if (!is24HourView()) { + // convert [0,23] ordinal to wall clock display + if (currentHour > HOURS_IN_HALF_DAY) { + currentHour -= HOURS_IN_HALF_DAY; + mIsAm = false; + } else { + if (currentHour == 0) { + currentHour = HOURS_IN_HALF_DAY; + } + mIsAm = true; + } + updateAmPmControl(); + } + mHourSpinner.setValue(currentHour); + onTimeChanged(); } /** * Set whether in 24 hour or AM/PM mode. + * * @param is24HourView True = 24 hour mode. False = AM/PM. */ public void setIs24HourView(Boolean is24HourView) { - if (mIs24HourView != is24HourView) { - mIs24HourView = is24HourView; - configurePickerRanges(); - updateHourDisplay(); + if (mIs24HourView == is24HourView) { + return; } + mIs24HourView = is24HourView; + // cache the current hour since spinner range changes + int currentHour = getCurrentHour(); + updateHourControl(); + // set value after spinner range is updated + setCurrentHour(currentHour); + updateAmPmControl(); } /** @@ -311,20 +382,23 @@ public class TimePicker extends FrameLayout { public boolean is24HourView() { return mIs24HourView; } - + /** * @return The current minute. */ public Integer getCurrentMinute() { - return mCurrentMinute; + return mMinuteSpinner.getValue(); } /** * Set the current minute (0-59). */ public void setCurrentMinute(Integer currentMinute) { - this.mCurrentMinute = currentMinute; - updateMinuteDisplay(); + if (currentMinute == getCurrentMinute()) { + return; + } + mMinuteSpinner.setValue(currentMinute); + onTimeChanged(); } @Override @@ -332,39 +406,34 @@ public class TimePicker extends FrameLayout { return mHourSpinner.getBaseline(); } - /** - * Set the state of the spinners appropriate to the current hour. - */ - private void updateHourDisplay() { - int currentHour = mCurrentHour; - if (!mIs24HourView) { - // convert [0,23] ordinal to wall clock display - if (currentHour > 12) { - currentHour -= 12; - } else if (currentHour == 0) { - currentHour = 12; - } - } - mHourSpinner.setValue(currentHour); - mIsAm = mCurrentHour < 12; - mAmPmSpinner.setValue(mIsAm ? Calendar.AM : Calendar.PM); - onTimeChanged(); - } - - private void configurePickerRanges() { - if (mIs24HourView) { + private void updateHourControl() { + if (is24HourView()) { mHourSpinner.setMinValue(0); mHourSpinner.setMaxValue(23); mHourSpinner.setFormatter(NumberPicker.TWO_DIGIT_FORMATTER); - mAmPmSpinner.setVisibility(View.GONE); } else { mHourSpinner.setMinValue(1); mHourSpinner.setMaxValue(12); mHourSpinner.setFormatter(null); - mAmPmSpinner.setVisibility(View.VISIBLE); - mAmPmSpinner.setMinValue(0); - mAmPmSpinner.setMaxValue(1); - mAmPmSpinner.setDisplayedValues(mAmPmStrings); + } + } + + private void updateAmPmControl() { + if (is24HourView()) { + if (mAmPmSpinner != null) { + mAmPmSpinner.setVisibility(View.GONE); + } else { + mAmPmButton.setVisibility(View.GONE); + } + } else { + int index = mIsAm ? Calendar.AM : Calendar.PM; + if (mAmPmSpinner != null) { + mAmPmSpinner.setValue(index); + mAmPmSpinner.setVisibility(View.VISIBLE); + } else { + mAmPmButton.setText(mAmPmStrings[index]); + mAmPmButton.setVisibility(View.VISIBLE); + } } } @@ -373,12 +442,4 @@ public class TimePicker extends FrameLayout { mOnTimeChangedListener.onTimeChanged(this, getCurrentHour(), getCurrentMinute()); } } - - /** - * Set the state of the spinners appropriate to the current minute. - */ - private void updateMinuteDisplay() { - mMinuteSpinner.setValue(mCurrentMinute); - onTimeChanged(); - } } diff --git a/core/java/android/widget/Toast.java b/core/java/android/widget/Toast.java index 29ca49a..a8f9f62 100644 --- a/core/java/android/widget/Toast.java +++ b/core/java/android/widget/Toast.java @@ -33,6 +33,8 @@ import android.view.WindowManagerImpl; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityManager; +import java.lang.ref.WeakReference; + /** * A toast is a view containing a quick little message for the user. The toast class * helps you create and show those. @@ -67,7 +69,6 @@ public class Toast { */ public static final int LENGTH_LONG = 1; - final Handler mHandler = new Handler(); final Context mContext; final TN mTN; int mDuration; @@ -87,7 +88,7 @@ public class Toast { */ public Toast(Context context) { mContext = context; - mTN = new TN(); + mTN = new TN(this); mY = context.getResources().getDimensionPixelSize( com.android.internal.R.dimen.toast_y_offset); } @@ -101,13 +102,10 @@ public class Toast { } INotificationManager service = getService(); - String pkg = mContext.getPackageName(); - TN tn = mTN; - try { - service.enqueueToast(pkg, tn, mDuration); + service.enqueueToast(pkg, mTN, mDuration); } catch (RemoteException e) { // Empty } @@ -313,7 +311,9 @@ public class Toast { return sService; } - private class TN extends ITransientNotification.Stub { + private static class TN extends ITransientNotification.Stub { + final Handler mHandler = new Handler(); + final Runnable mShow = new Runnable() { public void run() { handleShow(); @@ -327,10 +327,12 @@ public class Toast { }; private final WindowManager.LayoutParams mParams = new WindowManager.LayoutParams(); + private final WeakReference<Toast> mToast; WindowManagerImpl mWM; - TN() { + TN(Toast toast) { + mToast = new WeakReference<Toast>(toast); // XXX This should be changed to use a Dialog, with a Theme.Toast // defined that sets up the layout params appropriately. final WindowManager.LayoutParams params = mParams; @@ -362,49 +364,53 @@ public class Toast { } public void handleShow() { - if (localLOGV) Log.v(TAG, "HANDLE SHOW: " + this + " mView=" + mView - + " mNextView=" + mNextView); - if (mView != mNextView) { - // remove the old view if necessary - handleHide(); - mView = mNextView; - mWM = WindowManagerImpl.getDefault(); - final int gravity = mGravity; - mParams.gravity = gravity; - if ((gravity & Gravity.HORIZONTAL_GRAVITY_MASK) == Gravity.FILL_HORIZONTAL) { - mParams.horizontalWeight = 1.0f; + final Toast toast = mToast.get(); + if (toast != null) { + if (localLOGV) Log.v(TAG, "HANDLE SHOW: " + this + " mView=" + toast.mView + + " mNextView=" + toast.mNextView); + if (toast.mView != toast.mNextView) { + // remove the old view if necessary + handleHide(); + toast.mView = toast.mNextView; + mWM = WindowManagerImpl.getDefault(); + final int gravity = toast.mGravity; + mParams.gravity = gravity; + if ((gravity & Gravity.HORIZONTAL_GRAVITY_MASK) == Gravity.FILL_HORIZONTAL) { + mParams.horizontalWeight = 1.0f; + } + if ((gravity & Gravity.VERTICAL_GRAVITY_MASK) == Gravity.FILL_VERTICAL) { + mParams.verticalWeight = 1.0f; + } + mParams.x = toast.mX; + mParams.y = toast.mY; + mParams.verticalMargin = toast.mVerticalMargin; + mParams.horizontalMargin = toast.mHorizontalMargin; + if (toast.mView.getParent() != null) { + if (localLOGV) Log.v(TAG, "REMOVE! " + toast.mView + " in " + this); + mWM.removeView(toast.mView); + } + if (localLOGV) Log.v(TAG, "ADD! " + toast.mView + " in " + this); + mWM.addView(toast.mView, mParams); + toast.trySendAccessibilityEvent(); } - if ((gravity & Gravity.VERTICAL_GRAVITY_MASK) == Gravity.FILL_VERTICAL) { - mParams.verticalWeight = 1.0f; - } - mParams.x = mX; - mParams.y = mY; - mParams.verticalMargin = mVerticalMargin; - mParams.horizontalMargin = mHorizontalMargin; - if (mView.getParent() != null) { - if (localLOGV) Log.v( - TAG, "REMOVE! " + mView + " in " + this); - mWM.removeView(mView); - } - if (localLOGV) Log.v(TAG, "ADD! " + mView + " in " + this); - mWM.addView(mView, mParams); - trySendAccessibilityEvent(); } } public void handleHide() { - if (localLOGV) Log.v(TAG, "HANDLE HIDE: " + this + " mView=" + mView); - if (mView != null) { - // note: checking parent() just to make sure the view has - // been added... i have seen cases where we get here when - // the view isn't yet added, so let's try not to crash. - if (mView.getParent() != null) { - if (localLOGV) Log.v( - TAG, "REMOVE! " + mView + " in " + this); - mWM.removeView(mView); + final Toast toast = mToast.get(); + if (toast != null) { + if (localLOGV) Log.v(TAG, "HANDLE HIDE: " + this + " mView=" + toast.mView); + if (toast.mView != null) { + // note: checking parent() just to make sure the view has + // been added... i have seen cases where we get here when + // the view isn't yet added, so let's try not to crash. + if (toast.mView.getParent() != null) { + if (localLOGV) Log.v(TAG, "REMOVE! " + toast.mView + " in " + this); + mWM.removeView(toast.mView); + } + + toast.mView = null; } - - mView = null; } } } diff --git a/core/java/com/android/internal/app/PlatLogoActivity.java b/core/java/com/android/internal/app/PlatLogoActivity.java index e1c5564..9fbbb3d 100644 --- a/core/java/com/android/internal/app/PlatLogoActivity.java +++ b/core/java/com/android/internal/app/PlatLogoActivity.java @@ -29,11 +29,11 @@ public class PlatLogoActivity extends Activity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - mToast = Toast.makeText(this, "Zombie art by Jack Larson", Toast.LENGTH_SHORT); + mToast = Toast.makeText(this, "REZZZZZZZ...", Toast.LENGTH_SHORT); ImageView content = new ImageView(this); content.setImageResource(com.android.internal.R.drawable.platlogo); - content.setScaleType(ImageView.ScaleType.FIT_CENTER); + content.setScaleType(ImageView.ScaleType.CENTER_INSIDE); setContentView(content); } diff --git a/core/jni/AndroidRuntime.cpp b/core/jni/AndroidRuntime.cpp index f023e94..342b884 100644 --- a/core/jni/AndroidRuntime.cpp +++ b/core/jni/AndroidRuntime.cpp @@ -568,6 +568,7 @@ int AndroidRuntime::startVm(JavaVM** pJavaVM, JNIEnv** pEnv) char jniOptsBuf[sizeof("-Xjniopts:")-1 + PROPERTY_VALUE_MAX]; char heapstartsizeOptsBuf[sizeof("-Xms")-1 + PROPERTY_VALUE_MAX]; char heapsizeOptsBuf[sizeof("-Xmx")-1 + PROPERTY_VALUE_MAX]; + char heapgrowthlimitOptsBuf[sizeof("-XX:HeapGrowthLimit=")-1 + PROPERTY_VALUE_MAX]; char extraOptsBuf[PROPERTY_VALUE_MAX]; char* stackTraceFile = NULL; bool checkJni = false; @@ -659,6 +660,13 @@ int AndroidRuntime::startVm(JavaVM** pJavaVM, JNIEnv** pEnv) opt.optionString = heapsizeOptsBuf; mOptions.add(opt); + strcpy(heapgrowthlimitOptsBuf, "-XX:HeapGrowthLimit="); + property_get("dalvik.vm.heapgrowthlimit", heapgrowthlimitOptsBuf+20, ""); + if (heapgrowthlimitOptsBuf[20] != '\0') { + opt.optionString = heapgrowthlimitOptsBuf; + mOptions.add(opt); + } + /* * Enable or disable dexopt features, such as bytecode verification and * calculation of register maps for precise GC. diff --git a/core/res/res/drawable-nodpi/platlogo.png b/core/res/res/drawable-nodpi/platlogo.png Binary files differindex e5af356..67e6ac3 100644 --- a/core/res/res/drawable-nodpi/platlogo.png +++ b/core/res/res/drawable-nodpi/platlogo.png diff --git a/core/res/res/layout/date_picker.xml b/core/res/res/layout/date_picker.xml index e9663b1..1649466 100644 --- a/core/res/res/layout/date_picker.xml +++ b/core/res/res/layout/date_picker.xml @@ -40,10 +40,10 @@ <!-- Month --> <NumberPicker android:id="@+id/month" - android:layout_width="48dip" + android:layout_width="80dip" android:layout_height="wrap_content" - android:layout_marginLeft="22dip" - android:layout_marginRight="22dip" + android:layout_marginLeft="1dip" + android:layout_marginRight="1dip" android:focusable="true" android:focusableInTouchMode="true" /> @@ -51,10 +51,10 @@ <!-- Day --> <NumberPicker android:id="@+id/day" - android:layout_width="48dip" + android:layout_width="80dip" android:layout_height="wrap_content" - android:layout_marginLeft="22dip" - android:layout_marginRight="22dip" + android:layout_marginLeft="1dip" + android:layout_marginRight="1dip" android:focusable="true" android:focusableInTouchMode="true" /> @@ -62,10 +62,10 @@ <!-- Year --> <NumberPicker android:id="@+id/year" - android:layout_width="48dip" + android:layout_width="95dip" android:layout_height="wrap_content" - android:layout_marginLeft="22dip" - android:layout_marginRight="22dip" + android:layout_marginLeft="1dip" + android:layout_marginRight="1dip" android:focusable="true" android:focusableInTouchMode="true" /> @@ -81,6 +81,7 @@ android:layout_weight="1" android:focusable="true" android:focusableInTouchMode="true" + android:visibility="gone" /> </LinearLayout> diff --git a/core/res/res/layout/date_picker_holo.xml b/core/res/res/layout/date_picker_holo.xml new file mode 100644 index 0000000..026cbfb --- /dev/null +++ b/core/res/res/layout/date_picker_holo.xml @@ -0,0 +1,86 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +** +** Copyright 2011, 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. +*/ +--> + +<!-- Layout of date picker--> + +<!-- Warning: everything within the "pickers" layout is removed and re-ordered + depending on the date format selected by the user. +--> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:layout_gravity="center_horizontal" + android:orientation="horizontal" + android:gravity="center"> + + <LinearLayout android:id="@+id/pickers" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginRight="22dip" + android:layout_weight="1" + android:orientation="horizontal" + android:gravity="center"> + + <!-- Month --> + <NumberPicker + android:id="@+id/month" + android:layout_width="48dip" + android:layout_height="wrap_content" + android:layout_marginLeft="22dip" + android:layout_marginRight="22dip" + android:focusable="true" + android:focusableInTouchMode="true" + /> + + <!-- Day --> + <NumberPicker + android:id="@+id/day" + android:layout_width="48dip" + android:layout_height="wrap_content" + android:layout_marginLeft="22dip" + android:layout_marginRight="22dip" + android:focusable="true" + android:focusableInTouchMode="true" + /> + + <!-- Year --> + <NumberPicker + android:id="@+id/year" + android:layout_width="48dip" + android:layout_height="wrap_content" + android:layout_marginLeft="22dip" + android:layout_marginRight="22dip" + android:focusable="true" + android:focusableInTouchMode="true" + /> + + </LinearLayout> + + <!-- calendar view --> + <CalendarView + android:id="@+id/calendar_view" + android:layout_width="245dip" + android:layout_height="280dip" + android:layout_marginLeft="22dip" + android:layout_weight="1" + android:focusable="true" + android:focusableInTouchMode="true" + /> + +</LinearLayout> diff --git a/core/res/res/layout/time_picker.xml b/core/res/res/layout/time_picker.xml index 382b2f6..df46db4 100644 --- a/core/res/res/layout/time_picker.xml +++ b/core/res/res/layout/time_picker.xml @@ -28,42 +28,33 @@ <!-- hour --> <NumberPicker android:id="@+id/hour" - android:layout_width="48dip" + android:layout_width="70dip" android:layout_height="wrap_content" - android:layout_marginLeft="22dip" - android:layout_marginRight="20dip" android:focusable="true" android:focusableInTouchMode="true" /> - <!-- divider --> - <TextView - android:id="@+id/divider" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_gravity="center_vertical" - /> - <!-- minute --> <NumberPicker android:id="@+id/minute" - android:layout_width="48dip" + android:layout_width="70dip" android:layout_height="wrap_content" - android:layout_marginLeft="20dip" - android:layout_marginRight="22dip" + android:layout_marginLeft="5dip" android:focusable="true" android:focusableInTouchMode="true" /> <!-- AM / PM --> - <NumberPicker + <Button android:id="@+id/amPm" - android:layout_width="48dip" + android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginLeft="22dip" - android:layout_marginRight="22dip" - android:focusable="true" - android:focusableInTouchMode="true" + android:layout_marginTop="43dip" + android:layout_marginLeft="5dip" + android:paddingLeft="20dip" + android:paddingRight="20dip" + style="?android:attr/textAppearanceLargeInverse" + android:textColor="@android:color/primary_text_light_nodisable" /> </LinearLayout> diff --git a/core/res/res/layout/time_picker_holo.xml b/core/res/res/layout/time_picker_holo.xml new file mode 100644 index 0000000..ca6fe2d --- /dev/null +++ b/core/res/res/layout/time_picker_holo.xml @@ -0,0 +1,69 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +** +** Copyright 2011, 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. +*/ +--> + +<!-- Layout of time picker --> + +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:orientation="horizontal" + android:layout_gravity="center_horizontal" + android:layout_width="wrap_content" + android:layout_height="wrap_content"> + + <!-- hour --> + <NumberPicker + android:id="@+id/hour" + android:layout_width="48dip" + android:layout_height="wrap_content" + android:layout_marginLeft="22dip" + android:layout_marginRight="20dip" + android:focusable="true" + android:focusableInTouchMode="true" + /> + + <!-- divider --> + <TextView + android:id="@+id/divider" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center_vertical" + /> + + <!-- minute --> + <NumberPicker + android:id="@+id/minute" + android:layout_width="48dip" + android:layout_height="wrap_content" + android:layout_marginLeft="20dip" + android:layout_marginRight="22dip" + android:focusable="true" + android:focusableInTouchMode="true" + /> + + <!-- AM / PM --> + <NumberPicker + android:id="@+id/amPm" + android:layout_width="48dip" + android:layout_height="wrap_content" + android:layout_marginLeft="22dip" + android:layout_marginRight="22dip" + android:focusable="true" + android:focusableInTouchMode="true" + /> + +</LinearLayout> diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml index de233c8..457baa6 100755 --- a/core/res/res/values/attrs.xml +++ b/core/res/res/values/attrs.xml @@ -534,6 +534,12 @@ <!-- The CalndarView style. --> <attr name="calendarViewStyle" format="reference" /> + <!-- The TimePicker style. --> + <attr name="timePickerStyle" format="reference" /> + + <!-- The DatePicker style. --> + <attr name="datePickerStyle" format="reference" /> + <!-- Fast scroller styles --> <eat-comment /> @@ -2869,6 +2875,7 @@ <!-- Gravity setting for positioning the currently selected item. --> <attr name="gravity" /> </declare-styleable> + <declare-styleable name="DatePicker"> <!-- The first year (inclusive), for example "1940". --> <attr name="startYear" format="integer" /> @@ -2882,6 +2889,8 @@ <attr name="minDate" format="string" /> <!-- The minimal date shown by this calendar view in mm/dd/yyyy format. --> <attr name="maxDate" format="string" /> + <!-- @hide The layout of the time picker. --> + <attr name="layout" /> </declare-styleable> <declare-styleable name="TwoLineListItem"> @@ -3080,9 +3089,20 @@ </declare-styleable> <declare-styleable name="NumberPicker"> - <attr name="orientation" /> - <!-- Color for the solid color background if such for optimized rendering. --> + <!-- @hide Color for the solid color background if such for optimized rendering. --> <attr name="solidColor" format="color|reference" /> + <!-- @hide Whether the number picker supports fligning. --> + <attr name="flingable" format="boolean" /> + </declare-styleable> + + <declare-styleable name="TimePicker"> + <!-- @hide The layout of the time picker. --> + <attr name="layout" /> + </declare-styleable> + + <declare-styleable name="DatePicker"> + <!-- @hide The layout of the time picker. --> + <attr name="layout" /> </declare-styleable> <!-- ========================= --> diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml index 1b47b54..a30e316 100644 --- a/core/res/res/values/public.xml +++ b/core/res/res/values/public.xml @@ -1426,6 +1426,8 @@ <public type="attr" name="fastScrollTextColor" /> <public type="attr" name="largeHeap" /> <public type="attr" name="windowCloseOnTouchOutside" /> + <public type="attr" name="datePickerStyle" /> + <public type="attr" name="calendarViewStyle" /> <!-- A simple fade-in animation. --> <public type="animator" name="fade_in" id="0x010b0000" /> @@ -1627,21 +1629,15 @@ <public type="style" name="Holo.Light.ButtonBar.AlertDialog" /> <public type="style" name="Holo.SegmentedButton" /> <public type="style" name="Holo.Light.SegmentedButton" /> - <public type="style" name="Widget.ImageButton.NumberPickerUpButton" /> - <public type="style" name="Widget.EditText.NumberPickerInputText" /> - <public type="style" name="Widget.ImageButton.NumberPickerDownButton" /> - <public type="style" name="Widget.Holo.ImageButton.NumberPickerUpButton" /> - <public type="style" name="Widget.Holo.EditText.NumberPickerInputText" /> - <public type="style" name="Widget.Holo.ImageButton.NumberPickerDownButton" /> - <public type="style" name="Widget.Holo.Light.ImageButton.NumberPickerUpButton" /> - <public type="style" name="Widget.Holo.Light.EditText.NumberPickerInputText" /> - <public type="style" name="Widget.Holo.Light.ImageButton.NumberPickerDownButton" /> <public type="style" name="Widget.CalendarView" /> <public type="style" name="Widget.Holo.CalendarView" /> <public type="style" name="Widget.Holo.Light.CalendarView" /> + <public type="style" name="Widget.DatePicker" /> + <public type="style" name="Widget.Holo.DatePicker" /> <public type="string" name="selectTextMode" /> <!-- Default icon for applications that don't specify an icon. --> <public type="mipmap" name="sym_def_app_icon" id="0x010d0000" /> + </resources> diff --git a/core/res/res/values/styles.xml b/core/res/res/values/styles.xml index 16c80d0..b7b43e0 100644 --- a/core/res/res/values/styles.xml +++ b/core/res/res/values/styles.xml @@ -489,7 +489,16 @@ <item name="android:orientation">vertical</item> <item name="android:fadingEdge">vertical</item> <item name="android:fadingEdgeLength">50dip</item> - <item name="android:solidColor">@android:color/transparent</item> + <item name="android:flingable">false</item> + </style> + + <style name="Widget.TimePicker"> + <item name="android:layout">@android:layout/time_picker</item> + </style> + + <style name="Widget.DatePicker"> + <item name="android:layout">@android:layout/date_picker</item> + <item name="android:calendarViewShown">false</item> </style> <style name="Widget.ImageButton.NumberPickerUpButton"> @@ -1502,6 +1511,20 @@ <item name="android:background">@android:drawable/btn_default_holo_dark</item> </style> + <style name="Widget.Holo.NumberPicker" parent="Widget.NumberPicker"> + <item name="android:solidColor">@android:color/transparent</item> + <item name="android:flingable">true</item> + </style> + + <style name="Widget.Holo.TimePicker" parent="Widget.TimePicker"> + <item name="android:layout">@android:layout/time_picker_holo</item> + </style> + + <style name="Widget.Holo.DatePicker" parent="Widget.DatePicker"> + <item name="android:layout">@android:layout/date_picker_holo</item> + <item name="android:calendarViewShown">true</item> + </style> + <style name="Widget.Holo.ImageButton.NumberPickerUpButton"> <item name="android:background">@null</item> <item name="android:src">@android:drawable/numberpicker_up_btn_holo_dark</item> @@ -1870,6 +1893,15 @@ <item name="android:weekDayTextAppearance">@android:style/TextAppearance.Holo.Light.CalendarViewWeekDayView</item> </style> + <style name="Widget.Holo.Light.NumberPicker" parent="Widget.Holo.NumberPicker"> + </style> + + <style name="Widget.Holo.Light.TimePicker" parent="Widget.Holo.TimePicker"> + </style> + + <style name="Widget.Holo.Light.DatePicker" parent="Widget.Holo.DatePicker"> + </style> + <style name="Widget.Holo.Light.ImageButton.NumberPickerUpButton" parent="Widget.Holo.ImageButton.NumberPickerUpButton"> <item name="android:src">@android:drawable/numberpicker_up_btn_holo_light</item> </style> diff --git a/core/res/res/values/themes.xml b/core/res/res/values/themes.xml index b257a73..2f8cffc 100644 --- a/core/res/res/values/themes.xml +++ b/core/res/res/values/themes.xml @@ -290,6 +290,12 @@ <!-- CalendarView style--> <item name="calendarViewStyle">@style/Widget.CalendarView</item> + <!-- TimePicker style --> + <item name="timePickerStyle">@style/Widget.TimePicker</item> + + <!-- DatePicker style --> + <item name="datePickerStyle">@style/Widget.DatePicker</item> + <item name="fastScrollThumbDrawable">@android:drawable/scrollbar_handle_accelerated_anim2</item> <item name="fastScrollTrackDrawable">@null</item> <item name="fastScrollPreviewBackgroundRight">@android:drawable/menu_submenu_background</item> @@ -978,10 +984,17 @@ <item name="numberPickerUpButtonStyle">@style/Widget.Holo.ImageButton.NumberPickerUpButton</item> <item name="numberPickerDownButtonStyle">@style/Widget.Holo.ImageButton.NumberPickerDownButton</item> <item name="numberPickerInputTextStyle">@style/Widget.Holo.EditText.NumberPickerInputText</item> + <item name="numberPickerStyle">@style/Widget.Holo.NumberPicker</item> <!-- CalendarView style--> <item name="calendarViewStyle">@style/Widget.Holo.CalendarView</item> + <!-- TimePicker style --> + <item name="timePickerStyle">@style/Widget.Holo.TimePicker</item> + + <!-- DatePicker style --> + <item name="datePickerStyle">@style/Widget.Holo.DatePicker</item> + <item name="fastScrollThumbDrawable">@android:drawable/fastscroll_thumb_holo</item> <item name="fastScrollPreviewBackgroundLeft">@android:drawable/fastscroll_label_left_holo_dark</item> <item name="fastScrollPreviewBackgroundRight">@android:drawable/fastscroll_label_right_holo_dark</item> @@ -1003,6 +1016,7 @@ <item name="disabledAlpha">0.5</item> <item name="backgroundDimAmount">0.6</item> + <!-- Text styles --> <item name="textAppearance">@android:style/TextAppearance.Holo.Light</item> <item name="textAppearanceInverse">@android:style/TextAppearance.Holo.Light.Inverse</item> @@ -1236,10 +1250,17 @@ <item name="numberPickerUpButtonStyle">@style/Widget.Holo.Light.ImageButton.NumberPickerUpButton</item> <item name="numberPickerDownButtonStyle">@style/Widget.Holo.Light.ImageButton.NumberPickerDownButton</item> <item name="numberPickerInputTextStyle">@style/Widget.Holo.Light.EditText.NumberPickerInputText</item> + <item name="numberPickerStyle">@style/Widget.Holo.Light.NumberPicker</item> <!-- CalendarView style--> <item name="calendarViewStyle">@style/Widget.Holo.Light.CalendarView</item> + <!-- TimePicker style --> + <item name="timePickerStyle">@style/Widget.Holo.Light.TimePicker</item> + + <!-- DatePicker style --> + <item name="datePickerStyle">@style/Widget.Holo.Light.DatePicker</item> + <item name="fastScrollThumbDrawable">@android:drawable/fastscroll_thumb_holo</item> <item name="fastScrollPreviewBackgroundLeft">@android:drawable/fastscroll_label_left_holo_light</item> <item name="fastScrollPreviewBackgroundRight">@android:drawable/fastscroll_label_right_holo_light</item> diff --git a/libs/hwui/FontRenderer.cpp b/libs/hwui/FontRenderer.cpp index c080501..c43e40d 100644 --- a/libs/hwui/FontRenderer.cpp +++ b/libs/hwui/FontRenderer.cpp @@ -298,8 +298,10 @@ Font* Font::create(FontRenderer* state, uint32_t fontId, float fontSize, // FontRenderer /////////////////////////////////////////////////////////////////////////////// +static bool sLogFontRendererCreate = true; + FontRenderer::FontRenderer() { - LOGD("Creating FontRenderer"); + if (sLogFontRendererCreate) LOGD("Creating FontRenderer"); mGammaTable = NULL; mInitialized = false; @@ -317,18 +319,24 @@ FontRenderer::FontRenderer() { char property[PROPERTY_VALUE_MAX]; if (property_get(PROPERTY_TEXT_CACHE_WIDTH, property, NULL) > 0) { - LOGD(" Setting text cache width to %s pixels", property); + if (sLogFontRendererCreate) LOGD(" Setting text cache width to %s pixels", property); mCacheWidth = atoi(property); } else { - LOGD(" Using default text cache width of %i pixels", mCacheWidth); + if (sLogFontRendererCreate) { + LOGD(" Using default text cache width of %i pixels", mCacheWidth); + } } if (property_get(PROPERTY_TEXT_CACHE_HEIGHT, property, NULL) > 0) { - LOGD(" Setting text cache width to %s pixels", property); + if (sLogFontRendererCreate) LOGD(" Setting text cache width to %s pixels", property); mCacheHeight = atoi(property); } else { - LOGD(" Using default text cache height of %i pixels", mCacheHeight); + if (sLogFontRendererCreate) { + LOGD(" Using default text cache height of %i pixels", mCacheHeight); + } } + + sLogFontRendererCreate = false; } FontRenderer::~FontRenderer() { diff --git a/libs/hwui/LayerRenderer.cpp b/libs/hwui/LayerRenderer.cpp index e6bea78..a167429 100644 --- a/libs/hwui/LayerRenderer.cpp +++ b/libs/hwui/LayerRenderer.cpp @@ -29,7 +29,6 @@ namespace uirenderer { void LayerRenderer::prepare(bool opaque) { LAYER_RENDERER_LOGD("Rendering into layer, fbo = %d", mLayer->fbo); - glGetIntegerv(GL_FRAMEBUFFER_BINDING, (GLint*) &mPreviousFbo); glBindFramebuffer(GL_FRAMEBUFFER, mLayer->fbo); OpenGLRenderer::prepare(opaque); @@ -37,11 +36,17 @@ void LayerRenderer::prepare(bool opaque) { void LayerRenderer::finish() { OpenGLRenderer::finish(); - glBindFramebuffer(GL_FRAMEBUFFER, mPreviousFbo); generateMesh(); LAYER_RENDERER_LOGD("Finished rendering into layer, fbo = %d", mLayer->mFbo); + + // No need to unbind our FBO, this will be taken care of by the caller + // who will invoke OpenGLRenderer::resume() +} + +GLint LayerRenderer::getTargetFbo() { + return mLayer->fbo; } /////////////////////////////////////////////////////////////////////////////// diff --git a/libs/hwui/LayerRenderer.h b/libs/hwui/LayerRenderer.h index f2fb898..1e39847 100644 --- a/libs/hwui/LayerRenderer.h +++ b/libs/hwui/LayerRenderer.h @@ -51,6 +51,7 @@ public: bool hasLayer(); Region* getRegion(); + GLint getTargetFbo(); static Layer* createLayer(uint32_t width, uint32_t height, bool isOpaque = false); static bool resizeLayer(Layer* layer, uint32_t width, uint32_t height); @@ -61,8 +62,6 @@ private: void generateMesh(); Layer* mLayer; - GLuint mPreviousFbo; - }; // class LayerRenderer }; // namespace uirenderer diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp index 2067acc..6477eb0 100644 --- a/libs/hwui/OpenGLRenderer.cpp +++ b/libs/hwui/OpenGLRenderer.cpp @@ -200,7 +200,7 @@ void OpenGLRenderer::resume() { glDisable(GL_DITHER); - glBindFramebuffer(GL_FRAMEBUFFER, 0); + glBindFramebuffer(GL_FRAMEBUFFER, getTargetFbo()); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); mCaches.blend = true; @@ -430,18 +430,18 @@ bool OpenGLRenderer::createLayer(sp<Snapshot> snapshot, float left, float top, } else { // Copy the framebuffer into the layer glBindTexture(GL_TEXTURE_2D, layer->texture); - - if (layer->empty) { - glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, bounds.left, - snapshot->height - bounds.bottom, layer->width, layer->height, 0); - layer->empty = false; - } else { - glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, bounds.left, - snapshot->height - bounds.bottom, bounds.getWidth(), bounds.getHeight()); + if (!bounds.isEmpty()) { + if (layer->empty) { + glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, bounds.left, + snapshot->height - bounds.bottom, layer->width, layer->height, 0); + layer->empty = false; + } else { + glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, bounds.left, + snapshot->height - bounds.bottom, bounds.getWidth(), bounds.getHeight()); + } + // Enqueue the buffer coordinates to clear the corresponding region later + mLayers.push(new Rect(bounds)); } - - // Enqueue the buffer coordinates to clear the corresponding region later - mLayers.push(new Rect(bounds)); } return true; @@ -565,8 +565,10 @@ void OpenGLRenderer::composeLayer(sp<Snapshot> current, sp<Snapshot> previous) { resetColorFilter(); } } else { - dirtyLayer(rect.left, rect.top, rect.right, rect.bottom); - composeLayerRect(layer, rect, true); + if (!rect.isEmpty()) { + dirtyLayer(rect.left, rect.top, rect.right, rect.bottom); + composeLayerRect(layer, rect, true); + } } if (fboLayer) { diff --git a/libs/hwui/OpenGLRenderer.h b/libs/hwui/OpenGLRenderer.h index 272c5c2..4150ddc 100644 --- a/libs/hwui/OpenGLRenderer.h +++ b/libs/hwui/OpenGLRenderer.h @@ -145,14 +145,27 @@ protected: return mSnapshot; } + /** + * Returns the region of the current layer. + */ virtual Region* getRegion() { return mSnapshot->region; } + /** + * Indicates whether rendering is currently targeted at a layer. + */ virtual bool hasLayer() { return (mSnapshot->flags & Snapshot::kFlagFboTarget) && mSnapshot->region; } + /** + * Returns the name of the FBO this renderer is rendering into. + */ + virtual GLint getTargetFbo() { + return 0; + } + private: /** * Saves the current state of the renderer as a new snapshot. diff --git a/libs/hwui/Patch.cpp b/libs/hwui/Patch.cpp index 3f0036a..11eb953 100644 --- a/libs/hwui/Patch.cpp +++ b/libs/hwui/Patch.cpp @@ -177,8 +177,10 @@ void Patch::updateVertices(const float bitmapWidth, const float bitmapHeight, previousStepY = stepY; } - generateRow(vertex, y1, bottom - top, v1, 1.0f, stretchX, right - left, - bitmapWidth, quadCount); + if (previousStepY != bitmapHeight) { + generateRow(vertex, y1, bottom - top, v1, 1.0f, stretchX, right - left, + bitmapWidth, quadCount); + } if (verticesCount > 0) { Caches::getInstance().bindMeshBuffer(meshBuffer); @@ -225,7 +227,9 @@ void Patch::generateRow(TextureVertex*& vertex, float y1, float y2, float v1, fl previousStepX = stepX; } - generateQuad(vertex, x1, y1, width, y2, u1, v1, 1.0f, v2, quadCount); + if (previousStepX != bitmapWidth) { + generateQuad(vertex, x1, y1, width, y2, u1, v1, 1.0f, v2, quadCount); + } } void Patch::generateQuad(TextureVertex*& vertex, float x1, float y1, float x2, float y2, diff --git a/libs/rs/scriptc/rs_types.rsh b/libs/rs/scriptc/rs_types.rsh index 0f8717f..a010096 100644 --- a/libs/rs/scriptc/rs_types.rsh +++ b/libs/rs/scriptc/rs_types.rsh @@ -3,12 +3,7 @@ #define M_PI 3.14159265358979323846264338327950288f /* pi */ -//#include "external/clang/lib/Headers/stdbool.h" -#define bool _Bool -#define true 1 -#define false 0 -#define __bool_true_false_are_defined 1 - +#include "stdbool.h" typedef char int8_t; typedef short int16_t; typedef int int32_t; diff --git a/media/java/android/media/videoeditor/MediaImageItem.java b/media/java/android/media/videoeditor/MediaImageItem.java index b03588f..1c02878 100755 --- a/media/java/android/media/videoeditor/MediaImageItem.java +++ b/media/java/android/media/videoeditor/MediaImageItem.java @@ -93,29 +93,28 @@ public class MediaImageItem extends MediaItem { * * @throws IOException */ - public MediaImageItem(VideoEditor editor, String mediaItemId, - String filename, long durationMs, - int renderingMode) throws IOException { + public MediaImageItem(VideoEditor editor, String mediaItemId, String filename, long durationMs, + int renderingMode) throws IOException { super(editor, mediaItemId, filename, renderingMode); mMANativeHelper = ((VideoEditorImpl)editor).getNativeContext(); mVideoEditor = ((VideoEditorImpl)editor); try { - final Properties properties = - mMANativeHelper.getMediaProperties(filename); + final Properties properties = mMANativeHelper.getMediaProperties(filename); switch (mMANativeHelper.getFileType(properties.fileType)) { case MediaProperties.FILE_JPEG: + case MediaProperties.FILE_PNG: { break; - case MediaProperties.FILE_PNG: - break; + } - default: - throw new IllegalArgumentException("Unsupported Input File Type"); + default: { + throw new IllegalArgumentException("Unsupported Input File Type"); + } } } catch (Exception e) { - throw new IllegalArgumentException("Unsupported file or file not found"); + throw new IllegalArgumentException("Unsupported file or file not found: " + filename); } /** @@ -130,13 +129,13 @@ public class MediaImageItem extends MediaItem { mDurationMs = durationMs; mDecodedFilename = String.format(mMANativeHelper.getProjectPath() + "/" + "decoded" + getId()+ ".rgb"); - final FileOutputStream fl = new FileOutputStream(mDecodedFilename); - final DataOutputStream dos = new DataOutputStream(fl); + try { mAspectRatio = mMANativeHelper.getAspectRatio(mWidth, mHeight); } catch(IllegalArgumentException e) { throw new IllegalArgumentException ("Null width and height"); } + mGeneratedClipHeight = 0; mGeneratedClipWidth = 0; @@ -146,9 +145,12 @@ public class MediaImageItem extends MediaItem { */ final Pair<Integer, Integer>[] resolutions = MediaProperties.getSupportedResolutions(mAspectRatio); + /** * Get the highest resolution */ + final FileOutputStream fl = new FileOutputStream(mDecodedFilename); + final DataOutputStream dos = new DataOutputStream(fl); final Pair<Integer, Integer> maxResolution = resolutions[resolutions.length - 1]; if (mHeight > maxResolution.second) { /** @@ -171,16 +173,16 @@ public class MediaImageItem extends MediaItem { int mNewHeight = 0; if ((mScaledWidth % 2 ) != 0) { mNewWidth = mScaledWidth - 1; - } - else { + } else { mNewWidth = mScaledWidth; } + if ((mScaledHeight % 2 ) != 0) { mNewHeight = mScaledHeight - 1; - } - else { + } else { mNewHeight = mScaledHeight; } + final int [] framingBuffer = new int[mNewWidth]; final ByteBuffer byteBuffer = ByteBuffer.allocate(framingBuffer.length * 4); IntBuffer intBuffer; @@ -195,6 +197,7 @@ public class MediaImageItem extends MediaItem { dos.write(array); tmp += 1; } + mScaledWidth = mNewWidth; mScaledHeight = mNewHeight; scaledImage.recycle(); @@ -204,10 +207,11 @@ public class MediaImageItem extends MediaItem { + "/" + "scaled" + getId()+ ".JPG"); if (!((new File(mScaledFilename)).exists())) { super.mRegenerateClip = true; - FileOutputStream f1 = new FileOutputStream(mScaledFilename); + final FileOutputStream f1 = new FileOutputStream(mScaledFilename); scaledImage.compress(Bitmap.CompressFormat.JPEG, 50,f1); f1.close(); } + mScaledWidth = scaledImage.getWidth(); mScaledHeight = scaledImage.getHeight(); @@ -215,17 +219,17 @@ public class MediaImageItem extends MediaItem { int mNewheight = 0; if ((mScaledWidth % 2 ) != 0) { mNewWidth = mScaledWidth - 1; - } - else { + } else { mNewWidth = mScaledWidth; } + if ((mScaledHeight % 2 ) != 0) { mNewheight = mScaledHeight - 1; - } - else { + } else { mNewheight = mScaledHeight; } - Bitmap imageBitmap = BitmapFactory.decodeFile(mScaledFilename); + + final Bitmap imageBitmap = BitmapFactory.decodeFile(mScaledFilename); final int [] framingBuffer = new int[mNewWidth]; ByteBuffer byteBuffer = ByteBuffer.allocate(framingBuffer.length * 4); IntBuffer intBuffer; @@ -240,10 +244,12 @@ public class MediaImageItem extends MediaItem { dos.write(array); tmp += 1; } + mScaledWidth = mNewWidth; mScaledHeight = mNewheight; imageBitmap.recycle(); } + fl.close(); System.gc(); } @@ -286,7 +292,7 @@ public class MediaImageItem extends MediaItem { /** * @return The file name of image which is decoded and stored - * in rgb format + * in RGB format */ String getDecodedImageFileName() { return mDecodedFilename; @@ -447,7 +453,7 @@ public class MediaImageItem extends MediaItem { * Check if the effect overlaps with the end transition */ if (effect.getStartTime() + effect.getDuration() > - mDurationMs - transitionDurationMs) { + mDurationMs - transitionDurationMs) { mEndTransition.invalidate(); break; } @@ -464,7 +470,7 @@ public class MediaImageItem extends MediaItem { * Check if the overlay overlaps with the end transition */ if (overlay.getStartTime() + overlay.getDuration() > - mDurationMs - transitionDurationMs) { + mDurationMs - transitionDurationMs) { mEndTransition.invalidate(); break; } @@ -648,23 +654,24 @@ public class MediaImageItem extends MediaItem { for (int i = 0; i < thumbnailCount; i++) { thumbnailArray[i] = thumbnail; } - return thumbnailArray; - - } - else { + return thumbnailArray; + } else { if (startMs > endMs) { throw new IllegalArgumentException("Start time is greater than end time"); } + if (endMs > mDurationMs) { throw new IllegalArgumentException("End time is greater than file duration"); } + if (startMs == endMs) { Bitmap[] bitmap = new Bitmap[1]; bitmap[0] = mMANativeHelper.getPixels(getGeneratedImageClip(), width, height,startMs); return bitmap; } + return mMANativeHelper.getPixelsList(getGeneratedImageClip(), width, height,startMs,endMs,thumbnailCount); } @@ -704,31 +711,51 @@ public class MediaImageItem extends MediaItem { */ if (mBeginTransition != null) { final long transitionDurationMs = mBeginTransition.getDuration(); + final boolean oldOverlap = isOverlapping(oldStartTimeMs, oldDurationMs, 0, + transitionDurationMs); + final boolean newOverlap = isOverlapping(newStartTimeMs, newDurationMs, 0, + transitionDurationMs); /** - * If the start time has changed and if the old or the new item - * overlaps with the begin transition, invalidate the transition. + * Invalidate transition if: + * + * 1. New item overlaps the transition, the old one did not + * 2. New item does not overlap the transition, the old one did + * 3. New and old item overlap the transition if begin or end + * time changed */ - if (((oldStartTimeMs != newStartTimeMs) - || (oldDurationMs != newDurationMs) )&& - (isOverlapping(oldStartTimeMs, oldDurationMs, 0, transitionDurationMs) || - isOverlapping(newStartTimeMs, newDurationMs, 0, - transitionDurationMs))) { + if (newOverlap != oldOverlap) { // Overlap has changed mBeginTransition.invalidate(); + } else if (newOverlap) { // Both old and new overlap + if ((oldStartTimeMs != newStartTimeMs) || + !(oldStartTimeMs + oldDurationMs > transitionDurationMs && + newStartTimeMs + newDurationMs > transitionDurationMs)) { + mBeginTransition.invalidate(); + } } } if (mEndTransition != null) { final long transitionDurationMs = mEndTransition.getDuration(); + final boolean oldOverlap = isOverlapping(oldStartTimeMs, oldDurationMs, + mDurationMs - transitionDurationMs, transitionDurationMs); + final boolean newOverlap = isOverlapping(newStartTimeMs, newDurationMs, + mDurationMs - transitionDurationMs, transitionDurationMs); /** - * If the start time + duration has changed and if the old or the new - * item overlaps the end transition, invalidate the transition + * Invalidate transition if: + * + * 1. New item overlaps the transition, the old one did not + * 2. New item does not overlap the transition, the old one did + * 3. New and old item overlap the transition if begin or end + * time changed */ - if (oldStartTimeMs + oldDurationMs != newStartTimeMs + newDurationMs && - (isOverlapping(oldStartTimeMs, oldDurationMs, - mDurationMs - transitionDurationMs, transitionDurationMs) || - isOverlapping(newStartTimeMs, newDurationMs, - mDurationMs - transitionDurationMs, transitionDurationMs))) { + if (newOverlap != oldOverlap) { // Overlap has changed mEndTransition.invalidate(); + } else if (newOverlap) { // Both old and new overlap + if ((oldStartTimeMs + oldDurationMs != newStartTimeMs + newDurationMs) || + ((oldStartTimeMs > mDurationMs - transitionDurationMs) || + newStartTimeMs > mDurationMs - transitionDurationMs)) { + mEndTransition.invalidate(); + } } } } @@ -743,10 +770,12 @@ public class MediaImageItem extends MediaItem { setGeneratedImageClip(null); setRegenerateClip(true); } + if (mScaledFilename != null) { new File(mScaledFilename).delete(); mScaledFilename = null; } + if (mDecodedFilename != null) { new File(mDecodedFilename).delete(); mDecodedFilename = null; diff --git a/media/java/android/media/videoeditor/MediaVideoItem.java b/media/java/android/media/videoeditor/MediaVideoItem.java index 772b360..2981b41 100755 --- a/media/java/android/media/videoeditor/MediaVideoItem.java +++ b/media/java/android/media/videoeditor/MediaVideoItem.java @@ -78,12 +78,9 @@ public class MediaVideoItem extends MediaItem { * * @throws IOException if the file cannot be opened for reading */ - public MediaVideoItem(VideoEditor editor, String mediaItemId, - String filename, - int renderingMode) - throws IOException { - this(editor, mediaItemId, filename, renderingMode, 0, END_OF_FILE, - 100, false, null); + public MediaVideoItem(VideoEditor editor, String mediaItemId, String filename, + int renderingMode) throws IOException { + this(editor, mediaItemId, filename, renderingMode, 0, END_OF_FILE, 100, false, null); } /** @@ -105,20 +102,22 @@ public class MediaVideoItem extends MediaItem { * @throws IOException if the file cannot be opened for reading */ MediaVideoItem(VideoEditor editor, String mediaItemId, String filename, - int renderingMode, - long beginMs, long endMs, int volumePercent, boolean muted, + int renderingMode, long beginMs, long endMs, int volumePercent, boolean muted, String audioWaveformFilename) throws IOException { super(editor, mediaItemId, filename, renderingMode); + if (editor instanceof VideoEditorImpl) { mMANativeHelper = ((VideoEditorImpl)editor).getNativeContext(); mVideoEditor = ((VideoEditorImpl)editor); } - Properties properties = null; + + final Properties properties; try { properties = mMANativeHelper.getMediaProperties(filename); } catch ( Exception e) { - throw new IllegalArgumentException("Unsupported file or file not found"); + throw new IllegalArgumentException("Unsupported file or file not found: " + filename); } + switch (mMANativeHelper.getFileType(properties.fileType)) { case MediaProperties.FILE_3GP: break; @@ -163,8 +162,7 @@ public class MediaVideoItem extends MediaItem { mMuted = muted; mAudioWaveformFilename = audioWaveformFilename; if (audioWaveformFilename != null) { - mWaveformData = - new SoftReference<WaveformData>( + mWaveformData = new SoftReference<WaveformData>( new WaveformData(audioWaveformFilename)); } else { mWaveformData = null; @@ -190,9 +188,11 @@ public class MediaVideoItem extends MediaItem { if (beginMs > mDurationMs) { throw new IllegalArgumentException("setExtractBoundaries: Invalid start time"); } + if (endMs > mDurationMs) { throw new IllegalArgumentException("setExtractBoundaries: Invalid end time"); } + if ((endMs != -1) && (beginMs >= endMs) ) { throw new IllegalArgumentException("setExtractBoundaries: Start time is greater than end time"); } @@ -255,18 +255,18 @@ public class MediaVideoItem extends MediaItem { */ @Override public Bitmap getThumbnail(int width, int height, long timeMs) { - if (timeMs > mDurationMs) - { + if (timeMs > mDurationMs) { throw new IllegalArgumentException("Time Exceeds duration"); } - if (timeMs < 0) - { + + if (timeMs < 0) { throw new IllegalArgumentException("Invalid Time duration"); } - if ((width <=0) || (height <= 0)) - { + + if ((width <=0) || (height <= 0)) { throw new IllegalArgumentException("Invalid Dimensions"); } + return mMANativeHelper.getPixels(super.getFilename(), width, height,timeMs); } @@ -280,18 +280,21 @@ public class MediaVideoItem extends MediaItem { if (startMs > endMs) { throw new IllegalArgumentException("Start time is greater than end time"); } + if (endMs > mDurationMs) { throw new IllegalArgumentException("End time is greater than file duration"); } + if ((height <= 0) || (width <= 0)) { throw new IllegalArgumentException("Invalid dimension"); } + if (startMs == endMs) { - Bitmap[] bitmap = new Bitmap[1]; - bitmap[0] = mMANativeHelper.getPixels(super.getFilename(), - width, height,startMs); + final Bitmap[] bitmap = new Bitmap[1]; + bitmap[0] = mMANativeHelper.getPixels(super.getFilename(), width, height,startMs); return bitmap; } + return mMANativeHelper.getPixelsList(super.getFilename(), width, height,startMs,endMs,thumbnailCount); } @@ -324,40 +327,58 @@ public class MediaVideoItem extends MediaItem { * {@inheritDoc} */ @Override - void invalidateTransitions(long oldStartTimeMs, long oldDurationMs, - long newStartTimeMs, + void invalidateTransitions(long oldStartTimeMs, long oldDurationMs, long newStartTimeMs, long newDurationMs) { /** * Check if the item overlaps with the beginning and end transitions */ if (mBeginTransition != null) { final long transitionDurationMs = mBeginTransition.getDuration(); + final boolean oldOverlap = isOverlapping(oldStartTimeMs, oldDurationMs, + mBeginBoundaryTimeMs, transitionDurationMs); + final boolean newOverlap = isOverlapping(newStartTimeMs, newDurationMs, + mBeginBoundaryTimeMs, transitionDurationMs); /** - * If the start time has changed and if the old or the new item - * overlaps with the begin transition, invalidate the transition. + * Invalidate transition if: + * + * 1. New item overlaps the transition, the old one did not + * 2. New item does not overlap the transition, the old one did + * 3. New and old item overlap the transition if begin or end + * time changed */ - if (((oldStartTimeMs != newStartTimeMs) - || (oldDurationMs != newDurationMs) )&& - (isOverlapping(oldStartTimeMs, oldDurationMs, - mBeginBoundaryTimeMs, transitionDurationMs) || - isOverlapping(newStartTimeMs, newDurationMs, - mBeginBoundaryTimeMs, transitionDurationMs))) { + if (newOverlap != oldOverlap) { // Overlap has changed mBeginTransition.invalidate(); + } else if (newOverlap) { // Both old and new overlap + if ((oldStartTimeMs != newStartTimeMs) || + !(oldStartTimeMs + oldDurationMs > transitionDurationMs && + newStartTimeMs + newDurationMs > transitionDurationMs)) { + mBeginTransition.invalidate(); + } } } if (mEndTransition != null) { final long transitionDurationMs = mEndTransition.getDuration(); + final boolean oldOverlap = isOverlapping(oldStartTimeMs, oldDurationMs, + mEndBoundaryTimeMs - transitionDurationMs, transitionDurationMs); + final boolean newOverlap = isOverlapping(newStartTimeMs, newDurationMs, + mEndBoundaryTimeMs - transitionDurationMs, transitionDurationMs); /** - * If the start time + duration has changed and if the old or the new - * item overlaps the end transition, invalidate the transition + * Invalidate transition if: + * + * 1. New item overlaps the transition, the old one did not + * 2. New item does not overlap the transition, the old one did + * 3. New and old item overlap the transition if begin or end + * time changed */ - if (oldStartTimeMs + oldDurationMs != newStartTimeMs + newDurationMs && - (isOverlapping(oldStartTimeMs, oldDurationMs, - mEndBoundaryTimeMs - transitionDurationMs, transitionDurationMs) || - isOverlapping(newStartTimeMs, newDurationMs, - mEndBoundaryTimeMs - transitionDurationMs, transitionDurationMs))) { + if (newOverlap != oldOverlap) { // Overlap has changed mEndTransition.invalidate(); + } else if (newOverlap) { // Both old and new overlap + if ((oldStartTimeMs + oldDurationMs != newStartTimeMs + newDurationMs) || + ((oldStartTimeMs > mEndBoundaryTimeMs - transitionDurationMs) || + newStartTimeMs > mEndBoundaryTimeMs - transitionDurationMs)) { + mEndTransition.invalidate(); + } } } } @@ -434,7 +455,7 @@ public class MediaVideoItem extends MediaItem { throw new IllegalArgumentException("requested time not correct"); } - Surface surface = surfaceHolder.getSurface(); + final Surface surface = surfaceHolder.getSurface(); if (surface == null) { throw new RuntimeException("Surface could not be retrieved from Surface holder"); } @@ -442,8 +463,7 @@ public class MediaVideoItem extends MediaItem { if (mFilename != null) { return mMANativeHelper.renderMediaItemPreviewFrame(surface, mFilename,timeMs,mWidth,mHeight); - } - else { + } else { return 0; } } @@ -462,7 +482,7 @@ public class MediaVideoItem extends MediaItem { * Audio track */ public void extractAudioWaveform(ExtractAudioWaveformProgressListener listener) - throws IOException { + throws IOException { int frameDuration = 0; int sampleCount = 0; final String projectPath = mMANativeHelper.getProjectPath(); @@ -481,19 +501,17 @@ public class MediaVideoItem extends MediaItem { * Logic to get frame duration = (no. of frames per sample * 1000)/ * sampling frequency */ - if ( mMANativeHelper.getAudioCodecType(mAudioType) == + if (mMANativeHelper.getAudioCodecType(mAudioType) == MediaProperties.ACODEC_AMRNB ) { frameDuration = (MediaProperties.SAMPLES_PER_FRAME_AMRNB*1000)/ MediaProperties.DEFAULT_SAMPLING_FREQUENCY; sampleCount = MediaProperties.SAMPLES_PER_FRAME_AMRNB; - } - else if ( mMANativeHelper.getAudioCodecType(mAudioType) == + } else if (mMANativeHelper.getAudioCodecType(mAudioType) == MediaProperties.ACODEC_AMRWB ) { frameDuration = (MediaProperties.SAMPLES_PER_FRAME_AMRWB * 1000)/ MediaProperties.DEFAULT_SAMPLING_FREQUENCY; sampleCount = MediaProperties.SAMPLES_PER_FRAME_AMRWB; - } - else if ( mMANativeHelper.getAudioCodecType(mAudioType) == + } else if (mMANativeHelper.getAudioCodecType(mAudioType) == MediaProperties.ACODEC_AAC_LC ) { frameDuration = (MediaProperties.SAMPLES_PER_FRAME_AAC * 1000)/ MediaProperties.DEFAULT_SAMPLING_FREQUENCY; @@ -682,5 +700,4 @@ public class MediaVideoItem extends MediaItem { return clipSettings; } - } diff --git a/media/jni/mediaeditor/Android.mk b/media/jni/mediaeditor/Android.mk index 27c41be..0a01fb2 100755 --- a/media/jni/mediaeditor/Android.mk +++ b/media/jni/mediaeditor/Android.mk @@ -85,6 +85,6 @@ LOCAL_MODULE:= libvideoeditor_jni # to add this library to the prelink map and set this to true. LOCAL_PRELINK_MODULE := false -LOCAL_MODULE_TAGS := eng development +LOCAL_MODULE_TAGS := optional include $(BUILD_SHARED_LIBRARY) diff --git a/media/jni/mediaeditor/VideoEditorLogging.h b/media/jni/mediaeditor/VideoEditorLogging.h index ca8c047..c13f6ff 100755 --- a/media/jni/mediaeditor/VideoEditorLogging.h +++ b/media/jni/mediaeditor/VideoEditorLogging.h @@ -21,12 +21,13 @@ #define VIDEOEDIT_LOG_INDENTATION (3) +#define VIDEOEDIT_LOG_ERROR __android_log_print +#define VIDEOEDIT_LOG_EXCEPTION __android_log_print + #ifdef VIDEOEDIT_LOGGING_ENABLED #define VIDEOEDIT_LOG_ALLOCATION __android_log_print #define VIDEOEDIT_LOG_API __android_log_print -#define VIDEOEDIT_LOG_ERROR __android_log_print -#define VIDEOEDIT_LOG_EXCEPTION __android_log_print #define VIDEOEDIT_LOG_FUNCTION __android_log_print #define VIDEOEDIT_LOG_RESULT(x,y, ...) LOGI(y, __VA_ARGS__ ) #define VIDEOEDIT_LOG_SETTING __android_log_print @@ -40,8 +41,6 @@ #define VIDEOEDIT_LOG_ALLOCATION (void) #define VIDEOEDIT_LOG_API (void) -#define VIDEOEDIT_LOG_ERROR (void) -#define VIDEOEDIT_LOG_EXCEPTION (void) #define VIDEOEDIT_LOG_FUNCTION (void) #define VIDEOEDIT_LOG_RESULT (void) #define VIDEOEDIT_LOG_SETTING (void) diff --git a/media/jni/mediaeditor/VideoEditorMain.cpp b/media/jni/mediaeditor/VideoEditorMain.cpp index e66e4b9..643f698 100755 --- a/media/jni/mediaeditor/VideoEditorMain.cpp +++ b/media/jni/mediaeditor/VideoEditorMain.cpp @@ -437,7 +437,7 @@ static int videoEditor_renderPreviewFrame(JNIEnv* pEnv, VideoEditor_renderPreviewFrameStr frameStr; M4OSA_Context tnContext = M4OSA_NULL; const char* pMessage = NULL; - M4VIFI_ImagePlane *yuvPlane; + M4VIFI_ImagePlane *yuvPlane = NULL; VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR", "surfaceWidth = %d",surfaceWidth); @@ -1179,7 +1179,7 @@ static int removeAlphafromRGB8888 ( } /** Remove the alpha channel */ - for (int i = 0, j = 0; i < frameSize_argb; i++) { + for (size_t i = 0, j = 0; i < frameSize_argb; i++) { if ((i % 4) == 0) continue; pFramingCtx->FramingRgb->pac_data[j] = pTmpData[i]; j++; @@ -2729,7 +2729,7 @@ typedef struct } M4AM_Buffer; -M4OSA_UInt8 logLookUp[256]{ +M4OSA_UInt8 logLookUp[256] = { 0,120,137,146,154,159,163,167,171,173,176,178,181,182,184,186,188,189,190,192,193, 194,195,196,198,199,199,200,201,202,203,204,205,205,206,207,207,208,209,209,210, 211,211,212,212,213,213,214,215,215,216,216,216,217,217,218,218,219,219,220,220, @@ -2788,7 +2788,7 @@ M4OSA_ERR M4MA_generateAudioGraphFile(JNIEnv* pEnv, M4OSA_Char* pInputFileURL, err = M4OSA_fileReadOpen (&inputFileHandle, pInputFileURL, M4OSA_kFileRead); if (inputFileHandle == M4OSA_NULL) { VIDEOEDIT_LOG_ERROR(ANDROID_LOG_INFO, "VIDEO_EDITOR", - "M4MA_generateAudioGraphFile: Cannot open input file 0x%x", err); + "M4MA_generateAudioGraphFile: Cannot open input file 0x%lx", err); return err; } @@ -2822,7 +2822,7 @@ M4OSA_ERR M4MA_generateAudioGraphFile(JNIEnv* pEnv, M4OSA_Char* pInputFileURL, bufferIn.m_bufferSize = samplesCountInBytes*sizeof(M4OSA_UInt16); } else { VIDEOEDIT_LOG_ERROR(ANDROID_LOG_INFO, "VIDEO_EDITOR", - "M4MA_generateAudioGraphFile: Malloc failed for bufferIn.m_dataAddress 0x%x",\ + "M4MA_generateAudioGraphFile: Malloc failed for bufferIn.m_dataAddress 0x%lx", M4ERR_ALLOC); return M4ERR_ALLOC; } @@ -2862,7 +2862,7 @@ M4OSA_ERR M4MA_generateAudioGraphFile(JNIEnv* pEnv, M4OSA_Char* pInputFileURL, if (err != M4NO_ERROR) { // if out value of bytes-read is 0, break if ( numBytesToRead == 0) { - VIDEOEDIT_LOG_ERROR(ANDROID_LOG_INFO, "VIDEO_EDITOR", "numBytesToRead 0x%x",\ + VIDEOEDIT_LOG_ERROR(ANDROID_LOG_INFO, "VIDEO_EDITOR", "numBytesToRead 0x%lx", numBytesToRead); break; /* stop if file is empty or EOF */ } @@ -2914,7 +2914,7 @@ M4OSA_ERR M4MA_generateAudioGraphFile(JNIEnv* pEnv, M4OSA_Char* pInputFileURL, } while (numBytesToRead != 0); - VIDEOEDIT_LOG_ERROR(ANDROID_LOG_INFO, "VIDEO_EDITOR", "loop 0x%x", volumeValuesCount); + VIDEOEDIT_LOG_ERROR(ANDROID_LOG_INFO, "VIDEO_EDITOR", "loop 0x%lx", volumeValuesCount); /* if some error occured in fwrite */ if (numBytesToRead != 0) { diff --git a/media/libmedia/IOMX.cpp b/media/libmedia/IOMX.cpp index 9ce6738..af67175 100644 --- a/media/libmedia/IOMX.cpp +++ b/media/libmedia/IOMX.cpp @@ -5,6 +5,7 @@ #include <binder/IMemory.h> #include <binder/Parcel.h> #include <media/IOMX.h> +#include <media/stagefright/foundation/ADebug.h> #include <surfaceflinger/ISurface.h> #include <surfaceflinger/Surface.h> @@ -449,48 +450,9 @@ status_t BnOMX::onTransact( } case GET_PARAMETER: - { - CHECK_INTERFACE(IOMX, data, reply); - - node_id node = (void*)data.readIntPtr(); - OMX_INDEXTYPE index = static_cast<OMX_INDEXTYPE>(data.readInt32()); - - size_t size = data.readInt32(); - - // XXX I am not happy with this but Parcel::readInplace didn't work. - void *params = malloc(size); - data.read(params, size); - - status_t err = getParameter(node, index, params, size); - - reply->writeInt32(err); - - if (err == OK) { - reply->write(params, size); - } - - free(params); - params = NULL; - - return NO_ERROR; - } - case SET_PARAMETER: - { - CHECK_INTERFACE(IOMX, data, reply); - - node_id node = (void*)data.readIntPtr(); - OMX_INDEXTYPE index = static_cast<OMX_INDEXTYPE>(data.readInt32()); - - size_t size = data.readInt32(); - void *params = const_cast<void *>(data.readInplace(size)); - - reply->writeInt32(setParameter(node, index, params, size)); - - return NO_ERROR; - } - case GET_CONFIG: + case SET_CONFIG: { CHECK_INTERFACE(IOMX, data, reply); @@ -499,15 +461,30 @@ status_t BnOMX::onTransact( size_t size = data.readInt32(); - // XXX I am not happy with this but Parcel::readInplace didn't work. void *params = malloc(size); data.read(params, size); - status_t err = getConfig(node, index, params, size); + status_t err; + switch (code) { + case GET_PARAMETER: + err = getParameter(node, index, params, size); + break; + case SET_PARAMETER: + err = setParameter(node, index, params, size); + break; + case GET_CONFIG: + err = getConfig(node, index, params, size); + break; + case SET_CONFIG: + err = setConfig(node, index, params, size); + break; + default: + TRESPASS(); + } reply->writeInt32(err); - if (err == OK) { + if ((code == GET_PARAMETER || code == GET_CONFIG) && err == OK) { reply->write(params, size); } @@ -517,21 +494,6 @@ status_t BnOMX::onTransact( return NO_ERROR; } - case SET_CONFIG: - { - CHECK_INTERFACE(IOMX, data, reply); - - node_id node = (void*)data.readIntPtr(); - OMX_INDEXTYPE index = static_cast<OMX_INDEXTYPE>(data.readInt32()); - - size_t size = data.readInt32(); - void *params = const_cast<void *>(data.readInplace(size)); - - reply->writeInt32(setConfig(node, index, params, size)); - - return NO_ERROR; - } - case ENABLE_GRAPHIC_BUFFERS: { CHECK_INTERFACE(IOMX, data, reply); diff --git a/media/libstagefright/MPEG4Writer.cpp b/media/libstagefright/MPEG4Writer.cpp index 06c4c98..a47ee3a 100644 --- a/media/libstagefright/MPEG4Writer.cpp +++ b/media/libstagefright/MPEG4Writer.cpp @@ -590,6 +590,7 @@ status_t MPEG4Writer::stop() { status_t err = OK; int64_t maxDurationUs = 0; + int64_t minDurationUs = 0x7fffffffffffffffLL; for (List<Track *>::iterator it = mTracks.begin(); it != mTracks.end(); ++it) { status_t status = (*it)->stop(); @@ -601,6 +602,14 @@ status_t MPEG4Writer::stop() { if (durationUs > maxDurationUs) { maxDurationUs = durationUs; } + if (durationUs < minDurationUs) { + minDurationUs = durationUs; + } + } + + if (mTracks.size() > 1) { + LOGD("Duration from tracks range is [%lld, %lld] us", + minDurationUs, maxDurationUs); } stopWriterThread(); diff --git a/media/libstagefright/httplive/LiveSession.cpp b/media/libstagefright/httplive/LiveSession.cpp index 5979be6..f20a4cb 100644 --- a/media/libstagefright/httplive/LiveSession.cpp +++ b/media/libstagefright/httplive/LiveSession.cpp @@ -438,8 +438,7 @@ rinse_repeat: if (mSeqNumber < firstSeqNumberInPlaylist || mSeqNumber > lastSeqNumberInPlaylist) { - if (mSeqNumber < firstSeqNumberInPlaylist - && mPrevBandwidthIndex != (ssize_t)bandwidthIndex) { + if (mPrevBandwidthIndex != (ssize_t)bandwidthIndex) { // Go back to the previous bandwidth. LOGI("new bandwidth does not have the sequence number " @@ -493,8 +492,14 @@ rinse_repeat: CHECK(buffer != NULL); - CHECK_EQ((status_t)OK, - decryptBuffer(mSeqNumber - firstSeqNumberInPlaylist, buffer)); + err = decryptBuffer(mSeqNumber - firstSeqNumberInPlaylist, buffer); + + if (err != OK) { + LOGE("decryptBuffer failed w/ error %d", err); + + mDataSource->queueEOS(err); + return; + } if (buffer->size() == 0 || buffer->data()[0] != 0x47) { // Not a transport stream??? diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java index 3e930ae..bbb2228 100644 --- a/services/java/com/android/server/WindowManagerService.java +++ b/services/java/com/android/server/WindowManagerService.java @@ -583,7 +583,7 @@ public class WindowManagerService extends IWindowManager.Stub void broadcastDragStartedLw(final float touchX, final float touchY) { // Cache a base-class instance of the clip metadata so that parceling // works correctly in calling out to the apps. - mDataDescription = mData.getDescription(); + mDataDescription = (mData != null) ? mData.getDescription() : null; mNotifiedWindows.clear(); mDragInProgress = true; diff --git a/tests/HwAccelerationTest/AndroidManifest.xml b/tests/HwAccelerationTest/AndroidManifest.xml index 691aff28..7a61b3c 100644 --- a/tests/HwAccelerationTest/AndroidManifest.xml +++ b/tests/HwAccelerationTest/AndroidManifest.xml @@ -53,6 +53,15 @@ </activity> <activity + android:name="ViewLayersActivity3" + android:label="_ViewLayers3"> + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + <category android:name="android.intent.category.LAUNCHER" /> + </intent-filter> + </activity> + + <activity android:name="AlphaLayersActivity" android:label="_αLayers"> <intent-filter> diff --git a/tests/HwAccelerationTest/res/layout/view_layers_3.xml b/tests/HwAccelerationTest/res/layout/view_layers_3.xml new file mode 100644 index 0000000..a820f5f --- /dev/null +++ b/tests/HwAccelerationTest/res/layout/view_layers_3.xml @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2011 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. +--> + +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:orientation="horizontal" + android:layout_width="match_parent" + android:layout_height="match_parent"> + + <LinearLayout + android:background="#30ff0000" + android:layout_width="0dip" + android:layout_height="match_parent" + android:layout_weight="1" /> + + <LinearLayout + android:background="#3000ff00" + android:layout_width="0dip" + android:layout_height="match_parent" + android:layout_weight="1" + android:padding="12dip"> + + <ListView + android:id="@+id/list1" + android:layout_width="match_parent" + android:layout_height="match_parent" /> + + </LinearLayout> + + <LinearLayout + android:background="#300000ff" + android:layout_width="0dip" + android:layout_height="match_parent" + android:layout_weight="1" /> + +</LinearLayout> diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/ViewLayersActivity3.java b/tests/HwAccelerationTest/src/com/android/test/hwui/ViewLayersActivity3.java new file mode 100644 index 0000000..c8ae75b --- /dev/null +++ b/tests/HwAccelerationTest/src/com/android/test/hwui/ViewLayersActivity3.java @@ -0,0 +1,108 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.test.hwui; + +import android.app.Activity; +import android.content.Context; +import android.content.res.Resources; +import android.os.Bundle; +import android.util.DisplayMetrics; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ArrayAdapter; +import android.widget.ListView; +import android.widget.TextView; + +@SuppressWarnings({"UnusedDeclaration"}) +public class ViewLayersActivity3 extends Activity { + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + setContentView(R.layout.view_layers_3); + + setupList(R.id.list1); + } + + private void setupList(int listId) { + final ListView list = (ListView) findViewById(listId); + list.setAdapter(new SimpleListAdapter(this)); + list.setLayerType(View.LAYER_TYPE_HARDWARE, null); + ((View) list.getParent()).setLayerType(View.LAYER_TYPE_HARDWARE, null); + } + + private static class SimpleListAdapter extends ArrayAdapter<String> { + public SimpleListAdapter(Context context) { + super(context, android.R.layout.simple_list_item_1, DATA_LIST); + } + + @Override + public View getView(int position, View convertView, ViewGroup parent) { + TextView v = (TextView) super.getView(position, convertView, parent); + final Resources r = getContext().getResources(); + final DisplayMetrics metrics = r.getDisplayMetrics(); + v.setCompoundDrawablePadding((int) (6 * metrics.density + 0.5f)); + v.setCompoundDrawablesWithIntrinsicBounds(r.getDrawable(R.drawable.icon), + null, null, null); + return v; + } + } + + private static final String[] DATA_LIST = { + "Afghanistan", "Albania", "Algeria", "American Samoa", "Andorra", + "Angola", "Anguilla", "Antarctica", "Antigua and Barbuda", "Argentina", + "Armenia", "Aruba", "Australia", "Austria", "Azerbaijan", + "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", + "Belize", "Benin", "Bermuda", "Bhutan", "Bolivia", + "Bosnia and Herzegovina", "Botswana", "Bouvet Island", "Brazil", + "British Indian Ocean Territory", "British Virgin Islands", "Brunei", "Bulgaria", + "Burkina Faso", "Burundi", "Cote d'Ivoire", "Cambodia", "Cameroon", "Canada", "Cape Verde", + "Cayman Islands", "Central African Republic", "Chad", "Chile", "China", + "Christmas Island", "Cocos (Keeling) Islands", "Colombia", "Comoros", "Congo", + "Cook Islands", "Costa Rica", "Croatia", "Cuba", "Cyprus", "Czech Republic", + "Democratic Republic of the Congo", "Denmark", "Djibouti", "Dominica", "Dominican Republic", + "East Timor", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", + "Estonia", "Ethiopia", "Faeroe Islands", "Falkland Islands", "Fiji", "Finland", + "Former Yugoslav Republic of Macedonia", "France", "French Guiana", "French Polynesia", + "French Southern Territories", "Gabon", "Georgia", "Germany", "Ghana", "Gibraltar", + "Greece", "Greenland", "Grenada", "Guadeloupe", "Guam", "Guatemala", "Guinea", "Guinea-Bissau", + "Guyana", "Haiti", "Heard Island and McDonald Islands", "Honduras", "Hong Kong", "Hungary", + "Iceland", "India", "Indonesia", "Iran", "Iraq", "Ireland", "Israel", "Italy", "Jamaica", + "Japan", "Jordan", "Kazakhstan", "Kenya", "Kiribati", "Kuwait", "Kyrgyzstan", "Laos", + "Latvia", "Lebanon", "Lesotho", "Liberia", "Libya", "Liechtenstein", "Lithuania", "Luxembourg", + "Macau", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands", + "Martinique", "Mauritania", "Mauritius", "Mayotte", "Mexico", "Micronesia", "Moldova", + "Monaco", "Mongolia", "Montserrat", "Morocco", "Mozambique", "Myanmar", "Namibia", + "Nauru", "Nepal", "Netherlands", "Netherlands Antilles", "New Caledonia", "New Zealand", + "Nicaragua", "Niger", "Nigeria", "Niue", "Norfolk Island", "North Korea", "Northern Marianas", + "Norway", "Oman", "Pakistan", "Palau", "Panama", "Papua New Guinea", "Paraguay", "Peru", + "Philippines", "Pitcairn Islands", "Poland", "Portugal", "Puerto Rico", "Qatar", + "Reunion", "Romania", "Russia", "Rwanda", "Sqo Tome and Principe", "Saint Helena", + "Saint Kitts and Nevis", "Saint Lucia", "Saint Pierre and Miquelon", + "Saint Vincent and the Grenadines", "Samoa", "San Marino", "Saudi Arabia", "Senegal", + "Seychelles", "Sierra Leone", "Singapore", "Slovakia", "Slovenia", "Solomon Islands", + "Somalia", "South Africa", "South Georgia and the South Sandwich Islands", "South Korea", + "Spain", "Sri Lanka", "Sudan", "Suriname", "Svalbard and Jan Mayen", "Swaziland", "Sweden", + "Switzerland", "Syria", "Taiwan", "Tajikistan", "Tanzania", "Thailand", "The Bahamas", + "The Gambia", "Togo", "Tokelau", "Tonga", "Trinidad and Tobago", "Tunisia", "Turkey", + "Turkmenistan", "Turks and Caicos Islands", "Tuvalu", "Virgin Islands", "Uganda", + "Ukraine", "United Arab Emirates", "United Kingdom", + "United States", "United States Minor Outlying Islands", "Uruguay", "Uzbekistan", + "Vanuatu", "Vatican City", "Venezuela", "Vietnam", "Wallis and Futuna", "Western Sahara", + "Yemen", "Yugoslavia", "Zambia", "Zimbabwe" + }; +} diff --git a/wifi/java/android/net/wifi/WifiStateMachine.java b/wifi/java/android/net/wifi/WifiStateMachine.java index 0548b4d..df21399 100644 --- a/wifi/java/android/net/wifi/WifiStateMachine.java +++ b/wifi/java/android/net/wifi/WifiStateMachine.java @@ -61,7 +61,6 @@ import android.os.WorkSource; import android.provider.Settings; import android.util.EventLog; import android.util.Log; -import android.util.Slog; import android.app.backup.IBackupManager; import android.bluetooth.BluetoothAdapter; import android.content.BroadcastReceiver; @@ -1671,10 +1670,18 @@ public class WifiStateMachine extends HierarchicalStateMachine { nwService.startAccessPoint((WifiConfiguration) message.obj, mInterfaceName, SOFTAP_IFACE); - } catch(Exception e) { - Log.e(TAG, "Exception in startAccessPoint()"); - sendMessage(obtainMessage(CMD_UNLOAD_DRIVER, WIFI_AP_STATE_FAILED, 0)); - break; + } catch (Exception e) { + Log.e(TAG, "Exception in softap start " + e); + try { + nwService.stopAccessPoint(); + nwService.startAccessPoint((WifiConfiguration) message.obj, + mInterfaceName, + SOFTAP_IFACE); + } catch (Exception ee) { + Log.e(TAG, "Exception during softap restart : " + ee); + sendMessage(obtainMessage(CMD_UNLOAD_DRIVER, WIFI_AP_STATE_FAILED, 0)); + break; + } } Log.d(TAG, "Soft AP start successful"); setWifiApState(WIFI_AP_STATE_ENABLED); @@ -2824,13 +2831,16 @@ public class WifiStateMachine extends HierarchicalStateMachine { mInterfaceName, SOFTAP_IFACE); } catch(Exception e) { - Log.e(TAG, "Exception in nwService during soft AP set"); + Log.e(TAG, "Exception in softap set " + e); try { nwService.stopAccessPoint(); + nwService.startAccessPoint((WifiConfiguration) message.obj, + mInterfaceName, + SOFTAP_IFACE); } catch (Exception ee) { - Slog.e(TAG, "Could not stop AP, :" + ee); + Log.e(TAG, "Could not restart softap after set failed " + ee); + sendMessage(obtainMessage(CMD_UNLOAD_DRIVER, WIFI_AP_STATE_FAILED, 0)); } - sendMessage(obtainMessage(CMD_UNLOAD_DRIVER, WIFI_AP_STATE_FAILED, 0)); } break; /* Fail client mode operation when soft AP is enabled */ |
