diff --git a/android/jni/app-android.cpp b/android/jni/app-android.cpp
index 1046266a7f..672f9ff7d8 100644
--- a/android/jni/app-android.cpp
+++ b/android/jni/app-android.cpp
@@ -1069,3 +1069,27 @@ extern "C" bool JNICALL Java_org_ppsspp_ppsspp_NativeActivity_runEGLRenderLoop(J
WLOG("Render loop function exited.");
return true;
}
+
+extern "C" jstring Java_org_ppsspp_ppsspp_ShortcutActivity_queryGameName(JNIEnv *env, jclass, jstring jpath) {
+ std::string path = GetJavaString(env, jpath);
+ std::string result = "";
+
+ GameInfoCache *cache = new GameInfoCache();
+ GameInfo *info = cache->GetInfo(nullptr, path, 0);
+ // Wait until it's done: this is synchronous, unfortunately.
+ if (info) {
+ cache->WaitUntilDone(info);
+ if (info->fileType != FILETYPE_UNKNOWN) {
+ result = info->GetTitle();
+
+ // Pretty arbitrary, but the home screen will often truncate titles.
+ // Let's remove "The " from names since it's common in English titles.
+ if (result.length() > strlen("The ") && startsWithNoCase(result, "The ")) {
+ result = result.substr(strlen("The "));
+ }
+ }
+ }
+ delete cache;
+
+ return env->NewStringUTF(result.c_str());
+}
diff --git a/android/res/values/strings.xml b/android/res/values/strings.xml
index f1e35e61ec..3c5cb89192 100644
--- a/android/res/values/strings.xml
+++ b/android/res/values/strings.xml
@@ -5,4 +5,7 @@
PPSSPP
PPSSPP game
-
\ No newline at end of file
+ Unsupported disc
+ The file you selected wasn\'t recognized as a game.
+
+
diff --git a/android/src/org/ppsspp/ppsspp/PpssppActivity.java b/android/src/org/ppsspp/ppsspp/PpssppActivity.java
index 7073cb8618..72884f6c11 100644
--- a/android/src/org/ppsspp/ppsspp/PpssppActivity.java
+++ b/android/src/org/ppsspp/ppsspp/PpssppActivity.java
@@ -18,7 +18,7 @@ public class PpssppActivity extends NativeActivity {
private static boolean m_hasNoNativeBinary = false;
@SuppressWarnings("deprecation")
- static void CheckABIAndLoadLibrary() {
+ public static void CheckABIAndLoadLibrary() {
if (Build.CPU_ABI.equals("armeabi")) {
m_hasUnsupportedABI = true;
} else {
@@ -73,13 +73,13 @@ public class PpssppActivity extends NativeActivity {
// (from app drawer or file explorer).
Intent intent = getIntent();
String action = intent.getAction();
- if(Intent.ACTION_VIEW.equals(action))
- {
+ if (Intent.ACTION_VIEW.equals(action)) {
String path = intent.getData().getPath();
super.setShortcutParam(path);
Toast.makeText(getApplicationContext(), path, Toast.LENGTH_SHORT).show();
+ } else {
+ super.setShortcutParam(getIntent().getStringExtra(SHORTCUT_EXTRA_KEY));
}
- else super.setShortcutParam(getIntent().getStringExtra(SHORTCUT_EXTRA_KEY));
super.onCreate(savedInstanceState);
}
diff --git a/android/src/org/ppsspp/ppsspp/ShortcutActivity.java b/android/src/org/ppsspp/ppsspp/ShortcutActivity.java
index ed1e8663e0..1dcfe5e9d3 100644
--- a/android/src/org/ppsspp/ppsspp/ShortcutActivity.java
+++ b/android/src/org/ppsspp/ppsspp/ShortcutActivity.java
@@ -3,10 +3,12 @@ package org.ppsspp.ppsspp;
import java.io.File;
import android.app.Activity;
+import android.app.AlertDialog;
import android.content.Intent;
import android.content.Intent.ShortcutIconResource;
import android.os.Bundle;
import android.os.Environment;
+import android.os.Looper;
/**
* This class will respond to android.intent.action.CREATE_SHORTCUT intent from
@@ -25,6 +27,8 @@ public class ShortcutActivity extends Activity {
fileDialog.showDialog();
}
+ public static native String queryGameName(String path);
+
// Create shortcut as response for ACTION_CREATE_SHORTCUT intent.
private void respondToShortcutRequest(String path) {
// This is Intent that will be sent when user execute our shortcut on
@@ -33,12 +37,18 @@ public class ShortcutActivity extends Activity {
Intent shortcutIntent = new Intent(this, PpssppActivity.class);
shortcutIntent.putExtra(PpssppActivity.SHORTCUT_EXTRA_KEY, path);
+ PpssppActivity.CheckABIAndLoadLibrary();
+ String name = queryGameName(path);
+ if (name.equals("")) {
+ showBadGameMessage();
+ return;
+ }
+
// This is Intent that will be returned by this method, as response to
// ACTION_CREATE_SHORTCUT. Wrap shortcut intent inside this intent.
Intent responseIntent = new Intent();
responseIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
- responseIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, getResources()
- .getString(R.string.app_name));
+ responseIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, name);
ShortcutIconResource iconResource = Intent.ShortcutIconResource
.fromContext(this, R.drawable.ic_launcher);
responseIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
@@ -50,6 +60,29 @@ public class ShortcutActivity extends Activity {
finish();
}
+ private void showBadGameMessage() {
+ new Thread() {
+ @SuppressWarnings("deprecation")
+ @Override
+ public void run() {
+ Looper.prepare();
+ AlertDialog.Builder builder = new AlertDialog.Builder(ShortcutActivity.this);
+ builder.setMessage(getResources().getString(R.string.bad_disc_message));
+ builder.setTitle(getResources().getString(R.string.bad_disc_title));
+ builder.create().show();
+ Looper.loop();
+ }
+ }.start();
+
+ try {
+ Thread.sleep(3000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+
+ System.exit(-1);
+ }
+
// Event when a file is selected on file dialog.
private SimpleFileChooser.FileSelectedListener onFileSelectedListener = new SimpleFileChooser.FileSelectedListener() {
public void onFileSelected(File file) {