Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: getActivityList crash on some profile #447

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions shared/src/main/java/com/oasisfeng/island/util/Users.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.content.pm.ApplicationInfo.FLAG_DEBUGGABLE
import android.content.pm.LauncherActivityInfo
import android.content.pm.LauncherApps
import android.graphics.drawable.Drawable
import android.os.Build.VERSION.SDK_INT
Expand Down Expand Up @@ -78,11 +79,19 @@ class Users : PseudoContentProvider() {
val uiModule = Modules.getMainLaunchActivity(context).packageName
val la = context.getSystemService<LauncherApps>()!!
val activityInOwner = la.getActivityList(uiModule, CURRENT)[0].name
for (profile in profiles.drop(1)/* skip parent */)
for (activity in la.getActivityList(uiModule, profile))
for (profile in profiles.drop(1)/* skip parent */) {
val activityList: List<LauncherActivityInfo>
try {
activityList = la.getActivityList(uiModule, profile)
} catch (e: SecurityException) {
Log.w(TAG, "Skip profile ${profile.toId()} (most probably not normal profile)")
continue
}
for (activity in activityList)
// Separate "Island Settings" launcher activity is enabled, only if profile is managed by Island.
if (activity.name == activityInOwner) Log.i(TAG, "Profile not managed by Island: ${profile.toId()}")
else profilesByIsland.add(profile).also { Log.i(TAG, "Profile managed by Island: ${profile.toId()}") }
}
} else for (user in profiles.drop(1)/* skip parent */)
if (user != CURRENT) Log.w(TAG, "Skip sibling profile (may not managed by Island): ${user.toId()}")
else profilesByIsland.add(user).also { Log.i(TAG, "Profile managed by Island: ${user.toId()}") }
Expand Down