use of java.lang.NoSuchMethodException in project DeepLinkDispatch by airbnb.
the class DeepLinkDelegate method dispatchFrom.
public DeepLinkResult dispatchFrom(Activity activity, Intent sourceIntent) {
if (activity == null) {
throw new NullPointerException("activity == null");
}
if (sourceIntent == null) {
throw new NullPointerException("sourceIntent == null");
}
Uri uri = sourceIntent.getData();
if (uri == null) {
return createResultAndNotify(activity, false, null, "No Uri in given activity's intent.");
}
String uriString = uri.toString();
DeepLinkEntry entry = findEntry(uriString);
if (entry != null) {
DeepLinkUri deepLinkUri = DeepLinkUri.parse(uriString);
Map<String, String> parameterMap = entry.getParameters(uriString);
for (String queryParameter : deepLinkUri.queryParameterNames()) {
for (String queryParameterValue : deepLinkUri.queryParameterValues(queryParameter)) {
if (parameterMap.containsKey(queryParameter)) {
Log.w(TAG, "Duplicate parameter name in path and query param: " + queryParameter);
}
parameterMap.put(queryParameter, queryParameterValue);
}
}
parameterMap.put(DeepLink.URI, uri.toString());
Bundle parameters;
if (sourceIntent.getExtras() != null) {
parameters = new Bundle(sourceIntent.getExtras());
} else {
parameters = new Bundle();
}
for (Map.Entry<String, String> parameterEntry : parameterMap.entrySet()) {
parameters.putString(parameterEntry.getKey(), parameterEntry.getValue());
}
try {
Class<?> c = entry.getActivityClass();
Intent newIntent;
TaskStackBuilder taskStackBuilder = null;
if (entry.getType() == DeepLinkEntry.Type.CLASS) {
newIntent = new Intent(activity, c);
} else {
Method method;
try {
method = c.getMethod(entry.getMethod(), Context.class);
if (method.getReturnType().equals(TaskStackBuilder.class)) {
taskStackBuilder = (TaskStackBuilder) method.invoke(c, activity);
if (taskStackBuilder.getIntentCount() == 0) {
return createResultAndNotify(activity, false, uri, "Could not deep link to method: " + entry.getMethod() + " intents length == 0");
}
newIntent = taskStackBuilder.editIntentAt(taskStackBuilder.getIntentCount() - 1);
} else {
newIntent = (Intent) method.invoke(c, activity);
}
} catch (NoSuchMethodException exception) {
method = c.getMethod(entry.getMethod(), Context.class, Bundle.class);
if (method.getReturnType().equals(TaskStackBuilder.class)) {
taskStackBuilder = (TaskStackBuilder) method.invoke(c, activity, parameters);
if (taskStackBuilder.getIntentCount() == 0) {
return createResultAndNotify(activity, false, uri, "Could not deep link to method: " + entry.getMethod() + " intents length == 0");
}
newIntent = taskStackBuilder.editIntentAt(taskStackBuilder.getIntentCount() - 1);
} else {
newIntent = (Intent) method.invoke(c, activity, parameters);
}
}
}
if (newIntent.getAction() == null) {
newIntent.setAction(sourceIntent.getAction());
}
if (newIntent.getData() == null) {
newIntent.setData(sourceIntent.getData());
}
newIntent.putExtras(parameters);
newIntent.putExtra(DeepLink.IS_DEEP_LINK, true);
newIntent.putExtra(DeepLink.REFERRER_URI, uri);
if (activity.getCallingActivity() != null) {
newIntent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
}
if (taskStackBuilder != null) {
taskStackBuilder.startActivities();
} else {
activity.startActivity(newIntent);
}
return createResultAndNotify(activity, true, uri, null);
} catch (NoSuchMethodException exception) {
return createResultAndNotify(activity, false, uri, "Deep link to non-existent method: " + entry.getMethod());
} catch (IllegalAccessException exception) {
return createResultAndNotify(activity, false, uri, "Could not deep link to method: " + entry.getMethod());
} catch (InvocationTargetException exception) {
return createResultAndNotify(activity, false, uri, "Could not deep link to method: " + entry.getMethod());
}
} else {
return createResultAndNotify(activity, false, uri, "No registered entity to handle deep link: " + uri.toString());
}
}
use of java.lang.NoSuchMethodException in project android_frameworks_base by DirtyUnicorns.
the class NotificationTests method testCreate.
public void testCreate() throws Exception {
ArrayList<Notification> mNotifications = new ArrayList<Notification>();
NotificationManager noMa = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
L("Constructing notifications...");
if (SHOW_BIG_TEXT) {
int bigtextId = mNotifications.size();
final long time = SystemClock.currentThreadTimeMillis();
final Notification n = makeBigTextNotification(mContext, 0, bigtextId, System.currentTimeMillis());
L(" %s: create=%dms", summarize(n), SystemClock.currentThreadTimeMillis() - time);
mNotifications.add(n);
}
int uploadId = mNotifications.size();
long uploadWhen = System.currentTimeMillis();
if (SHOW_PROGRESS) {
mNotifications.add(makeUploadNotification(mContext, 0, uploadWhen));
}
if (SHOW_PHONE_CALL) {
int phoneId = mNotifications.size();
final PendingIntent fullscreenIntent = FullScreenActivity.getPendingIntent(mContext, phoneId);
final long time = SystemClock.currentThreadTimeMillis();
Notification phoneCall = new Notification.Builder(mContext).setContentTitle("Incoming call").setContentText("Matias Duarte").setLargeIcon(getBitmap(mContext, R.drawable.matias_hed)).setSmallIcon(R.drawable.stat_sys_phone_call).setDefaults(Notification.DEFAULT_SOUND).setPriority(Notification.PRIORITY_MAX).setContentIntent(fullscreenIntent).setFullScreenIntent(fullscreenIntent, true).addAction(R.drawable.ic_dial_action_call, "Answer", ToastService.getPendingIntent(mContext, "Clicked on Answer")).addAction(R.drawable.ic_end_call, "Ignore", ToastService.getPendingIntent(mContext, "Clicked on Ignore")).setOngoing(true).addPerson(Uri.fromParts("tel", "1 (617) 555-1212", null).toString()).build();
L(" %s: create=%dms", phoneCall.toString(), SystemClock.currentThreadTimeMillis() - time);
mNotifications.add(phoneCall);
}
if (SHOW_STOPWATCH) {
final long time = SystemClock.currentThreadTimeMillis();
final Notification n = new Notification.Builder(mContext).setContentTitle("Stopwatch PRO").setContentText("Counting up").setContentIntent(ToastService.getPendingIntent(mContext, "Clicked on Stopwatch")).setSmallIcon(R.drawable.stat_notify_alarm).setUsesChronometer(true).build();
L(" %s: create=%dms", summarize(n), SystemClock.currentThreadTimeMillis() - time);
mNotifications.add(n);
}
if (SHOW_CALENDAR) {
final long time = SystemClock.currentThreadTimeMillis();
final Notification n = new Notification.Builder(mContext).setContentTitle("J Planning").setContentText("The Botcave").setWhen(System.currentTimeMillis()).setSmallIcon(R.drawable.stat_notify_calendar).setContentIntent(ToastService.getPendingIntent(mContext, "Clicked on calendar event")).setContentInfo("7PM").addAction(R.drawable.stat_notify_snooze, "+10 min", ToastService.getPendingIntent(mContext, "snoozed 10 min")).addAction(R.drawable.stat_notify_snooze_longer, "+1 hour", ToastService.getPendingIntent(mContext, "snoozed 1 hr")).addAction(R.drawable.stat_notify_email, "Email", ToastService.getPendingIntent(mContext, "Congratulations, you just destroyed someone's inbox zero")).build();
L(" %s: create=%dms", summarize(n), SystemClock.currentThreadTimeMillis() - time);
mNotifications.add(n);
}
if (SHOW_BIG_PICTURE) {
BitmapDrawable d = (BitmapDrawable) mContext.getResources().getDrawable(R.drawable.romainguy_rockaway);
final long time = SystemClock.currentThreadTimeMillis();
final Notification n = new Notification.Builder(mContext).setContentTitle("Romain Guy").setContentText("I was lucky to find a Canon 5D Mk III at a local Bay Area " + "store last week but I had not been able to try it in the field " + "until tonight. After a few days of rain the sky finally cleared " + "up. Rockaway Beach did not disappoint and I was finally able to " + "see what my new camera feels like when shooting landscapes.").setSmallIcon(android.R.drawable.stat_notify_chat).setContentIntent(ToastService.getPendingIntent(mContext, "Clicked picture")).setLargeIcon(getBitmap(mContext, R.drawable.romainguy_hed)).addAction(R.drawable.add, "Add to Gallery", ToastService.getPendingIntent(mContext, "Added")).setStyle(new Notification.BigPictureStyle().bigPicture(d.getBitmap())).build();
L(" %s: create=%dms", summarize(n), SystemClock.currentThreadTimeMillis() - time);
mNotifications.add(n);
}
if (SHOW_INBOX) {
final long time = SystemClock.currentThreadTimeMillis();
final Notification n = new Notification.Builder(mContext).setContentTitle("New mail").setContentText("3 new messages").setSubText("example@gmail.com").setContentIntent(ToastService.getPendingIntent(mContext, "Clicked on Mail")).setSmallIcon(R.drawable.stat_notify_email).setStyle(new Notification.InboxStyle().setSummaryText("example@gmail.com").addLine(BOLD("Alice:").append(" hey there!")).addLine(BOLD("Bob:").append(" hi there!")).addLine(BOLD("Charlie:").append(" Iz IN UR EMAILZ!!"))).build();
L(" %s: create=%dms", summarize(n), SystemClock.currentThreadTimeMillis() - time);
mNotifications.add(n);
}
if (SHOW_SOCIAL) {
final long time = SystemClock.currentThreadTimeMillis();
final Notification n = new Notification.Builder(mContext).setContentTitle("Social Network").setContentText("You were mentioned in a post").setContentInfo("example@gmail.com").setContentIntent(ToastService.getPendingIntent(mContext, "Clicked on Social")).setSmallIcon(android.R.drawable.stat_notify_chat).setPriority(Notification.PRIORITY_LOW).build();
L(" %s: create=%dms", summarize(n), SystemClock.currentThreadTimeMillis() - time);
mNotifications.add(n);
}
L("Posting notifications...");
for (int i = 0; i < mNotifications.size(); i++) {
final int count = 4;
for (int j = 0; j < count; j++) {
long time = SystemClock.currentThreadTimeMillis();
final Notification n = mNotifications.get(i);
noMa.notify(NOTIFICATION_ID + i, n);
time = SystemClock.currentThreadTimeMillis() - time;
L(" %s: notify=%dms (%d/%d)", summarize(n), time, j + 1, count);
sleepIfYouCan(150);
}
}
sleepIfYouCan(1000);
L("Canceling notifications...");
for (int i = 0; i < mNotifications.size(); i++) {
final Notification n = mNotifications.get(i);
long time = SystemClock.currentThreadTimeMillis();
noMa.cancel(NOTIFICATION_ID + i);
time = SystemClock.currentThreadTimeMillis() - time;
L(" %s: cancel=%dms", summarize(n), time);
}
sleepIfYouCan(500);
L("Parceling notifications...");
// we want to be able to use this test on older OSes that do not have getBlobAshmemSize
Method getBlobAshmemSize = null;
try {
getBlobAshmemSize = Parcel.class.getMethod("getBlobAshmemSize");
} catch (NoSuchMethodException ex) {
}
for (int i = 0; i < mNotifications.size(); i++) {
Parcel p = Parcel.obtain();
{
final Notification n = mNotifications.get(i);
long time = SystemClock.currentThreadTimeMillis();
n.writeToParcel(p, 0);
time = SystemClock.currentThreadTimeMillis() - time;
L(" %s: write parcel=%dms size=%d ashmem=%s", summarize(n), time, p.dataPosition(), (getBlobAshmemSize != null) ? getBlobAshmemSize.invoke(p) : "???");
p.setDataPosition(0);
}
long time = SystemClock.currentThreadTimeMillis();
final Notification n2 = Notification.CREATOR.createFromParcel(p);
time = SystemClock.currentThreadTimeMillis() - time;
L(" %s: parcel read=%dms", summarize(n2), time);
time = SystemClock.currentThreadTimeMillis();
noMa.notify(NOTIFICATION_ID + i, n2);
time = SystemClock.currentThreadTimeMillis() - time;
L(" %s: notify=%dms", summarize(n2), time);
}
sleepIfYouCan(500);
L("Canceling notifications...");
for (int i = 0; i < mNotifications.size(); i++) {
long time = SystemClock.currentThreadTimeMillis();
final Notification n = mNotifications.get(i);
noMa.cancel(NOTIFICATION_ID + i);
time = SystemClock.currentThreadTimeMillis() - time;
L(" %s: cancel=%dms", summarize(n), time);
}
// if (SHOW_PROGRESS) {
// ProgressService.startProgressUpdater(this, uploadId, uploadWhen, 0);
// }
}
use of java.lang.NoSuchMethodException in project platform_frameworks_base by android.
the class NotificationTests method testCreate.
public void testCreate() throws Exception {
ArrayList<Notification> mNotifications = new ArrayList<Notification>();
NotificationManager noMa = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
L("Constructing notifications...");
if (SHOW_BIG_TEXT) {
int bigtextId = mNotifications.size();
final long time = SystemClock.currentThreadTimeMillis();
final Notification n = makeBigTextNotification(mContext, 0, bigtextId, System.currentTimeMillis());
L(" %s: create=%dms", summarize(n), SystemClock.currentThreadTimeMillis() - time);
mNotifications.add(n);
}
int uploadId = mNotifications.size();
long uploadWhen = System.currentTimeMillis();
if (SHOW_PROGRESS) {
mNotifications.add(makeUploadNotification(mContext, 0, uploadWhen));
}
if (SHOW_PHONE_CALL) {
int phoneId = mNotifications.size();
final PendingIntent fullscreenIntent = FullScreenActivity.getPendingIntent(mContext, phoneId);
final long time = SystemClock.currentThreadTimeMillis();
Notification phoneCall = new Notification.Builder(mContext).setContentTitle("Incoming call").setContentText("Matias Duarte").setLargeIcon(getBitmap(mContext, R.drawable.matias_hed)).setSmallIcon(R.drawable.stat_sys_phone_call).setDefaults(Notification.DEFAULT_SOUND).setPriority(Notification.PRIORITY_MAX).setContentIntent(fullscreenIntent).setFullScreenIntent(fullscreenIntent, true).addAction(R.drawable.ic_dial_action_call, "Answer", ToastService.getPendingIntent(mContext, "Clicked on Answer")).addAction(R.drawable.ic_end_call, "Ignore", ToastService.getPendingIntent(mContext, "Clicked on Ignore")).setOngoing(true).addPerson(Uri.fromParts("tel", "1 (617) 555-1212", null).toString()).build();
L(" %s: create=%dms", phoneCall.toString(), SystemClock.currentThreadTimeMillis() - time);
mNotifications.add(phoneCall);
}
if (SHOW_STOPWATCH) {
final long time = SystemClock.currentThreadTimeMillis();
final Notification n = new Notification.Builder(mContext).setContentTitle("Stopwatch PRO").setContentText("Counting up").setContentIntent(ToastService.getPendingIntent(mContext, "Clicked on Stopwatch")).setSmallIcon(R.drawable.stat_notify_alarm).setUsesChronometer(true).build();
L(" %s: create=%dms", summarize(n), SystemClock.currentThreadTimeMillis() - time);
mNotifications.add(n);
}
if (SHOW_CALENDAR) {
final long time = SystemClock.currentThreadTimeMillis();
final Notification n = new Notification.Builder(mContext).setContentTitle("J Planning").setContentText("The Botcave").setWhen(System.currentTimeMillis()).setSmallIcon(R.drawable.stat_notify_calendar).setContentIntent(ToastService.getPendingIntent(mContext, "Clicked on calendar event")).setContentInfo("7PM").addAction(R.drawable.stat_notify_snooze, "+10 min", ToastService.getPendingIntent(mContext, "snoozed 10 min")).addAction(R.drawable.stat_notify_snooze_longer, "+1 hour", ToastService.getPendingIntent(mContext, "snoozed 1 hr")).addAction(R.drawable.stat_notify_email, "Email", ToastService.getPendingIntent(mContext, "Congratulations, you just destroyed someone's inbox zero")).build();
L(" %s: create=%dms", summarize(n), SystemClock.currentThreadTimeMillis() - time);
mNotifications.add(n);
}
if (SHOW_BIG_PICTURE) {
BitmapDrawable d = (BitmapDrawable) mContext.getResources().getDrawable(R.drawable.romainguy_rockaway);
final long time = SystemClock.currentThreadTimeMillis();
final Notification n = new Notification.Builder(mContext).setContentTitle("Romain Guy").setContentText("I was lucky to find a Canon 5D Mk III at a local Bay Area " + "store last week but I had not been able to try it in the field " + "until tonight. After a few days of rain the sky finally cleared " + "up. Rockaway Beach did not disappoint and I was finally able to " + "see what my new camera feels like when shooting landscapes.").setSmallIcon(android.R.drawable.stat_notify_chat).setContentIntent(ToastService.getPendingIntent(mContext, "Clicked picture")).setLargeIcon(getBitmap(mContext, R.drawable.romainguy_hed)).addAction(R.drawable.add, "Add to Gallery", ToastService.getPendingIntent(mContext, "Added")).setStyle(new Notification.BigPictureStyle().bigPicture(d.getBitmap())).build();
L(" %s: create=%dms", summarize(n), SystemClock.currentThreadTimeMillis() - time);
mNotifications.add(n);
}
if (SHOW_INBOX) {
final long time = SystemClock.currentThreadTimeMillis();
final Notification n = new Notification.Builder(mContext).setContentTitle("New mail").setContentText("3 new messages").setSubText("example@gmail.com").setContentIntent(ToastService.getPendingIntent(mContext, "Clicked on Mail")).setSmallIcon(R.drawable.stat_notify_email).setStyle(new Notification.InboxStyle().setSummaryText("example@gmail.com").addLine(BOLD("Alice:").append(" hey there!")).addLine(BOLD("Bob:").append(" hi there!")).addLine(BOLD("Charlie:").append(" Iz IN UR EMAILZ!!"))).build();
L(" %s: create=%dms", summarize(n), SystemClock.currentThreadTimeMillis() - time);
mNotifications.add(n);
}
if (SHOW_SOCIAL) {
final long time = SystemClock.currentThreadTimeMillis();
final Notification n = new Notification.Builder(mContext).setContentTitle("Social Network").setContentText("You were mentioned in a post").setContentInfo("example@gmail.com").setContentIntent(ToastService.getPendingIntent(mContext, "Clicked on Social")).setSmallIcon(android.R.drawable.stat_notify_chat).setPriority(Notification.PRIORITY_LOW).build();
L(" %s: create=%dms", summarize(n), SystemClock.currentThreadTimeMillis() - time);
mNotifications.add(n);
}
L("Posting notifications...");
for (int i = 0; i < mNotifications.size(); i++) {
final int count = 4;
for (int j = 0; j < count; j++) {
long time = SystemClock.currentThreadTimeMillis();
final Notification n = mNotifications.get(i);
noMa.notify(NOTIFICATION_ID + i, n);
time = SystemClock.currentThreadTimeMillis() - time;
L(" %s: notify=%dms (%d/%d)", summarize(n), time, j + 1, count);
sleepIfYouCan(150);
}
}
sleepIfYouCan(1000);
L("Canceling notifications...");
for (int i = 0; i < mNotifications.size(); i++) {
final Notification n = mNotifications.get(i);
long time = SystemClock.currentThreadTimeMillis();
noMa.cancel(NOTIFICATION_ID + i);
time = SystemClock.currentThreadTimeMillis() - time;
L(" %s: cancel=%dms", summarize(n), time);
}
sleepIfYouCan(500);
L("Parceling notifications...");
// we want to be able to use this test on older OSes that do not have getBlobAshmemSize
Method getBlobAshmemSize = null;
try {
getBlobAshmemSize = Parcel.class.getMethod("getBlobAshmemSize");
} catch (NoSuchMethodException ex) {
}
for (int i = 0; i < mNotifications.size(); i++) {
Parcel p = Parcel.obtain();
{
final Notification n = mNotifications.get(i);
long time = SystemClock.currentThreadTimeMillis();
n.writeToParcel(p, 0);
time = SystemClock.currentThreadTimeMillis() - time;
L(" %s: write parcel=%dms size=%d ashmem=%s", summarize(n), time, p.dataPosition(), (getBlobAshmemSize != null) ? getBlobAshmemSize.invoke(p) : "???");
p.setDataPosition(0);
}
long time = SystemClock.currentThreadTimeMillis();
final Notification n2 = Notification.CREATOR.createFromParcel(p);
time = SystemClock.currentThreadTimeMillis() - time;
L(" %s: parcel read=%dms", summarize(n2), time);
time = SystemClock.currentThreadTimeMillis();
noMa.notify(NOTIFICATION_ID + i, n2);
time = SystemClock.currentThreadTimeMillis() - time;
L(" %s: notify=%dms", summarize(n2), time);
}
sleepIfYouCan(500);
L("Canceling notifications...");
for (int i = 0; i < mNotifications.size(); i++) {
long time = SystemClock.currentThreadTimeMillis();
final Notification n = mNotifications.get(i);
noMa.cancel(NOTIFICATION_ID + i);
time = SystemClock.currentThreadTimeMillis() - time;
L(" %s: cancel=%dms", summarize(n), time);
}
// if (SHOW_PROGRESS) {
// ProgressService.startProgressUpdater(this, uploadId, uploadWhen, 0);
// }
}
use of java.lang.NoSuchMethodException in project android_frameworks_base by crdroidandroid.
the class NotificationTests method testCreate.
public void testCreate() throws Exception {
ArrayList<Notification> mNotifications = new ArrayList<Notification>();
NotificationManager noMa = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
L("Constructing notifications...");
if (SHOW_BIG_TEXT) {
int bigtextId = mNotifications.size();
final long time = SystemClock.currentThreadTimeMillis();
final Notification n = makeBigTextNotification(mContext, 0, bigtextId, System.currentTimeMillis());
L(" %s: create=%dms", summarize(n), SystemClock.currentThreadTimeMillis() - time);
mNotifications.add(n);
}
int uploadId = mNotifications.size();
long uploadWhen = System.currentTimeMillis();
if (SHOW_PROGRESS) {
mNotifications.add(makeUploadNotification(mContext, 0, uploadWhen));
}
if (SHOW_PHONE_CALL) {
int phoneId = mNotifications.size();
final PendingIntent fullscreenIntent = FullScreenActivity.getPendingIntent(mContext, phoneId);
final long time = SystemClock.currentThreadTimeMillis();
Notification phoneCall = new Notification.Builder(mContext).setContentTitle("Incoming call").setContentText("Matias Duarte").setLargeIcon(getBitmap(mContext, R.drawable.matias_hed)).setSmallIcon(R.drawable.stat_sys_phone_call).setDefaults(Notification.DEFAULT_SOUND).setPriority(Notification.PRIORITY_MAX).setContentIntent(fullscreenIntent).setFullScreenIntent(fullscreenIntent, true).addAction(R.drawable.ic_dial_action_call, "Answer", ToastService.getPendingIntent(mContext, "Clicked on Answer")).addAction(R.drawable.ic_end_call, "Ignore", ToastService.getPendingIntent(mContext, "Clicked on Ignore")).setOngoing(true).addPerson(Uri.fromParts("tel", "1 (617) 555-1212", null).toString()).build();
L(" %s: create=%dms", phoneCall.toString(), SystemClock.currentThreadTimeMillis() - time);
mNotifications.add(phoneCall);
}
if (SHOW_STOPWATCH) {
final long time = SystemClock.currentThreadTimeMillis();
final Notification n = new Notification.Builder(mContext).setContentTitle("Stopwatch PRO").setContentText("Counting up").setContentIntent(ToastService.getPendingIntent(mContext, "Clicked on Stopwatch")).setSmallIcon(R.drawable.stat_notify_alarm).setUsesChronometer(true).build();
L(" %s: create=%dms", summarize(n), SystemClock.currentThreadTimeMillis() - time);
mNotifications.add(n);
}
if (SHOW_CALENDAR) {
final long time = SystemClock.currentThreadTimeMillis();
final Notification n = new Notification.Builder(mContext).setContentTitle("J Planning").setContentText("The Botcave").setWhen(System.currentTimeMillis()).setSmallIcon(R.drawable.stat_notify_calendar).setContentIntent(ToastService.getPendingIntent(mContext, "Clicked on calendar event")).setContentInfo("7PM").addAction(R.drawable.stat_notify_snooze, "+10 min", ToastService.getPendingIntent(mContext, "snoozed 10 min")).addAction(R.drawable.stat_notify_snooze_longer, "+1 hour", ToastService.getPendingIntent(mContext, "snoozed 1 hr")).addAction(R.drawable.stat_notify_email, "Email", ToastService.getPendingIntent(mContext, "Congratulations, you just destroyed someone's inbox zero")).build();
L(" %s: create=%dms", summarize(n), SystemClock.currentThreadTimeMillis() - time);
mNotifications.add(n);
}
if (SHOW_BIG_PICTURE) {
BitmapDrawable d = (BitmapDrawable) mContext.getResources().getDrawable(R.drawable.romainguy_rockaway);
final long time = SystemClock.currentThreadTimeMillis();
final Notification n = new Notification.Builder(mContext).setContentTitle("Romain Guy").setContentText("I was lucky to find a Canon 5D Mk III at a local Bay Area " + "store last week but I had not been able to try it in the field " + "until tonight. After a few days of rain the sky finally cleared " + "up. Rockaway Beach did not disappoint and I was finally able to " + "see what my new camera feels like when shooting landscapes.").setSmallIcon(android.R.drawable.stat_notify_chat).setContentIntent(ToastService.getPendingIntent(mContext, "Clicked picture")).setLargeIcon(getBitmap(mContext, R.drawable.romainguy_hed)).addAction(R.drawable.add, "Add to Gallery", ToastService.getPendingIntent(mContext, "Added")).setStyle(new Notification.BigPictureStyle().bigPicture(d.getBitmap())).build();
L(" %s: create=%dms", summarize(n), SystemClock.currentThreadTimeMillis() - time);
mNotifications.add(n);
}
if (SHOW_INBOX) {
final long time = SystemClock.currentThreadTimeMillis();
final Notification n = new Notification.Builder(mContext).setContentTitle("New mail").setContentText("3 new messages").setSubText("example@gmail.com").setContentIntent(ToastService.getPendingIntent(mContext, "Clicked on Mail")).setSmallIcon(R.drawable.stat_notify_email).setStyle(new Notification.InboxStyle().setSummaryText("example@gmail.com").addLine(BOLD("Alice:").append(" hey there!")).addLine(BOLD("Bob:").append(" hi there!")).addLine(BOLD("Charlie:").append(" Iz IN UR EMAILZ!!"))).build();
L(" %s: create=%dms", summarize(n), SystemClock.currentThreadTimeMillis() - time);
mNotifications.add(n);
}
if (SHOW_SOCIAL) {
final long time = SystemClock.currentThreadTimeMillis();
final Notification n = new Notification.Builder(mContext).setContentTitle("Social Network").setContentText("You were mentioned in a post").setContentInfo("example@gmail.com").setContentIntent(ToastService.getPendingIntent(mContext, "Clicked on Social")).setSmallIcon(android.R.drawable.stat_notify_chat).setPriority(Notification.PRIORITY_LOW).build();
L(" %s: create=%dms", summarize(n), SystemClock.currentThreadTimeMillis() - time);
mNotifications.add(n);
}
L("Posting notifications...");
for (int i = 0; i < mNotifications.size(); i++) {
final int count = 4;
for (int j = 0; j < count; j++) {
long time = SystemClock.currentThreadTimeMillis();
final Notification n = mNotifications.get(i);
noMa.notify(NOTIFICATION_ID + i, n);
time = SystemClock.currentThreadTimeMillis() - time;
L(" %s: notify=%dms (%d/%d)", summarize(n), time, j + 1, count);
sleepIfYouCan(150);
}
}
sleepIfYouCan(1000);
L("Canceling notifications...");
for (int i = 0; i < mNotifications.size(); i++) {
final Notification n = mNotifications.get(i);
long time = SystemClock.currentThreadTimeMillis();
noMa.cancel(NOTIFICATION_ID + i);
time = SystemClock.currentThreadTimeMillis() - time;
L(" %s: cancel=%dms", summarize(n), time);
}
sleepIfYouCan(500);
L("Parceling notifications...");
// we want to be able to use this test on older OSes that do not have getBlobAshmemSize
Method getBlobAshmemSize = null;
try {
getBlobAshmemSize = Parcel.class.getMethod("getBlobAshmemSize");
} catch (NoSuchMethodException ex) {
}
for (int i = 0; i < mNotifications.size(); i++) {
Parcel p = Parcel.obtain();
{
final Notification n = mNotifications.get(i);
long time = SystemClock.currentThreadTimeMillis();
n.writeToParcel(p, 0);
time = SystemClock.currentThreadTimeMillis() - time;
L(" %s: write parcel=%dms size=%d ashmem=%s", summarize(n), time, p.dataPosition(), (getBlobAshmemSize != null) ? getBlobAshmemSize.invoke(p) : "???");
p.setDataPosition(0);
}
long time = SystemClock.currentThreadTimeMillis();
final Notification n2 = Notification.CREATOR.createFromParcel(p);
time = SystemClock.currentThreadTimeMillis() - time;
L(" %s: parcel read=%dms", summarize(n2), time);
time = SystemClock.currentThreadTimeMillis();
noMa.notify(NOTIFICATION_ID + i, n2);
time = SystemClock.currentThreadTimeMillis() - time;
L(" %s: notify=%dms", summarize(n2), time);
}
sleepIfYouCan(500);
L("Canceling notifications...");
for (int i = 0; i < mNotifications.size(); i++) {
long time = SystemClock.currentThreadTimeMillis();
final Notification n = mNotifications.get(i);
noMa.cancel(NOTIFICATION_ID + i);
time = SystemClock.currentThreadTimeMillis() - time;
L(" %s: cancel=%dms", summarize(n), time);
}
// if (SHOW_PROGRESS) {
// ProgressService.startProgressUpdater(this, uploadId, uploadWhen, 0);
// }
}
use of java.lang.NoSuchMethodException in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class DimmableIZatIconPreference method load.
private static void load(Context context) {
if (mLoader == null) {
try {
if (mXtProxyClz == null || mNotifierClz == null) {
mLoader = new DexClassLoader("/system/framework/izat.xt.srv.jar", context.getFilesDir().getAbsolutePath(), null, ClassLoader.getSystemClassLoader());
mXtProxyClz = Class.forName("com.qti.izat.XTProxy", true, mLoader);
mNotifierClz = Class.forName("com.qti.izat.XTProxy$Notifier", true, mLoader);
mIzatPackage = (String) mXtProxyClz.getField("IZAT_XT_PACKAGE").get(null);
mGetXtProxyMethod = mXtProxyClz.getMethod("getXTProxy", Context.class, mNotifierClz);
mGetConsentMethod = mXtProxyClz.getMethod("getUserConsent");
mShowIzatMethod = mXtProxyClz.getMethod("showIzat", Context.class, String.class);
}
} catch (NoSuchMethodException | NullPointerException | SecurityException | NoSuchFieldException | LinkageError | IllegalAccessException | ClassNotFoundException e) {
mXtProxyClz = null;
mNotifierClz = null;
mIzatPackage = null;
mGetXtProxyMethod = null;
mGetConsentMethod = null;
mShowIzatMethod = null;
e.printStackTrace();
}
}
}
Aggregations