Java Code Examples for android.content.pm.ApplicationInfo

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project android_packages_apps_phone, under directory /src/com/android/phone/.

Source file: PhoneUtils.java

  20 
vote

/** 
 * Get the provider's label from the intent.
 * @param context to lookup the provider's package name.
 * @param intent with an extra set to the provider's package name.
 * @return The provider's application label. null if an erroroccurred during the lookup of the package name or the label.
 */
static CharSequence getProviderLabel(Context context,Intent intent){
  String packageName=intent.getStringExtra(InCallScreen.EXTRA_GATEWAY_PROVIDER_PACKAGE);
  PackageManager pm=context.getPackageManager();
  try {
    ApplicationInfo info=pm.getApplicationInfo(packageName,0);
    return pm.getApplicationLabel(info);
  }
 catch (  PackageManager.NameNotFoundException e) {
    return null;
  }
}
 

Example 2

From project droidparts, under directory /base/src/org/droidparts/util/.

Source file: L.java

  20 
vote

private static boolean isDebug(){
  if (_debug == null) {
    Context ctx=Injector.getApplicationContext();
    if (ctx != null) {
      ApplicationInfo appInfo=ctx.getApplicationInfo();
      _debug=(appInfo.flags & FLAG_DEBUGGABLE) != 0;
    }
  }
  boolean debug=(_debug == null) ? true : _debug;
  return debug;
}
 

Example 3

From project android_packages_apps_Nfc, under directory /src/com/android/nfc/.

Source file: P2pLinkManager.java

  19 
vote

boolean beamDefaultDisabled(String pkgName){
  try {
    ApplicationInfo ai=mPackageManager.getApplicationInfo(pkgName,PackageManager.GET_META_DATA);
    if (ai == null || ai.metaData == null) {
      return false;
    }
    return ai.metaData.getBoolean(DISABLE_BEAM_DEFAULT);
  }
 catch (  NameNotFoundException e) {
    return false;
  }
}
 

Example 4

From project Android_1, under directory /LeftNavBarExample/LeftNavBarLibrary/src/com/example/google/tv/leftnavbar/.

Source file: HomeDisplay.java

  18 
vote

HomeDisplay(Context context,ViewGroup parent,TypedArray attributes){
  mContext=context;
  mMode=Mode.ICON;
  ApplicationInfo appInfo=context.getApplicationInfo();
  PackageManager pm=context.getPackageManager();
  loadLogo(attributes,pm,appInfo);
  loadIcon(attributes,pm,appInfo);
  createView(parent,attributes);
}
 

Example 5

From project BazaarUtils, under directory /src/com/congenialmobile/adad/.

Source file: AdsManager.java

  18 
vote

/** 
 * Reads the app token from AndroidManifest.xml. Adad gives a special token for each app, according to its package name, and this should be saved in the AndroidManifest as told by our manual. This function reads that.
 */
private void readAppToken(){
  try {
    ApplicationInfo appinfo=mContext.getPackageManager().getApplicationInfo(mContext.getPackageName(),PackageManager.GET_META_DATA);
    Bundle bundle=appinfo.metaData;
    if (bundle != null) {
      mToken=bundle.getString("ADAD_TOKEN");
    }
  }
 catch (  NameNotFoundException nfe) {
    if (DEBUG_ADAD) {
      Log.w(TAG,"AdsManager :: NameNotFoundException in readAppToken",nfe);
    }
  }
}
 

Example 6

From project creamed_glacier_app_settings, under directory /tests/src/com/android/settings/.

Source file: SettingsHookTests.java

  18 
vote

/** 
 * Test that the operator/manufacturer settings hook test application is available and that it's installed in the device's system image.
 */
public void testSettingsHookTestAppAvailable() throws Exception {
  Context context=mSettings.getApplicationContext();
  PackageManager pm=context.getPackageManager();
  ApplicationInfo applicationInfo=pm.getApplicationInfo(PACKAGE_NAME,0);
  assertTrue((applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0);
}
 

Example 7

From project iJetty, under directory /i-jetty/i-jetty-ui/src/org/mortbay/ijetty/util/.

Source file: AndroidInfo.java

  18 
vote

public static CharSequence getApplicationLabel(Context context){
  try {
    PackageManager pm=context.getPackageManager();
    ApplicationInfo ai=pm.getApplicationInfo(context.getPackageName(),0);
    return pm.getApplicationLabel(ai);
  }
 catch (  NameNotFoundException e) {
    return "AnonDroid";
  }
}
 

Example 8

From project IOCipherServer, under directory /src/info/guardianproject/iocipher/server/.

Source file: AppShareServlet.java

  18 
vote

private void getApps(){
  PackageManager pMgr=context.getPackageManager();
  List<ApplicationInfo> lAppInfo=pMgr.getInstalledApplications(0);
  Iterator<ApplicationInfo> itAppInfo=lAppInfo.iterator();
  ApplicationInfo aInfo;
  while (itAppInfo.hasNext()) {
    aInfo=itAppInfo.next();
    String path=aInfo.sourceDir;
    String name=aInfo.name;
  }
}
 

Example 9

From project Jota-Text-Editor, under directory /src/jp/sblo/pandora/jota/.

Source file: DonateActivity.java

  18 
vote

public boolean isDebuggable(){
  PackageManager manager=getPackageManager();
  ApplicationInfo appInfo=null;
  try {
    appInfo=manager.getApplicationInfo(getPackageName(),0);
  }
 catch (  NameNotFoundException e) {
    return false;
  }
  if ((appInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) == ApplicationInfo.FLAG_DEBUGGABLE)   return true;
  return false;
}
 

Example 10

From project madvertise-android-sdk, under directory /madvertiseSDK/src/de/madvertise/android/sdk/.

Source file: MadvertiseUtil.java

  18 
vote

public static String getApplicationName(final Context context){
  String appName="";
  PackageManager packageManager=context.getPackageManager();
  try {
    ApplicationInfo applicationInfo=packageManager.getApplicationInfo(context.getPackageName(),PackageManager.GET_META_DATA);
    appName=packageManager.getApplicationLabel(applicationInfo).toString();
  }
 catch (  NameNotFoundException e) {
    e.printStackTrace();
  }
  return appName;
}
 

Example 11

From project mWater-Android-App, under directory /android/src/co/mwater/clientapp/ui/map/.

Source file: SourceMapActivity.java

  18 
vote

/** 
 * Check if in debug mode for correct map key
 * @return
 */
private boolean isDebuggable(){
  boolean debuggable=false;
  PackageManager pm=getPackageManager();
  try {
    ApplicationInfo appinfo=pm.getApplicationInfo(getPackageName(),0);
    debuggable=(0 != (appinfo.flags&=ApplicationInfo.FLAG_DEBUGGABLE));
  }
 catch (  NameNotFoundException e) {
  }
  return debuggable;
}
 

Example 12

From project Ohmage_Phone, under directory /src/org/ohmage/.

Source file: OhmageApplication.java

  18 
vote

public void setupObject(){
  GlobalConfig config=GlobalConfig.getInstance();
  PackageManager pm=getPackageManager();
  ApplicationInfo ai=getApplicationInfo();
  String name=(String)pm.getApplicationLabel(ai);
  try {
    _base_uri=config.getRoot().append(OhmagePDVManager.getAppInstance());
  }
 catch (  MalformedContentNameStringException ex) {
    throw new Error("Unable to set base name",ex);
  }
  _data_stream=new HashMap<String,DataStream>();
  _to_pull=new LinkedHashSet<String>();
}
 

Example 13

From project packages_apps_Phone_1, under directory /src/com/android/phone/.

Source file: PhoneUtils.java

  18 
vote

/** 
 * Get the provider's label from the intent.
 * @param context to lookup the provider's package name.
 * @param intent with an extra set to the provider's package name.
 * @return The provider's application label. null if an erroroccurred during the lookup of the package name or the label.
 */
static CharSequence getProviderLabel(Context context,Intent intent){
  String packageName=intent.getStringExtra(InCallScreen.EXTRA_GATEWAY_PROVIDER_PACKAGE);
  PackageManager pm=context.getPackageManager();
  try {
    ApplicationInfo info=pm.getApplicationInfo(packageName,0);
    return pm.getApplicationLabel(info);
  }
 catch (  PackageManager.NameNotFoundException e) {
    return null;
  }
}
 

Example 14

From project packages_apps_ROMControl, under directory /src/com/aokp/romcontrol/fragments/.

Source file: LEDControl.java

  18 
vote

private void putAppInUnicornList(String packageName){
  final PackageManager pm=mActivity.getPackageManager();
  ApplicationInfo ai;
  try {
    ai=pm.getApplicationInfo(packageName,0);
  }
 catch (  final NameNotFoundException e) {
    ai=null;
  }
  final String applicationName=(String)(ai != null ? pm.getApplicationLabel(ai) : "unknown");
  unicornApps.add(unicornApps.size() - 1,applicationName);
  adapterRefreshSetting();
}
 

Example 15

From project platform_packages_apps_CytownPhone, under directory /src/com/android/phone/.

Source file: PhoneUtils.java

  18 
vote

/** 
 * Get the provider's label from the intent.
 * @param context to lookup the provider's package name.
 * @param intent with an extra set to the provider's package name.
 * @return The provider's application label. null if an erroroccurred during the lookup of the package name or the label.
 */
static CharSequence getProviderLabel(Context context,Intent intent){
  String packageName=intent.getStringExtra(InCallScreen.EXTRA_GATEWAY_PROVIDER_PACKAGE);
  PackageManager pm=context.getPackageManager();
  try {
    ApplicationInfo info=pm.getApplicationInfo(packageName,0);
    return pm.getApplicationLabel(info);
  }
 catch (  PackageManager.NameNotFoundException e) {
    return null;
  }
}
 

Example 16

From project platform_packages_apps_phone, under directory /src/com/android/phone/.

Source file: PhoneUtils.java

  18 
vote

/** 
 * Get the provider's label from the intent.
 * @param context to lookup the provider's package name.
 * @param intent with an extra set to the provider's package name.
 * @return The provider's application label. null if an erroroccurred during the lookup of the package name or the label.
 */
static CharSequence getProviderLabel(Context context,Intent intent){
  String packageName=intent.getStringExtra(InCallScreen.EXTRA_GATEWAY_PROVIDER_PACKAGE);
  PackageManager pm=context.getPackageManager();
  try {
    ApplicationInfo info=pm.getApplicationInfo(packageName,0);
    return pm.getApplicationLabel(info);
  }
 catch (  PackageManager.NameNotFoundException e) {
    return null;
  }
}
 

Example 17

From project platform_packages_apps_settings, under directory /tests/src/com/android/settings/.

Source file: SettingsHookTests.java

  18 
vote

/** 
 * Test that the operator/manufacturer settings hook test application is available and that it's installed in the device's system image.
 */
public void testSettingsHookTestAppAvailable() throws Exception {
  Context context=mSettings.getApplicationContext();
  PackageManager pm=context.getPackageManager();
  ApplicationInfo applicationInfo=pm.getApplicationInfo(PACKAGE_NAME,0);
  assertTrue((applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0);
}
 

Example 18

From project platform_packages_providers_contactsprovider, under directory /src/com/android/providers/contacts/.

Source file: ContactsDatabaseHelper.java

  18 
vote

/** 
 * Return the  {@link ApplicationInfo#uid} for the given package name.
 */
public static int getUidForPackageName(PackageManager pm,String packageName){
  try {
    ApplicationInfo clientInfo=pm.getApplicationInfo(packageName,0);
    return clientInfo.uid;
  }
 catch (  NameNotFoundException e) {
    throw new RuntimeException(e);
  }
}
 

Example 19

From project PowerTutor, under directory /src/edu/umich/PowerTutor/util/.

Source file: SystemInfo.java

  18 
vote

public Drawable getUidIconNoCache(int uid,PackageManager pm){
  String[] packages=pm.getPackagesForUid(uid);
  if (packages != null)   for (int i=0; i < packages.length; i++) {
    try {
      ApplicationInfo ai=pm.getApplicationInfo(packages[i],0);
      if (ai.icon != 0) {
        return ai.loadIcon(pm);
      }
    }
 catch (    PackageManager.NameNotFoundException e) {
    }
  }
  return pm.getDefaultActivityIcon();
}
 

Example 20

From project sls, under directory /src/com/adam/aslfms/util/.

Source file: Util.java

  18 
vote

public static String getAppName(Context ctx,String pkgName){
  try {
    PackageManager pm=ctx.getPackageManager();
    ApplicationInfo appInfo=pm.getApplicationInfo(pkgName,0);
    String label=pm.getApplicationLabel(appInfo).toString();
    return label;
  }
 catch (  NameNotFoundException e) {
    return "";
  }
}
 

Example 21

From project ToolkitForAndroid, under directory /src/main/java/com/apkits/android/system/.

Source file: ApkUtil.java

  18 
vote

/** 
 * <b>description :</b>		???APK??????? </br><b>time :</b>		2012-8-11 ???8:39:44
 * @param context
 * @param packageName
 * @return
 */
public static boolean exist(Context context,String packageName){
  if (null == packageName || "".equals(packageName)) {
    throw new IllegalArgumentException("Package name cannot be null or empty !");
  }
  try {
    ApplicationInfo info=context.getPackageManager().getApplicationInfo(packageName,PackageManager.GET_UNINSTALLED_PACKAGES);
    return null != info;
  }
 catch (  NameNotFoundException e) {
    return false;
  }
}
 

Example 22

From project xinkvpn, under directory /main/src/domain/xink/vpn/wrapper/.

Source file: AbstractWrapper.java

  18 
vote

private static void initClassLoader(final Context ctx) throws NameNotFoundException {
  if (stubClassLoader != null) {
    return;
  }
  ApplicationInfo vpnAppInfo=ctx.getPackageManager().getApplicationInfo(STUB_PACK,0);
  stubClassLoader=new PathClassLoader(vpnAppInfo.sourceDir,ClassLoader.getSystemClassLoader());
}
 

Example 23

From project yammp, under directory /src/org/yammp/util/.

Source file: PluginInfo.java

  18 
vote

public PluginInfo(ResolveInfo resolveInfo,PackageManager pm){
  ApplicationInfo info=resolveInfo.activityInfo.applicationInfo;
  icon=info.loadIcon(pm);
  name=info.loadLabel(pm);
  pname=info.packageName;
  description=info.loadDescription(pm);
  if (description == null) {
    description="";
  }
}
 

Example 24

From project ActionBarCompat, under directory /ActionBarCompat/src/sk/m217/actionbarcompat/.

Source file: ActionBarHelperBase.java

  17 
vote

/** 
 * Sets up the compatibility action bar with the given title.
 */
private void setupActionBar(){
  final ViewGroup actionBarCompat=getActionBarCompat();
  if (actionBarCompat == null) {
    return;
  }
  mHomeItem=new SimpleMenuItem(new SimpleMenu(mActivity),android.R.id.home,0,mActivity.getTitle());
  final LayoutInflater inflater=LayoutInflater.from(mActivity);
  mHomeLayout=(HomeView)inflater.inflate(R.layout.actionbar_compat_home,actionBarCompat,false);
  mHomeLayout.setOnClickListener(mUpClickListener);
  mHomeLayout.setClickable(true);
  mHomeLayout.setFocusable(true);
  mExpandedHomeLayout=(HomeView)inflater.inflate(R.layout.actionbar_compat_home,actionBarCompat,false);
  mExpandedHomeLayout.setUp(true);
  mExpandedHomeLayout.setOnClickListener(mExpandedActionViewUpListener);
  mExpandedHomeLayout.setContentDescription(mActivity.getResources().getText(R.string.action_bar_up_description));
  mExpandedHomeLayout.setFocusable(true);
  ApplicationInfo appInfo=mActivity.getApplicationInfo();
  PackageManager pm=mActivity.getPackageManager();
  try {
    mIcon=pm.getActivityIcon(mActivity.getComponentName());
  }
 catch (  NameNotFoundException e) {
    Log.e(TAG,"Activity component name not found!",e);
  }
  if (mIcon == null) {
    mIcon=appInfo.loadIcon(pm);
  }
  mHomeLayout.setIcon(mIcon);
  actionBarCompat.addView(mHomeLayout);
  LinearLayout.LayoutParams springLayoutParams=new LinearLayout.LayoutParams(0,ViewGroup.LayoutParams.FILL_PARENT);
  springLayoutParams.weight=1;
  mTitle=mActivity.getTitle();
  mTitleText=new TextView(mActivity,null,R.attr.actionbarCompatTitleStyle);
  mTitleText.setLayoutParams(springLayoutParams);
  mTitleText.setText(mTitle);
  actionBarCompat.addView(mTitleText);
  setDisplayOptions(DISPLAY_SHOW_HOME | DISPLAY_SHOW_TITLE);
}
 

Example 25

From project Android-File-Manager, under directory /src/com/nexes/manager/.

Source file: ApplicationBackup.java

  17 
vote

public void run(){
  BufferedInputStream mBuffIn;
  BufferedOutputStream mBuffOut;
  Message msg;
  int len=mDataSource.size();
  int read=0;
  for (int i=0; i < len; i++) {
    ApplicationInfo info=mDataSource.get(i);
    String source_dir=info.sourceDir;
    String out_file=source_dir.substring(source_dir.lastIndexOf("/") + 1,source_dir.length());
    try {
      mBuffIn=new BufferedInputStream(new FileInputStream(source_dir));
      mBuffOut=new BufferedOutputStream(new FileOutputStream(BACKUP_LOC + out_file));
      while ((read=mBuffIn.read(mData,0,BUFFER)) != -1)       mBuffOut.write(mData,0,read);
      mBuffOut.flush();
      mBuffIn.close();
      mBuffOut.close();
      msg=new Message();
      msg.what=SET_PROGRESS;
      msg.obj=i + " out of " + len+ " apps backed up";
      mHandler.sendMessage(msg);
    }
 catch (    FileNotFoundException e) {
      e.printStackTrace();
    }
catch (    IOException e) {
      e.printStackTrace();
    }
  }
  mHandler.sendEmptyMessage(FINISH_PROGRESS);
}
 

Example 26

From project AndroidCommon, under directory /src/com/asksven/android/common/nameutils/.

Source file: UidNameResolver.java

  17 
vote

public String getLabel(Context context,String packageName){
  String ret=packageName;
  PackageManager pm=context.getPackageManager();
  try {
    ApplicationInfo ai=pm.getApplicationInfo(packageName,0);
    CharSequence label=ai.loadLabel(pm);
    if (label != null) {
      ret=label.toString();
    }
  }
 catch (  NameNotFoundException e) {
    ret=packageName;
  }
  return ret;
}
 

Example 27

From project android_aosp_packages_apps_Settings, under directory /src/com/android/settings/.

Source file: AccessibilitySettings.java

  17 
vote

/** 
 * Displays a message telling the user that they do not have any accessibility related apps installed and that they can get TalkBack (Google's free screen reader) from Market.
 */
private void displayNoAppsAlert(){
  try {
    PackageManager pm=getPackageManager();
    ApplicationInfo info=pm.getApplicationInfo("com.android.vending",0);
  }
 catch (  NameNotFoundException e) {
    return;
  }
  AlertDialog.Builder noAppsAlert=new AlertDialog.Builder(this);
  noAppsAlert.setTitle(R.string.accessibility_service_no_apps_title);
  noAppsAlert.setMessage(R.string.accessibility_service_no_apps_message);
  noAppsAlert.setPositiveButton(android.R.string.ok,new DialogInterface.OnClickListener(){
    public void onClick(    DialogInterface dialog,    int which){
      String screenreaderMarketLink=SystemProperties.get("ro.screenreader.market",DEFAULT_SCREENREADER_MARKET_LINK);
      Uri marketUri=Uri.parse(screenreaderMarketLink);
      Intent marketIntent=new Intent(Intent.ACTION_VIEW,marketUri);
      startActivity(marketIntent);
      finish();
    }
  }
);
  noAppsAlert.setNegativeButton(android.R.string.cancel,new DialogInterface.OnClickListener(){
    public void onClick(    DialogInterface dialog,    int which){
    }
  }
);
  noAppsAlert.show();
}
 

Example 28

From project android_packages_apps_cmparts, under directory /src/com/cyanogenmod/cmparts/activities/.

Source file: PhoneGogglesActivity.java

  17 
vote

@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setTitle(R.string.title_phone_goggles);
  addPreferencesFromResource(R.xml.phone_goggles_settings);
  PreferenceScreen prefSet=getPreferenceScreen();
  PreferenceCategory appCategory=(PreferenceCategory)prefSet.findPreference("phone_goggles_apps");
  PackageManager packageManager=getPackageManager();
  Intent intent=new Intent(ACTION_PHONE_GOGGLES_COMMUNICATION);
  List<ResolveInfo> infos=packageManager.queryIntentActivities(intent,0);
  mPhoneGogglesEnabled=(CheckBoxPreference)prefSet.findPreference(Settings.System.PHONE_GOGGLES_ENABLED);
  mPhoneGogglesApps=new ArrayList<Preference>();
  for (  ResolveInfo currentInfo : infos) {
    ApplicationInfo appInfos=currentInfo.activityInfo.applicationInfo;
    CharSequence label=appInfos.loadLabel(getPackageManager());
    CharSequence summary=appInfos.loadDescription(packageManager);
    String packageName=appInfos.packageName;
    Preference pref=new Preference(this);
    pref.setKey(packageName);
    pref.setTitle(label);
    pref.setSummary(summary);
    pref.setEnabled(mPhoneGogglesEnabled.isChecked());
    appCategory.addPreference(pref);
    mPhoneGogglesApps.add(pref);
  }
}
 

Example 29

From project android_packages_apps_Superuser, under directory /src/com/noshufou/android/su/util/.

Source file: Util.java

  17 
vote

public static Drawable getAppIcon(Context c,int uid){
  PackageManager pm=c.getPackageManager();
  Drawable appIcon=c.getResources().getDrawable(R.drawable.sym_def_app_icon);
  String[] packages=pm.getPackagesForUid(uid);
  if (packages != null) {
    try {
      ApplicationInfo appInfo=pm.getApplicationInfo(packages[0],0);
      appIcon=pm.getApplicationIcon(appInfo);
    }
 catch (    NameNotFoundException e) {
      Log.e(TAG,"No package found matching with the uid " + uid);
    }
  }
 else {
    Log.e(TAG,"Package not found for uid " + uid);
  }
  return appIcon;
}
 

Example 30

From project be.norio.twunch.android, under directory /src/be/norio/twunch/android/util/.

Source file: ViewServer.java

  17 
vote

/** 
 * Returns a unique instance of the ViewServer. This method should only be called from the main thread of your application. The server will have the same lifetime as your process. If your application does not have the <code>android:debuggable</code> flag set in its manifest, the server returned by this method will be a dummy object that does not do anything. This allows you to use the same code in debug and release versions of your application.
 * @param context A Context used to check whether the application is debuggable, this can be the application context
 */
public static ViewServer get(Context context){
  ApplicationInfo info=context.getApplicationInfo();
  if (BUILD_TYPE_USER.equals(Build.TYPE) && (info.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) {
    if (sServer == null) {
      sServer=new ViewServer(ViewServer.VIEW_SERVER_DEFAULT_PORT);
    }
    if (!sServer.isRunning()) {
      try {
        sServer.start();
      }
 catch (      IOException e) {
        Log.d("LocalViewServer","Error:",e);
      }
    }
  }
 else {
    sServer=new NoopViewServer();
  }
  return sServer;
}
 

Example 31

From project CheckIn4Me, under directory /src/com/davidivins/checkin4me/core/.

Source file: MetaData.java

  17 
vote

/** 
 * initialize
 * @param activity
 */
public static Bundle getInstance(Activity activity){
  if (null == meta_data || !good_bundle) {
    try {
      ApplicationInfo app_info=activity.getPackageManager().getApplicationInfo(activity.getPackageName(),PackageManager.GET_META_DATA);
      meta_data=app_info.metaData;
      good_bundle=true;
    }
 catch (    Exception e) {
      meta_data=new Bundle();
      good_bundle=false;
      Log.e(TAG,"Failed to get app info. Returning empty bundle.");
    }
  }
  return meta_data;
}
 

Example 32

From project cornerstone, under directory /frameworks/base/services/java/com/android/server/am/.

Source file: ActivityManagerService.java

  17 
vote

public static void setSystemProcess(){
  try {
    ActivityManagerService m=mSelf;
    ServiceManager.addService("activity",m);
    ServiceManager.addService("meminfo",new MemBinder(m));
    ServiceManager.addService("gfxinfo",new GraphicsBinder(m));
    if (MONITOR_CPU_USAGE) {
      ServiceManager.addService("cpuinfo",new CpuBinder(m));
    }
    ServiceManager.addService("permission",new PermissionController(m));
    ApplicationInfo info=mSelf.mContext.getPackageManager().getApplicationInfo("android",STOCK_PM_FLAGS);
    mSystemThread.installSystemApplicationInfo(info);
synchronized (mSelf) {
      ProcessRecord app=mSelf.newProcessRecordLocked(mSystemThread.getApplicationThread(),info,info.processName);
      app.persistent=true;
      app.pid=MY_PID;
      app.maxAdj=ProcessList.SYSTEM_ADJ;
      mSelf.mProcessNames.put(app.processName,app.info.uid,app);
synchronized (mSelf.mPidsSelfLocked) {
        mSelf.mPidsSelfLocked.put(app.pid,app);
      }
      mSelf.updateLruProcessLocked(app,true,true);
    }
  }
 catch (  PackageManager.NameNotFoundException e) {
    throw new RuntimeException("Unable to find android system package",e);
  }
}
 

Example 33

From project COSsettings, under directory /src/com/cyanogenmod/cmparts/activities/.

Source file: PhoneGogglesActivity.java

  17 
vote

@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setTitle(R.string.title_phone_goggles);
  addPreferencesFromResource(R.xml.phone_goggles_settings);
  PreferenceScreen prefSet=getPreferenceScreen();
  PreferenceCategory appCategory=(PreferenceCategory)prefSet.findPreference("phone_goggles_apps");
  PackageManager packageManager=getPackageManager();
  Intent intent=new Intent(ACTION_PHONE_GOGGLES_COMMUNICATION);
  List<ResolveInfo> infos=packageManager.queryIntentActivities(intent,0);
  mPhoneGogglesEnabled=(CheckBoxPreference)prefSet.findPreference(Settings.System.PHONE_GOGGLES_ENABLED);
  mPhoneGogglesApps=new ArrayList<Preference>();
  for (  ResolveInfo currentInfo : infos) {
    ApplicationInfo appInfos=currentInfo.activityInfo.applicationInfo;
    CharSequence label=appInfos.loadLabel(getPackageManager());
    CharSequence summary=appInfos.loadDescription(packageManager);
    String packageName=appInfos.packageName;
    Preference pref=new Preference(this);
    pref.setKey(packageName);
    pref.setTitle(label);
    pref.setSummary(summary);
    pref.setEnabled(mPhoneGogglesEnabled.isChecked());
    appCategory.addPreference(pref);
    mPhoneGogglesApps.add(pref);
  }
}
 

Example 34

From project dccsched, under directory /src/com/underhilllabs/dccsched/ui/.

Source file: SessionDetailActivity.java

  17 
vote

/** 
 * Handle Moderator link. 
 */
public void onModeratorClick(View v){
  boolean appPresent=false;
  try {
    final PackageManager pm=getPackageManager();
    final ApplicationInfo ai=pm.getApplicationInfo(MODERATOR_PACKAGE,0);
    if (ai != null)     appPresent=true;
  }
 catch (  NameNotFoundException e) {
    Log.w(TAG,"Problem searching for moderator: " + e.toString());
  }
  if (appPresent) {
    startModerator();
  }
 else {
    showDialog(R.id.dialog_moderator);
  }
}
 

Example 35

From project DrmLicenseService, under directory /src/com/sonyericsson/android/drm/drmlicenseservice/.

Source file: HttpClient.java

  17 
vote

private String getUserAgent(){
  String userAgent=Constants.FALLBACK_USER_AGENT;
  boolean uaFinalized=false;
  if (mParameters != null && mParameters.containsKey(Constants.DRM_KEYPARAM_USER_AGENT)) {
    String tempUA=mParameters.getString(Constants.DRM_KEYPARAM_USER_AGENT);
    if (tempUA != null && tempUA.length() > 0) {
      userAgent=tempUA;
      uaFinalized=true;
    }
  }
  if (!uaFinalized) {
    String versionName=null;
    CharSequence appName=null;
    try {
      PackageManager packageManager=mContext.getPackageManager();
      PackageInfo pInfo=packageManager.getPackageInfo(mContext.getPackageName(),0);
      versionName=pInfo.versionName;
      ApplicationInfo applicationInfo=pInfo.applicationInfo;
      appName=packageManager.getApplicationLabel(applicationInfo);
    }
 catch (    NameNotFoundException e) {
    }
    if (versionName != null && appName != null) {
      userAgent=appName + "/" + versionName+ " ("+ Build.VERSION.RELEASE+ ")";
    }
  }
  return userAgent;
}
 

Example 36

From project FileExplorer, under directory /src/net/micode/fileexplorer/.

Source file: Util.java

  17 
vote

public static Drawable getApkIcon(Context context,String apkPath){
  PackageManager pm=context.getPackageManager();
  PackageInfo info=pm.getPackageArchiveInfo(apkPath,PackageManager.GET_ACTIVITIES);
  if (info != null) {
    ApplicationInfo appInfo=info.applicationInfo;
    appInfo.sourceDir=apkPath;
    appInfo.publicSourceDir=apkPath;
    try {
      return appInfo.loadIcon(pm);
    }
 catch (    OutOfMemoryError e) {
      Log.e(LOG_TAG,e.toString());
    }
  }
  return null;
}
 

Example 37

From project friendica-for-android, under directory /mw-android-friendica-01/src/de/wikilab/android/friendica01/.

Source file: ViewServer.java

  17 
vote

/** 
 * Returns a unique instance of the ViewServer. This method should only be called from the main thread of your application. The server will have the same lifetime as your process. If your application does not have the <code>android:debuggable</code> flag set in its manifest, the server returned by this method will be a dummy object that does not do anything. This allows you to use the same code in debug and release versions of your application.
 * @param context A Context used to check whether the application isdebuggable, this can be the application context
 */
public static ViewServer get(Context context){
  ApplicationInfo info=context.getApplicationInfo();
  if (BUILD_TYPE_USER.equals(Build.TYPE) && (info.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) {
    if (sServer == null) {
      sServer=new ViewServer(ViewServer.VIEW_SERVER_DEFAULT_PORT);
    }
    if (!sServer.isRunning()) {
      try {
        sServer.start();
      }
 catch (      IOException e) {
        Log.d("LocalViewServer","Error:",e);
      }
    }
  }
 else {
    sServer=new NoopViewServer();
  }
  return sServer;
}
 

Example 38

From project incubator-cordova-android, under directory /framework/src/org/apache/cordova/.

Source file: CordovaWebViewClient.java

  17 
vote

/** 
 * Notify the host application that an SSL error occurred while loading a resource.  The host application must call either handler.cancel() or handler.proceed().  Note that the decision may be retained for use in response to future SSL errors.  The default behavior is to cancel the load.
 * @param view          The WebView that is initiating the callback.
 * @param handler       An SslErrorHandler object that will handle the user's response.
 * @param error         The SSL error object.
 */
@TargetApi(8) @Override public void onReceivedSslError(WebView view,SslErrorHandler handler,SslError error){
  final String packageName=this.cordova.getActivity().getPackageName();
  final PackageManager pm=this.cordova.getActivity().getPackageManager();
  ApplicationInfo appInfo;
  try {
    appInfo=pm.getApplicationInfo(packageName,PackageManager.GET_META_DATA);
    if ((appInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) {
      handler.proceed();
      return;
    }
 else {
      super.onReceivedSslError(view,handler,error);
    }
  }
 catch (  NameNotFoundException e) {
    super.onReceivedSslError(view,handler,error);
  }
}
 

Example 39

From project iosched_1, under directory /src/com/google/android/apps/iosched/ui/.

Source file: SessionDetailActivity.java

  17 
vote

/** 
 * Handle Moderator link. 
 */
public void onModeratorClick(View v){
  boolean appPresent=false;
  try {
    final PackageManager pm=getPackageManager();
    final ApplicationInfo ai=pm.getApplicationInfo(MODERATOR_PACKAGE,0);
    if (ai != null)     appPresent=true;
  }
 catch (  NameNotFoundException e) {
    Log.w(TAG,"Problem searching for moderator: " + e.toString());
  }
  if (appPresent) {
    startModerator();
  }
 else {
    showDialog(R.id.dialog_moderator);
  }
}
 

Example 40

From project Juggernaut_SystemUI, under directory /src/com/android/systemui/usb/.

Source file: UsbPermissionActivity.java

  17 
vote

@Override public void onCreate(Bundle icicle){
  super.onCreate(icicle);
  Intent intent=getIntent();
  mAccessory=(UsbAccessory)intent.getParcelableExtra(UsbManager.EXTRA_ACCESSORY);
  mDisconnectedReceiver=new UsbDisconnectedReceiver(this,mAccessory);
  mPendingIntent=(PendingIntent)intent.getParcelableExtra(Intent.EXTRA_INTENT);
  mUid=intent.getIntExtra("uid",0);
  mPackageName=intent.getStringExtra("package");
  PackageManager packageManager=getPackageManager();
  ApplicationInfo aInfo;
  try {
    aInfo=packageManager.getApplicationInfo(mPackageName,0);
  }
 catch (  PackageManager.NameNotFoundException e) {
    Log.e(TAG,"unable to look up package name",e);
    finish();
    return;
  }
  String appName=aInfo.loadLabel(packageManager).toString();
  final AlertController.AlertParams ap=mAlertParams;
  ap.mIcon=aInfo.loadIcon(packageManager);
  ap.mTitle=appName;
  ap.mMessage=getString(R.string.usb_accessory_permission_prompt,appName);
  ap.mPositiveButtonText=getString(android.R.string.ok);
  ap.mNegativeButtonText=getString(android.R.string.cancel);
  ap.mPositiveButtonListener=this;
  ap.mNegativeButtonListener=this;
  LayoutInflater inflater=(LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  ap.mView=inflater.inflate(com.android.internal.R.layout.always_use_checkbox,null);
  mAlwaysUse=(CheckBox)ap.mView.findViewById(com.android.internal.R.id.alwaysUse);
  mAlwaysUse.setText(R.string.always_use_accessory);
  mAlwaysUse.setOnCheckedChangeListener(this);
  mClearDefaultHint=(TextView)ap.mView.findViewById(com.android.internal.R.id.clearDefaultHint);
  mClearDefaultHint.setVisibility(View.GONE);
  setupAlert();
}
 

Example 41

From project kevoree-library, under directory /android/org.kevoree.library.android.osmdroid/src/main/java/org/osmdroid/tileprovider/util/.

Source file: CloudmadeUtil.java

  17 
vote

/** 
 * Retrieve the key from the manifest and store it for later use.
 */
public static void retrieveCloudmadeKey(final Context pContext){
  mAndroidId=Settings.Secure.getString(pContext.getContentResolver(),Settings.Secure.ANDROID_ID);
  final PackageManager pm=pContext.getPackageManager();
  try {
    final ApplicationInfo info=pm.getApplicationInfo(pContext.getPackageName(),PackageManager.GET_META_DATA);
    if (info.metaData == null) {
      logger.info("Cloudmade key not found in manifest");
    }
 else {
      final String key=info.metaData.getString(CLOUDMADE_KEY);
      if (key == null) {
        logger.info("Cloudmade key not found in manifest");
      }
 else {
        if (DEBUGMODE) {
          logger.debug("Cloudmade key: " + key);
        }
        mKey=key.trim();
      }
    }
  }
 catch (  final NameNotFoundException e) {
    logger.info("Cloudmade key not found in manifest",e);
  }
  final SharedPreferences pref=PreferenceManager.getDefaultSharedPreferences(pContext);
  mPreferenceEditor=pref.edit();
  final String id=pref.getString(CLOUDMADE_ID,"");
  if (id.equals(mAndroidId)) {
    mToken=pref.getString(CLOUDMADE_TOKEN,"");
    if (mToken.length() > 0) {
      mPreferenceEditor=null;
    }
  }
 else {
    mPreferenceEditor.putString(CLOUDMADE_ID,mAndroidId);
    mPreferenceEditor.commit();
  }
}
 

Example 42

From project mediautilities, under directory /src/ac/robinson/util/.

Source file: IOUtilities.java

  17 
vote

@SuppressLint("SdCardPath") public static boolean isInstalledOnSdCard(Context context){
  if (VERSION.SDK_INT > android.os.Build.VERSION_CODES.ECLAIR_MR1) {
    PackageManager packageManager=context.getPackageManager();
    try {
      PackageInfo packageInfo=packageManager.getPackageInfo(context.getPackageName(),0);
      ApplicationInfo applicationInfo=packageInfo.applicationInfo;
      return (applicationInfo.flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) == ApplicationInfo.FLAG_EXTERNAL_STORAGE;
    }
 catch (    NameNotFoundException e) {
    }
  }
  try {
    String filesDir=context.getFilesDir().getAbsolutePath();
    if (filesDir.startsWith("/data/")) {
      return false;
    }
 else     if (filesDir.contains("/mnt/") || filesDir.contains("/sdcard/")) {
      return true;
    }
  }
 catch (  Throwable e) {
  }
  return false;
}
 

Example 43

From project Monetizing-Android-Demo-Project, under directory /src/com/adwhirl/.

Source file: AdWhirlLayout.java

  17 
vote

protected String getAdWhirlKey(Context context){
  final String packageName=context.getPackageName();
  final String activityName=context.getClass().getName();
  final PackageManager pm=context.getPackageManager();
  Bundle bundle=null;
  try {
    ActivityInfo activityInfo=pm.getActivityInfo(new ComponentName(packageName,activityName),PackageManager.GET_META_DATA);
    bundle=activityInfo.metaData;
    if (bundle != null) {
      return bundle.getString(AdWhirlLayout.ADWHIRL_KEY);
    }
  }
 catch (  NameNotFoundException exception) {
    return null;
  }
  try {
    ApplicationInfo appInfo=pm.getApplicationInfo(packageName,PackageManager.GET_META_DATA);
    bundle=appInfo.metaData;
    if (bundle != null) {
      return bundle.getString(AdWhirlLayout.ADWHIRL_KEY);
    }
  }
 catch (  NameNotFoundException exception) {
    return null;
  }
  return null;
}
 

Example 44

From project platform_packages_providers_downloadprovider, under directory /src/com/android/providers/downloads/.

Source file: DownloadProvider.java

  17 
vote

/** 
 * Initializes the content provider when it is created.
 */
@Override public boolean onCreate(){
  if (mSystemFacade == null) {
    mSystemFacade=new RealSystemFacade(getContext());
  }
  mOpenHelper=new DatabaseHelper(getContext());
  mSystemUid=Process.SYSTEM_UID;
  ApplicationInfo appInfo=null;
  try {
    appInfo=getContext().getPackageManager().getApplicationInfo("com.android.defcontainer",0);
  }
 catch (  NameNotFoundException e) {
    e.printStackTrace();
  }
  if (appInfo != null) {
    mDefContainerUid=appInfo.uid;
  }
  Context context=getContext();
  context.startService(new Intent(context,DownloadService.class));
  mDownloadsDataDir=StorageManager.getInstance(getContext()).getDownloadDataDirectory();
  return true;
}
 

Example 45

From project proxydroid, under directory /src/org/proxydroid/.

Source file: AppManager.java

  17 
vote

public static ProxyedApp[] getProxyedApps(Context context,boolean self){
  SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(context);
  String tordAppString=prefs.getString(PREFS_KEY_PROXYED,"");
  String[] tordApps;
  StringTokenizer st=new StringTokenizer(tordAppString,"|");
  tordApps=new String[st.countTokens()];
  int tordIdx=0;
  while (st.hasMoreTokens()) {
    tordApps[tordIdx++]=st.nextToken();
  }
  Arrays.sort(tordApps);
  PackageManager pMgr=context.getPackageManager();
  List<ApplicationInfo> lAppInfo=pMgr.getInstalledApplications(0);
  Iterator<ApplicationInfo> itAppInfo=lAppInfo.iterator();
  Vector<ProxyedApp> vectorApps=new Vector<ProxyedApp>();
  ApplicationInfo aInfo=null;
  int appIdx=0;
  while (itAppInfo.hasNext()) {
    aInfo=itAppInfo.next();
    if (aInfo.uid < 10000)     continue;
    ProxyedApp app=new ProxyedApp();
    app.setUid(aInfo.uid);
    app.setUsername(pMgr.getNameForUid(app.getUid()));
    if (aInfo.packageName != null && aInfo.packageName.equals("org.proxydroid")) {
      if (self)       app.setProxyed(true);
    }
 else     if (Arrays.binarySearch(tordApps,app.getUsername()) >= 0) {
      app.setProxyed(true);
    }
 else {
      app.setProxyed(false);
    }
    if (app.isProxyed())     vectorApps.add(app);
  }
  ProxyedApp[] apps=new ProxyedApp[vectorApps.size()];
  vectorApps.toArray(apps);
  return apps;
}
 

Example 46

From project ratebeer-for-Android, under directory /JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/app/.

Source file: ActionBarSupportImpl.java

  17 
vote

public void init(){
  mActionBar=(ActionBarView)getActivity().findViewById(R.id.action_bar);
  final MenuItemImpl homeMenuItem=getHomeMenuItem();
  final ActionBarView.Item homeItem=mActionBar.getHomeItem();
  final WatsonItemViewWrapper homeWrapper=new WatsonItemViewWrapper(homeItem);
  homeWrapper.initialize(homeMenuItem,MenuBuilder.TYPE_WATSON);
  homeMenuItem.setItemView(MenuBuilder.TYPE_WATSON,homeWrapper);
  final PackageManager pm=getActivity().getPackageManager();
  final ApplicationInfo appInfo=getActivity().getApplicationInfo();
  ActivityInfo actInfo=null;
  try {
    actInfo=pm.getActivityInfo(getActivity().getComponentName(),PackageManager.GET_ACTIVITIES);
  }
 catch (  NameNotFoundException e) {
  }
  if (mActionBar.getTitle() == null) {
    if ((actInfo != null) && (actInfo.labelRes != 0)) {
      mActionBar.setTitle(actInfo.labelRes);
    }
 else {
      mActionBar.setTitle(actInfo.loadLabel(pm));
    }
  }
  if (homeItem.getIcon() == null) {
    if ((actInfo != null) && (actInfo.icon != 0)) {
      homeItem.setIcon(actInfo.icon);
    }
 else {
      homeItem.setIcon(pm.getApplicationIcon(appInfo));
    }
  }
}
 

Example 47

From project ratebeerforandroid, under directory /JakeWharton-ActionBarSherlock/library/src/com/actionbarsherlock/internal/app/.

Source file: ActionBarSupportImpl.java

  17 
vote

public void init(){
  mActionBar=(ActionBarView)getActivity().findViewById(R.id.action_bar);
  final MenuItemImpl homeMenuItem=getHomeMenuItem();
  final ActionBarView.Item homeItem=mActionBar.getHomeItem();
  final WatsonItemViewWrapper homeWrapper=new WatsonItemViewWrapper(homeItem);
  homeWrapper.initialize(homeMenuItem,MenuBuilder.TYPE_WATSON);
  homeMenuItem.setItemView(MenuBuilder.TYPE_WATSON,homeWrapper);
  final PackageManager pm=getActivity().getPackageManager();
  final ApplicationInfo appInfo=getActivity().getApplicationInfo();
  ActivityInfo actInfo=null;
  try {
    actInfo=pm.getActivityInfo(getActivity().getComponentName(),PackageManager.GET_ACTIVITIES);
  }
 catch (  NameNotFoundException e) {
  }
  if (mActionBar.getTitle() == null) {
    if ((actInfo != null) && (actInfo.labelRes != 0)) {
      mActionBar.setTitle(actInfo.labelRes);
    }
 else {
      mActionBar.setTitle(actInfo.loadLabel(pm));
    }
  }
  if (homeItem.getIcon() == null) {
    if ((actInfo != null) && (actInfo.icon != 0)) {
      homeItem.setIcon(actInfo.icon);
    }
 else {
      homeItem.setIcon(pm.getApplicationIcon(appInfo));
    }
  }
}
 

Example 48

From project tramhunter, under directory /android/TramHunter/src/com/andybotting/tramhunter/service/.

Source file: TramTrackerServiceJSON.java

  17 
vote

/** 
 * Generate a User Agent
 */
private String getUserAgent(){
  final PackageManager pm=mContext.getPackageManager();
  String packageName="Unknown";
  String packageVersion="Unknown";
  String applicationName="Unknown";
  String androidVersion=android.os.Build.VERSION.RELEASE;
  if (androidVersion == null)   androidVersion="N/A";
  try {
    packageName=mContext.getPackageName();
    ApplicationInfo ai=pm.getApplicationInfo(packageName,0);
    applicationName=(String)pm.getApplicationLabel(ai);
    PackageInfo pi=mContext.getPackageManager().getPackageInfo(packageName,0);
    packageVersion=pi.versionName;
  }
 catch (  NameNotFoundException e) {
    return "Unknown";
  }
  return String.format("%s/%s (Android %s)",applicationName,packageVersion,androidVersion);
}
 

Example 49

From project vanilla, under directory /src/org/kreed/vanilla/.

Source file: LibraryActivity.java

  17 
vote

@Override public ApplicationInfo getApplicationInfo(){
  ApplicationInfo info;
  if (mFakeTarget) {
    info=mFakeInfo;
    if (info == null) {
      info=new ApplicationInfo(super.getApplicationInfo());
      info.targetSdkVersion=Build.VERSION_CODES.GINGERBREAD;
      mFakeInfo=info;
    }
  }
 else {
    info=super.getApplicationInfo();
  }
  return info;
}
 

Example 50

From project ActionBarSherlock, under directory /samples/fragments/src/com/actionbarsherlock/sample/fragments/.

Source file: LoaderCustomSupport.java

  15 
vote

/** 
 * This is where the bulk of our work is done.  This function is called in a background thread and should generate a new set of data to be published by the loader.
 */
@Override public List<AppEntry> loadInBackground(){
  List<ApplicationInfo> apps=mPm.getInstalledApplications(PackageManager.GET_UNINSTALLED_PACKAGES | PackageManager.GET_DISABLED_COMPONENTS);
  if (apps == null) {
    apps=new ArrayList<ApplicationInfo>();
  }
  final Context context=getContext();
  List<AppEntry> entries=new ArrayList<AppEntry>(apps.size());
  for (int i=0; i < apps.size(); i++) {
    AppEntry entry=new AppEntry(this,apps.get(i));
    entry.loadLabel(context);
    entries.add(entry);
  }
  Collections.sort(entries,ALPHA_COMPARATOR);
  return entries;
}
 

Example 51

From project android-thaiime, under directory /latinime/src/com/android/inputmethod/compat/.

Source file: InputMethodSubtypeCompatWrapper.java

  15 
vote

public CharSequence getDisplayName(Context context,String packageName,ApplicationInfo appInfo){
  if (mObj != null) {
    return (CharSequence)CompatUtils.invoke(mObj,"",METHOD_getDisplayName,context,packageName,appInfo);
  }
  final Locale locale=new Locale(getLocale());
  final String localeStr=locale.getDisplayName();
  if (getNameResId() == 0) {
    return localeStr;
  }
  final CharSequence subtypeName=context.getText(getNameResId());
  if (!TextUtils.isEmpty(localeStr)) {
    return String.format(subtypeName.toString(),localeStr);
  }
 else {
    return localeStr;
  }
}
 

Example 52

From project androidquery, under directory /src/com/androidquery/service/.

Source file: MarketService.java

  15 
vote

private ApplicationInfo getApplicationInfo(){
  if (ai == null) {
    ai=act.getApplicationInfo();
  }
  return ai;
}
 

Example 53

From project android_packages_apps_QuickSearchBox, under directory /src/com/android/quicksearchbox/util/.

Source file: Util.java

  15 
vote

public static Uri getResourceUri(Context context,ApplicationInfo appInfo,int res){
  try {
    Resources resources=context.getPackageManager().getResourcesForApplication(appInfo);
    return getResourceUri(resources,appInfo.packageName,res);
  }
 catch (  PackageManager.NameNotFoundException e) {
    Log.e(TAG,"Resources not found for " + appInfo.packageName);
    return null;
  }
catch (  Resources.NotFoundException e) {
    Log.e(TAG,"Resource not found: " + res + " in "+ appInfo.packageName);
    return null;
  }
}
 

Example 54

From project android_packages_inputmethods_LatinIME, under directory /java/src/com/android/inputmethod/compat/.

Source file: InputMethodSubtypeCompatWrapper.java

  15 
vote

public CharSequence getDisplayName(Context context,String packageName,ApplicationInfo appInfo){
  if (mObj != null) {
    return (CharSequence)CompatUtils.invoke(mObj,"",METHOD_getDisplayName,context,packageName,appInfo);
  }
  final Locale locale=new Locale(getLocale());
  final String localeStr=locale.getDisplayName();
  if (getNameResId() == 0) {
    return localeStr;
  }
  final CharSequence subtypeName=context.getText(getNameResId());
  if (!TextUtils.isEmpty(localeStr)) {
    return String.format(subtypeName.toString(),localeStr);
  }
 else {
    return localeStr;
  }
}
 

Example 55

From project BF3-Battlelog, under directory /src/com/ninetwozero/battlelog/.

Source file: Battlelog.java

  15 
vote

private void setDebugMode(){
  int debuggable=getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE;
  isInDebugMode=debuggable > 0;
  if (isInDebugMode) {
    setupDebugOptions();
  }
 else {
    setupReleaseOptions();
  }
}
 

Example 56

From project Cafe, under directory /testservice/src/com/baidu/cafe/remote/.

Source file: SystemLib.java

  15 
vote

/** 
 * check whether there is an application running in sdcard
 * @return true if has
 */
public boolean hasAppsAccessingStorage(){
  try {
    String extStoragePath=Environment.getExternalStorageDirectory().toString();
    IMountService mountService=getMountService();
    int stUsers[]=mountService.getStorageUsers(extStoragePath);
    if (stUsers != null && stUsers.length > 0) {
      return true;
    }
    List<ApplicationInfo> list=mActivityManager.getRunningExternalApplications();
    if (list != null && list.size() > 0) {
      return true;
    }
  }
 catch (  RemoteException e) {
    e.printStackTrace();
  }
  return false;
}
 

Example 57

From project cw-omnibus, under directory /Bandwidth/TrafficMonitor/src/com/commonsware/android/tuning/traffic/.

Source file: TrafficSnapshot.java

  15 
vote

TrafficSnapshot(Context ctxt){
  device=new TrafficRecord();
  HashMap<Integer,String> appNames=new HashMap<Integer,String>();
  for (  ApplicationInfo app : ctxt.getPackageManager().getInstalledApplications(0)) {
    appNames.put(app.uid,app.packageName);
  }
  for (  Integer uid : appNames.keySet()) {
    apps.put(uid,new TrafficRecord(uid,appNames.get(uid)));
  }
}
 

Example 58

From project ElectricSleep, under directory /src/com/androsz/electricsleepbeta/app/.

Source file: StrictModeWhenDebuggableApplication.java

  15 
vote

@Override public void onCreate(){
  super.onCreate();
  GoogleAnalyticsTracker.getInstance().setAnonymizeIp(true);
  final int applicationFlags=getApplicationInfo().flags;
  if ((applicationFlags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) {
    Log.toggleDebug(true);
    GoogleAnalyticsTracker.getInstance().setDryRun(true);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
      StrictMode.ThreadPolicy.Builder builder=new StrictMode.ThreadPolicy.Builder().detectAll().penaltyLog();
      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        builder.penaltyFlashScreen();
      }
      StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll().penaltyLog().build());
      StrictMode.setThreadPolicy(builder.build());
    }
  }
}
 

Example 59

From project finch, under directory /libs/JakeWharton-ActionBarSherlock-2eabf25/samples/fragments/src/com/actionbarsherlock/sample/fragments/.

Source file: LoaderCustomSupport.java

  15 
vote

/** 
 * This is where the bulk of our work is done.  This function is called in a background thread and should generate a new set of data to be published by the loader.
 */
@Override public List<AppEntry> loadInBackground(){
  List<ApplicationInfo> apps=mPm.getInstalledApplications(PackageManager.GET_UNINSTALLED_PACKAGES | PackageManager.GET_DISABLED_COMPONENTS);
  if (apps == null) {
    apps=new ArrayList<ApplicationInfo>();
  }
  final Context context=getContext();
  List<AppEntry> entries=new ArrayList<AppEntry>(apps.size());
  for (int i=0; i < apps.size(); i++) {
    AppEntry entry=new AppEntry(this,apps.get(i));
    entry.loadLabel(context);
    entries.add(entry);
  }
  Collections.sort(entries,ALPHA_COMPARATOR);
  return entries;
}
 

Example 60

From project google-voice-tasker-plugin, under directory /src/com/ko/googlevoice/.

Source file: PluginApplication.java

  15 
vote

@Override public void onCreate(){
  super.onCreate();
  if ((getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) {
    if (Constants.IS_LOGGABLE) {
      Log.v(Constants.LOG_TAG,"Application is debuggable.  Enabling additional debug logging");
    }
    if (Build.VERSION.SDK_INT >= 9) {
      try {
        final Class<?> strictModeClass=Class.forName("android.os.StrictMode");
        final Method enableDefaultsMethod=strictModeClass.getMethod("enableDefaults");
        enableDefaultsMethod.invoke(strictModeClass);
      }
 catch (      final ClassNotFoundException e) {
        throw new RuntimeException(e);
      }
catch (      final SecurityException e) {
        throw new RuntimeException(e);
      }
catch (      final NoSuchMethodException e) {
        throw new RuntimeException(e);
      }
catch (      final IllegalArgumentException e) {
        throw new RuntimeException(e);
      }
catch (      final IllegalAccessException e) {
        throw new RuntimeException(e);
      }
catch (      final InvocationTargetException e) {
        throw new RuntimeException(e);
      }
    }
  }
}
 

Example 61

From project huiswerk, under directory /print/zxing-1.6/android/src/com/google/zxing/client/android/share/.

Source file: LoadPackagesAsyncTask.java

  15 
vote

@Override protected List<String[]> doInBackground(List<String[]>... objects){
  List<String[]> labelsPackages=objects[0];
  PackageManager packageManager=appPickerActivity.getPackageManager();
  List<ApplicationInfo> appInfos=packageManager.getInstalledApplications(0);
  for (  ApplicationInfo appInfo : appInfos) {
    CharSequence label=appInfo.loadLabel(packageManager);
    if (label != null) {
      String packageName=appInfo.packageName;
      if (!isHidden(packageName)) {
        labelsPackages.add(new String[]{label.toString(),packageName});
      }
    }
  }
  Collections.sort(labelsPackages,new ByFirstStringComparator());
  return labelsPackages;
}
 

Example 62

From project ICS_LatinIME_QHD, under directory /java/src/com/android/inputmethod/compat/.

Source file: InputMethodSubtypeCompatWrapper.java

  15 
vote

public CharSequence getDisplayName(Context context,String packageName,ApplicationInfo appInfo){
  if (mObj != null) {
    return (CharSequence)CompatUtils.invoke(mObj,"",METHOD_getDisplayName,context,packageName,appInfo);
  }
  final Locale locale=new Locale(getLocale());
  final String localeStr=locale.getDisplayName();
  if (getNameResId() == 0) {
    return localeStr;
  }
  final CharSequence subtypeName=context.getText(getNameResId());
  if (!TextUtils.isEmpty(localeStr)) {
    return String.format(subtypeName.toString(),localeStr);
  }
 else {
    return localeStr;
  }
}
 

Example 63

From project Locale-MWM, under directory /src/org/metawatch/manager/locale/.

Source file: PluginApplication.java

  15 
vote

@Override public void onCreate(){
  super.onCreate();
  if ((getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) {
    if (Constants.IS_LOGGABLE) {
      Log.v(Constants.LOG_TAG,"Application is debuggable.  Enabling additional debug logging");
    }
    if (Build.VERSION.SDK_INT >= 9) {
      enableApiLevel9Debugging();
    }
    if (Build.VERSION.SDK_INT >= 11) {
      enableApiLevel11Debugging();
    }
  }
}
 

Example 64

From project maven-android-plugin-samples, under directory /morseflash/morseflash-app/src/main/java/com/simpligility/android/morseflash/.

Source file: MorseFlashApplication.java

  15 
vote

@Override public void onCreate(){
  if (strictModeAvailable) {
    int applicationFlags=getApplicationInfo().flags;
    if ((applicationFlags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) {
      StrictModeWrapper.enableDefaults();
    }
  }
  super.onCreate();
}
 

Example 65

From project Mobile-Tour-Guide, under directory /zxing-2.0/android/src/com/google/zxing/client/android/share/.

Source file: LoadPackagesAsyncTask.java

  15 
vote

@Override protected List<String[]> doInBackground(List<String[]>... objects){
  List<String[]> labelsPackages=objects[0];
  PackageManager packageManager=activity.getPackageManager();
  List<ApplicationInfo> appInfos=packageManager.getInstalledApplications(0);
  for (  ApplicationInfo appInfo : appInfos) {
    CharSequence label=appInfo.loadLabel(packageManager);
    if (label != null) {
      String packageName=appInfo.packageName;
      if (!isHidden(packageName)) {
        labelsPackages.add(new String[]{label.toString(),packageName});
      }
    }
  }
  Collections.sort(labelsPackages,new ByFirstStringComparator());
  return labelsPackages;
}
 

Example 66

From project NotePad, under directory /NotePad/src/org/openintents/notepad/theme/.

Source file: ThemeUtils.java

  15 
vote

/** 
 * Return list of all applications that contain the theme meta-tag.
 * @param pm
 * @param firstPackage : package name of package that should be moved to front.
 * @return
 */
private static List<ApplicationInfo> getThemePackages(PackageManager pm,String firstPackage){
  List<ApplicationInfo> appinfolist=new LinkedList<ApplicationInfo>();
  List<ApplicationInfo> allapps=pm.getInstalledApplications(PackageManager.GET_META_DATA);
  for (  ApplicationInfo ai : allapps) {
    if (ai.metaData != null) {
      if (ai.metaData.containsKey(METADATA_THEMES)) {
        if (ai.packageName.equals(firstPackage)) {
          appinfolist.add(0,ai);
        }
 else {
          appinfolist.add(ai);
        }
      }
    }
  }
  return appinfolist;
}
 

Example 67

From project npr-android-app, under directory /src/org/npr/android/util/.

Source file: Tracker.java

  15 
vote

private boolean isDebuggableSet(){
  int flags=0;
  try {
    PackageInfo pi=application.getPackageManager().getPackageInfo(application.getPackageName(),0);
    flags=pi.applicationInfo.flags;
  }
 catch (  PackageManager.NameNotFoundException e) {
  }
  if ((flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) {
    return true;
  }
  return false;
}
 

Example 68

From project ohmagePhone, under directory /src/org/ohmage/.

Source file: OhmageApplication.java

  15 
vote

/** 
 * Determines if we are running on release or debug
 * @return true if we are running Debug
 * @throws Exception
 */
public static boolean isDebugBuild(){
  PackageManager pm=getContext().getPackageManager();
  PackageInfo pi;
  try {
    pi=pm.getPackageInfo(getContext().getPackageName(),0);
    return ((pi.applicationInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0);
  }
 catch (  NameNotFoundException e) {
    e.printStackTrace();
    return false;
  }
}
 

Example 69

From project PartyWare, under directory /android/src/com/google/zxing/client/android/share/.

Source file: LoadPackagesAsyncTask.java

  15 
vote

@Override protected List<String[]> doInBackground(List<String[]>... objects){
  List<String[]> labelsPackages=objects[0];
  PackageManager packageManager=appPickerActivity.getPackageManager();
  List<ApplicationInfo> appInfos=packageManager.getInstalledApplications(0);
  for (  ApplicationInfo appInfo : appInfos) {
    CharSequence label=appInfo.loadLabel(packageManager);
    if (label != null) {
      String packageName=appInfo.packageName;
      if (!isHidden(packageName)) {
        labelsPackages.add(new String[]{label.toString(),packageName});
      }
    }
  }
  Collections.sort(labelsPackages,new Comparator<String[]>(){
    public int compare(    String[] o1,    String[] o2){
      return o1[0].compareTo(o2[0]);
    }
  }
);
  return labelsPackages;
}
 

Example 70

From project platform_packages_apps_contacts, under directory /src/com/android/contacts/quickcontact/.

Source file: ResolveCache.java

  15 
vote

/** 
 * Best  {@link ResolveInfo} when multiple found. Ties are broken byselecting first from the  {@link QuickContactActivity#sPreferResolve} list ofpreferred packages, second by apps that live on the system partition, otherwise the app from the top of the list. This is <strong>only</strong> used for selecting a default icon for displaying in the track, and does not shortcut the system {@link Intent} disambiguation dialog.
 */
protected ResolveInfo getBestResolve(Intent intent,List<ResolveInfo> matches){
  final ResolveInfo foundResolve=mPackageManager.resolveActivity(intent,PackageManager.MATCH_DEFAULT_ONLY);
  final boolean foundDisambig=(foundResolve.match & IntentFilter.MATCH_CATEGORY_MASK) == 0;
  if (!foundDisambig) {
    return foundResolve;
  }
  ResolveInfo firstSystem=null;
  for (  ResolveInfo info : matches) {
    final boolean isSystem=(info.activityInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0;
    final boolean isPrefer=sPreferResolve.contains(info.activityInfo.applicationInfo.packageName);
    if (isPrefer)     return info;
    if (isSystem && firstSystem == null)     firstSystem=info;
  }
  return firstSystem != null ? firstSystem : matches.get(0);
}
 

Example 71

From project Playlist, under directory /src/com/google/zxing/client/android/share/.

Source file: LoadPackagesAsyncTask.java

  15 
vote

@Override protected List<String[]> doInBackground(List<String[]>... objects){
  List<String[]> labelsPackages=objects[0];
  PackageManager packageManager=appPickerActivity.getPackageManager();
  List<ApplicationInfo> appInfos=packageManager.getInstalledApplications(0);
  for (  ApplicationInfo appInfo : appInfos) {
    CharSequence label=appInfo.loadLabel(packageManager);
    if (label != null) {
      String packageName=appInfo.packageName;
      if (!isHidden(packageName)) {
        labelsPackages.add(new String[]{label.toString(),packageName});
      }
    }
  }
  Collections.sort(labelsPackages,new Comparator<String[]>(){
    public int compare(    String[] o1,    String[] o2){
      return o1[0].compareTo(o2[0]);
    }
  }
);
  return labelsPackages;
}
 

Example 72

From project QuasselDroid, under directory /src/com/iskrembilen/quasseldroid/gui/.

Source file: SplashActivity.java

  15 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  setTheme(ThemeUtil.theme);
  super.onCreate(savedInstanceState);
  boolean isDebugbuild=(0 != (getApplicationInfo().flags&=ApplicationInfo.FLAG_DEBUGGABLE));
  if (!isDebugbuild && getResources().getBoolean(R.bool.use_crittercism)) {
    Log.i(TAG,"Enabeling Crittercism");
    Crittercism.init(getApplicationContext(),getResources().getString(R.string.crittercism_api_key));
  }
  setContentView(R.layout.splash);
  getSupportActionBar().hide();
}
 

Example 73

From project roboguice, under directory /roboguice/src/main/java/roboguice/util/.

Source file: Ln.java

  15 
vote

@Inject public BaseConfig(Context context){
  try {
    packageName=context.getPackageName();
    final int flags=context.getPackageManager().getApplicationInfo(packageName,0).flags;
    minimumLogLevel=(flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0 ? Log.VERBOSE : Log.INFO;
    scope=packageName.toUpperCase();
    Ln.d("Configuring Logging, minimum log level is %s",logLevelToString(minimumLogLevel));
  }
 catch (  PackageManager.NameNotFoundException e) {
    Log.e(packageName,"Error configuring logger",e);
  }
}
 

Example 74

From project SanDisk-HQME-SDK, under directory /projects/HqmeCache/project/src/com/hqme/cm/cache/.

Source file: UntenCacheService.java

  15 
vote

public void onCreate(){
  debugLog(sTag,"onCreate: called");
  Thread.setDefaultUncaughtExceptionHandler(new UntenDefaultUncaughtExceptionHandler());
  sIsDebugMode=(getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;
  sPackageManager=getPackageManager();
  sPluginContext=getApplicationContext();
  if (sPluginManagerProxy == null || !sPluginManagerProxy.asBinder().isBinderAlive()) {
    debugLog(sTag,"onCreate: bindService() calling...");
    sPluginContext.bindService(new Intent(IStorageManager.class.getName()),mPluginManagerConnection,0);
  }
  if (streamingServerWorker == null) {
    streamingServerWorker=new Thread(streamingServerHandler);
    streamingServerWorker.setDaemon(true);
    streamingServerWorker.start();
  }
  doLoad();
}
 

Example 75

From project shoppinglist, under directory /ShoppingList/src/org/openintents/shopping/theme/.

Source file: ThemeUtils.java

  15 
vote

/** 
 * Return list of all applications that contain the theme meta-tag.
 * @param pm
 * @param firstPackage : package name of package that should be moved to front.
 * @return
 */
private static List<ApplicationInfo> getThemePackages(PackageManager pm,String firstPackage){
  List<ApplicationInfo> appinfolist=new LinkedList<ApplicationInfo>();
  List<ApplicationInfo> allapps=pm.getInstalledApplications(PackageManager.GET_META_DATA);
  for (  ApplicationInfo ai : allapps) {
    if (ai.metaData != null) {
      if (ai.metaData.containsKey(METADATA_THEMES)) {
        if (ai.packageName.equals(firstPackage)) {
          appinfolist.add(0,ai);
        }
 else {
          appinfolist.add(ai);
        }
      }
    }
  }
  return appinfolist;
}
 

Example 76

From project SimpleMoney-Android, under directory /Zxing/bin/src/com/google/zxing/client/android/share/.

Source file: LoadPackagesAsyncTask.java

  15 
vote

@Override protected List<String[]> doInBackground(List<String[]>... objects){
  List<String[]> labelsPackages=objects[0];
  PackageManager packageManager=activity.getPackageManager();
  List<ApplicationInfo> appInfos=packageManager.getInstalledApplications(0);
  for (  ApplicationInfo appInfo : appInfos) {
    CharSequence label=appInfo.loadLabel(packageManager);
    if (label != null) {
      String packageName=appInfo.packageName;
      if (!isHidden(packageName)) {
        labelsPackages.add(new String[]{label.toString(),packageName});
      }
    }
  }
  Collections.sort(labelsPackages,new ByFirstStringComparator());
  return labelsPackages;
}
 

Example 77

From project sms-backup-plus, under directory /src/com/zegoggles/smssync/.

Source file: PrefStore.java

  15 
vote

static boolean isInstalledOnSDCard(Context context){
  android.content.pm.PackageInfo pInfo;
  try {
    pInfo=context.getPackageManager().getPackageInfo(SmsSync.class.getPackage().getName(),PackageManager.GET_META_DATA);
    return (pInfo.applicationInfo.flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) != 0;
  }
 catch (  PackageManager.NameNotFoundException e) {
    Log.e(TAG,"error",e);
    return false;
  }
}
 

Example 78

From project zaduiReader, under directory /src/cn/zadui/reader/service/.

Source file: UsageCollector.java

  15 
vote

/** 
 * Ping string includes: uid this collection started at device information: os type and version; app version etc. usage string hour prefer usage string
 * @param ctx
 * @return
 */
public static String generateHttpPostData(Context ctx){
  StringBuilder sb=new StringBuilder();
  sb.append("pv=2");
  sb.append("&uid=" + getDeviceId(ctx));
  SimpleDateFormat df=new SimpleDateFormat("yyyyMMdd'T'HH:mm");
  Date d=new Date(Settings.getLongPreferenceValue(ctx,Settings.PRE_COLLECTION_STARTED_AT,0));
  Date installed=new Date(Settings.getLongPreferenceValue(ctx,Settings.PRE_INSTALLED_AT,0));
  sb.append("&installed_at=" + df.format(installed));
  sb.append("&from=" + df.format(d));
  sb.append("&dev[os][name]=" + "android");
  sb.append("&dev[os][codename]=" + Build.VERSION.CODENAME);
  sb.append("&dev[os][incremental]=" + Build.VERSION.INCREMENTAL);
  sb.append("&dev[os][release]=" + Build.VERSION.RELEASE);
  sb.append("&dev[os][sdk]=" + String.valueOf(Build.VERSION.SDK_INT));
  sb.append("&dev[model]=" + Build.MODEL);
  sb.append("&dev[device]=" + Build.DEVICE);
  sb.append("&app[package_name]=" + ctx.getPackageName());
  boolean testBuild=(ctx.getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;
  sb.append("&app[debug]=" + String.valueOf(testBuild));
  PackageInfo pi=null;
  try {
    pi=ctx.getPackageManager().getPackageInfo(ctx.getPackageName(),0);
  }
 catch (  NameNotFoundException e) {
    e.printStackTrace();
  }
  sb.append("&app[version_code]=" + String.valueOf(pi.versionCode));
  sb.append("&usage=" + Settings.getStringPreferenceValue(ctx,Settings.PRE_USAGE,INI_USAGE_STR));
  sb.append("&hour=" + Settings.getStringPreferenceValue(ctx,Settings.PRE_HOUR_PREFER_USAGE,HOUR_PREFER_STR));
  return sb.toString();
}
 

Example 79

From project zxing, under directory /android/src/com/google/zxing/client/android/share/.

Source file: LoadPackagesAsyncTask.java

  15 
vote

@Override protected List<String[]> doInBackground(List<String[]>... objects){
  List<String[]> labelsPackages=objects[0];
  PackageManager packageManager=activity.getPackageManager();
  List<ApplicationInfo> appInfos=packageManager.getInstalledApplications(0);
  for (  ApplicationInfo appInfo : appInfos) {
    CharSequence label=appInfo.loadLabel(packageManager);
    if (label != null) {
      String packageName=appInfo.packageName;
      if (!isHidden(packageName)) {
        labelsPackages.add(new String[]{label.toString(),packageName});
      }
    }
  }
  Collections.sort(labelsPackages,new ByFirstStringComparator());
  return labelsPackages;
}
 

Example 80

From project zxing-android, under directory /src/com/laundrylocker/barcodescanner/share/.

Source file: LoadPackagesAsyncTask.java

  15 
vote

@Override protected List<String[]> doInBackground(List<String[]>... objects){
  List<String[]> labelsPackages=objects[0];
  PackageManager packageManager=activity.getPackageManager();
  List<ApplicationInfo> appInfos=packageManager.getInstalledApplications(0);
  for (  ApplicationInfo appInfo : appInfos) {
    CharSequence label=appInfo.loadLabel(packageManager);
    if (label != null) {
      String packageName=appInfo.packageName;
      if (!isHidden(packageName)) {
        labelsPackages.add(new String[]{label.toString(),packageName});
      }
    }
  }
  Collections.sort(labelsPackages,new ByFirstStringComparator());
  return labelsPackages;
}
 

Example 81

From project zxing-iphone, under directory /android/src/com/google/zxing/client/android/share/.

Source file: LoadPackagesAsyncTask.java

  15 
vote

@Override protected List<String[]> doInBackground(List<String[]>... objects){
  List<String[]> labelsPackages=objects[0];
  PackageManager packageManager=appPickerActivity.getPackageManager();
  List<ApplicationInfo> appInfos=packageManager.getInstalledApplications(0);
  for (  ApplicationInfo appInfo : appInfos) {
    CharSequence label=appInfo.loadLabel(packageManager);
    if (label != null) {
      String packageName=appInfo.packageName;
      if (!isHidden(packageName)) {
        labelsPackages.add(new String[]{label.toString(),packageName});
      }
    }
  }
  Collections.sort(labelsPackages,new Comparator<String[]>(){
    public int compare(    String[] o1,    String[] o2){
      return o1[0].compareTo(o2[0]);
    }
  }
);
  return labelsPackages;
}