private String getCIJobPath(ApplicationInfo appInfo) { StringBuilder builder = new StringBuilder(Utility.getProjectHome()); builder.append(appInfo.getAppDirName()); builder.append(File.separator); builder.append(FOLDER_DOT_PHRESCO); builder.append(File.separator); builder.append(CI_JOB_INFO_NAME); return builder.toString(); }
public synchronized ApplicationRecord getCachedApplicationRecord(String applicationName) { ApplicationInfo existing = applicationHash.get(applicationName); if (existing == null) throw new UnknownApplicationException(String.format(UNKNOWN_APPLICATION_S, applicationName)); ApplicationRecord res = existing.getCachedApplicationRecord(); LOG.debug( String.format(this + " Returning cached app record for %s: %s", applicationName, res)); return res; }
public synchronized void setApplicationStatus(String applicationName, ApplicationStatus status) { ApplicationInfo existing = applicationHash.get(applicationName); if (existing == null) throw new UnknownApplicationException( String.format(APPLICATION_S_HAS_NOT_BEEN_REGISTERED, applicationName)); LOG.debug( String.format(this + " Setting app status for app %s to %s", applicationName, status)); existing.setApplicationStatus(status); }
private static void updateApplicationInfoTitleAndIcon( PackageManager manager, ResolveInfo info, ApplicationInfo application, Context context) { application.title = info.loadLabel(manager); if (application.title == null) { application.title = info.activityInfo.name; } application.icon = Utilities.createIconThumbnail(info.activityInfo.loadIcon(manager), context); application.filtered = false; }
public synchronized void setCachedApplicationRecord( String applicationName, ApplicationRecord applicationRecord) { ApplicationInfo existing = applicationHash.get(applicationName); if (existing == null) throw new UnknownApplicationException( String.format(APPLICATION_S_HAS_NOT_BEEN_REGISTERED, applicationName)); LOG.debug( String.format( this + " Caching app record for %s to %s", applicationName, applicationRecord)); existing.setCachedApplicationRecord(applicationRecord); }
/** Fill in "application" with the icon and label for "info." */ public void getTitleAndIcon(ApplicationInfo application, ResolveInfo info) { synchronized (mCache) { CacheEntry entry = cacheLocked(application.componentName, info); if (entry.titleBitmap == null) { entry.titleBitmap = mBubble.createTextBitmap(entry.title); } application.title = entry.title; application.titleBitmap = entry.titleBitmap; application.iconBitmap = entry.icon; } }
private void createGlassSettingsAppInfo() { ApplicationInfo application = new ApplicationInfo(); application.title = "Glass Settings"; application.setActivity( new ComponentName( "com.google.glass.home", "com.google.glass.home.settings.SettingsTimelineActivity"), Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); // application.icon = info.activityInfo.loadIcon(manager); mApplications.add(application); }
/** Loads the list of installed applications in mApplications. */ public void loadApplications(boolean isLaunching) { if (isLaunching && mApplications != null) { return; } PackageManager manager = mActivity.getPackageManager(); Intent mainIntent = new Intent(Intent.ACTION_MAIN, null); mainIntent.addCategory(Intent.CATEGORY_LAUNCHER); final List<ResolveInfo> apps = manager.queryIntentActivities(mainIntent, 0); Collections.sort(apps, new ResolveInfo.DisplayNameComparator(manager)); if (apps != null) { final int count = apps.size(); if (mApplications == null) { mApplications = new ArrayList<ApplicationInfo>(count); } mApplications.clear(); // Create a launcher for Glass Settings or we have no way to hit that createGlassSettingsAppInfo(); for (int i = 0; i < count; i++) { ApplicationInfo application = new ApplicationInfo(); ResolveInfo info = apps.get(i); Log.d("Launchyi", info.activityInfo.applicationInfo.packageName); // Let's filter out this app if (!mExcludedApps.contains(info.activityInfo.applicationInfo.packageName)) { application.title = info.loadLabel(manager); application.setActivity( new ComponentName( info.activityInfo.applicationInfo.packageName, info.activityInfo.name), Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); application.icon = info.activityInfo.loadIcon(manager); mApplications.add(application); } } // FIXME: should make a way to clear defaults // PackageManagerclearPackagePreferredActivities in special case // This needs to always be last? } }
@Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder viewHolder; if (convertView == null) { viewHolder = new ViewHolder(); convertView = mLayoutInflater.inflate(R.layout.custom_application_icon, null); viewHolder.mAppIcon = (ImageView) convertView.findViewById(R.id.custom_app_icon_image); viewHolder.mAppLabel = (TextView) convertView.findViewById(R.id.custom_app_icon_label); convertView.setTag(viewHolder); } else { viewHolder = (ViewHolder) convertView.getTag(); } ApplicationInfo info = mCustomAppList.get(position); Log.d("custom app", info.toString()); viewHolder.mAppIcon.setImageDrawable(info.getIcon()); viewHolder.mAppLabel.setText(info.getTitle()); return convertView; }
void InsertAllApps() { final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null); mainIntent.addCategory(Intent.CATEGORY_LAUNCHER); PackageManager manager = this.getPackageManager(); final List<ResolveInfo> apps = manager.queryIntentActivities(mainIntent, 0); for (int i = 0; i < apps.size(); i++) { ResolveInfo info = apps.get(i); ComponentName componentName = new ComponentName(info.activityInfo.applicationInfo.packageName, info.activityInfo.name); ApplicationInfo application = new ApplicationInfo(); application.container = ItemInfo.NO_ID; updateApplicationInfoTitleAndIcon(manager, info, application, this); application.setActivity( componentName, Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); MoveApplication( i, "MainMenu", application.title.toString(), application.intent.toString(), true); } }
/** Tests to make sure a normal user must be activated by the admin after confirmation. */ @Test public void testAppUserConfirmationMail() throws Exception { final String orgName = uniqueOrg(); final String appName = uniqueApp(); final String userName = uniqueUsername(); final String email = uniqueEmail(); final String passwd = "testpassword"; OrganizationOwnerInfo orgOwner; orgOwner = createOwnerAndOrganization(orgName, appName, userName, email, passwd, false, false); assertNotNull(orgOwner); setup.getEntityIndex().refresh(app.getId()); ApplicationInfo app = setup.getMgmtSvc().createApplication(orgOwner.getOrganization().getUuid(), appName); setup.refreshIndex(app.getId()); assertNotNull(app); enableEmailConfirmation(app.getId()); enableAdminApproval(app.getId()); setup.getEntityIndex().refresh(app.getId()); final String appUserEmail = uniqueEmail(); final String appUserUsername = uniqueUsername(); User user = setupAppUser(app.getId(), appUserUsername, appUserEmail, true); OrganizationConfig orgConfig = setup.getMgmtSvc().getOrganizationConfigByUuid(orgOwner.getOrganization().getUuid()); String subject = "User Account Confirmation: " + appUserEmail; String confirmation_url = orgConfig.getFullUrl( WorkflowUrl.USER_CONFIRMATION_URL, orgName, appName, user.getUuid().toString()); // request confirmation setup.getMgmtSvc().startAppUserActivationFlow(app.getId(), user); List<Message> inbox = Mailbox.get(appUserEmail); assertFalse(inbox.isEmpty()); MockImapClient client = new MockImapClient("test.com", appUserUsername, "somepassword"); client.processMail(); // subject ok Message confirmation = inbox.get(0); assertEquals(subject, confirmation.getSubject()); // confirmation url ok String mailContent = (String) ((MimeMultipart) confirmation.getContent()).getBodyPart(1).getContent(); logger.info(mailContent); assertTrue(StringUtils.contains(mailContent.toLowerCase(), confirmation_url.toLowerCase())); // token ok String token = getTokenFromMessage(confirmation); logger.info(token); ActivationState activeState = setup.getMgmtSvc().handleConfirmationTokenForAppUser(app.getId(), user.getUuid(), token); assertEquals(ActivationState.CONFIRMED_AWAITING_ACTIVATION, activeState); }
/** * Tests that when a user is added to an app and activation on that app is required, the org admin * is emailed * * @throws Exception * <p>TODO, I'm not convinced this worked correctly. IT can't find users collection in the * orgs. Therefore, I think this is a legitimate bug that was just found from fixing the tests * to be unique admins orgs and emails */ @Test public void testAppUserActivationResetpwdMail() throws Exception { final String orgName = uniqueOrg(); final String appName = uniqueApp(); final String adminUserName = uniqueUsername(); final String adminEmail = uniqueEmail(); final String adminPasswd = "testpassword"; OrganizationOwnerInfo orgOwner = createOwnerAndOrganization( orgName, appName, adminUserName, adminEmail, adminPasswd, false, false); assertNotNull(orgOwner); ApplicationInfo app = setup.getMgmtSvc().createApplication(orgOwner.getOrganization().getUuid(), appName); this.app.refreshIndex(); // turn on app admin approval for app users enableAdminApproval(app.getId()); final String appUserUsername = uniqueUsername(); final String appUserEmail = uniqueEmail(); OrganizationConfig orgConfig = setup.getMgmtSvc().getOrganizationConfigByUuid(orgOwner.getOrganization().getUuid()); User appUser = setupAppUser(app.getId(), appUserUsername, appUserEmail, false); String subject = "Request For User Account Activation " + appUserEmail; String activation_url = orgConfig.getFullUrl( WorkflowUrl.USER_ACTIVATION_URL, orgName, appName, appUser.getUuid().toString()); setup.refreshIndex(app.getId()); // Activation setup.getMgmtSvc().startAppUserActivationFlow(app.getId(), appUser); List<Message> inbox = Mailbox.get(adminEmail); assertFalse(inbox.isEmpty()); MockImapClient client = new MockImapClient("usergrid.com", adminUserName, "somepassword"); client.processMail(); // subject ok Message activation = inbox.get(0); assertEquals(subject, activation.getSubject()); // activation url ok String mailContent = (String) ((MimeMultipart) activation.getContent()).getBodyPart(1).getContent(); logger.info(mailContent); assertTrue(StringUtils.contains(mailContent.toLowerCase(), activation_url.toLowerCase())); // token ok String token = getTokenFromMessage(activation); logger.info(token); ActivationState activeState = setup.getMgmtSvc().handleActivationTokenForAppUser(app.getId(), appUser.getUuid(), token); assertEquals(ActivationState.ACTIVATED, activeState); subject = "Password Reset"; String reset_url = orgConfig.getFullUrl( WorkflowUrl.USER_RESETPW_URL, orgName, appName, appUser.getUuid().toString()); // reset_pwd setup.getMgmtSvc().startAppUserPasswordResetFlow(app.getId(), appUser); inbox = Mailbox.get(appUserEmail); assertFalse(inbox.isEmpty()); client = new MockImapClient("test.com", appUserUsername, "somepassword"); client.processMail(); // subject ok Message reset = inbox.get(1); assertEquals(subject, reset.getSubject()); // resetpwd url ok mailContent = (String) ((MimeMultipart) reset.getContent()).getBodyPart(1).getContent(); logger.info(mailContent); assertTrue(StringUtils.contains(mailContent.toLowerCase(), reset_url.toLowerCase())); // token ok token = getTokenFromMessage(reset); logger.info(token); assertTrue( setup .getMgmtSvc() .checkPasswordResetTokenForAppUser(app.getId(), appUser.getUuid(), token)); // ensure revoke works setup.getMgmtSvc().revokeAccessTokenForAppUser(token); assertFalse( setup .getMgmtSvc() .checkPasswordResetTokenForAppUser(app.getId(), appUser.getUuid(), token)); }
@Bean ApplicationInfo applicationInfo() { return ApplicationInfo.applicationInfo("test-app", "desc", "test-group", "test-env"); }
public synchronized ApplicationStatus getApplicationStatus(String applicationName) { ApplicationInfo existing = applicationHash.get(applicationName); if (existing == null) throw new UnknownApplicationException(String.format(UNKNOWN_APPLICATION_S, applicationName)); return existing.getApplicationStatus(); }