[Android] Add support for launching a game through activity monitor.

This also allows setting the user directory.
This is mainly for FifoCI in the future.
This commit is contained in:
Ryan Houdek 2016-01-01 08:05:55 -06:00
parent 787bf156f0
commit e77d454b8b
3 changed files with 58 additions and 28 deletions

View File

@ -28,6 +28,7 @@ import org.dolphinemu.dolphinemu.model.Game;
import org.dolphinemu.dolphinemu.model.GameDatabase;
import org.dolphinemu.dolphinemu.model.GameProvider;
import org.dolphinemu.dolphinemu.services.AssetCopyService;
import org.dolphinemu.dolphinemu.utils.StartupHandler;
/**
* The main Activity of the Lollipop style UI. Manages several PlatformGamesFragments, which
@ -90,20 +91,7 @@ public final class MainActivity extends AppCompatActivity implements LoaderManag
// Stuff in this block only happens when this activity is newly created (i.e. not a rotation)
if (savedInstanceState == null)
{
NativeLibrary.SetUserDirectory(""); // Auto-Detect
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
boolean assetsCopied = preferences.getBoolean("assetsCopied", false);
// Only perform these extensive copy operations once.
if (!assetsCopied)
{
// Copy assets into appropriate locations.
Intent copyAssets = new Intent(this, AssetCopyService.class);
startService(copyAssets);
}
}
StartupHandler.HandleInit(this);
}
/**

View File

@ -30,6 +30,7 @@ import org.dolphinemu.dolphinemu.model.GameDatabase;
import org.dolphinemu.dolphinemu.model.GameProvider;
import org.dolphinemu.dolphinemu.model.TvSettingsItem;
import org.dolphinemu.dolphinemu.services.AssetCopyService;
import org.dolphinemu.dolphinemu.utils.StartupHandler;
import org.dolphinemu.dolphinemu.viewholders.TvGameViewHolder;
public final class TvMainActivity extends Activity
@ -118,20 +119,7 @@ public final class TvMainActivity extends Activity
// Stuff in this block only happens when this activity is newly created (i.e. not a rotation)
if (savedInstanceState == null)
{
NativeLibrary.SetUserDirectory(""); // Auto-Detect
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
boolean assetsCopied = preferences.getBoolean("assetsCopied", false);
// Only perform these extensive copy operations once.
if (!assetsCopied)
{
// Copy assets into appropriate locations.
Intent copyAssets = new Intent(this, AssetCopyService.class);
startService(copyAssets);
}
}
StartupHandler.HandleInit(this);
}
/**

View File

@ -0,0 +1,54 @@
package org.dolphinemu.dolphinemu.utils;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.text.TextUtils;
import android.util.Log;
import org.dolphinemu.dolphinemu.NativeLibrary;
import org.dolphinemu.dolphinemu.activities.EmulationActivity;
import org.dolphinemu.dolphinemu.services.AssetCopyService;
public final class StartupHandler
{
public static boolean HandleInit(Activity parent)
{
NativeLibrary.SetUserDirectory(""); // Auto-Detect
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent);
boolean assetsCopied = preferences.getBoolean("assetsCopied", false);
// Only perform these extensive copy operations once.
if (!assetsCopied)
{
// Copy assets into appropriate locations.
Intent copyAssets = new Intent(parent, AssetCopyService.class);
parent.startService(copyAssets);
}
Intent intent = parent.getIntent();
Bundle extras = intent.getExtras();
if (extras != null)
{
String user_dir = extras.getString("UserDir");
String start_file = extras.getString("AutoStartFile");
if (!TextUtils.isEmpty(user_dir))
NativeLibrary.SetUserDirectory(user_dir);
if (!TextUtils.isEmpty(start_file))
{
// Start the emulation activity and send the ISO passed in.
Intent emulation_intent = new Intent(parent, EmulationActivity.class);
emulation_intent.putExtra("SelectedGame", start_file);
parent.startActivity(emulation_intent);
return false;
}
}
return false;
}
}