Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
classpath 'com.android.tools.build:gradle:8.6.0'
}
}

Expand All @@ -23,7 +23,7 @@ apply plugin: 'com.android.library'

android {
namespace 'com.browserstack.fluttersystemproxy.flutter_system_proxy'
compileSdkVersion 30
compileSdkVersion 35

defaultConfig {
minSdkVersion 16
Expand Down
6 changes: 3 additions & 3 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 31

compileSdkVersion 35
namespace "com.browserstack.fluttersystemproxy.flutter_system_proxy_example"
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.browserstack.fluttersystemproxy.flutter_system_proxy_example"
minSdkVersion 16
minSdkVersion flutter.minSdkVersion
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
Expand Down
4 changes: 2 additions & 2 deletions example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
classpath 'com.android.tools.build:gradle:8.6.0'
}
}

Expand All @@ -22,6 +22,6 @@ subprojects {
project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
37 changes: 20 additions & 17 deletions ios/Classes/SwiftFlutterSystemProxyPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,26 +41,20 @@ public class SwiftFlutterSystemProxyPlugin: NSObject, FlutterPlugin {
if(SwiftFlutterSystemProxyPlugin.proxyCache[url] != nil){
return SwiftFlutterSystemProxyPlugin.proxyCache[url]
}
let proxConfigDict = CFNetworkCopySystemProxySettings()?.takeUnretainedValue() as NSDictionary?
if(proxConfigDict != nil){
if(proxConfigDict!["ProxyAutoConfigEnable"] as? Int == 1){
let pacUrl = proxConfigDict!["ProxyAutoConfigURLString"] as? String
let pacContent = proxConfigDict!["ProxyAutoConfigJavaScript"] as? String
let proxConfigDict = CFNetworkCopySystemProxySettings()?.takeUnretainedValue() as NSDictionary?
if proxConfigDict != nil {
if(proxConfigDict?[kCFNetworkProxiesProxyAutoConfigEnable] as? Int == 1){
let pacUrl = proxConfigDict?[kCFNetworkProxiesProxyAutoConfigURLString] as! String?
let pacContent = proxConfigDict?[kCFNetworkProxiesProxyAutoConfigJavaScript] as! String?
if(pacContent != nil){
self.handlePacContent(pacContent: pacContent! as String, url: url)
self.handlePacContent(pacContent: pacContent!, url: url)
}else if(pacUrl != nil){
self.handlePacUrl(pacUrl: pacUrl!,url: url)
}
} else if (proxConfigDict!["HTTPEnable"] as? Int == 1){
} else if (proxConfigDict![kCFNetworkProxiesHTTPEnable] as? Int == 1){
var dict: [String: Any] = [:]
dict["host"] = proxConfigDict!["HTTPProxy"] as? String
dict["port"] = proxConfigDict!["HTTPPort"] as? Int
SwiftFlutterSystemProxyPlugin.proxyCache[url] = dict

} else if ( proxConfigDict!["HTTPSEnable"] as? Int == 1){
var dict: [String: Any] = [:]
dict["host"] = proxConfigDict!["HTTPSProxy"] as? String
dict["port"] = proxConfigDict!["HTTPSPort"] as? Int
dict["host"] = proxConfigDict![kCFNetworkProxiesHTTPProxy] as? String
dict["port"] = proxConfigDict![kCFNetworkProxiesHTTPPort] as? Int
SwiftFlutterSystemProxyPlugin.proxyCache[url] = dict
}
}
Expand Down Expand Up @@ -105,11 +99,20 @@ public class SwiftFlutterSystemProxyPlugin: NSObject, FlutterPlugin {
CFRunLoopStop(CFRunLoopGetCurrent());
}, &context);
let runLoop = CFRunLoopGetCurrent();
CFRunLoopAddSource(runLoop, runLoopSource, CFRunLoopMode.defaultMode);
CFRunLoopAddSource(runLoop, getRunLoopSource(runLoopSource), CFRunLoopMode.defaultMode);
CFRunLoopRun();
CFRunLoopRemoveSource(CFRunLoopGetCurrent(), runLoopSource, CFRunLoopMode.defaultMode);
CFRunLoopRemoveSource(CFRunLoopGetCurrent(), getRunLoopSource(runLoopSource), CFRunLoopMode.defaultMode);
})
}

//For backward compatibility <= XCode 15
static func getRunLoopSource<T>(_ runLoopSource: T) -> CFRunLoopSource {
if let unmanagedValue = runLoopSource as? Unmanaged<CFRunLoopSource> {
return unmanagedValue.takeUnretainedValue()
} else {
return runLoopSource as! CFRunLoopSource
}
}

}

2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flutter_system_proxy
description: A Flutter Plugin to detect System proxy. When using HTTP client that are not proxy aware this plugin can help with finding the proxy from system settings which then can be used with HTTP Client to make a successful request.
version: 0.1.4
version: 0.1.5
homepage: https://github.com/BrowserStackCE/flutter_system_proxy.git

environment:
Expand Down