mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2025-07-01 23:35:28 +00:00
Move shortcut creation/updates off the main thread for the common cases
These caused quite a few ANRs due to long Binder calls in ShortcutManager.getDynamicShortcuts()
This commit is contained in:
parent
ebfe843299
commit
0da47da8d8
@ -127,6 +127,7 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
||||
private int suppressPipRefCount = 0;
|
||||
private String pcName;
|
||||
private String appName;
|
||||
private NvApp app;
|
||||
private float desiredRefreshRate;
|
||||
|
||||
private InputCaptureProvider inputCaptureProvider;
|
||||
@ -146,8 +147,6 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
||||
private int requestedNotificationOverlayVisibility = View.GONE;
|
||||
private TextView performanceOverlayView;
|
||||
|
||||
private ShortcutHelper shortcutHelper;
|
||||
|
||||
private MediaCodecDecoderRenderer decoderRenderer;
|
||||
private boolean reportedCrash;
|
||||
|
||||
@ -318,10 +317,11 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
||||
int httpsPort = Game.this.getIntent().getIntExtra(EXTRA_HTTPS_PORT, 0); // 0 is treated as unknown
|
||||
int appId = Game.this.getIntent().getIntExtra(EXTRA_APP_ID, StreamConfiguration.INVALID_APP_ID);
|
||||
String uniqueId = Game.this.getIntent().getStringExtra(EXTRA_UNIQUEID);
|
||||
String uuid = Game.this.getIntent().getStringExtra(EXTRA_PC_UUID);
|
||||
boolean appSupportsHdr = Game.this.getIntent().getBooleanExtra(EXTRA_APP_HDR, false);
|
||||
byte[] derCertData = Game.this.getIntent().getByteArrayExtra(EXTRA_SERVER_CERT);
|
||||
|
||||
app = new NvApp(appName != null ? appName : "app", appId, appSupportsHdr);
|
||||
|
||||
X509Certificate serverCert = null;
|
||||
try {
|
||||
if (derCertData != null) {
|
||||
@ -337,17 +337,6 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
||||
return;
|
||||
}
|
||||
|
||||
// Report this shortcut being used
|
||||
ComputerDetails computer = new ComputerDetails();
|
||||
computer.name = pcName;
|
||||
computer.uuid = uuid;
|
||||
shortcutHelper = new ShortcutHelper(this);
|
||||
shortcutHelper.reportComputerShortcutUsed(computer);
|
||||
if (appName != null) {
|
||||
// This may be null if launched from the "Resume Session" PC context menu item
|
||||
shortcutHelper.reportGameLaunched(computer, new NvApp(appName, appId, appSupportsHdr));
|
||||
}
|
||||
|
||||
// Initialize the MediaCodec helper before creating the decoder
|
||||
GlPreferences glPrefs = GlPreferences.readPreferences(this);
|
||||
MediaCodecHelper.initialize(this, glPrefs.glRenderer);
|
||||
@ -479,7 +468,7 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
||||
.setResolution(prefConfig.width, prefConfig.height)
|
||||
.setLaunchRefreshRate(prefConfig.fps)
|
||||
.setRefreshRate(chosenFrameRate)
|
||||
.setApp(new NvApp(appName != null ? appName : "app", appId, appSupportsHdr))
|
||||
.setApp(app)
|
||||
.setBitrate(prefConfig.bitrate)
|
||||
.setEnableSops(prefConfig.enableSops)
|
||||
.enableLocalAudioPlayback(prefConfig.playHostAudio)
|
||||
@ -2445,6 +2434,17 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
||||
hideSystemUi(1000);
|
||||
}
|
||||
});
|
||||
|
||||
// Report this shortcut being used (off the main thread to prevent ANRs)
|
||||
ComputerDetails computer = new ComputerDetails();
|
||||
computer.name = pcName;
|
||||
computer.uuid = Game.this.getIntent().getStringExtra(EXTRA_PC_UUID);
|
||||
ShortcutHelper shortcutHelper = new ShortcutHelper(this);
|
||||
shortcutHelper.reportComputerShortcutUsed(computer);
|
||||
if (appName != null) {
|
||||
// This may be null if launched from the "Resume Session" PC context menu item
|
||||
shortcutHelper.reportGameLaunched(computer, app);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -260,6 +260,11 @@ public class PcView extends Activity implements AdapterFragmentCallbacks {
|
||||
updateComputer(details);
|
||||
}
|
||||
});
|
||||
|
||||
// Add a launcher shortcut for this PC (off the main thread to prevent ANRs)
|
||||
if (details.pairState == PairState.PAIRED) {
|
||||
shortcutHelper.createAppViewShortcutForOnlineHost(details);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -720,11 +725,6 @@ public class PcView extends Activity implements AdapterFragmentCallbacks {
|
||||
}
|
||||
}
|
||||
|
||||
// Add a launcher shortcut for this PC
|
||||
if (details.pairState == PairState.PAIRED) {
|
||||
shortcutHelper.createAppViewShortcutForOnlineHost(details);
|
||||
}
|
||||
|
||||
if (existingEntry != null) {
|
||||
// Replace the information in the existing entry
|
||||
existingEntry.details = details;
|
||||
|
Loading…
x
Reference in New Issue
Block a user