how to check AccessibilityService [duplicate] - java

I was wondering how could I detect if my own service is enabled. So I could check if my service is not enabled, then tell the user to enable it.

Below is the method to check if your accessibility service is enabled or not. 
Note: Change value of YOURAccessibilityService with your Service. 
// To check if service is enabled
private boolean isAccessibilitySettingsOn(Context mContext) {
int accessibilityEnabled = 0;
final String service = getPackageName() + "/" + YOURAccessibilityService.class.getCanonicalName();
try {
accessibilityEnabled = Settings.Secure.getInt(
mContext.getApplicationContext().getContentResolver(),
android.provider.Settings.Secure.ACCESSIBILITY_ENABLED);
Log.v(TAG, "accessibilityEnabled = " + accessibilityEnabled);
} catch (Settings.SettingNotFoundException e) {
Log.e(TAG, "Error finding setting, default accessibility to not found: "
+ e.getMessage());
}
TextUtils.SimpleStringSplitter mStringColonSplitter = new TextUtils.SimpleStringSplitter(':');
if (accessibilityEnabled == 1) {
Log.v(TAG, "***ACCESSIBILITY IS ENABLED*** -----------------");
String settingValue = Settings.Secure.getString(
mContext.getApplicationContext().getContentResolver(),
Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES);
if (settingValue != null) {
mStringColonSplitter.setString(settingValue);
while (mStringColonSplitter.hasNext()) {
String accessibilityService = mStringColonSplitter.next();
Log.v(TAG, "-------------- > accessibilityService :: " + accessibilityService + " " + service);
if (accessibilityService.equalsIgnoreCase(service)) {
Log.v(TAG, "We've found the correct setting - accessibility is switched on!");
return true;
}
}
}
} else {
Log.v(TAG, "***ACCESSIBILITY IS DISABLED***");
}
return false;
}
And to call this method:
if (!isAccessibilitySettingsOn(getApplicationContext())) {
startActivity(new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS));
}
This will check and launch accessibility settings if not enabled.

This is a modified version of Jakub Bláha's answer in java.
public boolean isAccessServiceEnabled(Context context, Class accessibilityServiceClass)
{
String prefString = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES);
return prefString!= null && prefString.contains(context.getPackageName() + "/" + accessibilityServiceClass.getName());
}

This is somehow a smaller version, but it is working.
fun isAccessServiceEnabled(context: Context): Boolean {
val prefString =
Settings.Secure.getString(context.contentResolver, Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES)
return prefString.contains("${context.packageName}/${context.packageName}.${context.getString(R.string.access_service_name)}")
}
Feel free to correct me if there is something missing.

1:Kotlin Based answer
2:Added a current package name check as well cos it will return true only if accessibility service will be Enabled for current package, Recently it was returning true if any package accessibility service enabled
private fun checkAccessibilityPermission(): Boolean {
var isAccessibilityEnabled = false
(requireActivity().getSystemService(Context.ACCESSIBILITY_SERVICE) as AccessibilityManager).apply {
installedAccessibilityServiceList.forEach { installedService ->
installedService.resolveInfo.serviceInfo.apply {
if (getEnabledAccessibilityServiceList(AccessibilityServiceInfo.FEEDBACK_ALL_MASK).any { it.resolveInfo.serviceInfo.packageName == packageName && it.resolveInfo.serviceInfo.name == name && permission == Manifest.permission.BIND_ACCESSIBILITY_SERVICE && it.resolveInfo.serviceInfo.packageName == requireActivity().packageName })
isAccessibilityEnabled = true
}
}
}
if (isAccessibilityEnabled.not())
startActivity(Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS).apply {
flags = Intent.FLAG_ACTIVITY_NEW_TASK
})
return isAccessibilityEnabled
}

Kotlin version based on answer of #Pankaj Kumar
inline fun <reified T> Context.isAccessibilityEnabled(): Boolean {
var enabled = 0
try {
enabled = Settings.Secure.getInt(contentResolver, Settings.Secure.ACCESSIBILITY_ENABLED)
} catch (e: SettingNotFoundException) {
Timber.e(e)
}
if (enabled == 1) {
val name = ComponentName(applicationContext, T::class.java)
val services = Settings.Secure.getString(contentResolver, Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES)
return services?.contains(name.flattenToString()) ?: false
}
return false
}

