public class EnabledComponentsObserver extends Object implements SettingsObserver.SettingChangeListener
Modifier and Type | Class and Description |
---|---|
static interface |
EnabledComponentsObserver.EnabledComponentChangeListener
Implement this to receive callbacks when relevant changes to the allowed components occur.
|
Modifier and Type | Field and Description |
---|---|
static int |
DISABLED |
static int |
NO_ERROR |
static int |
NOT_INSTALLED |
Modifier and Type | Method and Description |
---|---|
static EnabledComponentsObserver |
build(Context context,
Handler handler,
String settingName,
Looper looper,
String servicePermission,
String serviceName,
Object lock,
Collection<EnabledComponentsObserver.EnabledComponentChangeListener> listeners)
Create a EnabledComponentObserver instance.
|
ArraySet<ComponentName> |
getEnabled(int userId)
Return all VrListenerService components enabled for this user.
|
ArraySet<ComponentName> |
getInstalled(int userId)
Return all VrListenerService components installed for this user.
|
int |
isValid(ComponentName component,
int userId)
Check whether a given component is present and enabled for the given user.
|
static ArraySet<ComponentName> |
loadComponentNames(PackageManager pm,
int userId,
String serviceName,
String permissionName) |
void |
onPackagesChanged() |
void |
onSettingChanged()
Called when the tracked setting has changed.
|
void |
onSettingRestored(String prevValue,
String newValue,
int userId)
Called when the tracked setting has been restored for a particular user.
|
void |
onUsersChanged() |
void |
rebuildAll()
Rebuild the sets of allowed components for each current user profile.
|
public static final int NO_ERROR
public static final int DISABLED
public static final int NOT_INSTALLED
public static EnabledComponentsObserver build(Context context, Handler handler, String settingName, Looper looper, String servicePermission, String serviceName, Object lock, Collection<EnabledComponentsObserver.EnabledComponentChangeListener> listeners)
context
- the context to query for changes.handler
- a handler to receive lifecycle events from system services on.settingName
- the name of a setting to monitor for a list of enabled components.looper
- a Looper
to use for receiving package callbacks.servicePermission
- the permission required by the components to be bound.serviceName
- the intent action implemented by the tracked components.lock
- a lock object used to guard instance state in all callbacks and method calls.public void onPackagesChanged()
public void onSettingChanged()
SettingsObserver.SettingChangeListener
onSettingChanged
in interface SettingsObserver.SettingChangeListener
public void onSettingRestored(String prevValue, String newValue, int userId)
SettingsObserver.SettingChangeListener
onSettingRestored
in interface SettingsObserver.SettingChangeListener
prevValue
- the previous value of the setting.newValue
- the new value of the setting.userId
- the user ID for which this setting has been restored.public void onUsersChanged()
public void rebuildAll()
public int isValid(ComponentName component, int userId)
component
- the component to check.userId
- the user ID for the component to check.true
if present and enabled.public ArraySet<ComponentName> getInstalled(int userId)
userId
- ID of the user to check.ComponentName
s.public ArraySet<ComponentName> getEnabled(int userId)
userId
- ID of the user to check.ComponentName
s.public static ArraySet<ComponentName> loadComponentNames(PackageManager pm, int userId, String serviceName, String permissionName)