--- a/src/de/duenndns/ssl/MemorizingTrustManager.java Mon Aug 22 22:35:57 2011 +0200
+++ b/src/de/duenndns/ssl/MemorizingTrustManager.java Mon Aug 22 22:42:58 2011 +0200
@@ -67,6 +67,8 @@
*/
public class MemorizingTrustManager implements X509TrustManager {
final static String TAG = "MemorizingTrustManager";
+ public final static String INTERCEPT_DECISION_INTENT = "de.duenndns.ssl.INTERCEPT_DECISION";
+ public final static String INTERCEPT_DECISION_INTENT_LAUNCH = INTERCEPT_DECISION_INTENT + ".launch_intent";
final static String DECISION_INTENT = "de.duenndns.ssl.DECISION";
final static String DECISION_INTENT_APP = DECISION_INTENT + ".app";
final static String DECISION_INTENT_ID = DECISION_INTENT + ".decisionId";
@@ -291,19 +293,34 @@
return si.toString();
}
- void startActivityNotification(Intent intent, String certName) {
+ void startActivityNotification(PendingIntent intent, String certName) {
Notification n = new Notification(android.R.drawable.ic_lock_lock,
master.getString(R.string.mtm_notification),
System.currentTimeMillis());
- PendingIntent call = PendingIntent.getActivity(master, 0, intent, 0);
n.setLatestEventInfo(master.getApplicationContext(),
master.getString(R.string.mtm_notification),
- certName, call);
+ certName, intent);
n.flags |= Notification.FLAG_AUTO_CANCEL;
notificationManager.notify(NOTIFICATION_ID, n);
}
+ void launchServiceMode(Intent activityIntent, final String certMessage) {
+ BroadcastReceiver launchNotifReceiver= new BroadcastReceiver() {
+ public void onReceive(Context ctx, Intent i) {
+ Log.i(TAG, "Interception not done by the application. Send notification");
+ PendingIntent pi = i.getParcelableExtra(INTERCEPT_DECISION_INTENT_LAUNCH);
+ startActivityNotification(pi, certMessage);
+ }
+ };
+ master.registerReceiver(launchNotifReceiver, new IntentFilter(INTERCEPT_DECISION_INTENT + "/" + master.getPackageName()));
+ PendingIntent call = PendingIntent.getActivity(master, 0, activityIntent, 0);
+ Intent ni = new Intent(INTERCEPT_DECISION_INTENT + "/" + master.getPackageName());
+ ni.putExtra(INTERCEPT_DECISION_INTENT_LAUNCH, call);
+ master.sendOrderedBroadcast(ni, null);
+
+ }
+
void interact(final X509Certificate[] chain, String authType, CertificateException cause)
throws CertificateException
{
@@ -329,7 +346,7 @@
master.startActivity(ni);
} catch (Exception e) {
Log.e(TAG, "startActivity: " + e);
- startActivityNotification(ni, certMessage);
+ launchServiceMode(ni, certMessage);
}
}
});