Example usage for android.content.pm PackageManager hasSystemFeature

List of usage examples for android.content.pm PackageManager hasSystemFeature

Introduction

In this page you can find the example usage for android.content.pm PackageManager hasSystemFeature.

Prototype

public abstract boolean hasSystemFeature(String name);

Source Link

Document

Check whether the given feature name is one of the available features as returned by #getSystemAvailableFeatures() .

Usage

From source file:com.google.android.marvin.mytalkback.TalkBackService.java

/**
 * Initializes the controllers, managers, and processors. This should only
 * be called once from {@link #onCreate}.
 *///from   w  w w. j  av a2s  . c  om
private void initializeInfrastructure() {
    // Initialize static instances that do not have dependencies.
    NodeSpeechRuleProcessor.initialize(this);
    ClassLoadingManager.getInstance().init(this);

    mAccessibilityManager = (AccessibilityManager) getSystemService(ACCESSIBILITY_SERVICE);
    mPowerManager = (PowerManager) getSystemService(POWER_SERVICE);

    // Initialize the feedback controller and load the default theme.
    mFeedbackController = MappedFeedbackController.initialize(this);
    final MappedThemeLoader themeLoader = mFeedbackController.getThemeLoader();
    themeLoader.loadTheme(this, R.raw.feedbacktheme_default);

    mSpeechController = new SpeechController(this);

    if (Build.VERSION.SDK_INT >= CursorController.MIN_API_LEVEL) {
        mCursorController = new CursorController(this);
        mCursorController.setListener(mCursorControllerListener);
        mAccessibilityEventListeners.add(mCursorController);
    }

    if (Build.VERSION.SDK_INT >= FullScreenReadController.MIN_API_LEVEL) {
        mFullScreenReadController = new FullScreenReadController(this);
        mAccessibilityEventListeners.add(mFullScreenReadController);
    }

    if (Build.VERSION.SDK_INT >= ShakeDetector.MIN_API_LEVEL) {
        mShakeDetector = new ShakeDetector(this);
    }

    // Add event processors. These will process incoming AccessibilityEvents
    // in the order they are added.
    mProcessorEventQueue = new ProcessorEventQueue(this);
    mProcessorEventQueue.setTestingListener(mTestingListener);

    mAccessibilityEventListeners.add(mProcessorEventQueue);
    mAccessibilityEventListeners.add(new ProcessorScrollPosition(this));

    if (Build.VERSION.SDK_INT >= ProcessorLongHover.MIN_API_LEVEL) {
        mAccessibilityEventListeners.add(new ProcessorLongHover(this));
    }

    if (Build.VERSION.SDK_INT >= ProcessorFocusAndSingleTap.MIN_API_LEVEL) {
        mProcessorFollowFocus = new ProcessorFocusAndSingleTap(this);
        mAccessibilityEventListeners.add(mProcessorFollowFocus);
    }

    if (Build.VERSION.SDK_INT >= VolumeMonitor.MIN_API_LEVEL) {
        mVolumeMonitor = new VolumeMonitor(this);
    }

    if (Build.VERSION.SDK_INT >= ProcessorGestureVibrator.MIN_API_LEVEL) {
        mAccessibilityEventListeners.add(new ProcessorGestureVibrator());
    }

    if (Build.VERSION.SDK_INT >= ProcessorWebContent.MIN_API_LEVEL) {
        mAccessibilityEventListeners.add(new ProcessorWebContent(this));
    }

    if (Build.VERSION.SDK_INT >= ProcessorVolumeStream.MIN_API_LEVEL) {
        final ProcessorVolumeStream processorVolumeStream = new ProcessorVolumeStream(this);
        mAccessibilityEventListeners.add(processorVolumeStream);
        mKeyEventListeners.add(processorVolumeStream);
    }

    if (Build.VERSION.SDK_INT >= KeyComboManager.MIN_API_LEVEL) {
        final KeyComboManager keyComboManager = new KeyComboManager();
        keyComboManager.setListener(mKeyComboListener);
        keyComboManager.loadDefaultCombos();
        mKeyEventListeners.add(keyComboManager);
    }

    mOrientationMonitor = new OrientationMonitor(this);

    final PackageManager packageManager = getPackageManager();
    final boolean deviceIsPhone = packageManager.hasSystemFeature(PackageManager.FEATURE_TELEPHONY);

    // Only initialize telephony and call state for phones.
    if (deviceIsPhone) {
        mCallStateMonitor = new CallStateMonitor(this);
    }

    final boolean deviceHasTouchscreen = packageManager.hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN);

    if (deviceIsPhone || deviceHasTouchscreen) {
        // Although this receiver includes code responding to phone-specific
        // intents, it should also be registered for touch screen devices
        // without telephony.
        mRingerModeAndScreenMonitor = new RingerModeAndScreenMonitor(this);
    }

    if (Build.VERSION.SDK_INT >= TextToSpeechManager.MIN_API_LEVEL) {
        mTextToSpeechManager = new TextToSpeechManager(this);
        mTextToSpeechManager.addListener(mTtsDiscoveryListener);
    }

    // Set up the radial menu manager and TalkBack-specific client.
    final TalkBackRadialMenuClient radialMenuClient = new TalkBackRadialMenuClient(this);
    mRadialMenuManager = new RadialMenuManager(this);
    mRadialMenuManager.setClient(radialMenuClient);
}

