Fix race condition in checkPattern and verifyPattern.
am: 9475460e66

Change-Id: I88a9304c1f7d23b70cb23988112fc6c34db51338