@@ -851,11 +851,16 @@ void doHandleMessage(Message msg) {
851851 + args .packageURI .toString ());
852852 state .setVerifierResponse (Binder .getCallingUid (),
853853 PackageManager .VERIFICATION_ALLOW_WITHOUT_SUFFICIENT );
854+ broadcastPackageVerified (verificationId , args .packageURI ,
855+ PackageManager .VERIFICATION_ALLOW );
854856 try {
855857 ret = args .copyApk (mContainerService , true );
856858 } catch (RemoteException e ) {
857859 Slog .e (TAG , "Could not contact the ContainerService" );
858860 }
861+ } else {
862+ broadcastPackageVerified (verificationId , args .packageURI ,
863+ PackageManager .VERIFICATION_REJECT );
859864 }
860865
861866 processPendingInstall (args , ret );
@@ -884,6 +889,8 @@ void doHandleMessage(Message msg) {
884889 int ret ;
885890 if (state .isInstallAllowed ()) {
886891 ret = PackageManager .INSTALL_FAILED_INTERNAL_ERROR ;
892+ broadcastPackageVerified (verificationId , args .packageURI ,
893+ response .code );
887894 try {
888895 ret = args .copyApk (mContainerService , true );
889896 } catch (RemoteException e ) {
@@ -5641,13 +5648,15 @@ public void extendVerificationTimeout(int id, int verificationCodeAtTimeout,
56415648 final PackageVerificationResponse response = new PackageVerificationResponse (
56425649 verificationCodeAtTimeout , Binder .getCallingUid ());
56435650
5644- if ((millisecondsToDelay > PackageManager .MAXIMUM_VERIFICATION_TIMEOUT )
5645- || (millisecondsToDelay < 0 )) {
5646- throw new IllegalArgumentException ("millisecondsToDelay is out of bounds." );
5651+ if (millisecondsToDelay > PackageManager .MAXIMUM_VERIFICATION_TIMEOUT ) {
5652+ millisecondsToDelay = PackageManager .MAXIMUM_VERIFICATION_TIMEOUT ;
5653+ }
5654+ if (millisecondsToDelay < 0 ) {
5655+ millisecondsToDelay = 0 ;
56475656 }
56485657 if ((verificationCodeAtTimeout != PackageManager .VERIFICATION_ALLOW )
5649- || (verificationCodeAtTimeout != PackageManager .VERIFICATION_REJECT )) {
5650- throw new IllegalArgumentException ( " verificationCodeAtTimeout is unknown." ) ;
5658+ && (verificationCodeAtTimeout != PackageManager .VERIFICATION_REJECT )) {
5659+ verificationCodeAtTimeout = PackageManager . VERIFICATION_REJECT ;
56515660 }
56525661
56535662 if ((state != null ) && !state .timeoutExtended ()) {
@@ -5660,6 +5669,17 @@ public void extendVerificationTimeout(int id, int verificationCodeAtTimeout,
56605669 }
56615670 }
56625671
5672+ private void broadcastPackageVerified (int verificationId , Uri packageUri ,
5673+ int verificationCode ) {
5674+ final Intent intent = new Intent (Intent .ACTION_PACKAGE_VERIFIED );
5675+ intent .setDataAndType (packageUri , PACKAGE_MIME_TYPE );
5676+ intent .addFlags (Intent .FLAG_GRANT_READ_URI_PERMISSION );
5677+ intent .putExtra (PackageManager .EXTRA_VERIFICATION_ID , verificationId );
5678+ intent .putExtra (PackageManager .EXTRA_VERIFICATION_RESULT , verificationCode );
5679+
5680+ mContext .sendBroadcast (intent , android .Manifest .permission .PACKAGE_VERIFICATION_AGENT );
5681+ }
5682+
56635683 private ComponentName matchComponentForVerifier (String packageName ,
56645684 List <ResolveInfo > receivers ) {
56655685 ActivityInfo targetReceiver = null ;
0 commit comments