Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 76b41e00 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Using the lock to obtain mRemoteStatusReceiver." into rvc-dev

parents 0b35eb55 221cd08d
Loading
Loading
Loading
Loading
+14 −7
Original line number Original line Diff line number Diff line
@@ -2822,8 +2822,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
                        }
                        }
                        case IDataLoaderStatusListener.DATA_LOADER_UNAVAILABLE: {
                        case IDataLoaderStatusListener.DATA_LOADER_UNAVAILABLE: {
                            // Don't fail or commit the session. Allow caller to commit again.
                            // Don't fail or commit the session. Allow caller to commit again.
                            sendPendingStreaming(mContext, mRemoteStatusReceiver, sessionId,
                            sendPendingStreaming("DataLoader unavailable");
                                    "DataLoader unavailable");
                            break;
                            break;
                        }
                        }
                        case IDataLoaderStatusListener.DATA_LOADER_UNRECOVERABLE:
                        case IDataLoaderStatusListener.DATA_LOADER_UNRECOVERABLE:
@@ -2835,8 +2834,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
                } catch (RemoteException e) {
                } catch (RemoteException e) {
                    // In case of streaming failure we don't want to fail or commit the session.
                    // In case of streaming failure we don't want to fail or commit the session.
                    // Just return from this method and allow caller to commit again.
                    // Just return from this method and allow caller to commit again.
                    sendPendingStreaming(mContext, mRemoteStatusReceiver, sessionId,
                    sendPendingStreaming(e.getMessage());
                            e.getMessage());
                }
                }
            }
            }
        };
        };
@@ -3196,8 +3194,17 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
        }
        }
    }
    }


    private static void sendPendingStreaming(Context context, IntentSender target, int sessionId,
    private void sendPendingStreaming(@Nullable String cause) {
            @Nullable String cause) {
        final IntentSender statusReceiver;
        synchronized (mLock) {
            statusReceiver = mRemoteStatusReceiver;
        }

        if (statusReceiver == null) {
            Slog.e(TAG, "Missing receiver for pending streaming status.");
            return;
        }

        final Intent intent = new Intent();
        final Intent intent = new Intent();
        intent.putExtra(PackageInstaller.EXTRA_SESSION_ID, sessionId);
        intent.putExtra(PackageInstaller.EXTRA_SESSION_ID, sessionId);
        intent.putExtra(PackageInstaller.EXTRA_STATUS, PackageInstaller.STATUS_PENDING_STREAMING);
        intent.putExtra(PackageInstaller.EXTRA_STATUS, PackageInstaller.STATUS_PENDING_STREAMING);
@@ -3208,7 +3215,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
            intent.putExtra(PackageInstaller.EXTRA_STATUS_MESSAGE, "Staging Image Not Ready");
            intent.putExtra(PackageInstaller.EXTRA_STATUS_MESSAGE, "Staging Image Not Ready");
        }
        }
        try {
        try {
            target.sendIntent(context, 0, intent, null, null);
            statusReceiver.sendIntent(mContext, 0, intent, null, null);
        } catch (IntentSender.SendIntentException ignored) {
        } catch (IntentSender.SendIntentException ignored) {
        }
        }
    }
    }