Created
February 16, 2022 09:27
-
-
Save orllewin/71d66bd2a9d16a64235d0b5529ac8f87 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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