public class TileLifecycleManager extends BroadcastReceiver implements ServiceConnection, IBinder.DeathRecipient
Will keep track of all calls on the IQSTileService interface and will relay those calls to the
TileService as soon as it is bound. It will only bind to the service when it is allowed to
(setBindService(boolean)
) and when the service is available.
Modifier and Type | Class and Description |
---|---|
static interface |
TileLifecycleManager.TileChangeListener |
BroadcastReceiver.PendingResult
Modifier and Type | Field and Description |
---|---|
static boolean |
DEBUG |
Constructor and Description |
---|
TileLifecycleManager(Handler handler,
Context context,
IQSService service,
Tile tile,
Intent intent,
UserHandle user) |
Modifier and Type | Method and Description |
---|---|
IBinder |
asBinder() |
void |
binderDied() |
void |
flushMessagesAndUnbind()
Binds just long enough to send any queued messages, then unbinds.
|
ComponentName |
getComponent() |
IBinder |
getToken() |
void |
handleDestroy() |
boolean |
hasPendingClick() |
boolean |
isActiveTile() |
static boolean |
isTileAdded(Context context,
ComponentName component) |
void |
onClick(IBinder iBinder) |
void |
onReceive(Context context,
Intent intent)
This method is called when the BroadcastReceiver is receiving an Intent
broadcast.
|
void |
onServiceConnected(ComponentName name,
IBinder service)
Called when a connection to the Service has been established, with
the
IBinder of the communication channel to the
Service. |
void |
onServiceDisconnected(ComponentName name)
Called when a connection to the Service has been lost.
|
void |
onStartListening() |
void |
onStopListening() |
void |
onTileAdded() |
void |
onTileRemoved() |
void |
onUnlockComplete() |
void |
setBindService(boolean bind) |
static void |
setTileAdded(Context context,
ComponentName component,
boolean added) |
void |
setTileChangeListener(TileLifecycleManager.TileChangeListener changeListener) |
abortBroadcast, clearAbortBroadcast, getAbortBroadcast, getDebugUnregister, getPendingResult, getResultCode, getResultData, getResultExtras, getSendingUserId, goAsync, isInitialStickyBroadcast, isOrderedBroadcast, peekService, setDebugUnregister, setOrderedHint, setPendingResult, setResult, setResultCode, setResultData, setResultExtras
public static final boolean DEBUG
public TileLifecycleManager(Handler handler, Context context, IQSService service, Tile tile, Intent intent, UserHandle user)
public ComponentName getComponent()
public boolean hasPendingClick()
public boolean isActiveTile()
public void flushMessagesAndUnbind()
public void setBindService(boolean bind)
public void onServiceConnected(ComponentName name, IBinder service)
ServiceConnection
IBinder
of the communication channel to the
Service.onServiceConnected
in interface ServiceConnection
name
- The concrete component name of the service that has
been connected.service
- The IBinder of the Service's communication channel,
which you can now make calls on.public void onServiceDisconnected(ComponentName name)
ServiceConnection
ServiceConnection.onServiceConnected(android.content.ComponentName, android.os.IBinder)
when the Service is next running.onServiceDisconnected
in interface ServiceConnection
name
- The concrete component name of the service whose
connection has been lost.public void handleDestroy()
public void setTileChangeListener(TileLifecycleManager.TileChangeListener changeListener)
public void onReceive(Context context, Intent intent)
BroadcastReceiver
Context.registerReceiver(BroadcastReceiver,
IntentFilter, String, android.os.Handler)
. When it runs on the main
thread you should
never perform long-running operations in it (there is a timeout of
10 seconds that the system allows before considering the receiver to
be blocked and a candidate to be killed). You cannot launch a popup dialog
in your implementation of onReceive().
If this BroadcastReceiver was launched through a <receiver> tag,
then the object is no longer alive after returning from this
function. This means you should not perform any operations that
return a result to you asynchronously -- in particular, for interacting
with services, you should use
Context.startService(Intent)
instead of
Context.bindService(Intent, ServiceConnection, int)
. If you wish
to interact with a service that is already running, you can use
BroadcastReceiver.peekService(android.content.Context, android.content.Intent)
.
The Intent filters used in Context.registerReceiver(android.content.BroadcastReceiver, android.content.IntentFilter)
and in application manifests are not guaranteed to be exclusive. They
are hints to the operating system about how to find suitable recipients. It is
possible for senders to force delivery to specific recipients, bypassing filter
resolution. For this reason, onReceive()
implementations should respond only to known actions, ignoring any unexpected
Intents that they may receive.
onReceive
in class BroadcastReceiver
context
- The Context in which the receiver is running.intent
- The Intent being received.public void onTileAdded()
public void onTileRemoved()
public void onStartListening()
public void onStopListening()
public void onClick(IBinder iBinder)
public void onUnlockComplete()
public IBinder asBinder()
public void binderDied()
binderDied
in interface IBinder.DeathRecipient
public IBinder getToken()
public static boolean isTileAdded(Context context, ComponentName component)
public static void setTileAdded(Context context, ComponentName component, boolean added)