Skip to content

Commit

Permalink
more fixes for target sdk 34
Browse files Browse the repository at this point in the history
  • Loading branch information
ukanth committed Oct 25, 2024
1 parent 7619ecd commit a15b454
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 6 deletions.
23 changes: 20 additions & 3 deletions app/src/main/java/dev/ukanth/ufirewall/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import static dev.ukanth.ufirewall.util.SecurityUtil.REQ_ENTER_PATTERN;

import android.Manifest;
import android.annotation.SuppressLint;
import android.app.KeyguardManager;
import android.app.NotificationManager;
import android.content.ActivityNotFoundException;
Expand Down Expand Up @@ -113,6 +114,7 @@
import dev.ukanth.ufirewall.util.PackageComparator;
import dev.ukanth.ufirewall.util.SecurityUtil;
import haibison.android.lockpattern.utils.AlpSettings;
import kotlin.Suppress;


public class MainActivity extends AppCompatActivity implements AdapterView.OnItemSelectedListener, OnClickListener, SwipeRefreshLayout.OnRefreshListener,
Expand Down Expand Up @@ -280,6 +282,7 @@ private void registerLogService() {
}
}

@SuppressLint("UnspecifiedRegisterReceiverFlag")
private void registerUIRefresh() {
IntentFilter filter = new IntentFilter("dev.ukanth.ufirewall.ui.CHECKREFRESH");
uiRefreshReceiver = new BroadcastReceiver() {
Expand All @@ -295,9 +298,14 @@ public void onReceive(Context context, Intent intent) {
}
}
};
registerReceiver(uiRefreshReceiver, filter);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
registerReceiver(uiRefreshReceiver, filter, RECEIVER_EXPORTED);
} else {
registerReceiver(uiRefreshReceiver, filter);
}
}

@SuppressLint("UnspecifiedRegisterReceiverFlag")
private void registerThemeIntent() {

IntentFilter filter = new IntentFilter("dev.ukanth.ufirewall.theme.REFRESH");
Expand All @@ -308,7 +316,11 @@ public void onReceive(Context context, Intent intent) {
recreate();
}
};
registerReceiver(themeRefreshReceiver, filter);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
registerReceiver(themeRefreshReceiver, filter, RECEIVER_EXPORTED);
} else {
registerReceiver(themeRefreshReceiver, filter);
}
}

private void probeLogTarget() {
Expand Down Expand Up @@ -416,6 +428,7 @@ public void onBackPressed() {
}*/


@SuppressLint("UnspecifiedRegisterReceiverFlag")
private void registerToastbroadcast() {
IntentFilter filter = new IntentFilter("TOAST");
toastReceiver = new BroadcastReceiver() {
Expand All @@ -424,7 +437,11 @@ public void onReceive(Context context, Intent intent) {
Api.toast(getApplicationContext(), intent.getExtras().get("MSG") != null ? intent.getExtras().get("MSG").toString() : "", Toast.LENGTH_SHORT);
}
};
registerReceiver(toastReceiver, filter);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
registerReceiver(toastReceiver, filter, RECEIVER_EXPORTED);
} else {
registerReceiver(toastReceiver, filter);
}
}

private void registerUIbroadcast4() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,17 +189,31 @@ public int onStartCommand(Intent intent, int flags, int startId) {
connectivityReciver = new ConnectivityChangeReceiver();
filter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION);
filter.addAction(ConnectivityChangeReceiver.TETHER_STATE_CHANGED_ACTION);
registerReceiver(connectivityReciver, filter);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
registerReceiver(connectivityReciver, filter, RECEIVER_EXPORTED);
} else {
registerReceiver(connectivityReciver, filter);
}

IntentFilter intentFilter = new IntentFilter(Intent.ACTION_PACKAGE_ADDED);
intentFilter.addDataScheme("package");
packageReceiver = new PackageBroadcast();
registerReceiver(packageReceiver, intentFilter);

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
registerReceiver(packageReceiver, intentFilter, RECEIVER_EXPORTED);
} else {
registerReceiver(packageReceiver, intentFilter);
}


intentFilter = new IntentFilter(Intent.ACTION_PACKAGE_REMOVED);
intentFilter.addDataScheme("package");
registerReceiver(packageReceiver, intentFilter);

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
registerReceiver(packageReceiver, intentFilter,RECEIVER_EXPORTED);
} else {
registerReceiver(packageReceiver, intentFilter);
}

if(bluetoothAdapter == null) {
bluetoothAdapter = getBTAdapter(context);
Expand Down

0 comments on commit a15b454

Please sign in to comment.