Source:
public static void init(Context context, String appDefinedUserAgent) { String appId = "unknown"; try { PackageInfo pi = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); appId = pi.packageName; } catch (Exception ignore) { } String userAgent = "Unknown"; try { StringBuilder sb = new StringBuilder(); sb.append("RealmJava/"); sb.append(BuildConfig.VERSION_NAME); sb.append(" ("); sb.append(Util.isEmptyString(Build.DEVICE) ? "unknown-device" : Build.DEVICE); sb.append(", "); sb.append(Util.isEmptyString(Build.MODEL) ? "unknown-model" : Build.MODEL); sb.append(", v"); sb.append(Build.VERSION.SDK_INT); sb.append(")"); if (!appDefinedUserAgent.isEmpty()) { sb.append(" "); sb.append(appDefinedUserAgent); } userAgent = sb.toString(); } catch (Exception e) { RealmLog.warn("Constructing User-Agent description failed.", e); } if (SyncManager.Debug.separatedDirForSyncManager) { try { File dir = File.createTempFile("remote_sync_", "_" + android.os.Process.myPid(), context.getFilesDir()); if (!dir.delete()) { throw new IllegalStateException(String.format(Locale.US, "Temp file '%s' cannot be deleted.", dir.getPath())); } if (!dir.mkdir()) { throw new IllegalStateException(String.format(Locale.US, "Directory '%s' for SyncManager cannot be created. ", dir.getPath())); } SyncManager.nativeInitializeSyncManager(dir.getPath(), userAgent); } catch (IOException e) { throw new IllegalStateException(e); } } else { SyncManager.nativeInitializeSyncManager(context.getFilesDir().getPath(), userAgent); } UserStore userStore = new RealmFileUserStore(); SyncManager.init(appId, userAgent, userStore); }

Target:
public static void init(Context context, String appDefinedUserAgent) { String appId = "unknown"; try { PackageInfo pi = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); appId = pi.packageName; } catch (Exception ignore) { } String userAgent = "Unknown"; try { StringBuilder sb = new StringBuilder(); sb.append("RealmJava/"); sb.append(BuildConfig.VERSION_NAME); sb.append(" ("); sb.append(Util.isEmptyString(Build.DEVICE) ? "unknown-device" : Build.DEVICE); sb.append(", "); sb.append(Util.isEmptyString(Build.MODEL) ? "unknown-model" : Build.MODEL); sb.append(", v"); sb.append(Build.VERSION.SDK_INT); sb.append(")"); if (!Util.isEmptyString(appDefinedUserAgent)) { sb.append(" "); sb.append(appDefinedUserAgent); } userAgent = sb.toString(); } catch (Exception e) { RealmLog.warn("Constructing User-Agent description failed.", e); } if (SyncManager.Debug.separatedDirForSyncManager) { try { File dir = File.createTempFile("remote_sync_", "_" + android.os.Process.myPid(), context.getFilesDir()); if (!dir.delete()) { throw new IllegalStateException(String.format(Locale.US, "Temp file '%s' cannot be deleted.", dir.getPath())); } if (!dir.mkdir()) { throw new IllegalStateException(String.format(Locale.US, "Directory '%s' for SyncManager cannot be created. ", dir.getPath())); } SyncManager.nativeInitializeSyncManager(dir.getPath(), userAgent); } catch (IOException e) { throw new IllegalStateException(e); } } else { SyncManager.nativeInitializeSyncManager(context.getFilesDir().getPath(), userAgent); } UserStore userStore = new RealmFileUserStore(); SyncManager.init(appId, userStore); }