Related

How to find commit distance using JGit?

I've a little Kotlin utility class that uses JGit to find the following information:
branch, latestCommit, lastTag, lastTagCommit, lastReleaseTag, lastReleaseTagCommit, commitDistance
where lastReleaseTag is found by matching a given prefix.
All that is working, except for commitDistance, which is the number of commits between the latestCommit and a tag. I'm using RevWalkUtils.count, but it always returns zero.
class GitRepo(dir: File) {
private val log = LoggerFactory.getLogger(GitRepo::class.java)
constructor(dir: String) : this(File(dir))
private val repository = FileRepositoryBuilder()
.setGitDir(File(dir, ".git"))
.readEnvironment()
.findGitDir()
.setMustExist(true)
.build()
#JvmOverloads
fun info(releaseTagPrefix: String = "release/"): RepoInfo {
repository.use { repo ->
RevWalk(repo).use { walk ->
val latestCommit: RevCommit? = Git(repository).use {
try {
it.log().setMaxCount(1).call().iterator().next()
} catch (ex: NoHeadException) {
log.warn("Repository has no HEAD")
null
}
}
val tags = repo.refDatabase.getRefsByPrefix("refs/tags/")
.groupBy { it.name.startsWith("refs/tags/$releaseTagPrefix") }
.mapValues { entry ->
entry.value.maxByOrNull { it.name }
}
val lastReleaseTag = tags[true]
val lastTag = tags[false]
val lastTagCommit = lastTag?.toRevCommit(walk)
val commitDistance = if (latestCommit == null || lastTagCommit == null) 0
else RevWalkUtils.count(walk, latestCommit, lastTagCommit)
return RepoInfo(
repo.branch,
latestCommit?.toObjectId()?.shorten(),
lastTag?.tagName(),
lastTag?.objectId?.shorten(),
lastReleaseTag?.tagName(),
lastReleaseTag?.objectId?.shorten(),
commitDistance
)
}
}
}
private fun ObjectId.shorten(): String {
return name.take(8)
}
private fun Ref.tagName(): String? {
return "refs\\/tags\\/(.*)".toRegex().find(this.name)?.groupValues?.get(1)
}
private fun Ref.toRevCommit(revWalk: RevWalk): RevCommit? {
val id = repository.refDatabase.peel(this)?.peeledObjectId ?: objectId
return try {
revWalk.parseCommit(id)
} catch (ex: MissingObjectException) {
log.warn("Tag: {} points to a non-existing commit", tagName())
null
}
}
}
A command line invocation of git rev-list --count start...end returns 33.
JGit 5.9.0.202009080501-r.
Thanks to #fredrik, it's just a simple matter of swapping the commits in the call to RevWalkUtils.count. However, it turns out that RevWalkUtils.count is returning a greater number than git rev-list --count start...end, perhaps because of this:
count the number of commits that are reachable from start until a commit that is reachable from end is encountered
I ended up changing my implementation as follows:
class GitRepo(dir: File) {
constructor(dir: String) : this(File(dir))
private val log = LoggerFactory.getLogger(GitRepo::class.java)
private val repository = FileRepositoryBuilder()
.setGitDir(File(dir, ".git"))
.readEnvironment()
.findGitDir()
.setMustExist(true)
.build()
#JvmOverloads
fun info(tagPrefix: String = ".*"): RepoInfo {
repository.use { repo ->
val lastTag: Ref? = repo.refDatabase.getRefsByPrefix("refs/tags/")
.filter { it.name.matches("refs/tags/$tagPrefix".toRegex()) }
.maxByOrNull { it.name }
var latestCommit: RevCommit? = null
var lastTagCommit: RevCommit?
var commitDistance = 0
Git(repo).use { git ->
try {
latestCommit = git.log().setMaxCount(1).call().firstOrNull()
lastTagCommit = lastTag?.let {
val id = repo.refDatabase.peel(it)?.peeledObjectId ?: it.objectId
git.log().add(id).call().firstOrNull()
}
if (latestCommit != null && lastTagCommit != null) {
commitDistance = git.log().addRange(lastTagCommit, latestCommit).call().count()
}
} catch (ex: NoHeadException) {
log.warn("Repository has no HEAD")
} catch (ex: MissingObjectException) {
log.warn("Tag: {} points to a non-existing commit: ", lastTag?.tagName(), ex.objectId.shorten())
}
return RepoInfo(
repo.branch,
latestCommit?.toObjectId()?.shorten(),
lastTag?.tagName(),
lastTag?.objectId?.shorten(),
commitDistance
)
}
}
}
private fun ObjectId.shorten(): String {
return name.take(8)
}
private fun Ref.tagName(): String? {
return "refs\\/tags\\/(.*)".toRegex().find(name)?.groupValues?.get(1)
}
}

