Permalink
Browse files

Merge pull request #7413 from zackhow/launcher-crash

Android: Run Directory Initialization as a thread instead of service
  • Loading branch information...
JosJuice committed Oct 5, 2018
2 parents 4ebf3f3 + 1311f84 commit 683eef304424780da9becb4351e06eef97e03ccd
Showing with 90 additions and 99 deletions.
  1. +1 −1 Source/Android/app/src/main/AndroidManifest.xml
  2. +2 −2 Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/DolphinApplication.java
  3. +6 −6 Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/AppLinkActivity.java
  4. +2 −2 Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameAdapter.java
  5. +2 −2 Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameRowPresenter.java
  6. +2 −2 ...ce/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsActivity.java
  7. +4 −4 ...d/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsActivityPresenter.java
  8. +3 −3 ...ndroid/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsActivityView.java
  9. +2 −2 ...d/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentPresenter.java
  10. +5 −5 Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/utils/SettingsFile.java
  11. +5 −5 Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/EmulationFragment.java
  12. +2 −2 Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/MainActivity.java
  13. +3 −3 Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/TvMainActivity.java
  14. +3 −4 Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/Analytics.java
  15. +41 −47 ...mu/dolphinemu/{services/DirectoryInitializationService.java → utils/DirectoryInitialization.java}
  16. +2 −3 Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/DirectoryStateReceiver.java
  17. +5 −6 Source/Android/jni/MainAndroid.cpp
