public void WaitUntilDeviceVibrate(int timeoutMs)
        {
            int threadSleepTimeMs = 100;
            int threadLoopCount   = timeoutMs / threadSleepTimeMs + 1;
            VibrationEventListener eventListener = new VibrationEventListener();

            try
            {
                if (mDevice.RegisterHardwareEvent(GameDevice.HW_EVENT_VIBRATOR, eventListener) < 0)
                {
                    Log.E(TAG, "could not register vibrator event.");
                    return;
                }

                while (threadLoopCount-- > 0)
                {
                    if (eventListener.GetVibrated())
                    {
                        Log.D(TAG, "detect vibration, end event pulling looping");
                        return;
                    }
                    Thread.Sleep(threadSleepTimeMs);
                }
            }
            finally
            { // note that the exception will be rethrown
                mDevice.DeregisterHardwareEvent(GameDevice.HW_EVENT_VIBRATOR, eventListener);
            }
        }
        //
        // Main functions
        //

        // calculate the offset of dump file for
        // retrieving color of the specific point
        private int CalculateOffset(ScreenCoord coord)
        {
            int       offset = 0;
            const int bpp    = 4;

            if (mChatty)
            {
                if (coord.orientation == ScreenPoint.SO_Landscape)
                {
                    Log.D(TAG, "Mapping (" + coord.x + ", " + coord.y +
                          ") to (" + (coord.x + mScreenYOffset) + ", " + (coord.y + mScreenXOffset) + ")");
                }
                else
                {
                    Log.D(TAG, "Mapping (" + coord.x + ", " + coord.y +
                          ") to (" + (coord.x + mScreenXOffset) + ", " + (coord.y + mScreenYOffset) + ")");
                }
            }

            //if Android version is 7.0 or higher, the dump orientation will obey the device status
            if (mCurrentGameOrientation == ScreenPoint.SO_Portrait)
            {
                if (coord.orientation == ScreenPoint.SO_Portrait)
                {
                    offset = (mScreenWidth * (coord.y + mScreenYOffset) + (coord.x + mScreenXOffset)) * bpp;
                }
                else if (coord.orientation == ScreenPoint.SO_Landscape)
                {
                    offset = (mScreenWidth * (coord.x + mScreenYOffset) + (mScreenWidth - (coord.y + mScreenXOffset))) * bpp;
                }
            }
            else
            {
                if (coord.orientation == ScreenPoint.SO_Portrait)
                {
                    offset = (mScreenHeight * (mScreenWidth - (coord.x + mScreenXOffset)) + (coord.y + mScreenYOffset)) * bpp;
                }
                else if (coord.orientation == ScreenPoint.SO_Landscape)
                {
                    offset = (mScreenHeight * (coord.y + mScreenXOffset) + (coord.x + mScreenYOffset)) * bpp;
                }
            }

            return(offset);
        }