Skip to content
Permalink
Browse files
Merge pull request #10224 from JosJuice/android-not-service
Android: Make GameFileCacheService not be a service
  • Loading branch information
lioncash committed Nov 17, 2021
2 parents 0b81640 + ffd8cd0 commit f10d95e
Show file tree
Hide file tree
Showing 13 changed files with 112 additions and 125 deletions.
@@ -132,14 +132,6 @@
android:exported="false"
android:theme="@style/DolphinBase" />

<service
android:name=".utils.DirectoryInitialization"
android:exported="false"/>

<service
android:name=".services.GameFileCacheService"
android:exported="false"/>

<service
android:name=".services.SyncChannelJobService"
android:exported="false"
@@ -14,7 +14,7 @@
import androidx.localbroadcastmanager.content.LocalBroadcastManager;

import org.dolphinemu.dolphinemu.model.GameFile;
import org.dolphinemu.dolphinemu.services.GameFileCacheService;
import org.dolphinemu.dolphinemu.services.GameFileCacheManager;
import org.dolphinemu.dolphinemu.ui.main.TvMainActivity;
import org.dolphinemu.dolphinemu.utils.AfterDirectoryInitializationRunner;
import org.dolphinemu.dolphinemu.utils.AppLinkHelper;
@@ -69,7 +69,7 @@ private void initResources()
mAfterDirectoryInitializationRunner = new AfterDirectoryInitializationRunner();
mAfterDirectoryInitializationRunner.run(this, true, () -> tryPlay(playAction));

IntentFilter gameFileCacheIntentFilter = new IntentFilter(GameFileCacheService.DONE_LOADING);
IntentFilter gameFileCacheIntentFilter = new IntentFilter(GameFileCacheManager.DONE_LOADING);

BroadcastReceiver gameFileCacheReceiver = new BroadcastReceiver()
{
@@ -87,7 +87,7 @@ public void onReceive(Context context, Intent intent)
broadcastManager.registerReceiver(gameFileCacheReceiver, gameFileCacheIntentFilter);

DirectoryInitialization.start(this);
GameFileCacheService.startLoad(this);
GameFileCacheManager.startLoad(this);
}

