Skip to content

Instantly share code, notes, and snippets.

@orllewin
Created February 16, 2022 09:27
Show Gist options
  • Select an option

  • Save orllewin/71d66bd2a9d16a64235d0b5529ac8f87 to your computer and use it in GitHub Desktop.

Select an option

Save orllewin/71d66bd2a9d16a64235d0b5529ac8f87 to your computer and use it in GitHub Desktop.
package orllewin.osname
import android.content.Context
import android.content.pm.PackageManager
/**
* Don't forget to add the packages to the manifest.xml:
<manifest xmlns:android="http://schemas.android.com/apk/res/android" ... >
<queries>
<package android:name="app.grapheneos.camera" />
<package android:name="org.grapheneos.pdfviewer" />
<package android:name="app.grapheneos.gmscompat" />
</queries>
<application ...
*/
class Graphene(private val context: Context){
fun isGraphene(): Boolean {
return packageInstalled("app.grapheneos.camera") &&
packageInstalled("org.grapheneos.pdfviewer") &&
packageInstalled("app.grapheneos.gmscompat")
}
private fun packageInstalled(packageName: String): Boolean{
return try{
context.packageManager.getPackageInfo(packageName, PackageManager.GET_META_DATA)
true
}catch (e: PackageManager.NameNotFoundException){
false
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment