title: Null pointer exception while creating a custom robolectric shadow for UserManager
body: <p>In Robolectric 2.4, I need to create a custom shadow for android.os.UserManager class.</p>
  
  <p>Following is the code to be tested:</p>
  
  <pre><code>private Bundle checkFoo() {
      UserManager userMgr = ((UserManager) getSystemService(Context.USER_SERVICE));
      Bundle restrictionsBundle = userMgr.getApplicationRestrictions("test-pkg_name");
      return restrictionsBundle;
  }
  </code></pre>
  
  <p>Since there was no default ShadowUserManager provided by Robolectric in 2.4 I created following custom shadow UserManager class: </p>
  
  <pre><code>@Implements(UserManager.class)
  public class ShadowUserManager {
  
  @Implementation
  public Bundle getApplicationRestrictions(String packageName) {
  ...
  return new Bundle();
  }
  </code></pre>
  
  <p>For above class I tried to shadow the constructor too as follows but IUserManager seems to be not available to import.</p>
  
  <pre><code>public void __constructor__(Context context, IUserManager usrMgr){
  }
  </code></pre>
  
  <p>Following is the test code:</p>
  
  <pre><code>@RunWith(MyTestRunner.class)
  @Config(shadows = {ShadowUserManager.class})
  public class MyTestClass {
  @Test
  public void testFoo() {
      Bundle actualBundle = checkfoo();
      //assert actual and expected bundle
      ...
  }
  }
  </code></pre>
  
  <p>I believe I do not need to explicitly specify UserManager to be instrumented in my TestRunner's shouldInstrument() function as UserManger is in android.os package, which gets instrumented by default if shadow is available. (Though I tried this too but to no avail!!)</p>
  
  <p>While running the test I always end up getting a null pointer in checkFoo() function when trying to call getApplicationRestrictions() on userMgr object. userMgr always end up being null. 
  Any pointers to solve this is appreciated.</p>
  
  <p>Or is there a way to mock the getSystemService() API in Android context to provide custom UserManager object?</p>