Commit 960d18d7 authored by shadowsocksRb's avatar shadowsocksRb Committed by Mygod

Add permission for receiver (#2334)

Also removes an overly conservative check.
parent 5da2fef6
......@@ -3,6 +3,11 @@
package="com.github.shadowsocks.core"
android:installLocation="internalOnly">
<permission
android:name="${applicationId}.SERVICE"
android:protectionLevel="signature" />
<uses-permission android:name="${applicationId}.SERVICE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
......
......@@ -148,6 +148,6 @@ object Core {
else @Suppress("DEPRECATION") PackageManager.GET_SIGNATURES)!!
fun startService() = ContextCompat.startForegroundService(app, Intent(app, ShadowsocksConnection.serviceClass))
fun reloadService() = app.sendBroadcast(Intent(Action.RELOAD))
fun stopService() = app.sendBroadcast(Intent(Action.CLOSE))
fun reloadService() = app.sendBroadcast(Intent(Action.RELOAD).setPackage(app.packageName))
fun stopService() = app.sendBroadcast(Intent(Action.CLOSE).setPackage(app.packageName))
}
......@@ -331,7 +331,7 @@ object BaseService {
addAction(Action.RELOAD)
addAction(Intent.ACTION_SHUTDOWN)
addAction(Action.CLOSE)
})
}, "$packageName.SERVICE", null)
data.closeReceiverRegistered = true
}
......
......@@ -102,7 +102,6 @@ fun broadcastReceiver(callback: (Context, Intent) -> Unit): BroadcastReceiver =
fun Context.listenForPackageChanges(onetime: Boolean = true, callback: () -> Unit) = object : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
if (intent.getBooleanExtra(Intent.EXTRA_REPLACING, false)) return
callback()
if (onetime) context.unregisterReceiver(this)
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment