@tokamakdev/platform-android-arm64 0.1.1-beta.51 → 0.1.1-beta.53

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.
Binary file
@@ -50,7 +50,7 @@ class TokamakApplication : Application(), TokamakHost {
50
50
  return if (!endpoint.isNullOrEmpty() && !sessionToken.isNullOrEmpty()) {
51
51
  TokamakRuntime.startDevelopment(stateDir(), appHost, endpoint, sessionToken)
52
52
  } else {
53
- TokamakRuntime.start(unpackApp(), stateDir(), appHost)
53
+ TokamakRuntime.start(unpackApp(), stateDir(), storageDir(), appHost)
54
54
  }
55
55
  }
56
56
 
@@ -59,8 +59,8 @@ class TokamakApplication : Application(), TokamakHost {
59
59
 
60
60
  /** Copy the packaged app out of the APK once per install, so the runtime can read it as files. */
61
61
  private fun unpackApp(): File {
62
- val app = File(filesDir, "tokamak/app")
63
- val unpacked = File(filesDir, "tokamak/app.installed")
62
+ val app = File(noBackupFilesDir, "tokamak/app")
63
+ val unpacked = File(noBackupFilesDir, "tokamak/app.installed")
64
64
  val installed = packageManager.getPackageInfo(packageName, 0).lastUpdateTime.toString()
65
65
  if (unpacked.isFile && unpacked.readText() == installed) return app
66
66
  app.deleteRecursively()
@@ -82,5 +82,16 @@ class TokamakApplication : Application(), TokamakHost {
82
82
  for (entry in entries) copyAsset("$source/$entry", File(destination, entry))
83
83
  }
84
84
 
85
- private fun stateDir(): File = File(filesDir, "tokamak/state").apply { mkdirs() }
85
+ /** Runtime state, which backups leave out. */
86
+ private fun stateDir(): File = File(noBackupFilesDir, "tokamak/state").apply { mkdirs() }
87
+
88
+ /**
89
+ * Stores behind storage bindings, which Auto Backup includes. tokamak keeps nothing else in the
90
+ * files directory, so everything else under `tokamak` there is removed.
91
+ */
92
+ private fun storageDir(): File {
93
+ val root = File(filesDir, "tokamak")
94
+ root.listFiles()?.filter { it.name != "storage" }?.forEach { it.deleteRecursively() }
95
+ return File(root, "storage").apply { mkdirs() }
96
+ }
86
97
  }
@@ -40,8 +40,13 @@ internal class TokamakRuntime private constructor(private val handle: Long) {
40
40
  }
41
41
 
42
42
  /** Start the runtime, throwing when it cannot serve the app. */
43
- fun start(packagedDir: File, stateDir: File, host: String): TokamakRuntime =
44
- TokamakRuntime(nativeStart(packagedDir.path, stateDir.path, host))
43
+ fun start(
44
+ packagedDir: File,
45
+ stateDir: File,
46
+ storageDir: File,
47
+ host: String,
48
+ ): TokamakRuntime =
49
+ TokamakRuntime(nativeStart(packagedDir.path, stateDir.path, storageDir.path, host))
45
50
 
46
51
  /** Start the runtime against a host development server. */
47
52
  fun startDevelopment(
@@ -53,7 +58,12 @@ internal class TokamakRuntime private constructor(private val handle: Long) {
53
58
  TokamakRuntime(nativeStartDevelopment(stateDir.path, host, endpoint, sessionToken))
54
59
 
55
60
  @JvmStatic
56
- private external fun nativeStart(packagedDir: String, stateDir: String, host: String): Long
61
+ private external fun nativeStart(
62
+ packagedDir: String,
63
+ stateDir: String,
64
+ storageDir: String,
65
+ host: String,
66
+ ): Long
57
67
 
58
68
  @JvmStatic
59
69
  private external fun nativeStartDevelopment(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tokamakdev/platform-android-arm64",
3
- "version": "0.1.1-beta.51",
3
+ "version": "0.1.1-beta.53",
4
4
  "description": "The tokamak platform pack for android-arm64",
5
5
  "repository": {
6
6
  "type": "git",