Java Code Examples for android.content.pm.FeatureInfo

The following examples show how to use android.content.pm.FeatureInfo. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
@Override
@SuppressWarnings("unchecked")
public FeatureInfo[] getSystemAvailableFeatures() {
    try {
        ParceledListSlice<FeatureInfo> parceledList =
                mPM.getSystemAvailableFeatures();
        if (parceledList == null) {
            return new FeatureInfo[0];
        }
        final List<FeatureInfo> list = parceledList.getList();
        final FeatureInfo[] res = new FeatureInfo[list.size()];
        for (int i = 0; i < res.length; i++) {
            res[i] = list.get(i);
        }
        return res;
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example 2
@Override
@SuppressWarnings("unchecked")
public FeatureInfo[] getSystemAvailableFeatures() {
    try {
        ParceledListSlice<FeatureInfo> parceledList =
                mPM.getSystemAvailableFeatures();
        if (parceledList == null) {
            return new FeatureInfo[0];
        }
        final List<FeatureInfo> list = parceledList.getList();
        final FeatureInfo[] res = new FeatureInfo[list.size()];
        for (int i = 0; i < res.length; i++) {
            res[i] = list.get(i);
        }
        return res;
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example 3
@Override
@SuppressWarnings("unchecked")
public FeatureInfo[] getSystemAvailableFeatures() {
    try {
        ParceledListSlice<FeatureInfo> parceledList =
                mPM.getSystemAvailableFeatures();
        if (parceledList == null) {
            return new FeatureInfo[0];
        }
        final List<FeatureInfo> list = parceledList.getList();
        final FeatureInfo[] res = new FeatureInfo[list.size()];
        for (int i = 0; i < res.length; i++) {
            res[i] = list.get(i);
        }
        return res;
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example 4
@Override
@SuppressWarnings("unchecked")
public FeatureInfo[] getSystemAvailableFeatures() {
    try {
        ParceledListSlice<FeatureInfo> parceledList =
                mPM.getSystemAvailableFeatures();
        if (parceledList == null) {
            return new FeatureInfo[0];
        }
        final List<FeatureInfo> list = parceledList.getList();
        final FeatureInfo[] res = new FeatureInfo[list.size()];
        for (int i = 0; i < res.length; i++) {
            res[i] = list.get(i);
        }
        return res;
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example 5
@Override
@SuppressWarnings("unchecked")
public FeatureInfo[] getSystemAvailableFeatures() {
    try {
        ParceledListSlice<FeatureInfo> parceledList =
                mPM.getSystemAvailableFeatures();
        if (parceledList == null) {
            return new FeatureInfo[0];
        }
        final List<FeatureInfo> list = parceledList.getList();
        final FeatureInfo[] res = new FeatureInfo[list.size()];
        for (int i = 0; i < res.length; i++) {
            res[i] = list.get(i);
        }
        return res;
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example 6
@Override
@SuppressWarnings("unchecked")
public FeatureInfo[] getSystemAvailableFeatures() {
    try {
        ParceledListSlice<FeatureInfo> parceledList =
                mPM.getSystemAvailableFeatures();
        if (parceledList == null) {
            return new FeatureInfo[0];
        }
        final List<FeatureInfo> list = parceledList.getList();
        final FeatureInfo[] res = new FeatureInfo[list.size()];
        for (int i = 0; i < res.length; i++) {
            res[i] = list.get(i);
        }
        return res;
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example 7
@Override
@SuppressWarnings("unchecked")
public FeatureInfo[] getSystemAvailableFeatures() {
    try {
        ParceledListSlice<FeatureInfo> parceledList =
                mPM.getSystemAvailableFeatures();
        if (parceledList == null) {
            return new FeatureInfo[0];
        }
        final List<FeatureInfo> list = parceledList.getList();
        final FeatureInfo[] res = new FeatureInfo[list.size()];
        for (int i = 0; i < res.length; i++) {
            res[i] = list.get(i);
        }
        return res;
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example 8
@Override
@SuppressWarnings("unchecked")
public FeatureInfo[] getSystemAvailableFeatures() {
    try {
        ParceledListSlice<FeatureInfo> parceledList =
                mPM.getSystemAvailableFeatures();
        if (parceledList == null) {
            return new FeatureInfo[0];
        }
        final List<FeatureInfo> list = parceledList.getList();
        final FeatureInfo[] res = new FeatureInfo[list.size()];
        for (int i = 0; i < res.length; i++) {
            res[i] = list.get(i);
        }
        return res;
    } catch (RemoteException e) {
        throw e.rethrowFromSystemServer();
    }
}
 
Example 9
Source Project: Android-plugin-support   Source File: DynamicApkParser.java    License: MIT License 6 votes vote down vote up
private FeatureInfo parseUsesFeature(Resources res, AttributeSet attrs)
        throws XmlPullParserException, IOException {
    FeatureInfo fi = new FeatureInfo();
    TypedArray sa = res.obtainAttributes(attrs,
            Hooks.getStyleableArray("AndroidManifestUsesFeature"));
    // Note: don't allow this value to be a reference to a resource
    // that may change.
    fi.name = sa.getNonResourceString(
            Hooks.getStyleable("AndroidManifestUsesFeature_name"));
    if (fi.name == null) {
        fi.reqGlEsVersion = sa.getInt(
                Hooks.getStyleable("AndroidManifestUsesFeature_glEsVersion"),
                FeatureInfo.GL_ES_VERSION_UNDEFINED);
    }
    if (sa.getBoolean(
            Hooks.getStyleable("AndroidManifestUsesFeature_required"), true)) {
        fi.flags |= FeatureInfo.FLAG_REQUIRED;
    }
    sa.recycle();
    return fi;
}
 
Example 10
Source Project: Noyze   Source File: AudioHelper.java    License: Apache License 2.0 6 votes vote down vote up
private static boolean _isHTC(Context context) {
    // CHECK: Build prop to see if HTC is there.
    if (Build.MANUFACTURER.contains("HTC")) return true;
    // CHECK: available features, like HTC sense.
    FeatureInfo[] features = context.getPackageManager().getSystemAvailableFeatures();
    for (FeatureInfo feature : features) {
        if (!TextUtils.isEmpty(feature.name) &&
            feature.name.startsWith("com.htc")) {
            return true;
        }
    }
    // CHECK: the HTC Sense launcher package.
    PackageManager pm = context.getPackageManager();
    Intent intent = new Intent(Intent.ACTION_MAIN);
    intent.addCategory(Intent.CATEGORY_HOME);
    List<ResolveInfo> list = pm.queryIntentActivities(
            intent, PackageManager.MATCH_DEFAULT_ONLY);
    for (ResolveInfo info : list) {
        if (info.activityInfo != null) {
            if ("com.htc.launcher.Launcher".equals(info.activityInfo.name)) {
                return true;
            }
        }
    }
    return false;
}
 
Example 11
Source Project: 365browser   Source File: SPenSupport.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Initialize SPen support. This is done lazily at the first invocation of
 * {@link #convertSPenEventAction(int)}.
 */
private static void initialize() {
    if (sIsSPenSupported != null) return;

    if (!"SAMSUNG".equalsIgnoreCase(Build.MANUFACTURER)) {
        sIsSPenSupported = false;
        return;
    }

    Context context = ContextUtils.getApplicationContext();
    final FeatureInfo[] infos = context.getPackageManager().getSystemAvailableFeatures();
    for (FeatureInfo info : infos) {
        if ("com.sec.feature.spen_usp".equalsIgnoreCase(info.name)) {
            sIsSPenSupported = true;
            return;
        }
    }
    sIsSPenSupported = false;
}
 
Example 12
private void setUpSystemFeatures(TextView systemFeaturesTextView) {
    FeatureInfo[] featureInfoArray = getActivity().getPackageManager().getSystemAvailableFeatures();
    List<String> features = new ArrayList<>();
    for (FeatureInfo featureInfo : featureInfoArray) {
        final String name = featureInfo.name;
        if (name != null) {
            features.add(name);
        }
    }
    Collections.sort(features, new Comparator<String>() {
        @Override
        public int compare(String lhs, String rhs) {
            return lhs.compareTo(rhs);
        }
    });
    StringBuilder systemFeatures = new StringBuilder();
    for (String feature : features) {
        systemFeatures.append(feature);
        systemFeatures.append("\n");
    }
    this.systemFeatures = systemFeatures.toString();
    systemFeaturesTextView.setText(this.systemFeatures);
    this.systemFeatures = "Device: " + Utils.getDeviceSummary() + "\n" + this.systemFeatures;
}
 
Example 13
private boolean isSPenSupported()
{
    final FeatureInfo[] featureInfo = getPackageManager().getSystemAvailableFeatures();
    for (FeatureInfo info : featureInfo)
    {
        if (SPEN_FEATURE.equalsIgnoreCase(info.name))
        {
            return true;
        }
    }
    if (SAMSUNG.equalsIgnoreCase(Build.MANUFACTURER))
    {
        if (Build.MODEL.toUpperCase(Locale.ENGLISH).startsWith(NOTE))
        {
            return true;
        }
    }
    return false;
}
 
Example 14
Source Project: Noyze   Source File: AudioHelper.java    License: Apache License 2.0 6 votes vote down vote up
private static boolean _isHTC(Context context) {
    // CHECK: Build prop to see if HTC is there.
    if (Build.MANUFACTURER.contains("HTC")) return true;
    // CHECK: available features, like HTC sense.
    FeatureInfo[] features = context.getPackageManager().getSystemAvailableFeatures();
    for (FeatureInfo feature : features) {
        if (!TextUtils.isEmpty(feature.name) &&
            feature.name.startsWith("com.htc")) {
            return true;
        }
    }
    // CHECK: the HTC Sense launcher package.
    PackageManager pm = context.getPackageManager();
    Intent intent = new Intent(Intent.ACTION_MAIN);
    intent.addCategory(Intent.CATEGORY_HOME);
    List<ResolveInfo> list = pm.queryIntentActivities(
            intent, PackageManager.MATCH_DEFAULT_ONLY);
    for (ResolveInfo info : list) {
        if (info.activityInfo != null) {
            if ("com.htc.launcher.Launcher".equals(info.activityInfo.name)) {
                return true;
            }
        }
    }
    return false;
}
 
Example 15
public CompatibilityChecker(Context ctx) {

        context = ctx.getApplicationContext();

        forceTouchApps = Preferences.get().forceTouchApps();

        PackageManager pm = ctx.getPackageManager();

        features = new HashSet<>();
        if (pm != null) {
            final FeatureInfo[] featureArray = pm.getSystemAvailableFeatures();
            if (featureArray != null) {
                for (FeatureInfo fi : pm.getSystemAvailableFeatures()) {
                    features.add(fi.name);
                }
            }
        }

        cpuAbis = SupportedArchitectures.getAbis();
    }
 
Example 16
Source Project: COCOFramework   Source File: DeviceInfo.java    License: Apache License 2.0 6 votes vote down vote up
private String getOpenGLVersion() {
    Context context = getActivity();
    PackageManager packageManager = context.getPackageManager();
    FeatureInfo[] featureInfos = packageManager.getSystemAvailableFeatures();
    if (featureInfos != null && featureInfos.length > 0) {
        for (FeatureInfo featureInfo : featureInfos) {
            // Null feature name means this feature is the open gl es version feature.
            if (featureInfo.name == null) {
                if (featureInfo.reqGlEsVersion != FeatureInfo.GL_ES_VERSION_UNDEFINED) {
                    return String.valueOf((featureInfo.reqGlEsVersion & 0xFFFF0000) >> 16) + "." + String.valueOf((featureInfo.reqGlEsVersion & 0x0000FFFF));
                } else {
                    return "1.0"; // Lack of property means OpenGL ES version 1
                }
            }
        }
    }
    return "1.0";
}
 
Example 17
@Override
public FeatureInfo[] getSystemAvailableFeatures() {
    try {
        return mPM.getSystemAvailableFeatures();
    } catch (RemoteException e) {
        throw new RuntimeException("Package manager has died", e);
    }
}
 
Example 18
@Override
public FeatureInfo[] getSystemAvailableFeatures() {
    try {
        return mPM.getSystemAvailableFeatures();
    } catch (RemoteException e) {
        throw new RuntimeException("Package manager has died", e);
    }
}
 
Example 19
@Override
public FeatureInfo[] getSystemAvailableFeatures() {
    try {
        return mPM.getSystemAvailableFeatures();
    } catch (RemoteException e) {
        throw new RuntimeException("Package manager has died", e);
    }
}
 
Example 20
private int runListFeatures() throws RemoteException {
    final PrintWriter pw = getOutPrintWriter();
    final List<FeatureInfo> list = mInterface.getSystemAvailableFeatures().getList();

    // sort by name
    Collections.sort(list, new Comparator<FeatureInfo>() {
        public int compare(FeatureInfo o1, FeatureInfo o2) {
            if (o1.name == o2.name) return 0;
            if (o1.name == null) return -1;
            if (o2.name == null) return 1;
            return o1.name.compareTo(o2.name);
        }
    });

    final int count = (list != null) ? list.size() : 0;
    for (int p = 0; p < count; p++) {
        FeatureInfo fi = list.get(p);
        pw.print("feature:");
        if (fi.name != null) {
            pw.print(fi.name);
            if (fi.version > 0) {
                pw.print("=");
                pw.print(fi.version);
            }
            pw.println();
        } else {
            pw.println("reqGlEsVersion=0x"
                    + Integer.toHexString(fi.reqGlEsVersion));
        }
    }
    return 0;
}
 
Example 21
Source Project: AlbumCameraRecorder   Source File: PackageManagerUtils.java    License: MIT License 5 votes vote down vote up
/**
 * 判断是否支持闪光灯
 * @param pm PackageManager
 * @return 是否
 */
public static boolean isSupportCameraLedFlash(PackageManager pm) {
    if (pm != null) {
        FeatureInfo[] features = pm.getSystemAvailableFeatures();
        if (features != null) {
            for (FeatureInfo f : features) {
                if (f != null && PackageManager.FEATURE_CAMERA_FLASH.equals(f.name));
                return true;
            }
        }
    }
    return false;
}
 
Example 22
Source Project: o2oa   Source File: CameraUtils.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * 是否支持闪光
 * @param context
 * @return
 */
static boolean isSupportFlashCamera(Context context) {
    FeatureInfo[] features = context.getPackageManager().getSystemAvailableFeatures();
    for(FeatureInfo info : features) {
        if(PackageManager.FEATURE_CAMERA_FLASH.equals(info.name))
            return true;
    }
    return false;
}
 
Example 23
Source Project: zxing   Source File: CaptureActivity.java    License: MIT License 5 votes vote down vote up
/**
 * @param pm
 * @return 是否有闪光灯
 */
public static boolean isSupportCameraLedFlash(PackageManager pm) {
    if (pm != null) {
        FeatureInfo[] features = pm.getSystemAvailableFeatures();
        if (features != null) {
            for (FeatureInfo f : features) {
                if (f != null && PackageManager.FEATURE_CAMERA_FLASH.equals(f.name)) {
                    return true;
                }
            }
        }
    }
    return false;
}
 
Example 24
static public List<String> getFeatures(Context context) {
    List<String> featureStringList = new ArrayList<>();
    for (FeatureInfo feature: context.getPackageManager().getSystemAvailableFeatures()) {
        if (!TextUtils.isEmpty(feature.name)) {
            featureStringList.add(feature.name);
        }
    }
    Collections.sort(featureStringList);
    return featureStringList;
}
 
Example 25
Source Project: VideoRecord   Source File: DeviceUtils.java    License: MIT License 5 votes vote down vote up
/** 判断是否支持闪光灯 */
public static boolean isSupportCameraLedFlash(PackageManager pm) {
    if (pm != null) {
        FeatureInfo[] features = pm.getSystemAvailableFeatures();
        if (features != null) {
            for (FeatureInfo f : features) {
                if (f != null && PackageManager.FEATURE_CAMERA_FLASH.equals(f.name)) //判断设备是否支持闪光灯
                    return true;
            }
        }
    }
    return false;
}
 
Example 26
Source Project: under-the-hood   Source File: PackageInfoAssembler.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Creates entries for all declared system features (see Manifest &lt;uses-feature> tags)
 * Uses {@link DefaultProperties#createSystemFeatureInfo(Context, Map)} call.
 *
 * @param context     must not be null
 * @param packageInfo from {@link PackageManager#getPackageInfo(String, int)} requiring {@link PackageManager#GET_CONFIGURATIONS} flag
 * @return list of all declared uses-feature tags in AndroidManifest as page entries
 */
public static List<PageEntry<?>> createPmDeclaredSystemFeatureInfo(@NonNull Context context, @NonNull PackageInfo packageInfo) {
    try {
        Map<CharSequence, String> featureMap = new TreeMap<>();
        if (packageInfo.reqFeatures != null && packageInfo.reqFeatures.length > 0) {
            for (FeatureInfo reqFeature : packageInfo.reqFeatures) {
                boolean required = reqFeature.flags == FeatureInfo.FLAG_REQUIRED;
                String fullLabel;
                String id;
                if ((reqFeature.name == null || reqFeature.name.trim().isEmpty())
                        && reqFeature.getGlEsVersion() != null && !reqFeature.getGlEsVersion().isEmpty()) {
                    fullLabel = "glEsVersion " + reqFeature.getGlEsVersion();
                    id = String.valueOf(reqFeature.reqGlEsVersion);
                } else {
                    fullLabel = reqFeature.name;
                    id = reqFeature.name;
                }

                fullLabel += (required ? " (req)" : "");
                featureMap.put(Hood.ext().createFullLabel(fullLabel.replace("android.hardware.", ""), fullLabel), id);
            }
        }

        return DefaultProperties.createSystemFeatureInfo(context, featureMap);
    } catch (Exception e) {
        throw new IllegalStateException(e);
    }
}
 
Example 27
Source Project: Android-Applications-Info   Source File: DetailFragment.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Boring view inflation / creation
 */
private View getFeaturesView(ViewGroup viewGroup, View convertView, int index) {
    ViewHolder viewHolder;
    if (!checkIfConvertViewMatch(convertView, FEATURES)) {
        convertView = mLayoutInflater.inflate(R.layout.detail_features, viewGroup, false);

        viewHolder = new ViewHolder();
        viewHolder.currentViewType = FEATURES;
        viewHolder.textView1 = (TextView) convertView.findViewById(R.id.name);
        viewHolder.textView2 = (TextView) convertView.findViewById(R.id.flags);
        viewHolder.textView3 = (TextView) convertView.findViewById(R.id.gles_ver);
    } else {
        viewHolder = (ViewHolder) convertView.getTag();
    }

    final FeatureInfo featureInfo = mPackageInfo.reqFeatures[index];
    convertView.setBackgroundColor(index % 2 == 0 ? mColorGrey1 : mColorGrey2);

    //Name
    viewHolder.textView1.setText(featureInfo.name);

    //Falgs
    viewHolder.textView2.setText(getString(R.string.flags) + ": " + Utils.getFeatureFlagsString(featureInfo.flags));

    //GLES ver
    viewHolder.textView3.setText(getString(R.string.gles_ver) + ": " + featureInfo.reqGlEsVersion);

    return convertView;
}
 
Example 28
Source Project: react-native-device-info   Source File: RNDeviceModule.java    License: MIT License 5 votes vote down vote up
@ReactMethod(isBlockingSynchronousMethod = true)
public WritableArray getSystemAvailableFeaturesSync() {
  final FeatureInfo[] featureList = getReactApplicationContext().getPackageManager().getSystemAvailableFeatures();

  WritableArray promiseArray = Arguments.createArray();
  for (FeatureInfo f : featureList) {
    if (f.name != null) {
      promiseArray.pushString(f.name);
    }
  }

  return promiseArray;
}
 
Example 29
@Override
public Object getProperty() {
    JSONArray jsonArray = new JSONArray();

    PackageManager pm = Application.getContext().getPackageManager();
    FeatureInfo[] features = pm != null ? pm.getSystemAvailableFeatures() : new FeatureInfo[0];
    for(FeatureInfo feature: features) {
        jsonArray.put(feature.name);
    }
    return jsonArray;
}
 
Example 30
Source Project: Flashlight-PhoneGap-Plugin   Source File: Flashlight.java    License: MIT License 5 votes vote down vote up
private boolean isCapable() {
  if (capable == null) {
    capable = false;
    final PackageManager packageManager = this.cordova.getActivity().getPackageManager();
    for (final FeatureInfo feature : packageManager.getSystemAvailableFeatures()) {
      if (PackageManager.FEATURE_CAMERA_FLASH.equalsIgnoreCase(feature.name)) {
        capable = true;
        break;
      }
    }
  }
  return capable;
}