public AppSecurityPermissions(android.content.Context context, java.util.List <android.content.pm.PermissionInfo > permList) { mContext = context; mPm = mContext.getPackageManager(); mPermsList = permList; }
public AppSecurityPermissions(android.content.Context context, string packageName ) { mContext = context; mPm = mContext.getPackageManager(); mPermsList = new java.util.ArrayList <android.content.pm.PermissionInfo>(); java.util.Set <android.content.pm.PermissionInfo> permSet = new java.util.HashSet < android.content.pm.PermissionInfo>(); android.content.pm.PackageInfo pkgInfo; try { pkgInfo = mPm.getPackageInfo(packageName, android.content.pm.PackageManager.GET_PERMISSIONS ); } catch (android.content.pm.PackageManager.NameNotFoundException) { android.util.Log.w(TAG, "Could'nt retrieve permissions for package:" + packageName ); return; } // Extract all user permissions if ((pkgInfo.applicationInfo != null) && (pkgInfo.applicationInfo.uid != -1)) { getAllUsedPermissions(pkgInfo.applicationInfo.uid, permSet); } foreach (android.content.pm.PermissionInfo tmpInfo in Sharpen.IterableProxy.Create (permSet)) { mPermsList.add(tmpInfo); } }
/// <summary> /// @brief Read application name (label) from package manager /// </summary> /// <param name="packageName"> application package /// </param> /// <returns> Application name retrieved from PackageManager </returns> public virtual string getApplicationName(string packageName) { string appName = "<None>"; Context context = Context; if (null == context) { Log.w(TAG, "Cannot retrieve application name: context is null"); return(appName); } PackageManager pm = context.PackageManager; ApplicationInfo appInfo = null; try { appInfo = pm.getApplicationInfo(packageName, NO_FLAGS); } catch (PackageManager.NameNotFoundException) { Log.w(TAG, "Cannot retrieve application info for package: " + packageName); } if (null != appInfo) { appName = pm.getApplicationLabel(appInfo).ToString(); } return(appName); }
/// <summary> /// @brief Retrieve drawable from resources of application given by package name /// /// Drawable is retrieved using PackageManager. /// </summary> /// <param name="packageName"> package name of the application to retrieve drawables from </param> /// <param name="drawableId"> id of the drawable to retrieve /// </param> /// <returns> Drawable or null in case of problems </returns> public virtual Drawable getApplicationDrawable(string packageName, int drawableId) { Context context = Context; if (null == context) { Log.w(TAG, "Cannot retrieve drawable from application (" + packageName + ") " + "as the context is null"); return(null); } if (drawableId < 0) { Log.w(TAG, "Cannot retrieve drawable of negative Id"); return(null); } PackageManager pm = context.PackageManager; Drawable drawable = null; try { Resources res = pm.getResourcesForApplication(packageName); drawable = res.getDrawable(drawableId); } catch (PackageManager.NameNotFoundException) { Log.w(TAG, "Cannot retrieve drawable from application (" + packageName + "): " + "name not found"); } return(drawable); }
public virtual int addIntentOptions(int groupId, int itemId, int order, android.content.ComponentName caller, android.content.Intent[] specifics, android.content.Intent intent, int flags, android.view.MenuItem[] outSpecificItems) { android.content.pm.PackageManager pm = mContext.getPackageManager(); java.util.List <android.content.pm.ResolveInfo> lri = pm.queryIntentActivityOptions (caller, specifics, intent, 0); int N = lri != null?lri.size() : 0; if ((flags & android.view.MenuClass.FLAG_APPEND_TO_GROUP) == 0) { removeGroup(groupId); } { for (int i = 0; i < N; i++) { android.content.pm.ResolveInfo ri = lri.get(i); android.content.Intent rintent = new android.content.Intent(ri.specificIndex < 0 ? intent : specifics[ri.specificIndex]); rintent.setComponent(new android.content.ComponentName(ri.activityInfo.applicationInfo .packageName, ri.activityInfo.name)); android.view.MenuItem item = add(groupId, itemId, order, ri.loadLabel(pm)).setIcon (ri.loadIcon(pm)).setIntent(rintent); if (outSpecificItems != null && ri.specificIndex >= 0) { outSpecificItems[ri.specificIndex] = item; } } } return(N); }
public override java.lang.CharSequence loadLabel(android.content.pm.PackageManager pm) { if (nonLocalizedLabel != null) { return(nonLocalizedLabel); } android.content.pm.ApplicationInfo ai = applicationInfo; java.lang.CharSequence label; if (labelRes != 0) { label = pm.getText(packageName, labelRes, ai); if (label != null) { return(label); } } if (ai.nonLocalizedLabel != null) { return(ai.nonLocalizedLabel); } if (ai.labelRes != 0) { label = pm.getText(packageName, ai.labelRes, ai); if (label != null) { return(label); } } return(java.lang.CharSequenceProxy.Wrap(name)); }
/// <summary>Gets the activity or application icon for an activity.</summary> /// <remarks>Gets the activity or application icon for an activity.</remarks> /// <param name="component">Name of an activity.</param> /// <returns> /// A drawable, or /// <code>null</code> /// if neither the acitivy or the application /// have an icon set. /// </returns> private android.graphics.drawable.Drawable getActivityIcon(android.content.ComponentName component) { android.content.pm.PackageManager pm = mContext.getPackageManager(); android.content.pm.ActivityInfo activityInfo; try { activityInfo = pm.getActivityInfo(component, android.content.pm.PackageManager.GET_META_DATA ); } catch (android.content.pm.PackageManager.NameNotFoundException ex) { android.util.Log.w(LOG_TAG, ex.ToString()); return(null); } int iconId = activityInfo.getIconResource(); if (iconId == 0) { return(null); } string pkg = component.getPackageName(); android.graphics.drawable.Drawable drawable = pm.getDrawable(pkg, iconId, activityInfo .applicationInfo); if (drawable == null) { android.util.Log.w(LOG_TAG, "Invalid icon resource " + iconId + " for " + component .flattenToShortString()); return(null); } return(drawable); }
public override android.view.View getView(int position, android.view.View convertView , android.view.ViewGroup parent) { int itemViewType = this.getItemViewType(position); switch (itemViewType) { case ITEM_VIEW_TYPE_FOOTER: { if (convertView == null || convertView.getId() != ITEM_VIEW_TYPE_FOOTER) { convertView = android.view.LayoutInflater.from(this._enclosing.getContext()).inflate ([email protected]_chooser_view_list_item, parent, false); convertView.setId(ITEM_VIEW_TYPE_FOOTER); android.widget.TextView titleView = (android.widget.TextView)convertView.findViewById ([email protected]); titleView.setText(java.lang.CharSequenceProxy.Wrap(this._enclosing.mContext.getString ([email protected][email protected]_chooser_view_see_all))); } return(convertView); } case ITEM_VIEW_TYPE_ACTIVITY: { if (convertView == null || convertView.getId() != [email protected]_item) { convertView = android.view.LayoutInflater.from(this._enclosing.getContext()).inflate ([email protected]_chooser_view_list_item, parent, false); } android.content.pm.PackageManager packageManager = this._enclosing.mContext.getPackageManager (); // Set the icon android.widget.ImageView iconView = (android.widget.ImageView)convertView.findViewById ([email protected]); android.content.pm.ResolveInfo activity = (android.content.pm.ResolveInfo) this.getItem (position); iconView.setImageDrawable(activity.loadIcon(packageManager)); // Set the title. android.widget.TextView titleView_1 = (android.widget.TextView)convertView.findViewById ([email protected]); titleView_1.setText(activity.loadLabel(packageManager)); // Highlight the default. if (this.mShowDefaultActivity && position == 0 && this.mHighlightDefaultActivity) { convertView.setActivated(true); } else { convertView.setActivated(false); } return(convertView); } default: { throw new System.ArgumentException(); } } }
private bool isPackageUnavailable(android.content.pm.PackageManager pm) { try { return(pm.getPackageInfo(packageName, 0) == null); } catch (android.content.pm.PackageManager.NameNotFoundException) { return(true); } }
public virtual global::android.content.res.XmlResourceParser loadXmlMetaData(android.content.pm.PackageManager arg0, java.lang.String arg1) { global::MonoJavaBridge.JNIEnv @__env = global::MonoJavaBridge.JNIEnv.ThreadEnv; if (!IsClrObject) { return(global::MonoJavaBridge.JavaBridge.WrapIJavaObject <global::android.content.res.XmlResourceParser>(@__env.CallObjectMethod(this.JvmHandle, global::android.content.pm.PackageItemInfo._loadXmlMetaData1968, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg1))) as android.content.res.XmlResourceParser); } else { return(global::MonoJavaBridge.JavaBridge.WrapIJavaObject <global::android.content.res.XmlResourceParser>(@__env.CallNonVirtualObjectMethod(this.JvmHandle, global::android.content.pm.PackageItemInfo.staticClass, global::android.content.pm.PackageItemInfo._loadXmlMetaData1968, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg1))) as android.content.res.XmlResourceParser); } }
public override global::java.lang.CharSequence loadLabel(android.content.pm.PackageManager arg0) { global::MonoJavaBridge.JNIEnv @__env = global::MonoJavaBridge.JNIEnv.ThreadEnv; if (!IsClrObject) { return(global::MonoJavaBridge.JavaBridge.WrapIJavaObject <global::java.lang.CharSequence>(@__env.CallObjectMethod(this.JvmHandle, global::android.content.pm.ComponentInfo._loadLabel1881, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0))) as java.lang.CharSequence); } else { return(global::MonoJavaBridge.JavaBridge.WrapIJavaObject <global::java.lang.CharSequence>(@__env.CallNonVirtualObjectMethod(this.JvmHandle, global::android.content.pm.ComponentInfo.staticClass, global::android.content.pm.ComponentInfo._loadLabel1881, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0))) as java.lang.CharSequence); } }
public global::android.graphics.drawable.Drawable loadIcon(android.content.pm.PackageManager arg0) { global::MonoJavaBridge.JNIEnv @__env = global::MonoJavaBridge.JNIEnv.ThreadEnv; if (!IsClrObject) { return(global::MonoJavaBridge.JavaBridge.WrapJavaObject(@__env.CallObjectMethod(this.JvmHandle, global::android.view.inputmethod.InputMethodInfo._loadIcon10219, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0))) as android.graphics.drawable.Drawable); } else { return(global::MonoJavaBridge.JavaBridge.WrapJavaObject(@__env.CallNonVirtualObjectMethod(this.JvmHandle, global::android.view.inputmethod.InputMethodInfo.staticClass, global::android.view.inputmethod.InputMethodInfo._loadIcon10219, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0))) as android.graphics.drawable.Drawable); } }
public virtual global::java.lang.CharSequence loadDescription(android.content.pm.PackageManager arg0) { global::MonoJavaBridge.JNIEnv @__env = global::MonoJavaBridge.JNIEnv.ThreadEnv; if (!IsClrObject) { return(global::MonoJavaBridge.JavaBridge.WrapIJavaObject <global::java.lang.CharSequence>(@__env.CallObjectMethod(this.JvmHandle, global::android.content.pm.ApplicationInfo._loadDescription1860, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0))) as java.lang.CharSequence); } else { return(global::MonoJavaBridge.JavaBridge.WrapIJavaObject <global::java.lang.CharSequence>(@__env.CallNonVirtualObjectMethod(this.JvmHandle, global::android.content.pm.ApplicationInfo.staticClass, global::android.content.pm.ApplicationInfo._loadDescription1860, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0))) as java.lang.CharSequence); } }
/// <summary>Load an XML resource attached to the meta-data of this item.</summary> /// <remarks> /// Load an XML resource attached to the meta-data of this item. This will /// retrieved the name meta-data entry, and if defined call back on the /// given PackageManager to load its XML file from the application. /// </remarks> /// <param name="pm"> /// A PackageManager from which the XML can be loaded; usually /// the PackageManager from which you originally retrieved this item. /// </param> /// <param name="name">Name of the meta-date you would like to load.</param> /// <returns> /// Returns an XmlPullParser you can use to parse the XML file /// assigned as the given meta-data. If the meta-data name is not defined /// or the XML resource could not be found, null is returned. /// </returns> public virtual android.content.res.XmlResourceParser loadXmlMetaData(android.content.pm.PackageManager pm, string name) { if (metaData != null) { int resid = metaData.getInt(name); if (resid != 0) { return(pm.getXml(packageName, resid, getApplicationInfo())); } } return(null); }
/// <summary>Retrieve the textual description of the application.</summary> /// <remarks> /// Retrieve the textual description of the application. This /// will call back on the given PackageManager to load the description from /// the application. /// </remarks> /// <param name="pm"> /// A PackageManager from which the label can be loaded; usually /// the PackageManager from which you originally retrieved this item. /// </param> /// <returns> /// Returns a CharSequence containing the application's description. /// If there is no description, null is returned. /// </returns> public virtual java.lang.CharSequence loadDescription(android.content.pm.PackageManager pm) { if (descriptionRes != 0) { java.lang.CharSequence label = pm.getText(packageName, descriptionRes, this); if (label != null) { return(label); } } return(null); }
/// <summary>Retrieve the current graphical icon associated with this item.</summary> /// <remarks> /// Retrieve the current graphical icon associated with this item. This /// will call back on the given PackageManager to load the icon from /// the application. /// </remarks> /// <param name="pm"> /// A PackageManager from which the icon can be loaded; usually /// the PackageManager from which you originally retrieved this item. /// </param> /// <returns> /// Returns a Drawable containing the item's icon. If the /// item does not have an icon, the item's default icon is returned /// such as the default activity icon. /// </returns> public virtual android.graphics.drawable.Drawable loadIcon(android.content.pm.PackageManager pm) { if (icon != 0) { android.graphics.drawable.Drawable dr = pm.getDrawable(packageName, icon, getApplicationInfo ()); if (dr != null) { return(dr); } } return(loadDefaultIcon(pm)); }
/// <summary>Retrieve the current graphical logo associated with this item.</summary> /// <remarks> /// Retrieve the current graphical logo associated with this item. This /// will call back on the given PackageManager to load the logo from /// the application. /// </remarks> /// <param name="pm"> /// A PackageManager from which the logo can be loaded; usually /// the PackageManager from which you originally retrieved this item. /// </param> /// <returns> /// Returns a Drawable containing the item's logo. If the item /// does not have a logo, this method will return null. /// </returns> public virtual android.graphics.drawable.Drawable loadLogo(android.content.pm.PackageManager pm) { if (logo != 0) { android.graphics.drawable.Drawable d = pm.getDrawable(packageName, logo, getApplicationInfo ()); if (d != null) { return(d); } } return(loadDefaultLogo(pm)); }
/// <summary>Updates the buttons state.</summary> /// <remarks>Updates the buttons state.</remarks> private void updateAppearance() { // Expand overflow button. if (mAdapter.getCount() > 0) { mExpandActivityOverflowButton.setEnabled(true); } else { mExpandActivityOverflowButton.setEnabled(false); } // Default activity button. int activityCount = mAdapter.getActivityCount(); int historySize = mAdapter.getHistorySize(); if (activityCount > 0 && historySize > 0) { mDefaultActivityButton.setVisibility(VISIBLE); android.content.pm.ResolveInfo activity = mAdapter.getDefaultActivity(); android.content.pm.PackageManager packageManager = mContext.getPackageManager(); mDefaultActivityButtonImage.setImageDrawable(activity.loadIcon(packageManager)); if (mDefaultActionButtonContentDescription != 0) { java.lang.CharSequence label = activity.loadLabel(packageManager); string contentDescription = mContext.getString(mDefaultActionButtonContentDescription , label); mDefaultActivityButton.setContentDescription(java.lang.CharSequenceProxy.Wrap(contentDescription )); } } else { mDefaultActivityButton.setVisibility(android.view.View.GONE); } // Activity chooser content. if (mDefaultActivityButton.getVisibility() == VISIBLE) { mActivityChooserContent.setBackgroundDrawable(mActivityChooserContentBackground); } else { mActivityChooserContent.setBackgroundDrawable(null); } }
public AppSecurityPermissions(android.content.Context context, android.content.pm.PackageParser .Package pkg) { mContext = context; mPm = mContext.getPackageManager(); mPermsList = new java.util.ArrayList <android.content.pm.PermissionInfo>(); java.util.Set <android.content.pm.PermissionInfo> permSet = new java.util.HashSet < android.content.pm.PermissionInfo>(); if (pkg == null) { return; } // Get requested permissions if (pkg.requestedPermissions != null) { java.util.ArrayList <string> strList = pkg.requestedPermissions; int size = strList.size(); if (size > 0) { extractPerms(strList.toArray(new string[size]), permSet); } } // Get permissions related to shared user if any if (pkg.mSharedUserId != null) { int sharedUid; try { sharedUid = mPm.getUidForSharedUser(pkg.mSharedUserId); getAllUsedPermissions(sharedUid, permSet); } catch (android.content.pm.PackageManager.NameNotFoundException) { android.util.Log.w(TAG, "Could'nt retrieve shared user id for:" + pkg.packageName ); } } // Retrieve list of permissions foreach (android.content.pm.PermissionInfo tmpInfo in Sharpen.IterableProxy.Create (permSet)) { mPermsList.add(tmpInfo); } }
/// <summary>Retrieve the current textual label associated with this item.</summary> /// <remarks> /// Retrieve the current textual label associated with this item. This /// will call back on the given PackageManager to load the label from /// the application. /// </remarks> /// <param name="pm"> /// A PackageManager from which the label can be loaded; usually /// the PackageManager from which you originally retrieved this item. /// </param> /// <returns> /// Returns a CharSequence containing the item's label. If the /// item does not have a label, its name is returned. /// </returns> public virtual java.lang.CharSequence loadLabel(android.content.pm.PackageManager pm) { if (nonLocalizedLabel != null) { return(nonLocalizedLabel); } if (labelRes != 0) { java.lang.CharSequence label = pm.getText(packageName, labelRes, getApplicationInfo ()); if (label != null) { return(java.lang.CharSequenceProxy.Wrap(label.ToString().Trim())); } } if (name != null) { return(java.lang.CharSequenceProxy.Wrap(name)); } return(java.lang.CharSequenceProxy.Wrap(packageName)); }
public override void onPrepareSubMenu(android.view.SubMenu subMenu) { // Clear since the order of items may change. subMenu.clear(); android.widget.ActivityChooserModel dataModel = android.widget.ActivityChooserModel .get(mContext, mShareHistoryFileName); android.content.pm.PackageManager packageManager = mContext.getPackageManager(); int expandedActivityCount = dataModel.getActivityCount(); int collapsedActivityCount = System.Math.Min(expandedActivityCount, mMaxShownActivityCount ); { // Populate the sub-menu with a sub set of the activities. for (int i = 0; i < collapsedActivityCount; i++) { android.content.pm.ResolveInfo activity = dataModel.getActivity(i); subMenu.add(0, i, i, activity.loadLabel(packageManager)).setIcon(activity.loadIcon (packageManager)).setOnMenuItemClickListener(mOnMenuItemClickListener); } } if (collapsedActivityCount < expandedActivityCount) { // Add a sub-menu for showing all activities as a list item. android.view.SubMenu expandedSubMenu = subMenu.addSubMenu(android.view.MenuClass.NONE , collapsedActivityCount, collapsedActivityCount, java.lang.CharSequenceProxy.Wrap (mContext.getString([email protected][email protected]_chooser_view_see_all))); { for (int i_1 = 0; i_1 < expandedActivityCount; i_1++) { android.content.pm.ResolveInfo activity = dataModel.getActivity(i_1); expandedSubMenu.add(0, i_1, i_1, activity.loadLabel(packageManager)).setIcon(activity .loadIcon(packageManager)).setOnMenuItemClickListener(mOnMenuItemClickListener); } } } }
public android.graphics.drawable.Drawable loadIcon(android.content.pm.PackageManager pm) { throw new System.NotImplementedException(); }
public java.lang.CharSequence loadLabel(android.content.pm.PackageManager pm) { throw new System.NotImplementedException(); }
protected internal override android.graphics.drawable.Drawable loadDefaultIcon(android.content.pm.PackageManager pm) { if ((flags & FLAG_EXTERNAL_STORAGE) != 0 && isPackageUnavailable(pm)) { return(android.content.res.Resources.getSystem().getDrawable([email protected]. drawable.sym_app_on_sd_unavailable_icon)); } return(pm.getDefaultActivityIcon()); }
/// <summary>Retrieve the default graphical logo associated with this item.</summary> /// <remarks>Retrieve the default graphical logo associated with this item.</remarks> /// <param name="pm"> /// A PackageManager from which the logo can be loaded; usually /// the PackageManager from which you originally retrieved this item. /// </param> /// <returns> /// Returns a Drawable containing the item's default logo /// or null if no default logo is available. /// </returns> /// <hide></hide> protected internal virtual android.graphics.drawable.Drawable loadDefaultLogo(android.content.pm.PackageManager pm) { return(null); }
public DisplayNameComparator(android.content.pm.PackageManager pm) { mPM = pm; }
internal static android.content.ComponentName getErrorReportReceiver(android.content.pm.PackageManager pm, string errorPackage, string receiverPackage) { throw new System.NotImplementedException(); }
public DisplayNameComparator(android.content.pm.PackageManager arg0) : base(global::MonoJavaBridge.JNIEnv.ThreadEnv) { global::MonoJavaBridge.JNIEnv @__env = global::MonoJavaBridge.JNIEnv.ThreadEnv; global::MonoJavaBridge.JniLocalHandle handle = @__env.NewObject(android.content.pm.ApplicationInfo.DisplayNameComparator.staticClass, global::android.content.pm.ApplicationInfo.DisplayNameComparator._DisplayNameComparator1855, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0)); Init(@__env, handle); }
public virtual java.lang.CharSequence loadDescription(android.content.pm.PackageManager pm) { throw new System.NotImplementedException(); }
protected internal override android.graphics.drawable.Drawable loadDefaultLogo(android.content.pm.PackageManager pm) { return(applicationInfo.loadLogo(pm)); }