|
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;
|
@@ -1107,7 +1108,7 @@ private void reload() {
|
1107 | 1108 | if (!mIsReceiverRegistered) {
|
1108 | 1109 | IntentFilter filter = new IntentFilter();
|
1109 | 1110 | filter.addAction(getReloadAppAction(mApplicationContext));
|
1110 |
| - mApplicationContext.registerReceiver(mReloadAppBroadcastReceiver, filter); |
| 1111 | + compatRegisterReceiver(mApplicationContext, mReloadAppBroadcastReceiver, filter, true); |
1111 | 1112 | mIsReceiverRegistered = true;
|
1112 | 1113 | }
|
1113 | 1114 |
|
@@ -1223,4 +1224,21 @@ public void setPackagerLocationCustomizer(
|
1223 | 1224 |
|
1224 | 1225 | return mSurfaceDelegateFactory.createSurfaceDelegate(moduleName);
|
1225 | 1226 | }
|
| 1227 | + |
| 1228 | + /** |
| 1229 | + * Starting with Android 14, apps and services that target Android 14 and use context-registered |
| 1230 | + * receivers are required to specify a flag to indicate whether or not the receiver should be |
| 1231 | + * exported to all other apps on the device: either RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED |
| 1232 | + * |
| 1233 | + * <p>https://developer.android.com/about/versions/14/behavior-changes-14#runtime-receivers-exported |
| 1234 | + */ |
| 1235 | + private void compatRegisterReceiver( |
| 1236 | + Context context, BroadcastReceiver receiver, IntentFilter filter, boolean exported) { |
| 1237 | + if (Build.VERSION.SDK_INT >= 34 && context.getApplicationInfo().targetSdkVersion >= 34) { |
| 1238 | + context.registerReceiver( |
| 1239 | + receiver, filter, exported ? Context.RECEIVER_EXPORTED : Context.RECEIVER_NOT_EXPORTED); |
| 1240 | + } else { |
| 1241 | + context.registerReceiver(receiver, filter); |
| 1242 | + } |
| 1243 | + } |
1226 | 1244 | }
|
0 commit comments