Search in sources :

Example 11 with NfcAdapter

use of android.nfc.NfcAdapter in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class SettingsActivity method doUpdateTilesList.

private void doUpdateTilesList() {
    PackageManager pm = getPackageManager();
    final UserManager um = UserManager.get(this);
    final boolean isAdmin = um.isAdminUser();
    String packageName = getPackageName();
    setTileEnabled(new ComponentName(packageName, WifiSettingsActivity.class.getName()), pm.hasSystemFeature(PackageManager.FEATURE_WIFI), isAdmin, pm);
    setTileEnabled(new ComponentName(packageName, Settings.BluetoothSettingsActivity.class.getName()), pm.hasSystemFeature(PackageManager.FEATURE_BLUETOOTH), isAdmin, pm);
    setTileEnabled(new ComponentName(packageName, Settings.DataUsageSummaryActivity.class.getName()), Utils.isBandwidthControlEnabled(), isAdmin, pm);
    setTileEnabled(new ComponentName(packageName, Settings.RoamingSettingsActivity.class.getName()), getResources().getBoolean(R.bool.config_roamingsettings_enabled), isAdmin, pm);
    setTileEnabled(new ComponentName(packageName, Settings.SimSettingsActivity.class.getName()), Utils.showSimCardTile(this), isAdmin, pm);
    setTileEnabled(new ComponentName(packageName, Settings.PowerUsageSummaryActivity.class.getName()), mBatteryPresent, isAdmin, pm);
    setTileEnabled(new ComponentName(packageName, Settings.UserSettingsActivity.class.getName()), UserHandle.MU_ENABLED && UserManager.supportsMultipleUsers() && !Utils.isMonkeyRunning(), isAdmin, pm);
    setTileEnabled(new ComponentName(packageName, Settings.WirelessSettingsActivity.class.getName()), !UserManager.isDeviceInDemoMode(this), isAdmin, pm);
    setTileEnabled(new ComponentName(packageName, Settings.DateTimeSettingsActivity.class.getName()), !UserManager.isDeviceInDemoMode(this), isAdmin, pm);
    NfcAdapter adapter = NfcAdapter.getDefaultAdapter(this);
    setTileEnabled(new ComponentName(packageName, Settings.PaymentSettingsActivity.class.getName()), pm.hasSystemFeature(PackageManager.FEATURE_NFC) && pm.hasSystemFeature(PackageManager.FEATURE_NFC_HOST_CARD_EMULATION) && adapter != null && adapter.isEnabled(), isAdmin, pm);
    setTileEnabled(new ComponentName(packageName, Settings.PrintSettingsActivity.class.getName()), pm.hasSystemFeature(PackageManager.FEATURE_PRINTING), isAdmin, pm);
    final boolean showDev = mDevelopmentPreferences.getBoolean(DevelopmentSettings.PREF_SHOW, android.os.Build.TYPE.equals("eng") || android.os.Build.TYPE.equals("userdebug")) && !um.hasUserRestriction(UserManager.DISALLOW_DEBUGGING_FEATURES);
    setTileEnabled(new ComponentName(packageName, Settings.DevelopmentSettingsActivity.class.getName()), showDev, isAdmin, pm);
    boolean kapresent = false;
    try {
        kapresent = (getPackageManager().getPackageInfo("com.grarak.kerneladiutor", 0).versionCode > 0);
    } catch (PackageManager.NameNotFoundException e) {
    }
    setTileEnabled(new ComponentName(packageName, Settings.KActivity.class.getName()), kapresent, isAdmin, pm);
    boolean themesSupported = false;
    try {
        themesSupported = (getPackageManager().getPackageInfo("projekt.substratum", 0).versionCode > 0);
    } catch (PackageManager.NameNotFoundException e) {
    }
    setTileEnabled(new ComponentName(packageName, Settings.ThemesActivity.class.getName()), themesSupported, isAdmin, pm);
    // Reveal development-only quick settings tiles
    DevelopmentTiles.setTilesEnabled(this, showDev);
    // Magisk Manager
    boolean magiskSupported = false;
    try {
        magiskSupported = (getPackageManager().getPackageInfo("com.topjohnwu.magisk", 0).versionCode > 0);
    } catch (PackageManager.NameNotFoundException e) {
    }
    setTileEnabled(new ComponentName(packageName, Settings.MagiskActivity.class.getName()), magiskSupported, isAdmin, pm);
    // Show scheduled power on and off if support
    boolean showTimerSwitch = false;
    Intent intent = new Intent(ACTION_TIMER_SWITCH);
    List<ResolveInfo> infos = getBaseContext().getPackageManager().queryIntentActivities(intent, 0);
    if (infos != null && !infos.isEmpty()) {
        showTimerSwitch = true;
    }
    setTileEnabled(new ComponentName(packageName, Settings.TimerSwitchSettingsActivity.class.getName()), showTimerSwitch, isAdmin, pm);
    if (UserHandle.MU_ENABLED && !isAdmin) {
        // When on restricted users, disable all extra categories (but only the settings ones).
        List<DashboardCategory> categories = getDashboardCategories();
        for (DashboardCategory category : categories) {
            for (Tile tile : category.tiles) {
                ComponentName component = tile.intent.getComponent();
                if (packageName.equals(component.getPackageName()) && !ArrayUtils.contains(SETTINGS_FOR_RESTRICTED, component.getClassName())) {
                    setTileEnabled(component, false, isAdmin, pm);
                }
            }
        }
    }
    String backupIntent = getResources().getString(R.string.config_backup_settings_intent);
    boolean useDefaultBackup = TextUtils.isEmpty(backupIntent);
    setTileEnabled(new ComponentName(packageName, Settings.PrivacySettingsActivity.class.getName()), useDefaultBackup, isAdmin, pm);
    boolean hasBackupActivity = false;
    if (!useDefaultBackup) {
        try {
            intent = Intent.parseUri(backupIntent, 0);
            hasBackupActivity = !getPackageManager().queryIntentActivities(intent, 0).isEmpty();
        } catch (URISyntaxException e) {
            Log.e(LOG_TAG, "Invalid backup intent URI!", e);
        }
    }
    setTileEnabled(new ComponentName(packageName, BackupSettingsActivity.class.getName()), hasBackupActivity, isAdmin || Utils.isCarrierDemoUser(this), pm);
}
Also used : DashboardCategory(com.android.settingslib.drawer.DashboardCategory) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) Tile(com.android.settingslib.drawer.Tile) Intent(android.content.Intent) URISyntaxException(java.net.URISyntaxException) ResolveInfo(android.content.pm.ResolveInfo) PackageManager(android.content.pm.PackageManager) UserManager(android.os.UserManager) ComponentName(android.content.ComponentName) NfcAdapter(android.nfc.NfcAdapter) ZenModeAutomationSettings(com.android.settings.notification.ZenModeAutomationSettings) NotificationAccessSettings(com.android.settings.notification.NotificationAccessSettings) HWSettings(com.android.settings.rr.input.HWSettings) AccountSettings(com.android.settings.accounts.AccountSettings) SmartbarSettings(com.android.settings.rr.navbar.SmartbarSettings) GestureSettings(com.android.settings.gestures.GestureSettings) AccessibilitySettings(com.android.settings.accessibility.AccessibilitySettings) LocationSettings(com.android.settings.location.LocationSettings) OtherSoundSettings(com.android.settings.notification.OtherSoundSettings) ZenModeEventRuleSettings(com.android.settings.notification.ZenModeEventRuleSettings) InputMethodAndLanguageSettings(com.android.settings.inputmethod.InputMethodAndLanguageSettings) ManagedProfileSettings(com.android.settings.accounts.ManagedProfileSettings) GestureAnywhereSettings(com.android.settings.rr.gestureanywhere.GestureAnywhereSettings) PaymentSettings(com.android.settings.nfc.PaymentSettings) AccountSyncSettings(com.android.settings.accounts.AccountSyncSettings) SimSettings(com.android.settings.sim.SimSettings) UserSettings(com.android.settings.users.UserSettings) WifiSettings(com.android.settings.wifi.WifiSettings) SavedAccessPointsWifiSettings(com.android.settings.wifi.SavedAccessPointsWifiSettings) ZenModeSettings(com.android.settings.notification.ZenModeSettings) FlingSettings(com.android.settings.rr.navbar.FlingSettings) StorageSettings(com.android.settings.deviceinfo.StorageSettings) AmbientSettings(com.android.settings.rr.ambientdisplay.AmbientSettings) VrListenerSettings(com.android.settings.applications.VrListenerSettings) ZenAccessSettings(com.android.settings.notification.ZenAccessSettings) PrivateVolumeSettings(com.android.settings.deviceinfo.PrivateVolumeSettings) SpellCheckersSettings(com.android.settings.inputmethod.SpellCheckersSettings) NavbarSettings(com.android.settings.rr.navbar.NavbarSettings) NightDisplaySettings(com.android.settings.display.NightDisplaySettings) BatterySaverSettings(com.android.settings.fuelgauge.BatterySaverSettings) AdvancedAppSettings(com.android.settings.applications.AdvancedAppSettings) ZenModeVisualInterruptionSettings(com.android.settings.notification.ZenModeVisualInterruptionSettings) WifiDisplaySettings(com.android.settings.wfd.WifiDisplaySettings) AutomaticStorageManagerSettings(com.android.settings.deletionhelper.AutomaticStorageManagerSettings) ZenModePrioritySettings(com.android.settings.notification.ZenModePrioritySettings) SoundSettings(com.android.settings.notification.SoundSettings) AppNotificationSettings(com.android.settings.notification.AppNotificationSettings) AdvancedWifiSettings(com.android.settings.wifi.AdvancedWifiSettings) TextToSpeechSettings(com.android.settings.tts.TextToSpeechSettings) WifiP2pSettings(com.android.settings.wifi.p2p.WifiP2pSettings) PulseSettings(com.android.settings.rr.navbar.PulseSettings) MainSettings(com.android.settings.rr.MainSettings) ZenModeScheduleRuleSettings(com.android.settings.notification.ZenModeScheduleRuleSettings) VpnSettings(com.android.settings.vpn2.VpnSettings) BluetoothSettings(com.android.settings.bluetooth.BluetoothSettings) PublicVolumeSettings(com.android.settings.deviceinfo.PublicVolumeSettings) ConfigureNotificationSettings(com.android.settings.notification.ConfigureNotificationSettings)

