fix lint UnsafeProtectedBroadcastReceiver
Android won't protect us from other apps sending other Intents to these receivers, so at least check that the action string matches what its looking for. This is based on a lint recommendation.
This commit is contained in:
parent
e2256d3d8c
commit
a5a90954bc
@ -203,7 +203,7 @@ android {
|
||||
// to make CI fail on errors until this is fixed https://github.com/rtyley/spongycastle/issues/7
|
||||
warning 'InvalidPackage'
|
||||
|
||||
error 'AppCompatMethod', 'NestedScrolling', 'StringFormatCount'
|
||||
error 'AppCompatMethod', 'NestedScrolling', 'StringFormatCount', 'UnsafeProtectedBroadcastReceiver'
|
||||
}
|
||||
|
||||
packagingOptions {
|
||||
|
@ -23,12 +23,18 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import org.fdroid.fdroid.UpdateService;
|
||||
import org.fdroid.fdroid.Utils;
|
||||
|
||||
public class StartupReceiver extends BroadcastReceiver {
|
||||
private static final String TAG = "StartupReceiver";
|
||||
|
||||
@Override
|
||||
public void onReceive(Context ctx, Intent intent) {
|
||||
UpdateService.schedule(ctx);
|
||||
if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
|
||||
UpdateService.schedule(ctx);
|
||||
} else {
|
||||
Utils.debugLog(TAG, "received unsupported Intent " + intent);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,14 +4,21 @@ import android.content.BroadcastReceiver;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.wifi.WifiManager;
|
||||
|
||||
import org.fdroid.fdroid.Utils;
|
||||
import org.fdroid.fdroid.net.WifiStateChangeService;
|
||||
|
||||
public class WifiStateChangeReceiver extends BroadcastReceiver {
|
||||
private static final String TAG = "WifiStateChangeReceiver";
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
intent.setComponent(new ComponentName(context, WifiStateChangeService.class));
|
||||
context.startService(intent);
|
||||
if (WifiManager.NETWORK_STATE_CHANGED_ACTION.equals(intent.getAction())) {
|
||||
intent.setComponent(new ComponentName(context, WifiStateChangeService.class));
|
||||
context.startService(intent);
|
||||
} else {
|
||||
Utils.debugLog(TAG, "received unsupported Intent: " + intent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user