android.content.pm.FeatureInfo Java Examples

The following examples show how to use android.content.pm.FeatureInfo. 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 check out the related API usage on the sidebar.
Example #1
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 6 votes vote down vote up
@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
Source File: DynamicApkParser.java    From Android-plugin-support with 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 #3
Source File: AudioHelper.java    From Noyze with 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 #4
Source File: SPenSupport.java    From 365browser with 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 #5
Source File: SystemFeaturesFragment.java    From java-android-developertools with Apache License 2.0 6 votes vote down vote up
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 #6
Source File: SettingsActivity.java    From slide-android with GNU General Public License v2.0 6 votes vote down vote up
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 #7
Source File: ApplicationPackageManager.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
@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
Source File: AudioHelper.java    From Noyze with 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 #9
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 6 votes vote down vote up
@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 #10
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 6 votes vote down vote up
@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 #11
Source File: CompatibilityChecker.java    From fdroidclient with GNU General Public License v3.0 6 votes vote down vote up
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 #12
Source File: DeviceInfo.java    From COCOFramework with 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 #13
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 6 votes vote down vote up
@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 #14
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 6 votes vote down vote up
@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 #15
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 6 votes vote down vote up
@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 #16
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 6 votes vote down vote up
@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 #17
Source File: NativeDeviceInfoProvider.java    From YalpStore with GNU General Public License v2.0 5 votes vote down vote up
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 #18
Source File: Flashlight.java    From Flashlight-PhoneGap-Plugin with 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;
}
 
Example #19
Source File: DeviceUtils.java    From VideoRecord with 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 #20
Source File: PackageInfoAssembler.java    From under-the-hood with 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 #21
Source File: DetailFragment.java    From Android-Applications-Info with 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 #22
Source File: RNDeviceModule.java    From react-native-device-info with 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 #23
Source File: FeaturesProperty.java    From androiddevice.info with GNU General Public License v2.0 5 votes vote down vote up
@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 #24
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
@Override
public FeatureInfo[] getSystemAvailableFeatures() {
    try {
        return mPM.getSystemAvailableFeatures();
    } catch (RemoteException e) {
        throw new RuntimeException("Package manager has died", e);
    }
}
 
Example #25
Source File: CaptureActivity.java    From zxing with 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 #26
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
@Override
public FeatureInfo[] getSystemAvailableFeatures() {
    try {
        return mPM.getSystemAvailableFeatures();
    } catch (RemoteException e) {
        throw new RuntimeException("Package manager has died", e);
    }
}
 
Example #27
Source File: CameraUtils.java    From o2oa with 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 #28
Source File: PackageManagerUtils.java    From AlbumCameraRecorder with 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 #29
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
@Override
public FeatureInfo[] getSystemAvailableFeatures() {
    try {
        return mPM.getSystemAvailableFeatures();
    } catch (RemoteException e) {
        throw new RuntimeException("Package manager has died", e);
    }
}
 
Example #30
Source File: PackageManagerShellCommand.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
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;
}