Example 12 with NfcAdapter

use of android.nfc.NfcAdapter in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class WriteWifiConfigToNfcDialog method onClick.

@Override
public void onClick(View v) {
    mWakeLock.acquire();
    String password = mPasswordView.getText().toString();
    String wpsNfcConfigurationToken = mWifiManager.getWpsNfcConfigurationToken(mNetworkId);
    String passwordHex = byteArrayToHexString(password.getBytes());
    String passwordLength = password.length() >= HEX_RADIX ? Integer.toString(password.length(), HEX_RADIX) : "0" + Character.forDigit(password.length(), HEX_RADIX);
    passwordHex = String.format(PASSWORD_FORMAT, passwordLength, passwordHex).toUpperCase();
    if (wpsNfcConfigurationToken.contains(passwordHex)) {
        mWpsNfcConfigurationToken = wpsNfcConfigurationToken;
        Activity activity = getOwnerActivity();
        NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(activity);
        nfcAdapter.enableReaderMode(activity, new NfcAdapter.ReaderCallback() {

            @Override
            public void onTagDiscovered(Tag tag) {
                handleWriteNfcEvent(tag);
            }
        }, NfcAdapter.FLAG_READER_NFC_A | NfcAdapter.FLAG_READER_NFC_B | NfcAdapter.FLAG_READER_NFC_BARCODE | NfcAdapter.FLAG_READER_NFC_F | NfcAdapter.FLAG_READER_NFC_V, null);
        mPasswordView.setVisibility(View.GONE);
        mPasswordCheckBox.setVisibility(View.GONE);
        mSubmitButton.setVisibility(View.GONE);
        InputMethodManager imm = (InputMethodManager) getOwnerActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(mPasswordView.getWindowToken(), 0);
        mLabelView.setText(R.string.status_awaiting_tap);
        mView.findViewById(R.id.password_layout).setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
        mProgressBar.setVisibility(View.VISIBLE);
    } else {
        mLabelView.setText(R.string.status_invalid_password);
    }
}
Also used : Activity(android.app.Activity) NfcAdapter(android.nfc.NfcAdapter) InputMethodManager(android.view.inputmethod.InputMethodManager) Tag(android.nfc.Tag)

