Merge "[pm/metrics][7/n] log verification failures"
This commit is contained in:
committed by
Android (Google) Code Review
commit
a1641963f3
@@ -16,6 +16,8 @@
|
||||
|
||||
package com.android.server.pm;
|
||||
|
||||
import static android.os.Process.INVALID_UID;
|
||||
|
||||
import android.annotation.IntDef;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.parsing.ApkLiteParseUtils;
|
||||
@@ -209,4 +211,35 @@ final class PackageMetrics {
|
||||
deleteFlags, PackageManager.DELETE_SUCCEEDED, info.mIsRemovedPackageSystemUpdate,
|
||||
!info.mRemovedForAllUsers);
|
||||
}
|
||||
|
||||
public static void onVerificationFailed(VerifyingSession verifyingSession) {
|
||||
FrameworkStatsLog.write(FrameworkStatsLog.PACKAGE_INSTALLATION_SESSION_REPORTED,
|
||||
verifyingSession.getSessionId() /* session_id */,
|
||||
null /* package_name */,
|
||||
INVALID_UID /* uid */,
|
||||
null /* user_ids */,
|
||||
null /* user_types */,
|
||||
null /* original_user_ids */,
|
||||
null /* original_user_types */,
|
||||
verifyingSession.getRet() /* public_return_code */,
|
||||
0 /* internal_error_code */,
|
||||
0 /* apks_size_bytes */,
|
||||
0 /* version_code */,
|
||||
null /* install_steps */,
|
||||
null /* step_duration_millis */,
|
||||
0 /* total_duration_millis */,
|
||||
0 /* install_flags */,
|
||||
verifyingSession.getInstallerPackageUid() /* installer_package_uid */,
|
||||
INVALID_UID /* original_installer_package_uid */,
|
||||
verifyingSession.getDataLoaderType() /* data_loader_type */,
|
||||
verifyingSession.getUserActionRequiredType() /* user_action_required_type */,
|
||||
verifyingSession.isInstant() /* is_instant */,
|
||||
false /* is_replace */,
|
||||
false /* is_system */,
|
||||
verifyingSession.isInherit() /* is_inherit */,
|
||||
false /* is_installing_existing_as_user */,
|
||||
false /* is_move_install */,
|
||||
verifyingSession.isStaged() /* is_staged */
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ final class VerificationUtils {
|
||||
|
||||
VerificationUtils.broadcastPackageVerified(verificationId, originUri,
|
||||
verificationCode, null,
|
||||
verifyingSession.mDataLoaderType, verifyingSession.getUser(),
|
||||
verifyingSession.getDataLoaderType(), verifyingSession.getUser(),
|
||||
pms.mContext);
|
||||
|
||||
if (state.isInstallAllowed()) {
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.android.server.pm;
|
||||
import static android.content.Intent.EXTRA_LONG_VERSION_CODE;
|
||||
import static android.content.Intent.EXTRA_PACKAGE_NAME;
|
||||
import static android.content.Intent.EXTRA_VERSION_CODE;
|
||||
import static android.content.pm.PackageInstaller.SessionParams.MODE_INHERIT_EXISTING;
|
||||
import static android.content.pm.PackageManager.EXTRA_VERIFICATION_ID;
|
||||
import static android.content.pm.PackageManager.INSTALL_SUCCEEDED;
|
||||
import static android.content.pm.PackageManager.MATCH_DEBUG_TRIAGED_MISSING;
|
||||
@@ -114,30 +115,32 @@ final class VerifyingSession {
|
||||
|
||||
final OriginInfo mOriginInfo;
|
||||
final IPackageInstallObserver2 mObserver;
|
||||
final int mInstallFlags;
|
||||
private final int mInstallFlags;
|
||||
@NonNull
|
||||
final InstallSource mInstallSource;
|
||||
final String mPackageAbiOverride;
|
||||
final VerificationInfo mVerificationInfo;
|
||||
final SigningDetails mSigningDetails;
|
||||
private final InstallSource mInstallSource;
|
||||
private final String mPackageAbiOverride;
|
||||
private final VerificationInfo mVerificationInfo;
|
||||
private final SigningDetails mSigningDetails;
|
||||
@Nullable
|
||||
MultiPackageVerifyingSession mParentVerifyingSession;
|
||||
final long mRequiredInstalledVersionCode;
|
||||
final int mDataLoaderType;
|
||||
final int mSessionId;
|
||||
final boolean mUserActionRequired;
|
||||
|
||||
private final long mRequiredInstalledVersionCode;
|
||||
private final int mDataLoaderType;
|
||||
private final int mSessionId;
|
||||
private final boolean mUserActionRequired;
|
||||
private final int mUserActionRequiredType;
|
||||
private boolean mWaitForVerificationToComplete;
|
||||
private boolean mWaitForIntegrityVerificationToComplete;
|
||||
private boolean mWaitForEnableRollbackToComplete;
|
||||
private int mRet = PackageManager.INSTALL_SUCCEEDED;
|
||||
private String mErrorMessage = null;
|
||||
private final boolean mIsInherit;
|
||||
private final boolean mIsStaged;
|
||||
|
||||
final PackageLite mPackageLite;
|
||||
private final PackageLite mPackageLite;
|
||||
private final UserHandle mUser;
|
||||
@NonNull
|
||||
final PackageManagerService mPm;
|
||||
final InstallPackageHelper mInstallPackageHelper;
|
||||
private final PackageManagerService mPm;
|
||||
private final InstallPackageHelper mInstallPackageHelper;
|
||||
|
||||
VerifyingSession(UserHandle user, File stagedDir, IPackageInstallObserver2 observer,
|
||||
PackageInstaller.SessionParams sessionParams, InstallSource installSource,
|
||||
@@ -164,6 +167,9 @@ final class VerifyingSession {
|
||||
mSessionId = sessionId;
|
||||
mPackageLite = lite;
|
||||
mUserActionRequired = userActionRequired;
|
||||
mUserActionRequiredType = sessionParams.requireUserAction;
|
||||
mIsInherit = sessionParams.mode == MODE_INHERIT_EXISTING;
|
||||
mIsStaged = sessionParams.isStaged;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -186,7 +192,7 @@ final class VerifyingSession {
|
||||
// Perform package verification and enable rollback (unless we are simply moving the
|
||||
// package).
|
||||
if (!mOriginInfo.mExisting) {
|
||||
if ((mInstallFlags & PackageManager.INSTALL_APEX) == 0) {
|
||||
if (!isApex()) {
|
||||
// TODO(b/182426975): treat APEX as APK when APK verification is concerned
|
||||
sendApkVerificationRequest(pkgLite);
|
||||
}
|
||||
@@ -674,10 +680,9 @@ final class VerifyingSession {
|
||||
}
|
||||
|
||||
final int installerUid = mVerificationInfo == null ? -1 : mVerificationInfo.mInstallerUid;
|
||||
final int installFlags = mInstallFlags;
|
||||
|
||||
// Check if installing from ADB
|
||||
if ((installFlags & PackageManager.INSTALL_FROM_ADB) != 0) {
|
||||
if ((mInstallFlags & PackageManager.INSTALL_FROM_ADB) != 0) {
|
||||
boolean requestedDisableVerification =
|
||||
(mInstallFlags & PackageManager.INSTALL_DISABLE_VERIFICATION) != 0;
|
||||
return isAdbVerificationEnabled(pkgInfoLite, userId, requestedDisableVerification);
|
||||
@@ -685,8 +690,7 @@ final class VerifyingSession {
|
||||
|
||||
// only when not installed from ADB, skip verification for instant apps when
|
||||
// the installer and verifier are the same.
|
||||
if ((installFlags & PackageManager.INSTALL_INSTANT_APP) != 0
|
||||
&& mPm.mInstantAppInstallerActivity != null) {
|
||||
if (isInstant() && mPm.mInstantAppInstallerActivity != null) {
|
||||
String installerPackage = mPm.mInstantAppInstallerActivity.packageName;
|
||||
for (String requiredVerifierPackage : requiredVerifierPackages) {
|
||||
if (installerPackage.equals(requiredVerifierPackage)) {
|
||||
@@ -818,6 +822,9 @@ final class VerifyingSession {
|
||||
return;
|
||||
}
|
||||
sendVerificationCompleteNotification();
|
||||
if (mRet != INSTALL_SUCCEEDED) {
|
||||
PackageMetrics.onVerificationFailed(this);
|
||||
}
|
||||
}
|
||||
|
||||
private void sendVerificationCompleteNotification() {
|
||||
@@ -865,4 +872,28 @@ final class VerifyingSession {
|
||||
public UserHandle getUser() {
|
||||
return mUser;
|
||||
}
|
||||
public int getSessionId() {
|
||||
return mSessionId;
|
||||
}
|
||||
public int getDataLoaderType() {
|
||||
return mDataLoaderType;
|
||||
}
|
||||
public int getUserActionRequiredType() {
|
||||
return mUserActionRequiredType;
|
||||
}
|
||||
public boolean isInstant() {
|
||||
return (mInstallFlags & PackageManager.INSTALL_INSTANT_APP) != 0;
|
||||
}
|
||||
public boolean isInherit() {
|
||||
return mIsInherit;
|
||||
}
|
||||
public int getInstallerPackageUid() {
|
||||
return mInstallSource.mInstallerPackageUid;
|
||||
}
|
||||
public boolean isApex() {
|
||||
return (mInstallFlags & PackageManager.INSTALL_APEX) != 0;
|
||||
}
|
||||
public boolean isStaged() {
|
||||
return mIsStaged;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user