@Test public void testNotDirectBootAware() { mPackageManager.addResolveInfoForIntent( new Intent(ACTION_PARTNER_CUSTOMIZATION), Collections.singletonList(createResolveInfo("test.partner.package", true, false))); ResourceEntry entry = Partner.getResourceEntry(mContext, R.color.suw_color_accent_dark); int partnerValue = entry.resources.getColor(entry.id); assertEquals("Partner value should default to 0xff448aff", 0xff448aff, partnerValue); assertFalse("Partner value should come from fallback", entry.isOverlay); }
public static ResourceEntry getResourceEntry(Context context, int id) { final Partner partner = Partner.get(context); if (partner != null) { final Resources ourResources = context.getResources(); final String name = ourResources.getResourceEntryName(id); final String type = ourResources.getResourceTypeName(id); final int partnerId = partner.getIdentifier(name, type); if (partnerId != 0) { return new ResourceEntry(partner.mResources, partnerId, true); } } return new ResourceEntry(context.getResources(), id, false); }
Partner { public static ResourceEntry getResourceEntry(Context context, int id) { final Partner partner = Partner.get(context); if (partner != null) { final Resources ourResources = context.getResources(); final String name = ourResources.getResourceEntryName(id); final String type = ourResources.getResourceTypeName(id); final int partnerId = partner.getIdentifier(name, type); if (partnerId != 0) { return new ResourceEntry(partner.mResources, partnerId, true); } } return new ResourceEntry(context.getResources(), id, false); } }
Partner { public static ResourceEntry getResourceEntry(Context context, int id) { final Partner partner = Partner.get(context); if (partner != null) { final Resources ourResources = context.getResources(); final String name = ourResources.getResourceEntryName(id); final String type = ourResources.getResourceTypeName(id); final int partnerId = partner.getIdentifier(name, type); if (partnerId != 0) { return new ResourceEntry(partner.mResources, partnerId, true); } } return new ResourceEntry(context.getResources(), id, false); } private  Partner(String packageName, Resources res); }
Partner { public static ResourceEntry getResourceEntry(Context context, int id) { final Partner partner = Partner.get(context); if (partner != null) { final Resources ourResources = context.getResources(); final String name = ourResources.getResourceEntryName(id); final String type = ourResources.getResourceTypeName(id); final int partnerId = partner.getIdentifier(name, type); if (partnerId != 0) { return new ResourceEntry(partner.mResources, partnerId, true); } } return new ResourceEntry(context.getResources(), id, false); } private  Partner(String packageName, Resources res); static Drawable getDrawable(Context context, int id); static String getString(Context context, int id); static ResourceEntry getResourceEntry(Context context, int id); static synchronized Partner get(Context context); @VisibleForTesting static synchronized void resetForTesting(); String getPackageName(); Resources getResources(); int getIdentifier(String name, String defType); }
Partner { public static ResourceEntry getResourceEntry(Context context, int id) { final Partner partner = Partner.get(context); if (partner != null) { final Resources ourResources = context.getResources(); final String name = ourResources.getResourceEntryName(id); final String type = ourResources.getResourceTypeName(id); final int partnerId = partner.getIdentifier(name, type); if (partnerId != 0) { return new ResourceEntry(partner.mResources, partnerId, true); } } return new ResourceEntry(context.getResources(), id, false); } private  Partner(String packageName, Resources res); static Drawable getDrawable(Context context, int id); static String getString(Context context, int id); static ResourceEntry getResourceEntry(Context context, int id); static synchronized Partner get(Context context); @VisibleForTesting static synchronized void resetForTesting(); String getPackageName(); Resources getResources(); int getIdentifier(String name, String defType);  }