![JAR search and dependency download from the Maven repository](/logo.png)
src.android.telephony.BinderCacheManager Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of android-all Show documentation
Show all versions of android-all Show documentation
A library jar that provides APIs for Applications written for the Google Android Platform.
/*
* Copyright (C) 2020 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.telephony;
import android.annotation.NonNull;
import android.os.IBinder;
import android.os.IInterface;
import android.os.RemoteException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.NoSuchElementException;
import java.util.concurrent.atomic.AtomicReference;
/**
* Keeps track of the connection to a Binder node, refreshes the cache if the node dies, and lets
* interested parties register listeners on the node to be notified when the node has died via the
* registered {@link Runnable}.
* @param The IInterface representing the Binder type that this manager will be managing the
* cache of.
* @hide
*/
public class BinderCacheManager {
/**
* Factory class for creating new IInterfaces in the case that {@link #getBinder()} is
* called and there is no active binder available.
* @param The IInterface that should be cached and returned to the caller when
* {@link #getBinder()} is called until the Binder node dies.
*/
public interface BinderInterfaceFactory {
/**
* @return A new instance of the Binder node, which will be cached until it dies.
*/
T create();
}
/**
* Tracks the cached Binder node as well as the listeners that were associated with that
* Binder node during its lifetime. If the Binder node dies, the listeners will be called and
* then this tracker will be unlinked and cleaned up.
*/
private class BinderDeathTracker implements IBinder.DeathRecipient {
private final T mConnection;
private final HashMap
© 2015 - 2025 Weber Informatics LLC | Privacy Policy