Default to TOOL_TYPE_STYLUS for external stylus events.

Change-Id: Ife6a7c4802e8b1ec1ff8445e639f8a6d90a00592
diff --git a/services/inputflinger/InputReader.cpp b/services/inputflinger/InputReader.cpp
index 3e9f765..8de8132 100644
--- a/services/inputflinger/InputReader.cpp
+++ b/services/inputflinger/InputReader.cpp
@@ -6511,6 +6511,11 @@
 
     mStylusState.when = when;
 
+    mStylusState.toolType = mTouchButtonAccumulator.getToolType();
+    if (mStylusState.toolType == AMOTION_EVENT_TOOL_TYPE_UNKNOWN) {
+        mStylusState.toolType = AMOTION_EVENT_TOOL_TYPE_STYLUS;
+    }
+
     int32_t pressure = mSingleTouchMotionAccumulator.getAbsolutePressure();
     if (mRawPressureAxis.valid) {
         mStylusState.pressure = float(pressure) / mRawPressureAxis.maxValue;
@@ -6521,7 +6526,6 @@
     }
 
     mStylusState.buttons = mTouchButtonAccumulator.getButtonState();
-    mStylusState.toolType = mTouchButtonAccumulator.getToolType();
 
     mContext->dispatchExternalStylusState(mStylusState);
 }