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

Commit d8c16035 authored by Koji Fukui's avatar Koji Fukui Committed by Shunta Sato
Browse files

Ignore toast request of pinning if request interval is too short

Symptom:
System crash happens if an application repeatedly requests to finish
itself in pinning state.

Root cause:
Toast for pinning state is shown when the application requests to
finish itself. Every toasts use file descripters and they consumes all
available file descripters. System crash happens because of file
descriptor shortage.

Solution:
Ignore toast request for pinning state if request interval is too short.

Bug: 34211454

Change-Id: I4c3b45825270ab96fcfb24723195e9189709c2ec
parent 4a895309
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -20,6 +20,8 @@ import android.app.ActivityManager;
import android.content.Context;
import android.os.Handler;
import android.os.Message;
import android.os.SystemClock;
import android.util.Slog;
import android.view.WindowManager;
import android.widget.Toast;

@@ -31,10 +33,12 @@ import com.android.internal.R;
 */
public class LockTaskNotify {
    private static final String TAG = "LockTaskNotify";
    private static final long SHOW_TOAST_MINIMUM_INTERVAL = 1000;

    private final Context mContext;
    private final H mHandler;
    private Toast mLastToast;
    private long mLastShowToastTime;

    public LockTaskNotify(Context context) {
        mContext = context;
@@ -55,10 +59,16 @@ public class LockTaskNotify {
        if (text == null) {
            return;
        }
        long showToastTime = SystemClock.elapsedRealtime();
        if ((showToastTime - mLastShowToastTime) < SHOW_TOAST_MINIMUM_INTERVAL) {
            Slog.i(TAG, "Ignore toast since it is requested in very short interval.");
            return;
        }
        if (mLastToast != null) {
            mLastToast.cancel();
        }
        mLastToast = makeAllUserToastAndShow(text);
        mLastShowToastTime = showToastTime;
    }

    public void show(boolean starting) {