am ebdfb6e8: Merge "[ActivityManager] Distinguish FG or BG receiver finished"
* commit 'ebdfb6e8642e649f7efe877af398eae71cd9b80c': [ActivityManager] Distinguish FG or BG receiver finished
This commit is contained in:
@@ -466,8 +466,9 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
|
||||
String resultData = data.readString();
|
||||
Bundle resultExtras = data.readBundle();
|
||||
boolean resultAbort = data.readInt() != 0;
|
||||
int intentFlags = data.readInt();
|
||||
if (who != null) {
|
||||
finishReceiver(who, resultCode, resultData, resultExtras, resultAbort);
|
||||
finishReceiver(who, resultCode, resultData, resultExtras, resultAbort, intentFlags);
|
||||
}
|
||||
reply.writeNoException();
|
||||
return true;
|
||||
@@ -2807,7 +2808,8 @@ class ActivityManagerProxy implements IActivityManager
|
||||
data.recycle();
|
||||
reply.recycle();
|
||||
}
|
||||
public void finishReceiver(IBinder who, int resultCode, String resultData, Bundle map, boolean abortBroadcast) throws RemoteException
|
||||
public void finishReceiver(IBinder who, int resultCode, String resultData, Bundle map,
|
||||
boolean abortBroadcast, int flags) throws RemoteException
|
||||
{
|
||||
Parcel data = Parcel.obtain();
|
||||
Parcel reply = Parcel.obtain();
|
||||
@@ -2817,6 +2819,7 @@ class ActivityManagerProxy implements IActivityManager
|
||||
data.writeString(resultData);
|
||||
data.writeBundle(map);
|
||||
data.writeInt(abortBroadcast ? 1 : 0);
|
||||
data.writeInt(flags);
|
||||
mRemote.transact(FINISH_RECEIVER_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY);
|
||||
reply.readException();
|
||||
data.recycle();
|
||||
|
||||
@@ -359,7 +359,7 @@ public final class ActivityThread {
|
||||
public ReceiverData(Intent intent, int resultCode, String resultData, Bundle resultExtras,
|
||||
boolean ordered, boolean sticky, IBinder token, int sendingUser) {
|
||||
super(resultCode, resultData, resultExtras, TYPE_COMPONENT, ordered, sticky,
|
||||
token, sendingUser);
|
||||
token, sendingUser, intent.getFlags());
|
||||
this.intent = intent;
|
||||
}
|
||||
|
||||
|
||||
@@ -106,7 +106,8 @@ public interface IActivityManager extends IInterface {
|
||||
String resultData, Bundle map, String requiredPermission,
|
||||
int appOp, boolean serialized, boolean sticky, int userId) throws RemoteException;
|
||||
public void unbroadcastIntent(IApplicationThread caller, Intent intent, int userId) throws RemoteException;
|
||||
public void finishReceiver(IBinder who, int resultCode, String resultData, Bundle map, boolean abortBroadcast) throws RemoteException;
|
||||
public void finishReceiver(IBinder who, int resultCode, String resultData, Bundle map,
|
||||
boolean abortBroadcast, int flags) throws RemoteException;
|
||||
public void attachApplication(IApplicationThread app) throws RemoteException;
|
||||
public void activityResumed(IBinder token) throws RemoteException;
|
||||
public void activityIdle(IBinder token, Configuration config,
|
||||
|
||||
@@ -796,7 +796,7 @@ public final class LoadedApk {
|
||||
if (extras != null) {
|
||||
extras.setAllowFds(false);
|
||||
}
|
||||
mgr.finishReceiver(this, resultCode, data, extras, false);
|
||||
mgr.finishReceiver(this, resultCode, data, extras, false, intent.getFlags());
|
||||
} catch (RemoteException e) {
|
||||
Slog.w(ActivityThread.TAG, "Couldn't finish broadcast to unregistered receiver");
|
||||
}
|
||||
@@ -821,8 +821,8 @@ public final class LoadedApk {
|
||||
public Args(Intent intent, int resultCode, String resultData, Bundle resultExtras,
|
||||
boolean ordered, boolean sticky, int sendingUser) {
|
||||
super(resultCode, resultData, resultExtras,
|
||||
mRegistered ? TYPE_REGISTERED : TYPE_UNREGISTERED,
|
||||
ordered, sticky, mIIntentReceiver.asBinder(), sendingUser);
|
||||
mRegistered ? TYPE_REGISTERED : TYPE_UNREGISTERED, ordered,
|
||||
sticky, mIIntentReceiver.asBinder(), sendingUser, intent.getFlags());
|
||||
mCurIntent = intent;
|
||||
mOrdered = ordered;
|
||||
}
|
||||
|
||||
@@ -238,6 +238,7 @@ public abstract class BroadcastReceiver {
|
||||
final boolean mInitialStickyHint;
|
||||
final IBinder mToken;
|
||||
final int mSendingUser;
|
||||
final int mFlags;
|
||||
|
||||
int mResultCode;
|
||||
String mResultData;
|
||||
@@ -246,8 +247,8 @@ public abstract class BroadcastReceiver {
|
||||
boolean mFinished;
|
||||
|
||||
/** @hide */
|
||||
public PendingResult(int resultCode, String resultData, Bundle resultExtras,
|
||||
int type, boolean ordered, boolean sticky, IBinder token, int userId) {
|
||||
public PendingResult(int resultCode, String resultData, Bundle resultExtras, int type,
|
||||
boolean ordered, boolean sticky, IBinder token, int userId, int flags) {
|
||||
mResultCode = resultCode;
|
||||
mResultData = resultData;
|
||||
mResultExtras = resultExtras;
|
||||
@@ -256,6 +257,7 @@ public abstract class BroadcastReceiver {
|
||||
mInitialStickyHint = sticky;
|
||||
mToken = token;
|
||||
mSendingUser = userId;
|
||||
mFlags = flags;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -417,11 +419,11 @@ public abstract class BroadcastReceiver {
|
||||
}
|
||||
if (mOrderedHint) {
|
||||
am.finishReceiver(mToken, mResultCode, mResultData, mResultExtras,
|
||||
mAbortBroadcast);
|
||||
mAbortBroadcast, mFlags);
|
||||
} else {
|
||||
// This broadcast was sent to a component; it is not ordered,
|
||||
// but we still need to tell the activity manager we are done.
|
||||
am.finishReceiver(mToken, 0, null, null, false);
|
||||
am.finishReceiver(mToken, 0, null, null, false, mFlags);
|
||||
}
|
||||
} catch (RemoteException ex) {
|
||||
}
|
||||
|
||||
37
services/core/java/com/android/server/am/ActivityManagerService.java
Executable file → Normal file
37
services/core/java/com/android/server/am/ActivityManagerService.java
Executable file → Normal file
@@ -399,16 +399,6 @@ public final class ActivityManagerService extends ActivityManagerNative
|
||||
return (isFg) ? mFgBroadcastQueue : mBgBroadcastQueue;
|
||||
}
|
||||
|
||||
BroadcastRecord broadcastRecordForReceiverLocked(IBinder receiver) {
|
||||
for (BroadcastQueue queue : mBroadcastQueues) {
|
||||
BroadcastRecord r = queue.getMatchingOrderedReceiver(receiver);
|
||||
if (r != null) {
|
||||
return r;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Activity we have told the window manager to have key focus.
|
||||
*/
|
||||
@@ -15314,11 +15304,11 @@ public final class ActivityManagerService extends ActivityManagerNative
|
||||
synchronized(this) {
|
||||
ReceiverList rl = mRegisteredReceivers.get(receiver.asBinder());
|
||||
if (rl != null) {
|
||||
if (rl.curBroadcast != null) {
|
||||
BroadcastRecord r = rl.curBroadcast;
|
||||
final boolean doNext = finishReceiverLocked(
|
||||
receiver.asBinder(), r.resultCode, r.resultData,
|
||||
r.resultExtras, r.resultAbort);
|
||||
final BroadcastRecord r = rl.curBroadcast;
|
||||
if (r != null && r == r.queue.getMatchingOrderedReceiver(r)) {
|
||||
final boolean doNext = r.queue.finishReceiverLocked(
|
||||
r, r.resultCode, r.resultData, r.resultExtras,
|
||||
r.resultAbort, false);
|
||||
if (doNext) {
|
||||
doTrim = true;
|
||||
r.queue.processNextBroadcast(false);
|
||||
@@ -15991,17 +15981,6 @@ public final class ActivityManagerService extends ActivityManagerNative
|
||||
}
|
||||
}
|
||||
|
||||
private final boolean finishReceiverLocked(IBinder receiver, int resultCode,
|
||||
String resultData, Bundle resultExtras, boolean resultAbort) {
|
||||
final BroadcastRecord r = broadcastRecordForReceiverLocked(receiver);
|
||||
if (r == null) {
|
||||
Slog.w(TAG, "finishReceiver called but not found on queue");
|
||||
return false;
|
||||
}
|
||||
|
||||
return r.queue.finishReceiverLocked(r, resultCode, resultData, resultExtras, resultAbort, false);
|
||||
}
|
||||
|
||||
void backgroundServicesFinishedLocked(int userId) {
|
||||
for (BroadcastQueue queue : mBroadcastQueues) {
|
||||
queue.backgroundServicesFinishedLocked(userId);
|
||||
@@ -16009,7 +15988,7 @@ public final class ActivityManagerService extends ActivityManagerNative
|
||||
}
|
||||
|
||||
public void finishReceiver(IBinder who, int resultCode, String resultData,
|
||||
Bundle resultExtras, boolean resultAbort) {
|
||||
Bundle resultExtras, boolean resultAbort, int flags) {
|
||||
if (DEBUG_BROADCAST) Slog.v(TAG, "Finish receiver: " + who);
|
||||
|
||||
// Refuse possible leaked file descriptors
|
||||
@@ -16023,7 +16002,9 @@ public final class ActivityManagerService extends ActivityManagerNative
|
||||
BroadcastRecord r;
|
||||
|
||||
synchronized(this) {
|
||||
r = broadcastRecordForReceiverLocked(who);
|
||||
BroadcastQueue queue = (flags & Intent.FLAG_RECEIVER_FOREGROUND) != 0
|
||||
? mFgBroadcastQueue : mBgBroadcastQueue;
|
||||
r = queue.getMatchingOrderedReceiver(who);
|
||||
if (r != null) {
|
||||
doNext = r.queue.finishReceiverLocked(r, resultCode,
|
||||
resultData, resultExtras, resultAbort, true);
|
||||
|
||||
Reference in New Issue
Block a user