From source file:com.google.android.marvin.talkback.TalkBackService.java

/**
 * Initializes the controllers, managers, and processors. This should only
 * be called once from {@link #onCreate}.
 *//*from   w  w  w .ja  v a2s .  c  o m*/
private void initializeInfrastructure() {
    // Initialize static instances that do not have dependencies.
    NodeSpeechRuleProcessor.initialize(this);
    ClassLoadingManager.getInstance().init(this);

    mAccessibilityManager = (AccessibilityManager) getSystemService(ACCESSIBILITY_SERVICE);
    mPowerManager = (PowerManager) getSystemService(POWER_SERVICE);

    // Initialize the feedback controller and load the default theme.
    mFeedbackController = MappedFeedbackController.initialize(this);
    final MappedThemeLoader themeLoader = mFeedbackController.getThemeLoader();
    themeLoader.loadTheme(this, R.raw.feedbacktheme_default);

    mSpeechController = new SpeechController(this);

    if (Build.VERSION.SDK_INT >= CursorController.MIN_API_LEVEL) {
        mCursorController = new CursorController(this);
        mCursorController.setListener(mCursorControllerListener);
        mAccessibilityEventListeners.add(mCursorController);
    }

    if (Build.VERSION.SDK_INT >= FullScreenReadController.MIN_API_LEVEL) {
        mFullScreenReadController = new FullScreenReadController(this);
        mAccessibilityEventListeners.add(mFullScreenReadController);
    }

    if (Build.VERSION.SDK_INT >= ShakeDetector.MIN_API_LEVEL) {
        mShakeDetector = new ShakeDetector(this);
    }

    // Add event processors. These will process incoming AccessibilityEvents
    // in the order they are added.
    mProcessorEventQueue = new ProcessorEventQueue(this);
    mProcessorEventQueue.setTestingListener(mTestingListener);

    mAccessibilityEventListeners.add(mProcessorEventQueue);
    mAccessibilityEventListeners.add(new ProcessorScrollPosition(this));

    if (Build.VERSION.SDK_INT >= ProcessorLongHover.MIN_API_LEVEL) {
        mAccessibilityEventListeners.add(new ProcessorLongHover(this));
    }

    if (Build.VERSION.SDK_INT >= ProcessorFocusAndSingleTap.MIN_API_LEVEL) {
        mProcessorFollowFocus = new ProcessorFocusAndSingleTap(this);
        mAccessibilityEventListeners.add(mProcessorFollowFocus);
    }

    if (Build.VERSION.SDK_INT >= VolumeMonitor.MIN_API_LEVEL) {
        mVolumeMonitor = new VolumeMonitor(this);
    }

    if (Build.VERSION.SDK_INT >= PackageRemovalReceiver.MIN_API_LEVEL) {
        mPackageReceiver = new PackageRemovalReceiver();
    }

    if (Build.VERSION.SDK_INT >= ProcessorGestureVibrator.MIN_API_LEVEL) {
        mAccessibilityEventListeners.add(new ProcessorGestureVibrator());
    }

    if (Build.VERSION.SDK_INT >= ProcessorWebContent.MIN_API_LEVEL) {
        mAccessibilityEventListeners.add(new ProcessorWebContent(this));
    }

    if (Build.VERSION.SDK_INT >= ProcessorVolumeStream.MIN_API_LEVEL) {
        final ProcessorVolumeStream processorVolumeStream = new ProcessorVolumeStream(this);
        mAccessibilityEventListeners.add(processorVolumeStream);
        mKeyEventListeners.add(processorVolumeStream);
    }

    if (Build.VERSION.SDK_INT >= KeyComboManager.MIN_API_LEVEL) {
        final KeyComboManager keyComboManager = new KeyComboManager();
        keyComboManager.setListener(mKeyComboListener);
        keyComboManager.loadDefaultCombos();
        mKeyEventListeners.add(keyComboManager);
    }

    mOrientationMonitor = new OrientationMonitor(this);

    final PackageManager packageManager = getPackageManager();
    final boolean deviceIsPhone = packageManager.hasSystemFeature(PackageManager.FEATURE_TELEPHONY);

    // Only initialize telephony and call state for phones.
    if (deviceIsPhone) {
        mCallStateMonitor = new CallStateMonitor(this);
    }

    final boolean deviceHasTouchscreen = packageManager.hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN);

    if (deviceIsPhone || deviceHasTouchscreen) {
        // Although this receiver includes code responding to phone-specific
        // intents, it should also be registered for touch screen devices
        // without telephony.
        mRingerModeAndScreenMonitor = new RingerModeAndScreenMonitor(this);
    }

    if (Build.VERSION.SDK_INT >= TextToSpeechManager.MIN_API_LEVEL) {
        mTextToSpeechManager = new TextToSpeechManager(this);
        mTextToSpeechManager.addListener(mTtsDiscoveryListener);
    }

    // Set up the radial menu manager and TalkBack-specific client.
    final TalkBackRadialMenuClient radialMenuClient = new TalkBackRadialMenuClient(this);
    mRadialMenuManager = new RadialMenuManager(this);
    mRadialMenuManager.setClient(radialMenuClient);

    if (Build.VERSION.SDK_INT >= CustomLabelManager.MIN_API_LEVEL) {
        mLabelManager = new CustomLabelManager(this);
        mAccessibilityEventListeners.add(mLabelManager);
    }
}

