resources/src/main/java/org/robolectric/res/android/DynamicRefTable.java
int lookupResourceId(Ref<Integer> resId) {
    int res = resId.get();
    int packageId = Res_GETPACKAGE(res) + 1;

    if (packageId == APP_PACKAGE_ID && !mAppAsLib) {
      // No lookup needs to be done, app package IDs are absolute.
      return NO_ERROR;
    }

    if (packageId == 0 || (packageId == APP_PACKAGE_ID && mAppAsLib)) {
      // The package ID is 0x00. That means that a shared library is accessing
      // its own local resource.
      // Or if app resource is loaded as shared library, the resource which has
      // app package Id is local resources.
      // so we fix up those resources with the calling package ID.
      resId.set((0xFFFFFF & (resId.get())) | (((int) mAssignedPackageId) << 24));
      return NO_ERROR;
    }

    // Do a proper lookup.
    int translatedId = mLookupTable[packageId];
    if (translatedId == 0) {
      ALOGW("DynamicRefTable(0x%02x): No mapping for build-time package ID 0x%02x.",
          mAssignedPackageId, packageId);
      for (int i = 0; i < 256; i++) {
        if (mLookupTable[i] != 0) {
          ALOGW("e[0x%02x] . 0x%02x", i, mLookupTable[i]);
        }
      }
      return UNKNOWN_ERROR;
    }

    resId.set((res & 0x00ffffff) | (((int) translatedId) << 24));
    return NO_ERROR;
  }
int lookupResourceId(Ref<Integer> resId) {
    int res = resId.get();
    int packageId = Res_GETPACKAGE(res) + 1;

    if (packageId == APP_PACKAGE_ID && !mAppAsLib) {
      // No lookup needs to be done, app package IDs are absolute.
      return NO_ERROR;
    }

    if (packageId == 0 || (packageId == APP_PACKAGE_ID && mAppAsLib)) {
      // The package ID is 0x00. That means that a shared library is accessing
      // its own local resource.
      // Or if app resource is loaded as shared library, the resource which has
      // app package Id is local resources.
      // so we fix up those resources with the calling package ID.
      resId.set((0xFFFFFF & (resId.get())) | (((int) mAssignedPackageId) << 24));
      return NO_ERROR;
    }

    // Do a proper lookup.
    int translatedId = mLookupTable[packageId];
    if (translatedId == 0) {
      ALOGW("DynamicRefTable(0x%02x): No mapping for build-time package ID 0x%02x.",
          mAssignedPackageId, packageId);
      for (int i = 0; i < 256; i++) {
        if (mLookupTable[i] != 0) {
          ALOGW("e[0x%02x] . 0x%02x", i, mLookupTable[i]);
        }
      }
      return UNKNOWN_ERROR;
    }

    resId.set((res & 0x00ffffff) | (((int) translatedId) << 24));
    return NO_ERROR;
  }
// resource ID.