Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support OBBs with different version codes to the app #25

Open
robinnorth opened this issue Oct 23, 2020 · 0 comments
Open

Support OBBs with different version codes to the app #25

robinnorth opened this issue Oct 23, 2020 · 0 comments

Comments

@robinnorth
Copy link

As per https://developer.android.com/google/play/expansion-files#Filename, it is possible to have a case where the OBB and app version codes are different to one another:

<expansion-version>

This is an integer that matches the version code of the APK with which the expansion is first associated (it matches the app's android:versionCode value).

"First" is emphasized because although the Play Console allows you to re-use an uploaded expansion file with a new APK, the expansion file's name does not change—it retains the version applied to it when you first uploaded the file.

When dealing with large expansion files, it is likely that app developers will want to reuse them, in order to avoid forcing unnecessary re-downloads of the same expansion content when an app update is published.

The underlying expansion file downloader library around which this plugin is based already supports this, as it queries the expected expansion file name(s) and checks for their existence on the file system in order to determine whether a download is required or not:

DownloadInfo[] infos = db.getDownloads();
if (null != infos) {
for (DownloadInfo info : infos) {
if (!Helpers.doesFileExist(context, info.mFileName, info.mTotalBytes, true)) {
status = DOWNLOAD_REQUIRED;
db.updateStatus(-1);
break;
}
}
}

However, the C# implementation makes the assumption that the expansion files will have the same version number as the app:

private static void PopulateOBBProperties()
{
using (var unityPlayerClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
{
var currentActivity = unityPlayerClass.GetStatic<AndroidJavaObject>("currentActivity");
m_ObbPackage = currentActivity.Call<string>("getPackageName");
var packageInfo = currentActivity.Call<AndroidJavaObject>("getPackageManager").Call<AndroidJavaObject>("getPackageInfo", m_ObbPackage, 0);
m_ObbVersion = packageInfo.Get<int>("versionCode");
}

If the Java plugin were able to provide a means for the C# script to call a native method that performs the same check as DownloaderService, then expected expansion file names could be returned and their existence checked with File.Exists.

Currently, you could always call IGooglePlayObbDownloader.FetchOBB, rather than first checking if GetMainOBBPath returns null (as in DownloadObbExample) and allow the native plugin to decide if a download is required, but then there's no easy way to check if/when the native plugin has finished downloading, because waiting for GetMainPath to not be null to indicate completion will result in an infinite wait, due to the version codes mismatch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant