Fields Summary |
---|
public static final int | SUCCESSSuccessful operation. |
public static final int | ERRORUnspecified error. |
public static final int | ERROR_BAD_VALUEOperation failed due to bad parameter value. |
public static final int | ERROR_DEAD_OBJECTOperation failed due to dead remote object. |
public static final long | INVALID_GROUP_IDSentinel value returned by {@link #getMasterElectionGroupId()} when an error occurs trying to
fetch the master election group. |
public static final String | SERVICE_NAMEName of the underlying native binder service |
private final Object | mListenerLock |
private OnServerDiedListener | mServerDiedListener |
private android.os.IBinder | mRemote |
private String | mInterfaceDesc |
private android.os.CommonTimeUtils | mUtils |
private IBinder.DeathRecipient | mDeathHandler |
private static final int | METHOD_GET_MASTER_ELECTION_PRIORITY |
private static final int | METHOD_SET_MASTER_ELECTION_PRIORITY |
private static final int | METHOD_GET_MASTER_ELECTION_ENDPOINT |
private static final int | METHOD_SET_MASTER_ELECTION_ENDPOINT |
private static final int | METHOD_GET_MASTER_ELECTION_GROUP_ID |
private static final int | METHOD_SET_MASTER_ELECTION_GROUP_ID |
private static final int | METHOD_GET_INTERFACE_BINDING |
private static final int | METHOD_SET_INTERFACE_BINDING |
private static final int | METHOD_GET_MASTER_ANNOUNCE_INTERVAL |
private static final int | METHOD_SET_MASTER_ANNOUNCE_INTERVAL |
private static final int | METHOD_GET_CLIENT_SYNC_INTERVAL |
private static final int | METHOD_SET_CLIENT_SYNC_INTERVAL |
private static final int | METHOD_GET_PANIC_THRESHOLD |
private static final int | METHOD_SET_PANIC_THRESHOLD |
private static final int | METHOD_GET_AUTO_DISABLE |
private static final int | METHOD_SET_AUTO_DISABLE |
private static final int | METHOD_FORCE_NETWORKLESS_MASTER_MODE |
Methods Summary |
---|
private boolean | checkDeadServer()
return ((null == mRemote) || (null == mUtils));
|
public static android.os.CommonTimeConfig | create()Handy class factory method.
CommonTimeConfig retVal;
try {
retVal = new CommonTimeConfig();
}
catch (RemoteException e) {
retVal = null;
}
return retVal;
|
protected void | finalize() release();
|
public int | forceNetworklessMasterMode()At startup, the time service enters the initial state and remains there until it is given a
network interface to bind to. Common time will be unavailable to clients of the common time
service until the service joins a network (even an empty network). Devices may use the
{@link #forceNetworklessMasterMode()} method to force a time service in the INITIAL state
with no network configuration to assume MASTER status for a brand new timeline in order to
allow clients of the common time service to operate, even though the device is isolated and
not on any network. When a networkless master does join a network, it will defer to any
masters already on the network, or continue to maintain the timeline it made up during its
networkless state if no other masters are detected. Attempting to force a client into master
mode while it is actively bound to a network will fail with the status code {@link #ERROR}
android.os.Parcel data = android.os.Parcel.obtain();
android.os.Parcel reply = android.os.Parcel.obtain();
try {
data.writeInterfaceToken(mInterfaceDesc);
mRemote.transact(METHOD_FORCE_NETWORKLESS_MASTER_MODE, data, reply, 0);
return reply.readInt();
}
catch (RemoteException e) {
return ERROR_DEAD_OBJECT;
}
finally {
reply.recycle();
data.recycle();
}
|
public boolean | getAutoDisable()Gets the current state of the common time service's auto disable flag.
throwOnDeadServer();
return (1 == mUtils.transactGetInt(METHOD_GET_AUTO_DISABLE, 1));
|
public int | getClientSyncInterval()Gets the amount of time the common time service will wait between time synchronization
requests when it is the client of another common time service on the network.
throwOnDeadServer();
return mUtils.transactGetInt(METHOD_GET_CLIENT_SYNC_INTERVAL, -1);
|
public java.lang.String | getInterfaceBinding()Gets the name of the network interface which the common time service attempts to bind to.
throwOnDeadServer();
String ifaceName = mUtils.transactGetString(METHOD_GET_INTERFACE_BINDING, null);
if ((null != ifaceName) && (0 == ifaceName.length()))
return null;
return ifaceName;
|
public int | getMasterAnnounceInterval()Gets the amount of time the common time service will wait between master announcements when
it is the timeline master.
throwOnDeadServer();
return mUtils.transactGetInt(METHOD_GET_MASTER_ANNOUNCE_INTERVAL, -1);
|
public java.net.InetSocketAddress | getMasterElectionEndpoint()Gets the IP endpoint used by the time service to participate in the master election protocol.
throwOnDeadServer();
return mUtils.transactGetSockaddr(METHOD_GET_MASTER_ELECTION_ENDPOINT);
|
public long | getMasterElectionGroupId()Gets the current group ID used by the common time service in the master election protocol.
throwOnDeadServer();
return mUtils.transactGetLong(METHOD_GET_MASTER_ELECTION_GROUP_ID, INVALID_GROUP_ID);
|
public byte | getMasterElectionPriority()Gets the current priority of the common time service used in the master election protocol.
throwOnDeadServer();
return (byte)mUtils.transactGetInt(METHOD_GET_MASTER_ELECTION_PRIORITY, -1);
|
public int | getPanicThreshold()Gets the panic threshold for the estimated error level of the common time service. When the
common time service's estimated error rises above this level, the service will panic and
reset, causing a discontinuity in the currently synchronized timeline.
throwOnDeadServer();
return mUtils.transactGetInt(METHOD_GET_PANIC_THRESHOLD, -1);
|
public void | release()Release all native resources held by this {@link android.os.CommonTimeConfig} instance. Once
resources have been released, the {@link android.os.CommonTimeConfig} instance is
disconnected from the native service and will throw a {@link android.os.RemoteException} if
any of its methods are called. Clients should always call release on their client instances
before releasing their last Java reference to the instance. Failure to do this will cause
non-deterministic native resource reclamation and may cause the common time service to remain
active on the network for longer than it should.
if (null != mRemote) {
try {
mRemote.unlinkToDeath(mDeathHandler, 0);
}
catch (NoSuchElementException e) { }
mRemote = null;
}
mUtils = null;
|
public int | setAutoDisable(boolean autoDisable)Sets the current state of the common time service's auto disable flag. When the time
service's auto disable flag is set, it will automatically cease all network activity when
it has no active local clients, resuming activity the next time the service has interested
local clients. When the auto disabled flag is cleared, the common time service will continue
to participate the time synchronization group even when it has no active local clients.
if (checkDeadServer())
return ERROR_DEAD_OBJECT;
return mUtils.transactSetInt(METHOD_SET_AUTO_DISABLE, autoDisable ? 1 : 0);
|
public int | setClientSyncInterval(int interval)Sets the amount of time the common time service will wait between time synchronization
requests when it is the client of another common time service on the network.
if (checkDeadServer())
return ERROR_DEAD_OBJECT;
return mUtils.transactSetInt(METHOD_SET_CLIENT_SYNC_INTERVAL, interval);
|
public int | setMasterAnnounceInterval(int interval)Sets the amount of time the common time service will wait between master announcements when
it is the timeline master.
if (checkDeadServer())
return ERROR_DEAD_OBJECT;
return mUtils.transactSetInt(METHOD_SET_MASTER_ANNOUNCE_INTERVAL, interval);
|
public int | setMasterElectionEndpoint(java.net.InetSocketAddress ep)Sets the IP endpoint used by the common time service to participate in the master election
protocol.
if (checkDeadServer())
return ERROR_DEAD_OBJECT;
return mUtils.transactSetSockaddr(METHOD_SET_MASTER_ELECTION_ENDPOINT, ep);
|
public int | setMasterElectionGroupId(long id)Sets the current group ID used by the common time service in the master election protocol.
if (checkDeadServer())
return ERROR_DEAD_OBJECT;
return mUtils.transactSetLong(METHOD_SET_MASTER_ELECTION_GROUP_ID, id);
|
public int | setMasterElectionPriority(byte priority)Sets the current priority of the common time service used in the master election protocol.
if (checkDeadServer())
return ERROR_DEAD_OBJECT;
return mUtils.transactSetInt(METHOD_SET_MASTER_ELECTION_PRIORITY, priority);
|
public int | setNetworkBinding(java.lang.String ifaceName)Sets the name of the network interface which the common time service should attempt to bind
to.
if (checkDeadServer())
return ERROR_DEAD_OBJECT;
return mUtils.transactSetString(METHOD_SET_INTERFACE_BINDING,
(null == ifaceName) ? "" : ifaceName);
|
public int | setPanicThreshold(int threshold)Sets the panic threshold for the estimated error level of the common time service. When the
common time service's estimated error rises above this level, the service will panic and
reset, causing a discontinuity in the currently synchronized timeline.
if (checkDeadServer())
return ERROR_DEAD_OBJECT;
return mUtils.transactSetInt(METHOD_SET_PANIC_THRESHOLD, threshold);
|
public void | setServerDiedListener(android.os.CommonTimeConfig$OnServerDiedListener listener)Registers an OnServerDiedListener interface.
Call this method with a null listener to stop receiving server death notifications.
synchronized (mListenerLock) {
mServerDiedListener = listener;
}
|
private void | throwOnDeadServer()
if (checkDeadServer())
throw new RemoteException();
|