kopia lustrzana https://github.com/ryukoposting/Signal-Android
Add internal setting for manually initializing PNP mode.
rodzic
f1d204b834
commit
202f20893c
|
@ -29,6 +29,7 @@ import org.thoughtcrime.securesms.dependencies.ApplicationDependencies
|
||||||
import org.thoughtcrime.securesms.jobmanager.JobTracker
|
import org.thoughtcrime.securesms.jobmanager.JobTracker
|
||||||
import org.thoughtcrime.securesms.jobs.DownloadLatestEmojiDataJob
|
import org.thoughtcrime.securesms.jobs.DownloadLatestEmojiDataJob
|
||||||
import org.thoughtcrime.securesms.jobs.EmojiSearchIndexDownloadJob
|
import org.thoughtcrime.securesms.jobs.EmojiSearchIndexDownloadJob
|
||||||
|
import org.thoughtcrime.securesms.jobs.PnpInitializeDevicesJob
|
||||||
import org.thoughtcrime.securesms.jobs.RefreshAttributesJob
|
import org.thoughtcrime.securesms.jobs.RefreshAttributesJob
|
||||||
import org.thoughtcrime.securesms.jobs.RefreshOwnProfileJob
|
import org.thoughtcrime.securesms.jobs.RefreshOwnProfileJob
|
||||||
import org.thoughtcrime.securesms.jobs.RemoteConfigRefreshJob
|
import org.thoughtcrime.securesms.jobs.RemoteConfigRefreshJob
|
||||||
|
@ -544,6 +545,37 @@ class InternalSettingsFragment : DSLSettingsFragment(R.string.preferences__inter
|
||||||
findNavController().safeNavigate(InternalSettingsFragmentDirections.actionInternalSettingsFragmentToStoryDialogsLauncherFragment())
|
findNavController().safeNavigate(InternalSettingsFragmentDirections.actionInternalSettingsFragmentToStoryDialogsLauncherFragment())
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
dividerPref()
|
||||||
|
|
||||||
|
sectionHeaderPref(DSLSettingsText.from("PNP"))
|
||||||
|
|
||||||
|
clickPref(
|
||||||
|
title = DSLSettingsText.from("Trigger No-Op Change Number"),
|
||||||
|
summary = DSLSettingsText.from("Mimics the 'Hello world' event"),
|
||||||
|
isEnabled = true,
|
||||||
|
onClick = {
|
||||||
|
SimpleTask.run(viewLifecycleOwner.lifecycle, {
|
||||||
|
ApplicationDependencies.getJobManager().runSynchronously(PnpInitializeDevicesJob(), 10.seconds.inWholeMilliseconds)
|
||||||
|
}, { state ->
|
||||||
|
if (state.isPresent) {
|
||||||
|
Toast.makeText(context, "Job finished with result: ${state.get()}!", Toast.LENGTH_SHORT).show()
|
||||||
|
viewModel.refresh()
|
||||||
|
} else {
|
||||||
|
Toast.makeText(context, "Job timed out after 10 seconds!", Toast.LENGTH_SHORT).show()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
clickPref(
|
||||||
|
title = DSLSettingsText.from("Reset 'PNP initialized' state"),
|
||||||
|
summary = DSLSettingsText.from("Current initialized state: ${state.pnpInitialized}"),
|
||||||
|
isEnabled = state.pnpInitialized,
|
||||||
|
onClick = {
|
||||||
|
viewModel.resetPnpInitializedState()
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,5 +20,6 @@ data class InternalSettingsState(
|
||||||
val removeSenderKeyMinimium: Boolean,
|
val removeSenderKeyMinimium: Boolean,
|
||||||
val delayResends: Boolean,
|
val delayResends: Boolean,
|
||||||
val disableStorageService: Boolean,
|
val disableStorageService: Boolean,
|
||||||
val canClearOnboardingState: Boolean
|
val canClearOnboardingState: Boolean,
|
||||||
|
val pnpInitialized: Boolean
|
||||||
)
|
)
|
||||||
|
|
|
@ -64,6 +64,11 @@ class InternalSettingsViewModel(private val repository: InternalSettingsReposito
|
||||||
refresh()
|
refresh()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun resetPnpInitializedState() {
|
||||||
|
SignalStore.misc().setPniInitializedDevices(false)
|
||||||
|
refresh()
|
||||||
|
}
|
||||||
|
|
||||||
fun setUseBuiltInEmoji(enabled: Boolean) {
|
fun setUseBuiltInEmoji(enabled: Boolean) {
|
||||||
preferenceDataStore.putBoolean(InternalValues.FORCE_BUILT_IN_EMOJI, enabled)
|
preferenceDataStore.putBoolean(InternalValues.FORCE_BUILT_IN_EMOJI, enabled)
|
||||||
refresh()
|
refresh()
|
||||||
|
@ -103,7 +108,7 @@ class InternalSettingsViewModel(private val repository: InternalSettingsReposito
|
||||||
repository.addSampleReleaseNote()
|
repository.addSampleReleaseNote()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun refresh() {
|
fun refresh() {
|
||||||
store.update { getState().copy(emojiVersion = it.emojiVersion) }
|
store.update { getState().copy(emojiVersion = it.emojiVersion) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,7 +129,8 @@ class InternalSettingsViewModel(private val repository: InternalSettingsReposito
|
||||||
removeSenderKeyMinimium = SignalStore.internalValues().removeSenderKeyMinimum(),
|
removeSenderKeyMinimium = SignalStore.internalValues().removeSenderKeyMinimum(),
|
||||||
delayResends = SignalStore.internalValues().delayResends(),
|
delayResends = SignalStore.internalValues().delayResends(),
|
||||||
disableStorageService = SignalStore.internalValues().storageServiceDisabled(),
|
disableStorageService = SignalStore.internalValues().storageServiceDisabled(),
|
||||||
canClearOnboardingState = SignalStore.storyValues().hasDownloadedOnboardingStory && Stories.isFeatureEnabled()
|
canClearOnboardingState = SignalStore.storyValues().hasDownloadedOnboardingStory && Stories.isFeatureEnabled(),
|
||||||
|
pnpInitialized = SignalStore.misc().hasPniInitializedDevices()
|
||||||
)
|
)
|
||||||
|
|
||||||
fun onClearOnboardingState() {
|
fun onClearOnboardingState() {
|
||||||
|
|
|
@ -10,6 +10,7 @@ import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint
|
||||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||||
import org.thoughtcrime.securesms.recipients.Recipient
|
import org.thoughtcrime.securesms.recipients.Recipient
|
||||||
import org.thoughtcrime.securesms.registration.VerifyAccountResponseWithoutKbs
|
import org.thoughtcrime.securesms.registration.VerifyAccountResponseWithoutKbs
|
||||||
|
import org.thoughtcrime.securesms.util.FeatureFlags
|
||||||
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
|
|
||||||
|
@ -27,7 +28,7 @@ class PnpInitializeDevicesJob private constructor(parameters: Parameters) : Base
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun enqueueIfNecessary() {
|
fun enqueueIfNecessary() {
|
||||||
if (SignalStore.misc().hasPniInitializedDevices() || !SignalStore.account().isRegistered || SignalStore.account().aci == null || Recipient.self().pnpCapability != Recipient.Capability.SUPPORTED) {
|
if (SignalStore.misc().hasPniInitializedDevices() || !SignalStore.account().isRegistered || SignalStore.account().aci == null || Recipient.self().pnpCapability != Recipient.Capability.SUPPORTED || !FeatureFlags.phoneNumberPrivacy()) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,6 +50,14 @@ class PnpInitializeDevicesJob private constructor(parameters: Parameters) : Base
|
||||||
|
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
public override fun onRun() {
|
public override fun onRun() {
|
||||||
|
if (Recipient.self().pnpCapability != Recipient.Capability.SUPPORTED) {
|
||||||
|
throw IllegalStateException("This should only be run if you have the capability!")
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!FeatureFlags.phoneNumberPrivacy()) {
|
||||||
|
throw IllegalStateException("This should only be running if PNP is enabled!")
|
||||||
|
}
|
||||||
|
|
||||||
if (!SignalStore.account().isRegistered || SignalStore.account().aci == null) {
|
if (!SignalStore.account().isRegistered || SignalStore.account().aci == null) {
|
||||||
Log.w(TAG, "Not registered! Skipping, as it wouldn't do anything.")
|
Log.w(TAG, "Not registered! Skipping, as it wouldn't do anything.")
|
||||||
return
|
return
|
||||||
|
|
Ładowanie…
Reference in New Issue