List of usage examples for android.content.pm ResolveInfo ResolveInfo
public ResolveInfo()
From source file:com.android.tv.util.TestUtils.java
public static ResolveInfo createResolveInfo(String packageName, String name) { ResolveInfo resolveInfo = new ResolveInfo(); resolveInfo.serviceInfo = new ServiceInfo(); resolveInfo.serviceInfo.packageName = packageName; resolveInfo.serviceInfo.name = name; return resolveInfo; }
From source file:com.test.onesignal.MainOneSignalClassRunner.java
private static void AddLauncherIntentFilter() { Intent launchIntent = new Intent(Intent.ACTION_MAIN); launchIntent.setPackage("com.onesignal.example"); launchIntent.addCategory(Intent.CATEGORY_LAUNCHER); ResolveInfo resolveInfo = new ResolveInfo(); resolveInfo.activityInfo = new ActivityInfo(); resolveInfo.activityInfo.packageName = "com.onesignal.example"; resolveInfo.activityInfo.name = "MainActivity"; RuntimeEnvironment.getRobolectricPackageManager().addResolveInfoForIntent(launchIntent, resolveInfo); }
From source file:com.test.onesignal.GenerateNotificationRunner.java
@Test @Config(shadows = { ShadowOneSignal.class }) public void shouldFireNotificationExtenderService() throws Exception { // Test that GCM receiver starts the NotificationExtenderServiceTest when it is in the AndroidManifest.xml Bundle bundle = getBaseNotifBundle(); Intent serviceIntent = new Intent(); serviceIntent.setPackage("com.onesignal.example"); serviceIntent.setAction("com.onesignal.NotificationExtender"); ResolveInfo resolveInfo = new ResolveInfo(); resolveInfo.serviceInfo = new ServiceInfo(); resolveInfo.serviceInfo.name = "com.onesignal.example.NotificationExtenderServiceTest"; RuntimeEnvironment.getRobolectricPackageManager().addResolveInfoForIntent(serviceIntent, resolveInfo); boolean ret = OneSignalPackagePrivateHelper.GcmBroadcastReceiver_processBundle(blankActivity, bundle); Assert.assertTrue(ret);//from w w w . ja va2s. co m Intent intent = Shadows.shadowOf(blankActivity).getNextStartedService(); Assert.assertEquals("com.onesignal.NotificationExtender", intent.getAction()); // Test that all options are set. NotificationExtenderServiceTest service = (NotificationExtenderServiceTest) startNotificationExtender( createInternalPayloadBundle(getBundleWithAllOptionsSet()), NotificationExtenderServiceTest.class); OSNotificationReceivedResult notificationReceived = service.notification; OSNotificationPayload notificationPayload = notificationReceived.payload; Assert.assertEquals("Test H", notificationPayload.title); Assert.assertEquals("Test B", notificationPayload.body); Assert.assertEquals("9764eaeb-10ce-45b1-a66d-8f95938aaa51", notificationPayload.notificationID); Assert.assertEquals(0, notificationPayload.lockScreenVisibility); Assert.assertEquals("FF0000FF", notificationPayload.smallIconAccentColor); Assert.assertEquals("703322744261", notificationPayload.fromProjectNumber); Assert.assertEquals("FFFFFF00", notificationPayload.ledColor); Assert.assertEquals("big_picture", notificationPayload.bigPicture); Assert.assertEquals("large_icon", notificationPayload.largeIcon); Assert.assertEquals("small_icon", notificationPayload.smallIcon); Assert.assertEquals("test_sound", notificationPayload.sound); Assert.assertEquals("You test $[notif_count] MSGs!", notificationPayload.groupMessage); Assert.assertEquals("http://google.com", notificationPayload.launchURL); Assert.assertEquals(10, notificationPayload.priority); Assert.assertEquals("a_key", notificationPayload.collapseId); Assert.assertEquals("id1", notificationPayload.actionButtons.get(0).id); Assert.assertEquals("button1", notificationPayload.actionButtons.get(0).text); Assert.assertEquals("ic_menu_share", notificationPayload.actionButtons.get(0).icon); Assert.assertEquals("id2", notificationPayload.actionButtons.get(1).id); Assert.assertEquals("button2", notificationPayload.actionButtons.get(1).text); Assert.assertEquals("ic_menu_send", notificationPayload.actionButtons.get(1).icon); Assert.assertEquals("test_image_url", notificationPayload.backgroundImageLayout.image); Assert.assertEquals("FF000000", notificationPayload.backgroundImageLayout.titleTextColor); Assert.assertEquals("FFFFFFFF", notificationPayload.backgroundImageLayout.bodyTextColor); JSONObject additionalData = notificationPayload.additionalData; Assert.assertEquals("myValue", additionalData.getString("myKey")); Assert.assertEquals("nValue", additionalData.getJSONObject("nested").getString("nKey")); Assert.assertNotSame(-1, service.notificationId); // Test a basic notification without anything special. startNotificationExtender(createInternalPayloadBundle(getBaseNotifBundle()), NotificationExtenderServiceTest.class); Assert.assertFalse(ShadowOneSignal.messages.contains("Error assigning")); // Test that a notification is still displayed if the developer's code in onNotificationProcessing throws an Exception. NotificationExtenderServiceTest.throwInAppCode = true; startNotificationExtender(createInternalPayloadBundle(getBaseNotifBundle("NewUUID1")), NotificationExtenderServiceTest.class); Assert.assertTrue(ShadowOneSignal.messages.contains("onNotificationProcessing throw an exception")); Map<Integer, PostedNotification> postedNotifs = ShadowRoboNotificationManager.notifications; Assert.assertEquals(3, postedNotifs.size()); }
From source file:com.afwsamples.testdpc.policy.PolicyManagementFragment.java
/** * Displays an alert dialog that allows the user to select applications from all non-system * applications installed on the current profile. After the user selects an app, this app can't * be uninstallation.//from w w w . j ava 2s . c o m */ private void showBlockUninstallationPrompt() { Activity activity = getActivity(); if (activity == null || activity.isFinishing()) { return; } List<ApplicationInfo> applicationInfoList = mPackageManager.getInstalledApplications(0 /* No flag */); List<ResolveInfo> resolveInfoList = new ArrayList<ResolveInfo>(); Collections.sort(applicationInfoList, new ApplicationInfo.DisplayNameComparator(mPackageManager)); for (ApplicationInfo applicationInfo : applicationInfoList) { // Ignore system apps because they can't be uninstalled. if ((applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) { ResolveInfo resolveInfo = new ResolveInfo(); resolveInfo.resolvePackageName = applicationInfo.packageName; resolveInfoList.add(resolveInfo); } } final BlockUninstallationInfoArrayAdapter blockUninstallationInfoArrayAdapter = new BlockUninstallationInfoArrayAdapter( getActivity(), R.id.pkg_name, resolveInfoList); ListView listview = new ListView(getActivity()); listview.setAdapter(blockUninstallationInfoArrayAdapter); listview.setOnItemClickListener(new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int pos, long id) { blockUninstallationInfoArrayAdapter.onItemClick(parent, view, pos, id); } }); new AlertDialog.Builder(getActivity()).setTitle(R.string.block_uninstallation_title).setView(listview) .setPositiveButton(R.string.close, null /* Nothing to do */).show(); }