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);
}
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);
}
}
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();
}
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);
}
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);
}
Aggregations