Loading services/core/java/com/android/server/pm/PackageInstallerSession.java +22 −10 Original line number Diff line number Diff line Loading @@ -1391,7 +1391,8 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub { userId); } synchronized (mMetrics) { mMetrics.onDeveloperVerificationBindStarted(); mMetrics.onDeveloperVerificationBindStarted( mDeveloperVerifierController.getVerifierUidIfBound(userId)); } } } Loading Loading @@ -3201,9 +3202,9 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub { * Called by the VerifierController to indicate that the verifier has been connected. Only * used for metrics logging for now. */ public void onConnectionEstablished(int verifierUid) { public void onConnectionEstablished() { synchronized (mMetrics) { mMetrics.onDeveloperVerifierConnectionEstablished(verifierUid); mMetrics.onDeveloperVerifierConnectionEstablished(); } } Loading Loading @@ -3425,7 +3426,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub { private void maybeSendUserActionForVerification(boolean blockingFailure, @Nullable PersistableBundle extensionResponse) { Intent intent = getUserNotificationIntent(); if (shouldSendUserNotificationIntent(blockingFailure)) { if (shouldSendUserActionForVerification(blockingFailure)) { mVerificationUserActionNeeded = true; sendOnUserActionRequired(mContext, getRemoteStatusReceiver(), sessionId, intent); Loading Loading @@ -3453,24 +3454,35 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub { } /** * User will be notified about a failed or incomplete install in the following scenarios: * 1. If it's a non-blocking failure and the installer targets Baklava or above * 2. If the installer targets less than Baklava and the installer is not a privileged app. * User will be notified about a failed or incomplete developer verification in the * following scenarios: * 1. The installer is the system package installer. * 2. If it's a non-blocking failure and the installer targets Baklava or above. * 3. If the installer targets less than Baklava and the installer is not a privileged app. * For other cases, the installer will receive a failure status code in its IntentSender */ private boolean shouldSendUserNotificationIntent(boolean blockingFailure) { private boolean shouldSendUserActionForVerification(boolean blockingFailure) { final Computer snapshot = mPm.snapshotComputer(); final String installerPackageName; synchronized (mLock) { installerPackageName = mInstallSource.mInstallerPackageName; } if (installerPackageName == null) { // This can only happen if the installer intentionally set the installer package // name of the session to be null. return false; } ApplicationInfo installerInfo = snapshot.getApplicationInfo( installerPackageName, 0, userId); if (installerInfo == null) { Log.w(TAG, "Could not find ApplicationInfo for " + installerPackageName); Log.w(TAG, "Could not find ApplicationInfo for " + installerPackageName); return false; } // If the installer is the system package installer, always notify user for developer // verification failures or issues. if (installerPackageName.equals(mPm.getPackageInstallerPackageName())) { return true; } if (CompatChanges.isChangeEnabled(NOTIFY_USER_VERIFICATION_INCOMPLETE, getInstallerUid())) { Loading services/core/java/com/android/server/pm/SessionMetrics.java +9 −7 Original line number Diff line number Diff line Loading @@ -197,13 +197,13 @@ final class SessionMetrics { reportStats(); } public void onDeveloperVerificationBindStarted() { public void onDeveloperVerificationBindStarted(int verifierUid) { mDeveloperVerifierBindStartedMillis = System.currentTimeMillis(); mDeveloperVerifierUid = verifierUid; } public void onDeveloperVerifierConnectionEstablished(int verifierUid) { public void onDeveloperVerifierConnectionEstablished() { mDeveloperVerifierConnectedMillis = System.currentTimeMillis(); mDeveloperVerifierUid = verifierUid; } public void onDeveloperVerificationRequestSent() { Loading Loading @@ -234,7 +234,7 @@ final class SessionMetrics { final long responseReceivedMillis = System.currentTimeMillis(); if (mDeveloperVerifierRequestSentMillis != 0 && mDeveloperVerifierRetryRequestSentMillis == 0) { mDeveloperVerifierRequestSentMillis = mDeveloperVerificationDurationMillis = responseReceivedMillis - mDeveloperVerifierRequestSentMillis; } else if (mDeveloperVerifierRetryRequestSentMillis != 0) { // Calculate the last retry duration Loading Loading @@ -278,7 +278,9 @@ final class SessionMetrics { mInternalInstallationFinished - mInternalInstallationStarted; final long sessionLifetimeMillis = mFinishedMillis - mCreatedMillis; final long developerVerifierConnectionDurationMillis = mDeveloperVerifierConnectedMillis - mDeveloperVerifierBindStartedMillis; mDeveloperVerifierConnectedMillis == 0 ? 0 // Binding was already established before ths installation : mDeveloperVerifierConnectedMillis - mDeveloperVerifierBindStartedMillis; final long developerVerificationPrepDurationMillis = mDeveloperVerifierRequestSentMillis - mDeveloperVerifierBindStartedMillis; // Do this on a handler so that we don't block anything critical Loading Loading @@ -308,7 +310,7 @@ final class SessionMetrics { mIsPreapproval, mIsUnarchive, mIsAutoInstallDependenciesEnabled, mApksSizeBytes, // TODO: compute apks size bytes mApksSizeBytes, // TODO(b/418283971): compute apks size bytes getTranslatedStatusCodeForStats(installStatusToPublicStatus(mStatusCode)), mWasUserActionIntentSent, mIsExpired, Loading services/core/java/com/android/server/pm/verify/developer/DeveloperVerifierController.java +15 −1 Original line number Diff line number Diff line Loading @@ -184,6 +184,20 @@ public class DeveloperVerifierController { return mDeveloperVerificationServiceProvider.getPackageName(); } /** * Return the UID of the verifier that is bound to the system. If the verifier has not been * bound, return INVALID_UID. */ public int getVerifierUidIfBound(int userId) { synchronized (mRemoteServices) { var remoteService = mRemoteServices.get(userId); if (remoteService == null) { return INVALID_UID; } return remoteService.getUid(); } } /** * Called to start querying and binding to a qualified verifier agent. * Loading Loading @@ -247,7 +261,7 @@ public class DeveloperVerifierController { Slog.i(TAG, "Verifier " + verifierPackageName + " is connected" + " on user " + userId); // Logging the success of connecting to the verifier. callback.onConnectionEstablished(verifierUid); callback.onConnectionEstablished(); // Aggressively auto-disconnect until verification requests are sent out startAutoDisconnectCountdown( remoteServiceWrapper.getAutoDisconnectCallback()); Loading services/tests/PackageManagerServiceTests/server/src/com/android/server/pm/verify/developer/DeveloperVerifierControllerTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -197,7 +197,7 @@ public class DeveloperVerifierControllerTest { // Verify that the countdown to auto-disconnect has started ArgumentCaptor<Runnable> runnableCaptor = ArgumentCaptor.forClass(Runnable.class); callbacks.onConnected(mMockService); verify(mSessionCallback, times(1)).onConnectionEstablished(anyInt()); verify(mSessionCallback, times(1)).onConnectionEstablished(); verify(mInjector, times(1)).removeCallbacks(eq(mHandler), runnableCaptor.capture()); Runnable autoDisconnectRunnable = runnableCaptor.getValue(); Loading Loading
services/core/java/com/android/server/pm/PackageInstallerSession.java +22 −10 Original line number Diff line number Diff line Loading @@ -1391,7 +1391,8 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub { userId); } synchronized (mMetrics) { mMetrics.onDeveloperVerificationBindStarted(); mMetrics.onDeveloperVerificationBindStarted( mDeveloperVerifierController.getVerifierUidIfBound(userId)); } } } Loading Loading @@ -3201,9 +3202,9 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub { * Called by the VerifierController to indicate that the verifier has been connected. Only * used for metrics logging for now. */ public void onConnectionEstablished(int verifierUid) { public void onConnectionEstablished() { synchronized (mMetrics) { mMetrics.onDeveloperVerifierConnectionEstablished(verifierUid); mMetrics.onDeveloperVerifierConnectionEstablished(); } } Loading Loading @@ -3425,7 +3426,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub { private void maybeSendUserActionForVerification(boolean blockingFailure, @Nullable PersistableBundle extensionResponse) { Intent intent = getUserNotificationIntent(); if (shouldSendUserNotificationIntent(blockingFailure)) { if (shouldSendUserActionForVerification(blockingFailure)) { mVerificationUserActionNeeded = true; sendOnUserActionRequired(mContext, getRemoteStatusReceiver(), sessionId, intent); Loading Loading @@ -3453,24 +3454,35 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub { } /** * User will be notified about a failed or incomplete install in the following scenarios: * 1. If it's a non-blocking failure and the installer targets Baklava or above * 2. If the installer targets less than Baklava and the installer is not a privileged app. * User will be notified about a failed or incomplete developer verification in the * following scenarios: * 1. The installer is the system package installer. * 2. If it's a non-blocking failure and the installer targets Baklava or above. * 3. If the installer targets less than Baklava and the installer is not a privileged app. * For other cases, the installer will receive a failure status code in its IntentSender */ private boolean shouldSendUserNotificationIntent(boolean blockingFailure) { private boolean shouldSendUserActionForVerification(boolean blockingFailure) { final Computer snapshot = mPm.snapshotComputer(); final String installerPackageName; synchronized (mLock) { installerPackageName = mInstallSource.mInstallerPackageName; } if (installerPackageName == null) { // This can only happen if the installer intentionally set the installer package // name of the session to be null. return false; } ApplicationInfo installerInfo = snapshot.getApplicationInfo( installerPackageName, 0, userId); if (installerInfo == null) { Log.w(TAG, "Could not find ApplicationInfo for " + installerPackageName); Log.w(TAG, "Could not find ApplicationInfo for " + installerPackageName); return false; } // If the installer is the system package installer, always notify user for developer // verification failures or issues. if (installerPackageName.equals(mPm.getPackageInstallerPackageName())) { return true; } if (CompatChanges.isChangeEnabled(NOTIFY_USER_VERIFICATION_INCOMPLETE, getInstallerUid())) { Loading
services/core/java/com/android/server/pm/SessionMetrics.java +9 −7 Original line number Diff line number Diff line Loading @@ -197,13 +197,13 @@ final class SessionMetrics { reportStats(); } public void onDeveloperVerificationBindStarted() { public void onDeveloperVerificationBindStarted(int verifierUid) { mDeveloperVerifierBindStartedMillis = System.currentTimeMillis(); mDeveloperVerifierUid = verifierUid; } public void onDeveloperVerifierConnectionEstablished(int verifierUid) { public void onDeveloperVerifierConnectionEstablished() { mDeveloperVerifierConnectedMillis = System.currentTimeMillis(); mDeveloperVerifierUid = verifierUid; } public void onDeveloperVerificationRequestSent() { Loading Loading @@ -234,7 +234,7 @@ final class SessionMetrics { final long responseReceivedMillis = System.currentTimeMillis(); if (mDeveloperVerifierRequestSentMillis != 0 && mDeveloperVerifierRetryRequestSentMillis == 0) { mDeveloperVerifierRequestSentMillis = mDeveloperVerificationDurationMillis = responseReceivedMillis - mDeveloperVerifierRequestSentMillis; } else if (mDeveloperVerifierRetryRequestSentMillis != 0) { // Calculate the last retry duration Loading Loading @@ -278,7 +278,9 @@ final class SessionMetrics { mInternalInstallationFinished - mInternalInstallationStarted; final long sessionLifetimeMillis = mFinishedMillis - mCreatedMillis; final long developerVerifierConnectionDurationMillis = mDeveloperVerifierConnectedMillis - mDeveloperVerifierBindStartedMillis; mDeveloperVerifierConnectedMillis == 0 ? 0 // Binding was already established before ths installation : mDeveloperVerifierConnectedMillis - mDeveloperVerifierBindStartedMillis; final long developerVerificationPrepDurationMillis = mDeveloperVerifierRequestSentMillis - mDeveloperVerifierBindStartedMillis; // Do this on a handler so that we don't block anything critical Loading Loading @@ -308,7 +310,7 @@ final class SessionMetrics { mIsPreapproval, mIsUnarchive, mIsAutoInstallDependenciesEnabled, mApksSizeBytes, // TODO: compute apks size bytes mApksSizeBytes, // TODO(b/418283971): compute apks size bytes getTranslatedStatusCodeForStats(installStatusToPublicStatus(mStatusCode)), mWasUserActionIntentSent, mIsExpired, Loading
services/core/java/com/android/server/pm/verify/developer/DeveloperVerifierController.java +15 −1 Original line number Diff line number Diff line Loading @@ -184,6 +184,20 @@ public class DeveloperVerifierController { return mDeveloperVerificationServiceProvider.getPackageName(); } /** * Return the UID of the verifier that is bound to the system. If the verifier has not been * bound, return INVALID_UID. */ public int getVerifierUidIfBound(int userId) { synchronized (mRemoteServices) { var remoteService = mRemoteServices.get(userId); if (remoteService == null) { return INVALID_UID; } return remoteService.getUid(); } } /** * Called to start querying and binding to a qualified verifier agent. * Loading Loading @@ -247,7 +261,7 @@ public class DeveloperVerifierController { Slog.i(TAG, "Verifier " + verifierPackageName + " is connected" + " on user " + userId); // Logging the success of connecting to the verifier. callback.onConnectionEstablished(verifierUid); callback.onConnectionEstablished(); // Aggressively auto-disconnect until verification requests are sent out startAutoDisconnectCountdown( remoteServiceWrapper.getAutoDisconnectCallback()); Loading
services/tests/PackageManagerServiceTests/server/src/com/android/server/pm/verify/developer/DeveloperVerifierControllerTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -197,7 +197,7 @@ public class DeveloperVerifierControllerTest { // Verify that the countdown to auto-disconnect has started ArgumentCaptor<Runnable> runnableCaptor = ArgumentCaptor.forClass(Runnable.class); callbacks.onConnected(mMockService); verify(mSessionCallback, times(1)).onConnectionEstablished(anyInt()); verify(mSessionCallback, times(1)).onConnectionEstablished(); verify(mInjector, times(1)).removeCallbacks(eq(mHandler), runnableCaptor.capture()); Runnable autoDisconnectRunnable = runnableCaptor.getValue(); Loading