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

Commit d741bd50 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 9366140 from 73c69416 to tm-qpr2-release

Change-Id: I17bacb3f0cabf6c367ca49289b0118e3581c60c1
parents faa91512 73c69416
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
@@ -16,7 +16,10 @@

package android.app;

import android.annotation.NonNull;
import android.annotation.RequiresPermission;
import android.app.job.IJobScheduler;
import android.app.job.IUserVisibleJobObserver;
import android.app.job.JobInfo;
import android.app.job.JobScheduler;
import android.app.job.JobSnapshot;
@@ -119,4 +122,28 @@ public class JobSchedulerImpl extends JobScheduler {
            return null;
        }
    }

    @RequiresPermission(allOf = {
            android.Manifest.permission.MANAGE_ACTIVITY_TASKS,
            android.Manifest.permission.INTERACT_ACROSS_USERS_FULL})
    @Override
    public void registerUserVisibleJobObserver(@NonNull IUserVisibleJobObserver observer) {
        // TODO(255767350): implement
    }

    @RequiresPermission(allOf = {
            android.Manifest.permission.MANAGE_ACTIVITY_TASKS,
            android.Manifest.permission.INTERACT_ACROSS_USERS_FULL})
    @Override
    public void unregisterUserVisibleJobObserver(@NonNull IUserVisibleJobObserver observer) {
        // TODO(255767350): implement
    }

    @RequiresPermission(allOf = {
            android.Manifest.permission.MANAGE_ACTIVITY_TASKS,
            android.Manifest.permission.INTERACT_ACROSS_USERS_FULL})
    @Override
    public void stopUserVisibleJobsForUser(@NonNull String packageName, int userId) {
        // TODO(255767350): implement
    }
}
+33 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.app.job;

import android.app.job.UserVisibleJobSummary;

/**
 * IPC protocol to know about user-visible job activity.
 *
 * @hide
 */
oneway interface IUserVisibleJobObserver {
    /**
     * Notify the client of all changes to a user-visible jobs' state.
     * @param summary A token/summary that uniquely identifies and details a single running job
     * @param isRunning whether the job is currently running or not
     */
    void onUserVisibleJobStateChanged(in UserVisibleJobSummary summary, boolean isRunning);
}
+29 −1
Original line number Diff line number Diff line
@@ -237,4 +237,32 @@ public abstract class JobScheduler {
     */
    @SuppressWarnings("HiddenAbstractMethod")
    public abstract List<JobSnapshot> getAllJobSnapshots();

    /**
     * @hide
     */
    @RequiresPermission(allOf = {
            android.Manifest.permission.MANAGE_ACTIVITY_TASKS,
            android.Manifest.permission.INTERACT_ACROSS_USERS_FULL})
    @SuppressWarnings("HiddenAbstractMethod")
    public abstract void registerUserVisibleJobObserver(@NonNull IUserVisibleJobObserver observer);

    /**
     * @hide
     */
    @RequiresPermission(allOf = {
            android.Manifest.permission.MANAGE_ACTIVITY_TASKS,
            android.Manifest.permission.INTERACT_ACROSS_USERS_FULL})
    @SuppressWarnings("HiddenAbstractMethod")
    public abstract void unregisterUserVisibleJobObserver(
            @NonNull IUserVisibleJobObserver observer);

    /**
     * @hide
     */
    @RequiresPermission(allOf = {
            android.Manifest.permission.MANAGE_ACTIVITY_TASKS,
            android.Manifest.permission.INTERACT_ACROSS_USERS_FULL})
    @SuppressWarnings("HiddenAbstractMethod")
    public abstract void stopUserVisibleJobsForUser(@NonNull String packageName, int userId);
}
+19 −0
Original line number Diff line number Diff line
/**
 * Copyright (C) 2022 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.app.job;

parcelable UserVisibleJobSummary;
+122 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.app.job;

import android.annotation.NonNull;
import android.os.Parcel;
import android.os.Parcelable;

/**
 * Summary of a scheduled job that the user is meant to be aware of.
 *
 * @hide
 */
public class UserVisibleJobSummary implements Parcelable {
    private final int mCallingUid;
    private final int mSourceUserId;
    @NonNull
    private final String mSourcePackageName;
    private final int mJobId;

    public UserVisibleJobSummary(int callingUid, int sourceUserId,
            @NonNull String sourcePackageName, int jobId) {
        mCallingUid = callingUid;
        mSourceUserId = sourceUserId;
        mSourcePackageName = sourcePackageName;
        mJobId = jobId;
    }

    protected UserVisibleJobSummary(Parcel in) {
        mCallingUid = in.readInt();
        mSourceUserId = in.readInt();
        mSourcePackageName = in.readString();
        mJobId = in.readInt();
    }

    public int getCallingUid() {
        return mCallingUid;
    }

    public int getJobId() {
        return mJobId;
    }

    public int getSourceUserId() {
        return mSourceUserId;
    }

    public String getSourcePackageName() {
        return mSourcePackageName;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof UserVisibleJobSummary)) return false;
        UserVisibleJobSummary that = (UserVisibleJobSummary) o;
        return mCallingUid == that.mCallingUid
                && mSourceUserId == that.mSourceUserId
                && mSourcePackageName.equals(that.mSourcePackageName)
                && mJobId == that.mJobId;
    }

    @Override
    public int hashCode() {
        int result = 0;
        result = 31 * result + mCallingUid;
        result = 31 * result + mSourceUserId;
        result = 31 * result + mSourcePackageName.hashCode();
        result = 31 * result + mJobId;
        return result;
    }

    @Override
    public String toString() {
        return "UserVisibleJobSummary{"
                + "callingUid=" + mCallingUid
                + ", sourceUserId=" + mSourceUserId
                + ", sourcePackageName='" + mSourcePackageName + "'"
                + ", jobId=" + mJobId
                + "}";
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(mCallingUid);
        dest.writeInt(mSourceUserId);
        dest.writeString(mSourcePackageName);
        dest.writeInt(mJobId);
    }

    public static final Creator<UserVisibleJobSummary> CREATOR =
            new Creator<UserVisibleJobSummary>() {
                @Override
                public UserVisibleJobSummary createFromParcel(Parcel in) {
                    return new UserVisibleJobSummary(in);
                }

                @Override
                public UserVisibleJobSummary[] newArray(int size) {
                    return new UserVisibleJobSummary[size];
                }
            };
}
Loading