Introducing a new way to review your PRs.

Read the announcement

shmykelsa / aaad

The original application for downloading and installing apps made specifically for Android Auto outside of Google Play Store. Active since 2021.

View on GitHub

6 documents · Updated Nov 16, 2026

docs / payment-license-and-user-flows

Payment, License, and User Flows

Overview

This flow covers the legacy PRO purchase, promo-code, and license-transfer screens, all centered on a Firebase Realtime Database boolean license flag at users/{deviceId}. In the covered code, deviceId is the Firebase Authentication UID returned by AuthManager: app/…/AboutPaymentActivity.kt awaits AuthManager.ensureAuthenticated(), while app/…/EnterProCode.java and app/…/TransferLicense.java read AuthManager.INSTANCE.getCurrentUid() or receive the UID from the payment screen.

app/…/AboutPaymentActivity.kt is the payment/about entrypoint declared as .AboutPaymentActivity in app/…/AndroidManifest.xml. It renders app/…/activity_about_payment.xml, initializes Stripe with BuildConfig.STRIPE_PUBLISHABLE_KEY, authenticates silently, optionally displays a cooldown countdown from the date intent extra in next_time_download, and checks users/{deviceId} in BuildConfig.FIREBASE_INSTANCE. If that Firebase value is true, showProStatus() changes the screen to the PRO state and hides proButton; otherwise the proButton remains visible and its XML android:onClick="checkout" opens a warning dialog before starting checkout.

Stripe checkout in app/…/AboutPaymentActivity.kt chooses BuildConfig.STRIPE_PRICE_ID_PROMO when the activity intent has promotion=true, otherwise BuildConfig.STRIPE_PRICE_ID. It posts JSON { price_id, device_id } to https://{FIREBASE_REGION}-{FIREBASE_PROJECT_ID}.cloudfunctions.net/createPaymentIntent, expects a client_secret, and optionally reads a customer object containing id and ephemeral_key for PaymentSheet.CustomerConfiguration. On a successful PaymentSheetResult.Completed, the activity records stripe_transactions/{deviceId} with the payment intent client secret, timestamp, and device ID, then forces the buyer through a non-cancelable email dialog. A valid email is written to user_emails/{deviceId} with timestamp and payment intent, and only after that succeeds does the activity set users/{deviceId}=true and return to MainActivityNew with refresh_pro_status=true.

The promo/license-code path is exposed from app/…/payment_activity_menu.xml: have_code starts EnterProCode from AboutPaymentActivity with the current UID in the did extra. app/…/EnterProCode.java renders app/…/code_input.xml, validates a text code against pc/{code}, and branches on that Firebase boolean. If pc/{code} exists and is true, the code is consumed with removeValue(), users/{deviceId} is set to true, and the app returns to MainActivityNew with refresh_pro_status=true. If pc/{code} exists but is false, the code is treated as a promotion token: the activity starts AboutPaymentActivity with promotion=true so the payment screen uses the promo Stripe price. Missing codes and cancelled Firebase reads show toast errors and leave the user on the code-input screen.

app/…/TransferLicense.java is the legacy transfer UI declared as .TransferLicense in app/…/AndroidManifest.xml and backed by app/…/activity_transfer_license.xml. On create it requires an authenticated UID, reads users/{deviceId}, and enables the “transfer from here” (donate) button only for current PRO users; non-PRO users get a no_license_found toast. The “transfer license here” (receive) button hides both action buttons, renders a QR code containing this device's UID into img_result_qr, and immediately checks users/{deviceId} once; if the value is already true, it treats the transfer as successful and returns to MainActivityNew.

For transfer-out, TransferLicense requests Manifest.permission.CAMERA if needed, starts the third-party com.blikoon.qrcodescanner.QrCodeActivity, and receives scanned data in onActivityResult(). After a confirmation dialog, it sets users/{scannedUid}=true, then sets users/{currentDeviceId}=false, then returns to MainActivityNew with refresh_pro_status=true. QR scan errors are shown in an alert dialog; camera permission denial shows a toast.

app/…/User.java is effectively unused state for these flows: it has a constructor that discards its boolean argument and a package-private activated field, while the active license model in the covered code is the raw Realtime Database boolean stored directly under users/{uid}.

Coupling

  • If the license representation at Firebase users/{uid} changes, update all of app/…/AboutPaymentActivity.kt, app/…/EnterProCode.java, and app/…/TransferLicense.java: they read or write it as a nullable Boolean, not as the User class in app/…/User.java or a structured object.
  • If the Cloud Function contract for createPaymentIntent changes, update app/…/AboutPaymentActivity.kt together with the BuildConfig keys from app/build.gradle: the client constructs the URL from FIREBASE_REGION and FIREBASE_PROJECT_ID, sends price_id and device_id, and requires client_secret plus optional customer.id and customer.ephemeral_key in the response.
  • If payment completion should grant PRO without collecting email, change app/…/AboutPaymentActivity.kt: the current flow records the transaction on Stripe completion but does not set users/{deviceId}=true until saveUserEmail() succeeds.
  • If MainActivityNew changes how it refreshes PRO status, verify the intents created in app/…/AboutPaymentActivity.kt, app/…/EnterProCode.java, and app/…/TransferLicense.java; each clears the task stack and passes refresh_pro_status=true after a successful purchase, code redemption, or transfer.
  • If QR transfer format or scanner library changes, update both QR generation and scan handling in app/…/TransferLicense.java: the generated QR payload is only the receiving device's UID, and the scanner result key is the library-specific string com.blikoon.qrcodescanner.got_qr_scan_relult.

Risks

  • app/…/TransferLicense.java assumes snapshot.getValue(Boolean.class) is non-null in multiple places. If users/{deviceId} is absent, unboxing can crash before the non-PRO toast path runs, so new users or database cleanup can break the transfer screen.
  • app/…/EnterProCode.java removes pc/{code} before confirming that users/{deviceId}=true was written. If the second Firebase write fails, the promo/license code is consumed and the user remains non-PRO.
  • app/…/TransferLicense.java performs license transfer as two independent writes: users/{scannedUid}=true followed by users/{currentDeviceId}=false. If the second write fails, both devices can remain PRO; if the scanned QR payload is not another AAAD UID, the first write can create an arbitrary users/{payload} license flag.
  • app/…/AboutPaymentActivity.kt saves paymentIntentClientSecret under stripe_transactions/{deviceId} and user_emails/{deviceId}. If this value is used operationally as a payment identifier, it is not the payment intent ID and may be sensitive because it is the client secret returned by Stripe.
  • app/…/TransferLicense.java only checks for a received license once immediately after displaying the QR. If the donor scans and writes users/{receivingUid}=true after that single read, the receiving screen will not update unless the user re-enters the flow.