Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 454de9dd authored by Yasin Kilicdere's avatar Yasin Kilicdere Committed by Automerger Merge Worker
Browse files

Merge "Add traces to WallpaperManagerService and WallpaperService." into tm-qpr-dev am: e9bad1ca

parents 38a88cca e9bad1ca
Loading
Loading
Loading
Loading
+54 −12
Original line number Diff line number Diff line
@@ -578,6 +578,7 @@ public abstract class WallpaperService extends Service {
         */
        public void reportEngineShown(boolean waitForEngineShown) {
            if (mIWallpaperEngine.mShownReported) return;
            Trace.beginSection("WPMS.reportEngineShown-" + waitForEngineShown);
            Log.d(TAG, "reportEngineShown: shouldWait=" + waitForEngineShown);
            if (!waitForEngineShown) {
                Message message = mCaller.obtainMessage(MSG_REPORT_SHOWN);
@@ -590,6 +591,7 @@ public abstract class WallpaperService extends Service {
                    mCaller.sendMessageDelayed(message, TimeUnit.SECONDS.toMillis(5));
                }
            }
            Trace.endSection();
        }

        /**
@@ -1259,7 +1261,9 @@ public abstract class WallpaperService extends Service {
                            didSurface = true;
                            if (DEBUG) Log.v(TAG, "onSurfaceCreated("
                                    + mSurfaceHolder + "): " + this);
                            Trace.beginSection("WPMS.Engine.onSurfaceCreated");
                            onSurfaceCreated(mSurfaceHolder);
                            Trace.endSection();
                            SurfaceHolder.Callback callbacks[] = mSurfaceHolder.getCallbacks();
                            if (callbacks != null) {
                                for (SurfaceHolder.Callback c : callbacks) {
@@ -1285,8 +1289,10 @@ public abstract class WallpaperService extends Service {
                                    + ", " + mCurWidth + ", " + mCurHeight
                                    + "): " + this);
                            didSurface = true;
                            Trace.beginSection("WPMS.Engine.onSurfaceChanged");
                            onSurfaceChanged(mSurfaceHolder, mFormat,
                                    mCurWidth, mCurHeight);
                            Trace.endSection();
                            SurfaceHolder.Callback callbacks[] = mSurfaceHolder.getCallbacks();
                            if (callbacks != null) {
                                for (SurfaceHolder.Callback c : callbacks) {
@@ -1303,11 +1309,15 @@ public abstract class WallpaperService extends Service {
                            if (DEBUG) {
                                Log.v(TAG, "dispatching insets=" + windowInsets);
                            }
                            Trace.beginSection("WPMS.Engine.onApplyWindowInsets");
                            onApplyWindowInsets(windowInsets);
                            Trace.endSection();
                        }

                        if (redrawNeeded) {
                            Trace.beginSection("WPMS.Engine.onSurfaceRedrawNeeded");
                            onSurfaceRedrawNeeded(mSurfaceHolder);
                            Trace.endSection();
                            SurfaceHolder.Callback callbacks[] = mSurfaceHolder.getCallbacks();
                            if (callbacks != null) {
                                for (SurfaceHolder.Callback c : callbacks) {
@@ -1332,11 +1342,15 @@ public abstract class WallpaperService extends Service {
                                // the state to get them to notice.
                                if (DEBUG) Log.v(TAG, "onVisibilityChanged(true) at surface: "
                                        + this);
                                Trace.beginSection("WPMS.Engine.onVisibilityChanged-true");
                                onVisibilityChanged(true);
                                Trace.endSection();
                            }
                            if (DEBUG) Log.v(TAG, "onVisibilityChanged(false) at surface: "
                                        + this);
                            Trace.beginSection("WPMS.Engine.onVisibilityChanged-false");
                            onVisibilityChanged(false);
                            Trace.endSection();
                        }
                    } finally {
                        mIsCreating = false;
@@ -1422,12 +1436,16 @@ public abstract class WallpaperService extends Service {
            mDisplayInstallOrientation = mDisplay.getInstallOrientation();

            if (DEBUG) Log.v(TAG, "onCreate(): " + this);
            Trace.beginSection("WPMS.Engine.onCreate");
            onCreate(mSurfaceHolder);
            Trace.endSection();

            mInitializing = false;

            mReportedVisible = false;
            Trace.beginSection("WPMS.Engine.updateSurface");
            updateSurface(false, false, false);
            Trace.endSection();
        }

        /**
@@ -2237,14 +2255,15 @@ public abstract class WallpaperService extends Service {
        public void reportShown() {
            if (!mShownReported) {
                mShownReported = true;
                Trace.beginSection("WPMS.mConnection.engineShown");
                try {
                    mConnection.engineShown(this);
                    Log.d(TAG, "Wallpaper has updated the surface:"
                            + mWallpaperManager.getWallpaperInfo());
                } catch (RemoteException e) {
                    Log.w(TAG, "Wallpaper host disappeared", e);
                    return;
                }
                Trace.endSection();
            }
        }

@@ -2286,6 +2305,27 @@ public abstract class WallpaperService extends Service {
            return mEngine == null ? null : SurfaceControl.mirrorSurface(mEngine.mSurfaceControl);
        }

        private void doAttachEngine() {
            Trace.beginSection("WPMS.onCreateEngine");
            Engine engine = onCreateEngine();
            Trace.endSection();
            mEngine = engine;
            Trace.beginSection("WPMS.mConnection.attachEngine-" + mDisplayId);
            try {
                mConnection.attachEngine(this, mDisplayId);
            } catch (RemoteException e) {
                engine.detach();
                Log.w(TAG, "Wallpaper host disappeared", e);
                return;
            } finally {
                Trace.endSection();
            }
            mActiveEngines.add(engine);
            Trace.beginSection("WPMS.engine.attach");
            engine.attach(this);
            Trace.endSection();
        }

        private void doDetachEngine() {
            mActiveEngines.remove(mEngine);
            mEngine.detach();
@@ -2311,21 +2351,15 @@ public abstract class WallpaperService extends Service {
            }
            switch (message.what) {
                case DO_ATTACH: {
                    Engine engine = onCreateEngine();
                    mEngine = engine;
                    try {
                        mConnection.attachEngine(this, mDisplayId);
                    } catch (RemoteException e) {
                        engine.detach();
                        Log.w(TAG, "Wallpaper host disappeared", e);
                        return;
                    }
                    mActiveEngines.add(engine);
                    engine.attach(this);
                    Trace.beginSection("WPMS.DO_ATTACH");
                    doAttachEngine();
                    Trace.endSection();
                    return;
                }
                case DO_DETACH: {
                    Trace.beginSection("WPMS.DO_DETACH");
                    doDetachEngine();
                    Trace.endSection();
                    return;
                }
                case DO_SET_DESIRED_SIZE: {
@@ -2406,7 +2440,9 @@ public abstract class WallpaperService extends Service {
                    }
                } break;
                case MSG_REPORT_SHOWN: {
                    Trace.beginSection("WPMS.MSG_REPORT_SHOWN");
                    reportShown();
                    Trace.endSection();
                } break;
                default :
                    Log.w(TAG, "Unknown message type " + message.what);
@@ -2430,8 +2466,10 @@ public abstract class WallpaperService extends Service {
        public void attach(IWallpaperConnection conn, IBinder windowToken,
                int windowType, boolean isPreview, int reqWidth, int reqHeight, Rect padding,
                int displayId, @SetWallpaperFlags int which) {
            Trace.beginSection("WPMS.ServiceWrapper.attach");
            mEngineWrapper = new IWallpaperEngineWrapper(mTarget, conn, windowToken,
                    windowType, isPreview, reqWidth, reqHeight, padding, displayId);
            Trace.endSection();
        }

        @Override
@@ -2442,16 +2480,20 @@ public abstract class WallpaperService extends Service {

    @Override
    public void onCreate() {
        Trace.beginSection("WPMS.onCreate");
        super.onCreate();
        Trace.endSection();
    }

    @Override
    public void onDestroy() {
        Trace.beginSection("WPMS.onDestroy");
        super.onDestroy();
        for (int i=0; i<mActiveEngines.size(); i++) {
            mActiveEngines.get(i).detach();
        }
        mActiveEngines.clear();
        Trace.endSection();
    }

    /**
+19 −0
Original line number Diff line number Diff line
@@ -1157,6 +1157,8 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
                    Slog.w(TAG, "WallpaperService is not connected yet");
                    return;
                }
                TimingsTraceAndSlog t = new TimingsTraceAndSlog(TAG);
                t.traceBegin("WPMS.connectLocked-" + wallpaper.wallpaperComponent);
                if (DEBUG) Slog.v(TAG, "Adding window token: " + mToken);
                mWindowManagerInternal.addWindowToken(mToken, TYPE_WALLPAPER, mDisplayId,
                        null /* options */);
