Skip to content

Commit

Permalink
FIX: Minor crashes.
Browse files Browse the repository at this point in the history
  • Loading branch information
oasisfeng committed Oct 17, 2023
1 parent 7580ac8 commit a694bd0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class MainViewModel(app: Application, state: SavedStateHandle): AppListViewModel
tabs.addTab(tabs.newTab().setText(R.string.tab_discovery),/* setSelected = */false)
val currentProfile = currentProfile
tabs.addTab(tabs.newTab().setText(com.oasisfeng.island.shared.R.string.mainland_name),
/* setSelected = */Users.isParentProfile(currentProfile))
/* setSelected */currentProfile?.let { Users.isParentProfile(it) } == true)

for ((profile, name) in IslandNameManager.getAllNames(activity)) {
val tab = tabs.newTab().setTag(profile).setText(name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ object IslandAppShortcut {
ShortcutManagerCompat.removeLongLivedShortcuts(context, listOf(id))

if (! Users.isParentProfile()) Shuttle(context, to = Users.parentProfile).launchNoThrows(with = Users.currentId()) {
ShortcutManagerCompat.removeLongLivedShortcuts(context, listOf(getShortcutId(pkg, it, isCrossProfile = true))) }
ShortcutManagerCompat.removeLongLivedShortcuts(this, listOf(getShortcutId(pkg, it, isCrossProfile = true))) }
}

@OwnerUser @ProfileUser @RequiresApi(O) fun updateIfNeeded(context: Context, app: ApplicationInfo, isCrossProfile: Boolean) {
Expand All @@ -106,7 +106,7 @@ object IslandAppShortcut {
val dynamic = isDynamicLabelEnabled(context)
updateAll(context, dynamic)
Users.getProfilesManagedByIsland().forEach {
Shuttle(context, to = it).launchNoThrows { updateAll(context, dynamic) }}
Shuttle(context, to = it).launchNoThrows { updateAll(this, dynamic) }}
}

@RequiresApi(O) fun updateAll(context: Context, dynamic: Boolean) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import android.os.Build.VERSION_CODES.Q
import android.util.Log
import androidx.annotation.ColorRes
import androidx.annotation.RequiresApi
import androidx.core.content.ContextCompat
import androidx.core.content.ContextCompat.RECEIVER_NOT_EXPORTED
import com.oasisfeng.android.util.Apps
import com.oasisfeng.island.api.Api
import com.oasisfeng.island.notification.NotificationIds
Expand Down Expand Up @@ -90,8 +92,9 @@ import java.util.*
/** This provider tracks all freezing and unfreezing events triggered by other modules within the default process of Island */
class AppStateTracker : PseudoContentProvider() {

override fun onCreate() = false.also { context().registerReceiver(IslandAppWatcher(), IntentFilter().apply {
addAction(DevicePolicies.ACTION_PACKAGE_UNFROZEN); addAction(ACTION_PACKAGE_REMOVED); addDataScheme(("package")) }) }
override fun onCreate() = false.also { ContextCompat.registerReceiver(context(), IslandAppWatcher(),
IntentFilter(DevicePolicies.ACTION_PACKAGE_UNFROZEN).apply { addAction(ACTION_PACKAGE_REMOVED); addDataScheme(("package")) },
RECEIVER_NOT_EXPORTED) }
}

companion object {
Expand Down

0 comments on commit a694bd0

Please sign in to comment.