Example 13 with NfcAdapter

use of android.nfc.NfcAdapter in project android_frameworks_base by crdroidandroid.

the class NfcFCardEmulation method recoverService.

void recoverService() {
    NfcAdapter adapter = NfcAdapter.getDefaultAdapter(mContext);
    sService = adapter.getNfcFCardEmulationService();
}
Also used : NfcAdapter(android.nfc.NfcAdapter)

Example 14 with NfcAdapter

use of android.nfc.NfcAdapter in project iosched by google.

the class BeamUtils method setBeamSessionUri.

/**
     * Sets this activity's Android Beam message to one representing the given session.
     */
public static void setBeamSessionUri(Activity activity, Uri sessionUri) {
    NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(activity);
    if (nfcAdapter == null) {
        // No NFC :-(
        return;
    }
    nfcAdapter.setNdefPushMessage(new NdefMessage(new NdefRecord[] { new NdefRecord(NdefRecord.TNF_MIME_MEDIA, ScheduleContract.makeContentItemType(ScheduleContract.Sessions.CONTENT_TYPE_ID).getBytes(), new byte[0], sessionUri.toString().getBytes()) }), activity);
}
Also used : NdefRecord(android.nfc.NdefRecord) NdefMessage(android.nfc.NdefMessage) NfcAdapter(android.nfc.NfcAdapter)

