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

Commit a6ddc8af authored by Dianne Hackborn's avatar Dianne Hackborn
Browse files

Fix issue #1999179: search -> click result -> press home = search dialog is shown then hidden

Re-arrange various things to ensure that the search dialog is told about system windows being
closed before it is told about the navigation back to home.
parent ac38dfc5
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -1085,6 +1085,7 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
            reply.writeInt(result);
            return true;
        }
        
        case KILL_APPLICATION_WITH_UID_TRANSACTION: {
            data.enforceInterface(IActivityManager.descriptor);
            String pkg = data.readString();
@@ -1093,6 +1094,14 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
            reply.writeNoException();
            return true;
        }
        
        case CLOSE_SYSTEM_DIALOGS_TRANSACTION: {
            data.enforceInterface(IActivityManager.descriptor);
            String reason = data.readString();
            closeSystemDialogs(reason);
            reply.writeNoException();
            return true;
        }
        }
        
        return super.onTransact(code, data, reply, flags);
@@ -2376,6 +2385,7 @@ class ActivityManagerProxy implements IActivityManager
        data.recycle();
        return result;
    }
    
    public void killApplicationWithUid(String pkg, int uid) throws RemoteException {
        Parcel data = Parcel.obtain();
        Parcel reply = Parcel.obtain();
@@ -2388,5 +2398,16 @@ class ActivityManagerProxy implements IActivityManager
        reply.recycle();
    }
    
    public void closeSystemDialogs(String reason) throws RemoteException {
        Parcel data = Parcel.obtain();
        Parcel reply = Parcel.obtain();
        data.writeInterfaceToken(IActivityManager.descriptor);
        data.writeString(reason);
        mRemote.transact(CLOSE_SYSTEM_DIALOGS_TRANSACTION, data, reply, 0);
        reply.readException();
        data.recycle();
        reply.recycle();
    }
        
    private IBinder mRemote;
}
+4 −1
Original line number Diff line number Diff line
@@ -269,6 +269,8 @@ public interface IActivityManager extends IInterface {

    public void killApplicationWithUid(String pkg, int uid) throws RemoteException;
    
    public void closeSystemDialogs(String reason) throws RemoteException;
    
    /*
     * Private non-Binder interfaces
     */
@@ -424,4 +426,5 @@ public interface IActivityManager extends IInterface {
    int UNREGISTER_ACTIVITY_WATCHER_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+93;
    int START_ACTIVITY_IN_PACKAGE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+94;
    int KILL_APPLICATION_WITH_UID_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+95;
    int CLOSE_SYSTEM_DIALOGS_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+96;
}
+1 −0
Original line number Diff line number Diff line
@@ -23,4 +23,5 @@ package android.app;
 */
oneway interface IActivityWatcher {
    void activityResuming(int activityId);
    void closingSystemDialogs(String reason);
}
+32 −8
Original line number Diff line number Diff line
@@ -63,6 +63,8 @@ implements DialogInterface.OnCancelListener, DialogInterface.OnDismissListener {
    private static final int MSG_STOP_SEARCH = 2;
    // arg1 is activity id
    private static final int MSG_ACTIVITY_RESUMING = 3;
    // obj is the reason
    private static final int MSG_CLOSING_SYSTEM_DIALOGS = 4;

    private static final String KEY_INITIAL_QUERY = "q";
    private static final String KEY_LAUNCH_ACTIVITY = "a";
@@ -127,8 +129,7 @@ implements DialogInterface.OnCancelListener, DialogInterface.OnDismissListener {
    private void registerBroadcastReceiver() {
        if (!mReceiverRegistered) {
            IntentFilter filter = new IntentFilter(
                    Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
            filter.addAction(Intent.ACTION_CONFIGURATION_CHANGED);
                    Intent.ACTION_CONFIGURATION_CHANGED);
            mContext.registerReceiver(mBroadcastReceiver, filter, null,
                    mSearchUiThread);
            mReceiverRegistered = true;
@@ -149,12 +150,7 @@ implements DialogInterface.OnCancelListener, DialogInterface.OnDismissListener {
        @Override
        public void onReceive(Context context, Intent intent) {
            String action = intent.getAction();
            if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(action)) {
                if (!"search".equals(intent.getStringExtra("reason"))) {
                    if (DBG) debug(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
                    performStopSearch();
                }
            } else if (Intent.ACTION_CONFIGURATION_CHANGED.equals(action)) {
            if (Intent.ACTION_CONFIGURATION_CHANGED.equals(action)) {
                if (DBG) debug(Intent.ACTION_CONFIGURATION_CHANGED);
                performOnConfigurationChanged();
            }
@@ -219,6 +215,18 @@ implements DialogInterface.OnCancelListener, DialogInterface.OnDismissListener {
        mSearchUiThread.sendMessage(msg);
    }

    /**
     * Handles closing of system windows/dialogs
     * Can be called from any thread.
     */
    public void closingSystemDialogs(String reason) {
        if (DBG) debug("closingSystemDialogs(reason=" + reason + ")");
        Message msg = Message.obtain();
        msg.what = MSG_CLOSING_SYSTEM_DIALOGS;
        msg.obj = reason;
        mSearchUiThread.sendMessage(msg);
    }

    //
    // Implementation methods that run on the search UI thread
    //
@@ -244,6 +252,9 @@ implements DialogInterface.OnCancelListener, DialogInterface.OnDismissListener {
                case MSG_ACTIVITY_RESUMING:
                    performActivityResuming(msg.arg1);
                    break;
                case MSG_CLOSING_SYSTEM_DIALOGS:
                    performClosingSystemDialogs((String)msg.obj);
                    break;
            }
        }

@@ -329,6 +340,19 @@ implements DialogInterface.OnCancelListener, DialogInterface.OnDismissListener {
        }
    }

    /**
     * Updates due to system dialogs being closed
     * This must be called on the search UI thread.
     */
    void performClosingSystemDialogs(String reason) {
        if (DBG) debug("performClosingSystemDialogs(): mStartedIdent="
                + mStartedIdent + ", reason: " + reason);
        if (!"search".equals(reason)) {
            if (DBG) debug(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
            performStopSearch();
        }
    }

    /**
     * Must be called from the search UI thread.
     */
+5 −0
Original line number Diff line number Diff line
@@ -138,6 +138,11 @@ public class SearchManagerService extends ISearchManager.Stub {
            if (mSearchDialog == null) return;
            mSearchDialog.activityResuming(activityId);
        }
        public void closingSystemDialogs(String reason) {
            if (DBG) Log.i("foo", "********************** closing dialogs: " + reason);
            if (mSearchDialog == null) return;
            mSearchDialog.closingSystemDialogs(reason);
        }
    };
    
    /**
Loading