-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prevent Android Cached App Freezer from freezing the replay server #3504
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package @RENDERDOC_ANDROID_PACKAGE_NAME@; | ||
import android.app.Notification; | ||
import android.content.Intent; | ||
import android.os.Binder; | ||
import android.os.Handler; | ||
import android.os.HandlerThread; | ||
import android.os.IBinder; | ||
import android.os.Looper; | ||
import android.os.Message; | ||
import android.os.Process; | ||
|
||
public class DummyService extends android.app.Service | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps something like |
||
{ | ||
private Looper serviceLooper; | ||
private Handler serviceHandler; | ||
|
||
@Override | ||
public void onCreate() { | ||
HandlerThread thread = new HandlerThread("DummyServiceThread", Process.THREAD_PRIORITY_BACKGROUND); | ||
thread.start(); | ||
|
||
serviceLooper = thread.getLooper(); | ||
serviceHandler = new Handler(serviceLooper); | ||
} | ||
|
||
@Override | ||
public int onStartCommand(Intent intent, int flags, int startId) { | ||
Notification notification = new Notification.Builder(this) | ||
.setPriority(Notification.PRIORITY_LOW) | ||
.setSmallIcon(R.drawable.icon) | ||
.setContentTitle("RenderDoc Dummy Foreground Service") | ||
.setContentText("RenderDoc needs this dummy foreground service to prevent cached app freezer from interrupting the network connection") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe something like "RenderDoc server running" as the text, with "RenderDoc" as the title? Cached app freezer is an implementation detail that's unimportant to the user. |
||
.build(); | ||
startForeground(startId, notification); | ||
|
||
// If we get killed, don't restart | ||
return START_NOT_STICKY; | ||
} | ||
|
||
@Override | ||
public IBinder onBind(Intent intent) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void onDestroy() { | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
package @RENDERDOC_ANDROID_PACKAGE_NAME@; | ||
import android.os.Build; | ||
import android.app.Activity; | ||
import android.view.WindowManager; | ||
import android.os.Environment; | ||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.os.Build; | ||
import android.os.Environment; | ||
import android.view.WindowManager; | ||
|
||
public class Loader extends android.app.NativeActivity | ||
{ | ||
|
@@ -17,6 +18,11 @@ protected void onCreate(android.os.Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | ||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); | ||
|
||
Context context = getApplicationContext(); | ||
if(context != null) { | ||
context.startService(new Intent(this, DummyService.class)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we also stop the foreground service when the activity is destroyed, or if the remote server exits for whatever reason? |
||
} | ||
|
||
// if we're running on something older than Android M (6.0), return now | ||
// before requesting permissions as it's not supported | ||
if(Build.VERSION.SDK_INT < Build.VERSION_CODES.M) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like an unrelated fix, consider moving to a separate PR.