mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Reworked a few things to speed up app cold startup
This commit is contained in:
parent
1734d11639
commit
52e7acb4ee
10 changed files with 32 additions and 35 deletions
|
|
@ -58,6 +58,7 @@ import org.linphone.utils.AppUtils
|
|||
import org.linphone.utils.ImageUtils
|
||||
import org.linphone.utils.LinphoneUtils
|
||||
import org.linphone.utils.PhoneNumberUtils
|
||||
import org.linphone.utils.ShortcutUtils
|
||||
|
||||
class ContactsManager @UiThread constructor() {
|
||||
companion object {
|
||||
|
|
@ -174,6 +175,9 @@ class ContactsManager @UiThread constructor() {
|
|||
conferenceAvatarMap.clear()
|
||||
|
||||
notifyContactsListChanged()
|
||||
|
||||
Log.i("$TAG Native contacts have been loaded, creating chat rooms shortcuts")
|
||||
ShortcutUtils.createShortcutsToChatRooms(coreContext.context)
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
|
|
@ -343,6 +347,16 @@ class ContactsManager @UiThread constructor() {
|
|||
for (list in core.friendsLists) {
|
||||
list.addListener(friendListListener)
|
||||
}
|
||||
|
||||
val context = coreContext.context
|
||||
if (ActivityCompat.checkSelfPermission(
|
||||
context,
|
||||
Manifest.permission.READ_CONTACTS
|
||||
) != PackageManager.PERMISSION_GRANTED
|
||||
) {
|
||||
Log.w("$TAG READ_CONTACTS permission was denied, creating chat rooms shortcuts")
|
||||
ShortcutUtils.createShortcutsToChatRooms(context)
|
||||
}
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
|
|
|
|||
|
|
@ -236,12 +236,20 @@ class CoreContext @UiThread constructor(val context: Context) : HandlerThread("C
|
|||
core.isAutoIterateEnabled = true
|
||||
core.addListener(coreListener)
|
||||
|
||||
coreThread.postDelayed({ startCore() }, 50)
|
||||
|
||||
Looper.loop()
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
fun startCore() {
|
||||
Log.i("$TAG Configuring Core")
|
||||
core.videoCodecPriorityPolicy = CodecPriorityPolicy.Auto
|
||||
|
||||
updateFriendListsSubscriptionDependingOnDefaultAccount()
|
||||
|
||||
computeUserAgent()
|
||||
Log.i("$TAG Core has been created with user-agent [${core.userAgent}], starting it")
|
||||
Log.i("$TAG Core has been configured with user-agent [${core.userAgent}], starting it")
|
||||
core.start()
|
||||
|
||||
contactsManager.onCoreStarted(core)
|
||||
|
|
@ -252,7 +260,6 @@ class CoreContext @UiThread constructor(val context: Context) : HandlerThread("C
|
|||
audioManager.registerAudioDeviceCallback(audioDeviceCallback, coreThread)
|
||||
|
||||
Log.i("$TAG Report Core created and started")
|
||||
Looper.loop()
|
||||
}
|
||||
|
||||
@Deprecated("Deprecated in Java")
|
||||
|
|
|
|||
|
|
@ -379,8 +379,6 @@ class NotificationsManager @MainThread constructor(private val context: Context)
|
|||
fun onCoreStarted(core: Core) {
|
||||
Log.i("$TAG Core has been started")
|
||||
core.addListener(coreListener)
|
||||
|
||||
ShortcutUtils.createShortcutsToChatRooms(context)
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
|
|
|
|||
|
|
@ -54,10 +54,6 @@ class AssistantActivity : GenericActivity() {
|
|||
binding = DataBindingUtil.setContentView(this, R.layout.assistant_activity)
|
||||
binding.lifecycleOwner = this
|
||||
|
||||
while (!coreContext.isReady()) {
|
||||
Thread.sleep(20)
|
||||
}
|
||||
|
||||
coreContext.postOnCoreThread { core ->
|
||||
if (core.accountList.isEmpty()) {
|
||||
Log.i("$TAG No account configured, disabling back gesture")
|
||||
|
|
|
|||
|
|
@ -29,12 +29,12 @@ import android.os.Bundle
|
|||
import android.os.Parcelable
|
||||
import android.view.Gravity
|
||||
import android.view.ViewGroup
|
||||
import android.view.ViewTreeObserver
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.annotation.MainThread
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
|
||||
import androidx.core.view.children
|
||||
import androidx.core.view.doOnAttach
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
|
|
@ -91,7 +91,7 @@ class MainActivity : GenericActivity() {
|
|||
binding.lifecycleOwner = this
|
||||
|
||||
while (!coreContext.isReady()) {
|
||||
Thread.sleep(20)
|
||||
Thread.sleep(50)
|
||||
}
|
||||
|
||||
if (checkSelfPermission(Manifest.permission.READ_CONTACTS) == PackageManager.PERMISSION_GRANTED) {
|
||||
|
|
@ -158,25 +158,14 @@ class MainActivity : GenericActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
// Wait for fragment to be displayed before hiding the splashscreen
|
||||
binding.root.viewTreeObserver.addOnPreDrawListener(
|
||||
object : ViewTreeObserver.OnPreDrawListener {
|
||||
override fun onPreDraw(): Boolean {
|
||||
return if (sharedViewModel.isFirstFragmentReady) {
|
||||
Log.i("$TAG Report UI has been fully drawn (TTFD)")
|
||||
try {
|
||||
reportFullyDrawn()
|
||||
} catch (se: SecurityException) {
|
||||
Log.e("$TAG Security exception when doing reportFullyDrawn(): $se")
|
||||
}
|
||||
binding.root.viewTreeObserver.removeOnPreDrawListener(this)
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
binding.root.doOnAttach {
|
||||
Log.i("$TAG Report UI has been fully drawn (TTFD)")
|
||||
try {
|
||||
reportFullyDrawn()
|
||||
} catch (se: SecurityException) {
|
||||
Log.e("$TAG Security exception when doing reportFullyDrawn(): $se")
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onPostCreate(savedInstanceState: Bundle?) {
|
||||
|
|
|
|||
|
|
@ -191,7 +191,6 @@ class ConversationsListFragment : AbstractTopBarFragment() {
|
|||
|
||||
(view.parent as? ViewGroup)?.doOnPreDraw {
|
||||
startPostponedEnterTransition()
|
||||
sharedViewModel.isFirstFragmentReady = true
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -131,7 +131,6 @@ class ContactsListFragment : AbstractTopBarFragment() {
|
|||
|
||||
(view.parent as? ViewGroup)?.doOnPreDraw {
|
||||
startPostponedEnterTransition()
|
||||
sharedViewModel.isFirstFragmentReady = true
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -197,7 +197,6 @@ class HistoryListFragment : AbstractTopBarFragment() {
|
|||
|
||||
(view.parent as? ViewGroup)?.doOnPreDraw {
|
||||
startPostponedEnterTransition()
|
||||
sharedViewModel.isFirstFragmentReady = true
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -137,7 +137,6 @@ class MeetingsListFragment : AbstractTopBarFragment() {
|
|||
|
||||
(view.parent as? ViewGroup)?.doOnPreDraw {
|
||||
startPostponedEnterTransition()
|
||||
sharedViewModel.isFirstFragmentReady = true
|
||||
|
||||
if (currentCount < newCount) {
|
||||
scrollToToday()
|
||||
|
|
|
|||
|
|
@ -28,9 +28,6 @@ import org.linphone.ui.main.chat.model.MessageModel
|
|||
import org.linphone.utils.Event
|
||||
|
||||
class SharedMainViewModel @UiThread constructor() : ViewModel() {
|
||||
// When set to true, it will hide the splashscreen
|
||||
var isFirstFragmentReady: Boolean = false
|
||||
|
||||
/* Sliding Pane & navigation related */
|
||||
|
||||
val isSlidingPaneSlideable = MutableLiveData<Boolean>()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue