Skip to content

Commit 8b88cef

Browse files
committed
get apk path from Unity
1 parent 9a7167b commit 8b88cef

5 files changed

Lines changed: 13 additions & 4 deletions

File tree

Binary file not shown.
Binary file not shown.
Binary file not shown.

Assets/AndroidIl2cppPatchDemo/Script/Bootstrap.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ public class Bootstrap
1010
public static extern string get_arch_abi();
1111

1212
[DllImport("bootstrap")]
13-
public static extern string use_data_dir(string _data_path);
13+
public static extern string use_data_dir(string _data_path, string _apk_path);
1414
#else
1515
public static string get_arch_abi() { return "armeabi-v7a"; }
16-
public static string use_data_dir(string _data_path) { return ""; }
16+
public static string use_data_dir(string _data_path, string _apk_path) { return ""; }
1717
#endif
1818

1919
public static void reboot_app()

Assets/AndroidIl2cppPatchDemo/Script/VersionSettor.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public void OnClickSetVersion()
2323

2424
if (updateVersion <= 0)
2525
{
26-
string error = Bootstrap.use_data_dir("");
26+
string error = Bootstrap.use_data_dir("", "");
2727
if (!string.IsNullOrEmpty(error))
2828
{
2929
messageBox.Show("use failed. empty path error:" + error, "ok", ()=> { messageBox.Close(); });
@@ -68,7 +68,16 @@ private IEnumerator PreparePatchAndRestart()
6868
ZipHelper.UnZip(zipLibil2cppPath, runtimePatchPath, "", true);
6969

7070
//4. tell libboostrap.so to use the right patch after reboot
71-
string error = Bootstrap.use_data_dir(runtimePatchPath);
71+
//jar:file:///data/app/x.x.x/base.apk!/assets/
72+
int apkPathStart = Application.streamingAssetsPath.IndexOf("/data");
73+
int apkPathEnd = Application.streamingAssetsPath.IndexOf("!");
74+
string apkPath = Application.streamingAssetsPath.Substring(apkPathStart,apkPathEnd - apkPathStart);
75+
if (string.IsNullOrEmpty(apkPath))
76+
{
77+
messageBox.Show("use failed. apk path not found in [" + Application.streamingAssetsPath + "]", "ok", () => { messageBox.Close(); });
78+
yield break;
79+
}
80+
string error = Bootstrap.use_data_dir(runtimePatchPath, apkPath);
7281
if (!string.IsNullOrEmpty(error))
7382
{
7483
messageBox.Show("use failed. path:" + zipLibil2cppPath + ", error:" + error, "ok", () => { messageBox.Close(); });

0 commit comments

Comments
 (0)