use of android.annotation.SystemApi in project android_frameworks_base by AOSPA.
the class NotificationListenerService method getActiveNotifications.
/**
* Request one or more notifications by key. Useful if you have been keeping track of
* notifications but didn't want to retain the bits, and now need to go back and extract
* more data out of those notifications.
*
* @hide
*
* @param keys the keys of the notifications to request
* @param trim trim of the notifications to be returned. See <code>TRIM_*</code> constants.
* @return An array of notifications corresponding to the requested keys, in the
* same order as the key list.
*/
@SystemApi
public StatusBarNotification[] getActiveNotifications(String[] keys, int trim) {
if (!isBound())
return null;
try {
ParceledListSlice<StatusBarNotification> parceledList = getNotificationInterface().getActiveNotificationsFromListener(mWrapper, keys, trim);
List<StatusBarNotification> list = parceledList.getList();
ArrayList<StatusBarNotification> corruptNotifications = null;
int N = list.size();
for (int i = 0; i < N; i++) {
StatusBarNotification sbn = list.get(i);
Notification notification = sbn.getNotification();
try {
// convert icon metadata to legacy format for older clients
createLegacyIconExtras(notification);
// populate remote views for older clients.
maybePopulateRemoteViews(notification);
} catch (IllegalArgumentException e) {
if (corruptNotifications == null) {
corruptNotifications = new ArrayList<>(N);
}
corruptNotifications.add(sbn);
Log.w(TAG, "onNotificationPosted: can't rebuild notification from " + sbn.getPackageName());
}
}
if (corruptNotifications != null) {
list.removeAll(corruptNotifications);
}
return list.toArray(new StatusBarNotification[list.size()]);
} catch (android.os.RemoteException ex) {
Log.v(TAG, "Unable to contact notification manager", ex);
}
return null;
}
use of android.annotation.SystemApi in project android_frameworks_base by AOSPA.
the class NotificationListenerService method registerAsSystemService.
/**
* Directly register this service with the Notification Manager.
*
* <p>Only system services may use this call. It will fail for non-system callers.
* Apps should ask the user to add their listener in Settings.
*
* @param context Context required for accessing resources. Since this service isn't
* launched as a real Service when using this method, a context has to be passed in.
* @param componentName the component that will consume the notification information
* @param currentUser the user to use as the stream filter
* @hide
*/
@SystemApi
public void registerAsSystemService(Context context, ComponentName componentName, int currentUser) throws RemoteException {
if (mWrapper == null) {
mWrapper = new NotificationListenerWrapper();
}
mSystemContext = context;
INotificationManager noMan = getNotificationInterface();
mHandler = new MyHandler(context.getMainLooper());
mCurrentUser = currentUser;
noMan.registerListener(mWrapper, componentName, currentUser);
}
use of android.annotation.SystemApi in project android_frameworks_base by AOSPA.
the class NotificationListenerService method unregisterAsSystemService.
/**
* Directly unregister this service from the Notification Manager.
*
* <p>This method will fail for listeners that were not registered
* with (@link registerAsService).
* @hide
*/
@SystemApi
public void unregisterAsSystemService() throws RemoteException {
if (mWrapper != null) {
INotificationManager noMan = getNotificationInterface();
noMan.unregisterListener(mWrapper, mCurrentUser);
}
}
use of android.annotation.SystemApi in project android_frameworks_base by AOSPA.
the class Condition method copy.
@SystemApi
public Condition copy() {
final Parcel parcel = Parcel.obtain();
try {
writeToParcel(parcel, 0);
parcel.setDataPosition(0);
return new Condition(parcel);
} finally {
parcel.recycle();
}
}
use of android.annotation.SystemApi in project android_frameworks_base by AOSPA.
the class AbstractAccountAuthenticator method isCredentialsUpdateSuggested.
/**
* Checks if update of the account credentials is suggested.
*
* @param response to send the result back to the AccountManager, will never be null.
* @param account the account to check, will never be null
* @param statusToken a String of token to check if update of credentials is suggested.
* @return a Bundle result or null if the result is to be returned via the response. The result
* will contain either:
* <ul>
* <li>{@link AccountManager#KEY_BOOLEAN_RESULT}, true if update of account's
* credentials is suggested, false otherwise
* <li>{@link AccountManager#KEY_ERROR_CODE} and
* {@link AccountManager#KEY_ERROR_MESSAGE} to indicate an error
* </ul>
* @throws NetworkErrorException if the authenticator could not honor the request due to a
* network error
* @hide
*/
@SystemApi
public Bundle isCredentialsUpdateSuggested(final AccountAuthenticatorResponse response, Account account, String statusToken) throws NetworkErrorException {
Bundle result = new Bundle();
result.putBoolean(AccountManager.KEY_BOOLEAN_RESULT, false);
return result;
}
Aggregations