Skip to content

Commit

Permalink
Remove unused code.
Browse files Browse the repository at this point in the history
  • Loading branch information
akwizgran committed Sep 8, 2023
1 parent 0df88c0 commit 73d3980
Showing 1 changed file with 1 addition and 15 deletions.
16 changes: 1 addition & 15 deletions app/src/main/java/org/onionshare/android/OnionShareApp.kt
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
package org.onionshare.android

import android.app.Activity
import android.app.ActivityManager
import android.app.Application
import android.app.Application.ActivityLifecycleCallbacks
import android.content.Intent.FLAG_GRANT_READ_URI_PERMISSION
import android.content.UriPermission
import android.os.Build.VERSION.SDK_INT
import android.os.Bundle
import android.os.Process
import android.os.StrictMode
import android.os.StrictMode.ThreadPolicy
import android.os.StrictMode.VmPolicy
Expand All @@ -27,23 +24,12 @@ class OnionShareApp @Inject constructor() : Application(), ActivityLifecycleCall
if (BuildConfig.DEBUG) enableStrictMode()
super.onCreate()
registerActivityLifecycleCallbacks(this)
if (!isTorProcess()) releaseUriPermissions()
releaseUriPermissions()
// Route java.util.logging through Logback
SLF4JBridgeHandler.removeHandlersForRootLogger()
SLF4JBridgeHandler.install()
}

private fun isTorProcess(): Boolean {
val processName = if (SDK_INT >= 28) {
getProcessName()
} else {
val pid = Process.myPid()
val manager = getSystemService(ACTIVITY_SERVICE) as ActivityManager
manager.runningAppProcesses?.firstOrNull { it.pid == pid }?.processName ?: return false
}
return processName.endsWith(":tor")
}

/**
* There's a limit to how many persistable [UriPermission]s we can hold.
* At each app start, we release the ones that we may still hold from last time.
Expand Down

0 comments on commit 73d3980

Please sign in to comment.