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

Commit 4addfc5f authored by Craig Mautner's avatar Craig Mautner
Browse files

Add API to convert translucent Activity to opaque.

Fixes bug 9298778.

Change-Id: If6198f42bdea8aa727a2abc672eb0062aaf63ca3
parent 144a6ae7
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -2697,6 +2697,7 @@ package android.app {
    method public void addContentView(android.view.View, android.view.ViewGroup.LayoutParams);
    method public void closeContextMenu();
    method public void closeOptionsMenu();
    method public void convertToOpaque();
    method public android.app.PendingIntent createPendingResult(int, android.content.Intent, int);
    method public final deprecated void dismissDialog(int);
    method public boolean dispatchGenericMotionEvent(android.view.MotionEvent);
+19 −0
Original line number Diff line number Diff line
@@ -4861,6 +4861,25 @@ public class Activity extends ContextThemeWrapper
        }
    }

    /**
     * Convert a translucent themed Activity {@link android.R.attr#windowIsTranslucent} to a
     * fullscreen opaque Activity.
     *
     * Call this whenever the background of a translucent Activity has changed to become opaque.
     * Doing so will allow the previously visible Activity behind this one to be stopped. Stopped
     * apps consume no CPU cycles and are eligible for removal when reclaiming memory.
     *
     * This call has no effect on non-translucent activities or on activities with the
     * {@link android.R.attr#windowIsFloating} attribute.
     */
    public void convertToOpaque() {
        try {
            ActivityManagerNative.getDefault().convertToOpaque(mToken);
        } catch (RemoteException e) {
            // pass
        }
    }

    /**
     * Adjust the current immersive mode setting.
     *
+21 −1
Original line number Diff line number Diff line
@@ -1499,6 +1499,14 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
            return true;
        }

        case CONVERT_TO_OPAQUE_TRANSACTION: {
            data.enforceInterface(IActivityManager.descriptor);
            IBinder token = data.readStrongBinder();
            convertToOpaque(token);
            reply.writeNoException();
            return true;
        }

        case SET_IMMERSIVE_TRANSACTION: {
            data.enforceInterface(IActivityManager.descriptor);
            IBinder token = data.readStrongBinder();
@@ -3824,6 +3832,18 @@ class ActivityManagerProxy implements IActivityManager
        reply.recycle();
    }

    public void convertToOpaque(IBinder token)
            throws RemoteException {
        Parcel data = Parcel.obtain();
        Parcel reply = Parcel.obtain();
        data.writeInterfaceToken(IActivityManager.descriptor);
        data.writeStrongBinder(token);
        mRemote.transact(CONVERT_TO_OPAQUE_TRANSACTION, data, reply, 0);
        reply.readException();
        data.recycle();
        reply.recycle();
    }

    public void setImmersive(IBinder token, boolean immersive)
            throws RemoteException {
        Parcel data = Parcel.obtain();
+3 −0
Original line number Diff line number Diff line
@@ -301,6 +301,8 @@ public interface IActivityManager extends IInterface {

    public void finishHeavyWeightApp() throws RemoteException;

    public void convertToOpaque(IBinder token) throws RemoteException;

    public void setImmersive(IBinder token, boolean immersive) throws RemoteException;
    public boolean isImmersive(IBinder token) throws RemoteException;
    public boolean isTopActivityImmersive() throws RemoteException;
@@ -666,4 +668,5 @@ public interface IActivityManager extends IInterface {
    int GET_STACK_BOXES_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+170;
    int SET_FOCUSED_STACK_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+171;
    int GET_STACK_BOX_INFO_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+172;
    int CONVERT_TO_OPAQUE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+173;
}
+25 −3
Original line number Diff line number Diff line
@@ -7851,12 +7851,33 @@ public final class ActivityManagerService extends ActivityManagerNative
        }
    }
    @Override
    public void unregisterProcessObserver(IProcessObserver observer) {
        synchronized (this) {
            mProcessObservers.unregister(observer);
        }
    }
    @Override
    public void convertToOpaque(IBinder token) {
        final long origId = Binder.clearCallingIdentity();
        try {
            synchronized (this) {
                final ActivityRecord r = ActivityRecord.isInStackLocked(token);
                if (r == null) {
                    return;
                }
                if (r.convertToOpaque()) {
                    mWindowManager.setAppFullscreen(token);
                    mStackSupervisor.ensureActivitiesVisibleLocked(null, 0);
                }
            }
        } finally {
            Binder.restoreCallingIdentity(origId);
        }
    }
    @Override
    public void setImmersive(IBinder token, boolean immersive) {
        synchronized(this) {
            final ActivityRecord r = ActivityRecord.isInStackLocked(token);
@@ -7875,6 +7896,7 @@ public final class ActivityManagerService extends ActivityManagerNative
        }
    }
    @Override
    public boolean isImmersive(IBinder token) {
        synchronized (this) {
            ActivityRecord r = ActivityRecord.isInStackLocked(token);
Loading