Skip to content

Commit

Permalink
chore(AndroidExecutors): clean up outdated compat function (#43958)
Browse files Browse the repository at this point in the history
Summary:
this PR cleans up an outdated compatibility function in AndroidExecutors. the function in question was checking whether the code was running on Gingerbread or later - this is no longer needed, as RN requires Marshmallow or later.

## Changelog:

[INTERNAL] [FIXED] - Clean up outdated compatibility function

Pull Request resolved: #43958

Test Plan: this should work as normal.

Reviewed By: cortinico

Differential Revision: D55877661

Pulled By: dmytrorykun

fbshipit-source-id: 02eac50b0898d683f6abf731bf8e438ae4219a41
  • Loading branch information
Rexogamer authored and facebook-github-bot committed Apr 11, 2024
1 parent 77efd19 commit 9433506
Showing 1 changed file with 2 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

package com.facebook.react.runtime.internal.bolts;

import android.annotation.SuppressLint;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import androidx.annotation.NonNull;
Expand Down Expand Up @@ -78,7 +76,7 @@ private AndroidExecutors() {
TimeUnit.SECONDS,
new LinkedBlockingQueue<Runnable>());

allowCoreThreadTimeout(executor, true);
executor.allowCoreThreadTimeOut(true);

return executor;
}
Expand All @@ -104,27 +102,11 @@ private AndroidExecutors() {
new LinkedBlockingQueue<Runnable>(),
threadFactory);

allowCoreThreadTimeout(executor, true);
executor.allowCoreThreadTimeOut(true);

return executor;
}

/**
* Compatibility helper function for {@link
* java.util.concurrent.ThreadPoolExecutor#allowCoreThreadTimeOut(boolean)}
*
* <p>Only available on android-9+.
*
* @param executor the {@link java.util.concurrent.ThreadPoolExecutor}
* @param value true if should time out, else false
*/
@SuppressLint("NewApi")
public static void allowCoreThreadTimeout(@NonNull ThreadPoolExecutor executor, boolean value) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
executor.allowCoreThreadTimeOut(value);
}
}

/**
* An {@link java.util.concurrent.Executor} that schedules tasks to run asynchronously on the UI
* thread.
Expand Down

0 comments on commit 9433506

Please sign in to comment.