mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-14 15:00:30 +02:00
Android: Remove LifeCycle.java, keep the logging
It was a debug aid that asserted the activity callbacks arrive in the order Android promises. That has served its purpose - nothing has tripped it in a long time, and the lifecycle work this sits on top of has been exercised hard. What it also did, though, was log every callback, and that is worth keeping: the begin/end pairs are what makes a bad startup or a surprise recreate legible in a logcat. So the tracker goes and the Log.i calls stay, at the same points, under this class's own tag instead of LifeCycle's. onStart and onStop now only log, so they lose the no-native-binary guard. There is nothing left in them to guard, and if the library is missing is exactly when you want to see the callbacks. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01152igCdjTNhT29qvphPyPC
This commit is contained in:
1 parent
937022aa8e
commit
afedbab578
2 files changed
+6
-101
No files matched your search
@@ -1,86 +0,0 @@
|
||||
package org.ppsspp.ppsspp;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import android.util.Log;
|
||||
|
||||
// Simple class to validate the app lifecycle progression.
|
||||
// Useful to debug using logs.
|
||||
public class LifeCycle {
|
||||
private final String TAG = "PPSSPPNativeActivity";
|
||||
|
||||
public enum State {
|
||||
LAUNCHED,
|
||||
CREATED,
|
||||
STARTED,
|
||||
RUNNING;
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String toString() {
|
||||
// Optional: return a custom string if needed
|
||||
return name(); // "LAUNCHED", "CREATED", etc.
|
||||
}
|
||||
}
|
||||
|
||||
private State state = State.LAUNCHED;
|
||||
|
||||
public boolean onCreate() {
|
||||
if (state != State.LAUNCHED) {
|
||||
Log.e(TAG, "Lifecycle: onCreate, but state is " + state + ". Expected LAUNCHED");
|
||||
return false;
|
||||
}
|
||||
Log.i(TAG, "onCreate begin");
|
||||
state = State.CREATED;
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean onStart() {
|
||||
if (state != State.CREATED) {
|
||||
Log.e(TAG, "Lifecycle: onStart, but state is " + state + ". Expected CREATED");
|
||||
return false;
|
||||
}
|
||||
Log.i(TAG, "onStart begin");
|
||||
state = State.STARTED;
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean onResume() {
|
||||
if (state != State.STARTED) {
|
||||
Log.e(TAG, "Lifecycle: onResume, but state is " + state + ". Expected STARTED");
|
||||
return false;
|
||||
}
|
||||
state = State.RUNNING;
|
||||
Log.i(TAG, "onResume begin");
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean onPause() {
|
||||
if (state != State.RUNNING) {
|
||||
Log.e(TAG, "Lifecycle: onPause, but state is " + state + ". Expected RUNNING");
|
||||
return false;
|
||||
}
|
||||
state = State.STARTED;
|
||||
Log.i(TAG, "onPause begin");
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean onStop() {
|
||||
if (state != State.STARTED) {
|
||||
Log.e(TAG, "Lifecycle: onStop, but state is " + state + ". Expected STARTED");
|
||||
return false;
|
||||
}
|
||||
state = State.CREATED;
|
||||
Log.i(TAG, "onStop begin");
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean onDestroy() {
|
||||
if (state != State.CREATED) {
|
||||
Log.e(TAG, "Lifecycle: onDestroy, but state is " + state + ". Expected CREATED");
|
||||
return false;
|
||||
}
|
||||
state = State.LAUNCHED;
|
||||
Log.i(TAG, "onDestroy begin");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -83,9 +83,6 @@ public class PpssppActivity extends AppCompatActivity implements SensorEventList
|
||||
private static int latestInstance = 0;
|
||||
private int instance;
|
||||
|
||||
// Lifecycle tracker, to detect erroneous states.
|
||||
private final LifeCycle lifeCycle = new LifeCycle();
|
||||
|
||||
// The surface we hand to the native render loop thread, for both OpenGL and Vulkan.
|
||||
private NativeSurfaceView mSurfaceView;
|
||||
private Surface mSurface;
|
||||
@@ -678,7 +675,7 @@ public class PpssppActivity extends AppCompatActivity implements SensorEventList
|
||||
Log.i(TAG, "Found achievements host override");
|
||||
}
|
||||
|
||||
lifeCycle.onCreate();
|
||||
Log.i(TAG, "onCreate begin");
|
||||
|
||||
mSensorManager = (SensorManager)getSystemService(Activity.SENSOR_SERVICE);
|
||||
mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
|
||||
@@ -936,7 +933,7 @@ public class PpssppActivity extends AppCompatActivity implements SensorEventList
|
||||
if (m_hasNoNativeBinary) {
|
||||
return;
|
||||
}
|
||||
lifeCycle.onDestroy();
|
||||
Log.i(TAG, "onDestroy begin");
|
||||
|
||||
mSurfaceView = null;
|
||||
mSurface = null;
|
||||
@@ -986,19 +983,13 @@ public class PpssppActivity extends AppCompatActivity implements SensorEventList
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
if (m_hasNoNativeBinary) {
|
||||
return;
|
||||
}
|
||||
lifeCycle.onStart();
|
||||
Log.i(TAG, "onStart");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
if (m_hasNoNativeBinary) {
|
||||
return;
|
||||
}
|
||||
lifeCycle.onStop();
|
||||
Log.i(TAG, "onStop");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1007,7 +998,7 @@ public class PpssppActivity extends AppCompatActivity implements SensorEventList
|
||||
if (m_hasNoNativeBinary) {
|
||||
return;
|
||||
}
|
||||
lifeCycle.onPause();
|
||||
Log.i(TAG, "onPause begin");
|
||||
|
||||
InputManager inputManager = (InputManager)getSystemService(Context.INPUT_SERVICE);
|
||||
inputManager.unregisterInputDeviceListener(inputDeviceListener);
|
||||
@@ -1039,7 +1030,7 @@ public class PpssppActivity extends AppCompatActivity implements SensorEventList
|
||||
if (m_hasNoNativeBinary) {
|
||||
return;
|
||||
}
|
||||
lifeCycle.onResume();
|
||||
Log.i(TAG, "onResume begin");
|
||||
|
||||
updateSustainedPerformanceMode();
|
||||
sizeManager.onResume();
|
||||
|
||||
Reference in new issue
Block a user