Move duplicated union of HashSets logic into helper class

Bug: 36850431
Test: adb shell am instrument -w -e package com.android.server.backup com.android.frameworks.servicestests/android.support.test.runner.AndroidJUnitRunner
Change-Id: I83a95919d7b85131cc7ad73575d7a89c7f2d78f9
3 files changed