Programmatically turning on all notifications

I am new to Android development and I can't understand how to properly turn all ble notifications and get all of them.
I've tried to loop through all services
for(BluetoothGattService service : gatt.getServices()){
if( service.getUuid().equals(Step_UUID)) {
BluetoothGattCharacteristic characteristicData = service.getCharacteristic(Step_UUID);
for (BluetoothGattDescriptor descriptor : characteristicData.getDescriptors()) {
descriptor.setValue( BluetoothGattDescriptor.ENABLE_INDICATION_VALUE);
gatt.writeDescriptor(descriptor);
}
gatt.setCharacteristicNotification(characteristicData, true);
}
}
but I don't get any notifications back.
Please, help I do not understand what I am doing wrong..
EDIT
Right now I use this method to enable notifications after services are discovered:
public void setCharacteristicNotification(BluetoothGattCharacteristic characteristic, boolean enabled) {
// Setting default write type according to CDT 222486
characteristic.setWriteType(BluetoothGattCharacteristic.WRITE_TYPE_DEFAULT);
String serviceUUID = characteristic.getService().getUuid().toString();
String serviceName = GattAttributes.lookupUUID(characteristic.getService().getUuid(), serviceUUID);
String characteristicUUID = characteristic.getUuid().toString();
String characteristicName = GattAttributes.lookupUUID(characteristic.getUuid(), characteristicUUID);
String descriptorUUID = GattAttributes.CLIENT_CHARACTERISTIC_CONFIG;
String descriptorName = GattAttributes.lookupUUID(UUIDDatabase.UUID_CLIENT_CHARACTERISTIC_CONFIG, descriptorUUID);
if (characteristic.getDescriptor(UUID.fromString(GattAttributes.CLIENT_CHARACTERISTIC_CONFIG)) != null) {
if (enabled == true) {
BluetoothGattDescriptor descriptor = characteristic.getDescriptor(UUID.fromString(GattAttributes.CLIENT_CHARACTERISTIC_CONFIG));
descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
boolean aaa = mBluetoothGatt.writeDescriptor(descriptor);
aaa = mBluetoothGatt.writeDescriptor(descriptor);
aaa = false;
} else {
BluetoothGattDescriptor descriptor = characteristic.getDescriptor(UUID.fromString(GattAttributes.CLIENT_CHARACTERISTIC_CONFIG));
descriptor.setValue(BluetoothGattDescriptor.DISABLE_NOTIFICATION_VALUE);
mBluetoothGatt.writeDescriptor(descriptor);
}
}
boolean aaaa = mBluetoothGatt.setCharacteristicNotification(characteristic, enabled);
aaaa = false;
}
The problem is that first characteristic notifies well, but all others I am trying to enable fails on the line
mBluetoothGatt.writeDescriptor(descriptor);
Don't know what to do...
My problem was resolved by overiding onDescriptorWrite method. I made a flag inside, and if it is true I continue to notify all left characteristics.
#Override
public void onDescriptorWrite(BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status) {
String serviceUUID = descriptor.getCharacteristic().getService().getUuid().toString();
String serviceName = GattAttributes.lookupUUID(descriptor.getCharacteristic().getService().getUuid(), serviceUUID);
String characteristicUUID = descriptor.getCharacteristic().getUuid().toString();
String characteristicName = GattAttributes.lookupUUID(descriptor.getCharacteristic().getUuid(), characteristicUUID);
String descriptorUUID = descriptor.getUuid().toString();
String descriptorName = GattAttributes.lookupUUID(descriptor.getUuid(), descriptorUUID);
if (status == BluetoothGatt.GATT_SUCCESS) {
written = true;
numberLeft--;
} else {
written = true;
numberLeft--;
}
}

void can not converted to Unit when use kotlin in java code - android

I am working with kotlin and java together in my project, I have a class kotlin like bellow:
class AuthenticationPresenter #Inject constructor(
private val navigator: AuthenticationNavigator,
private val getCurrentServerInteractor: GetCurrentServerInteractor,
private val getAccountInteractor: GetAccountInteractor,
private val settingsRepository: SettingsRepository,
private val localRepository: LocalRepository,
private val tokenRepository: TokenRepository
) {
suspend fun loadCredentials(newServer: Boolean, callback: (authenticated: Boolean) -> Unit) {
val currentServer = getCurrentServerInteractor.get()
val serverToken = currentServer?.let { tokenRepository.get(currentServer) }
val settings = currentServer?.let { settingsRepository.get(currentServer) }
val account = currentServer?.let { getAccountInteractor.get(currentServer) }
account?.let {
localRepository.save(LocalRepository.CURRENT_USERNAME_KEY, account.userName)
}
if (newServer || currentServer == null || serverToken == null || settings == null || account?.userName == null) {
callback(false)
} else {
callback(true)
navigator.toChatList()
}
}
}
I am converting bellow code (kotlin) to java:
presenter.loadCredentials(newServer || deepLinkInfo != null) { authenticated ->
if (!authenticated) {
showServerInput(deepLinkInfo)
}
}
And this is my convert code to java but get me error:
presenter.loadCredentials((newServer || deepLinkInfo != null), authenticated ->{
if (!authenticated) {
showServerInput(deepLinkInfo);
}
});
But say me: Missing return statement
What can I use from this loadCredentials in java code?
Code of showServerInput:
fun showServerInput(deepLinkInfo: LoginDeepLinkInfo?) {
addFragment(TAG_SERVER_FRAGMENT, R.id.fragment_container, allowStateLoss = true) {
ServerFragment.newInstance(deepLinkInfo)
}
}
All the previous answers fail to include the part where you need to return an instance of Unit, once I did that I was able to get a similar issue fixed.
There is a slight issue with the original question in that "AA" cannot be returned and so would throw an error and instead you'd need to call a method.
Here's how to do it in the context of this question.
presenter.loadCredentials((newServer || deepLinkInfo != null), authenticated ->{
if (!authenticated) {
showServerInput(deepLinkInfo); // Here!
} else {
myOtherMethod();
}
return Unit.INSTANCE;
});
You need to return the result of showServerInput:
presenter.loadCredentials((newServer || deepLinkInfo != null), authenticated ->{
if (!authenticated) {
return showServerInput(deepLinkInfo); // Here!
} else {
return "AA";
}
});
Try this
presenter.loadCredentials((newServer || deepLinkInfo != null), authenticated ->{
if (!authenticated) {
showServerInput(deepLinkInfo);
}
});

Google API v3 checking exist folder by passing folder name

I'm using google API v3 for check exist folder. If folder does not exist, then create the new folder. This is my code for creating folder
private void createFolderInDrive() throws IOException {
boolean existed = checkExistedFolder("MyFolder");
if (existed = false) {
File fileMetadata = new File();
fileMetadata.setName("MyFolder");
fileMetadata.setMimeType("application/vnd.google-apps.folder");
File file = mService.files().create(fileMetadata)
.setFields("id")
.execute();
System.out.println("Folder ID: " + file.getId());
Log.e(this.toString(), "Folder Created with ID:" + file.getId());
Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(getApplicationContext(),
"Folder is existed already", Toast.LENGTH_SHORT).show();
}
}
and here is the code for checking exist file
private boolean checkExistedFolder(String folderName) {
//File file = null;
boolean existedFolder = true;
// check if the folder exists already
try {
//String query = "mimeType='application/vnd.google-apps.folder' and trashed=false and title='" + "Evacuation Kit" + "'";
String query = "mimeType='application/vnd.google-apps.folder' and trashed=false and name='Evacuation Kit'";
// add parent param to the query if needed
//if (parentId != null) {
//query = query + " and '" + parentId + "' in parents";
// }
Drive.Files.List request = mService.files().list().setQ(query);
FileList fileList = request.execute();
if (fileList.getFiles().size() == 0 ) {
// file = fileList.getFiles().get(0);
existedFolder = false;
}
} catch (IOException e) {
e.printStackTrace();
}
return existedFolder;
fileList.getFiles().size() keep returning 3, even there is no folder on g drive. Can you guys tell me where am I doing wrong?
In the code you show, checkExistedFolder is always looking for the name "Evacuation Kit" and not using the argument folderName. Maybe this is the main reason you're always getting 3 from fileList.getFiles().size().
Also there's an assignment in if (existed = false), you should use if ( false == existed ) -using the static value in the left side of the comparison helps avoiding such mistakes-, or if (!existed). Note that it's important to check the nextPageToken when calling Files:list to check if there is more pages to look for the file. See more here https://developers.google.com/drive/api/v3/reference/files/list and Create folder if it does not exist in the Google Drive
This code will check if folder exist on drive. if exists, it will return id else create folder and returns id.
private DriveFile file;
GoogleApiClient mGoogleApiClient;
#Override
public void onConnected(#Nullable Bundle bundle) {
Log.e(TAG, "connected");
new Thread(new Runnable() {
#Override
public void run() {
DriveId Id = getFolder(Drive.DriveApi.getRootFolder(mGoogleApiClient).getDriveId(), "FOLDER_NAME");
Log.e(TAG, "run: " + Id);
}
}).start();
}
DriveId getFolder(DriveId parentId, String titl) {
DriveId dId = null;
if (parentId != null && titl != null) try {
ArrayList<Filter> fltrs = new ArrayList<>();
fltrs.add(Filters.in(SearchableField.PARENTS, parentId));
fltrs.add(Filters.eq(SearchableField.TITLE, titl));
fltrs.add(Filters.eq(SearchableField.MIME_TYPE, DriveFolder.MIME_TYPE));
Query qry = new Query.Builder().addFilter(Filters.and(fltrs)).build();
MetadataBuffer mdb = null;
DriveApi.MetadataBufferResult rslt = Drive.DriveApi.query(mGoogleApiClient, qry).await();
if (rslt.getStatus().isSuccess()) try {
mdb = rslt.getMetadataBuffer();
if (mdb.getCount() > 0)
dId = mdb.get(0).getDriveId();
} catch (Exception ignore) {
} finally {
if (mdb != null) mdb.close();
}
if (dId == null) {
MetadataChangeSet meta = new MetadataChangeSet.Builder().setTitle(titl).setMimeType(DriveFolder.MIME_TYPE).build();
DriveFolder.DriveFolderResult r1 = parentId.asDriveFolder().createFolder(mGoogleApiClient, meta).await();
DriveFolder dFld = (r1 != null) && r1.getStatus().isSuccess() ? r1.getDriveFolder() : null;
if (dFld != null) {
DriveResource.MetadataResult r2 = dFld.getMetadata(mGoogleApiClient).await();
if ((r2 != null) && r2.getStatus().isSuccess()) {
dId = r2.getMetadata().getDriveId();
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return dId;
}
The code working for me with updated API on Kotlin:
override fun createFolder(name: String): Task<GoogleDriveFileHolder> {
check(googleDriveService != null) { "You have to init Google Drive Service first!" }
check(search(name, FOLDER_MIME_TYPE).not()){"folder already exist"}
return Tasks.call<GoogleDriveFileHolder>(
mExecutor,
Callable<GoogleDriveFileHolder> {
val metadata = File()
.setMimeType(FOLDER_MIME_TYPE)
.setName(name)
GoogleDriveFileHolder(
googleDriveService!!.files()
.create(metadata)
.setFields("id")
.execute() ?: throw IOException("Null result when requesting file creation.")
)
})
}
private fun search(name: String, mimeType:String): Boolean {
var pageToken: String? = null
do {
val result: FileList =
googleDriveService!!
.files()
.list()
.setQ("mimeType='$FOLDER_MIME_TYPE'")
.setSpaces("drive")
.setFields("nextPageToken, files(id, name)")
.setPageToken(pageToken)
.execute()
for (file in result.files) {
Log.d(TAG_UPLOAD_FILE , "Found file: %s (%s)\n ${file.name}, ${file.id} ")
if (name == file.name) return true
}
pageToken = result.nextPageToken
} while (pageToken != null)
return false
}
private const val FOLDER_MIME_TYPE= "application/vnd.google-apps.folder"

How to reliably detect device type on a MediaRoute select/unselect event

I have dug into the Android sources and found that under the hood, each time an Audio route event occurs, an AudioRoutesInfo object is based to the internal updateAudioRoutes method in MediaRouter:
void updateAudioRoutes(AudioRoutesInfo newRoutes) {
if (newRoutes.mMainType != mCurAudioRoutesInfo.mMainType) {
mCurAudioRoutesInfo.mMainType = newRoutes.mMainType;
int name;
if ((newRoutes.mMainType&AudioRoutesInfo.MAIN_HEADPHONES) != 0
|| (newRoutes.mMainType&AudioRoutesInfo.MAIN_HEADSET) != 0) {
name = com.android.internal.R.string.default_audio_route_name_headphones;
} else if ((newRoutes.mMainType&AudioRoutesInfo.MAIN_DOCK_SPEAKERS) != 0) {
name = com.android.internal.R.string.default_audio_route_name_dock_speakers;
} else if ((newRoutes.mMainType&AudioRoutesInfo.MAIN_HDMI) != 0) {
name = com.android.internal.R.string.default_media_route_name_hdmi;
} else {
name = com.android.internal.R.string.default_audio_route_name;
}
sStatic.mDefaultAudioVideo.mNameResId = name;
dispatchRouteChanged(sStatic.mDefaultAudioVideo);
}
final int mainType = mCurAudioRoutesInfo.mMainType;
boolean a2dpEnabled;
try {
a2dpEnabled = mAudioService.isBluetoothA2dpOn();
} catch (RemoteException e) {
Log.e(TAG, "Error querying Bluetooth A2DP state", e);
a2dpEnabled = false;
}
if (!TextUtils.equals(newRoutes.mBluetoothName, mCurAudioRoutesInfo.mBluetoothName)) {
mCurAudioRoutesInfo.mBluetoothName = newRoutes.mBluetoothName;
if (mCurAudioRoutesInfo.mBluetoothName != null) {
if (sStatic.mBluetoothA2dpRoute == null) {
final RouteInfo info = new RouteInfo(sStatic.mSystemCategory);
info.mName = mCurAudioRoutesInfo.mBluetoothName;
info.mDescription = sStatic.mResources.getText(
com.android.internal.R.string.bluetooth_a2dp_audio_route_name);
info.mSupportedTypes = ROUTE_TYPE_LIVE_AUDIO;
sStatic.mBluetoothA2dpRoute = info;
addRouteStatic(sStatic.mBluetoothA2dpRoute);
} else {
sStatic.mBluetoothA2dpRoute.mName = mCurAudioRoutesInfo.mBluetoothName;
dispatchRouteChanged(sStatic.mBluetoothA2dpRoute);
}
} else if (sStatic.mBluetoothA2dpRoute != null) {
removeRouteStatic(sStatic.mBluetoothA2dpRoute);
sStatic.mBluetoothA2dpRoute = null;
}
}
if (mBluetoothA2dpRoute != null) {
if (mainType != AudioRoutesInfo.MAIN_SPEAKER &&
mSelectedRoute == mBluetoothA2dpRoute && !a2dpEnabled) {
selectRouteStatic(ROUTE_TYPE_LIVE_AUDIO, mDefaultAudioVideo, false);
} else if ((mSelectedRoute == mDefaultAudioVideo || mSelectedRoute == null) &&
a2dpEnabled) {
selectRouteStatic(ROUTE_TYPE_LIVE_AUDIO, mBluetoothA2dpRoute, false);
}
}
}
Unfortunately, the only thing I have found that is exposed about the device type in the MediaRouter callbacks, is the internal string resource name of the device (e.g. Phone or Headphones). However, you can see that under the hood, this AudioRoutesInfo object has references to whether the device was a headphone, HDMI etc.
Has anyone found a solution to get at this information? The best way I have found is to use the internal resource names, which is pretty ugly. God, if they would just provide the AudioRoutesInfo object all this information could be accessed without having to rely on a resource hack.

Categories