mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 21:37:52 -07:00
Merge pull request #9079 from JosJuice/android-permissions-check
Android: Check for granted permission when returning to MainActivity
This commit is contained in:
commit
a481a52972
@ -25,7 +25,7 @@ public class DolphinApplication extends Application
|
|||||||
Java_GCAdapter.manager = (UsbManager) getSystemService(Context.USB_SERVICE);
|
Java_GCAdapter.manager = (UsbManager) getSystemService(Context.USB_SERVICE);
|
||||||
Java_WiimoteAdapter.manager = (UsbManager) getSystemService(Context.USB_SERVICE);
|
Java_WiimoteAdapter.manager = (UsbManager) getSystemService(Context.USB_SERVICE);
|
||||||
|
|
||||||
if (PermissionsHandler.hasWriteAccess(getApplicationContext()))
|
if (DirectoryInitialization.shouldStart(getApplicationContext()))
|
||||||
DirectoryInitialization.start(getApplicationContext());
|
DirectoryInitialization.start(getApplicationContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,7 +80,16 @@ public final class MainActivity extends AppCompatActivity implements MainView
|
|||||||
protected void onResume()
|
protected void onResume()
|
||||||
{
|
{
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
|
if (DirectoryInitialization.shouldStart(this))
|
||||||
|
{
|
||||||
|
DirectoryInitialization.start(this);
|
||||||
|
new AfterDirectoryInitializationRunner()
|
||||||
|
.run(this, false, this::setPlatformTabsAndStartGameFileCacheService);
|
||||||
|
}
|
||||||
|
|
||||||
mPresenter.addDirIfNeeded(this);
|
mPresenter.addDirIfNeeded(this);
|
||||||
|
|
||||||
if (sShouldRescanLibrary)
|
if (sShouldRescanLibrary)
|
||||||
{
|
{
|
||||||
GameFileCacheService.startRescan(this);
|
GameFileCacheService.startRescan(this);
|
||||||
|
@ -63,7 +63,15 @@ public final class TvMainActivity extends FragmentActivity implements MainView
|
|||||||
protected void onResume()
|
protected void onResume()
|
||||||
{
|
{
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
|
if (DirectoryInitialization.shouldStart(this))
|
||||||
|
{
|
||||||
|
DirectoryInitialization.start(this);
|
||||||
|
GameFileCacheService.startLoad(this);
|
||||||
|
}
|
||||||
|
|
||||||
mPresenter.addDirIfNeeded(this);
|
mPresenter.addDirIfNeeded(this);
|
||||||
|
|
||||||
if (sShouldRescanLibrary)
|
if (sShouldRescanLibrary)
|
||||||
{
|
{
|
||||||
GameFileCacheService.startRescan(this);
|
GameFileCacheService.startRescan(this);
|
||||||
|
@ -53,6 +53,9 @@ public final class DirectoryInitialization
|
|||||||
|
|
||||||
public static void start(Context context)
|
public static void start(Context context)
|
||||||
{
|
{
|
||||||
|
if (!isDolphinDirectoryInitializationRunning.compareAndSet(false, true))
|
||||||
|
return;
|
||||||
|
|
||||||
// Can take a few seconds to run, so don't block UI thread.
|
// Can take a few seconds to run, so don't block UI thread.
|
||||||
//noinspection TrivialFunctionalExpressionUsage
|
//noinspection TrivialFunctionalExpressionUsage
|
||||||
((Runnable) () -> init(context)).run();
|
((Runnable) () -> init(context)).run();
|
||||||
@ -60,9 +63,6 @@ public final class DirectoryInitialization
|
|||||||
|
|
||||||
private static void init(Context context)
|
private static void init(Context context)
|
||||||
{
|
{
|
||||||
if (!isDolphinDirectoryInitializationRunning.compareAndSet(false, true))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (directoryState != DirectoryInitializationState.DOLPHIN_DIRECTORIES_INITIALIZED)
|
if (directoryState != DirectoryInitializationState.DOLPHIN_DIRECTORIES_INITIALIZED)
|
||||||
{
|
{
|
||||||
if (PermissionsHandler.hasWriteAccess(context))
|
if (PermissionsHandler.hasWriteAccess(context))
|
||||||
@ -196,6 +196,12 @@ public final class DirectoryInitialization
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean shouldStart(Context context)
|
||||||
|
{
|
||||||
|
return !isDolphinDirectoryInitializationRunning.get() &&
|
||||||
|
getDolphinDirectoriesState(context) == DirectoryInitializationState.NOT_YET_INITIALIZED;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean areDolphinDirectoriesReady()
|
public static boolean areDolphinDirectoriesReady()
|
||||||
{
|
{
|
||||||
return directoryState == DirectoryInitializationState.DOLPHIN_DIRECTORIES_INITIALIZED;
|
return directoryState == DirectoryInitializationState.DOLPHIN_DIRECTORIES_INITIALIZED;
|
||||||
|
Loading…
Reference in New Issue
Block a user