Fixing issue with toasts not showing for guest users. am: 675c5d8e5a
am: fcf8f8382b
Change-Id: I99fa2bef8e4e2a14d2d81c812ef8cd78e2caf453
This commit is contained in:
@@ -35,4 +35,5 @@ oneway interface IRecentsNonSystemUserCallbacks {
|
||||
in Rect initialBounds);
|
||||
void onDraggingInRecents(float distanceFromTop);
|
||||
void onDraggingInRecentsEnded(float velocity);
|
||||
void showCurrentUserToast(int msgResId, int msgLength);
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -40,6 +40,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;
|
||||
@@ -396,6 +397,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.
|
||||
*/
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
@@ -1258,7 +1258,7 @@ public class TaskStackLayoutAlgorithm {
|
||||
String innerPrefix = prefix + " ";
|
||||
|
||||
writer.print(prefix); writer.print(TAG);
|
||||
writer.write(" numStackTasks="); writer.write(mNumStackTasks);
|
||||
writer.write(" numStackTasks="); writer.print(mNumStackTasks);
|
||||
writer.println();
|
||||
|
||||
writer.print(innerPrefix);
|
||||
|
||||
@@ -20,12 +20,14 @@ import android.app.ActivityOptions;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Handler;
|
||||
import android.os.UserHandle;
|
||||
import android.util.ArraySet;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.recents.events.EventBus;
|
||||
import com.android.systemui.recents.events.activity.AppTransitionFinishedEvent;
|
||||
import com.android.systemui.recents.events.component.ShowUserToastEvent;
|
||||
import com.android.systemui.recents.misc.SystemServicesProxy;
|
||||
import com.android.systemui.recents.misc.SystemServicesProxy.TaskStackListener;
|
||||
import com.android.systemui.stackdivider.events.StartedDragingEvent;
|
||||
@@ -100,9 +102,8 @@ public class ForcedResizableInfoActivityController {
|
||||
}
|
||||
|
||||
private void activityDismissingDockedStack() {
|
||||
Toast toast = Toast.makeText(mContext, R.string.dock_non_resizeble_failed_to_dock_text,
|
||||
Toast.LENGTH_SHORT);
|
||||
toast.show();
|
||||
EventBus.getDefault().send(new ShowUserToastEvent(
|
||||
R.string.dock_non_resizeble_failed_to_dock_text, Toast.LENGTH_SHORT));
|
||||
}
|
||||
|
||||
private void showPending() {
|
||||
@@ -112,7 +113,7 @@ public class ForcedResizableInfoActivityController {
|
||||
ActivityOptions options = ActivityOptions.makeBasic();
|
||||
options.setLaunchTaskId(mPendingTaskIds.valueAt(i));
|
||||
options.setTaskOverlay(true);
|
||||
mContext.startActivity(intent, options.toBundle());
|
||||
mContext.startActivityAsUser(intent, options.toBundle(), UserHandle.CURRENT);
|
||||
}
|
||||
mPendingTaskIds.clear();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user