Adding SSL dev code

This commit is contained in:
Joe Bowser 2011-06-21 10:08:42 -07:00
parent 939754e1c9
commit afa85a74b3

View File

@ -14,11 +14,15 @@ import android.widget.EditText;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.Color; import android.graphics.Color;
import android.media.AudioManager; import android.media.AudioManager;
import android.net.Uri; import android.net.Uri;
import android.net.http.SslError;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log; import android.util.Log;
import android.view.KeyEvent; import android.view.KeyEvent;
@ -27,6 +31,7 @@ import android.view.ViewGroup;
import android.view.Window; import android.view.Window;
import android.view.WindowManager; import android.view.WindowManager;
import android.webkit.JsResult; import android.webkit.JsResult;
import android.webkit.SslErrorHandler;
import android.webkit.WebChromeClient; import android.webkit.WebChromeClient;
import android.webkit.JsPromptResult; import android.webkit.JsPromptResult;
import android.webkit.WebSettings; import android.webkit.WebSettings;
@ -1115,6 +1120,27 @@ public class DroidGap extends PhonegapActivity {
// Handle error // Handle error
this.ctx.onReceivedError(errorCode, description, failingUrl); this.ctx.onReceivedError(errorCode, description, failingUrl);
} }
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
final String packageName = this.ctx.getPackageName();
final PackageManager pm = this.ctx.getPackageManager();
ApplicationInfo appInfo;
try {
appInfo = pm.getApplicationInfo(packageName, PackageManager.GET_META_DATA);
if ((appInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) {
// debug = true
handler.proceed();
return;
} else {
// debug = false
super.onReceivedSslError(view, handler, error);
}
} catch (NameNotFoundException e) {
// When it doubt, lock it out!
super.onReceivedSslError(view, handler, error);
}
}
} }
/** /**