mirror of
https://github.com/ppy/osu
synced 2025-03-29 14:47:04 +00:00
Merge pull request #9299 from peppy/fix-android-build-number-parsing
Fix regression in android build parsing behaviour
This commit is contained in:
commit
26ea75519c
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using Android.App;
|
using Android.App;
|
||||||
|
using Android.OS;
|
||||||
using osu.Game;
|
using osu.Game;
|
||||||
using osu.Game.Updater;
|
using osu.Game.Updater;
|
||||||
|
|
||||||
@ -18,9 +19,32 @@ namespace osu.Android
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// todo: needs checking before play store redeploy.
|
// We store the osu! build number in the "VersionCode" field to better support google play releases.
|
||||||
string versionName = packageInfo.VersionName;
|
// If we were to use the main build number, it would require a new submission each time (similar to TestFlight).
|
||||||
// undo play store version garbling
|
// In order to do this, we should split it up and pad the numbers to still ensure sequential increase over time.
|
||||||
|
//
|
||||||
|
// We also need to be aware that older SDK versions store this as a 32bit int.
|
||||||
|
//
|
||||||
|
// Basic conversion format (as done in Fastfile): 2020.606.0 -> 202006060
|
||||||
|
|
||||||
|
// https://stackoverflow.com/questions/52977079/android-sdk-28-versioncode-in-packageinfo-has-been-deprecated
|
||||||
|
string versionName = string.Empty;
|
||||||
|
|
||||||
|
if (Build.VERSION.SdkInt >= BuildVersionCodes.P)
|
||||||
|
{
|
||||||
|
versionName = packageInfo.LongVersionCode.ToString();
|
||||||
|
// ensure we only read the trailing portion of long (the part we are interested in).
|
||||||
|
versionName = versionName.Substring(versionName.Length - 9);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
#pragma warning disable CS0618 // Type or member is obsolete
|
||||||
|
// this is required else older SDKs will report missing method exception.
|
||||||
|
versionName = packageInfo.VersionCode.ToString();
|
||||||
|
#pragma warning restore CS0618 // Type or member is obsolete
|
||||||
|
}
|
||||||
|
|
||||||
|
// undo play store version garbling (as mentioned above).
|
||||||
return new Version(int.Parse(versionName.Substring(0, 4)), int.Parse(versionName.Substring(4, 4)), int.Parse(versionName.Substring(8, 1)));
|
return new Version(int.Parse(versionName.Substring(0, 4)), int.Parse(versionName.Substring(4, 4)), int.Parse(versionName.Substring(8, 1)));
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
@ -33,4 +57,4 @@ namespace osu.Android
|
|||||||
|
|
||||||
protected override UpdateManager CreateUpdateManager() => new SimpleUpdateManager();
|
protected override UpdateManager CreateUpdateManager() => new SimpleUpdateManager();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user