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

Commit 5226518e authored by Automerger Merge Worker's avatar Automerger Merge Worker
Browse files

Merge "Merge "Fix content capture session id collision bug" into rvc-dev am:...

Merge "Merge "Fix content capture session id collision bug" into rvc-dev am: dd9c140e am: 3618b46f am: a8122e5d" into rvc-qpr-dev-plus-aosp am: 81659831

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11829309

Change-Id: I4e62f93b804817ea3cfe45faa0fff7b6c20ec2c9
parents 72b7bb11 81659831
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -39,8 +39,8 @@ import com.android.internal.util.Preconditions;
import java.io.PrintWriter;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.Random;

/**
 * Session used when the Android a system-provided content capture service
@@ -50,7 +50,9 @@ public abstract class ContentCaptureSession implements AutoCloseable {

    private static final String TAG = ContentCaptureSession.class.getSimpleName();

    private static final Random sIdGenerator = new Random();
    // TODO(b/158778794): to make the session ids truly globally unique across
    //  processes, we may need to explore other options.
    private static final SecureRandom ID_GENERATOR = new SecureRandom();

    /**
     * Initial state, when there is no session.
@@ -622,7 +624,7 @@ public abstract class ContentCaptureSession implements AutoCloseable {
    private static int getRandomSessionId() {
        int id;
        do {
            id = sIdGenerator.nextInt();
            id = ID_GENERATOR.nextInt();
        } while (id == NO_SESSION_ID);
        return id;
    }