Commit ad9f5731 authored by Geoffrey Métais's avatar Geoffrey Métais

Check CPU compatibility in background

parent a9bec4a7
......@@ -36,9 +36,9 @@ import android.content.ServiceConnection;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.media.audiofx.AudioEffect;
import android.media.AudioManager;
import android.media.AudioManager.OnAudioFocusChangeListener;
import android.media.audiofx.AudioEffect;
import android.net.Uri;
import android.os.Binder;
import android.os.Build;
......@@ -90,7 +90,6 @@ import org.videolan.vlc.util.AndroidDevices;
import org.videolan.vlc.util.Constants;
import org.videolan.vlc.util.Permissions;
import org.videolan.vlc.util.Util;
import org.videolan.vlc.util.VLCInstance;
import org.videolan.vlc.util.VLCOptions;
import org.videolan.vlc.util.VoiceSearchParams;
import org.videolan.vlc.util.WeakHandler;
......@@ -177,10 +176,7 @@ public class PlaybackService extends MediaBrowserServiceCompat{
super.onCreate();
mSettings = PreferenceManager.getDefaultSharedPreferences(this);
playlistManager = new PlaylistManager(this);
if (!VLCInstance.testCompatibleCPU(this)) {
stopSelf();
return;
}
Util.checkCpuCompatibility(this);
mMedialibrary = VLCApplication.getMLInstance();
if (!mMedialibrary.isInitiated()) registerMedialibrary(null);
......
......@@ -76,6 +76,7 @@ import org.videolan.vlc.interfaces.IRefreshable;
import org.videolan.vlc.media.MediaUtils;
import org.videolan.vlc.util.Constants;
import org.videolan.vlc.util.Permissions;
import org.videolan.vlc.util.Util;
import org.videolan.vlc.util.VLCInstance;
import java.lang.ref.WeakReference;
......@@ -109,10 +110,7 @@ public class MainActivity extends ContentActivity implements FilterQueryProvider
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (!VLCInstance.testCompatibleCPU(this)) {
finish();
return;
}
Util.checkCpuCompatibility(this);
Permissions.checkReadStoragePermission(this, false);
......
......@@ -82,7 +82,7 @@ import org.videolan.vlc.media.MediaUtils;
import org.videolan.vlc.util.AndroidDevices;
import org.videolan.vlc.util.Constants;
import org.videolan.vlc.util.Permissions;
import org.videolan.vlc.util.VLCInstance;
import org.videolan.vlc.util.Util;
import java.util.List;
......@@ -125,10 +125,7 @@ public class MainTvActivity extends BaseTvActivity implements OnItemViewSelected
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (!VLCInstance.testCompatibleCPU(this)) {
finish();
return;
}
Util.checkCpuCompatibility(this);
// Delay access permission dialog prompt to avoid background corruption
if (!Permissions.canReadStorage(this))
......
......@@ -351,10 +351,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (!VLCInstance.testCompatibleCPU(this)) {
exit(RESULT_CANCELED);
return;
}
Util.checkCpuCompatibility(this);
mSettings = PreferenceManager.getDefaultSharedPreferences(this);
......@@ -1001,7 +998,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
}
};
protected void exit(int resultCode){
public void exit(int resultCode){
if (isFinishing())
return;
Intent resultIntent = new Intent(ACTION_RESULT);
......
......@@ -304,7 +304,7 @@ public class BenchActivity extends ShallowVideoPlayer {
* @param resultCode VideoPlayerActivity's resultCode
*/
@Override
protected void exit (int resultCode) {
public void exit (int resultCode) {
if (resultCode != RESULT_OK) {
mVLCFailed = true;
}
......
......@@ -20,6 +20,8 @@
package org.videolan.vlc.util;
import android.app.Activity;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
......@@ -35,6 +37,7 @@ import org.videolan.medialibrary.Tools;
import org.videolan.medialibrary.media.MediaLibraryItem;
import org.videolan.vlc.R;
import org.videolan.vlc.VLCApplication;
import org.videolan.vlc.gui.video.VideoPlayerActivity;
import java.io.BufferedReader;
import java.io.Closeable;
......@@ -203,4 +206,20 @@ public class Util {
}
return false;
}
public static void checkCpuCompatibility(final Context ctx) {
VLCApplication.runBackground(new Runnable() {
@Override
public void run() {
if (!VLCInstance.testCompatibleCPU(ctx)) VLCApplication.runOnMainThread(new Runnable() {
@Override
public void run() {
if (ctx instanceof Service) ((Service) ctx).stopSelf();
else if (ctx instanceof VideoPlayerActivity) ((VideoPlayerActivity) ctx).exit(Activity.RESULT_CANCELED);
else if (ctx instanceof Activity) ((Activity) ctx).finish();
}
});
}
});
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment