Get the time at which the app was first installed, in milliseconds.
@param context Context.
@return the time at which the app was first installed.
331791
static long getFirstInstallTime(Context context) {
        long firstTime = 0L;
        if (context != null) {
            try {
                final PackageInfo packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
                firstTime = packageInfo.firstInstallTime;
            } catch (Exception e) {
                PrefHelper.LogException("Error obtaining FirstInstallTime", e);
            }
        }

        return firstTime;
    }
345427
public static boolean isInstalled(@NonNull final Context context,
                                      @NonNull final String appPackage) {
        try {
            return context.getPackageManager().getApplicationInfo(appPackage, 0) != null;
        } catch (PackageManager.NameNotFoundException ignore) {
            // ignore
        }
        return false;
    }
957563
protected ApplicationContext getApplicationContext(JobExecutionContext context)
            throws SchedulerException {

        final SchedulerContext schedulerContext = context.getScheduler().getContext();
        ApplicationContext applicationContext =  (ApplicationContext) schedulerContext.get(APPLICATION_CONTEXT_KEY);

        // show keys in context
        if(applicationContext==null) {
            logger.error(APPLICATION_CONTEXT_KEY+" is empty in "+ schedulerContext+":");
            if(schedulerContext.getKeys()!=null) {
                for (String key : schedulerContext.getKeys()) {
                    Object value = schedulerContext.get(key);
                    String valueText = value!=null ? value.toString() : "<NULL>";
                    logger.info("    {} = {}", key, valueText);
                }
            }
        }

        return applicationContext;
    }
464321
private MillisProvider getCurrentTimeMillisProvider() {
		try {
			Field providerField = DateTimeUtils.class.getDeclaredField("cMillisProvider");
			providerField.setAccessible(true);
			return (MillisProvider) providerField.get(null);
		} catch (NoSuchFieldException e) {
			throw new UnsupportedClassVersionError("The JodaTime version in use is not supported by TimeMachine. Try to use version 2.2");
		} catch (IllegalArgumentException e) {
			throw new RuntimeException("This should not happen", e);
		} catch (IllegalAccessException e) {
			throw new RuntimeException("This should not happen", e);
		}
	}
1192474
public static final synchronized StateManager getInstance(Object context) {
		
		return (instance == null)? 
				(instance = new StateService(ContextUtils.asApplication(context))) :instance;
	}
446703
public static boolean isSystemApp(@NonNull final Context context,
                                      @NonNull final String appPackage) {
        try {
            final ApplicationInfo appInfo = context.getPackageManager().getApplicationInfo(
                    appPackage, 0);
            return (appInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0
                    || (appInfo.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0;
        } catch (PackageManager.NameNotFoundException ignore) {
            // ignore
        }
        return false;
    }
332457
public int getMinutesPerMonth()
   {
      return m_minutesPerMonth == null ? NumberHelper.getInt(getParentFile().getProjectProperties().getMinutesPerMonth()) : m_minutesPerMonth.intValue();
   }
921980
@Nullable
    public static String getPackageInstaller(@NonNull final Context context) {
        final PackageManager packageManager = context.getPackageManager();
        return packageManager.getInstallerPackageName(context.getPackageName());
    }
990551
public final TemporalAmount getDuration() {
        if (duration == null) {
            return TemporalAmountAdapter.fromDateRange(getStart(), getEnd()).getDuration();
        }
        return duration.getDuration();
    }
911769
@TargetApi(Build.VERSION_CODES.GINGERBREAD)
    public static boolean hasSipFeature(Context context) {
        return hasSipFeature(context.getPackageManager());
    }
1271325
public static int getFirstDayOfWeek(Context context) {
        int startDay = Calendar.getInstance().getFirstDayOfWeek();

        if (startDay == Calendar.SATURDAY) {
            return Time.SATURDAY;
        } else if (startDay == Calendar.MONDAY) {
            return Time.MONDAY;
        } else {
            return Time.SUNDAY;
        }
    }
804361
private static String getRegistrationId(Context context) {
        final SharedPreferences prefs = getGcmPreferences(context);
        String registrationId = prefs.getString(PROPERTY_REG_ID, "");
        if (registrationId.isEmpty()) {
            return "";
        }
        // Check if app was updated; if so, it must clear the registration ID
        // since the existing regID is not guaranteed to work with the new
        // app version.
        int registeredVersion = prefs.getInt(PROPERTY_APP_VERSION, Integer.MIN_VALUE);
        int currentVersion = getAppVersion(context);
        if (registeredVersion != currentVersion) {
            return "";
        }

        if (OrtcClient.getOnRegistrationId() != null){
            OrtcClient.getOnRegistrationId().run(registrationId);
        }

        return registrationId;
    }
1163713
@JmxGetter(name = "lastSwapped", description = "Time in milliseconds since the store was swapped")
    public long getLastSwapped() {
        long timeSinceLastSwap = System.currentTimeMillis() - lastSwapped;
        return timeSinceLastSwap > 0 ? timeSinceLastSwap : 0;
    }
315293
public com.google.api.Context getContext() {
    return context_ == null ? com.google.api.Context.getDefaultInstance() : context_;
  }
1197589
public long total(ByteBuffer context)
    {
        long total = 0L;
        // we could use a ContextState but it is easy enough that we avoid the object creation
        for (int offset = context.position() + headerLength(context); offset < context.limit(); offset += STEP_LENGTH)
            total += context.getLong(offset + CounterId.LENGTH + CLOCK_LENGTH);
        return total;
    }
1302030
public static Date getCurrentDate(Context context) throws GeneralException {

        URI propName = Constants.ENVIRONMENT.CURRENT_DATE_TIME.attributeId;
        String dateTimeValue = context.getEnvironmentValue(propName);
        if (dateTimeValue == null) {
            throw new GeneralException("Missing value for environment "
                    + "context attribute: " + propName);
        }

        try {
            return DateUtility.parseDateStrict(dateTimeValue);
        } catch (ParseException e) {
            throw new GeneralException(e.getMessage());
        }
    }
625079
public static boolean isTopApplication(Context context) {
		ComponentName activity = getTopActivity(context);
		if (activity == null) {
			return false;
		}
		return activity.getPackageName().equals(context.getApplicationInfo().packageName);
	}