private static Resources getManagedProvisioningPackageResources(final Context context) {
        try {
            final Resources self_resources = context.getResources();
            final Context target_context = context.createPackageContext(getManagedProvisioningPackageName(context), 0);
            final Resources target_resources = target_context.getResources();
            return new Resources(target_resources.getAssets(), target_resources.getDisplayMetrics(), target_resources.getConfiguration()) {
                @NonNull @Override public String[] getStringArray(final int id) throws NotFoundException {
                    final String entry_name = self_resources.getResourceEntryName(id);
                    final int target_res_id = target_resources.getIdentifier(entry_name, "array", target_context.getPackageName());
                    if (target_res_id == 0) return new String[0];       // Return empty array instead of throwing NotFoundException.
                    try {
                        return target_resources.getStringArray(target_res_id);
                    } catch (Resources.NotFoundException e) {
                        Analytics.$().report("No string array " + entry_name + " in " + target_context.getPackageName(), e);
                        return new String[]{};
                    }
                }
            };
        } catch (final NameNotFoundException e) {
            return context.getResources();          // Fall-back to self, with default resource values.
        }
    }
Runs the next task when all packages have been deleted or shuts down the activity if package
deletion fails.
engine/src/main/java/com/oasisfeng/island/provisioning/task/DeleteNonRequiredAppsTask.java