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

Commit 66b8ec99 authored by Mathias Agopian's avatar Mathias Agopian Committed by The Android Open Source Project
Browse files

AI 143171: am: CL 142873 fix [1732012] Only show screen rotation animation when triggered by sensor

  Original author: mathias
  Merged from: //branches/cupcake/...

Automated import of CL 143171
parent 1e880dba
Loading
Loading
Loading
Loading
+18 −1
Original line number Original line Diff line number Diff line
@@ -118,6 +118,12 @@ public class Surface implements Parcelable {
    public static final int ROTATION_180     = 2;
    public static final int ROTATION_180     = 2;
    public static final int ROTATION_270     = 3;
    public static final int ROTATION_270     = 3;
    
    
    /** 
     * Disable the orientation animation 
     * {@hide} 
     */
    public static final int FLAGS_ORIENTATION_ANIMATION_DISABLE = 0x000000001;

    @SuppressWarnings("unused")
    @SuppressWarnings("unused")
    private int mSurface;
    private int mSurface;
    @SuppressWarnings("unused")
    @SuppressWarnings("unused")
@@ -222,12 +228,23 @@ public class Surface implements Parcelable {
     */
     */
    public static native   void unfreezeDisplay(int display);
    public static native   void unfreezeDisplay(int display);


    /**
     * set the orientation of the given display.
     * @param display
     * @param orientation
     * @param flags
     * {@hide}
     */
    public static native   void setOrientation(int display, int orientation, int flags);

    /**
    /**
     * set the orientation of the given display.
     * set the orientation of the given display.
     * @param display
     * @param display
     * @param orientation
     * @param orientation
     */
     */
    public static native   void setOrientation(int display, int orientation);
    public static void setOrientation(int display, int orientation) {
        setOrientation(display, orientation, 0);
    }
    
    
    /**
    /**
     * set surface parameters.
     * set surface parameters.
+3 −3
Original line number Original line Diff line number Diff line
@@ -324,9 +324,9 @@ static void Surface_closeTransaction(
}
}


static void Surface_setOrientation(
static void Surface_setOrientation(
        JNIEnv* env, jobject clazz, jint display, jint orientation)
        JNIEnv* env, jobject clazz, jint display, jint orientation, jint flags)
{
{
    int err = SurfaceComposerClient::setOrientation(display, orientation);
    int err = SurfaceComposerClient::setOrientation(display, orientation, flags);
    if (err < 0) {
    if (err < 0) {
        doThrow(env, "java/lang/IllegalArgumentException", NULL);
        doThrow(env, "java/lang/IllegalArgumentException", NULL);
    }
    }
@@ -565,7 +565,7 @@ static JNINativeMethod gSurfaceMethods[] = {
	{"unlockCanvas",        "(Landroid/graphics/Canvas;)V", (void*)Surface_unlockCanvas },
	{"unlockCanvas",        "(Landroid/graphics/Canvas;)V", (void*)Surface_unlockCanvas },
	{"openTransaction",     "()V",  (void*)Surface_openTransaction },
	{"openTransaction",     "()V",  (void*)Surface_openTransaction },
    {"closeTransaction",    "()V",  (void*)Surface_closeTransaction },
    {"closeTransaction",    "()V",  (void*)Surface_closeTransaction },
    {"setOrientation",      "(II)V", (void*)Surface_setOrientation },
    {"setOrientation",      "(III)V", (void*)Surface_setOrientation },
    {"freezeDisplay",       "(I)V", (void*)Surface_freezeDisplay },
    {"freezeDisplay",       "(I)V", (void*)Surface_freezeDisplay },
    {"unfreezeDisplay",     "(I)V", (void*)Surface_unfreezeDisplay },
    {"unfreezeDisplay",     "(I)V", (void*)Surface_unfreezeDisplay },
    {"setLayer",            "(I)V", (void*)Surface_setLayer },
    {"setLayer",            "(I)V", (void*)Surface_setLayer },
+6 −1
Original line number Original line Diff line number Diff line
@@ -82,6 +82,11 @@ public:
        eOrientationSwapMask    = 0x01
        eOrientationSwapMask    = 0x01
    };
    };
    
    
    // flags for setOrientation
    enum {
        eOrientationAnimationDisable = 0x00000001
    };

    /* create connection with surface flinger, requires
    /* create connection with surface flinger, requires
     * ACCESS_SURFACE_FLINGER permission
     * ACCESS_SURFACE_FLINGER permission
     */
     */
@@ -100,7 +105,7 @@ public:
    virtual status_t unfreezeDisplay(DisplayID dpy, uint32_t flags) = 0;
    virtual status_t unfreezeDisplay(DisplayID dpy, uint32_t flags) = 0;


    /* Set display orientation. recquires ACCESS_SURFACE_FLINGER permission */
    /* Set display orientation. recquires ACCESS_SURFACE_FLINGER permission */
    virtual int setOrientation(DisplayID dpy, int orientation) = 0;
    virtual int setOrientation(DisplayID dpy, int orientation, uint32_t flags) = 0;


    /* signal that we're done booting.
    /* signal that we're done booting.
     * recquires ACCESS_SURFACE_FLINGER permission
     * recquires ACCESS_SURFACE_FLINGER permission
+1 −1
Original line number Original line Diff line number Diff line
@@ -97,7 +97,7 @@ public:
    static status_t unfreezeDisplay(DisplayID dpy, uint32_t flags = 0);
    static status_t unfreezeDisplay(DisplayID dpy, uint32_t flags = 0);


    //! Set the orientation of the given display
    //! Set the orientation of the given display
    static int setOrientation(DisplayID dpy, int orientation);
    static int setOrientation(DisplayID dpy, int orientation, uint32_t flags);


    // Query the number of displays
    // Query the number of displays
    static ssize_t getNumberOfDisplays();
    static ssize_t getNumberOfDisplays();
+15 −16
Original line number Original line Diff line number Diff line
@@ -44,11 +44,15 @@ OrientationAnimation::~OrientationAnimation()
{
{
}
}


void OrientationAnimation::onOrientationChanged()
void OrientationAnimation::onOrientationChanged(uint32_t type)
{
{
    if (mState == DONE)
    if (mState == DONE) {
        mType = type;
        if (!(type & ISurfaceComposer::eOrientationAnimationDisable)) {
            mState = PREPARE;
            mState = PREPARE;
        }
        }
    }
}


void OrientationAnimation::onAnimationFinished()
void OrientationAnimation::onAnimationFinished()
{
{
@@ -82,14 +86,7 @@ bool OrientationAnimation::run_impl()


bool OrientationAnimation::done()
bool OrientationAnimation::done()
{
{
    if (mFlinger->isFrozen()) {
    return done_impl();
        // we are not allowed to draw, but pause a bit to make sure
        // apps don't end up using the whole CPU, if they depend on
        // surfaceflinger for synchronization.
        usleep(8333); // 8.3ms ~ 120fps
        return true;
    }
    return false;
}
}


bool OrientationAnimation::prepare()
bool OrientationAnimation::prepare()
@@ -115,11 +112,13 @@ bool OrientationAnimation::prepare()


    LayerOrientationAnimBase* l;
    LayerOrientationAnimBase* l;
    
    
    if (mType & 0x80) {
        l = new LayerOrientationAnimRotate(
                mFlinger.get(), 0, this, bitmap, bitmapIn);
    } else {
        l = new LayerOrientationAnim(
        l = new LayerOrientationAnim(
                mFlinger.get(), 0, this, bitmap, bitmapIn);
                mFlinger.get(), 0, this, bitmap, bitmapIn);

    }
    //l = new LayerOrientationAnimRotate(
    //        mFlinger.get(), 0, this, bitmap, bitmapIn);


    l->initStates(w, h, 0);
    l->initStates(w, h, 0);
    l->setLayer(INT_MAX-1);
    l->setLayer(INT_MAX-1);
Loading