|
20 | 20 | import android.graphics.Color; |
21 | 21 | import android.graphics.Typeface; |
22 | 22 | import android.hardware.SensorManager; |
| 23 | +import android.os.Build; |
23 | 24 | import android.util.Pair; |
24 | 25 | import android.view.Gravity; |
25 | 26 | import android.view.View; |
@@ -1098,7 +1099,7 @@ private void reload() { |
1098 | 1099 | if (!mIsReceiverRegistered) { |
1099 | 1100 | IntentFilter filter = new IntentFilter(); |
1100 | 1101 | filter.addAction(getReloadAppAction(mApplicationContext)); |
1101 | | - mApplicationContext.registerReceiver(mReloadAppBroadcastReceiver, filter); |
| 1102 | + compatRegisterReceiver(mApplicationContext, mReloadAppBroadcastReceiver, filter, true); |
1102 | 1103 | mIsReceiverRegistered = true; |
1103 | 1104 | } |
1104 | 1105 |
|
@@ -1214,4 +1215,21 @@ public void setPackagerLocationCustomizer( |
1214 | 1215 |
|
1215 | 1216 | return mSurfaceDelegateFactory.createSurfaceDelegate(moduleName); |
1216 | 1217 | } |
| 1218 | + |
| 1219 | + /** |
| 1220 | + * Starting with Android 14, apps and services that target Android 14 and use context-registered |
| 1221 | + * receivers are required to specify a flag to indicate whether or not the receiver should be |
| 1222 | + * exported to all other apps on the device: either RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED |
| 1223 | + * |
| 1224 | + * <p>https://developer.android.com/about/versions/14/behavior-changes-14#runtime-receivers-exported |
| 1225 | + */ |
| 1226 | + private void compatRegisterReceiver( |
| 1227 | + Context context, BroadcastReceiver receiver, IntentFilter filter, boolean exported) { |
| 1228 | + if (Build.VERSION.SDK_INT >= 34 && context.getApplicationInfo().targetSdkVersion >= 34) { |
| 1229 | + context.registerReceiver( |
| 1230 | + receiver, filter, exported ? Context.RECEIVER_EXPORTED : Context.RECEIVER_NOT_EXPORTED); |
| 1231 | + } else { |
| 1232 | + context.registerReceiver(receiver, filter); |
| 1233 | + } |
| 1234 | + } |
1217 | 1235 | } |
0 commit comments