@@ -1173,6 +1175,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
                                false /* fromUser */, wallpaper, null /* reply */);
                    }
                }
                t.traceEnd();
            }

            void disconnectLocked() {
@@ -1322,6 +1325,8 @@ public class WallpaperManagerService extends IWallpaperManager.Stub

        @Override
        public void onServiceConnected(ComponentName name, IBinder service) {
            TimingsTraceAndSlog t = new TimingsTraceAndSlog(TAG);
            t.traceBegin("WPMS.onServiceConnected-" + name);
            synchronized (mLock) {
                if (mWallpaper.connection == this) {
                    mService = IWallpaperService.Stub.asInterface(service);
@@ -1338,6 +1343,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
                    mContext.getMainThreadHandler().removeCallbacks(mDisconnectRunnable);
                }
            }
            t.traceEnd();
        }

        @Override
@@ -1545,6 +1551,8 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
        public void engineShown(IWallpaperEngine engine) {
            synchronized (mLock) {
                if (mReply != null) {
                    TimingsTraceAndSlog t = new TimingsTraceAndSlog(TAG);
                    t.traceBegin("WPMS.mReply.sendResult");
                    final long ident = Binder.clearCallingIdentity();
                    try {
                        mReply.sendResult(null);
@@ -1552,6 +1560,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
                        Binder.restoreCallingIdentity(ident);
                        Slog.d(TAG, "failed to send callback!", e);
                    }
                    t.traceEnd();
                    mReply = null;
                }
            }
@@ -3057,6 +3066,8 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
            return true;
        }

        TimingsTraceAndSlog t = new TimingsTraceAndSlog(TAG);
        t.traceBegin("WPMS.bindWallpaperComponentLocked-" + componentName);
        try {
            if (componentName == null) {
                componentName = mDefaultWallpaperComponent;
@@ -3189,6 +3200,8 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
            }
            Slog.w(TAG, msg);
            return false;
        } finally {
            t.traceEnd();
        }
        return true;
    }
@@ -3233,7 +3246,10 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
    }

    private void attachServiceLocked(WallpaperConnection conn, WallpaperData wallpaper) {
        TimingsTraceAndSlog t = new TimingsTraceAndSlog(TAG);
        t.traceBegin("WPMS.attachServiceLocked");
        conn.forEachDisplayConnector(connector-> connector.connectLocked(conn, wallpaper));
        t.traceEnd();
    }

    private void notifyCallbacksLocked(WallpaperData wallpaper) {
@@ -3359,6 +3375,8 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
    }

    void saveSettingsLocked(int userId) {
        TimingsTraceAndSlog t = new TimingsTraceAndSlog(TAG);
        t.traceBegin("WPMS.saveSettingsLocked-" + userId);
        JournaledFile journal = makeJournaledFile(userId);
        FileOutputStream fstream = null;
        try {
@@ -3387,6 +3405,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
            IoUtils.closeQuietly(fstream);
            journal.rollback();
        }
        t.traceEnd();
    }