Java Code Examples for android.content.pm.PackageManager#getSystemAvailableFeatures()
The following examples show how to use
android.content.pm.PackageManager#getSystemAvailableFeatures() .
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: CompatibilityChecker.java From fdroidclient with GNU General Public License v3.0 | 6 votes |
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 2
Source File: DeviceInfo.java From COCOFramework with Apache License 2.0 | 6 votes |
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 3
Source File: PackageManagerUtils.java From AlbumCameraRecorder with MIT License | 5 votes |
/** * 判断是否支持闪光灯 * @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 4
Source File: CaptureActivity.java From zxing with MIT License | 5 votes |
/** * @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 5
Source File: DeviceUtils.java From VideoRecord with MIT License | 5 votes |
/** 判断是否支持闪光灯 */ 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 6
Source File: FeaturesProperty.java From androiddevice.info with GNU General Public License v2.0 | 5 votes |
@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 7
Source File: Flashlight.java From Flashlight-PhoneGap-Plugin with MIT License | 5 votes |
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 8
Source File: ActivityManagerShellCommand.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
private void writeDeviceConfig(ProtoOutputStream protoOutputStream, long fieldId, PrintWriter pw, Configuration config, DisplayManager dm) { Point stableSize = dm.getStableDisplaySize(); long token = -1; if (protoOutputStream != null) { token = protoOutputStream.start(fieldId); protoOutputStream.write(DeviceConfigurationProto.STABLE_SCREEN_WIDTH_PX, stableSize.x); protoOutputStream.write(DeviceConfigurationProto.STABLE_SCREEN_HEIGHT_PX, stableSize.y); protoOutputStream.write(DeviceConfigurationProto.STABLE_DENSITY_DPI, DisplayMetrics.DENSITY_DEVICE_STABLE); } if (pw != null) { pw.print("stable-width-px: "); pw.println(stableSize.x); pw.print("stable-height-px: "); pw.println(stableSize.y); pw.print("stable-density-dpi: "); pw.println(DisplayMetrics.DENSITY_DEVICE_STABLE); } MemInfoReader memreader = new MemInfoReader(); memreader.readMemInfo(); KeyguardManager kgm = mInternal.mContext.getSystemService(KeyguardManager.class); if (protoOutputStream != null) { protoOutputStream.write(DeviceConfigurationProto.TOTAL_RAM, memreader.getTotalSize()); protoOutputStream.write(DeviceConfigurationProto.LOW_RAM, ActivityManager.isLowRamDeviceStatic()); protoOutputStream.write(DeviceConfigurationProto.MAX_CORES, Runtime.getRuntime().availableProcessors()); protoOutputStream.write(DeviceConfigurationProto.HAS_SECURE_SCREEN_LOCK, kgm.isDeviceSecure()); } if (pw != null) { pw.print("total-ram: "); pw.println(memreader.getTotalSize()); pw.print("low-ram: "); pw.println(ActivityManager.isLowRamDeviceStatic()); pw.print("max-cores: "); pw.println(Runtime.getRuntime().availableProcessors()); pw.print("has-secure-screen-lock: "); pw.println(kgm.isDeviceSecure()); } ConfigurationInfo configInfo = mInternal.getDeviceConfigurationInfo(); if (configInfo.reqGlEsVersion != ConfigurationInfo.GL_ES_VERSION_UNDEFINED) { if (protoOutputStream != null) { protoOutputStream.write(DeviceConfigurationProto.OPENGL_VERSION, configInfo.reqGlEsVersion); } if (pw != null) { pw.print("opengl-version: 0x"); pw.println(Integer.toHexString(configInfo.reqGlEsVersion)); } } Set<String> glExtensionsSet = getGlExtensionsFromDriver(); String[] glExtensions = new String[glExtensionsSet.size()]; glExtensions = glExtensionsSet.toArray(glExtensions); Arrays.sort(glExtensions); for (int i = 0; i < glExtensions.length; i++) { if (protoOutputStream != null) { protoOutputStream.write(DeviceConfigurationProto.OPENGL_EXTENSIONS, glExtensions[i]); } if (pw != null) { pw.print("opengl-extensions: "); pw.println(glExtensions[i]); } } PackageManager pm = mInternal.mContext.getPackageManager(); List<SharedLibraryInfo> slibs = pm.getSharedLibraries(0); Collections.sort(slibs, Comparator.comparing(SharedLibraryInfo::getName)); for (int i = 0; i < slibs.size(); i++) { if (protoOutputStream != null) { protoOutputStream.write(DeviceConfigurationProto.SHARED_LIBRARIES, slibs.get(i).getName()); } if (pw != null) { pw.print("shared-libraries: "); pw.println(slibs.get(i).getName()); } } FeatureInfo[] features = pm.getSystemAvailableFeatures(); Arrays.sort(features, (o1, o2) -> (o1.name == o2.name ? 0 : (o1.name == null ? -1 : o1.name.compareTo(o2.name)))); for (int i = 0; i < features.length; i++) { if (features[i].name != null) { if (protoOutputStream != null) { protoOutputStream.write(DeviceConfigurationProto.FEATURES, features[i].name); } if (pw != null) { pw.print("features: "); pw.println(features[i].name); } } } if (protoOutputStream != null) { protoOutputStream.end(token); } }
Example 9
Source File: DeviceConfiguration.java From android_packages_apps_GmsCore with Apache License 2.0 | 4 votes |
public DeviceConfiguration(Context context) { ConfigurationInfo configurationInfo = ((ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE)).getDeviceConfigurationInfo(); touchScreen = configurationInfo.reqTouchScreen; keyboardType = configurationInfo.reqKeyboardType; navigation = configurationInfo.reqNavigation; Configuration configuration = context.getResources().getConfiguration(); screenLayout = configuration.screenLayout; hasHardKeyboard = (configurationInfo.reqInputFeatures & ConfigurationInfo.INPUT_FEATURE_HARD_KEYBOARD) > 0; hasFiveWayNavigation = (configurationInfo.reqInputFeatures & ConfigurationInfo.INPUT_FEATURE_FIVE_WAY_NAV) > 0; DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics(); densityDpi = displayMetrics.densityDpi; glEsVersion = configurationInfo.reqGlEsVersion; PackageManager packageManager = context.getPackageManager(); String[] systemSharedLibraryNames = packageManager.getSystemSharedLibraryNames(); sharedLibraries = new ArrayList<String>(); if (systemSharedLibraryNames != null) sharedLibraries.addAll(Arrays.asList(systemSharedLibraryNames)); for (String s : new String[]{"com.google.android.maps", "com.google.android.media.effects", "com.google.widevine.software.drm"}) { if (!sharedLibraries.contains(s)) { sharedLibraries.add(s); } } Collections.sort(sharedLibraries); availableFeatures = new ArrayList<String>(); if (packageManager.getSystemAvailableFeatures() != null) { for (FeatureInfo featureInfo : packageManager.getSystemAvailableFeatures()) { if (featureInfo != null && featureInfo.name != null) availableFeatures.add(featureInfo.name); } } Collections.sort(availableFeatures); this.nativePlatforms = getNativePlatforms(); widthPixels = displayMetrics.widthPixels; heightPixels = displayMetrics.heightPixels; locales = new ArrayList<String>(Arrays.asList(context.getAssets().getLocales())); for (int i = 0; i < locales.size(); i++) { locales.set(i, locales.get(i).replace("-", "_")); } Collections.sort(locales); Set<String> glExtensions = new HashSet<String>(); addEglExtensions(glExtensions); this.glExtensions = new ArrayList<String>(glExtensions); Collections.sort(this.glExtensions); }
Example 10
Source File: DeviceInfo.java From COCOFramework with Apache License 2.0 | 4 votes |
private ArrayList<Row> generateDeviceInfoList() { ArrayList<Row> result = new ArrayList<Row>(); DisplayMetrics metrics = new DisplayMetrics(); getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics); result.add(buildLineItem("SDK", VERSION.CODENAME + "(" + VERSION.SDK_INT + ")")); result.add(buildLineItem("Density", "Density", " (", String.valueOf(metrics.density), ")")); result.add(buildLineItem("DPI X/Y", String.valueOf(metrics.xdpi), " / ", String.valueOf(metrics.ydpi))); result.add(buildLineItem("Screen size", "Screen size")); result.add(buildLineItem("Screen resolution", String.valueOf(metrics.widthPixels), "x", String.valueOf(metrics.heightPixels))); result.add(buildLineItem("Orientation", "Orientation")); result.add(buildLineItem("Locale", getResources().getConfiguration().locale.toString())); result.add(buildLineItem("Mobile County/Network code", String.valueOf(getResources().getConfiguration().mcc), "/", String.valueOf(getResources().getConfiguration().mnc))); result.add(buildLineItem("UserAgent", getUserAgent())); result.add(buildLineItem("OpenGL Version", getOpenGLVersion())); result.add(buildLineItem("Manufacturer", Build.MANUFACTURER)); result.add(buildLineItem("Model", Build.MODEL)); result.add(buildLineItem("Device", Build.DEVICE)); result.add(buildLineItem("Product", Build.PRODUCT)); result.add(buildLineItem("Brand", Build.BRAND)); result.add(buildLineItem("CPU+ABI", Build.CPU_ABI)); result.add(buildLineItem("Build (Tags)", Build.DISPLAY, " (", Build.TAGS, ")")); PackageManager pm = getActivity().getPackageManager(); FeatureInfo[] features = pm.getSystemAvailableFeatures(); TreeSet<String> l = new TreeSet<String>(); for (FeatureInfo f : features) { if (f.name != null) { l.add(f.name); } } result.add(buildLineItem("Features", l)); String[] libraries = pm.getSystemSharedLibraryNames(); l = new TreeSet<String>(); for (String lib : libraries) { if (lib != null) { l.add(lib); } } result.add(buildLineItem("Shared Libraries", l)); StatFs fs = new StatFs("/data"); Log.d("StatFS", Formatter.formatFileSize(getActivity(), fs.getAvailableBlocks() * fs.getBlockSize())); return result; }