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

Commit 62a7c656 authored by Winson's avatar Winson Committed by android-build-merger
Browse files

Fixing issue with toasts not showing for guest users. am: 675c5d8e am: fcf8f838

am: 8a01cd98

Change-Id: Idc3faee4eaf5aa0bbcce639820db953438fe10ec
parents b33e053d 8a01cd98
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -35,4 +35,5 @@ oneway interface IRecentsNonSystemUserCallbacks {
            in Rect initialBounds);
    void onDraggingInRecents(float distanceFromTop);
    void onDraggingInRecentsEnded(float velocity);
    void showCurrentUserToast(int msgResId, int msgLength);
}
+24 −2
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@ import com.android.systemui.recents.events.activity.DockedTopTaskEvent;
import com.android.systemui.recents.events.activity.RecentsActivityStartingEvent;
import com.android.systemui.recents.events.component.RecentsVisibilityChangedEvent;
import com.android.systemui.recents.events.component.ScreenPinningRequestEvent;
import com.android.systemui.recents.events.component.ShowUserToastEvent;
import com.android.systemui.recents.events.ui.RecentsDrawnEvent;
import com.android.systemui.recents.misc.SystemServicesProxy;
import com.android.systemui.recents.model.RecentsTaskLoader;
@@ -477,8 +478,8 @@ public class Recents extends SystemUI
                mDraggingInRecentsCurrentUser = currentUser;
                return true;
            } else {
                Toast.makeText(mContext, R.string.recents_incompatible_app_message,
                        Toast.LENGTH_SHORT).show();
                EventBus.getDefault().send(new ShowUserToastEvent(
                        R.string.recents_incompatible_app_message, Toast.LENGTH_SHORT));
                return false;
            }
        } else {
@@ -696,6 +697,27 @@ public class Recents extends SystemUI
        mImpl.onConfigurationChanged();
    }

    public final void onBusEvent(ShowUserToastEvent event) {
        int currentUser = sSystemServicesProxy.getCurrentUser();
        if (sSystemServicesProxy.isSystemUser(currentUser)) {
            mImpl.onShowCurrentUserToast(event.msgResId, event.msgLength);
        } else {
            if (mSystemToUserCallbacks != null) {
                IRecentsNonSystemUserCallbacks callbacks =
                        mSystemToUserCallbacks.getNonSystemUserRecentsForUser(currentUser);
                if (callbacks != null) {
                    try {
                        callbacks.showCurrentUserToast(event.msgResId, event.msgLength);
                    } catch (RemoteException e) {
                        Log.e(TAG, "Callback failed", e);
                    }
                } else {
                    Log.e(TAG, "No SystemUI callbacks found for user: " + currentUser);
                }
            }
        }
    }

    /**
     * Attempts to register with the system user.
     */
+5 −0
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ import android.view.LayoutInflater;
import android.view.ViewConfiguration;
import android.view.WindowManager;

import android.widget.Toast;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.policy.DockedDividerUtils;
import com.android.systemui.R;
@@ -397,6 +398,10 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
        EventBus.getDefault().sendOntoMainThread(new DraggingInRecentsEndedEvent(velocity));
    }

    public void onShowCurrentUserToast(int msgResId, int msgLength) {
        Toast.makeText(mContext, msgResId, msgLength).show();
    }

    /**
     * Transitions to the next recent task in the stack.
     */
+9 −0
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ public class RecentsImplProxy extends IRecentsNonSystemUserCallbacks.Stub {
    private static final int MSG_DOCK_TOP_TASK = 7;
    private static final int MSG_ON_DRAGGING_IN_RECENTS = 8;
    private static final int MSG_ON_DRAGGING_IN_RECENTS_ENDED = 9;
    private static final int MSG_SHOW_USER_TOAST = 10;

    private RecentsImpl mImpl;

@@ -109,6 +110,11 @@ public class RecentsImplProxy extends IRecentsNonSystemUserCallbacks.Stub {
        mHandler.sendMessage(mHandler.obtainMessage(MSG_ON_DRAGGING_IN_RECENTS_ENDED, velocity));
    }

    @Override
    public void showCurrentUserToast(int msgResId, int msgLength) {
        mHandler.sendMessage(mHandler.obtainMessage(MSG_SHOW_USER_TOAST, msgResId, msgLength));
    }

    private final Handler mHandler = new Handler() {

        @Override
@@ -147,6 +153,9 @@ public class RecentsImplProxy extends IRecentsNonSystemUserCallbacks.Stub {
                case MSG_ON_DRAGGING_IN_RECENTS_ENDED:
                    mImpl.onDraggingInRecentsEnded((Float) msg.obj);
                    break;
                case MSG_SHOW_USER_TOAST:
                    mImpl.onShowCurrentUserToast(msg.arg1, msg.arg2);
                    break;
                default:
                    super.handleMessage(msg);
            }
+33 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2016 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.systemui.recents.events.component;

import com.android.systemui.recents.events.EventBus;

/**
 * This is sent when we want to show a toast for the current user.
 */
public class ShowUserToastEvent extends EventBus.Event {

    public final int msgResId;
    public final int msgLength;

    public ShowUserToastEvent(int msgResId, int msgLength) {
        this.msgResId = msgResId;
        this.msgLength = msgLength;
    }
}
Loading