Merge change 8911 into donut

* changes:
  Fix issue #1999179: search -> click result -> press home = search dialog is shown then hidden
This commit is contained in:
Android (Google) Code Review
2009-07-28 22:08:30 -07:00
6 changed files with 91 additions and 9 deletions

View File

@@ -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();
@@ -2387,6 +2397,17 @@ class ActivityManagerProxy implements IActivityManager
data.recycle();
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;
}

View File

@@ -268,7 +268,9 @@ public interface IActivityManager extends IInterface {
throws RemoteException;
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;
}

View File

@@ -23,4 +23,5 @@ package android.app;
*/
oneway interface IActivityWatcher {
void activityResuming(int activityId);
void closingSystemDialogs(String reason);
}

View File

@@ -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.
*/

View File

@@ -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);
}
};
/**

View File

@@ -4760,6 +4760,34 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
}
}
public void closeSystemDialogs(String reason) {
Intent intent = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
if (reason != null) {
intent.putExtra("reason", reason);
}
final int uid = Binder.getCallingUid();
final long origId = Binder.clearCallingIdentity();
synchronized (this) {
int i = mWatchers.beginBroadcast();
while (i > 0) {
i--;
IActivityWatcher w = mWatchers.getBroadcastItem(i);
if (w != null) {
try {
w.closingSystemDialogs(reason);
} catch (RemoteException e) {
}
}
}
mWatchers.finishBroadcast();
broadcastIntentLocked(null, null, intent, null,
null, 0, null, null, null, false, false, -1, uid);
}
Binder.restoreCallingIdentity(origId);
}
private void restartPackageLocked(final String packageName, int uid) {
uninstallPackageLocked(packageName, uid, false);
Intent intent = new Intent(Intent.ACTION_PACKAGE_RESTARTED,