Fix the security vulnerability issue in AppLocalePickerActivity
Examine whether the packages is allowed to display app locales list when creating the AppLocalePickerActivity, and examine whether the target user is the same as the calling user.
Bug: 257954050
Test: Follows the test step listed in b/257954050#comment14
Change-Id: I2e25a308bcba6ea0edee89c7a78465f766bdbeac
Merged-In: I2e25a308bcba6ea0edee89c7a78465f766bdbeac
(cherry picked from commit 5d7d1665fe)
Merged-In: I2e25a308bcba6ea0edee89c7a78465f766bdbeac
This commit is contained in:
committed by
Android Build Coastguard Worker
parent
b420deb9b7
commit
211f81afe6
@@ -19,6 +19,7 @@ package com.android.settings.localepicker;
|
||||
import android.app.FragmentTransaction;
|
||||
import android.app.LocaleManager;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.LocaleList;
|
||||
@@ -34,6 +35,7 @@ import com.android.internal.app.LocalePickerWithRegion;
|
||||
import com.android.internal.app.LocaleStore;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.applications.AppInfoBase;
|
||||
import com.android.settings.applications.AppLocaleUtil;
|
||||
import com.android.settings.applications.appinfo.AppLocaleDetails;
|
||||
import com.android.settings.core.SettingsBaseActivity;
|
||||
|
||||
@@ -64,12 +66,17 @@ public class AppLocalePickerActivity extends SettingsBaseActivity
|
||||
}
|
||||
mContextAsUser = this;
|
||||
if (getIntent().hasExtra(AppInfoBase.ARG_PACKAGE_UID)) {
|
||||
int userId = getIntent().getIntExtra(AppInfoBase.ARG_PACKAGE_UID, -1);
|
||||
if (userId != -1) {
|
||||
UserHandle userHandle = UserHandle.getUserHandleForUid(userId);
|
||||
int uid = getIntent().getIntExtra(AppInfoBase.ARG_PACKAGE_UID, -1);
|
||||
if (uid != -1) {
|
||||
UserHandle userHandle = UserHandle.getUserHandleForUid(uid);
|
||||
mContextAsUser = createContextAsUser(userHandle, 0);
|
||||
}
|
||||
}
|
||||
if (!canDisplayLocaleUi() || mContextAsUser.getUserId() != UserHandle.myUserId()) {
|
||||
Log.w(TAG, "Not allow to display Locale Settings UI.");
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
setTitle(R.string.app_locale_picker_title);
|
||||
getActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
@@ -160,4 +167,10 @@ public class AppLocalePickerActivity extends SettingsBaseActivity
|
||||
.replace(R.id.content_frame, mLocalePickerWithRegion)
|
||||
.commit();
|
||||
}
|
||||
|
||||
private boolean canDisplayLocaleUi() {
|
||||
return AppLocaleUtil.canDisplayLocaleUi(mContextAsUser, mPackageName,
|
||||
mContextAsUser.getPackageManager().queryIntentActivities(
|
||||
AppLocaleUtil.LAUNCHER_ENTRY_INTENT, PackageManager.GET_META_DATA));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user