From source file:com.inmobi.rendering.RenderView.java

public boolean m1976g(String str) {
    boolean z = true;
    PackageManager packageManager = this.f1770d.getPackageManager();
    boolean z2 = true;
    switch (str.hashCode()) {
    case -1886160473:
        if (str.equals("playVideo")) {
            z2 = true;// w w w . j  a v a 2  s  .c o m
            break;
        }
        break;
    case -1647691422:
        if (str.equals("inlineVideo")) {
            z2 = true;
            break;
        }
        break;
    case -587360353:
        if (str.equals("getGalleryImage")) {
            z2 = true;
            break;
        }
        break;
    case -178324674:
        if (str.equals("calendar")) {
            z2 = true;
            break;
        }
        break;
    case 114009:
        if (str.equals("sms")) {
            z2 = true;
            break;
        }
        break;
    case 114715:
        if (str.equals("tel")) {
            z2 = false;
            break;
        }
        break;
    case 451310959:
        if (str.equals("vibrate")) {
            z2 = true;
            break;
        }
        break;
    case 459238621:
        if (str.equals("storePicture")) {
            z2 = true;
            break;
        }
        break;
    case 1247233375:
        if (str.equals("sendMail")) {
            z2 = true;
            break;
        }
        break;
    case 1370921258:
        if (str.equals("microphone")) {
            z2 = true;
            break;
        }
        break;
    case 1509574865:
        if (str.equals("html5video")) {
            z2 = true;
            break;
        }
        break;
    case 1642189884:
        if (str.equals("saveContent")) {
            z2 = true;
            break;
        }
        break;
    case 1895570642:
        if (str.equals("takeCameraPicture")) {
            z2 = true;
            break;
        }
        break;
    case 1921345160:
        if (str.equals("postToSocial")) {
            z2 = true;
            break;
        }
        break;
    }
    Intent intent;
    ResolveInfo resolveActivity;
    switch (z2) {
    case DurationDV.DURATION_TYPE /*0*/:
        intent = new Intent("android.intent.action.DIAL");
        intent.setData(Uri.parse("tel:123456789"));
        if (this.f1770d.getPackageManager().resolveActivity(intent,
                AccessibilityNodeInfoCompat.ACTION_CUT) == null) {
            return false;
        }
        return true;
    case MainNavigationActivity.REQUEST_CODE /*1*/:
    case DurationDV.DAYTIMEDURATION_TYPE /*2*/:
        return true;
    case ConnectionResult.SERVICE_DISABLED /*3*/:
        z2 = packageManager.hasSystemFeature("android.hardware.microphone")
                && packageManager.checkPermission("android.permission.RECORD_AUDIO",
                        packageManager.getNameForUid(Binder.getCallingUid())) == 0;
        return z2;
    case ConnectionResult.SIGN_IN_REQUIRED /*4*/:
    case MetaData.DEFAULT_SMART_REDIRECT_TIMEOUT /*5*/:
        if (VERSION.SDK_INT >= 11 && !(this.f1786t && m1988p())) {
            z = false;
        }
        Logger.m1744a(InternalLogLevel.INTERNAL, f1748a, "HTML5 video supported:" + z);
        return z;
    case ConnectionResult.RESOLUTION_REQUIRED /*6*/:
        if (this.f1770d.getPackageManager().resolveActivity(
                new Intent("android.intent.action.SENDTO", Uri.parse("smsto:123456789")),
                AccessibilityNodeInfoCompat.ACTION_CUT) == null) {
            return false;
        }
        return true;
    case ConnectionResult.NETWORK_ERROR /*7*/:
        if (VERSION.SDK_INT >= 19 || packageManager.checkPermission("android.permission.WRITE_EXTERNAL_STORAGE",
                packageManager.getNameForUid(Binder.getCallingUid())) == 0) {
            return true;
        }
        return false;
    case ConnectionResult.INTERNAL_ERROR /*8*/:
        intent = new Intent("android.intent.action.SEND");
        intent.setType("plain/text");
        if (this.f1770d.getPackageManager().resolveActivity(intent,
                AccessibilityNodeInfoCompat.ACTION_CUT) == null) {
            return false;
        }
        return true;
    case ConnectionResult.SERVICE_INVALID /*9*/:
        intent = new Intent("android.intent.action.VIEW");
        intent.setType("vnd.android.cursor.item/event");
        ResolveInfo resolveActivity2 = this.f1770d.getPackageManager().resolveActivity(intent,
                AccessibilityNodeInfoCompat.ACTION_CUT);
        z2 = packageManager.checkPermission("android.permission.WRITE_CALENDAR",
                packageManager.getNameForUid(Binder.getCallingUid())) == 0;
        boolean z3;
        if (packageManager.checkPermission("android.permission.READ_CALENDAR",
                packageManager.getNameForUid(Binder.getCallingUid())) == 0) {
            z3 = true;
        } else {
            z3 = false;
        }
        if (resolveActivity2 != null && z2 && r3) {
            return true;
        }
        return false;
    case MetaData.DEFAULT_MAX_ADS /*10*/:
        resolveActivity = this.f1770d.getPackageManager().resolveActivity(
                new Intent("android.media.action.IMAGE_CAPTURE"), AccessibilityNodeInfoCompat.ACTION_CUT);
        z2 = packageManager.checkPermission("android.permission.WRITE_EXTERNAL_STORAGE",
                packageManager.getNameForUid(Binder.getCallingUid())) == 0;
        if (resolveActivity == null || !z2) {
            return false;
        }
        return true;
    case ConnectionResult.LICENSE_CHECK_FAILED /*11*/:
        resolveActivity = this.f1770d.getPackageManager().resolveActivity(
                new Intent("android.intent.action.PICK", Media.EXTERNAL_CONTENT_URI),
                AccessibilityNodeInfoCompat.ACTION_CUT);
        z2 = packageManager.checkPermission("android.permission.WRITE_EXTERNAL_STORAGE",
                packageManager.getNameForUid(Binder.getCallingUid())) == 0;
        if (resolveActivity == null || !z2) {
            return false;
        }
        return true;
    case Tokens.EXPRTOKEN_NODETYPE_COMMENT /*12*/:
        if (VERSION.SDK_INT < 9 || packageManager.checkPermission("android.permission.WRITE_EXTERNAL_STORAGE",
                packageManager.getNameForUid(Binder.getCallingUid())) != 0) {
            return false;
        }
        return true;
    case ConnectionResult.CANCELED /*13*/:
        Vibrator vibrator = (Vibrator) this.f1770d.getSystemService("vibrator");
        if (!(packageManager.checkPermission("android.permission.VIBRATE",
                packageManager.getNameForUid(Binder.getCallingUid())) == 0) || vibrator == null
                || VERSION.SDK_INT < 11 || !m1912a(vibrator)) {
            return false;
        }
        return true;
    default:
        return false;
    }
}