[Safer intents] Credentials

To avoid implicit intents, make intents launch explicitly.

Bug: 323061508
Test: build
Change-Id: I236b6214e761574c82a81b4a7e068f617eae5e9d
This commit is contained in:
Jason Chiu
2024-03-25 18:02:41 +08:00
parent 67bfb4141f
commit 7f344f53f6
3 changed files with 5 additions and 0 deletions

View File

@@ -117,6 +117,7 @@ public class MonitoringCertInfoActivity extends Activity implements OnClickListe
@Override
public void onClick(DialogInterface dialog, int which) {
Intent intent = new Intent(android.provider.Settings.ACTION_TRUSTED_CREDENTIALS_USER);
intent.setPackage(getPackageName());
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtra(TrustedCredentialsSettings.ARG_SHOW_NEW_FOR_USER, mUserId);
startActivity(intent);

View File

@@ -139,6 +139,7 @@ public final class CredentialStorage extends FragmentActivity {
}
final Intent installIntent = new Intent(ACTION_INSTALL)
.setPackage(getPackageName())
.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT)
.putExtras(bundle);
startActivityAsUser(installIntent, new UserHandle(dstUserId));

View File

@@ -41,6 +41,8 @@ import com.google.android.setupdesign.util.ThemeHelper;
*/
public class InstallCaCertificateWarning extends Activity {
private static final String CERT_INSTALLER_PACKAGE_NAME = "com.android.certinstaller";
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -79,6 +81,7 @@ public class InstallCaCertificateWarning extends Activity {
return v -> {
final Intent intent = new Intent();
intent.setAction(Credentials.INSTALL_ACTION);
intent.setPackage(CERT_INSTALLER_PACKAGE_NAME);
intent.putExtra(Credentials.EXTRA_CERTIFICATE_USAGE, Credentials.CERTIFICATE_USAGE_CA);
startActivity(intent);
finish();