[Android] Bypass Chromecast certificates warning
Geoffrey Métais
git at videolan.org
Fri Jan 19 16:42:42 CET 2018
vlc-android | branch: chromecast | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Jan 17 15:56:00 2018 +0100| [01c92da1f8d8827e83a2ed98cf9689582cf13e4a] | committer: Geoffrey Métais
Bypass Chromecast certificates warning
> https://code.videolan.org/videolan/vlc-android/commit/01c92da1f8d8827e83a2ed98cf9689582cf13e4a
---
.../src/org/videolan/vlc/VLCApplication.java | 33 +++++++++++-----------
vlc-android/src/org/videolan/vlc/util/Util.java | 7 +++++
2 files changed, 23 insertions(+), 17 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/VLCApplication.java b/vlc-android/src/org/videolan/vlc/VLCApplication.java
index d32b9064c..4e80b97f9 100644
--- a/vlc-android/src/org/videolan/vlc/VLCApplication.java
+++ b/vlc-android/src/org/videolan/vlc/VLCApplication.java
@@ -48,6 +48,7 @@ import org.videolan.vlc.gui.helpers.BitmapCache;
import org.videolan.vlc.gui.helpers.NotificationHelper;
import org.videolan.vlc.util.AndroidDevices;
import org.videolan.vlc.util.Strings;
+import org.videolan.vlc.util.Util;
import org.videolan.vlc.util.VLCInstance;
import java.lang.ref.WeakReference;
@@ -170,17 +171,13 @@ public class VLCApplication extends Application {
}
public static void runBackground(Runnable runnable) {
- if (Looper.myLooper() != Looper.getMainLooper())
- runnable.run();
- else
- instance.mThreadPool.execute(runnable);
+ if (Looper.myLooper() != Looper.getMainLooper()) runnable.run();
+ else instance.mThreadPool.execute(runnable);
}
public static void runOnMainThread(Runnable runnable) {
- if (Looper.myLooper() == Looper.getMainLooper())
- runnable.run();
- else
- instance.mHandler.post(runnable);
+ if (Looper.myLooper() == Looper.getMainLooper()) runnable.run();
+ else instance.mHandler.post(runnable);
}
public static boolean removeTask(Runnable runnable) {
@@ -212,33 +209,35 @@ public class VLCApplication extends Application {
@Override
public void onDisplay(Dialog.LoginDialog dialog) {
- String key = DialogActivity.KEY_LOGIN + sDialogCounter++;
+ final String key = DialogActivity.KEY_LOGIN + sDialogCounter++;
fireDialog(dialog, key);
}
@Override
public void onDisplay(Dialog.QuestionDialog dialog) {
- String key = DialogActivity.KEY_QUESTION + sDialogCounter++;
- fireDialog(dialog, key);
+ if ("Insecure site".equals(dialog.getTitle())) {
+ Util.byPassChromecastDialog(dialog);
+ } else {
+ final String key = DialogActivity.KEY_QUESTION + sDialogCounter++;
+ fireDialog(dialog, key);
+ }
}
@Override
public void onDisplay(Dialog.ProgressDialog dialog) {
- String key = DialogActivity.KEY_PROGRESS + sDialogCounter++;
+ final String key = DialogActivity.KEY_PROGRESS + sDialogCounter++;
fireDialog(dialog, key);
}
@Override
public void onCanceled(Dialog dialog) {
- if (dialog != null && dialog.getContext() != null)
- ((DialogFragment)dialog.getContext()).dismiss();
+ if (dialog != null && dialog.getContext() != null) ((DialogFragment)dialog.getContext()).dismiss();
}
@Override
public void onProgressUpdate(Dialog.ProgressDialog dialog) {
VlcProgressDialog vlcProgressDialog = (VlcProgressDialog) dialog.getContext();
- if (vlcProgressDialog != null && vlcProgressDialog.isVisible())
- vlcProgressDialog.updateProgress();
+ if (vlcProgressDialog != null && vlcProgressDialog.isVisible()) vlcProgressDialog.updateProgress();
}
};
@@ -258,7 +257,7 @@ public class VLCApplication extends Application {
if (!p.equals("")) {
Locale locale;
// workaround due to region code
- if(p.equals("zh-TW")) {
+ if (p.equals("zh-TW")) {
locale = Locale.TRADITIONAL_CHINESE;
} else if(p.startsWith("zh")) {
locale = Locale.CHINA;
diff --git a/vlc-android/src/org/videolan/vlc/util/Util.java b/vlc-android/src/org/videolan/vlc/util/Util.java
index ab7df1aaf..c30681602 100644
--- a/vlc-android/src/org/videolan/vlc/util/Util.java
+++ b/vlc-android/src/org/videolan/vlc/util/Util.java
@@ -28,6 +28,7 @@ import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.text.TextUtils;
+import org.videolan.libvlc.Dialog;
import org.videolan.libvlc.util.AndroidUtil;
import org.videolan.medialibrary.Tools;
import org.videolan.medialibrary.media.MediaLibraryItem;
@@ -185,4 +186,10 @@ public class Util {
else
ctx.startForegroundService(intent);
}
+
+ public static void byPassChromecastDialog(Dialog.QuestionDialog dialog) {
+ if ("View certificate".equals(dialog.getAction1Text())) dialog.postAction(1);
+ else if ("Accept permanently".equals(dialog.getAction2Text())) dialog.postAction(2);
+ dialog.dismiss();
+ }
}
More information about the Android
mailing list