Merge "Fix CTS failed test cases issue" into udc-dev
This commit is contained in:
@@ -323,7 +323,7 @@ public class LocaleManagerService extends SystemService {
|
||||
*/
|
||||
void notifyInstallerOfAppWhoseLocaleChanged(String appPackageName, int userId,
|
||||
LocaleList locales) {
|
||||
String installingPackageName = getInstallingPackageName(appPackageName);
|
||||
String installingPackageName = getInstallingPackageName(appPackageName, userId);
|
||||
if (installingPackageName != null) {
|
||||
Intent intent = createBaseIntent(Intent.ACTION_APPLICATION_LOCALE_CHANGED,
|
||||
appPackageName, locales);
|
||||
@@ -464,7 +464,7 @@ public class LocaleManagerService extends SystemService {
|
||||
* Checks if the calling app is the installer of the app whose locale changed.
|
||||
*/
|
||||
private boolean isCallerInstaller(String appPackageName, int userId) {
|
||||
String installingPackageName = getInstallingPackageName(appPackageName);
|
||||
String installingPackageName = getInstallingPackageName(appPackageName, userId);
|
||||
if (installingPackageName != null) {
|
||||
// Get the uid of installer-on-record to compare with the calling uid.
|
||||
int installerUid = getPackageUid(installingPackageName, userId);
|
||||
@@ -513,10 +513,11 @@ public class LocaleManagerService extends SystemService {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
String getInstallingPackageName(String packageName) {
|
||||
String getInstallingPackageName(String packageName, int userId) {
|
||||
try {
|
||||
return mContext.getPackageManager()
|
||||
.getInstallSourceInfo(packageName).getInstallingPackageName();
|
||||
return mContext.createContextAsUser(UserHandle.of(userId), /* flags= */
|
||||
0).getPackageManager().getInstallSourceInfo(
|
||||
packageName).getInstallingPackageName();
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
Slog.w(TAG, "Package not found " + packageName);
|
||||
}
|
||||
|
||||
@@ -152,9 +152,10 @@ public class SystemAppUpdateTracker {
|
||||
void onPackageUpdateFinished(String packageName, int uid) {
|
||||
try {
|
||||
if ((!mUpdatedApps.contains(packageName)) && isUpdatedSystemApp(packageName)) {
|
||||
int userId = UserHandle.getUserId(uid);
|
||||
// If a system app is updated, verify that it has an installer-on-record.
|
||||
String installingPackageName = mLocaleManagerService.getInstallingPackageName(
|
||||
packageName);
|
||||
packageName, userId);
|
||||
if (installingPackageName == null) {
|
||||
// We want to broadcast the locales info to the installer.
|
||||
// If this app does not have an installer then do nothing.
|
||||
@@ -162,7 +163,6 @@ public class SystemAppUpdateTracker {
|
||||
}
|
||||
|
||||
try {
|
||||
int userId = UserHandle.getUserId(uid);
|
||||
// Fetch the app-specific locales.
|
||||
// If non-empty then send the info to the installer.
|
||||
LocaleList appLocales = mLocaleManagerService.getApplicationLocales(
|
||||
|
||||
@@ -105,6 +105,7 @@ public class LocaleManagerServiceTest {
|
||||
mMockPackageManager = mock(PackageManager.class);
|
||||
mMockPackageMonitor = mock(PackageMonitor.class);
|
||||
|
||||
doReturn(mMockContext).when(mMockContext).createContextAsUser(any(), anyInt());
|
||||
// For unit tests, set the default installer info
|
||||
doReturn(DEFAULT_INSTALL_SOURCE_INFO).when(mMockPackageManager)
|
||||
.getInstallSourceInfo(anyString());
|
||||
|
||||
@@ -131,6 +131,7 @@ public class SystemAppUpdateTrackerTest {
|
||||
doReturn(mMockPackageManager).when(mMockContext).getPackageManager();
|
||||
doReturn(InstrumentationRegistry.getContext().getContentResolver())
|
||||
.when(mMockContext).getContentResolver();
|
||||
doReturn(mMockContext).when(mMockContext).createContextAsUser(any(), anyInt());
|
||||
|
||||
mStoragefile = new AtomicFile(new File(
|
||||
Environment.getExternalStorageDirectory(), "systemUpdateUnitTests.xml"));
|
||||
|
||||
Reference in New Issue
Block a user