mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-11 06:44:00 +00:00
Fixed possible crashes below U
This commit is contained in:
@@ -77,6 +77,7 @@ open class SystemApiWrapper(context: Context?) : ApiWrapper(context) {
|
||||
if (!enablePrivateSpace() || !LawnchairApp.isRecentsEnabled) {
|
||||
return super.queryAllUsers()
|
||||
}
|
||||
return try {
|
||||
val users = ArrayMap<UserHandle, UserIconInfo>()
|
||||
mContext.getSystemService(UserManager::class.java)!!.userProfiles?.forEach { user ->
|
||||
mContext.getSystemService(LauncherApps::class.java)!!.getLauncherUserInfo(user)?.apply {
|
||||
@@ -94,17 +95,26 @@ open class SystemApiWrapper(context: Context?) : ApiWrapper(context) {
|
||||
}
|
||||
}
|
||||
return users
|
||||
} catch (t : Throwable) {
|
||||
return super.queryAllUsers()
|
||||
}
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.VANILLA_ICE_CREAM)
|
||||
override fun getPreInstalledSystemPackages(user: UserHandle): List<String> =
|
||||
override fun getPreInstalledSystemPackages(user: UserHandle): List<String> {
|
||||
return try {
|
||||
if (enablePrivateSpace() && privateSpaceSysAppsSeparation())
|
||||
mContext
|
||||
.getSystemService(LauncherApps::class.java)!!
|
||||
.getPreInstalledSystemPackages(user)
|
||||
else ArrayList()
|
||||
} catch (t: Throwable) {
|
||||
super.getPreInstalledSystemPackages(user)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getAppMarketActivityIntent(packageName: String, user: UserHandle): Intent =
|
||||
override fun getAppMarketActivityIntent(packageName: String, user: UserHandle): Intent {
|
||||
return try {
|
||||
if (
|
||||
enablePrivateSpace() &&
|
||||
(privateSpaceAppInstallerButton() || enablePrivateSpaceInstallShortcut())
|
||||
@@ -126,6 +136,10 @@ open class SystemApiWrapper(context: Context?) : ApiWrapper(context) {
|
||||
}
|
||||
)
|
||||
else super.getAppMarketActivityIntent(packageName, user)
|
||||
} catch (t: Throwable) {
|
||||
super.getAppMarketActivityIntent(packageName, user)
|
||||
}
|
||||
}
|
||||
|
||||
/** Returns an intent which can be used to open Private Space Settings. */
|
||||
override fun getPrivateSpaceSettingsIntent(): Intent? =
|
||||
|
||||
@@ -101,7 +101,8 @@ public class ApiWrapper implements ResourceBasedOverride, SafeCloseable {
|
||||
isWork ? UserIconInfo.TYPE_WORK : UserIconInfo.TYPE_MAIN,
|
||||
serial);
|
||||
|
||||
if (launcherApps != null && Utilities.ATLEAST_V) {
|
||||
try {
|
||||
if (Utilities.ATLEAST_U && launcherApps != null) {
|
||||
LauncherUserInfo userInfo = launcherApps.getLauncherUserInfo(user);
|
||||
if (userInfo != null) {
|
||||
var userType = userInfo.getUserType();
|
||||
@@ -115,6 +116,9 @@ public class ApiWrapper implements ResourceBasedOverride, SafeCloseable {
|
||||
);
|
||||
}
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
// Ignore
|
||||
}
|
||||
|
||||
users.put(user, info);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user