[Panlingual] Can't set per-app languages for apps on work profile page

Use startActivityAsUser instead of startActivity API to start the AppLocalePickerActivity of different users

Bug: 274378136
Test: 1. Perform AppLocalePickerActivityTest robolectric test
      2. Perform the manual test by switching different users
      3. Perform the manual test by switching different profiles
Change-Id: I4405b3b7e832b71b9ef66fa71d9e42ce12da167c
This commit is contained in:
Josh Hou
2023-03-21 10:49:35 +00:00
parent 36d78f8fe0
commit 38df174bba
5 changed files with 11 additions and 50 deletions

View File

@@ -21,6 +21,7 @@ import android.content.Intent
import android.content.pm.ApplicationInfo
import android.content.pm.PackageManager
import android.net.Uri
import android.os.UserHandle
import androidx.compose.runtime.Composable
import androidx.compose.runtime.State
import androidx.compose.runtime.remember
@@ -94,9 +95,9 @@ class AppLanguagesListModel(private val context: Context) : AppListModel<AppLang
AppListItem {
val intent = Intent(context, AppLocalePickerActivity::class.java).apply {
data = Uri.parse("package:${record.app.packageName}")
this.putExtra("uid", record.app.uid)
}
context.startActivity(intent)
val userHandle : UserHandle = UserHandle.getUserHandleForUid(record.app.uid)
context.startActivityAsUser(intent, userHandle)
}
}
}