Skip to content

Commit 85ac733

Browse files
committed
Use ordinary content:// protocol instead of love2d://.
1 parent 3ad966d commit 85ac733

File tree

2 files changed

+5
-33
lines changed

2 files changed

+5
-33
lines changed

app/src/main/java/org/love2d/android/GameActivity.java

+4-32
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import android.media.AudioManager;
3131
import android.net.Uri;
3232
import android.os.Bundle;
33-
import android.os.ParcelFileDescriptor;
3433
import android.os.VibrationEffect;
3534
import android.os.Vibrator;
3635
import android.util.DisplayMetrics;
@@ -324,11 +323,6 @@ public void requestRecordAudioPermission() {
324323
}
325324
}
326325

327-
@Keep
328-
public int convertToFileDescriptor(String uri) {
329-
return convertToFileDescriptor(Uri.parse(uri));
330-
}
331-
332326
public int getAudioSMP() {
333327
int smp = 256;
334328
AudioManager a = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
@@ -354,12 +348,8 @@ public int getAudioFreq() {
354348
}
355349

356350
public boolean isNativeLibsExtracted() {
357-
if (android.os.Build.VERSION.SDK_INT >= 23) {
358-
ApplicationInfo appInfo = getApplicationInfo();
359-
return (appInfo.flags & ApplicationInfo.FLAG_EXTRACT_NATIVE_LIBS) != 0;
360-
}
361-
362-
return false;
351+
ApplicationInfo appInfo = getApplicationInfo();
352+
return (appInfo.flags & ApplicationInfo.FLAG_EXTRACT_NATIVE_LIBS) != 0;
363353
}
364354

365355
public void sendUriAsDroppedFile(Uri uri) {
@@ -426,32 +416,14 @@ private HashMap<String, Boolean> buildFileTree(AssetManager assetManager, String
426416
return map;
427417
}
428418

429-
private int convertToFileDescriptor(Uri uri) {
430-
int fd = -1;
431-
432-
try {
433-
ParcelFileDescriptor pfd = getContentResolver().openFileDescriptor(uri, "r");
434-
if (pfd == null) {
435-
throw new RuntimeException("pfd is null");
436-
}
437-
438-
fd = pfd.dup().detachFd();
439-
pfd.close();
440-
} catch (Exception e) {
441-
Log.e(TAG, "Failed attempt to convert " + uri.toString() + " to file descriptor", e);
442-
}
443-
444-
return fd;
445-
}
446-
447419
private void processOpenGame(Uri game) {
448420
String scheme = game.getScheme();
449421
String path = game.getPath();
450422

451423
if (scheme != null) {
452424
if (scheme.equals("content")) {
453-
// Convert the URI to file descriptor.
454-
args = new String[]{"love2d://fd/" + convertToFileDescriptor(game)};
425+
// Pass content URI as-is.
426+
args = new String[]{game.toString()};
455427
} else if (scheme.equals("file")) {
456428
// Regular file, pass as-is.
457429
args = new String[]{path};

0 commit comments

Comments
 (0)