Skip to content

Commit

Permalink
chore(android): prepare SDK for Android 34 (#13940)
Browse files Browse the repository at this point in the history
* chore(android): target API 34

* stay on target 33
  • Loading branch information
m1ga authored Jun 25, 2024
1 parent 9f85623 commit ada10bb
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
2 changes: 1 addition & 1 deletion android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
package ti.modules.titanium.network;

import org.appcelerator.kroll.common.Log;
import org.appcelerator.titanium.TiApplication;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
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;
Expand Down Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit ada10bb

Please sign in to comment.