Pracuję nad aplikacją open source (droidwall fork) i utknąłem z jednym z problemów, gdy reguły iptables nie zostały poprawnie zastosowane po ponownym uruchomieniu systemu. działa doskonale na większości wersji Androida. Ale w niektórych szczególnych ROM (cm 10,1) daje następujące logcatJuż nie chcę ActivityManager - nie jest to problem z usługą
12-26 08:39:27.116 I/ActivityManager(582):
No longer want dev.ukanth.ufirewall (pid 2297): empty #17
mój kod działa latków jak poniżej,
private Handler mHandler = new Handler(Looper.getMainLooper());
@Override
public void onReceive(final Context context, final Intent intent) {
if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
if (Api.isEnabled(context.getApplicationContext())) {
final Handler toaster = new Handler() {
public void handleMessage(Message msg) {
if (msg.arg1 != 0) Toast.makeText(context, msg.arg1, Toast.LENGTH_SHORT).show();
}
};
mHandler.post(
// Start a new thread to enable the firewall - this prevents ANR
new Runnable() {
@Override
public void run() {
if (!Api.applySavedIptablesRules(context.getApplicationContext(), false)) {
// Error enabling firewall on boot
final Message msg = new Message();
msg.arg1 = R.string.toast_error_enabling;
toaster.sendMessage(msg);
Api.setEnabled(context.getApplicationContext(), false, false);
}
}
});
// Start a new thread to enable the firewall - this prevents ANR
}
/*Intent i = new Intent(context, StartupService.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startService(i);*/
}
można znaleźć moją klasę Api.java here.
Tak. Rozumiem tę część bardzo dobrze. Możesz znaleźć więcej informacji na temat tego problemu tutaj, https://github.com/ukanth/afwall/issues/91 – ukanth