summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Android.mk6
-rw-r--r--api/current.txt45
-rw-r--r--cmds/dumpstate/dumpstate.c1
-rw-r--r--core/java/android/content/pm/ResolveInfo.java9
-rw-r--r--core/java/android/hardware/Camera.java79
-rw-r--r--core/java/android/net/ConnectivityManager.java22
-rw-r--r--core/java/android/net/IConnectivityManager.aidl4
-rw-r--r--core/java/android/preference/PreferenceActivity.java2
-rw-r--r--core/java/android/preference/PreferenceFragment.java1
-rw-r--r--core/java/android/provider/Settings.java1
-rw-r--r--core/java/android/text/TextUtils.java11
-rw-r--r--core/java/android/view/MotionEvent.java28
-rw-r--r--core/java/android/view/TextureView.java16
-rw-r--r--core/java/android/view/ViewGroup.java4
-rw-r--r--core/java/android/view/VolumePanel.java20
-rw-r--r--core/java/android/webkit/WebSettings.java4
-rw-r--r--core/java/android/webkit/WebView.java12
-rw-r--r--core/java/android/widget/ActivityChooserModel.java59
-rw-r--r--core/java/android/widget/ActivityChooserView.java37
-rw-r--r--core/java/android/widget/AdapterView.java3
-rw-r--r--core/java/android/widget/ImageView.java53
-rw-r--r--core/java/android/widget/NumberPicker.java5
-rw-r--r--core/java/android/widget/SearchView.java2
-rw-r--r--core/java/android/widget/ShareActionProvider.java75
-rw-r--r--core/java/com/android/internal/app/ActionBarImpl.java4
-rw-r--r--core/java/com/android/internal/os/BatteryStatsImpl.java30
-rw-r--r--core/java/com/android/internal/view/menu/ActionMenuPresenter.java16
-rw-r--r--core/java/com/android/internal/view/menu/MenuBuilder.java7
-rw-r--r--core/java/com/android/internal/view/menu/MenuItemImpl.java2
-rw-r--r--core/java/com/android/internal/widget/ActionBarContextView.java9
-rw-r--r--core/java/com/android/internal/widget/ActionBarView.java25
-rw-r--r--core/java/com/android/internal/widget/PointerLocationView.java91
-rw-r--r--core/java/com/android/server/NetworkManagementSocketTagger.java3
-rw-r--r--core/jni/android/graphics/Canvas.cpp10
-rw-r--r--core/jni/android/graphics/TextLayout.h8
-rw-r--r--core/jni/android/graphics/TextLayoutCache.cpp11
-rw-r--r--core/jni/android_server_BluetoothEventLoop.cpp14
-rw-r--r--core/jni/android_util_Binder.cpp52
-rw-r--r--core/jni/android_view_GLES20Canvas.cpp6
-rw-r--r--core/res/res/drawable-hdpi/ic_lockscreen_ime.pngbin0 -> 202 bytes
-rw-r--r--core/res/res/drawable-hdpi/ic_notification_ime_default.pngbin749 -> 755 bytes
-rw-r--r--core/res/res/drawable-hdpi/overscroll_glow.pngbin30724 -> 36241 bytes
-rw-r--r--core/res/res/drawable-mdpi/ic_lockscreen_ime.pngbin0 -> 157 bytes
-rw-r--r--core/res/res/drawable-mdpi/ic_notification_ime_default.pngbin686 -> 642 bytes
-rw-r--r--core/res/res/drawable-mdpi/overscroll_glow.pngbin17073 -> 20055 bytes
-rw-r--r--core/res/res/drawable-xhdpi/ic_lockscreen_ime.pngbin0 -> 217 bytes
-rw-r--r--core/res/res/drawable-xhdpi/ic_notification_ime_default.pngbin1191 -> 1012 bytes
-rw-r--r--core/res/res/drawable-xhdpi/overscroll_glow.pngbin44139 -> 50899 bytes
-rw-r--r--core/res/res/layout-sw600dp/preference_list_content.xml7
-rw-r--r--core/res/res/layout/activity_chooser_view.xml7
-rw-r--r--core/res/res/layout/breadcrumbs_in_fragment.xml10
-rw-r--r--core/res/res/layout/keyguard_screen_password_landscape.xml16
-rw-r--r--core/res/res/layout/keyguard_screen_password_portrait.xml45
-rw-r--r--core/res/res/layout/preference_list_content.xml3
-rw-r--r--core/res/res/layout/preference_list_fragment.xml8
-rw-r--r--core/res/res/layout/volume_adjust.xml1
-rw-r--r--core/res/res/values-h720dp/dimens.xml6
-rw-r--r--core/res/res/values-w360dp/dimens.xml (renamed from core/res/res/values-port/dimens.xml)2
-rw-r--r--core/res/res/values-w500dp/dimens.xml24
-rw-r--r--core/res/res/values-w600dp/dimens.xml24
-rw-r--r--core/res/res/values-w720dp/dimens.xml5
-rw-r--r--core/res/res/values/arrays.xml3
-rwxr-xr-xcore/res/res/values/attrs.xml4
-rw-r--r--core/res/res/values/dimens.xml13
-rwxr-xr-xcore/res/res/values/strings.xml10
-rw-r--r--core/res/res/values/styles.xml2
-rw-r--r--core/tests/coretests/src/android/provider/SettingsProviderTest.java50
-rw-r--r--docs/html/guide/topics/graphics/opengl.jd54
-rw-r--r--docs/html/resources/tutorials/opengl/opengl-es10.jd4
-rw-r--r--docs/html/resources/tutorials/opengl/opengl-es20.jd4
-rw-r--r--include/camera/CameraParameters.h23
-rw-r--r--include/media/MediaProfiles.h26
-rw-r--r--include/surfaceflinger/ISurfaceComposer.h5
-rwxr-xr-xinclude/ui/KeycodeLabels.h2
-rw-r--r--libs/camera/CameraParameters.cpp1
-rw-r--r--libs/gui/ISurfaceComposer.cpp26
-rw-r--r--libs/gui/Surface.cpp3
-rw-r--r--libs/gui/SurfaceTextureClient.cpp12
-rw-r--r--libs/rs/driver/rsdBcc.cpp24
-rw-r--r--libs/rs/driver/rsdCore.cpp111
-rw-r--r--libs/rs/driver/rsdCore.h5
-rw-r--r--libs/rs/rsAllocation.cpp27
-rw-r--r--libs/rs/rsAllocation.h2
-rw-r--r--libs/rs/rsContext.cpp1
-rw-r--r--libs/rs/rsObjectBase.cpp26
-rw-r--r--libs/rs/rsObjectBase.h2
-rw-r--r--libs/rs/rsProgram.cpp21
-rw-r--r--libs/rs/rsProgram.h1
-rw-r--r--media/java/android/media/videoeditor/MediaArtistNativeHelper.java207
-rwxr-xr-xmedia/java/android/media/videoeditor/MediaProperties.java174
-rwxr-xr-xmedia/java/android/media/videoeditor/MediaVideoItem.java28
-rwxr-xr-xmedia/java/android/media/videoeditor/VideoEditor.java2
-rwxr-xr-xmedia/java/android/media/videoeditor/VideoEditorImpl.java98
-rwxr-xr-xmedia/java/android/media/videoeditor/VideoEditorProfile.java48
-rw-r--r--media/jni/android_media_MediaProfiles.cpp40
-rwxr-xr-xmedia/jni/mediaeditor/VideoEditorClasses.cpp122
-rwxr-xr-xmedia/jni/mediaeditor/VideoEditorClasses.h38
-rwxr-xr-xmedia/jni/mediaeditor/VideoEditorMain.cpp278
-rwxr-xr-xmedia/jni/mediaeditor/VideoEditorPropertiesMain.cpp19
-rw-r--r--media/libmedia/MediaProfiles.cpp59
-rw-r--r--media/libstagefright/AwesomePlayer.cpp72
-rw-r--r--media/libstagefright/codecs/on2/dec/SoftVPX.cpp2
-rw-r--r--media/libstagefright/include/AwesomePlayer.h3
-rw-r--r--media/libstagefright/omx/OMXNodeInstance.cpp5
-rwxr-xr-xmedia/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/MediaPropertiesTest.java105
-rwxr-xr-xmedia/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/VideoEditorExportTest.java16
-rw-r--r--media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/performance/VideoEditorPerformance.java9
-rwxr-xr-xmedia/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/stress/VideoEditorStressTest.java15
-rw-r--r--native/include/android/input.h1
-rw-r--r--opengl/libagl/state.cpp3
-rw-r--r--opengl/libagl/texture.cpp8
-rw-r--r--packages/SystemUI/res/drawable-hdpi/compat_mode_help_top_divider.9.pngbin155 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-hdpi/ic_notification_open.pngbin886 -> 1043 bytes
-rw-r--r--packages/SystemUI/res/drawable-hdpi/ic_sysbar_airplane_off.pngbin1091 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-hdpi/ic_sysbar_apps_default.pngbin719 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-hdpi/ic_sysbar_apps_default_land.pngbin709 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-hdpi/ic_sysbar_back_ime_default_land.pngbin443 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-hdpi/ic_sysbar_brightness_low.pngbin1126 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-hdpi/ic_sysbar_gps_on.pngbin1734 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-hdpi/ic_sysbar_ime_default_land.pngbin960 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-hdpi/ic_sysbar_notification_dnd.pngbin1384 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-hdpi/ic_sysbar_notification_dnd_off.pngbin1322 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-hdpi/ic_sysbar_rotate_off_lanscape.pngbin895 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-hdpi/ic_sysbar_rotate_off_portrait.pngbin908 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-hdpi/ic_sysbar_settings.pngbin1349 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-hdpi/ic_sysbar_shadow.9.pngbin208 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-hdpi/ic_sysbar_sound_off.pngbin1196 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-hdpi/ic_sysbar_sound_on.pngbin1186 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-hdpi/recent_overlay.pngbin277728 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-hdpi/recent_rez_border.pngbin26875 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-hdpi/shade_handlebar.9.pngbin2101 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-hdpi/shade_header_background.9.pngbin164 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-hdpi/stat_sys_battery_unknown.pngbin816 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-hdpi/stat_sys_data_in_1x.pngbin302 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-hdpi/stat_sys_data_in_3g.pngbin302 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-hdpi/stat_sys_data_in_4g.pngbin302 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-hdpi/stat_sys_data_in_e.pngbin302 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-hdpi/stat_sys_data_in_g.pngbin302 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-hdpi/stat_sys_data_in_h.pngbin302 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-hdpi/stat_sys_data_inandout_1x.pngbin302 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-hdpi/stat_sys_data_inandout_3g.pngbin302 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-hdpi/stat_sys_data_inandout_4g.pngbin302 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-hdpi/stat_sys_data_inandout_e.pngbin302 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-hdpi/stat_sys_data_inandout_g.pngbin302 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-hdpi/stat_sys_data_inandout_h.pngbin302 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-hdpi/stat_sys_data_out_1x.pngbin302 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-hdpi/stat_sys_data_out_3g.pngbin302 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-hdpi/stat_sys_data_out_4g.pngbin302 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-hdpi/stat_sys_data_out_e.pngbin302 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-hdpi/stat_sys_data_out_g.pngbin302 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-hdpi/stat_sys_data_out_h.pngbin302 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-hdpi/statusbar_background.9.pngbin119 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-hdpi/title_bar_portrait.9.pngbin172 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/ic_notification_open.pngbin611 -> 788 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/ic_sysbar_airplane_off.pngbin786 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/ic_sysbar_apps_default.pngbin663 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/ic_sysbar_apps_default_land.pngbin622 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/ic_sysbar_back_ime_default_land.pngbin375 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/ic_sysbar_brightness_low.pngbin793 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/ic_sysbar_gps_on.pngbin465 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/ic_sysbar_ime_default_land.pngbin733 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/ic_sysbar_notification_dnd.pngbin974 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/ic_sysbar_notification_dnd_off.pngbin966 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/ic_sysbar_rotate_off_lanscape.pngbin713 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/ic_sysbar_rotate_off_portrait.pngbin728 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/ic_sysbar_settings.pngbin953 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/ic_sysbar_shadow.9.pngbin156 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/ic_sysbar_sound_off.pngbin849 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/ic_sysbar_sound_on.pngbin826 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/recent_overlay.pngbin159608 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/recent_rez_border.pngbin20126 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/shade_handlebar.9.pngbin614 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/shade_header_background.9.pngbin149 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/stat_sys_battery_unknown.pngbin651 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/stat_sys_data_in_1x.pngbin92 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/stat_sys_data_in_3g.pngbin92 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/stat_sys_data_in_4g.pngbin92 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/stat_sys_data_in_e.pngbin92 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/stat_sys_data_in_g.pngbin92 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/stat_sys_data_in_h.pngbin92 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/stat_sys_data_inandout_1x.pngbin92 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/stat_sys_data_inandout_3g.pngbin92 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/stat_sys_data_inandout_4g.pngbin92 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/stat_sys_data_inandout_e.pngbin92 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/stat_sys_data_inandout_g.pngbin92 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/stat_sys_data_inandout_h.pngbin92 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/stat_sys_data_out_1x.pngbin92 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/stat_sys_data_out_3g.pngbin92 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/stat_sys_data_out_4g.pngbin92 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/stat_sys_data_out_e.pngbin92 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/stat_sys_data_out_g.pngbin92 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/stat_sys_data_out_h.pngbin92 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/statusbar_background.9.pngbin119 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-mdpi/title_bar_portrait.9.pngbin160 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-nodpi/bg_scrim_notification.pngbin55518 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-nodpi/compat_mode_help_bg.pngbin2561 -> 2067 bytes
-rw-r--r--packages/SystemUI/res/drawable-nodpi/notify_glow_back.pngbin57373 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-nodpi/notify_item_glow_left.pngbin99 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-nodpi/notify_item_glow_top.pngbin104 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-nodpi/panel_notification.pngbin224 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-sw600dp-hdpi/stat_sys_battery_unknown.pngbin1089 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-sw600dp-mdpi/stat_sys_battery_unknown.pngbin802 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-sw600dp-xhdpi/stat_sys_battery_unknown.pngbin1335 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-xhdpi/ic_notification_open.pngbin0 -> 1310 bytes
-rw-r--r--packages/SystemUI/res/drawable-xhdpi/ic_sysbar_airplane_off.pngbin1455 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-xhdpi/ic_sysbar_apps_default.pngbin901 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-xhdpi/ic_sysbar_apps_default_land.pngbin919 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-xhdpi/ic_sysbar_back_ime_default_land.pngbin501 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-xhdpi/ic_sysbar_brightness_low.pngbin1602 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-xhdpi/ic_sysbar_gps_on.pngbin3199 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-xhdpi/ic_sysbar_ime_default_land.pngbin1165 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-xhdpi/ic_sysbar_notification_dnd.pngbin1794 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-xhdpi/ic_sysbar_notification_dnd_off.pngbin1767 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-xhdpi/ic_sysbar_rotate_off_lanscape.pngbin1078 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-xhdpi/ic_sysbar_rotate_off_portrait.pngbin1076 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-xhdpi/ic_sysbar_settings.pngbin1865 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-xhdpi/ic_sysbar_shadow.9.pngbin367 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-xhdpi/ic_sysbar_sound_off.pngbin1637 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-xhdpi/ic_sysbar_sound_on.pngbin1601 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-xhdpi/stat_sys_battery_unknown.pngbin1000 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-xhdpi/stat_sys_data_in_1x.pngbin322 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-xhdpi/stat_sys_data_in_3g.pngbin322 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-xhdpi/stat_sys_data_in_4g.pngbin322 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-xhdpi/stat_sys_data_in_e.pngbin322 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-xhdpi/stat_sys_data_in_g.pngbin322 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-xhdpi/stat_sys_data_in_h.pngbin322 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-xhdpi/stat_sys_data_inandout_1x.pngbin322 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-xhdpi/stat_sys_data_inandout_3g.pngbin322 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-xhdpi/stat_sys_data_inandout_4g.pngbin322 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-xhdpi/stat_sys_data_inandout_e.pngbin322 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-xhdpi/stat_sys_data_inandout_g.pngbin322 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-xhdpi/stat_sys_data_inandout_h.pngbin322 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-xhdpi/stat_sys_data_out_1x.pngbin322 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-xhdpi/stat_sys_data_out_3g.pngbin322 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-xhdpi/stat_sys_data_out_4g.pngbin322 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-xhdpi/stat_sys_data_out_e.pngbin322 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-xhdpi/stat_sys_data_out_g.pngbin322 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable-xhdpi/stat_sys_data_out_h.pngbin322 -> 0 bytes
-rw-r--r--packages/SystemUI/res/drawable/compat_mode_help_bg.pngbin2067 -> 0 bytes
-rw-r--r--packages/SystemUI/res/layout/navigation_bar.xml101
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java23
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java84
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java80
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java20
-rw-r--r--policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java4
-rw-r--r--policy/src/com/android/internal/policy/impl/LockScreen.java10
-rw-r--r--policy/src/com/android/internal/policy/impl/PasswordUnlockScreen.java70
-rw-r--r--policy/src/com/android/internal/policy/impl/PhoneWindow.java21
-rwxr-xr-xpolicy/src/com/android/internal/policy/impl/PhoneWindowManager.java87
-rw-r--r--services/input/InputDispatcher.cpp59
-rw-r--r--services/input/InputDispatcher.h18
-rw-r--r--services/input/InputListener.cpp19
-rw-r--r--services/input/InputListener.h20
-rw-r--r--services/input/InputReader.cpp1534
-rw-r--r--services/input/InputReader.h309
-rw-r--r--services/input/tests/InputReader_test.cpp509
-rw-r--r--services/java/com/android/server/ConnectivityService.java47
-rw-r--r--services/java/com/android/server/MountService.java9
-rw-r--r--services/java/com/android/server/am/ActivityManagerService.java233
-rw-r--r--services/java/com/android/server/am/BroadcastRecord.java4
-rw-r--r--services/java/com/android/server/net/NetworkPolicyManagerService.java127
-rw-r--r--services/java/com/android/server/pm/PackageManagerService.java10
-rw-r--r--services/jni/com_android_server_InputManager.cpp68
-rw-r--r--services/sensorservice/Fusion.cpp27
-rw-r--r--services/sensorservice/Fusion.h4
-rw-r--r--services/sensorservice/mat.h23
-rw-r--r--services/surfaceflinger/Layer.cpp10
-rw-r--r--services/surfaceflinger/Layer.h3
-rw-r--r--services/surfaceflinger/LayerBase.cpp5
-rw-r--r--services/surfaceflinger/LayerBase.h2
-rw-r--r--services/surfaceflinger/SurfaceFlinger.cpp23
-rw-r--r--services/surfaceflinger/SurfaceFlinger.h2
-rw-r--r--telephony/java/com/android/internal/telephony/IccCard.java3
-rw-r--r--tests/BiDiTests/res/layout/basic.xml14
-rw-r--r--tests/BiDiTests/res/values/strings.xml1
-rw-r--r--tests/DumpRenderTree/src/com/android/dumprendertree/FsUtils.java2
-rw-r--r--tests/DumpRenderTree/src/com/android/dumprendertree/forwarder/ForwardService.java14
-rw-r--r--tests/RenderScriptTests/tests/src/com/android/rs/test/RSTestCore.java1
-rw-r--r--tests/RenderScriptTests/tests/src/com/android/rs/test/UT_foreach.java56
-rw-r--r--tests/RenderScriptTests/tests/src/com/android/rs/test/foreach.rs42
-rw-r--r--tools/aapt/Command.cpp29
-rw-r--r--tools/aapt/Package.cpp9
-rw-r--r--tools/aapt/Resource.cpp4
-rw-r--r--wifi/java/android/net/wifi/WifiNative.java97
-rw-r--r--wifi/java/android/net/wifi/p2p/WifiP2pConfig.java4
-rw-r--r--wifi/java/android/net/wifi/p2p/WifiP2pDevice.java8
-rw-r--r--wifi/java/android/net/wifi/p2p/WifiP2pService.java37
287 files changed, 4616 insertions, 2029 deletions
diff --git a/Android.mk b/Android.mk
index a0b80e4..fdf0933 100644
--- a/Android.mk
+++ b/Android.mk
@@ -319,6 +319,9 @@ fwbase_dirs_to_document := \
# include definition of libcore_to_document
include $(LOCAL_PATH)/../../libcore/Docs.mk
+# include definition of libfilterfw_to_document
+include $(LOCAL_PATH)/../../system/media/mca/Docs.mk
+
non_base_dirs := \
../../external/apache-http/src/org/apache/http
@@ -335,7 +338,8 @@ html_dirs := \
framework_docs_LOCAL_SRC_FILES := \
$(call find-other-java-files, $(dirs_to_document)) \
$(call find-other-html-files, $(html_dirs)) \
- $(addprefix ../../libcore/, $(call libcore_to_document, $(LOCAL_PATH)/../../libcore))
+ $(addprefix ../../libcore/, $(call libcore_to_document, $(LOCAL_PATH)/../../libcore)) \
+ $(addprefix ../../system/media/mca/, $(call libfilterfw_to_document, $(LOCAL_PATH)/../../system/media/mca))
# This is used by ide.mk as the list of source files that are
# always included.
diff --git a/api/current.txt b/api/current.txt
index 3ea70b7..cd85eea 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -9235,7 +9235,11 @@ package android.hardware {
public static class Camera.Face {
ctor public Camera.Face();
+ field public int id;
+ field public android.graphics.Point leftEye;
+ field public android.graphics.Point mouth;
field public android.graphics.Rect rect;
+ field public android.graphics.Point rightEye;
field public int score;
}
@@ -11267,6 +11271,37 @@ package android.media.audiofx {
}
+package android.media.effect {
+
+ public abstract class Effect {
+ ctor public Effect();
+ method public abstract void apply(int, int, int, int);
+ method public abstract java.lang.String getName();
+ method public abstract void release();
+ method public abstract void setParameter(java.lang.String, java.lang.Object);
+ method public void setUpdateListener(android.media.effect.EffectUpdateListener);
+ }
+
+ public class EffectContext {
+ method public static android.media.effect.EffectContext createWithCurrentGlContext();
+ method public android.media.effect.EffectFactory getFactory();
+ method public void release();
+ }
+
+ public class EffectFactory {
+ method public android.media.effect.Effect createEffect(java.lang.String);
+ method public static boolean isEffectSupported(java.lang.String);
+ field public static final java.lang.String EFFECT_BRIGHTNESS = "BrightnessEffect";
+ field public static final java.lang.String EFFECT_CONTRAST = "ContrastEffect";
+ field public static final java.lang.String EFFECT_FISHEYE = "FisheyeEffect";
+ }
+
+ public abstract interface EffectUpdateListener {
+ method public abstract void onEffectUpdated(android.media.effect.Effect, java.lang.Object);
+ }
+
+}
+
package android.mtp {
public final class MtpConstants {
@@ -11400,7 +11435,7 @@ package android.net {
method public android.net.NetworkInfo getActiveNetworkInfo();
method public android.net.NetworkQuotaInfo getActiveNetworkQuotaInfo();
method public android.net.NetworkInfo[] getAllNetworkInfo();
- method public boolean getBackgroundDataSetting();
+ method public deprecated boolean getBackgroundDataSetting();
method public android.net.NetworkInfo getNetworkInfo(int);
method public int getNetworkPreference();
method public static boolean isNetworkTypeValid(int);
@@ -17056,7 +17091,7 @@ package android.provider {
field public static final java.lang.String ALLOWED_GEOLOCATION_ORIGINS = "allowed_geolocation_origins";
field public static final java.lang.String ALLOW_MOCK_LOCATION = "mock_location";
field public static final java.lang.String ANDROID_ID = "android_id";
- field public static final java.lang.String BACKGROUND_DATA = "background_data";
+ field public static final deprecated java.lang.String BACKGROUND_DATA = "background_data";
field public static final java.lang.String BLUETOOTH_ON = "bluetooth_on";
field public static final android.net.Uri CONTENT_URI;
field public static final java.lang.String DATA_ROAMING = "data_roaming";
@@ -22284,6 +22319,7 @@ package android.view {
field public static final int AXIS_RZ = 14; // 0xe
field public static final int AXIS_SIZE = 3; // 0x3
field public static final int AXIS_THROTTLE = 19; // 0x13
+ field public static final int AXIS_TILT = 25; // 0x19
field public static final int AXIS_TOOL_MAJOR = 6; // 0x6
field public static final int AXIS_TOOL_MINOR = 7; // 0x7
field public static final int AXIS_TOUCH_MAJOR = 4; // 0x4
@@ -26658,11 +26694,16 @@ package android.widget {
public class ShareActionProvider extends android.view.ActionProvider {
ctor public ShareActionProvider(android.content.Context);
method public android.view.View onCreateActionView();
+ method public void setOnShareTargetSelectedListener(android.widget.ShareActionProvider.OnShareTargetSelectedListener);
method public void setShareHistoryFileName(java.lang.String);
method public void setShareIntent(android.content.Intent);
field public static final java.lang.String DEFAULT_SHARE_HISTORY_FILE_NAME = "share_history.xml";
}
+ public static abstract interface ShareActionProvider.OnShareTargetSelectedListener {
+ method public abstract boolean onShareTargetSelected(android.widget.ShareActionProvider, android.content.Intent);
+ }
+
public class SimpleAdapter extends android.widget.BaseAdapter implements android.widget.Filterable {
ctor public SimpleAdapter(android.content.Context, java.util.List<? extends java.util.Map<java.lang.String, ?>>, int, java.lang.String[], int[]);
method public int getCount();
diff --git a/cmds/dumpstate/dumpstate.c b/cmds/dumpstate/dumpstate.c
index c2beb74..836cf15 100644
--- a/cmds/dumpstate/dumpstate.c
+++ b/cmds/dumpstate/dumpstate.c
@@ -79,6 +79,7 @@ static void dumpstate() {
dump_file("VMALLOC INFO", "/proc/vmallocinfo");
dump_file("SLAB INFO", "/proc/slabinfo");
dump_file("ZONEINFO", "/proc/zoneinfo");
+ dump_file("PAGETYPEINFO", "/proc/pagetypeinfo");
if (screenshot_path[0]) {
LOGI("taking screenshot\n");
diff --git a/core/java/android/content/pm/ResolveInfo.java b/core/java/android/content/pm/ResolveInfo.java
index 74e756b..bcd599b 100644
--- a/core/java/android/content/pm/ResolveInfo.java
+++ b/core/java/android/content/pm/ResolveInfo.java
@@ -113,7 +113,12 @@ public class ResolveInfo implements Parcelable {
* containing the resolved component.
*/
public String resolvePackageName;
-
+
+ /**
+ * @hide Target comes from system process?
+ */
+ public boolean system;
+
/**
* Retrieve the current textual label associated with this resolution. This
* will call back on the given PackageManager to load the label from
@@ -261,6 +266,7 @@ public class ResolveInfo implements Parcelable {
TextUtils.writeToParcel(nonLocalizedLabel, dest, parcelableFlags);
dest.writeInt(icon);
dest.writeString(resolvePackageName);
+ dest.writeInt(system ? 1 : 0);
}
public static final Creator<ResolveInfo> CREATOR
@@ -300,6 +306,7 @@ public class ResolveInfo implements Parcelable {
= TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source);
icon = source.readInt();
resolvePackageName = source.readString();
+ system = source.readInt() != 0;
}
public static class DisplayNameComparator
diff --git a/core/java/android/hardware/Camera.java b/core/java/android/hardware/Camera.java
index cab8457..08bb133 100644
--- a/core/java/android/hardware/Camera.java
+++ b/core/java/android/hardware/Camera.java
@@ -1162,6 +1162,43 @@ public class Camera {
* @see #startFaceDetection(int)
*/
public int score;
+
+ /**
+ * An unique id per face while the face is visible to the tracker. If
+ * the face leaves the field-of-view and comes back, it will get a new
+ * id. This is an optional field, may not be supported on all devices.
+ * If not supported, id will always be set to -1. The optional fields
+ * are supported as a set. Either they are all valid, or none of them
+ * are.
+ */
+ public int id = -1;
+
+ /**
+ * The coordinates of the center of the left eye. The coordinates are in
+ * the same space as the ones for {@link #rect}. This is an optional
+ * field, may not be supported on all devices. If not supported, the
+ * value will always be set to null. The optional fields are supported
+ * as a set. Either they are all valid, or none of them are.
+ */
+ public Point leftEye = null;
+
+ /**
+ * The coordinates of the center of the right eye. The coordinates are
+ * in the same space as the ones for {@link #rect}.This is an optional
+ * field, may not be supported on all devices. If not supported, the
+ * value will always be set to null. The optional fields are supported
+ * as a set. Either they are all valid, or none of them are.
+ */
+ public Point rightEye = null;
+
+ /**
+ * The coordinates of the center of the mouth. The coordinates are in
+ * the same space as the ones for {@link #rect}. This is an optional
+ * field, may not be supported on all devices. If not supported, the
+ * value will always be set to null. The optional fields are supported
+ * as a set. Either they are all valid, or none of them are.
+ */
+ public Point mouth = null;
}
// Error codes match the enum in include/ui/Camera.h
@@ -1613,17 +1650,34 @@ public class Camera {
/**
* Continuous auto focus mode intended for video recording. The camera
- * continuously tries to focus. This is ideal for shooting video.
- * Applications still can call {@link
- * #takePicture(Camera.ShutterCallback, Camera.PictureCallback,
- * Camera.PictureCallback)} in this mode but the subject may not be in
- * focus. Auto focus starts when the parameter is set. Applications
- * should not call {@link #autoFocus(AutoFocusCallback)} in this mode.
- * To stop continuous focus, applications should change the focus mode
- * to other modes.
+ * continuously tries to focus. This is the best choice for video
+ * recording because the focus changes smoothly . Applications still can
+ * call {@link #takePicture(Camera.ShutterCallback,
+ * Camera.PictureCallback, Camera.PictureCallback)} in this mode but the
+ * subject may not be in focus. Auto focus starts when the parameter is
+ * set. Applications should not call {@link
+ * #autoFocus(AutoFocusCallback)} in this mode. To stop continuous
+ * focus, applications should change the focus mode to other modes.
*/
public static final String FOCUS_MODE_CONTINUOUS_VIDEO = "continuous-video";
+ /**
+ * Continuous auto focus mode intended for taking pictures. The camera
+ * continuously tries to focus. The speed of focus change is more
+ * aggressive than {@link #FOCUS_MODE_CONTINUOUS_VIDEO}. Auto focus
+ * starts when the parameter is set. If applications call {@link
+ * #autoFocus(AutoFocusCallback)} in this mode, the focus callback will
+ * immediately return with a boolean that indicates whether the focus is
+ * sharp or not. The apps can then decide if they want to take a picture
+ * immediately or to change the focus mode to auto, and run a full
+ * autofocus cycle. To stop continuous focus, applications should change
+ * the focus mode to other modes.
+ *
+ * @see #FOCUS_MODE_CONTINUOUS_VIDEO
+ * @hide
+ */
+ public static final String FOCUS_MODE_CONTINUOUS_PICTURE = "continuous-picture";
+
// Indices for focus distance array.
/**
* The array index of near focus distance for use with
@@ -2389,13 +2443,16 @@ public class Camera {
}
/**
- * Sets the white balance.
+ * Sets the white balance. Changing the setting will release the
+ * auto-white balance lock.
*
* @param value new white balance.
* @see #getWhiteBalance()
+ * @see #setAutoWhiteBalanceLock()
*/
public void setWhiteBalance(String value) {
set(KEY_WHITE_BALANCE, value);
+ set(KEY_AUTO_WHITEBALANCE_LOCK, FALSE);
}
/**
@@ -2806,6 +2863,9 @@ public class Camera {
* set the lock to false. However, the lock can be re-enabled before
* preview is re-started to keep the same white balance parameters.</p>
*
+ * <p> Changing the white balance mode with {@link #setWhiteBalance}
+ * will release the auto-white balance lock if it is set.</p>
+ *
* <p>Exposure compensation, in conjunction with re-enabling the AE and
* AWB locks after each still capture, can be used to capture an
* exposure-bracketed burst of images, for example. Auto-white balance
@@ -2828,6 +2888,7 @@ public class Camera {
* auto-white balance routine is free to run normally.
*
* @see #getAutoWhiteBalanceLock()
+ * @see #setWhiteBalance(String)
*/
public void setAutoWhiteBalanceLock(boolean toggle) {
set(KEY_AUTO_WHITEBALANCE_LOCK, toggle ? TRUE : FALSE);
diff --git a/core/java/android/net/ConnectivityManager.java b/core/java/android/net/ConnectivityManager.java
index 53fd50d..9c96883 100644
--- a/core/java/android/net/ConnectivityManager.java
+++ b/core/java/android/net/ConnectivityManager.java
@@ -21,6 +21,7 @@ import static com.android.internal.util.Preconditions.checkNotNull;
import android.annotation.SdkConstant;
import android.annotation.SdkConstant.SdkConstantType;
import android.os.Binder;
+import android.os.Build.VERSION_CODES;
import android.os.RemoteException;
import java.net.InetAddress;
@@ -503,16 +504,19 @@ public class ConnectivityManager {
* <p>
* All applications that have background services that use the network
* should listen to {@link #ACTION_BACKGROUND_DATA_SETTING_CHANGED}.
+ * <p>
+ * As of {@link VERSION_CODES#ICE_CREAM_SANDWICH}, availability of
+ * background data depends on several combined factors, and this method will
+ * always return {@code true}. Instead, when background data is unavailable,
+ * {@link #getActiveNetworkInfo()} will now appear disconnected.
*
* @return Whether background data usage is allowed.
*/
+ @Deprecated
public boolean getBackgroundDataSetting() {
- try {
- return mService.getBackgroundDataSetting();
- } catch (RemoteException e) {
- // Err on the side of safety
- return false;
- }
+ // assume that background data is allowed; final authority is
+ // NetworkInfo which may be blocked.
+ return true;
}
/**
@@ -525,11 +529,9 @@ public class ConnectivityManager {
* @see #getBackgroundDataSetting()
* @hide
*/
+ @Deprecated
public void setBackgroundDataSetting(boolean allowBackgroundData) {
- try {
- mService.setBackgroundDataSetting(allowBackgroundData);
- } catch (RemoteException e) {
- }
+ // ignored
}
/**
diff --git a/core/java/android/net/IConnectivityManager.aidl b/core/java/android/net/IConnectivityManager.aidl
index f391200..1b95b60 100644
--- a/core/java/android/net/IConnectivityManager.aidl
+++ b/core/java/android/net/IConnectivityManager.aidl
@@ -63,10 +63,6 @@ interface IConnectivityManager
boolean requestRouteToHostAddress(int networkType, in byte[] hostAddress);
- boolean getBackgroundDataSetting();
-
- void setBackgroundDataSetting(boolean allowBackgroundData);
-
boolean getMobileDataEnabled();
void setMobileDataEnabled(boolean enabled);
diff --git a/core/java/android/preference/PreferenceActivity.java b/core/java/android/preference/PreferenceActivity.java
index 78c9010..1029161 100644
--- a/core/java/android/preference/PreferenceActivity.java
+++ b/core/java/android/preference/PreferenceActivity.java
@@ -589,8 +589,6 @@ public abstract class PreferenceActivity extends ListActivity implements
mPreferenceManager.setOnPreferenceTreeClickListener(this);
}
- getListView().setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
-
// see if we should show Back/Next buttons
Intent intent = getIntent();
if (intent.getBooleanExtra(EXTRA_PREFS_SHOW_BUTTON_BAR, false)) {
diff --git a/core/java/android/preference/PreferenceFragment.java b/core/java/android/preference/PreferenceFragment.java
index f6ba7f7..bdd858b 100644
--- a/core/java/android/preference/PreferenceFragment.java
+++ b/core/java/android/preference/PreferenceFragment.java
@@ -159,7 +159,6 @@ public abstract class PreferenceFragment extends Fragment implements
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
- getListView().setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
if (mHavePrefs) {
bindPreferences();
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index de06f20..554afd2 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -3081,6 +3081,7 @@ public final class Settings {
* Whether background data usage is allowed by the user. See
* ConnectivityManager for more info.
*/
+ @Deprecated
public static final String BACKGROUND_DATA = "background_data";
/**
diff --git a/core/java/android/text/TextUtils.java b/core/java/android/text/TextUtils.java
index 29c9853..83ef6ce 100644
--- a/core/java/android/text/TextUtils.java
+++ b/core/java/android/text/TextUtils.java
@@ -259,6 +259,17 @@ public class TextUtils {
}
/**
+ * Returns list of multiple {@link CharSequence} joined into a single
+ * {@link CharSequence} separated by localized delimiter such as ", ".
+ *
+ * @hide
+ */
+ public static CharSequence join(Iterable<CharSequence> list) {
+ final CharSequence delimiter = Resources.getSystem().getText(R.string.list_delimeter);
+ return join(delimiter, list);
+ }
+
+ /**
* Returns a string containing the tokens joined by delimiters.
* @param tokens an array objects to be joined. Strings will be formed from
* the objects by calling object.toString().
diff --git a/core/java/android/view/MotionEvent.java b/core/java/android/view/MotionEvent.java
index da5c7b2..8e0ab1a 100644
--- a/core/java/android/view/MotionEvent.java
+++ b/core/java/android/view/MotionEvent.java
@@ -619,6 +619,11 @@ public final class MotionEvent extends InputEvent implements Parcelable {
* indicates that the major axis of contact is oriented to the left.
* The full range is from -PI/2 radians (finger pointing fully left) to PI/2 radians
* (finger pointing fully right).
+ * <li>For a stylus, the orientation indicates the direction in which the stylus
+ * is pointing in relation to the vertical axis of the current orientation of the screen.
+ * The range is from -PI radians to PI radians, where 0 is pointing up,
+ * -PI/2 radians is pointing left, -PI or PI radians is pointing down, and PI/2 radians
+ * is pointing right. See also {@link #AXIS_TILT}.
* </ul>
* </p>
*
@@ -883,8 +888,8 @@ public final class MotionEvent extends InputEvent implements Parcelable {
* <p>
* <ul>
* <li>For a stylus, reports the distance of the stylus from the screen.
- * The value is nominally measured in millimeters where 0.0 indicates direct contact
- * and larger values indicate increasing distance from the surface.
+ * A value of 0.0 indicates direct contact and larger values indicate increasing
+ * distance from the surface.
* </ul>
* </p>
*
@@ -896,6 +901,24 @@ public final class MotionEvent extends InputEvent implements Parcelable {
public static final int AXIS_DISTANCE = 24;
/**
+ * Axis constant: Tilt axis of a motion event.
+ * <p>
+ * <ul>
+ * <li>For a stylus, reports the tilt angle of the stylus in radians where
+ * 0 radians indicates that the stylus is being held perpendicular to the
+ * surface, and PI/2 radians indicates that the stylus is being held flat
+ * against the surface.
+ * </ul>
+ * </p>
+ *
+ * @see #getAxisValue(int, int)
+ * @see #getHistoricalAxisValue(int, int, int)
+ * @see MotionEvent.PointerCoords#getAxisValue(int, int)
+ * @see InputDevice#getMotionRange
+ */
+ public static final int AXIS_TILT = 25;
+
+ /**
* Axis constant: Generic 1 axis of a motion event.
* The interpretation of a generic axis is device-specific.
*
@@ -1104,6 +1127,7 @@ public final class MotionEvent extends InputEvent implements Parcelable {
names.append(AXIS_GAS, "AXIS_GAS");
names.append(AXIS_BRAKE, "AXIS_BRAKE");
names.append(AXIS_DISTANCE, "AXIS_DISTANCE");
+ names.append(AXIS_TILT, "AXIS_TILT");
names.append(AXIS_GENERIC_1, "AXIS_GENERIC_1");
names.append(AXIS_GENERIC_2, "AXIS_GENERIC_2");
names.append(AXIS_GENERIC_3, "AXIS_GENERIC_3");
diff --git a/core/java/android/view/TextureView.java b/core/java/android/view/TextureView.java
index b72222e..9d959fb 100644
--- a/core/java/android/view/TextureView.java
+++ b/core/java/android/view/TextureView.java
@@ -261,6 +261,7 @@ public class TextureView extends View {
@Override
public final void draw(Canvas canvas) {
applyUpdate();
+ applyTransformMatrix();
}
/**
@@ -315,11 +316,7 @@ public class TextureView extends View {
}
applyUpdate();
-
- if (mMatrixChanged) {
- mLayer.setTransform(mMatrix);
- mMatrixChanged = false;
- }
+ applyTransformMatrix();
return mLayer;
}
@@ -386,7 +383,7 @@ public class TextureView extends View {
public void setTransform(Matrix transform) {
mMatrix.set(transform);
mMatrixChanged = true;
- invalidate();
+ invalidateParentIfNeeded();
}
/**
@@ -410,6 +407,13 @@ public class TextureView extends View {
return transform;
}
+ private void applyTransformMatrix() {
+ if (mMatrixChanged) {
+ mLayer.setTransform(mMatrix);
+ mMatrixChanged = false;
+ }
+ }
+
/**
* <p>Returns a {@link android.graphics.Bitmap} representation of the content
* of the associated surface texture. If the surface texture is not available,
diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java
index 08cb270..8fa1922 100644
--- a/core/java/android/view/ViewGroup.java
+++ b/core/java/android/view/ViewGroup.java
@@ -5012,7 +5012,9 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
*/
public void requestTransitionStart(LayoutTransition transition) {
ViewRootImpl viewAncestor = getViewRootImpl();
- viewAncestor.requestTransitionStart(transition);
+ if (viewAncestor != null) {
+ viewAncestor.requestTransitionStart(transition);
+ }
}
@Override
diff --git a/core/java/android/view/VolumePanel.java b/core/java/android/view/VolumePanel.java
index cb85e5f..e1aa9a4 100644
--- a/core/java/android/view/VolumePanel.java
+++ b/core/java/android/view/VolumePanel.java
@@ -101,6 +101,8 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie
/** Dialog's content view */
private final View mView;
+ /** The visible portion of the volume overlay */
+ private final ViewGroup mPanel;
/** Contains the sliders and their touchable icons */
private final ViewGroup mSliderGroup;
/** The button that expands the dialog to show all sliders */
@@ -173,10 +175,23 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie
View view = mView = inflater.inflate(R.layout.volume_adjust, null);
mView.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
+ // Dismiss the dialog if the user touches outside the visible area. This is not
+ // handled by the usual dialog dismissing code because there is a region above
+ // the panel (marginTop) that is still within the dialog.
+ if (event.getAction() == MotionEvent.ACTION_DOWN) {
+ int x = (int) event.getX();
+ int y = (int) event.getY();
+ if (x < mPanel.getLeft() || x > mPanel.getRight() || y < mPanel.getTop()
+ || y > mPanel.getBottom()) {
+ forceTimeout();
+ return true;
+ }
+ }
resetTimeout();
return true;
}
});
+ mPanel = (ViewGroup) mView.findViewById(R.id.visible_panel);
mSliderGroup = (ViewGroup) mView.findViewById(R.id.slider_group);
mMoreButton = (ImageView) mView.findViewById(R.id.expand_button);
mDivider = (ImageView) mView.findViewById(R.id.expand_button_divider);
@@ -639,6 +654,11 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie
sendMessageDelayed(obtainMessage(MSG_TIMEOUT), TIMEOUT_DELAY);
}
+ private void forceTimeout() {
+ removeMessages(MSG_TIMEOUT);
+ sendMessage(obtainMessage(MSG_TIMEOUT));
+ }
+
public void onProgressChanged(SeekBar seekBar, int progress,
boolean fromUser) {
final Object tag = seekBar.getTag();
diff --git a/core/java/android/webkit/WebSettings.java b/core/java/android/webkit/WebSettings.java
index 642aa22..77f6776 100644
--- a/core/java/android/webkit/WebSettings.java
+++ b/core/java/android/webkit/WebSettings.java
@@ -1807,7 +1807,9 @@ public class WebSettings {
* @hide
*/
public void setProperty(String key, String value) {
- mWebView.nativeSetProperty(key, value);
+ if (mWebView.nativeSetProperty(key, value)) {
+ mWebView.contentInvalidateAll();
+ }
}
/**
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java
index 6374b47..5d776fd 100644
--- a/core/java/android/webkit/WebView.java
+++ b/core/java/android/webkit/WebView.java
@@ -9036,15 +9036,6 @@ public class WebView extends AbsoluteLayout
}
/**
- * Enable expanded tiles bound for smoother scrolling.
- *
- * @hide only used by the Browser
- */
- public void setExpandedTileBounds(boolean enabled) {
- nativeSetExpandedTileBounds(enabled);
- }
-
- /**
* Set the time to wait between passing touches to WebCore. See also the
* TOUCH_SENT_INTERVAL member for further discussion.
*
@@ -9273,7 +9264,6 @@ public class WebView extends AbsoluteLayout
static final int NO_LEFTEDGE = -1;
native int nativeGetBlockLeftEdge(int x, int y, float scale);
- private native void nativeSetExpandedTileBounds(boolean enabled);
private native void nativeUseHardwareAccelSkia(boolean enabled);
// Returns a pointer to the scrollable LayerAndroid at the given point.
@@ -9288,6 +9278,6 @@ public class WebView extends AbsoluteLayout
*/
private native boolean nativeScrollLayer(int layer, int newX, int newY);
private native int nativeGetBackgroundColor();
- native void nativeSetProperty(String key, String value);
+ native boolean nativeSetProperty(String key, String value);
native String nativeGetProperty(String key);
}
diff --git a/core/java/android/widget/ActivityChooserModel.java b/core/java/android/widget/ActivityChooserModel.java
index 4b0a6da..9fea506 100644
--- a/core/java/android/widget/ActivityChooserModel.java
+++ b/core/java/android/widget/ActivityChooserModel.java
@@ -131,6 +131,30 @@ public class ActivityChooserModel extends DataSetObservable {
}
/**
+ * Listener for choosing an activity.
+ */
+ public interface OnChooseActivityListener {
+
+ /**
+ * Called when an activity has been chosen. The client can decide whether
+ * an activity can be chosen and if so the caller of
+ * {@link ActivityChooserModel#chooseActivity(int)} will receive and {@link Intent}
+ * for launching it.
+ * <p>
+ * <strong>Note:</strong> Modifying the intent is not permitted and
+ * any changes to the latter will be ignored.
+ * </p>
+ *
+ * @param host The listener's host model.
+ * @param intent The intent for launching the chosen activity.
+ * @return Whether the intent is handled and should not be delivered to clients.
+ *
+ * @see ActivityChooserModel#chooseActivity(int)
+ */
+ public boolean onChooseActivity(ActivityChooserModel host, Intent intent);
+ }
+
+ /**
* Flag for selecting debug mode.
*/
private static final boolean DEBUG = false;
@@ -287,6 +311,11 @@ public class ActivityChooserModel extends DataSetObservable {
private final Handler mHandler = new Handler();
/**
+ * Policy for controlling how the model handles chosen activities.
+ */
+ private OnChooseActivityListener mActivityChoserModelPolicy;
+
+ /**
* Gets the data model backed by the contents of the provided file with historical data.
* Note that only one data model is backed by a given file, thus multiple calls with
* the same file name will return the same model instance. If no such instance is present
@@ -426,9 +455,11 @@ public class ActivityChooserModel extends DataSetObservable {
* the client solely to let additional customization before the start.
* </p>
*
- * @return Whether adding succeeded.
+ * @return An {@link Intent} for launching the activity or null if the
+ * policy has consumed the intent.
*
* @see HistoricalRecord
+ * @see OnChooseActivityListener
*/
public Intent chooseActivity(int index) {
ActivityResolveInfo chosenActivity = mActivites.get(index);
@@ -436,17 +467,37 @@ public class ActivityChooserModel extends DataSetObservable {
ComponentName chosenName = new ComponentName(
chosenActivity.resolveInfo.activityInfo.packageName,
chosenActivity.resolveInfo.activityInfo.name);
- HistoricalRecord historicalRecord = new HistoricalRecord(chosenName,
- System.currentTimeMillis(), DEFAULT_HISTORICAL_RECORD_WEIGHT);
- addHisoricalRecord(historicalRecord);
Intent choiceIntent = new Intent(mIntent);
choiceIntent.setComponent(chosenName);
+ if (mActivityChoserModelPolicy != null) {
+ // Do not allow the policy to change the intent.
+ Intent choiceIntentCopy = new Intent(choiceIntent);
+ final boolean handled = mActivityChoserModelPolicy.onChooseActivity(this,
+ choiceIntentCopy);
+ if (handled) {
+ return null;
+ }
+ }
+
+ HistoricalRecord historicalRecord = new HistoricalRecord(chosenName,
+ System.currentTimeMillis(), DEFAULT_HISTORICAL_RECORD_WEIGHT);
+ addHisoricalRecord(historicalRecord);
+
return choiceIntent;
}
/**
+ * Sets the listener for choosing an activity.
+ *
+ * @param listener The listener.
+ */
+ public void setOnChooseActivityListener(OnChooseActivityListener listener) {
+ mActivityChoserModelPolicy = listener;
+ }
+
+ /**
* Gets the default activity, The default activity is defined as the one
* with highest rank i.e. the first one in the list of activities that can
* handle the intent.
diff --git a/core/java/android/widget/ActivityChooserView.java b/core/java/android/widget/ActivityChooserView.java
index 45d73af..fcc7938 100644
--- a/core/java/android/widget/ActivityChooserView.java
+++ b/core/java/android/widget/ActivityChooserView.java
@@ -29,6 +29,8 @@ import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import android.view.ViewTreeObserver;
+import android.view.ViewTreeObserver.OnGlobalLayoutListener;
import android.widget.ActivityChooserModel.ActivityChooserModelClient;
import com.android.internal.R;
@@ -115,6 +117,19 @@ public class ActivityChooserView extends ViewGroup implements ActivityChooserMod
}
};
+ private final OnGlobalLayoutListener mOnGlobalLayoutListener = new OnGlobalLayoutListener() {
+ @Override
+ public void onGlobalLayout() {
+ if (isShowingPopup()) {
+ if (!isShown()) {
+ getListPopupWindow().dismiss();
+ } else {
+ getListPopupWindow().show();
+ }
+ }
+ }
+ };
+
/**
* Popup window for showing the activity overflow list.
*/
@@ -156,7 +171,7 @@ public class ActivityChooserView extends ViewGroup implements ActivityChooserMod
* @param attrs A collection of attributes.
*/
public ActivityChooserView(Context context, AttributeSet attrs) {
- this(context, attrs, R.attr.actionButtonStyle);
+ this(context, attrs, 0);
}
/**
@@ -261,6 +276,8 @@ public class ActivityChooserView extends ViewGroup implements ActivityChooserMod
throw new IllegalStateException("No data model. Did you call #setDataModel?");
}
+ getViewTreeObserver().addOnGlobalLayoutListener(mOnGlobalLayoutListener);
+
mAdapter.setMaxActivityCount(maxActivityCount);
final int activityCount = mAdapter.getActivityCount();
@@ -292,6 +309,10 @@ public class ActivityChooserView extends ViewGroup implements ActivityChooserMod
public boolean dismissPopup() {
if (isShowingPopup()) {
getListPopupWindow().dismiss();
+ ViewTreeObserver viewTreeObserver = getViewTreeObserver();
+ if (viewTreeObserver.isAlive()) {
+ viewTreeObserver.removeGlobalOnLayoutListener(mOnGlobalLayoutListener);
+ }
}
return true;
}
@@ -322,6 +343,10 @@ public class ActivityChooserView extends ViewGroup implements ActivityChooserMod
if (dataModel != null) {
dataModel.unregisterObserver(mModelDataSetOberver);
}
+ ViewTreeObserver viewTreeObserver = getViewTreeObserver();
+ if (viewTreeObserver.isAlive()) {
+ viewTreeObserver.removeGlobalOnLayoutListener(mOnGlobalLayoutListener);
+ }
mIsAttachedToWindow = false;
}
@@ -433,8 +458,10 @@ public class ActivityChooserView extends ViewGroup implements ActivityChooserMod
}
} else {
// The first item in the model is default action => adjust index
- Intent launchIntent = mAdapter.getDataModel().chooseActivity(position + 1);
- mContext.startActivity(launchIntent);
+ Intent launchIntent = mAdapter.getDataModel().chooseActivity(position + 1);
+ if (launchIntent != null) {
+ mContext.startActivity(launchIntent);
+ }
}
} break;
default:
@@ -449,7 +476,9 @@ public class ActivityChooserView extends ViewGroup implements ActivityChooserMod
ResolveInfo defaultActivity = mAdapter.getDefaultActivity();
final int index = mAdapter.getDataModel().getActivityIndex(defaultActivity);
Intent launchIntent = mAdapter.getDataModel().chooseActivity(index);
- mContext.startActivity(launchIntent);
+ if (launchIntent != null) {
+ mContext.startActivity(launchIntent);
+ }
} else if (view == mExpandActivityOverflowButton) {
mIsSelectingDefaultActivity = false;
showPopupUnchecked(mInitialActivityCount);
diff --git a/core/java/android/widget/AdapterView.java b/core/java/android/widget/AdapterView.java
index 9f5737e..f267458c 100644
--- a/core/java/android/widget/AdapterView.java
+++ b/core/java/android/widget/AdapterView.java
@@ -23,11 +23,11 @@ import android.os.SystemClock;
import android.util.AttributeSet;
import android.util.SparseArray;
import android.view.ContextMenu;
+import android.view.ContextMenu.ContextMenuInfo;
import android.view.SoundEffectConstants;
import android.view.View;
import android.view.ViewDebug;
import android.view.ViewGroup;
-import android.view.ContextMenu.ContextMenuInfo;
import android.view.accessibility.AccessibilityEvent;
@@ -278,6 +278,7 @@ public abstract class AdapterView<T extends Adapter> extends ViewGroup {
*/
public boolean performItemClick(View view, int position, long id) {
view.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CLICKED);
+
if (mOnItemClickListener != null) {
playSoundEffect(SoundEffectConstants.CLICK);
mOnItemClickListener.onItemClick(this, view, position, id);
diff --git a/core/java/android/widget/ImageView.java b/core/java/android/widget/ImageView.java
index fc60949..b92130d 100644
--- a/core/java/android/widget/ImageView.java
+++ b/core/java/android/widget/ImageView.java
@@ -83,7 +83,6 @@ public class ImageView extends View {
// Avoid allocations...
private RectF mTempSrc = new RectF();
private RectF mTempDst = new RectF();
- private float[] mTempPoints;
private boolean mCropToPadding;
@@ -347,29 +346,13 @@ public class ImageView extends View {
if (mDrawable != drawable) {
mResource = 0;
mUri = null;
+
int oldWidth = mDrawableWidth;
int oldHeight = mDrawableHeight;
- updateDrawable(drawable);
- boolean needsLayout;
- if (mScaleType == ScaleType.CENTER) {
- needsLayout = mDrawableWidth != oldWidth || mDrawableHeight != oldHeight;
- } else {
- if (mTempPoints == null) {
- mTempPoints = new float[4];
- }
- float[] points = mTempPoints;
- points[0] = oldWidth;
- points[1] = oldHeight;
- points[2] = mDrawableWidth;
- points[3] = mDrawableHeight;
- if (!mMatrix.isIdentity()) {
- mMatrix.mapPoints(points);
- }
- needsLayout = points[0] != points[2] || points[1] != points[3];
- }
+ updateDrawable(drawable);
- if (needsLayout) {
+ if (oldWidth != mDrawableWidth || oldHeight != mDrawableHeight) {
requestLayout();
}
invalidate();
@@ -621,6 +604,8 @@ public class ImageView extends View {
mDrawableHeight = d.getIntrinsicHeight();
applyColorMod();
configureBounds();
+ } else {
+ mDrawableWidth = mDrawableHeight = -1;
}
}
@@ -679,14 +664,14 @@ public class ImageView extends View {
h = mDrawableHeight;
if (w <= 0) w = 1;
if (h <= 0) h = 1;
-
+
// We are supposed to adjust view bounds to match the aspect
// ratio of our drawable. See if that is possible.
if (mAdjustViewBounds) {
resizeWidth = widthSpecMode != MeasureSpec.EXACTLY;
resizeHeight = heightSpecMode != MeasureSpec.EXACTLY;
- desiredAspect = (float)w/(float)h;
+ desiredAspect = (float) w / (float) h;
}
}
@@ -705,13 +690,11 @@ public class ImageView extends View {
*/
// Get the max possible width given our constraints
- widthSize = resolveAdjustedSize(w + pleft + pright,
- mMaxWidth, widthMeasureSpec);
-
+ widthSize = resolveAdjustedSize(w + pleft + pright, mMaxWidth, widthMeasureSpec);
+
// Get the max possible height given our constraints
- heightSize = resolveAdjustedSize(h + ptop + pbottom,
- mMaxHeight, heightMeasureSpec);
-
+ heightSize = resolveAdjustedSize(h + ptop + pbottom, mMaxHeight, heightMeasureSpec);
+
if (desiredAspect != 0.0f) {
// See what our actual aspect ratio is
float actualAspect = (float)(widthSize - pleft - pright) /
@@ -723,9 +706,8 @@ public class ImageView extends View {
// Try adjusting width to be proportional to height
if (resizeWidth) {
- int newWidth = (int)(desiredAspect *
- (heightSize - ptop - pbottom))
- + pleft + pright;
+ int newWidth = (int)(desiredAspect * (heightSize - ptop - pbottom)) +
+ pleft + pright;
if (newWidth <= widthSize) {
widthSize = newWidth;
done = true;
@@ -734,8 +716,8 @@ public class ImageView extends View {
// Try adjusting height to be proportional to width
if (!done && resizeHeight) {
- int newHeight = (int)((widthSize - pleft - pright)
- / desiredAspect) + ptop + pbottom;
+ int newHeight = (int)((widthSize - pleft - pright) / desiredAspect) +
+ ptop + pbottom;
if (newHeight <= heightSize) {
heightSize = newHeight;
}
@@ -859,7 +841,7 @@ public class ImageView extends View {
if (dwidth <= vwidth && dheight <= vheight) {
scale = 1.0f;
} else {
- scale = Math.min((float) vwidth / (float) dwidth,
+ scale = Math.min((float) vwidth / (float) dwidth,
(float) vheight / (float) dheight);
}
@@ -874,8 +856,7 @@ public class ImageView extends View {
mTempDst.set(0, 0, vwidth, vheight);
mDrawMatrix = mMatrix;
- mDrawMatrix.setRectToRect(mTempSrc, mTempDst,
- scaleTypeToScaleToFit(mScaleType));
+ mDrawMatrix.setRectToRect(mTempSrc, mTempDst, scaleTypeToScaleToFit(mScaleType));
}
}
}
diff --git a/core/java/android/widget/NumberPicker.java b/core/java/android/widget/NumberPicker.java
index aa23ad0..2a299bd 100644
--- a/core/java/android/widget/NumberPicker.java
+++ b/core/java/android/widget/NumberPicker.java
@@ -1208,7 +1208,10 @@ public class NumberPicker extends LinearLayout {
float textGapCount = selectorIndices.length - 1;
int selectorTextGapHeight = (int) (totalTextGapHeight / textGapCount + 0.5f);
mSelectorElementHeight = mTextSize + selectorTextGapHeight;
- mInitialScrollOffset = mTextSize - 3 * (mSelectorElementHeight % 2);
+ // Ensure that the middle item is positioned the same as the text in mInputText
+ int editTextTextPosition = mInputText.getBaseline() + mInputText.getTop();
+ mInitialScrollOffset = editTextTextPosition -
+ (mSelectorElementHeight * SELECTOR_MIDDLE_ITEM_INDEX);
mCurrentScrollOffset = mInitialScrollOffset;
updateInputTextView();
}
diff --git a/core/java/android/widget/SearchView.java b/core/java/android/widget/SearchView.java
index 99f2765..f230031 100644
--- a/core/java/android/widget/SearchView.java
+++ b/core/java/android/widget/SearchView.java
@@ -745,7 +745,7 @@ public class SearchView extends LinearLayout implements CollapsibleActionView {
}
@Override
- public void onDetachedFromWindow() {
+ protected void onDetachedFromWindow() {
removeCallbacks(mUpdateDrawableStateRunnable);
super.onDetachedFromWindow();
}
diff --git a/core/java/android/widget/ShareActionProvider.java b/core/java/android/widget/ShareActionProvider.java
index 665109a..6e29024 100644
--- a/core/java/android/widget/ShareActionProvider.java
+++ b/core/java/android/widget/ShareActionProvider.java
@@ -28,6 +28,7 @@ import android.view.MenuItem;
import android.view.MenuItem.OnMenuItemClickListener;
import android.view.SubMenu;
import android.view.View;
+import android.widget.ActivityChooserModel.OnChooseActivityListener;
import com.android.internal.R;
@@ -73,6 +74,27 @@ import com.android.internal.R;
public class ShareActionProvider extends ActionProvider {
/**
+ * Listener for the event of selecting a share target.
+ */
+ public interface OnShareTargetSelectedListener {
+
+ /**
+ * Called when a share target has been selected. The client can
+ * decide whether to handle the intent or rely on the default
+ * behavior which is launching it.
+ * <p>
+ * <strong>Note:</strong> Modifying the intent is not permitted and
+ * any changes to the latter will be ignored.
+ * </p>
+ *
+ * @param source The source of the notification.
+ * @param intent The intent for launching the chosen share target.
+ * @return Whether the client has handled the intent.
+ */
+ public boolean onShareTargetSelected(ShareActionProvider source, Intent intent);
+ }
+
+ /**
* The default for the maximal number of activities shown in the sub-menu.
*/
private static final int DEFAULT_INITIAL_ACTIVITY_COUNT = 4;
@@ -103,6 +125,10 @@ public class ShareActionProvider extends ActionProvider {
*/
private String mShareHistoryFileName = DEFAULT_SHARE_HISTORY_FILE_NAME;
+ private OnShareTargetSelectedListener mOnShareTargetSelectedListener;
+
+ private OnChooseActivityListener mOnChooseActivityListener;
+
/**
* Creates a new instance.
*
@@ -114,6 +140,21 @@ public class ShareActionProvider extends ActionProvider {
}
/**
+ * Sets a listener to be notified when a share target has been selected.
+ * The listener can optionally decide to handle the selection and
+ * not rely on the default behavior which is to launch the activity.
+ * <p>
+ * <strong>Note:</strong> If you choose the backing share history file
+ * you will still be notified in this callback.
+ * </p>
+ * @param listener The listener.
+ */
+ public void setOnShareTargetSelectedListener(OnShareTargetSelectedListener listener) {
+ mOnShareTargetSelectedListener = listener;
+ setActivityChooserPolicyIfNeeded();
+ }
+
+ /**
* {@inheritDoc}
*/
@Override
@@ -192,6 +233,7 @@ public class ShareActionProvider extends ActionProvider {
*/
public void setShareHistoryFileName(String shareHistoryFile) {
mShareHistoryFileName = shareHistoryFile;
+ setActivityChooserPolicyIfNeeded();
}
/**
@@ -229,8 +271,39 @@ public class ShareActionProvider extends ActionProvider {
mShareHistoryFileName);
final int itemId = item.getItemId();
Intent launchIntent = dataModel.chooseActivity(itemId);
- mContext.startActivity(launchIntent);
+ if (launchIntent != null) {
+ mContext.startActivity(launchIntent);
+ }
return true;
}
}
+
+ /**
+ * Set the activity chooser policy of the model backed by the current
+ * share history file if needed which is if there is a registered callback.
+ */
+ private void setActivityChooserPolicyIfNeeded() {
+ if (mOnShareTargetSelectedListener == null) {
+ return;
+ }
+ if (mOnChooseActivityListener == null) {
+ mOnChooseActivityListener = new ShareAcitivityChooserModelPolicy();
+ }
+ ActivityChooserModel dataModel = ActivityChooserModel.get(mContext, mShareHistoryFileName);
+ dataModel.setOnChooseActivityListener(mOnChooseActivityListener);
+ }
+
+ /**
+ * Policy that delegates to the {@link OnShareTargetSelectedListener}, if such.
+ */
+ private class ShareAcitivityChooserModelPolicy implements OnChooseActivityListener {
+ @Override
+ public boolean onChooseActivity(ActivityChooserModel host, Intent intent) {
+ if (mOnShareTargetSelectedListener != null) {
+ return mOnShareTargetSelectedListener.onShareTargetSelected(
+ ShareActionProvider.this, intent);
+ }
+ return false;
+ }
+ }
}
diff --git a/core/java/com/android/internal/app/ActionBarImpl.java b/core/java/com/android/internal/app/ActionBarImpl.java
index 31360e1..cfecca5 100644
--- a/core/java/com/android/internal/app/ActionBarImpl.java
+++ b/core/java/com/android/internal/app/ActionBarImpl.java
@@ -111,6 +111,9 @@ public class ActionBarImpl extends ActionBar {
mContentView.setTranslationY(0);
mContainerView.setTranslationY(0);
}
+ if (mSplitView != null && mContextDisplayMode == CONTEXT_DISPLAY_SPLIT) {
+ mSplitView.setVisibility(View.GONE);
+ }
mContainerView.setVisibility(View.GONE);
mContainerView.setTransitioning(false);
mCurrentShowAnim = null;
@@ -540,6 +543,7 @@ public class ActionBarImpl extends ActionBar {
}
if (mSplitView != null && mContextDisplayMode == CONTEXT_DISPLAY_SPLIT) {
mSplitView.setAlpha(0);
+ mSplitView.setVisibility(View.VISIBLE);
b.with(ObjectAnimator.ofFloat(mSplitView, "alpha", 1));
}
anim.addListener(mShowListener);
diff --git a/core/java/com/android/internal/os/BatteryStatsImpl.java b/core/java/com/android/internal/os/BatteryStatsImpl.java
index 7b65964..df5071f 100644
--- a/core/java/com/android/internal/os/BatteryStatsImpl.java
+++ b/core/java/com/android/internal/os/BatteryStatsImpl.java
@@ -67,12 +67,13 @@ public final class BatteryStatsImpl extends BatteryStats {
private static final String TAG = "BatteryStatsImpl";
private static final boolean DEBUG = false;
private static final boolean DEBUG_HISTORY = false;
+ private static final boolean USE_OLD_HISTORY = false; // for debugging.
// In-memory Parcel magic number, used to detect attempts to unmarshall bad data
private static final int MAGIC = 0xBA757475; // 'BATSTATS'
// Current on-disk Parcel version
- private static final int VERSION = 60;
+ private static final int VERSION = 61 + (USE_OLD_HISTORY ? 1000 : 0);
// Maximum number of items we will record in the history.
private static final int MAX_HISTORY_ITEMS = 2000;
@@ -1285,6 +1286,10 @@ public final class BatteryStatsImpl extends BatteryStats {
void addHistoryRecordLocked(long curTime) {
addHistoryBufferLocked(curTime);
+ if (!USE_OLD_HISTORY) {
+ return;
+ }
+
if (!mHaveBatteryLevel || !mRecordingHistory) {
return;
}
@@ -1363,12 +1368,15 @@ public final class BatteryStatsImpl extends BatteryStats {
void clearHistoryLocked() {
if (DEBUG_HISTORY) Slog.i(TAG, "********** CLEARING HISTORY!");
- if (mHistory != null) {
- mHistoryEnd.next = mHistoryCache;
- mHistoryCache = mHistory;
- mHistory = mHistoryLastEnd = mHistoryEnd = null;
+ if (USE_OLD_HISTORY) {
+ if (mHistory != null) {
+ mHistoryEnd.next = mHistoryCache;
+ mHistoryCache = mHistory;
+ mHistory = mHistoryLastEnd = mHistoryEnd = null;
+ }
+ mNumHistoryItems = 0;
}
- mNumHistoryItems = 0;
+
mHistoryBaseTime = 0;
mLastHistoryTime = 0;
@@ -4863,7 +4871,9 @@ public final class BatteryStatsImpl extends BatteryStats {
}
long now = SystemClock.elapsedRealtime();
- addHistoryRecordLocked(now, HistoryItem.CMD_START);
+ if (USE_OLD_HISTORY) {
+ addHistoryRecordLocked(now, HistoryItem.CMD_START);
+ }
addHistoryBufferLocked(now, HistoryItem.CMD_START);
}
@@ -4923,6 +4933,9 @@ public final class BatteryStatsImpl extends BatteryStats {
}
void readOldHistory(Parcel in) {
+ if (!USE_OLD_HISTORY) {
+ return;
+ }
mHistory = mHistoryEnd = mHistoryCache = null;
long time;
while (in.dataAvail() > 0 && (time=in.readLong()) >= 0) {
@@ -4952,6 +4965,9 @@ public final class BatteryStatsImpl extends BatteryStats {
}
void writeOldHistory(Parcel out) {
+ if (!USE_OLD_HISTORY) {
+ return;
+ }
HistoryItem rec = mHistory;
while (rec != null) {
if (rec.time >= 0) rec.writeToParcel(out, 0);
diff --git a/core/java/com/android/internal/view/menu/ActionMenuPresenter.java b/core/java/com/android/internal/view/menu/ActionMenuPresenter.java
index 5c42579..df4243a 100644
--- a/core/java/com/android/internal/view/menu/ActionMenuPresenter.java
+++ b/core/java/com/android/internal/view/menu/ActionMenuPresenter.java
@@ -19,6 +19,7 @@ package com.android.internal.view.menu;
import com.android.internal.view.menu.ActionMenuView.ActionMenuChildView;
import android.content.Context;
+import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Parcel;
import android.os.Parcelable;
@@ -109,6 +110,16 @@ public class ActionMenuPresenter extends BaseMenuPresenter {
mScrapActionButtonView = null;
}
+ public void onConfigurationChanged(Configuration newConfig) {
+ if (!mMaxItemsSet) {
+ mMaxItems = mContext.getResources().getInteger(
+ com.android.internal.R.integer.max_action_buttons);
+ if (mMenu != null) {
+ mMenu.onItemsChanged(true);
+ }
+ }
+ }
+
public void setWidthLimit(int width, boolean strict) {
mWidthLimit = width;
mStrictWidthLimit = strict;
@@ -391,7 +402,6 @@ public class ActionMenuPresenter extends BaseMenuPresenter {
final boolean inGroup = seenGroups.get(groupId);
boolean isAction = (maxActions > 0 || inGroup) && widthLimit > 0 &&
(!mStrictWidthLimit || cellsRemaining > 0);
- maxActions--;
if (isAction) {
View v = getItemView(item, mScrapActionButtonView, parent);
@@ -430,11 +440,15 @@ public class ActionMenuPresenter extends BaseMenuPresenter {
for (int j = 0; j < i; j++) {
MenuItemImpl areYouMyGroupie = visibleItems.get(j);
if (areYouMyGroupie.getGroupId() == groupId) {
+ // Give back the action slot
+ if (areYouMyGroupie.isActionButton()) maxActions++;
areYouMyGroupie.setIsActionButton(false);
}
}
}
+ if (isAction) maxActions--;
+
item.setIsActionButton(isAction);
}
}
diff --git a/core/java/com/android/internal/view/menu/MenuBuilder.java b/core/java/com/android/internal/view/menu/MenuBuilder.java
index 5e70e4c..5622b44 100644
--- a/core/java/com/android/internal/view/menu/MenuBuilder.java
+++ b/core/java/com/android/internal/view/menu/MenuBuilder.java
@@ -567,7 +567,7 @@ public class MenuBuilder implements Menu {
}
}
- if (changedAtLeastOneItem) onItemsChanged(false);
+ if (changedAtLeastOneItem) onItemsChanged(true);
}
public void setGroupEnabled(int group, boolean enabled) {
@@ -929,6 +929,7 @@ public class MenuBuilder implements Menu {
*
* @param structureChanged true if the menu structure changed,
* false if only item properties changed.
+ * (Visibility is a structural property since it affects layout.)
*/
void onItemsChanged(boolean structureChanged) {
if (!mPreventDispatchingItemsChanged) {
@@ -971,7 +972,7 @@ public class MenuBuilder implements Menu {
void onItemVisibleChanged(MenuItemImpl item) {
// Notify of items being changed
mIsVisibleItemsStale = true;
- onItemsChanged(false);
+ onItemsChanged(true);
}
/**
@@ -981,7 +982,7 @@ public class MenuBuilder implements Menu {
void onItemActionRequestChanged(MenuItemImpl item) {
// Notify of items being changed
mIsActionItemsStale = true;
- onItemsChanged(false);
+ onItemsChanged(true);
}
ArrayList<MenuItemImpl> getVisibleItems() {
diff --git a/core/java/com/android/internal/view/menu/MenuItemImpl.java b/core/java/com/android/internal/view/menu/MenuItemImpl.java
index 8b53bb8..04147ab 100644
--- a/core/java/com/android/internal/view/menu/MenuItemImpl.java
+++ b/core/java/com/android/internal/view/menu/MenuItemImpl.java
@@ -585,7 +585,7 @@ public final class MenuItemImpl implements MenuItem {
public MenuItem setActionProvider(ActionProvider actionProvider) {
mActionView = null;
mActionProvider = actionProvider;
- mMenu.onItemsChanged(false);
+ mMenu.onItemsChanged(true); // Measurement can be changed
return this;
}
diff --git a/core/java/com/android/internal/widget/ActionBarContextView.java b/core/java/com/android/internal/widget/ActionBarContextView.java
index 5645a6f..45d38ae 100644
--- a/core/java/com/android/internal/widget/ActionBarContextView.java
+++ b/core/java/com/android/internal/widget/ActionBarContextView.java
@@ -25,6 +25,7 @@ import android.animation.Animator.AnimatorListener;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.content.Context;
+import android.content.res.Configuration;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
@@ -92,6 +93,14 @@ public class ActionBarContextView extends AbsActionBarView implements AnimatorLi
a.recycle();
}
+ @Override
+ public void onConfigurationChanged(Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+ if (mActionMenuPresenter != null) {
+ mActionMenuPresenter.onConfigurationChanged(newConfig);
+ }
+ }
+
public void setHeight(int height) {
mContentHeight = height;
}
diff --git a/core/java/com/android/internal/widget/ActionBarView.java b/core/java/com/android/internal/widget/ActionBarView.java
index 7baa412..28181ba 100644
--- a/core/java/com/android/internal/widget/ActionBarView.java
+++ b/core/java/com/android/internal/widget/ActionBarView.java
@@ -34,14 +34,12 @@ import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Configuration;
-import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;
import android.util.AttributeSet;
-import android.util.DisplayMetrics;
import android.util.Log;
import android.view.CollapsibleActionView;
import android.view.Gravity;
@@ -52,7 +50,6 @@ import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.view.Window;
-import android.view.ViewGroup.LayoutParams;
import android.widget.AdapterView;
import android.widget.FrameLayout;
import android.widget.ImageView;
@@ -88,7 +85,7 @@ public class ActionBarView extends AbsActionBarView {
private int mContentHeight;
private int mNavigationMode;
- private int mDisplayOptions = ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_HOME_AS_UP;
+ private int mDisplayOptions = -1;
private CharSequence mTitle;
private CharSequence mSubtitle;
private Drawable mIcon;
@@ -262,6 +259,9 @@ public class ActionBarView extends AbsActionBarView {
com.android.internal.R.attr.actionBarStyle, 0);
setContentHeight(a.getLayoutDimension(R.styleable.ActionBar_height, 0));
a.recycle();
+ if (mActionMenuPresenter != null) {
+ mActionMenuPresenter.onConfigurationChanged(newConfig);
+ }
}
@Override
@@ -514,7 +514,7 @@ public class ActionBarView extends AbsActionBarView {
}
public void setDisplayOptions(int options) {
- final int flagsChanged = options ^ mDisplayOptions;
+ final int flagsChanged = mDisplayOptions == -1 ? -1 : options ^ mDisplayOptions;
mDisplayOptions = options;
if ((flagsChanged & DISPLAY_RELAYOUT_MASK) != 0) {
@@ -737,8 +737,9 @@ public class ActionBarView extends AbsActionBarView {
}
addView(mTitleLayout);
- if (mExpandedActionView != null) {
- // Don't show while in expanded mode
+ if (mExpandedActionView != null ||
+ (TextUtils.isEmpty(mTitle) && TextUtils.isEmpty(mSubtitle))) {
+ // Don't show while in expanded mode or with empty text
mTitleLayout.setVisibility(GONE);
}
}
@@ -1036,6 +1037,8 @@ public class ActionBarView extends AbsActionBarView {
} else if (centeredLeft + navWidth > menuLeft) {
hgravity = Gravity.RIGHT;
}
+ } else if (gravity == -1) {
+ hgravity = Gravity.LEFT;
}
int xpos = 0;
@@ -1051,8 +1054,14 @@ public class ActionBarView extends AbsActionBarView {
break;
}
+ int vgravity = gravity & Gravity.VERTICAL_GRAVITY_MASK;
+
+ if (gravity == -1) {
+ vgravity = Gravity.CENTER_VERTICAL;
+ }
+
int ypos = 0;
- switch (gravity & Gravity.VERTICAL_GRAVITY_MASK) {
+ switch (vgravity) {
case Gravity.CENTER_VERTICAL:
final int paddedTop = getPaddingTop();
final int paddedBottom = mBottom - mTop - getPaddingBottom();
diff --git a/core/java/com/android/internal/widget/PointerLocationView.java b/core/java/com/android/internal/widget/PointerLocationView.java
index bf1c637..158291b 100644
--- a/core/java/com/android/internal/widget/PointerLocationView.java
+++ b/core/java/com/android/internal/widget/PointerLocationView.java
@@ -46,6 +46,7 @@ public class PointerLocationView extends View {
// Most recent coordinates.
private PointerCoords mCoords = new PointerCoords();
+ private int mToolType;
// Most recent velocity.
private float mXVelocity;
@@ -88,7 +89,7 @@ public class PointerLocationView extends View {
private int mMaxNumPointers;
private int mActivePointerId;
private final ArrayList<PointerState> mPointers = new ArrayList<PointerState>();
- private final PointerCoords mHoverCoords = new PointerCoords();
+ private final PointerCoords mTempCoords = new PointerCoords();
private final VelocityTracker mVelocity;
@@ -306,22 +307,66 @@ public class PointerLocationView extends View {
ps.mCoords.toolMinor, ps.mCoords.orientation, mPaint);
// Draw the orientation arrow.
+ float arrowSize = ps.mCoords.toolMajor * 0.7f;
+ if (arrowSize < 20) {
+ arrowSize = 20;
+ }
mPaint.setARGB(255, pressureLevel, 255, 0);
- float orientationVectorX = (float) (Math.sin(-ps.mCoords.orientation)
- * ps.mCoords.toolMajor * 0.7);
- float orientationVectorY = (float) (Math.cos(-ps.mCoords.orientation)
- * ps.mCoords.toolMajor * 0.7);
- canvas.drawLine(
- ps.mCoords.x - orientationVectorX, ps.mCoords.y - orientationVectorY,
- ps.mCoords.x + orientationVectorX, ps.mCoords.y + orientationVectorY,
- mPaint);
+ float orientationVectorX = (float) (Math.sin(ps.mCoords.orientation)
+ * arrowSize);
+ float orientationVectorY = (float) (-Math.cos(ps.mCoords.orientation)
+ * arrowSize);
+ if (ps.mToolType == MotionEvent.TOOL_TYPE_STYLUS
+ || ps.mToolType == MotionEvent.TOOL_TYPE_ERASER) {
+ // Show full circle orientation.
+ canvas.drawLine(ps.mCoords.x, ps.mCoords.y,
+ ps.mCoords.x + orientationVectorX,
+ ps.mCoords.y + orientationVectorY,
+ mPaint);
+ } else {
+ // Show half circle orientation.
+ canvas.drawLine(
+ ps.mCoords.x - orientationVectorX,
+ ps.mCoords.y - orientationVectorY,
+ ps.mCoords.x + orientationVectorX,
+ ps.mCoords.y + orientationVectorY,
+ mPaint);
+ }
+
+ // Draw the tilt point along the orientation arrow.
+ float tiltScale = (float) Math.sin(
+ ps.mCoords.getAxisValue(MotionEvent.AXIS_TILT));
+ canvas.drawCircle(
+ ps.mCoords.x + orientationVectorX * tiltScale,
+ ps.mCoords.y + orientationVectorY * tiltScale,
+ 3.0f, mPaint);
}
}
}
}
-
- private void logPointerCoords(int action, int index, MotionEvent.PointerCoords coords, int id,
- int toolType, int buttonState) {
+
+ private void logMotionEvent(String type, MotionEvent event) {
+ final int action = event.getAction();
+ final int N = event.getHistorySize();
+ final int NI = event.getPointerCount();
+ for (int historyPos = 0; historyPos < N; historyPos++) {
+ for (int i = 0; i < NI; i++) {
+ final int id = event.getPointerId(i);
+ event.getHistoricalPointerCoords(i, historyPos, mTempCoords);
+ logCoords(type, action, i, mTempCoords, id,
+ event.getToolType(i), event.getButtonState());
+ }
+ }
+ for (int i = 0; i < NI; i++) {
+ final int id = event.getPointerId(i);
+ event.getPointerCoords(i, mTempCoords);
+ logCoords(type, action, i, mTempCoords, id,
+ event.getToolType(i), event.getButtonState());
+ }
+ }
+
+ private void logCoords(String type, int action, int index,
+ MotionEvent.PointerCoords coords, int id, int toolType, int buttonState) {
final String prefix;
switch (action & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_DOWN:
@@ -373,7 +418,7 @@ public class PointerLocationView extends View {
}
Log.i(TAG, mText.clear()
- .append("Pointer ").append(id + 1)
+ .append(type).append(" id ").append(id + 1)
.append(": ")
.append(prefix)
.append(" (").append(coords.x, 3).append(", ").append(coords.y, 3)
@@ -385,6 +430,9 @@ public class PointerLocationView extends View {
.append(" ToolMinor=").append(coords.toolMinor, 3)
.append(" Orientation=").append((float)(coords.orientation * 180 / Math.PI), 1)
.append("deg")
+ .append(" Tilt=").append((float)(
+ coords.getAxisValue(MotionEvent.AXIS_TILT) * 180 / Math.PI), 1)
+ .append("deg")
.append(" Distance=").append(coords.getAxisValue(MotionEvent.AXIS_DISTANCE), 1)
.append(" VScroll=").append(coords.getAxisValue(MotionEvent.AXIS_VSCROLL), 1)
.append(" HScroll=").append(coords.getAxisValue(MotionEvent.AXIS_HSCROLL), 1)
@@ -445,10 +493,10 @@ public class PointerLocationView extends View {
for (int i = 0; i < NI; i++) {
final int id = event.getPointerId(i);
final PointerState ps = mCurDown ? mPointers.get(id) : null;
- final PointerCoords coords = ps != null ? ps.mCoords : mHoverCoords;
+ final PointerCoords coords = ps != null ? ps.mCoords : mTempCoords;
event.getHistoricalPointerCoords(i, historyPos, coords);
if (mPrintCoords) {
- logPointerCoords(action, i, coords, id,
+ logCoords("Pointer", action, i, coords, id,
event.getToolType(i), event.getButtonState());
}
if (ps != null) {
@@ -459,16 +507,17 @@ public class PointerLocationView extends View {
for (int i = 0; i < NI; i++) {
final int id = event.getPointerId(i);
final PointerState ps = mCurDown ? mPointers.get(id) : null;
- final PointerCoords coords = ps != null ? ps.mCoords : mHoverCoords;
+ final PointerCoords coords = ps != null ? ps.mCoords : mTempCoords;
event.getPointerCoords(i, coords);
if (mPrintCoords) {
- logPointerCoords(action, i, coords, id,
+ logCoords("Pointer", action, i, coords, id,
event.getToolType(i), event.getButtonState());
}
if (ps != null) {
ps.addTrace(coords.x, coords.y);
ps.mXVelocity = mVelocity.getXVelocity(id);
ps.mYVelocity = mVelocity.getYVelocity(id);
+ ps.mToolType = event.getToolType(i);
}
}
@@ -515,11 +564,11 @@ public class PointerLocationView extends View {
if ((source & InputDevice.SOURCE_CLASS_POINTER) != 0) {
addPointerEvent(event);
} else if ((source & InputDevice.SOURCE_CLASS_JOYSTICK) != 0) {
- Log.i(TAG, "Joystick: " + event);
+ logMotionEvent("Joystick", event);
} else if ((source & InputDevice.SOURCE_CLASS_POSITION) != 0) {
- Log.i(TAG, "Position: " + event);
+ logMotionEvent("Position", event);
} else {
- Log.i(TAG, "Generic: " + event);
+ logMotionEvent("Generic", event);
}
return true;
}
@@ -563,7 +612,7 @@ public class PointerLocationView extends View {
@Override
public boolean onTrackballEvent(MotionEvent event) {
- Log.i(TAG, "Trackball: " + event);
+ logMotionEvent("Trackball", event);
return true;
}
diff --git a/core/java/com/android/server/NetworkManagementSocketTagger.java b/core/java/com/android/server/NetworkManagementSocketTagger.java
index 23af37e..9f6ab31 100644
--- a/core/java/com/android/server/NetworkManagementSocketTagger.java
+++ b/core/java/com/android/server/NetworkManagementSocketTagger.java
@@ -115,7 +115,8 @@ public final class NetworkManagementSocketTagger extends SocketTagger {
private void unTagSocketFd(FileDescriptor fd) throws IOException {
int fdNum = fd.getInt$();
- if (fdNum == -1) return;
+ final SocketTags options = threadSocketTags.get();
+ if (fdNum == -1 || (options.statsTag == -1 && options.statsUid == -1)) return;
String cmd = "u " + fdNum;
internalModuleCtrl(cmd);
}
diff --git a/core/jni/android/graphics/Canvas.cpp b/core/jni/android/graphics/Canvas.cpp
index f8be136..b01dcd8 100644
--- a/core/jni/android/graphics/Canvas.cpp
+++ b/core/jni/android/graphics/Canvas.cpp
@@ -770,11 +770,7 @@ public:
value->computeValues(paint, textArray, start, count, end, flags);
#endif
-#if DEBUG_GLYPHS
- logGlyphs(value);
-#endif
-
- doDrawGlyphs(canvas, value->getGlyphs(), 0, value->getGlyphsCount(),
+ doDrawGlyphs(canvas, value->getGlyphs(), 0, value->getGlyphsCount(),
x, y, flags, paint);
}
@@ -794,10 +790,6 @@ public:
value->computeValues(paint, textArray, start, count, contextCount, flags);
#endif
-#if DEBUG_GLYPHS
- logGlyphs(value);
-#endif
-
doDrawGlyphs(canvas, value->getGlyphs(), 0, value->getGlyphsCount(),
x, y, flags, paint);
}
diff --git a/core/jni/android/graphics/TextLayout.h b/core/jni/android/graphics/TextLayout.h
index d197d04..9bb1b92 100644
--- a/core/jni/android/graphics/TextLayout.h
+++ b/core/jni/android/graphics/TextLayout.h
@@ -64,14 +64,6 @@ enum {
kDirection_Mask = 0x1
};
-static void logGlyphs(sp<TextLayoutCacheValue> value) {
- if (value == NULL) return;
- LOGD("Got glyphs - count=%d", value->getGlyphsCount());
- for (size_t i = 0; i < value->getGlyphsCount(); i++) {
- LOGD(" glyphs[%d]=%d", i, value->getGlyphs()[i]);
- }
-}
-
class TextLayout {
public:
diff --git a/core/jni/android/graphics/TextLayoutCache.cpp b/core/jni/android/graphics/TextLayoutCache.cpp
index 89440c9..f04c5eb 100644
--- a/core/jni/android/graphics/TextLayoutCache.cpp
+++ b/core/jni/android/graphics/TextLayoutCache.cpp
@@ -554,6 +554,15 @@ void TextLayoutCacheValue::computeValuesWithHarfbuzz(SkPaint* paint, const UChar
#endif
}
+static void logGlyphs(HB_ShaperItem shaperItem) {
+ LOGD("Got glyphs - count=%d", shaperItem.num_glyphs);
+ for (size_t i = 0; i < shaperItem.num_glyphs; i++) {
+ LOGD(" glyphs[%d]=%d - offset.x=%f offset.y=%f", i, shaperItem.glyphs[i],
+ HBFixedToFloat(shaperItem.offsets[i].x),
+ HBFixedToFloat(shaperItem.offsets[i].y));
+ }
+}
+
void TextLayoutCacheValue::computeRunValuesWithHarfbuzz(SkPaint* paint, const UChar* chars,
size_t start, size_t count, size_t contextCount, bool isRTL,
jfloat* outAdvances, jfloat* outTotalAdvance,
@@ -570,6 +579,8 @@ void TextLayoutCacheValue::computeRunValuesWithHarfbuzz(SkPaint* paint, const UC
shaperItem.kerning_applied);
LOGD(" -- string= '%s'", String8(chars + start, count).string());
LOGD(" -- isDevKernText=%d", paint->isDevKernText());
+
+ logGlyphs(shaperItem);
#endif
if (shaperItem.advances == NULL || shaperItem.num_glyphs == 0) {
diff --git a/core/jni/android_server_BluetoothEventLoop.cpp b/core/jni/android_server_BluetoothEventLoop.cpp
index 438e201..eee256a 100644
--- a/core/jni/android_server_BluetoothEventLoop.cpp
+++ b/core/jni/android_server_BluetoothEventLoop.cpp
@@ -507,6 +507,7 @@ static void tearDownEventLoop(native_data_t *nat) {
#define EVENT_LOOP_EXIT 1
#define EVENT_LOOP_ADD 2
#define EVENT_LOOP_REMOVE 3
+#define EVENT_LOOP_WAKEUP 4
dbus_bool_t dbusAddWatch(DBusWatch *watch, void *data) {
native_data_t *nat = (native_data_t *)data;
@@ -551,6 +552,13 @@ void dbusToggleWatch(DBusWatch *watch, void *data) {
}
}
+void dbusWakeup(void *data) {
+ native_data_t *nat = (native_data_t *)data;
+
+ char control = EVENT_LOOP_WAKEUP;
+ write(nat->controlFdW, &control, sizeof(char));
+}
+
static void handleWatchAdd(native_data_t *nat) {
DBusWatch *watch;
int newFD;
@@ -634,6 +642,7 @@ static void *eventLoopMain(void *ptr) {
dbus_connection_set_watch_functions(nat->conn, dbusAddWatch,
dbusRemoveWatch, dbusToggleWatch, ptr, NULL);
+ dbus_connection_set_wakeup_main_function(nat->conn, dbusWakeup, ptr, NULL);
nat->running = true;
@@ -669,6 +678,11 @@ static void *eventLoopMain(void *ptr) {
handleWatchRemove(nat);
break;
}
+ case EVENT_LOOP_WAKEUP:
+ {
+ // noop
+ break;
+ }
}
}
} else {
diff --git a/core/jni/android_util_Binder.cpp b/core/jni/android_util_Binder.cpp
index b432d65..b8f2d6f 100644
--- a/core/jni/android_util_Binder.cpp
+++ b/core/jni/android_util_Binder.cpp
@@ -385,7 +385,8 @@ class JavaDeathRecipient : public IBinder::DeathRecipient
{
public:
JavaDeathRecipient(JNIEnv* env, jobject object, const sp<DeathRecipientList>& list)
- : mVM(jnienv_to_javavm(env)), mObject(env->NewGlobalRef(object)), mList(list)
+ : mVM(jnienv_to_javavm(env)), mObject(env->NewGlobalRef(object)),
+ mObjectWeak(NULL), mList(list)
{
// These objects manage their own lifetimes so are responsible for final bookkeeping.
// The list holds a strong reference to this object.
@@ -398,16 +399,23 @@ public:
void binderDied(const wp<IBinder>& who)
{
- JNIEnv* env = javavm_to_jnienv(mVM);
-
LOGDEATH("Receiving binderDied() on JavaDeathRecipient %p\n", this);
+ if (mObject != NULL) {
+ JNIEnv* env = javavm_to_jnienv(mVM);
+
+ env->CallStaticVoidMethod(gBinderProxyOffsets.mClass,
+ gBinderProxyOffsets.mSendDeathNotice, mObject);
+ jthrowable excep = env->ExceptionOccurred();
+ if (excep) {
+ report_exception(env, excep,
+ "*** Uncaught exception returned from death notification!");
+ }
- env->CallStaticVoidMethod(gBinderProxyOffsets.mClass,
- gBinderProxyOffsets.mSendDeathNotice, mObject);
- jthrowable excep = env->ExceptionOccurred();
- if (excep) {
- report_exception(env, excep,
- "*** Uncaught exception returned from death notification!");
+ // Demote from strong ref to weak after binderDied() has been delivered,
+ // to allow the DeathRecipient and BinderProxy to be GC'd if no longer needed.
+ mObjectWeak = env->NewWeakGlobalRef(mObject);
+ env->DeleteGlobalRef(mObject);
+ mObject = NULL;
}
}
@@ -423,8 +431,17 @@ public:
}
bool matches(jobject obj) {
+ bool result;
JNIEnv* env = javavm_to_jnienv(mVM);
- return env->IsSameObject(obj, mObject);
+
+ if (mObject != NULL) {
+ result = env->IsSameObject(obj, mObject);
+ } else {
+ jobject me = env->NewLocalRef(mObjectWeak);
+ result = env->IsSameObject(obj, me);
+ env->DeleteLocalRef(me);
+ }
+ return result;
}
protected:
@@ -433,12 +450,17 @@ protected:
//LOGI("Removing death ref: recipient=%p\n", mObject);
android_atomic_dec(&gNumDeathRefs);
JNIEnv* env = javavm_to_jnienv(mVM);
- env->DeleteGlobalRef(mObject);
+ if (mObject != NULL) {
+ env->DeleteGlobalRef(mObject);
+ } else {
+ env->DeleteWeakGlobalRef(mObjectWeak);
+ }
}
private:
- JavaVM* const mVM;
- jobject const mObject;
+ JavaVM* const mVM;
+ jobject mObject;
+ jweak mObjectWeak; // will be a weak ref to the same VM-side DeathRecipient after binderDied()
wp<DeathRecipientList> mList;
};
@@ -512,7 +534,7 @@ jobject javaObjectForIBinder(JNIEnv* env, const sp<IBinder>& val)
if (val->checkSubclass(&gBinderOffsets)) {
// One of our own!
jobject object = static_cast<JavaBBinder*>(val.get())->object();
- //printf("objectForBinder %p: it's our own %p!\n", val.get(), object);
+ LOGDEATH("objectForBinder %p: it's our own %p!\n", val.get(), object);
return object;
}
@@ -528,7 +550,7 @@ jobject javaObjectForIBinder(JNIEnv* env, const sp<IBinder>& val)
LOGV("objectForBinder %p: found existing %p!\n", val.get(), res);
return res;
}
- LOGV("Proxy object %p of IBinder %p no longer in working set!!!", object, val.get());
+ LOGDEATH("Proxy object %p of IBinder %p no longer in working set!!!", object, val.get());
android_atomic_dec(&gNumProxyRefs);
val->detachObject(&gBinderProxyOffsets);
env->DeleteGlobalRef(object);
diff --git a/core/jni/android_view_GLES20Canvas.cpp b/core/jni/android_view_GLES20Canvas.cpp
index 80c79fd..fb5e5fe 100644
--- a/core/jni/android_view_GLES20Canvas.cpp
+++ b/core/jni/android_view_GLES20Canvas.cpp
@@ -472,9 +472,6 @@ static void renderText(OpenGLRenderer* renderer, const jchar* text, int count,
value = new TextLayoutCacheValue();
value->computeValues(paint, text, 0, count, count, flags);
#endif
-#if DEBUG_GLYPHS
- logGlyphs(value);
-#endif
const jchar* glyphArray = value->getGlyphs();
int glyphCount = value->getGlyphsCount();
int bytesCount = glyphCount * sizeof(jchar);
@@ -505,9 +502,6 @@ static void renderTextRun(OpenGLRenderer* renderer, const jchar* text,
value = new TextLayoutCacheValue();
value->computeValues(paint, text, start, count, contextCount, flags);
#endif
-#if DEBUG_GLYPHS
- logGlyphs(value);
-#endif
const jchar* glyphArray = value->getGlyphs();
int glyphCount = value->getGlyphsCount();
int bytesCount = glyphCount * sizeof(jchar);
diff --git a/core/res/res/drawable-hdpi/ic_lockscreen_ime.png b/core/res/res/drawable-hdpi/ic_lockscreen_ime.png
new file mode 100644
index 0000000..29a7989
--- /dev/null
+++ b/core/res/res/drawable-hdpi/ic_lockscreen_ime.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/ic_notification_ime_default.png b/core/res/res/drawable-hdpi/ic_notification_ime_default.png
index 1a9d88c..ac59819 100644
--- a/core/res/res/drawable-hdpi/ic_notification_ime_default.png
+++ b/core/res/res/drawable-hdpi/ic_notification_ime_default.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/overscroll_glow.png b/core/res/res/drawable-hdpi/overscroll_glow.png
index 5963c00..8f0c2cb 100644
--- a/core/res/res/drawable-hdpi/overscroll_glow.png
+++ b/core/res/res/drawable-hdpi/overscroll_glow.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/ic_lockscreen_ime.png b/core/res/res/drawable-mdpi/ic_lockscreen_ime.png
new file mode 100644
index 0000000..b27e059
--- /dev/null
+++ b/core/res/res/drawable-mdpi/ic_lockscreen_ime.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/ic_notification_ime_default.png b/core/res/res/drawable-mdpi/ic_notification_ime_default.png
index 25700c0..67269e8 100644
--- a/core/res/res/drawable-mdpi/ic_notification_ime_default.png
+++ b/core/res/res/drawable-mdpi/ic_notification_ime_default.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/overscroll_glow.png b/core/res/res/drawable-mdpi/overscroll_glow.png
index e63e465..8389ef4 100644
--- a/core/res/res/drawable-mdpi/overscroll_glow.png
+++ b/core/res/res/drawable-mdpi/overscroll_glow.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/ic_lockscreen_ime.png b/core/res/res/drawable-xhdpi/ic_lockscreen_ime.png
new file mode 100644
index 0000000..a40ddeb
--- /dev/null
+++ b/core/res/res/drawable-xhdpi/ic_lockscreen_ime.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/ic_notification_ime_default.png b/core/res/res/drawable-xhdpi/ic_notification_ime_default.png
index 7eda69e..4d0f074 100644
--- a/core/res/res/drawable-xhdpi/ic_notification_ime_default.png
+++ b/core/res/res/drawable-xhdpi/ic_notification_ime_default.png
Binary files differ
diff --git a/core/res/res/drawable-xhdpi/overscroll_glow.png b/core/res/res/drawable-xhdpi/overscroll_glow.png
index 227565e..75c3eb4 100644
--- a/core/res/res/drawable-xhdpi/overscroll_glow.png
+++ b/core/res/res/drawable-xhdpi/overscroll_glow.png
Binary files differ
diff --git a/core/res/res/layout-sw600dp/preference_list_content.xml b/core/res/res/layout-sw600dp/preference_list_content.xml
index 5b67d71..08f6453 100644
--- a/core/res/res/layout-sw600dp/preference_list_content.xml
+++ b/core/res/res/layout-sw600dp/preference_list_content.xml
@@ -44,8 +44,11 @@
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="1"
- android:paddingTop="16dp"
- android:paddingBottom="16dp"
+ android:paddingLeft="@dimen/preference_screen_header_padding_side"
+ android:paddingRight="@dimen/preference_screen_header_padding_side"
+ android:paddingTop="@dimen/preference_screen_header_vertical_padding"
+ android:paddingBottom="@dimen/preference_screen_header_vertical_padding"
+ android:scrollbarStyle="@integer/preference_screen_header_scrollbarStyle"
android:drawSelectorOnTop="false"
android:cacheColorHint="@android:color/transparent"
android:listPreferredItemHeight="48dp"
diff --git a/core/res/res/layout/activity_chooser_view.xml b/core/res/res/layout/activity_chooser_view.xml
index 5d82a97..82e1f83 100644
--- a/core/res/res/layout/activity_chooser_view.xml
+++ b/core/res/res/layout/activity_chooser_view.xml
@@ -22,7 +22,8 @@
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
- style="?android:attr/actionButtonStyle">
+ style="?android:attr/actionButtonStyle"
+ android:padding="0dip">
<FrameLayout
android:id="@+id/default_activity_button"
@@ -31,7 +32,7 @@
android:layout_gravity="center"
android:focusable="true"
android:addStatesFromChildren="true"
- android:background="?android:attr/selectableItemBackground">
+ android:background="?android:attr/actionBarItemBackground">
<ImageView android:id="@+id/image"
android:layout_width="32dip"
@@ -53,7 +54,7 @@
android:layout_gravity="center"
android:focusable="true"
android:addStatesFromChildren="true"
- android:background="?android:attr/selectableItemBackground">
+ android:background="?android:attr/actionBarItemBackground">
<ImageView android:id="@+id/image"
android:layout_width="32dip"
diff --git a/core/res/res/layout/breadcrumbs_in_fragment.xml b/core/res/res/layout/breadcrumbs_in_fragment.xml
index 98fffb7..9c12618 100644
--- a/core/res/res/layout/breadcrumbs_in_fragment.xml
+++ b/core/res/res/layout/breadcrumbs_in_fragment.xml
@@ -13,10 +13,10 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
+
<!-- This layout disables breadcrumbs in the fragment area and causes PreferenceActivity to
put the breadcrumbs in the action bar. -->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_height="@dimen/preference_fragment_padding_side"
- android:layout_width="match_parent">
-</LinearLayout> \ No newline at end of file
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="0dip"
+ android:layout_height="0dip"
+ android:visibility="gone" />
diff --git a/core/res/res/layout/keyguard_screen_password_landscape.xml b/core/res/res/layout/keyguard_screen_password_landscape.xml
index 4c44049..bc86ab7 100644
--- a/core/res/res/layout/keyguard_screen_password_landscape.xml
+++ b/core/res/res/layout/keyguard_screen_password_landscape.xml
@@ -133,13 +133,14 @@
<!-- Column 2 - password entry field and PIN keyboard -->
<LinearLayout
- android:orientation="vertical"
+ android:orientation="horizontal"
android:layout_width="270dip"
android:layout_gravity="center_vertical">
<EditText android:id="@+id/passwordEntry"
android:layout_height="wrap_content"
- android:layout_width="match_parent"
+ android:layout_width="0dip"
+ android:layout_weight="1"
android:gravity="center"
android:singleLine="true"
android:textStyle="normal"
@@ -153,6 +154,17 @@
android:suggestionsEnabled="false"
/>
+ <ImageView android:id="@+id/switch_ime_button"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:src="@drawable/ic_lockscreen_ime"
+ android:clickable="true"
+ android:padding="8dip"
+ android:layout_gravity="center"
+ android:background="?android:attr/selectableItemBackground"
+ android:visibility="gone"
+ />
+
</LinearLayout>
<!-- Numeric keyboard -->
diff --git a/core/res/res/layout/keyguard_screen_password_portrait.xml b/core/res/res/layout/keyguard_screen_password_portrait.xml
index 1d0ea54..994c439 100644
--- a/core/res/res/layout/keyguard_screen_password_portrait.xml
+++ b/core/res/res/layout/keyguard_screen_password_portrait.xml
@@ -95,22 +95,39 @@
/>
<!-- Password entry field -->
- <EditText android:id="@+id/passwordEntry"
- android:layout_height="wrap_content"
- android:layout_width="match_parent"
+ <LinearLayout
android:layout_gravity="center_vertical|fill_horizontal"
- android:gravity="center_horizontal"
- android:singleLine="true"
- android:textStyle="normal"
- android:inputType="textPassword"
- android:textSize="36sp"
+ android:orientation="horizontal"
android:layout_marginLeft="16dip"
- android:layout_marginRight="16dip"
- android:background="@drawable/lockscreen_password_field_dark"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textColor="#ffffffff"
- android:imeOptions="actionDone"
- android:suggestionsEnabled="false"/>
+ android:layout_marginRight="16dip">
+
+ <EditText android:id="@+id/passwordEntry"
+ android:layout_width="0dip"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:gravity="center_horizontal"
+ android:singleLine="true"
+ android:textStyle="normal"
+ android:inputType="textPassword"
+ android:textSize="36sp"
+ android:background="@drawable/lockscreen_password_field_dark"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:textColor="#ffffffff"
+ android:imeOptions="actionDone"
+ android:suggestionsEnabled="false"/>
+
+ <ImageView android:id="@+id/switch_ime_button"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:src="@drawable/ic_lockscreen_ime"
+ android:clickable="true"
+ android:padding="8dip"
+ android:layout_gravity="center"
+ android:background="?android:attr/selectableItemBackground"
+ android:visibility="gone"
+ />
+
+ </LinearLayout>
<!-- Numeric keyboard -->
<com.android.internal.widget.PasswordEntryKeyboardView android:id="@+id/keyboard"
diff --git a/core/res/res/layout/preference_list_content.xml b/core/res/res/layout/preference_list_content.xml
index 4e7981a..62181b5 100644
--- a/core/res/res/layout/preference_list_content.xml
+++ b/core/res/res/layout/preference_list_content.xml
@@ -44,8 +44,11 @@
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="1"
+ android:paddingLeft="@dimen/preference_screen_header_padding_side"
+ android:paddingRight="@dimen/preference_screen_header_padding_side"
android:paddingTop="@dimen/preference_screen_header_vertical_padding"
android:paddingBottom="@dimen/preference_screen_header_vertical_padding"
+ android:scrollbarStyle="@integer/preference_screen_header_scrollbarStyle"
android:drawSelectorOnTop="false"
android:cacheColorHint="@android:color/transparent"
android:listPreferredItemHeight="48dp"
diff --git a/core/res/res/layout/preference_list_fragment.xml b/core/res/res/layout/preference_list_fragment.xml
index 315f708..fdef4fc 100644
--- a/core/res/res/layout/preference_list_fragment.xml
+++ b/core/res/res/layout/preference_list_fragment.xml
@@ -32,11 +32,19 @@
android:paddingBottom="@dimen/preference_fragment_padding_bottom"
android:paddingLeft="@dimen/preference_fragment_padding_side"
android:paddingRight="@dimen/preference_fragment_padding_side"
+ android:scrollbarStyle="@integer/preference_fragment_scrollbarStyle"
android:clipToPadding="false"
android:drawSelectorOnTop="false"
android:cacheColorHint="@android:color/transparent"
android:scrollbarAlwaysDrawVerticalTrack="true" />
+ <TextView android:id="@android:id/empty"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:padding="@dimen/preference_fragment_padding_side"
+ android:gravity="center"
+ android:visibility="gone" />
+
<RelativeLayout android:id="@+id/button_bar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
diff --git a/core/res/res/layout/volume_adjust.xml b/core/res/res/layout/volume_adjust.xml
index 7303003..ea4e1f9 100644
--- a/core/res/res/layout/volume_adjust.xml
+++ b/core/res/res/layout/volume_adjust.xml
@@ -18,6 +18,7 @@
android:layout_width="480dp"
android:layout_height="wrap_content">
<LinearLayout
+ android:id="@+id/visible_panel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="80dp"
diff --git a/core/res/res/values-h720dp/dimens.xml b/core/res/res/values-h720dp/dimens.xml
index 37dee8e..7efe322 100644
--- a/core/res/res/values-h720dp/dimens.xml
+++ b/core/res/res/values-h720dp/dimens.xml
@@ -25,4 +25,10 @@
<dimen name="preference_screen_top_margin">16dp</dimen>
<!-- Preference activity bottom margin -->
<dimen name="preference_screen_bottom_margin">16dp</dimen>
+
+ <dimen name="preference_screen_header_padding_side">0dip</dimen>
+
+ <integer name="preference_screen_header_scrollbarStyle">0x0</integer> <!-- insideOverlay -->
+ <integer name="preference_fragment_scrollbarStyle">0x0</integer> <!-- insideOverlay -->
+
</resources>
diff --git a/core/res/res/values-port/dimens.xml b/core/res/res/values-w360dp/dimens.xml
index bf0a342..0f5d656 100644
--- a/core/res/res/values-port/dimens.xml
+++ b/core/res/res/values-w360dp/dimens.xml
@@ -20,5 +20,5 @@
<!-- The maximum number of action buttons that should be permitted within
an action bar/action mode. This will be used to determine how many
showAsAction="ifRoom" items can fit. "always" items can override this. -->
- <integer name="max_action_buttons">2</integer>
+ <integer name="max_action_buttons">3</integer>
</resources>
diff --git a/core/res/res/values-w500dp/dimens.xml b/core/res/res/values-w500dp/dimens.xml
new file mode 100644
index 0000000..68841ca
--- /dev/null
+++ b/core/res/res/values-w500dp/dimens.xml
@@ -0,0 +1,24 @@
+<?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.
+*/
+-->
+<resources>
+ <!-- The maximum number of action buttons that should be permitted within
+ an action bar/action mode. This will be used to determine how many
+ showAsAction="ifRoom" items can fit. "always" items can override this. -->
+ <integer name="max_action_buttons">4</integer>
+</resources>
diff --git a/core/res/res/values-w600dp/dimens.xml b/core/res/res/values-w600dp/dimens.xml
new file mode 100644
index 0000000..83c45b5
--- /dev/null
+++ b/core/res/res/values-w600dp/dimens.xml
@@ -0,0 +1,24 @@
+<?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.
+*/
+-->
+<resources>
+ <!-- The maximum number of action buttons that should be permitted within
+ an action bar/action mode. This will be used to determine how many
+ showAsAction="ifRoom" items can fit. "always" items can override this. -->
+ <integer name="max_action_buttons">5</integer>
+</resources>
diff --git a/core/res/res/values-w720dp/dimens.xml b/core/res/res/values-w720dp/dimens.xml
index 3d10103..c62c3f5 100644
--- a/core/res/res/values-w720dp/dimens.xml
+++ b/core/res/res/values-w720dp/dimens.xml
@@ -29,4 +29,9 @@
This helps in aligning titles when some items have icons and some don't. When space is
at a premium, we don't pre-allocate any space. -->
<dimen name="preference_icon_minWidth">56dp</dimen>
+
+ <dimen name="preference_screen_header_padding_side">0dip</dimen>
+
+ <integer name="preference_screen_header_scrollbarStyle">0x0</integer> <!-- insideOverlay -->
+ <integer name="preference_fragment_scrollbarStyle">0x0</integer> <!-- insideOverlay -->
</resources>
diff --git a/core/res/res/values/arrays.xml b/core/res/res/values/arrays.xml
index fe5ace8..04e510b 100644
--- a/core/res/res/values/arrays.xml
+++ b/core/res/res/values/arrays.xml
@@ -236,11 +236,8 @@
<item>@drawable/spinner_dropdown_background_up</item>
<item>@drawable/spinner_focused_holo_dark</item>
<item>@drawable/spinner_focused_holo_light</item>
- <item>@drawable/spinner_normal</item>
- <item>@drawable/spinner_press</item>
<item>@drawable/spinner_pressed_holo_dark</item>
<item>@drawable/spinner_pressed_holo_light</item>
- <item>@drawable/spinner_select</item>
<item>@drawable/cab_background_bottom_holo_dark</item>
<item>@drawable/cab_background_top_holo_light</item>
<item>@drawable/cab_background_bottom_holo_light</item>
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index 40355e3..aa3397f 100755
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -5264,9 +5264,9 @@
<!-- Specifies a background drawable for the action bar. -->
<attr name="background" />
<!-- Specifies a background drawable for a second stacked row of the action bar. -->
- <attr name="backgroundStacked" format="reference" />
+ <attr name="backgroundStacked" format="reference|color" />
<!-- Specifies a background drawable for the bottom component of a split action bar. -->
- <attr name="backgroundSplit" format="reference" />
+ <attr name="backgroundSplit" format="reference|color" />
<!-- Specifies a layout for custom navigation. Overrides navigationMode. -->
<attr name="customNavigationLayout" format="reference" />
<!-- Specifies a fixed height. -->
diff --git a/core/res/res/values/dimens.xml b/core/res/res/values/dimens.xml
index 8855645..c522c1e 100644
--- a/core/res/res/values/dimens.xml
+++ b/core/res/res/values/dimens.xml
@@ -28,7 +28,7 @@
<!-- The maximum number of action buttons that should be permitted within
an action bar/action mode. This will be used to determine how many
showAsAction="ifRoom" items can fit. "always" items can override this. -->
- <integer name="max_action_buttons">3</integer>
+ <integer name="max_action_buttons">2</integer>
<dimen name="toast_y_offset">64dip</dimen>
<!-- Height of the status bar -->
<dimen name="status_bar_height">25dip</dimen>
@@ -76,9 +76,9 @@
<dimen name="multiwaveview_hit_radius">60dip</dimen>
<!-- Preference activity side margins -->
- <dimen name="preference_screen_side_margin">16dp</dimen>
+ <dimen name="preference_screen_side_margin">0dp</dimen>
<!-- Preference activity side margins negative-->
- <dimen name="preference_screen_side_margin_negative">16dp</dimen>
+ <dimen name="preference_screen_side_margin_negative">0dp</dimen>
<!-- Preference activity top margin -->
<dimen name="preference_screen_top_margin">0dp</dimen>
<!-- Preference activity bottom margin -->
@@ -88,7 +88,7 @@
<!-- Preference fragment padding, bottom -->
<dimen name="preference_fragment_padding_bottom">0dp</dimen>
<!-- Preference fragment padding, sides -->
- <dimen name="preference_fragment_padding_side">0dp</dimen>
+ <dimen name="preference_fragment_padding_side">16dp</dimen>
<!-- Weight of the left pane in a multi-pane preference layout. -->
<integer name="preferences_left_pane_weight">4</integer>
<!-- Weight of the right pane in a multi-pane preference layout. So the split is 40:60 -->
@@ -108,6 +108,11 @@
<!-- Preference activity, vertical padding for the header list -->
<dimen name="preference_screen_header_vertical_padding">0dp</dimen>
+ <dimen name="preference_screen_header_padding_side">16dip</dimen>
+ <integer name="preference_screen_header_scrollbarStyle">0x02000000</integer> <!-- outsideOverlay -->
+
+ <integer name="preference_fragment_scrollbarStyle">0x02000000</integer> <!-- outsideOverlay -->
+
<dimen name="preference_item_padding_side">8dip</dimen>
<dimen name="preference_item_padding_inner">8dip</dimen>
<dimen name="preference_child_padding_side">16dip</dimen>
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index 9c774f8..6aff54e 100755
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -3099,7 +3099,7 @@
<!-- Notification title when mobile data usage has exceeded limit threshold, and has been disabled. [CHAR LIMIT=32] -->
<string name="data_usage_mobile_limit_title">Mobile data disabled</string>
<!-- Notification body when data usage has exceeded limit threshold, and has been disabled. [CHAR LIMIT=32] -->
- <string name="data_usage_limit_body">tap to enable</string>
+ <string name="data_usage_limit_body">Touch to enable</string>
<!-- Notification title when 2G-3G data usage has exceeded limit threshold. [CHAR LIMIT=32] -->
<string name="data_usage_3g_limit_snoozed_title">2G-3G data limit exceeded</string>
@@ -3110,6 +3110,11 @@
<!-- Notification body when data usage has exceeded limit threshold. [CHAR LIMIT=32] -->
<string name="data_usage_limit_snoozed_body"><xliff:g id="size" example="3.8GB">%s</xliff:g> over specified limit</string>
+ <!-- Notification title when background data usage is limited. [CHAR LIMIT=32] -->
+ <string name="data_usage_restricted_title">Background data restricted</string>
+ <!-- Notification body when background data usage is limited. [CHAR LIMIT=32] -->
+ <string name="data_usage_restricted_body">Touch to remove restriction</string>
+
<!-- SSL Certificate dialogs -->
<!-- Title for an SSL Certificate dialog -->
<string name="ssl_certificate">Security certificate</string>
@@ -3153,4 +3158,7 @@
<!-- Description of for the status bar's icon that the device is locked for accessibility. [CHAR LIMIT=NONE] -->
<string name="status_bar_device_locked">Device locked.</string>
+ <!-- Delimeter used between each item in a textual list; for example "Alpha, Beta". [CHAR LIMIT=3] -->
+ <string name="list_delimeter">", "</string>
+
</resources>
diff --git a/core/res/res/values/styles.xml b/core/res/res/values/styles.xml
index 6f2f1e5..94c6e41 100644
--- a/core/res/res/values/styles.xml
+++ b/core/res/res/values/styles.xml
@@ -2363,7 +2363,7 @@ please see styles_device_defaults.xml.
<style name="Widget.Holo.PreferenceFrameLayout">
<item name="android:borderTop">0dip</item>
- <item name="android:borderBottom">@dimen/preference_fragment_padding_side</item>
+ <item name="android:borderBottom">@dimen/preference_fragment_padding_bottom</item>
<item name="android:borderLeft">@dimen/preference_fragment_padding_side</item>
<item name="android:borderRight">@dimen/preference_fragment_padding_side</item>
</style>
diff --git a/core/tests/coretests/src/android/provider/SettingsProviderTest.java b/core/tests/coretests/src/android/provider/SettingsProviderTest.java
index b82e698..3e96dc4 100644
--- a/core/tests/coretests/src/android/provider/SettingsProviderTest.java
+++ b/core/tests/coretests/src/android/provider/SettingsProviderTest.java
@@ -20,11 +20,16 @@ import android.content.ContentResolver;
import android.content.ContentUris;
import android.content.ContentValues;
import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
import android.database.Cursor;
import android.net.Uri;
import android.provider.Settings;
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.MediumTest;
+import android.test.suitebuilder.annotation.SmallTest;
+
+import java.util.List;
/** Unit test for SettingsProvider. */
public class SettingsProviderTest extends AndroidTestCase {
@@ -191,4 +196,49 @@ public class SettingsProviderTest extends AndroidTestCase {
assertEquals("test1,test2",
Settings.Secure.getString(r, Settings.Secure.LOCATION_PROVIDERS_ALLOWED));
}
+
+ @SmallTest
+ public void testSettings() {
+ assertCanBeHandled(new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS));
+ assertCanBeHandled(new Intent(Settings.ACTION_ADD_ACCOUNT));
+ assertCanBeHandled(new Intent(Settings.ACTION_AIRPLANE_MODE_SETTINGS));
+ assertCanBeHandled(new Intent(Settings.ACTION_APN_SETTINGS));
+ assertCanBeHandled(new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
+ .setData(Uri.parse("package:" + getContext().getPackageName())));
+ assertCanBeHandled(new Intent(Settings.ACTION_APPLICATION_DEVELOPMENT_SETTINGS));
+ assertCanBeHandled(new Intent(Settings.ACTION_APPLICATION_SETTINGS));
+ assertCanBeHandled(new Intent(Settings.ACTION_BLUETOOTH_SETTINGS));
+ assertCanBeHandled(new Intent(Settings.ACTION_DATA_ROAMING_SETTINGS));
+ assertCanBeHandled(new Intent(Settings.ACTION_DATE_SETTINGS));
+ assertCanBeHandled(new Intent(Settings.ACTION_DEVICE_INFO_SETTINGS));
+ assertCanBeHandled(new Intent(Settings.ACTION_DISPLAY_SETTINGS));
+ assertCanBeHandled(new Intent(Settings.ACTION_INPUT_METHOD_SETTINGS));
+ assertCanBeHandled(new Intent(Settings.ACTION_INTERNAL_STORAGE_SETTINGS));
+ assertCanBeHandled(new Intent(Settings.ACTION_LOCALE_SETTINGS));
+ assertCanBeHandled(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS));
+ assertCanBeHandled(new Intent(Settings.ACTION_MANAGE_ALL_APPLICATIONS_SETTINGS));
+ assertCanBeHandled(new Intent(Settings.ACTION_MANAGE_APPLICATIONS_SETTINGS));
+ assertCanBeHandled(new Intent(Settings.ACTION_MEMORY_CARD_SETTINGS));
+ assertCanBeHandled(new Intent(Settings.ACTION_NETWORK_OPERATOR_SETTINGS));
+ assertCanBeHandled(new Intent(Settings.ACTION_PRIVACY_SETTINGS));
+ assertCanBeHandled(new Intent(Settings.ACTION_QUICK_LAUNCH_SETTINGS));
+ assertCanBeHandled(new Intent(Settings.ACTION_SEARCH_SETTINGS));
+ assertCanBeHandled(new Intent(Settings.ACTION_SECURITY_SETTINGS));
+ assertCanBeHandled(new Intent(Settings.ACTION_SETTINGS));
+ assertCanBeHandled(new Intent(Settings.ACTION_SOUND_SETTINGS));
+ assertCanBeHandled(new Intent(Settings.ACTION_SYNC_SETTINGS));
+ assertCanBeHandled(new Intent(Settings.ACTION_SYSTEM_UPDATE_SETTINGS));
+ assertCanBeHandled(new Intent(Settings.ACTION_USER_DICTIONARY_SETTINGS));
+ assertCanBeHandled(new Intent(Settings.ACTION_WIFI_IP_SETTINGS));
+ assertCanBeHandled(new Intent(Settings.ACTION_WIFI_SETTINGS));
+ assertCanBeHandled(new Intent(Settings.ACTION_WIRELESS_SETTINGS));
+ }
+
+ private void assertCanBeHandled(final Intent intent) {
+ PackageManager packageManager = mContext.getPackageManager();
+ List<ResolveInfo> resolveInfoList = packageManager.queryIntentActivities(intent, 0);
+ assertNotNull(resolveInfoList);
+ // one or more activity can handle this intent.
+ assertTrue(resolveInfoList.size() > 0);
+ }
}
diff --git a/docs/html/guide/topics/graphics/opengl.jd b/docs/html/guide/topics/graphics/opengl.jd
index 2edc63d..b750858 100644
--- a/docs/html/guide/topics/graphics/opengl.jd
+++ b/docs/html/guide/topics/graphics/opengl.jd
@@ -14,7 +14,7 @@ parent.link=index.html
</ol>
<li><a href="#manifest">Declaring OpenGL Requirements</a></li>
</li>
- <li><a href="#coordinate-mapping">Coordinate Mapping for Drawn Objects</a>
+ <li><a href="#coordinate-mapping">Mapping Coordinates for Drawn Objects</a>
<ol>
<li><a href="#proj-es1">Projection and camera in ES 1.0</a></li>
<li><a href="#proj-es1">Projection and camera in ES 2.0</a></li>
@@ -197,9 +197,9 @@ shown below.
installed on devices that do not support OpenGL ES 2.0.</p>
</li>
<li><strong>Texture compression requirements</strong> - If your application uses texture
-compression formats that are not supported by all devices, you must declare them in your manifest
-file using <a href="{@docRoot}guide/topics/manifest/supports-gl-texture-element.html">
-{@code &lt;supports-gl-texture&gt;}</a>. For more information about available texture compression
+compression formats, you must declare the formats your application supports in your manifest file
+using <a href="{@docRoot}guide/topics/manifest/supports-gl-texture-element.html">{@code
+&lt;supports-gl-texture&gt;}</a>. For more information about available texture compression
formats, see <a href="#textures">Texture compression support</a>.
<p>Declaring texture compression requirements in your manifest hides your application from users
@@ -212,7 +212,7 @@ Android Market and texture compression filtering</a> section of the {@code
</ul>
-<h2 id="coordinate-mapping">Coordinate Mapping for Drawn Objects</h2>
+<h2 id="coordinate-mapping">Mapping Coordinates for Drawn Objects</h2>
<p>One of the basic problems in displaying graphics on Android devices is that their screens can
vary in size and shape. OpenGL assumes a square, uniform coordinate system and, by default, happily
@@ -241,9 +241,11 @@ adding them to the OpenGL environment.</p>
<ol>
<li><strong>Projection matrix</strong> - Create a projection matrix using the geometry of the
device screen in order to recalculate object coordinates so they are drawn with correct proportions.
-The following example code demonstrates how to modify the {@code onSurfaceChanged()} method of a
-{@link android.opengl.GLSurfaceView.Renderer} implementation to create a projection matrix based on
-the screen's aspect ratio and apply it to the OpenGL rendering environment.
+The following example code demonstrates how to modify the {@link
+android.opengl.GLSurfaceView.Renderer#onSurfaceChanged(javax.microedition.khronos.opengles.GL10,
+int, int) onSurfaceChanged()} method of a {@link android.opengl.GLSurfaceView.Renderer}
+implementation to create a projection matrix based on the screen's aspect ratio and apply it to the
+OpenGL rendering environment.
<pre>
public void onSurfaceChanged(GL10 gl, int width, int height) {
@@ -260,11 +262,13 @@ the screen's aspect ratio and apply it to the OpenGL rendering environment.
<li><strong>Camera transformation matrix</strong> - Once you have adjusted the coordinate system
using a projection matrix, you must also apply a camera view. The following example code shows how
-to modify the {@code onDrawFrame()} method of a {@link android.opengl.GLSurfaceView.Renderer}
-implementation to apply a model view and use the {@link
-android.opengl.GLU#gluLookAt(javax.microedition.khronos.opengles.GL10, float, float, float, float,
-float, float, float, float, float) GLU.gluLookAt()} utility to create a viewing tranformation which
-simulates a camera position.
+to modify the {@link
+android.opengl.GLSurfaceView.Renderer#onDrawFrame(javax.microedition.khronos.opengles.GL10)
+onDrawFrame()} method of a {@link android.opengl.GLSurfaceView.Renderer}
+implementation to apply a model view and use the
+{@link android.opengl.GLU#gluLookAt(javax.microedition.khronos.opengles.GL10, float, float, float,
+float, float, float, float, float, float) GLU.gluLookAt()} utility to create a viewing tranformation
+which simulates a camera position.
<pre>
public void onDrawFrame(GL10 gl) {
@@ -320,8 +324,10 @@ independently.</p>
</li>
<li><strong>Access the shader matrix</strong> - After creating a hook in your vertex shaders to
apply projection and camera view, you can then access that variable to apply projection and
-camera viewing matrices. The following code shows how to modify the {@code onSurfaceCreated()}
-method of a {@link android.opengl.GLSurfaceView.Renderer} implementation to access the matrix
+camera viewing matrices. The following code shows how to modify the {@link
+android.opengl.GLSurfaceView.Renderer#onSurfaceCreated(javax.microedition.khronos.opengles.GL10,
+javax.microedition.khronos.egl.EGLConfig) onSurfaceCreated()} method of a {@link
+android.opengl.GLSurfaceView.Renderer} implementation to access the matrix
variable defined in the vertex shader above.
<pre>
@@ -334,9 +340,13 @@ variable defined in the vertex shader above.
</li>
<li><strong>Create projection and camera viewing matrices</strong> - Generate the projection and
viewing matrices to be applied the graphic objects. The following example code shows how to modify
-the {@code onSurfaceCreated()} and {@code onSurfaceChanged()} methods of a {@link
-android.opengl.GLSurfaceView.Renderer} implementation to create camera view matrix and a projection
-matrix based on the screen aspect ratio of the device.
+the {@link
+android.opengl.GLSurfaceView.Renderer#onSurfaceCreated(javax.microedition.khronos.opengles.GL10,
+javax.microedition.khronos.egl.EGLConfig) onSurfaceCreated()} and {@link
+android.opengl.GLSurfaceView.Renderer#onSurfaceChanged(javax.microedition.khronos.opengles.GL10,
+int, int) onSurfaceChanged()} methods of a {@link android.opengl.GLSurfaceView.Renderer}
+implementation to create camera view matrix and a projection matrix based on the screen aspect ratio
+of the device.
<pre>
public void onSurfaceCreated(GL10 unused, EGLConfig config) {
@@ -358,9 +368,11 @@ matrix based on the screen aspect ratio of the device.
<li><strong>Apply projection and camera viewing matrices</strong> - To apply the projection and
camera view transformations, multiply the matrices together and then set them into the vertex
-shader. The following example code shows how modify the {@code onDrawFrame()} method of a {@link
-android.opengl.GLSurfaceView.Renderer} implementation to combine the projection matrix and camera
-view created in the code above and then apply it to the graphic objects to be rendered by OpenGL.
+shader. The following example code shows how modify the {@link
+android.opengl.GLSurfaceView.Renderer#onDrawFrame(javax.microedition.khronos.opengles.GL10)
+onDrawFrame()} method of a {@link android.opengl.GLSurfaceView.Renderer} implementation to combine
+the projection matrix and camera view created in the code above and then apply it to the graphic
+objects to be rendered by OpenGL.
<pre>
public void onDrawFrame(GL10 unused) {
diff --git a/docs/html/resources/tutorials/opengl/opengl-es10.jd b/docs/html/resources/tutorials/opengl/opengl-es10.jd
index 40304fd..3570766 100644
--- a/docs/html/resources/tutorials/opengl/opengl-es10.jd
+++ b/docs/html/resources/tutorials/opengl/opengl-es10.jd
@@ -342,8 +342,8 @@ not square and, by default, OpenGL happily maps a perfectly square, uniform coor
system onto your typically non-square screen. To solve this problem, you can apply an OpenGL
projection mode and camera view (eye point) to transform the coordinates of your graphic objects
so they have the correct proportions on any display. For more information about OpenGL coordinate
-mapping, see <a href="{@docRoot}guide/topics/graphics/opengl.html#coordinate-mapping">Coordinate
-Mapping for Drawn Objects</a>.</p>
+mapping, see <a href="{@docRoot}guide/topics/graphics/opengl.html#coordinate-mapping">Mapping
+Coordinates for Drawn Objects</a>.</p>
<p>To apply projection and camera view transformations to your triangle:
</p>
diff --git a/docs/html/resources/tutorials/opengl/opengl-es20.jd b/docs/html/resources/tutorials/opengl/opengl-es20.jd
index 439f7d5..889dd50 100644
--- a/docs/html/resources/tutorials/opengl/opengl-es20.jd
+++ b/docs/html/resources/tutorials/opengl/opengl-es20.jd
@@ -422,8 +422,8 @@ not square and, by default, OpenGL happily maps a perfectly square, uniform coor
system onto your typically non-square screen. To solve this problem, you can apply an OpenGL
projection mode and camera view (eye point) to transform the coordinates of your graphic objects
so they have the correct proportions on any display. For more information about OpenGL coordinate
-mapping, see <a href="{@docRoot}guide/topics/graphics/opengl.html#coordinate-mapping">Coordinate
-Mapping for Drawn Objects</a>.</p>
+mapping, see <a href="{@docRoot}guide/topics/graphics/opengl.html#coordinate-mapping">Mapping
+Coordinates for Drawn Objects</a>.</p>
<p>To apply projection and camera view transformations to your triangle:
</p>
diff --git a/include/camera/CameraParameters.h b/include/camera/CameraParameters.h
index b661496..6c91dfc 100644
--- a/include/camera/CameraParameters.h
+++ b/include/camera/CameraParameters.h
@@ -597,13 +597,24 @@ public:
// CameraHardwareInterface.autoFocus in this mode.
static const char FOCUS_MODE_EDOF[];
// Continuous auto focus mode intended for video recording. The camera
- // continuously tries to focus. This is ideal for shooting video.
- // Applications still can call CameraHardwareInterface.takePicture in this
- // mode but the subject may not be in focus. Auto focus starts when the
- // parameter is set. Applications should not call
- // CameraHardwareInterface.autoFocus in this mode. To stop continuous focus,
- // applications should change the focus mode to other modes.
+ // continuously tries to focus. This is the best choice for video
+ // recording because the focus changes smoothly . Applications still can
+ // call CameraHardwareInterface.takePicture in this mode but the subject may
+ // not be in focus. Auto focus starts when the parameter is set.
+ // Applications should not call CameraHardwareInterface.autoFocus in this
+ // mode. To stop continuous focus, applications should change the focus mode
+ // to other modes.
static const char FOCUS_MODE_CONTINUOUS_VIDEO[];
+ // Continuous auto focus mode intended for taking pictures. The camera
+ // continuously tries to focus. The speed of focus change is more aggressive
+ // than FOCUS_MODE_CONTINUOUS_VIDEO. Auto focus starts when the parameter is
+ // set. If applications call autoFocus in this mode, the focus callback will
+ // immediately return with a boolean that indicates the focus is sharp or
+ // not. The apps can then decide if they want to take a picture immediately
+ // or to change the focus mode to auto, and run a full autofocus cycle. To
+ // stop continuous focus, applications should change the focus mode to other
+ // modes.
+ static const char FOCUS_MODE_CONTINUOUS_PICTURE[];
private:
DefaultKeyedVector<String8,String8> mMap;
diff --git a/include/media/MediaProfiles.h b/include/media/MediaProfiles.h
index 69d5001..4b023d1 100644
--- a/include/media/MediaProfiles.h
+++ b/include/media/MediaProfiles.h
@@ -140,6 +140,19 @@ public:
int getVideoEditorCapParamByName(const char *name) const;
/**
+ * Returns the value for the given param name for the video editor export codec format
+ * param or -1 if error.
+ * Supported param name are:
+ * videoeditor.export.profile - export video profile
+ * videoeditor.export.level - export video level
+ * Supported param codec are:
+ * 1 for h263
+ * 2 for h264
+ * 3 for mpeg4
+ */
+ int getVideoEditorExportParamByName(const char *name, int codec) const;
+
+ /**
* Returns the audio encoders supported.
*/
Vector<audio_encoder> getAudioEncoders() const;
@@ -332,7 +345,14 @@ private:
int mCameraId;
Vector<int> mLevels;
};
-
+ struct ExportVideoProfile {
+ ExportVideoProfile(int codec, int profile, int level)
+ :mCodec(codec),mProfile(profile),mLevel(level) {}
+ ~ExportVideoProfile() {}
+ int mCodec;
+ int mProfile;
+ int mLevel;
+ };
struct VideoEditorCap {
VideoEditorCap(int inFrameWidth, int inFrameHeight,
int outFrameWidth, int outFrameHeight)
@@ -374,6 +394,7 @@ private:
static AudioEncoderCap* createAudioEncoderCap(const char **atts);
static VideoEditorCap* createVideoEditorCap(
const char **atts, MediaProfiles *profiles);
+ static ExportVideoProfile* createExportVideoProfile(const char **atts);
static CamcorderProfile* createCamcorderProfile(
int cameraId, const char **atts, Vector<int>& cameraIds);
@@ -418,6 +439,8 @@ private:
static void createDefaultImageEncodingQualityLevels(MediaProfiles *profiles);
static void createDefaultImageDecodingMaxMemory(MediaProfiles *profiles);
static void createDefaultVideoEditorCap(MediaProfiles *profiles);
+ static void createDefaultExportVideoProfiles(MediaProfiles *profiles);
+
static VideoEncoderCap* createDefaultH263VideoEncoderCap();
static VideoEncoderCap* createDefaultM4vVideoEncoderCap();
static AudioEncoderCap* createDefaultAmrNBEncoderCap();
@@ -475,6 +498,7 @@ private:
RequiredProfiles *mRequiredProfileRefs;
Vector<int> mCameraIds;
VideoEditorCap* mVideoEditorCap;
+ Vector<ExportVideoProfile*> mVideoEditorExportProfiles;
};
}; // namespace android
diff --git a/include/surfaceflinger/ISurfaceComposer.h b/include/surfaceflinger/ISurfaceComposer.h
index dba98a3..6b31ca4 100644
--- a/include/surfaceflinger/ISurfaceComposer.h
+++ b/include/surfaceflinger/ISurfaceComposer.h
@@ -132,9 +132,10 @@ public:
virtual status_t turnElectronBeamOff(int32_t mode) = 0;
virtual status_t turnElectronBeamOn(int32_t mode) = 0;
- /* verify that an ISurface was created by SurfaceFlinger.
+ /* verify that an ISurfaceTexture was created by SurfaceFlinger.
*/
- virtual bool authenticateSurface(const sp<ISurface>& surface) const = 0;
+ virtual bool authenticateSurfaceTexture(
+ const sp<ISurfaceTexture>& surface) const = 0;
};
// ----------------------------------------------------------------------------
diff --git a/include/ui/KeycodeLabels.h b/include/ui/KeycodeLabels.h
index 8383957..2efe8ca 100755
--- a/include/ui/KeycodeLabels.h
+++ b/include/ui/KeycodeLabels.h
@@ -278,6 +278,8 @@ static const KeycodeLabel AXES[] = {
{ "WHEEL", 21 },
{ "GAS", 22 },
{ "BRAKE", 23 },
+ { "DISTANCE", 24 },
+ { "TILT", 25 },
{ "GENERIC_1", 32 },
{ "GENERIC_2", 33 },
{ "GENERIC_3", 34 },
diff --git a/libs/camera/CameraParameters.cpp b/libs/camera/CameraParameters.cpp
index 51b96c1..0eb5d50 100644
--- a/libs/camera/CameraParameters.cpp
+++ b/libs/camera/CameraParameters.cpp
@@ -160,6 +160,7 @@ const char CameraParameters::FOCUS_MODE_MACRO[] = "macro";
const char CameraParameters::FOCUS_MODE_FIXED[] = "fixed";
const char CameraParameters::FOCUS_MODE_EDOF[] = "edof";
const char CameraParameters::FOCUS_MODE_CONTINUOUS_VIDEO[] = "continuous-video";
+const char CameraParameters::FOCUS_MODE_CONTINUOUS_PICTURE[] = "continuous-picture";
CameraParameters::CameraParameters()
: mMap()
diff --git a/libs/gui/ISurfaceComposer.cpp b/libs/gui/ISurfaceComposer.cpp
index c1156d5..030a83e 100644
--- a/libs/gui/ISurfaceComposer.cpp
+++ b/libs/gui/ISurfaceComposer.cpp
@@ -31,6 +31,8 @@
#include <ui/DisplayInfo.h>
+#include <gui/ISurfaceTexture.h>
+
#include <utils/Log.h>
// ---------------------------------------------------------------------------
@@ -166,35 +168,36 @@ public:
return reply.readInt32();
}
- virtual bool authenticateSurface(const sp<ISurface>& surface) const
+ virtual bool authenticateSurfaceTexture(
+ const sp<ISurfaceTexture>& surfaceTexture) const
{
Parcel data, reply;
int err = NO_ERROR;
err = data.writeInterfaceToken(
ISurfaceComposer::getInterfaceDescriptor());
if (err != NO_ERROR) {
- LOGE("ISurfaceComposer::authenticateSurface: error writing "
+ LOGE("ISurfaceComposer::authenticateSurfaceTexture: error writing "
"interface descriptor: %s (%d)", strerror(-err), -err);
return false;
}
- err = data.writeStrongBinder(surface->asBinder());
+ err = data.writeStrongBinder(surfaceTexture->asBinder());
if (err != NO_ERROR) {
- LOGE("ISurfaceComposer::authenticateSurface: error writing strong "
- "binder to parcel: %s (%d)", strerror(-err), -err);
+ LOGE("ISurfaceComposer::authenticateSurfaceTexture: error writing "
+ "strong binder to parcel: %s (%d)", strerror(-err), -err);
return false;
}
err = remote()->transact(BnSurfaceComposer::AUTHENTICATE_SURFACE, data,
&reply);
if (err != NO_ERROR) {
- LOGE("ISurfaceComposer::authenticateSurface: error performing "
- "transaction: %s (%d)", strerror(-err), -err);
+ LOGE("ISurfaceComposer::authenticateSurfaceTexture: error "
+ "performing transaction: %s (%d)", strerror(-err), -err);
return false;
}
int32_t result = 0;
err = reply.readInt32(&result);
if (err != NO_ERROR) {
- LOGE("ISurfaceComposer::authenticateSurface: error retrieving "
- "result: %s (%d)", strerror(-err), -err);
+ LOGE("ISurfaceComposer::authenticateSurfaceTexture: error "
+ "retrieving result: %s (%d)", strerror(-err), -err);
return false;
}
return result != 0;
@@ -291,8 +294,9 @@ status_t BnSurfaceComposer::onTransact(
} break;
case AUTHENTICATE_SURFACE: {
CHECK_INTERFACE(ISurfaceComposer, data, reply);
- sp<ISurface> surface = interface_cast<ISurface>(data.readStrongBinder());
- int32_t result = authenticateSurface(surface) ? 1 : 0;
+ sp<ISurfaceTexture> surfaceTexture =
+ interface_cast<ISurfaceTexture>(data.readStrongBinder());
+ int32_t result = authenticateSurfaceTexture(surfaceTexture) ? 1 : 0;
reply->writeInt32(result);
} break;
default:
diff --git a/libs/gui/Surface.cpp b/libs/gui/Surface.cpp
index 2c70251..54d04aa 100644
--- a/libs/gui/Surface.cpp
+++ b/libs/gui/Surface.cpp
@@ -342,9 +342,6 @@ sp<IBinder> Surface::asBinder() const {
int Surface::query(int what, int* value) const {
switch (what) {
- case NATIVE_WINDOW_QUEUES_TO_WINDOW_COMPOSER:
- *value = 1;
- return NO_ERROR;
case NATIVE_WINDOW_CONCRETE_TYPE:
*value = NATIVE_WINDOW_SURFACE;
return NO_ERROR;
diff --git a/libs/gui/SurfaceTextureClient.cpp b/libs/gui/SurfaceTextureClient.cpp
index e91be84..5a35b4d 100644
--- a/libs/gui/SurfaceTextureClient.cpp
+++ b/libs/gui/SurfaceTextureClient.cpp
@@ -18,6 +18,8 @@
//#define LOG_NDEBUG 0
#include <gui/SurfaceTextureClient.h>
+#include <surfaceflinger/ISurfaceComposer.h>
+#include <surfaceflinger/SurfaceComposerClient.h>
#include <utils/Log.h>
@@ -234,7 +236,15 @@ int SurfaceTextureClient::query(int what, int* value) const {
}
break;
case NATIVE_WINDOW_QUEUES_TO_WINDOW_COMPOSER:
- *value = 0;
+ {
+ sp<ISurfaceComposer> composer(
+ ComposerService::getComposerService());
+ if (composer->authenticateSurfaceTexture(mSurfaceTexture)) {
+ *value = 1;
+ } else {
+ *value = 0;
+ }
+ }
return NO_ERROR;
case NATIVE_WINDOW_CONCRETE_TYPE:
*value = NATIVE_WINDOW_SURFACE_TEXTURE_CLIENT;
diff --git a/libs/rs/driver/rsdBcc.cpp b/libs/rs/driver/rsdBcc.cpp
index 176dd18..44ea79c 100644
--- a/libs/rs/driver/rsdBcc.cpp
+++ b/libs/rs/driver/rsdBcc.cpp
@@ -45,6 +45,7 @@ struct DrvScript {
InvokeFunc_t *mInvokeFunctions;
void ** mFieldAddress;
bool * mFieldIsObject;
+ const uint32_t *mExportForEachSignatureList;
const uint8_t * mScriptText;
uint32_t mScriptTextLength;
@@ -74,6 +75,7 @@ bool rsdScriptInit(const Context *rsc,
size_t exportFuncCount = 0;
size_t exportVarCount = 0;
size_t objectSlotCount = 0;
+ size_t exportForEachSignatureCount = 0;
DrvScript *drv = (DrvScript *)calloc(1, sizeof(DrvScript));
if (drv == NULL) {
@@ -153,6 +155,10 @@ bool rsdScriptInit(const Context *rsc,
}
}
+ exportForEachSignatureCount = drv->ME->getExportForEachSignatureCount();
+ rsAssert(exportForEachSignatureCount <= 1);
+ drv->mExportForEachSignatureList = drv->ME->getExportForEachSignatureList();
+
// Copy info over to runtime
script->mHal.info.exportedFunctionCount = drv->ME->getExportFuncCount();
script->mHal.info.exportedVariableCount = drv->ME->getExportVarCount();
@@ -179,6 +185,7 @@ error:
typedef struct {
Context *rsc;
Script *script;
+ uint32_t sig;
const Allocation * ain;
Allocation * aout;
const void * usr;
@@ -206,7 +213,7 @@ typedef struct {
uint32_t dimZ;
uint32_t dimArray;
} MTLaunchStruct;
-typedef int (*rs_t)(const void *, void *, const void *, uint32_t, uint32_t, uint32_t, uint32_t);
+typedef void (*rs_t)(const void *, void *, const void *, uint32_t, uint32_t, uint32_t, uint32_t);
static void wc_xy(void *usr, uint32_t idx) {
MTLaunchStruct *mtls = (MTLaunchStruct *)usr;
@@ -214,6 +221,8 @@ static void wc_xy(void *usr, uint32_t idx) {
memset(&p, 0, sizeof(p));
p.usr = mtls->usr;
p.usr_len = mtls->usrLen;
+ RsdHal * dc = (RsdHal *)mtls->rsc->mHal.drv;
+ uint32_t sig = mtls->sig;
while (1) {
uint32_t slice = (uint32_t)android_atomic_inc(&mtls->mSliceNum);
@@ -234,7 +243,7 @@ static void wc_xy(void *usr, uint32_t idx) {
for (p.x = mtls->xStart; p.x < mtls->xEnd; p.x++) {
p.in = xPtrIn;
p.out = xPtrOut;
- ((rs_t)mtls->script->mHal.info.root) (p.in, p.out, p.usr, p.x, p.y, 0, 0);
+ dc->mForEachLaunch[sig](&mtls->script->mHal.info.root, &p);
xPtrIn += mtls->eStrideIn;
xPtrOut += mtls->eStrideOut;
}
@@ -248,6 +257,8 @@ static void wc_x(void *usr, uint32_t idx) {
memset(&p, 0, sizeof(p));
p.usr = mtls->usr;
p.usr_len = mtls->usrLen;
+ RsdHal * dc = (RsdHal *)mtls->rsc->mHal.drv;
+ uint32_t sig = mtls->sig;
while (1) {
uint32_t slice = (uint32_t)android_atomic_inc(&mtls->mSliceNum);
@@ -265,7 +276,7 @@ static void wc_x(void *usr, uint32_t idx) {
for (p.x = xStart; p.x < xEnd; p.x++) {
p.in = xPtrIn;
p.out = xPtrOut;
- ((rs_t)mtls->script->mHal.info.root) (p.in, p.out, p.usr, p.x, 0, 0, 0);
+ dc->mForEachLaunch[sig](&mtls->script->mHal.info.root, &p);
xPtrIn += mtls->eStrideIn;
xPtrOut += mtls->eStrideOut;
}
@@ -286,6 +297,10 @@ void rsdScriptInvokeForEach(const Context *rsc,
MTLaunchStruct mtls;
memset(&mtls, 0, sizeof(mtls));
+ DrvScript *drv = (DrvScript *)s->mHal.drv;
+ // We only support slot 0 (root) at this point in time.
+ rsAssert(slot == 0);
+ mtls.sig = drv->mExportForEachSignatureList[slot];
if (ain) {
mtls.dimX = ain->getType()->getDimX();
mtls.dimY = ain->getType()->getDimY();
@@ -369,6 +384,7 @@ void rsdScriptInvokeForEach(const Context *rsc,
memset(&p, 0, sizeof(p));
p.usr = mtls.usr;
p.usr_len = mtls.usrLen;
+ uint32_t sig = mtls.sig;
//LOGE("launch 3");
for (p.ar[0] = mtls.arrayStart; p.ar[0] < mtls.arrayEnd; p.ar[0]++) {
@@ -383,7 +399,7 @@ void rsdScriptInvokeForEach(const Context *rsc,
for (p.x = mtls.xStart; p.x < mtls.xEnd; p.x++) {
p.in = xPtrIn;
p.out = xPtrOut;
- ((rs_t)s->mHal.info.root) (p.in, p.out, p.usr, p.x, p.y, p.z, p.ar[0]);
+ dc->mForEachLaunch[sig](&s->mHal.info.root, &p);
xPtrIn += mtls.eStrideIn;
xPtrOut += mtls.eStrideOut;
}
diff --git a/libs/rs/driver/rsdCore.cpp b/libs/rs/driver/rsdCore.cpp
index 38f6895..171d045 100644
--- a/libs/rs/driver/rsdCore.cpp
+++ b/libs/rs/driver/rsdCore.cpp
@@ -43,6 +43,7 @@ using namespace android::renderscript;
static void Shutdown(Context *rsc);
static void SetPriority(const Context *rsc, int32_t priority);
+static void initForEach(outer_foreach_t* forEachLaunch);
static RsdHalFunctions FunctionTable = {
rsdGLInit,
@@ -206,6 +207,8 @@ bool rsdHalInit(Context *rsc, uint32_t version_major, uint32_t version_minor) {
rsdgThreadTLSKeyCount++;
pthread_mutex_unlock(&rsdgInitMutex);
+ initForEach(dc->mForEachLaunch);
+
dc->mTlsStruct.mContext = rsc;
dc->mTlsStruct.mScript = NULL;
int status = pthread_setspecific(rsdgThreadTLSKey, &dc->mTlsStruct);
@@ -287,4 +290,112 @@ void Shutdown(Context *rsc) {
}
+static void rsdForEach17(const void *vRoot,
+ const android::renderscript::RsForEachStubParamStruct *p) {
+ typedef void (*fe)(const void *, uint32_t);
+ (*(fe*)vRoot)(p->in, p->y);
+}
+
+static void rsdForEach18(const void *vRoot,
+ const android::renderscript::RsForEachStubParamStruct *p) {
+ typedef void (*fe)(void *, uint32_t);
+ (*(fe*)vRoot)(p->out, p->y);
+}
+
+static void rsdForEach19(const void *vRoot,
+ const android::renderscript::RsForEachStubParamStruct *p) {
+ typedef void (*fe)(const void *, void *, uint32_t);
+ (*(fe*)vRoot)(p->in, p->out, p->y);
+}
+
+static void rsdForEach21(const void *vRoot,
+ const android::renderscript::RsForEachStubParamStruct *p) {
+ typedef void (*fe)(const void *, const void *, uint32_t);
+ (*(fe*)vRoot)(p->in, p->usr, p->y);
+}
+
+static void rsdForEach22(const void *vRoot,
+ const android::renderscript::RsForEachStubParamStruct *p) {
+ typedef void (*fe)(void *, const void *, uint32_t);
+ (*(fe*)vRoot)(p->out, p->usr, p->y);
+}
+
+static void rsdForEach23(const void *vRoot,
+ const android::renderscript::RsForEachStubParamStruct *p) {
+ typedef void (*fe)(const void *, void *, const void *, uint32_t);
+ (*(fe*)vRoot)(p->in, p->out, p->usr, p->y);
+}
+
+static void rsdForEach25(const void *vRoot,
+ const android::renderscript::RsForEachStubParamStruct *p) {
+ typedef void (*fe)(const void *, uint32_t, uint32_t);
+ (*(fe*)vRoot)(p->in, p->x, p->y);
+}
+
+static void rsdForEach26(const void *vRoot,
+ const android::renderscript::RsForEachStubParamStruct *p) {
+ typedef void (*fe)(void *, uint32_t, uint32_t);
+ (*(fe*)vRoot)(p->out, p->x, p->y);
+}
+
+static void rsdForEach27(const void *vRoot,
+ const android::renderscript::RsForEachStubParamStruct *p) {
+ typedef void (*fe)(const void *, void *, uint32_t, uint32_t);
+ (*(fe*)vRoot)(p->in, p->out, p->x, p->y);
+}
+
+static void rsdForEach29(const void *vRoot,
+ const android::renderscript::RsForEachStubParamStruct *p) {
+ typedef void (*fe)(const void *, const void *, uint32_t, uint32_t);
+ (*(fe*)vRoot)(p->in, p->usr, p->x, p->y);
+}
+
+static void rsdForEach30(const void *vRoot,
+ const android::renderscript::RsForEachStubParamStruct *p) {
+ typedef void (*fe)(void *, const void *, uint32_t, uint32_t);
+ (*(fe*)vRoot)(p->out, p->usr, p->x, p->y);
+}
+
+static void rsdForEach31(const void *vRoot,
+ const android::renderscript::RsForEachStubParamStruct *p) {
+ typedef void (*fe)(const void *, void *, const void *, uint32_t, uint32_t);
+ (*(fe*)vRoot)(p->in, p->out, p->usr, p->x, p->y);
+}
+
+
+static void initForEach(outer_foreach_t* forEachLaunch) {
+ rsAssert(forEachLaunch);
+ forEachLaunch[0x00] = NULL;
+ forEachLaunch[0x01] = rsdForEach31; // in
+ forEachLaunch[0x02] = rsdForEach30; // out
+ forEachLaunch[0x03] = rsdForEach31; // in, out
+ forEachLaunch[0x04] = NULL;
+ forEachLaunch[0x05] = rsdForEach29; // in, usr
+ forEachLaunch[0x06] = rsdForEach30; // out, usr
+ forEachLaunch[0x07] = rsdForEach31; // in, out, usr
+ forEachLaunch[0x08] = NULL;
+ forEachLaunch[0x09] = rsdForEach25; // in, x
+ forEachLaunch[0x0a] = rsdForEach26; // out, x
+ forEachLaunch[0x0b] = rsdForEach27; // in, out, x
+ forEachLaunch[0x0c] = NULL;
+ forEachLaunch[0x0d] = rsdForEach29; // in, usr, x
+ forEachLaunch[0x0e] = rsdForEach30; // out, usr, x
+ forEachLaunch[0x0f] = rsdForEach31; // in, out, usr, x
+ forEachLaunch[0x10] = NULL;
+ forEachLaunch[0x11] = rsdForEach17; // in y
+ forEachLaunch[0x12] = rsdForEach18; // out, y
+ forEachLaunch[0x13] = rsdForEach19; // in, out, y
+ forEachLaunch[0x14] = NULL;
+ forEachLaunch[0x15] = rsdForEach21; // in, usr, y
+ forEachLaunch[0x16] = rsdForEach22; // out, usr, y
+ forEachLaunch[0x17] = rsdForEach23; // in, out, usr, y
+ forEachLaunch[0x18] = NULL;
+ forEachLaunch[0x19] = rsdForEach25; // in, x, y
+ forEachLaunch[0x1a] = rsdForEach26; // out, x, y
+ forEachLaunch[0x1b] = rsdForEach27; // in, out, x, y
+ forEachLaunch[0x1c] = NULL;
+ forEachLaunch[0x1d] = rsdForEach29; // in, usr, x, y
+ forEachLaunch[0x1e] = rsdForEach30; // out, usr, x, y
+ forEachLaunch[0x1f] = rsdForEach31; // in, out, usr, x, y
+}
diff --git a/libs/rs/driver/rsdCore.h b/libs/rs/driver/rsdCore.h
index f393b60..159b72a 100644
--- a/libs/rs/driver/rsdCore.h
+++ b/libs/rs/driver/rsdCore.h
@@ -27,6 +27,9 @@
typedef void (* InvokeFunc_t)(void);
typedef void (*WorkerCallback_t)(void *usr, uint32_t idx);
+typedef void (*outer_foreach_t)(const void *,
+ const android::renderscript::RsForEachStubParamStruct *);
+
typedef struct RsdSymbolTableRec {
const char * mName;
void * mPtr;
@@ -57,6 +60,8 @@ typedef struct RsdHalRec {
Workers mWorkers;
bool mExit;
+ outer_foreach_t mForEachLaunch[32];
+
ScriptTLSStruct mTlsStruct;
RsdGL gl;
diff --git a/libs/rs/rsAllocation.cpp b/libs/rs/rsAllocation.cpp
index a366d49..4359d95 100644
--- a/libs/rs/rsAllocation.cpp
+++ b/libs/rs/rsAllocation.cpp
@@ -58,19 +58,7 @@ void Allocation::updateCache() {
}
Allocation::~Allocation() {
- if (mHal.state.hasReferences &&
- (mHal.state.hasFaces || mHal.state.hasMipmaps)) {
- LOGE("Cube/mip allocation with references unsupported, memory not cleaned up!");
- }
-
- uint32_t elemCount = mHal.state.dimensionX;
- if (mHal.state.dimensionY > 1) {
- elemCount *= mHal.state.dimensionY;
- }
- if (mHal.state.dimensionZ > 1) {
- elemCount *= mHal.state.dimensionZ;
- }
- decRefs(getPtr(), elemCount, 0);
+ freeChildrenUnlocked();
mRSC->mHal.funcs.allocation.destroy(mRSC, this);
}
@@ -299,6 +287,19 @@ void Allocation::decRefs(const void *ptr, size_t ct, size_t startOff) const {
}
}
+void Allocation::freeChildrenUnlocked () {
+ decRefs(getPtr(), mHal.state.type->getSizeBytes() / mHal.state.type->getElementSizeBytes(), 0);
+}
+
+bool Allocation::freeChildren() {
+ if (mHal.state.hasReferences) {
+ incSysRef();
+ freeChildrenUnlocked();
+ return decSysRef();
+ }
+ return false;
+}
+
void Allocation::copyRange1D(Context *rsc, const Allocation *src, int32_t srcOff, int32_t destOff, int32_t len) {
}
diff --git a/libs/rs/rsAllocation.h b/libs/rs/rsAllocation.h
index f2589c0..67fc3b5 100644
--- a/libs/rs/rsAllocation.h
+++ b/libs/rs/rsAllocation.h
@@ -116,6 +116,7 @@ public:
void incRefs(const void *ptr, size_t ct, size_t startOff = 0) const;
void decRefs(const void *ptr, size_t ct, size_t startOff = 0) const;
+ virtual bool freeChildren();
void sendDirty(const Context *rsc) const;
bool getHasGraphicsMipmaps() const {
@@ -127,6 +128,7 @@ protected:
Vector<const Program *> mToDirtyList;
private:
+ void freeChildrenUnlocked();
Allocation(Context *rsc, const Type *, uint32_t usages, RsAllocationMipmapControl mc);
};
diff --git a/libs/rs/rsContext.cpp b/libs/rs/rsContext.cpp
index 8996ad1..e3a9cf8 100644
--- a/libs/rs/rsContext.cpp
+++ b/libs/rs/rsContext.cpp
@@ -312,6 +312,7 @@ void Context::destroyWorkerThreadResources() {
mStateSampler.deinit(this);
mFBOCache.deinit(this);
}
+ ObjectBase::freeAllChildren(this);
//LOGV("destroyWorkerThreadResources 2");
mExit = true;
}
diff --git a/libs/rs/rsObjectBase.cpp b/libs/rs/rsObjectBase.cpp
index f428f94..f5ced26 100644
--- a/libs/rs/rsObjectBase.cpp
+++ b/libs/rs/rsObjectBase.cpp
@@ -81,6 +81,10 @@ void ObjectBase::incSysRef() const {
void ObjectBase::preDestroy() const {
}
+bool ObjectBase::freeChildren() {
+ return false;
+}
+
bool ObjectBase::checkDelete(const ObjectBase *ref) {
if (!ref) {
return false;
@@ -217,6 +221,28 @@ void ObjectBase::zeroAllUserRef(Context *rsc) {
}
}
+void ObjectBase::freeAllChildren(Context *rsc) {
+ if (rsc->props.mLogObjects) {
+ LOGV("Forcing release of all child objects.");
+ }
+
+ // This operation can be slow, only to be called during context cleanup.
+ ObjectBase * o = (ObjectBase *)rsc->mObjHead;
+ while (o) {
+ if (o->freeChildren()) {
+ // deleted ref to self and possibly others, restart from head.
+ o = (ObjectBase *)rsc->mObjHead;
+ } else {
+ o = (ObjectBase *)o->mNext;
+ }
+ }
+
+ if (rsc->props.mLogObjects) {
+ LOGV("Objects remaining.");
+ dumpAll(rsc);
+ }
+}
+
void ObjectBase::dumpAll(Context *rsc) {
asyncLock();
diff --git a/libs/rs/rsObjectBase.h b/libs/rs/rsObjectBase.h
index c7cfb0e..d9f5f3b 100644
--- a/libs/rs/rsObjectBase.h
+++ b/libs/rs/rsObjectBase.h
@@ -50,8 +50,10 @@ public:
void setName(const char *, uint32_t len);
Context * getContext() const {return mRSC;}
+ virtual bool freeChildren();
static void zeroAllUserRef(Context *rsc);
+ static void freeAllChildren(Context *rsc);
static void dumpAll(Context *rsc);
virtual void dumpLOGV(const char *prefix) const;
diff --git a/libs/rs/rsProgram.cpp b/libs/rs/rsProgram.cpp
index 33eb422..4178aa5 100644
--- a/libs/rs/rsProgram.cpp
+++ b/libs/rs/rsProgram.cpp
@@ -70,15 +70,8 @@ Program::Program(Context *rsc, const char * shaderText, uint32_t shaderLength,
}
Program::~Program() {
+ freeChildren();
- for (uint32_t ct=0; ct < mHal.state.constantsCount; ct++) {
- bindAllocation(NULL, NULL, ct);
- }
-
- for (uint32_t ct=0; ct < mHal.state.texturesCount; ct++) {
- bindTexture(NULL, ct, NULL);
- bindSampler(NULL, ct, NULL);
- }
delete[] mHal.state.textures;
delete[] mHal.state.samplers;
delete[] mHal.state.textureTargets;
@@ -90,6 +83,18 @@ Program::~Program() {
mHal.state.texturesCount = 0;
}
+bool Program::freeChildren() {
+ for (uint32_t ct=0; ct < mHal.state.constantsCount; ct++) {
+ bindAllocation(NULL, NULL, ct);
+ }
+
+ for (uint32_t ct=0; ct < mHal.state.texturesCount; ct++) {
+ bindTexture(NULL, ct, NULL);
+ bindSampler(NULL, ct, NULL);
+ }
+ return false;
+}
+
void Program::initMemberVars() {
mDirty = true;
diff --git a/libs/rs/rsProgram.h b/libs/rs/rsProgram.h
index 948ba3e..3237a72 100644
--- a/libs/rs/rsProgram.h
+++ b/libs/rs/rsProgram.h
@@ -34,6 +34,7 @@ public:
Program(Context *, const char * shaderText, uint32_t shaderLength,
const uint32_t * params, uint32_t paramLength);
virtual ~Program();
+ virtual bool freeChildren();
void bindAllocation(Context *, Allocation *, uint32_t slot);
diff --git a/media/java/android/media/videoeditor/MediaArtistNativeHelper.java b/media/java/android/media/videoeditor/MediaArtistNativeHelper.java
index 8caa04c..b7d129d 100644
--- a/media/java/android/media/videoeditor/MediaArtistNativeHelper.java
+++ b/media/java/android/media/videoeditor/MediaArtistNativeHelper.java
@@ -79,7 +79,8 @@ class MediaArtistNativeHelper {
private boolean mRegenerateAudio = true;
private String mExportFilename = null;
-
+ private int mExportVideoCodec = 0;
+ private int mExportAudioCodec = 0;
private int mProgressToApp;
private String mRenderPreviewOverlayFile;
@@ -765,17 +766,14 @@ class MediaArtistNativeHelper {
/** No video present in output clip. Used to generate audio only clip */
public static final int NO_VIDEO = 0;
- /** H263 baseline format. */
+ /** H263 video format. */
public static final int H263 = 1;
- /** MPEG4 video Simple Profile format. */
- public static final int MPEG4 = 2;
-
- /** MPEG4 video Simple Profile format with support for EMP. */
- public static final int MPEG4_EMP = 3;
-
/** H264 video */
- public static final int H264 = 4;
+ public static final int H264 = 2;
+
+ /** MPEG4 video format. */
+ public static final int MPEG4 = 3;
/** No transcoding. Output video format is same as input video format */
public static final int NULL_VIDEO = 254;
@@ -784,96 +782,6 @@ class MediaArtistNativeHelper {
public static final int UNSUPPORTED = 255;
}
- /** Defines video profiles and levels. */
- public final class VideoProfile {
- /** H263, Profile 0, Level 10. */
- public static final int H263_PROFILE_0_LEVEL_10 = MediaProperties.H263_PROFILE_0_LEVEL_10;
-
- /** H263, Profile 0, Level 20. */
- public static final int H263_PROFILE_0_LEVEL_20 = MediaProperties.H263_PROFILE_0_LEVEL_20;
-
- /** H263, Profile 0, Level 30. */
- public static final int H263_PROFILE_0_LEVEL_30 = MediaProperties.H263_PROFILE_0_LEVEL_30;
-
- /** H263, Profile 0, Level 40. */
- public static final int H263_PROFILE_0_LEVEL_40 = MediaProperties.H263_PROFILE_0_LEVEL_40;
-
- /** H263, Profile 0, Level 45. */
- public static final int H263_PROFILE_0_LEVEL_45 = MediaProperties.H263_PROFILE_0_LEVEL_45;
-
- /** MPEG4, Simple Profile, Level 0. */
- public static final int MPEG4_SP_LEVEL_0 = MediaProperties.MPEG4_SP_LEVEL_0;
-
- /** MPEG4, Simple Profile, Level 0B. */
- public static final int MPEG4_SP_LEVEL_0B = MediaProperties.MPEG4_SP_LEVEL_0B;
-
- /** MPEG4, Simple Profile, Level 1. */
- public static final int MPEG4_SP_LEVEL_1 = MediaProperties.MPEG4_SP_LEVEL_1;
-
- /** MPEG4, Simple Profile, Level 2. */
- public static final int MPEG4_SP_LEVEL_2 = MediaProperties.MPEG4_SP_LEVEL_2;
-
- /** MPEG4, Simple Profile, Level 3. */
- public static final int MPEG4_SP_LEVEL_3 = MediaProperties.MPEG4_SP_LEVEL_3;
-
- /** MPEG4, Simple Profile, Level 4A. */
- public static final int MPEG4_SP_LEVEL_4A = MediaProperties.MPEG4_SP_LEVEL_4A;
-
- /** MPEG4, Simple Profile, Level 0. */
- public static final int MPEG4_SP_LEVEL_5 = MediaProperties.MPEG4_SP_LEVEL_5;
-
- /** H264, Profile 0, Level 1. */
- public static final int H264_PROFILE_0_LEVEL_1 = MediaProperties.H264_PROFILE_0_LEVEL_1;
-
- /** H264, Profile 0, Level 1b. */
- public static final int H264_PROFILE_0_LEVEL_1b = MediaProperties.H264_PROFILE_0_LEVEL_1B;
-
- /** H264, Profile 0, Level 1.1 */
- public static final int H264_PROFILE_0_LEVEL_1_1 = MediaProperties.H264_PROFILE_0_LEVEL_1_1;
-
- /** H264, Profile 0, Level 1.2 */
- public static final int H264_PROFILE_0_LEVEL_1_2 = MediaProperties.H264_PROFILE_0_LEVEL_1_2;
-
- /** H264, Profile 0, Level 1.3 */
- public static final int H264_PROFILE_0_LEVEL_1_3 = MediaProperties.H264_PROFILE_0_LEVEL_1_3;
-
- /** H264, Profile 0, Level 2. */
- public static final int H264_PROFILE_0_LEVEL_2 = MediaProperties.H264_PROFILE_0_LEVEL_2;
-
- /** H264, Profile 0, Level 2.1 */
- public static final int H264_PROFILE_0_LEVEL_2_1 = MediaProperties.H264_PROFILE_0_LEVEL_2_1;
-
- /** H264, Profile 0, Level 2.2 */
- public static final int H264_PROFILE_0_LEVEL_2_2 = MediaProperties.H264_PROFILE_0_LEVEL_2_2;
-
- /** H264, Profile 0, Level 3. */
- public static final int H264_PROFILE_0_LEVEL_3 = MediaProperties.H264_PROFILE_0_LEVEL_3;
-
- /** H264, Profile 0, Level 3.1 */
- public static final int H264_PROFILE_0_LEVEL_3_1 = MediaProperties.H264_PROFILE_0_LEVEL_3_1;
-
- /** H264, Profile 0, Level 3.2 */
- public static final int H264_PROFILE_0_LEVEL_3_2 = MediaProperties.H264_PROFILE_0_LEVEL_3_2;
-
- /** H264, Profile 0, Level 4. */
- public static final int H264_PROFILE_0_LEVEL_4 = MediaProperties.H264_PROFILE_0_LEVEL_4;
-
- /** H264, Profile 0, Level 4.1 */
- public static final int H264_PROFILE_0_LEVEL_4_1 = MediaProperties.H264_PROFILE_0_LEVEL_4_1;
-
- /** H264, Profile 0, Level 4.2 */
- public static final int H264_PROFILE_0_LEVEL_4_2 = MediaProperties.H264_PROFILE_0_LEVEL_4_2;
-
- /** H264, Profile 0, Level 5. */
- public static final int H264_PROFILE_0_LEVEL_5 = MediaProperties.H264_PROFILE_0_LEVEL_5;
-
- /** H264, Profile 0, Level 5.1 */
- public static final int H264_PROFILE_0_LEVEL_5_1 = MediaProperties.H264_PROFILE_0_LEVEL_5_1;
-
- /** Profile out of range. */
- public static final int OUT_OF_RANGE = MediaProperties.UNSUPPORTED_PROFILE_LEVEL;
- }
-
/** Defines video frame sizes. */
public final class VideoFrameSize {
@@ -1620,6 +1528,16 @@ class MediaArtistNativeHelper {
public int videoFormat;
/**
+ * Profile of the video stream in the output clip.
+ */
+ public int videoProfile;
+
+ /**
+ * Level of the video stream in the output clip.
+ */
+ public int videoLevel;
+
+ /**
* Format of the audio stream in the output clip. See
* {@link AudioFormat AudioFormat} for valid values.
*/
@@ -1723,10 +1641,28 @@ class MediaArtistNativeHelper {
public float averageFrameRate;
/**
- * Profile and level of the video in the media.
+ * Profile of the video in the media.
+ */
+
+ public int profile;
+
+ /**
+ * Level of the video in the media.
+ */
+
+ public int level;
+
+ /**
+ * Is Video Profile supported.
*/
- public int profileAndLevel;
+ public boolean profileSupported;
+
+ /**
+ * Is Video Level supported.
+ */
+
+ public boolean levelSupported;
/**
* Audio format.
@@ -2112,6 +2048,25 @@ class MediaArtistNativeHelper {
}
/**
+ * Sets the export audio codec
+ *
+ * @param export audio codec
+ *
+ */
+ void setAudioCodec(int codec) {
+ mExportAudioCodec = codec;
+ }
+ /**
+ * Sets the export video codec
+ *
+ * @param export video codec
+ *
+ */
+ void setVideoCodec(int codec) {
+ mExportVideoCodec = codec;
+ }
+
+ /**
* Sets the audio regenerate flag
*
* @param flag The boolean to set the audio regenerate flag
@@ -2320,7 +2275,8 @@ class MediaArtistNativeHelper {
int err = 0;
EditSettings editSettings = null;
String EffectClipPath = null;
-
+ int outVideoProfile = 0;
+ int outVideoLevel = 0;
editSettings = new EditSettings();
editSettings.clipSettingsArray = new ClipSettings[1];
@@ -2338,6 +2294,11 @@ class MediaArtistNativeHelper {
tmpFile.delete();
}
+ outVideoProfile = VideoEditorProfile.getExportProfile(VideoFormat.H264);
+ outVideoLevel = VideoEditorProfile.getExportLevel(VideoFormat.H264);
+ editSettings.videoProfile = outVideoProfile;
+ editSettings.videoLevel= outVideoLevel;
+
if (lMediaItem instanceof MediaVideoItem) {
MediaVideoItem m = (MediaVideoItem)lMediaItem;
@@ -2399,6 +2360,8 @@ class MediaArtistNativeHelper {
String generateKenBurnsClip(EditSettings e, MediaImageItem m) {
String output = null;
int err = 0;
+ int outVideoProfile = 0;
+ int outVideoLevel = 0;
e.backgroundMusicSettings = null;
e.transitionSettingsArray = null;
@@ -2410,6 +2373,11 @@ class MediaArtistNativeHelper {
tmpFile.delete();
}
+ outVideoProfile = VideoEditorProfile.getExportProfile(VideoFormat.H264);
+ outVideoLevel = VideoEditorProfile.getExportLevel(VideoFormat.H264);
+ e.videoProfile = outVideoProfile;
+ e.videoLevel = outVideoLevel;
+
e.outputFile = output;
e.audioBitrate = Bitrate.BR_64_KBPS;
e.audioChannels = 2;
@@ -2496,8 +2464,15 @@ class MediaArtistNativeHelper {
MediaItem m1, MediaItem m2,Transition t) {
String outputFilename = null;
int err = 0;
-
+ int outVideoProfile = 0;
+ int outVideoLevel = 0;
outputFilename = String.format(mProjectPath + "/" + uniqueId + ".3gp");
+
+ outVideoProfile = VideoEditorProfile.getExportProfile(VideoFormat.H264);
+ outVideoLevel = VideoEditorProfile.getExportLevel(VideoFormat.H264);
+ e.videoProfile = outVideoProfile;
+ e.videoLevel = outVideoLevel;
+
e.outputFile = outputFilename;
e.audioBitrate = Bitrate.BR_64_KBPS;
e.audioChannels = 2;
@@ -3275,7 +3250,7 @@ class MediaArtistNativeHelper {
retValue = MediaProperties.VCODEC_H263;
break;
case VideoFormat.H264:
- retValue = MediaProperties.VCODEC_H264BP;
+ retValue = MediaProperties.VCODEC_H264;
break;
case VideoFormat.MPEG4:
retValue = MediaProperties.VCODEC_MPEG4;
@@ -3602,6 +3577,24 @@ class MediaArtistNativeHelper {
mExportFilename = filePath;
previewStoryBoard(mediaItemsList, mediaTransitionList, mediaBGMList,null);
mExportProgressListener = listener;
+ int outVideoProfile = 0;
+ int outVideoLevel = 0;
+
+ /** Check the platform specific maximum export resolution */
+ VideoEditorProfile veProfile = VideoEditorProfile.get();
+ if (veProfile == null) {
+ throw new RuntimeException("Can't get the video editor profile");
+ }
+ final int maxOutputHeight = veProfile.maxOutputVideoFrameHeight;
+ final int maxOutputWidth = veProfile.maxOutputVideoFrameWidth;
+ if (height > maxOutputHeight) {
+ throw new IllegalArgumentException(
+ "Unsupported export resolution. Supported maximum width:" +
+ maxOutputWidth + " height:" + maxOutputHeight +
+ " current height:" + height);
+ }
+ outVideoProfile = VideoEditorProfile.getExportProfile(mExportVideoCodec);
+ outVideoLevel = VideoEditorProfile.getExportLevel(mExportVideoCodec);
mProgressToApp = 0;
@@ -3655,8 +3648,10 @@ class MediaArtistNativeHelper {
int aspectRatio = mVideoEditor.getAspectRatio();
mPreviewEditSettings.videoFrameSize = findVideoResolution(aspectRatio, height);
- mPreviewEditSettings.videoFormat = VideoFormat.H264;
- mPreviewEditSettings.audioFormat = AudioFormat.AAC;
+ mPreviewEditSettings.videoFormat = mExportVideoCodec;
+ mPreviewEditSettings.audioFormat = mExportAudioCodec;
+ mPreviewEditSettings.videoProfile = outVideoProfile;
+ mPreviewEditSettings.videoLevel = outVideoLevel;
mPreviewEditSettings.audioSamplingFreq = AudioSamplingFrequency.FREQ_32000;
mPreviewEditSettings.maxFileSize = 0;
mPreviewEditSettings.audioChannels = 2;
diff --git a/media/java/android/media/videoeditor/MediaProperties.java b/media/java/android/media/videoeditor/MediaProperties.java
index ff13e5d..fd034ab 100755
--- a/media/java/android/media/videoeditor/MediaProperties.java
+++ b/media/java/android/media/videoeditor/MediaProperties.java
@@ -135,89 +135,118 @@ public class MediaProperties {
* Video codec types
*/
public static final int VCODEC_H263 = 1;
- public static final int VCODEC_MPEG4 = 2;
- // 3 Value is used for MPEG4_EMP
- public static final int VCODEC_H264BP = 4;
- public static final int VCODEC_H264MP = 5; // Unsupported
+ public static final int VCODEC_H264 = 2;
+ public static final int VCODEC_MPEG4 = 3;
/**
* The array of supported video codecs
*/
private static final int[] SUPPORTED_VCODECS = new int[] {
- VCODEC_H264BP,
+ VCODEC_H264,
VCODEC_H263,
VCODEC_MPEG4,
};
- /* H.263 Profiles and levels */
- public static final int H263_PROFILE_0_LEVEL_10 = 0;
- public static final int H263_PROFILE_0_LEVEL_20 = 1;
- public static final int H263_PROFILE_0_LEVEL_30 = 2;
- public static final int H263_PROFILE_0_LEVEL_40 = 3;
- public static final int H263_PROFILE_0_LEVEL_45 = 4;
- /* MPEG-4 Profiles and levels */
- public static final int MPEG4_SP_LEVEL_0 = 50;
- public static final int MPEG4_SP_LEVEL_0B = 51;
- public static final int MPEG4_SP_LEVEL_1 = 52;
- public static final int MPEG4_SP_LEVEL_2 = 53;
- public static final int MPEG4_SP_LEVEL_3 = 54;
- public static final int MPEG4_SP_LEVEL_4A = 55;
- public static final int MPEG4_SP_LEVEL_5 = 56;
- /* AVC Profiles and levels */
- public static final int H264_PROFILE_0_LEVEL_1 = 150;
- public static final int H264_PROFILE_0_LEVEL_1B = 151;
- public static final int H264_PROFILE_0_LEVEL_1_1 = 152;
- public static final int H264_PROFILE_0_LEVEL_1_2 = 153;
- public static final int H264_PROFILE_0_LEVEL_1_3 = 154;
- public static final int H264_PROFILE_0_LEVEL_2 = 155;
- public static final int H264_PROFILE_0_LEVEL_2_1 = 156;
- public static final int H264_PROFILE_0_LEVEL_2_2 = 157;
- public static final int H264_PROFILE_0_LEVEL_3 = 158;
- public static final int H264_PROFILE_0_LEVEL_3_1 = 159;
- public static final int H264_PROFILE_0_LEVEL_3_2 = 160;
- public static final int H264_PROFILE_0_LEVEL_4 = 161;
- public static final int H264_PROFILE_0_LEVEL_4_1 = 162;
- public static final int H264_PROFILE_0_LEVEL_4_2 = 163;
- public static final int H264_PROFILE_0_LEVEL_5 = 164;
- public static final int H264_PROFILE_0_LEVEL_5_1 = 165;
- /* Unsupported profile and level */
- public static final int UNSUPPORTED_PROFILE_LEVEL = 255;
-
/**
- * The array of supported video codec Profile and Levels
+ * The H264 profile, the values are same as the one in OMX_Video.h
*/
- private static final int[] SUPPORTED_VCODEC_PROFILE_LEVELS = new int[] {
- H263_PROFILE_0_LEVEL_10,
- H263_PROFILE_0_LEVEL_20,
- H263_PROFILE_0_LEVEL_30,
- H263_PROFILE_0_LEVEL_40,
- H263_PROFILE_0_LEVEL_45,
- MPEG4_SP_LEVEL_0,
- MPEG4_SP_LEVEL_0B,
- MPEG4_SP_LEVEL_1,
- MPEG4_SP_LEVEL_2,
- MPEG4_SP_LEVEL_3,
- MPEG4_SP_LEVEL_4A,
- MPEG4_SP_LEVEL_5,
- H264_PROFILE_0_LEVEL_1,
- H264_PROFILE_0_LEVEL_1B,
- H264_PROFILE_0_LEVEL_1_1,
- H264_PROFILE_0_LEVEL_1_2,
- H264_PROFILE_0_LEVEL_1_3,
- H264_PROFILE_0_LEVEL_2,
- H264_PROFILE_0_LEVEL_2_1,
- H264_PROFILE_0_LEVEL_2_2,
- H264_PROFILE_0_LEVEL_3,
- H264_PROFILE_0_LEVEL_3_1,
- H264_PROFILE_0_LEVEL_3_2,
- H264_PROFILE_0_LEVEL_4,
- H264_PROFILE_0_LEVEL_4_1,
- H264_PROFILE_0_LEVEL_4_2,
- H264_PROFILE_0_LEVEL_5,
- H264_PROFILE_0_LEVEL_5_1,
- UNSUPPORTED_PROFILE_LEVEL
- };
-
+ public final class H264Profile {
+ public static final int H264ProfileBaseline = 0x01; /**< Baseline profile */
+ public static final int H264ProfileMain = 0x02; /**< Main profile */
+ public static final int H264ProfileExtended = 0x04; /**< Extended profile */
+ public static final int H264ProfileHigh = 0x08; /**< High profile */
+ public static final int H264ProfileHigh10 = 0x10; /**< High 10 profile */
+ public static final int H264ProfileHigh422 = 0x20; /**< High 4:2:2 profile */
+ public static final int H264ProfileHigh444 = 0x40; /**< High 4:4:4 profile */
+ public static final int H264ProfileUnknown = 0x7FFFFFFF;
+ }
+ /**
+ * The H264 level, the values are same as the one in OMX_Video.h
+ */
+ public final class H264Level {
+ public static final int H264Level1 = 0x01; /**< Level 1 */
+ public static final int H264Level1b = 0x02; /**< Level 1b */
+ public static final int H264Level11 = 0x04; /**< Level 1.1 */
+ public static final int H264Level12 = 0x08; /**< Level 1.2 */
+ public static final int H264Level13 = 0x10; /**< Level 1.3 */
+ public static final int H264Level2 = 0x20; /**< Level 2 */
+ public static final int H264Level21 = 0x40; /**< Level 2.1 */
+ public static final int H264Level22 = 0x80; /**< Level 2.2 */
+ public static final int H264Level3 = 0x100; /**< Level 3 */
+ public static final int H264Level31 = 0x200; /**< Level 3.1 */
+ public static final int H264Level32 = 0x400; /**< Level 3.2 */
+ public static final int H264Level4 = 0x800; /**< Level 4 */
+ public static final int H264Level41 = 0x1000; /**< Level 4.1 */
+ public static final int H264Level42 = 0x2000; /**< Level 4.2 */
+ public static final int H264Level5 = 0x4000; /**< Level 5 */
+ public static final int H264Level51 = 0x8000; /**< Level 5.1 */
+ public static final int H264LevelUnknown = 0x7FFFFFFF;
+ }
+ /**
+ * The H263 profile, the values are same as the one in OMX_Video.h
+ */
+ public final class H263Profile {
+ public static final int H263ProfileBaseline = 0x01;
+ public static final int H263ProfileH320Coding = 0x02;
+ public static final int H263ProfileBackwardCompatible = 0x04;
+ public static final int H263ProfileISWV2 = 0x08;
+ public static final int H263ProfileISWV3 = 0x10;
+ public static final int H263ProfileHighCompression = 0x20;
+ public static final int H263ProfileInternet = 0x40;
+ public static final int H263ProfileInterlace = 0x80;
+ public static final int H263ProfileHighLatency = 0x100;
+ public static final int H263ProfileUnknown = 0x7FFFFFFF;
+ }
+ /**
+ * The H263 level, the values are same as the one in OMX_Video.h
+ */
+ public final class H263Level {
+ public static final int H263Level10 = 0x01;
+ public static final int H263Level20 = 0x02;
+ public static final int H263Level30 = 0x04;
+ public static final int H263Level40 = 0x08;
+ public static final int H263Level45 = 0x10;
+ public static final int H263Level50 = 0x20;
+ public static final int H263Level60 = 0x40;
+ public static final int H263Level70 = 0x80;
+ public static final int H263LevelUnknown = 0x7FFFFFFF;
+ }
+ /**
+ * The mpeg4 profile, the values are same as the one in OMX_Video.h
+ */
+ public final class MPEG4Profile {
+ public static final int MPEG4ProfileSimple = 0x01;
+ public static final int MPEG4ProfileSimpleScalable = 0x02;
+ public static final int MPEG4ProfileCore = 0x04;
+ public static final int MPEG4ProfileMain = 0x08;
+ public static final int MPEG4ProfileNbit = 0x10;
+ public static final int MPEG4ProfileScalableTexture = 0x20;
+ public static final int MPEG4ProfileSimpleFace = 0x40;
+ public static final int MPEG4ProfileSimpleFBA = 0x80;
+ public static final int MPEG4ProfileBasicAnimated = 0x100;
+ public static final int MPEG4ProfileHybrid = 0x200;
+ public static final int MPEG4ProfileAdvancedRealTime = 0x400;
+ public static final int MPEG4ProfileCoreScalable = 0x800;
+ public static final int MPEG4ProfileAdvancedCoding = 0x1000;
+ public static final int MPEG4ProfileAdvancedCore = 0x2000;
+ public static final int MPEG4ProfileAdvancedScalable = 0x4000;
+ public static final int MPEG4ProfileAdvancedSimple = 0x8000;
+ public static final int MPEG4ProfileUnknown = 0x7FFFFFFF;
+ }
+ /**
+ * The mpeg4 level, the values are same as the one in OMX_Video.h
+ */
+ public final class MPEG4Level {
+ public static final int MPEG4Level0 = 0x01; /**< Level 0 */
+ public static final int MPEG4Level0b = 0x02; /**< Level 0b */
+ public static final int MPEG4Level1 = 0x04; /**< Level 1 */
+ public static final int MPEG4Level2 = 0x08; /**< Level 2 */
+ public static final int MPEG4Level3 = 0x10; /**< Level 3 */
+ public static final int MPEG4Level4 = 0x20; /**< Level 4 */
+ public static final int MPEG4Level4a = 0x40; /**< Level 4a */
+ public static final int MPEG4Level5 = 0x80; /**< Level 5 */
+ public static final int MPEG4LevelUnknown = 0x7FFFFFFF;
+ }
/**
* Audio codec types
*/
@@ -241,7 +270,6 @@ public class MediaProperties {
ACODEC_AMRWB
};
-
/**
* Samples per frame for each audio codec
*/
diff --git a/media/java/android/media/videoeditor/MediaVideoItem.java b/media/java/android/media/videoeditor/MediaVideoItem.java
index 0ac354b..fea751b 100755
--- a/media/java/android/media/videoeditor/MediaVideoItem.java
+++ b/media/java/android/media/videoeditor/MediaVideoItem.java
@@ -42,6 +42,7 @@ public class MediaVideoItem extends MediaItem {
private final int mFileType;
private final int mVideoType;
private final int mVideoProfile;
+ private final int mVideoLevel;
private final int mVideoBitrate;
private final long mDurationMs;
private final int mAudioBitrate;
@@ -134,6 +135,15 @@ public class MediaVideoItem extends MediaItem {
", current width:" + properties.width +
" height:" + properties.height);
}
+ /** Check the platform specific maximum video profile and level */
+ if (!properties.profileSupported) {
+ throw new IllegalArgumentException(
+ "Unsupported video profile " + properties.profile);
+ }
+ if (!properties.levelSupported) {
+ throw new IllegalArgumentException(
+ "Unsupported video level " + properties.level);
+ }
switch (mMANativeHelper.getFileType(properties.fileType)) {
case MediaProperties.FILE_3GP:
case MediaProperties.FILE_MP4:
@@ -146,8 +156,7 @@ public class MediaVideoItem extends MediaItem {
switch (mMANativeHelper.getVideoCodecType(properties.videoFormat)) {
case MediaProperties.VCODEC_H263:
- case MediaProperties.VCODEC_H264BP:
- case MediaProperties.VCODEC_H264MP:
+ case MediaProperties.VCODEC_H264:
case MediaProperties.VCODEC_MPEG4:
break;
@@ -155,18 +164,14 @@ public class MediaVideoItem extends MediaItem {
throw new IllegalArgumentException("Unsupported Video Codec Format in Input File");
}
- /* Check if the profile is unsupported. */
- if (properties.profileAndLevel == MediaProperties.UNDEFINED_VIDEO_PROFILE) {
- throw new IllegalArgumentException("Unsupported Video Codec Profile in Input File");
- }
-
mWidth = properties.width;
mHeight = properties.height;
mAspectRatio = mMANativeHelper.getAspectRatio(properties.width,
properties.height);
mFileType = mMANativeHelper.getFileType(properties.fileType);
mVideoType = mMANativeHelper.getVideoCodecType(properties.videoFormat);
- mVideoProfile = properties.profileAndLevel;
+ mVideoProfile = properties.profile;
+ mVideoLevel = properties.level;
mDurationMs = properties.videoDuration;
mVideoBitrate = properties.videoBitrate;
mAudioBitrate = properties.audioBitrate;
@@ -661,6 +666,13 @@ public class MediaVideoItem extends MediaItem {
}
/**
+ * @return The video profile
+ */
+ public int getVideoLevel() {
+ return mVideoLevel;
+ }
+
+ /**
* @return The video bitrate
*/
public int getVideoBitrate() {
diff --git a/media/java/android/media/videoeditor/VideoEditor.java b/media/java/android/media/videoeditor/VideoEditor.java
index 720e8022..424e436 100755
--- a/media/java/android/media/videoeditor/VideoEditor.java
+++ b/media/java/android/media/videoeditor/VideoEditor.java
@@ -396,7 +396,7 @@ public interface VideoEditor {
* supported for export purposes.
* @param videoCodec The video codec to be used for the export. The video
* codec values are defined in the MediaProperties class (e.g.
- * VCODEC_H264BP). Note that not all video codec types are
+ * VCODEC_H264). Note that not all video codec types are
* supported for export purposes.
* @param listener The listener for progress notifications. Use null if
* export progress notifications are not needed.
diff --git a/media/java/android/media/videoeditor/VideoEditorImpl.java b/media/java/android/media/videoeditor/VideoEditorImpl.java
index ea7fe63..f18dd88 100755
--- a/media/java/android/media/videoeditor/VideoEditorImpl.java
+++ b/media/java/android/media/videoeditor/VideoEditorImpl.java
@@ -339,42 +339,8 @@ public class VideoEditorImpl implements VideoEditor {
int audioCodec, int videoCodec,
ExportProgressListener listener)
throws IOException {
-
- switch (audioCodec) {
- case MediaProperties.ACODEC_AAC_LC:
- break;
- case MediaProperties.ACODEC_AMRNB:
- break;
-
- default: {
- String message = "Unsupported audio codec type " + audioCodec;
- throw new IllegalArgumentException(message);
- }
- }
-
- switch (videoCodec) {
- case MediaProperties.VCODEC_H263:
- break;
- case MediaProperties.VCODEC_H264BP:
- break;
- case MediaProperties.VCODEC_MPEG4:
- break;
-
- default: {
- String message = "Unsupported video codec type " + videoCodec;
- throw new IllegalArgumentException(message);
- }
- }
-
- export(filename, height, bitrate, listener);
- }
-
- /*
- * {@inheritDoc}
- */
- public void export(String filename, int height, int bitrate,
- ExportProgressListener listener)
- throws IOException {
+ int audcodec = 0;
+ int vidcodec = 0;
if (filename == null) {
throw new IllegalArgumentException("export: filename is null");
}
@@ -388,20 +354,6 @@ public class VideoEditorImpl implements VideoEditor {
throw new IllegalStateException("No MediaItems added");
}
- /** Check the platform specific maximum export resolution */
- VideoEditorProfile veProfile = VideoEditorProfile.get();
- if (veProfile == null) {
- throw new RuntimeException("Can't get the video editor profile");
- }
- final int maxOutputHeight = veProfile.maxOutputVideoFrameHeight;
- final int maxOutputWidth = veProfile.maxOutputVideoFrameWidth;
- if (height > maxOutputHeight) {
- throw new IllegalArgumentException(
- "Unsupported export resolution. Supported maximum width:" +
- maxOutputWidth + " height:" + maxOutputHeight +
- " current height:" + height);
- }
-
switch (height) {
case MediaProperties.HEIGHT_144:
break;
@@ -461,6 +413,36 @@ public class VideoEditorImpl implements VideoEditor {
if (MAX_SUPPORTED_FILE_SIZE <= fileSize) {
throw new IllegalStateException("Export Size is more than 2GB");
}
+ switch (audioCodec) {
+ case MediaProperties.ACODEC_AAC_LC:
+ audcodec = MediaArtistNativeHelper.AudioFormat.AAC;
+ break;
+ case MediaProperties.ACODEC_AMRNB:
+ audcodec = MediaArtistNativeHelper.AudioFormat.AMR_NB;
+ break;
+
+ default: {
+ String message = "Unsupported audio codec type " + audioCodec;
+ throw new IllegalArgumentException(message);
+ }
+ }
+
+ switch (videoCodec) {
+ case MediaProperties.VCODEC_H263:
+ vidcodec = MediaArtistNativeHelper.VideoFormat.H263;
+ break;
+ case MediaProperties.VCODEC_H264:
+ vidcodec = MediaArtistNativeHelper.VideoFormat.H264;
+ break;
+ case MediaProperties.VCODEC_MPEG4:
+ vidcodec = MediaArtistNativeHelper.VideoFormat.MPEG4;
+ break;
+
+ default: {
+ String message = "Unsupported video codec type " + videoCodec;
+ throw new IllegalArgumentException(message);
+ }
+ }
boolean semAcquireDone = false;
try {
@@ -470,7 +452,8 @@ public class VideoEditorImpl implements VideoEditor {
if (mMANativeHelper == null) {
throw new IllegalStateException("The video editor is not initialized");
}
-
+ mMANativeHelper.setAudioCodec(audcodec);
+ mMANativeHelper.setVideoCodec(vidcodec);
mMANativeHelper.export(filename, mProjectPath, height,bitrate,
mMediaItems, mTransitions, mAudioTracks, listener);
} catch (InterruptedException ex) {
@@ -485,6 +468,19 @@ public class VideoEditorImpl implements VideoEditor {
/*
* {@inheritDoc}
*/
+ public void export(String filename, int height, int bitrate,
+ ExportProgressListener listener)
+ throws IOException {
+ int defaultAudiocodec = MediaArtistNativeHelper.AudioFormat.AAC;
+ int defaultVideocodec = MediaArtistNativeHelper.VideoFormat.H264;
+
+ export(filename, height, bitrate, defaultAudiocodec,
+ defaultVideocodec, listener);
+ }
+
+ /*
+ * {@inheritDoc}
+ */
public void generatePreview(MediaProcessingProgressListener listener) {
boolean semAcquireDone = false;
try {
diff --git a/media/java/android/media/videoeditor/VideoEditorProfile.java b/media/java/android/media/videoeditor/VideoEditorProfile.java
index 7d9fc8f..ecdcdfb 100755
--- a/media/java/android/media/videoeditor/VideoEditorProfile.java
+++ b/media/java/android/media/videoeditor/VideoEditorProfile.java
@@ -31,6 +31,10 @@ package android.media.videoeditor;
*/
public class VideoEditorProfile
{
+ static {
+ System.loadLibrary("media_jni");
+ native_init();
+ }
/**
* The max input video frame width
*/
@@ -58,9 +62,42 @@ public class VideoEditorProfile
return native_get_videoeditor_profile();
}
- static {
- System.loadLibrary("media_jni");
- native_init();
+ /**
+ * Returns the supported profile by given video codec
+ */
+ public static int getExportProfile(int vidCodec) {
+ int profile = -1;
+
+ switch (vidCodec) {
+ case MediaProperties.VCODEC_H263:
+ case MediaProperties.VCODEC_H264:
+ case MediaProperties.VCODEC_MPEG4:
+ profile = native_get_videoeditor_export_profile(vidCodec);
+ break;
+ default :
+ throw new IllegalArgumentException("Unsupported video codec" + vidCodec);
+ }
+
+ return profile;
+ }
+
+ /**
+ * Returns the supported level by given video codec
+ */
+ public static int getExportLevel(int vidCodec) {
+ int level = -1;
+
+ switch (vidCodec) {
+ case MediaProperties.VCODEC_H263:
+ case MediaProperties.VCODEC_H264:
+ case MediaProperties.VCODEC_MPEG4:
+ level = native_get_videoeditor_export_profile(vidCodec);
+ break;
+ default :
+ throw new IllegalArgumentException("Unsupported video codec" + vidCodec);
+ }
+
+ return level;
}
// Private constructor called by JNI
@@ -78,5 +115,8 @@ public class VideoEditorProfile
// Methods implemented by JNI
private static native final void native_init();
private static native final VideoEditorProfile
- native_get_videoeditor_profile();
+ native_get_videoeditor_profile();
+ private static native final int native_get_videoeditor_export_profile(int codec);
+ private static native final int native_get_videoeditor_export_level(int level);
+
}
diff --git a/media/jni/android_media_MediaProfiles.cpp b/media/jni/android_media_MediaProfiles.cpp
index 2b8dfe4..e5e688c 100644
--- a/media/jni/android_media_MediaProfiles.cpp
+++ b/media/jni/android_media_MediaProfiles.cpp
@@ -324,7 +324,37 @@ android_media_MediaProfiles_native_get_videoeditor_profile(JNIEnv *env, jobject
maxOutputFrameWidth,
maxOutputFrameHeight);
}
+static jint
+android_media_MediaProfiles_native_get_videoeditor_export_profile(
+ JNIEnv *env, jobject thiz, jint codec)
+{
+ LOGV("android_media_MediaProfiles_native_get_export_profile index ");
+ int profile =0;
+ profile = sProfiles->getVideoEditorExportParamByName("videoeditor.export.profile", codec);
+ // Check the values retrieved
+ if (profile == -1) {
+ jniThrowException(env, "java/lang/RuntimeException",\
+ "Error retrieving videoeditor export profile params");
+ return -1;
+ }
+ return static_cast<jint>(profile);
+}
+static jint
+android_media_MediaProfiles_native_get_videoeditor_export_level(
+ JNIEnv *env, jobject thiz, jint codec)
+{
+ LOGV("android_media_MediaProfiles_native_get_export_level");
+ int level =0;
+ level = sProfiles->getVideoEditorExportParamByName("videoeditor.export.level", codec);
+ // Check the values retrieved
+ if (level == -1) {
+ jniThrowException(env, "java/lang/RuntimeException",\
+ "Error retrieving videoeditor export level params");
+ return -1;
+ }
+ return static_cast<jint>(level);
+}
static JNINativeMethod gMethodsForEncoderCapabilitiesClass[] = {
{"native_init", "()V", (void *)android_media_MediaProfiles_native_init},
{"native_get_num_file_formats", "()I", (void *)android_media_MediaProfiles_native_get_num_file_formats},
@@ -363,16 +393,18 @@ static JNINativeMethod gMethodsForCameraProfileClass[] = {
};
static JNINativeMethod gMethodsForVideoEditorProfileClass[] = {
- {"native_init", "()V", (void *)android_media_MediaProfiles_native_init},
- {"native_get_videoeditor_profile", "()Landroid/media/videoeditor/VideoEditorProfile;",
- (void *)android_media_MediaProfiles_native_get_videoeditor_profile},
+ {"native_init", "()V", (void *)android_media_MediaProfiles_native_init},
+ {"native_get_videoeditor_profile", "()Landroid/media/videoeditor/VideoEditorProfile;", (void *)android_media_MediaProfiles_native_get_videoeditor_profile},
+ {"native_get_videoeditor_export_profile", "(I)I", (void *)android_media_MediaProfiles_native_get_videoeditor_export_profile},
+ {"native_get_videoeditor_export_level", "(I)I", (void *)android_media_MediaProfiles_native_get_videoeditor_export_level},
};
static const char* const kEncoderCapabilitiesClassPathName = "android/media/EncoderCapabilities";
static const char* const kDecoderCapabilitiesClassPathName = "android/media/DecoderCapabilities";
static const char* const kCamcorderProfileClassPathName = "android/media/CamcorderProfile";
static const char* const kCameraProfileClassPathName = "android/media/CameraProfile";
-static const char* const kVideoEditorProfileClassPathName = "android/media/videoeditor/VideoEditorProfile";
+static const char* const kVideoEditorProfileClassPathName =
+ "android/media/videoeditor/VideoEditorProfile";
// This function only registers the native methods, and is called from
// JNI_OnLoad in android_media_MediaPlayer.cpp
diff --git a/media/jni/mediaeditor/VideoEditorClasses.cpp b/media/jni/mediaeditor/VideoEditorClasses.cpp
index 4c0e731..69735ca 100755
--- a/media/jni/mediaeditor/VideoEditorClasses.cpp
+++ b/media/jni/mediaeditor/VideoEditorClasses.cpp
@@ -402,7 +402,6 @@ VIDEOEDIT_JAVA_DEFINE_CONSTANTS(VideoFormat)
VIDEOEDIT_JAVA_CONSTANT_INIT("NO_VIDEO", M4VIDEOEDITING_kNoneVideo),
VIDEOEDIT_JAVA_CONSTANT_INIT("H263", M4VIDEOEDITING_kH263),
VIDEOEDIT_JAVA_CONSTANT_INIT("MPEG4", M4VIDEOEDITING_kMPEG4),
- VIDEOEDIT_JAVA_CONSTANT_INIT("MPEG4_EMP", M4VIDEOEDITING_kMPEG4_EMP),
VIDEOEDIT_JAVA_CONSTANT_INIT("H264", M4VIDEOEDITING_kH264),
VIDEOEDIT_JAVA_CONSTANT_INIT("NULL_VIDEO", M4VIDEOEDITING_kNullVideo),
VIDEOEDIT_JAVA_CONSTANT_INIT("UNSUPPORTED", M4VIDEOEDITING_kUnsupportedVideo),
@@ -448,73 +447,6 @@ VIDEOEDIT_JAVA_DEFINE_CONSTANTS(VideoFrameSize)
VIDEOEDIT_JAVA_DEFINE_CONSTANT_CLASS(VideoFrameSize, VIDEO_FRAME_SIZE_CLASS_NAME,
M4OSA_NULL, M4OSA_NULL)
-
-VIDEOEDIT_JAVA_DEFINE_CONSTANTS(VideoProfile)
-{
- VIDEOEDIT_JAVA_CONSTANT_INIT("MPEG4_SP_LEVEL_0", \
- M4VIDEOEDITING_kMPEG4_SP_Level_0),
- VIDEOEDIT_JAVA_CONSTANT_INIT("MPEG4_SP_LEVEL_0B", \
- M4VIDEOEDITING_kMPEG4_SP_Level_0b),
- VIDEOEDIT_JAVA_CONSTANT_INIT("MPEG4_SP_LEVEL_1", \
- M4VIDEOEDITING_kMPEG4_SP_Level_1),
- VIDEOEDIT_JAVA_CONSTANT_INIT("MPEG4_SP_LEVEL_2", \
- M4VIDEOEDITING_kMPEG4_SP_Level_2),
- VIDEOEDIT_JAVA_CONSTANT_INIT("MPEG4_SP_LEVEL_3", \
- M4VIDEOEDITING_kMPEG4_SP_Level_3),
- VIDEOEDIT_JAVA_CONSTANT_INIT("MPEG4_SP_LEVEL_4A", \
- M4VIDEOEDITING_kMPEG4_SP_Level_4a),
- VIDEOEDIT_JAVA_CONSTANT_INIT("MPEG4_SP_LEVEL_5", \
- M4VIDEOEDITING_kMPEG4_SP_Level_5),
- VIDEOEDIT_JAVA_CONSTANT_INIT("H263_PROFILE_0_LEVEL_10",\
- M4VIDEOEDITING_kH263_Profile_0_Level_10),
- VIDEOEDIT_JAVA_CONSTANT_INIT("H263_PROFILE_0_LEVEL_20",\
- M4VIDEOEDITING_kH263_Profile_0_Level_20),
- VIDEOEDIT_JAVA_CONSTANT_INIT("H263_PROFILE_0_LEVEL_30",\
- M4VIDEOEDITING_kH263_Profile_0_Level_30),
- VIDEOEDIT_JAVA_CONSTANT_INIT("H263_PROFILE_0_LEVEL_40",\
- M4VIDEOEDITING_kH263_Profile_0_Level_40),
- VIDEOEDIT_JAVA_CONSTANT_INIT("H263_PROFILE_0_LEVEL_45",\
- M4VIDEOEDITING_kH263_Profile_0_Level_45),
- VIDEOEDIT_JAVA_CONSTANT_INIT("H264_PROFILE_0_LEVEL_1", \
- M4VIDEOEDITING_kH264_Profile_0_Level_1),
- VIDEOEDIT_JAVA_CONSTANT_INIT("H264_PROFILE_0_LEVEL_1b",\
- M4VIDEOEDITING_kH264_Profile_0_Level_1b),
- VIDEOEDIT_JAVA_CONSTANT_INIT("H264_PROFILE_0_LEVEL_1_1",\
- M4VIDEOEDITING_kH264_Profile_0_Level_1_1),
- VIDEOEDIT_JAVA_CONSTANT_INIT("H264_PROFILE_0_LEVEL_1_2",\
- M4VIDEOEDITING_kH264_Profile_0_Level_1_2),
- VIDEOEDIT_JAVA_CONSTANT_INIT("H264_PROFILE_0_LEVEL_1_3",\
- M4VIDEOEDITING_kH264_Profile_0_Level_1_3),
- VIDEOEDIT_JAVA_CONSTANT_INIT("H264_PROFILE_0_LEVEL_2", \
- M4VIDEOEDITING_kH264_Profile_0_Level_2),
- VIDEOEDIT_JAVA_CONSTANT_INIT("H264_PROFILE_0_LEVEL_2_1",\
- M4VIDEOEDITING_kH264_Profile_0_Level_2_1),
- VIDEOEDIT_JAVA_CONSTANT_INIT("H264_PROFILE_0_LEVEL_2_2",\
- M4VIDEOEDITING_kH264_Profile_0_Level_2_2),
- VIDEOEDIT_JAVA_CONSTANT_INIT("H264_PROFILE_0_LEVEL_3", \
- M4VIDEOEDITING_kH264_Profile_0_Level_3),
- VIDEOEDIT_JAVA_CONSTANT_INIT("H264_PROFILE_0_LEVEL_3_1",\
- M4VIDEOEDITING_kH264_Profile_0_Level_3_1),
- VIDEOEDIT_JAVA_CONSTANT_INIT("H264_PROFILE_0_LEVEL_3_2",\
- M4VIDEOEDITING_kH264_Profile_0_Level_3_2),
- VIDEOEDIT_JAVA_CONSTANT_INIT("H264_PROFILE_0_LEVEL_4", \
- M4VIDEOEDITING_kH264_Profile_0_Level_4),
- VIDEOEDIT_JAVA_CONSTANT_INIT("H264_PROFILE_0_LEVEL_4_1",\
- M4VIDEOEDITING_kH264_Profile_0_Level_4_1),
- VIDEOEDIT_JAVA_CONSTANT_INIT("H264_PROFILE_0_LEVEL_4_2",\
- M4VIDEOEDITING_kH264_Profile_0_Level_4_2),
- VIDEOEDIT_JAVA_CONSTANT_INIT("H264_PROFILE_0_LEVEL_5", \
- M4VIDEOEDITING_kH264_Profile_0_Level_5),
- VIDEOEDIT_JAVA_CONSTANT_INIT("H264_PROFILE_0_LEVEL_5_1",\
- M4VIDEOEDITING_kH264_Profile_0_Level_5_1),
- VIDEOEDIT_JAVA_CONSTANT_INIT("OUT_OF_RANGE", \
- M4VIDEOEDITING_kProfile_and_Level_Out_Of_Range)
-};
-
-VIDEOEDIT_JAVA_DEFINE_CONSTANT_CLASS(VideoProfile, VIDEO_PROFILE_CLASS_NAME, M4OSA_NULL,
- M4OSA_NULL)
-
-
VIDEOEDIT_JAVA_DEFINE_CONSTANTS(VideoTransition)
{
VIDEOEDIT_JAVA_CONSTANT_INIT("NONE", M4VSS3GPP_kVideoTransitionType_None),
@@ -550,7 +482,10 @@ VIDEOEDIT_JAVA_DEFINE_FIELDS(Properties)
VIDEOEDIT_JAVA_FIELD_INIT("width", "I"),
VIDEOEDIT_JAVA_FIELD_INIT("height", "I"),
VIDEOEDIT_JAVA_FIELD_INIT("averageFrameRate", "F"),
- VIDEOEDIT_JAVA_FIELD_INIT("profileAndLevel", "I"),
+ VIDEOEDIT_JAVA_FIELD_INIT("profile", "I"),
+ VIDEOEDIT_JAVA_FIELD_INIT("level", "I"),
+ VIDEOEDIT_JAVA_FIELD_INIT("profileSupported", "Z"),
+ VIDEOEDIT_JAVA_FIELD_INIT("levelSupported", "Z"),
VIDEOEDIT_JAVA_FIELD_INIT("audioFormat", "I"),
VIDEOEDIT_JAVA_FIELD_INIT("audioDuration", "I"),
VIDEOEDIT_JAVA_FIELD_INIT("audioBitrate", "I"),
@@ -620,6 +555,8 @@ VIDEOEDIT_JAVA_DEFINE_FIELDS(EditSettings)
VIDEOEDIT_JAVA_FIELD_INIT("outputFile", "Ljava/lang/String;" ),
VIDEOEDIT_JAVA_FIELD_INIT("videoFrameSize", "I" ),
VIDEOEDIT_JAVA_FIELD_INIT("videoFormat", "I" ),
+ VIDEOEDIT_JAVA_FIELD_INIT("videoProfile", "I" ),
+ VIDEOEDIT_JAVA_FIELD_INIT("videoLevel", "I" ),
VIDEOEDIT_JAVA_FIELD_INIT("audioFormat", "I" ),
VIDEOEDIT_JAVA_FIELD_INIT("audioSamplingFreq", "I" ),
VIDEOEDIT_JAVA_FIELD_INIT("maxFileSize", "I" ),
@@ -846,7 +783,6 @@ videoEditClasses_init(
videoEditJava_initVideoFormatConstants(pResult, pEnv);
videoEditJava_initVideoFrameRateConstants(pResult, pEnv);
videoEditJava_initVideoFrameSizeConstants(pResult, pEnv);
- videoEditJava_initVideoProfileConstants(pResult, pEnv);
videoEditJava_initVideoTransitionConstants(pResult, pEnv);
// Initialize the fields.
@@ -881,7 +817,6 @@ videoEditPropClass_init(
videoEditJava_initErrorConstants(pResult, pEnv);
videoEditJava_initFileTypeConstants(pResult, pEnv);
videoEditJava_initVideoFormatConstants(pResult, pEnv);
- videoEditJava_initVideoProfileConstants(pResult, pEnv);
// Initialize the fields.
videoEditJava_initPropertiesFields(pResult, pEnv);
@@ -1251,15 +1186,6 @@ videoEditClasses_logClipProperties(
"%*c fAverageFrameRate: %.3f", indentation, ' ',
pProperties->fAverageFrameRate);
VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
- "%*c ProfileAndLevel: %s", indentation, ' ',
- videoEditJava_getVideoProfileString(pProperties->ProfileAndLevel));
- VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
- "%*c uiH263level: %d", indentation, ' ',
- pProperties->uiH263level);
- VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
- "%*c uiVideoProfile: %d", indentation, ' ',
- pProperties->uiVideoProfile);
- VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
"%*c bMPEG4dataPartition: %s", indentation, ' ',
pProperties->bMPEG4dataPartition ? "true" : "false");
VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
@@ -1650,9 +1576,21 @@ videoEditPropClass_createProperties(
// Set the averageFrameRate field.
pEnv->SetFloatField(object, fieldIds.averageFrameRate, pProperties->fAverageFrameRate);
- // Set the profileAndLevel field.
- pEnv->SetIntField(object, fieldIds.profileAndLevel,
- videoEditJava_getVideoProfileCToJava(pProperties->ProfileAndLevel));
+ // Set the profile field.
+ pEnv->SetIntField(object, fieldIds.profile,
+ pProperties->uiVideoProfile);
+
+ // Set the level field.
+ pEnv->SetIntField(object, fieldIds.level,
+ pProperties->uiVideoLevel);
+
+ // Set whether profile supported
+ pEnv->SetBooleanField(object, fieldIds.profileSupported,
+ pProperties->bProfileSupported);
+
+ // Set whether level supported
+ pEnv->SetBooleanField(object, fieldIds.levelSupported,
+ pProperties->bLevelSupported);
// Set the audioFormat field.
pEnv->SetIntField(object, fieldIds.audioFormat,
@@ -2062,6 +2000,14 @@ videoEditClasses_getEditSettings(
pSettings->xVSS.outputVideoBitrate = (M4OSA_UInt32)pEnv->GetIntField(object,
fieldIds.videoBitrate);
+ // Set the output video profile.
+ pSettings->xVSS.outputVideoProfile = (M4OSA_UInt32)pEnv->GetIntField(object,
+ fieldIds.videoProfile);
+
+ // Set the output video level.
+ pSettings->xVSS.outputVideoLevel = (M4OSA_UInt32)pEnv->GetIntField(object,
+ fieldIds.videoLevel);
+
// Set the output audio bitrate.
pSettings->xVSS.outputAudioBitrate = (M4OSA_UInt32)pEnv->GetIntField(object,
fieldIds.audioBitrate);
@@ -2256,6 +2202,12 @@ videoEditClasses_logEditSettings(
"%*c outputVideoFormat: %s", indentation, ' ',
videoEditJava_getVideoFormatString(pSettings->xVSS.outputVideoFormat));
VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
+ "%*c outputVideoProfile: %u", indentation, ' ',
+ videoEditJava_getVideoFormatString(pSettings->xVSS.outputVideoProfile));
+ VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
+ "%*c outputVideoLevel: %u", indentation, ' ',
+ videoEditJava_getVideoFormatString(pSettings->xVSS.outputVideoLevel));
+ VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
"%*c outputAudioFormat: %s", indentation, ' ',
videoEditJava_getAudioFormatString(pSettings->xVSS.outputAudioFormat));
VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_CLASSES",
@@ -2984,10 +2936,6 @@ videoEditPropClass_logProperties(
pProperties->fAverageFrameRate);
VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_PROP_CLASSES",
- "%*c ProfileAndLevel: %s", indentation, ' ',
- videoEditJava_getVideoProfileString(pProperties->ProfileAndLevel));
-
- VIDEOEDIT_LOG_SETTING(ANDROID_LOG_INFO, "VIDEO_EDITOR_PROP_CLASSES",
"%*c AudioStreamType: %s", indentation, ' ',
videoEditJava_getAudioFormatString(pProperties->AudioStreamType));
diff --git a/media/jni/mediaeditor/VideoEditorClasses.h b/media/jni/mediaeditor/VideoEditorClasses.h
index 045f229..3c10b1d 100755
--- a/media/jni/mediaeditor/VideoEditorClasses.h
+++ b/media/jni/mediaeditor/VideoEditorClasses.h
@@ -128,20 +128,23 @@ typedef struct
* Structure to hold media properties from native layer
*/
typedef struct {
- M4OSA_UInt32 uiClipDuration;
- VideoEditClasses_FileType FileType;
- M4VIDEOEDITING_VideoFormat VideoStreamType;
- M4OSA_UInt32 uiClipVideoDuration;
- M4OSA_UInt32 uiVideoBitrate;
- M4OSA_UInt32 uiVideoWidth;
- M4OSA_UInt32 uiVideoHeight;
- M4OSA_Float fAverageFrameRate;
- M4VIDEOEDITING_VideoProfileAndLevel ProfileAndLevel;
- M4VIDEOEDITING_AudioFormat AudioStreamType;
- M4OSA_UInt32 uiClipAudioDuration;
- M4OSA_UInt32 uiAudioBitrate;
- M4OSA_UInt32 uiNbChannels;
- M4OSA_UInt32 uiSamplingFrequency;
+ M4OSA_UInt32 uiClipDuration;
+ VideoEditClasses_FileType FileType;
+ M4VIDEOEDITING_VideoFormat VideoStreamType;
+ M4OSA_UInt32 uiClipVideoDuration;
+ M4OSA_UInt32 uiVideoBitrate;
+ M4OSA_UInt32 uiVideoWidth;
+ M4OSA_UInt32 uiVideoHeight;
+ M4OSA_Float fAverageFrameRate;
+ M4OSA_UInt32 uiVideoProfile; /**< H263 or MPEG-4 or H264 profile(from core decoder) */
+ M4OSA_UInt32 uiVideoLevel; /**< H263 or MPEG-4 or H264 level*/
+ M4OSA_Bool bProfileSupported;
+ M4OSA_Bool bLevelSupported;
+ M4VIDEOEDITING_AudioFormat AudioStreamType;
+ M4OSA_UInt32 uiClipAudioDuration;
+ M4OSA_UInt32 uiAudioBitrate;
+ M4OSA_UInt32 uiNbChannels;
+ M4OSA_UInt32 uiSamplingFrequency;
} VideoEditPropClass_Properties;
typedef struct
@@ -154,7 +157,10 @@ typedef struct
jfieldID width;
jfieldID height;
jfieldID averageFrameRate;
- jfieldID profileAndLevel;
+ jfieldID profile;
+ jfieldID level;
+ jfieldID profileSupported;
+ jfieldID levelSupported;
jfieldID audioFormat;
jfieldID audioDuration;
jfieldID audioBitrate;
@@ -192,6 +198,8 @@ typedef struct
jfieldID outputFile;
jfieldID videoFrameSize;
jfieldID videoFormat;
+ jfieldID videoProfile;
+ jfieldID videoLevel;
jfieldID audioFormat;
jfieldID audioSamplingFreq;
jfieldID maxFileSize;
diff --git a/media/jni/mediaeditor/VideoEditorMain.cpp b/media/jni/mediaeditor/VideoEditorMain.cpp
index 7d0f56f..b737e5d 100755
--- a/media/jni/mediaeditor/VideoEditorMain.cpp
+++ b/media/jni/mediaeditor/VideoEditorMain.cpp
@@ -13,7 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
+#define LOG_NDEBUG 1
+#define LOG_TAG "VideoEditorMain"
#include <dlfcn.h>
#include <stdio.h>
#include <unistd.h>
@@ -103,6 +104,7 @@ typedef struct
bool mIsUpdateOverlay;
char *mOverlayFileName;
int mOverlayRenderingMode;
+ M4DECODER_VideoDecoders* decoders;
} ManualEditContext;
extern "C" M4OSA_ERR M4MCS_open_normalMode(
@@ -484,6 +486,82 @@ static void jniPreviewProgressCallback (void* cookie, M4OSA_UInt32 msgType,
pContext->pVM->DetachCurrentThread();
}
+static M4OSA_ERR checkClipVideoProfileAndLevel(M4DECODER_VideoDecoders *pDecoders,
+ M4OSA_Int32 format, M4OSA_UInt32 profile, M4OSA_UInt32 level){
+
+ M4OSA_Int32 codec = 0;
+ M4OSA_Bool foundCodec = M4OSA_FALSE;
+ M4OSA_ERR result = M4VSS3GPP_ERR_EDITING_UNSUPPORTED_VIDEO_PROFILE;
+ M4OSA_Bool foundProfile = M4OSA_FALSE;
+ LOGV("checkClipVideoProfileAndLevel format %d profile;%d level:0x%x",
+ format, profile, level);
+
+ switch (format) {
+ case M4VIDEOEDITING_kH263:
+ codec = M4DA_StreamTypeVideoH263;
+ break;
+ case M4VIDEOEDITING_kH264:
+ codec = M4DA_StreamTypeVideoMpeg4Avc;
+ break;
+ case M4VIDEOEDITING_kMPEG4:
+ codec = M4DA_StreamTypeVideoMpeg4;
+ break;
+ case M4VIDEOEDITING_kNoneVideo:
+ case M4VIDEOEDITING_kNullVideo:
+ case M4VIDEOEDITING_kUnsupportedVideo:
+ // For these case we do not check the profile and level
+ return M4NO_ERROR;
+ default :
+ LOGE("checkClipVideoProfileAndLevel unsupport Video format %ld", format);
+ break;
+ }
+
+ if (pDecoders != M4OSA_NULL && pDecoders->decoderNumber > 0) {
+ VideoDecoder *pVideoDecoder = pDecoders->decoder;
+ for(size_t k =0; k < pDecoders->decoderNumber; k++) {
+ if (pVideoDecoder != M4OSA_NULL) {
+ if (pVideoDecoder->codec == codec) {
+ foundCodec = M4OSA_TRUE;
+ break;
+ }
+ }
+ pVideoDecoder++;
+ }
+
+ if (foundCodec) {
+ VideoComponentCapabilities* pComponent = pVideoDecoder->component;
+ for (size_t i = 0; i < pVideoDecoder->componentNumber; i++) {
+ if (pComponent != M4OSA_NULL) {
+ VideoProfileLevel *pProfileLevel = pComponent->profileLevel;
+ for (size_t j =0; j < pComponent->profileNumber; j++) {
+ // Check the profile and level
+ if (pProfileLevel != M4OSA_NULL) {
+ if (profile == pProfileLevel->mProfile) {
+ foundProfile = M4OSA_TRUE;
+
+ if (level <= pProfileLevel->mLevel) {
+ return M4NO_ERROR;
+ }
+ } else {
+ foundProfile = M4OSA_FALSE;
+ }
+ }
+ pProfileLevel++;
+ }
+ }
+ pComponent++;
+ }
+ }
+ }
+
+ if (foundProfile) {
+ result = M4VSS3GPP_ERR_EDITING_UNSUPPORTED_VIDEO_LEVEL;
+ } else {
+ result = M4VSS3GPP_ERR_EDITING_UNSUPPORTED_VIDEO_PROFILE;
+ }
+
+ return result;
+}
static int videoEditor_stopPreview(JNIEnv* pEnv,
jobject thiz)
{
@@ -1244,6 +1322,8 @@ M4OSA_ERR videoEditor_generateAudio(JNIEnv* pEnv,ManualEditContext* pContext,
// Set the video format.
pOutputParams->OutputVideoFormat =
(M4VIDEOEDITING_VideoFormat)M4VIDEOEDITING_kNoneVideo;//M4VIDEOEDITING_kNoneVideo;
+ pOutputParams->outputVideoProfile = 1;
+ pOutputParams->outputVideoLevel = 1;
// Set the frame size.
pOutputParams->OutputVideoFrameSize
= (M4VIDEOEDITING_VideoFrameSize)M4VIDEOEDITING_kQCIF;
@@ -1797,7 +1877,8 @@ videoEditor_populateSettings(
}
fid = pEnv->GetFieldID(audioSettingClazz,"bRemoveOriginal","Z");
- pContext->mAudioSettings->bRemoveOriginal = pEnv->GetIntField(audioSettingObject,fid);
+ pContext->mAudioSettings->bRemoveOriginal =
+ pEnv->GetBooleanField(audioSettingObject,fid);
M4OSA_TRACE1_1("bRemoveOriginal = %d",pContext->mAudioSettings->bRemoveOriginal);
fid = pEnv->GetFieldID(audioSettingClazz,"channels","I");
@@ -1816,7 +1897,7 @@ videoEditor_populateSettings(
fid = pEnv->GetFieldID(audioSettingClazz,"startMs","J");
pContext->mAudioSettings->uiAddCts
- = pEnv->GetIntField(audioSettingObject,fid);
+ = pEnv->GetLongField(audioSettingObject,fid);
M4OSA_TRACE1_1("uiAddCts = %d",pContext->mAudioSettings->uiAddCts);
fid = pEnv->GetFieldID(audioSettingClazz,"volume","I");
@@ -1826,17 +1907,17 @@ videoEditor_populateSettings(
fid = pEnv->GetFieldID(audioSettingClazz,"loop","Z");
pContext->mAudioSettings->bLoop
- = pEnv->GetIntField(audioSettingObject,fid);
+ = pEnv->GetBooleanField(audioSettingObject,fid);
M4OSA_TRACE1_1("bLoop = %d",pContext->mAudioSettings->bLoop);
fid = pEnv->GetFieldID(audioSettingClazz,"beginCutTime","J");
pContext->mAudioSettings->beginCutMs
- = pEnv->GetIntField(audioSettingObject,fid);
+ = pEnv->GetLongField(audioSettingObject,fid);
M4OSA_TRACE1_1("begin cut time = %d",pContext->mAudioSettings->beginCutMs);
fid = pEnv->GetFieldID(audioSettingClazz,"endCutTime","J");
pContext->mAudioSettings->endCutMs
- = pEnv->GetIntField(audioSettingObject,fid);
+ = pEnv->GetLongField(audioSettingObject,fid);
M4OSA_TRACE1_1("end cut time = %d",pContext->mAudioSettings->endCutMs);
fid = pEnv->GetFieldID(audioSettingClazz,"fileType","I");
@@ -2090,8 +2171,44 @@ videoEditor_getProperties(
jstring file)
{
jobject object = M4OSA_NULL;
+ jclass clazz = pEnv->FindClass(PROPERTIES_CLASS_NAME);
+ jfieldID fid;
+ bool needToBeLoaded = true;
+ ManualEditContext* pContext = M4OSA_NULL;
+ M4OSA_ERR result = M4NO_ERROR;
+ int profile = 0;
+ int level = 0;
+ int videoFormat = 0;
+
+ // Get the context.
+ pContext = (ManualEditContext*)videoEditClasses_getContext(&needToBeLoaded, pEnv, thiz);
+
+ videoEditJava_checkAndThrowIllegalStateException(&needToBeLoaded, pEnv,
+ (M4OSA_NULL == clazz),
+ "not initialized");
+
object = videoEditProp_getProperties(pEnv,thiz,file);
+ if (object != M4OSA_NULL) {
+ fid = pEnv->GetFieldID(clazz,"profile","I");
+ profile = pEnv->GetIntField(object,fid);
+ fid = pEnv->GetFieldID(clazz,"level","I");
+ level = pEnv->GetIntField(object,fid);
+ fid = pEnv->GetFieldID(clazz,"videoFormat","I");
+ videoFormat = pEnv->GetIntField(object,fid);
+
+ result = checkClipVideoProfileAndLevel(pContext->decoders, videoFormat, profile, level);
+
+ fid = pEnv->GetFieldID(clazz,"profileSupported","Z");
+ if (M4VSS3GPP_ERR_EDITING_UNSUPPORTED_VIDEO_PROFILE == result) {
+ pEnv->SetBooleanField(object,fid,false);
+ }
+
+ fid = pEnv->GetFieldID(clazz,"levelSupported","Z");
+ if (M4VSS3GPP_ERR_EDITING_UNSUPPORTED_VIDEO_LEVEL == result) {
+ pEnv->SetBooleanField(object,fid,false);
+ }
+ }
return object;
}
@@ -2499,12 +2616,13 @@ videoEditor_init(
//initialize the first char. so that strcat works.
M4OSA_Char *ptmpChar = (M4OSA_Char*)pContext->initParams.pTempPath;
ptmpChar[0] = 0x00;
- strncat((char *)pContext->initParams.pTempPath, (const char *)tmpString,
+ strncat((char *)pContext->initParams.pTempPath, (const char *)tmpString,
(size_t)strlen((const char *)tmpString));
strncat((char *)pContext->initParams.pTempPath, (const char *)"/", (size_t)1);
free(tmpString);
pContext->mIsUpdateOverlay = false;
pContext->mOverlayFileName = NULL;
+ pContext->decoders = NULL;
}
// Check if the initialization succeeded
@@ -2550,6 +2668,12 @@ videoEditor_init(
// Check if the library could be initialized.
videoEditJava_checkAndThrowRuntimeException(&initialized, pEnv,
(M4NO_ERROR != result), result);
+
+ // Get platform video decoder capablities.
+ result = M4xVSS_getVideoDecoderCapabilities(&pContext->decoders);
+
+ videoEditJava_checkAndThrowRuntimeException(&initialized, pEnv,
+ (M4NO_ERROR != result), result);
}
if(initialized)
@@ -2631,7 +2755,8 @@ M4OSA_ERR videoEditor_processClip(
ManualEditState completionState = ManualEditState_OPENED;
ManualEditState errorState = ManualEditState_ANALYZING_ERROR;
- // While analyzing progress goes from 0 to 50
+ // While analyzing progress goes from 0 to 10 (except Kenburn clip
+ // generation, which goes from 0 to 50)
progressBase = 0;
// Set the text rendering function.
@@ -2667,6 +2792,7 @@ M4OSA_ERR videoEditor_processClip(
// Check if a task is being performed.
// ??? ADD STOPPING MECHANISM
LOGV("videoEditor_processClip Entering processing loop");
+ M4OSA_UInt8 prevReportedProgress = 0;
while((result == M4NO_ERROR)
&&(pContext->state!=ManualEditState_SAVED)
&&(pContext->state!=ManualEditState_STOPPING)) {
@@ -2674,19 +2800,35 @@ M4OSA_ERR videoEditor_processClip(
// Perform the next processing step.
//LOGV("LVME_processClip Entering M4xVSS_Step()");
result = M4xVSS_Step(pContext->engineContext, &progress);
- //LOGV("LVME_processClip M4xVSS_Step() returned 0x%x", (unsigned int)result);
- // Log the the 1 % .. 100 % progress after processing.
- progress = progressBase + progress/2;
- if (progress != lastProgress)
- {
- // Send a progress notification.
- LOGV("videoEditor_processClip ITEM %d Progress indication %d",
- unuseditemID, progress);
- pEnv->CallVoidMethod(pContext->engine,
- pContext->onProgressUpdateMethodId,
- unuseditemID, progress);
- lastProgress = progress;
+ if (progress != prevReportedProgress) {
+ prevReportedProgress = progress;
+ // Log the 1 % .. 100 % progress after processing.
+ if (M4OSA_TRUE ==
+ pContext->pEditSettings->pClipList[0]->xVSS.isPanZoom) {
+ // For KenBurn clip generation, return 0 to 50
+ // for Analysis phase and 50 to 100 for Saving phase
+ progress = progressBase + progress/2;
+ } else {
+ // For export/transition clips, 0 to 10 for Analysis phase
+ // and 10 to 100 for Saving phase
+ if (ManualEditState_INITIALIZED == pContext->state) {
+ progress = 0.1*progress;
+ } else {
+ progress = progressBase + 0.9*progress;
+ }
+ }
+
+ if (progress > lastProgress)
+ {
+ // Send a progress notification.
+ LOGV("videoEditor_processClip ITEM %d Progress indication %d",
+ unuseditemID, progress);
+ pEnv->CallVoidMethod(pContext->engine,
+ pContext->onProgressUpdateMethodId,
+ unuseditemID, progress);
+ lastProgress = progress;
+ }
}
// Check if processing has been completed.
@@ -2719,20 +2861,26 @@ M4OSA_ERR videoEditor_processClip(
completionResult = M4VSS3GPP_WAR_SAVING_DONE;
errorState = ManualEditState_SAVING_ERROR;
- // While saving progress goes from 50 to 100
- progressBase = 50;
+ // While saving, progress goes from 10 to 100
+ // except for Kenburn clip which goes from 50 to 100
+ if (M4OSA_TRUE ==
+ pContext->pEditSettings->pClipList[0]->xVSS.isPanZoom) {
+ progressBase = 50;
+ } else {
+ progressBase = 10;
+ }
}
// Check if we encoding is ongoing
else if (pContext->state == ManualEditState_SAVED) {
- if (progress != 100) {
- // Send a progress notification.
- progress = 100;
- LOGI("videoEditor_processClip ITEM %d Last progress indication %d",
- unuseditemID, progress);
- pEnv->CallVoidMethod(pContext->engine,
- pContext->onProgressUpdateMethodId,
- unuseditemID, progress);
- }
+
+ // Send a progress notification.
+ progress = 100;
+ LOGV("videoEditor_processClip ITEM %d Last progress indication %d",
+ unuseditemID, progress);
+ pEnv->CallVoidMethod(pContext->engine,
+ pContext->onProgressUpdateMethodId,
+ unuseditemID, progress);
+
// Stop the encoding.
LOGV("videoEditor_processClip Calling M4xVSS_SaveStop()");
@@ -3073,6 +3221,47 @@ videoEditor_release(
free(pContext->mAudioSettings);
pContext->mAudioSettings = M4OSA_NULL;
}
+ // Free video Decoders capabilities
+ if (pContext->decoders != M4OSA_NULL) {
+ VideoDecoder *pDecoder = NULL;
+ VideoComponentCapabilities *pComponents = NULL;
+ int32_t decoderNumber = pContext->decoders->decoderNumber;
+ if (pContext->decoders->decoder != NULL &&
+ decoderNumber > 0) {
+ pDecoder = pContext->decoders->decoder;
+ for (int32_t k = 0; k < decoderNumber; k++) {
+ // free each component
+ LOGV("decoder index :%d",k);
+ if (pDecoder != NULL &&
+ pDecoder->component != NULL &&
+ pDecoder->componentNumber > 0) {
+ LOGV("component number %d",pDecoder->componentNumber);
+ int32_t componentNumber =
+ pDecoder->componentNumber;
+
+ pComponents = pDecoder->component;
+ for (int32_t i = 0; i< componentNumber; i++) {
+ LOGV("component index :%d",i);
+ if (pComponents != NULL &&
+ pComponents->profileLevel != NULL) {
+ free(pComponents->profileLevel);
+ pComponents->profileLevel = NULL;
+ }
+ pComponents++;
+ }
+ free(pDecoder->component);
+ pDecoder->component = NULL;
+ }
+
+ pDecoder++;
+ }
+ free(pContext->decoders->decoder);
+ pContext->decoders->decoder = NULL;
+ }
+ free(pContext->decoders);
+ pContext->decoders = NULL;
+ }
+
videoEditor_freeContext(pEnv, &pContext);
}
}
@@ -3397,6 +3586,7 @@ static int videoEditor_generateAudioWaveFormSync (JNIEnv* pEnv, jobject thiz,
M4OSA_ERR result = M4NO_ERROR;
ManualEditContext* pContext = M4OSA_NULL;
bool needToBeLoaded = true;
+ const char *pPCMFilePath, *pStringOutAudioGraphFile;
VIDEOEDIT_LOG_API(ANDROID_LOG_INFO, "VIDEO_EDITOR",
"videoEditor_generateAudioWaveFormSync() ");
@@ -3411,20 +3601,20 @@ static int videoEditor_generateAudioWaveFormSync (JNIEnv* pEnv, jobject thiz,
VIDEOEDIT_LOG_API(ANDROID_LOG_INFO, "VIDEO_EDITOR",
"videoEditor_generateAudioWaveFormSync Retrieving pStringOutAudioGraphFile");
- const char *pPCMFilePath = pEnv->GetStringUTFChars(pcmfilePath, NULL);
+ pPCMFilePath = pEnv->GetStringUTFChars(pcmfilePath, NULL);
if (pPCMFilePath == M4OSA_NULL) {
- if (pEnv != NULL) {
- jniThrowException(pEnv, "java/lang/RuntimeException",
- "Input string PCMFilePath is null");
- }
+ jniThrowException(pEnv, "java/lang/RuntimeException",
+ "Input string PCMFilePath is null");
+ result = M4ERR_PARAMETER;
+ goto out;
}
- const char *pStringOutAudioGraphFile = pEnv->GetStringUTFChars(outGraphfilePath, NULL);
+ pStringOutAudioGraphFile = pEnv->GetStringUTFChars(outGraphfilePath, NULL);
if (pStringOutAudioGraphFile == M4OSA_NULL) {
- if (pEnv != NULL) {
- jniThrowException(pEnv, "java/lang/RuntimeException",
- "Input string outGraphfilePath is null");
- }
+ jniThrowException(pEnv, "java/lang/RuntimeException",
+ "Input string outGraphfilePath is null");
+ result = M4ERR_PARAMETER;
+ goto out2;
}
VIDEOEDIT_LOG_API(ANDROID_LOG_INFO, "VIDEO_EDITOR",
@@ -3439,14 +3629,14 @@ static int videoEditor_generateAudioWaveFormSync (JNIEnv* pEnv, jobject thiz,
(M4OSA_UInt32)frameDuration,
pContext);
- if (pStringOutAudioGraphFile != NULL) {
- pEnv->ReleaseStringUTFChars(outGraphfilePath, pStringOutAudioGraphFile);
- }
+ pEnv->ReleaseStringUTFChars(outGraphfilePath, pStringOutAudioGraphFile);
+out2:
if (pPCMFilePath != NULL) {
pEnv->ReleaseStringUTFChars(pcmfilePath, pPCMFilePath);
}
+out:
VIDEOEDIT_LOG_FUNCTION(ANDROID_LOG_INFO, "VIDEO_EDITOR",
"videoEditor_generateAudioWaveFormSync pContext->bSkipState ");
diff --git a/media/jni/mediaeditor/VideoEditorPropertiesMain.cpp b/media/jni/mediaeditor/VideoEditorPropertiesMain.cpp
index 93fe702..2ca3a08 100755
--- a/media/jni/mediaeditor/VideoEditorPropertiesMain.cpp
+++ b/media/jni/mediaeditor/VideoEditorPropertiesMain.cpp
@@ -248,7 +248,11 @@ jobject videoEditProp_getProperties(
pProperties->uiVideoWidth = pClipProperties->uiVideoWidth;
pProperties->uiVideoHeight = pClipProperties->uiVideoHeight;
pProperties->fAverageFrameRate = pClipProperties->fAverageFrameRate;
- pProperties->ProfileAndLevel = pClipProperties->ProfileAndLevel;
+ pProperties->uiVideoProfile = pClipProperties->uiVideoProfile;
+ pProperties->uiVideoLevel = pClipProperties->uiVideoLevel;
+ // Set profile and level support to TRUE, pending check
+ pProperties->bProfileSupported = M4OSA_TRUE;
+ pProperties->bLevelSupported = M4OSA_TRUE;
pProperties->AudioStreamType = pClipProperties->AudioStreamType;
pProperties->uiClipAudioDuration = pClipProperties->uiClipAudioDuration;
pProperties->uiAudioBitrate = pClipProperties->uiAudioBitrate;
@@ -272,7 +276,8 @@ jobject videoEditProp_getProperties(
pProperties->uiVideoWidth = width;
pProperties->uiVideoHeight = height;
pProperties->fAverageFrameRate = 0.0f;
- pProperties->ProfileAndLevel = M4VIDEOEDITING_kProfile_and_Level_Out_Of_Range;
+ pProperties->uiVideoProfile = M4VIDEOEDITING_VIDEO_UNKNOWN_PROFILE;
+ pProperties->uiVideoLevel = M4VIDEOEDITING_VIDEO_UNKNOWN_LEVEL;
pProperties->AudioStreamType = M4VIDEOEDITING_kNoneAudio;
pProperties->uiClipAudioDuration = 0;
pProperties->uiAudioBitrate = 0;
@@ -291,11 +296,13 @@ jobject videoEditProp_getProperties(
}
}
- // Create a properties object.
- videoEditPropClass_createProperties(&gotten, pEnv, pProperties, &properties);
+ if (M4NO_ERROR == result) {
+ // Create a properties object.
+ videoEditPropClass_createProperties(&gotten, pEnv, pProperties, &properties);
- // Log the properties.
- VIDEOEDIT_PROP_LOG_PROPERTIES(pProperties);
+ // Log the properties.
+ VIDEOEDIT_PROP_LOG_PROPERTIES(pProperties);
+ }
// Free the properties.
videoEditOsal_free(pProperties);
diff --git a/media/libmedia/MediaProfiles.cpp b/media/libmedia/MediaProfiles.cpp
index f0f07a2..5a8bc60 100644
--- a/media/libmedia/MediaProfiles.cpp
+++ b/media/libmedia/MediaProfiles.cpp
@@ -26,6 +26,7 @@
#include <expat.h>
#include <media/MediaProfiles.h>
#include <media/stagefright/MediaDebug.h>
+#include <media/stagefright/openmax/OMX_Video.h>
namespace android {
@@ -377,7 +378,24 @@ void MediaProfiles::addStartTimeOffset(int cameraId, const char** atts)
LOGV("%s: cameraId=%d, offset=%d ms", __func__, cameraId, offsetTimeMs);
mStartTimeOffsets.replaceValueFor(cameraId, offsetTimeMs);
}
+/*static*/ MediaProfiles::ExportVideoProfile*
+MediaProfiles::createExportVideoProfile(const char **atts)
+{
+ CHECK(!strcmp("name", atts[0]) &&
+ !strcmp("profile", atts[2]) &&
+ !strcmp("level", atts[4]));
+
+ const size_t nMappings =
+ sizeof(sVideoEncoderNameMap)/sizeof(sVideoEncoderNameMap[0]);
+ const int codec = findTagForName(sVideoEncoderNameMap, nMappings, atts[1]);
+ CHECK(codec != -1);
+
+ MediaProfiles::ExportVideoProfile *profile =
+ new MediaProfiles::ExportVideoProfile(
+ codec, atoi(atts[3]), atoi(atts[5]));
+ return profile;
+}
/*static*/ MediaProfiles::VideoEditorCap*
MediaProfiles::createVideoEditorCap(const char **atts, MediaProfiles *profiles)
{
@@ -428,6 +446,8 @@ MediaProfiles::startElementHandler(void *userData, const char *name, const char
profiles->addImageEncodingQualityLevel(profiles->mCurrentCameraId, atts);
} else if (strcmp("VideoEditorCap", name) == 0) {
createVideoEditorCap(atts, profiles);
+ } else if (strcmp("ExportVideoProfile", name) == 0) {
+ profiles->mVideoEditorExportProfiles.add(createExportVideoProfile(atts));
}
}
@@ -830,6 +850,20 @@ MediaProfiles::createDefaultVideoEditorCap(MediaProfiles *profiles)
VIDEOEDITOR_DEFAULT_MAX_OUTPUT_FRAME_WIDTH,
VIDEOEDITOR_DEFUALT_MAX_OUTPUT_FRAME_HEIGHT);
}
+/*static*/ void
+MediaProfiles::createDefaultExportVideoProfiles(MediaProfiles *profiles)
+{
+ // Create default video export profiles
+ profiles->mVideoEditorExportProfiles.add(
+ new ExportVideoProfile(VIDEO_ENCODER_H263,
+ OMX_VIDEO_H263ProfileBaseline, OMX_VIDEO_H263Level10));
+ profiles->mVideoEditorExportProfiles.add(
+ new ExportVideoProfile(VIDEO_ENCODER_MPEG_4_SP,
+ OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level1));
+ profiles->mVideoEditorExportProfiles.add(
+ new ExportVideoProfile(VIDEO_ENCODER_H264,
+ OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel13));
+}
/*static*/ MediaProfiles*
MediaProfiles::createDefaultInstance()
@@ -843,6 +877,7 @@ MediaProfiles::createDefaultInstance()
createDefaultEncoderOutputFileFormats(profiles);
createDefaultImageEncodingQualityLevels(profiles);
createDefaultVideoEditorCap(profiles);
+ createDefaultExportVideoProfiles(profiles);
return profiles;
}
@@ -940,7 +975,31 @@ int MediaProfiles::getVideoEncoderParamByName(const char *name, video_encoder co
LOGE("The given video encoder param name %s is not found", name);
return -1;
}
+int MediaProfiles::getVideoEditorExportParamByName(
+ const char *name, int codec) const
+{
+ LOGV("getVideoEditorExportParamByName: name %s codec %d", name, codec);
+ ExportVideoProfile *exportProfile = NULL;
+ int index = -1;
+ for (size_t i =0; i < mVideoEditorExportProfiles.size(); i++) {
+ exportProfile = mVideoEditorExportProfiles[i];
+ if (exportProfile->mCodec == codec) {
+ index = i;
+ break;
+ }
+ }
+ if (index == -1) {
+ LOGE("The given video decoder %d is not found", codec);
+ return -1;
+ }
+ if (!strcmp("videoeditor.export.profile", name))
+ return exportProfile->mProfile;
+ if (!strcmp("videoeditor.export.level", name))
+ return exportProfile->mLevel;
+ LOGE("The given video editor export param name %s is not found", name);
+ return -1;
+}
int MediaProfiles::getVideoEditorCapParamByName(const char *name) const
{
LOGV("getVideoEditorCapParamByName: %s", name);
diff --git a/media/libstagefright/AwesomePlayer.cpp b/media/libstagefright/AwesomePlayer.cpp
index 99242ab..f2673b3 100644
--- a/media/libstagefright/AwesomePlayer.cpp
+++ b/media/libstagefright/AwesomePlayer.cpp
@@ -59,6 +59,7 @@
#include <cutils/properties.h>
#define USE_SURFACE_ALLOC 1
+#define FRAME_DROP_FREQ 0
namespace android {
@@ -548,7 +549,7 @@ void AwesomePlayer::reset_l() {
mVideoTimeUs = 0;
mSeeking = NO_SEEK;
- mSeekNotificationSent = false;
+ mSeekNotificationSent = true;
mSeekTimeUs = 0;
mUri.setTo("");
@@ -820,7 +821,12 @@ void AwesomePlayer::onStreamDone() {
return;
}
- if (mFlags & (LOOPING | AUTO_LOOPING)) {
+ if ((mFlags & LOOPING)
+ || ((mFlags & AUTO_LOOPING)
+ && (mAudioSink == NULL || mAudioSink->realtime()))) {
+ // Don't AUTO_LOOP if we're being recorded, since that cannot be
+ // turned off and recording would go on indefinitely.
+
seekTo_l(0);
if (mVideoSource != NULL) {
@@ -1204,7 +1210,6 @@ void AwesomePlayer::setNativeWindow_l(const sp<ANativeWindow> &native) {
if (mLastVideoTimeUs >= 0) {
mSeeking = SEEK;
- mSeekNotificationSent = true;
mSeekTimeUs = mLastVideoTimeUs;
modifyFlags((AT_EOS | AUDIO_AT_EOS | VIDEO_AT_EOS), CLEAR);
}
@@ -1305,8 +1310,10 @@ void AwesomePlayer::OnRTSPSeekDoneWrapper(void *cookie) {
}
void AwesomePlayer::onRTSPSeekDone() {
- notifyListener_l(MEDIA_SEEK_COMPLETE);
- mSeekNotificationSent = true;
+ if (!mSeekNotificationSent) {
+ notifyListener_l(MEDIA_SEEK_COMPLETE);
+ mSeekNotificationSent = true;
+ }
}
status_t AwesomePlayer::seekTo_l(int64_t timeUs) {
@@ -1518,14 +1525,29 @@ status_t AwesomePlayer::initVideoDecoder(uint32_t flags) {
}
if (mVideoSource != NULL) {
- Mutex::Autolock autoLock(mStatsLock);
- TrackStat *stat = &mStats.mTracks.editItemAt(mStats.mVideoTrackIndex);
-
- const char *component;
+ const char *componentName;
CHECK(mVideoSource->getFormat()
- ->findCString(kKeyDecoderComponent, &component));
+ ->findCString(kKeyDecoderComponent, &componentName));
- stat->mDecoderName = component;
+ {
+ Mutex::Autolock autoLock(mStatsLock);
+ TrackStat *stat = &mStats.mTracks.editItemAt(mStats.mVideoTrackIndex);
+
+ stat->mDecoderName = componentName;
+ }
+
+ static const char *kPrefix = "OMX.Nvidia.";
+ static const char *kSuffix = ".decode";
+ static const size_t kSuffixLength = strlen(kSuffix);
+
+ size_t componentNameLength = strlen(componentName);
+
+ if (!strncmp(componentName, kPrefix, strlen(kPrefix))
+ && componentNameLength >= kSuffixLength
+ && !strcmp(&componentName[
+ componentNameLength - kSuffixLength], kSuffix)) {
+ modifyFlags(SLOW_DECODER_HACK, SET);
+ }
}
return mVideoSource != NULL ? OK : UNKNOWN_ERROR;
@@ -1705,6 +1727,7 @@ void AwesomePlayer::onVideoEvent() {
if (mFlags & FIRST_FRAME) {
modifyFlags(FIRST_FRAME, CLEAR);
+ mSinceLastDropped = 0;
mTimeSourceDeltaUs = ts->getRealTimeUs() - timeUs;
}
@@ -1751,18 +1774,28 @@ void AwesomePlayer::onVideoEvent() {
if (latenessUs > 40000) {
// We're more than 40ms late.
- LOGV("we're late by %lld us (%.2f secs), dropping frame",
+ LOGV("we're late by %lld us (%.2f secs)",
latenessUs, latenessUs / 1E6);
- mVideoBuffer->release();
- mVideoBuffer = NULL;
+ if (!(mFlags & SLOW_DECODER_HACK)
+ || mSinceLastDropped > FRAME_DROP_FREQ)
{
- Mutex::Autolock autoLock(mStatsLock);
- ++mStats.mNumVideoFramesDropped;
- }
+ LOGV("we're late by %lld us (%.2f secs) dropping "
+ "one after %d frames",
+ latenessUs, latenessUs / 1E6, mSinceLastDropped);
- postVideoEvent_l();
- return;
+ mSinceLastDropped = 0;
+ mVideoBuffer->release();
+ mVideoBuffer = NULL;
+
+ {
+ Mutex::Autolock autoLock(mStatsLock);
+ ++mStats.mNumVideoFramesDropped;
+ }
+
+ postVideoEvent_l();
+ return;
+ }
}
if (latenessUs < -10000) {
@@ -1781,6 +1814,7 @@ void AwesomePlayer::onVideoEvent() {
}
if (mVideoRenderer != NULL) {
+ mSinceLastDropped++;
mVideoRenderer->render(mVideoBuffer);
}
diff --git a/media/libstagefright/codecs/on2/dec/SoftVPX.cpp b/media/libstagefright/codecs/on2/dec/SoftVPX.cpp
index 7e83163..61a02ac 100644
--- a/media/libstagefright/codecs/on2/dec/SoftVPX.cpp
+++ b/media/libstagefright/codecs/on2/dec/SoftVPX.cpp
@@ -66,7 +66,7 @@ void SoftVPX::initPorts() {
def.eDir = OMX_DirInput;
def.nBufferCountMin = kNumBuffers;
def.nBufferCountActual = def.nBufferCountMin;
- def.nBufferSize = 8192;
+ def.nBufferSize = 256 * 1024;
def.bEnabled = OMX_TRUE;
def.bPopulated = OMX_FALSE;
def.eDomain = OMX_PortDomainVideo;
diff --git a/media/libstagefright/include/AwesomePlayer.h b/media/libstagefright/include/AwesomePlayer.h
index 95f2ae8..14476d3 100644
--- a/media/libstagefright/include/AwesomePlayer.h
+++ b/media/libstagefright/include/AwesomePlayer.h
@@ -141,6 +141,8 @@ private:
TEXT_RUNNING = 0x10000,
TEXTPLAYER_STARTED = 0x20000,
+
+ SLOW_DECODER_HACK = 0x40000,
};
mutable Mutex mLock;
@@ -181,6 +183,7 @@ private:
uint32_t mFlags;
uint32_t mExtractorFlags;
+ uint32_t mSinceLastDropped;
int64_t mTimeSourceDeltaUs;
int64_t mVideoTimeUs;
diff --git a/media/libstagefright/omx/OMXNodeInstance.cpp b/media/libstagefright/omx/OMXNodeInstance.cpp
index 12ab941..b612f89 100644
--- a/media/libstagefright/omx/OMXNodeInstance.cpp
+++ b/media/libstagefright/omx/OMXNodeInstance.cpp
@@ -419,7 +419,7 @@ status_t OMXNodeInstance::useGraphicBuffer2_l(
def.nVersion.s.nStep = 0;
def.nPortIndex = portIndex;
OMX_ERRORTYPE err = OMX_GetParameter(mHandle, OMX_IndexParamPortDefinition, &def);
- if (err != OK)
+ if (err != OMX_ErrorNone)
{
LOGE("%s::%d:Error getting OMX_IndexParamPortDefinition", __FUNCTION__, __LINE__);
return err;
@@ -474,9 +474,6 @@ status_t OMXNodeInstance::useGraphicBuffer(
return useGraphicBuffer2_l(portIndex, graphicBuffer, buffer);
}
- LOGW("Falling back to the deprecated useAndroidNativeBuffer support. You "
- "should switch to the useAndroidNativeBuffer2 extension.");
-
OMX_ERRORTYPE err = OMX_GetExtensionIndex(
mHandle,
const_cast<OMX_STRING>("OMX.google.android.index.useAndroidNativeBuffer"),
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/MediaPropertiesTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/MediaPropertiesTest.java
index 4d517db..0ad6760 100755
--- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/MediaPropertiesTest.java
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/MediaPropertiesTest.java
@@ -71,7 +71,7 @@ public class MediaPropertiesTest extends
protected void validateVideoProperties(int aspectRatio, int fileType,
int videoCodecType, int duration, int videoBitrate, int fps,
- int videoProfile, int width, int height, int audioCodecType,
+ int videoProfile, int videoLevel, int width, int height, int audioCodecType,
int audioSamplingFrequency, int audioChannel, int audioBitrate,
MediaVideoItem mvi) throws Exception {
assertEquals("Aspect Ratio Mismatch", aspectRatio, mvi.getAspectRatio());
@@ -82,6 +82,8 @@ public class MediaPropertiesTest extends
duration, mvi.getDuration(), 10));
assertEquals("Video Profile " + mvi.getVideoProfile(), videoProfile,
mvi.getVideoProfile());
+ assertEquals("Video Level " + mvi.getVideoLevel(), videoLevel,
+ mvi.getVideoLevel());
assertEquals("Video height " + mvi.getHeight(), height, mvi.getHeight());
assertEquals("Video width " + mvi.getWidth(), width, mvi.getWidth());
/** Check FPS with 10% range */
@@ -143,7 +145,8 @@ public class MediaPropertiesTest extends
final int audioCodecType = MediaProperties.ACODEC_AAC_LC;
final int audioSamplingFrequency = 16000;
final int audioChannel = 2;
- final int videoProfile = MediaProperties.MPEG4_SP_LEVEL_1;
+ final int videoProfile = MediaProperties.MPEG4Profile.MPEG4ProfileSimple;
+ final int videoLevel = MediaProperties.MPEG4Level.MPEG4Level1;
final int width = 854;
final int height = MediaProperties.HEIGHT_480;
@@ -152,7 +155,7 @@ public class MediaPropertiesTest extends
MediaItem.RENDERING_MODE_BLACK_BORDER);
validateVideoProperties(aspectRatio, fileType, videoCodecType, duration,
- videoBitrate, fps, videoProfile, width, height, audioCodecType,
+ videoBitrate, fps, videoProfile, videoLevel, width, height, audioCodecType,
audioSamplingFrequency, audioChannel, audioBitrate, mvi);
}
@@ -175,7 +178,8 @@ public class MediaPropertiesTest extends
final int audioCodecType = MediaProperties.ACODEC_AMRNB;
final int audioSamplingFrequency = 8000;
final int audioChannel = 1;
- final int videoProfile = MediaProperties.MPEG4_SP_LEVEL_1;
+ final int videoProfile = MediaProperties.MPEG4Profile.MPEG4ProfileSimple;
+ final int videoLevel = MediaProperties.MPEG4Level.MPEG4Level1;
final int width = 800;
final int height = MediaProperties.HEIGHT_480;
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
@@ -184,7 +188,7 @@ public class MediaPropertiesTest extends
(mVideoEditor, "m1", videoItemFilename, renderingMode);
validateVideoProperties(aspectRatio, fileType, videoCodecType, duration,
- videoBitrate, fps, videoProfile, width, height, audioCodecType,
+ videoBitrate, fps, videoProfile, videoLevel, width, height, audioCodecType,
audioSamplingFrequency, audioChannel, audioBitrate, mvi);
}
@@ -206,7 +210,8 @@ public class MediaPropertiesTest extends
final int audioCodecType = MediaProperties.ACODEC_AAC_LC;
final int audioSamplingFrequency = 48000;
final int audioChannel = 2;
- final int videoProfile = MediaProperties.MPEG4_SP_LEVEL_1;
+ final int videoProfile = MediaProperties.MPEG4Profile.MPEG4ProfileSimple;
+ final int videoLevel = MediaProperties.MPEG4Level.MPEG4Level1;
final int width = 720;
final int height = MediaProperties.HEIGHT_480;
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
@@ -215,7 +220,7 @@ public class MediaPropertiesTest extends
(mVideoEditor, "m1", videoItemFilename, renderingMode);
validateVideoProperties(aspectRatio, fileType, videoCodecType, duration,
- videoBitrate, fps, videoProfile, width, height, audioCodecType,
+ videoBitrate, fps, videoProfile, videoLevel, width, height, audioCodecType,
audioSamplingFrequency, audioChannel, audioBitrate, mvi);
}
@@ -237,7 +242,8 @@ public class MediaPropertiesTest extends
final int audioCodecType = MediaProperties.ACODEC_AAC_LC;
final int audioSamplingFrequency = 48000;
final int audioChannel = 2;
- final int videoProfile = MediaProperties.MPEG4_SP_LEVEL_1;
+ final int videoProfile = MediaProperties.MPEG4Profile.MPEG4ProfileSimple;
+ final int videoLevel = MediaProperties.MPEG4Level.MPEG4Level1;
final int width = 640;
final int height = MediaProperties.HEIGHT_480;
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
@@ -246,7 +252,7 @@ public class MediaPropertiesTest extends
(mVideoEditor, "m1", videoItemFilename, renderingMode);
validateVideoProperties(aspectRatio, fileType, videoCodecType, duration,
- videoBitrate, fps, videoProfile, width, height, audioCodecType,
+ videoBitrate, fps, videoProfile, videoLevel, width, height, audioCodecType,
audioSamplingFrequency, audioChannel, audioBitrate, mvi);
}
@@ -268,7 +274,8 @@ public class MediaPropertiesTest extends
final int audioCodecType = MediaProperties.ACODEC_AMRNB;
final int audioSamplingFrequency = 8000;
final int audioChannel = 1;
- final int videoProfile = MediaProperties.MPEG4_SP_LEVEL_1;
+ final int videoProfile = MediaProperties.MPEG4Profile.MPEG4ProfileSimple;
+ final int videoLevel = MediaProperties.MPEG4Level.MPEG4Level1;
final int width = 176;
final int height = MediaProperties.HEIGHT_144;
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
@@ -277,7 +284,7 @@ public class MediaPropertiesTest extends
(mVideoEditor, "m1", videoItemFilename, renderingMode);
validateVideoProperties(aspectRatio, fileType, videoCodecType, duration,
- videoBitrate, fps, videoProfile, width, height, audioCodecType,
+ videoBitrate, fps, videoProfile, videoLevel, width, height, audioCodecType,
audioSamplingFrequency, audioChannel, audioBitrate, mvi);
}
@@ -299,7 +306,8 @@ public class MediaPropertiesTest extends
final int audioCodecType = MediaProperties.ACODEC_AAC_LC;
final int audioSamplingFrequency = 16000;
final int audioChannel = 1;
- final int videoProfile = MediaProperties.H263_PROFILE_0_LEVEL_10;
+ final int videoProfile = MediaProperties.H263Profile.H263ProfileBaseline;
+ final int videoLevel = MediaProperties.H263Level.H263Level10;
final int width = 176;
final int height = MediaProperties.HEIGHT_144;
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
@@ -307,7 +315,7 @@ public class MediaPropertiesTest extends
(mVideoEditor, "m1", videoItemFilename, renderingMode);
validateVideoProperties(aspectRatio, fileType, videoCodecType, duration,
- videoBitrate, fps, videoProfile, width, height, audioCodecType,
+ videoBitrate, fps, videoProfile, videoLevel, width, height, audioCodecType,
audioSamplingFrequency, audioChannel, audioBitrate, mvi);
}
@@ -321,7 +329,7 @@ public class MediaPropertiesTest extends
+ "H264_BP_640x480_15fps_1200Kbps_AACLC_48KHz_64kps_m_0_27.3gp";
final int aspectRatio = MediaProperties.ASPECT_RATIO_4_3;
final int fileType = MediaProperties.FILE_3GP;
- final int videoCodecType = MediaProperties.VCODEC_H264BP;
+ final int videoCodecType = MediaProperties.VCODEC_H264;
final int duration = 77600;
final int videoBitrate = 745000;
final int audioBitrate = 64000;
@@ -329,7 +337,8 @@ public class MediaPropertiesTest extends
final int audioCodecType = MediaProperties.ACODEC_AAC_LC;
final int audioSamplingFrequency = 48000;
final int audioChannel = 2;
- final int videoProfile = MediaProperties.H264_PROFILE_0_LEVEL_1_3;
+ final int videoProfile = MediaProperties.H264Profile.H264ProfileBaseline;
+ final int videoLevel = MediaProperties.H264Level.H264Level13;
final int width = 640;
final int height = MediaProperties.HEIGHT_480;
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
@@ -337,7 +346,7 @@ public class MediaPropertiesTest extends
(mVideoEditor, "m1", videoItemFilename, renderingMode);
validateVideoProperties(aspectRatio, fileType, videoCodecType, duration,
- videoBitrate, fps, videoProfile, width, height, audioCodecType,
+ videoBitrate, fps, videoProfile, videoLevel, width, height, audioCodecType,
audioSamplingFrequency, audioChannel, audioBitrate, mvi);
}
@@ -351,7 +360,7 @@ public class MediaPropertiesTest extends
+ "H264_BP_720x480_25fps_256kbps_AMRNB_8khz_12.2kbps_m_0_26.mp4";
final int aspectRatio = MediaProperties.ASPECT_RATIO_3_2;
final int fileType = MediaProperties.FILE_MP4;
- final int videoCodecType = MediaProperties.VCODEC_H264BP;
+ final int videoCodecType = MediaProperties.VCODEC_H264;
final int duration = 26880;
final int videoBitrate = 244000;
final int audioBitrate = 12200;
@@ -359,7 +368,8 @@ public class MediaPropertiesTest extends
final int audioCodecType = MediaProperties.ACODEC_AMRNB;
final int audioSamplingFrequency = 8000;
final int audioChannel = 1;
- final int videoProfile = MediaProperties.H264_PROFILE_0_LEVEL_1_3;
+ final int videoProfile = MediaProperties.H264Profile.H264ProfileBaseline;
+ final int videoLevel = MediaProperties.H264Level.H264Level13;
final int width = 720;
final int height = MediaProperties.HEIGHT_480;
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
@@ -368,7 +378,7 @@ public class MediaPropertiesTest extends
(mVideoEditor, "m1", videoItemFilename, renderingMode);
validateVideoProperties(aspectRatio, fileType, videoCodecType, duration,
- videoBitrate, fps, videoProfile, width, height, audioCodecType,
+ videoBitrate, fps, videoProfile, videoLevel, width, height, audioCodecType,
audioSamplingFrequency, audioChannel, audioBitrate, mvi);
}
@@ -382,7 +392,7 @@ public class MediaPropertiesTest extends
"H264_BP_800x480_15fps_512kbps_AACLC_24KHz_38Kbps_s_1_17.mp4";
final int aspectRatio = MediaProperties.ASPECT_RATIO_5_3;
final int fileType = MediaProperties.FILE_MP4;
- final int videoCodecType = MediaProperties.VCODEC_H264BP;
+ final int videoCodecType = MediaProperties.VCODEC_H264;
final int duration = 77466;
final int videoBitrate = 528000;
final int audioBitrate = 38000;
@@ -390,7 +400,8 @@ public class MediaPropertiesTest extends
final int audioCodecType = MediaProperties.ACODEC_AAC_LC;
final int audioSamplingFrequency = 24000;
final int audioChannel = 2;
- final int videoProfile = MediaProperties.H264_PROFILE_0_LEVEL_1_3;
+ final int videoProfile = MediaProperties.H264Profile.H264ProfileBaseline;
+ final int videoLevel = MediaProperties.H264Level.H264Level13;
final int width = 800;
final int height = MediaProperties.HEIGHT_480;
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
@@ -399,7 +410,7 @@ public class MediaPropertiesTest extends
(mVideoEditor, "m1", videoItemFilename, renderingMode);
validateVideoProperties(aspectRatio, fileType, videoCodecType, duration,
- videoBitrate, fps, videoProfile, width, height, audioCodecType,
+ videoBitrate, fps, videoProfile, videoLevel, width, height, audioCodecType,
audioSamplingFrequency, audioChannel, audioBitrate, mvi);
}
@@ -413,7 +424,7 @@ public class MediaPropertiesTest extends
+ "H264_BP_1280x720_15fps_512kbps_AACLC_16khz_48kbps_s_1_17.mp4";
final int aspectRatio = MediaProperties.ASPECT_RATIO_16_9;
final int fileType = MediaProperties.FILE_MP4;
- final int videoCodecType = MediaProperties.VCODEC_H264BP;
+ final int videoCodecType = MediaProperties.VCODEC_H264;
final int duration = 77600;
final int videoBitrate = 606000;
final int audioBitrate = 48000;
@@ -421,7 +432,8 @@ public class MediaPropertiesTest extends
final int audioCodecType = MediaProperties.ACODEC_AAC_LC;
final int audioSamplingFrequency = 16000;
final int audioChannel = 2;
- final int videoProfile = MediaProperties.H264_PROFILE_0_LEVEL_1_3;
+ final int videoProfile = MediaProperties.H264Profile.H264ProfileBaseline;
+ final int videoLevel = MediaProperties.H264Level.H264Level13;
final int width = 1280;
final int height = MediaProperties.HEIGHT_720;
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
@@ -430,7 +442,7 @@ public class MediaPropertiesTest extends
(mVideoEditor, "m1", videoItemFilename, renderingMode);
validateVideoProperties(aspectRatio, fileType, videoCodecType, duration,
- videoBitrate, fps, videoProfile, width, height, audioCodecType,
+ videoBitrate, fps, videoProfile, videoLevel, width, height, audioCodecType,
audioSamplingFrequency, audioChannel, audioBitrate, mvi);
}
@@ -444,7 +456,7 @@ public class MediaPropertiesTest extends
+ "H264_BP_1080x720_30fps_12Mbps_AACLC_44.1khz_64kbps_s_1_17.mp4";
final int aspectRatio = MediaProperties.ASPECT_RATIO_3_2;
final int fileType = MediaProperties.FILE_MP4;
- final int videoCodecType = MediaProperties.VCODEC_H264BP;
+ final int videoCodecType = MediaProperties.VCODEC_H264;
final int duration = 77500;
final int videoBitrate = 1190000;
final int audioBitrate = 64000;
@@ -452,7 +464,8 @@ public class MediaPropertiesTest extends
final int audioCodecType = MediaProperties.ACODEC_AAC_LC;
final int audioSamplingFrequency = 44100;
final int audioChannel = 2;
- final int videoProfile = MediaProperties.H264_PROFILE_0_LEVEL_1_3;
+ final int videoProfile = MediaProperties.H264Profile.H264ProfileBaseline;
+ final int videoLevel = MediaProperties.H264Level.H264Level13;
final int width = 1080;
final int height = MediaProperties.HEIGHT_720;
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
@@ -461,7 +474,7 @@ public class MediaPropertiesTest extends
(mVideoEditor, "m1", videoItemFilename, renderingMode);
validateVideoProperties(aspectRatio, fileType, videoCodecType, duration,
- videoBitrate, fps, videoProfile, width, height, audioCodecType,
+ videoBitrate, fps, videoProfile, videoLevel, width, height, audioCodecType,
audioSamplingFrequency, audioChannel, audioBitrate, mvi);
}
@@ -491,7 +504,7 @@ public class MediaPropertiesTest extends
}
/**
- *To test media properties for H.264 Main/Advanced profile. (unsupported profile input)
+ *To test media properties for H.264 Main/Advanced profile.
*/
// TODO : Remove TC_MP_013
@LargeTest
@@ -499,19 +512,28 @@ public class MediaPropertiesTest extends
final String videoItemFilename = INPUT_FILE_PATH
+ "H264_MP_960x720_25fps_800kbps_AACLC_48Khz_192Kbps_s_1_17.mp4";
final int aspectRatio = MediaProperties.ASPECT_RATIO_4_3;
- //final int videoCodecType = MediaProperties.VCODEC_H264BP;
- final int videoCodecType = MediaProperties.VCODEC_H264MP;
+ final int videoCodecType = MediaProperties.VCODEC_H264;
+ final int fileType = MediaProperties.FILE_MP4;
+ final int duration = 77500;
+ final int videoBitrate = 800000;
+ final int audioBitrate = 192000;
+ final int fps = 25;
+ final int audioCodecType = MediaProperties.ACODEC_AAC_LC;
+ final int audioSamplingFrequency = 48000;
+ final int audioChannel = 2;
+ final int videoProfile = MediaProperties.H264Profile.H264ProfileMain;
+ final int videoLevel = MediaProperties.H264Level.H264Level31;
+ final int width = 960;
+ final int height = MediaProperties.HEIGHT_720;
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
- boolean flagForException = false;
- try {
final MediaVideoItem mvi = mVideoEditorHelper.createMediaItem
(mVideoEditor, "m1", videoItemFilename, renderingMode);
- assertEquals("VideoCodec Mismatch", videoCodecType, mvi.getVideoType());
- }catch (IllegalArgumentException e){
- flagForException = true;
- }
- assertTrue("Unsupported Main Profile", flagForException);
+
+ validateVideoProperties(aspectRatio, fileType, videoCodecType, duration,
+ videoBitrate, fps, videoProfile, videoLevel, width, height, audioCodecType,
+ audioSamplingFrequency, audioChannel, audioBitrate, mvi);
+
}
/**
@@ -544,7 +566,7 @@ public class MediaPropertiesTest extends
"H264_BP_1080x720_30fps_800kbps_1_17.mp4";
final int aspectRatio = MediaProperties.ASPECT_RATIO_3_2;
final int fileType = MediaProperties.FILE_MP4;
- final int videoCodecType = MediaProperties.VCODEC_H264BP;
+ final int videoCodecType = MediaProperties.VCODEC_H264;
final int duration = 77366;
final int videoBitrate = 859000;
final int audioBitrate = 0;
@@ -552,7 +574,8 @@ public class MediaPropertiesTest extends
final int audioCodecType = -1;
final int audioSamplingFrequency = 0;
final int audioChannel = 0;
- final int videoProfile = MediaProperties.H264_PROFILE_0_LEVEL_1_3;
+ final int videoProfile = MediaProperties.H264Profile.H264ProfileBaseline;
+ final int videoLevel = MediaProperties.H264Level.H264Level13;
final int width = 1080;
final int height = MediaProperties.HEIGHT_720;
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
@@ -561,7 +584,7 @@ public class MediaPropertiesTest extends
(mVideoEditor, "m1", videoItemFilename, renderingMode);
validateVideoProperties(aspectRatio, fileType, videoCodecType, duration,
- videoBitrate, fps, videoProfile, width, height, audioCodecType,
+ videoBitrate, fps, videoProfile, videoLevel, width, height, audioCodecType,
audioSamplingFrequency, audioChannel, audioBitrate, mvi);
}
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/VideoEditorExportTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/VideoEditorExportTest.java
index 74d4766..e1b337d 100755
--- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/VideoEditorExportTest.java
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/VideoEditorExportTest.java
@@ -166,7 +166,7 @@ public class VideoEditorExportTest extends
+ mediaImageItem6.getDuration();
mVideoEditorHelper.validateExport(mVideoEditor, outFilename,
MediaProperties.HEIGHT_720, 0, storyBoardDuration,
- MediaProperties.VCODEC_H264BP, MediaProperties.ACODEC_AAC_LC);
+ MediaProperties.VCODEC_H264, MediaProperties.ACODEC_AAC_LC);
mVideoEditorHelper.checkDeleteExistingFile(outFilename);
}
@@ -294,7 +294,7 @@ public class VideoEditorExportTest extends
+ mediaImageItem6.getDuration();
mVideoEditorHelper.validateExport(mVideoEditor, outFilename,
MediaProperties.HEIGHT_720, 0, storyBoardDuration,
- MediaProperties.VCODEC_H264BP, MediaProperties.ACODEC_AAC_LC);
+ MediaProperties.VCODEC_H264, MediaProperties.ACODEC_AAC_LC);
mVideoEditorHelper.checkDeleteExistingFile(outFilename);
}
@@ -352,7 +352,7 @@ public class VideoEditorExportTest extends
}
mVideoEditorHelper.validateExport(mVideoEditor, outFilename,
MediaProperties.HEIGHT_720, 0, mediaImageItem.getDuration(),
- MediaProperties.VCODEC_H264BP, MediaProperties.ACODEC_AAC_LC);
+ MediaProperties.VCODEC_H264, MediaProperties.ACODEC_AAC_LC);
mVideoEditorHelper.checkDeleteExistingFile(outFilename);
}
@@ -412,7 +412,7 @@ public class VideoEditorExportTest extends
mVideoEditorHelper.validateExport(mVideoEditor, outFilename,
MediaProperties.HEIGHT_720, 0, (mediaVideoItem.getTimelineDuration() +
mediaImageItem.getDuration()),
- MediaProperties.VCODEC_H264BP, MediaProperties.ACODEC_AAC_LC);
+ MediaProperties.VCODEC_H264, MediaProperties.ACODEC_AAC_LC);
mVideoEditorHelper.checkDeleteExistingFile(outFilename);
}
@@ -531,7 +531,7 @@ public class VideoEditorExportTest extends
+ mediaItem6.getTimelineDuration() - transition5And6.getDuration();
mVideoEditorHelper.validateExport(mVideoEditor, outFilename,
MediaProperties.HEIGHT_720, 0, storyBoardDuration,
- MediaProperties.VCODEC_H264BP, MediaProperties.ACODEC_AAC_LC);
+ MediaProperties.VCODEC_H264, MediaProperties.ACODEC_AAC_LC);
mVideoEditorHelper.checkDeleteExistingFile(outFilename);
}
@@ -693,7 +693,7 @@ public class VideoEditorExportTest extends
mVideoEditorHelper.validateExport(mVideoEditor, outFilename,
MediaProperties.HEIGHT_144, 0, storyBoardDuration,
- MediaProperties.VCODEC_H264BP, MediaProperties.ACODEC_AAC_LC);
+ MediaProperties.VCODEC_H264, MediaProperties.ACODEC_AAC_LC);
mVideoEditorHelper.checkDeleteExistingFile(outFilename);
}
@@ -730,7 +730,7 @@ public class VideoEditorExportTest extends
}
mVideoEditorHelper.validateExport(mVideoEditor, outFilename,
MediaProperties.HEIGHT_720, 0, mediaItem1.getDuration(),
- MediaProperties.VCODEC_H264BP, MediaProperties.ACODEC_AAC_LC);
+ MediaProperties.VCODEC_H264, MediaProperties.ACODEC_AAC_LC);
mVideoEditorHelper.checkDeleteExistingFile(outFilename);
}
@@ -814,7 +814,7 @@ public class VideoEditorExportTest extends
mVideoEditorHelper.validateExport(mVideoEditor, outFilename,
MediaProperties.HEIGHT_720, 0,
(mediaVideoItem.getDuration()+ mediaVideoItem1.getDuration()),
- MediaProperties.VCODEC_H264BP, MediaProperties.ACODEC_AAC_LC);
+ MediaProperties.VCODEC_H264, MediaProperties.ACODEC_AAC_LC);
mVideoEditorHelper.checkDeleteExistingFile(outFilename);
}
}
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/performance/VideoEditorPerformance.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/performance/VideoEditorPerformance.java
index 7eb6d22..3d0be4f 100644
--- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/performance/VideoEditorPerformance.java
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/performance/VideoEditorPerformance.java
@@ -366,7 +366,7 @@ public class VideoEditorPerformance extends
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
final int outHeight = MediaProperties.HEIGHT_480;
final int outBitrate = MediaProperties.BITRATE_256K;
- final int outVcodec = MediaProperties.VCODEC_H264BP;
+ final int outVcodec = MediaProperties.VCODEC_H264;
final String[] loggingInfo = new String[1];
final String outFilename = mVideoEditorHelper
.createRandomFile(mVideoEditor.getPath() + "/") + ".3gp";
@@ -639,11 +639,12 @@ public class VideoEditorPerformance extends
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
final int aspectRatio = MediaProperties.ASPECT_RATIO_3_2;
final int fileType = MediaProperties.FILE_MP4;
- final int videoCodecType = MediaProperties.VCODEC_H264BP;
+ final int videoCodecType = MediaProperties.VCODEC_H264;
final int duration = 77366;
final int videoBitrate = 3169971;
final int fps = 30;
- final int videoProfile = MediaProperties.H264_PROFILE_0_LEVEL_1_3;
+ final int videoProfile = MediaProperties.H264Profile.H264ProfileBaseline;
+ final int videoLevel = MediaProperties.H264Level.H264Level13;
final int width = 1080;
final int height = MediaProperties.HEIGHT_720;
int timeTaken = 0;
@@ -665,6 +666,8 @@ public class VideoEditorPerformance extends
duration, mediaVideoItem.getDuration());
assertEquals("Video Profile ",
videoProfile, mediaVideoItem.getVideoProfile());
+ assertEquals("Video Level ",
+ videoLevel, mediaVideoItem.getVideoLevel());
assertEquals("Video height ",
height, mediaVideoItem.getHeight());
assertEquals("Video width ",
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/stress/VideoEditorStressTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/stress/VideoEditorStressTest.java
index 94ffb8e..4d30784 100755
--- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/stress/VideoEditorStressTest.java
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/stress/VideoEditorStressTest.java
@@ -665,9 +665,10 @@ public class VideoEditorStressTest
int i = 0;
final int videoAspectRatio = MediaProperties.ASPECT_RATIO_3_2;
final int videoFileType = MediaProperties.FILE_MP4;
- final int videoCodecType = MediaProperties.VCODEC_H264BP;
+ final int videoCodecType = MediaProperties.VCODEC_H264;
final int videoDuration = 77366;
- final int videoProfile = MediaProperties.H264_PROFILE_0_LEVEL_1_3;
+ final int videoProfile = MediaProperties.H264Profile.H264ProfileBaseline;
+ final int videoLevel = MediaProperties.H264Level.H264Level13;
final int videoHeight = MediaProperties.HEIGHT_720;
final int videoWidth = 1080;
@@ -698,6 +699,8 @@ public class VideoEditorStressTest
videoDuration, mediaItem1.getDuration());
assertEquals("Video Profile ",
videoProfile, mediaItem1.getVideoProfile());
+ assertEquals("Video Level ",
+ videoLevel, mediaItem1.getVideoLevel());
assertEquals("Video height ",
videoHeight, mediaItem1.getHeight());
assertEquals("Video width ",
@@ -939,9 +942,9 @@ public class VideoEditorStressTest
for ( i = 0; i < 50; i++) {
if(i%4 ==0){
- final int aspectRatio = MediaProperties.ASPECT_RATIO_4_3;
+ final int aspectRatio = MediaProperties.ASPECT_RATIO_11_9;
mVideoEditor.setAspectRatio(aspectRatio);
- mVideoEditor.export(outFilename, MediaProperties.HEIGHT_480,
+ mVideoEditor.export(outFilename, MediaProperties.HEIGHT_288,
MediaProperties.BITRATE_256K,MediaProperties.ACODEC_AAC_LC,
MediaProperties.VCODEC_H263,
new ExportProgressListener() {
@@ -967,7 +970,7 @@ public class VideoEditorStressTest
mVideoEditor.setAspectRatio(aspectRatio);
mVideoEditor.export(outFilename, MediaProperties.HEIGHT_144,
MediaProperties.BITRATE_512K,MediaProperties.ACODEC_AAC_LC,
- MediaProperties.VCODEC_H264BP,
+ MediaProperties.VCODEC_H264,
new ExportProgressListener() {
public void onProgress(VideoEditor ve, String outFileName,
int progress) {
@@ -979,7 +982,7 @@ public class VideoEditorStressTest
mVideoEditor.setAspectRatio(aspectRatio);
mVideoEditor.export(outFilename, MediaProperties.HEIGHT_480,
MediaProperties.BITRATE_800K,MediaProperties.ACODEC_AAC_LC,
- MediaProperties.VCODEC_H264BP,
+ MediaProperties.VCODEC_H264,
new ExportProgressListener() {
public void onProgress(VideoEditor ve, String outFileName,
int progress) {
diff --git a/native/include/android/input.h b/native/include/android/input.h
index 7a0dcd3..f2befa9 100644
--- a/native/include/android/input.h
+++ b/native/include/android/input.h
@@ -373,6 +373,7 @@ enum {
AMOTION_EVENT_AXIS_GAS = 22,
AMOTION_EVENT_AXIS_BRAKE = 23,
AMOTION_EVENT_AXIS_DISTANCE = 24,
+ AMOTION_EVENT_AXIS_TILT = 25,
AMOTION_EVENT_AXIS_GENERIC_1 = 32,
AMOTION_EVENT_AXIS_GENERIC_2 = 33,
AMOTION_EVENT_AXIS_GENERIC_3 = 34,
diff --git a/opengl/libagl/state.cpp b/opengl/libagl/state.cpp
index 8b4136a..90e9612 100644
--- a/opengl/libagl/state.cpp
+++ b/opengl/libagl/state.cpp
@@ -191,6 +191,9 @@ static void enable_disable(ogles_context_t* c, GLenum cap, int enabled)
// these need to fall through into the rasterizer
c->rasterizer.procs.enableDisable(c, cap, enabled);
break;
+ case GL_TEXTURE_EXTERNAL_OES:
+ c->rasterizer.procs.enableDisable(c, GL_TEXTURE_2D, enabled);
+ break;
case GL_MULTISAMPLE:
case GL_SAMPLE_ALPHA_TO_COVERAGE:
diff --git a/opengl/libagl/texture.cpp b/opengl/libagl/texture.cpp
index 8eb17c4..88e8651 100644
--- a/opengl/libagl/texture.cpp
+++ b/opengl/libagl/texture.cpp
@@ -633,7 +633,7 @@ void generateMipmap(ogles_context_t* c, GLint level)
static void texParameterx(
GLenum target, GLenum pname, GLfixed param, ogles_context_t* c)
{
- if (target != GL_TEXTURE_2D) {
+ if (target != GL_TEXTURE_2D && target != GL_TEXTURE_EXTERNAL_OES) {
ogles_error(c, GL_INVALID_ENUM);
return;
}
@@ -866,7 +866,7 @@ void glActiveTexture(GLenum texture)
void glBindTexture(GLenum target, GLuint texture)
{
ogles_context_t* c = ogles_context_t::get();
- if (target != GL_TEXTURE_2D) {
+ if (target != GL_TEXTURE_2D && target != GL_TEXTURE_EXTERNAL_OES) {
ogles_error(c, GL_INVALID_ENUM);
return;
}
@@ -1012,7 +1012,7 @@ void glTexParameteriv(
GLenum target, GLenum pname, const GLint* params)
{
ogles_context_t* c = ogles_context_t::get();
- if (target != GGL_TEXTURE_2D) {
+ if (target != GL_TEXTURE_2D && target != GL_TEXTURE_EXTERNAL_OES) {
ogles_error(c, GL_INVALID_ENUM);
return;
}
@@ -1605,7 +1605,7 @@ void glDrawTexxOES(GLfixed x, GLfixed y, GLfixed z, GLfixed w, GLfixed h) {
void glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image)
{
ogles_context_t* c = ogles_context_t::get();
- if (target != GL_TEXTURE_2D) {
+ if (target != GL_TEXTURE_2D && target != GL_TEXTURE_EXTERNAL_OES) {
ogles_error(c, GL_INVALID_ENUM);
return;
}
diff --git a/packages/SystemUI/res/drawable-hdpi/compat_mode_help_top_divider.9.png b/packages/SystemUI/res/drawable-hdpi/compat_mode_help_top_divider.9.png
deleted file mode 100644
index 03a5639..0000000
--- a/packages/SystemUI/res/drawable-hdpi/compat_mode_help_top_divider.9.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/ic_notification_open.png b/packages/SystemUI/res/drawable-hdpi/ic_notification_open.png
index 165fa80..d697c2f 100644
--- a/packages/SystemUI/res/drawable-hdpi/ic_notification_open.png
+++ b/packages/SystemUI/res/drawable-hdpi/ic_notification_open.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_airplane_off.png b/packages/SystemUI/res/drawable-hdpi/ic_sysbar_airplane_off.png
deleted file mode 100644
index a557164..0000000
--- a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_airplane_off.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_apps_default.png b/packages/SystemUI/res/drawable-hdpi/ic_sysbar_apps_default.png
deleted file mode 100644
index 48cab60..0000000
--- a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_apps_default.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_apps_default_land.png b/packages/SystemUI/res/drawable-hdpi/ic_sysbar_apps_default_land.png
deleted file mode 100644
index 000af5e..0000000
--- a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_apps_default_land.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_back_ime_default_land.png b/packages/SystemUI/res/drawable-hdpi/ic_sysbar_back_ime_default_land.png
deleted file mode 100644
index e77dfaf..0000000
--- a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_back_ime_default_land.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_brightness_low.png b/packages/SystemUI/res/drawable-hdpi/ic_sysbar_brightness_low.png
deleted file mode 100644
index b91be07..0000000
--- a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_brightness_low.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_gps_on.png b/packages/SystemUI/res/drawable-hdpi/ic_sysbar_gps_on.png
deleted file mode 100644
index 31e747e..0000000
--- a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_gps_on.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_ime_default_land.png b/packages/SystemUI/res/drawable-hdpi/ic_sysbar_ime_default_land.png
deleted file mode 100644
index 8883601..0000000
--- a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_ime_default_land.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_notification_dnd.png b/packages/SystemUI/res/drawable-hdpi/ic_sysbar_notification_dnd.png
deleted file mode 100644
index 13b969c..0000000
--- a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_notification_dnd.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_notification_dnd_off.png b/packages/SystemUI/res/drawable-hdpi/ic_sysbar_notification_dnd_off.png
deleted file mode 100644
index 25e7e6f..0000000
--- a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_notification_dnd_off.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_rotate_off_lanscape.png b/packages/SystemUI/res/drawable-hdpi/ic_sysbar_rotate_off_lanscape.png
deleted file mode 100644
index da512e4..0000000
--- a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_rotate_off_lanscape.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_rotate_off_portrait.png b/packages/SystemUI/res/drawable-hdpi/ic_sysbar_rotate_off_portrait.png
deleted file mode 100644
index f2a7c6d..0000000
--- a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_rotate_off_portrait.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_settings.png b/packages/SystemUI/res/drawable-hdpi/ic_sysbar_settings.png
deleted file mode 100644
index 18fe5be..0000000
--- a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_settings.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_shadow.9.png b/packages/SystemUI/res/drawable-hdpi/ic_sysbar_shadow.9.png
deleted file mode 100644
index ab581a1..0000000
--- a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_shadow.9.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_sound_off.png b/packages/SystemUI/res/drawable-hdpi/ic_sysbar_sound_off.png
deleted file mode 100644
index 0246cd4..0000000
--- a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_sound_off.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_sound_on.png b/packages/SystemUI/res/drawable-hdpi/ic_sysbar_sound_on.png
deleted file mode 100644
index bec75e5..0000000
--- a/packages/SystemUI/res/drawable-hdpi/ic_sysbar_sound_on.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/recent_overlay.png b/packages/SystemUI/res/drawable-hdpi/recent_overlay.png
deleted file mode 100644
index ce48e0b..0000000
--- a/packages/SystemUI/res/drawable-hdpi/recent_overlay.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/recent_rez_border.png b/packages/SystemUI/res/drawable-hdpi/recent_rez_border.png
deleted file mode 100644
index f10a487..0000000
--- a/packages/SystemUI/res/drawable-hdpi/recent_rez_border.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/shade_handlebar.9.png b/packages/SystemUI/res/drawable-hdpi/shade_handlebar.9.png
deleted file mode 100644
index 0c12103..0000000
--- a/packages/SystemUI/res/drawable-hdpi/shade_handlebar.9.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/shade_header_background.9.png b/packages/SystemUI/res/drawable-hdpi/shade_header_background.9.png
deleted file mode 100644
index 8fbe78e..0000000
--- a/packages/SystemUI/res/drawable-hdpi/shade_header_background.9.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/stat_sys_battery_unknown.png b/packages/SystemUI/res/drawable-hdpi/stat_sys_battery_unknown.png
deleted file mode 100644
index e6c9e80..0000000
--- a/packages/SystemUI/res/drawable-hdpi/stat_sys_battery_unknown.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/stat_sys_data_in_1x.png b/packages/SystemUI/res/drawable-hdpi/stat_sys_data_in_1x.png
deleted file mode 100644
index b2e725c..0000000
--- a/packages/SystemUI/res/drawable-hdpi/stat_sys_data_in_1x.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/stat_sys_data_in_3g.png b/packages/SystemUI/res/drawable-hdpi/stat_sys_data_in_3g.png
deleted file mode 100644
index b2e725c..0000000
--- a/packages/SystemUI/res/drawable-hdpi/stat_sys_data_in_3g.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/stat_sys_data_in_4g.png b/packages/SystemUI/res/drawable-hdpi/stat_sys_data_in_4g.png
deleted file mode 100644
index b2e725c..0000000
--- a/packages/SystemUI/res/drawable-hdpi/stat_sys_data_in_4g.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/stat_sys_data_in_e.png b/packages/SystemUI/res/drawable-hdpi/stat_sys_data_in_e.png
deleted file mode 100644
index b2e725c..0000000
--- a/packages/SystemUI/res/drawable-hdpi/stat_sys_data_in_e.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/stat_sys_data_in_g.png b/packages/SystemUI/res/drawable-hdpi/stat_sys_data_in_g.png
deleted file mode 100644
index b2e725c..0000000
--- a/packages/SystemUI/res/drawable-hdpi/stat_sys_data_in_g.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/stat_sys_data_in_h.png b/packages/SystemUI/res/drawable-hdpi/stat_sys_data_in_h.png
deleted file mode 100644
index b2e725c..0000000
--- a/packages/SystemUI/res/drawable-hdpi/stat_sys_data_in_h.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/stat_sys_data_inandout_1x.png b/packages/SystemUI/res/drawable-hdpi/stat_sys_data_inandout_1x.png
deleted file mode 100644
index b2e725c..0000000
--- a/packages/SystemUI/res/drawable-hdpi/stat_sys_data_inandout_1x.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/stat_sys_data_inandout_3g.png b/packages/SystemUI/res/drawable-hdpi/stat_sys_data_inandout_3g.png
deleted file mode 100644
index b2e725c..0000000
--- a/packages/SystemUI/res/drawable-hdpi/stat_sys_data_inandout_3g.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/stat_sys_data_inandout_4g.png b/packages/SystemUI/res/drawable-hdpi/stat_sys_data_inandout_4g.png
deleted file mode 100644
index b2e725c..0000000
--- a/packages/SystemUI/res/drawable-hdpi/stat_sys_data_inandout_4g.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/stat_sys_data_inandout_e.png b/packages/SystemUI/res/drawable-hdpi/stat_sys_data_inandout_e.png
deleted file mode 100644
index b2e725c..0000000
--- a/packages/SystemUI/res/drawable-hdpi/stat_sys_data_inandout_e.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/stat_sys_data_inandout_g.png b/packages/SystemUI/res/drawable-hdpi/stat_sys_data_inandout_g.png
deleted file mode 100644
index b2e725c..0000000
--- a/packages/SystemUI/res/drawable-hdpi/stat_sys_data_inandout_g.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/stat_sys_data_inandout_h.png b/packages/SystemUI/res/drawable-hdpi/stat_sys_data_inandout_h.png
deleted file mode 100644
index b2e725c..0000000
--- a/packages/SystemUI/res/drawable-hdpi/stat_sys_data_inandout_h.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/stat_sys_data_out_1x.png b/packages/SystemUI/res/drawable-hdpi/stat_sys_data_out_1x.png
deleted file mode 100644
index b2e725c..0000000
--- a/packages/SystemUI/res/drawable-hdpi/stat_sys_data_out_1x.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/stat_sys_data_out_3g.png b/packages/SystemUI/res/drawable-hdpi/stat_sys_data_out_3g.png
deleted file mode 100644
index b2e725c..0000000
--- a/packages/SystemUI/res/drawable-hdpi/stat_sys_data_out_3g.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/stat_sys_data_out_4g.png b/packages/SystemUI/res/drawable-hdpi/stat_sys_data_out_4g.png
deleted file mode 100644
index b2e725c..0000000
--- a/packages/SystemUI/res/drawable-hdpi/stat_sys_data_out_4g.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/stat_sys_data_out_e.png b/packages/SystemUI/res/drawable-hdpi/stat_sys_data_out_e.png
deleted file mode 100644
index b2e725c..0000000
--- a/packages/SystemUI/res/drawable-hdpi/stat_sys_data_out_e.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/stat_sys_data_out_g.png b/packages/SystemUI/res/drawable-hdpi/stat_sys_data_out_g.png
deleted file mode 100644
index b2e725c..0000000
--- a/packages/SystemUI/res/drawable-hdpi/stat_sys_data_out_g.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/stat_sys_data_out_h.png b/packages/SystemUI/res/drawable-hdpi/stat_sys_data_out_h.png
deleted file mode 100644
index b2e725c..0000000
--- a/packages/SystemUI/res/drawable-hdpi/stat_sys_data_out_h.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/statusbar_background.9.png b/packages/SystemUI/res/drawable-hdpi/statusbar_background.9.png
deleted file mode 100644
index 6eaf6c9..0000000
--- a/packages/SystemUI/res/drawable-hdpi/statusbar_background.9.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-hdpi/title_bar_portrait.9.png b/packages/SystemUI/res/drawable-hdpi/title_bar_portrait.9.png
deleted file mode 100644
index da1b637..0000000
--- a/packages/SystemUI/res/drawable-hdpi/title_bar_portrait.9.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_notification_open.png b/packages/SystemUI/res/drawable-mdpi/ic_notification_open.png
index ba0ca70..839c134 100644
--- a/packages/SystemUI/res/drawable-mdpi/ic_notification_open.png
+++ b/packages/SystemUI/res/drawable-mdpi/ic_notification_open.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_airplane_off.png b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_airplane_off.png
deleted file mode 100644
index 6d8b923..0000000
--- a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_airplane_off.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_apps_default.png b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_apps_default.png
deleted file mode 100644
index 2ed5df4..0000000
--- a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_apps_default.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_apps_default_land.png b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_apps_default_land.png
deleted file mode 100644
index c877f72..0000000
--- a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_apps_default_land.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_back_ime_default_land.png b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_back_ime_default_land.png
deleted file mode 100644
index 14d437e..0000000
--- a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_back_ime_default_land.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_brightness_low.png b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_brightness_low.png
deleted file mode 100644
index 91e1429..0000000
--- a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_brightness_low.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_gps_on.png b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_gps_on.png
deleted file mode 100644
index 08d60d1..0000000
--- a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_gps_on.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_ime_default_land.png b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_ime_default_land.png
deleted file mode 100644
index e5711eb..0000000
--- a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_ime_default_land.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_notification_dnd.png b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_notification_dnd.png
deleted file mode 100644
index c046f58..0000000
--- a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_notification_dnd.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_notification_dnd_off.png b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_notification_dnd_off.png
deleted file mode 100644
index 6b72be2..0000000
--- a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_notification_dnd_off.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_rotate_off_lanscape.png b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_rotate_off_lanscape.png
deleted file mode 100644
index 540af65..0000000
--- a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_rotate_off_lanscape.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_rotate_off_portrait.png b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_rotate_off_portrait.png
deleted file mode 100644
index 268a9bf..0000000
--- a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_rotate_off_portrait.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_settings.png b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_settings.png
deleted file mode 100644
index 06e09e7..0000000
--- a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_settings.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_shadow.9.png b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_shadow.9.png
deleted file mode 100644
index 897d216..0000000
--- a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_shadow.9.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_sound_off.png b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_sound_off.png
deleted file mode 100644
index a11dabb..0000000
--- a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_sound_off.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_sound_on.png b/packages/SystemUI/res/drawable-mdpi/ic_sysbar_sound_on.png
deleted file mode 100644
index 16215bd..0000000
--- a/packages/SystemUI/res/drawable-mdpi/ic_sysbar_sound_on.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/recent_overlay.png b/packages/SystemUI/res/drawable-mdpi/recent_overlay.png
deleted file mode 100644
index 33eabb2..0000000
--- a/packages/SystemUI/res/drawable-mdpi/recent_overlay.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/recent_rez_border.png b/packages/SystemUI/res/drawable-mdpi/recent_rez_border.png
deleted file mode 100644
index 5da42a3..0000000
--- a/packages/SystemUI/res/drawable-mdpi/recent_rez_border.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/shade_handlebar.9.png b/packages/SystemUI/res/drawable-mdpi/shade_handlebar.9.png
deleted file mode 100644
index d9598ae..0000000
--- a/packages/SystemUI/res/drawable-mdpi/shade_handlebar.9.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/shade_header_background.9.png b/packages/SystemUI/res/drawable-mdpi/shade_header_background.9.png
deleted file mode 100644
index 761ef05..0000000
--- a/packages/SystemUI/res/drawable-mdpi/shade_header_background.9.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_battery_unknown.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_battery_unknown.png
deleted file mode 100644
index d4dca3e..0000000
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_battery_unknown.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_in_1x.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_in_1x.png
deleted file mode 100644
index eecdefb..0000000
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_in_1x.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_in_3g.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_in_3g.png
deleted file mode 100644
index eecdefb..0000000
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_in_3g.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_in_4g.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_in_4g.png
deleted file mode 100644
index eecdefb..0000000
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_in_4g.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_in_e.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_in_e.png
deleted file mode 100644
index eecdefb..0000000
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_in_e.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_in_g.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_in_g.png
deleted file mode 100644
index eecdefb..0000000
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_in_g.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_in_h.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_in_h.png
deleted file mode 100644
index eecdefb..0000000
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_in_h.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_inandout_1x.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_inandout_1x.png
deleted file mode 100644
index eecdefb..0000000
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_inandout_1x.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_inandout_3g.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_inandout_3g.png
deleted file mode 100644
index eecdefb..0000000
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_inandout_3g.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_inandout_4g.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_inandout_4g.png
deleted file mode 100644
index eecdefb..0000000
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_inandout_4g.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_inandout_e.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_inandout_e.png
deleted file mode 100644
index eecdefb..0000000
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_inandout_e.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_inandout_g.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_inandout_g.png
deleted file mode 100644
index eecdefb..0000000
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_inandout_g.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_inandout_h.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_inandout_h.png
deleted file mode 100644
index eecdefb..0000000
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_inandout_h.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_out_1x.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_out_1x.png
deleted file mode 100644
index eecdefb..0000000
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_out_1x.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_out_3g.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_out_3g.png
deleted file mode 100644
index eecdefb..0000000
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_out_3g.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_out_4g.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_out_4g.png
deleted file mode 100644
index eecdefb..0000000
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_out_4g.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_out_e.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_out_e.png
deleted file mode 100644
index eecdefb..0000000
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_out_e.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_out_g.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_out_g.png
deleted file mode 100644
index eecdefb..0000000
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_out_g.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_out_h.png b/packages/SystemUI/res/drawable-mdpi/stat_sys_data_out_h.png
deleted file mode 100644
index eecdefb..0000000
--- a/packages/SystemUI/res/drawable-mdpi/stat_sys_data_out_h.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/statusbar_background.9.png b/packages/SystemUI/res/drawable-mdpi/statusbar_background.9.png
deleted file mode 100644
index 6f19bf4..0000000
--- a/packages/SystemUI/res/drawable-mdpi/statusbar_background.9.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-mdpi/title_bar_portrait.9.png b/packages/SystemUI/res/drawable-mdpi/title_bar_portrait.9.png
deleted file mode 100644
index 9de8324..0000000
--- a/packages/SystemUI/res/drawable-mdpi/title_bar_portrait.9.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-nodpi/bg_scrim_notification.png b/packages/SystemUI/res/drawable-nodpi/bg_scrim_notification.png
deleted file mode 100644
index 4d5135e..0000000
--- a/packages/SystemUI/res/drawable-nodpi/bg_scrim_notification.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-nodpi/compat_mode_help_bg.png b/packages/SystemUI/res/drawable-nodpi/compat_mode_help_bg.png
index 59a70ff..87d8c41 100644
--- a/packages/SystemUI/res/drawable-nodpi/compat_mode_help_bg.png
+++ b/packages/SystemUI/res/drawable-nodpi/compat_mode_help_bg.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-nodpi/notify_glow_back.png b/packages/SystemUI/res/drawable-nodpi/notify_glow_back.png
deleted file mode 100644
index 269049e..0000000
--- a/packages/SystemUI/res/drawable-nodpi/notify_glow_back.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-nodpi/notify_item_glow_left.png b/packages/SystemUI/res/drawable-nodpi/notify_item_glow_left.png
deleted file mode 100644
index 0e8c25c..0000000
--- a/packages/SystemUI/res/drawable-nodpi/notify_item_glow_left.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-nodpi/notify_item_glow_top.png b/packages/SystemUI/res/drawable-nodpi/notify_item_glow_top.png
deleted file mode 100644
index 536357a..0000000
--- a/packages/SystemUI/res/drawable-nodpi/notify_item_glow_top.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-nodpi/panel_notification.png b/packages/SystemUI/res/drawable-nodpi/panel_notification.png
deleted file mode 100644
index 275e492..0000000
--- a/packages/SystemUI/res/drawable-nodpi/panel_notification.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-sw600dp-hdpi/stat_sys_battery_unknown.png b/packages/SystemUI/res/drawable-sw600dp-hdpi/stat_sys_battery_unknown.png
deleted file mode 100644
index 004aee3..0000000
--- a/packages/SystemUI/res/drawable-sw600dp-hdpi/stat_sys_battery_unknown.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-sw600dp-mdpi/stat_sys_battery_unknown.png b/packages/SystemUI/res/drawable-sw600dp-mdpi/stat_sys_battery_unknown.png
deleted file mode 100644
index d71738d..0000000
--- a/packages/SystemUI/res/drawable-sw600dp-mdpi/stat_sys_battery_unknown.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-sw600dp-xhdpi/stat_sys_battery_unknown.png b/packages/SystemUI/res/drawable-sw600dp-xhdpi/stat_sys_battery_unknown.png
deleted file mode 100644
index 4394f92..0000000
--- a/packages/SystemUI/res/drawable-sw600dp-xhdpi/stat_sys_battery_unknown.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/ic_notification_open.png b/packages/SystemUI/res/drawable-xhdpi/ic_notification_open.png
new file mode 100644
index 0000000..4f8c987
--- /dev/null
+++ b/packages/SystemUI/res/drawable-xhdpi/ic_notification_open.png
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_airplane_off.png b/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_airplane_off.png
deleted file mode 100644
index ed968c8..0000000
--- a/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_airplane_off.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_apps_default.png b/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_apps_default.png
deleted file mode 100644
index 5641b2b..0000000
--- a/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_apps_default.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_apps_default_land.png b/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_apps_default_land.png
deleted file mode 100644
index 1ea83fc..0000000
--- a/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_apps_default_land.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_back_ime_default_land.png b/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_back_ime_default_land.png
deleted file mode 100644
index dc08550..0000000
--- a/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_back_ime_default_land.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_brightness_low.png b/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_brightness_low.png
deleted file mode 100644
index 03885fa..0000000
--- a/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_brightness_low.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_gps_on.png b/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_gps_on.png
deleted file mode 100644
index 92e86c6..0000000
--- a/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_gps_on.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_ime_default_land.png b/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_ime_default_land.png
deleted file mode 100644
index 94acf9a..0000000
--- a/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_ime_default_land.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_notification_dnd.png b/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_notification_dnd.png
deleted file mode 100644
index 4fc936b..0000000
--- a/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_notification_dnd.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_notification_dnd_off.png b/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_notification_dnd_off.png
deleted file mode 100644
index 27357ea..0000000
--- a/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_notification_dnd_off.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_rotate_off_lanscape.png b/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_rotate_off_lanscape.png
deleted file mode 100644
index 53c7094..0000000
--- a/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_rotate_off_lanscape.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_rotate_off_portrait.png b/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_rotate_off_portrait.png
deleted file mode 100644
index a882b94..0000000
--- a/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_rotate_off_portrait.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_settings.png b/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_settings.png
deleted file mode 100644
index fdcf409..0000000
--- a/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_settings.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_shadow.9.png b/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_shadow.9.png
deleted file mode 100644
index 792bac4..0000000
--- a/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_shadow.9.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_sound_off.png b/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_sound_off.png
deleted file mode 100644
index 31b4663..0000000
--- a/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_sound_off.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_sound_on.png b/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_sound_on.png
deleted file mode 100644
index 45b5bf3..0000000
--- a/packages/SystemUI/res/drawable-xhdpi/ic_sysbar_sound_on.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/stat_sys_battery_unknown.png b/packages/SystemUI/res/drawable-xhdpi/stat_sys_battery_unknown.png
deleted file mode 100644
index ffac512..0000000
--- a/packages/SystemUI/res/drawable-xhdpi/stat_sys_battery_unknown.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/stat_sys_data_in_1x.png b/packages/SystemUI/res/drawable-xhdpi/stat_sys_data_in_1x.png
deleted file mode 100644
index 48038f0..0000000
--- a/packages/SystemUI/res/drawable-xhdpi/stat_sys_data_in_1x.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/stat_sys_data_in_3g.png b/packages/SystemUI/res/drawable-xhdpi/stat_sys_data_in_3g.png
deleted file mode 100644
index 48038f0..0000000
--- a/packages/SystemUI/res/drawable-xhdpi/stat_sys_data_in_3g.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/stat_sys_data_in_4g.png b/packages/SystemUI/res/drawable-xhdpi/stat_sys_data_in_4g.png
deleted file mode 100644
index 48038f0..0000000
--- a/packages/SystemUI/res/drawable-xhdpi/stat_sys_data_in_4g.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/stat_sys_data_in_e.png b/packages/SystemUI/res/drawable-xhdpi/stat_sys_data_in_e.png
deleted file mode 100644
index 48038f0..0000000
--- a/packages/SystemUI/res/drawable-xhdpi/stat_sys_data_in_e.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/stat_sys_data_in_g.png b/packages/SystemUI/res/drawable-xhdpi/stat_sys_data_in_g.png
deleted file mode 100644
index 48038f0..0000000
--- a/packages/SystemUI/res/drawable-xhdpi/stat_sys_data_in_g.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/stat_sys_data_in_h.png b/packages/SystemUI/res/drawable-xhdpi/stat_sys_data_in_h.png
deleted file mode 100644
index 48038f0..0000000
--- a/packages/SystemUI/res/drawable-xhdpi/stat_sys_data_in_h.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/stat_sys_data_inandout_1x.png b/packages/SystemUI/res/drawable-xhdpi/stat_sys_data_inandout_1x.png
deleted file mode 100644
index 48038f0..0000000
--- a/packages/SystemUI/res/drawable-xhdpi/stat_sys_data_inandout_1x.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/stat_sys_data_inandout_3g.png b/packages/SystemUI/res/drawable-xhdpi/stat_sys_data_inandout_3g.png
deleted file mode 100644
index 48038f0..0000000
--- a/packages/SystemUI/res/drawable-xhdpi/stat_sys_data_inandout_3g.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/stat_sys_data_inandout_4g.png b/packages/SystemUI/res/drawable-xhdpi/stat_sys_data_inandout_4g.png
deleted file mode 100644
index 48038f0..0000000
--- a/packages/SystemUI/res/drawable-xhdpi/stat_sys_data_inandout_4g.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/stat_sys_data_inandout_e.png b/packages/SystemUI/res/drawable-xhdpi/stat_sys_data_inandout_e.png
deleted file mode 100644
index 48038f0..0000000
--- a/packages/SystemUI/res/drawable-xhdpi/stat_sys_data_inandout_e.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/stat_sys_data_inandout_g.png b/packages/SystemUI/res/drawable-xhdpi/stat_sys_data_inandout_g.png
deleted file mode 100644
index 48038f0..0000000
--- a/packages/SystemUI/res/drawable-xhdpi/stat_sys_data_inandout_g.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/stat_sys_data_inandout_h.png b/packages/SystemUI/res/drawable-xhdpi/stat_sys_data_inandout_h.png
deleted file mode 100644
index 48038f0..0000000
--- a/packages/SystemUI/res/drawable-xhdpi/stat_sys_data_inandout_h.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/stat_sys_data_out_1x.png b/packages/SystemUI/res/drawable-xhdpi/stat_sys_data_out_1x.png
deleted file mode 100644
index 48038f0..0000000
--- a/packages/SystemUI/res/drawable-xhdpi/stat_sys_data_out_1x.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/stat_sys_data_out_3g.png b/packages/SystemUI/res/drawable-xhdpi/stat_sys_data_out_3g.png
deleted file mode 100644
index 48038f0..0000000
--- a/packages/SystemUI/res/drawable-xhdpi/stat_sys_data_out_3g.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/stat_sys_data_out_4g.png b/packages/SystemUI/res/drawable-xhdpi/stat_sys_data_out_4g.png
deleted file mode 100644
index 48038f0..0000000
--- a/packages/SystemUI/res/drawable-xhdpi/stat_sys_data_out_4g.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/stat_sys_data_out_e.png b/packages/SystemUI/res/drawable-xhdpi/stat_sys_data_out_e.png
deleted file mode 100644
index 48038f0..0000000
--- a/packages/SystemUI/res/drawable-xhdpi/stat_sys_data_out_e.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/stat_sys_data_out_g.png b/packages/SystemUI/res/drawable-xhdpi/stat_sys_data_out_g.png
deleted file mode 100644
index 48038f0..0000000
--- a/packages/SystemUI/res/drawable-xhdpi/stat_sys_data_out_g.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable-xhdpi/stat_sys_data_out_h.png b/packages/SystemUI/res/drawable-xhdpi/stat_sys_data_out_h.png
deleted file mode 100644
index 48038f0..0000000
--- a/packages/SystemUI/res/drawable-xhdpi/stat_sys_data_out_h.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/drawable/compat_mode_help_bg.png b/packages/SystemUI/res/drawable/compat_mode_help_bg.png
deleted file mode 100644
index 87d8c41..0000000
--- a/packages/SystemUI/res/drawable/compat_mode_help_bg.png
+++ /dev/null
Binary files differ
diff --git a/packages/SystemUI/res/layout/navigation_bar.xml b/packages/SystemUI/res/layout/navigation_bar.xml
index 6c4c9c1..fbca299 100644
--- a/packages/SystemUI/res/layout/navigation_bar.xml
+++ b/packages/SystemUI/res/layout/navigation_bar.xml
@@ -23,12 +23,12 @@
xmlns:systemui="http://schemas.android.com/apk/res/com.android.systemui"
android:layout_height="match_parent"
android:layout_width="match_parent"
+ android:background="#FF000000"
>
<FrameLayout android:id="@+id/rot0"
android:layout_height="match_parent"
android:layout_width="match_parent"
- android:background="#FF000000"
>
<LinearLayout
@@ -98,6 +98,51 @@
/>
</LinearLayout>
+ <!-- lights out layout to match exactly -->
+ <LinearLayout
+ android:layout_height="match_parent"
+ android:layout_width="match_parent"
+ android:orientation="horizontal"
+ android:id="@+id/lights_out"
+ android:visibility="gone"
+ >
+ <ImageView
+ android:layout_width="80dp"
+ android:layout_height="match_parent"
+ android:layout_marginLeft="40dp"
+ android:src="@drawable/ic_sysbar_lights_out_dot_small"
+ android:scaleType="center"
+ android:layout_weight="0"
+ />
+ <View
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_weight="1"
+ android:visibility="invisible"
+ />
+ <ImageView
+ android:layout_width="80dp"
+ android:layout_height="match_parent"
+ android:src="@drawable/ic_sysbar_lights_out_dot_large"
+ android:scaleType="center"
+ android:layout_weight="0"
+ />
+ <View
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_weight="1"
+ android:visibility="invisible"
+ />
+ <ImageView
+ android:layout_width="80dp"
+ android:layout_marginRight="40dp"
+ android:layout_height="match_parent"
+ android:src="@drawable/ic_sysbar_lights_out_dot_small"
+ android:scaleType="center"
+ android:layout_weight="0"
+ />
+ </LinearLayout>
+
<View android:id="@+id/deadzone"
android:layout_height="@dimen/navigation_bar_deadzone_size"
android:layout_width="match_parent"
@@ -109,7 +154,6 @@
<FrameLayout android:id="@+id/rot90"
android:layout_height="match_parent"
android:layout_width="match_parent"
- android:background="#FF000000"
android:visibility="gone"
android:paddingTop="24dp"
>
@@ -131,6 +175,8 @@
systemui:keyCode="82"
android:layout_weight="0"
android:visibility="invisible"
+ android:contentDescription="@string/accessibility_menu"
+ systemui:glowBackground="@drawable/ic_sysbar_highlight_land"
/>
<com.android.systemui.statusbar.policy.KeyButtonView android:id="@+id/recent_apps"
android:layout_height="80dp"
@@ -171,15 +217,56 @@
android:contentDescription="@string/accessibility_back"
systemui:glowBackground="@drawable/ic_sysbar_highlight_land"
/>
- <com.android.systemui.statusbar.policy.KeyButtonView android:id="@+id/menu"
+ <View
android:layout_height="40dp"
android:layout_width="match_parent"
- android:src="@drawable/ic_sysbar_menu_land"
- systemui:keyCode="82"
android:layout_weight="0"
android:visibility="invisible"
- android:contentDescription="@string/accessibility_menu"
- systemui:glowBackground="@drawable/ic_sysbar_highlight_land"
+ />
+ </LinearLayout>
+
+ <!-- lights out layout to match exactly -->
+ <LinearLayout
+ android:layout_height="match_parent"
+ android:layout_width="match_parent"
+ android:orientation="vertical"
+ android:id="@+id/lights_out"
+ android:visibility="gone"
+ >
+ <ImageView
+ android:layout_height="80dp"
+ android:layout_marginTop="40dp"
+ android:layout_width="match_parent"
+ android:src="@drawable/ic_sysbar_lights_out_dot_small"
+ android:scaleType="center"
+ android:layout_weight="0"
+ />
+ <View
+ android:layout_height="match_parent"
+ android:layout_width="match_parent"
+ android:layout_weight="1"
+ android:visibility="invisible"
+ />
+ <ImageView
+ android:layout_height="80dp"
+ android:layout_width="match_parent"
+ android:src="@drawable/ic_sysbar_lights_out_dot_large"
+ android:scaleType="center"
+ android:layout_weight="0"
+ />
+ <View
+ android:layout_height="match_parent"
+ android:layout_width="match_parent"
+ android:layout_weight="1"
+ android:visibility="invisible"
+ />
+ <ImageView
+ android:layout_height="80dp"
+ android:layout_marginBottom="40dp"
+ android:layout_width="match_parent"
+ android:src="@drawable/ic_sysbar_lights_out_dot_small"
+ android:scaleType="center"
+ android:layout_weight="0"
/>
</LinearLayout>
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java
index 1e27233..a90eb3f 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java
@@ -59,13 +59,17 @@ public class StatusBarIconView extends AnimatedImageView {
mNotification = notification;
setContentDescription(notification);
- final int outerBounds = res.getDimensionPixelSize(R.dimen.status_bar_icon_size);
- final int imageBounds = res.getDimensionPixelSize(R.dimen.status_bar_icon_drawing_size);
- final float scale = (float)imageBounds / (float)outerBounds;
- setScaleX(scale);
- setScaleY(scale);
- final float alpha = res.getFraction(R.dimen.status_bar_icon_drawing_alpha, 1, 1);
- setAlpha(alpha);
+ // We do not resize and scale system icons (on the right), only notification icons (on the
+ // left).
+ if (notification != null) {
+ final int outerBounds = res.getDimensionPixelSize(R.dimen.status_bar_icon_size);
+ final int imageBounds = res.getDimensionPixelSize(R.dimen.status_bar_icon_drawing_size);
+ final float scale = (float)imageBounds / (float)outerBounds;
+ setScaleX(scale);
+ setScaleY(scale);
+ final float alpha = res.getFraction(R.dimen.status_bar_icon_drawing_alpha, 1, 1);
+ setAlpha(alpha);
+ }
}
private static boolean streq(String a, String b) {
@@ -247,4 +251,9 @@ public class StatusBarIconView extends AnimatedImageView {
}
}
}
+
+ public String toString() {
+ return "StatusBarIconView(slot=" + mSlot + " icon=" + mIcon
+ + " notification=" + mNotification + ")";
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
index c3f20bc..e6c0b96 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
@@ -25,6 +25,7 @@ import android.content.res.Resources;
import android.os.ServiceManager;
import android.util.AttributeSet;
import android.util.Slog;
+import android.view.animation.AccelerateInterpolator;
import android.view.Display;
import android.view.KeyEvent;
import android.view.MotionEvent;
@@ -47,6 +48,8 @@ public class NavigationBarView extends LinearLayout {
final static boolean NAVBAR_ALWAYS_AT_RIGHT = true;
+ final static boolean ANIMATE_HIDE_TRANSITION = false; // turned off because it introduces unsightly delay when videos goes to full screen
+
protected IStatusBarService mBarService;
final Display mDisplay;
View mCurrentView = null;
@@ -56,7 +59,8 @@ public class NavigationBarView extends LinearLayout {
int mBarSize;
boolean mVertical;
- boolean mHidden;
+ boolean mHidden, mLowProfile;
+ boolean mEnabled = true;
public View getRecentsButton() {
return mCurrentView.findViewById(R.id.recent_apps);
@@ -81,6 +85,70 @@ public class NavigationBarView extends LinearLayout {
mVertical = false;
}
+ public void setEnabled(final boolean enable) {
+ mEnabled = enable;
+ mCurrentView.setVisibility(enable ? View.VISIBLE : View.INVISIBLE);
+ }
+
+ View.OnTouchListener mLightsOutListener = new View.OnTouchListener() {
+ @Override
+ public boolean onTouch(View v, MotionEvent ev) {
+ if (ev.getAction() == MotionEvent.ACTION_DOWN) {
+ // even though setting the systemUI visibility below will turn these views
+ // on, we need them to come up faster so that they can catch this motion
+ // event
+ setLowProfile(false, false);
+
+ try {
+ mBarService.setSystemUiVisibility(0);
+ } catch (android.os.RemoteException ex) {
+ }
+ }
+ return false;
+ }
+ };
+
+ public void setLowProfile(final boolean lightsOut) {
+ setLowProfile(lightsOut, true);
+ }
+
+ public void setLowProfile(final boolean lightsOut, final boolean animate) {
+ if (lightsOut == mLowProfile) return;
+
+ mLowProfile = lightsOut;
+
+ if (DEBUG) Slog.d(TAG, "setting lights " + (lightsOut?"out":"on"));
+
+ final View navButtons = mCurrentView.findViewById(R.id.nav_buttons);
+ final View lowLights = mCurrentView.findViewById(R.id.lights_out);
+
+ if (!animate) {
+ lowLights.setVisibility(View.GONE);
+ navButtons.setAlpha(1f);
+ } else {
+ navButtons.animate()
+ .alpha(lightsOut ? 0f : 1f)
+ .setDuration(lightsOut ? 600 : 200)
+ .start();
+
+ lowLights.setOnTouchListener(mLightsOutListener);
+ lowLights.setAlpha(0f);
+ lowLights.setVisibility(View.VISIBLE);
+ lowLights.animate()
+ .alpha(lightsOut ? 1f : 0f)
+ .setStartDelay(lightsOut ? 500 : 0)
+ .setDuration(lightsOut ? 1000 : 300)
+ .setInterpolator(new AccelerateInterpolator(2.0f))
+ .setListener(lightsOut ? null : new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationEnd(Animator _a) {
+ lowLights.setVisibility(View.GONE);
+ }
+ })
+ .start();
+ }
+ }
+
public void setHidden(final boolean hide) {
if (hide == mHidden) return;
@@ -88,6 +156,14 @@ public class NavigationBarView extends LinearLayout {
Slog.d(TAG,
(hide ? "HIDING" : "SHOWING") + " navigation bar");
+ // bring up the lights no matter what
+ setLowProfile(false);
+
+ if (!ANIMATE_HIDE_TRANSITION) {
+ setVisibility(hide ? View.GONE : View.VISIBLE);
+ return;
+ }
+
float oldAlpha = mCurrentView.getAlpha();
if (DEBUG) {
Slog.d(TAG, "animating alpha: " + oldAlpha + " -> "
@@ -141,8 +217,10 @@ public class NavigationBarView extends LinearLayout {
@Override
public boolean onTouchEvent(MotionEvent ev) {
- // immediately bring up the lights
- setHidden(false);
+ try {
+ mBarService.setSystemUiVisibility(0);
+ } catch (android.os.RemoteException ex) {
+ }
return false; // pass it on
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
index e894831..fe9eceb 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -91,6 +91,7 @@ public class PhoneStatusBar extends StatusBar {
static final String TAG = "PhoneStatusBar";
public static final boolean DEBUG = false;
public static final boolean SPEW = false;
+ public static final boolean DUMPTRUCK = true; // extra dumpsys info
// additional instrumentation for testing purposes; intended to be left on during development
public static final boolean CHATTY = DEBUG || true;
@@ -283,6 +284,8 @@ public class PhoneStatusBar extends StatusBar {
mNavigationBarView =
(NavigationBarView) View.inflate(context, R.layout.navigation_bar, null);
+ mNavigationBarView.setEnabled((mDisabled & StatusBarManager.DISABLE_NAVIGATION) == 0);
+
sb.setOnSystemUiVisibilityChangeListener(
new View.OnSystemUiVisibilityChangeListener() {
@Override
@@ -316,8 +319,8 @@ public class PhoneStatusBar extends StatusBar {
mPile = (ViewGroup)expanded.findViewById(R.id.latestItems);
mExpandedContents = mPile; // was: expanded.findViewById(R.id.notificationLinearLayout);
mNoNotificationsTitle = (TextView)expanded.findViewById(R.id.noNotificationsTitle);
- mNoNotificationsTitle.setAlpha(0f);
- mNoNotificationsTitle.setVisibility(View.VISIBLE);
+ mNoNotificationsTitle.setVisibility(View.GONE); // disabling for now
+
mClearButton = expanded.findViewById(R.id.clear_all_button);
mClearButton.setOnClickListener(mClearButtonListener);
mClearButton.setAlpha(0f);
@@ -1026,6 +1029,7 @@ public class PhoneStatusBar extends StatusBar {
mClearButton.setAlpha(clearable ? 1.0f : 0.0f);
}
+ /*
if (mNoNotificationsTitle.isShown()) {
if (any != (mNoNotificationsTitle.getAlpha() == 0.0f)) {
ObjectAnimator a = ObjectAnimator.ofFloat(mNoNotificationsTitle, "alpha",
@@ -1037,6 +1041,7 @@ public class PhoneStatusBar extends StatusBar {
} else {
mNoNotificationsTitle.setAlpha(any ? 0.0f : 0.75f);
}
+ */
}
@@ -1048,12 +1053,32 @@ public class PhoneStatusBar extends StatusBar {
final int diff = state ^ old;
mDisabled = state;
+ if (DEBUG) {
+ Slog.d(TAG, String.format("disable: 0x%08x -> 0x%08x (diff: 0x%08x)",
+ old, state, diff));
+ }
+
if ((diff & StatusBarManager.DISABLE_EXPAND) != 0) {
if ((state & StatusBarManager.DISABLE_EXPAND) != 0) {
Slog.d(TAG, "DISABLE_EXPAND: yes");
animateCollapse();
}
}
+
+ if ((diff & StatusBarManager.DISABLE_NAVIGATION) != 0) {
+ if ((state & StatusBarManager.DISABLE_NAVIGATION) != 0) {
+ Slog.d(TAG, "DISABLE_NAVIGATION: yes");
+
+ // close recents if it's visible
+ mHandler.removeMessages(MSG_CLOSE_RECENTS_PANEL);
+ mHandler.sendEmptyMessage(MSG_CLOSE_RECENTS_PANEL);
+ }
+
+ if (mNavigationBarView != null) {
+ mNavigationBarView.setEnabled((state & StatusBarManager.DISABLE_NAVIGATION) == 0);
+ }
+ }
+
if ((diff & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) {
if ((state & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) {
Slog.d(TAG, "DISABLE_NOTIFICATION_ICONS: yes");
@@ -1469,11 +1494,20 @@ public class PhoneStatusBar extends StatusBar {
@Override // CommandQueue
public void setSystemUiVisibility(int vis) {
- if (vis != mSystemUiVisibility) {
+ final int old = mSystemUiVisibility;
+ final int diff = vis ^ old;
+
+ if (diff != 0) {
mSystemUiVisibility = vis;
- if (0 != (vis & View.SYSTEM_UI_FLAG_LOW_PROFILE)) {
- animateCollapse();
+ if (0 != (diff & View.SYSTEM_UI_FLAG_LOW_PROFILE)) {
+ final boolean lightsOut = (0 != (vis & View.SYSTEM_UI_FLAG_LOW_PROFILE));
+ if (lightsOut) {
+ animateCollapse();
+ }
+ if (mNavigationBarView != null) {
+ mNavigationBarView.setLowProfile(lightsOut);
+ }
}
notifyUiVisibilityChanged();
@@ -1679,26 +1713,28 @@ public class PhoneStatusBar extends StatusBar {
pw.println(" mScrollView: " + viewInfo(mScrollView)
+ " scroll " + mScrollView.getScrollX() + "," + mScrollView.getScrollY());
}
- /*
- synchronized (mNotificationData) {
- int N = mNotificationData.ongoingCount();
- pw.println(" ongoingCount.size=" + N);
- for (int i=0; i<N; i++) {
- StatusBarNotification n = mNotificationData.getOngoing(i);
- pw.println(" [" + i + "] key=" + n.key + " view=" + n.view);
- pw.println(" data=" + n.data);
+
+ if (DUMPTRUCK) {
+ synchronized (mNotificationData) {
+ int N = mNotificationData.size();
+ pw.println(" notification icons: " + N);
+ for (int i=0; i<N; i++) {
+ NotificationData.Entry e = mNotificationData.get(i);
+ pw.println(" [" + i + "] key=" + e.key + " icon=" + e.icon);
+ StatusBarNotification n = e.notification;
+ pw.println(" pkg=" + n.pkg + " id=" + n.id + " priority=" + n.priority);
+ pw.println(" notification=" + n.notification);
+ pw.println(" tickerText=\"" + n.notification.tickerText + "\"");
+ }
}
- N = mNotificationData.latestCount();
- pw.println(" ongoingCount.size=" + N);
+
+ int N = mStatusIcons.getChildCount();
+ pw.println(" system icons: " + N);
for (int i=0; i<N; i++) {
- StatusBarNotification n = mNotificationData.getLatest(i);
- pw.println(" [" + i + "] key=" + n.key + " view=" + n.view);
- pw.println(" data=" + n.data);
+ StatusBarIconView ic = (StatusBarIconView) mStatusIcons.getChildAt(i);
+ pw.println(" [" + i + "] icon=" + ic);
}
- }
- */
-
- if (false) {
+
pw.println("see the logcat for a dump of the views we have created.");
// must happen on ui thread
mHandler.post(new Runnable() {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java
index 201ff2d..76dec5e 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java
@@ -1220,9 +1220,7 @@ public class TabletStatusBar extends StatusBar implements
private View.OnClickListener mOnClickListener = new View.OnClickListener() {
public void onClick(View v) {
- if (v == mNotificationTrigger) {
- onClickNotificationTrigger();
- } else if (v == mRecentButton) {
+ if (v == mRecentButton) {
onClickRecentButton();
} else if (v == mInputMethodSwitchButton) {
onClickInputMethodSwitchButton();
@@ -1232,17 +1230,6 @@ public class TabletStatusBar extends StatusBar implements
}
};
- public void onClickNotificationTrigger() {
- if (DEBUG) Slog.d(TAG, "clicked notification icons; disabled=" + mDisabled);
- if ((mDisabled & StatusBarManager.DISABLE_EXPAND) == 0) {
- int msg = !mNotificationPanel.isShowing()
- ? MSG_OPEN_NOTIFICATION_PANEL
- : MSG_CLOSE_NOTIFICATION_PANEL;
- mHandler.removeMessages(msg);
- mHandler.sendEmptyMessage(msg);
- }
- }
-
public void onClickRecentButton() {
if (DEBUG) Slog.d(TAG, "clicked recent apps; disabled=" + mDisabled);
if ((mDisabled & StatusBarManager.DISABLE_EXPAND) == 0) {
@@ -1374,6 +1361,11 @@ public class TabletStatusBar extends StatusBar implements
// event.getY(),
// mInitialTouchX,
// mInitialTouchY));
+
+ if ((mDisabled & StatusBarManager.DISABLE_EXPAND) != 0) {
+ return true;
+ }
+
final int action = event.getAction();
switch (action) {
case MotionEvent.ACTION_DOWN:
diff --git a/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java b/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java
index 06b7fb9..86de558 100644
--- a/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java
+++ b/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java
@@ -1142,6 +1142,10 @@ public class KeyguardViewMediator implements KeyguardViewCallback,
// insecure and (is covered by another window OR this feature is enabled in general)
boolean enable = !mShowing
|| ((ENABLE_STATUS_BAR_IN_KEYGUARD || mHidden) && !isSecure());
+ if (DEBUG) {
+ Log.d(TAG, "adjustStatusBarLocked: mShowing=" + mShowing + " mHidden=" + mHidden
+ + " isSecure=" + isSecure() + " --> enable=" + enable);
+ }
mStatusBarManager.disable(enable ?
StatusBarManager.DISABLE_NONE :
( StatusBarManager.DISABLE_EXPAND
diff --git a/policy/src/com/android/internal/policy/impl/LockScreen.java b/policy/src/com/android/internal/policy/impl/LockScreen.java
index 9d360ac..4f6df36 100644
--- a/policy/src/com/android/internal/policy/impl/LockScreen.java
+++ b/policy/src/com/android/internal/policy/impl/LockScreen.java
@@ -23,7 +23,6 @@ import com.android.internal.widget.WaveView;
import com.android.internal.widget.multiwaveview.MultiWaveView;
import android.app.ActivityManager;
-import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
@@ -46,6 +45,7 @@ import java.io.File;
*/
class LockScreen extends LinearLayout implements KeyguardScreen {
+ private static final int ON_RESUME_PING_DELAY = 500; // delay first ping until the screen is on
private static final boolean DBG = false;
private static final String TAG = "LockScreen";
private static final String ENABLE_MENU_KEY_FILE = "/data/local/enable_menu_key";
@@ -441,10 +441,16 @@ class LockScreen extends LinearLayout implements KeyguardScreen {
mUnlockWidgetMethods.reset(false);
}
+ private final Runnable mOnResumePing = new Runnable() {
+ public void run() {
+ mUnlockWidgetMethods.ping();
+ }
+ };
+
/** {@inheritDoc} */
public void onResume() {
mStatusViewManager.onResume();
- mUnlockWidgetMethods.ping();
+ postDelayed(mOnResumePing, ON_RESUME_PING_DELAY);
}
/** {@inheritDoc} */
diff --git a/policy/src/com/android/internal/policy/impl/PasswordUnlockScreen.java b/policy/src/com/android/internal/policy/impl/PasswordUnlockScreen.java
index 7c1f93a..d70b3bb 100644
--- a/policy/src/com/android/internal/policy/impl/PasswordUnlockScreen.java
+++ b/policy/src/com/android/internal/policy/impl/PasswordUnlockScreen.java
@@ -16,6 +16,8 @@
package com.android.internal.policy.impl;
+import java.util.List;
+
import android.app.admin.DevicePolicyManager;
import android.content.Context;
import android.content.res.Configuration;
@@ -27,18 +29,18 @@ import com.android.internal.widget.PasswordEntryKeyboardView;
import android.os.CountDownTimer;
import android.os.SystemClock;
import android.security.KeyStore;
-import android.telephony.TelephonyManager;
import android.text.Editable;
import android.text.InputType;
import android.text.TextWatcher;
import android.text.method.DigitsKeyListener;
import android.text.method.TextKeyListener;
-import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
-import android.view.View.OnClickListener;
import android.view.inputmethod.EditorInfo;
+import android.view.inputmethod.InputMethodInfo;
+import android.view.inputmethod.InputMethodManager;
+import android.view.inputmethod.InputMethodSubtype;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
@@ -159,6 +161,68 @@ public class PasswordUnlockScreen extends LinearLayout implements KeyguardScreen
}
}
});
+
+ // If there's more than one IME, enable the IME switcher button
+ View switchImeButton = findViewById(R.id.switch_ime_button);
+ final InputMethodManager imm = (InputMethodManager) getContext().getSystemService(
+ Context.INPUT_METHOD_SERVICE);
+ if (switchImeButton != null && hasMultipleEnabledIMEsOrSubtypes(imm, false)) {
+ switchImeButton.setVisibility(View.VISIBLE);
+ switchImeButton.setOnClickListener(new OnClickListener() {
+ public void onClick(View v) {
+ mCallback.pokeWakelock(); // Leave the screen on a bit longer
+ imm.showInputMethodPicker();
+ }
+ });
+ }
+ }
+
+ /**
+ * Method adapted from com.android.inputmethod.latin.Utils
+ *
+ * @param imm The input method manager
+ * @param shouldIncludeAuxiliarySubtypes
+ * @return true if we have multiple IMEs to choose from
+ */
+ private boolean hasMultipleEnabledIMEsOrSubtypes(InputMethodManager imm,
+ final boolean shouldIncludeAuxiliarySubtypes) {
+ final List<InputMethodInfo> enabledImis = imm.getEnabledInputMethodList();
+
+ // Number of the filtered IMEs
+ int filteredImisCount = 0;
+
+ for (InputMethodInfo imi : enabledImis) {
+ // We can return true immediately after we find two or more filtered IMEs.
+ if (filteredImisCount > 1) return true;
+ final List<InputMethodSubtype> subtypes =
+ imm.getEnabledInputMethodSubtypeList(imi, true);
+ // IMEs that have no subtypes should be counted.
+ if (subtypes.isEmpty()) {
+ ++filteredImisCount;
+ continue;
+ }
+
+ int auxCount = 0;
+ for (InputMethodSubtype subtype : subtypes) {
+ if (subtype.isAuxiliary()) {
+ ++auxCount;
+ }
+ }
+ final int nonAuxCount = subtypes.size() - auxCount;
+
+ // IMEs that have one or more non-auxiliary subtypes should be counted.
+ // If shouldIncludeAuxiliarySubtypes is true, IMEs that have two or more auxiliary
+ // subtypes should be counted as well.
+ if (nonAuxCount > 0 || (shouldIncludeAuxiliarySubtypes && auxCount > 1)) {
+ ++filteredImisCount;
+ continue;
+ }
+ }
+
+ return filteredImisCount > 1
+ // imm.getEnabledInputMethodSubtypeList(null, false) will return the current IME's enabled
+ // input method subtype (The current IME should be LatinIME.)
+ || imm.getEnabledInputMethodSubtypeList(null, false).size() > 1;
}
@Override
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindow.java b/policy/src/com/android/internal/policy/impl/PhoneWindow.java
index 73e4338..c929bbc 100644
--- a/policy/src/com/android/internal/policy/impl/PhoneWindow.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindow.java
@@ -386,8 +386,10 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
// Ditch the menu created above
st.menu = null;
- // Don't show it in the action bar either
- mActionBar.setMenu(null, mActionMenuPresenterCallback);
+ if (mActionBar != null) {
+ // Don't show it in the action bar either
+ mActionBar.setMenu(null, mActionMenuPresenterCallback);
+ }
return false;
}
@@ -409,9 +411,11 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
}
if (!cb.onPreparePanel(st.featureId, st.createdPanelView, st.menu)) {
- // The app didn't want to show the menu for now but it still exists.
- // Clear it out of the action bar.
- mActionBar.setMenu(null, mActionMenuPresenterCallback);
+ if (mActionBar != null) {
+ // The app didn't want to show the menu for now but it still exists.
+ // Clear it out of the action bar.
+ mActionBar.setMenu(null, mActionMenuPresenterCallback);
+ }
st.menu.startDispatchingItemsChanged();
return false;
}
@@ -583,6 +587,13 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
}
} else if (!st.isInListMode()) {
width = MATCH_PARENT;
+ } else if (st.createdPanelView != null) {
+ // If we already had a panel view, carry width=MATCH_PARENT through
+ // as we did above when it was created.
+ ViewGroup.LayoutParams lp = st.createdPanelView.getLayoutParams();
+ if (lp != null && lp.width == ViewGroup.LayoutParams.MATCH_PARENT) {
+ width = MATCH_PARENT;
+ }
}
st.isOpen = true;
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
index 7764e35..ebadb5e 100755
--- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
@@ -2398,10 +2398,11 @@ public class PhoneWindowManager implements WindowManagerPolicy {
}
}
+ final Object mScreenshotLock = new Object();
ServiceConnection mScreenshotConnection = null;
Runnable mScreenshotTimeout = null;
- void finishScreenshot(ServiceConnection conn) {
+ void finishScreenshotLSS(ServiceConnection conn) {
if (mScreenshotConnection == conn) {
mContext.unbindService(conn);
mScreenshotConnection = null;
@@ -2416,48 +2417,56 @@ public class PhoneWindowManager implements WindowManagerPolicy {
mHandler.post(new Runnable() {
@Override
public void run() {
- if (mScreenshotConnection != null) {
- return;
- }
- ComponentName cn = new ComponentName("com.android.systemui",
- "com.android.systemui.screenshot.TakeScreenshotService");
- Intent intent = new Intent();
- intent.setComponent(cn);
- ServiceConnection conn = new ServiceConnection() {
- @Override
- public void onServiceConnected(ComponentName name, IBinder service) {
- if (mScreenshotConnection != this) {
- return;
- }
- Messenger messenger = new Messenger(service);
- Message msg = Message.obtain(null, 1);
- final ServiceConnection myConn = this;
- Handler h = new Handler(mHandler.getLooper()) {
- @Override
- public void handleMessage(Message msg) {
- finishScreenshot(myConn);
- }
- };
- msg.replyTo = new Messenger(h);
- try {
- messenger.send(msg);
- } catch (RemoteException e) {
- }
+ synchronized (mScreenshotLock) {
+ if (mScreenshotConnection != null) {
+ return;
}
- @Override
- public void onServiceDisconnected(ComponentName name) {}
- };
- if (mContext.bindService(intent, conn, Context.BIND_AUTO_CREATE)) {
- mScreenshotConnection = conn;
- mScreenshotTimeout = new Runnable() {
- @Override public void run() {
- if (mScreenshotConnection != null) {
- finishScreenshot(mScreenshotConnection);
+ ComponentName cn = new ComponentName("com.android.systemui",
+ "com.android.systemui.screenshot.TakeScreenshotService");
+ Intent intent = new Intent();
+ intent.setComponent(cn);
+ ServiceConnection conn = new ServiceConnection() {
+ @Override
+ public void onServiceConnected(ComponentName name, IBinder service) {
+ synchronized (mScreenshotLock) {
+ if (mScreenshotConnection != this) {
+ return;
+ }
+ Messenger messenger = new Messenger(service);
+ Message msg = Message.obtain(null, 1);
+ final ServiceConnection myConn = this;
+ Handler h = new Handler(mHandler.getLooper()) {
+ @Override
+ public void handleMessage(Message msg) {
+ synchronized (mScreenshotLock) {
+ finishScreenshotLSS(myConn);
+ }
+ }
+ };
+ msg.replyTo = new Messenger(h);
+ try {
+ messenger.send(msg);
+ } catch (RemoteException e) {
+ }
}
}
-
+ @Override
+ public void onServiceDisconnected(ComponentName name) {}
};
- mHandler.postDelayed(mScreenshotTimeout, 10000);
+ if (mContext.bindService(intent, conn, Context.BIND_AUTO_CREATE)) {
+ mScreenshotConnection = conn;
+ mScreenshotTimeout = new Runnable() {
+ @Override public void run() {
+ synchronized (mScreenshotLock) {
+ if (mScreenshotConnection != null) {
+ finishScreenshotLSS(mScreenshotConnection);
+ }
+ }
+ }
+
+ };
+ mHandler.postDelayed(mScreenshotTimeout, 10000);
+ }
}
}
});
diff --git a/services/input/InputDispatcher.cpp b/services/input/InputDispatcher.cpp
index 3cd3ac3..f6ce44c 100644
--- a/services/input/InputDispatcher.cpp
+++ b/services/input/InputDispatcher.cpp
@@ -401,6 +401,14 @@ void InputDispatcher::dispatchOnceInnerLocked(nsecs_t* nextWakeupTime) {
break;
}
+ case EventEntry::TYPE_DEVICE_RESET: {
+ DeviceResetEntry* typedEntry =
+ static_cast<DeviceResetEntry*>(mPendingEvent);
+ done = dispatchDeviceResetLocked(currentTime, typedEntry);
+ dropReason = DROP_REASON_NOT_DROPPED; // device resets are never dropped
+ break;
+ }
+
case EventEntry::TYPE_KEY: {
KeyEntry* typedEntry = static_cast<KeyEntry*>(mPendingEvent);
if (isAppSwitchDue) {
@@ -727,6 +735,19 @@ bool InputDispatcher::dispatchConfigurationChangedLocked(
return true;
}
+bool InputDispatcher::dispatchDeviceResetLocked(
+ nsecs_t currentTime, DeviceResetEntry* entry) {
+#if DEBUG_OUTBOUND_EVENT_DETAILS
+ LOGD("dispatchDeviceReset - eventTime=%lld, deviceId=%d", entry->eventTime, entry->deviceId);
+#endif
+
+ CancelationOptions options(CancelationOptions::CANCEL_ALL_EVENTS,
+ "device was reset");
+ options.deviceId = entry->deviceId;
+ synthesizeCancelationEventsForAllConnectionsLocked(options);
+ return true;
+}
+
bool InputDispatcher::dispatchKeyLocked(nsecs_t currentTime, KeyEntry* entry,
DropReason* dropReason, nsecs_t* nextWakeupTime) {
// Preprocessing.
@@ -2921,6 +2942,25 @@ void InputDispatcher::notifySwitch(const NotifySwitchArgs* args) {
args->switchCode, args->switchValue, policyFlags);
}
+void InputDispatcher::notifyDeviceReset(const NotifyDeviceResetArgs* args) {
+#if DEBUG_INBOUND_EVENT_DETAILS
+ LOGD("notifyDeviceReset - eventTime=%lld, deviceId=%d",
+ args->eventTime, args->deviceId);
+#endif
+
+ bool needWake;
+ { // acquire lock
+ AutoMutex _l(mLock);
+
+ DeviceResetEntry* newEntry = new DeviceResetEntry(args->eventTime, args->deviceId);
+ needWake = enqueueInboundEventLocked(newEntry);
+ } // release lock
+
+ if (needWake) {
+ mLooper->wake();
+ }
+}
+
int32_t InputDispatcher::injectInputEvent(const InputEvent* event,
int32_t injectorPid, int32_t injectorUid, int32_t syncMode, int32_t timeoutMillis,
uint32_t policyFlags) {
@@ -4016,6 +4056,17 @@ InputDispatcher::ConfigurationChangedEntry::~ConfigurationChangedEntry() {
}
+// --- InputDispatcher::DeviceResetEntry ---
+
+InputDispatcher::DeviceResetEntry::DeviceResetEntry(nsecs_t eventTime, int32_t deviceId) :
+ EventEntry(TYPE_DEVICE_RESET, eventTime, 0),
+ deviceId(deviceId) {
+}
+
+InputDispatcher::DeviceResetEntry::~DeviceResetEntry() {
+}
+
+
// --- InputDispatcher::KeyEntry ---
InputDispatcher::KeyEntry::KeyEntry(nsecs_t eventTime,
@@ -4407,6 +4458,10 @@ bool InputDispatcher::InputState::shouldCancelKey(const KeyMemento& memento,
return false;
}
+ if (options.deviceId != -1 && memento.deviceId != options.deviceId) {
+ return false;
+ }
+
switch (options.mode) {
case CancelationOptions::CANCEL_ALL_EVENTS:
case CancelationOptions::CANCEL_NON_POINTER_EVENTS:
@@ -4420,6 +4475,10 @@ bool InputDispatcher::InputState::shouldCancelKey(const KeyMemento& memento,
bool InputDispatcher::InputState::shouldCancelMotion(const MotionMemento& memento,
const CancelationOptions& options) {
+ if (options.deviceId != -1 && memento.deviceId != options.deviceId) {
+ return false;
+ }
+
switch (options.mode) {
case CancelationOptions::CANCEL_ALL_EVENTS:
return true;
diff --git a/services/input/InputDispatcher.h b/services/input/InputDispatcher.h
index cae1610..3c83691 100644
--- a/services/input/InputDispatcher.h
+++ b/services/input/InputDispatcher.h
@@ -381,6 +381,7 @@ public:
virtual void notifyKey(const NotifyKeyArgs* args);
virtual void notifyMotion(const NotifyMotionArgs* args);
virtual void notifySwitch(const NotifySwitchArgs* args);
+ virtual void notifyDeviceReset(const NotifyDeviceResetArgs* args);
virtual int32_t injectInputEvent(const InputEvent* event,
int32_t injectorPid, int32_t injectorUid, int32_t syncMode, int32_t timeoutMillis,
@@ -424,6 +425,7 @@ private:
struct EventEntry : Link<EventEntry> {
enum {
TYPE_CONFIGURATION_CHANGED,
+ TYPE_DEVICE_RESET,
TYPE_KEY,
TYPE_MOTION
};
@@ -453,6 +455,15 @@ private:
virtual ~ConfigurationChangedEntry();
};
+ struct DeviceResetEntry : EventEntry {
+ int32_t deviceId;
+
+ DeviceResetEntry(nsecs_t eventTime, int32_t deviceId);
+
+ protected:
+ virtual ~DeviceResetEntry();
+ };
+
struct KeyEntry : EventEntry {
int32_t deviceId;
uint32_t source;
@@ -688,8 +699,11 @@ private:
// The specific keycode of the key event to cancel, or -1 to cancel any key event.
int32_t keyCode;
+ // The specific device id of events to cancel, or -1 to cancel events from any device.
+ int32_t deviceId;
+
CancelationOptions(Mode mode, const char* reason) :
- mode(mode), reason(reason), keyCode(-1) { }
+ mode(mode), reason(reason), keyCode(-1), deviceId(-1) { }
};
/* Tracks dispatched key and motion event state so that cancelation events can be
@@ -982,6 +996,8 @@ private:
// Dispatch inbound events.
bool dispatchConfigurationChangedLocked(
nsecs_t currentTime, ConfigurationChangedEntry* entry);
+ bool dispatchDeviceResetLocked(
+ nsecs_t currentTime, DeviceResetEntry* entry);
bool dispatchKeyLocked(
nsecs_t currentTime, KeyEntry* entry,
DropReason* dropReason, nsecs_t* nextWakeupTime);
diff --git a/services/input/InputListener.cpp b/services/input/InputListener.cpp
index 4f9fe90..657a6b9 100644
--- a/services/input/InputListener.cpp
+++ b/services/input/InputListener.cpp
@@ -118,6 +118,21 @@ void NotifySwitchArgs::notify(const sp<InputListenerInterface>& listener) const
}
+// --- NotifyDeviceResetArgs ---
+
+NotifyDeviceResetArgs::NotifyDeviceResetArgs(nsecs_t eventTime, int32_t deviceId) :
+ eventTime(eventTime), deviceId(deviceId) {
+}
+
+NotifyDeviceResetArgs::NotifyDeviceResetArgs(const NotifyDeviceResetArgs& other) :
+ eventTime(other.eventTime), deviceId(other.deviceId) {
+}
+
+void NotifyDeviceResetArgs::notify(const sp<InputListenerInterface>& listener) const {
+ listener->notifyDeviceReset(this);
+}
+
+
// --- QueuedInputListener ---
QueuedInputListener::QueuedInputListener(const sp<InputListenerInterface>& innerListener) :
@@ -148,6 +163,10 @@ void QueuedInputListener::notifySwitch(const NotifySwitchArgs* args) {
mArgsQueue.push(new NotifySwitchArgs(*args));
}
+void QueuedInputListener::notifyDeviceReset(const NotifyDeviceResetArgs* args) {
+ mArgsQueue.push(new NotifyDeviceResetArgs(*args));
+}
+
void QueuedInputListener::flush() {
size_t count = mArgsQueue.size();
for (size_t i = 0; i < count; i++) {
diff --git a/services/input/InputListener.h b/services/input/InputListener.h
index 3fef132..f920cd1 100644
--- a/services/input/InputListener.h
+++ b/services/input/InputListener.h
@@ -131,6 +131,24 @@ struct NotifySwitchArgs : public NotifyArgs {
};
+/* Describes a device reset event, such as when a device is added,
+ * reconfigured, or removed. */
+struct NotifyDeviceResetArgs : public NotifyArgs {
+ nsecs_t eventTime;
+ int32_t deviceId;
+
+ inline NotifyDeviceResetArgs() { }
+
+ NotifyDeviceResetArgs(nsecs_t eventTime, int32_t deviceId);
+
+ NotifyDeviceResetArgs(const NotifyDeviceResetArgs& other);
+
+ virtual ~NotifyDeviceResetArgs() { }
+
+ virtual void notify(const sp<InputListenerInterface>& listener) const;
+};
+
+
/*
* The interface used by the InputReader to notify the InputListener about input events.
*/
@@ -144,6 +162,7 @@ public:
virtual void notifyKey(const NotifyKeyArgs* args) = 0;
virtual void notifyMotion(const NotifyMotionArgs* args) = 0;
virtual void notifySwitch(const NotifySwitchArgs* args) = 0;
+ virtual void notifyDeviceReset(const NotifyDeviceResetArgs* args) = 0;
};
@@ -162,6 +181,7 @@ public:
virtual void notifyKey(const NotifyKeyArgs* args);
virtual void notifyMotion(const NotifyMotionArgs* args);
virtual void notifySwitch(const NotifySwitchArgs* args);
+ virtual void notifyDeviceReset(const NotifyDeviceResetArgs* args);
void flush();
diff --git a/services/input/InputReader.cpp b/services/input/InputReader.cpp
index 2035a4b..40c85fc 100644
--- a/services/input/InputReader.cpp
+++ b/services/input/InputReader.cpp
@@ -198,6 +198,39 @@ static void synthesizeButtonKeys(InputReaderContext* context, int32_t action,
}
+// --- InputReaderConfiguration ---
+
+bool InputReaderConfiguration::getDisplayInfo(int32_t displayId, bool external,
+ int32_t* width, int32_t* height, int32_t* orientation) const {
+ if (displayId == 0) {
+ const DisplayInfo& info = external ? mExternalDisplay : mInternalDisplay;
+ if (info.width > 0 && info.height > 0) {
+ if (width) {
+ *width = info.width;
+ }
+ if (height) {
+ *height = info.height;
+ }
+ if (orientation) {
+ *orientation = info.orientation;
+ }
+ return true;
+ }
+ }
+ return false;
+}
+
+void InputReaderConfiguration::setDisplayInfo(int32_t displayId, bool external,
+ int32_t width, int32_t height, int32_t orientation) {
+ if (displayId == 0) {
+ DisplayInfo& info = external ? mExternalDisplay : mInternalDisplay;
+ info.width = width;
+ info.height = height;
+ info.orientation = orientation;
+ }
+}
+
+
// --- InputReader ---
InputReader::InputReader(const sp<EventHubInterface>& eventHub,
@@ -289,10 +322,10 @@ void InputReader::processEventsLocked(const RawEvent* rawEvents, size_t count) {
} else {
switch (rawEvent->type) {
case EventHubInterface::DEVICE_ADDED:
- addDeviceLocked(rawEvent->deviceId);
+ addDeviceLocked(rawEvent->when, rawEvent->deviceId);
break;
case EventHubInterface::DEVICE_REMOVED:
- removeDeviceLocked(rawEvent->deviceId);
+ removeDeviceLocked(rawEvent->when, rawEvent->deviceId);
break;
case EventHubInterface::FINISHED_DEVICE_SCAN:
handleConfigurationChangedLocked(rawEvent->when);
@@ -307,12 +340,13 @@ void InputReader::processEventsLocked(const RawEvent* rawEvents, size_t count) {
}
}
-void InputReader::addDeviceLocked(int32_t deviceId) {
+void InputReader::addDeviceLocked(nsecs_t when, int32_t deviceId) {
String8 name = mEventHub->getDeviceName(deviceId);
uint32_t classes = mEventHub->getDeviceClasses(deviceId);
InputDevice* device = createDeviceLocked(deviceId, name, classes);
- device->configure(&mConfig, 0);
+ device->configure(when, &mConfig, 0);
+ device->reset(when);
if (device->isIgnored()) {
LOGI("Device added: id=%d, name='%s' (ignored non-input device)", deviceId, name.string());
@@ -331,7 +365,7 @@ void InputReader::addDeviceLocked(int32_t deviceId) {
}
}
-void InputReader::removeDeviceLocked(int32_t deviceId) {
+void InputReader::removeDeviceLocked(nsecs_t when, int32_t deviceId) {
InputDevice* device = NULL;
ssize_t deviceIndex = mDevices.indexOfKey(deviceId);
if (deviceIndex >= 0) {
@@ -350,8 +384,7 @@ void InputReader::removeDeviceLocked(int32_t deviceId) {
device->getId(), device->getName().string(), device->getSources());
}
- device->reset();
-
+ device->reset(when);
delete device;
}
@@ -453,13 +486,14 @@ void InputReader::refreshConfigurationLocked(uint32_t changes) {
if (changes) {
LOGI("Reconfiguring input devices. changes=0x%08x", changes);
+ nsecs_t now = systemTime(SYSTEM_TIME_MONOTONIC);
if (changes & InputReaderConfiguration::CHANGE_MUST_REOPEN) {
mEventHub->requestReopenDevices();
} else {
for (size_t i = 0; i < mDevices.size(); i++) {
InputDevice* device = mDevices.valueAt(i);
- device->configure(&mConfig, changes);
+ device->configure(now, &mConfig, changes);
}
}
}
@@ -861,7 +895,7 @@ void InputDevice::addMapper(InputMapper* mapper) {
mMappers.add(mapper);
}
-void InputDevice::configure(const InputReaderConfiguration* config, uint32_t changes) {
+void InputDevice::configure(nsecs_t when, const InputReaderConfiguration* config, uint32_t changes) {
mSources = 0;
if (!isIgnored()) {
@@ -872,18 +906,22 @@ void InputDevice::configure(const InputReaderConfiguration* config, uint32_t cha
size_t numMappers = mMappers.size();
for (size_t i = 0; i < numMappers; i++) {
InputMapper* mapper = mMappers[i];
- mapper->configure(config, changes);
+ mapper->configure(when, config, changes);
mSources |= mapper->getSources();
}
}
}
-void InputDevice::reset() {
+void InputDevice::reset(nsecs_t when) {
size_t numMappers = mMappers.size();
for (size_t i = 0; i < numMappers; i++) {
InputMapper* mapper = mMappers[i];
- mapper->reset();
+ mapper->reset(when);
}
+
+ mContext->updateGlobalMetaState();
+
+ notifyReset(when);
}
void InputDevice::process(const RawEvent* rawEvents, size_t count) {
@@ -915,7 +953,7 @@ void InputDevice::process(const RawEvent* rawEvents, size_t count) {
} else if (rawEvent->type == EV_SYN && rawEvent->scanCode == SYN_DROPPED) {
LOGI("Detected input event buffer overrun for device %s.", mName.string());
mDropUntilNextSync = true;
- reset();
+ reset(rawEvent->when);
} else {
for (size_t i = 0; i < numMappers; i++) {
InputMapper* mapper = mMappers[i];
@@ -1001,6 +1039,11 @@ void InputDevice::fadePointer() {
}
}
+void InputDevice::notifyReset(nsecs_t when) {
+ NotifyDeviceResetArgs args(when, mId);
+ mContext->getListener()->notifyDeviceReset(&args);
+}
+
// --- CursorButtonAccumulator ---
@@ -1008,6 +1051,17 @@ CursorButtonAccumulator::CursorButtonAccumulator() {
clearButtons();
}
+void CursorButtonAccumulator::reset(InputDevice* device) {
+ mBtnLeft = device->isKeyPressed(BTN_LEFT);
+ mBtnRight = device->isKeyPressed(BTN_RIGHT);
+ mBtnMiddle = device->isKeyPressed(BTN_MIDDLE);
+ mBtnBack = device->isKeyPressed(BTN_BACK);
+ mBtnSide = device->isKeyPressed(BTN_SIDE);
+ mBtnForward = device->isKeyPressed(BTN_FORWARD);
+ mBtnExtra = device->isKeyPressed(BTN_EXTRA);
+ mBtnTask = device->isKeyPressed(BTN_TASK);
+}
+
void CursorButtonAccumulator::clearButtons() {
mBtnLeft = 0;
mBtnRight = 0;
@@ -1073,21 +1127,17 @@ uint32_t CursorButtonAccumulator::getButtonState() const {
// --- CursorMotionAccumulator ---
-CursorMotionAccumulator::CursorMotionAccumulator() :
- mHaveRelWheel(false), mHaveRelHWheel(false) {
+CursorMotionAccumulator::CursorMotionAccumulator() {
clearRelativeAxes();
}
-void CursorMotionAccumulator::configure(InputDevice* device) {
- mHaveRelWheel = device->getEventHub()->hasRelativeAxis(device->getId(), REL_WHEEL);
- mHaveRelHWheel = device->getEventHub()->hasRelativeAxis(device->getId(), REL_HWHEEL);
+void CursorMotionAccumulator::reset(InputDevice* device) {
+ clearRelativeAxes();
}
void CursorMotionAccumulator::clearRelativeAxes() {
mRelX = 0;
mRelY = 0;
- mRelWheel = 0;
- mRelHWheel = 0;
}
void CursorMotionAccumulator::process(const RawEvent* rawEvent) {
@@ -1099,6 +1149,39 @@ void CursorMotionAccumulator::process(const RawEvent* rawEvent) {
case REL_Y:
mRelY = rawEvent->value;
break;
+ }
+ }
+}
+
+void CursorMotionAccumulator::finishSync() {
+ clearRelativeAxes();
+}
+
+
+// --- CursorScrollAccumulator ---
+
+CursorScrollAccumulator::CursorScrollAccumulator() :
+ mHaveRelWheel(false), mHaveRelHWheel(false) {
+ clearRelativeAxes();
+}
+
+void CursorScrollAccumulator::configure(InputDevice* device) {
+ mHaveRelWheel = device->getEventHub()->hasRelativeAxis(device->getId(), REL_WHEEL);
+ mHaveRelHWheel = device->getEventHub()->hasRelativeAxis(device->getId(), REL_HWHEEL);
+}
+
+void CursorScrollAccumulator::reset(InputDevice* device) {
+ clearRelativeAxes();
+}
+
+void CursorScrollAccumulator::clearRelativeAxes() {
+ mRelWheel = 0;
+ mRelHWheel = 0;
+}
+
+void CursorScrollAccumulator::process(const RawEvent* rawEvent) {
+ if (rawEvent->type == EV_REL) {
+ switch (rawEvent->scanCode) {
case REL_WHEEL:
mRelWheel = rawEvent->value;
break;
@@ -1109,6 +1192,10 @@ void CursorMotionAccumulator::process(const RawEvent* rawEvent) {
}
}
+void CursorScrollAccumulator::finishSync() {
+ clearRelativeAxes();
+}
+
// --- TouchButtonAccumulator ---
@@ -1118,7 +1205,21 @@ TouchButtonAccumulator::TouchButtonAccumulator() :
}
void TouchButtonAccumulator::configure(InputDevice* device) {
- mHaveBtnTouch = device->getEventHub()->hasScanCode(device->getId(), BTN_TOUCH);
+ mHaveBtnTouch = device->hasKey(BTN_TOUCH);
+}
+
+void TouchButtonAccumulator::reset(InputDevice* device) {
+ mBtnTouch = device->isKeyPressed(BTN_TOUCH);
+ mBtnStylus = device->isKeyPressed(BTN_STYLUS);
+ mBtnStylus2 = device->isKeyPressed(BTN_STYLUS);
+ mBtnToolFinger = device->isKeyPressed(BTN_TOOL_FINGER);
+ mBtnToolPen = device->isKeyPressed(BTN_TOOL_PEN);
+ mBtnToolRubber = device->isKeyPressed(BTN_TOOL_RUBBER);
+ mBtnToolBrush = device->isKeyPressed(BTN_TOOL_BRUSH);
+ mBtnToolPencil = device->isKeyPressed(BTN_TOOL_PENCIL);
+ mBtnToolAirbrush = device->isKeyPressed(BTN_TOOL_AIRBRUSH);
+ mBtnToolMouse = device->isKeyPressed(BTN_TOOL_MOUSE);
+ mBtnToolLens = device->isKeyPressed(BTN_TOOL_LENS);
}
void TouchButtonAccumulator::clearButtons() {
@@ -1128,6 +1229,11 @@ void TouchButtonAccumulator::clearButtons() {
mBtnToolFinger = 0;
mBtnToolPen = 0;
mBtnToolRubber = 0;
+ mBtnToolBrush = 0;
+ mBtnToolPencil = 0;
+ mBtnToolAirbrush = 0;
+ mBtnToolMouse = 0;
+ mBtnToolLens = 0;
}
void TouchButtonAccumulator::process(const RawEvent* rawEvent) {
@@ -1151,6 +1257,21 @@ void TouchButtonAccumulator::process(const RawEvent* rawEvent) {
case BTN_TOOL_RUBBER:
mBtnToolRubber = rawEvent->value;
break;
+ case BTN_TOOL_BRUSH:
+ mBtnToolBrush = rawEvent->value;
+ break;
+ case BTN_TOOL_PENCIL:
+ mBtnToolPencil = rawEvent->value;
+ break;
+ case BTN_TOOL_AIRBRUSH:
+ mBtnToolAirbrush = rawEvent->value;
+ break;
+ case BTN_TOOL_MOUSE:
+ mBtnToolMouse = rawEvent->value;
+ break;
+ case BTN_TOOL_LENS:
+ mBtnToolLens = rawEvent->value;
+ break;
}
}
}
@@ -1167,10 +1288,13 @@ uint32_t TouchButtonAccumulator::getButtonState() const {
}
int32_t TouchButtonAccumulator::getToolType() const {
+ if (mBtnToolMouse || mBtnToolLens) {
+ return AMOTION_EVENT_TOOL_TYPE_MOUSE;
+ }
if (mBtnToolRubber) {
return AMOTION_EVENT_TOOL_TYPE_ERASER;
}
- if (mBtnToolPen) {
+ if (mBtnToolPen || mBtnToolBrush || mBtnToolPencil || mBtnToolAirbrush) {
return AMOTION_EVENT_TOOL_TYPE_STYLUS;
}
if (mBtnToolFinger) {
@@ -1180,7 +1304,9 @@ int32_t TouchButtonAccumulator::getToolType() const {
}
bool TouchButtonAccumulator::isToolActive() const {
- return mBtnTouch || mBtnToolFinger || mBtnToolPen || mBtnToolRubber;
+ return mBtnTouch || mBtnToolFinger || mBtnToolPen || mBtnToolRubber
+ || mBtnToolBrush || mBtnToolPencil || mBtnToolAirbrush
+ || mBtnToolMouse || mBtnToolLens;
}
bool TouchButtonAccumulator::isHovering() const {
@@ -1204,6 +1330,8 @@ void RawPointerAxes::clear() {
toolMinor.clear();
orientation.clear();
distance.clear();
+ tiltX.clear();
+ tiltY.clear();
trackingId.clear();
slot.clear();
}
@@ -1284,12 +1412,24 @@ SingleTouchMotionAccumulator::SingleTouchMotionAccumulator() {
clearAbsoluteAxes();
}
+void SingleTouchMotionAccumulator::reset(InputDevice* device) {
+ mAbsX = device->getAbsoluteAxisValue(ABS_X);
+ mAbsY = device->getAbsoluteAxisValue(ABS_Y);
+ mAbsPressure = device->getAbsoluteAxisValue(ABS_PRESSURE);
+ mAbsToolWidth = device->getAbsoluteAxisValue(ABS_TOOL_WIDTH);
+ mAbsDistance = device->getAbsoluteAxisValue(ABS_DISTANCE);
+ mAbsTiltX = device->getAbsoluteAxisValue(ABS_TILT_X);
+ mAbsTiltY = device->getAbsoluteAxisValue(ABS_TILT_Y);
+}
+
void SingleTouchMotionAccumulator::clearAbsoluteAxes() {
mAbsX = 0;
mAbsY = 0;
mAbsPressure = 0;
mAbsToolWidth = 0;
mAbsDistance = 0;
+ mAbsTiltX = 0;
+ mAbsTiltY = 0;
}
void SingleTouchMotionAccumulator::process(const RawEvent* rawEvent) {
@@ -1310,6 +1450,12 @@ void SingleTouchMotionAccumulator::process(const RawEvent* rawEvent) {
case ABS_DISTANCE:
mAbsDistance = rawEvent->value;
break;
+ case ABS_TILT_X:
+ mAbsTiltX = rawEvent->value;
+ break;
+ case ABS_TILT_Y:
+ mAbsTiltY = rawEvent->value;
+ break;
}
}
}
@@ -1333,9 +1479,37 @@ void MultiTouchMotionAccumulator::configure(size_t slotCount, bool usingSlotsPro
mSlots = new Slot[slotCount];
}
+void MultiTouchMotionAccumulator::reset(InputDevice* device) {
+ // Unfortunately there is no way to read the initial contents of the slots.
+ // So when we reset the accumulator, we must assume they are all zeroes.
+ if (mUsingSlotsProtocol) {
+ // Query the driver for the current slot index and use it as the initial slot
+ // before we start reading events from the device. It is possible that the
+ // current slot index will not be the same as it was when the first event was
+ // written into the evdev buffer, which means the input mapper could start
+ // out of sync with the initial state of the events in the evdev buffer.
+ // In the extremely unlikely case that this happens, the data from
+ // two slots will be confused until the next ABS_MT_SLOT event is received.
+ // This can cause the touch point to "jump", but at least there will be
+ // no stuck touches.
+ int32_t initialSlot;
+ status_t status = device->getEventHub()->getAbsoluteAxisValue(device->getId(),
+ ABS_MT_SLOT, &initialSlot);
+ if (status) {
+ LOGD("Could not retrieve current multitouch slot index. status=%d", status);
+ initialSlot = -1;
+ }
+ clearSlots(initialSlot);
+ } else {
+ clearSlots(-1);
+ }
+}
+
void MultiTouchMotionAccumulator::clearSlots(int32_t initialSlot) {
- for (size_t i = 0; i < mSlotCount; i++) {
- mSlots[i].clear();
+ if (mSlots) {
+ for (size_t i = 0; i < mSlotCount; i++) {
+ mSlots[i].clear();
+ }
}
mCurrentSlot = initialSlot;
}
@@ -1425,6 +1599,12 @@ void MultiTouchMotionAccumulator::process(const RawEvent* rawEvent) {
}
}
+void MultiTouchMotionAccumulator::finishSync() {
+ if (!mUsingSlotsProtocol) {
+ clearSlots(-1);
+ }
+}
+
// --- MultiTouchMotionAccumulator::Slot ---
@@ -1479,10 +1659,11 @@ void InputMapper::populateDeviceInfo(InputDeviceInfo* info) {
void InputMapper::dump(String8& dump) {
}
-void InputMapper::configure(const InputReaderConfiguration* config, uint32_t changes) {
+void InputMapper::configure(nsecs_t when,
+ const InputReaderConfiguration* config, uint32_t changes) {
}
-void InputMapper::reset() {
+void InputMapper::reset(nsecs_t when) {
}
void InputMapper::timeoutExpired(nsecs_t when) {
@@ -1564,17 +1745,11 @@ KeyboardInputMapper::KeyboardInputMapper(InputDevice* device,
uint32_t source, int32_t keyboardType) :
InputMapper(device), mSource(source),
mKeyboardType(keyboardType) {
- initialize();
}
KeyboardInputMapper::~KeyboardInputMapper() {
}
-void KeyboardInputMapper::initialize() {
- mMetaState = AMETA_NONE;
- mDownTime = 0;
-}
-
uint32_t KeyboardInputMapper::getSources() {
return mSource;
}
@@ -1589,21 +1764,31 @@ void KeyboardInputMapper::dump(String8& dump) {
dump.append(INDENT2 "Keyboard Input Mapper:\n");
dumpParameters(dump);
dump.appendFormat(INDENT3 "KeyboardType: %d\n", mKeyboardType);
+ dump.appendFormat(INDENT3 "Orientation: %d\n", mOrientation);
dump.appendFormat(INDENT3 "KeyDowns: %d keys currently down\n", mKeyDowns.size());
dump.appendFormat(INDENT3 "MetaState: 0x%0x\n", mMetaState);
dump.appendFormat(INDENT3 "DownTime: %lld\n", mDownTime);
}
-void KeyboardInputMapper::configure(const InputReaderConfiguration* config, uint32_t changes) {
- InputMapper::configure(config, changes);
+void KeyboardInputMapper::configure(nsecs_t when,
+ const InputReaderConfiguration* config, uint32_t changes) {
+ InputMapper::configure(when, config, changes);
if (!changes) { // first time only
// Configure basic parameters.
configureParameters();
+ }
- // Reset LEDs.
- resetLedState();
+ if (!changes || (changes & InputReaderConfiguration::CHANGE_DISPLAY_INFO)) {
+ if (mParameters.orientationAware && mParameters.associatedDisplayId >= 0) {
+ if (!config->getDisplayInfo(mParameters.associatedDisplayId,
+ false /*external*/, NULL, NULL, &mOrientation)) {
+ mOrientation = DISPLAY_ORIENTATION_0;
+ }
+ } else {
+ mOrientation = DISPLAY_ORIENTATION_0;
+ }
}
}
@@ -1626,19 +1811,14 @@ void KeyboardInputMapper::dumpParameters(String8& dump) {
toString(mParameters.orientationAware));
}
-void KeyboardInputMapper::reset() {
- // Synthesize key up event on reset if keys are currently down.
- while (!mKeyDowns.isEmpty()) {
- const KeyDown& keyDown = mKeyDowns.top();
- nsecs_t when = systemTime(SYSTEM_TIME_MONOTONIC);
- processKey(when, false, keyDown.keyCode, keyDown.scanCode, 0);
- }
+void KeyboardInputMapper::reset(nsecs_t when) {
+ mMetaState = AMETA_NONE;
+ mDownTime = 0;
+ mKeyDowns.clear();
- initialize();
resetLedState();
- InputMapper::reset();
- getContext()->updateGlobalMetaState();
+ InputMapper::reset(when);
}
void KeyboardInputMapper::process(const RawEvent* rawEvent) {
@@ -1666,15 +1846,8 @@ void KeyboardInputMapper::processKey(nsecs_t when, bool down, int32_t keyCode,
if (down) {
// Rotate key codes according to orientation if needed.
- // Note: getDisplayInfo is non-reentrant so we can continue holding the lock.
if (mParameters.orientationAware && mParameters.associatedDisplayId >= 0) {
- int32_t orientation;
- if (!getPolicy()->getDisplayInfo(mParameters.associatedDisplayId,
- false /*external*/, NULL, NULL, & orientation)) {
- orientation = DISPLAY_ORIENTATION_0;
- }
-
- keyCode = rotateKeyCode(keyCode, orientation);
+ keyCode = rotateKeyCode(keyCode, mOrientation);
}
// Add key down.
@@ -1813,7 +1986,6 @@ void KeyboardInputMapper::updateLedStateForModifier(LedState& ledState,
CursorInputMapper::CursorInputMapper(InputDevice* device) :
InputMapper(device) {
- initialize();
}
CursorInputMapper::~CursorInputMapper() {
@@ -1838,10 +2010,10 @@ void CursorInputMapper::populateDeviceInfo(InputDeviceInfo* info) {
}
info->addMotionRange(AMOTION_EVENT_AXIS_PRESSURE, mSource, 0.0f, 1.0f, 0.0f, 0.0f);
- if (mCursorMotionAccumulator.haveRelativeVWheel()) {
+ if (mCursorScrollAccumulator.haveRelativeVWheel()) {
info->addMotionRange(AMOTION_EVENT_AXIS_VSCROLL, mSource, -1.0f, 1.0f, 0.0f, 0.0f);
}
- if (mCursorMotionAccumulator.haveRelativeHWheel()) {
+ if (mCursorScrollAccumulator.haveRelativeHWheel()) {
info->addMotionRange(AMOTION_EVENT_AXIS_HSCROLL, mSource, -1.0f, 1.0f, 0.0f, 0.0f);
}
}
@@ -1854,21 +2026,23 @@ void CursorInputMapper::dump(String8& dump) {
dump.appendFormat(INDENT3 "XPrecision: %0.3f\n", mXPrecision);
dump.appendFormat(INDENT3 "YPrecision: %0.3f\n", mYPrecision);
dump.appendFormat(INDENT3 "HaveVWheel: %s\n",
- toString(mCursorMotionAccumulator.haveRelativeVWheel()));
+ toString(mCursorScrollAccumulator.haveRelativeVWheel()));
dump.appendFormat(INDENT3 "HaveHWheel: %s\n",
- toString(mCursorMotionAccumulator.haveRelativeHWheel()));
+ toString(mCursorScrollAccumulator.haveRelativeHWheel()));
dump.appendFormat(INDENT3 "VWheelScale: %0.3f\n", mVWheelScale);
dump.appendFormat(INDENT3 "HWheelScale: %0.3f\n", mHWheelScale);
+ dump.appendFormat(INDENT3 "Orientation: %d\n", mOrientation);
dump.appendFormat(INDENT3 "ButtonState: 0x%08x\n", mButtonState);
dump.appendFormat(INDENT3 "Down: %s\n", toString(isPointerDown(mButtonState)));
dump.appendFormat(INDENT3 "DownTime: %lld\n", mDownTime);
}
-void CursorInputMapper::configure(const InputReaderConfiguration* config, uint32_t changes) {
- InputMapper::configure(config, changes);
+void CursorInputMapper::configure(nsecs_t when,
+ const InputReaderConfiguration* config, uint32_t changes) {
+ InputMapper::configure(when, config, changes);
if (!changes) { // first time only
- mCursorMotionAccumulator.configure(getDevice());
+ mCursorScrollAccumulator.configure(getDevice());
// Configure basic parameters.
configureParameters();
@@ -1901,6 +2075,17 @@ void CursorInputMapper::configure(const InputReaderConfiguration* config, uint32
mWheelXVelocityControl.setParameters(config->wheelVelocityControlParameters);
mWheelYVelocityControl.setParameters(config->wheelVelocityControlParameters);
}
+
+ if (!changes || (changes & InputReaderConfiguration::CHANGE_DISPLAY_INFO)) {
+ if (mParameters.orientationAware && mParameters.associatedDisplayId >= 0) {
+ if (!config->getDisplayInfo(mParameters.associatedDisplayId,
+ false /*external*/, NULL, NULL, &mOrientation)) {
+ mOrientation = DISPLAY_ORIENTATION_0;
+ }
+ } else {
+ mOrientation = DISPLAY_ORIENTATION_0;
+ }
+ }
}
void CursorInputMapper::configureParameters() {
@@ -1944,34 +2129,25 @@ void CursorInputMapper::dumpParameters(String8& dump) {
toString(mParameters.orientationAware));
}
-void CursorInputMapper::initialize() {
- mCursorButtonAccumulator.clearButtons();
- mCursorMotionAccumulator.clearRelativeAxes();
-
+void CursorInputMapper::reset(nsecs_t when) {
mButtonState = 0;
mDownTime = 0;
-}
-void CursorInputMapper::reset() {
- // Reset velocity.
mPointerVelocityControl.reset();
mWheelXVelocityControl.reset();
mWheelYVelocityControl.reset();
- // Synthesize button up event on reset.
- nsecs_t when = systemTime(SYSTEM_TIME_MONOTONIC);
- mCursorButtonAccumulator.clearButtons();
- mCursorMotionAccumulator.clearRelativeAxes();
- sync(when);
-
- initialize();
+ mCursorButtonAccumulator.reset(getDevice());
+ mCursorMotionAccumulator.reset(getDevice());
+ mCursorScrollAccumulator.reset(getDevice());
- InputMapper::reset();
+ InputMapper::reset(when);
}
void CursorInputMapper::process(const RawEvent* rawEvent) {
mCursorButtonAccumulator.process(rawEvent);
mCursorMotionAccumulator.process(rawEvent);
+ mCursorScrollAccumulator.process(rawEvent);
if (rawEvent->type == EV_SYN && rawEvent->scanCode == SYN_REPORT) {
sync(rawEvent->when);
@@ -2001,19 +2177,13 @@ void CursorInputMapper::sync(nsecs_t when) {
float deltaY = mCursorMotionAccumulator.getRelativeY() * mYScale;
bool moved = deltaX != 0 || deltaY != 0;
+ // Rotate delta according to orientation if needed.
if (mParameters.orientationAware && mParameters.associatedDisplayId >= 0
&& (deltaX != 0.0f || deltaY != 0.0f)) {
- // Rotate motion based on display orientation if needed.
- // Note: getDisplayInfo is non-reentrant so we can continue holding the lock.
- int32_t orientation;
- if (! getPolicy()->getDisplayInfo(mParameters.associatedDisplayId,
- false /*external*/, NULL, NULL, & orientation)) {
- orientation = DISPLAY_ORIENTATION_0;
- }
-
- rotateDelta(orientation, &deltaX, &deltaY);
+ rotateDelta(mOrientation, &deltaX, &deltaY);
}
+ // Move the pointer.
PointerProperties pointerProperties;
pointerProperties.clear();
pointerProperties.id = 0;
@@ -2022,8 +2192,8 @@ void CursorInputMapper::sync(nsecs_t when) {
PointerCoords pointerCoords;
pointerCoords.clear();
- float vscroll = mCursorMotionAccumulator.getRelativeVWheel();
- float hscroll = mCursorMotionAccumulator.getRelativeHWheel();
+ float vscroll = mCursorScrollAccumulator.getRelativeVWheel();
+ float hscroll = mCursorScrollAccumulator.getRelativeHWheel();
bool scrolled = vscroll != 0 || hscroll != 0;
mWheelYVelocityControl.move(when, NULL, &vscroll);
@@ -2115,7 +2285,8 @@ void CursorInputMapper::sync(nsecs_t when) {
synthesizeButtonKeys(getContext(), AKEY_EVENT_ACTION_UP, when, getDeviceId(), mSource,
policyFlags, lastButtonState, currentButtonState);
- mCursorMotionAccumulator.clearRelativeAxes();
+ mCursorMotionAccumulator.finishSync();
+ mCursorScrollAccumulator.finishSync();
}
int32_t CursorInputMapper::getScanCodeState(uint32_t sourceMask, int32_t scanCode) {
@@ -2137,65 +2308,57 @@ void CursorInputMapper::fadePointer() {
TouchInputMapper::TouchInputMapper(InputDevice* device) :
InputMapper(device),
+ mSource(0), mDeviceMode(DEVICE_MODE_DISABLED),
mSurfaceOrientation(-1), mSurfaceWidth(-1), mSurfaceHeight(-1) {
- initialize();
}
TouchInputMapper::~TouchInputMapper() {
}
uint32_t TouchInputMapper::getSources() {
- return mTouchSource | mPointerSource;
+ return mSource;
}
void TouchInputMapper::populateDeviceInfo(InputDeviceInfo* info) {
InputMapper::populateDeviceInfo(info);
- // Ensure surface information is up to date so that orientation changes are
- // noticed immediately.
- if (!configureSurface()) {
- return;
- }
-
- info->addMotionRange(mOrientedRanges.x);
- info->addMotionRange(mOrientedRanges.y);
-
- if (mOrientedRanges.havePressure) {
+ if (mDeviceMode != DEVICE_MODE_DISABLED) {
+ info->addMotionRange(mOrientedRanges.x);
+ info->addMotionRange(mOrientedRanges.y);
info->addMotionRange(mOrientedRanges.pressure);
- }
- if (mOrientedRanges.haveSize) {
- info->addMotionRange(mOrientedRanges.size);
- }
+ if (mOrientedRanges.haveSize) {
+ info->addMotionRange(mOrientedRanges.size);
+ }
- if (mOrientedRanges.haveTouchSize) {
- info->addMotionRange(mOrientedRanges.touchMajor);
- info->addMotionRange(mOrientedRanges.touchMinor);
- }
+ if (mOrientedRanges.haveTouchSize) {
+ info->addMotionRange(mOrientedRanges.touchMajor);
+ info->addMotionRange(mOrientedRanges.touchMinor);
+ }
- if (mOrientedRanges.haveToolSize) {
- info->addMotionRange(mOrientedRanges.toolMajor);
- info->addMotionRange(mOrientedRanges.toolMinor);
- }
+ if (mOrientedRanges.haveToolSize) {
+ info->addMotionRange(mOrientedRanges.toolMajor);
+ info->addMotionRange(mOrientedRanges.toolMinor);
+ }
- if (mOrientedRanges.haveOrientation) {
- info->addMotionRange(mOrientedRanges.orientation);
- }
+ if (mOrientedRanges.haveOrientation) {
+ info->addMotionRange(mOrientedRanges.orientation);
+ }
- if (mOrientedRanges.haveDistance) {
- info->addMotionRange(mOrientedRanges.distance);
- }
+ if (mOrientedRanges.haveDistance) {
+ info->addMotionRange(mOrientedRanges.distance);
+ }
- if (mPointerController != NULL) {
- float minX, minY, maxX, maxY;
- if (mPointerController->getBounds(&minX, &minY, &maxX, &maxY)) {
- info->addMotionRange(AMOTION_EVENT_AXIS_X, mPointerSource,
- minX, maxX, 0.0f, 0.0f);
- info->addMotionRange(AMOTION_EVENT_AXIS_Y, mPointerSource,
- minY, maxY, 0.0f, 0.0f);
+ if (mOrientedRanges.haveTilt) {
+ info->addMotionRange(mOrientedRanges.tilt);
+ }
+
+ if (mCursorScrollAccumulator.haveRelativeVWheel()) {
+ info->addMotionRange(AMOTION_EVENT_AXIS_VSCROLL, mSource, -1.0f, 1.0f, 0.0f, 0.0f);
+ }
+ if (mCursorScrollAccumulator.haveRelativeHWheel()) {
+ info->addMotionRange(AMOTION_EVENT_AXIS_HSCROLL, mSource, -1.0f, 1.0f, 0.0f, 0.0f);
}
- info->addMotionRange(AMOTION_EVENT_AXIS_PRESSURE, mPointerSource,
- 0.0f, 1.0f, 0.0f, 0.0f);
}
}
@@ -2215,8 +2378,14 @@ void TouchInputMapper::dump(String8& dump) {
dump.appendFormat(INDENT4 "GeometricScale: %0.3f\n", mGeometricScale);
dump.appendFormat(INDENT4 "PressureScale: %0.3f\n", mPressureScale);
dump.appendFormat(INDENT4 "SizeScale: %0.3f\n", mSizeScale);
+ dump.appendFormat(INDENT4 "OrientationCenter: %0.3f\n", mOrientationCenter);
dump.appendFormat(INDENT4 "OrientationScale: %0.3f\n", mOrientationScale);
dump.appendFormat(INDENT4 "DistanceScale: %0.3f\n", mDistanceScale);
+ dump.appendFormat(INDENT4 "HaveTilt: %s\n", toString(mHaveTilt));
+ dump.appendFormat(INDENT4 "TiltXCenter: %0.3f\n", mTiltXCenter);
+ dump.appendFormat(INDENT4 "TiltXScale: %0.3f\n", mTiltXScale);
+ dump.appendFormat(INDENT4 "TiltYCenter: %0.3f\n", mTiltYCenter);
+ dump.appendFormat(INDENT4 "TiltYScale: %0.3f\n", mTiltYScale);
dump.appendFormat(INDENT3 "Last Button State: 0x%08x\n", mLastButtonState);
@@ -2226,11 +2395,12 @@ void TouchInputMapper::dump(String8& dump) {
const RawPointerData::Pointer& pointer = mLastRawPointerData.pointers[i];
dump.appendFormat(INDENT4 "[%d]: id=%d, x=%d, y=%d, pressure=%d, "
"touchMajor=%d, touchMinor=%d, toolMajor=%d, toolMinor=%d, "
- "orientation=%d, distance=%d, toolType=%d, isHovering=%s\n", i,
+ "orientation=%d, tiltX=%d, tiltY=%d, distance=%d, "
+ "toolType=%d, isHovering=%s\n", i,
pointer.id, pointer.x, pointer.y, pointer.pressure,
pointer.touchMajor, pointer.touchMinor,
pointer.toolMajor, pointer.toolMinor,
- pointer.orientation, pointer.distance,
+ pointer.orientation, pointer.tiltX, pointer.tiltY, pointer.distance,
pointer.toolType, toString(pointer.isHovering));
}
@@ -2241,7 +2411,8 @@ void TouchInputMapper::dump(String8& dump) {
const PointerCoords& pointerCoords = mLastCookedPointerData.pointerCoords[i];
dump.appendFormat(INDENT4 "[%d]: id=%d, x=%0.3f, y=%0.3f, pressure=%0.3f, "
"touchMajor=%0.3f, touchMinor=%0.3f, toolMajor=%0.3f, toolMinor=%0.3f, "
- "orientation=%0.3f, distance=%0.3f, toolType=%d, isHovering=%s\n", i,
+ "orientation=%0.3f, tilt=%0.3f, distance=%0.3f, "
+ "toolType=%d, isHovering=%s\n", i,
pointerProperties.id,
pointerCoords.getX(),
pointerCoords.getY(),
@@ -2251,50 +2422,30 @@ void TouchInputMapper::dump(String8& dump) {
pointerCoords.getAxisValue(AMOTION_EVENT_AXIS_TOOL_MAJOR),
pointerCoords.getAxisValue(AMOTION_EVENT_AXIS_TOOL_MINOR),
pointerCoords.getAxisValue(AMOTION_EVENT_AXIS_ORIENTATION),
+ pointerCoords.getAxisValue(AMOTION_EVENT_AXIS_TILT),
pointerCoords.getAxisValue(AMOTION_EVENT_AXIS_DISTANCE),
pointerProperties.toolType,
toString(mLastCookedPointerData.isHovering(i)));
}
- if (mParameters.deviceType == Parameters::DEVICE_TYPE_POINTER) {
+ if (mDeviceMode == DEVICE_MODE_POINTER) {
dump.appendFormat(INDENT3 "Pointer Gesture Detector:\n");
dump.appendFormat(INDENT4 "XMovementScale: %0.3f\n",
- mPointerGestureXMovementScale);
+ mPointerXMovementScale);
dump.appendFormat(INDENT4 "YMovementScale: %0.3f\n",
- mPointerGestureYMovementScale);
+ mPointerYMovementScale);
dump.appendFormat(INDENT4 "XZoomScale: %0.3f\n",
- mPointerGestureXZoomScale);
+ mPointerXZoomScale);
dump.appendFormat(INDENT4 "YZoomScale: %0.3f\n",
- mPointerGestureYZoomScale);
+ mPointerYZoomScale);
dump.appendFormat(INDENT4 "MaxSwipeWidth: %f\n",
mPointerGestureMaxSwipeWidth);
}
}
-void TouchInputMapper::initialize() {
- mCurrentRawPointerData.clear();
- mLastRawPointerData.clear();
- mCurrentCookedPointerData.clear();
- mLastCookedPointerData.clear();
- mCurrentButtonState = 0;
- mLastButtonState = 0;
- mSentHoverEnter = false;
- mDownTime = 0;
-
- mCurrentVirtualKey.down = false;
-
- mOrientedRanges.havePressure = false;
- mOrientedRanges.haveSize = false;
- mOrientedRanges.haveTouchSize = false;
- mOrientedRanges.haveToolSize = false;
- mOrientedRanges.haveOrientation = false;
- mOrientedRanges.haveDistance = false;
-
- mPointerGesture.reset();
-}
-
-void TouchInputMapper::configure(const InputReaderConfiguration* config, uint32_t changes) {
- InputMapper::configure(config, changes);
+void TouchInputMapper::configure(nsecs_t when,
+ const InputReaderConfiguration* config, uint32_t changes) {
+ InputMapper::configure(when, config, changes);
mConfig = *config;
@@ -2302,23 +2453,9 @@ void TouchInputMapper::configure(const InputReaderConfiguration* config, uint32_
// Configure basic parameters.
configureParameters();
- // Configure sources.
- switch (mParameters.deviceType) {
- case Parameters::DEVICE_TYPE_TOUCH_SCREEN:
- mTouchSource = AINPUT_SOURCE_TOUCHSCREEN;
- mPointerSource = 0;
- break;
- case Parameters::DEVICE_TYPE_TOUCH_PAD:
- mTouchSource = AINPUT_SOURCE_TOUCHPAD;
- mPointerSource = 0;
- break;
- case Parameters::DEVICE_TYPE_POINTER:
- mTouchSource = AINPUT_SOURCE_TOUCHPAD;
- mPointerSource = AINPUT_SOURCE_MOUSE;
- break;
- default:
- LOG_ASSERT(false);
- }
+ // Configure common accumulators.
+ mCursorScrollAccumulator.configure(getDevice());
+ mTouchButtonAccumulator.configure(getDevice());
// Configure absolute axis information.
configureRawPointerAxes();
@@ -2326,19 +2463,27 @@ void TouchInputMapper::configure(const InputReaderConfiguration* config, uint32_
// Prepare input device calibration.
parseCalibration();
resolveCalibration();
-
- // Configure surface dimensions and orientation.
- configureSurface();
}
if (!changes || (changes & InputReaderConfiguration::CHANGE_POINTER_SPEED)) {
- mPointerGesture.pointerVelocityControl.setParameters(
- mConfig.pointerVelocityControlParameters);
+ // Update pointer speed.
+ mPointerVelocityControl.setParameters(mConfig.pointerVelocityControlParameters);
+ mWheelXVelocityControl.setParameters(mConfig.wheelVelocityControlParameters);
+ mWheelYVelocityControl.setParameters(mConfig.wheelVelocityControlParameters);
}
- if (!changes || (changes & InputReaderConfiguration::CHANGE_POINTER_GESTURE_ENABLEMENT)) {
- // Reset the touch screen when pointer gesture enablement changes.
- reset();
+ bool resetNeeded = false;
+ if (!changes || (changes & (InputReaderConfiguration::CHANGE_DISPLAY_INFO
+ | InputReaderConfiguration::CHANGE_POINTER_GESTURE_ENABLEMENT))) {
+ // Configure device sources, surface dimensions, orientation and
+ // scaling factors.
+ configureSurface(when, &resetNeeded);
+ }
+
+ if (changes && resetNeeded) {
+ // Send reset, unless this is the first time the device has been configured,
+ // in which case the reader will call reset itself after all mappers are ready.
+ getDevice()->notifyReset(when);
}
}
@@ -2435,8 +2580,8 @@ void TouchInputMapper::dumpParameters(String8& dump) {
LOG_ASSERT(false);
}
- dump.appendFormat(INDENT4 "AssociatedDisplayId: %d\n",
- mParameters.associatedDisplayId);
+ dump.appendFormat(INDENT4 "AssociatedDisplay: id=%d, isExternal=%s\n",
+ mParameters.associatedDisplayId, toString(mParameters.associatedDisplayIsExternal));
dump.appendFormat(INDENT4 "OrientationAware: %s\n",
toString(mParameters.orientationAware));
}
@@ -2456,47 +2601,79 @@ void TouchInputMapper::dumpRawPointerAxes(String8& dump) {
dumpRawAbsoluteAxisInfo(dump, mRawPointerAxes.toolMinor, "ToolMinor");
dumpRawAbsoluteAxisInfo(dump, mRawPointerAxes.orientation, "Orientation");
dumpRawAbsoluteAxisInfo(dump, mRawPointerAxes.distance, "Distance");
+ dumpRawAbsoluteAxisInfo(dump, mRawPointerAxes.tiltX, "TiltX");
+ dumpRawAbsoluteAxisInfo(dump, mRawPointerAxes.tiltY, "TiltY");
dumpRawAbsoluteAxisInfo(dump, mRawPointerAxes.trackingId, "TrackingId");
dumpRawAbsoluteAxisInfo(dump, mRawPointerAxes.slot, "Slot");
}
-bool TouchInputMapper::configureSurface() {
+void TouchInputMapper::configureSurface(nsecs_t when, bool* outResetNeeded) {
+ int32_t oldDeviceMode = mDeviceMode;
+
+ // Determine device mode.
+ if (mParameters.deviceType == Parameters::DEVICE_TYPE_POINTER
+ && mConfig.pointerGesturesEnabled) {
+ mSource = AINPUT_SOURCE_MOUSE;
+ mDeviceMode = DEVICE_MODE_POINTER;
+ } else if (mParameters.deviceType == Parameters::DEVICE_TYPE_TOUCH_SCREEN
+ && mParameters.associatedDisplayId >= 0) {
+ mSource = AINPUT_SOURCE_TOUCHSCREEN;
+ mDeviceMode = DEVICE_MODE_DIRECT;
+ } else {
+ mSource = AINPUT_SOURCE_TOUCHPAD;
+ mDeviceMode = DEVICE_MODE_UNSCALED;
+ }
+
// Ensure we have valid X and Y axes.
if (!mRawPointerAxes.x.valid || !mRawPointerAxes.y.valid) {
LOGW(INDENT "Touch device '%s' did not report support for X or Y axis! "
"The device will be inoperable.", getDeviceName().string());
- return false;
+ mDeviceMode = DEVICE_MODE_DISABLED;
+ return;
}
- // Update orientation and dimensions if needed.
- int32_t orientation = DISPLAY_ORIENTATION_0;
- int32_t width = mRawPointerAxes.x.maxValue - mRawPointerAxes.x.minValue + 1;
- int32_t height = mRawPointerAxes.y.maxValue - mRawPointerAxes.y.minValue + 1;
-
+ // Get associated display dimensions.
if (mParameters.associatedDisplayId >= 0) {
- // Note: getDisplayInfo is non-reentrant so we can continue holding the lock.
- if (! getPolicy()->getDisplayInfo(mParameters.associatedDisplayId,
+ if (!mConfig.getDisplayInfo(mParameters.associatedDisplayId,
mParameters.associatedDisplayIsExternal,
&mAssociatedDisplayWidth, &mAssociatedDisplayHeight,
&mAssociatedDisplayOrientation)) {
- return false;
+ LOGI(INDENT "Touch device '%s' could not query the properties of its associated "
+ "display %d. The device will be inoperable until the display size "
+ "becomes available.",
+ getDeviceName().string(), mParameters.associatedDisplayId);
+ mDeviceMode = DEVICE_MODE_DISABLED;
+ return;
}
+ }
- // A touch screen inherits the dimensions of the display.
- if (mParameters.deviceType == Parameters::DEVICE_TYPE_TOUCH_SCREEN) {
- width = mAssociatedDisplayWidth;
- height = mAssociatedDisplayHeight;
- }
+ // Configure dimensions.
+ int32_t width, height, orientation;
+ if (mDeviceMode == DEVICE_MODE_DIRECT || mDeviceMode == DEVICE_MODE_POINTER) {
+ width = mAssociatedDisplayWidth;
+ height = mAssociatedDisplayHeight;
+ orientation = mParameters.orientationAware ?
+ mAssociatedDisplayOrientation : DISPLAY_ORIENTATION_0;
+ } else {
+ width = mRawPointerAxes.x.maxValue - mRawPointerAxes.x.minValue + 1;
+ height = mRawPointerAxes.y.maxValue - mRawPointerAxes.y.minValue + 1;
+ orientation = DISPLAY_ORIENTATION_0;
+ }
+
+ // If moving between pointer modes, need to reset some state.
+ bool deviceModeChanged;
+ if (mDeviceMode != oldDeviceMode) {
+ deviceModeChanged = true;
- // The device inherits the orientation of the display if it is orientation aware.
- if (mParameters.orientationAware) {
- orientation = mAssociatedDisplayOrientation;
+ if (mDeviceMode == DEVICE_MODE_POINTER) {
+ if (mPointerController == NULL) {
+ mPointerController = getPolicy()->obtainPointerController(getDeviceId());
+ }
+ } else {
+ mPointerController.clear();
}
- }
- if (mParameters.deviceType == Parameters::DEVICE_TYPE_POINTER
- && mPointerController == NULL) {
- mPointerController = getPolicy()->obtainPointerController(getDeviceId());
+ mOrientedRanges.clear();
}
bool orientationChanged = mSurfaceOrientation != orientation;
@@ -2505,9 +2682,9 @@ bool TouchInputMapper::configureSurface() {
}
bool sizeChanged = mSurfaceWidth != width || mSurfaceHeight != height;
- if (sizeChanged) {
- LOGI("Device reconfigured: id=%d, name='%s', surface size is now %dx%d",
- getDeviceId(), getDeviceName().string(), width, height);
+ if (sizeChanged || deviceModeChanged) {
+ LOGI("Device reconfigured: id=%d, name='%s', surface size is now %dx%d, mode is %d",
+ getDeviceId(), getDeviceName().string(), width, height, mDeviceMode);
mSurfaceWidth = width;
mSurfaceHeight = height;
@@ -2519,9 +2696,9 @@ bool TouchInputMapper::configureSurface() {
mYPrecision = 1.0f / mYScale;
mOrientedRanges.x.axis = AMOTION_EVENT_AXIS_X;
- mOrientedRanges.x.source = mTouchSource;
+ mOrientedRanges.x.source = mSource;
mOrientedRanges.y.axis = AMOTION_EVENT_AXIS_Y;
- mOrientedRanges.y.source = mTouchSource;
+ mOrientedRanges.y.source = mSource;
configureVirtualKeys();
@@ -2550,7 +2727,7 @@ bool TouchInputMapper::configureSurface() {
mOrientedRanges.haveSize = true;
mOrientedRanges.touchMajor.axis = AMOTION_EVENT_AXIS_TOUCH_MAJOR;
- mOrientedRanges.touchMajor.source = mTouchSource;
+ mOrientedRanges.touchMajor.source = mSource;
mOrientedRanges.touchMajor.min = 0;
mOrientedRanges.touchMajor.max = diagonalSize;
mOrientedRanges.touchMajor.flat = 0;
@@ -2560,7 +2737,7 @@ bool TouchInputMapper::configureSurface() {
mOrientedRanges.touchMinor.axis = AMOTION_EVENT_AXIS_TOUCH_MINOR;
mOrientedRanges.toolMajor.axis = AMOTION_EVENT_AXIS_TOOL_MAJOR;
- mOrientedRanges.toolMajor.source = mTouchSource;
+ mOrientedRanges.toolMajor.source = mSource;
mOrientedRanges.toolMajor.min = 0;
mOrientedRanges.toolMajor.max = diagonalSize;
mOrientedRanges.toolMajor.flat = 0;
@@ -2570,7 +2747,7 @@ bool TouchInputMapper::configureSurface() {
mOrientedRanges.toolMinor.axis = AMOTION_EVENT_AXIS_TOOL_MINOR;
mOrientedRanges.size.axis = AMOTION_EVENT_AXIS_SIZE;
- mOrientedRanges.size.source = mTouchSource;
+ mOrientedRanges.size.source = mSource;
mOrientedRanges.size.min = 0;
mOrientedRanges.size.max = 1.0;
mOrientedRanges.size.flat = 0;
@@ -2581,44 +2758,77 @@ bool TouchInputMapper::configureSurface() {
// Pressure factors.
mPressureScale = 0;
- if (mCalibration.pressureCalibration != Calibration::PRESSURE_CALIBRATION_NONE) {
- if (mCalibration.pressureCalibration == Calibration::PRESSURE_CALIBRATION_PHYSICAL
- || mCalibration.pressureCalibration
- == Calibration::PRESSURE_CALIBRATION_AMPLITUDE) {
- if (mCalibration.havePressureScale) {
- mPressureScale = mCalibration.pressureScale;
- } else if (mRawPointerAxes.pressure.valid
- && mRawPointerAxes.pressure.maxValue != 0) {
- mPressureScale = 1.0f / mRawPointerAxes.pressure.maxValue;
- }
+ if (mCalibration.pressureCalibration == Calibration::PRESSURE_CALIBRATION_PHYSICAL
+ || mCalibration.pressureCalibration
+ == Calibration::PRESSURE_CALIBRATION_AMPLITUDE) {
+ if (mCalibration.havePressureScale) {
+ mPressureScale = mCalibration.pressureScale;
+ } else if (mRawPointerAxes.pressure.valid
+ && mRawPointerAxes.pressure.maxValue != 0) {
+ mPressureScale = 1.0f / mRawPointerAxes.pressure.maxValue;
}
+ }
- mOrientedRanges.havePressure = true;
-
- mOrientedRanges.pressure.axis = AMOTION_EVENT_AXIS_PRESSURE;
- mOrientedRanges.pressure.source = mTouchSource;
- mOrientedRanges.pressure.min = 0;
- mOrientedRanges.pressure.max = 1.0;
- mOrientedRanges.pressure.flat = 0;
- mOrientedRanges.pressure.fuzz = 0;
+ mOrientedRanges.pressure.axis = AMOTION_EVENT_AXIS_PRESSURE;
+ mOrientedRanges.pressure.source = mSource;
+ mOrientedRanges.pressure.min = 0;
+ mOrientedRanges.pressure.max = 1.0;
+ mOrientedRanges.pressure.flat = 0;
+ mOrientedRanges.pressure.fuzz = 0;
+
+ // Tilt
+ mTiltXCenter = 0;
+ mTiltXScale = 0;
+ mTiltYCenter = 0;
+ mTiltYScale = 0;
+ mHaveTilt = mRawPointerAxes.tiltX.valid && mRawPointerAxes.tiltY.valid;
+ if (mHaveTilt) {
+ mTiltXCenter = avg(mRawPointerAxes.tiltX.minValue,
+ mRawPointerAxes.tiltX.maxValue);
+ mTiltYCenter = avg(mRawPointerAxes.tiltY.minValue,
+ mRawPointerAxes.tiltY.maxValue);
+ mTiltXScale = M_PI / 180;
+ mTiltYScale = M_PI / 180;
+
+ mOrientedRanges.haveTilt = true;
+
+ mOrientedRanges.tilt.axis = AMOTION_EVENT_AXIS_TILT;
+ mOrientedRanges.tilt.source = mSource;
+ mOrientedRanges.tilt.min = 0;
+ mOrientedRanges.tilt.max = M_PI_2;
+ mOrientedRanges.tilt.flat = 0;
+ mOrientedRanges.tilt.fuzz = 0;
}
// Orientation
+ mOrientationCenter = 0;
mOrientationScale = 0;
- if (mCalibration.orientationCalibration != Calibration::ORIENTATION_CALIBRATION_NONE) {
+ if (mHaveTilt) {
+ mOrientedRanges.haveOrientation = true;
+
+ mOrientedRanges.orientation.axis = AMOTION_EVENT_AXIS_ORIENTATION;
+ mOrientedRanges.orientation.source = mSource;
+ mOrientedRanges.orientation.min = -M_PI;
+ mOrientedRanges.orientation.max = M_PI;
+ mOrientedRanges.orientation.flat = 0;
+ mOrientedRanges.orientation.fuzz = 0;
+ } else if (mCalibration.orientationCalibration !=
+ Calibration::ORIENTATION_CALIBRATION_NONE) {
if (mCalibration.orientationCalibration
== Calibration::ORIENTATION_CALIBRATION_INTERPOLATED) {
- if (mRawPointerAxes.orientation.valid
- && mRawPointerAxes.orientation.maxValue != 0) {
- mOrientationScale = float(M_PI_2) / mRawPointerAxes.orientation.maxValue;
+ if (mRawPointerAxes.orientation.valid) {
+ mOrientationCenter = avg(mRawPointerAxes.orientation.minValue,
+ mRawPointerAxes.orientation.maxValue);
+ mOrientationScale = M_PI / (mRawPointerAxes.orientation.maxValue -
+ mRawPointerAxes.orientation.minValue);
}
}
mOrientedRanges.haveOrientation = true;
mOrientedRanges.orientation.axis = AMOTION_EVENT_AXIS_ORIENTATION;
- mOrientedRanges.orientation.source = mTouchSource;
- mOrientedRanges.orientation.min = - M_PI_2;
+ mOrientedRanges.orientation.source = mSource;
+ mOrientedRanges.orientation.min = -M_PI_2;
mOrientedRanges.orientation.max = M_PI_2;
mOrientedRanges.orientation.flat = 0;
mOrientedRanges.orientation.fuzz = 0;
@@ -2639,7 +2849,7 @@ bool TouchInputMapper::configureSurface() {
mOrientedRanges.haveDistance = true;
mOrientedRanges.distance.axis = AMOTION_EVENT_AXIS_DISTANCE;
- mOrientedRanges.distance.source = mTouchSource;
+ mOrientedRanges.distance.source = mSource;
mOrientedRanges.distance.min =
mRawPointerAxes.distance.minValue * mDistanceScale;
mOrientedRanges.distance.max =
@@ -2650,7 +2860,7 @@ bool TouchInputMapper::configureSurface() {
}
}
- if (orientationChanged || sizeChanged) {
+ if (orientationChanged || sizeChanged || deviceModeChanged) {
// Compute oriented surface dimensions, precision, scales and ranges.
// Note that the maximum value reported is an inclusive maximum value so it is one
// unit less than the total width or height of surface.
@@ -2698,7 +2908,7 @@ bool TouchInputMapper::configureSurface() {
}
// Compute pointer gesture detection parameters.
- if (mParameters.deviceType == Parameters::DEVICE_TYPE_POINTER) {
+ if (mDeviceMode == DEVICE_MODE_POINTER) {
int32_t rawWidth = mRawPointerAxes.x.maxValue - mRawPointerAxes.x.minValue + 1;
int32_t rawHeight = mRawPointerAxes.y.maxValue - mRawPointerAxes.y.minValue + 1;
float rawDiagonal = hypotf(rawWidth, rawHeight);
@@ -2710,34 +2920,30 @@ bool TouchInputMapper::configureSurface() {
// is applied.
// Assume that the touch pad has a square aspect ratio such that movements in
// X and Y of the same number of raw units cover the same physical distance.
- mPointerGestureXMovementScale = mConfig.pointerGestureMovementSpeedRatio
+ mPointerXMovementScale = mConfig.pointerGestureMovementSpeedRatio
* displayDiagonal / rawDiagonal;
- mPointerGestureYMovementScale = mPointerGestureXMovementScale;
+ mPointerYMovementScale = mPointerXMovementScale;
// Scale zooms to cover a smaller range of the display than movements do.
// This value determines the area around the pointer that is affected by freeform
// pointer gestures.
- mPointerGestureXZoomScale = mConfig.pointerGestureZoomSpeedRatio
+ mPointerXZoomScale = mConfig.pointerGestureZoomSpeedRatio
* displayDiagonal / rawDiagonal;
- mPointerGestureYZoomScale = mPointerGestureXZoomScale;
+ mPointerYZoomScale = mPointerXZoomScale;
// Max width between pointers to detect a swipe gesture is more than some fraction
// of the diagonal axis of the touch pad. Touches that are wider than this are
// translated into freeform gestures.
mPointerGestureMaxSwipeWidth =
mConfig.pointerGestureSwipeMaxWidthRatio * rawDiagonal;
+ }
- // Reset the current pointer gesture.
- mPointerGesture.reset();
+ // Abort current pointer usages because the state has changed.
+ abortPointerUsage(when, 0 /*policyFlags*/);
- // Remove any current spots.
- if (mParameters.gestureMode == Parameters::GESTURE_MODE_SPOTS) {
- mPointerController->clearSpots();
- }
- }
+ // Inform the dispatcher about the changes.
+ *outResetNeeded = true;
}
-
- return true;
}
void TouchInputMapper::dumpSurface(String8& dump) {
@@ -3023,26 +3229,71 @@ void TouchInputMapper::dumpCalibration(String8& dump) {
}
}
-void TouchInputMapper::reset() {
- // Synthesize touch up event.
- // This will also take care of finishing virtual key processing if needed.
- nsecs_t when = systemTime(SYSTEM_TIME_MONOTONIC);
+void TouchInputMapper::reset(nsecs_t when) {
+ mCursorButtonAccumulator.reset(getDevice());
+ mCursorScrollAccumulator.reset(getDevice());
+ mTouchButtonAccumulator.reset(getDevice());
+
+ mPointerVelocityControl.reset();
+ mWheelXVelocityControl.reset();
+ mWheelYVelocityControl.reset();
+
mCurrentRawPointerData.clear();
+ mLastRawPointerData.clear();
+ mCurrentCookedPointerData.clear();
+ mLastCookedPointerData.clear();
mCurrentButtonState = 0;
- syncTouch(when, true);
+ mLastButtonState = 0;
+ mCurrentRawVScroll = 0;
+ mCurrentRawHScroll = 0;
+ mCurrentFingerIdBits.clear();
+ mLastFingerIdBits.clear();
+ mCurrentStylusIdBits.clear();
+ mLastStylusIdBits.clear();
+ mCurrentMouseIdBits.clear();
+ mLastMouseIdBits.clear();
+ mPointerUsage = POINTER_USAGE_NONE;
+ mSentHoverEnter = false;
+ mDownTime = 0;
- initialize();
+ mCurrentVirtualKey.down = false;
+
+ mPointerGesture.reset();
+ mPointerSimple.reset();
- if (mPointerController != NULL
- && mParameters.gestureMode == Parameters::GESTURE_MODE_SPOTS) {
+ if (mPointerController != NULL) {
mPointerController->fade(PointerControllerInterface::TRANSITION_GRADUAL);
mPointerController->clearSpots();
}
- InputMapper::reset();
+ InputMapper::reset(when);
}
-void TouchInputMapper::syncTouch(nsecs_t when, bool havePointerIds) {
+void TouchInputMapper::process(const RawEvent* rawEvent) {
+ mCursorButtonAccumulator.process(rawEvent);
+ mCursorScrollAccumulator.process(rawEvent);
+ mTouchButtonAccumulator.process(rawEvent);
+
+ if (rawEvent->type == EV_SYN && rawEvent->scanCode == SYN_REPORT) {
+ sync(rawEvent->when);
+ }
+}
+
+void TouchInputMapper::sync(nsecs_t when) {
+ // Sync button state.
+ mCurrentButtonState = mTouchButtonAccumulator.getButtonState()
+ | mCursorButtonAccumulator.getButtonState();
+
+ // Sync scroll state.
+ mCurrentRawVScroll = mCursorScrollAccumulator.getRelativeVWheel();
+ mCurrentRawHScroll = mCursorScrollAccumulator.getRelativeHWheel();
+ mCursorScrollAccumulator.finishSync();
+
+ // Sync touch state.
+ bool havePointerIds = true;
+ mCurrentRawPointerData.clear();
+ syncTouch(when, &havePointerIds);
+
#if DEBUG_RAW_EVENTS
if (!havePointerIds) {
LOGD("syncTouch: pointerCount %d -> %d, no pointer ids",
@@ -3060,66 +3311,121 @@ void TouchInputMapper::syncTouch(nsecs_t when, bool havePointerIds) {
}
#endif
- // Configure the surface now, if possible.
- if (!configureSurface()) {
- mLastRawPointerData.clear();
- mLastCookedPointerData.clear();
- mLastButtonState = 0;
- return;
- }
+ // Reset state that we will compute below.
+ mCurrentFingerIdBits.clear();
+ mCurrentStylusIdBits.clear();
+ mCurrentMouseIdBits.clear();
+ mCurrentCookedPointerData.clear();
- // Preprocess pointer data.
- if (!havePointerIds) {
- assignPointerIds();
- }
+ if (mDeviceMode == DEVICE_MODE_DISABLED) {
+ // Drop all input if the device is disabled.
+ mCurrentRawPointerData.clear();
+ mCurrentButtonState = 0;
+ } else {
+ // Preprocess pointer data.
+ if (!havePointerIds) {
+ assignPointerIds();
+ }
- // Handle policy on initial down or hover events.
- uint32_t policyFlags = 0;
- if (mLastRawPointerData.pointerCount == 0 && mCurrentRawPointerData.pointerCount != 0) {
- if (mParameters.deviceType == Parameters::DEVICE_TYPE_TOUCH_SCREEN) {
- // If this is a touch screen, hide the pointer on an initial down.
- getContext()->fadePointer();
+ // Handle policy on initial down or hover events.
+ uint32_t policyFlags = 0;
+ if (mLastRawPointerData.pointerCount == 0 && mCurrentRawPointerData.pointerCount != 0) {
+ if (mDeviceMode == DEVICE_MODE_DIRECT) {
+ // If this is a touch screen, hide the pointer on an initial down.
+ getContext()->fadePointer();
+ }
+
+ // Initial downs on external touch devices should wake the device.
+ // We don't do this for internal touch screens to prevent them from waking
+ // up in your pocket.
+ // TODO: Use the input device configuration to control this behavior more finely.
+ if (getDevice()->isExternal()) {
+ policyFlags |= POLICY_FLAG_WAKE_DROPPED;
+ }
}
- // Initial downs on external touch devices should wake the device.
- // We don't do this for internal touch screens to prevent them from waking
- // up in your pocket.
- // TODO: Use the input device configuration to control this behavior more finely.
- if (getDevice()->isExternal()) {
- policyFlags |= POLICY_FLAG_WAKE_DROPPED;
+ // Synthesize key down from raw buttons if needed.
+ synthesizeButtonKeys(getContext(), AKEY_EVENT_ACTION_DOWN, when, getDeviceId(), mSource,
+ policyFlags, mLastButtonState, mCurrentButtonState);
+
+ // Consume raw off-screen touches before cooking pointer data.
+ // If touches are consumed, subsequent code will not receive any pointer data.
+ if (consumeRawTouches(when, policyFlags)) {
+ mCurrentRawPointerData.clear();
}
- }
- // Synthesize key down from raw buttons if needed.
- synthesizeButtonKeys(getContext(), AKEY_EVENT_ACTION_DOWN, when, getDeviceId(), mTouchSource,
- policyFlags, mLastButtonState, mCurrentButtonState);
+ // Cook pointer data. This call populates the mCurrentCookedPointerData structure
+ // with cooked pointer data that has the same ids and indices as the raw data.
+ // The following code can use either the raw or cooked data, as needed.
+ cookPointerData();
- if (consumeRawTouches(when, policyFlags)) {
- mCurrentRawPointerData.clear();
- }
+ // Dispatch the touches either directly or by translation through a pointer on screen.
+ if (mPointerController != NULL) {
+ for (BitSet32 idBits(mCurrentRawPointerData.touchingIdBits); !idBits.isEmpty(); ) {
+ uint32_t id = idBits.clearFirstMarkedBit();
+ const RawPointerData::Pointer& pointer = mCurrentRawPointerData.pointerForId(id);
+ if (pointer.toolType == AMOTION_EVENT_TOOL_TYPE_STYLUS
+ || pointer.toolType == AMOTION_EVENT_TOOL_TYPE_ERASER) {
+ mCurrentStylusIdBits.markBit(id);
+ } else if (pointer.toolType == AMOTION_EVENT_TOOL_TYPE_FINGER
+ || pointer.toolType == AMOTION_EVENT_TOOL_TYPE_UNKNOWN) {
+ mCurrentFingerIdBits.markBit(id);
+ } else if (pointer.toolType == AMOTION_EVENT_TOOL_TYPE_MOUSE) {
+ mCurrentMouseIdBits.markBit(id);
+ }
+ }
+ for (BitSet32 idBits(mCurrentRawPointerData.hoveringIdBits); !idBits.isEmpty(); ) {
+ uint32_t id = idBits.clearFirstMarkedBit();
+ const RawPointerData::Pointer& pointer = mCurrentRawPointerData.pointerForId(id);
+ if (pointer.toolType == AMOTION_EVENT_TOOL_TYPE_STYLUS
+ || pointer.toolType == AMOTION_EVENT_TOOL_TYPE_ERASER) {
+ mCurrentStylusIdBits.markBit(id);
+ }
+ }
- if (mPointerController != NULL && mConfig.pointerGesturesEnabled) {
- dispatchPointerGestures(when, policyFlags, false /*isTimeout*/);
- }
+ // Stylus takes precedence over all tools, then mouse, then finger.
+ PointerUsage pointerUsage = mPointerUsage;
+ if (!mCurrentStylusIdBits.isEmpty()) {
+ mCurrentMouseIdBits.clear();
+ mCurrentFingerIdBits.clear();
+ pointerUsage = POINTER_USAGE_STYLUS;
+ } else if (!mCurrentMouseIdBits.isEmpty()) {
+ mCurrentFingerIdBits.clear();
+ pointerUsage = POINTER_USAGE_MOUSE;
+ } else if (!mCurrentFingerIdBits.isEmpty() || isPointerDown(mCurrentButtonState)) {
+ pointerUsage = POINTER_USAGE_GESTURES;
+ }
- cookPointerData();
- dispatchHoverExit(when, policyFlags);
- dispatchTouches(when, policyFlags);
- dispatchHoverEnterAndMove(when, policyFlags);
+ dispatchPointerUsage(when, policyFlags, pointerUsage);
+ } else {
+ dispatchHoverExit(when, policyFlags);
+ dispatchTouches(when, policyFlags);
+ dispatchHoverEnterAndMove(when, policyFlags);
+ }
- // Synthesize key up from raw buttons if needed.
- synthesizeButtonKeys(getContext(), AKEY_EVENT_ACTION_UP, when, getDeviceId(), mTouchSource,
- policyFlags, mLastButtonState, mCurrentButtonState);
+ // Synthesize key up from raw buttons if needed.
+ synthesizeButtonKeys(getContext(), AKEY_EVENT_ACTION_UP, when, getDeviceId(), mSource,
+ policyFlags, mLastButtonState, mCurrentButtonState);
+ }
// Copy current touch to last touch in preparation for the next cycle.
mLastRawPointerData.copyFrom(mCurrentRawPointerData);
mLastCookedPointerData.copyFrom(mCurrentCookedPointerData);
mLastButtonState = mCurrentButtonState;
+ mLastFingerIdBits = mCurrentFingerIdBits;
+ mLastStylusIdBits = mCurrentStylusIdBits;
+ mLastMouseIdBits = mCurrentMouseIdBits;
+
+ // Clear some transient state.
+ mCurrentRawVScroll = 0;
+ mCurrentRawHScroll = 0;
}
void TouchInputMapper::timeoutExpired(nsecs_t when) {
if (mPointerController != NULL) {
- dispatchPointerGestures(when, 0 /*policyFlags*/, true /*isTimeout*/);
+ if (mPointerUsage == POINTER_USAGE_GESTURES) {
+ dispatchPointerGestures(when, 0 /*policyFlags*/, true /*isTimeout*/);
+ }
}
}
@@ -3245,7 +3551,7 @@ void TouchInputMapper::dispatchTouches(nsecs_t when, uint32_t policyFlags) {
if (!currentIdBits.isEmpty()) {
// No pointer id changes so this is a move event.
// The listener takes care of batching moves so we don't have to deal with that here.
- dispatchMotion(when, policyFlags, mTouchSource,
+ dispatchMotion(when, policyFlags, mSource,
AMOTION_EVENT_ACTION_MOVE, 0, metaState, buttonState,
AMOTION_EVENT_EDGE_FLAG_NONE,
mCurrentCookedPointerData.pointerProperties,
@@ -3280,7 +3586,7 @@ void TouchInputMapper::dispatchTouches(nsecs_t when, uint32_t policyFlags) {
while (!upIdBits.isEmpty()) {
uint32_t upId = upIdBits.clearFirstMarkedBit();
- dispatchMotion(when, policyFlags, mTouchSource,
+ dispatchMotion(when, policyFlags, mSource,
AMOTION_EVENT_ACTION_POINTER_UP, 0, metaState, buttonState, 0,
mLastCookedPointerData.pointerProperties,
mLastCookedPointerData.pointerCoords,
@@ -3295,7 +3601,7 @@ void TouchInputMapper::dispatchTouches(nsecs_t when, uint32_t policyFlags) {
// events, they do not generally handle them except when presented in a move event.
if (moveNeeded) {
LOG_ASSERT(moveIdBits.value == dispatchedIdBits.value);
- dispatchMotion(when, policyFlags, mTouchSource,
+ dispatchMotion(when, policyFlags, mSource,
AMOTION_EVENT_ACTION_MOVE, 0, metaState, buttonState, 0,
mCurrentCookedPointerData.pointerProperties,
mCurrentCookedPointerData.pointerCoords,
@@ -3314,7 +3620,7 @@ void TouchInputMapper::dispatchTouches(nsecs_t when, uint32_t policyFlags) {
mDownTime = when;
}
- dispatchMotion(when, policyFlags, mTouchSource,
+ dispatchMotion(when, policyFlags, mSource,
AMOTION_EVENT_ACTION_POINTER_DOWN, 0, metaState, buttonState, 0,
mCurrentCookedPointerData.pointerProperties,
mCurrentCookedPointerData.pointerCoords,
@@ -3330,7 +3636,7 @@ void TouchInputMapper::dispatchHoverExit(nsecs_t when, uint32_t policyFlags) {
(mCurrentCookedPointerData.hoveringIdBits.isEmpty()
|| !mCurrentCookedPointerData.touchingIdBits.isEmpty())) {
int32_t metaState = getContext()->getGlobalMetaState();
- dispatchMotion(when, policyFlags, mTouchSource,
+ dispatchMotion(when, policyFlags, mSource,
AMOTION_EVENT_ACTION_HOVER_EXIT, 0, metaState, mLastButtonState, 0,
mLastCookedPointerData.pointerProperties,
mLastCookedPointerData.pointerCoords,
@@ -3346,7 +3652,7 @@ void TouchInputMapper::dispatchHoverEnterAndMove(nsecs_t when, uint32_t policyFl
&& !mCurrentCookedPointerData.hoveringIdBits.isEmpty()) {
int32_t metaState = getContext()->getGlobalMetaState();
if (!mSentHoverEnter) {
- dispatchMotion(when, policyFlags, mTouchSource,
+ dispatchMotion(when, policyFlags, mSource,
AMOTION_EVENT_ACTION_HOVER_ENTER, 0, metaState, mCurrentButtonState, 0,
mCurrentCookedPointerData.pointerProperties,
mCurrentCookedPointerData.pointerCoords,
@@ -3356,7 +3662,7 @@ void TouchInputMapper::dispatchHoverEnterAndMove(nsecs_t when, uint32_t policyFl
mSentHoverEnter = true;
}
- dispatchMotion(when, policyFlags, mTouchSource,
+ dispatchMotion(when, policyFlags, mSource,
AMOTION_EVENT_ACTION_HOVER_MOVE, 0, metaState, mCurrentButtonState, 0,
mCurrentCookedPointerData.pointerProperties,
mCurrentCookedPointerData.pointerCoords,
@@ -3467,30 +3773,40 @@ void TouchInputMapper::cookPointerData() {
break;
}
- // Orientation
+ // Tilt and Orientation
+ float tilt;
float orientation;
- switch (mCalibration.orientationCalibration) {
- case Calibration::ORIENTATION_CALIBRATION_INTERPOLATED:
- orientation = in.orientation * mOrientationScale;
- break;
- case Calibration::ORIENTATION_CALIBRATION_VECTOR: {
- int32_t c1 = signExtendNybble((in.orientation & 0xf0) >> 4);
- int32_t c2 = signExtendNybble(in.orientation & 0x0f);
- if (c1 != 0 || c2 != 0) {
- orientation = atan2f(c1, c2) * 0.5f;
- float confidence = hypotf(c1, c2);
- float scale = 1.0f + confidence / 16.0f;
- touchMajor *= scale;
- touchMinor /= scale;
- toolMajor *= scale;
- toolMinor /= scale;
- } else {
+ if (mHaveTilt) {
+ float tiltXAngle = (in.tiltX - mTiltXCenter) * mTiltXScale;
+ float tiltYAngle = (in.tiltY - mTiltYCenter) * mTiltYScale;
+ orientation = atan2f(-sinf(tiltXAngle), sinf(tiltYAngle));
+ tilt = acosf(cosf(tiltXAngle) * cosf(tiltYAngle));
+ } else {
+ tilt = 0;
+
+ switch (mCalibration.orientationCalibration) {
+ case Calibration::ORIENTATION_CALIBRATION_INTERPOLATED:
+ orientation = (in.orientation - mOrientationCenter) * mOrientationScale;
+ break;
+ case Calibration::ORIENTATION_CALIBRATION_VECTOR: {
+ int32_t c1 = signExtendNybble((in.orientation & 0xf0) >> 4);
+ int32_t c2 = signExtendNybble(in.orientation & 0x0f);
+ if (c1 != 0 || c2 != 0) {
+ orientation = atan2f(c1, c2) * 0.5f;
+ float confidence = hypotf(c1, c2);
+ float scale = 1.0f + confidence / 16.0f;
+ touchMajor *= scale;
+ touchMinor /= scale;
+ toolMajor *= scale;
+ toolMinor /= scale;
+ } else {
+ orientation = 0;
+ }
+ break;
+ }
+ default:
orientation = 0;
}
- break;
- }
- default:
- orientation = 0;
}
// Distance
@@ -3545,6 +3861,7 @@ void TouchInputMapper::cookPointerData() {
out.setAxisValue(AMOTION_EVENT_AXIS_TOOL_MAJOR, toolMajor);
out.setAxisValue(AMOTION_EVENT_AXIS_TOOL_MINOR, toolMinor);
out.setAxisValue(AMOTION_EVENT_AXIS_ORIENTATION, orientation);
+ out.setAxisValue(AMOTION_EVENT_AXIS_TILT, tilt);
out.setAxisValue(AMOTION_EVENT_AXIS_DISTANCE, distance);
// Write output properties.
@@ -3559,6 +3876,46 @@ void TouchInputMapper::cookPointerData() {
}
}
+void TouchInputMapper::dispatchPointerUsage(nsecs_t when, uint32_t policyFlags,
+ PointerUsage pointerUsage) {
+ if (pointerUsage != mPointerUsage) {
+ abortPointerUsage(when, policyFlags);
+ mPointerUsage = pointerUsage;
+ }
+
+ switch (mPointerUsage) {
+ case POINTER_USAGE_GESTURES:
+ dispatchPointerGestures(when, policyFlags, false /*isTimeout*/);
+ break;
+ case POINTER_USAGE_STYLUS:
+ dispatchPointerStylus(when, policyFlags);
+ break;
+ case POINTER_USAGE_MOUSE:
+ dispatchPointerMouse(when, policyFlags);
+ break;
+ default:
+ break;
+ }
+}
+
+void TouchInputMapper::abortPointerUsage(nsecs_t when, uint32_t policyFlags) {
+ switch (mPointerUsage) {
+ case POINTER_USAGE_GESTURES:
+ abortPointerGestures(when, policyFlags);
+ break;
+ case POINTER_USAGE_STYLUS:
+ abortPointerStylus(when, policyFlags);
+ break;
+ case POINTER_USAGE_MOUSE:
+ abortPointerMouse(when, policyFlags);
+ break;
+ default:
+ break;
+ }
+
+ mPointerUsage = POINTER_USAGE_NONE;
+}
+
void TouchInputMapper::dispatchPointerGestures(nsecs_t when, uint32_t policyFlags,
bool isTimeout) {
// Update current gesture coordinates.
@@ -3649,7 +4006,7 @@ void TouchInputMapper::dispatchPointerGestures(nsecs_t when, uint32_t policyFlag
BitSet32 dispatchedGestureIdBits(mPointerGesture.lastGestureIdBits);
if (!dispatchedGestureIdBits.isEmpty()) {
if (cancelPreviousGesture) {
- dispatchMotion(when, policyFlags, mPointerSource,
+ dispatchMotion(when, policyFlags, mSource,
AMOTION_EVENT_ACTION_CANCEL, 0, metaState, buttonState,
AMOTION_EVENT_EDGE_FLAG_NONE,
mPointerGesture.lastGestureProperties,
@@ -3669,7 +4026,7 @@ void TouchInputMapper::dispatchPointerGestures(nsecs_t when, uint32_t policyFlag
while (!upGestureIdBits.isEmpty()) {
uint32_t id = upGestureIdBits.clearFirstMarkedBit();
- dispatchMotion(when, policyFlags, mPointerSource,
+ dispatchMotion(when, policyFlags, mSource,
AMOTION_EVENT_ACTION_POINTER_UP, 0,
metaState, buttonState, AMOTION_EVENT_EDGE_FLAG_NONE,
mPointerGesture.lastGestureProperties,
@@ -3684,7 +4041,7 @@ void TouchInputMapper::dispatchPointerGestures(nsecs_t when, uint32_t policyFlag
// Send motion events for all pointers that moved.
if (moveNeeded) {
- dispatchMotion(when, policyFlags, mPointerSource,
+ dispatchMotion(when, policyFlags, mSource,
AMOTION_EVENT_ACTION_MOVE, 0, metaState, buttonState, AMOTION_EVENT_EDGE_FLAG_NONE,
mPointerGesture.currentGestureProperties,
mPointerGesture.currentGestureCoords, mPointerGesture.currentGestureIdToIndex,
@@ -3704,7 +4061,7 @@ void TouchInputMapper::dispatchPointerGestures(nsecs_t when, uint32_t policyFlag
mPointerGesture.downTime = when;
}
- dispatchMotion(when, policyFlags, mPointerSource,
+ dispatchMotion(when, policyFlags, mSource,
AMOTION_EVENT_ACTION_POINTER_DOWN, 0, metaState, buttonState, 0,
mPointerGesture.currentGestureProperties,
mPointerGesture.currentGestureCoords, mPointerGesture.currentGestureIdToIndex,
@@ -3715,7 +4072,7 @@ void TouchInputMapper::dispatchPointerGestures(nsecs_t when, uint32_t policyFlag
// Send motion events for hover.
if (mPointerGesture.currentGestureMode == PointerGesture::HOVER) {
- dispatchMotion(when, policyFlags, mPointerSource,
+ dispatchMotion(when, policyFlags, mSource,
AMOTION_EVENT_ACTION_HOVER_MOVE, 0,
metaState, buttonState, AMOTION_EVENT_EDGE_FLAG_NONE,
mPointerGesture.currentGestureProperties,
@@ -3741,7 +4098,7 @@ void TouchInputMapper::dispatchPointerGestures(nsecs_t when, uint32_t policyFlag
pointerCoords.setAxisValue(AMOTION_EVENT_AXIS_X, x);
pointerCoords.setAxisValue(AMOTION_EVENT_AXIS_Y, y);
- NotifyMotionArgs args(when, getDeviceId(), mPointerSource, policyFlags,
+ NotifyMotionArgs args(when, getDeviceId(), mSource, policyFlags,
AMOTION_EVENT_ACTION_HOVER_MOVE, 0,
metaState, buttonState, AMOTION_EVENT_EDGE_FLAG_NONE,
1, &pointerProperties, &pointerCoords, 0, 0, mPointerGesture.downTime);
@@ -3766,6 +4123,31 @@ void TouchInputMapper::dispatchPointerGestures(nsecs_t when, uint32_t policyFlag
}
}
+void TouchInputMapper::abortPointerGestures(nsecs_t when, uint32_t policyFlags) {
+ // Cancel previously dispatches pointers.
+ if (!mPointerGesture.lastGestureIdBits.isEmpty()) {
+ int32_t metaState = getContext()->getGlobalMetaState();
+ int32_t buttonState = mCurrentButtonState;
+ dispatchMotion(when, policyFlags, mSource,
+ AMOTION_EVENT_ACTION_CANCEL, 0, metaState, buttonState,
+ AMOTION_EVENT_EDGE_FLAG_NONE,
+ mPointerGesture.lastGestureProperties,
+ mPointerGesture.lastGestureCoords, mPointerGesture.lastGestureIdToIndex,
+ mPointerGesture.lastGestureIdBits, -1,
+ 0, 0, mPointerGesture.downTime);
+ }
+
+ // Reset the current pointer gesture.
+ mPointerGesture.reset();
+ mPointerVelocityControl.reset();
+
+ // Remove any current spots.
+ if (mPointerController != NULL) {
+ mPointerController->fade(PointerControllerInterface::TRANSITION_GRADUAL);
+ mPointerController->clearSpots();
+ }
+}
+
bool TouchInputMapper::preparePointerGestures(nsecs_t when,
bool* outCancelPreviousGesture, bool* outFinishPreviousGesture, bool isTimeout) {
*outCancelPreviousGesture = false;
@@ -3793,7 +4175,7 @@ bool TouchInputMapper::preparePointerGestures(nsecs_t when,
mPointerGesture.currentGestureMode = PointerGesture::NEUTRAL;
mPointerGesture.currentGestureIdBits.clear();
- mPointerGesture.pointerVelocityControl.reset();
+ mPointerVelocityControl.reset();
return true;
}
}
@@ -3802,18 +4184,21 @@ bool TouchInputMapper::preparePointerGestures(nsecs_t when,
return false;
}
+ const uint32_t currentFingerCount = mCurrentFingerIdBits.count();
+ const uint32_t lastFingerCount = mLastFingerIdBits.count();
+
// Update the velocity tracker.
{
VelocityTracker::Position positions[MAX_POINTERS];
uint32_t count = 0;
- for (BitSet32 idBits(mCurrentRawPointerData.touchingIdBits); !idBits.isEmpty(); count++) {
+ for (BitSet32 idBits(mCurrentFingerIdBits); !idBits.isEmpty(); count++) {
uint32_t id = idBits.clearFirstMarkedBit();
const RawPointerData::Pointer& pointer = mCurrentRawPointerData.pointerForId(id);
- positions[count].x = pointer.x * mPointerGestureXMovementScale;
- positions[count].y = pointer.y * mPointerGestureYMovementScale;
+ positions[count].x = pointer.x * mPointerXMovementScale;
+ positions[count].y = pointer.y * mPointerYMovementScale;
}
mPointerGesture.velocityTracker.addMovement(when,
- mCurrentRawPointerData.touchingIdBits, positions);
+ mCurrentFingerIdBits, positions);
}
// Pick a new active touch id if needed.
@@ -3825,25 +4210,22 @@ bool TouchInputMapper::preparePointerGestures(nsecs_t when,
int32_t lastActiveTouchId = mPointerGesture.activeTouchId;
int32_t activeTouchId = lastActiveTouchId;
if (activeTouchId < 0) {
- if (!mCurrentRawPointerData.touchingIdBits.isEmpty()) {
+ if (!mCurrentFingerIdBits.isEmpty()) {
activeTouchChanged = true;
activeTouchId = mPointerGesture.activeTouchId =
- mCurrentRawPointerData.touchingIdBits.firstMarkedBit();
+ mCurrentFingerIdBits.firstMarkedBit();
mPointerGesture.firstTouchTime = when;
}
- } else if (!mCurrentRawPointerData.touchingIdBits.hasBit(activeTouchId)) {
+ } else if (!mCurrentFingerIdBits.hasBit(activeTouchId)) {
activeTouchChanged = true;
- if (!mCurrentRawPointerData.touchingIdBits.isEmpty()) {
+ if (!mCurrentFingerIdBits.isEmpty()) {
activeTouchId = mPointerGesture.activeTouchId =
- mCurrentRawPointerData.touchingIdBits.firstMarkedBit();
+ mCurrentFingerIdBits.firstMarkedBit();
} else {
activeTouchId = mPointerGesture.activeTouchId = -1;
}
}
- uint32_t currentTouchingPointerCount = mCurrentRawPointerData.touchingIdBits.count();
- uint32_t lastTouchingPointerCount = mLastRawPointerData.touchingIdBits.count();
-
// Determine whether we are in quiet time.
bool isQuietTime = false;
if (activeTouchId < 0) {
@@ -3854,13 +4236,13 @@ bool TouchInputMapper::preparePointerGestures(nsecs_t when,
if ((mPointerGesture.lastGestureMode == PointerGesture::PRESS
|| mPointerGesture.lastGestureMode == PointerGesture::SWIPE
|| mPointerGesture.lastGestureMode == PointerGesture::FREEFORM)
- && currentTouchingPointerCount < 2) {
+ && currentFingerCount < 2) {
// Enter quiet time when exiting swipe or freeform state.
// This is to prevent accidentally entering the hover state and flinging the
// pointer when finishing a swipe and there is still one pointer left onscreen.
isQuietTime = true;
} else if (mPointerGesture.lastGestureMode == PointerGesture::BUTTON_CLICK_OR_DRAG
- && currentTouchingPointerCount >= 2
+ && currentFingerCount >= 2
&& !isPointerDown(mCurrentButtonState)) {
// Enter quiet time when releasing the button and there are still two or more
// fingers down. This may indicate that one finger was used to press the button
@@ -3888,7 +4270,7 @@ bool TouchInputMapper::preparePointerGestures(nsecs_t when,
mPointerGesture.currentGestureMode = PointerGesture::QUIET;
mPointerGesture.currentGestureIdBits.clear();
- mPointerGesture.pointerVelocityControl.reset();
+ mPointerVelocityControl.reset();
} else if (isPointerDown(mCurrentButtonState)) {
// Case 2: Button is pressed. (BUTTON_CLICK_OR_DRAG)
// The pointer follows the active touch point.
@@ -3905,7 +4287,7 @@ bool TouchInputMapper::preparePointerGestures(nsecs_t when,
// being dragged.
#if DEBUG_GESTURES
LOGD("Gestures: BUTTON_CLICK_OR_DRAG activeTouchId=%d, "
- "currentTouchingPointerCount=%d", activeTouchId, currentTouchingPointerCount);
+ "currentFingerCount=%d", activeTouchId, currentFingerCount);
#endif
// Reset state when just starting.
if (mPointerGesture.lastGestureMode != PointerGesture::BUTTON_CLICK_OR_DRAG) {
@@ -3915,10 +4297,10 @@ bool TouchInputMapper::preparePointerGestures(nsecs_t when,
// Switch pointers if needed.
// Find the fastest pointer and follow it.
- if (activeTouchId >= 0 && currentTouchingPointerCount > 1) {
+ if (activeTouchId >= 0 && currentFingerCount > 1) {
int32_t bestId = -1;
float bestSpeed = mConfig.pointerGestureDragMinSwitchSpeed;
- for (BitSet32 idBits(mCurrentRawPointerData.touchingIdBits); !idBits.isEmpty(); ) {
+ for (BitSet32 idBits(mCurrentFingerIdBits); !idBits.isEmpty(); ) {
uint32_t id = idBits.clearFirstMarkedBit();
float vx, vy;
if (mPointerGesture.velocityTracker.getVelocity(id, &vx, &vy)) {
@@ -3939,23 +4321,23 @@ bool TouchInputMapper::preparePointerGestures(nsecs_t when,
}
}
- if (activeTouchId >= 0 && mLastRawPointerData.touchingIdBits.hasBit(activeTouchId)) {
+ if (activeTouchId >= 0 && mLastFingerIdBits.hasBit(activeTouchId)) {
const RawPointerData::Pointer& currentPointer =
mCurrentRawPointerData.pointerForId(activeTouchId);
const RawPointerData::Pointer& lastPointer =
mLastRawPointerData.pointerForId(activeTouchId);
- float deltaX = (currentPointer.x - lastPointer.x) * mPointerGestureXMovementScale;
- float deltaY = (currentPointer.y - lastPointer.y) * mPointerGestureYMovementScale;
+ float deltaX = (currentPointer.x - lastPointer.x) * mPointerXMovementScale;
+ float deltaY = (currentPointer.y - lastPointer.y) * mPointerYMovementScale;
rotateDelta(mSurfaceOrientation, &deltaX, &deltaY);
- mPointerGesture.pointerVelocityControl.move(when, &deltaX, &deltaY);
+ mPointerVelocityControl.move(when, &deltaX, &deltaY);
// Move the pointer using a relative motion.
// When using spots, the click will occur at the position of the anchor
// spot and all other spots will move there.
mPointerController->move(deltaX, deltaY);
} else {
- mPointerGesture.pointerVelocityControl.reset();
+ mPointerVelocityControl.reset();
}
float x, y;
@@ -3972,7 +4354,7 @@ bool TouchInputMapper::preparePointerGestures(nsecs_t when,
mPointerGesture.currentGestureCoords[0].setAxisValue(AMOTION_EVENT_AXIS_X, x);
mPointerGesture.currentGestureCoords[0].setAxisValue(AMOTION_EVENT_AXIS_Y, y);
mPointerGesture.currentGestureCoords[0].setAxisValue(AMOTION_EVENT_AXIS_PRESSURE, 1.0f);
- } else if (currentTouchingPointerCount == 0) {
+ } else if (currentFingerCount == 0) {
// Case 3. No fingers down and button is not pressed. (NEUTRAL)
if (mPointerGesture.lastGestureMode != PointerGesture::NEUTRAL) {
*outFinishPreviousGesture = true;
@@ -3983,7 +4365,7 @@ bool TouchInputMapper::preparePointerGestures(nsecs_t when,
bool tapped = false;
if ((mPointerGesture.lastGestureMode == PointerGesture::HOVER
|| mPointerGesture.lastGestureMode == PointerGesture::TAP_DRAG)
- && lastTouchingPointerCount == 1) {
+ && lastFingerCount == 1) {
if (when <= mPointerGesture.tapDownTime + mConfig.pointerGestureTapInterval) {
float x, y;
mPointerController->getPosition(&x, &y);
@@ -4033,7 +4415,7 @@ bool TouchInputMapper::preparePointerGestures(nsecs_t when,
}
}
- mPointerGesture.pointerVelocityControl.reset();
+ mPointerVelocityControl.reset();
if (!tapped) {
#if DEBUG_GESTURES
@@ -4043,7 +4425,7 @@ bool TouchInputMapper::preparePointerGestures(nsecs_t when,
mPointerGesture.currentGestureMode = PointerGesture::NEUTRAL;
mPointerGesture.currentGestureIdBits.clear();
}
- } else if (currentTouchingPointerCount == 1) {
+ } else if (currentFingerCount == 1) {
// Case 4. Exactly one finger down, button is not pressed. (HOVER or TAP_DRAG)
// The pointer follows the active touch point.
// When in HOVER, emit HOVER_MOVE events at the pointer location.
@@ -4075,24 +4457,24 @@ bool TouchInputMapper::preparePointerGestures(nsecs_t when,
mPointerGesture.currentGestureMode = PointerGesture::TAP_DRAG;
}
- if (mLastRawPointerData.touchingIdBits.hasBit(activeTouchId)) {
+ if (mLastFingerIdBits.hasBit(activeTouchId)) {
const RawPointerData::Pointer& currentPointer =
mCurrentRawPointerData.pointerForId(activeTouchId);
const RawPointerData::Pointer& lastPointer =
mLastRawPointerData.pointerForId(activeTouchId);
float deltaX = (currentPointer.x - lastPointer.x)
- * mPointerGestureXMovementScale;
+ * mPointerXMovementScale;
float deltaY = (currentPointer.y - lastPointer.y)
- * mPointerGestureYMovementScale;
+ * mPointerYMovementScale;
rotateDelta(mSurfaceOrientation, &deltaX, &deltaY);
- mPointerGesture.pointerVelocityControl.move(when, &deltaX, &deltaY);
+ mPointerVelocityControl.move(when, &deltaX, &deltaY);
// Move the pointer using a relative motion.
// When using spots, the hover or drag will occur at the position of the anchor spot.
mPointerController->move(deltaX, deltaY);
} else {
- mPointerGesture.pointerVelocityControl.reset();
+ mPointerVelocityControl.reset();
}
bool down;
@@ -4128,7 +4510,7 @@ bool TouchInputMapper::preparePointerGestures(nsecs_t when,
mPointerGesture.currentGestureCoords[0].setAxisValue(AMOTION_EVENT_AXIS_PRESSURE,
down ? 1.0f : 0.0f);
- if (lastTouchingPointerCount == 0 && currentTouchingPointerCount != 0) {
+ if (lastFingerCount == 0 && currentFingerCount != 0) {
mPointerGesture.resetTap();
mPointerGesture.tapDownTime = when;
mPointerGesture.tapX = x;
@@ -4156,7 +4538,7 @@ bool TouchInputMapper::preparePointerGestures(nsecs_t when,
&& mPointerGesture.lastGestureMode != PointerGesture::SWIPE
&& mPointerGesture.lastGestureMode != PointerGesture::FREEFORM) {
*outFinishPreviousGesture = true;
- } else if (!settled && currentTouchingPointerCount > lastTouchingPointerCount) {
+ } else if (!settled && currentFingerCount > lastFingerCount) {
// Additional pointers have gone down but not yet settled.
// Reset the gesture.
#if DEBUG_GESTURES
@@ -4175,7 +4557,7 @@ bool TouchInputMapper::preparePointerGestures(nsecs_t when,
mPointerGesture.currentGestureMode = PointerGesture::PRESS;
mPointerGesture.activeGestureId = 0;
mPointerGesture.referenceIdBits.clear();
- mPointerGesture.pointerVelocityControl.reset();
+ mPointerVelocityControl.reset();
// Use the centroid and pointer location as the reference points for the gesture.
#if DEBUG_GESTURES
@@ -4192,18 +4574,18 @@ bool TouchInputMapper::preparePointerGestures(nsecs_t when,
}
// Clear the reference deltas for fingers not yet included in the reference calculation.
- for (BitSet32 idBits(mCurrentRawPointerData.touchingIdBits.value
+ for (BitSet32 idBits(mCurrentFingerIdBits.value
& ~mPointerGesture.referenceIdBits.value); !idBits.isEmpty(); ) {
uint32_t id = idBits.clearFirstMarkedBit();
mPointerGesture.referenceDeltas[id].dx = 0;
mPointerGesture.referenceDeltas[id].dy = 0;
}
- mPointerGesture.referenceIdBits = mCurrentRawPointerData.touchingIdBits;
+ mPointerGesture.referenceIdBits = mCurrentFingerIdBits;
// Add delta for all fingers and calculate a common movement delta.
float commonDeltaX = 0, commonDeltaY = 0;
- BitSet32 commonIdBits(mLastRawPointerData.touchingIdBits.value
- & mCurrentRawPointerData.touchingIdBits.value);
+ BitSet32 commonIdBits(mLastFingerIdBits.value
+ & mCurrentFingerIdBits.value);
for (BitSet32 idBits(commonIdBits); !idBits.isEmpty(); ) {
bool first = (idBits == commonIdBits);
uint32_t id = idBits.clearFirstMarkedBit();
@@ -4229,8 +4611,8 @@ bool TouchInputMapper::preparePointerGestures(nsecs_t when,
for (BitSet32 idBits(mPointerGesture.referenceIdBits); !idBits.isEmpty(); ) {
uint32_t id = idBits.clearFirstMarkedBit();
PointerGesture::Delta& delta = mPointerGesture.referenceDeltas[id];
- dist[id] = hypotf(delta.dx * mPointerGestureXZoomScale,
- delta.dy * mPointerGestureYZoomScale);
+ dist[id] = hypotf(delta.dx * mPointerXZoomScale,
+ delta.dy * mPointerYZoomScale);
if (dist[id] > mConfig.pointerGestureMultitouchMinDistance) {
distOverThreshold += 1;
}
@@ -4239,17 +4621,17 @@ bool TouchInputMapper::preparePointerGestures(nsecs_t when,
// Only transition when at least two pointers have moved further than
// the minimum distance threshold.
if (distOverThreshold >= 2) {
- if (currentTouchingPointerCount > 2) {
+ if (currentFingerCount > 2) {
// There are more than two pointers, switch to FREEFORM.
#if DEBUG_GESTURES
LOGD("Gestures: PRESS transitioned to FREEFORM, number of pointers %d > 2",
- currentTouchingPointerCount);
+ currentFingerCount);
#endif
*outCancelPreviousGesture = true;
mPointerGesture.currentGestureMode = PointerGesture::FREEFORM;
} else {
// There are exactly two pointers.
- BitSet32 idBits(mCurrentRawPointerData.touchingIdBits);
+ BitSet32 idBits(mCurrentFingerIdBits);
uint32_t id1 = idBits.clearFirstMarkedBit();
uint32_t id2 = idBits.firstMarkedBit();
const RawPointerData::Pointer& p1 = mCurrentRawPointerData.pointerForId(id1);
@@ -4277,10 +4659,10 @@ bool TouchInputMapper::preparePointerGestures(nsecs_t when,
// approches 1.0. Recall that dot(v1, v2) = cos(angle) * mag(v1) * mag(v2).
PointerGesture::Delta& delta1 = mPointerGesture.referenceDeltas[id1];
PointerGesture::Delta& delta2 = mPointerGesture.referenceDeltas[id2];
- float dx1 = delta1.dx * mPointerGestureXZoomScale;
- float dy1 = delta1.dy * mPointerGestureYZoomScale;
- float dx2 = delta2.dx * mPointerGestureXZoomScale;
- float dy2 = delta2.dy * mPointerGestureYZoomScale;
+ float dx1 = delta1.dx * mPointerXZoomScale;
+ float dy1 = delta1.dy * mPointerYZoomScale;
+ float dx2 = delta2.dx * mPointerXZoomScale;
+ float dy2 = delta2.dy * mPointerYZoomScale;
float dot = dx1 * dx2 + dy1 * dy2;
float cosine = dot / (dist1 * dist2); // denominator always > 0
if (cosine >= mConfig.pointerGestureSwipeTransitionAngleCosine) {
@@ -4314,10 +4696,10 @@ bool TouchInputMapper::preparePointerGestures(nsecs_t when,
} else if (mPointerGesture.currentGestureMode == PointerGesture::SWIPE) {
// Switch from SWIPE to FREEFORM if additional pointers go down.
// Cancel previous gesture.
- if (currentTouchingPointerCount > 2) {
+ if (currentFingerCount > 2) {
#if DEBUG_GESTURES
LOGD("Gestures: SWIPE transitioned to FREEFORM, number of pointers %d > 2",
- currentTouchingPointerCount);
+ currentFingerCount);
#endif
*outCancelPreviousGesture = true;
mPointerGesture.currentGestureMode = PointerGesture::FREEFORM;
@@ -4338,11 +4720,11 @@ bool TouchInputMapper::preparePointerGestures(nsecs_t when,
mPointerGesture.referenceTouchX += commonDeltaX;
mPointerGesture.referenceTouchY += commonDeltaY;
- commonDeltaX *= mPointerGestureXMovementScale;
- commonDeltaY *= mPointerGestureYMovementScale;
+ commonDeltaX *= mPointerXMovementScale;
+ commonDeltaY *= mPointerYMovementScale;
rotateDelta(mSurfaceOrientation, &commonDeltaX, &commonDeltaY);
- mPointerGesture.pointerVelocityControl.move(when, &commonDeltaX, &commonDeltaY);
+ mPointerVelocityControl.move(when, &commonDeltaX, &commonDeltaY);
mPointerGesture.referenceGestureX += commonDeltaX;
mPointerGesture.referenceGestureY += commonDeltaY;
@@ -4355,7 +4737,7 @@ bool TouchInputMapper::preparePointerGestures(nsecs_t when,
#if DEBUG_GESTURES
LOGD("Gestures: PRESS or SWIPE activeTouchId=%d,"
"activeGestureId=%d, currentTouchPointerCount=%d",
- activeTouchId, mPointerGesture.activeGestureId, currentTouchingPointerCount);
+ activeTouchId, mPointerGesture.activeGestureId, currentFingerCount);
#endif
LOG_ASSERT(mPointerGesture.activeGestureId >= 0);
@@ -4377,7 +4759,7 @@ bool TouchInputMapper::preparePointerGestures(nsecs_t when,
#if DEBUG_GESTURES
LOGD("Gestures: FREEFORM activeTouchId=%d,"
"activeGestureId=%d, currentTouchPointerCount=%d",
- activeTouchId, mPointerGesture.activeGestureId, currentTouchingPointerCount);
+ activeTouchId, mPointerGesture.activeGestureId, currentFingerCount);
#endif
LOG_ASSERT(mPointerGesture.activeGestureId >= 0);
@@ -4399,14 +4781,14 @@ bool TouchInputMapper::preparePointerGestures(nsecs_t when,
} else {
// Otherwise, assume we mapped all touches from the previous frame.
// Reuse all mappings that are still applicable.
- mappedTouchIdBits.value = mLastRawPointerData.touchingIdBits.value
- & mCurrentRawPointerData.touchingIdBits.value;
+ mappedTouchIdBits.value = mLastFingerIdBits.value
+ & mCurrentFingerIdBits.value;
usedGestureIdBits = mPointerGesture.lastGestureIdBits;
// Check whether we need to choose a new active gesture id because the
// current went went up.
- for (BitSet32 upTouchIdBits(mLastRawPointerData.touchingIdBits.value
- & ~mCurrentRawPointerData.touchingIdBits.value);
+ for (BitSet32 upTouchIdBits(mLastFingerIdBits.value
+ & ~mCurrentFingerIdBits.value);
!upTouchIdBits.isEmpty(); ) {
uint32_t upTouchId = upTouchIdBits.clearFirstMarkedBit();
uint32_t upGestureId = mPointerGesture.freeformTouchToGestureIdMap[upTouchId];
@@ -4425,8 +4807,8 @@ bool TouchInputMapper::preparePointerGestures(nsecs_t when,
mPointerGesture.activeGestureId);
#endif
- BitSet32 idBits(mCurrentRawPointerData.touchingIdBits);
- for (uint32_t i = 0; i < currentTouchingPointerCount; i++) {
+ BitSet32 idBits(mCurrentFingerIdBits);
+ for (uint32_t i = 0; i < currentFingerCount; i++) {
uint32_t touchId = idBits.clearFirstMarkedBit();
uint32_t gestureId;
if (!mappedTouchIdBits.hasBit(touchId)) {
@@ -4451,9 +4833,9 @@ bool TouchInputMapper::preparePointerGestures(nsecs_t when,
const RawPointerData::Pointer& pointer =
mCurrentRawPointerData.pointerForId(touchId);
float deltaX = (pointer.x - mPointerGesture.referenceTouchX)
- * mPointerGestureXZoomScale;
+ * mPointerXZoomScale;
float deltaY = (pointer.y - mPointerGesture.referenceTouchY)
- * mPointerGestureYZoomScale;
+ * mPointerYZoomScale;
rotateDelta(mSurfaceOrientation, &deltaX, &deltaY);
mPointerGesture.currentGestureProperties[i].clear();
@@ -4517,6 +4899,215 @@ bool TouchInputMapper::preparePointerGestures(nsecs_t when,
return true;
}
+void TouchInputMapper::dispatchPointerStylus(nsecs_t when, uint32_t policyFlags) {
+ mPointerSimple.currentCoords.clear();
+ mPointerSimple.currentProperties.clear();
+
+ bool down, hovering;
+ if (!mCurrentStylusIdBits.isEmpty()) {
+ uint32_t id = mCurrentStylusIdBits.firstMarkedBit();
+ uint32_t index = mCurrentCookedPointerData.idToIndex[id];
+ float x = mCurrentCookedPointerData.pointerCoords[index].getX();
+ float y = mCurrentCookedPointerData.pointerCoords[index].getY();
+ mPointerController->setPosition(x, y);
+
+ hovering = mCurrentCookedPointerData.hoveringIdBits.hasBit(id);
+ down = !hovering;
+
+ mPointerController->getPosition(&x, &y);
+ mPointerSimple.currentCoords.copyFrom(mCurrentCookedPointerData.pointerCoords[index]);
+ mPointerSimple.currentCoords.setAxisValue(AMOTION_EVENT_AXIS_X, x);
+ mPointerSimple.currentCoords.setAxisValue(AMOTION_EVENT_AXIS_Y, y);
+ mPointerSimple.currentProperties.id = 0;
+ mPointerSimple.currentProperties.toolType =
+ mCurrentCookedPointerData.pointerProperties[index].toolType;
+ } else {
+ down = false;
+ hovering = false;
+ }
+
+ dispatchPointerSimple(when, policyFlags, down, hovering);
+}
+
+void TouchInputMapper::abortPointerStylus(nsecs_t when, uint32_t policyFlags) {
+ abortPointerSimple(when, policyFlags);
+}
+
+void TouchInputMapper::dispatchPointerMouse(nsecs_t when, uint32_t policyFlags) {
+ mPointerSimple.currentCoords.clear();
+ mPointerSimple.currentProperties.clear();
+
+ bool down, hovering;
+ if (!mCurrentMouseIdBits.isEmpty()) {
+ uint32_t id = mCurrentMouseIdBits.firstMarkedBit();
+ uint32_t currentIndex = mCurrentRawPointerData.idToIndex[id];
+ if (mLastMouseIdBits.hasBit(id)) {
+ uint32_t lastIndex = mCurrentRawPointerData.idToIndex[id];
+ float deltaX = (mCurrentRawPointerData.pointers[currentIndex].x
+ - mLastRawPointerData.pointers[lastIndex].x)
+ * mPointerXMovementScale;
+ float deltaY = (mCurrentRawPointerData.pointers[currentIndex].y
+ - mLastRawPointerData.pointers[lastIndex].y)
+ * mPointerYMovementScale;
+
+ rotateDelta(mSurfaceOrientation, &deltaX, &deltaY);
+ mPointerVelocityControl.move(when, &deltaX, &deltaY);
+
+ mPointerController->move(deltaX, deltaY);
+ } else {
+ mPointerVelocityControl.reset();
+ }
+
+ down = isPointerDown(mCurrentButtonState);
+ hovering = !down;
+
+ float x, y;
+ mPointerController->getPosition(&x, &y);
+ mPointerSimple.currentCoords.copyFrom(
+ mCurrentCookedPointerData.pointerCoords[currentIndex]);
+ mPointerSimple.currentCoords.setAxisValue(AMOTION_EVENT_AXIS_X, x);
+ mPointerSimple.currentCoords.setAxisValue(AMOTION_EVENT_AXIS_Y, y);
+ mPointerSimple.currentCoords.setAxisValue(AMOTION_EVENT_AXIS_PRESSURE,
+ hovering ? 0.0f : 1.0f);
+ mPointerSimple.currentProperties.id = 0;
+ mPointerSimple.currentProperties.toolType =
+ mCurrentCookedPointerData.pointerProperties[currentIndex].toolType;
+ } else {
+ mPointerVelocityControl.reset();
+
+ down = false;
+ hovering = false;
+ }
+
+ dispatchPointerSimple(when, policyFlags, down, hovering);
+}
+
+void TouchInputMapper::abortPointerMouse(nsecs_t when, uint32_t policyFlags) {
+ abortPointerSimple(when, policyFlags);
+
+ mPointerVelocityControl.reset();
+}
+
+void TouchInputMapper::dispatchPointerSimple(nsecs_t when, uint32_t policyFlags,
+ bool down, bool hovering) {
+ int32_t metaState = getContext()->getGlobalMetaState();
+
+ if (mPointerController != NULL) {
+ if (down || hovering) {
+ mPointerController->setPresentation(PointerControllerInterface::PRESENTATION_POINTER);
+ mPointerController->clearSpots();
+ mPointerController->setButtonState(mCurrentButtonState);
+ mPointerController->unfade(PointerControllerInterface::TRANSITION_IMMEDIATE);
+ } else if (!down && !hovering && (mPointerSimple.down || mPointerSimple.hovering)) {
+ mPointerController->fade(PointerControllerInterface::TRANSITION_GRADUAL);
+ }
+ }
+
+ if (mPointerSimple.down && !down) {
+ mPointerSimple.down = false;
+
+ // Send up.
+ NotifyMotionArgs args(when, getDeviceId(), mSource, policyFlags,
+ AMOTION_EVENT_ACTION_UP, 0, metaState, mLastButtonState, 0,
+ 1, &mPointerSimple.lastProperties, &mPointerSimple.lastCoords,
+ mOrientedXPrecision, mOrientedYPrecision,
+ mPointerSimple.downTime);
+ getListener()->notifyMotion(&args);
+ }
+
+ if (mPointerSimple.hovering && !hovering) {
+ mPointerSimple.hovering = false;
+
+ // Send hover exit.
+ NotifyMotionArgs args(when, getDeviceId(), mSource, policyFlags,
+ AMOTION_EVENT_ACTION_HOVER_EXIT, 0, metaState, mLastButtonState, 0,
+ 1, &mPointerSimple.lastProperties, &mPointerSimple.lastCoords,
+ mOrientedXPrecision, mOrientedYPrecision,
+ mPointerSimple.downTime);
+ getListener()->notifyMotion(&args);
+ }
+
+ if (down) {
+ if (!mPointerSimple.down) {
+ mPointerSimple.down = true;
+ mPointerSimple.downTime = when;
+
+ // Send down.
+ NotifyMotionArgs args(when, getDeviceId(), mSource, policyFlags,
+ AMOTION_EVENT_ACTION_DOWN, 0, metaState, mCurrentButtonState, 0,
+ 1, &mPointerSimple.currentProperties, &mPointerSimple.currentCoords,
+ mOrientedXPrecision, mOrientedYPrecision,
+ mPointerSimple.downTime);
+ getListener()->notifyMotion(&args);
+ }
+
+ // Send move.
+ NotifyMotionArgs args(when, getDeviceId(), mSource, policyFlags,
+ AMOTION_EVENT_ACTION_MOVE, 0, metaState, mCurrentButtonState, 0,
+ 1, &mPointerSimple.currentProperties, &mPointerSimple.currentCoords,
+ mOrientedXPrecision, mOrientedYPrecision,
+ mPointerSimple.downTime);
+ getListener()->notifyMotion(&args);
+ }
+
+ if (hovering) {
+ if (!mPointerSimple.hovering) {
+ mPointerSimple.hovering = true;
+
+ // Send hover enter.
+ NotifyMotionArgs args(when, getDeviceId(), mSource, policyFlags,
+ AMOTION_EVENT_ACTION_HOVER_ENTER, 0, metaState, mCurrentButtonState, 0,
+ 1, &mPointerSimple.currentProperties, &mPointerSimple.currentCoords,
+ mOrientedXPrecision, mOrientedYPrecision,
+ mPointerSimple.downTime);
+ getListener()->notifyMotion(&args);
+ }
+
+ // Send hover move.
+ NotifyMotionArgs args(when, getDeviceId(), mSource, policyFlags,
+ AMOTION_EVENT_ACTION_HOVER_MOVE, 0, metaState, mCurrentButtonState, 0,
+ 1, &mPointerSimple.currentProperties, &mPointerSimple.currentCoords,
+ mOrientedXPrecision, mOrientedYPrecision,
+ mPointerSimple.downTime);
+ getListener()->notifyMotion(&args);
+ }
+
+ if (mCurrentRawVScroll || mCurrentRawHScroll) {
+ float vscroll = mCurrentRawVScroll;
+ float hscroll = mCurrentRawHScroll;
+ mWheelYVelocityControl.move(when, NULL, &vscroll);
+ mWheelXVelocityControl.move(when, &hscroll, NULL);
+
+ // Send scroll.
+ PointerCoords pointerCoords;
+ pointerCoords.copyFrom(mPointerSimple.currentCoords);
+ pointerCoords.setAxisValue(AMOTION_EVENT_AXIS_VSCROLL, vscroll);
+ pointerCoords.setAxisValue(AMOTION_EVENT_AXIS_HSCROLL, hscroll);
+
+ NotifyMotionArgs args(when, getDeviceId(), mSource, policyFlags,
+ AMOTION_EVENT_ACTION_SCROLL, 0, metaState, mCurrentButtonState, 0,
+ 1, &mPointerSimple.currentProperties, &pointerCoords,
+ mOrientedXPrecision, mOrientedYPrecision,
+ mPointerSimple.downTime);
+ getListener()->notifyMotion(&args);
+ }
+
+ // Save state.
+ if (down || hovering) {
+ mPointerSimple.lastCoords.copyFrom(mPointerSimple.currentCoords);
+ mPointerSimple.lastProperties.copyFrom(mPointerSimple.currentProperties);
+ } else {
+ mPointerSimple.reset();
+ }
+}
+
+void TouchInputMapper::abortPointerSimple(nsecs_t when, uint32_t policyFlags) {
+ mPointerSimple.currentCoords.clear();
+ mPointerSimple.currentProperties.clear();
+
+ dispatchPointerSimple(when, policyFlags, false, false);
+}
+
void TouchInputMapper::dispatchMotion(nsecs_t when, uint32_t policyFlags, uint32_t source,
int32_t action, int32_t flags, int32_t metaState, int32_t buttonState, int32_t edgeFlags,
const PointerProperties* properties, const PointerCoords* coords,
@@ -4862,44 +5453,32 @@ bool TouchInputMapper::markSupportedKeyCodes(uint32_t sourceMask, size_t numCode
SingleTouchInputMapper::SingleTouchInputMapper(InputDevice* device) :
TouchInputMapper(device) {
- clearState();
}
SingleTouchInputMapper::~SingleTouchInputMapper() {
}
-void SingleTouchInputMapper::clearState() {
- mCursorButtonAccumulator.clearButtons();
- mTouchButtonAccumulator.clearButtons();
- mSingleTouchMotionAccumulator.clearAbsoluteAxes();
-}
+void SingleTouchInputMapper::reset(nsecs_t when) {
+ mSingleTouchMotionAccumulator.reset(getDevice());
-void SingleTouchInputMapper::reset() {
- TouchInputMapper::reset();
-
- clearState();
- }
+ TouchInputMapper::reset(when);
+}
void SingleTouchInputMapper::process(const RawEvent* rawEvent) {
- mCursorButtonAccumulator.process(rawEvent);
- mTouchButtonAccumulator.process(rawEvent);
- mSingleTouchMotionAccumulator.process(rawEvent);
+ TouchInputMapper::process(rawEvent);
- if (rawEvent->type == EV_SYN && rawEvent->scanCode == SYN_REPORT) {
- sync(rawEvent->when);
- }
+ mSingleTouchMotionAccumulator.process(rawEvent);
}
-void SingleTouchInputMapper::sync(nsecs_t when) {
- mCurrentRawPointerData.clear();
- mCurrentButtonState = 0;
-
+void SingleTouchInputMapper::syncTouch(nsecs_t when, bool* outHavePointerIds) {
if (mTouchButtonAccumulator.isToolActive()) {
mCurrentRawPointerData.pointerCount = 1;
mCurrentRawPointerData.idToIndex[0] = 0;
- bool isHovering = mTouchButtonAccumulator.isHovering()
- || mSingleTouchMotionAccumulator.getAbsoluteDistance() > 0;
+ bool isHovering = mTouchButtonAccumulator.getToolType() != AMOTION_EVENT_TOOL_TYPE_MOUSE
+ && (mTouchButtonAccumulator.isHovering()
+ || (mRawPointerAxes.pressure.valid
+ && mSingleTouchMotionAccumulator.getAbsolutePressure() <= 0));
mCurrentRawPointerData.markIdBit(0, isHovering);
RawPointerData::Pointer& outPointer = mCurrentRawPointerData.pointers[0];
@@ -4913,29 +5492,26 @@ void SingleTouchInputMapper::sync(nsecs_t when) {
outPointer.toolMinor = mSingleTouchMotionAccumulator.getAbsoluteToolWidth();
outPointer.orientation = 0;
outPointer.distance = mSingleTouchMotionAccumulator.getAbsoluteDistance();
+ outPointer.tiltX = mSingleTouchMotionAccumulator.getAbsoluteTiltX();
+ outPointer.tiltY = mSingleTouchMotionAccumulator.getAbsoluteTiltY();
outPointer.toolType = mTouchButtonAccumulator.getToolType();
if (outPointer.toolType == AMOTION_EVENT_TOOL_TYPE_UNKNOWN) {
outPointer.toolType = AMOTION_EVENT_TOOL_TYPE_FINGER;
}
outPointer.isHovering = isHovering;
}
-
- mCurrentButtonState = mTouchButtonAccumulator.getButtonState()
- | mCursorButtonAccumulator.getButtonState();
-
- syncTouch(when, true);
}
void SingleTouchInputMapper::configureRawPointerAxes() {
TouchInputMapper::configureRawPointerAxes();
- mTouchButtonAccumulator.configure(getDevice());
-
getAbsoluteAxisInfo(ABS_X, &mRawPointerAxes.x);
getAbsoluteAxisInfo(ABS_Y, &mRawPointerAxes.y);
getAbsoluteAxisInfo(ABS_PRESSURE, &mRawPointerAxes.pressure);
getAbsoluteAxisInfo(ABS_TOOL_WIDTH, &mRawPointerAxes.toolMajor);
getAbsoluteAxisInfo(ABS_DISTANCE, &mRawPointerAxes.distance);
+ getAbsoluteAxisInfo(ABS_TILT_X, &mRawPointerAxes.tiltX);
+ getAbsoluteAxisInfo(ABS_TILT_Y, &mRawPointerAxes.tiltY);
}
@@ -4948,58 +5524,25 @@ MultiTouchInputMapper::MultiTouchInputMapper(InputDevice* device) :
MultiTouchInputMapper::~MultiTouchInputMapper() {
}
-void MultiTouchInputMapper::clearState() {
- mCursorButtonAccumulator.clearButtons();
- mTouchButtonAccumulator.clearButtons();
- mPointerIdBits.clear();
+void MultiTouchInputMapper::reset(nsecs_t when) {
+ mMultiTouchMotionAccumulator.reset(getDevice());
- if (mMultiTouchMotionAccumulator.isUsingSlotsProtocol()) {
- // Query the driver for the current slot index and use it as the initial slot
- // before we start reading events from the device. It is possible that the
- // current slot index will not be the same as it was when the first event was
- // written into the evdev buffer, which means the input mapper could start
- // out of sync with the initial state of the events in the evdev buffer.
- // In the extremely unlikely case that this happens, the data from
- // two slots will be confused until the next ABS_MT_SLOT event is received.
- // This can cause the touch point to "jump", but at least there will be
- // no stuck touches.
- int32_t initialSlot;
- status_t status = getEventHub()->getAbsoluteAxisValue(getDeviceId(), ABS_MT_SLOT,
- &initialSlot);
- if (status) {
- LOGW("Could not retrieve current multitouch slot index. status=%d", status);
- initialSlot = -1;
- }
- mMultiTouchMotionAccumulator.clearSlots(initialSlot);
- } else {
- mMultiTouchMotionAccumulator.clearSlots(-1);
- }
-}
-
-void MultiTouchInputMapper::reset() {
- TouchInputMapper::reset();
+ mPointerIdBits.clear();
- clearState();
+ TouchInputMapper::reset(when);
}
void MultiTouchInputMapper::process(const RawEvent* rawEvent) {
- mCursorButtonAccumulator.process(rawEvent);
- mTouchButtonAccumulator.process(rawEvent);
- mMultiTouchMotionAccumulator.process(rawEvent);
+ TouchInputMapper::process(rawEvent);
- if (rawEvent->type == EV_SYN && rawEvent->scanCode == SYN_REPORT) {
- sync(rawEvent->when);
- }
+ mMultiTouchMotionAccumulator.process(rawEvent);
}
-void MultiTouchInputMapper::sync(nsecs_t when) {
+void MultiTouchInputMapper::syncTouch(nsecs_t when, bool* outHavePointerIds) {
size_t inCount = mMultiTouchMotionAccumulator.getSlotCount();
size_t outCount = 0;
- bool havePointerIds = true;
BitSet32 newPointerIdBits;
- mCurrentRawPointerData.clear();
-
for (size_t inIndex = 0; inIndex < inCount; inIndex++) {
const MultiTouchMotionAccumulator::Slot* inSlot =
mMultiTouchMotionAccumulator.getSlot(inIndex);
@@ -5026,6 +5569,8 @@ void MultiTouchInputMapper::sync(nsecs_t when) {
outPointer.toolMinor = inSlot->getToolMinor();
outPointer.orientation = inSlot->getOrientation();
outPointer.distance = inSlot->getDistance();
+ outPointer.tiltX = 0;
+ outPointer.tiltY = 0;
outPointer.toolType = inSlot->getToolType();
if (outPointer.toolType == AMOTION_EVENT_TOOL_TYPE_UNKNOWN) {
@@ -5035,12 +5580,13 @@ void MultiTouchInputMapper::sync(nsecs_t when) {
}
}
- bool isHovering = mTouchButtonAccumulator.isHovering()
- || inSlot->getDistance() > 0;
+ bool isHovering = mTouchButtonAccumulator.getToolType() != AMOTION_EVENT_TOOL_TYPE_MOUSE
+ && (mTouchButtonAccumulator.isHovering()
+ || (mRawPointerAxes.pressure.valid && inSlot->getPressure() <= 0));
outPointer.isHovering = isHovering;
// Assign pointer id using tracking id if available.
- if (havePointerIds) {
+ if (*outHavePointerIds) {
int32_t trackingId = inSlot->getTrackingId();
int32_t id = -1;
if (trackingId >= 0) {
@@ -5057,7 +5603,7 @@ void MultiTouchInputMapper::sync(nsecs_t when) {
}
}
if (id < 0) {
- havePointerIds = false;
+ *outHavePointerIds = false;
mCurrentRawPointerData.clearIdBits();
newPointerIdBits.clear();
} else {
@@ -5072,23 +5618,14 @@ void MultiTouchInputMapper::sync(nsecs_t when) {
}
mCurrentRawPointerData.pointerCount = outCount;
- mCurrentButtonState = mTouchButtonAccumulator.getButtonState()
- | mCursorButtonAccumulator.getButtonState();
-
mPointerIdBits = newPointerIdBits;
- syncTouch(when, havePointerIds);
-
- if (!mMultiTouchMotionAccumulator.isUsingSlotsProtocol()) {
- mMultiTouchMotionAccumulator.clearSlots(-1);
- }
+ mMultiTouchMotionAccumulator.finishSync();
}
void MultiTouchInputMapper::configureRawPointerAxes() {
TouchInputMapper::configureRawPointerAxes();
- mTouchButtonAccumulator.configure(getDevice());
-
getAbsoluteAxisInfo(ABS_MT_POSITION_X, &mRawPointerAxes.x);
getAbsoluteAxisInfo(ABS_MT_POSITION_Y, &mRawPointerAxes.y);
getAbsoluteAxisInfo(ABS_MT_TOUCH_MAJOR, &mRawPointerAxes.touchMajor);
@@ -5115,8 +5652,6 @@ void MultiTouchInputMapper::configureRawPointerAxes() {
} else {
mMultiTouchMotionAccumulator.configure(MAX_POINTERS, false /*usingSlotsProtocol*/);
}
-
- clearState();
}
@@ -5184,8 +5719,9 @@ void JoystickInputMapper::dump(String8& dump) {
}
}
-void JoystickInputMapper::configure(const InputReaderConfiguration* config, uint32_t changes) {
- InputMapper::configure(config, changes);
+void JoystickInputMapper::configure(nsecs_t when,
+ const InputReaderConfiguration* config, uint32_t changes) {
+ InputMapper::configure(when, config, changes);
if (!changes) { // first time only
// Collect all axes.
@@ -5314,19 +5850,15 @@ bool JoystickInputMapper::isCenteredAxis(int32_t axis) {
}
}
-void JoystickInputMapper::reset() {
+void JoystickInputMapper::reset(nsecs_t when) {
// Recenter all axes.
- nsecs_t when = systemTime(SYSTEM_TIME_MONOTONIC);
-
size_t numAxes = mAxes.size();
for (size_t i = 0; i < numAxes; i++) {
Axis& axis = mAxes.editValueAt(i);
axis.resetValue();
}
- sync(when, true /*force*/);
-
- InputMapper::reset();
+ InputMapper::reset(when);
}
void JoystickInputMapper::process(const RawEvent* rawEvent) {
diff --git a/services/input/InputReader.h b/services/input/InputReader.h
index 72802fc..76d77f1 100644
--- a/services/input/InputReader.h
+++ b/services/input/InputReader.h
@@ -53,6 +53,9 @@ struct InputReaderConfiguration {
// The pointer gesture control changed.
CHANGE_POINTER_GESTURE_ENABLEMENT = 1 << 1,
+ // The display size or orientation changed.
+ CHANGE_DISPLAY_INFO = 1 << 2,
+
// All devices must be reopened.
CHANGE_MUST_REOPEN = 1 << 31,
};
@@ -153,6 +156,26 @@ struct InputReaderConfiguration {
pointerGestureSwipeMaxWidthRatio(0.25f),
pointerGestureMovementSpeedRatio(0.8f),
pointerGestureZoomSpeedRatio(0.3f) { }
+
+ bool getDisplayInfo(int32_t displayId, bool external,
+ int32_t* width, int32_t* height, int32_t* orientation) const;
+
+ void setDisplayInfo(int32_t displayId, bool external,
+ int32_t width, int32_t height, int32_t orientation);
+
+private:
+ struct DisplayInfo {
+ int32_t width;
+ int32_t height;
+ int32_t orientation;
+
+ DisplayInfo() :
+ width(-1), height(-1), orientation(DISPLAY_ORIENTATION_0) {
+ }
+ };
+
+ DisplayInfo mInternalDisplay;
+ DisplayInfo mExternalDisplay;
};
@@ -174,22 +197,6 @@ protected:
virtual ~InputReaderPolicyInterface() { }
public:
- /* Display orientations. */
- enum {
- ROTATION_0 = 0,
- ROTATION_90 = 1,
- ROTATION_180 = 2,
- ROTATION_270 = 3
- };
-
- /* Gets information about the display with the specified id.
- * If external is true, returns the size of the external mirrored
- * counterpart of the specified display.
- * Returns true if the display info is available, false otherwise.
- */
- virtual bool getDisplayInfo(int32_t displayId, bool external,
- int32_t* width, int32_t* height, int32_t* orientation) = 0;
-
/* Gets the input reader configuration. */
virtual void getReaderConfiguration(InputReaderConfiguration* outConfig) = 0;
@@ -364,8 +371,8 @@ private:
// low-level input event decoding and device management
void processEventsLocked(const RawEvent* rawEvents, size_t count);
- void addDeviceLocked(int32_t deviceId);
- void removeDeviceLocked(int32_t deviceId);
+ void addDeviceLocked(nsecs_t when, int32_t deviceId);
+ void removeDeviceLocked(nsecs_t when, int32_t deviceId);
void processEventsForDeviceLocked(int32_t deviceId, const RawEvent* rawEvents, size_t count);
void timeoutExpiredLocked(nsecs_t when);
@@ -431,8 +438,8 @@ public:
void dump(String8& dump);
void addMapper(InputMapper* mapper);
- void configure(const InputReaderConfiguration* config, uint32_t changes);
- void reset();
+ void configure(nsecs_t when, const InputReaderConfiguration* config, uint32_t changes);
+ void reset(nsecs_t when);
void process(const RawEvent* rawEvents, size_t count);
void timeoutExpired(nsecs_t when);
@@ -447,9 +454,25 @@ public:
void fadePointer();
+ void notifyReset(nsecs_t when);
+
inline const PropertyMap& getConfiguration() { return mConfiguration; }
inline EventHubInterface* getEventHub() { return mContext->getEventHub(); }
+ bool hasKey(int32_t code) {
+ return getEventHub()->hasScanCode(mId, code);
+ }
+
+ bool isKeyPressed(int32_t code) {
+ return getEventHub()->getScanCodeState(mId, code) == AKEY_STATE_DOWN;
+ }
+
+ int32_t getAbsoluteAxisValue(int32_t code) {
+ int32_t value;
+ getEventHub()->getAbsoluteAxisValue(mId, code, &value);
+ return value;
+ }
+
private:
InputReaderContext* mContext;
int32_t mId;
@@ -472,8 +495,8 @@ private:
class CursorButtonAccumulator {
public:
CursorButtonAccumulator();
+ void reset(InputDevice* device);
- void clearButtons();
void process(const RawEvent* rawEvent);
uint32_t getButtonState() const;
@@ -487,6 +510,8 @@ private:
bool mBtnForward;
bool mBtnExtra;
bool mBtnTask;
+
+ void clearButtons();
};
@@ -495,10 +520,32 @@ private:
class CursorMotionAccumulator {
public:
CursorMotionAccumulator();
- void configure(InputDevice* device);
+ void reset(InputDevice* device);
+
+ void process(const RawEvent* rawEvent);
+ void finishSync();
+
+ inline int32_t getRelativeX() const { return mRelX; }
+ inline int32_t getRelativeY() const { return mRelY; }
+
+private:
+ int32_t mRelX;
+ int32_t mRelY;
void clearRelativeAxes();
+};
+
+
+/* Keeps track of cursor scrolling motions. */
+
+class CursorScrollAccumulator {
+public:
+ CursorScrollAccumulator();
+ void configure(InputDevice* device);
+ void reset(InputDevice* device);
+
void process(const RawEvent* rawEvent);
+ void finishSync();
inline bool haveRelativeVWheel() const { return mHaveRelWheel; }
inline bool haveRelativeHWheel() const { return mHaveRelHWheel; }
@@ -516,6 +563,8 @@ private:
int32_t mRelY;
int32_t mRelWheel;
int32_t mRelHWheel;
+
+ void clearRelativeAxes();
};
@@ -524,8 +573,8 @@ class TouchButtonAccumulator {
public:
TouchButtonAccumulator();
void configure(InputDevice* device);
+ void reset(InputDevice* device);
- void clearButtons();
void process(const RawEvent* rawEvent);
uint32_t getButtonState() const;
@@ -542,6 +591,13 @@ private:
bool mBtnToolFinger;
bool mBtnToolPen;
bool mBtnToolRubber;
+ bool mBtnToolBrush;
+ bool mBtnToolPencil;
+ bool mBtnToolAirbrush;
+ bool mBtnToolMouse;
+ bool mBtnToolLens;
+
+ void clearButtons();
};
@@ -556,6 +612,8 @@ struct RawPointerAxes {
RawAbsoluteAxisInfo toolMinor;
RawAbsoluteAxisInfo orientation;
RawAbsoluteAxisInfo distance;
+ RawAbsoluteAxisInfo tiltX;
+ RawAbsoluteAxisInfo tiltY;
RawAbsoluteAxisInfo trackingId;
RawAbsoluteAxisInfo slot;
@@ -577,6 +635,8 @@ struct RawPointerData {
int32_t toolMinor;
int32_t orientation;
int32_t distance;
+ int32_t tiltX;
+ int32_t tiltY;
int32_t toolType; // a fully decoded AMOTION_EVENT_TOOL_TYPE constant
bool isHovering;
};
@@ -637,14 +697,16 @@ class SingleTouchMotionAccumulator {
public:
SingleTouchMotionAccumulator();
- void clearAbsoluteAxes();
void process(const RawEvent* rawEvent);
+ void reset(InputDevice* device);
inline int32_t getAbsoluteX() const { return mAbsX; }
inline int32_t getAbsoluteY() const { return mAbsY; }
inline int32_t getAbsolutePressure() const { return mAbsPressure; }
inline int32_t getAbsoluteToolWidth() const { return mAbsToolWidth; }
inline int32_t getAbsoluteDistance() const { return mAbsDistance; }
+ inline int32_t getAbsoluteTiltX() const { return mAbsTiltX; }
+ inline int32_t getAbsoluteTiltY() const { return mAbsTiltY; }
private:
int32_t mAbsX;
@@ -652,6 +714,10 @@ private:
int32_t mAbsPressure;
int32_t mAbsToolWidth;
int32_t mAbsDistance;
+ int32_t mAbsTiltX;
+ int32_t mAbsTiltY;
+
+ void clearAbsoluteAxes();
};
@@ -703,11 +769,10 @@ public:
~MultiTouchMotionAccumulator();
void configure(size_t slotCount, bool usingSlotsProtocol);
+ void reset(InputDevice* device);
void process(const RawEvent* rawEvent);
+ void finishSync();
- void clearSlots(int32_t initialSlot);
-
- inline bool isUsingSlotsProtocol() const { return mUsingSlotsProtocol; }
inline size_t getSlotCount() const { return mSlotCount; }
inline const Slot* getSlot(size_t index) const { return &mSlots[index]; }
@@ -716,12 +781,22 @@ private:
Slot* mSlots;
size_t mSlotCount;
bool mUsingSlotsProtocol;
+
+ void clearSlots(int32_t initialSlot);
};
/* An input mapper transforms raw input events into cooked event data.
* A single input device can have multiple associated input mappers in order to interpret
* different classes of events.
+ *
+ * InputMapper lifecycle:
+ * - create
+ * - configure with 0 changes
+ * - reset
+ * - process, process, process (may occasionally reconfigure with non-zero changes or reset)
+ * - reset
+ * - destroy
*/
class InputMapper {
public:
@@ -739,8 +814,8 @@ public:
virtual uint32_t getSources() = 0;
virtual void populateDeviceInfo(InputDeviceInfo* deviceInfo);
virtual void dump(String8& dump);
- virtual void configure(const InputReaderConfiguration* config, uint32_t changes);
- virtual void reset();
+ virtual void configure(nsecs_t when, const InputReaderConfiguration* config, uint32_t changes);
+ virtual void reset(nsecs_t when);
virtual void process(const RawEvent* rawEvent) = 0;
virtual void timeoutExpired(nsecs_t when);
@@ -788,8 +863,8 @@ public:
virtual uint32_t getSources();
virtual void populateDeviceInfo(InputDeviceInfo* deviceInfo);
virtual void dump(String8& dump);
- virtual void configure(const InputReaderConfiguration* config, uint32_t changes);
- virtual void reset();
+ virtual void configure(nsecs_t when, const InputReaderConfiguration* config, uint32_t changes);
+ virtual void reset(nsecs_t when);
virtual void process(const RawEvent* rawEvent);
virtual int32_t getKeyCodeState(uint32_t sourceMask, int32_t keyCode);
@@ -800,8 +875,6 @@ public:
virtual int32_t getMetaState();
private:
- Mutex mLock;
-
struct KeyDown {
int32_t keyCode;
int32_t scanCode;
@@ -810,6 +883,8 @@ private:
uint32_t mSource;
int32_t mKeyboardType;
+ int32_t mOrientation; // orientation for dpad keys
+
Vector<KeyDown> mKeyDowns; // keys that are down
int32_t mMetaState;
nsecs_t mDownTime; // time of most recent key down
@@ -828,8 +903,6 @@ private:
bool orientationAware;
} mParameters;
- void initialize();
-
void configureParameters();
void dumpParameters(String8& dump);
@@ -856,8 +929,8 @@ public:
virtual uint32_t getSources();
virtual void populateDeviceInfo(InputDeviceInfo* deviceInfo);
virtual void dump(String8& dump);
- virtual void configure(const InputReaderConfiguration* config, uint32_t changes);
- virtual void reset();
+ virtual void configure(nsecs_t when, const InputReaderConfiguration* config, uint32_t changes);
+ virtual void reset(nsecs_t when);
virtual void process(const RawEvent* rawEvent);
virtual int32_t getScanCodeState(uint32_t sourceMask, int32_t scanCode);
@@ -882,6 +955,7 @@ private:
CursorButtonAccumulator mCursorButtonAccumulator;
CursorMotionAccumulator mCursorMotionAccumulator;
+ CursorScrollAccumulator mCursorScrollAccumulator;
int32_t mSource;
float mXScale;
@@ -898,13 +972,13 @@ private:
VelocityControl mWheelXVelocityControl;
VelocityControl mWheelYVelocityControl;
+ int32_t mOrientation;
+
sp<PointerControllerInterface> mPointerController;
int32_t mButtonState;
nsecs_t mDownTime;
- void initialize();
-
void configureParameters();
void dumpParameters(String8& dump);
@@ -920,8 +994,9 @@ public:
virtual uint32_t getSources();
virtual void populateDeviceInfo(InputDeviceInfo* deviceInfo);
virtual void dump(String8& dump);
- virtual void configure(const InputReaderConfiguration* config, uint32_t changes);
- virtual void reset();
+ virtual void configure(nsecs_t when, const InputReaderConfiguration* config, uint32_t changes);
+ virtual void reset(nsecs_t when);
+ virtual void process(const RawEvent* rawEvent);
virtual int32_t getKeyCodeState(uint32_t sourceMask, int32_t keyCode);
virtual int32_t getScanCodeState(uint32_t sourceMask, int32_t scanCode);
@@ -932,6 +1007,10 @@ public:
virtual void timeoutExpired(nsecs_t when);
protected:
+ CursorButtonAccumulator mCursorButtonAccumulator;
+ CursorScrollAccumulator mCursorScrollAccumulator;
+ TouchButtonAccumulator mTouchButtonAccumulator;
+
struct VirtualKey {
int32_t keyCode;
int32_t scanCode;
@@ -948,9 +1027,16 @@ protected:
}
};
- // Input sources supported by the device.
- uint32_t mTouchSource; // sources when reporting touch data
- uint32_t mPointerSource; // sources when reporting pointer gestures
+ // Input sources and device mode.
+ uint32_t mSource;
+
+ enum DeviceMode {
+ DEVICE_MODE_DISABLED, // input is disabled
+ DEVICE_MODE_DIRECT, // direct mapping (touchscreen)
+ DEVICE_MODE_UNSCALED, // unscaled mapping (touchpad)
+ DEVICE_MODE_POINTER, // pointer mapping (pointer)
+ };
+ DeviceMode mDeviceMode;
// The reader's configuration.
InputReaderConfiguration mConfig;
@@ -1053,6 +1139,18 @@ protected:
int32_t mCurrentButtonState;
int32_t mLastButtonState;
+ // Scroll state.
+ int32_t mCurrentRawVScroll;
+ int32_t mCurrentRawHScroll;
+
+ // Id bits used to differentiate fingers, stylus and mouse tools.
+ BitSet32 mCurrentFingerIdBits; // finger or unknown
+ BitSet32 mLastFingerIdBits;
+ BitSet32 mCurrentStylusIdBits; // stylus or eraser
+ BitSet32 mLastStylusIdBits;
+ BitSet32 mCurrentMouseIdBits; // mouse or lens
+ BitSet32 mLastMouseIdBits;
+
// True if we sent a HOVER_ENTER event.
bool mSentHoverEnter;
@@ -1068,7 +1166,7 @@ protected:
virtual void dumpParameters(String8& dump);
virtual void configureRawPointerAxes();
virtual void dumpRawPointerAxes(String8& dump);
- virtual bool configureSurface();
+ virtual void configureSurface(nsecs_t when, bool* outResetNeeded);
virtual void dumpSurface(String8& dump);
virtual void configureVirtualKeys();
virtual void dumpVirtualKeys(String8& dump);
@@ -1076,7 +1174,7 @@ protected:
virtual void resolveCalibration();
virtual void dumpCalibration(String8& dump);
- void syncTouch(nsecs_t when, bool havePointerIds);
+ virtual void syncTouch(nsecs_t when, bool* outHavePointerIds) = 0;
private:
// The surface orientation and width and height set by configureSurface().
@@ -1102,16 +1200,21 @@ private:
float mSizeScale;
+ float mOrientationCenter;
float mOrientationScale;
float mDistanceScale;
+ bool mHaveTilt;
+ float mTiltXCenter;
+ float mTiltXScale;
+ float mTiltYCenter;
+ float mTiltYScale;
+
// Oriented motion ranges for input device info.
struct OrientedRanges {
InputDeviceInfo::MotionRange x;
InputDeviceInfo::MotionRange y;
-
- bool havePressure;
InputDeviceInfo::MotionRange pressure;
bool haveSize;
@@ -1130,6 +1233,22 @@ private:
bool haveDistance;
InputDeviceInfo::MotionRange distance;
+
+ bool haveTilt;
+ InputDeviceInfo::MotionRange tilt;
+
+ OrientedRanges() {
+ clear();
+ }
+
+ void clear() {
+ haveSize = false;
+ haveTouchSize = false;
+ haveToolSize = false;
+ haveOrientation = false;
+ haveDistance = false;
+ haveTilt = false;
+ }
} mOrientedRanges;
// Oriented dimensions and precision.
@@ -1146,13 +1265,13 @@ private:
int32_t scanCode;
} mCurrentVirtualKey;
- // Scale factor for gesture based pointer movements.
- float mPointerGestureXMovementScale;
- float mPointerGestureYMovementScale;
+ // Scale factor for gesture or mouse based pointer movements.
+ float mPointerXMovementScale;
+ float mPointerYMovementScale;
// Scale factor for gesture based zooming and other freeform motions.
- float mPointerGestureXZoomScale;
- float mPointerGestureYZoomScale;
+ float mPointerXZoomScale;
+ float mPointerYZoomScale;
// The maximum swipe width.
float mPointerGestureMaxSwipeWidth;
@@ -1163,6 +1282,14 @@ private:
uint64_t distance : 48; // squared distance
};
+ enum PointerUsage {
+ POINTER_USAGE_NONE,
+ POINTER_USAGE_GESTURES,
+ POINTER_USAGE_STYLUS,
+ POINTER_USAGE_MOUSE,
+ };
+ PointerUsage mPointerUsage;
+
struct PointerGesture {
enum Mode {
// No fingers, button is not pressed.
@@ -1273,9 +1400,6 @@ private:
// A velocity tracker for determining whether to switch active pointers during drags.
VelocityTracker velocityTracker;
- // Velocity control for pointer movements.
- VelocityControl pointerVelocityControl;
-
void reset() {
firstTouchTime = LLONG_MIN;
activeTouchId = -1;
@@ -1288,7 +1412,6 @@ private:
velocityTracker.clear();
resetTap();
resetQuietTime();
- pointerVelocityControl.reset();
}
void resetTap() {
@@ -1301,7 +1424,38 @@ private:
}
} mPointerGesture;
- void initialize();
+ struct PointerSimple {
+ PointerCoords currentCoords;
+ PointerProperties currentProperties;
+ PointerCoords lastCoords;
+ PointerProperties lastProperties;
+
+ // True if the pointer is down.
+ bool down;
+
+ // True if the pointer is hovering.
+ bool hovering;
+
+ // Time the pointer last went down.
+ nsecs_t downTime;
+
+ void reset() {
+ currentCoords.clear();
+ currentProperties.clear();
+ lastCoords.clear();
+ lastProperties.clear();
+ down = false;
+ hovering = false;
+ downTime = 0;
+ }
+ } mPointerSimple;
+
+ // The pointer and scroll velocity controls.
+ VelocityControl mPointerVelocityControl;
+ VelocityControl mWheelXVelocityControl;
+ VelocityControl mWheelYVelocityControl;
+
+ void sync(nsecs_t when);
bool consumeRawTouches(nsecs_t when, uint32_t policyFlags);
void dispatchVirtualKey(nsecs_t when, uint32_t policyFlags,
@@ -1312,9 +1466,24 @@ private:
void dispatchHoverEnterAndMove(nsecs_t when, uint32_t policyFlags);
void cookPointerData();
+ void dispatchPointerUsage(nsecs_t when, uint32_t policyFlags, PointerUsage pointerUsage);
+ void abortPointerUsage(nsecs_t when, uint32_t policyFlags);
+
void dispatchPointerGestures(nsecs_t when, uint32_t policyFlags, bool isTimeout);
+ void abortPointerGestures(nsecs_t when, uint32_t policyFlags);
bool preparePointerGestures(nsecs_t when,
- bool* outCancelPreviousGesture, bool* outFinishPreviousGesture, bool isTimeout);
+ bool* outCancelPreviousGesture, bool* outFinishPreviousGesture,
+ bool isTimeout);
+
+ void dispatchPointerStylus(nsecs_t when, uint32_t policyFlags);
+ void abortPointerStylus(nsecs_t when, uint32_t policyFlags);
+
+ void dispatchPointerMouse(nsecs_t when, uint32_t policyFlags);
+ void abortPointerMouse(nsecs_t when, uint32_t policyFlags);
+
+ void dispatchPointerSimple(nsecs_t when, uint32_t policyFlags,
+ bool down, bool hovering);
+ void abortPointerSimple(nsecs_t when, uint32_t policyFlags);
// Dispatches a motion event.
// If the changedId is >= 0 and the action is POINTER_DOWN or POINTER_UP, the
@@ -1346,20 +1515,15 @@ public:
SingleTouchInputMapper(InputDevice* device);
virtual ~SingleTouchInputMapper();
- virtual void reset();
+ virtual void reset(nsecs_t when);
virtual void process(const RawEvent* rawEvent);
protected:
+ virtual void syncTouch(nsecs_t when, bool* outHavePointerIds);
virtual void configureRawPointerAxes();
private:
- CursorButtonAccumulator mCursorButtonAccumulator;
- TouchButtonAccumulator mTouchButtonAccumulator;
SingleTouchMotionAccumulator mSingleTouchMotionAccumulator;
-
- void clearState();
-
- void sync(nsecs_t when);
};
@@ -1368,24 +1532,19 @@ public:
MultiTouchInputMapper(InputDevice* device);
virtual ~MultiTouchInputMapper();
- virtual void reset();
+ virtual void reset(nsecs_t when);
virtual void process(const RawEvent* rawEvent);
protected:
+ virtual void syncTouch(nsecs_t when, bool* outHavePointerIds);
virtual void configureRawPointerAxes();
private:
- CursorButtonAccumulator mCursorButtonAccumulator;
- TouchButtonAccumulator mTouchButtonAccumulator;
MultiTouchMotionAccumulator mMultiTouchMotionAccumulator;
// Specifies the pointer id bits that are in use, and their associated tracking id.
BitSet32 mPointerIdBits;
int32_t mPointerTrackingIdMap[MAX_POINTER_ID + 1];
-
- void clearState();
-
- void sync(nsecs_t when);
};
@@ -1397,8 +1556,8 @@ public:
virtual uint32_t getSources();
virtual void populateDeviceInfo(InputDeviceInfo* deviceInfo);
virtual void dump(String8& dump);
- virtual void configure(const InputReaderConfiguration* config, uint32_t changes);
- virtual void reset();
+ virtual void configure(nsecs_t when, const InputReaderConfiguration* config, uint32_t changes);
+ virtual void reset(nsecs_t when);
virtual void process(const RawEvent* rawEvent);
private:
diff --git a/services/input/tests/InputReader_test.cpp b/services/input/tests/InputReader_test.cpp
index ebf66aa..4796958 100644
--- a/services/input/tests/InputReader_test.cpp
+++ b/services/input/tests/InputReader_test.cpp
@@ -125,13 +125,6 @@ private:
// --- FakeInputReaderPolicy ---
class FakeInputReaderPolicy : public InputReaderPolicyInterface {
- struct DisplayInfo {
- int32_t width;
- int32_t height;
- int32_t orientation;
- };
-
- KeyedVector<int32_t, DisplayInfo> mDisplayInfos;
InputReaderConfiguration mConfig;
KeyedVector<int32_t, sp<FakePointerController> > mPointerControllers;
@@ -142,18 +135,10 @@ public:
FakeInputReaderPolicy() {
}
- void removeDisplayInfo(int32_t displayId) {
- mDisplayInfos.removeItem(displayId);
- }
-
void setDisplayInfo(int32_t displayId, int32_t width, int32_t height, int32_t orientation) {
- removeDisplayInfo(displayId);
-
- DisplayInfo info;
- info.width = width;
- info.height = height;
- info.orientation = orientation;
- mDisplayInfos.add(displayId, info);
+ // Set the size of both the internal and external display at the same time.
+ mConfig.setDisplayInfo(displayId, false /*external*/, width, height, orientation);
+ mConfig.setDisplayInfo(displayId, true /*external*/, width, height, orientation);
}
virtual nsecs_t getVirtualKeyQuietTime() {
@@ -168,26 +153,11 @@ public:
mPointerControllers.add(deviceId, controller);
}
-private:
- virtual bool getDisplayInfo(int32_t displayId, bool external /*currently ignored*/,
- int32_t* width, int32_t* height, int32_t* orientation) {
- ssize_t index = mDisplayInfos.indexOfKey(displayId);
- if (index >= 0) {
- const DisplayInfo& info = mDisplayInfos.valueAt(index);
- if (width) {
- *width = info.width;
- }
- if (height) {
- *height = info.height;
- }
- if (orientation) {
- *orientation = info.orientation;
- }
- return true;
- }
- return false;
+ const InputReaderConfiguration* getReaderConfiguration() const {
+ return &mConfig;
}
+private:
virtual void getReaderConfiguration(InputReaderConfiguration* outConfig) {
*outConfig = mConfig;
}
@@ -203,6 +173,7 @@ private:
class FakeInputListener : public InputListenerInterface {
private:
List<NotifyConfigurationChangedArgs> mNotifyConfigurationChangedArgsQueue;
+ List<NotifyDeviceResetArgs> mNotifyDeviceResetArgsQueue;
List<NotifyKeyArgs> mNotifyKeyArgsQueue;
List<NotifyMotionArgs> mNotifyMotionArgsQueue;
List<NotifySwitchArgs> mNotifySwitchArgsQueue;
@@ -224,6 +195,16 @@ public:
mNotifyConfigurationChangedArgsQueue.erase(mNotifyConfigurationChangedArgsQueue.begin());
}
+ void assertNotifyDeviceResetWasCalled(
+ NotifyDeviceResetArgs* outEventArgs = NULL) {
+ ASSERT_FALSE(mNotifyDeviceResetArgsQueue.empty())
+ << "Expected notifyDeviceReset() to have been called.";
+ if (outEventArgs) {
+ *outEventArgs = *mNotifyDeviceResetArgsQueue.begin();
+ }
+ mNotifyDeviceResetArgsQueue.erase(mNotifyDeviceResetArgsQueue.begin());
+ }
+
void assertNotifyKeyWasCalled(NotifyKeyArgs* outEventArgs = NULL) {
ASSERT_FALSE(mNotifyKeyArgsQueue.empty())
<< "Expected notifyKey() to have been called.";
@@ -266,6 +247,10 @@ private:
mNotifyConfigurationChangedArgsQueue.push_back(*args);
}
+ virtual void notifyDeviceReset(const NotifyDeviceResetArgs* args) {
+ mNotifyDeviceResetArgsQueue.push_back(*args);
+ }
+
virtual void notifyKey(const NotifyKeyArgs* args) {
mNotifyKeyArgsQueue.push_back(*args);
}
@@ -792,11 +777,12 @@ private:
}
}
- virtual void configure(const InputReaderConfiguration* config, uint32_t changes) {
+ virtual void configure(nsecs_t when,
+ const InputReaderConfiguration* config, uint32_t changes) {
mConfigureWasCalled = true;
}
- virtual void reset() {
+ virtual void reset(nsecs_t when) {
mResetWasCalled = true;
}
@@ -913,6 +899,7 @@ protected:
void addDevice(int32_t deviceId, const String8& name, uint32_t classes,
const PropertyMap* configuration) {
mFakeEventHub->addDevice(deviceId, name, classes);
+
if (configuration) {
mFakeEventHub->addConfigurationMap(deviceId, configuration);
}
@@ -1263,7 +1250,15 @@ TEST_F(InputDeviceTest, ImmutableProperties) {
TEST_F(InputDeviceTest, WhenNoMappersAreRegistered_DeviceIsIgnored) {
// Configuration.
InputReaderConfiguration config;
- mDevice->configure(&config, 0);
+ mDevice->configure(ARBITRARY_TIME, &config, 0);
+
+ // Reset.
+ mDevice->reset(ARBITRARY_TIME);
+
+ NotifyDeviceResetArgs resetArgs;
+ ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyDeviceResetWasCalled(&resetArgs));
+ ASSERT_EQ(ARBITRARY_TIME, resetArgs.eventTime);
+ ASSERT_EQ(DEVICE_ID, resetArgs.deviceId);
// Metadata.
ASSERT_TRUE(mDevice->isIgnored());
@@ -1292,9 +1287,6 @@ TEST_F(InputDeviceTest, WhenNoMappersAreRegistered_DeviceIsIgnored) {
<< "Ignored device should never mark any key codes.";
ASSERT_EQ(0, flags[0]) << "Flag for unsupported key should be unchanged.";
ASSERT_EQ(1, flags[1]) << "Flag for unsupported key should be unchanged.";
-
- // Reset.
- mDevice->reset();
}
TEST_F(InputDeviceTest, WhenMappersAreRegistered_DeviceIsNotIgnoredAndForwardsRequestsToMappers) {
@@ -1318,7 +1310,7 @@ TEST_F(InputDeviceTest, WhenMappersAreRegistered_DeviceIsNotIgnoredAndForwardsRe
mDevice->addMapper(mapper2);
InputReaderConfiguration config;
- mDevice->configure(&config, 0);
+ mDevice->configure(ARBITRARY_TIME, &config, 0);
String8 propertyValue;
ASSERT_TRUE(mDevice->getConfiguration().tryGetProperty(String8("key"), propertyValue))
@@ -1328,6 +1320,16 @@ TEST_F(InputDeviceTest, WhenMappersAreRegistered_DeviceIsNotIgnoredAndForwardsRe
ASSERT_NO_FATAL_FAILURE(mapper1->assertConfigureWasCalled());
ASSERT_NO_FATAL_FAILURE(mapper2->assertConfigureWasCalled());
+ // Reset
+ mDevice->reset(ARBITRARY_TIME);
+ ASSERT_NO_FATAL_FAILURE(mapper1->assertResetWasCalled());
+ ASSERT_NO_FATAL_FAILURE(mapper2->assertResetWasCalled());
+
+ NotifyDeviceResetArgs resetArgs;
+ ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyDeviceResetWasCalled(&resetArgs));
+ ASSERT_EQ(ARBITRARY_TIME, resetArgs.eventTime);
+ ASSERT_EQ(DEVICE_ID, resetArgs.deviceId);
+
// Metadata.
ASSERT_FALSE(mDevice->isIgnored());
ASSERT_EQ(uint32_t(AINPUT_SOURCE_KEYBOARD | AINPUT_SOURCE_TOUCHSCREEN), mDevice->getSources());
@@ -1379,12 +1381,6 @@ TEST_F(InputDeviceTest, WhenMappersAreRegistered_DeviceIsNotIgnoredAndForwardsRe
ASSERT_NO_FATAL_FAILURE(mapper1->assertProcessWasCalled());
ASSERT_NO_FATAL_FAILURE(mapper2->assertProcessWasCalled());
-
- // Reset.
- mDevice->reset();
-
- ASSERT_NO_FATAL_FAILURE(mapper1->assertResetWasCalled());
- ASSERT_NO_FATAL_FAILURE(mapper2->assertResetWasCalled());
}
@@ -1424,10 +1420,16 @@ protected:
}
void addMapperAndConfigure(InputMapper* mapper) {
- InputReaderConfiguration config;
-
mDevice->addMapper(mapper);
- mDevice->configure(&config, 0);
+ mDevice->configure(ARBITRARY_TIME, mFakePolicy->getReaderConfiguration(), 0);
+ mDevice->reset(ARBITRARY_TIME);
+ }
+
+ void setDisplayInfoAndReconfigure(int32_t displayId, int32_t width, int32_t height,
+ int32_t orientation) {
+ mFakePolicy->setDisplayInfo(displayId, width, height, orientation);
+ mDevice->configure(ARBITRARY_TIME, mFakePolicy->getReaderConfiguration(),
+ InputReaderConfiguration::CHANGE_DISPLAY_INFO);
}
static void process(InputMapper* mapper, nsecs_t when, int32_t deviceId, int32_t type,
@@ -1593,71 +1595,6 @@ TEST_F(KeyboardInputMapperTest, Process_SimpleKeyPress) {
ASSERT_EQ(ARBITRARY_TIME, args.downTime);
}
-TEST_F(KeyboardInputMapperTest, Reset_WhenKeysAreNotDown_DoesNotSynthesizeKeyUp) {
- KeyboardInputMapper* mapper = new KeyboardInputMapper(mDevice,
- AINPUT_SOURCE_KEYBOARD, AINPUT_KEYBOARD_TYPE_ALPHABETIC);
- addMapperAndConfigure(mapper);
-
- // Key down.
- process(mapper, ARBITRARY_TIME, DEVICE_ID,
- EV_KEY, KEY_HOME, AKEYCODE_HOME, 1, POLICY_FLAG_WAKE);
- ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasCalled());
-
- // Key up.
- process(mapper, ARBITRARY_TIME, DEVICE_ID,
- EV_KEY, KEY_HOME, AKEYCODE_HOME, 0, POLICY_FLAG_WAKE);
- ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasCalled());
-
- // Reset. Since no keys still down, should not synthesize any key ups.
- mapper->reset();
- ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasNotCalled());
-}
-
-TEST_F(KeyboardInputMapperTest, Reset_WhenKeysAreDown_SynthesizesKeyUps) {
- KeyboardInputMapper* mapper = new KeyboardInputMapper(mDevice,
- AINPUT_SOURCE_KEYBOARD, AINPUT_KEYBOARD_TYPE_ALPHABETIC);
- addMapperAndConfigure(mapper);
-
- // Metakey down.
- process(mapper, ARBITRARY_TIME, DEVICE_ID,
- EV_KEY, KEY_LEFTSHIFT, AKEYCODE_SHIFT_LEFT, 1, 0);
- ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasCalled());
-
- // Key down.
- process(mapper, ARBITRARY_TIME + 1, DEVICE_ID,
- EV_KEY, KEY_A, AKEYCODE_A, 1, 0);
- ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasCalled());
-
- // Reset. Since two keys are still down, should synthesize two key ups in reverse order.
- mapper->reset();
-
- NotifyKeyArgs args;
- ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasCalled(&args));
- ASSERT_EQ(DEVICE_ID, args.deviceId);
- ASSERT_EQ(AINPUT_SOURCE_KEYBOARD, args.source);
- ASSERT_EQ(AKEY_EVENT_ACTION_UP, args.action);
- ASSERT_EQ(AKEYCODE_A, args.keyCode);
- ASSERT_EQ(KEY_A, args.scanCode);
- ASSERT_EQ(AMETA_SHIFT_LEFT_ON | AMETA_SHIFT_ON, args.metaState);
- ASSERT_EQ(AKEY_EVENT_FLAG_FROM_SYSTEM, args.flags);
- ASSERT_EQ(uint32_t(0), args.policyFlags);
- ASSERT_EQ(ARBITRARY_TIME + 1, args.downTime);
-
- ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasCalled(&args));
- ASSERT_EQ(DEVICE_ID, args.deviceId);
- ASSERT_EQ(AINPUT_SOURCE_KEYBOARD, args.source);
- ASSERT_EQ(AKEY_EVENT_ACTION_UP, args.action);
- ASSERT_EQ(AKEYCODE_SHIFT_LEFT, args.keyCode);
- ASSERT_EQ(KEY_LEFTSHIFT, args.scanCode);
- ASSERT_EQ(AMETA_NONE, args.metaState);
- ASSERT_EQ(AKEY_EVENT_FLAG_FROM_SYSTEM, args.flags);
- ASSERT_EQ(uint32_t(0), args.policyFlags);
- ASSERT_EQ(ARBITRARY_TIME + 1, args.downTime);
-
- // And that's it.
- ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasNotCalled());
-}
-
TEST_F(KeyboardInputMapperTest, Process_ShouldUpdateMetaState) {
KeyboardInputMapper* mapper = new KeyboardInputMapper(mDevice,
AINPUT_SOURCE_KEYBOARD, AINPUT_KEYBOARD_TYPE_ALPHABETIC);
@@ -1703,7 +1640,7 @@ TEST_F(KeyboardInputMapperTest, Process_WhenNotOrientationAware_ShouldNotRotateD
AINPUT_SOURCE_KEYBOARD, AINPUT_KEYBOARD_TYPE_ALPHABETIC);
addMapperAndConfigure(mapper);
- mFakePolicy->setDisplayInfo(DISPLAY_ID,
+ setDisplayInfoAndReconfigure(DISPLAY_ID,
DISPLAY_WIDTH, DISPLAY_HEIGHT,
DISPLAY_ORIENTATION_90);
ASSERT_NO_FATAL_FAILURE(testDPadKeyRotation(mapper,
@@ -1722,7 +1659,7 @@ TEST_F(KeyboardInputMapperTest, Process_WhenOrientationAware_ShouldRotateDPad) {
addConfigurationProperty("keyboard.orientationAware", "1");
addMapperAndConfigure(mapper);
- mFakePolicy->setDisplayInfo(DISPLAY_ID,
+ setDisplayInfoAndReconfigure(DISPLAY_ID,
DISPLAY_WIDTH, DISPLAY_HEIGHT,
DISPLAY_ORIENTATION_0);
ASSERT_NO_FATAL_FAILURE(testDPadKeyRotation(mapper,
@@ -1734,7 +1671,7 @@ TEST_F(KeyboardInputMapperTest, Process_WhenOrientationAware_ShouldRotateDPad) {
ASSERT_NO_FATAL_FAILURE(testDPadKeyRotation(mapper,
KEY_LEFT, AKEYCODE_DPAD_LEFT, AKEYCODE_DPAD_LEFT));
- mFakePolicy->setDisplayInfo(DISPLAY_ID,
+ setDisplayInfoAndReconfigure(DISPLAY_ID,
DISPLAY_WIDTH, DISPLAY_HEIGHT,
DISPLAY_ORIENTATION_90);
ASSERT_NO_FATAL_FAILURE(testDPadKeyRotation(mapper,
@@ -1746,7 +1683,7 @@ TEST_F(KeyboardInputMapperTest, Process_WhenOrientationAware_ShouldRotateDPad) {
ASSERT_NO_FATAL_FAILURE(testDPadKeyRotation(mapper,
KEY_LEFT, AKEYCODE_DPAD_LEFT, AKEYCODE_DPAD_DOWN));
- mFakePolicy->setDisplayInfo(DISPLAY_ID,
+ setDisplayInfoAndReconfigure(DISPLAY_ID,
DISPLAY_WIDTH, DISPLAY_HEIGHT,
DISPLAY_ORIENTATION_180);
ASSERT_NO_FATAL_FAILURE(testDPadKeyRotation(mapper,
@@ -1758,7 +1695,7 @@ TEST_F(KeyboardInputMapperTest, Process_WhenOrientationAware_ShouldRotateDPad) {
ASSERT_NO_FATAL_FAILURE(testDPadKeyRotation(mapper,
KEY_LEFT, AKEYCODE_DPAD_LEFT, AKEYCODE_DPAD_RIGHT));
- mFakePolicy->setDisplayInfo(DISPLAY_ID,
+ setDisplayInfoAndReconfigure(DISPLAY_ID,
DISPLAY_WIDTH, DISPLAY_HEIGHT,
DISPLAY_ORIENTATION_270);
ASSERT_NO_FATAL_FAILURE(testDPadKeyRotation(mapper,
@@ -1774,7 +1711,7 @@ TEST_F(KeyboardInputMapperTest, Process_WhenOrientationAware_ShouldRotateDPad) {
// in the key up as we did in the key down.
NotifyKeyArgs args;
- mFakePolicy->setDisplayInfo(DISPLAY_ID,
+ setDisplayInfoAndReconfigure(DISPLAY_ID,
DISPLAY_WIDTH, DISPLAY_HEIGHT,
DISPLAY_ORIENTATION_270);
process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_KEY, KEY_UP, AKEYCODE_DPAD_UP, 1, 0);
@@ -1783,7 +1720,7 @@ TEST_F(KeyboardInputMapperTest, Process_WhenOrientationAware_ShouldRotateDPad) {
ASSERT_EQ(KEY_UP, args.scanCode);
ASSERT_EQ(AKEYCODE_DPAD_RIGHT, args.keyCode);
- mFakePolicy->setDisplayInfo(DISPLAY_ID,
+ setDisplayInfoAndReconfigure(DISPLAY_ID,
DISPLAY_WIDTH, DISPLAY_HEIGHT,
DISPLAY_ORIENTATION_180);
process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_KEY, KEY_UP, AKEYCODE_DPAD_UP, 0, 0);
@@ -2149,58 +2086,12 @@ TEST_F(CursorInputMapperTest, Process_ShouldHandleCombinedXYAndButtonUpdates) {
0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f));
}
-TEST_F(CursorInputMapperTest, Reset_WhenButtonIsNotDown_ShouldNotSynthesizeButtonUp) {
- CursorInputMapper* mapper = new CursorInputMapper(mDevice);
- addConfigurationProperty("cursor.mode", "navigation");
- addMapperAndConfigure(mapper);
-
- NotifyMotionArgs args;
-
- // Button press.
- process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_KEY, BTN_MOUSE, 0, 1, 0);
- process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_SYN, SYN_REPORT, 0, 0, 0);
- ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&args));
- ASSERT_EQ(AMOTION_EVENT_ACTION_DOWN, args.action);
-
- // Button release.
- process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_KEY, BTN_MOUSE, 0, 0, 0);
- process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_SYN, SYN_REPORT, 0, 0, 0);
- ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&args));
- ASSERT_EQ(AMOTION_EVENT_ACTION_UP, args.action);
-
- // Reset. Should not synthesize button up since button is not pressed.
- mapper->reset();
-
- ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasNotCalled());
-}
-
-TEST_F(CursorInputMapperTest, Reset_WhenButtonIsDown_ShouldSynthesizeButtonUp) {
- CursorInputMapper* mapper = new CursorInputMapper(mDevice);
- addConfigurationProperty("cursor.mode", "navigation");
- addMapperAndConfigure(mapper);
-
- NotifyMotionArgs args;
-
- // Button press.
- process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_KEY, BTN_MOUSE, 0, 1, 0);
- process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_SYN, SYN_REPORT, 0, 0, 0);
- ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&args));
-
- // Reset. Should synthesize button up.
- mapper->reset();
-
- ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&args));
- ASSERT_EQ(AMOTION_EVENT_ACTION_UP, args.action);
- ASSERT_NO_FATAL_FAILURE(assertPointerCoords(args.pointerCoords[0],
- 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f));
-}
-
TEST_F(CursorInputMapperTest, Process_WhenNotOrientationAware_ShouldNotRotateMotions) {
CursorInputMapper* mapper = new CursorInputMapper(mDevice);
addConfigurationProperty("cursor.mode", "navigation");
addMapperAndConfigure(mapper);
- mFakePolicy->setDisplayInfo(DISPLAY_ID,
+ setDisplayInfoAndReconfigure(DISPLAY_ID,
DISPLAY_WIDTH, DISPLAY_HEIGHT,
DISPLAY_ORIENTATION_90);
ASSERT_NO_FATAL_FAILURE(testMotionRotation(mapper, 0, 1, 0, 1));
@@ -2219,7 +2110,7 @@ TEST_F(CursorInputMapperTest, Process_WhenOrientationAware_ShouldRotateMotions)
addConfigurationProperty("cursor.orientationAware", "1");
addMapperAndConfigure(mapper);
- mFakePolicy->setDisplayInfo(DISPLAY_ID,
+ setDisplayInfoAndReconfigure(DISPLAY_ID,
DISPLAY_WIDTH, DISPLAY_HEIGHT, DISPLAY_ORIENTATION_0);
ASSERT_NO_FATAL_FAILURE(testMotionRotation(mapper, 0, 1, 0, 1));
ASSERT_NO_FATAL_FAILURE(testMotionRotation(mapper, 1, 1, 1, 1));
@@ -2230,7 +2121,7 @@ TEST_F(CursorInputMapperTest, Process_WhenOrientationAware_ShouldRotateMotions)
ASSERT_NO_FATAL_FAILURE(testMotionRotation(mapper, -1, 0, -1, 0));
ASSERT_NO_FATAL_FAILURE(testMotionRotation(mapper, -1, 1, -1, 1));
- mFakePolicy->setDisplayInfo(DISPLAY_ID,
+ setDisplayInfoAndReconfigure(DISPLAY_ID,
DISPLAY_WIDTH, DISPLAY_HEIGHT, DISPLAY_ORIENTATION_90);
ASSERT_NO_FATAL_FAILURE(testMotionRotation(mapper, 0, 1, 1, 0));
ASSERT_NO_FATAL_FAILURE(testMotionRotation(mapper, 1, 1, 1, -1));
@@ -2241,7 +2132,7 @@ TEST_F(CursorInputMapperTest, Process_WhenOrientationAware_ShouldRotateMotions)
ASSERT_NO_FATAL_FAILURE(testMotionRotation(mapper, -1, 0, 0, 1));
ASSERT_NO_FATAL_FAILURE(testMotionRotation(mapper, -1, 1, 1, 1));
- mFakePolicy->setDisplayInfo(DISPLAY_ID,
+ setDisplayInfoAndReconfigure(DISPLAY_ID,
DISPLAY_WIDTH, DISPLAY_HEIGHT, DISPLAY_ORIENTATION_180);
ASSERT_NO_FATAL_FAILURE(testMotionRotation(mapper, 0, 1, 0, -1));
ASSERT_NO_FATAL_FAILURE(testMotionRotation(mapper, 1, 1, -1, -1));
@@ -2252,7 +2143,7 @@ TEST_F(CursorInputMapperTest, Process_WhenOrientationAware_ShouldRotateMotions)
ASSERT_NO_FATAL_FAILURE(testMotionRotation(mapper, -1, 0, 1, 0));
ASSERT_NO_FATAL_FAILURE(testMotionRotation(mapper, -1, 1, 1, -1));
- mFakePolicy->setDisplayInfo(DISPLAY_ID,
+ setDisplayInfoAndReconfigure(DISPLAY_ID,
DISPLAY_WIDTH, DISPLAY_HEIGHT, DISPLAY_ORIENTATION_270);
ASSERT_NO_FATAL_FAILURE(testMotionRotation(mapper, 0, 1, -1, 0));
ASSERT_NO_FATAL_FAILURE(testMotionRotation(mapper, 1, 1, -1, 1));
@@ -2480,6 +2371,8 @@ protected:
static const int32_t RAW_ORIENTATION_MAX;
static const int32_t RAW_DISTANCE_MIN;
static const int32_t RAW_DISTANCE_MAX;
+ static const int32_t RAW_TILT_MIN;
+ static const int32_t RAW_TILT_MAX;
static const int32_t RAW_ID_MIN;
static const int32_t RAW_ID_MAX;
static const int32_t RAW_SLOT_MIN;
@@ -2500,8 +2393,9 @@ protected:
MINOR = 1 << 5,
ID = 1 << 6,
DISTANCE = 1 << 7,
- SLOT = 1 << 8,
- TOOL_TYPE = 1 << 9,
+ TILT = 1 << 8,
+ SLOT = 1 << 9,
+ TOOL_TYPE = 1 << 10,
};
void prepareDisplay(int32_t orientation);
@@ -2526,6 +2420,8 @@ const int32_t TouchInputMapperTest::RAW_ORIENTATION_MIN = -7;
const int32_t TouchInputMapperTest::RAW_ORIENTATION_MAX = 7;
const int32_t TouchInputMapperTest::RAW_DISTANCE_MIN = 0;
const int32_t TouchInputMapperTest::RAW_DISTANCE_MAX = 7;
+const int32_t TouchInputMapperTest::RAW_TILT_MIN = 0;
+const int32_t TouchInputMapperTest::RAW_TILT_MAX = 150;
const int32_t TouchInputMapperTest::RAW_ID_MIN = 0;
const int32_t TouchInputMapperTest::RAW_ID_MAX = 9;
const int32_t TouchInputMapperTest::RAW_SLOT_MIN = 0;
@@ -2543,7 +2439,7 @@ const VirtualKeyDefinition TouchInputMapperTest::VIRTUAL_KEYS[2] = {
};
void TouchInputMapperTest::prepareDisplay(int32_t orientation) {
- mFakePolicy->setDisplayInfo(DISPLAY_ID, DISPLAY_WIDTH, DISPLAY_HEIGHT, orientation);
+ setDisplayInfoAndReconfigure(DISPLAY_ID, DISPLAY_WIDTH, DISPLAY_HEIGHT, orientation);
}
void TouchInputMapperTest::prepareVirtualKeys() {
@@ -2583,6 +2479,7 @@ protected:
void processPressure(SingleTouchInputMapper* mapper, int32_t pressure);
void processToolMajor(SingleTouchInputMapper* mapper, int32_t toolMajor);
void processDistance(SingleTouchInputMapper* mapper, int32_t distance);
+ void processTilt(SingleTouchInputMapper* mapper, int32_t tiltX, int32_t tiltY);
void processKey(SingleTouchInputMapper* mapper, int32_t code, int32_t value);
void processSync(SingleTouchInputMapper* mapper);
};
@@ -2610,6 +2507,12 @@ void SingleTouchInputMapperTest::prepareAxes(int axes) {
mFakeEventHub->addAbsoluteAxis(DEVICE_ID, ABS_DISTANCE,
RAW_DISTANCE_MIN, RAW_DISTANCE_MAX, 0, 0);
}
+ if (axes & TILT) {
+ mFakeEventHub->addAbsoluteAxis(DEVICE_ID, ABS_TILT_X,
+ RAW_TILT_MIN, RAW_TILT_MAX, 0, 0);
+ mFakeEventHub->addAbsoluteAxis(DEVICE_ID, ABS_TILT_Y,
+ RAW_TILT_MIN, RAW_TILT_MAX, 0, 0);
+ }
}
void SingleTouchInputMapperTest::processDown(SingleTouchInputMapper* mapper, int32_t x, int32_t y) {
@@ -2642,6 +2545,12 @@ void SingleTouchInputMapperTest::processDistance(
process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_ABS, ABS_DISTANCE, 0, distance, 0);
}
+void SingleTouchInputMapperTest::processTilt(
+ SingleTouchInputMapper* mapper, int32_t tiltX, int32_t tiltY) {
+ process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_ABS, ABS_TILT_X, 0, tiltX, 0);
+ process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_ABS, ABS_TILT_Y, 0, tiltY, 0);
+}
+
void SingleTouchInputMapperTest::processKey(
SingleTouchInputMapper* mapper, int32_t code, int32_t value) {
process(mapper, ARBITRARY_TIME, DEVICE_ID, EV_KEY, code, 0, value, 0);
@@ -2658,7 +2567,7 @@ TEST_F(SingleTouchInputMapperTest, GetSources_WhenDeviceTypeIsNotSpecifiedAndNot
prepareAxes(POSITION);
addMapperAndConfigure(mapper);
- ASSERT_EQ(AINPUT_SOURCE_MOUSE | AINPUT_SOURCE_TOUCHPAD, mapper->getSources());
+ ASSERT_EQ(AINPUT_SOURCE_MOUSE, mapper->getSources());
}
TEST_F(SingleTouchInputMapperTest, GetSources_WhenDeviceTypeIsNotSpecifiedAndIsACursor_ReturnsTouchPad) {
@@ -2766,71 +2675,6 @@ TEST_F(SingleTouchInputMapperTest, MarkSupportedKeyCodes) {
ASSERT_FALSE(flags[1]);
}
-TEST_F(SingleTouchInputMapperTest, Reset_WhenVirtualKeysAreDown_SendsUp) {
- // Note: Ideally we should send cancels but the implementation is more straightforward
- // with up and this will only happen if a device is forcibly removed.
- SingleTouchInputMapper* mapper = new SingleTouchInputMapper(mDevice);
- addConfigurationProperty("touch.deviceType", "touchScreen");
- prepareDisplay(DISPLAY_ORIENTATION_0);
- prepareButtons();
- prepareAxes(POSITION);
- prepareVirtualKeys();
- addMapperAndConfigure(mapper);
-
- mFakeContext->setGlobalMetaState(AMETA_SHIFT_LEFT_ON | AMETA_SHIFT_ON);
-
- // Press virtual key.
- int32_t x = toRawX(VIRTUAL_KEYS[0].centerX);
- int32_t y = toRawY(VIRTUAL_KEYS[0].centerY);
- processDown(mapper, x, y);
- processSync(mapper);
- ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasCalled());
-
- // Reset. Since key is down, synthesize key up.
- mapper->reset();
-
- NotifyKeyArgs args;
- ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasCalled(&args));
- //ASSERT_EQ(ARBITRARY_TIME, args.eventTime);
- ASSERT_EQ(DEVICE_ID, args.deviceId);
- ASSERT_EQ(AINPUT_SOURCE_KEYBOARD, args.source);
- ASSERT_EQ(POLICY_FLAG_VIRTUAL, args.policyFlags);
- ASSERT_EQ(AKEY_EVENT_ACTION_UP, args.action);
- ASSERT_EQ(AKEY_EVENT_FLAG_FROM_SYSTEM | AKEY_EVENT_FLAG_VIRTUAL_HARD_KEY, args.flags);
- ASSERT_EQ(AKEYCODE_HOME, args.keyCode);
- ASSERT_EQ(KEY_HOME, args.scanCode);
- ASSERT_EQ(AMETA_SHIFT_LEFT_ON | AMETA_SHIFT_ON, args.metaState);
- ASSERT_EQ(ARBITRARY_TIME, args.downTime);
-}
-
-TEST_F(SingleTouchInputMapperTest, Reset_WhenNothingIsPressed_NothingMuchHappens) {
- SingleTouchInputMapper* mapper = new SingleTouchInputMapper(mDevice);
- addConfigurationProperty("touch.deviceType", "touchScreen");
- prepareDisplay(DISPLAY_ORIENTATION_0);
- prepareButtons();
- prepareAxes(POSITION);
- prepareVirtualKeys();
- addMapperAndConfigure(mapper);
-
- // Press virtual key.
- int32_t x = toRawX(VIRTUAL_KEYS[0].centerX);
- int32_t y = toRawY(VIRTUAL_KEYS[0].centerY);
- processDown(mapper, x, y);
- processSync(mapper);
- ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasCalled());
-
- // Release virtual key.
- processUp(mapper);
- processSync(mapper);
- ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasCalled());
-
- // Reset. Since no key is down, nothing happens.
- mapper->reset();
-
- ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyKeyWasNotCalled());
- ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasNotCalled());
-}
-
TEST_F(SingleTouchInputMapperTest, Process_WhenVirtualKeyIsPressedAndReleasedNormally_SendsKeyDownAndKeyUp) {
SingleTouchInputMapper* mapper = new SingleTouchInputMapper(mDevice);
addConfigurationProperty("touch.deviceType", "touchScreen");
@@ -3260,7 +3104,7 @@ TEST_F(SingleTouchInputMapperTest, Process_AllAxes_DefaultCalibration) {
addConfigurationProperty("touch.deviceType", "touchScreen");
prepareDisplay(DISPLAY_ORIENTATION_0);
prepareButtons();
- prepareAxes(POSITION | PRESSURE | TOOL | DISTANCE);
+ prepareAxes(POSITION | PRESSURE | TOOL | DISTANCE | TILT);
addMapperAndConfigure(mapper);
// These calculations are based on the input device calibration documentation.
@@ -3268,7 +3112,9 @@ TEST_F(SingleTouchInputMapperTest, Process_AllAxes_DefaultCalibration) {
int32_t rawY = 200;
int32_t rawPressure = 10;
int32_t rawToolMajor = 12;
- int32_t rawDistance = 0;
+ int32_t rawDistance = 2;
+ int32_t rawTiltX = 30;
+ int32_t rawTiltY = 110;
float x = toDisplayX(rawX);
float y = toDisplayY(rawY);
@@ -3277,16 +3123,25 @@ TEST_F(SingleTouchInputMapperTest, Process_AllAxes_DefaultCalibration) {
float tool = float(rawToolMajor) * GEOMETRIC_SCALE;
float distance = float(rawDistance);
+ float tiltCenter = (RAW_TILT_MAX + RAW_TILT_MIN) * 0.5f;
+ float tiltScale = M_PI / 180;
+ float tiltXAngle = (rawTiltX - tiltCenter) * tiltScale;
+ float tiltYAngle = (rawTiltY - tiltCenter) * tiltScale;
+ float orientation = atan2f(-sinf(tiltXAngle), sinf(tiltYAngle));
+ float tilt = acosf(cosf(tiltXAngle) * cosf(tiltYAngle));
+
processDown(mapper, rawX, rawY);
processPressure(mapper, rawPressure);
processToolMajor(mapper, rawToolMajor);
processDistance(mapper, rawDistance);
+ processTilt(mapper, rawTiltX, rawTiltY);
processSync(mapper);
NotifyMotionArgs args;
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&args));
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(args.pointerCoords[0],
- x, y, pressure, size, tool, tool, tool, tool, 0, distance));
+ x, y, pressure, size, tool, tool, tool, tool, orientation, distance));
+ ASSERT_EQ(tilt, args.pointerCoords[0].getAxisValue(AMOTION_EVENT_AXIS_TILT));
}
TEST_F(SingleTouchInputMapperTest, Process_ShouldHandleAllButtons) {
@@ -3482,8 +3337,48 @@ TEST_F(SingleTouchInputMapperTest, Process_ShouldHandleAllToolTypes) {
ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_STYLUS, motionArgs.pointerProperties[0].toolType);
- // finger
+ // brush
processKey(mapper, BTN_TOOL_PEN, 0);
+ processKey(mapper, BTN_TOOL_BRUSH, 1);
+ processSync(mapper);
+ ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+ ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+ ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_STYLUS, motionArgs.pointerProperties[0].toolType);
+
+ // pencil
+ processKey(mapper, BTN_TOOL_BRUSH, 0);
+ processKey(mapper, BTN_TOOL_PENCIL, 1);
+ processSync(mapper);
+ ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+ ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+ ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_STYLUS, motionArgs.pointerProperties[0].toolType);
+
+ // airbrush
+ processKey(mapper, BTN_TOOL_PENCIL, 0);
+ processKey(mapper, BTN_TOOL_AIRBRUSH, 1);
+ processSync(mapper);
+ ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+ ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+ ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_STYLUS, motionArgs.pointerProperties[0].toolType);
+
+ // mouse
+ processKey(mapper, BTN_TOOL_AIRBRUSH, 0);
+ processKey(mapper, BTN_TOOL_MOUSE, 1);
+ processSync(mapper);
+ ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+ ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+ ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_MOUSE, motionArgs.pointerProperties[0].toolType);
+
+ // lens
+ processKey(mapper, BTN_TOOL_MOUSE, 0);
+ processKey(mapper, BTN_TOOL_LENS, 1);
+ processSync(mapper);
+ ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+ ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+ ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_MOUSE, motionArgs.pointerProperties[0].toolType);
+
+ // finger
+ processKey(mapper, BTN_TOOL_LENS, 0);
processKey(mapper, BTN_TOOL_FINGER, 1);
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
@@ -3504,7 +3399,15 @@ TEST_F(SingleTouchInputMapperTest, Process_ShouldHandleAllToolTypes) {
ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_ERASER, motionArgs.pointerProperties[0].toolType);
+ // mouse trumps eraser
+ processKey(mapper, BTN_TOOL_MOUSE, 1);
+ processSync(mapper);
+ ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+ ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+ ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_MOUSE, motionArgs.pointerProperties[0].toolType);
+
// back to default tool type
+ processKey(mapper, BTN_TOOL_MOUSE, 0);
processKey(mapper, BTN_TOOL_RUBBER, 0);
processKey(mapper, BTN_TOOL_PEN, 0);
processKey(mapper, BTN_TOOL_FINGER, 0);
@@ -3587,29 +3490,29 @@ TEST_F(SingleTouchInputMapperTest, Process_WhenBtnTouchPresent_HoversIfItsValueI
toDisplayX(150), toDisplayY(250), 0, 0, 0, 0, 0, 0, 0, 0));
}
-TEST_F(SingleTouchInputMapperTest, Process_WhenAbsDistanceIsPresent_HoversIfItsValueIsGreaterThanZero) {
+TEST_F(SingleTouchInputMapperTest, Process_WhenAbsPressureIsPresent_HoversIfItsValueIsZero) {
SingleTouchInputMapper* mapper = new SingleTouchInputMapper(mDevice);
addConfigurationProperty("touch.deviceType", "touchScreen");
prepareDisplay(DISPLAY_ORIENTATION_0);
prepareButtons();
- prepareAxes(POSITION | DISTANCE);
+ prepareAxes(POSITION | PRESSURE);
addMapperAndConfigure(mapper);
NotifyMotionArgs motionArgs;
- // initially hovering because distance is 1, pressure defaults to 0
+ // initially hovering because pressure is 0
processDown(mapper, 100, 200);
- processDistance(mapper, 1);
+ processPressure(mapper, 0);
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(AMOTION_EVENT_ACTION_HOVER_ENTER, motionArgs.action);
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
- toDisplayX(100), toDisplayY(200), 0, 0, 0, 0, 0, 0, 0, 1));
+ toDisplayX(100), toDisplayY(200), 0, 0, 0, 0, 0, 0, 0, 0));
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(AMOTION_EVENT_ACTION_HOVER_MOVE, motionArgs.action);
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
- toDisplayX(100), toDisplayY(200), 0, 0, 0, 0, 0, 0, 0, 1));
+ toDisplayX(100), toDisplayY(200), 0, 0, 0, 0, 0, 0, 0, 0));
// move a little
processMove(mapper, 150, 250);
@@ -3617,23 +3520,23 @@ TEST_F(SingleTouchInputMapperTest, Process_WhenAbsDistanceIsPresent_HoversIfItsV
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(AMOTION_EVENT_ACTION_HOVER_MOVE, motionArgs.action);
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
- toDisplayX(150), toDisplayY(250), 0, 0, 0, 0, 0, 0, 0, 1));
+ toDisplayX(150), toDisplayY(250), 0, 0, 0, 0, 0, 0, 0, 0));
- // down when distance goes to 0, pressure defaults to 1
- processDistance(mapper, 0);
+ // down when pressure is non-zero
+ processPressure(mapper, RAW_PRESSURE_MAX);
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(AMOTION_EVENT_ACTION_HOVER_EXIT, motionArgs.action);
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
- toDisplayX(150), toDisplayY(250), 0, 0, 0, 0, 0, 0, 0, 1));
+ toDisplayX(150), toDisplayY(250), 0, 0, 0, 0, 0, 0, 0, 0));
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(AMOTION_EVENT_ACTION_DOWN, motionArgs.action);
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
toDisplayX(150), toDisplayY(250), 1, 0, 0, 0, 0, 0, 0, 0));
- // up when distance goes to 1, hover restored
- processDistance(mapper, 1);
+ // up when pressure becomes 0, hover restored
+ processPressure(mapper, 0);
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(AMOTION_EVENT_ACTION_UP, motionArgs.action);
@@ -3643,12 +3546,12 @@ TEST_F(SingleTouchInputMapperTest, Process_WhenAbsDistanceIsPresent_HoversIfItsV
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(AMOTION_EVENT_ACTION_HOVER_ENTER, motionArgs.action);
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
- toDisplayX(150), toDisplayY(250), 0, 0, 0, 0, 0, 0, 0, 1));
+ toDisplayX(150), toDisplayY(250), 0, 0, 0, 0, 0, 0, 0, 0));
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(AMOTION_EVENT_ACTION_HOVER_MOVE, motionArgs.action);
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
- toDisplayX(150), toDisplayY(250), 0, 0, 0, 0, 0, 0, 0, 1));
+ toDisplayX(150), toDisplayY(250), 0, 0, 0, 0, 0, 0, 0, 0));
// exit hover when pointer goes away
processUp(mapper);
@@ -3656,7 +3559,7 @@ TEST_F(SingleTouchInputMapperTest, Process_WhenAbsDistanceIsPresent_HoversIfItsV
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(AMOTION_EVENT_ACTION_HOVER_EXIT, motionArgs.action);
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
- toDisplayX(150), toDisplayY(250), 0, 0, 0, 0, 0, 0, 0, 1));
+ toDisplayX(150), toDisplayY(250), 0, 0, 0, 0, 0, 0, 0, 0));
}
@@ -4823,8 +4726,48 @@ TEST_F(MultiTouchInputMapperTest, Process_ShouldHandleAllToolTypes) {
ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_STYLUS, motionArgs.pointerProperties[0].toolType);
- // finger
+ // brush
processKey(mapper, BTN_TOOL_PEN, 0);
+ processKey(mapper, BTN_TOOL_BRUSH, 1);
+ processSync(mapper);
+ ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+ ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+ ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_STYLUS, motionArgs.pointerProperties[0].toolType);
+
+ // pencil
+ processKey(mapper, BTN_TOOL_BRUSH, 0);
+ processKey(mapper, BTN_TOOL_PENCIL, 1);
+ processSync(mapper);
+ ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+ ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+ ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_STYLUS, motionArgs.pointerProperties[0].toolType);
+
+ // airbrush
+ processKey(mapper, BTN_TOOL_PENCIL, 0);
+ processKey(mapper, BTN_TOOL_AIRBRUSH, 1);
+ processSync(mapper);
+ ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+ ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+ ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_STYLUS, motionArgs.pointerProperties[0].toolType);
+
+ // mouse
+ processKey(mapper, BTN_TOOL_AIRBRUSH, 0);
+ processKey(mapper, BTN_TOOL_MOUSE, 1);
+ processSync(mapper);
+ ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+ ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+ ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_MOUSE, motionArgs.pointerProperties[0].toolType);
+
+ // lens
+ processKey(mapper, BTN_TOOL_MOUSE, 0);
+ processKey(mapper, BTN_TOOL_LENS, 1);
+ processSync(mapper);
+ ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+ ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+ ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_MOUSE, motionArgs.pointerProperties[0].toolType);
+
+ // finger
+ processKey(mapper, BTN_TOOL_LENS, 0);
processKey(mapper, BTN_TOOL_FINGER, 1);
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
@@ -4845,6 +4788,13 @@ TEST_F(MultiTouchInputMapperTest, Process_ShouldHandleAllToolTypes) {
ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_ERASER, motionArgs.pointerProperties[0].toolType);
+ // mouse trumps eraser
+ processKey(mapper, BTN_TOOL_MOUSE, 1);
+ processSync(mapper);
+ ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
+ ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, motionArgs.action);
+ ASSERT_EQ(AMOTION_EVENT_TOOL_TYPE_MOUSE, motionArgs.pointerProperties[0].toolType);
+
// MT tool type trumps BTN tool types: MT_TOOL_FINGER
processToolType(mapper, MT_TOOL_FINGER); // this is the first time we send MT_TOOL_TYPE
processSync(mapper);
@@ -4861,6 +4811,7 @@ TEST_F(MultiTouchInputMapperTest, Process_ShouldHandleAllToolTypes) {
// back to default tool type
processToolType(mapper, -1); // use a deliberately undefined tool type, for testing
+ processKey(mapper, BTN_TOOL_MOUSE, 0);
processKey(mapper, BTN_TOOL_RUBBER, 0);
processKey(mapper, BTN_TOOL_PEN, 0);
processKey(mapper, BTN_TOOL_FINGER, 0);
@@ -4942,29 +4893,29 @@ TEST_F(MultiTouchInputMapperTest, Process_WhenBtnTouchPresent_HoversIfItsValueIs
toDisplayX(150), toDisplayY(250), 0, 0, 0, 0, 0, 0, 0, 0));
}
-TEST_F(MultiTouchInputMapperTest, Process_WhenAbsMTDistanceIsPresent_HoversIfItsValueIsGreaterThanZero) {
+TEST_F(MultiTouchInputMapperTest, Process_WhenAbsMTPressureIsPresent_HoversIfItsValueIsZero) {
MultiTouchInputMapper* mapper = new MultiTouchInputMapper(mDevice);
addConfigurationProperty("touch.deviceType", "touchScreen");
prepareDisplay(DISPLAY_ORIENTATION_0);
- prepareAxes(POSITION | ID | SLOT | DISTANCE);
+ prepareAxes(POSITION | ID | SLOT | PRESSURE);
addMapperAndConfigure(mapper);
NotifyMotionArgs motionArgs;
- // initially hovering because distance is 1, pressure defaults to 0
+ // initially hovering because pressure is 0
processId(mapper, 1);
processPosition(mapper, 100, 200);
- processDistance(mapper, 1);
+ processPressure(mapper, 0);
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(AMOTION_EVENT_ACTION_HOVER_ENTER, motionArgs.action);
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
- toDisplayX(100), toDisplayY(200), 0, 0, 0, 0, 0, 0, 0, 1));
+ toDisplayX(100), toDisplayY(200), 0, 0, 0, 0, 0, 0, 0, 0));
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(AMOTION_EVENT_ACTION_HOVER_MOVE, motionArgs.action);
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
- toDisplayX(100), toDisplayY(200), 0, 0, 0, 0, 0, 0, 0, 1));
+ toDisplayX(100), toDisplayY(200), 0, 0, 0, 0, 0, 0, 0, 0));
// move a little
processPosition(mapper, 150, 250);
@@ -4972,23 +4923,23 @@ TEST_F(MultiTouchInputMapperTest, Process_WhenAbsMTDistanceIsPresent_HoversIfIts
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(AMOTION_EVENT_ACTION_HOVER_MOVE, motionArgs.action);
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
- toDisplayX(150), toDisplayY(250), 0, 0, 0, 0, 0, 0, 0, 1));
+ toDisplayX(150), toDisplayY(250), 0, 0, 0, 0, 0, 0, 0, 0));
- // down when distance goes to 0, pressure defaults to 1
- processDistance(mapper, 0);
+ // down when pressure becomes non-zero
+ processPressure(mapper, RAW_PRESSURE_MAX);
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(AMOTION_EVENT_ACTION_HOVER_EXIT, motionArgs.action);
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
- toDisplayX(150), toDisplayY(250), 0, 0, 0, 0, 0, 0, 0, 1));
+ toDisplayX(150), toDisplayY(250), 0, 0, 0, 0, 0, 0, 0, 0));
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(AMOTION_EVENT_ACTION_DOWN, motionArgs.action);
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
toDisplayX(150), toDisplayY(250), 1, 0, 0, 0, 0, 0, 0, 0));
- // up when distance goes to 1, hover restored
- processDistance(mapper, 1);
+ // up when pressure becomes 0, hover restored
+ processPressure(mapper, 0);
processSync(mapper);
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(AMOTION_EVENT_ACTION_UP, motionArgs.action);
@@ -4998,12 +4949,12 @@ TEST_F(MultiTouchInputMapperTest, Process_WhenAbsMTDistanceIsPresent_HoversIfIts
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(AMOTION_EVENT_ACTION_HOVER_ENTER, motionArgs.action);
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
- toDisplayX(150), toDisplayY(250), 0, 0, 0, 0, 0, 0, 0, 1));
+ toDisplayX(150), toDisplayY(250), 0, 0, 0, 0, 0, 0, 0, 0));
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(AMOTION_EVENT_ACTION_HOVER_MOVE, motionArgs.action);
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
- toDisplayX(150), toDisplayY(250), 0, 0, 0, 0, 0, 0, 0, 1));
+ toDisplayX(150), toDisplayY(250), 0, 0, 0, 0, 0, 0, 0, 0));
// exit hover when pointer goes away
processId(mapper, -1);
@@ -5011,7 +4962,7 @@ TEST_F(MultiTouchInputMapperTest, Process_WhenAbsMTDistanceIsPresent_HoversIfIts
ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&motionArgs));
ASSERT_EQ(AMOTION_EVENT_ACTION_HOVER_EXIT, motionArgs.action);
ASSERT_NO_FATAL_FAILURE(assertPointerCoords(motionArgs.pointerCoords[0],
- toDisplayX(150), toDisplayY(250), 0, 0, 0, 0, 0, 0, 0, 1));
+ toDisplayX(150), toDisplayY(250), 0, 0, 0, 0, 0, 0, 0, 0));
}
diff --git a/services/java/com/android/server/ConnectivityService.java b/services/java/com/android/server/ConnectivityService.java
index 22ce484..1341dd4 100644
--- a/services/java/com/android/server/ConnectivityService.java
+++ b/services/java/com/android/server/ConnectivityService.java
@@ -163,8 +163,6 @@ public class ConnectivityService extends IConnectivityManager.Stub {
private boolean mTestMode;
private static ConnectivityService sServiceInstance;
- private AtomicBoolean mBackgroundDataEnabled = new AtomicBoolean(true);
-
private INetworkManagementService mNetd;
private INetworkPolicyManager mPolicyManager;
@@ -213,13 +211,6 @@ public class ConnectivityService extends IConnectivityManager.Stub {
MAX_NETWORK_STATE_TRACKER_EVENT + 5;
/**
- * used internally to set the background data preference
- * arg1 = TRUE for enabled, FALSE for disabled
- */
- private static final int EVENT_SET_BACKGROUND_DATA =
- MAX_NETWORK_STATE_TRACKER_EVENT + 6;
-
- /**
* used internally to set enable/disable cellular data
* arg1 = ENBALED or DISABLED
*/
@@ -317,9 +308,6 @@ public class ConnectivityService extends IConnectivityManager.Stub {
handlerThread.start();
mHandler = new MyHandler(handlerThread.getLooper());
- mBackgroundDataEnabled.set(Settings.Secure.getInt(context.getContentResolver(),
- Settings.Secure.BACKGROUND_DATA, 1) == 1);
-
// setup our unique device name
if (TextUtils.isEmpty(SystemProperties.get("net.hostname"))) {
String id = Settings.Secure.getString(context.getContentResolver(),
@@ -1209,35 +1197,6 @@ public class ConnectivityService extends IConnectivityManager.Stub {
}
/**
- * @see ConnectivityManager#getBackgroundDataSetting()
- */
- public boolean getBackgroundDataSetting() {
- return mBackgroundDataEnabled.get();
- }
-
- /**
- * @see ConnectivityManager#setBackgroundDataSetting(boolean)
- */
- public void setBackgroundDataSetting(boolean allowBackgroundDataUsage) {
- mContext.enforceCallingOrSelfPermission(
- android.Manifest.permission.CHANGE_BACKGROUND_DATA_SETTING,
- "ConnectivityService");
-
- mBackgroundDataEnabled.set(allowBackgroundDataUsage);
-
- mHandler.sendMessage(mHandler.obtainMessage(EVENT_SET_BACKGROUND_DATA,
- (allowBackgroundDataUsage ? ENABLED : DISABLED), 0));
- }
-
- private void handleSetBackgroundData(boolean enabled) {
- Settings.Secure.putInt(mContext.getContentResolver(),
- Settings.Secure.BACKGROUND_DATA, enabled ? 1 : 0);
- Intent broadcast = new Intent(
- ConnectivityManager.ACTION_BACKGROUND_DATA_SETTING_CHANGED);
- mContext.sendBroadcast(broadcast);
- }
-
- /**
* @see ConnectivityManager#getMobileDataEnabled()
*/
public boolean getMobileDataEnabled() {
@@ -2273,12 +2232,6 @@ public class ConnectivityService extends IConnectivityManager.Stub {
handleSetNetworkPreference(preference);
break;
}
- case EVENT_SET_BACKGROUND_DATA:
- {
- boolean enabled = (msg.arg1 == ENABLED);
- handleSetBackgroundData(enabled);
- break;
- }
case EVENT_SET_MOBILE_DATA:
{
boolean enabled = (msg.arg1 == ENABLED);
diff --git a/services/java/com/android/server/MountService.java b/services/java/com/android/server/MountService.java
index fd03201..00aa14c 100644
--- a/services/java/com/android/server/MountService.java
+++ b/services/java/com/android/server/MountService.java
@@ -97,6 +97,9 @@ class MountService extends IMountService.Stub
private static final boolean DEBUG_EVENTS = false;
private static final boolean DEBUG_OBB = false;
+ // Disable this since it messes up long-running cryptfs operations.
+ private static final boolean WATCHDOG_ENABLE = false;
+
private static final String TAG = "MountService";
private static final String VOLD_TAG = "VoldConnector";
@@ -1182,8 +1185,10 @@ class MountService extends IMountService.Stub
Thread thread = new Thread(mConnector, VOLD_TAG);
thread.start();
- // Add ourself to the Watchdog monitors.
- Watchdog.getInstance().addMonitor(this);
+ // Add ourself to the Watchdog monitors if enabled.
+ if (WATCHDOG_ENABLE) {
+ Watchdog.getInstance().addMonitor(this);
+ }
}
/**
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index e9c91e6..800c4fc 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -572,8 +572,8 @@ public final class ActivityManagerService extends ActivityManagerNative
* string containing the provider's implementation class and values are a
* ContentProviderRecord object containing the data about it.
*/
- final HashMap<String, ContentProviderRecord> mProvidersByClass
- = new HashMap<String, ContentProviderRecord>();
+ final HashMap<ComponentName, ContentProviderRecord> mProvidersByClass
+ = new HashMap<ComponentName, ContentProviderRecord>();
/**
* List of content providers who have clients waiting for them. The
@@ -1074,7 +1074,7 @@ public final class ActivityManagerService extends ActivityManagerNative
int uid = msg.arg1;
boolean restart = (msg.arg2 == 1);
String pkg = (String) msg.obj;
- forceStopPackageLocked(pkg, uid, restart, false, true);
+ forceStopPackageLocked(pkg, uid, restart, false, true, false);
}
} break;
case FINALIZE_PENDING_INTENT_MSG: {
@@ -2699,7 +2699,6 @@ public final class ActivityManagerService extends ActivityManagerNative
}
if (!haveBg) {
- Slog.i(TAG, "Low Memory: No more background processes.");
EventLog.writeEvent(EventLogTags.AM_LOW_MEMORY, mLruProcesses.size());
long now = SystemClock.uptimeMillis();
for (int i=mLruProcesses.size()-1; i>=0; i--) {
@@ -3087,7 +3086,7 @@ public final class ActivityManagerService extends ActivityManagerNative
return;
}
killPackageProcessesLocked(packageName, pkgUid,
- ProcessList.SECONDARY_SERVER_ADJ, false, true, true);
+ ProcessList.SECONDARY_SERVER_ADJ, false, true, true, false);
}
} finally {
Binder.restoreCallingIdentity(callingId);
@@ -3245,7 +3244,7 @@ public final class ActivityManagerService extends ActivityManagerNative
}
private void forceStopPackageLocked(final String packageName, int uid) {
- forceStopPackageLocked(packageName, uid, false, false, true);
+ forceStopPackageLocked(packageName, uid, false, false, true, false);
Intent intent = new Intent(Intent.ACTION_PACKAGE_RESTARTED,
Uri.fromParts("package", packageName, null));
if (!mProcessesReady) {
@@ -3258,7 +3257,8 @@ public final class ActivityManagerService extends ActivityManagerNative
}
private final boolean killPackageProcessesLocked(String packageName, int uid,
- int minOomAdj, boolean callerWillRestart, boolean allowRestart, boolean doit) {
+ int minOomAdj, boolean callerWillRestart, boolean allowRestart, boolean doit,
+ boolean evenPersistent) {
ArrayList<ProcessRecord> procs = new ArrayList<ProcessRecord>();
// Remove all processes this package may have touched: all with the
@@ -3269,7 +3269,7 @@ public final class ActivityManagerService extends ActivityManagerNative
final int NA = apps.size();
for (int ia=0; ia<NA; ia++) {
ProcessRecord app = apps.valueAt(ia);
- if (app.persistent) {
+ if (app.persistent && !evenPersistent) {
// we don't kill persistent processes
continue;
}
@@ -3299,7 +3299,8 @@ public final class ActivityManagerService extends ActivityManagerNative
}
private final boolean forceStopPackageLocked(String name, int uid,
- boolean callerWillRestart, boolean purgeCache, boolean doit) {
+ boolean callerWillRestart, boolean purgeCache, boolean doit,
+ boolean evenPersistent) {
int i;
int N;
@@ -3323,12 +3324,12 @@ public final class ActivityManagerService extends ActivityManagerNative
}
boolean didSomething = killPackageProcessesLocked(name, uid, -100,
- callerWillRestart, false, doit);
+ callerWillRestart, false, doit, evenPersistent);
for (i=mMainStack.mHistory.size()-1; i>=0; i--) {
ActivityRecord r = (ActivityRecord)mMainStack.mHistory.get(i);
if (r.packageName.equals(name)
- && (r.app == null || !r.app.persistent)) {
+ && (r.app == null || evenPersistent || !r.app.persistent)) {
if (!doit) {
return true;
}
@@ -3345,7 +3346,7 @@ public final class ActivityManagerService extends ActivityManagerNative
ArrayList<ServiceRecord> services = new ArrayList<ServiceRecord>();
for (ServiceRecord service : mServices.values()) {
if (service.packageName.equals(name)
- && (service.app == null || !service.app.persistent)) {
+ && (service.app == null || evenPersistent || !service.app.persistent)) {
if (!doit) {
return true;
}
@@ -3758,7 +3759,7 @@ public final class ActivityManagerService extends ActivityManagerNative
if (pkgs != null) {
for (String pkg : pkgs) {
synchronized (ActivityManagerService.this) {
- if (forceStopPackageLocked(pkg, -1, false, false, false)) {
+ if (forceStopPackageLocked(pkg, -1, false, false, false, false)) {
setResultCode(Activity.RESULT_OK);
return;
}
@@ -5439,10 +5440,11 @@ public final class ActivityManagerService extends ActivityManagerNative
for (int i=0; i<N; i++) {
ProviderInfo cpi =
(ProviderInfo)providers.get(i);
- ContentProviderRecord cpr = mProvidersByClass.get(cpi.name);
+ ComponentName comp = new ComponentName(cpi.packageName, cpi.name);
+ ContentProviderRecord cpr = mProvidersByClass.get(comp);
if (cpr == null) {
cpr = new ContentProviderRecord(cpi, app.info);
- mProvidersByClass.put(cpi.name, cpr);
+ mProvidersByClass.put(comp, cpr);
}
app.pubProviders.put(cpi.name, cpr);
app.addPackage(cpi.applicationInfo.packageName);
@@ -5607,8 +5609,9 @@ public final class ActivityManagerService extends ActivityManagerNative
throw new IllegalArgumentException(
"Attempt to launch content provider before system ready");
}
-
- cpr = mProvidersByClass.get(cpi.name);
+
+ ComponentName comp = new ComponentName(cpi.packageName, cpi.name);
+ cpr = mProvidersByClass.get(comp);
final boolean firstClass = cpr == null;
if (firstClass) {
try {
@@ -5690,7 +5693,7 @@ public final class ActivityManagerService extends ActivityManagerNative
// Make sure the provider is published (the same provider class
// may be published under multiple names).
if (firstClass) {
- mProvidersByClass.put(cpi.name, cpr);
+ mProvidersByClass.put(comp, cpr);
}
mProvidersByName.put(name, cpr);
@@ -5770,7 +5773,8 @@ public final class ActivityManagerService extends ActivityManagerNative
" when removing content provider " + name);
}
//update content provider record entry info
- ContentProviderRecord localCpr = mProvidersByClass.get(cpr.info.name);
+ ComponentName comp = new ComponentName(cpr.info.packageName, cpr.info.name);
+ ContentProviderRecord localCpr = mProvidersByClass.get(comp);
if (DEBUG_PROVIDER) Slog.v(TAG, "Removing provider requested by "
+ r.info.processName + " from process "
+ localCpr.appInfo.processName);
@@ -5802,7 +5806,8 @@ public final class ActivityManagerService extends ActivityManagerNative
}
//update content provider record entry info
- ContentProviderRecord localCpr = mProvidersByClass.get(cpr.info.name);
+ ComponentName comp = new ComponentName(cpr.info.packageName, cpr.info.name);
+ ContentProviderRecord localCpr = mProvidersByClass.get(comp);
localCpr.externals--;
if (localCpr.externals < 0) {
Slog.e(TAG, "Externals < 0 for content provider " + localCpr);
@@ -5836,7 +5841,8 @@ public final class ActivityManagerService extends ActivityManagerNative
}
ContentProviderRecord dst = r.pubProviders.get(src.info.name);
if (dst != null) {
- mProvidersByClass.put(dst.info.name, dst);
+ ComponentName comp = new ComponentName(dst.info.packageName, dst.info.name);
+ mProvidersByClass.put(comp, dst);
String names[] = dst.info.authority.split(";");
for (int j = 0; j < names.length; j++) {
mProvidersByName.put(names[j], dst);
@@ -6179,7 +6185,7 @@ public final class ActivityManagerService extends ActivityManagerNative
mDebugTransient = !persistent;
if (packageName != null) {
final long origId = Binder.clearCallingIdentity();
- forceStopPackageLocked(packageName, -1, false, false, true);
+ forceStopPackageLocked(packageName, -1, false, false, true, true);
Binder.restoreCallingIdentity(origId);
}
}
@@ -7608,15 +7614,15 @@ public final class ActivityManagerService extends ActivityManagerNative
pw.println(" i[ntents]: pending intent state");
pw.println(" p[rocesses]: process state");
pw.println(" o[om]: out of memory management");
- pw.println(" prov[iders]: content provider state");
- pw.println(" s[ervices]: service state");
+ pw.println(" prov[iders] [COMP_SPEC ...]: content provider state");
+ pw.println(" s[ervices] [COMP_SPEC ...]: service state");
pw.println(" service [COMP_SPEC]: service client-side state");
+ pw.println(" all: dump all activities");
+ pw.println(" top: dump the top activity");
pw.println(" cmd may also be a COMP_SPEC to dump activities.");
- pw.println(" COMP_SPEC may also be a component name (com.foo/.myApp),");
- pw.println(" a partial substring in a component name, an");
- pw.println(" ActivityRecord hex object identifier, or");
- pw.println(" \"all\" for all objects, or");
- pw.println(" \"top\" for the top activity.");
+ pw.println(" COMP_SPEC may be a component name (com.foo/.myApp),");
+ pw.println(" a partial substring in a component name, a");
+ pw.println(" hex object identifier.");
pw.println(" -a: include all available server state.");
pw.println(" -c: include client state.");
return;
@@ -8167,9 +8173,89 @@ public final class ActivityManagerService extends ActivityManagerNative
}
}
+ static class ItemMatcher {
+ ArrayList<ComponentName> components;
+ ArrayList<String> strings;
+ ArrayList<Integer> objects;
+ boolean all;
+
+ ItemMatcher() {
+ all = true;
+ }
+
+ void build(String name) {
+ ComponentName componentName = ComponentName.unflattenFromString(name);
+ if (componentName != null) {
+ if (components == null) {
+ components = new ArrayList<ComponentName>();
+ }
+ components.add(componentName);
+ all = false;
+ } else {
+ int objectId = 0;
+ // Not a '/' separated full component name; maybe an object ID?
+ try {
+ objectId = Integer.parseInt(name, 16);
+ if (objects == null) {
+ objects = new ArrayList<Integer>();
+ }
+ objects.add(objectId);
+ all = false;
+ } catch (RuntimeException e) {
+ // Not an integer; just do string match.
+ if (strings == null) {
+ strings = new ArrayList<String>();
+ }
+ strings.add(name);
+ all = false;
+ }
+ }
+ }
+
+ int build(String[] args, int opti) {
+ for (; opti<args.length; opti++) {
+ String name = args[opti];
+ if ("--".equals(name)) {
+ return opti+1;
+ }
+ build(name);
+ }
+ return opti;
+ }
+
+ boolean match(Object object, ComponentName comp) {
+ if (all) {
+ return true;
+ }
+ if (components != null) {
+ for (int i=0; i<components.size(); i++) {
+ if (components.get(i).equals(comp)) {
+ return true;
+ }
+ }
+ }
+ if (objects != null) {
+ for (int i=0; i<objects.size(); i++) {
+ if (System.identityHashCode(object) == objects.get(i)) {
+ return true;
+ }
+ }
+ }
+ if (strings != null) {
+ String flat = comp.flattenToString();
+ for (int i=0; i<strings.size(); i++) {
+ if (flat.contains(strings.get(i))) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+ }
+
/**
* There are three things that cmd can be:
- * - a flattened component name that matched an existing activity
+ * - a flattened component name that matches an existing activity
* - the cmd arg isn't the flattened component name of an existing activity:
* dump all activity whose component contains the cmd as a substring
* - A hex number of the ActivityRecord object instance.
@@ -8192,29 +8278,12 @@ public final class ActivityManagerService extends ActivityManagerNative
}
}
} else {
- ComponentName componentName = ComponentName.unflattenFromString(name);
- int objectId = 0;
- if (componentName == null) {
- // Not a '/' separated full component name; maybe an object ID?
- try {
- objectId = Integer.parseInt(name, 16);
- name = null;
- componentName = null;
- } catch (RuntimeException e) {
- }
- }
+ ItemMatcher matcher = new ItemMatcher();
+ matcher.build(name);
synchronized (this) {
for (ActivityRecord r1 : (ArrayList<ActivityRecord>)mMainStack.mHistory) {
- if (componentName != null) {
- if (r1.intent.getComponent().equals(componentName)) {
- activities.add(r1);
- }
- } else if (name != null) {
- if (r1.intent.getComponent().flattenToString().contains(name)) {
- activities.add(r1);
- }
- } else if (System.identityHashCode(r1) == objectId) {
+ if (matcher.match(r1, r1.intent.getComponent())) {
activities.add(r1);
}
}
@@ -8405,6 +8474,9 @@ public final class ActivityManagerService extends ActivityManagerNative
int opti, boolean dumpAll, boolean dumpClient) {
boolean needSep = false;
+ ItemMatcher matcher = new ItemMatcher();
+ matcher.build(args, opti);
+
pw.println("ACTIVITY MANAGER SERVICES (dumpsys activity services)");
if (mServices.size() > 0) {
pw.println(" Active services:");
@@ -8413,6 +8485,9 @@ public final class ActivityManagerService extends ActivityManagerNative
needSep = false;
while (it.hasNext()) {
ServiceRecord r = it.next();
+ if (!matcher.match(r, r.name)) {
+ continue;
+ }
if (needSep) {
pw.println();
}
@@ -8458,6 +8533,9 @@ public final class ActivityManagerService extends ActivityManagerNative
pw.println(" Pending services:");
for (int i=0; i<mPendingServices.size(); i++) {
ServiceRecord r = mPendingServices.get(i);
+ if (!matcher.match(r, r.name)) {
+ continue;
+ }
pw.print(" * Pending "); pw.println(r);
r.dump(pw, " ");
}
@@ -8469,6 +8547,9 @@ public final class ActivityManagerService extends ActivityManagerNative
pw.println(" Restarting services:");
for (int i=0; i<mRestartingServices.size(); i++) {
ServiceRecord r = mRestartingServices.get(i);
+ if (!matcher.match(r, r.name)) {
+ continue;
+ }
pw.print(" * Restarting "); pw.println(r);
r.dump(pw, " ");
}
@@ -8480,6 +8561,9 @@ public final class ActivityManagerService extends ActivityManagerNative
pw.println(" Stopping services:");
for (int i=0; i<mStoppingServices.size(); i++) {
ServiceRecord r = mStoppingServices.get(i);
+ if (!matcher.match(r, r.name)) {
+ continue;
+ }
pw.print(" * Stopping "); pw.println(r);
r.dump(pw, " ");
}
@@ -8495,8 +8579,12 @@ public final class ActivityManagerService extends ActivityManagerNative
while (it.hasNext()) {
ArrayList<ConnectionRecord> r = it.next();
for (int i=0; i<r.size(); i++) {
- pw.print(" * "); pw.println(r.get(i));
- r.get(i).dump(pw, " ");
+ ConnectionRecord cr = r.get(i);
+ if (!matcher.match(cr.binding.service, cr.binding.service.name)) {
+ continue;
+ }
+ pw.print(" * "); pw.println(cr);
+ cr.dump(pw, " ");
}
}
needSep = true;
@@ -8510,20 +8598,34 @@ public final class ActivityManagerService extends ActivityManagerNative
int opti, boolean dumpAll) {
boolean needSep = false;
+ ItemMatcher matcher = new ItemMatcher();
+ matcher.build(args, opti);
+
pw.println("ACTIVITY MANAGER CONTENT PROVIDERS (dumpsys activity providers)");
if (mProvidersByClass.size() > 0) {
if (needSep) pw.println(" ");
pw.println(" Published content providers (by class):");
- Iterator<Map.Entry<String, ContentProviderRecord>> it
+ Iterator<Map.Entry<ComponentName, ContentProviderRecord>> it
= mProvidersByClass.entrySet().iterator();
while (it.hasNext()) {
- Map.Entry<String, ContentProviderRecord> e = it.next();
+ Map.Entry<ComponentName, ContentProviderRecord> e = it.next();
ContentProviderRecord r = e.getValue();
+ ComponentName comp = e.getKey();
+ String cls = comp.getClassName();
+ int end = cls.lastIndexOf('.');
+ if (end > 0 && end < (cls.length()-2)) {
+ cls = cls.substring(end+1);
+ }
+ if (!matcher.match(r, comp)) {
+ continue;
+ }
+ pw.print(" * "); pw.print(cls); pw.print(" (");
+ pw.print(comp.flattenToShortString()); pw.print(")");
if (dumpAll) {
- pw.print(" * "); pw.println(r);
- r.dump(pw, " ");
+ pw.println();
+ r.dump(pw, " ");
} else {
- pw.print(" * "); pw.print(r.name.toShortString());
+ pw.print(" * "); pw.print(e.getKey().flattenToShortString());
if (r.app != null) {
pw.println(":");
pw.print(" "); pw.println(r.app);
@@ -8544,6 +8646,9 @@ public final class ActivityManagerService extends ActivityManagerNative
while (it.hasNext()) {
Map.Entry<String, ContentProviderRecord> e = it.next();
ContentProviderRecord r = e.getValue();
+ if (!matcher.match(r, r.name)) {
+ continue;
+ }
pw.print(" "); pw.print(e.getKey()); pw.print(": ");
pw.println(r);
}
@@ -11257,7 +11362,7 @@ public final class ActivityManagerService extends ActivityManagerNative
String list[] = intent.getStringArrayExtra(Intent.EXTRA_CHANGED_PACKAGE_LIST);
if (list != null && (list.length > 0)) {
for (String pkg : list) {
- forceStopPackageLocked(pkg, -1, false, true, true);
+ forceStopPackageLocked(pkg, -1, false, true, true, false);
}
sendPackageBroadcastLocked(
IApplicationThread.EXTERNAL_STORAGE_UNAVAILABLE, list);
@@ -11268,7 +11373,7 @@ public final class ActivityManagerService extends ActivityManagerNative
if (data != null && (ssp=data.getSchemeSpecificPart()) != null) {
if (!intent.getBooleanExtra(Intent.EXTRA_DONT_KILL_APP, false)) {
forceStopPackageLocked(ssp,
- intent.getIntExtra(Intent.EXTRA_UID, -1), false, true, true);
+ intent.getIntExtra(Intent.EXTRA_UID, -1), false, true, true, false);
}
if (Intent.ACTION_PACKAGE_REMOVED.equals(intent.getAction())) {
sendPackageBroadcastLocked(IApplicationThread.PACKAGE_REMOVED,
@@ -12019,6 +12124,7 @@ public final class ActivityManagerService extends ActivityManagerNative
while (mParallelBroadcasts.size() > 0) {
r = mParallelBroadcasts.remove(0);
r.dispatchTime = SystemClock.uptimeMillis();
+ r.dispatchClockTime = System.currentTimeMillis();
final int N = r.receivers.size();
if (DEBUG_BROADCAST_LIGHT) Slog.v(TAG, "Processing parallel broadcast "
+ r);
@@ -12157,7 +12263,7 @@ public final class ActivityManagerService extends ActivityManagerNative
r.receiverTime = SystemClock.uptimeMillis();
if (recIdx == 0) {
r.dispatchTime = r.receiverTime;
-
+ r.dispatchClockTime = System.currentTimeMillis();
if (DEBUG_BROADCAST_LIGHT) Slog.v(TAG, "Processing ordered broadcast "
+ r);
}
@@ -12218,7 +12324,7 @@ public final class ActivityManagerService extends ActivityManagerNative
}
skip = true;
}
- if (r.callingUid != Process.SYSTEM_UID &&
+ if (info.activityInfo.applicationInfo.uid != Process.SYSTEM_UID &&
r.requiredPermission != null) {
try {
perm = AppGlobals.getPackageManager().
@@ -12365,7 +12471,8 @@ public final class ActivityManagerService extends ActivityManagerNative
}
final long origId = Binder.clearCallingIdentity();
- forceStopPackageLocked(ii.targetPackage, -1, true, false, true);
+ // Instrumentation can kill and relaunch even persistent processes
+ forceStopPackageLocked(ii.targetPackage, -1, true, false, true, true);
ProcessRecord app = addAppLocked(ai);
app.instrumentationClass = className;
app.instrumentationInfo = ai;
@@ -12420,7 +12527,7 @@ public final class ActivityManagerService extends ActivityManagerNative
app.instrumentationProfileFile = null;
app.instrumentationArguments = null;
- forceStopPackageLocked(app.processName, -1, false, false, true);
+ forceStopPackageLocked(app.processName, -1, false, false, true, true);
}
public void finishInstrumentation(IApplicationThread target,
diff --git a/services/java/com/android/server/am/BroadcastRecord.java b/services/java/com/android/server/am/BroadcastRecord.java
index c95053e..bcb0134 100644
--- a/services/java/com/android/server/am/BroadcastRecord.java
+++ b/services/java/com/android/server/am/BroadcastRecord.java
@@ -29,6 +29,7 @@ import android.util.PrintWriterPrinter;
import android.util.TimeUtils;
import java.io.PrintWriter;
+import java.util.Date;
import java.util.List;
/**
@@ -47,6 +48,7 @@ class BroadcastRecord extends Binder {
final List receivers; // contains BroadcastFilter and ResolveInfo
IIntentReceiver resultTo; // who receives final result if non-null
long dispatchTime; // when dispatch started on this set of receivers
+ long dispatchClockTime; // the clock time the dispatch started
long receiverTime; // when current receiver started for timeouts.
long finishTime; // when we finished the broadcast.
int resultCode; // current result code value.
@@ -91,6 +93,8 @@ class BroadcastRecord extends Binder {
if (requiredPermission != null) {
pw.print(prefix); pw.print("requiredPermission="); pw.println(requiredPermission);
}
+ pw.print(prefix); pw.print("dispatchClockTime=");
+ pw.println(new Date(dispatchClockTime));
pw.print(prefix); pw.print("dispatchTime=");
TimeUtils.formatDuration(dispatchTime, now, pw);
if (finishTime != 0) {
diff --git a/services/java/com/android/server/net/NetworkPolicyManagerService.java b/services/java/com/android/server/net/NetworkPolicyManagerService.java
index 9c3d166..14d9665 100644
--- a/services/java/com/android/server/net/NetworkPolicyManagerService.java
+++ b/services/java/com/android/server/net/NetworkPolicyManagerService.java
@@ -89,6 +89,7 @@ import android.os.IPowerManager;
import android.os.Message;
import android.os.RemoteCallbackList;
import android.os.RemoteException;
+import android.provider.Settings;
import android.telephony.TelephonyManager;
import android.text.format.Formatter;
import android.text.format.Time;
@@ -168,6 +169,12 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
private static final String ATTR_UID = "uid";
private static final String ATTR_POLICY = "policy";
+ private static final String TAG_ALLOW_BACKGROUND = TAG + ":allowBackground";
+
+ // @VisibleForTesting
+ public static final String ACTION_ALLOW_BACKGROUND =
+ "com.android.server.action.ACTION_ALLOW_BACKGROUND";
+
private static final long TIME_CACHE_MAX_AGE = DAY_IN_MILLIS;
private static final int MSG_RULES_CHANGED = 0x1;
@@ -185,8 +192,8 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
private final Object mRulesLock = new Object();
- private boolean mScreenOn;
- private boolean mRestrictBackground;
+ private volatile boolean mScreenOn;
+ private volatile boolean mRestrictBackground;
/** Defined network policies. */
private HashMap<NetworkTemplate, NetworkPolicy> mNetworkPolicy = Maps.newHashMap();
@@ -265,6 +272,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
if (mRestrictBackground) {
updateRulesForRestrictBackgroundLocked();
+ updateNotificationsLocked();
}
}
@@ -309,6 +317,10 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
mContext.registerReceiver(
mStatsReceiver, statsFilter, READ_NETWORK_USAGE_HISTORY, mHandler);
+ // listen for restrict background changes from notifications
+ final IntentFilter allowFilter = new IntentFilter(ACTION_ALLOW_BACKGROUND);
+ mContext.registerReceiver(mAllowReceiver, allowFilter, MANAGE_NETWORK_POLICY, mHandler);
+
}
private IProcessObserver mProcessObserver = new IProcessObserver.Stub() {
@@ -402,6 +414,20 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
};
/**
+ * Receiver that watches for {@link Notification} control of
+ * {@link #mRestrictBackground}.
+ */
+ private BroadcastReceiver mAllowReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ // on background handler thread, and verified MANAGE_NETWORK_POLICY
+ // permission above.
+
+ setRestrictBackground(false);
+ }
+ };
+
+ /**
* Observer that watches for {@link INetworkManagementService} alerts.
*/
private INetworkManagementEventObserver mAlertObserver = new NetworkAlertObserver() {
@@ -494,6 +520,13 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
notifyUnderLimitLocked(policy.template);
}
}
+
+ // ongoing notification when restricting background data
+ if (mRestrictBackground) {
+ enqueueRestrictedNotification(TAG_ALLOW_BACKGROUND);
+ } else {
+ cancelNotification(TAG_ALLOW_BACKGROUND);
+ }
}
/**
@@ -614,16 +647,52 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
}
/**
+ * Show ongoing notification to reflect that {@link #mRestrictBackground}
+ * has been enabled.
+ */
+ private void enqueueRestrictedNotification(String tag) {
+ final Resources res = mContext.getResources();
+ final Notification.Builder builder = new Notification.Builder(mContext);
+
+ final CharSequence title = res.getText(R.string.data_usage_restricted_title);
+ final CharSequence body = res.getString(R.string.data_usage_restricted_body);
+
+ builder.setOnlyAlertOnce(true);
+ builder.setOngoing(true);
+ builder.setSmallIcon(R.drawable.ic_menu_info_details);
+ builder.setTicker(title);
+ builder.setContentTitle(title);
+ builder.setContentText(body);
+
+ final Intent intent = buildAllowBackgroundDataIntent();
+ builder.setContentIntent(
+ PendingIntent.getBroadcast(mContext, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT));
+
+ // TODO: move to NotificationManager once we can mock it
+ try {
+ final String packageName = mContext.getPackageName();
+ final int[] idReceived = new int[1];
+ mNotifManager.enqueueNotificationWithTag(packageName, tag,
+ 0x0, builder.getNotification(), idReceived);
+ } catch (RemoteException e) {
+ Slog.w(TAG, "problem during enqueueNotification: " + e);
+ }
+ }
+
+ /**
* Cancel any notification for combined {@link NetworkPolicy} and specific
* type, like {@link #TYPE_LIMIT}.
*/
private void cancelNotification(NetworkPolicy policy, int type) {
- final String tag = buildNotificationTag(policy, type);
+ cancelNotification(buildNotificationTag(policy, type));
+ }
+ private void cancelNotification(String tag) {
// TODO: move to NotificationManager once we can mock it
try {
final String packageName = mContext.getPackageName();
- mNotifManager.cancelNotificationWithTag(packageName, tag, 0x0);
+ mNotifManager.cancelNotificationWithTag(
+ packageName, tag, 0x0);
} catch (RemoteException e) {
Slog.w(TAG, "problem during enqueueNotification: " + e);
}
@@ -731,15 +800,9 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
final boolean hasLimit = policy.limitBytes != LIMIT_DISABLED;
final boolean hasWarning = policy.warningBytes != WARNING_DISABLED;
- if (hasLimit || hasWarning) {
- final long quotaBytes;
- if (hasLimit) {
- // remaining "quota" is based on usage in current cycle
- quotaBytes = Math.max(0, policy.limitBytes - total);
- } else {
- // to track warning alert later, use a high quota
- quotaBytes = Long.MAX_VALUE;
- }
+ if (hasLimit) {
+ // remaining "quota" is based on usage in current cycle
+ final long quotaBytes = Math.max(0, policy.limitBytes - total);
if (ifaces.length > 1) {
// TODO: switch to shared quota once NMS supports
@@ -754,16 +817,6 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
}
}
}
-
- if (hasWarning) {
- final long alertBytes = Math.max(0, policy.warningBytes - total);
- for (String iface : ifaces) {
- removeInterfaceAlert(iface);
- if (alertBytes > 0) {
- setInterfaceAlert(iface, alertBytes);
- }
- }
- }
}
// remove quota on any trailing interfaces
@@ -839,11 +892,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
mRestrictBackground = readBooleanAttribute(
in, ATTR_RESTRICT_BACKGROUND);
} else {
- try {
- mRestrictBackground = !mConnManager.getBackgroundDataSetting();
- } catch (RemoteException e) {
- mRestrictBackground = false;
- }
+ mRestrictBackground = false;
}
} else if (TAG_NETWORK_POLICY.equals(tag)) {
@@ -879,6 +928,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
} catch (FileNotFoundException e) {
// missing policy is okay, probably first boot
+ upgradeLegacyBackgroundData();
} catch (IOException e) {
Slog.e(TAG, "problem reading network stats", e);
} catch (XmlPullParserException e) {
@@ -888,6 +938,22 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
}
}
+ /**
+ * Upgrade legacy background data flags, notifying listeners of one last
+ * change to always-true.
+ */
+ private void upgradeLegacyBackgroundData() {
+ mRestrictBackground = Settings.Secure.getInt(
+ mContext.getContentResolver(), Settings.Secure.BACKGROUND_DATA, 1) != 1;
+
+ // kick off one last broadcast if restricted
+ if (mRestrictBackground) {
+ final Intent broadcast = new Intent(
+ ConnectivityManager.ACTION_BACKGROUND_DATA_SETTING_CHANGED);
+ mContext.sendBroadcast(broadcast);
+ }
+ }
+
private void writePolicyLocked() {
if (LOGV) Slog.v(TAG, "writePolicyLocked()");
@@ -1057,6 +1123,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
synchronized (mRulesLock) {
mRestrictBackground = restrictBackground;
updateRulesForRestrictBackgroundLocked();
+ updateNotificationsLocked();
writePolicyLocked();
}
}
@@ -1420,6 +1487,10 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
return telephony.getSubscriberId();
}
+ private static Intent buildAllowBackgroundDataIntent() {
+ return new Intent(ACTION_ALLOW_BACKGROUND);
+ }
+
private static Intent buildNetworkOverLimitIntent(NetworkTemplate template) {
final Intent intent = new Intent();
intent.setComponent(new ComponentName(
diff --git a/services/java/com/android/server/pm/PackageManagerService.java b/services/java/com/android/server/pm/PackageManagerService.java
index abb62de..dbb8164 100644
--- a/services/java/com/android/server/pm/PackageManagerService.java
+++ b/services/java/com/android/server/pm/PackageManagerService.java
@@ -4340,6 +4340,7 @@ public class PackageManagerService extends IPackageManager.Stub {
res.labelRes = info.labelRes;
res.nonLocalizedLabel = info.nonLocalizedLabel;
res.icon = info.icon;
+ res.system = isSystemApp(res.activityInfo.applicationInfo);
return res;
}
@@ -4512,6 +4513,7 @@ public class PackageManagerService extends IPackageManager.Stub {
res.labelRes = info.labelRes;
res.nonLocalizedLabel = info.nonLocalizedLabel;
res.icon = info.icon;
+ res.system = isSystemApp(res.serviceInfo.applicationInfo);
return res;
}
@@ -4569,7 +4571,13 @@ public class PackageManagerService extends IPackageManager.Stub {
v1 = r1.match;
v2 = r2.match;
//System.out.println("Comparing: m1=" + m1 + " m2=" + m2);
- return (v1 > v2) ? -1 : ((v1 < v2) ? 1 : 0);
+ if (v1 != v2) {
+ return (v1 > v2) ? -1 : 1;
+ }
+ if (r1.system != r2.system) {
+ return r1.system ? -1 : 1;
+ }
+ return 0;
}
};
diff --git a/services/jni/com_android_server_InputManager.cpp b/services/jni/com_android_server_InputManager.cpp
index 7c84e43..f2a0a71 100644
--- a/services/jni/com_android_server_InputManager.cpp
+++ b/services/jni/com_android_server_InputManager.cpp
@@ -182,8 +182,6 @@ public:
/* --- InputReaderPolicyInterface implementation --- */
- virtual bool getDisplayInfo(int32_t displayId, bool external,
- int32_t* width, int32_t* height, int32_t* orientation);
virtual void getReaderConfiguration(InputReaderConfiguration* outConfig);
virtual sp<PointerControllerInterface> obtainPointerController(int32_t deviceId);
@@ -273,7 +271,7 @@ NativeInputManager::NativeInputManager(jobject contextObj,
mLocked.displayHeight = -1;
mLocked.displayExternalWidth = -1;
mLocked.displayExternalHeight = -1;
- mLocked.displayOrientation = ROTATION_0;
+ mLocked.displayOrientation = DISPLAY_ORIENTATION_0;
mLocked.systemUiVisibility = ASYSTEM_UI_VISIBILITY_STATUS_BAR_VISIBLE;
mLocked.pointerSpeed = 0;
@@ -311,31 +309,42 @@ bool NativeInputManager::checkAndClearExceptionFromCallback(JNIEnv* env, const c
void NativeInputManager::setDisplaySize(int32_t displayId, int32_t width, int32_t height,
int32_t externalWidth, int32_t externalHeight) {
+ bool changed = false;
if (displayId == 0) {
- { // acquire lock
- AutoMutex _l(mLock);
+ AutoMutex _l(mLock);
- if (mLocked.displayWidth != width || mLocked.displayHeight != height) {
- mLocked.displayWidth = width;
- mLocked.displayHeight = height;
+ if (mLocked.displayWidth != width || mLocked.displayHeight != height) {
+ changed = true;
+ mLocked.displayWidth = width;
+ mLocked.displayHeight = height;
- sp<PointerController> controller = mLocked.pointerController.promote();
- if (controller != NULL) {
- controller->setDisplaySize(width, height);
- }
+ sp<PointerController> controller = mLocked.pointerController.promote();
+ if (controller != NULL) {
+ controller->setDisplaySize(width, height);
}
+ }
+ if (mLocked.displayExternalWidth != externalWidth
+ || mLocked.displayExternalHeight != externalHeight) {
+ changed = true;
mLocked.displayExternalWidth = externalWidth;
mLocked.displayExternalHeight = externalHeight;
- } // release lock
+ }
+ }
+
+ if (changed) {
+ mInputManager->getReader()->requestRefreshConfiguration(
+ InputReaderConfiguration::CHANGE_DISPLAY_INFO);
}
}
void NativeInputManager::setDisplayOrientation(int32_t displayId, int32_t orientation) {
+ bool changed = false;
if (displayId == 0) {
AutoMutex _l(mLock);
if (mLocked.displayOrientation != orientation) {
+ changed = true;
mLocked.displayOrientation = orientation;
sp<PointerController> controller = mLocked.pointerController.promote();
@@ -344,6 +353,11 @@ void NativeInputManager::setDisplayOrientation(int32_t displayId, int32_t orient
}
}
}
+
+ if (changed) {
+ mInputManager->getReader()->requestRefreshConfiguration(
+ InputReaderConfiguration::CHANGE_DISPLAY_INFO);
+ }
}
status_t NativeInputManager::registerInputChannel(JNIEnv* env,
@@ -358,28 +372,6 @@ status_t NativeInputManager::unregisterInputChannel(JNIEnv* env,
return mInputManager->getDispatcher()->unregisterInputChannel(inputChannel);
}
-bool NativeInputManager::getDisplayInfo(int32_t displayId, bool external,
- int32_t* width, int32_t* height, int32_t* orientation) {
- bool result = false;
- if (displayId == 0) {
- AutoMutex _l(mLock);
-
- if (mLocked.displayWidth > 0 && mLocked.displayHeight > 0) {
- if (width) {
- *width = external ? mLocked.displayExternalWidth : mLocked.displayWidth;
- }
- if (height) {
- *height = external ? mLocked.displayExternalHeight : mLocked.displayHeight;
- }
- if (orientation) {
- *orientation = mLocked.displayOrientation;
- }
- result = true;
- }
- }
- return result;
-}
-
void NativeInputManager::getReaderConfiguration(InputReaderConfiguration* outConfig) {
JNIEnv* env = jniEnv();
@@ -438,6 +430,12 @@ void NativeInputManager::getReaderConfiguration(InputReaderConfiguration* outCon
outConfig->pointerVelocityControlParameters.scale = exp2f(mLocked.pointerSpeed
* POINTER_SPEED_EXPONENT);
outConfig->pointerGesturesEnabled = mLocked.pointerGesturesEnabled;
+
+ outConfig->setDisplayInfo(0, false /*external*/,
+ mLocked.displayWidth, mLocked.displayHeight, mLocked.displayOrientation);
+ outConfig->setDisplayInfo(0, true /*external*/,
+ mLocked.displayExternalWidth, mLocked.displayExternalHeight,
+ mLocked.displayOrientation);
} // release lock
}
diff --git a/services/sensorservice/Fusion.cpp b/services/sensorservice/Fusion.cpp
index d706af5..ff4786b 100644
--- a/services/sensorservice/Fusion.cpp
+++ b/services/sensorservice/Fusion.cpp
@@ -48,6 +48,7 @@ static const float accSTDEV = 0.05f; // m/s^2 (measured 0.08 / CDD 0.05)
static const float magSTDEV = 0.5f; // uT (measured 0.7 / CDD 0.5)
static const float FREE_FALL_THRESHOLD = 0.981f;
+static const float SYMMETRY_TOLERANCE = 1e-10f;
// -----------------------------------------------------------------------
@@ -134,10 +135,13 @@ Fusion::Fusion() {
void Fusion::init() {
mInitState = 0;
+
mGyroRate = 0;
+
mCount[0] = 0;
mCount[1] = 0;
mCount[2] = 0;
+
mData = 0;
}
@@ -267,19 +271,16 @@ status_t Fusion::handleMag(const vec3_t& m) {
return NO_ERROR;
}
-bool Fusion::checkState(const vec3_t& v) {
- if (isnanf(length(v))) {
- LOGW("9-axis fusion diverged. reseting state.");
+void Fusion::checkState() {
+ // P needs to stay positive semidefinite or the fusion diverges. When we
+ // detect divergence, we reset the fusion.
+ // TODO(braun): Instead, find the reason for the divergence and fix it.
+
+ if (!isPositiveSemidefinite(P[0][0], SYMMETRY_TOLERANCE) ||
+ !isPositiveSemidefinite(P[1][1], SYMMETRY_TOLERANCE)) {
+ LOGW("Sensor fusion diverged; resetting state.");
P = 0;
- x1 = 0;
- mInitState = 0;
- mCount[0] = 0;
- mCount[1] = 0;
- mCount[2] = 0;
- mData = 0;
- return false;
}
- return true;
}
vec4_t Fusion::getAttitude() const {
@@ -327,6 +328,8 @@ void Fusion::predict(const vec3_t& w, float dT) {
Phi[1][0] = wx*k0 - I33dT - wx2*(ilwe*ilwe*ilwe)*(lwedT-k1);
P = Phi*P*transpose(Phi) + GQGt;
+
+ checkState();
}
void Fusion::update(const vec3_t& z, const vec3_t& Bi, float sigma) {
@@ -365,6 +368,8 @@ void Fusion::update(const vec3_t& z, const vec3_t& Bi, float sigma) {
q += getF(q)*(0.5f*dq);
x0 = normalize_quat(q);
x1 += db;
+
+ checkState();
}
// -----------------------------------------------------------------------
diff --git a/services/sensorservice/Fusion.h b/services/sensorservice/Fusion.h
index 556944b..7062999 100644
--- a/services/sensorservice/Fusion.h
+++ b/services/sensorservice/Fusion.h
@@ -37,7 +37,7 @@ class Fusion {
vec3_t x1;
/*
- * the predicated covariance matrix is made of 4 3x3 sub-matrices and it
+ * the predicated covariance matrix is made of 4 3x3 sub-matrices and it is
* semi-definite positive.
*
* P = | P00 P10 | = | P00 P10 |
@@ -74,7 +74,7 @@ private:
enum { ACC=0x1, MAG=0x2, GYRO=0x4 };
bool checkInitComplete(int, const vec3_t& w, float d = 0);
void initFusion(const vec4_t& q0, float dT);
- bool checkState(const vec3_t& v);
+ void checkState();
void predict(const vec3_t& w, float dT);
void update(const vec3_t& z, const vec3_t& Bi, float sigma);
static mat34_t getF(const vec4_t& p);
diff --git a/services/sensorservice/mat.h b/services/sensorservice/mat.h
index 1302ca3..a76fc91 100644
--- a/services/sensorservice/mat.h
+++ b/services/sensorservice/mat.h
@@ -295,6 +295,29 @@ mat<TYPE, R, C> PURE transpose(const mat<TYPE, C, R>& m) {
return r;
}
+// Calculate the trace of a matrix
+template <typename TYPE, size_t C> static TYPE trace(const mat<TYPE, C, C>& m) {
+ TYPE t;
+ for (size_t i=0 ; i<C ; i++)
+ t += m[i][i];
+ return t;
+}
+
+// Test positive-semidefiniteness of a matrix
+template <typename TYPE, size_t C>
+static bool isPositiveSemidefinite(const mat<TYPE, C, C>& m, TYPE tolerance) {
+ for (size_t i=0 ; i<C ; i++)
+ if (m[i][i] < 0)
+ return false;
+
+ for (size_t i=0 ; i<C ; i++)
+ for (size_t j=i+1 ; j<C ; j++)
+ if (fabs(m[i][j] - m[j][i]) > tolerance)
+ return false;
+
+ return true;
+}
+
// Transpose a vector
template <
template<typename T, size_t S> class VEC,
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index 0425fc3..19c7ddd 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -133,6 +133,11 @@ sp<ISurface> Layer::createSurface()
return sur;
}
+wp<IBinder> Layer::getSurfaceTextureBinder() const
+{
+ return mSurfaceTexture->asBinder();
+}
+
status_t Layer::setBuffers( uint32_t w, uint32_t h,
PixelFormat format, uint32_t flags)
{
@@ -191,13 +196,12 @@ void Layer::setGeometry(hwc_layer_t* hwcl)
* 1) buffer orientation/flip/mirror
* 2) state transformation (window manager)
* 3) layer orientation (screen orientation)
- * mOrientation is already the composition of (2) and (3)
+ * mTransform is already the composition of (2) and (3)
* (NOTE: the matrices are multiplied in reverse order)
*/
const Transform bufferOrientation(mCurrentTransform);
- const Transform layerOrientation(mOrientation);
- const Transform tr(layerOrientation * bufferOrientation);
+ const Transform tr(mTransform * bufferOrientation);
// this gives us only the "orientation" component of the transform
const uint32_t finalTransform = tr.getOrientation();
diff --git a/services/surfaceflinger/Layer.h b/services/surfaceflinger/Layer.h
index d3ddab4..5f0be80 100644
--- a/services/surfaceflinger/Layer.h
+++ b/services/surfaceflinger/Layer.h
@@ -74,6 +74,9 @@ public:
virtual bool isProtected() const;
virtual void onRemoved();
+ // LayerBaseClient interface
+ virtual wp<IBinder> getSurfaceTextureBinder() const;
+
// only for debugging
inline const sp<FreezeLock>& getFreezeLock() const { return mFreezeLock; }
diff --git a/services/surfaceflinger/LayerBase.cpp b/services/surfaceflinger/LayerBase.cpp
index e04c533..4cc245a 100644
--- a/services/surfaceflinger/LayerBase.cpp
+++ b/services/surfaceflinger/LayerBase.cpp
@@ -257,6 +257,7 @@ void LayerBase::validateVisibility(const Transform& planeTransform)
// cache a few things...
mOrientation = tr.getOrientation();
+ mTransform = tr;
mTransformedBounds = tr.makeBounds(w, h);
mLeft = tr.tx();
mTop = tr.ty();
@@ -544,6 +545,10 @@ wp<IBinder> LayerBaseClient::getSurfaceBinder() const {
return mClientSurfaceBinder;
}
+wp<IBinder> LayerBaseClient::getSurfaceTextureBinder() const {
+ return 0;
+}
+
void LayerBaseClient::dump(String8& result, char* buffer, size_t SIZE) const
{
LayerBase::dump(result, buffer, SIZE);
diff --git a/services/surfaceflinger/LayerBase.h b/services/surfaceflinger/LayerBase.h
index faf71dd..2cd3a94 100644
--- a/services/surfaceflinger/LayerBase.h
+++ b/services/surfaceflinger/LayerBase.h
@@ -247,6 +247,7 @@ private:
protected:
// cached during validateVisibility()
int32_t mOrientation;
+ Transform mTransform;
GLfloat mVertices[4][2];
Rect mTransformedBounds;
int mLeft;
@@ -288,6 +289,7 @@ public:
sp<ISurface> getSurface();
wp<IBinder> getSurfaceBinder() const;
+ virtual wp<IBinder> getSurfaceTextureBinder() const;
virtual sp<LayerBaseClient> getLayerBaseClient() const {
return const_cast<LayerBaseClient*>(this); }
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index a68ab30..50afb3d 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -353,9 +353,10 @@ void SurfaceFlinger::signalEvent() {
mEventQueue.invalidate();
}
-bool SurfaceFlinger::authenticateSurface(const sp<ISurface>& surface) const {
+bool SurfaceFlinger::authenticateSurfaceTexture(
+ const sp<ISurfaceTexture>& surfaceTexture) const {
Mutex::Autolock _l(mStateLock);
- sp<IBinder> surfBinder(surface->asBinder());
+ sp<IBinder> surfaceTextureBinder(surfaceTexture->asBinder());
// Check the visible layer list for the ISurface
const LayerVector& currentLayers = mCurrentState.layersSortedByZ;
@@ -363,14 +364,17 @@ bool SurfaceFlinger::authenticateSurface(const sp<ISurface>& surface) const {
for (size_t i=0 ; i<count ; i++) {
const sp<LayerBase>& layer(currentLayers[i]);
sp<LayerBaseClient> lbc(layer->getLayerBaseClient());
- if (lbc != NULL && lbc->getSurfaceBinder() == surfBinder) {
- return true;
+ if (lbc != NULL) {
+ wp<IBinder> lbcBinder = lbc->getSurfaceTextureBinder();
+ if (lbcBinder == surfaceTextureBinder) {
+ return true;
+ }
}
}
// Check the layers in the purgatory. This check is here so that if a
- // Surface gets destroyed before all the clients are done using it, the
- // error will not be reported as "surface XYZ is not authenticated", but
+ // SurfaceTexture gets destroyed before all the clients are done using it,
+ // the error will not be reported as "surface XYZ is not authenticated", but
// will instead fail later on when the client tries to use the surface,
// which should be reported as "surface XYZ returned an -ENODEV". The
// purgatorized layers are no less authentic than the visible ones, so this
@@ -379,8 +383,11 @@ bool SurfaceFlinger::authenticateSurface(const sp<ISurface>& surface) const {
for (size_t i=0 ; i<purgatorySize ; i++) {
const sp<LayerBase>& layer(mLayerPurgatory.itemAt(i));
sp<LayerBaseClient> lbc(layer->getLayerBaseClient());
- if (lbc != NULL && lbc->getSurfaceBinder() == surfBinder) {
- return true;
+ if (lbc != NULL) {
+ wp<IBinder> lbcBinder = lbc->getSurfaceTextureBinder();
+ if (lbcBinder == surfaceTextureBinder) {
+ return true;
+ }
}
}
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index 89df0de..1738238 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -171,7 +171,7 @@ public:
virtual status_t freezeDisplay(DisplayID dpy, uint32_t flags);
virtual status_t unfreezeDisplay(DisplayID dpy, uint32_t flags);
virtual int setOrientation(DisplayID dpy, int orientation, uint32_t flags);
- virtual bool authenticateSurface(const sp<ISurface>& surface) const;
+ virtual bool authenticateSurfaceTexture(const sp<ISurfaceTexture>& surface) const;
virtual status_t captureScreen(DisplayID dpy,
sp<IMemoryHeap>* heap,
diff --git a/telephony/java/com/android/internal/telephony/IccCard.java b/telephony/java/com/android/internal/telephony/IccCard.java
index 02617c8..bce9991 100644
--- a/telephony/java/com/android/internal/telephony/IccCard.java
+++ b/telephony/java/com/android/internal/telephony/IccCard.java
@@ -268,7 +268,6 @@ public abstract class IccCard {
}
public void supplyNetworkDepersonalization (String pin, Message onComplete) {
- if(mDbg) log("Network Despersonalization: " + pin);
mPhone.mCM.supplyNetworkDepersonalization(pin,
mHandler.obtainMessage(EVENT_PINPUK_DONE, onComplete));
}
@@ -359,7 +358,6 @@ public abstract class IccCard {
*/
public void changeIccLockPassword(String oldPassword, String newPassword,
Message onComplete) {
- if(mDbg) log("Change Pin1 old: " + oldPassword + " new: " + newPassword);
mPhone.mCM.changeIccPin(oldPassword, newPassword,
mHandler.obtainMessage(EVENT_CHANGE_ICC_PASSWORD_DONE, onComplete));
@@ -378,7 +376,6 @@ public abstract class IccCard {
*/
public void changeIccFdnPassword(String oldPassword, String newPassword,
Message onComplete) {
- if(mDbg) log("Change Pin2 old: " + oldPassword + " new: " + newPassword);
mPhone.mCM.changeIccPin2(oldPassword, newPassword,
mHandler.obtainMessage(EVENT_CHANGE_ICC_PASSWORD_DONE, onComplete));
diff --git a/tests/BiDiTests/res/layout/basic.xml b/tests/BiDiTests/res/layout/basic.xml
index e8f67a6..8a27213 100644
--- a/tests/BiDiTests/res/layout/basic.xml
+++ b/tests/BiDiTests/res/layout/basic.xml
@@ -34,6 +34,19 @@
android:textSize="32dip"
/>
+ <TextView android:id="@+id/textview_default"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:textSize="32dip"
+ android:text="@string/textview_default_text"
+ />
+
+ <EditText android:id="@+id/edittext_default"
+ android:layout_height="wrap_content"
+ android:layout_width="match_parent"
+ android:textSize="32dip"
+ />
+
<TextView android:id="@+id/textview_ltr"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
@@ -46,7 +59,6 @@
android:layout_width="match_parent"
android:textSize="32dip"
android:textDirection="ltr"
- android:text="@string/url"
/>
<TextView android:id="@+id/textview_rtl"
diff --git a/tests/BiDiTests/res/values/strings.xml b/tests/BiDiTests/res/values/strings.xml
index fde0ecf..b0809da 100644
--- a/tests/BiDiTests/res/values/strings.xml
+++ b/tests/BiDiTests/res/values/strings.xml
@@ -27,6 +27,7 @@
<string name="textview_text">This is a text for a TextView</string>
<string name="textview_ltr_text">This is a text for a LTR TextView</string>
<string name="textview_rtl_text">This is a text for a RTL TextView</string>
+ <string name="textview_default_text">This is a text for a default TextView</string>
<string name="edittext_text">mmmmmmmmmmmmmmmmmmmmmmmm</string>
<string name="normal_text">Normal String</string>
<string name="normal_long_text">mmmmmmmmmmmmmmmmmmmmmmmm</string>
diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/FsUtils.java b/tests/DumpRenderTree/src/com/android/dumprendertree/FsUtils.java
index b7d2c26..5e2a9fd 100644
--- a/tests/DumpRenderTree/src/com/android/dumprendertree/FsUtils.java
+++ b/tests/DumpRenderTree/src/com/android/dumprendertree/FsUtils.java
@@ -141,7 +141,7 @@ public class FsUtils {
} else if (!path.startsWith(HTTP_LOCAL_TESTS_PREFIX)
&& !path.startsWith(HTTP_MEDIA_TESTS_PREFIX)
&& !path.startsWith(HTTP_WML_TESTS_PREFIX)) {
- url = "http://127.0.0.1:8000/" + path.substring(HTTP_TESTS_PREFIX.length());
+ url = "http://127.0.0.1:18000/" + path.substring(HTTP_TESTS_PREFIX.length());
} else {
url = "file://" + path;
}
diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/forwarder/ForwardService.java b/tests/DumpRenderTree/src/com/android/dumprendertree/forwarder/ForwardService.java
index 25dd04fd..7a277d7 100644
--- a/tests/DumpRenderTree/src/com/android/dumprendertree/forwarder/ForwardService.java
+++ b/tests/DumpRenderTree/src/com/android/dumprendertree/forwarder/ForwardService.java
@@ -26,7 +26,7 @@ import android.util.Log;
public class ForwardService {
- private ForwardServer fs8000, fs8080, fs8443;
+ private ForwardServer fs18000, fs8080, fs8443;
private static ForwardService inst;
@@ -40,7 +40,7 @@ public class ForwardService {
private ForwardService() {
int addr = getForwardHostAddr();
if (addr != -1) {
- fs8000 = new ForwardServer(8000, addr, 8000);
+ fs18000 = new ForwardServer(18000, addr, 8000);
fs8080 = new ForwardServer(8080, addr, 8080);
fs8443 = new ForwardServer(8443, addr, 8443);
}
@@ -55,8 +55,8 @@ public class ForwardService {
public void startForwardService() {
try {
- if (fs8000 != null)
- fs8000.start();
+ if (fs18000 != null)
+ fs18000.start();
if (fs8080 != null)
fs8080.start();
if (fs8443 != null)
@@ -68,9 +68,9 @@ public class ForwardService {
}
public void stopForwardService() {
- if (fs8000 != null) {
- fs8000.stop();
- fs8000 = null;
+ if (fs18000 != null) {
+ fs18000.stop();
+ fs18000 = null;
}
if (fs8080 != null) {
fs8080.stop();
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/RSTestCore.java b/tests/RenderScriptTests/tests/src/com/android/rs/test/RSTestCore.java
index be012ee..e37e9b5 100644
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/RSTestCore.java
+++ b/tests/RenderScriptTests/tests/src/com/android/rs/test/RSTestCore.java
@@ -70,6 +70,7 @@ public class RSTestCore {
unitTests.add(new UT_rstime(this, mRes, mCtx));
unitTests.add(new UT_rstypes(this, mRes, mCtx));
unitTests.add(new UT_alloc(this, mRes, mCtx));
+ unitTests.add(new UT_foreach(this, mRes, mCtx));
unitTests.add(new UT_math(this, mRes, mCtx));
unitTests.add(new UT_fp_mad(this, mRes, mCtx));
/*
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_foreach.java b/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_foreach.java
new file mode 100644
index 0000000..1d2555e
--- /dev/null
+++ b/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_foreach.java
@@ -0,0 +1,56 @@
+/*
+ * 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.rs.test;
+
+import android.content.Context;
+import android.content.res.Resources;
+import android.renderscript.*;
+
+public class UT_foreach extends UnitTest {
+ private Resources mRes;
+ private Allocation A;
+
+ protected UT_foreach(RSTestCore rstc, Resources res, Context ctx) {
+ super(rstc, "ForEach", ctx);
+ mRes = res;
+ }
+
+ private void initializeGlobals(RenderScript RS, ScriptC_foreach s) {
+ Type.Builder typeBuilder = new Type.Builder(RS, Element.I32(RS));
+ int X = 5;
+ int Y = 7;
+ s.set_dimX(X);
+ s.set_dimY(Y);
+ typeBuilder.setX(X).setY(Y);
+ A = Allocation.createTyped(RS, typeBuilder.create());
+ s.bind_a(A);
+
+ return;
+ }
+
+ public void run() {
+ RenderScript pRS = RenderScript.create(mCtx);
+ ScriptC_foreach s = new ScriptC_foreach(pRS, mRes, R.raw.foreach);
+ pRS.setMessageHandler(mRsMessage);
+ initializeGlobals(pRS, s);
+ s.forEach_root(A);
+ s.invoke_foreach_test();
+ pRS.finish();
+ waitForMessage();
+ pRS.destroy();
+ }
+}
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/foreach.rs b/tests/RenderScriptTests/tests/src/com/android/rs/test/foreach.rs
new file mode 100644
index 0000000..3ba3eef
--- /dev/null
+++ b/tests/RenderScriptTests/tests/src/com/android/rs/test/foreach.rs
@@ -0,0 +1,42 @@
+#include "shared.rsh"
+
+int *a;
+int dimX;
+int dimY;
+
+void root(int *out, uint32_t x, uint32_t y) {
+ *out = x + y * dimX;
+}
+
+static bool test_foreach_output() {
+ bool failed = false;
+ int i, j;
+
+ for (j = 0; j < dimY; j++) {
+ for (i = 0; i < dimX; i++) {
+ _RS_ASSERT(a[i + j * dimX] == (i + j * dimX));
+ }
+ }
+
+ if (failed) {
+ rsDebug("test_foreach_output FAILED", 0);
+ }
+ else {
+ rsDebug("test_foreach_output PASSED", 0);
+ }
+
+ return failed;
+}
+
+void foreach_test() {
+ bool failed = false;
+ failed |= test_foreach_output();
+
+ if (failed) {
+ rsSendToClientBlocking(RS_MSG_TEST_FAILED);
+ }
+ else {
+ rsSendToClientBlocking(RS_MSG_TEST_PASSED);
+ }
+}
+
diff --git a/tools/aapt/Command.cpp b/tools/aapt/Command.cpp
index daf53e0..178e7fd 100644
--- a/tools/aapt/Command.cpp
+++ b/tools/aapt/Command.cpp
@@ -1546,7 +1546,9 @@ int doPackage(Bundle* bundle)
assets = new AaptAssets();
// Set up the resource gathering in assets if we're going to generate
- // dependency files
+ // dependency files. Every time we encounter a resource while slurping
+ // the tree, we'll add it to these stores so we have full resource paths
+ // to write to a dependency file.
if (bundle->getGenDependencies()) {
sp<FilePathStore> resPathStore = new FilePathStore;
assets->setFullResPaths(resPathStore);
@@ -1577,15 +1579,20 @@ int doPackage(Bundle* bundle)
goto bail;
}
+ // If we've been asked to generate a dependency file, do that here
if (bundle->getGenDependencies()) {
+ // If this is the packaging step, generate the dependency file next to
+ // the output apk (e.g. bin/resources.ap_.d)
if (outputAPKFile) {
dependencyFile = String8(outputAPKFile);
- // Strip the extension and add new one
- dependencyFile = dependencyFile.getBasePath();
+ // Add the .d extension to the dependency file.
dependencyFile.append(".d");
} else {
+ // Else if this is the R.java dependency generation step,
+ // generate the dependency file in the R.java package subdirectory
+ // e.g. gen/com/foo/app/R.java.d
dependencyFile = String8(bundle->getRClassDir());
- dependencyFile.appendPath("R.d");
+ dependencyFile.appendPath("R.java.d");
}
// Make sure we have a clean dependency file to start with
fp = fopen(dependencyFile, "w");
@@ -1595,13 +1602,18 @@ int doPackage(Bundle* bundle)
// Write out R.java constants
if (assets->getPackage() == assets->getSymbolsPrivatePackage()) {
if (bundle->getCustomPackage() == NULL) {
+ // Write the R.java file into the appropriate class directory
+ // e.g. gen/com/foo/app/R.java
err = writeResourceSymbols(bundle, assets, assets->getPackage(), true);
- // Copy R.java for libraries
+ // If we have library files, we're going to write our R.java file into
+ // the appropriate class directory for those libraries as well.
+ // e.g. gen/com/foo/app/lib/R.java
if (bundle->getExtraPackages() != NULL) {
// Split on colon
String8 libs(bundle->getExtraPackages());
char* packageString = strtok(libs.lockBuffer(libs.length()), ":");
while (packageString != NULL) {
+ // Write the R.java file out with the correct package name
err = writeResourceSymbols(bundle, assets, String8(packageString), true);
packageString = strtok(NULL, ":");
}
@@ -1640,6 +1652,10 @@ int doPackage(Bundle* bundle)
}
}
+ // If we've been asked to generate a dependency file, we need to finish up here.
+ // the writeResourceSymbols and writeAPK functions have already written the target
+ // half of the dependency file, now we need to write the prerequisites. (files that
+ // the R.java file or .ap_ file depend on)
if (bundle->getGenDependencies()) {
// Now that writeResourceSymbols or writeAPK has taken care of writing
// the targets to our dependency file, we'll write the prereqs
@@ -1647,7 +1663,8 @@ int doPackage(Bundle* bundle)
fprintf(fp, " : ");
bool includeRaw = (outputAPKFile != NULL);
err = writeDependencyPreReqs(bundle, assets, fp, includeRaw);
- // Also manually add the AndroidManifeset since it's a non-asset
+ // Also manually add the AndroidManifeset since it's not under res/ or assets/
+ // and therefore was not added to our pathstores during slurping
fprintf(fp, "%s \\\n", bundle->getAndroidManifestFile());
fclose(fp);
}
diff --git a/tools/aapt/Package.cpp b/tools/aapt/Package.cpp
index c9f6870..1e3efde 100644
--- a/tools/aapt/Package.cpp
+++ b/tools/aapt/Package.cpp
@@ -177,12 +177,17 @@ status_t writeAPK(Bundle* bundle, const sp<AaptAssets>& assets,
}
}
+ // If we've been asked to generate a dependency file for the .ap_ package,
+ // do so here
if (bundle->getGenDependencies()) {
- // Add this file to the dependency file
- String8 dependencyFile = outputFile.getBasePath();
+ // The dependency file gets output to the same directory
+ // as the specified output file with an additional .d extension.
+ // e.g. bin/resources.ap_.d
+ String8 dependencyFile = outputFile;
dependencyFile.append(".d");
FILE* fp = fopen(dependencyFile.string(), "a");
+ // Add this file to the dependency file
fprintf(fp, "%s \\\n", outputFile.string());
fclose(fp);
}
diff --git a/tools/aapt/Resource.cpp b/tools/aapt/Resource.cpp
index cb6484f..2e796a2 100644
--- a/tools/aapt/Resource.cpp
+++ b/tools/aapt/Resource.cpp
@@ -1958,10 +1958,12 @@ status_t writeResourceSymbols(Bundle* bundle, const sp<AaptAssets>& assets,
}
fclose(fp);
+ // If we were asked to generate a dependency file, we'll go ahead and add this R.java
+ // as a target in the dependency file right next to it.
if (bundle->getGenDependencies()) {
// Add this R.java to the dependency file
String8 dependencyFile(bundle->getRClassDir());
- dependencyFile.appendPath("R.d");
+ dependencyFile.appendPath("R.java.d");
fp = fopen(dependencyFile.string(), "a");
fprintf(fp,"%s \\\n", dest.string());
diff --git a/wifi/java/android/net/wifi/WifiNative.java b/wifi/java/android/net/wifi/WifiNative.java
index 3b043b3..6c6f149 100644
--- a/wifi/java/android/net/wifi/WifiNative.java
+++ b/wifi/java/android/net/wifi/WifiNative.java
@@ -203,70 +203,42 @@ public class WifiNative {
private native static boolean doBooleanCommand(String command);
- //STOPSHIP: remove this after native interface works and replace all
- //calls to doBooleanTempCommand() with doBooleanCommand()
- private static boolean doBooleanTempCommand(String command) {
- try {
- String str = "/system/bin/wpa_cli " + command;
- Log.e("WifiNative", "===> " + str);
- Runtime.getRuntime()
- .exec(str).waitFor();
- } catch (Exception e) {
- Log.e("WifiNative", "exception with doBooleanTempCommand");
- return false;
- }
- return true;
- }
-
- private static String doStringTempCommand(String command) {
- String lines[] = null;
- try {
- String str = "/system/bin/wpa_cli " + command;
- Log.e("WifiNative", "===> " + str);
- Process p = Runtime.getRuntime()
- .exec(str);
- InputStream in = p.getInputStream();
- p.waitFor();
- byte[] bytes=new byte[in.available()];
- in.read(bytes);
- String s = new String(bytes);
- Log.e("WifiNative", "====> doString: " + s);
- lines = s.split("\\r?\\n");
- } catch (Exception e) {
- Log.e("WifiNative", "exception with doBooleanTempCommand");
- return null;
- }
- return lines[1];
- }
-
private native static int doIntCommand(String command);
private native static String doStringCommand(String command);
+ public static boolean wpsPbc() {
+ return doBooleanCommand("WPS_PBC");
+ }
+
+ public static boolean wpsPin(String pin) {
+ return doBooleanCommand("WPS_PIN any " + pin);
+ }
+
public static boolean p2pFind() {
- return doBooleanTempCommand("p2p_find");
+ return doBooleanCommand("P2P_FIND");
}
public static boolean p2pFind(int timeout) {
if (timeout <= 0) {
return p2pFind();
}
- return doBooleanTempCommand("p2p_find " + timeout);
+ return doBooleanCommand("P2P_FIND " + timeout);
}
public static boolean p2pListen() {
- return doBooleanTempCommand("p2p_listen");
+ return doBooleanCommand("P2P_LISTEN");
}
public static boolean p2pListen(int timeout) {
if (timeout <= 0) {
return p2pListen();
}
- return doBooleanTempCommand("p2p_listen " + timeout);
+ return doBooleanCommand("P2P_LISTEN " + timeout);
}
public static boolean p2pFlush() {
- return doBooleanTempCommand("p2p_flush");
+ return doBooleanCommand("P2P_FLUSH");
}
/* p2p_connect <peer device address> <pbc|pin|PIN#> [label|display|keypad]
@@ -300,41 +272,60 @@ public class WifiNative {
if (config.isPersistent) args.add("persistent");
if (config.joinExistingGroup) args.add("join");
- args.add("go_intent=" + config.groupOwnerIntent);
+ int groupOwnerIntent = config.groupOwnerIntent;
+ if (groupOwnerIntent < 0 || groupOwnerIntent > 15) {
+ groupOwnerIntent = 3; //default value
+ }
+ args.add("go_intent=" + groupOwnerIntent);
if (config.channel > 0) args.add("freq=" + config.channel);
- String command = "p2p_connect ";
+ String command = "P2P_CONNECT ";
for (String s : args) command += s + " ";
- return doStringTempCommand(command);
+ return doStringCommand(command);
}
public static boolean p2pGroupAdd() {
- return doBooleanTempCommand("p2p_group_add");
+ return doBooleanCommand("P2P_GROUP_ADD");
}
public static boolean p2pGroupRemove(String iface) {
if (iface == null) return false;
- return doBooleanTempCommand("p2p_group_remove " + iface);
+ return doBooleanCommand("P2P_GROUP_REMOVE " + iface);
}
public static boolean p2pReject(String deviceAddress) {
- return doBooleanTempCommand("p2p_reject " + deviceAddress);
+ return doBooleanCommand("P2P_REJECT " + deviceAddress);
}
/* Invite a peer to a group */
public static boolean p2pInvite(WifiP2pGroup group, String deviceAddress) {
if (group == null || deviceAddress == null) return false;
- return doBooleanTempCommand("p2p_invite group=" + group.getInterface()
+ return doBooleanCommand("P2P_INVITE group=" + group.getInterface()
+ " peer=" + deviceAddress + " go_dev_addr=" + group.getOwner().deviceAddress);
}
- public static boolean p2pWpsPbc() {
- return doBooleanTempCommand("wps_pbc");
+ public static String p2pGetInterfaceAddress(String deviceAddress) {
+ if (deviceAddress == null) return null;
+
+ // "p2p_peer deviceAddress" returns a multi-line result containing
+ // intended_addr=fa:7b:7a:42:82:13
+ String peerInfo = p2pPeer(deviceAddress);
+ if (peerInfo == null) return null;
+ String[] tokens= peerInfo.split("\n");
+
+ for (String token : tokens) {
+ //TODO: update from interface_addr when wpa_supplicant implementation is fixed
+ if (token.startsWith("intended_addr=")) {
+ String[] nameValue = token.split("=");
+ if (nameValue.length != 2) break;
+ return nameValue[1];
+ }
+ }
+ return null;
}
- public static boolean p2pWpsPin(String pin) {
- return doBooleanTempCommand("wps_pin any " + pin);
+ public static String p2pPeer(String deviceAddress) {
+ return doStringCommand("P2P_PEER " + deviceAddress);
}
-
}
diff --git a/wifi/java/android/net/wifi/p2p/WifiP2pConfig.java b/wifi/java/android/net/wifi/p2p/WifiP2pConfig.java
index fff5ee3..b77fd76 100644
--- a/wifi/java/android/net/wifi/p2p/WifiP2pConfig.java
+++ b/wifi/java/android/net/wifi/p2p/WifiP2pConfig.java
@@ -46,8 +46,10 @@ public class WifiP2pConfig implements Parcelable {
* This is an integer value between 0 and 15 where 0 indicates the least
* inclination to be a group owner and 15 indicates the highest inclination
* to be a group owner.
+ *
+ * A value of -1 indicates the system can choose an appropriate value.
*/
- public int groupOwnerIntent;
+ public int groupOwnerIntent = -1;
public boolean isPersistent;
diff --git a/wifi/java/android/net/wifi/p2p/WifiP2pDevice.java b/wifi/java/android/net/wifi/p2p/WifiP2pDevice.java
index 83dc285..7908726 100644
--- a/wifi/java/android/net/wifi/p2p/WifiP2pDevice.java
+++ b/wifi/java/android/net/wifi/p2p/WifiP2pDevice.java
@@ -158,9 +158,6 @@ public class WifiP2pDevice implements Parcelable {
return;
}
- Pattern p = Pattern.compile("(?:[0-9a-f]{2}:){5}[0-9a-f]{2}", Pattern.CASE_INSENSITIVE);
- if (p.matcher(tokens[1]).matches()) interfaceAddress = tokens[1];
-
for (String token : tokens) {
String[] nameValue = token.split("=");
if (nameValue.length != 2) continue;
@@ -177,6 +174,7 @@ public class WifiP2pDevice implements Parcelable {
if (nameValue[0].equals("name")) {
deviceName = trimQuotes(nameValue[1]);
+ continue;
}
if (nameValue[0].equals("config_methods")) {
@@ -213,9 +211,7 @@ public class WifiP2pDevice implements Parcelable {
if (other == null || other.deviceAddress == null) {
return (deviceAddress == null);
}
- //STOPSHIP: fix later
- //return other.deviceAddress.equals(deviceAddress);
- return other.deviceAddress.startsWith(deviceAddress.substring(0,8));
+ return other.deviceAddress.equals(deviceAddress);
}
public String toString() {
diff --git a/wifi/java/android/net/wifi/p2p/WifiP2pService.java b/wifi/java/android/net/wifi/p2p/WifiP2pService.java
index 176191e..4447971 100644
--- a/wifi/java/android/net/wifi/p2p/WifiP2pService.java
+++ b/wifi/java/android/net/wifi/p2p/WifiP2pService.java
@@ -663,17 +663,20 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
if (DBG) Slog.d(TAG, getName() + message.toString());
switch (message.what) {
case WifiMonitor.AP_STA_CONNECTED_EVENT:
- String address = (String) message.obj;
- mGroup.addClient(address);
- updateDeviceStatus(address, Status.CONNECTED);
+ //After a GO setup, STA connected event comes with interface address
+ String interfaceAddress = (String) message.obj;
+ String deviceAddress = getDeviceAddress(interfaceAddress);
+ mGroup.addClient(deviceAddress);
+ updateDeviceStatus(deviceAddress, Status.CONNECTED);
if (DBG) Slog.d(TAG, getName() + " ap sta connected");
sendP2pPeersChangedBroadcast();
break;
case WifiMonitor.AP_STA_DISCONNECTED_EVENT:
- address = (String) message.obj;
- updateDeviceStatus(address, Status.AVAILABLE);
- if (mGroup.removeClient(address)) {
- if (DBG) Slog.d(TAG, "Removed client " + address);
+ interfaceAddress = (String) message.obj;
+ deviceAddress = getDeviceAddress(interfaceAddress);
+ updateDeviceStatus(deviceAddress, Status.AVAILABLE);
+ if (mGroup.removeClient(deviceAddress)) {
+ if (DBG) Slog.d(TAG, "Removed client " + deviceAddress);
if (mGroup.isClientListEmpty()) {
Slog.d(TAG, "Client list empty, killing p2p connection");
sendMessage(WifiP2pManager.REMOVE_GROUP);
@@ -682,7 +685,7 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
sendP2pPeersChangedBroadcast();
}
} else {
- if (DBG) Slog.d(TAG, "Failed to remove client " + address);
+ if (DBG) Slog.d(TAG, "Failed to remove client " + deviceAddress);
for (WifiP2pDevice c : mGroup.getClientList()) {
if (DBG) Slog.d(TAG,"client " + c.deviceAddress);
}
@@ -767,10 +770,10 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
notifyP2pProvDiscPinRequest((WifiP2pDevice) message.obj);
break;
case WifiP2pManager.WPS_PBC:
- WifiNative.p2pWpsPbc();
+ WifiNative.wpsPbc();
break;
case WifiP2pManager.WPS_PIN:
- WifiNative.p2pWpsPin((String) message.obj);
+ WifiNative.wpsPin((String) message.obj);
break;
default:
return NOT_HANDLED;
@@ -1005,12 +1008,20 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
private void updateDeviceStatus(String deviceAddress, Status status) {
for (WifiP2pDevice d : mPeers.getDeviceList()) {
- // TODO: fix later
- // if (d.deviceAddress.equals(deviceAddress)) {
- if (d.deviceAddress.startsWith(deviceAddress.substring(0, 8))) {
+ if (d.deviceAddress.equals(deviceAddress)) {
d.status = status;
}
}
}
+
+ private String getDeviceAddress(String interfaceAddress) {
+ for (WifiP2pDevice d : mPeers.getDeviceList()) {
+ if (interfaceAddress.equals(WifiNative.p2pGetInterfaceAddress(d.deviceAddress))) {
+ return d.deviceAddress;
+ }
+ }
+ return null;
+ }
+
}
}