/**
@@ -106,11 +106,11 @@ private void tryPlay(AppLinkHelper.PlayAction action)
// TODO: This approach of getting the game from the game file cache without rescanning the
// library means that we can fail to launch games if the cache file has been deleted.

GameFile game = GameFileCacheService.getGameFileByGameId(action.getGameId());
GameFile game = GameFileCacheManager.getGameFileByGameId(action.getGameId());

// If game == null and the load isn't done, wait for the next GameFileCacheService broadcast.
// If game == null and the load is done, call play with a null game, making us exit in failure.
if (game != null || !GameFileCacheService.isLoading())
if (game != null || !GameFileCacheManager.isLoading())
{
play(action, game);
}
@@ -140,6 +140,6 @@ private void startGame(GameFile game)
mAfterDirectoryInitializationRunner.cancel();
mAfterDirectoryInitializationRunner = null;
}
EmulationActivity.launch(this, GameFileCacheService.findSecondDiscAndGetPaths(game), false);
EmulationActivity.launch(this, GameFileCacheManager.findSecondDiscAndGetPaths(game), false);
}
}
@@ -9,15 +9,14 @@
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.FragmentActivity;
import androidx.recyclerview.widget.RecyclerView;

import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.activities.EmulationActivity;
import org.dolphinemu.dolphinemu.dialogs.GamePropertiesDialog;
import org.dolphinemu.dolphinemu.model.GameFile;
import org.dolphinemu.dolphinemu.services.GameFileCacheService;
import org.dolphinemu.dolphinemu.services.GameFileCacheManager;
import org.dolphinemu.dolphinemu.utils.PicassoUtils;
import org.dolphinemu.dolphinemu.viewholders.GameViewHolder;

@@ -77,7 +76,7 @@ public void onBindViewHolder(GameViewHolder holder, int position)

holder.textGameTitle.setText(gameFile.getTitle());

if (GameFileCacheService.findSecondDisc(gameFile) != null)
if (GameFileCacheManager.findSecondDisc(gameFile) != null)
{
holder.textGameCaption
.setText(context.getString(R.string.disc_number, gameFile.getDiscNumber() + 1));
@@ -140,7 +139,7 @@ public void onClick(View view)
{
GameViewHolder holder = (GameViewHolder) view.getTag();

String[] paths = GameFileCacheService.findSecondDiscAndGetPaths(holder.gameFile);
String[] paths = GameFileCacheManager.findSecondDiscAndGetPaths(holder.gameFile);
EmulationActivity.launch((FragmentActivity) view.getContext(), paths, false);
}

@@ -7,7 +7,6 @@
import android.view.ViewGroup;
import android.widget.ImageView;

import androidx.appcompat.app.AlertDialog;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.FragmentActivity;
import androidx.leanback.widget.ImageCardView;
@@ -16,7 +15,7 @@
import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.dialogs.GamePropertiesDialog;
import org.dolphinemu.dolphinemu.model.GameFile;
import org.dolphinemu.dolphinemu.services.GameFileCacheService;
import org.dolphinemu.dolphinemu.services.GameFileCacheManager;
import org.dolphinemu.dolphinemu.ui.platform.Platform;
import org.dolphinemu.dolphinemu.utils.PicassoUtils;
import org.dolphinemu.dolphinemu.viewholders.TvGameViewHolder;
@@ -56,7 +55,7 @@ public void onBindViewHolder(ViewHolder viewHolder, Object item)

holder.cardParent.setTitleText(gameFile.getTitle());

if (GameFileCacheService.findSecondDisc(gameFile) != null)
if (GameFileCacheManager.findSecondDisc(gameFile) != null)
{
holder.cardParent
.setContentText(
@@ -15,7 +15,7 @@
import org.dolphinemu.dolphinemu.NativeLibrary;
import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.model.GameFile;
import org.dolphinemu.dolphinemu.services.GameFileCacheService;
import org.dolphinemu.dolphinemu.services.GameFileCacheManager;
import org.dolphinemu.dolphinemu.utils.PicassoUtils;

public final class GameDetailsDialog extends DialogFragment
@@ -36,7 +36,7 @@ public static GameDetailsDialog newInstance(String gamePath)
@Override
public Dialog onCreateDialog(Bundle savedInstanceState)
{
GameFile gameFile = GameFileCacheService.addOrGet(getArguments().getString(ARG_GAME_PATH));
GameFile gameFile = GameFileCacheManager.addOrGet(getArguments().getString(ARG_GAME_PATH));

AlertDialog.Builder builder = new AlertDialog.Builder(requireActivity(),
R.style.DolphinDialogBase);
@@ -10,7 +10,7 @@
import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.features.settings.ui.SettingsActivityView;
import org.dolphinemu.dolphinemu.features.settings.utils.SettingsFile;
import org.dolphinemu.dolphinemu.services.GameFileCacheService;
import org.dolphinemu.dolphinemu.services.GameFileCacheManager;
import org.dolphinemu.dolphinemu.utils.DirectoryInitialization;
import org.dolphinemu.dolphinemu.utils.IniFile;

@@ -233,7 +233,7 @@ public void saveSettings(SettingsActivityView view, Context context)
if (mLoadedRecursiveIsoPathsValue != BooleanSetting.MAIN_RECURSIVE_ISO_PATHS.getBoolean(this))
{
// Refresh game library
GameFileCacheService.startRescan(context);
GameFileCacheManager.startRescan(context);
}
}
else
@@ -20,7 +20,7 @@
import org.dolphinemu.dolphinemu.NativeLibrary;
import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.model.GameFile;
import org.dolphinemu.dolphinemu.services.GameFileCacheService;
import org.dolphinemu.dolphinemu.services.GameFileCacheManager;
import org.dolphinemu.dolphinemu.ui.platform.Platform;

import java.io.File;
@@ -136,7 +136,7 @@ public static ConvertFragment newInstance(String gamePath)
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
gameFile = GameFileCacheService.addOrGet(requireArguments().getString(ARG_GAME_PATH));
gameFile = GameFileCacheManager.addOrGet(requireArguments().getString(ARG_GAME_PATH));
}

@Override

0 comments on commit f10d95e

Please sign in to comment.