com.andysu.unity 0.0.0-stage → 0.1.106
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md.meta +7 -0
- package/Runtime/AndySU.cs +98 -0
- package/Runtime/AndySU.cs.meta +11 -0
- package/Runtime/com.andysu.unity.asmdef +1 -0
- package/Runtime/com.andysu.unity.asmdef.meta +7 -0
- package/Runtime.meta +8 -0
- package/package.json +22 -4
- package/package.json.meta +7 -0
- package/README.md +0 -3
package/README.md.meta
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// AndySU for Unity (Android). Talks to the host's com.andysu.api.Host over JNI; on other
|
|
2
|
+
// platforms and without an AndySU host every call returns neutral values.
|
|
3
|
+
using System;
|
|
4
|
+
using UnityEngine;
|
|
5
|
+
|
|
6
|
+
namespace AndySU
|
|
7
|
+
{
|
|
8
|
+
public enum ApplyPolicy { Live, Restart, NextStart }
|
|
9
|
+
|
|
10
|
+
public enum UpdateMode { Auto, DownloadOnly, CheckOnly, Off }
|
|
11
|
+
|
|
12
|
+
public static class Updates
|
|
13
|
+
{
|
|
14
|
+
#if UNITY_ANDROID && !UNITY_EDITOR
|
|
15
|
+
static AndroidJavaObject HostApi()
|
|
16
|
+
{
|
|
17
|
+
using (var host = new AndroidJavaClass("com.andysu.api.Host"))
|
|
18
|
+
return host.CallStatic<AndroidJavaObject>("current");
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
static AndroidJavaObject Client()
|
|
22
|
+
{
|
|
23
|
+
var h = HostApi();
|
|
24
|
+
return h?.Call<AndroidJavaObject>("updates");
|
|
25
|
+
}
|
|
26
|
+
#else
|
|
27
|
+
static AndroidJavaObject HostApi() => null;
|
|
28
|
+
static AndroidJavaObject Client() => null;
|
|
29
|
+
#endif
|
|
30
|
+
|
|
31
|
+
// The update client when the host is Host API level 3 or newer, which added setMode/mode.
|
|
32
|
+
// On an older host those methods do not exist, so null means "do nothing".
|
|
33
|
+
static AndroidJavaObject ModeClient()
|
|
34
|
+
{
|
|
35
|
+
var h = HostApi();
|
|
36
|
+
if (h == null || h.Call<int>("apiLevel") < 3) return null;
|
|
37
|
+
return h.Call<AndroidJavaObject>("updates");
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/// <summary>True when the game runs under an AndySU host.</summary>
|
|
41
|
+
public static bool IsPresent => HostApi() != null;
|
|
42
|
+
|
|
43
|
+
public static string Version => HostApi()?.Call<string>("version") ?? "";
|
|
44
|
+
|
|
45
|
+
/// <summary>Status as JSON, e.g. {"state":"staged","release":"1.4.0"}.</summary>
|
|
46
|
+
public static string StatusJson => Client()?.Call<string>("status") ?? "{\"state\":\"idle\"}";
|
|
47
|
+
|
|
48
|
+
public static void CheckNow() => Client()?.Call("checkNow");
|
|
49
|
+
public static void ApplyNow() => Client()?.Call("applyNow");
|
|
50
|
+
public static void RestartNow() => Client()?.Call("restartNow");
|
|
51
|
+
|
|
52
|
+
/// <summary>Commit this payload once the game is known to work.</summary>
|
|
53
|
+
public static void MarkHealthy() => HostApi()?.Call("markHealthy");
|
|
54
|
+
|
|
55
|
+
/// <summary>How staged updates apply on this install; null for the configured policy.</summary>
|
|
56
|
+
public static void SetApplyPolicy(ApplyPolicy? p)
|
|
57
|
+
{
|
|
58
|
+
string v = p switch
|
|
59
|
+
{
|
|
60
|
+
ApplyPolicy.Live => "live",
|
|
61
|
+
ApplyPolicy.Restart => "restart",
|
|
62
|
+
ApplyPolicy.NextStart => "next_start",
|
|
63
|
+
_ => null,
|
|
64
|
+
};
|
|
65
|
+
Client()?.Call("setApplyPolicy", v);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/// <summary>
|
|
69
|
+
/// How much automatic updating this install performs; null for the mode configured in the
|
|
70
|
+
/// host. Needs Host API level 3: does nothing on an older host.
|
|
71
|
+
/// </summary>
|
|
72
|
+
public static void SetUpdateMode(UpdateMode? m)
|
|
73
|
+
{
|
|
74
|
+
string v = m switch
|
|
75
|
+
{
|
|
76
|
+
UpdateMode.Auto => "auto",
|
|
77
|
+
UpdateMode.DownloadOnly => "download_only",
|
|
78
|
+
UpdateMode.CheckOnly => "check_only",
|
|
79
|
+
UpdateMode.Off => "off",
|
|
80
|
+
_ => null,
|
|
81
|
+
};
|
|
82
|
+
ModeClient()?.Call("setMode", v);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/// <summary>The effective update mode; null without a host or on a host older than API level 3.</summary>
|
|
86
|
+
public static UpdateMode? GetUpdateMode()
|
|
87
|
+
{
|
|
88
|
+
switch (ModeClient()?.Call<string>("mode"))
|
|
89
|
+
{
|
|
90
|
+
case "auto": return UpdateMode.Auto;
|
|
91
|
+
case "download_only": return UpdateMode.DownloadOnly;
|
|
92
|
+
case "check_only": return UpdateMode.CheckOnly;
|
|
93
|
+
case "off": return UpdateMode.Off;
|
|
94
|
+
default: return null;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{ "name": "AndySU", "rootNamespace": "AndySU", "references": [], "includePlatforms": [], "excludePlatforms": [] }
|
package/Runtime.meta
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "com.andysu.unity",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
6
|
-
|
|
3
|
+
"version": "0.1.106",
|
|
4
|
+
"displayName": "AndySU",
|
|
5
|
+
"description": "Self-updates for Unity games on Android outside the stores: status, check, apply, apply policy.",
|
|
6
|
+
"unity": "2021.3",
|
|
7
|
+
"license": "Apache-2.0",
|
|
8
|
+
"author": {
|
|
9
|
+
"name": "dixonSolutions",
|
|
10
|
+
"url": "https://github.com/dixonSolutions/AndySU"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"Runtime",
|
|
14
|
+
"package.json.meta",
|
|
15
|
+
"README.md",
|
|
16
|
+
"README.md.meta",
|
|
17
|
+
"Runtime.meta"
|
|
18
|
+
],
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "https://github.com/dixonSolutions/AndySU",
|
|
22
|
+
"directory": "bindings/unity"
|
|
23
|
+
}
|
|
24
|
+
}
|
package/README.md
DELETED