|
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;
|
@@ -1142,7 +1143,7 @@ private void reload() {
|
1142 | 1143 | if (!mIsReceiverRegistered) {
|
1143 | 1144 | IntentFilter filter = new IntentFilter();
|
1144 | 1145 | filter.addAction(getReloadAppAction(mApplicationContext));
|
1145 |
| - mApplicationContext.registerReceiver(mReloadAppBroadcastReceiver, filter); |
| 1146 | + compatRegisterReceiver(mApplicationContext, mReloadAppBroadcastReceiver, filter, true); |
1146 | 1147 | mIsReceiverRegistered = true;
|
1147 | 1148 | }
|
1148 | 1149 |
|
@@ -1258,4 +1259,21 @@ public void setPackagerLocationCustomizer(
|
1258 | 1259 |
|
1259 | 1260 | return mSurfaceDelegateFactory.createSurfaceDelegate(moduleName);
|
1260 | 1261 | }
|
| 1262 | + |
| 1263 | + /** |
| 1264 | + * Starting with Android 14, apps and services that target Android 14 and use context-registered |
| 1265 | + * receivers are required to specify a flag to indicate whether or not the receiver should be |
| 1266 | + * exported to all other apps on the device: either RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED |
| 1267 | + * |
| 1268 | + * <p>https://developer.android.com/about/versions/14/behavior-changes-14#runtime-receivers-exported |
| 1269 | + */ |
| 1270 | + private void compatRegisterReceiver( |
| 1271 | + Context context, BroadcastReceiver receiver, IntentFilter filter, boolean exported) { |
| 1272 | + if (Build.VERSION.SDK_INT >= 34 && context.getApplicationInfo().targetSdkVersion >= 34) { |
| 1273 | + context.registerReceiver( |
| 1274 | + receiver, filter, exported ? Context.RECEIVER_EXPORTED : Context.RECEIVER_NOT_EXPORTED); |
| 1275 | + } else { |
| 1276 | + context.registerReceiver(receiver, filter); |
| 1277 | + } |
| 1278 | + } |
1261 | 1279 | }
|
0 commit comments