[Android] Bypass Chromecast certificates warning
Geoffrey Métais
git at videolan.org
Thu Jan 25 10:32:28 CET 2018
vlc-android | branch: chromecast | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Jan 17 15:56:00 2018 +0100| [3085798d7988be22d3ecf3fffb231be19c80da20] | committer: Geoffrey Métais
Bypass Chromecast certificates warning
> https://code.videolan.org/videolan/vlc-android/commit/3085798d7988be22d3ecf3fffb231be19c80da20
---
.../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 94319a51e..5d74f6555 100644
--- a/vlc-android/src/org/videolan/vlc/VLCApplication.java
+++ b/vlc-android/src/org/videolan/vlc/VLCApplication.java
@@ -47,6 +47,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;
@@ -163,17 +164,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) {
@@ -205,33 +202,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();
}
};
@@ -251,7 +250,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