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

Commit 980276e3 authored by Dianne Hackborn's avatar Dianne Hackborn Committed by The Android Automerger
Browse files

Implement issue #17906468: Allow search request to fall back to global search

Change-Id: I04834b2a9f1ec4a68c6a3fed14da2f8dd93b3be7
parent c6c4b377
Loading
Loading
Loading
Loading
+14 −4
Original line number Diff line number Diff line
@@ -3498,14 +3498,24 @@ public class Activity extends ContextThemeWrapper
     * <p>You can override this function to force global search, e.g. in response to a dedicated
     * search key, or to block search entirely (by simply returning false).
     *
     * @return Returns {@code true} if search launched, and {@code false} if activity blocks it.
     *         The default implementation always returns {@code true}.
     * <p>Note: when running in a {@link Configuration#UI_MODE_TYPE_TELEVISION}, the default
     * implementation changes to simply return false and you must supply your own custom
     * implementation if you want to support search.</p>
     *
     * @return Returns {@code true} if search launched, and {@code false} if the activity does
     * not respond to search.  The default implementation always returns {@code true}, except
     * when in {@link Configuration#UI_MODE_TYPE_TELEVISION} mode where it returns false.
     *
     * @see android.app.SearchManager
     */
    public boolean onSearchRequested() {
        if ((getResources().getConfiguration().uiMode&Configuration.UI_MODE_TYPE_MASK)
                != Configuration.UI_MODE_TYPE_TELEVISION) {
            startSearch(null, false, null, false);
            return true;
        } else {
            return false;
        }
    }

    /**
+30 −1
Original line number Diff line number Diff line
@@ -2102,6 +2102,18 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
            return true;
        }

        case LAUNCH_ASSIST_INTENT_TRANSACTION: {
            data.enforceInterface(IActivityManager.descriptor);
            Intent intent = Intent.CREATOR.createFromParcel(data);
            int requestType = data.readInt();
            String hint = data.readString();
            int userHandle = data.readInt();
            boolean res = launchAssistIntent(intent, requestType, hint, userHandle);
            reply.writeNoException();
            reply.writeInt(res ? 1 : 0);
            return true;
        }

        case KILL_UID_TRANSACTION: {
            data.enforceInterface(IActivityManager.descriptor);
            int uid = data.readInt();
@@ -5039,6 +5051,23 @@ class ActivityManagerProxy implements IActivityManager
        reply.recycle();
    }

    public boolean launchAssistIntent(Intent intent, int requestType, String hint, int userHandle)
            throws RemoteException {
        Parcel data = Parcel.obtain();
        Parcel reply = Parcel.obtain();
        data.writeInterfaceToken(IActivityManager.descriptor);
        intent.writeToParcel(data, 0);
        data.writeInt(requestType);
        data.writeString(hint);
        data.writeInt(userHandle);
        mRemote.transact(LAUNCH_ASSIST_INTENT_TRANSACTION, data, reply, 0);
        reply.readException();
        boolean res = reply.readInt() != 0;
        data.recycle();
        reply.recycle();
        return res;
    }

    public void killUid(int uid, String reason) throws RemoteException {
        Parcel data = Parcel.obtain();
        Parcel reply = Parcel.obtain();
+4 −0
Original line number Diff line number Diff line
@@ -417,6 +417,9 @@ public interface IActivityManager extends IInterface {

    public void reportAssistContextExtras(IBinder token, Bundle extras) throws RemoteException;

    public boolean launchAssistIntent(Intent intent, int requestType, String hint, int userHandle)
            throws RemoteException;

    public void killUid(int uid, String reason) throws RemoteException;

    public void hang(IBinder who, boolean allowRestart) throws RemoteException;
@@ -777,4 +780,5 @@ public interface IActivityManager extends IInterface {
    int RELEASE_SOME_ACTIVITIES_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+236;
    int BOOT_ANIMATION_COMPLETE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+237;
    int GET_TASK_DESCRIPTION_ICON_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+238;
    int LAUNCH_ASSIST_INTENT_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+239;
}
+1 −0
Original line number Diff line number Diff line
@@ -31,4 +31,5 @@ interface ISearchManager {
   ComponentName getGlobalSearchActivity();
   ComponentName getWebSearchActivity();
   ComponentName getAssistIntent(int userHandle);
   boolean launchAssistAction(int requestType, String hint, int userHandle);
}
+16 −0
Original line number Diff line number Diff line
@@ -989,4 +989,20 @@ public class SearchManager
            return null;
        }
    }

    /**
     * Launch an assist action for the current top activity.
     * @hide
     */
    public boolean launchAssistAction(int requestType, String hint, int userHandle) {
        try {
            if (mService == null) {
                return false;
            }
            return mService.launchAssistAction(requestType, hint, userHandle);
        } catch (RemoteException re) {
            Log.e(TAG, "launchAssistAction() failed: " + re);
            return false;
        }
    }
}
Loading