Example 15 with NfcAdapter

use of android.nfc.NfcAdapter in project weiciyuan by qii.

the class AbstractAppActivity method initNFC.

private void initNFC() {
    NfcAdapter mNfcAdapter = NfcAdapter.getDefaultAdapter(this);
    if (mNfcAdapter == null) {
        return;
    }
    mNfcAdapter.setNdefPushMessageCallback(new NfcAdapter.CreateNdefMessageCallback() {

        @Override
        public NdefMessage createNdefMessage(NfcEvent event) {
            String text = (GlobalContext.getInstance().getCurrentAccountName());
            NdefMessage msg = new NdefMessage(new NdefRecord[] { createMimeRecord("application/org.qii.weiciyuan.beam", text.getBytes()), NdefRecord.createApplicationRecord(getPackageName()) });
            return msg;
        }
    }, this);
}
Also used : NdefRecord(android.nfc.NdefRecord) NfcEvent(android.nfc.NfcEvent) NdefMessage(android.nfc.NdefMessage) NfcAdapter(android.nfc.NfcAdapter)

Aggregations

NfcAdapter (android.nfc.NfcAdapter)22 Activity (android.app.Activity)4 NdefMessage (android.nfc.NdefMessage)3 NdefRecord (android.nfc.NdefRecord)3 NfcEvent (android.nfc.NfcEvent)2 SuppressLint (android.annotation.SuppressLint)1 Fragment (android.app.Fragment)1 ComponentName (android.content.ComponentName)1 Intent (android.content.Intent)1 PackageManager (android.content.pm.PackageManager)1 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)1 ResolveInfo (android.content.pm.ResolveInfo)1 Resources (android.content.res.Resources)1 WifiConfiguration (android.net.wifi.WifiConfiguration)1 Tag (android.nfc.Tag)1 Bundle (android.os.Bundle)1 UserManager (android.os.UserManager)1 PreferenceFragment (android.preference.PreferenceFragment)1 Preference (android.support.v7.preference.Preference)1 InputMethodManager (android.view.inputmethod.InputMethodManager)1