将鼠标移到到Button上,鼠标样式由箭头变成小手,pointerType=1000是箭头,pointerType=1002是鼠标小手
@frameworks/base/core/java/android/view/ViewRootImpl.java
processPointerEventmaybeUpdatePointerIcon(event);if (event.getActionMasked() != MotionEvent.ACTION_HOVER_EXIT) { if (!updatePointerIcon(event) && }
@frameworks/base/core/java/android/view/ViewGroup.java final PointerIcon pointerIcon = mView.onResolvePointerIcon(event, pointerIndex);final PointerIcon pointerIcon = dispatchResolvePointerIcon(event, pointerIndex, child);pointerIcon = child.onResolvePointerIcon(transformedEvent, pointerIndex); // pointerType = 1002//onResolvePointerIcon 4 setPointerIcon, child=com.google.android.material.button.MaterialButton{ee1f3df VFED..C.. ....H.ID 1771,134-2068,230 #7f08000e app:id/VDSeriveButton} type=1002//onResolvePointerIcon 4 setPointerIcon, child=android.widget.LinearLayout{bfcf82c V.E...... .......D 0,0-3840,1080 #7f0801da app:id/main_layout} type=1002//onResolvePointerIcon 4 setPointerIcon, child=androidx.appcompat.widget.ContentFrameLayout{c5b42f5 V.E...... .......D 0,0-3840,1080 #1020002 android:id/content} type=1002//onResolvePointerIcon 4 setPointerIcon, child=androidx.appcompat.widget.FitWindowsLinearLayout{fc0588a V.E...... .......D 0,0-3840,1080 #7f080037 app:id/action_bar_root} type=1002//onResolvePointerIcon 4 setPointerIcon, child=android.widget.FrameLayout{49beefb V.E...... .......D 0,0-3840,1080} type=1002//onResolvePointerIcon 4 setPointerIcon, child=android.widget.LinearLayout{a576b18 V.E...... .......D 0,0-3840,1080} type=1002 InputManager.getInstance().setPointerIconType(pointerType); // pointerType = 1002......
@frameworks/base/libs/input/PointerController.cpp PointerController::updatePointerIcon
@frameworks/base/libs/input/MouseCursorController.cpp MouseCursorController::updatePointerIconmLocked.requestedPointerType = iconId;mLocked.updatePointerIcon = true; updatePointerLocked();
@frameworks/base/libs/input/SpriteController.cppstd::map<int32_t, SpriteIcon>::const_iterator iter = mLocked.additionalMouseResources.find(mLocked.requestedPointerType);mLocked.pointerSprite->setIcon(iter->second);mLocked.state.icon.bitmap = icon.bitmap.copy(ANDROID_BITMAP_FORMAT_RGBA_8888);