diff --git a/android/gradle.properties b/android/gradle.properties index e5e7569a7a5..a5678e41a60 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -14,4 +14,4 @@ android.useAndroidX=true android.enableJetifier=false # remove if com.android.tools.build:gradle can be raised in /android/build.gradle -android.suppressUnsupportedCompileSdk=33 +android.suppressUnsupportedCompileSdk=33,34 diff --git a/android/modules/android/src/java/ti/modules/titanium/android/AndroidModule.java b/android/modules/android/src/java/ti/modules/titanium/android/AndroidModule.java index 947cc59cde4..fdc5c89431a 100644 --- a/android/modules/android/src/java/ti/modules/titanium/android/AndroidModule.java +++ b/android/modules/android/src/java/ti/modules/titanium/android/AndroidModule.java @@ -756,7 +756,14 @@ public void registerBroadcastReceiver(BroadcastReceiverProxy receiverProxy, Obje filter.addAction(TiConvert.toString(action)); } - TiApplication.getInstance().registerReceiver(receiverProxy.getBroadcastReceiver(), filter); + if (Build.VERSION.SDK_INT > Build.VERSION_CODES.TIRAMISU + && TiApplication.getInstance().getApplicationInfo().targetSdkVersion > Build.VERSION_CODES.TIRAMISU) { + int receiverFlags = Context.RECEIVER_EXPORTED; + TiApplication.getInstance().registerReceiver( + receiverProxy.getBroadcastReceiver(), filter, receiverFlags); + } else { + TiApplication.getInstance().registerReceiver(receiverProxy.getBroadcastReceiver(), filter); + } if (this.registeredBroadcastReceiverProxyList.contains(receiverProxy) == false) { this.registeredBroadcastReceiverProxyList.add(receiverProxy); } diff --git a/android/modules/network/src/java/ti/modules/titanium/network/TiNetworkListener.java b/android/modules/network/src/java/ti/modules/titanium/network/TiNetworkListener.java index 9474800138d..88eec58c041 100644 --- a/android/modules/network/src/java/ti/modules/titanium/network/TiNetworkListener.java +++ b/android/modules/network/src/java/ti/modules/titanium/network/TiNetworkListener.java @@ -7,6 +7,7 @@ package ti.modules.titanium.network; import org.appcelerator.kroll.common.Log; +import org.appcelerator.titanium.TiApplication; import android.content.BroadcastReceiver; import android.content.Context; @@ -14,6 +15,7 @@ import android.content.IntentFilter; import android.net.ConnectivityManager; import android.net.NetworkInfo; +import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.os.Message; @@ -110,7 +112,13 @@ public void attach(Context context) } else { throw new IllegalStateException("Context was not cleaned up from last release."); } - context.registerReceiver(receiver, connectivityIntentFilter); + if (Build.VERSION.SDK_INT > Build.VERSION_CODES.TIRAMISU + && TiApplication.getInstance().getApplicationInfo().targetSdkVersion > Build.VERSION_CODES.TIRAMISU) { + int receiverFlags = Context.RECEIVER_EXPORTED; + context.registerReceiver(receiver, connectivityIntentFilter, receiverFlags); + } else { + context.registerReceiver(receiver, connectivityIntentFilter); + } listening = true; } else { Log.w(TAG, "Connectivity listener is already attached"); diff --git a/android/titanium/src/java/org/appcelerator/titanium/TiApplication.java b/android/titanium/src/java/org/appcelerator/titanium/TiApplication.java index eff4749d181..cbaef3950dd 100644 --- a/android/titanium/src/java/org/appcelerator/titanium/TiApplication.java +++ b/android/titanium/src/java/org/appcelerator/titanium/TiApplication.java @@ -14,6 +14,7 @@ import android.content.Intent; import android.content.IntentFilter; import android.content.res.Configuration; +import android.os.Build; import android.os.Looper; import android.os.SystemClock; import android.util.DisplayMetrics; @@ -961,7 +962,13 @@ public void onReceive(Context context, Intent intent) } }; - registerReceiver(localeReceiver, new IntentFilter(Intent.ACTION_LOCALE_CHANGED)); + if (Build.VERSION.SDK_INT > Build.VERSION_CODES.TIRAMISU + && TiApplication.getInstance().getApplicationInfo().targetSdkVersion > Build.VERSION_CODES.TIRAMISU) { + int receiverFlags = Context.RECEIVER_EXPORTED; + registerReceiver(localeReceiver, new IntentFilter(Intent.ACTION_LOCALE_CHANGED), receiverFlags); + } else { + registerReceiver(localeReceiver, new IntentFilter(Intent.ACTION_LOCALE_CHANGED)); + } } private void stopLocaleMonitor()