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

Commit 1d261135 authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

More misc `android.os` on Ravenwood.

Bring along some general utils along with tests to confirm their
behavior is consistent between devices and Ravenwood

Bug: 324417456
Test: atest FrameworksCoreTestsRavenwood
Change-Id: Idbf1265d8c487701c3605f446c8d7d005a34ebc4
parent 23d50f5d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.compat.annotation.UnsupportedAppUsage;
/**
 * Provides the ability to cancel an operation in progress.
 */
@android.ravenwood.annotation.RavenwoodKeepWholeClass
public final class CancellationSignal {
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
    private boolean mIsCanceled;
+6 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.compat.annotation.UnsupportedAppUsage;
 * @hide
 */
@SystemApi
@android.ravenwood.annotation.RavenwoodKeepWholeClass
public final class RemoteCallback implements Parcelable {

    public interface OnResultListener {
@@ -84,6 +85,11 @@ public final class RemoteCallback implements Parcelable {
        }
    }

    /** @hide */
    public IRemoteCallback getInterface() {
        return mCallback;
    }

    @Override
    public int describeContents() {
        return 0;
+1 −0
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ import java.util.function.Consumer;
 * additional work in this situation, you can create a subclass that
 * implements the {@link #onCallbackDied} method.
 */
@android.ravenwood.annotation.RavenwoodKeepWholeClass
public class RemoteCallbackList<E extends IInterface> {
    private static final String TAG = "RemoteCallbackList";

+1 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import com.android.internal.os.IResultReceiver;
 * the system that your process needs to continue running), the connection will
 * break if your process goes away for any reason, etc.</p>
 */
@android.ravenwood.annotation.RavenwoodKeepWholeClass
public class ResultReceiver implements Parcelable {
    final boolean mLocal;
    final Handler mHandler;
+53 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 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.os;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import android.platform.test.ravenwood.RavenwoodRule;

import androidx.test.runner.AndroidJUnit4;

import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

@RunWith(AndroidJUnit4.class)
public class CancellationSignalTest {
    @Rule
    public final RavenwoodRule mRavenwood = new RavenwoodRule.Builder()
            .setProvideMainThread(true)
            .build();

    @Test
    public void testSimple() throws Exception {
        final CancellationSignal signal = new CancellationSignal();
        final CountDownLatch latch = new CountDownLatch(1);
        signal.setOnCancelListener(() -> {
            latch.countDown();
        });

        assertFalse(signal.isCanceled());
        signal.cancel();
        assertTrue(signal.isCanceled());
        assertTrue(latch.await(100, TimeUnit.MILLISECONDS));
    }
}
Loading