@@ -85,7 +85,7 @@
</intent-filter>
</activity>
<service android:name=".services.DirectoryInitializationService"/>
<service android:name=".utils.DirectoryInitialization"/>
<service android:name=".services.GameFileCacheService"/>
<service
android:name=".services.SyncChannelJobService"
@@ -3,7 +3,7 @@
import android.app.Application;
import android.content.Context;
import org.dolphinemu.dolphinemu.services.DirectoryInitializationService;
import org.dolphinemu.dolphinemu.utils.DirectoryInitialization;
import org.dolphinemu.dolphinemu.utils.PermissionsHandler;
import org.dolphinemu.dolphinemu.utils.VolleyUtil;
@@ -20,7 +20,7 @@ public void onCreate()
System.loadLibrary("main");
if (PermissionsHandler.hasWriteAccess(getApplicationContext()))
DirectoryInitializationService.startService(getApplicationContext());
DirectoryInitialization.start(getApplicationContext());
}
public static Context getAppContext()
@@ -11,7 +11,7 @@
import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.model.GameFile;
import org.dolphinemu.dolphinemu.services.DirectoryInitializationService;
import org.dolphinemu.dolphinemu.utils.DirectoryInitialization;
import org.dolphinemu.dolphinemu.services.GameFileCacheService;
import org.dolphinemu.dolphinemu.ui.main.TvMainActivity;
import org.dolphinemu.dolphinemu.utils.AppLinkHelper;
@@ -64,24 +64,24 @@ protected void onCreate(Bundle savedInstanceState)
private void initResources()
{
IntentFilter statusIntentFilter = new IntentFilter(
DirectoryInitializationService.BROADCAST_ACTION);
DirectoryInitialization.BROADCAST_ACTION);
directoryStateReceiver =
new DirectoryStateReceiver(directoryInitializationState ->
{
if (directoryInitializationState ==
DirectoryInitializationService.DirectoryInitializationState.DOLPHIN_DIRECTORIES_INITIALIZED)
DirectoryInitialization.DirectoryInitializationState.DOLPHIN_DIRECTORIES_INITIALIZED)
{
play(playAction);
}
else if (directoryInitializationState ==
DirectoryInitializationService.DirectoryInitializationState.EXTERNAL_STORAGE_PERMISSION_NEEDED)
DirectoryInitialization.DirectoryInitializationState.EXTERNAL_STORAGE_PERMISSION_NEEDED)
{
Toast.makeText(this, R.string.write_permission_needed, Toast.LENGTH_SHORT)
.show();
}
else if (directoryInitializationState ==
DirectoryInitializationService.DirectoryInitializationState.CANT_FIND_EXTERNAL_STORAGE)
DirectoryInitialization.DirectoryInitializationState.CANT_FIND_EXTERNAL_STORAGE)
{
Toast.makeText(this, R.string.external_storage_not_mounted, Toast.LENGTH_SHORT)
.show();
@@ -92,7 +92,7 @@ else if (directoryInitializationState ==
LocalBroadcastManager.getInstance(this).registerReceiver(
directoryStateReceiver,
statusIntentFilter);
DirectoryInitializationService.startService(this);
DirectoryInitialization.start(this);
GameFileCacheService.startLoad(this);
}
@@ -15,7 +15,7 @@
import org.dolphinemu.dolphinemu.features.settings.ui.MenuTag;
import org.dolphinemu.dolphinemu.features.settings.ui.SettingsActivity;
import org.dolphinemu.dolphinemu.model.GameFile;
import org.dolphinemu.dolphinemu.services.DirectoryInitializationService;
import org.dolphinemu.dolphinemu.utils.DirectoryInitialization;
import org.dolphinemu.dolphinemu.utils.PicassoUtils;
import org.dolphinemu.dolphinemu.viewholders.GameViewHolder;
@@ -166,7 +166,7 @@ public void onClick(DialogInterface dialog, int which)
break;
case 2:
String path =
DirectoryInitializationService.getUserDirectory() + "/GameSettings/" +
DirectoryInitialization.getUserDirectory() + "/GameSettings/" +
gameId + ".ini";
File gameSettingsFile = new File(path);
if (gameSettingsFile.exists())
@@ -17,7 +17,7 @@
import org.dolphinemu.dolphinemu.features.settings.ui.MenuTag;
import org.dolphinemu.dolphinemu.features.settings.ui.SettingsActivity;
import org.dolphinemu.dolphinemu.model.GameFile;
import org.dolphinemu.dolphinemu.services.DirectoryInitializationService;
import org.dolphinemu.dolphinemu.utils.DirectoryInitialization;
import org.dolphinemu.dolphinemu.ui.platform.Platform;
import org.dolphinemu.dolphinemu.utils.PicassoUtils;
import org.dolphinemu.dolphinemu.viewholders.TvGameViewHolder;
@@ -113,7 +113,7 @@ public void onClick(DialogInterface dialog, int which)
SettingsActivity.launch(activity, MenuTag.GRAPHICS, gameId);
break;
case 2:
String path = DirectoryInitializationService.getUserDirectory() +
String path = DirectoryInitialization.getUserDirectory() +
"/GameSettings/" + gameId + ".ini";
File gameSettingsFile = new File(path);
if (gameSettingsFile.exists())
@@ -15,7 +15,7 @@
import android.widget.Toast;
import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.services.DirectoryInitializationService;
import org.dolphinemu.dolphinemu.utils.DirectoryInitialization;
import org.dolphinemu.dolphinemu.utils.DirectoryStateReceiver;
public final class SettingsActivity extends AppCompatActivity implements SettingsActivityView
@@ -142,7 +142,7 @@ public void startDirectoryInitializationService(DirectoryStateReceiver receiver,
LocalBroadcastManager.getInstance(this).registerReceiver(
receiver,
filter);
DirectoryInitializationService.startService(this);
DirectoryInitialization.start(this);
}
@Override
@@ -6,8 +6,8 @@
import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.features.settings.model.Settings;
import org.dolphinemu.dolphinemu.services.DirectoryInitializationService;
import org.dolphinemu.dolphinemu.services.DirectoryInitializationService.DirectoryInitializationState;
import org.dolphinemu.dolphinemu.utils.DirectoryInitialization;
import org.dolphinemu.dolphinemu.utils.DirectoryInitialization.DirectoryInitializationState;
import org.dolphinemu.dolphinemu.utils.DirectoryStateReceiver;
import org.dolphinemu.dolphinemu.utils.Log;
@@ -71,15 +71,15 @@ private void loadSettingsUI()
private void prepareDolphinDirectoriesIfNeeded()
{
if (DirectoryInitializationService.areDolphinDirectoriesReady())
if (DirectoryInitialization.areDolphinDirectoriesReady())
{
loadSettingsUI();
}
else
{
mView.showLoading();
IntentFilter statusIntentFilter = new IntentFilter(
DirectoryInitializationService.BROADCAST_ACTION);
DirectoryInitialization.BROADCAST_ACTION);
directoryStateReceiver =
new DirectoryStateReceiver(directoryInitializationState ->
@@ -120,15 +120,15 @@
void showExternalStorageNotMountedHint();
/**
* Start the DirectoryInitializationService and listen for the result.
* Start the DirectoryInitialization and listen for the result.
*
* @param receiver the broadcast receiver for the DirectoryInitializationService
* @param receiver the broadcast receiver for the DirectoryInitialization
* @param filter the Intent broadcasts to be received.
*/
void startDirectoryInitializationService(DirectoryStateReceiver receiver, IntentFilter filter);
/**
* Stop listening to the DirectoryInitializationService.
* Stop listening to the DirectoryInitialization.
*
* @param receiver The broadcast receiver to unregister.
*/
@@ -20,7 +20,7 @@
import org.dolphinemu.dolphinemu.features.settings.model.view.StringSingleChoiceSetting;
import org.dolphinemu.dolphinemu.features.settings.model.view.SubmenuSetting;
import org.dolphinemu.dolphinemu.features.settings.utils.SettingsFile;
import org.dolphinemu.dolphinemu.services.DirectoryInitializationService;
import org.dolphinemu.dolphinemu.utils.DirectoryInitialization;
import org.dolphinemu.dolphinemu.utils.EGLHelper;
import org.dolphinemu.dolphinemu.utils.Log;
@@ -473,7 +473,7 @@ private void addEnhanceSettings(ArrayList<SettingsItem> sl)
try
{
String shadersPath =
DirectoryInitializationService.getDolphinInternalDirectory() + "/Shaders";
DirectoryInitialization.getDolphinInternalDirectory() + "/Shaders";
if (!TextUtils.isEmpty(subDir))
{
shadersPath += "/" + subDir;
@@ -11,7 +11,7 @@
import org.dolphinemu.dolphinemu.features.settings.model.Settings;
import org.dolphinemu.dolphinemu.features.settings.model.StringSetting;
import org.dolphinemu.dolphinemu.features.settings.ui.SettingsActivityView;
import org.dolphinemu.dolphinemu.services.DirectoryInitializationService;
import org.dolphinemu.dolphinemu.utils.DirectoryInitialization;
import org.dolphinemu.dolphinemu.utils.BiMap;
import org.dolphinemu.dolphinemu.utils.Log;
@@ -462,29 +462,29 @@ private static String mapSectionNameToIni(String generalSectionName)
private static File getSettingsFile(String fileName)
{
return new File(
DirectoryInitializationService.getUserDirectory() + "/Config/" + fileName + ".ini");
DirectoryInitialization.getUserDirectory() + "/Config/" + fileName + ".ini");
}
private static File getGenericGameSettingsForAllRegions(String gameId)
{
// Use the first 3 chars from the gameId to load the generic game settings for all regions
gameId = gameId.substring(0, 3);
return new File(
DirectoryInitializationService.getDolphinInternalDirectory() + "/GameSettings/" +
DirectoryInitialization.getDolphinInternalDirectory() + "/GameSettings/" +
gameId + ".ini");
}
private static File getGenericGameSettingsFile(String gameId)
{
return new File(
DirectoryInitializationService.getDolphinInternalDirectory() + "/GameSettings/" +
DirectoryInitialization.getDolphinInternalDirectory() + "/GameSettings/" +
gameId + ".ini");
}
private static File getCustomGameSettingsFile(String gameId)
{
return new File(
DirectoryInitializationService.getUserDirectory() + "/GameSettings/" + gameId + ".ini");
DirectoryInitialization.getUserDirectory() + "/GameSettings/" + gameId + ".ini");
}
private static SettingSection sectionFromLine(String line, boolean isCustomGame)
@@ -20,8 +20,8 @@
import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.activities.EmulationActivity;
import org.dolphinemu.dolphinemu.overlay.InputOverlay;
import org.dolphinemu.dolphinemu.services.DirectoryInitializationService;
import org.dolphinemu.dolphinemu.services.DirectoryInitializationService.DirectoryInitializationState;
import org.dolphinemu.dolphinemu.utils.DirectoryInitialization;
import org.dolphinemu.dolphinemu.utils.DirectoryInitialization.DirectoryInitializationState;
import org.dolphinemu.dolphinemu.utils.DirectoryStateReceiver;
import org.dolphinemu.dolphinemu.utils.Log;
import org.dolphinemu.dolphinemu.utils.StartupHandler;
@@ -127,7 +127,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
public void onResume()
{
super.onResume();
if (DirectoryInitializationService.areDolphinDirectoriesReady())
if (DirectoryInitialization.areDolphinDirectoriesReady())
{
mEmulationState.run(activity.isActivityRecreated());
}
@@ -160,7 +160,7 @@ public void onDetach()
private void setupDolphinDirectoriesThenStartEmulation()
{
IntentFilter statusIntentFilter = new IntentFilter(
DirectoryInitializationService.BROADCAST_ACTION);
DirectoryInitialization.BROADCAST_ACTION);
directoryStateReceiver =
new DirectoryStateReceiver(directoryInitializationState ->
@@ -189,7 +189,7 @@ else if (directoryInitializationState ==
LocalBroadcastManager.getInstance(getActivity()).registerReceiver(
directoryStateReceiver,
statusIntentFilter);
DirectoryInitializationService.startService(getActivity());
DirectoryInitialization.start(getActivity());
}
public void toggleInputOverlayVisibility()
@@ -19,7 +19,7 @@
import org.dolphinemu.dolphinemu.adapters.PlatformPagerAdapter;
import org.dolphinemu.dolphinemu.features.settings.ui.MenuTag;
import org.dolphinemu.dolphinemu.features.settings.ui.SettingsActivity;
import org.dolphinemu.dolphinemu.services.DirectoryInitializationService;
import org.dolphinemu.dolphinemu.utils.DirectoryInitialization;
import org.dolphinemu.dolphinemu.services.GameFileCacheService;
import org.dolphinemu.dolphinemu.ui.platform.Platform;
import org.dolphinemu.dolphinemu.ui.platform.PlatformGamesView;
@@ -188,7 +188,7 @@ public void onRequestPermissionsResult(int requestCode, String[] permissions, in
case PermissionsHandler.REQUEST_CODE_WRITE_PERMISSION:
if (grantResults[0] == PackageManager.PERMISSION_GRANTED)
{
DirectoryInitializationService.startService(this);
DirectoryInitialization.start(this);
PlatformPagerAdapter platformPagerAdapter = new PlatformPagerAdapter(
getSupportFragmentManager(), this);
mViewPager.setAdapter(platformPagerAdapter);
@@ -22,7 +22,7 @@
import org.dolphinemu.dolphinemu.features.settings.ui.SettingsActivity;
import org.dolphinemu.dolphinemu.model.GameFile;
import org.dolphinemu.dolphinemu.model.TvSettingsItem;
import org.dolphinemu.dolphinemu.services.DirectoryInitializationService;
import org.dolphinemu.dolphinemu.utils.DirectoryInitialization;
import org.dolphinemu.dolphinemu.services.GameFileCacheService;
import org.dolphinemu.dolphinemu.ui.platform.Platform;
import org.dolphinemu.dolphinemu.utils.FileBrowserHelper;
@@ -158,7 +158,7 @@ public void showGames()
// Kicks off the program services to update all channels
TvUtil.updateAllChannels(getApplicationContext());
recreate();
buildRowsAdapter();
}
/**
@@ -195,7 +195,7 @@ public void onRequestPermissionsResult(int requestCode, String[] permissions, in
case PermissionsHandler.REQUEST_CODE_WRITE_PERMISSION:
if (grantResults[0] == PackageManager.PERMISSION_GRANTED)
{
DirectoryInitializationService.startService(this);
DirectoryInitialization.start(this);
GameFileCacheService.startLoad(this);
}
else
@@ -15,7 +15,6 @@
import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.features.settings.model.Settings;
import org.dolphinemu.dolphinemu.features.settings.utils.SettingsFile;
import org.dolphinemu.dolphinemu.services.DirectoryInitializationService;
public class Analytics
{
@@ -36,16 +35,16 @@ public static void checkAnalyticsInit(Context context)
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
if (!preferences.getBoolean(analyticsAsked, false))
{
if (!DirectoryInitializationService.areDolphinDirectoriesReady())
if (!DirectoryInitialization.areDolphinDirectoriesReady())
{
// Wait for directories to get initialized
IntentFilter statusIntentFilter = new IntentFilter(
DirectoryInitializationService.BROADCAST_ACTION);
DirectoryInitialization.BROADCAST_ACTION);
directoryStateReceiver = new DirectoryStateReceiver(directoryInitializationState ->
{
if (directoryInitializationState ==
DirectoryInitializationService.DirectoryInitializationState.DOLPHIN_DIRECTORIES_INITIALIZED)
DirectoryInitialization.DirectoryInitializationState.DOLPHIN_DIRECTORIES_INITIALIZED)
{
LocalBroadcastManager.getInstance(context).unregisterReceiver(directoryStateReceiver);
directoryStateReceiver = null;
Oops, something went wrong.

0 comments on commit 683eef3

Please sign in to comment.