Merge "Show calling app in Task Manager."
This commit is contained in:
@@ -30,6 +30,8 @@ import java.util.Objects;
|
||||
*/
|
||||
public class UserVisibleJobSummary implements Parcelable {
|
||||
private final int mCallingUid;
|
||||
@NonNull
|
||||
private final String mCallingPackageName;
|
||||
private final int mSourceUserId;
|
||||
@NonNull
|
||||
private final String mSourcePackageName;
|
||||
@@ -37,9 +39,11 @@ public class UserVisibleJobSummary implements Parcelable {
|
||||
private final String mNamespace;
|
||||
private final int mJobId;
|
||||
|
||||
public UserVisibleJobSummary(int callingUid, int sourceUserId,
|
||||
@NonNull String sourcePackageName, String namespace, int jobId) {
|
||||
public UserVisibleJobSummary(int callingUid, @NonNull String callingPackageName,
|
||||
int sourceUserId, @NonNull String sourcePackageName,
|
||||
@Nullable String namespace, int jobId) {
|
||||
mCallingUid = callingUid;
|
||||
mCallingPackageName = callingPackageName;
|
||||
mSourceUserId = sourceUserId;
|
||||
mSourcePackageName = sourcePackageName;
|
||||
mNamespace = namespace;
|
||||
@@ -48,12 +52,18 @@ public class UserVisibleJobSummary implements Parcelable {
|
||||
|
||||
protected UserVisibleJobSummary(Parcel in) {
|
||||
mCallingUid = in.readInt();
|
||||
mCallingPackageName = in.readString();
|
||||
mSourceUserId = in.readInt();
|
||||
mSourcePackageName = in.readString();
|
||||
mNamespace = in.readString();
|
||||
mJobId = in.readInt();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public String getCallingPackageName() {
|
||||
return mCallingPackageName;
|
||||
}
|
||||
|
||||
public int getCallingUid() {
|
||||
return mCallingUid;
|
||||
}
|
||||
@@ -62,6 +72,7 @@ public class UserVisibleJobSummary implements Parcelable {
|
||||
return mJobId;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getNamespace() {
|
||||
return mNamespace;
|
||||
}
|
||||
@@ -70,6 +81,7 @@ public class UserVisibleJobSummary implements Parcelable {
|
||||
return mSourceUserId;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public String getSourcePackageName() {
|
||||
return mSourcePackageName;
|
||||
}
|
||||
@@ -80,6 +92,7 @@ public class UserVisibleJobSummary implements Parcelable {
|
||||
if (!(o instanceof UserVisibleJobSummary)) return false;
|
||||
UserVisibleJobSummary that = (UserVisibleJobSummary) o;
|
||||
return mCallingUid == that.mCallingUid
|
||||
&& mCallingPackageName.equals(that.mCallingPackageName)
|
||||
&& mSourceUserId == that.mSourceUserId
|
||||
&& mSourcePackageName.equals(that.mSourcePackageName)
|
||||
&& Objects.equals(mNamespace, that.mNamespace)
|
||||
@@ -90,6 +103,7 @@ public class UserVisibleJobSummary implements Parcelable {
|
||||
public int hashCode() {
|
||||
int result = 0;
|
||||
result = 31 * result + mCallingUid;
|
||||
result = 31 * result + mCallingPackageName.hashCode();
|
||||
result = 31 * result + mSourceUserId;
|
||||
result = 31 * result + mSourcePackageName.hashCode();
|
||||
if (mNamespace != null) {
|
||||
@@ -103,6 +117,7 @@ public class UserVisibleJobSummary implements Parcelable {
|
||||
public String toString() {
|
||||
return "UserVisibleJobSummary{"
|
||||
+ "callingUid=" + mCallingUid
|
||||
+ ", callingPackageName='" + mCallingPackageName + "'"
|
||||
+ ", sourceUserId=" + mSourceUserId
|
||||
+ ", sourcePackageName='" + mSourcePackageName + "'"
|
||||
+ ", namespace=" + mNamespace
|
||||
@@ -118,6 +133,7 @@ public class UserVisibleJobSummary implements Parcelable {
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeInt(mCallingUid);
|
||||
dest.writeString(mCallingPackageName);
|
||||
dest.writeInt(mSourceUserId);
|
||||
dest.writeString(mSourcePackageName);
|
||||
dest.writeString(mNamespace);
|
||||
|
||||
@@ -1396,7 +1396,8 @@ public final class JobStatus {
|
||||
public UserVisibleJobSummary getUserVisibleJobSummary() {
|
||||
if (mUserVisibleJobSummary == null) {
|
||||
mUserVisibleJobSummary = new UserVisibleJobSummary(
|
||||
callingUid, getSourceUserId(), getSourcePackageName(),
|
||||
callingUid, getServiceComponent().getPackageName(),
|
||||
getSourceUserId(), getSourcePackageName(),
|
||||
getNamespace(), getJobId());
|
||||
}
|
||||
return mUserVisibleJobSummary;
|
||||
|
||||
@@ -636,7 +636,8 @@ class FgsManagerControllerImpl @Inject constructor(
|
||||
isRunning: Boolean
|
||||
) {
|
||||
synchronized(lock) {
|
||||
val userPackageKey = UserPackage(summary.sourceUserId, summary.sourcePackageName)
|
||||
val userPackageKey = UserPackage(
|
||||
UserHandle.getUserId(summary.callingUid), summary.callingPackageName)
|
||||
if (isRunning) {
|
||||
runningTaskIdentifiers
|
||||
.getOrPut(userPackageKey) { StartTimeAndIdentifiers(systemClock) }
|
||||
|
||||
@@ -147,16 +147,25 @@ public class FgsManagerControllerTest extends SysuiTestCase {
|
||||
setUserProfiles(0);
|
||||
setShowUserVisibleJobs(true);
|
||||
|
||||
UserVisibleJobSummary j1 = new UserVisibleJobSummary(0, 0, "pkg1", null, 0);
|
||||
UserVisibleJobSummary j2 = new UserVisibleJobSummary(1, 0, "pkg2", null, 1);
|
||||
UserVisibleJobSummary j1 = new UserVisibleJobSummary(0, "pkg1", 0, "pkg1", null, 0);
|
||||
UserVisibleJobSummary j2 = new UserVisibleJobSummary(1, "pkg2", 0, "pkg2", null, 1);
|
||||
// pkg2 is performing work on behalf of pkg3. Since pkg2 will show the notification
|
||||
// It should be the one shown in TaskManager.
|
||||
UserVisibleJobSummary j3 = new UserVisibleJobSummary(1, "pkg2", 0, "pkg3", null, 3);
|
||||
Assert.assertEquals(0, mFmc.getNumRunningPackages());
|
||||
mIUserVisibleJobObserver.onUserVisibleJobStateChanged(j1, true);
|
||||
Assert.assertEquals(1, mFmc.getNumRunningPackages());
|
||||
mIUserVisibleJobObserver.onUserVisibleJobStateChanged(j2, true);
|
||||
Assert.assertEquals(2, mFmc.getNumRunningPackages());
|
||||
// Job3 starts running. The source package (pkg3) shouldn't matter. Since pkg2 is
|
||||
// already running, the running package count shouldn't increase.
|
||||
mIUserVisibleJobObserver.onUserVisibleJobStateChanged(j3, true);
|
||||
Assert.assertEquals(2, mFmc.getNumRunningPackages());
|
||||
mIUserVisibleJobObserver.onUserVisibleJobStateChanged(j1, false);
|
||||
Assert.assertEquals(1, mFmc.getNumRunningPackages());
|
||||
mIUserVisibleJobObserver.onUserVisibleJobStateChanged(j2, false);
|
||||
Assert.assertEquals(1, mFmc.getNumRunningPackages());
|
||||
mIUserVisibleJobObserver.onUserVisibleJobStateChanged(j3, false);
|
||||
Assert.assertEquals(0, mFmc.getNumRunningPackages());
|
||||
}
|
||||
|
||||
@@ -167,8 +176,8 @@ public class FgsManagerControllerTest extends SysuiTestCase {
|
||||
|
||||
Binder b1 = new Binder();
|
||||
Binder b2 = new Binder();
|
||||
UserVisibleJobSummary j1 = new UserVisibleJobSummary(0, 0, "pkg1", null, 0);
|
||||
UserVisibleJobSummary j3 = new UserVisibleJobSummary(1, 0, "pkg3", null, 1);
|
||||
UserVisibleJobSummary j1 = new UserVisibleJobSummary(0, "pkg1", 0, "pkg1", null, 0);
|
||||
UserVisibleJobSummary j3 = new UserVisibleJobSummary(1, "pkg3", 0, "pkg3", null, 1);
|
||||
Assert.assertEquals(0, mFmc.getNumRunningPackages());
|
||||
mIForegroundServiceObserver.onForegroundStateChanged(b1, "pkg1", 0, true);
|
||||
Assert.assertEquals(1, mFmc.getNumRunningPackages());
|
||||
@@ -359,8 +368,8 @@ public class FgsManagerControllerTest extends SysuiTestCase {
|
||||
// pkg1 has only job
|
||||
// pkg2 has both job and fgs
|
||||
// pkg3 has only fgs
|
||||
UserVisibleJobSummary j1 = new UserVisibleJobSummary(0, 0, "pkg1", null, 0);
|
||||
UserVisibleJobSummary j2 = new UserVisibleJobSummary(1, 0, "pkg2", null, 1);
|
||||
UserVisibleJobSummary j1 = new UserVisibleJobSummary(0, "pkg1", 0, "pkg1", null, 0);
|
||||
UserVisibleJobSummary j2 = new UserVisibleJobSummary(1, "pkg2", 0, "pkg2", null, 1);
|
||||
Binder b2 = new Binder();
|
||||
Binder b3 = new Binder();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user