diff --git a/AGENTS.md b/AGENTS.md index ad2a1b01..a0ede87c 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -32,11 +32,6 @@ The export runs a second Editor in batch mode over a throwaway staging project: **Publish a release:** `deploy/release_unitypackage.sh` builds, moves the artifact into `Releases/`, commits, tags, pushes, and creates the GitHub release. Read its header before running it — it names three things it deliberately does not check, and each of them can publish something you did not mean to. `--dry-run` prints every command it would run and touches nothing. -**Android wrapper (Java):** Built separately via Gradle in `adaptyandroidwrapper/`: -```bash -cd adaptyandroidwrapper && ./gradlew :unitywrapper:build -``` - **Native dependency versions:** iOS is declared in `Packages/com.adapty.unity-sdk/Runtime/Editor/AdaptySDKDependencies.xml` (Swift Package Manager via External Dependency Manager 1.2.188+ — SPM support landed in 1.2.187, the Xcode project path for the Swift project type in 1.2.188; iOS deployment target 15.0+ is enforced by `Packages/com.adapty.unity-sdk/Editor/AdaptyIOSBuildValidator.cs`). **Xcode 26+ is the floor for the whole SDK on iOS**, not only for Kids Mode: AdaptySDK-iOS 4.0 declares `swift-tools-version: 6.2`, and SwiftPM refuses a package whose tools version exceeds the toolchain. Nothing in the Editor can check it, so it is a documented requirement only — re-check it on every native bump. Android is declared in `Packages/com.adapty.unity-sdk/Runtime/Plugins/Android/AdaptySDKDependencies.androidlib/build.gradle`. Update both when bumping native SDK versions. ## Architecture @@ -49,7 +44,7 @@ All SDK calls follow a single JSON-based bridge: 2. Each method serializes parameters to JSON via `AdaptyRequest.Send()` or `AdaptyRequest.SendVoid()` (`Runtime/AdaptyRequest.cs`), which adds the `method` key and calls `_Adapty.Invoke(method, json, callback)`. Those two are the only way to the bridge: the raw transport is `private`, and both take the caller's name through `[CallerMemberName]`, so no call site writes a diagnostic string of its own. `AdaptyRequest.FailEncoding` is the third member of that surface and reaches no bridge at all — it reports a request that could not be encoded *before* it could be built, with the error the transport would have produced, and exists for the one overload that has to encode an argument of its own (`UpdateAttribution` taking a dictionary). It takes the caller's name the same way. Do not add a second caller without first asking whether the encoding could happen inside the guard instead. 3. **`_Adapty`** is compile-time aliased per platform: - `AdaptySDK.iOS.AdaptyIOS` — P/Invoke `[DllImport("__Internal")]` to Swift plugin - - `AdaptySDK.Android.AdaptyAndroid` — `AndroidJavaClass` calling `com.adapty.unity.AdaptyAndroidWrapper` + - `AdaptySDK.Android.AdaptyAndroid` — JNI straight into `com.adapty.internal.crossplatform.CrossplatformHelper`, its four callback interfaces implemented as `AndroidJavaProxy`; the SDK ships no Java of its own. The callbacks arrive on the native SDK's thread and are posted to the Unity thread's native `ALooper` by `AdaptyAndroidLooper` — an `eventfd` from libc registered with `ALooper_addFd` from libandroid, both through P/Invoke, so no native library ships — **not** through `Adapty.RunOnMainThread`: a flow is an Activity of its own, Unity's player loop is paused underneath it, and a `SynchronizationContext` post would wait for the frame that comes only once the flow is gone — the `close` action would reach the listener when there is nothing left to dismiss. The looper runs through the pause on both entry points: `Looper.loop()` polls it under UnityPlayerActivity, the activity glue under GameActivity — the default for a new Unity 6 project — where the thread has no Java Looper at all and even `UnityPlayer.invokeOnMainThread` waits for the resume. That is also why it is not a `Handler` on `Looper.myLooper()`: under GameActivity there is none, and after someone's `Looper.prepare()` there would be one that nothing loops. Measured on an emulator with Unity 6000.0, 6000.4 and 6000.6; any change here is checked on both entry points by closing a flow; `RunOnMainThread` stays for the delegates the SDK hands to app code - `AdaptySDK.Noop.AdaptyNoop` — no-op for Editor/unsupported platforms 4. Native side processes the JSON request and returns a JSON response string via callback. 5. Response is parsed back into C# models by Newtonsoft, through `AdaptySDK.Serialization.AdaptyJson`. @@ -76,7 +71,7 @@ Editor code therefore cannot reference Runtime types, and the Editor asmdef's em - `Runtime/Obsolete/` — everything `[Obsolete]`, in a tree mirroring `Runtime/` (`Models/`, `Serialization/Converters/`). The point is that removing the deprecated API is a directory deletion plus the references that then fail to compile, so **nothing outside this folder may carry the attribute** — `EveryObsoleteMemberLivesUnderObsolete` in `SourceConventionTests` is the check. Members of a live `partial class` live here as their own part: `Adapty.Obsolete.cs`, `AdaptyUI.Obsolete.cs`, `Adapty.Events.Obsolete.cs`. The two csproj globs are **not** recursive, so a new subfolder here needs its own `` line in both `tests/surface/package` and `tests/AdaptySDK.NextTests` or the SDK silently compiles without it. - `Runtime/Serialization/` — the Newtonsoft JSON layer: `AdaptyJson` (the single entry point), `AdaptyContractResolver`, `AdaptyJsonRequire` (the required-key reads — a plain `node["x"]?` is what it exists instead of), `AdaptyResponse` (the reply side, and the one place `DecodingFailed` is raised), `AdaptyPaywallProductRequest`, and `Converters/`. Every converter lives in that folder, one per file, named `AdaptyConverter` after what it converts, and is registered in `AdaptyJson.Settings` — with one exception. `AdaptyConverterLooseJson` is deliberately **not** in the shared settings, so an ordinary `Dictionary` keeps Newtonsoft's own `JObject`/`JArray`/`Int64`. Three public payloads the contract types as a bare object must instead stay the CLR graph of doubles they were in 3.x, and each reaches the converter its own way: `AdaptyProfile.CustomAttributes` is a **member** and names it in a `[JsonConverter]` of its own — the one place a converter is declared outside `AdaptyJson`, and the reason that converter carries `[Preserve]`, since Newtonsoft then builds it by reflection — `AdaptyJson.DeserializeRemoteConfigDictionary` covers `AdaptyRemoteConfig.Dictionary`, which is a **string** parsed on demand, and `AdaptyJson.CreateSerializerFor` covers the dispatcher's `Required`/`Optional`, where `flow_view_did_receive_analytic_event` hands `params` straight to a listener. `CanConvert` is the single definition of "loose" that all three consult — do not restate the type list. Neither the fixtures nor the snapshots can see any of this: an integral `double` and a `long` print alike, and the profile fixture's only number is `12.5`. All three are pinned by type assertions instead. - `Runtime/Plugins/iOS/` — `AdaptyIOS.cs` (P/Invoke bridge) + `Source/` (Swift/ObjC native plugin code) - - `Runtime/Plugins/Android/` — `AdaptyAndroid.cs` (JNI bridge) + `Local/` (local AAR maven repo) + `AdaptySDKDependencies.androidlib` (Android maven dependencies) + - `Runtime/Plugins/Android/` — `AdaptyAndroid.cs` (JNI bridge) + `AdaptyAndroidLooper.cs` (posts callbacks to the Unity thread's native looper) + `AdaptySDKDependencies.androidlib` (Android maven dependencies) - `Runtime/Plugins/AdaptyNoop.cs` — Editor/no-op stub - `Runtime/Editor/AdaptySDKDependencies.xml` — iOS Swift Package declaration for External Dependency Manager - `Editor/` — Editor-only assembly (iOS build validation, Newtonsoft presence check, the `Adapty SDK > Install Dependencies` menu item, the Kids Mode trait edit) @@ -86,8 +81,6 @@ Editor code therefore cannot reference Runtime types, and the Editor asmdef's em The trait fixtures are an excerpt of a real generated project, not a written-out sample: `tests/shared/Fixtures/pbxproj/` holds what External Dependency Manager wrote and what the build produced from it, and the test round-trips between them, which pins the indentation to the tab. Anything hand-made would only test the format this repository imagines. Regenerate both by building for iOS with `ADAPTY_KIDS_MODE` and taking the same excerpt — and note that the object ids differ on every build, so no test may name one. The edit locates the reference by `isa = XCRemoteSwiftPackageReference` and insists on exactly one — the brace nearest the URL alone would aim the insertion at whatever object enclosed some other occurrence, and a Kids Category build that reports Kids Mode while still linking IDFA is the one failure nothing downstream catches. Verifying a change here means a real **device** build — a simulator one cannot tell you anything, because `Environment.Device.idfa.swift` also guards the IDFA code with `targetEnvironment(simulator)`, so neither framework is linked with or without the trait. Two traps make that easy to get wrong: `StrippingBuild.IOS` never sets `PlayerSettings.iOS.sdkVersion`, so after an `IOSSimulator` run it stays `SimulatorSDK` and the "device" build is quietly a simulator one, and `ADAPTY_KIDS_MODE` has to reach the **Editor** assemblies before the build, since the post-processor is compiled with it - Player Settings is the reliable route, and an active build profile's defines work too once Unity has recompiled for them, which is the state `AdaptyIOSBuildValidator` checks for. What discriminates, measured: `-DKidsMode` in the compiler invocations, and `otool -L` on `UnityFramework` inside the built `.app` — 0 references with the trait, 2 without. -- **`adaptyandroidwrapper/`** — Standalone Android Gradle project: - - `unitywrapper/src/main/java/com/adapty/unity/` — `AdaptyAndroidWrapper.java` (entry point), callback handler, message handler - **`tests/`** — .NET test projects for the JSON layer: `AdaptySDK.NextTests` (the suite), `shared/` (fixtures and snapshot helpers), `surface/` (the SDK compiled as a library to assert against), `aot-probe/`. Most of the suite asks the compiled assembly; `SourceConventionTests` and two checks in `ContractEnforcementTests` read the **sources** instead, for the things metadata cannot answer — `partial` does not survive compilation, an explicit enum value is indistinguishable from a counted one, and a file's directory is not a property of its types. - **`Assets/Scripts/`** — Demo app scripts (not part of distributed SDK) - **`cross_platform.yaml`** — Cross-platform API contract schema defining all request/response JSON formats and data types shared across iOS/Android/Unity @@ -133,7 +126,7 @@ Not every `[RuntimeInitializeOnLoadMethod]` here is a reset. `Adapty.InitializeT ### Platform conditionals -There are 26 `#if` in the package, and each belongs to one of five kinds. **Compilation boundary**, 8 — a native symbol exists only there: the `_Adapty` and `_AdaptyCallbackAction` aliases, everything under `Plugins/iOS` and `Plugins/Android`, the Kids Mode post-processor. **Wire contract**, 12 — the contract itself differs: a `[DataMember]` the schema marks platform-only (`is_family_shareable` on both product responses), `offer_tags` read on Android alone, the offer id required on one more branch there. **Public API behaviour**, 3 — the iOS-only methods that on an Android device report `null`, meaning success. Their guard is `UNITY_IOS || UNITY_EDITOR` rather than `UNITY_IOS && !UNITY_EDITOR`, so the Editor reaches the no-op bridge like every other method instead of taking that branch; three `TransportTests` cases pin it. **Where a file actually is**, 2 — a `StreamingAssets` path is a different location on each platform, and the two places that resolve one do **not** agree about the Editor. `AdaptyCustomAssetPath.Resolve` has an `#else` and hands the path back unchanged. `Adapty.SetFallback` has none, so in the Editor it sends no `path` key at all — `transport-set-fallback.editor.approved.txt` is the whole request, `{"method": "set_fallback"}`. Nothing is lost by that: the Editor call reaches the no-op bridge and comes back with the not-supported error, having never needed a path. It is not an omission to repair. **The Kids Mode define**, 1 — `AdaptyConfiguration` forces `apple_idfa_collection_disabled` under `ADAPTY_KIDS_MODE && UNITY_IOS`, because the trait has compiled IDFA out of the binary and the request has to say so. +There are 25 `#if` in the package, and each belongs to one of five kinds. **Compilation boundary**, 7 — a native symbol exists only there: the `_Adapty` and `_AdaptyCallbackAction` aliases, everything under `Plugins/iOS` and `Plugins/Android`, the Kids Mode post-processor. **Wire contract**, 12 — the contract itself differs: a `[DataMember]` the schema marks platform-only (`is_family_shareable` on both product responses), `offer_tags` read on Android alone, the offer id required on one more branch there. **Public API behaviour**, 3 — the iOS-only methods that on an Android device report `null`, meaning success. Their guard is `UNITY_IOS || UNITY_EDITOR` rather than `UNITY_IOS && !UNITY_EDITOR`, so the Editor reaches the no-op bridge like every other method instead of taking that branch; three `TransportTests` cases pin it. **Where a file actually is**, 2 — a `StreamingAssets` path is a different location on each platform, and the two places that resolve one do **not** agree about the Editor. `AdaptyCustomAssetPath.Resolve` has an `#else` and hands the path back unchanged. `Adapty.SetFallback` has none, so in the Editor it sends no `path` key at all — `transport-set-fallback.editor.approved.txt` is the whole request, `{"method": "set_fallback"}`. Nothing is lost by that: the Editor call reaches the no-op bridge and comes back with the not-supported error, having never needed a path. It is not an omission to repair. **The Kids Mode define**, 1 — `AdaptyConfiguration` forces `apple_idfa_collection_disabled` under `ADAPTY_KIDS_MODE && UNITY_IOS`, because the trait has compiled IDFA out of the binary and the request has to say so. The last two kinds are not platform questions the layer above could have answered, which is why they are here rather than folded away. Nothing else qualifies. A constructor must not re-decide by define what the layer above already decided: `AdaptySubscriptionOffer` used to null `OfferTags` off Android although its only caller, the converter, passes null there anyway — the approved snapshots did not move when it went, which is what redundant means. @@ -156,7 +149,7 @@ The public surface snapshots record signatures without attributes, so nothing fa When releasing a new version, update: 1. `Adapty.SDKVersion` in `Packages/com.adapty.unity-sdk/Runtime/Adapty.cs` 2. `version` in `Packages/com.adapty.unity-sdk/package.json` -3. Native dependency versions: iOS in `Runtime/Editor/AdaptySDKDependencies.xml`, Android in `Runtime/Plugins/Android/AdaptySDKDependencies.androidlib/build.gradle` and `adaptyandroidwrapper/unitywrapper/build.gradle` (then rebuild the AAR into `Runtime/Plugins/Android/Local/io/adapty/internal/unity-wrapper//`, and **delete the previous one** — no `build.gradle` in the package references the artifact, Unity picks up any `.aar` under `Plugins/Android` as a plugin, so two versions side by side both reach the player) +3. Native dependency versions: iOS in `Runtime/Editor/AdaptySDKDependencies.xml`, Android in `Runtime/Plugins/Android/AdaptySDKDependencies.androidlib/build.gradle` — the one place. There is no wrapper AAR to rebuild: `AdaptyAndroid.cs` reaches `CrossplatformHelper` by name, so a signature the closed-source `crossplatform` changes shows up as a JNI failure on the emulator, never at compile time — run the Android player after every bump (`javap` from an Editor's `PlaybackEngines/AndroidPlayer/OpenJDK/bin` over the AAR's `classes.jar` is how to read the new signature) 4. `cross_platform.yaml` schema `$id` version — must match the canonical contract in AdaptySDK-iOS (`Sources.AdaptyPlugin/cross_platform.yaml`); diff the two files, not just the version 5. `CHANGELOG.md` and the `_upm.changelog` string in `package.json` — keep both in sync, the latter is what Package Manager shows after an update. In step by the **set of entries**, not by wording: the Package Manager copy is deliberately terser, and comparing the two byte for byte only produces noise. What it must not do is drop one — a missing entry is invisible until someone reads the two side by side. The heading also lives in `CHANGELOG.md` alone: `_upm.changelog` holds the body of the section, with neither the version nor the date, so the release date is set in one place on the day of the cut 6. Managed dependency versions, when they move: `dependencies` and `peerDependencies` in `package.json` **and** the constants in `Editor/AdaptyDependencies.cs`, which is what installs them for `.unitypackage` users diff --git a/Assets/SdkHarness/AGENTS.md b/Assets/SdkHarness/AGENTS.md index 1bb08234..180314c6 100644 --- a/Assets/SdkHarness/AGENTS.md +++ b/Assets/SdkHarness/AGENTS.md @@ -1,6 +1,6 @@ # The SDK harness -`Assets/SdkHarness/` is a scene with nothing in it but a `RuntimePipelineManager` (port pinned to 7900) and `AdaptySdkHarness`, which registers four `[CliCommand]`s in the player: `harness_activate`, `harness_call` (any public static `Adapty` or `AdaptyUI` method by name, arguments as a JSON object keyed by parameter name, the overload chosen by exactly that key set — an argument written as `"$GetFlow"` or `"$GetPaywallProducts[0]"` is the object the last successful call of that method handed back, which is how a flow reaches `GetPaywallProducts` and a product reaches `MakePurchase`; do not paste a returned model's JSON back instead, the SDK never reads a response model from JSON — a product goes out as `AdaptyPaywallProductRequest`, its own shape — so the dump has no reader and fails on the subscription offer while proving nothing), `harness_events` (what the listeners received, decoded), `harness_status`. It exists because the desktop suite feeds the SDK fixtures, and only a player can say whether the C# layer decodes what the *native* SDK actually returns, on IL2CPP, after stripping — which is why the harness build adds a link.xml of its own (`SdkHarnessBuild`, not a file under `Assets/`, which would go into the demo's and `StrippingBuild`'s players too) that keeps only what the harness reaches by reflection — `Adapty`'s and `AdaptyUI`'s methods, `AdaptyJson`, the request-side types it builds from JSON or by member name — and leaves the response models and converters to the linker; a new request-side parameter type goes on that list. A callback with a value-type payload (`bool`, an enum) needs no AOT hint: IL2CPP's full generic sharing runs the `Capture` the harness makes at run time. Commands run on the request thread and post the call to the main one, because the SDK delivers callbacks through `SynchronizationContext.Post` and a main-thread wait would deadlock every call; the wait budget (`--timeout_ms`, 20 s by default) stays under the scene's 120 s request timeout; the first calls after an activation with a customer id have taken 8–20 s while the backend merged the profile, so give those more. It does not expose the raw bridge JSON — the request/response bytes live inside `AdaptyRequest` — only what the SDK decoded. It activates once per process: relaunch the app for another activation. The scenario is data, not code, so a new test is a new payload and needs no rebuild. The screen is not empty for the person watching: a UI Toolkit ledger built in code (the only asset is `SdkHarnessPanel.asset` with its `unity-theme://default` theme) lists every request (→), reply (←), failure (×), late reply (← or × with "late" — the command already returned as timed out; the object still becomes the handle) and delivered event («) with its timestamp, so a run can be followed on the simulator and read back when the agent is stuck. +`Assets/SdkHarness/` is a scene with nothing in it but `AdaptySdkHarness`, which registers four `[CliCommand]`s in the player: `harness_activate`, `harness_call` (any public static `Adapty` or `AdaptyUI` method by name, arguments as a JSON object keyed by parameter name, the overload chosen by exactly that key set — an argument written as `"$GetFlow"` or `"$GetPaywallProducts[0]"` is the object the last successful call of that method handed back, which is how a flow reaches `GetPaywallProducts` and a product reaches `MakePurchase`; do not paste a returned model's JSON back instead, the SDK never reads a response model from JSON — a product goes out as `AdaptyPaywallProductRequest`, its own shape — so the dump has no reader and fails on the subscription offer while proving nothing), `harness_events` (what the listeners received, decoded), `harness_status`. It exists because the desktop suite feeds the SDK fixtures, and only a player can say whether the C# layer decodes what the *native* SDK actually returns, on IL2CPP, after stripping — which is why the harness build adds a link.xml of its own (`SdkHarnessBuild`, not a file under `Assets/`, which would go into the demo's and `StrippingBuild`'s players too) that keeps only what the harness reaches by reflection — `Adapty`'s and `AdaptyUI`'s methods, `AdaptyJson`, the request-side types it builds from JSON or by member name — and leaves the response models and converters to the linker; a new request-side parameter type goes on that list. A callback with a value-type payload (`bool`, an enum) needs no AOT hint: IL2CPP's full generic sharing runs the `Capture` the harness makes at run time. Commands run on the request thread and post the call to the main one, because the SDK delivers callbacks through `SynchronizationContext.Post` and a main-thread wait would deadlock every call; the wait budget (`--timeout_ms`, 20 s by default) stays under the runtime server's 120 s request timeout (`requestTimeoutMs` in `RuntimePipelineConfig.json`); the first calls after an activation with a customer id have taken 8–20 s while the backend merged the profile, so give those more. It does not expose the raw bridge JSON — the request/response bytes live inside `AdaptyRequest` — only what the SDK decoded. It activates once per process: relaunch the app for another activation. The scenario is data, not code, so a new test is a new payload and needs no rebuild. The screen is not empty for the person watching: a UI Toolkit ledger built in code (the only asset is `SdkHarnessPanel.asset` with its `unity-theme://default` theme) lists every request (→), reply (←), failure (×), late reply (← or × with "late" — the command already returned as timed out; the object still becomes the handle) and delivered event («) with its timestamp, so a run can be followed on the simulator and read back when the agent is stuck. ## Build and run @@ -27,4 +27,19 @@ Open the **workspace**: External Dependency Manager writes a Podfile, and the ba ## What the commands can and cannot take -Some argument shapes have no JSON reader in the SDK and get one in the harness: a type whose instances are public static members (`AdaptyPlacementFetchPolicy`, `AdaptyExternalAttributionProvider`) is addressed by member name, and a string for a type with a one-string constructor becomes that instance (a provider by identifier); a `TimeSpan` parameter is taken as seconds (inside an object it is Newtonsoft's `"00:00:10"`); enums go through the SDK's own converter as strings; a request-only model with a nested `Builder` (`AdaptyProfileParameters`, `AdaptyConfiguration`) is built from a JSON object — constructor arguments by parameter name, every other key a `Set` call, `customAttributes` an object of string or number values — so `UpdateProfile` takes `{"param":{"firstName":"A","customAttributes":{"plan":"pro","score":3}}}`. Models with public fields and a parameterless constructor (`AdaptyUICreateFlowViewParameters`, `AdaptyUIDialogConfiguration`, `AdaptyPurchaseParameters`) read as plain JSON. Not reachable this way: `AdaptyCustomAsset` values (factory methods, no members), custom tags and timers on `CreateFlowView` (setters, not fields), `SetFallback` (needs a file in the app), and the legacy onboarding events (`IAdaptyOnboardingsEventsListener` is obsolete; the harness does not register it). `Activate` is refused by `harness_call` because activation is once per process — `harness_activate` builds the configuration, with `--configuration` for the Builder keys it has no flag for. Only iOS: `harness_build` targets the simulator SDK, an Android build is not written. The player's own command set adds `console`, `runtime_status`, `simulate_pointer`; `eval` is registered there but compiled out on anything that is not the Editor or a standalone development build, which is why the harness's commands are compiled ones. Nothing here runs on a real device without a package change: the runtime server writes its descriptor into the app bundle and stops itself when that write fails. +Some argument shapes have no JSON reader in the SDK and get one in the harness: a type whose instances are public static members (`AdaptyPlacementFetchPolicy`, `AdaptyExternalAttributionProvider`) is addressed by member name, and a string for a type with a one-string constructor becomes that instance (a provider by identifier); a `TimeSpan` parameter is taken as seconds (inside an object it is Newtonsoft's `"00:00:10"`); enums go through the SDK's own converter as strings; a request-only model with a nested `Builder` (`AdaptyProfileParameters`, `AdaptyConfiguration`) is built from a JSON object — constructor arguments by parameter name, every other key a `Set` call, `customAttributes` an object of string or number values — so `UpdateProfile` takes `{"param":{"firstName":"A","customAttributes":{"plan":"pro","score":3}}}`. Models with public fields and a parameterless constructor (`AdaptyUICreateFlowViewParameters`, `AdaptyUIDialogConfiguration`, `AdaptyPurchaseParameters`) read as plain JSON. Not reachable this way: `AdaptyCustomAsset` values (factory methods, no members), custom tags and timers on `CreateFlowView` (setters, not fields), `SetFallback` (needs a file in the app), and the legacy onboarding events (`IAdaptyOnboardingsEventsListener` is obsolete; the harness does not register it). `Activate` is refused by `harness_call` because activation is once per process — `harness_activate` builds the configuration, with `--configuration` for the Builder keys it has no flag for. `harness_build` targets the iOS simulator SDK, and refuses to run unless the Editor is on iOS, since the post-processor that adds the local StoreKit is compiled for the active platform; `harness_build_android` targets an Android device (see below). The player's own command set adds `console`, `runtime_status`, `simulate_pointer`; `eval` is registered there but compiled out on anything that is not the Editor or a standalone development build, which is why the harness's commands are compiled ones. An iOS device is out of reach without a package change: the runtime server writes its descriptor into the app bundle and stops itself when that write fails. + +## Android + +`harness_build_android` (`Assets/SdkHarness/Editor/`) builds the same scene into `android-harness-build.apk`: Development, ARM64, `com.adaptytest`. Pipeline 0.6.0 starts the runtime server from Project Settings > Pipeline > Runtime (`ProjectSettings/Packages/com.unity.pipeline/RuntimePipelineConfig.json`, port 7900), not from a scene component — the package no longer has the `RuntimePipelineManager` the scene used to carry. Its runtime assembly has no define constraint, so Enable In Builds puts the server into every player built while it is on, a release build in batchmode with only a warning. The project keeps it off; both harness builds turn it on for the build and put it back, together with `EditorUserBuildSettings.development` (the Pipeline build processor reads that flag rather than the build options, and with Enable In Builds on and the flag off it stops an interactive build on a Continue / Cancel / Disable Pipeline dialog that nothing driving the Editor from the CLI can answer), the iOS SDK, the Android architectures and application id. + +The stock runtime server cannot run on a device: it writes its descriptor next to `Application.dataPath`, which on Android is the APK, the write throws and the server stops itself. `AndroidHarnessServer` (`Assets/SdkHarness/AndroidHarnessServer.cs`, Android players only, not the Editor) turns the driver's autostart off at `AfterSceneLoad` and runs a subclass that writes the descriptor into the app's internal files directory, with a token of its own since the package's token manager is internal. Reaching it from the host: +```bash +adb install -r android-harness-build.apk && adb shell monkey -p com.adaptytest -c android.intent.category.LAUNCHER 1 +adb shell run-as com.adaptytest cat files/.unity-pipeline-runtime-port > rt/.unity-pipeline-runtime-port # a Development build is debuggable +adb forward tcp:7900 tcp:7900 +unity command harness_status --runtime-path rt +``` +Two things the CLI checks on the pulled copy, and deletes it when they fail: `pid` has to be a live process of the current user on the host (the device pid is meaningless here, and pid 1 is refused) — rewrite it to a long-lived one such as the Hub's; and `lastHeartbeat` has to be recent — rewrite it before each command, the device server does not touch its file on heartbeats. The Editor's Android Logcat restarts the adb server, which drops the forward: re-add it before each command too. `adb shell input tap`/`keyevent` do reach the flow. + +A flow is an Activity of its own on Android, and Unity's player loop is paused underneath it: `harness_call` (a post to the main thread) times out until the flow is gone, `harness_events` still answers. The SDK's callbacks are delivered through the Unity thread's native looper, which keeps running through the pause, so a `flow_view_did_perform_action` for Back or close shows up in `harness_events` within seconds — that is the check that the bridge delivers while paused, and it is what the demo app relies on to dismiss the view on close. The way back goes through the same looper: the harness grants a permission and reports an observer-mode purchase from a pool thread, as an app's OS or store callback would, and logs it (`SdkHarness: purchase reported from a pool thread`); in Observer mode the native `observerModeHandler: onStartPurchase called` follows in logcat within milliseconds while the flow is on screen. `adb shell input tap` does nothing on some devices (Xiaomi needs USB debugging's security settings); `input keyevent KEYCODE_TAB` until the button has focus, then `KEYCODE_ENTER`, presses it. The harness itself dismisses nothing: bring `UnityPlayerActivity` back with `am start -f 0x20000000`, which ends the flow and resumes the loop. diff --git a/Assets/SdkHarness/AdaptySdkHarness.cs b/Assets/SdkHarness/AdaptySdkHarness.cs index 5d104ded..c83edd1d 100644 --- a/Assets/SdkHarness/AdaptySdkHarness.cs +++ b/Assets/SdkHarness/AdaptySdkHarness.cs @@ -24,7 +24,7 @@ namespace AdaptyExample.SdkHarness /// Commands run on the request thread, not the main one. A call is posted to the main thread and /// awaited here, because the SDK delivers its callback through SynchronizationContext.Post /// and the main loop has to stay free to run it — waiting on the main thread would deadlock every - /// call. The wait budget stays below the scene's 120 s request timeout. + /// call. The wait budget stays below the runtime server's 120 s request timeout. /// /// A player discovers commands by reflection and reaches the harness from nothing else, so the /// harness build's own link.xml (SdkHarnessBuild) keeps the namespace and what the @@ -803,25 +803,34 @@ public void FlowViewDidReceiveAnalyticEvent(AdaptyUIFlowView view, string name, /// /// Recorded and granted: the harness has no user to ask, and a request left unanswered would hold - /// the view open for the rest of the run. + /// the view open for the rest of the run. Granted from a pool thread, where an OS permission + /// callback lands, so a run also checks that the answer reaches a view that is on screen. /// public void FlowViewDidAskPermission(AdaptyUIFlowView view, string permission, IReadOnlyDictionary customArgs, Action respond) { Record("flow_view_did_ask_permission", ("view", view), ("permission", permission), ("customArgs", customArgs)); - respond(true, null); + ThreadPool.QueueUserWorkItem(_ => + { + Debug.Log("SdkHarness: permission answered from a pool thread"); + respond(true, null); + }); } public void FlowViewDidRequestAppReview(AdaptyUIFlowView view) => Record("flow_view_did_request_app_review", ("view", view)); /// /// Observer mode leaves the purchase to the app; the harness has none, so it reports both stages - /// at once and lets the view continue. + /// at once and lets the view continue - from a pool thread, as a store callback would. /// public void FlowViewDidInitiatePurchase(AdaptyUIFlowView view, AdaptyPaywallProduct product, Action onStartPurchase, Action onFinishPurchase) { Record("flow_view_did_initiate_purchase", ("view", view), ("product", product)); - onStartPurchase(); - onFinishPurchase(); + ThreadPool.QueueUserWorkItem(_ => + { + Debug.Log("SdkHarness: purchase reported from a pool thread"); + onStartPurchase(); + onFinishPurchase(); + }); } public void FlowViewDidInitiateRestore(AdaptyUIFlowView view, Action onStartRestore, Action onFinishRestore) diff --git a/Assets/SdkHarness/AndroidHarnessServer.cs b/Assets/SdkHarness/AndroidHarnessServer.cs new file mode 100644 index 00000000..4d9a7b68 --- /dev/null +++ b/Assets/SdkHarness/AndroidHarnessServer.cs @@ -0,0 +1,155 @@ +#if UNITY_ANDROID && !UNITY_EDITOR +using System; +using System.IO; +using System.Security.Cryptography; +using Newtonsoft.Json; +using Unity.Pipeline; +using Unity.Pipeline.Config; +using UnityEngine; + +namespace AdaptyExample.SdkHarness +{ + /// + /// The Pipeline runtime server for an Android device. + /// + /// + /// The stock server writes its descriptor next to Application.dataPath, which on Android + /// is the APK, so the write throws and the server stops itself before it has served anything. + /// This one writes the descriptor into the app's internal files directory, with a token of its + /// own (the package's token manager is internal). Read it with + /// adb shell run-as com.adaptytest cat files/.unity-pipeline-runtime-port (a Development + /// build is debuggable), put it in a directory on the host as --runtime-path, and bridge + /// the port with adb forward tcp:7900 tcp:7900. + /// + internal sealed class AndroidHarnessServer : RuntimePipelineServer + { + private const string DescriptorFileName = ".unity-pipeline-runtime-port"; + + private readonly string m_DescriptorPath; + private readonly string m_Token = NewToken(); + private DateTime m_StartedAt; + private DateTime m_LastHeartbeat; + private bool m_HasDescriptor; + + internal AndroidHarnessServer(RuntimePipelineConfig config, string filesDirectory) + : base(config) + { + m_DescriptorPath = Path.Combine(filesDirectory, DescriptorFileName); + } + + public override DateTime StartedAt => m_StartedAt; + + protected override void CreateInstanceDescriptor() + { + m_StartedAt = DateTime.UtcNow; + m_LastHeartbeat = m_StartedAt; + + // The same shape the package writes, so the CLI reads it as any other runtime. The + // capabilities are BasePipelineServer.Capabilities, which is internal, restated. + var descriptor = new + { + capabilities = new[] { "exec.argv", "exec.commandLine" }, + pid = System.Diagnostics.Process.GetCurrentProcess().Id, + port = Port, + platform = Application.platform.ToString(), + unityVersion = Application.unityVersion, + buildGuid = Application.buildGUID, + startedAt = m_StartedAt, + lastHeartbeat = m_LastHeartbeat, + workingDirectory = Directory.GetCurrentDirectory(), + evalToken = m_Token, + }; + + File.WriteAllText(m_DescriptorPath, JsonConvert.SerializeObject(descriptor, Formatting.Indented)); + m_HasDescriptor = true; + Debug.Log($"SdkHarness: runtime descriptor written to {m_DescriptorPath}"); + } + + protected override void DeleteInstanceDescriptor() + { + m_HasDescriptor = false; + File.Delete(m_DescriptorPath); + } + + // The host reads a pulled copy, so rewriting the file on the device buys nothing. + protected override void UpdateHeartBeat() => m_LastHeartbeat = DateTime.UtcNow; + + protected override object GetServerStatus() + { + UpdateHeartBeat(); + return new + { + status = m_HasDescriptor ? "ready" : "error", + lastHeartbeat = m_LastHeartbeat, + }; + } + + protected override string GetToken() => m_Token; + + private static string NewToken() + { + var bytes = new byte[32]; + using var rng = RandomNumberGenerator.Create(); + rng.GetBytes(bytes); + return BitConverter.ToString(bytes).Replace("-", "").ToLowerInvariant(); + } + } + + /// + /// Keeps the package's driver from starting its server and runs + /// in its place, pumped the way the driver would. + /// + internal sealed class AndroidHarnessServerHost : MonoBehaviour + { + private AndroidHarnessServer m_Server; + private int m_MaxWorkItemsPerFrame; + + // AfterSceneLoad runs once the bootstrap (BeforeSceneLoad) has created the driver, and + // before the driver's Start, which is where it would start the stock server. There is a + // driver only in a harness build: any other player of this project, the demo's included, + // is built with Enable In Builds off and gets nothing from here. + [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterSceneLoad)] + private static void Install() + { + var driver = RuntimePipelineBootstrap.Instance; + if (driver == null) + { + return; + } + + driver.Config.autoStart = false; + + var config = Instantiate(driver.Config); + config.autoStart = true; + + var host = new GameObject("AndroidHarnessServer").AddComponent(); + DontDestroyOnLoad(host.gameObject); + host.m_MaxWorkItemsPerFrame = config.maxWorkItemsPerFrame; + host.m_Server = new AndroidHarnessServer(config, FilesDirectory()); + host.m_Server.Start(config.port); + + Debug.Log( + host.m_Server.IsRunning + ? $"SdkHarness: Android runtime server listening on port {host.m_Server.Port}" + : "SdkHarness: Android runtime server failed to start" + ); + } + + private static string FilesDirectory() + { + using var player = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); + using var activity = player.GetStatic("currentActivity"); + using var dir = activity.Call("getFilesDir"); + return dir.Call("getAbsolutePath"); + } + + private void Update() + { + m_Server?.Dispatcher.ProcessWorkQueue(m_MaxWorkItemsPerFrame); + m_Server?.WatchdogTick(); + } + + private void OnApplicationQuit() => m_Server?.Stop(); + } +} +#endif diff --git a/Assets/SdkHarness/AndroidHarnessServer.cs.meta b/Assets/SdkHarness/AndroidHarnessServer.cs.meta new file mode 100644 index 00000000..d78f550c --- /dev/null +++ b/Assets/SdkHarness/AndroidHarnessServer.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: af8cb810bb21e48699a3590c3cf1ec59 \ No newline at end of file diff --git a/Assets/SdkHarness/Editor/SdkHarnessBuild.cs b/Assets/SdkHarness/Editor/SdkHarnessBuild.cs index 9887646d..82d852f7 100644 --- a/Assets/SdkHarness/Editor/SdkHarnessBuild.cs +++ b/Assets/SdkHarness/Editor/SdkHarnessBuild.cs @@ -1,5 +1,7 @@ +using System; using System.IO; using Unity.Pipeline.Commands; +using Unity.Pipeline.Config; using UnityEditor; using UnityEditor.Build; using UnityEditor.Build.Reporting; @@ -58,10 +60,53 @@ public static class SdkHarnessBuild MainThreadRequired = true, Tags = new[] { "adapty" })] public static object Build() { + // AddLocalStoreKit is compiled for the platform the Editor is on, so from any other one + // the build would come out without the local StoreKit and purchases would hit the sandbox. + if (EditorUserBuildSettings.activeBuildTarget != BuildTarget.iOS) + { + throw new InvalidOperationException( + "harness_build needs the Editor switched to iOS (File > Build Profiles); it is on " + + EditorUserBuildSettings.activeBuildTarget + ); + } + + var sdkVersion = PlayerSettings.iOS.sdkVersion; PlayerSettings.iOS.sdkVersion = iOSSdkVersion.SimulatorSDK; + + try + { + return BuildHarness(BuildTarget.iOS, Output); + } + finally + { + PlayerSettings.iOS.sdkVersion = sdkVersion; + } + } + + /// + /// Builds the harness scene with what a harness build needs switched on, and puts every + /// setting it touched back afterwards. + /// + /// + /// Enable In Builds puts the Pipeline runtime server into any player built while it is on, + /// release ones included, so the project keeps it off and only a harness build turns it on. + /// The Pipeline build processor reads EditorUserBuildSettings.development, not the + /// build options: with Enable In Builds on and the flag off it stops an interactive build on + /// a release-build dialog. + /// + private static object BuildHarness(BuildTarget target, string output) + { + var pipeline = RuntimePipelineConfig.Load() + ?? throw new InvalidOperationException("No Pipeline runtime settings in ProjectSettings/Packages/com.unity.pipeline"); + var enableInBuilds = pipeline.enableInBuilds; + var development = EditorUserBuildSettings.development; + + pipeline.enableInBuilds = true; + pipeline.Save(); + EditorUserBuildSettings.development = true; s_RigBuild = true; - UnityEditor.Build.Reporting.BuildReport report; + BuildReport report; try { @@ -69,8 +114,8 @@ public static object Build() new BuildPlayerOptions { scenes = new[] { Scene }, - locationPathName = Output, - target = BuildTarget.iOS, + locationPathName = output, + target = target, options = BuildOptions.Development, } ); @@ -78,6 +123,10 @@ public static object Build() finally { s_RigBuild = false; + EditorUserBuildSettings.development = development; + pipeline.enableInBuilds = enableInBuilds; + pipeline.Save(); + UnityEngine.Object.DestroyImmediate(pipeline); } return new @@ -101,6 +150,30 @@ public string GenerateAdditionalLinkXmlFile(BuildReport report, UnityLinkerBuild } } + /// + /// The same scene for an Android device: a Development build, so the player is debuggable + /// and run-as can read the runtime descriptor AndroidHarnessServer writes. + /// + [CliCommand("harness_build_android", "Build the SDK harness scene for an Android device into android-harness-build.apk (Development, ARM64). Submit with --detach, then unity job wait.", + MainThreadRequired = true, Tags = new[] { "adapty" })] + public static object BuildAndroid() + { + var architectures = PlayerSettings.Android.targetArchitectures; + var identifier = PlayerSettings.GetApplicationIdentifier(NamedBuildTarget.Android); + PlayerSettings.Android.targetArchitectures = AndroidArchitecture.ARM64; + PlayerSettings.SetApplicationIdentifier(NamedBuildTarget.Android, "com.adaptytest"); + + try + { + return BuildHarness(BuildTarget.Android, "android-harness-build.apk"); + } + finally + { + PlayerSettings.Android.targetArchitectures = architectures; + PlayerSettings.SetApplicationIdentifier(NamedBuildTarget.Android, identifier); + } + } + /// /// Gives the harness build Xcode's local StoreKit: the configuration is filed in the project /// and selected in the scheme, so a run from Xcode syncs it into the simulator and diff --git a/Assets/SdkHarness/SdkHarness.unity b/Assets/SdkHarness/SdkHarness.unity index 259e3a8b..613e05ad 100644 --- a/Assets/SdkHarness/SdkHarness.unity +++ b/Assets/SdkHarness/SdkHarness.unity @@ -128,7 +128,6 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 867307090} - - component: {fileID: 867307091} - component: {fileID: 867307092} m_Layer: 0 m_Name: SdkHarness @@ -152,25 +151,6 @@ Transform: m_Children: [] m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!114 &867307091 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 867307089} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: dd4ab1c9091e0194196b5f5d51cb932f, type: 3} - m_Name: - m_EditorClassIdentifier: Unity.Pipeline::Unity.Pipeline.RuntimePipelineManager - enableInBuilds: 1 - port: 7900 - requestTimeoutMs: 120000 - enableAuditLogging: 1 - autoStart: 1 - maxWorkItemsPerFrame: 10 - m_AllowedReloadRoots: [] --- !u!114 &867307092 MonoBehaviour: m_ObjectHideFlags: 0 diff --git a/Packages/com.adapty.unity-sdk/CHANGELOG.md b/Packages/com.adapty.unity-sdk/CHANGELOG.md index 8bba5075..f2f2a2a7 100644 --- a/Packages/com.adapty.unity-sdk/CHANGELOG.md +++ b/Packages/com.adapty.unity-sdk/CHANGELOG.md @@ -12,6 +12,27 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 `unity` in `package.json`. The package will rely on UI Toolkit runtime bindings (2023.2+) for its Editor-side mock UI; projects on 2022.3 stay on 4.1.x. +### Changed + +- [Android] The package no longer ships a Java wrapper (`io.adapty.internal:unity-wrapper`): the + bridge calls `CrossplatformHelper` from `io.adapty.internal:crossplatform` directly through JNI. + Callbacks and events still arrive on the Unity thread while a flow is on screen, so its `close` + action reaches the listener in time. Nothing changes for an app on the Activity entry point + (GameActivity: see Fixed); a project that reached the wrapper's `com.adapty.unity.*` classes + itself will no longer find them. If you install from a `.unitypackage`, delete + `Assets/AdaptySDK/Plugins/Android/Local` before importing: a `.unitypackage` never removes + files, and the old wrapper's AAR there would still go into the build. + +### Fixed + +- [Android] With GameActivity as the application entry point — the default for a new Unity 6 + project — no completion handler or event reached C# in 4.1.0–4.1.2: the bridge expected a Java + Looper on Unity's thread, which GameActivity does not have. Callbacks now go through the + thread's native looper, which both entry points poll, so a flow's `close` and Back also reach + the listener while the flow is on screen. +- [Android] A permission `respond` or an observer-mode report made off Unity's thread while a + flow is on screen reaches the flow at once; it used to wait for the flow to close. + ## [4.1.2] - 2026-09-14 ### Fixed diff --git a/Packages/com.adapty.unity-sdk/Runtime/Adapty.Events.cs b/Packages/com.adapty.unity-sdk/Runtime/Adapty.Events.cs index 3a73aa39..32dae8fd 100644 --- a/Packages/com.adapty.unity-sdk/Runtime/Adapty.Events.cs +++ b/Packages/com.adapty.unity-sdk/Runtime/Adapty.Events.cs @@ -8,7 +8,7 @@ #if UNITY_IOS && !UNITY_EDITOR using _AdaptyCallbackAction = AdaptySDK.iOS.AdaptyIOSCallbackAction; #elif UNITY_ANDROID && !UNITY_EDITOR -using _AdaptyCallbackAction = AdaptySDK.Android.AdaptyAndroidCallbackAction; +using _AdaptyCallbackAction = AdaptySDK.Android.AdaptyAndroid; #else using _AdaptyCallbackAction = AdaptySDK.Noop.AdaptyNoopCallbackAction; #endif @@ -46,10 +46,11 @@ internal static void ResetListeners() /// /// /// Nothing native reaches C# until this has run: on iOS the bridge drops a completion while - /// its delegate is null, and on Android the wrapper has no handler to post it to. It used to - /// happen inside the listener setters, which made every completion handler depend on a + /// its delegate is null, and on Android the helper is not initialised. It used to happen + /// inside the listener setters, which made every completion handler depend on a /// subscription that is optional and unrelated. The stage covers the whole MonoBehaviour - /// lifecycle, and it is what binds Android's handler to the scripting thread. + /// lifecycle and runs on the scripting thread, whose looper Android's bridge registers on. + /// The context captured here serves only . /// [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)] internal static void InitializeTransport() @@ -64,14 +65,18 @@ internal static void InitializeTransport() /// /// Runs the action on the main thread: inline when the caller is already there, posted - /// through the captured otherwise. + /// otherwise - through the captured , and on Android + /// through the thread's native looper. /// /// /// For the requests behind the delegates the SDK hands to app code - the permission /// respond and the observer-mode reports - which the app may invoke from any thread. /// On Android the bridge is JNI, and a thread Unity did not attach cannot enter it, so the - /// hop is what makes "any thread" true off the main one. Without a captured context the - /// action runs inline, which is where every call was made before the capture existed. + /// hop is what makes "any thread" true off the main one. Both requests answer a flow that is + /// on screen, and on Android Unity's player loop is paused under it: a context post would + /// wait for the flow to close, the looper does not (see AdaptyAndroidLooper). Without + /// a captured context the action runs inline, which is where every call was made before the + /// capture existed. /// internal static void RunOnMainThread(Action action) { @@ -82,7 +87,11 @@ internal static void RunOnMainThread(Action action) return; } +#if UNITY_ANDROID && !UNITY_EDITOR + AdaptySDK.Android.AdaptyAndroidLooper.Post(action); +#else context.Post(_ => action(), null); +#endif } /// diff --git a/Packages/com.adapty.unity-sdk/Runtime/Plugins/Android/AdaptyAndroid.cs b/Packages/com.adapty.unity-sdk/Runtime/Plugins/Android/AdaptyAndroid.cs index c1cd12b4..eb04d00c 100644 --- a/Packages/com.adapty.unity-sdk/Runtime/Plugins/Android/AdaptyAndroid.cs +++ b/Packages/com.adapty.unity-sdk/Runtime/Plugins/Android/AdaptyAndroid.cs @@ -1,19 +1,144 @@ using System; using UnityEngine; -#if UNITY_ANDROID -using AdaptyAndroidCallback = AdaptySDK.Android.AdaptyAndroidCallbackAction; -#endif namespace AdaptySDK.Android { #if UNITY_ANDROID + /// + /// The Android bridge: CrossplatformHelper from io.adapty.internal:crossplatform, + /// called through JNI with no Java of the SDK's own in between. + /// + /// + /// The helper's four callbacks are plain Java interfaces with a single invoke, which is + /// the shape implements by method name. They arrive on the + /// thread the native SDK calls from, never Unity's, and are posted to Unity's through + /// - not through a SynchronizationContext, which + /// waits for a frame that does not come while a flow is on screen. + /// internal static class AdaptyAndroid { - private static AndroidJavaClass AdaptyAndroidClass = new AndroidJavaClass("com.adapty.unity.AdaptyAndroidWrapper"); + private const string HelperClass = "com.adapty.internal.crossplatform.CrossplatformHelper"; + private const string UnityPlayerClass = "com.unity3d.player.UnityPlayer"; + + private static AndroidJavaObject s_Helper; + + /// + /// Initialises the helper before the first scene, so an event has somewhere to land. + /// The null check is the idempotence guard: everything here runs on the main thread. + /// + internal static void InitializeOnce() + { + _ = Helper; + } internal static void Invoke(string method, string request, Action completionHandler) => - AdaptyAndroidClass.CallStatic("invokeRequest", method, request , AdaptyAndroidCallback.Action(completionHandler)); - + Helper.Call("onMethodCall", request, method, new ResultCallback(completionHandler)); + + private static AndroidJavaObject Helper + { + get + { + if (s_Helper != null) + { + return s_Helper; + } + + if (!AdaptyAndroidLooper.Install()) + { + throw new InvalidOperationException( + "Adapty: the bridge could not register on the calling thread's native " + + "looper, so SDK callbacks cannot be delivered back to it. It is expected " + + "to run on Unity's scripting thread, which Adapty.InitializeTransport " + + "does before the first scene loads." + ); + } + + using var player = new AndroidJavaClass(UnityPlayerClass); + using var activity = player.GetStatic("currentActivity"); + using var context = activity.Call("getApplicationContext"); + using var helperClass = new AndroidJavaClass(HelperClass); + + // init returns whether this was the process's first initialisation; the activity + // provider is set either way, as the other cross-platform SDKs do. + helperClass.CallStatic( + "init", + context, + new EventCallback(), + new FileLocationTransformer() + ); + s_Helper = helperClass.CallStatic("getShared"); + s_Helper.Call("setActivity", new ActivityProvider()); + + return s_Helper; + } + } + + private static AndroidJavaObject CurrentActivity() + { + using var player = new AndroidJavaClass(UnityPlayerClass); + return player.GetStatic("currentActivity"); + } + + private sealed class EventCallback : AndroidJavaProxy + { + internal EventCallback() + : base("com.adapty.internal.crossplatform.EventCallback") { } + + public void invoke(string id, string json) => + AdaptyAndroidLooper.Post(() => Adapty.OnMessage(id, json)); + } + + private sealed class ResultCallback : AndroidJavaProxy + { + private readonly Action m_Handler; + + internal ResultCallback(Action handler) + : base("com.adapty.internal.crossplatform.ResultCallback") + { + m_Handler = handler; + } + + public void invoke(string json) => + AdaptyAndroidLooper.Post(() => + { + try + { + m_Handler?.Invoke(json); + } + catch (Exception e) + { + Debug.LogError("Failed to invoke callback with arg " + json + ": " + e); + } + }); + } + + private sealed class ActivityProvider : AndroidJavaProxy + { + internal ActivityProvider() + : base("com.adapty.internal.crossplatform.ActivityProvider") { } + + public AndroidJavaObject invoke() => CurrentActivity(); + } + + /// + /// Maps a StreamingAssets path to the asset the native SDK reads: on Android that + /// path is inside the APK, jar:file://...!/assets/<name>. + /// + private sealed class FileLocationTransformer : AndroidJavaProxy + { + private const string AssetsMarker = "!/assets/"; + + internal FileLocationTransformer() + : base("com.adapty.internal.crossplatform.FileLocationTransformer") { } + + public AndroidJavaObject invoke(string path) + { + var marker = path.LastIndexOf(AssetsMarker, StringComparison.Ordinal); + var asset = marker < 0 ? path : path.Substring(marker + AssetsMarker.Length); + using var fileLocation = new AndroidJavaClass("com.adapty.utils.FileLocation"); + return fileLocation.CallStatic("fromAsset", asset); + } + } } #endif -} \ No newline at end of file +} diff --git a/Packages/com.adapty.unity-sdk/Runtime/Plugins/Android/AdaptyAndroidCallbackAction.cs b/Packages/com.adapty.unity-sdk/Runtime/Plugins/Android/AdaptyAndroidCallbackAction.cs deleted file mode 100644 index 14913c37..00000000 --- a/Packages/com.adapty.unity-sdk/Runtime/Plugins/Android/AdaptyAndroidCallbackAction.cs +++ /dev/null @@ -1,66 +0,0 @@ -using System; -using UnityEngine; - -namespace AdaptySDK.Android -{ -#if UNITY_ANDROID - internal static class AdaptyAndroidCallbackAction - { - internal class MessageHandler : AndroidJavaProxy - { - internal MessageHandler() : base("com.adapty.unity.AdaptyAndroidMessageHandler") { } - - public void onMessage(string id, string json) - { - Adapty.OnMessage(id, json); - } - } - - internal class CallbackHandler : AndroidJavaProxy - { - private readonly Action _resultHandler; - - internal CallbackHandler(Action resultHandler) : base("com.adapty.unity.AdaptyAndroidCallback") - { - _resultHandler = resultHandler; - } - - public void onHandleResult(string result) - { - if (_resultHandler == null) return; - try - { - _resultHandler.Invoke(result); - } - catch (Exception e) - { - Debug.LogError("Failed to invoke callback with arg " + result + ": " + e); - } - } - } - - public static AndroidJavaProxy Action(Action action) - { - return new CallbackHandler(action); - } - - private static readonly object m_Lock = new object(); - - private static bool m_IsInitialized = false; - - internal static void InitializeOnce() - { - lock(m_Lock) { - if (!m_IsInitialized) { - // Marked initialized only once registration has returned. Set before the call, - // a throw would leave the flag standing and this method has one caller - a - // [RuntimeInitializeOnLoadMethod] - so nothing would ever try again. - new AndroidJavaClass("com.adapty.unity.AdaptyAndroidWrapper").CallStatic("registerMessageHandler", new MessageHandler()); - m_IsInitialized = true; - } - } - } - - } -#endif -} \ No newline at end of file diff --git a/Packages/com.adapty.unity-sdk/Runtime/Plugins/Android/AdaptyAndroidLooper.cs b/Packages/com.adapty.unity-sdk/Runtime/Plugins/Android/AdaptyAndroidLooper.cs new file mode 100644 index 00000000..d8d7bd95 --- /dev/null +++ b/Packages/com.adapty.unity-sdk/Runtime/Plugins/Android/AdaptyAndroidLooper.cs @@ -0,0 +1,120 @@ +using System; +using System.Collections.Concurrent; +using System.Runtime.InteropServices; +using UnityEngine; + +namespace AdaptySDK.Android +{ +#if UNITY_ANDROID + /// + /// Posts to the native ALooper of the thread that installed it - Unity's scripting thread. + /// + /// + /// A flow is an Activity of its own, and Unity's player loop is paused underneath it: a + /// SynchronizationContext post, even UnityPlayer.invokeOnMainThread, waits for the + /// resume, and the flow's close would reach the listener with nothing left to dismiss. + /// The thread's native looper keeps turning through the pause on both entry points - + /// Looper.loop() polls it under UnityPlayerActivity, the activity glue under GameActivity, + /// where the thread has no Java Looper at all. An eventfd registered on it wakes + /// the thread, and the callback drains the queue there. It is not a Handler on + /// Looper.myLooper() because that finds none under GameActivity - or, after someone's + /// Looper.prepare(), one that nothing loops. Only the NDK's stable C API is called, so + /// the SDK ships no native library of its own. + /// + internal static class AdaptyAndroidLooper + { + private const int LooperPollCallback = -2; + private const int LooperEventInput = 1; + private const int EfdNonblockCloexec = 0x800 | 0x80000; + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate int LooperCallback(int fd, int events, IntPtr data); + + [DllImport("android")] + private static extern IntPtr ALooper_forThread(); + + [DllImport("android")] + private static extern int ALooper_addFd( + IntPtr looper, + int fd, + int ident, + int events, + LooperCallback callback, + IntPtr data + ); + + [DllImport("c")] + private static extern int eventfd(uint initval, int flags); + + [DllImport("c")] + private static extern IntPtr write(int fd, ref ulong value, IntPtr count); + + [DllImport("c")] + private static extern IntPtr read(int fd, out ulong value, IntPtr count); + + [DllImport("c")] + private static extern int close(int fd); + + private static readonly ConcurrentQueue s_Queue = new ConcurrentQueue(); + + // Held in a static so the marshalled pointer the looper keeps stays valid. + private static readonly LooperCallback s_Callback = OnReadable; + + private static int s_Fd = -1; + + /// + /// Registers on the calling thread's ALooper; false when that fails. + /// + internal static bool Install() + { + if (s_Fd >= 0) + { + return true; + } + var looper = ALooper_forThread(); + if (looper == IntPtr.Zero) + { + return false; + } + var fd = eventfd(0, EfdNonblockCloexec); + if (fd < 0) + { + return false; + } + if (ALooper_addFd(looper, fd, LooperPollCallback, LooperEventInput, s_Callback, IntPtr.Zero) != 1) + { + close(fd); + return false; + } + s_Fd = fd; + return true; + } + + internal static void Post(Action action) + { + s_Queue.Enqueue(action); + ulong one = 1; + write(s_Fd, ref one, (IntPtr)sizeof(ulong)); + } + + [AOT.MonoPInvokeCallback(typeof(LooperCallback))] + private static int OnReadable(int fd, int events, IntPtr data) + { + read(fd, out _, (IntPtr)sizeof(ulong)); + while (s_Queue.TryDequeue(out var action)) + { + // Nothing may unwind into the looper: it is native code with no handler above it. + try + { + action(); + } + catch (Exception e) + { + Debug.LogError("Adapty: a callback posted to the Unity thread failed: " + e); + } + } + return 1; + } + } +#endif +} diff --git a/Packages/com.adapty.unity-sdk/Runtime/Plugins/Android/AdaptyAndroidCallbackAction.cs.meta b/Packages/com.adapty.unity-sdk/Runtime/Plugins/Android/AdaptyAndroidLooper.cs.meta similarity index 83% rename from Packages/com.adapty.unity-sdk/Runtime/Plugins/Android/AdaptyAndroidCallbackAction.cs.meta rename to Packages/com.adapty.unity-sdk/Runtime/Plugins/Android/AdaptyAndroidLooper.cs.meta index b9e1cb3a..081570f4 100644 --- a/Packages/com.adapty.unity-sdk/Runtime/Plugins/Android/AdaptyAndroidCallbackAction.cs.meta +++ b/Packages/com.adapty.unity-sdk/Runtime/Plugins/Android/AdaptyAndroidLooper.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 86fa29bc97b8844bb8119309f9e0656d +guid: ff9c0ad600a6546a69dff27511ffb07d MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Packages/com.adapty.unity-sdk/Runtime/Plugins/Android/Local.meta b/Packages/com.adapty.unity-sdk/Runtime/Plugins/Android/Local.meta deleted file mode 100644 index ce1d0290..00000000 --- a/Packages/com.adapty.unity-sdk/Runtime/Plugins/Android/Local.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: ec46fd6649a4c42d3956f6ce19569663 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Packages/com.adapty.unity-sdk/Runtime/Plugins/Android/Local/io.meta b/Packages/com.adapty.unity-sdk/Runtime/Plugins/Android/Local/io.meta deleted file mode 100644 index f4934691..00000000 --- a/Packages/com.adapty.unity-sdk/Runtime/Plugins/Android/Local/io.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 489789e531d8b484c99a84c8900f9a6d -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Packages/com.adapty.unity-sdk/Runtime/Plugins/Android/Local/io/adapty.meta b/Packages/com.adapty.unity-sdk/Runtime/Plugins/Android/Local/io/adapty.meta deleted file mode 100644 index 3f76bb29..00000000 --- a/Packages/com.adapty.unity-sdk/Runtime/Plugins/Android/Local/io/adapty.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 9cab22ca9babb47de84899a7feeb3f9e -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Packages/com.adapty.unity-sdk/Runtime/Plugins/Android/Local/io/adapty/internal.meta b/Packages/com.adapty.unity-sdk/Runtime/Plugins/Android/Local/io/adapty/internal.meta deleted file mode 100644 index f8f77202..00000000 --- a/Packages/com.adapty.unity-sdk/Runtime/Plugins/Android/Local/io/adapty/internal.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 86308ab1b37c243b8af8c3b9da4860b6 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Packages/com.adapty.unity-sdk/Runtime/Plugins/Android/Local/io/adapty/internal/unity-wrapper.meta b/Packages/com.adapty.unity-sdk/Runtime/Plugins/Android/Local/io/adapty/internal/unity-wrapper.meta deleted file mode 100644 index 7ccd5dad..00000000 --- a/Packages/com.adapty.unity-sdk/Runtime/Plugins/Android/Local/io/adapty/internal/unity-wrapper.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 4af9ad28067354054a1c044dad21075f -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Packages/com.adapty.unity-sdk/Runtime/Plugins/Android/Local/io/adapty/internal/unity-wrapper/4.1.0.meta b/Packages/com.adapty.unity-sdk/Runtime/Plugins/Android/Local/io/adapty/internal/unity-wrapper/4.1.0.meta deleted file mode 100644 index 56812030..00000000 --- a/Packages/com.adapty.unity-sdk/Runtime/Plugins/Android/Local/io/adapty/internal/unity-wrapper/4.1.0.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: c7db3b5ff36b74856bd5a3ca6efb99f8 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Packages/com.adapty.unity-sdk/Runtime/Plugins/Android/Local/io/adapty/internal/unity-wrapper/4.1.0/unity-wrapper-4.1.0.aar b/Packages/com.adapty.unity-sdk/Runtime/Plugins/Android/Local/io/adapty/internal/unity-wrapper/4.1.0/unity-wrapper-4.1.0.aar deleted file mode 100644 index fdeb0936..00000000 Binary files a/Packages/com.adapty.unity-sdk/Runtime/Plugins/Android/Local/io/adapty/internal/unity-wrapper/4.1.0/unity-wrapper-4.1.0.aar and /dev/null differ diff --git a/Packages/com.adapty.unity-sdk/Runtime/Plugins/Android/Local/io/adapty/internal/unity-wrapper/4.1.0/unity-wrapper-4.1.0.aar.meta b/Packages/com.adapty.unity-sdk/Runtime/Plugins/Android/Local/io/adapty/internal/unity-wrapper/4.1.0/unity-wrapper-4.1.0.aar.meta deleted file mode 100644 index d0ef6887..00000000 --- a/Packages/com.adapty.unity-sdk/Runtime/Plugins/Android/Local/io/adapty/internal/unity-wrapper/4.1.0/unity-wrapper-4.1.0.aar.meta +++ /dev/null @@ -1,2 +0,0 @@ -fileFormatVersion: 2 -guid: b33df674d6b7147e6a07300be4eeaf1a \ No newline at end of file diff --git a/Packages/com.adapty.unity-sdk/Runtime/Plugins/Android/Local/io/adapty/internal/unity-wrapper/4.1.0/unity-wrapper-4.1.0.pom b/Packages/com.adapty.unity-sdk/Runtime/Plugins/Android/Local/io/adapty/internal/unity-wrapper/4.1.0/unity-wrapper-4.1.0.pom deleted file mode 100644 index 9f4ec4d9..00000000 --- a/Packages/com.adapty.unity-sdk/Runtime/Plugins/Android/Local/io/adapty/internal/unity-wrapper/4.1.0/unity-wrapper-4.1.0.pom +++ /dev/null @@ -1,9 +0,0 @@ - - - 4.0.0 - io.adapty.internal - unity-wrapper - 4.1.0 - aar - - diff --git a/Packages/com.adapty.unity-sdk/Runtime/Plugins/Android/Local/io/adapty/internal/unity-wrapper/4.1.0/unity-wrapper-4.1.0.pom.meta b/Packages/com.adapty.unity-sdk/Runtime/Plugins/Android/Local/io/adapty/internal/unity-wrapper/4.1.0/unity-wrapper-4.1.0.pom.meta deleted file mode 100644 index c0828657..00000000 --- a/Packages/com.adapty.unity-sdk/Runtime/Plugins/Android/Local/io/adapty/internal/unity-wrapper/4.1.0/unity-wrapper-4.1.0.pom.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: ac52b46de3aee45aebda96d399d28584 -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Packages/manifest.json b/Packages/manifest.json index 0e118329..d5562fcc 100644 --- a/Packages/manifest.json +++ b/Packages/manifest.json @@ -7,7 +7,7 @@ "com.unity.inputsystem": "1.20.0", "com.unity.mobile.android-logcat": "1.4.7", "com.unity.nuget.newtonsoft-json": "3.2.2", - "com.unity.pipeline": "0.5.0-exp.1", + "com.unity.pipeline": "0.6.0-exp.1", "com.unity.project-auditor-rules": "2.0.0", "com.unity.test-framework": "1.8.0", "com.unity.ugui": "2.6.0", diff --git a/Packages/packages-lock.json b/Packages/packages-lock.json index d281f933..d020ed67 100644 --- a/Packages/packages-lock.json +++ b/Packages/packages-lock.json @@ -70,7 +70,7 @@ "url": "https://packages.unity.com" }, "com.unity.pipeline": { - "version": "0.5.0-exp.1", + "version": "0.6.0-exp.1", "depth": 0, "source": "registry", "dependencies": { diff --git a/ProjectSettings/Packages/com.unity.pipeline/RuntimePipelineConfig.json b/ProjectSettings/Packages/com.unity.pipeline/RuntimePipelineConfig.json new file mode 100644 index 00000000..5e9bb012 --- /dev/null +++ b/ProjectSettings/Packages/com.unity.pipeline/RuntimePipelineConfig.json @@ -0,0 +1,8 @@ +{ + "enableInBuilds": false, + "port": 7900, + "requestTimeoutMs": 120000, + "enableAuditLogging": true, + "autoStart": true, + "maxWorkItemsPerFrame": 10 +} \ No newline at end of file diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index bf1e8bee..7c81eb09 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -8,7 +8,7 @@ PlayerSettings: AndroidProfiler: 0 AndroidFilterTouchesWhenObscured: 0 AndroidEnableSustainedPerformanceMode: 0 - defaultScreenOrientation: 4 + defaultScreenOrientation: 0 targetDevice: 0 useOnDemandResources: 0 accelerometerFrequency: 60 diff --git a/adaptyandroidwrapper/.gitignore b/adaptyandroidwrapper/.gitignore deleted file mode 100644 index 603b1407..00000000 --- a/adaptyandroidwrapper/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -*.iml -.gradle -/local.properties -/.idea/caches -/.idea/libraries -/.idea/modules.xml -/.idea/workspace.xml -/.idea/navEditor.xml -/.idea/assetWizardSettings.xml -.DS_Store -/build -/captures -.externalNativeBuild -.cxx diff --git a/adaptyandroidwrapper/app/.gitignore b/adaptyandroidwrapper/app/.gitignore deleted file mode 100644 index 42afabfd..00000000 --- a/adaptyandroidwrapper/app/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/build \ No newline at end of file diff --git a/adaptyandroidwrapper/app/build.gradle b/adaptyandroidwrapper/app/build.gradle deleted file mode 100644 index 120d2151..00000000 --- a/adaptyandroidwrapper/app/build.gradle +++ /dev/null @@ -1,32 +0,0 @@ -apply plugin: 'com.android.application' - -android { - compileSdkVersion 30 - - defaultConfig { - applicationId "com.adaptyunity" - minSdkVersion 16 - targetSdkVersion 30 - versionCode 1 - versionName "1.0" - - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } - } -} - -dependencies { - implementation fileTree(dir: "libs", include: ["*.jar"]) - implementation 'androidx.appcompat:appcompat:1.3.0' - implementation 'androidx.constraintlayout:constraintlayout:2.1.3' - testImplementation 'junit:junit:4.13.2' - androidTestImplementation 'androidx.test.ext:junit:1.1.3' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' - -} \ No newline at end of file diff --git a/adaptyandroidwrapper/app/localRepositories/io/adapty/internal/unity-wrapper/2.9.0/unity-wrapper-2.9.0.aar b/adaptyandroidwrapper/app/localRepositories/io/adapty/internal/unity-wrapper/2.9.0/unity-wrapper-2.9.0.aar deleted file mode 100644 index d519c862..00000000 Binary files a/adaptyandroidwrapper/app/localRepositories/io/adapty/internal/unity-wrapper/2.9.0/unity-wrapper-2.9.0.aar and /dev/null differ diff --git a/adaptyandroidwrapper/app/localRepositories/io/adapty/internal/unity-wrapper/2.9.0/unity-wrapper-2.9.0.pom b/adaptyandroidwrapper/app/localRepositories/io/adapty/internal/unity-wrapper/2.9.0/unity-wrapper-2.9.0.pom deleted file mode 100644 index 3e262b39..00000000 --- a/adaptyandroidwrapper/app/localRepositories/io/adapty/internal/unity-wrapper/2.9.0/unity-wrapper-2.9.0.pom +++ /dev/null @@ -1,9 +0,0 @@ - - - 4.0.0 - io.adapty.internal - unity-wrapper - 2.9.0 - aar - - diff --git a/adaptyandroidwrapper/app/proguard-rules.pro b/adaptyandroidwrapper/app/proguard-rules.pro deleted file mode 100644 index 481bb434..00000000 --- a/adaptyandroidwrapper/app/proguard-rules.pro +++ /dev/null @@ -1,21 +0,0 @@ -# Add project specific ProGuard rules here. -# You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} - -# Uncomment this to preserve the line number information for -# debugging stack traces. -#-keepattributes SourceFile,LineNumberTable - -# If you keep the line number information, uncomment this to -# hide the original source file name. -#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/adaptyandroidwrapper/app/src/androidTest/java/com/adapty/unity/ExampleInstrumentedTest.java b/adaptyandroidwrapper/app/src/androidTest/java/com/adapty/unity/ExampleInstrumentedTest.java deleted file mode 100644 index 5fa3de21..00000000 --- a/adaptyandroidwrapper/app/src/androidTest/java/com/adapty/unity/ExampleInstrumentedTest.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.adapty.unity; - -import android.content.Context; - -import androidx.test.platform.app.InstrumentationRegistry; -import androidx.test.ext.junit.runners.AndroidJUnit4; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import static org.junit.Assert.*; - -/** - * Instrumented test, which will execute on an Android device. - * - * @see Testing documentation - */ -@RunWith(AndroidJUnit4.class) -public class ExampleInstrumentedTest { - @Test - public void useAppContext() { - // Context of the app under test. - Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); - assertEquals("com.adapty.unity", appContext.getPackageName()); - } -} \ No newline at end of file diff --git a/adaptyandroidwrapper/app/src/main/AndroidManifest.xml b/adaptyandroidwrapper/app/src/main/AndroidManifest.xml deleted file mode 100644 index 8657d7c7..00000000 --- a/adaptyandroidwrapper/app/src/main/AndroidManifest.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/adaptyandroidwrapper/app/src/main/java/com/adapty/unity/MainActivity.java b/adaptyandroidwrapper/app/src/main/java/com/adapty/unity/MainActivity.java deleted file mode 100644 index ece8e9eb..00000000 --- a/adaptyandroidwrapper/app/src/main/java/com/adapty/unity/MainActivity.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.adapty.unity; - -import androidx.appcompat.app.AppCompatActivity; - -import android.os.Bundle; - -public class MainActivity extends AppCompatActivity { - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); - } -} \ No newline at end of file diff --git a/adaptyandroidwrapper/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/adaptyandroidwrapper/app/src/main/res/drawable-v24/ic_launcher_foreground.xml deleted file mode 100644 index 2b068d11..00000000 --- a/adaptyandroidwrapper/app/src/main/res/drawable-v24/ic_launcher_foreground.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/adaptyandroidwrapper/app/src/main/res/drawable/ic_launcher_background.xml b/adaptyandroidwrapper/app/src/main/res/drawable/ic_launcher_background.xml deleted file mode 100644 index 07d5da9c..00000000 --- a/adaptyandroidwrapper/app/src/main/res/drawable/ic_launcher_background.xml +++ /dev/null @@ -1,170 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/adaptyandroidwrapper/app/src/main/res/layout/activity_main.xml b/adaptyandroidwrapper/app/src/main/res/layout/activity_main.xml deleted file mode 100644 index 4fc24441..00000000 --- a/adaptyandroidwrapper/app/src/main/res/layout/activity_main.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/adaptyandroidwrapper/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/adaptyandroidwrapper/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml deleted file mode 100644 index eca70cfe..00000000 --- a/adaptyandroidwrapper/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/adaptyandroidwrapper/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/adaptyandroidwrapper/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml deleted file mode 100644 index eca70cfe..00000000 --- a/adaptyandroidwrapper/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/adaptyandroidwrapper/app/src/main/res/mipmap-hdpi/ic_launcher.png b/adaptyandroidwrapper/app/src/main/res/mipmap-hdpi/ic_launcher.png deleted file mode 100644 index a571e600..00000000 Binary files a/adaptyandroidwrapper/app/src/main/res/mipmap-hdpi/ic_launcher.png and /dev/null differ diff --git a/adaptyandroidwrapper/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/adaptyandroidwrapper/app/src/main/res/mipmap-hdpi/ic_launcher_round.png deleted file mode 100644 index 61da551c..00000000 Binary files a/adaptyandroidwrapper/app/src/main/res/mipmap-hdpi/ic_launcher_round.png and /dev/null differ diff --git a/adaptyandroidwrapper/app/src/main/res/mipmap-mdpi/ic_launcher.png b/adaptyandroidwrapper/app/src/main/res/mipmap-mdpi/ic_launcher.png deleted file mode 100644 index c41dd285..00000000 Binary files a/adaptyandroidwrapper/app/src/main/res/mipmap-mdpi/ic_launcher.png and /dev/null differ diff --git a/adaptyandroidwrapper/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/adaptyandroidwrapper/app/src/main/res/mipmap-mdpi/ic_launcher_round.png deleted file mode 100644 index db5080a7..00000000 Binary files a/adaptyandroidwrapper/app/src/main/res/mipmap-mdpi/ic_launcher_round.png and /dev/null differ diff --git a/adaptyandroidwrapper/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/adaptyandroidwrapper/app/src/main/res/mipmap-xhdpi/ic_launcher.png deleted file mode 100644 index 6dba46da..00000000 Binary files a/adaptyandroidwrapper/app/src/main/res/mipmap-xhdpi/ic_launcher.png and /dev/null differ diff --git a/adaptyandroidwrapper/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/adaptyandroidwrapper/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png deleted file mode 100644 index da31a871..00000000 Binary files a/adaptyandroidwrapper/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png and /dev/null differ diff --git a/adaptyandroidwrapper/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/adaptyandroidwrapper/app/src/main/res/mipmap-xxhdpi/ic_launcher.png deleted file mode 100644 index 15ac6817..00000000 Binary files a/adaptyandroidwrapper/app/src/main/res/mipmap-xxhdpi/ic_launcher.png and /dev/null differ diff --git a/adaptyandroidwrapper/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/adaptyandroidwrapper/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png deleted file mode 100644 index b216f2d3..00000000 Binary files a/adaptyandroidwrapper/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png and /dev/null differ diff --git a/adaptyandroidwrapper/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/adaptyandroidwrapper/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png deleted file mode 100644 index f25a4197..00000000 Binary files a/adaptyandroidwrapper/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png and /dev/null differ diff --git a/adaptyandroidwrapper/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/adaptyandroidwrapper/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png deleted file mode 100644 index e96783cc..00000000 Binary files a/adaptyandroidwrapper/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png and /dev/null differ diff --git a/adaptyandroidwrapper/app/src/main/res/values/colors.xml b/adaptyandroidwrapper/app/src/main/res/values/colors.xml deleted file mode 100644 index 4faecfa8..00000000 --- a/adaptyandroidwrapper/app/src/main/res/values/colors.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - #6200EE - #3700B3 - #03DAC5 - \ No newline at end of file diff --git a/adaptyandroidwrapper/app/src/main/res/values/strings.xml b/adaptyandroidwrapper/app/src/main/res/values/strings.xml deleted file mode 100644 index fba630b1..00000000 --- a/adaptyandroidwrapper/app/src/main/res/values/strings.xml +++ /dev/null @@ -1,3 +0,0 @@ - - unity - \ No newline at end of file diff --git a/adaptyandroidwrapper/app/src/main/res/values/styles.xml b/adaptyandroidwrapper/app/src/main/res/values/styles.xml deleted file mode 100644 index fac92916..00000000 --- a/adaptyandroidwrapper/app/src/main/res/values/styles.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - \ No newline at end of file diff --git a/adaptyandroidwrapper/app/src/test/java/com/adapty/unity/ExampleUnitTest.java b/adaptyandroidwrapper/app/src/test/java/com/adapty/unity/ExampleUnitTest.java deleted file mode 100644 index 5f088651..00000000 --- a/adaptyandroidwrapper/app/src/test/java/com/adapty/unity/ExampleUnitTest.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.adapty.unity; - -import org.junit.Test; - -import static org.junit.Assert.*; - -/** - * Example local unit test, which will execute on the development machine (host). - * - * @see Testing documentation - */ -public class ExampleUnitTest { - @Test - public void addition_isCorrect() { - assertEquals(4, 2 + 2); - } -} \ No newline at end of file diff --git a/adaptyandroidwrapper/build.gradle b/adaptyandroidwrapper/build.gradle deleted file mode 100644 index 4295a0c3..00000000 --- a/adaptyandroidwrapper/build.gradle +++ /dev/null @@ -1,24 +0,0 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. -buildscript { - repositories { - google() - mavenCentral() - } - dependencies { - classpath 'com.android.tools.build:gradle:7.4.2' - - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files - } -} - -allprojects { - repositories { - google() - mavenCentral() - } -} - -task clean(type: Delete) { - delete rootProject.buildDir -} \ No newline at end of file diff --git a/adaptyandroidwrapper/gradle.properties b/adaptyandroidwrapper/gradle.properties deleted file mode 100644 index c52ac9b7..00000000 --- a/adaptyandroidwrapper/gradle.properties +++ /dev/null @@ -1,19 +0,0 @@ -# Project-wide Gradle settings. -# IDE (e.g. Android Studio) users: -# Gradle settings configured through the IDE *will override* -# any settings specified in this file. -# For more details on how to configure your build environment visit -# http://www.gradle.org/docs/current/userguide/build_environment.html -# Specifies the JVM arguments used for the daemon process. -# The setting is particularly useful for tweaking memory settings. -org.gradle.jvmargs=-Xmx2048m -# When configured, Gradle will run in incubating parallel mode. -# This option should only be used with decoupled projects. More details, visit -# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects -# org.gradle.parallel=true -# AndroidX package structure to make it clearer which packages are bundled with the -# Android operating system, and which are packaged with your app"s APK -# https://developer.android.com/topic/libraries/support-library/androidx-rn -android.useAndroidX=true -# Automatically convert third-party libraries to use AndroidX -android.enableJetifier=true \ No newline at end of file diff --git a/adaptyandroidwrapper/gradle/wrapper/gradle-wrapper.jar b/adaptyandroidwrapper/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 7454180f..00000000 Binary files a/adaptyandroidwrapper/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/adaptyandroidwrapper/gradle/wrapper/gradle-wrapper.properties b/adaptyandroidwrapper/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index 8049c684..00000000 --- a/adaptyandroidwrapper/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,5 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/adaptyandroidwrapper/gradlew b/adaptyandroidwrapper/gradlew deleted file mode 100755 index cccdd3d5..00000000 --- a/adaptyandroidwrapper/gradlew +++ /dev/null @@ -1,172 +0,0 @@ -#!/usr/bin/env sh - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - -exec "$JAVACMD" "$@" diff --git a/adaptyandroidwrapper/gradlew.bat b/adaptyandroidwrapper/gradlew.bat deleted file mode 100644 index f9553162..00000000 --- a/adaptyandroidwrapper/gradlew.bat +++ /dev/null @@ -1,84 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/adaptyandroidwrapper/settings.gradle b/adaptyandroidwrapper/settings.gradle deleted file mode 100644 index 1d317014..00000000 --- a/adaptyandroidwrapper/settings.gradle +++ /dev/null @@ -1,3 +0,0 @@ -include ':unitywrapper' -include ':app' -rootProject.name = "unity" \ No newline at end of file diff --git a/adaptyandroidwrapper/unitywrapper/.gitignore b/adaptyandroidwrapper/unitywrapper/.gitignore deleted file mode 100644 index 42afabfd..00000000 --- a/adaptyandroidwrapper/unitywrapper/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/build \ No newline at end of file diff --git a/adaptyandroidwrapper/unitywrapper/build.gradle b/adaptyandroidwrapper/unitywrapper/build.gradle deleted file mode 100644 index a57eb49f..00000000 --- a/adaptyandroidwrapper/unitywrapper/build.gradle +++ /dev/null @@ -1,41 +0,0 @@ -apply plugin: 'com.android.library' - -android { - compileSdkVersion 34 - buildToolsVersion '36.0.0' - - defaultConfig { - minSdkVersion 21 - targetSdkVersion 34 - - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - consumerProguardFiles "consumer-rules.pro" - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } - } - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } -} - -repositories { - maven { url 'https://jitpack.io' } - maven { url "../../Packages/com.adapty.unity-sdk/Runtime/Plugins/Android/Local" } -} - -dependencies { - compileOnly fileTree(dir: "libs", include: ["*.jar"]) - testImplementation 'junit:junit:4.13.2' - androidTestImplementation 'androidx.test.ext:junit:1.1.3' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' - compileOnly 'io.adapty:android-sdk:4.1.0' - compileOnly 'io.adapty.internal:crossplatform:4.1.0' - compileOnly 'org.jetbrains.kotlin:kotlin-stdlib:1.4.32' - compileOnly 'com.google.code.gson:gson:2.10' -} diff --git a/adaptyandroidwrapper/unitywrapper/consumer-rules.pro b/adaptyandroidwrapper/unitywrapper/consumer-rules.pro deleted file mode 100644 index e69de29b..00000000 diff --git a/adaptyandroidwrapper/unitywrapper/libs/classes.jar b/adaptyandroidwrapper/unitywrapper/libs/classes.jar deleted file mode 100644 index c4cbb160..00000000 Binary files a/adaptyandroidwrapper/unitywrapper/libs/classes.jar and /dev/null differ diff --git a/adaptyandroidwrapper/unitywrapper/proguard-rules.pro b/adaptyandroidwrapper/unitywrapper/proguard-rules.pro deleted file mode 100644 index e28d4358..00000000 --- a/adaptyandroidwrapper/unitywrapper/proguard-rules.pro +++ /dev/null @@ -1,23 +0,0 @@ -# Add project specific ProGuard rules here. -# You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} - -# Uncomment this to preserve the line number information for -# debugging stack traces. -#-keepattributes SourceFile,LineNumberTable - -# If you keep the line number information, uncomment this to -# hide the original source file name. -#-renamesourcefileattribute SourceFile - --keep class com.adapty.** { *; } \ No newline at end of file diff --git a/adaptyandroidwrapper/unitywrapper/src/androidTest/java/com/adapty/unity/ExampleInstrumentedTest.java b/adaptyandroidwrapper/unitywrapper/src/androidTest/java/com/adapty/unity/ExampleInstrumentedTest.java deleted file mode 100644 index 5232c3c1..00000000 --- a/adaptyandroidwrapper/unitywrapper/src/androidTest/java/com/adapty/unity/ExampleInstrumentedTest.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.adapty.unity; - -import android.content.Context; - -import androidx.test.platform.app.InstrumentationRegistry; -import androidx.test.ext.junit.runners.AndroidJUnit4; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import static org.junit.Assert.*; - -/** - * Instrumented test, which will execute on an Android device. - * - * @see Testing documentation - */ -@RunWith(AndroidJUnit4.class) -public class ExampleInstrumentedTest { - @Test - public void useAppContext() { - // Context of the app under test. - Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); - assertEquals("com.adapty.unity.test", appContext.getPackageName()); - } -} \ No newline at end of file diff --git a/adaptyandroidwrapper/unitywrapper/src/main/AndroidManifest.xml b/adaptyandroidwrapper/unitywrapper/src/main/AndroidManifest.xml deleted file mode 100644 index 20c0a85d..00000000 --- a/adaptyandroidwrapper/unitywrapper/src/main/AndroidManifest.xml +++ /dev/null @@ -1,2 +0,0 @@ - \ No newline at end of file diff --git a/adaptyandroidwrapper/unitywrapper/src/main/java/com/adapty/unity/AdaptyAndroidCallback.java b/adaptyandroidwrapper/unitywrapper/src/main/java/com/adapty/unity/AdaptyAndroidCallback.java deleted file mode 100644 index af27a3dc..00000000 --- a/adaptyandroidwrapper/unitywrapper/src/main/java/com/adapty/unity/AdaptyAndroidCallback.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.adapty.unity; - -public interface AdaptyAndroidCallback { - void onHandleResult(String data); -} diff --git a/adaptyandroidwrapper/unitywrapper/src/main/java/com/adapty/unity/AdaptyAndroidMessageHandler.java b/adaptyandroidwrapper/unitywrapper/src/main/java/com/adapty/unity/AdaptyAndroidMessageHandler.java deleted file mode 100644 index dd0175d8..00000000 --- a/adaptyandroidwrapper/unitywrapper/src/main/java/com/adapty/unity/AdaptyAndroidMessageHandler.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.adapty.unity; - -public interface AdaptyAndroidMessageHandler { - void onMessage(String key, String data); -} diff --git a/adaptyandroidwrapper/unitywrapper/src/main/java/com/adapty/unity/AdaptyAndroidWrapper.java b/adaptyandroidwrapper/unitywrapper/src/main/java/com/adapty/unity/AdaptyAndroidWrapper.java deleted file mode 100644 index 07ac728e..00000000 --- a/adaptyandroidwrapper/unitywrapper/src/main/java/com/adapty/unity/AdaptyAndroidWrapper.java +++ /dev/null @@ -1,83 +0,0 @@ -package com.adapty.unity; - -import android.os.Handler; -import android.os.Looper; - -import com.adapty.internal.crossplatform.CrossplatformHelper; -import com.adapty.utils.FileLocation; -import com.unity3d.player.UnityPlayer; - -public class AdaptyAndroidWrapper { - - private static CrossplatformHelper helper = null; - - private static final Object lock = new Object(); - - public static CrossplatformHelper getHelper() { - if (helper != null) - return helper; - - synchronized (lock) { - if (helper != null) - return helper; - if (CrossplatformHelper.init( - UnityPlayer.currentActivity.getApplicationContext(), - (eventName, eventData) -> { - runOnUnityThread(() -> { - if (messageHandler != null) { - messageHandler.onMessage(eventName, eventData); - } - }); - }, - value -> { - int lastIndex = value.lastIndexOf("!/assets/"); - String result = (lastIndex != -1) ? value.substring(lastIndex + 9) : value; - return FileLocation.fromAsset(result); - } - ) - ) { - CrossplatformHelper.getShared().setActivity(() -> UnityPlayer.currentActivity); - } - helper = CrossplatformHelper.getShared(); - return helper; - } - } - private static Handler unityMainThreadHandler; - private static AdaptyAndroidMessageHandler messageHandler; - - /** - * Binds to the registering thread's Looper - Unity's, since the C# side registers from its - * scripting thread before the first scene loads. Unity's player loop is not the Android UI - * thread, so Looper.getMainLooper() would deliver every callback on the wrong one. - */ - public static void registerMessageHandler(AdaptyAndroidMessageHandler handler) { - if(unityMainThreadHandler == null) { - Looper looper = Looper.myLooper(); - if (looper == null) { - throw new IllegalStateException( - "Adapty: registerMessageHandler was called from a thread with no Looper, so SDK " - + "callbacks cannot be delivered back to it. It is expected to be called " - + "from Unity's scripting thread, which Adapty.InitializeTransport does " - + "before the first scene loads." - ); - } - unityMainThreadHandler = new Handler(looper); - } - - // Assigned only once there is a handler to deliver through. Set before the check, a failed - // registration would leave the wrapper holding a listener it can never call. - messageHandler = handler; - } - - public static void runOnUnityThread(Runnable runnable) { - if(unityMainThreadHandler != null && runnable != null) { - unityMainThreadHandler.post(runnable); - } - } - - public static void invokeRequest(String methodName, String argument, AdaptyAndroidCallback callback) { - getHelper().onMethodCall(argument, methodName, message -> { - runOnUnityThread(() -> callback.onHandleResult(message)); - }); - } -} diff --git a/adaptyandroidwrapper/unitywrapper/src/test/java/com/adapty/unity/ExampleUnitTest.java b/adaptyandroidwrapper/unitywrapper/src/test/java/com/adapty/unity/ExampleUnitTest.java deleted file mode 100644 index 5f088651..00000000 --- a/adaptyandroidwrapper/unitywrapper/src/test/java/com/adapty/unity/ExampleUnitTest.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.adapty.unity; - -import org.junit.Test; - -import static org.junit.Assert.*; - -/** - * Example local unit test, which will execute on the development machine (host). - * - * @see Testing documentation - */ -public class ExampleUnitTest { - @Test - public void addition_isCorrect() { - assertEquals(4, 2 + 2); - } -} \ No newline at end of file diff --git a/tests/shared/UnityStubs.cs b/tests/shared/UnityStubs.cs index e13c7195..7df339a4 100644 --- a/tests/shared/UnityStubs.cs +++ b/tests/shared/UnityStubs.cs @@ -178,9 +178,10 @@ protected AndroidJavaProxy(string javaInterface) { } namespace AOT { - // Marks the reverse-P/Invoke entry points on iOS. Attribute only - it changes nothing here, - // but the transport's callback boundary is exactly where a thrown exception would be fatal - // on IL2CPP, so the file has to compile in the test suite. + // Marks the reverse-P/Invoke entry points - the iOS transport's, Android's looper callback. + // Attribute only - it changes nothing here, but the transport's callback boundary is exactly + // where a thrown exception would be fatal on IL2CPP, so the files have to compile in the + // test suite. [AttributeUsage(AttributeTargets.Method)] public sealed class MonoPInvokeCallbackAttribute : Attribute {