|
19 | 19 | import android.content.pm.PackageManager;
|
20 | 20 | import android.graphics.Typeface;
|
21 | 21 | import android.hardware.SensorManager;
|
| 22 | +import android.os.Build; |
22 | 23 | import android.util.Pair;
|
23 | 24 | import android.view.Gravity;
|
24 | 25 | import android.view.View;
|
@@ -1022,7 +1023,7 @@ private void reload() {
|
1022 | 1023 | if (!mIsReceiverRegistered) {
|
1023 | 1024 | IntentFilter filter = new IntentFilter();
|
1024 | 1025 | filter.addAction(getReloadAppAction(mApplicationContext));
|
1025 |
| - mApplicationContext.registerReceiver(mReloadAppBroadcastReceiver, filter); |
| 1026 | + compatRegisterReceiver(mApplicationContext, mReloadAppBroadcastReceiver, filter, true); |
1026 | 1027 | mIsReceiverRegistered = true;
|
1027 | 1028 | }
|
1028 | 1029 |
|
@@ -1120,4 +1121,21 @@ public void setPackagerLocationCustomizer(
|
1120 | 1121 |
|
1121 | 1122 | return mSurfaceDelegateFactory.createSurfaceDelegate(moduleName);
|
1122 | 1123 | }
|
| 1124 | + |
| 1125 | + /** |
| 1126 | + * Starting with Android 14, apps and services that target Android 14 and use context-registered |
| 1127 | + * receivers are required to specify a flag to indicate whether or not the receiver should be |
| 1128 | + * exported to all other apps on the device: either RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED |
| 1129 | + * |
| 1130 | + * <p>https://developer.android.com/about/versions/14/behavior-changes-14#runtime-receivers-exported |
| 1131 | + */ |
| 1132 | + private void compatRegisterReceiver( |
| 1133 | + Context context, BroadcastReceiver receiver, IntentFilter filter, boolean exported) { |
| 1134 | + if (Build.VERSION.SDK_INT >= 34 && context.getApplicationInfo().targetSdkVersion >= 34) { |
| 1135 | + context.registerReceiver( |
| 1136 | + receiver, filter, exported ? Context.RECEIVER_EXPORTED : Context.RECEIVER_NOT_EXPORTED); |
| 1137 | + } else { |
| 1138 | + context.registerReceiver(receiver, filter); |
| 1139 | + } |
| 1140 | + } |
1123 | 1141 | }
|
0 commit comments