mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-24 13:08:46 +00:00
Add billing module and include in play implementation.
This commit is contained in:
@@ -558,6 +558,8 @@ dependencies {
|
||||
implementation(libs.rxjava3.rxkotlin)
|
||||
implementation(libs.rxdogtag)
|
||||
|
||||
"playImplementation"(project(":billing"))
|
||||
|
||||
"spinnerImplementation"(project(":spinner"))
|
||||
|
||||
"canaryImplementation"(libs.square.leakcanary)
|
||||
|
||||
@@ -196,6 +196,7 @@ public class ApplicationContext extends MultiDexApplication implements AppForegr
|
||||
.addNonBlocking(this::beginJobLoop)
|
||||
.addNonBlocking(EmojiSource::refresh)
|
||||
.addNonBlocking(() -> AppDependencies.getGiphyMp4Cache().onAppStart(this))
|
||||
.addNonBlocking(AppDependencies::getBillingApi)
|
||||
.addNonBlocking(this::ensureProfileUploaded)
|
||||
.addNonBlocking(() -> AppDependencies.getExpireStoriesManager().scheduleIfNecessary())
|
||||
.addPostRender(() -> AppDependencies.getDeletedCallEventManager().scheduleIfNecessary())
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright 2024 Signal Messenger, LLC
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
package org.thoughtcrime.securesms.billing
|
||||
|
||||
/**
|
||||
* Variant interface for the BillingApi.
|
||||
*/
|
||||
interface GooglePlayBillingApi {
|
||||
fun isApiAvailable(): Boolean = false
|
||||
suspend fun queryProducts() {}
|
||||
|
||||
/**
|
||||
* Empty implementation, to be used when play services are available but
|
||||
* GooglePlayBillingApi is not available.
|
||||
*/
|
||||
object Empty : GooglePlayBillingApi
|
||||
}
|
||||
@@ -12,6 +12,7 @@ import org.signal.core.util.resettableLazy
|
||||
import org.signal.libsignal.net.Network
|
||||
import org.signal.libsignal.zkgroup.profiles.ClientZkProfileOperations
|
||||
import org.signal.libsignal.zkgroup.receipts.ClientZkReceiptOperations
|
||||
import org.thoughtcrime.securesms.billing.GooglePlayBillingApi
|
||||
import org.thoughtcrime.securesms.components.TypingStatusRepository
|
||||
import org.thoughtcrime.securesms.components.TypingStatusSender
|
||||
import org.thoughtcrime.securesms.crypto.storage.SignalServiceDataStoreImpl
|
||||
@@ -210,6 +211,11 @@ object AppDependencies {
|
||||
provider.provideAndroidCallAudioManager()
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
val billingApi: GooglePlayBillingApi by lazy {
|
||||
provider.provideBillingApi()
|
||||
}
|
||||
|
||||
private val _webSocketObserver: Subject<WebSocketConnectionState> = BehaviorSubject.create()
|
||||
|
||||
/**
|
||||
@@ -342,5 +348,6 @@ object AppDependencies {
|
||||
fun provideClientZkReceiptOperations(signalServiceConfiguration: SignalServiceConfiguration): ClientZkReceiptOperations
|
||||
fun provideScheduledMessageManager(): ScheduledMessageManager
|
||||
fun provideLibsignalNetwork(config: SignalServiceConfiguration): Network
|
||||
fun provideBillingApi(): GooglePlayBillingApi
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ import org.signal.libsignal.net.Network;
|
||||
import org.signal.libsignal.zkgroup.profiles.ClientZkProfileOperations;
|
||||
import org.signal.libsignal.zkgroup.receipts.ClientZkReceiptOperations;
|
||||
import org.thoughtcrime.securesms.BuildConfig;
|
||||
import org.thoughtcrime.securesms.billing.GooglePlayBillingApi;
|
||||
import org.thoughtcrime.securesms.billing.GooglePlayBillingFactory;
|
||||
import org.thoughtcrime.securesms.components.TypingStatusRepository;
|
||||
import org.thoughtcrime.securesms.components.TypingStatusSender;
|
||||
import org.thoughtcrime.securesms.crypto.ReentrantSessionLock;
|
||||
@@ -69,8 +71,8 @@ import org.thoughtcrime.securesms.util.AlarmSleepTimer;
|
||||
import org.thoughtcrime.securesms.util.AppForegroundObserver;
|
||||
import org.thoughtcrime.securesms.util.ByteUnit;
|
||||
import org.thoughtcrime.securesms.util.EarlyMessageCache;
|
||||
import org.thoughtcrime.securesms.util.RemoteConfig;
|
||||
import org.thoughtcrime.securesms.util.FrameRateTracker;
|
||||
import org.thoughtcrime.securesms.util.RemoteConfig;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.thoughtcrime.securesms.video.exo.GiphyMp4Cache;
|
||||
import org.thoughtcrime.securesms.video.exo.SimpleExoPlayerPool;
|
||||
@@ -92,11 +94,11 @@ import org.whispersystems.signalservice.api.util.SleepTimer;
|
||||
import org.whispersystems.signalservice.api.util.UptimeSleepTimer;
|
||||
import org.whispersystems.signalservice.api.websocket.WebSocketFactory;
|
||||
import org.whispersystems.signalservice.internal.configuration.SignalServiceConfiguration;
|
||||
import org.whispersystems.signalservice.internal.websocket.LibSignalChatConnection;
|
||||
import org.whispersystems.signalservice.internal.websocket.LibSignalNetworkExtensions;
|
||||
import org.whispersystems.signalservice.internal.websocket.OkHttpWebSocketConnection;
|
||||
import org.whispersystems.signalservice.internal.websocket.ShadowingWebSocketConnection;
|
||||
import org.whispersystems.signalservice.internal.websocket.WebSocketConnection;
|
||||
import org.whispersystems.signalservice.internal.websocket.LibSignalChatConnection;
|
||||
import org.whispersystems.signalservice.internal.websocket.OkHttpWebSocketConnection;
|
||||
import org.whispersystems.signalservice.internal.websocket.WebSocketShadowingBridge;
|
||||
|
||||
import java.util.Optional;
|
||||
@@ -457,6 +459,11 @@ public class ApplicationDependencyProvider implements AppDependencies.Provider {
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull GooglePlayBillingApi provideBillingApi() {
|
||||
return GooglePlayBillingFactory.create(context);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
static class DynamicCredentialsProvider implements CredentialsProvider {
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.thoughtcrime.securesms.maps;
|
||||
|
||||
import android.Manifest;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.location.Location;
|
||||
@@ -73,6 +74,7 @@ class LocationRetriever implements DefaultLifecycleObserver, LocationListener {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("MissingPermission")
|
||||
@Override
|
||||
public void onStop(@NonNull LifecycleOwner owner) {
|
||||
Log.i(TAG, "Removing any possible location listeners.");
|
||||
|
||||
28
app/src/play/AndroidManifest.xml
Normal file
28
app/src/play/AndroidManifest.xml
Normal file
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<uses-permission android:name="android.permission.DOWNLOAD_WITHOUT_NOTIFICATION"/>
|
||||
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES"/>
|
||||
<uses-permission android:name="android.permission.UPDATE_PACKAGES_WITHOUT_USER_ACTION"/>
|
||||
|
||||
<application>
|
||||
<receiver android:name=".apkupdate.ApkUpdateRefreshListener" android:exported="false">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<receiver android:name=".apkupdate.ApkUpdateDownloadManagerReceiver" android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.DOWNLOAD_COMPLETE"/>
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<receiver
|
||||
android:name=".apkupdate.ApkUpdatePackageInstallerReceiver"
|
||||
android:exported="true" />
|
||||
|
||||
<receiver
|
||||
android:name=".apkupdate.ApkUpdateNotificationReceiver"
|
||||
android:exported="false" />
|
||||
</application>
|
||||
</manifest>
|
||||
@@ -0,0 +1,41 @@
|
||||
package org.thoughtcrime.securesms.billing
|
||||
|
||||
import android.content.Context
|
||||
import com.android.billingclient.api.ProductDetailsResult
|
||||
import org.signal.billing.BillingApi
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.thoughtcrime.securesms.util.RemoteConfig
|
||||
|
||||
/**
|
||||
* Play billing factory. Returns empty implementation if message backups are not enabled.
|
||||
*/
|
||||
object GooglePlayBillingFactory {
|
||||
@JvmStatic
|
||||
fun create(context: Context): GooglePlayBillingApi {
|
||||
return if (RemoteConfig.messageBackups) {
|
||||
GooglePlayBillingApiImpl(context)
|
||||
} else {
|
||||
GooglePlayBillingApi.Empty
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Play Store implementation
|
||||
*/
|
||||
private class GooglePlayBillingApiImpl(context: Context) : GooglePlayBillingApi {
|
||||
|
||||
private companion object {
|
||||
val TAG = Log.tag(GooglePlayBillingApiImpl::class)
|
||||
}
|
||||
|
||||
private val billingApi: BillingApi = BillingApi.getOrCreate(context)
|
||||
|
||||
override fun isApiAvailable(): Boolean = billingApi.areSubscriptionsSupported()
|
||||
|
||||
override suspend fun queryProducts() {
|
||||
val products: ProductDetailsResult = billingApi.queryProducts()
|
||||
|
||||
Log.d(TAG, "queryProducts: ${products.billingResult.responseCode}, ${products.billingResult.debugMessage}")
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import org.signal.core.util.concurrent.DeadlockDetector;
|
||||
import org.signal.libsignal.net.Network;
|
||||
import org.signal.libsignal.zkgroup.profiles.ClientZkProfileOperations;
|
||||
import org.signal.libsignal.zkgroup.receipts.ClientZkReceiptOperations;
|
||||
import org.thoughtcrime.securesms.billing.GooglePlayBillingApi;
|
||||
import org.thoughtcrime.securesms.components.TypingStatusRepository;
|
||||
import org.thoughtcrime.securesms.components.TypingStatusSender;
|
||||
import org.thoughtcrime.securesms.crypto.storage.SignalServiceDataStoreImpl;
|
||||
@@ -238,4 +239,9 @@ public class MockApplicationDependencyProvider implements AppDependencies.Provid
|
||||
public @NonNull Network provideLibsignalNetwork(@NonNull SignalServiceConfiguration config) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull GooglePlayBillingApi provideBillingApi() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package org.thoughtcrime.securesms.billing
|
||||
|
||||
import android.content.Context
|
||||
|
||||
/**
|
||||
* Website builds do not support google play billing.
|
||||
*/
|
||||
object GooglePlayBillingFactory {
|
||||
@JvmStatic
|
||||
fun create(context: Context): GooglePlayBillingApi {
|
||||
return GooglePlayBillingApi.Empty
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user