Loading core/java/android/view/ImeInsetsSourceConsumer.java +10 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import static android.view.InsetsState.ITYPE_IME; import android.annotation.Nullable; import android.inputmethodservice.InputMethodService; import android.os.IBinder; import android.os.Parcel; import android.text.TextUtils; import android.view.SurfaceControl.Transaction; Loading Loading @@ -153,6 +154,15 @@ public final class ImeInsetsSourceConsumer extends InsetsSourceConsumer { return mIsRequestedVisibleAwaitingControl || isRequestedVisible(); } @Override public void onPerceptible(boolean perceptible) { super.onPerceptible(perceptible); final IBinder window = mController.getHost().getWindowToken(); if (window != null) { getImm().reportPerceptible(window, perceptible); } } private boolean isDummyOrEmptyEditor(EditorInfo info) { // TODO(b/123044812): Handle dummy input gracefully in IME Insets API return info == null || (info.fieldId <= 0 && info.inputType <= 0); Loading core/java/android/view/InsetsAnimationControlCallbacks.java +12 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package android.view; import android.view.WindowInsets.Type.InsetsType; import android.view.WindowInsetsAnimation.Bounds; /** Loading Loading @@ -64,4 +65,15 @@ public interface InsetsAnimationControlCallbacks { * previous calls to applySurfaceParams. */ void releaseSurfaceControlFromRt(SurfaceControl sc); /** * Reports that the perceptibility of the given types has changed to the given value. * * A type is perceptible if it is not (almost) entirely off-screen and not (almost) entirely * transparent. * * @param types the (public) types whose perceptibility has changed * @param perceptible true, if the types are now perceptible, false if they are not perceptible */ void reportPerceptible(@InsetsType int types, boolean perceptible); } core/java/android/view/InsetsAnimationControlImpl.java +14 −0 Original line number Diff line number Diff line Loading @@ -87,6 +87,7 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll private float mPendingAlpha = 1.0f; @VisibleForTesting(visibility = PACKAGE) public boolean mReadyDispatched; private Boolean mPerceptible; @VisibleForTesting public InsetsAnimationControlImpl(SparseArray<InsetsSourceControl> controls, Rect frame, Loading Loading @@ -121,6 +122,14 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll new Bounds(mHiddenInsets, mShownInsets)); } private boolean calculatePerceptible(Insets currentInsets, float currentAlpha) { return 100 * currentInsets.left >= 5 * (mShownInsets.left - mHiddenInsets.left) && 100 * currentInsets.top >= 5 * (mShownInsets.top - mHiddenInsets.top) && 100 * currentInsets.right >= 5 * (mShownInsets.right - mHiddenInsets.right) && 100 * currentInsets.bottom >= 5 * (mShownInsets.bottom - mHiddenInsets.bottom) && currentAlpha >= 0.5f; } @Override public boolean hasZeroInsetsIme() { return mHasZeroInsetsIme; Loading Loading @@ -175,6 +184,11 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll mPendingInsets = sanitize(insets); mPendingAlpha = sanitize(alpha); mController.scheduleApplyChangeInsets(this); boolean perceptible = calculatePerceptible(mPendingInsets, mPendingAlpha); if (mPerceptible == null || perceptible != mPerceptible) { mController.reportPerceptible(mTypes, perceptible); mPerceptible = perceptible; } } @VisibleForTesting Loading core/java/android/view/InsetsAnimationThreadControlRunner.java +5 −0 Original line number Diff line number Diff line Loading @@ -90,6 +90,11 @@ public class InsetsAnimationThreadControlRunner implements InsetsAnimationContro // Since we don't push the SurfaceParams to the RT we can release directly sc.release(); } @Override public void reportPerceptible(int types, boolean perceptible) { mMainThreadHandler.post(() -> mOuterCallbacks.reportPerceptible(types, perceptible)); } }; @UiThread Loading core/java/android/view/InsetsController.java +19 −0 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ import android.graphics.Insets; import android.graphics.Rect; import android.os.CancellationSignal; import android.os.Handler; import android.os.IBinder; import android.os.Trace; import android.util.ArraySet; import android.util.Log; Loading Loading @@ -165,6 +166,12 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation /** @see ViewRootImpl#dipToPx */ int dipToPx(int dips); /** * @return token associated with the host, if it has one. */ @Nullable IBinder getWindowToken(); } private static final String TAG = "InsetsController"; Loading Loading @@ -1353,6 +1360,18 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation mHost.releaseSurfaceControlFromRt(sc); } @Override public void reportPerceptible(int types, boolean perceptible) { final ArraySet<Integer> internalTypes = toInternalType(types); final int size = mSourceConsumers.size(); for (int i = 0; i < size; i++) { final InsetsSourceConsumer consumer = mSourceConsumers.valueAt(i); if (internalTypes.contains(consumer.getType())) { consumer.onPerceptible(perceptible); } } } Host getHost() { return mHost; } Loading Loading
core/java/android/view/ImeInsetsSourceConsumer.java +10 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import static android.view.InsetsState.ITYPE_IME; import android.annotation.Nullable; import android.inputmethodservice.InputMethodService; import android.os.IBinder; import android.os.Parcel; import android.text.TextUtils; import android.view.SurfaceControl.Transaction; Loading Loading @@ -153,6 +154,15 @@ public final class ImeInsetsSourceConsumer extends InsetsSourceConsumer { return mIsRequestedVisibleAwaitingControl || isRequestedVisible(); } @Override public void onPerceptible(boolean perceptible) { super.onPerceptible(perceptible); final IBinder window = mController.getHost().getWindowToken(); if (window != null) { getImm().reportPerceptible(window, perceptible); } } private boolean isDummyOrEmptyEditor(EditorInfo info) { // TODO(b/123044812): Handle dummy input gracefully in IME Insets API return info == null || (info.fieldId <= 0 && info.inputType <= 0); Loading
core/java/android/view/InsetsAnimationControlCallbacks.java +12 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package android.view; import android.view.WindowInsets.Type.InsetsType; import android.view.WindowInsetsAnimation.Bounds; /** Loading Loading @@ -64,4 +65,15 @@ public interface InsetsAnimationControlCallbacks { * previous calls to applySurfaceParams. */ void releaseSurfaceControlFromRt(SurfaceControl sc); /** * Reports that the perceptibility of the given types has changed to the given value. * * A type is perceptible if it is not (almost) entirely off-screen and not (almost) entirely * transparent. * * @param types the (public) types whose perceptibility has changed * @param perceptible true, if the types are now perceptible, false if they are not perceptible */ void reportPerceptible(@InsetsType int types, boolean perceptible); }
core/java/android/view/InsetsAnimationControlImpl.java +14 −0 Original line number Diff line number Diff line Loading @@ -87,6 +87,7 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll private float mPendingAlpha = 1.0f; @VisibleForTesting(visibility = PACKAGE) public boolean mReadyDispatched; private Boolean mPerceptible; @VisibleForTesting public InsetsAnimationControlImpl(SparseArray<InsetsSourceControl> controls, Rect frame, Loading Loading @@ -121,6 +122,14 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll new Bounds(mHiddenInsets, mShownInsets)); } private boolean calculatePerceptible(Insets currentInsets, float currentAlpha) { return 100 * currentInsets.left >= 5 * (mShownInsets.left - mHiddenInsets.left) && 100 * currentInsets.top >= 5 * (mShownInsets.top - mHiddenInsets.top) && 100 * currentInsets.right >= 5 * (mShownInsets.right - mHiddenInsets.right) && 100 * currentInsets.bottom >= 5 * (mShownInsets.bottom - mHiddenInsets.bottom) && currentAlpha >= 0.5f; } @Override public boolean hasZeroInsetsIme() { return mHasZeroInsetsIme; Loading Loading @@ -175,6 +184,11 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll mPendingInsets = sanitize(insets); mPendingAlpha = sanitize(alpha); mController.scheduleApplyChangeInsets(this); boolean perceptible = calculatePerceptible(mPendingInsets, mPendingAlpha); if (mPerceptible == null || perceptible != mPerceptible) { mController.reportPerceptible(mTypes, perceptible); mPerceptible = perceptible; } } @VisibleForTesting Loading
core/java/android/view/InsetsAnimationThreadControlRunner.java +5 −0 Original line number Diff line number Diff line Loading @@ -90,6 +90,11 @@ public class InsetsAnimationThreadControlRunner implements InsetsAnimationContro // Since we don't push the SurfaceParams to the RT we can release directly sc.release(); } @Override public void reportPerceptible(int types, boolean perceptible) { mMainThreadHandler.post(() -> mOuterCallbacks.reportPerceptible(types, perceptible)); } }; @UiThread Loading
core/java/android/view/InsetsController.java +19 −0 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ import android.graphics.Insets; import android.graphics.Rect; import android.os.CancellationSignal; import android.os.Handler; import android.os.IBinder; import android.os.Trace; import android.util.ArraySet; import android.util.Log; Loading Loading @@ -165,6 +166,12 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation /** @see ViewRootImpl#dipToPx */ int dipToPx(int dips); /** * @return token associated with the host, if it has one. */ @Nullable IBinder getWindowToken(); } private static final String TAG = "InsetsController"; Loading Loading @@ -1353,6 +1360,18 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation mHost.releaseSurfaceControlFromRt(sc); } @Override public void reportPerceptible(int types, boolean perceptible) { final ArraySet<Integer> internalTypes = toInternalType(types); final int size = mSourceConsumers.size(); for (int i = 0; i < size; i++) { final InsetsSourceConsumer consumer = mSourceConsumers.valueAt(i); if (internalTypes.contains(consumer.getType())) { consumer.onPerceptible(perceptible); } } } Host getHost() { return mHost; } Loading