mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
[LOCAL] For targeting SDK 34 - Added RECEIVER_EXPORTED/RECEIVER_NOT_EXPORTED flag support in DevSupportManagerBase
This commit is contained in:
+19
-1
@@ -20,6 +20,7 @@ import android.content.pm.PackageManager;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Typeface;
|
||||
import android.hardware.SensorManager;
|
||||
import android.os.Build;
|
||||
import android.util.Pair;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
@@ -1098,7 +1099,7 @@ public abstract class DevSupportManagerBase implements DevSupportManager {
|
||||
if (!mIsReceiverRegistered) {
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.addAction(getReloadAppAction(mApplicationContext));
|
||||
mApplicationContext.registerReceiver(mReloadAppBroadcastReceiver, filter);
|
||||
compatRegisterReceiver(mApplicationContext, mReloadAppBroadcastReceiver, filter, true);
|
||||
mIsReceiverRegistered = true;
|
||||
}
|
||||
|
||||
@@ -1214,4 +1215,21 @@ public abstract class DevSupportManagerBase implements DevSupportManager {
|
||||
|
||||
return mSurfaceDelegateFactory.createSurfaceDelegate(moduleName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Starting with Android 14, apps and services that target Android 14 and use context-registered
|
||||
* receivers are required to specify a flag to indicate whether or not the receiver should be
|
||||
* exported to all other apps on the device: either RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED
|
||||
*
|
||||
* <p>https://developer.android.com/about/versions/14/behavior-changes-14#runtime-receivers-exported
|
||||
*/
|
||||
private void compatRegisterReceiver(
|
||||
Context context, BroadcastReceiver receiver, IntentFilter filter, boolean exported) {
|
||||
if (Build.VERSION.SDK_INT >= 34 && context.getApplicationInfo().targetSdkVersion >= 34) {
|
||||
context.registerReceiver(
|
||||
receiver, filter, exported ? Context.RECEIVER_EXPORTED : Context.RECEIVER_NOT_EXPORTED);
|
||||
} else {
|
||||
context.registerReceiver(receiver, filter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user