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
21 changes: 9 additions & 12 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
plugins {
id "com.android.application"
id "kotlin-android"
id "dev.flutter.flutter-gradle-plugin"
}
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
Expand All @@ -6,11 +11,6 @@ if (localPropertiesFile.exists()) {
}
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
Expand All @@ -21,17 +21,14 @@ if (flutterVersionName == null) {
flutterVersionName = '1.0'
}

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
targetSdkVersion 30
minSdkVersion flutter.minSdkVersion
targetSdkVersion 33
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
Expand Down
3 changes: 2 additions & 1 deletion example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
android:windowSoftInputMode="adjustResize"
android:exported="false">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
Expand Down
13 changes: 1 addition & 12 deletions example/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
buildscript {
repositories {
google()
jcenter()
}

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

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

task clean(type: Delete) {
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
29 changes: 21 additions & 8 deletions example/android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
include ':app'
pluginManagement {
def flutterSdkPath = {
def properties = new Properties()
file("local.properties").withInputStream { properties.load(it) }
def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
return flutterSdkPath
}()

def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
def properties = new Properties()
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")

assert localPropertiesFile.exists()
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}

def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "8.6.0" apply false
id "org.jetbrains.kotlin.android" version "1.9.22" apply false
}
include ':app'
35 changes: 19 additions & 16 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);
})
}

//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