From 07e8afa69a428a3928e38e9ed3bde6ee4ea69bb4 Mon Sep 17 00:00:00 2001 From: kr328 Date: Sat, 15 May 2021 00:51:08 +0800 Subject: [PATCH] Initial: initial commit --- .github/ISSUE_TEMPLATE/01-bug-report-en.md | 57 ++ .../ISSUE_TEMPLATE/02-feature-request-en.md | 24 + .github/ISSUE_TEMPLATE/03-bug-report-zh-cn.md | 55 ++ .../04-feature-request-zh-cn.md | 21 + .github/ISSUE_TEMPLATE/config.yml | 1 + .gitignore | 53 ++ .gitmodules | 3 + .idea/codeStyles/Project.xml | 151 ++++ .idea/codeStyles/codeStyleConfig.xml | 5 + CONTRIBUTING.md | 14 + LICENSE | 674 ++++++++++++++ NOTICE | 833 ++++++++++++++++++ PRIVACY_POLICY.md | 50 ++ README.md | 63 ++ app/build.gradle.kts | 136 +++ app/proguard-rules.pro | 33 + app/src/main/AndroidManifest.xml | 179 ++++ app/src/main/ic_launcher-web.png | Bin 0 -> 16852 bytes .../kr328/clash/AccessControlActivity.kt | 142 +++ .../github/kr328/clash/ApkBrokenActivity.kt | 20 + .../github/kr328/clash/AppCrashedActivity.kt | 46 + .../github/kr328/clash/AppSettingsActivity.kt | 62 ++ .../com/github/kr328/clash/BaseActivity.kt | 249 ++++++ .../kr328/clash/ExternalImportActivity.kt | 44 + .../com/github/kr328/clash/FilesActivity.kt | 160 ++++ .../com/github/kr328/clash/HelpActivity.kt | 19 + .../com/github/kr328/clash/LogcatActivity.kt | 185 ++++ .../com/github/kr328/clash/LogcatService.kt | 169 ++++ .../com/github/kr328/clash/LogsActivity.kt | 71 ++ .../com/github/kr328/clash/MainActivity.kt | 151 ++++ .../com/github/kr328/clash/MainApplication.kt | 44 + .../kr328/clash/NetworkSettingsActivity.kt | 39 + .../github/kr328/clash/NewProfileActivity.kt | 143 +++ .../kr328/clash/OverrideSettingsActivity.kt | 89 ++ .../github/kr328/clash/ProfilesActivity.kt | 77 ++ .../github/kr328/clash/PropertiesActivity.kt | 114 +++ .../github/kr328/clash/ProvidersActivity.kt | 71 ++ .../com/github/kr328/clash/ProxyActivity.kt | 133 +++ .../com/github/kr328/clash/RestartReceiver.kt | 18 + .../github/kr328/clash/SettingsActivity.kt | 32 + .../com/github/kr328/clash/TileService.kt | 104 +++ .../com/github/kr328/clash/log/LogcatCache.kt | 52 ++ .../github/kr328/clash/log/LogcatFilter.kt | 25 + .../github/kr328/clash/log/LogcatReader.kt | 32 + .../github/kr328/clash/log/LogcatWriter.kt | 25 + .../github/kr328/clash/log/SystemLogcat.kt | 31 + .../github/kr328/clash/remote/Broadcasts.kt | 103 +++ .../github/kr328/clash/remote/FilesClient.kt | 94 ++ .../com/github/kr328/clash/remote/Remote.kt | 72 ++ .../com/github/kr328/clash/remote/Resource.kt | 74 ++ .../com/github/kr328/clash/remote/Services.kt | 88 ++ .../github/kr328/clash/remote/StatusClient.kt | 34 + .../com/github/kr328/clash/store/AppStore.kt | 22 + .../com/github/kr328/clash/store/TipsStore.kt | 29 + .../com/github/kr328/clash/util/Activity.kt | 44 + .../github/kr328/clash/util/Application.kt | 78 ++ .../java/com/github/kr328/clash/util/Clash.kt | 32 + .../com/github/kr328/clash/util/Content.kt | 25 + .../java/com/github/kr328/clash/util/Files.kt | 7 + .../com/github/kr328/clash/util/Remote.kt | 44 + .../com/github/kr328/clash/util/Service.kt | 12 + .../java/com/github/kr328/clash/util/Uri.kt | 6 + .../res/drawable/ic_launcher_foreground.xml | 15 + .../res/mipmap-anydpi-v26/ic_launcher.xml | 5 + .../mipmap-anydpi-v26/ic_launcher_round.xml | 5 + app/src/main/res/mipmap-hdpi/ic_launcher.png | Bin 0 -> 1778 bytes .../res/mipmap-hdpi/ic_launcher_round.png | Bin 0 -> 3625 bytes app/src/main/res/mipmap-mdpi/ic_launcher.png | Bin 0 -> 1227 bytes .../res/mipmap-mdpi/ic_launcher_round.png | Bin 0 -> 2309 bytes app/src/main/res/mipmap-xhdpi/ic_banner.png | Bin 0 -> 6383 bytes app/src/main/res/mipmap-xhdpi/ic_launcher.png | Bin 0 -> 2425 bytes .../res/mipmap-xhdpi/ic_launcher_round.png | Bin 0 -> 5102 bytes .../main/res/mipmap-xxhdpi/ic_launcher.png | Bin 0 -> 3666 bytes .../res/mipmap-xxhdpi/ic_launcher_round.png | Bin 0 -> 8014 bytes .../main/res/mipmap-xxxhdpi/ic_launcher.png | Bin 0 -> 5123 bytes .../res/mipmap-xxxhdpi/ic_launcher_round.png | Bin 0 -> 11563 bytes app/src/main/res/values-night/themes.xml | 4 + app/src/main/res/values/colors.xml | 4 + app/src/main/res/values/ids.xml | 4 + app/src/main/res/values/themes.xml | 4 + app/src/main/res/xml/full_backup_content.xml | 18 + .../main/res/xml/network_security_config.xml | 10 + build.gradle.kts | 16 + buildSrc/build.gradle.kts | 35 + buildSrc/src/main/java/Build.kt | 17 + buildSrc/src/main/java/Dependencies.kt | 14 + buildSrc/src/main/java/Files.kt | 8 + buildSrc/src/main/java/GolangBuildTask.kt | 119 +++ buildSrc/src/main/java/LibraryGolangPlugin.kt | 69 ++ common/build.gradle.kts | 47 + common/consumer-rules.pro | 0 common/proguard-rules.pro | 21 + common/src/main/AndroidManifest.xml | 10 + .../com/github/kr328/clash/common/Global.kt | 14 + .../github/kr328/clash/common/compat/App.kt | 20 + .../kr328/clash/common/compat/Context.kt | 22 + .../github/kr328/clash/common/compat/Html.kt | 15 + .../kr328/clash/common/compat/Intents.kt | 12 + .../kr328/clash/common/compat/Package.kt | 14 + .../kr328/clash/common/compat/Resource.kt | 16 + .../kr328/clash/common/compat/Services.kt | 13 + .../github/kr328/clash/common/compat/UI.kt | 126 +++ .../github/kr328/clash/common/compat/View.kt | 17 + .../clash/common/constants/Authorities.kt | 9 + .../clash/common/constants/Components.kt | 9 + .../kr328/clash/common/constants/Intents.kt | 24 + .../kr328/clash/common/constants/Metadata.kt | 7 + .../clash/common/constants/Permissions.kt | 7 + .../kr328/clash/common/id/UndefinedIds.kt | 15 + .../com/github/kr328/clash/common/log/Log.kt | 23 + .../kr328/clash/common/store/Providers.kt | 60 ++ .../github/kr328/clash/common/store/Store.kt | 98 +++ .../kr328/clash/common/store/StoreProvider.kt | 18 + .../kr328/clash/common/util/Components.kt | 12 + .../github/kr328/clash/common/util/Global.kt | 5 + .../github/kr328/clash/common/util/Intent.kt | 47 + .../kr328/clash/common/util/Parcelable.kt | 89 ++ .../kr328/clash/common/util/Patterns.kt | 3 + .../github/kr328/clash/common/util/Ticker.kt | 25 + common/src/main/res/values-zh/strings.xml | 5 + common/src/main/res/values/strings.xml | 5 + core/build.gradle.kts | 134 +++ core/consumer-rules.pro | 18 + core/proguard-rules.pro | 21 + core/src/main/AndroidManifest.xml | 5 + core/src/main/cpp/CMakeLists.txt | 23 + core/src/main/cpp/bridge_helper.c | 12 + core/src/main/cpp/bridge_helper.h | 5 + core/src/main/cpp/jni_helper.c | 75 ++ core/src/main/cpp/jni_helper.h | 32 + core/src/main/cpp/main.c | 528 +++++++++++ .../main/golang/.idea/codeStyles/Project.xml | 11 + .../.idea/codeStyles/codeStyleConfig.xml | 5 + core/src/main/golang/app.go | 55 ++ core/src/main/golang/app/app.go | 48 + core/src/main/golang/app/content.go | 27 + core/src/main/golang/app/dns.go | 15 + core/src/main/golang/app/tun.go | 46 + core/src/main/golang/app/ui.go | 34 + core/src/main/golang/bridge.c | 115 +++ core/src/main/golang/bridge.h | 53 ++ core/src/main/golang/clash | 1 + core/src/main/golang/common/path.go | 23 + core/src/main/golang/config.go | 62 ++ core/src/main/golang/config/defaults.go | 27 + core/src/main/golang/config/fetch.go | 182 ++++ core/src/main/golang/config/load.go | 102 +++ core/src/main/golang/config/override.go | 68 ++ core/src/main/golang/config/process.go | 108 +++ core/src/main/golang/config/provider_open.go | 22 + .../main/golang/config/provider_premium.go | 32 + core/src/main/golang/core/init.go | 74 ++ core/src/main/golang/debug.go | 18 + core/src/main/golang/go.mod | 18 + core/src/main/golang/go.sum | 60 ++ core/src/main/golang/log.go | 79 ++ core/src/main/golang/main.go | 50 ++ core/src/main/golang/platform/limit.go | 42 + core/src/main/golang/platform/procfs.go | 163 ++++ core/src/main/golang/proxy.go | 23 + core/src/main/golang/proxy/http.go | 108 +++ core/src/main/golang/trace.c | 9 + core/src/main/golang/trace.h | 19 + core/src/main/golang/tun.go | 83 ++ core/src/main/golang/tun/dns.go | 101 +++ core/src/main/golang/tun/log.go | 21 + core/src/main/golang/tun/tcp.go | 40 + core/src/main/golang/tun/tun.go | 84 ++ core/src/main/golang/tun/udp.go | 76 ++ core/src/main/golang/tunnel.go | 124 +++ core/src/main/golang/tunnel/conn.go | 28 + core/src/main/golang/tunnel/connectivity.go | 50 ++ core/src/main/golang/tunnel/geoip.go | 26 + core/src/main/golang/tunnel/providers.go | 63 ++ .../main/golang/tunnel/providers_premium.go | 91 ++ core/src/main/golang/tunnel/proxies.go | 195 ++++ core/src/main/golang/tunnel/state.go | 9 + core/src/main/golang/tunnel/statistic.go | 17 + core/src/main/golang/tunnel/suspend.go | 7 + core/src/main/golang/utils.go | 32 + .../java/com/github/kr328/clash/core/Clash.kt | 228 +++++ .../github/kr328/clash/core/bridge/Bridge.kt | 75 ++ .../kr328/clash/core/bridge/ClashException.kt | 6 + .../github/kr328/clash/core/bridge/Content.kt | 21 + .../kr328/clash/core/bridge/FetchCallback.kt | 9 + .../clash/core/bridge/LogcatInterface.kt | 8 + .../kr328/clash/core/bridge/TunInterface.kt | 9 + .../clash/core/model/ConfigurationOverride.kt | 133 +++ .../kr328/clash/core/model/FetchStatus.kt | 38 + .../kr328/clash/core/model/LogMessage.kt | 56 ++ .../github/kr328/clash/core/model/Provider.kt | 44 + .../kr328/clash/core/model/ProviderList.kt | 28 + .../github/kr328/clash/core/model/Proxy.kt | 55 ++ .../kr328/clash/core/model/ProxyGroup.kt | 62 ++ .../kr328/clash/core/model/ProxySort.kt | 5 + .../github/kr328/clash/core/model/Traffic.kt | 3 + .../kr328/clash/core/model/TunnelState.kt | 45 + .../kr328/clash/core/model/UiConfiguration.kt | 27 + .../com/github/kr328/clash/core/util/Net.kt | 11 + .../kr328/clash/core/util/Parcelizer.kt | 258 ++++++ .../kr328/clash/core/util/Serializers.kt | 22 + .../github/kr328/clash/core/util/Traffic.kt | 54 ++ design/build.gradle.kts | 67 ++ design/consumer-rules.pro | 0 design/proguard-rules.pro | 21 + design/src/main/AndroidManifest.xml | 1 + .../kr328/clash/design/AccessControlDesign.kt | 134 +++ .../kr328/clash/design/ApkBrokenDesign.kt | 57 ++ .../kr328/clash/design/AppCrashedDesign.kt | 29 + .../kr328/clash/design/AppSettingsDesign.kt | 82 ++ .../com/github/kr328/clash/design/Design.kt | 59 ++ .../github/kr328/clash/design/FilesDesign.kt | 123 +++ .../github/kr328/clash/design/HelpDesign.kt | 84 ++ .../github/kr328/clash/design/LogcatDesign.kt | 70 ++ .../github/kr328/clash/design/LogsDesign.kt | 57 ++ .../github/kr328/clash/design/MainDesign.kt | 102 +++ .../clash/design/NetworkSettingsDesign.kt | 124 +++ .../kr328/clash/design/NewProfileDesign.kt | 51 ++ .../kr328/clash/design/ProfilesDesign.kt | 121 +++ .../kr328/clash/design/PropertiesDesign.kt | 172 ++++ .../kr328/clash/design/ProvidersDesign.kt | 62 ++ .../github/kr328/clash/design/ProxyDesign.kt | 194 ++++ .../kr328/clash/design/SettingsDesign.kt | 33 + .../kr328/clash/design/adapter/AppAdapter.kt | 49 ++ .../design/adapter/EditableTextListAdapter.kt | 49 ++ .../design/adapter/EditableTextMapAdapter.kt | 51 ++ .../kr328/clash/design/adapter/FileAdapter.kt | 53 ++ .../clash/design/adapter/LogFileAdapter.kt | 38 + .../clash/design/adapter/LogMessageAdapter.kt | 40 + .../clash/design/adapter/PopupListAdapter.kt | 59 ++ .../clash/design/adapter/ProfileAdapter.kt | 53 ++ .../design/adapter/ProfileProviderAdapter.kt | 48 + .../clash/design/adapter/ProviderAdapter.kt | 68 ++ .../clash/design/adapter/ProxyAdapter.kt | 44 + .../clash/design/adapter/ProxyPageAdapter.kt | 112 +++ .../design/adapter/SideloadProviderAdapter.kt | 48 + .../design/component/AccessControlMenu.kt | 97 ++ .../design/component/ProxyPageFactory.kt | 56 ++ .../kr328/clash/design/component/ProxyView.kt | 195 ++++ .../clash/design/component/ProxyViewConfig.kt | 37 + .../clash/design/component/ProxyViewState.kt | 127 +++ .../kr328/clash/design/dialog/Dialogs.kt | 94 ++ .../github/kr328/clash/design/dialog/Input.kt | 96 ++ .../kr328/clash/design/dialog/Progress.kt | 65 ++ .../kr328/clash/design/model/AppInfo.kt | 11 + .../kr328/clash/design/model/AppInfoSort.kt | 8 + .../kr328/clash/design/model/Behavior.kt | 5 + .../kr328/clash/design/model/DarkMode.kt | 5 + .../github/kr328/clash/design/model/File.kt | 9 + .../kr328/clash/design/model/LogFile.kt | 23 + .../clash/design/model/ProfileProvider.kt | 38 + .../kr328/clash/design/model/ProviderState.kt | 28 + .../clash/design/model/ProxyPageState.kt | 6 + .../kr328/clash/design/model/ProxyState.kt | 3 + .../kr328/clash/design/preference/Category.kt | 25 + .../clash/design/preference/Clickable.kt | 73 ++ .../clash/design/preference/EditableText.kt | 82 ++ .../design/preference/EditableTextList.kt | 110 +++ .../design/preference/EditableTextMap.kt | 149 ++++ .../kr328/clash/design/preference/Overlay.kt | 72 ++ .../clash/design/preference/Preference.kt | 20 + .../kr328/clash/design/preference/Screen.kt | 38 + .../clash/design/preference/SelectableList.kt | 96 ++ .../kr328/clash/design/preference/Switch.kt | 101 +++ .../kr328/clash/design/preference/Tips.kt | 42 + .../kr328/clash/design/preference/Value.kt | 49 ++ .../kr328/clash/design/store/UiStore.kt | 68 ++ .../github/kr328/clash/design/ui/DayNight.kt | 5 + .../github/kr328/clash/design/ui/Insets.kt | 7 + .../clash/design/ui/ObservableCurrentTime.kt | 19 + .../github/kr328/clash/design/ui/Surface.kt | 15 + .../kr328/clash/design/ui/ToastDuration.kt | 5 + .../kr328/clash/design/util/ActivityBar.kt | 21 + .../com/github/kr328/clash/design/util/App.kt | 15 + .../github/kr328/clash/design/util/Binding.kt | 9 + .../github/kr328/clash/design/util/Context.kt | 33 + .../github/kr328/clash/design/util/Diff.kt | 29 + .../kr328/clash/design/util/Elevation.kt | 59 ++ .../github/kr328/clash/design/util/I18n.kt | 68 ++ .../github/kr328/clash/design/util/Inserts.kt | 35 + .../kr328/clash/design/util/Interval.kt | 18 + .../kr328/clash/design/util/Landscape.kt | 23 + .../kr328/clash/design/util/ListView.kt | 37 + .../kr328/clash/design/util/RecyclerView.kt | 124 +++ .../kr328/clash/design/util/ScrollView.kt | 6 + .../github/kr328/clash/design/util/Theme.kt | 77 ++ .../github/kr328/clash/design/util/Toast.kt | 23 + .../kr328/clash/design/util/Validator.kt | 25 + .../github/kr328/clash/design/util/View.kt | 16 + .../kr328/clash/design/view/ActionLabel.kt | 62 ++ .../clash/design/view/ActionTextField.kt | 87 ++ .../clash/design/view/ActivityBarLayout.kt | 28 + .../clash/design/view/AppRecyclerView.kt | 25 + .../clash/design/view/LargeActionCard.kt | 65 ++ .../clash/design/view/LargeActionLabel.kt | 75 ++ .../clash/design/view/ObservableScrollView.kt | 32 + .../design/view/VerticalScrollableHost.kt | 41 + .../src/main/res/drawable/bg_bottom_sheet.xml | 22 + .../src/main/res/drawable/ic_baseline_adb.xml | 10 + .../src/main/res/drawable/ic_baseline_add.xml | 10 + .../main/res/drawable/ic_baseline_apps.xml | 10 + .../res/drawable/ic_baseline_arrow_back.xml | 10 + .../res/drawable/ic_baseline_assignment.xml | 10 + .../res/drawable/ic_baseline_attach_file.xml | 10 + .../res/drawable/ic_baseline_brightness_4.xml | 10 + .../res/drawable/ic_baseline_clear_all.xml | 10 + .../main/res/drawable/ic_baseline_close.xml | 10 + .../drawable/ic_baseline_cloud_download.xml | 10 + .../res/drawable/ic_baseline_content_copy.xml | 10 + .../main/res/drawable/ic_baseline_delete.xml | 10 + .../src/main/res/drawable/ic_baseline_dns.xml | 10 + .../main/res/drawable/ic_baseline_domain.xml | 10 + .../main/res/drawable/ic_baseline_edit.xml | 10 + .../res/drawable/ic_baseline_extension.xml | 10 + .../res/drawable/ic_baseline_flash_on.xml | 10 + .../main/res/drawable/ic_baseline_get_app.xml | 10 + .../res/drawable/ic_baseline_help_center.xml | 10 + .../main/res/drawable/ic_baseline_info.xml | 10 + .../res/drawable/ic_baseline_more_vert.xml | 10 + .../main/res/drawable/ic_baseline_publish.xml | 10 + .../main/res/drawable/ic_baseline_replay.xml | 10 + .../main/res/drawable/ic_baseline_restore.xml | 10 + .../main/res/drawable/ic_baseline_save.xml | 10 + .../main/res/drawable/ic_baseline_search.xml | 10 + .../res/drawable/ic_baseline_settings.xml | 10 + .../main/res/drawable/ic_baseline_stop.xml | 10 + .../res/drawable/ic_baseline_swap_vert.xml | 10 + .../ic_baseline_swap_vertical_circle.xml | 10 + .../main/res/drawable/ic_baseline_sync.xml | 10 + .../main/res/drawable/ic_baseline_update.xml | 10 + .../res/drawable/ic_baseline_view_list.xml | 10 + .../res/drawable/ic_baseline_vpn_lock.xml | 10 + .../main/res/drawable/ic_baseline_work.xml | 10 + design/src/main/res/drawable/ic_clash.xml | 12 + .../main/res/drawable/ic_outline_article.xml | 13 + .../res/drawable/ic_outline_check_circle.xml | 10 + .../main/res/drawable/ic_outline_delete.xml | 10 + .../main/res/drawable/ic_outline_folder.xml | 10 + .../main/res/drawable/ic_outline_inbox.xml | 10 + .../src/main/res/drawable/ic_outline_info.xml | 10 + .../main/res/drawable/ic_outline_label.xml | 10 + .../drawable/ic_outline_not_interested.xml | 10 + .../main/res/drawable/ic_outline_update.xml | 10 + design/src/main/res/layout/adapter_app.xml | 64 ++ .../res/layout/adapter_editable_text_list.xml | 32 + .../res/layout/adapter_editable_text_map.xml | 40 + design/src/main/res/layout/adapter_file.xml | 105 +++ .../main/res/layout/adapter_log_message.xml | 50 ++ .../src/main/res/layout/adapter_profile.xml | 103 +++ .../res/layout/adapter_profile_provider.xml | 44 + .../src/main/res/layout/adapter_provider.xml | 98 +++ .../res/layout/adapter_sideload_provider.xml | 69 ++ .../main/res/layout/common_activity_bar.xml | 28 + .../main/res/layout/common_recycler_list.xml | 16 + .../res/layout/component_action_label.xml | 39 + .../layout/component_action_text_field.xml | 62 ++ .../layout/component_large_action_label.xml | 37 + design/src/main/res/layout/design_about.xml | 42 + .../main/res/layout/design_access_control.xml | 70 ++ .../main/res/layout/design_app_crashed.xml | 43 + design/src/main/res/layout/design_files.xml | 68 ++ design/src/main/res/layout/design_logcat.xml | 102 +++ design/src/main/res/layout/design_logs.xml | 89 ++ design/src/main/res/layout/design_main.xml | 154 ++++ .../main/res/layout/design_new_profile.xml | 31 + .../src/main/res/layout/design_profiles.xml | 84 ++ .../src/main/res/layout/design_properties.xml | 151 ++++ .../src/main/res/layout/design_providers.xml | 59 ++ design/src/main/res/layout/design_proxy.xml | 134 +++ .../src/main/res/layout/design_settings.xml | 66 ++ .../res/layout/design_settings_common.xml | 39 + .../res/layout/design_settings_overide.xml | 66 ++ .../layout/dialog_editable_map_text_field.xml | 37 + .../main/res/layout/dialog_fetch_status.xml | 22 + .../src/main/res/layout/dialog_files_menu.xml | 65 ++ .../res/layout/dialog_preference_list.xml | 91 ++ .../main/res/layout/dialog_profiles_menu.xml | 59 ++ design/src/main/res/layout/dialog_search.xml | 52 ++ .../src/main/res/layout/dialog_text_field.xml | 24 + .../main/res/layout/preference_category.xml | 11 + .../main/res/layout/preference_clickable.xml | 40 + .../src/main/res/layout/preference_switch.xml | 52 ++ .../src/main/res/layout/preference_tips.xml | 23 + .../src/main/res/menu/menu_access_control.xml | 56 ++ design/src/main/res/values-v23/themes.xml | 38 + design/src/main/res/values-v27/themes.xml | 50 ++ design/src/main/res/values-v29/themes.xml | 56 ++ design/src/main/res/values-zh-rHK/strings.xml | 211 +++++ design/src/main/res/values-zh-rTW/strings.xml | 211 +++++ design/src/main/res/values-zh/strings.xml | 211 +++++ design/src/main/res/values/attrs.xml | 50 ++ design/src/main/res/values/colors.xml | 13 + design/src/main/res/values/dimens.xml | 84 ++ design/src/main/res/values/ids.xml | 4 + design/src/main/res/values/strings.xml | 270 ++++++ design/src/main/res/values/styles.xml | 10 + design/src/main/res/values/themes.xml | 169 ++++ .../clash/design/OverrideSettingsDesign.kt | 390 ++++++++ .../kr328/clash/design/component/ProxyMenu.kt | 113 +++ design/src/open/res/menu/menu_proxy.xml | 56 ++ .../clash/design/OverrideSettingsDesign.kt | 392 +++++++++ .../kr328/clash/design/component/ProxyMenu.kt | 116 +++ design/src/premium/res/menu/menu_proxy.xml | 59 ++ gradle.properties | 23 + gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 54329 bytes gradle/wrapper/gradle-wrapper.properties | 6 + gradlew | 172 ++++ gradlew.bat | 84 ++ hideapi/build.gradle.kts | 28 + hideapi/consumer-rules.pro | 0 hideapi/proguard-rules.pro | 21 + hideapi/src/main/AndroidManifest.xml | 2 + .../main/java/android/app/ActivityThread.java | 7 + service/build.gradle.kts | 79 ++ service/consumer-rules.pro | 0 service/proguard-rules.pro | 21 + service/src/main/AndroidManifest.xml | 80 ++ .../github/kr328/clash/service/BaseService.kt | 14 + .../kr328/clash/service/ClashManager.kt | 118 +++ .../kr328/clash/service/ClashService.kt | 117 +++ .../kr328/clash/service/FilesProvider.kt | 208 +++++ .../kr328/clash/service/PreferenceProvider.kt | 32 + .../kr328/clash/service/ProfileProcessor.kt | 192 ++++ .../kr328/clash/service/ProfileReceiver.kt | 120 +++ .../kr328/clash/service/ProfileService.kt | 215 +++++ .../kr328/clash/service/ProfileWorker.kt | 223 +++++ .../kr328/clash/service/StatusProvider.kt | 83 ++ .../github/kr328/clash/service/TunService.kt | 237 +++++ .../kr328/clash/service/clash/ClashRuntime.kt | 65 ++ .../clash/module/AppListCacheModule.kt | 40 + .../clash/service/clash/module/CloseModule.kt | 21 + .../clash/module/ConfigurationModule.kt | 80 ++ .../clash/module/DynamicNotificationModule.kt | 104 +++ .../clash/service/clash/module/Module.kt | 78 ++ .../clash/module/NetworkObserveModule.kt | 104 +++ .../clash/module/SideloadDatabaseModule.kt | 87 ++ .../clash/module/StaticNotificationModule.kt | 84 ++ .../service/clash/module/SuspendModule.kt | 50 ++ .../clash/service/clash/module/TunModule.kt | 81 ++ .../kr328/clash/service/data/Converters.kt | 27 + .../github/kr328/clash/service/data/Daos.kt | 13 + .../kr328/clash/service/data/Database.kt | 49 ++ .../kr328/clash/service/data/Imported.kt | 18 + .../kr328/clash/service/data/ImportedDao.kt | 26 + .../kr328/clash/service/data/Pending.kt | 18 + .../kr328/clash/service/data/PendingDao.kt | 26 + .../kr328/clash/service/data/Selection.kt | 25 + .../kr328/clash/service/data/SelectionDao.kt | 20 + .../data/migrations/LegacyMigration.kt | 199 +++++ .../service/data/migrations/Migrations.kt | 7 + .../kr328/clash/service/document/Document.kt | 10 + .../clash/service/document/FileDocument.kt | 22 + .../kr328/clash/service/document/Flag.kt | 5 + .../kr328/clash/service/document/Path.kt | 31 + .../kr328/clash/service/document/Paths.kt | 43 + .../kr328/clash/service/document/Picker.kt | 146 +++ .../clash/service/document/VirtualDocument.kt | 10 + .../clash/service/model/AccessControlMode.kt | 5 + .../kr328/clash/service/model/Profile.kt | 47 + .../clash/service/remote/IClashManager.kt | 26 + .../clash/service/remote/IFetchObserver.kt | 9 + .../clash/service/remote/ILogObserver.kt | 9 + .../clash/service/remote/IProfileManager.kt | 20 + .../clash/service/sideload/ExternalGeoip.kt | 21 + .../kr328/clash/service/store/ServiceStore.kt | 58 ++ .../kr328/clash/service/util/Address.kt | 34 + .../kr328/clash/service/util/Broadcast.kt | 51 ++ .../kr328/clash/service/util/Connectivity.kt | 11 + .../kr328/clash/service/util/Coroutine.kt | 14 + .../kr328/clash/service/util/Database.kt | 15 + .../github/kr328/clash/service/util/Files.kt | 18 + .../github/kr328/clash/service/util/Intent.kt | 8 + .../github/kr328/clash/service/util/Net.kt | 15 + .../kr328/clash/service/util/Serializers.kt | 22 + .../src/main/res/drawable/ic_logo_service.xml | 12 + .../src/main/res/values-zh-rHK/strings.xml | 19 + .../src/main/res/values-zh-rTW/strings.xml | 19 + service/src/main/res/values-zh/strings.xml | 19 + service/src/main/res/values/arrays.xml | 81 ++ service/src/main/res/values/colors.xml | 4 + service/src/main/res/values/ids.xml | 6 + service/src/main/res/values/strings.xml | 21 + settings.gradle.kts | 15 + 483 files changed, 26328 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/01-bug-report-en.md create mode 100644 .github/ISSUE_TEMPLATE/02-feature-request-en.md create mode 100644 .github/ISSUE_TEMPLATE/03-bug-report-zh-cn.md create mode 100644 .github/ISSUE_TEMPLATE/04-feature-request-zh-cn.md create mode 100644 .github/ISSUE_TEMPLATE/config.yml create mode 100644 .gitignore create mode 100644 .gitmodules create mode 100644 .idea/codeStyles/Project.xml create mode 100644 .idea/codeStyles/codeStyleConfig.xml create mode 100644 CONTRIBUTING.md create mode 100644 LICENSE create mode 100644 NOTICE create mode 100644 PRIVACY_POLICY.md create mode 100644 README.md create mode 100644 app/build.gradle.kts create mode 100644 app/proguard-rules.pro create mode 100644 app/src/main/AndroidManifest.xml create mode 100644 app/src/main/ic_launcher-web.png create mode 100644 app/src/main/java/com/github/kr328/clash/AccessControlActivity.kt create mode 100644 app/src/main/java/com/github/kr328/clash/ApkBrokenActivity.kt create mode 100644 app/src/main/java/com/github/kr328/clash/AppCrashedActivity.kt create mode 100644 app/src/main/java/com/github/kr328/clash/AppSettingsActivity.kt create mode 100644 app/src/main/java/com/github/kr328/clash/BaseActivity.kt create mode 100644 app/src/main/java/com/github/kr328/clash/ExternalImportActivity.kt create mode 100644 app/src/main/java/com/github/kr328/clash/FilesActivity.kt create mode 100644 app/src/main/java/com/github/kr328/clash/HelpActivity.kt create mode 100644 app/src/main/java/com/github/kr328/clash/LogcatActivity.kt create mode 100644 app/src/main/java/com/github/kr328/clash/LogcatService.kt create mode 100644 app/src/main/java/com/github/kr328/clash/LogsActivity.kt create mode 100644 app/src/main/java/com/github/kr328/clash/MainActivity.kt create mode 100644 app/src/main/java/com/github/kr328/clash/MainApplication.kt create mode 100644 app/src/main/java/com/github/kr328/clash/NetworkSettingsActivity.kt create mode 100644 app/src/main/java/com/github/kr328/clash/NewProfileActivity.kt create mode 100644 app/src/main/java/com/github/kr328/clash/OverrideSettingsActivity.kt create mode 100644 app/src/main/java/com/github/kr328/clash/ProfilesActivity.kt create mode 100644 app/src/main/java/com/github/kr328/clash/PropertiesActivity.kt create mode 100644 app/src/main/java/com/github/kr328/clash/ProvidersActivity.kt create mode 100644 app/src/main/java/com/github/kr328/clash/ProxyActivity.kt create mode 100644 app/src/main/java/com/github/kr328/clash/RestartReceiver.kt create mode 100644 app/src/main/java/com/github/kr328/clash/SettingsActivity.kt create mode 100644 app/src/main/java/com/github/kr328/clash/TileService.kt create mode 100644 app/src/main/java/com/github/kr328/clash/log/LogcatCache.kt create mode 100644 app/src/main/java/com/github/kr328/clash/log/LogcatFilter.kt create mode 100644 app/src/main/java/com/github/kr328/clash/log/LogcatReader.kt create mode 100644 app/src/main/java/com/github/kr328/clash/log/LogcatWriter.kt create mode 100644 app/src/main/java/com/github/kr328/clash/log/SystemLogcat.kt create mode 100644 app/src/main/java/com/github/kr328/clash/remote/Broadcasts.kt create mode 100644 app/src/main/java/com/github/kr328/clash/remote/FilesClient.kt create mode 100644 app/src/main/java/com/github/kr328/clash/remote/Remote.kt create mode 100644 app/src/main/java/com/github/kr328/clash/remote/Resource.kt create mode 100644 app/src/main/java/com/github/kr328/clash/remote/Services.kt create mode 100644 app/src/main/java/com/github/kr328/clash/remote/StatusClient.kt create mode 100644 app/src/main/java/com/github/kr328/clash/store/AppStore.kt create mode 100644 app/src/main/java/com/github/kr328/clash/store/TipsStore.kt create mode 100644 app/src/main/java/com/github/kr328/clash/util/Activity.kt create mode 100644 app/src/main/java/com/github/kr328/clash/util/Application.kt create mode 100644 app/src/main/java/com/github/kr328/clash/util/Clash.kt create mode 100644 app/src/main/java/com/github/kr328/clash/util/Content.kt create mode 100644 app/src/main/java/com/github/kr328/clash/util/Files.kt create mode 100644 app/src/main/java/com/github/kr328/clash/util/Remote.kt create mode 100644 app/src/main/java/com/github/kr328/clash/util/Service.kt create mode 100644 app/src/main/java/com/github/kr328/clash/util/Uri.kt create mode 100644 app/src/main/res/drawable/ic_launcher_foreground.xml create mode 100644 app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml create mode 100644 app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml create mode 100644 app/src/main/res/mipmap-hdpi/ic_launcher.png create mode 100644 app/src/main/res/mipmap-hdpi/ic_launcher_round.png create mode 100644 app/src/main/res/mipmap-mdpi/ic_launcher.png create mode 100644 app/src/main/res/mipmap-mdpi/ic_launcher_round.png create mode 100644 app/src/main/res/mipmap-xhdpi/ic_banner.png create mode 100644 app/src/main/res/mipmap-xhdpi/ic_launcher.png create mode 100644 app/src/main/res/mipmap-xhdpi/ic_launcher_round.png create mode 100644 app/src/main/res/mipmap-xxhdpi/ic_launcher.png create mode 100644 app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png create mode 100644 app/src/main/res/mipmap-xxxhdpi/ic_launcher.png create mode 100644 app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png create mode 100644 app/src/main/res/values-night/themes.xml create mode 100644 app/src/main/res/values/colors.xml create mode 100644 app/src/main/res/values/ids.xml create mode 100644 app/src/main/res/values/themes.xml create mode 100644 app/src/main/res/xml/full_backup_content.xml create mode 100644 app/src/main/res/xml/network_security_config.xml create mode 100644 build.gradle.kts create mode 100644 buildSrc/build.gradle.kts create mode 100644 buildSrc/src/main/java/Build.kt create mode 100644 buildSrc/src/main/java/Dependencies.kt create mode 100644 buildSrc/src/main/java/Files.kt create mode 100644 buildSrc/src/main/java/GolangBuildTask.kt create mode 100644 buildSrc/src/main/java/LibraryGolangPlugin.kt create mode 100644 common/build.gradle.kts create mode 100644 common/consumer-rules.pro create mode 100644 common/proguard-rules.pro create mode 100644 common/src/main/AndroidManifest.xml create mode 100644 common/src/main/java/com/github/kr328/clash/common/Global.kt create mode 100644 common/src/main/java/com/github/kr328/clash/common/compat/App.kt create mode 100644 common/src/main/java/com/github/kr328/clash/common/compat/Context.kt create mode 100644 common/src/main/java/com/github/kr328/clash/common/compat/Html.kt create mode 100644 common/src/main/java/com/github/kr328/clash/common/compat/Intents.kt create mode 100644 common/src/main/java/com/github/kr328/clash/common/compat/Package.kt create mode 100644 common/src/main/java/com/github/kr328/clash/common/compat/Resource.kt create mode 100644 common/src/main/java/com/github/kr328/clash/common/compat/Services.kt create mode 100644 common/src/main/java/com/github/kr328/clash/common/compat/UI.kt create mode 100644 common/src/main/java/com/github/kr328/clash/common/compat/View.kt create mode 100644 common/src/main/java/com/github/kr328/clash/common/constants/Authorities.kt create mode 100644 common/src/main/java/com/github/kr328/clash/common/constants/Components.kt create mode 100644 common/src/main/java/com/github/kr328/clash/common/constants/Intents.kt create mode 100644 common/src/main/java/com/github/kr328/clash/common/constants/Metadata.kt create mode 100644 common/src/main/java/com/github/kr328/clash/common/constants/Permissions.kt create mode 100644 common/src/main/java/com/github/kr328/clash/common/id/UndefinedIds.kt create mode 100644 common/src/main/java/com/github/kr328/clash/common/log/Log.kt create mode 100644 common/src/main/java/com/github/kr328/clash/common/store/Providers.kt create mode 100644 common/src/main/java/com/github/kr328/clash/common/store/Store.kt create mode 100644 common/src/main/java/com/github/kr328/clash/common/store/StoreProvider.kt create mode 100644 common/src/main/java/com/github/kr328/clash/common/util/Components.kt create mode 100644 common/src/main/java/com/github/kr328/clash/common/util/Global.kt create mode 100644 common/src/main/java/com/github/kr328/clash/common/util/Intent.kt create mode 100644 common/src/main/java/com/github/kr328/clash/common/util/Parcelable.kt create mode 100644 common/src/main/java/com/github/kr328/clash/common/util/Patterns.kt create mode 100644 common/src/main/java/com/github/kr328/clash/common/util/Ticker.kt create mode 100644 common/src/main/res/values-zh/strings.xml create mode 100644 common/src/main/res/values/strings.xml create mode 100644 core/build.gradle.kts create mode 100644 core/consumer-rules.pro create mode 100644 core/proguard-rules.pro create mode 100644 core/src/main/AndroidManifest.xml create mode 100644 core/src/main/cpp/CMakeLists.txt create mode 100644 core/src/main/cpp/bridge_helper.c create mode 100644 core/src/main/cpp/bridge_helper.h create mode 100644 core/src/main/cpp/jni_helper.c create mode 100644 core/src/main/cpp/jni_helper.h create mode 100644 core/src/main/cpp/main.c create mode 100644 core/src/main/golang/.idea/codeStyles/Project.xml create mode 100644 core/src/main/golang/.idea/codeStyles/codeStyleConfig.xml create mode 100644 core/src/main/golang/app.go create mode 100644 core/src/main/golang/app/app.go create mode 100644 core/src/main/golang/app/content.go create mode 100644 core/src/main/golang/app/dns.go create mode 100644 core/src/main/golang/app/tun.go create mode 100644 core/src/main/golang/app/ui.go create mode 100644 core/src/main/golang/bridge.c create mode 100644 core/src/main/golang/bridge.h create mode 160000 core/src/main/golang/clash create mode 100644 core/src/main/golang/common/path.go create mode 100644 core/src/main/golang/config.go create mode 100644 core/src/main/golang/config/defaults.go create mode 100644 core/src/main/golang/config/fetch.go create mode 100644 core/src/main/golang/config/load.go create mode 100644 core/src/main/golang/config/override.go create mode 100644 core/src/main/golang/config/process.go create mode 100644 core/src/main/golang/config/provider_open.go create mode 100644 core/src/main/golang/config/provider_premium.go create mode 100644 core/src/main/golang/core/init.go create mode 100644 core/src/main/golang/debug.go create mode 100644 core/src/main/golang/go.mod create mode 100644 core/src/main/golang/go.sum create mode 100644 core/src/main/golang/log.go create mode 100644 core/src/main/golang/main.go create mode 100644 core/src/main/golang/platform/limit.go create mode 100644 core/src/main/golang/platform/procfs.go create mode 100644 core/src/main/golang/proxy.go create mode 100644 core/src/main/golang/proxy/http.go create mode 100644 core/src/main/golang/trace.c create mode 100644 core/src/main/golang/trace.h create mode 100644 core/src/main/golang/tun.go create mode 100644 core/src/main/golang/tun/dns.go create mode 100644 core/src/main/golang/tun/log.go create mode 100644 core/src/main/golang/tun/tcp.go create mode 100644 core/src/main/golang/tun/tun.go create mode 100644 core/src/main/golang/tun/udp.go create mode 100644 core/src/main/golang/tunnel.go create mode 100644 core/src/main/golang/tunnel/conn.go create mode 100644 core/src/main/golang/tunnel/connectivity.go create mode 100644 core/src/main/golang/tunnel/geoip.go create mode 100644 core/src/main/golang/tunnel/providers.go create mode 100644 core/src/main/golang/tunnel/providers_premium.go create mode 100644 core/src/main/golang/tunnel/proxies.go create mode 100644 core/src/main/golang/tunnel/state.go create mode 100644 core/src/main/golang/tunnel/statistic.go create mode 100644 core/src/main/golang/tunnel/suspend.go create mode 100644 core/src/main/golang/utils.go create mode 100644 core/src/main/java/com/github/kr328/clash/core/Clash.kt create mode 100644 core/src/main/java/com/github/kr328/clash/core/bridge/Bridge.kt create mode 100644 core/src/main/java/com/github/kr328/clash/core/bridge/ClashException.kt create mode 100644 core/src/main/java/com/github/kr328/clash/core/bridge/Content.kt create mode 100644 core/src/main/java/com/github/kr328/clash/core/bridge/FetchCallback.kt create mode 100644 core/src/main/java/com/github/kr328/clash/core/bridge/LogcatInterface.kt create mode 100644 core/src/main/java/com/github/kr328/clash/core/bridge/TunInterface.kt create mode 100644 core/src/main/java/com/github/kr328/clash/core/model/ConfigurationOverride.kt create mode 100644 core/src/main/java/com/github/kr328/clash/core/model/FetchStatus.kt create mode 100644 core/src/main/java/com/github/kr328/clash/core/model/LogMessage.kt create mode 100644 core/src/main/java/com/github/kr328/clash/core/model/Provider.kt create mode 100644 core/src/main/java/com/github/kr328/clash/core/model/ProviderList.kt create mode 100644 core/src/main/java/com/github/kr328/clash/core/model/Proxy.kt create mode 100644 core/src/main/java/com/github/kr328/clash/core/model/ProxyGroup.kt create mode 100644 core/src/main/java/com/github/kr328/clash/core/model/ProxySort.kt create mode 100644 core/src/main/java/com/github/kr328/clash/core/model/Traffic.kt create mode 100644 core/src/main/java/com/github/kr328/clash/core/model/TunnelState.kt create mode 100644 core/src/main/java/com/github/kr328/clash/core/model/UiConfiguration.kt create mode 100644 core/src/main/java/com/github/kr328/clash/core/util/Net.kt create mode 100644 core/src/main/java/com/github/kr328/clash/core/util/Parcelizer.kt create mode 100644 core/src/main/java/com/github/kr328/clash/core/util/Serializers.kt create mode 100644 core/src/main/java/com/github/kr328/clash/core/util/Traffic.kt create mode 100644 design/build.gradle.kts create mode 100644 design/consumer-rules.pro create mode 100644 design/proguard-rules.pro create mode 100644 design/src/main/AndroidManifest.xml create mode 100644 design/src/main/java/com/github/kr328/clash/design/AccessControlDesign.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/ApkBrokenDesign.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/AppCrashedDesign.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/AppSettingsDesign.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/Design.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/FilesDesign.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/HelpDesign.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/LogcatDesign.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/LogsDesign.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/MainDesign.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/NetworkSettingsDesign.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/NewProfileDesign.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/ProfilesDesign.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/PropertiesDesign.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/ProvidersDesign.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/ProxyDesign.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/SettingsDesign.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/adapter/AppAdapter.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/adapter/EditableTextListAdapter.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/adapter/EditableTextMapAdapter.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/adapter/FileAdapter.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/adapter/LogFileAdapter.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/adapter/LogMessageAdapter.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/adapter/PopupListAdapter.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/adapter/ProfileAdapter.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/adapter/ProfileProviderAdapter.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/adapter/ProviderAdapter.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/adapter/ProxyAdapter.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/adapter/ProxyPageAdapter.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/adapter/SideloadProviderAdapter.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/component/AccessControlMenu.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/component/ProxyPageFactory.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/component/ProxyView.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/component/ProxyViewConfig.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/component/ProxyViewState.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/dialog/Dialogs.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/dialog/Input.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/dialog/Progress.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/model/AppInfo.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/model/AppInfoSort.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/model/Behavior.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/model/DarkMode.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/model/File.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/model/LogFile.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/model/ProfileProvider.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/model/ProviderState.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/model/ProxyPageState.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/model/ProxyState.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/preference/Category.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/preference/Clickable.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/preference/EditableText.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/preference/EditableTextList.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/preference/EditableTextMap.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/preference/Overlay.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/preference/Preference.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/preference/Screen.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/preference/SelectableList.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/preference/Switch.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/preference/Tips.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/preference/Value.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/store/UiStore.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/ui/DayNight.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/ui/Insets.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/ui/ObservableCurrentTime.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/ui/Surface.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/ui/ToastDuration.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/util/ActivityBar.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/util/App.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/util/Binding.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/util/Context.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/util/Diff.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/util/Elevation.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/util/I18n.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/util/Inserts.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/util/Interval.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/util/Landscape.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/util/ListView.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/util/RecyclerView.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/util/ScrollView.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/util/Theme.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/util/Toast.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/util/Validator.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/util/View.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/view/ActionLabel.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/view/ActionTextField.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/view/ActivityBarLayout.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/view/AppRecyclerView.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/view/LargeActionCard.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/view/LargeActionLabel.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/view/ObservableScrollView.kt create mode 100644 design/src/main/java/com/github/kr328/clash/design/view/VerticalScrollableHost.kt create mode 100644 design/src/main/res/drawable/bg_bottom_sheet.xml create mode 100644 design/src/main/res/drawable/ic_baseline_adb.xml create mode 100644 design/src/main/res/drawable/ic_baseline_add.xml create mode 100644 design/src/main/res/drawable/ic_baseline_apps.xml create mode 100644 design/src/main/res/drawable/ic_baseline_arrow_back.xml create mode 100644 design/src/main/res/drawable/ic_baseline_assignment.xml create mode 100644 design/src/main/res/drawable/ic_baseline_attach_file.xml create mode 100644 design/src/main/res/drawable/ic_baseline_brightness_4.xml create mode 100644 design/src/main/res/drawable/ic_baseline_clear_all.xml create mode 100644 design/src/main/res/drawable/ic_baseline_close.xml create mode 100644 design/src/main/res/drawable/ic_baseline_cloud_download.xml create mode 100644 design/src/main/res/drawable/ic_baseline_content_copy.xml create mode 100644 design/src/main/res/drawable/ic_baseline_delete.xml create mode 100644 design/src/main/res/drawable/ic_baseline_dns.xml create mode 100644 design/src/main/res/drawable/ic_baseline_domain.xml create mode 100644 design/src/main/res/drawable/ic_baseline_edit.xml create mode 100644 design/src/main/res/drawable/ic_baseline_extension.xml create mode 100644 design/src/main/res/drawable/ic_baseline_flash_on.xml create mode 100644 design/src/main/res/drawable/ic_baseline_get_app.xml create mode 100644 design/src/main/res/drawable/ic_baseline_help_center.xml create mode 100644 design/src/main/res/drawable/ic_baseline_info.xml create mode 100644 design/src/main/res/drawable/ic_baseline_more_vert.xml create mode 100644 design/src/main/res/drawable/ic_baseline_publish.xml create mode 100644 design/src/main/res/drawable/ic_baseline_replay.xml create mode 100644 design/src/main/res/drawable/ic_baseline_restore.xml create mode 100644 design/src/main/res/drawable/ic_baseline_save.xml create mode 100644 design/src/main/res/drawable/ic_baseline_search.xml create mode 100644 design/src/main/res/drawable/ic_baseline_settings.xml create mode 100644 design/src/main/res/drawable/ic_baseline_stop.xml create mode 100644 design/src/main/res/drawable/ic_baseline_swap_vert.xml create mode 100644 design/src/main/res/drawable/ic_baseline_swap_vertical_circle.xml create mode 100644 design/src/main/res/drawable/ic_baseline_sync.xml create mode 100644 design/src/main/res/drawable/ic_baseline_update.xml create mode 100644 design/src/main/res/drawable/ic_baseline_view_list.xml create mode 100644 design/src/main/res/drawable/ic_baseline_vpn_lock.xml create mode 100644 design/src/main/res/drawable/ic_baseline_work.xml create mode 100644 design/src/main/res/drawable/ic_clash.xml create mode 100644 design/src/main/res/drawable/ic_outline_article.xml create mode 100644 design/src/main/res/drawable/ic_outline_check_circle.xml create mode 100644 design/src/main/res/drawable/ic_outline_delete.xml create mode 100644 design/src/main/res/drawable/ic_outline_folder.xml create mode 100644 design/src/main/res/drawable/ic_outline_inbox.xml create mode 100644 design/src/main/res/drawable/ic_outline_info.xml create mode 100644 design/src/main/res/drawable/ic_outline_label.xml create mode 100644 design/src/main/res/drawable/ic_outline_not_interested.xml create mode 100644 design/src/main/res/drawable/ic_outline_update.xml create mode 100644 design/src/main/res/layout/adapter_app.xml create mode 100644 design/src/main/res/layout/adapter_editable_text_list.xml create mode 100644 design/src/main/res/layout/adapter_editable_text_map.xml create mode 100644 design/src/main/res/layout/adapter_file.xml create mode 100644 design/src/main/res/layout/adapter_log_message.xml create mode 100644 design/src/main/res/layout/adapter_profile.xml create mode 100644 design/src/main/res/layout/adapter_profile_provider.xml create mode 100644 design/src/main/res/layout/adapter_provider.xml create mode 100644 design/src/main/res/layout/adapter_sideload_provider.xml create mode 100644 design/src/main/res/layout/common_activity_bar.xml create mode 100644 design/src/main/res/layout/common_recycler_list.xml create mode 100644 design/src/main/res/layout/component_action_label.xml create mode 100644 design/src/main/res/layout/component_action_text_field.xml create mode 100644 design/src/main/res/layout/component_large_action_label.xml create mode 100644 design/src/main/res/layout/design_about.xml create mode 100644 design/src/main/res/layout/design_access_control.xml create mode 100644 design/src/main/res/layout/design_app_crashed.xml create mode 100644 design/src/main/res/layout/design_files.xml create mode 100644 design/src/main/res/layout/design_logcat.xml create mode 100644 design/src/main/res/layout/design_logs.xml create mode 100644 design/src/main/res/layout/design_main.xml create mode 100644 design/src/main/res/layout/design_new_profile.xml create mode 100644 design/src/main/res/layout/design_profiles.xml create mode 100644 design/src/main/res/layout/design_properties.xml create mode 100644 design/src/main/res/layout/design_providers.xml create mode 100644 design/src/main/res/layout/design_proxy.xml create mode 100644 design/src/main/res/layout/design_settings.xml create mode 100644 design/src/main/res/layout/design_settings_common.xml create mode 100644 design/src/main/res/layout/design_settings_overide.xml create mode 100644 design/src/main/res/layout/dialog_editable_map_text_field.xml create mode 100644 design/src/main/res/layout/dialog_fetch_status.xml create mode 100644 design/src/main/res/layout/dialog_files_menu.xml create mode 100644 design/src/main/res/layout/dialog_preference_list.xml create mode 100644 design/src/main/res/layout/dialog_profiles_menu.xml create mode 100644 design/src/main/res/layout/dialog_search.xml create mode 100644 design/src/main/res/layout/dialog_text_field.xml create mode 100644 design/src/main/res/layout/preference_category.xml create mode 100644 design/src/main/res/layout/preference_clickable.xml create mode 100644 design/src/main/res/layout/preference_switch.xml create mode 100644 design/src/main/res/layout/preference_tips.xml create mode 100644 design/src/main/res/menu/menu_access_control.xml create mode 100644 design/src/main/res/values-v23/themes.xml create mode 100644 design/src/main/res/values-v27/themes.xml create mode 100644 design/src/main/res/values-v29/themes.xml create mode 100644 design/src/main/res/values-zh-rHK/strings.xml create mode 100644 design/src/main/res/values-zh-rTW/strings.xml create mode 100644 design/src/main/res/values-zh/strings.xml create mode 100644 design/src/main/res/values/attrs.xml create mode 100644 design/src/main/res/values/colors.xml create mode 100644 design/src/main/res/values/dimens.xml create mode 100644 design/src/main/res/values/ids.xml create mode 100644 design/src/main/res/values/strings.xml create mode 100644 design/src/main/res/values/styles.xml create mode 100644 design/src/main/res/values/themes.xml create mode 100644 design/src/open/java/com/github/kr328/clash/design/OverrideSettingsDesign.kt create mode 100644 design/src/open/java/com/github/kr328/clash/design/component/ProxyMenu.kt create mode 100644 design/src/open/res/menu/menu_proxy.xml create mode 100644 design/src/premium/java/com/github/kr328/clash/design/OverrideSettingsDesign.kt create mode 100644 design/src/premium/java/com/github/kr328/clash/design/component/ProxyMenu.kt create mode 100644 design/src/premium/res/menu/menu_proxy.xml create mode 100644 gradle.properties create mode 100644 gradle/wrapper/gradle-wrapper.jar create mode 100644 gradle/wrapper/gradle-wrapper.properties create mode 100755 gradlew create mode 100644 gradlew.bat create mode 100644 hideapi/build.gradle.kts create mode 100644 hideapi/consumer-rules.pro create mode 100644 hideapi/proguard-rules.pro create mode 100644 hideapi/src/main/AndroidManifest.xml create mode 100644 hideapi/src/main/java/android/app/ActivityThread.java create mode 100644 service/build.gradle.kts create mode 100644 service/consumer-rules.pro create mode 100644 service/proguard-rules.pro create mode 100644 service/src/main/AndroidManifest.xml create mode 100644 service/src/main/java/com/github/kr328/clash/service/BaseService.kt create mode 100644 service/src/main/java/com/github/kr328/clash/service/ClashManager.kt create mode 100644 service/src/main/java/com/github/kr328/clash/service/ClashService.kt create mode 100644 service/src/main/java/com/github/kr328/clash/service/FilesProvider.kt create mode 100644 service/src/main/java/com/github/kr328/clash/service/PreferenceProvider.kt create mode 100644 service/src/main/java/com/github/kr328/clash/service/ProfileProcessor.kt create mode 100644 service/src/main/java/com/github/kr328/clash/service/ProfileReceiver.kt create mode 100644 service/src/main/java/com/github/kr328/clash/service/ProfileService.kt create mode 100644 service/src/main/java/com/github/kr328/clash/service/ProfileWorker.kt create mode 100644 service/src/main/java/com/github/kr328/clash/service/StatusProvider.kt create mode 100644 service/src/main/java/com/github/kr328/clash/service/TunService.kt create mode 100644 service/src/main/java/com/github/kr328/clash/service/clash/ClashRuntime.kt create mode 100644 service/src/main/java/com/github/kr328/clash/service/clash/module/AppListCacheModule.kt create mode 100644 service/src/main/java/com/github/kr328/clash/service/clash/module/CloseModule.kt create mode 100644 service/src/main/java/com/github/kr328/clash/service/clash/module/ConfigurationModule.kt create mode 100644 service/src/main/java/com/github/kr328/clash/service/clash/module/DynamicNotificationModule.kt create mode 100644 service/src/main/java/com/github/kr328/clash/service/clash/module/Module.kt create mode 100644 service/src/main/java/com/github/kr328/clash/service/clash/module/NetworkObserveModule.kt create mode 100644 service/src/main/java/com/github/kr328/clash/service/clash/module/SideloadDatabaseModule.kt create mode 100644 service/src/main/java/com/github/kr328/clash/service/clash/module/StaticNotificationModule.kt create mode 100644 service/src/main/java/com/github/kr328/clash/service/clash/module/SuspendModule.kt create mode 100644 service/src/main/java/com/github/kr328/clash/service/clash/module/TunModule.kt create mode 100644 service/src/main/java/com/github/kr328/clash/service/data/Converters.kt create mode 100644 service/src/main/java/com/github/kr328/clash/service/data/Daos.kt create mode 100644 service/src/main/java/com/github/kr328/clash/service/data/Database.kt create mode 100644 service/src/main/java/com/github/kr328/clash/service/data/Imported.kt create mode 100644 service/src/main/java/com/github/kr328/clash/service/data/ImportedDao.kt create mode 100644 service/src/main/java/com/github/kr328/clash/service/data/Pending.kt create mode 100644 service/src/main/java/com/github/kr328/clash/service/data/PendingDao.kt create mode 100644 service/src/main/java/com/github/kr328/clash/service/data/Selection.kt create mode 100644 service/src/main/java/com/github/kr328/clash/service/data/SelectionDao.kt create mode 100644 service/src/main/java/com/github/kr328/clash/service/data/migrations/LegacyMigration.kt create mode 100644 service/src/main/java/com/github/kr328/clash/service/data/migrations/Migrations.kt create mode 100644 service/src/main/java/com/github/kr328/clash/service/document/Document.kt create mode 100644 service/src/main/java/com/github/kr328/clash/service/document/FileDocument.kt create mode 100644 service/src/main/java/com/github/kr328/clash/service/document/Flag.kt create mode 100644 service/src/main/java/com/github/kr328/clash/service/document/Path.kt create mode 100644 service/src/main/java/com/github/kr328/clash/service/document/Paths.kt create mode 100644 service/src/main/java/com/github/kr328/clash/service/document/Picker.kt create mode 100644 service/src/main/java/com/github/kr328/clash/service/document/VirtualDocument.kt create mode 100644 service/src/main/java/com/github/kr328/clash/service/model/AccessControlMode.kt create mode 100644 service/src/main/java/com/github/kr328/clash/service/model/Profile.kt create mode 100644 service/src/main/java/com/github/kr328/clash/service/remote/IClashManager.kt create mode 100644 service/src/main/java/com/github/kr328/clash/service/remote/IFetchObserver.kt create mode 100644 service/src/main/java/com/github/kr328/clash/service/remote/ILogObserver.kt create mode 100644 service/src/main/java/com/github/kr328/clash/service/remote/IProfileManager.kt create mode 100644 service/src/main/java/com/github/kr328/clash/service/sideload/ExternalGeoip.kt create mode 100644 service/src/main/java/com/github/kr328/clash/service/store/ServiceStore.kt create mode 100644 service/src/main/java/com/github/kr328/clash/service/util/Address.kt create mode 100644 service/src/main/java/com/github/kr328/clash/service/util/Broadcast.kt create mode 100644 service/src/main/java/com/github/kr328/clash/service/util/Connectivity.kt create mode 100644 service/src/main/java/com/github/kr328/clash/service/util/Coroutine.kt create mode 100644 service/src/main/java/com/github/kr328/clash/service/util/Database.kt create mode 100644 service/src/main/java/com/github/kr328/clash/service/util/Files.kt create mode 100644 service/src/main/java/com/github/kr328/clash/service/util/Intent.kt create mode 100644 service/src/main/java/com/github/kr328/clash/service/util/Net.kt create mode 100644 service/src/main/java/com/github/kr328/clash/service/util/Serializers.kt create mode 100644 service/src/main/res/drawable/ic_logo_service.xml create mode 100644 service/src/main/res/values-zh-rHK/strings.xml create mode 100644 service/src/main/res/values-zh-rTW/strings.xml create mode 100644 service/src/main/res/values-zh/strings.xml create mode 100644 service/src/main/res/values/arrays.xml create mode 100644 service/src/main/res/values/colors.xml create mode 100644 service/src/main/res/values/ids.xml create mode 100644 service/src/main/res/values/strings.xml create mode 100644 settings.gradle.kts diff --git a/.github/ISSUE_TEMPLATE/01-bug-report-en.md b/.github/ISSUE_TEMPLATE/01-bug-report-en.md new file mode 100644 index 00000000..3bbd4b5e --- /dev/null +++ b/.github/ISSUE_TEMPLATE/01-bug-report-en.md @@ -0,0 +1,57 @@ +--- +name: "[English] Bug report" +about: Create a report to help us improve +title: "[BUG] " +labels: '' +assignees: '' + +--- + + + + + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Device Info (please complete the following information):** + + - Device: [e.g. Pixel 4] + - ROM: [e.g: AOSP] + - ROM Version: + - Android Version [e.g. 10] + +**Application Info (please complete the following information):** + + - Version: [e.g. 1.1.10] + - Apk File Name: [e.g. app-release-arm64-v8a.apk] + - Distribution Channel: [e.g. Google Play] + +**Additional context** +Add any other context about the problem here. + +**Configure** +Paste configure file which **removed server info** +```yaml +# paste here +``` + +**Logs** +Paste logs to help detect problem + +``` + +``` \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/02-feature-request-en.md b/.github/ISSUE_TEMPLATE/02-feature-request-en.md new file mode 100644 index 00000000..b139075b --- /dev/null +++ b/.github/ISSUE_TEMPLATE/02-feature-request-en.md @@ -0,0 +1,24 @@ +--- +name: "[English] Feature request" +about: Suggest an idea for this app +title: "[Feature Request] " +labels: '' +assignees: '' + +--- + + + + + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/.github/ISSUE_TEMPLATE/03-bug-report-zh-cn.md b/.github/ISSUE_TEMPLATE/03-bug-report-zh-cn.md new file mode 100644 index 00000000..cfbfd6d5 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/03-bug-report-zh-cn.md @@ -0,0 +1,55 @@ +--- +name: "[简体中文] 创建错误报告" +about: 创建错误报告以帮助我们改进应用 +title: "[BUG] " +labels: '' +assignees: '' + +--- + + + + + +**描述出现的错误** +请简洁的描述你遇到的错误 + +**如何复现该错误** +复现步骤: +1. ... +2. ... +3. ... +4. ... + +**预期行为** +清晰简单的描述你预期的应用应该表现的行为 + +**屏幕截图** +如果适用, 上传屏幕截图以帮助描述错误 + +**设备信息 (请完成以下信息):** + - 机型: [例如: Pixel 4] + - 系统/ROM: [例如: MIUI 11] + - Android 版本 [例如: 10] + - ROM版本 [例如: 20.3.19] + +**应用信息** + - 版本: [例如: 1.1.10] + - 安装包文件名: [例如: app-release-arm64-v8a.apk] + - 应用来源: [例如: Google Play] + +**附加信息** +其他的可能与改错误相关的信息 + +**配置文件** +在此粘贴 **去除服务器信息的** 的 **配置文件** +```yaml +# 在此粘贴 +``` + +**日志** +粘贴日志以帮助侦测错误 +``` +<在此粘贴> +``` + diff --git a/.github/ISSUE_TEMPLATE/04-feature-request-zh-cn.md b/.github/ISSUE_TEMPLATE/04-feature-request-zh-cn.md new file mode 100644 index 00000000..e1ccda3c --- /dev/null +++ b/.github/ISSUE_TEMPLATE/04-feature-request-zh-cn.md @@ -0,0 +1,21 @@ +--- +name: "[简体中文] 功能请求" +about: 你希望的能够在应用中增加的功能 +title: "[Feature Request] " +labels: '' +assignees: '' + +--- + + + + + +**功能描述** +请清晰的描述你想要的功能 + +**描述你希望的实现方式** +清晰的描述应用应该如何实现该功能 + +**附加信息** +其他的与改功能相关的附加信息 diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 00000000..3ba13e0c --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1 @@ +blank_issues_enabled: false diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..8017ae43 --- /dev/null +++ b/.gitignore @@ -0,0 +1,53 @@ +.gradle +build/ +/app/release/ +/captures + +# Ignore Gradle GUI config +gradle-app.setting + +# Avoid ignoring Gradle wrapper jar targetFile (.jar files are usually ignored) +!gradle-wrapper.jar + +# Cache of project +.gradletasknamecache + +# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898 +# gradle/wrapper/gradle-wrapper.properties + +# Ignore IDEA config +*.iml +/.idea/* +/core/src/main/golang/.idea/* +!/.idea/codeStyles +!/core/src/main/golang/.idea/codeStyles + +# KeyStore +*.keystore +*.jks + +# clion cmake build +cmake-build-* + +# local.properties +local.properties + +# keystore +keystore.properties + +# vscode +.vscode + +# cxx +.cxx + +*.hprof + +# firebase +google-services.json + +# Dolphin +.directory + +# logs +*.log \ No newline at end of file diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..00d59c05 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "core/src/main/golang/clash"] + path = core/src/main/golang/clash + url = https://github.com/Kr328/clash.git diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 00000000..446cdb23 --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,151 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 00000000..79ee123c --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..ed89524b --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,14 @@ +## Contributing to Clash for Android + +#### Code Style + +Please use `Android Studio` or `Intellij IDEA` to open the project and use the project code style profile. + +`File` -> `Settings` -> `Editor` -> `Code Style` -> `C/C++ and Kotlin` -> `Scheme` -> `Project` + + + +#### License + +Contributing to Clash for Android that assumes you allow code to be merged into closed-source branches. Other terms follow the [GPLv3](https://www.gnu.org/licenses/gpl-3.0.html) + diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..f288702d --- /dev/null +++ b/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/NOTICE b/NOTICE new file mode 100644 index 00000000..6853d882 --- /dev/null +++ b/NOTICE @@ -0,0 +1,833 @@ +3th-party software licenses + + * Clash +========================================================================== + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. + + * Android Open Source Project + * Android X Support Library +========================================================================== + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + 1. Definitions. + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + END OF TERMS AND CONDITIONS diff --git a/PRIVACY_POLICY.md b/PRIVACY_POLICY.md new file mode 100644 index 00000000..48f98b1a --- /dev/null +++ b/PRIVACY_POLICY.md @@ -0,0 +1,50 @@ +## Privacy Policy + +The Clash for Android is built as an Open Source software. This app is provided by personal at no cost and is intended for use as is. + +This page is used to inform visitors regarding our policies with the collection, use, and disclosure of Personal Information if anyone decided to use our app. + +If you choose to use our app, then you agree to the collection and use of information in relation to this policy. The Personal Information that we collect is used for providing and improving the app. We will not use or share your information with anyone except as described in this Privacy Policy. + +The terms used in this Privacy Policy have the same meanings as in our Terms and Conditions, which is accessible at Clash for Android unless otherwise defined in this Privacy Policy. + +**Information Collection and Use** + +For a better experience, while using our app, we may require you to provide us with certain personally identifiable information. The information that we request will be retained by us and used as described in this privacy policy. + +The app does use third party services that may collect information used to identify you. + +Link to privacy policy of third party service providers used by the app + +* [Google Play Services](https://www.google.com/policies/privacy/) +* [AppCenter](https://docs.microsoft.com/en-us/appcenter/gdpr/) + +**Log Data** + +We want to inform you that whenever you use our app, in a case of an error in the app we collect data and information (through third party products) on your phone called Log Data. This Log Data may include information such as your device Internet Protocol (“IP”) address, device name, operating system version, the configuration of the app when utilizing our App, the time and date of your use of the app, and other statistics. + +**Cookies** + +Cookies are files with a small amount of data that are commonly used as anonymous unique identifiers. These are sent to your browser from the websites that you visit and are stored on your device's internal memory. + +This app does not use these “cookies” explicitly. However, the app may use third party code and libraries that use “cookies” to collect information and improve their services. You have the option to either accept or refuse these cookies and know when a cookie is being sent to your device. If you choose to refuse our cookies, you may not be able to use some portions of this app. + +**Security** + +We value your trust in providing us your Personal Information, thus we are striving to use commercially acceptable means of protecting it. But remember that no method of transmission over the internet, or method of electronic storage is 100% secure and reliable, and we cannot guarantee its absolute security. + +**Links to Other Sites** + +This app may contain links to other sites. If you click on a third-party link, you will be directed to that site. Note that these external sites are not operated by us. Therefore, we strongly advise you to review the Privacy Policy of these websites. We have no control over and assume no responsibility for the content, privacy policies, or practices of any third-party sites or services. + +**Children’s Privacy** + +These Services do not address anyone under the age of 13\. We do not knowingly collect personally identifiable information from children under 13\. In the case we discover that a child under 13 has provided us with personal information, we immediately delete this from our servers. If you are a parent or guardian and you are aware that your child has provided us with personal information, please contact us so that we will be able to do necessary actions. + +**Changes to This Privacy Policy** + +We may update our Privacy Policy from time to time. Thus, you are advised to review this page periodically for any changes. We will notify you of any changes by posting the new Privacy Policy on this page. These changes are effective immediately after they are posted on this page. + +**Contact Us** + +If you have any questions or suggestions about our Privacy Policy, do not hesitate to contact us. diff --git a/README.md b/README.md new file mode 100644 index 00000000..8191d9fd --- /dev/null +++ b/README.md @@ -0,0 +1,63 @@ +## Clash for Android + +A Graphical user interface of [clash](https://github.com/Dreamacro/clash) for Android + +Get it on Google Play or [Releases](https://github.com/Kr328/ClashForAndroid/releases) + +### Feature + +Fully feature of [clash](https://github.com/Dreamacro/clash) ~~(Exclude `external-controller`~~ + + + +### Requirement + +* Android 5.0+ (minimum) +* Android 7.0+ (recommend) +* `armeabi-v7a` , `arm64-v8a`, `x86` or `x86_64` Architecture + +### License + +See also [LICENSE](./LICENSE) and [NOTICE](./NOTICE) + + + +### Privacy Policy + +See also [PRIVACY_POLICY.md](./PRIVACY_POLICY.md) + + + +### Build + +1. Update submodules + + ```bash + git submodule update --init --recursive + ``` + +2. Install `JDK 1.8`, `Android SDK` and `Golang` + +3. Create `local.properties` in project root with + + ```properties + sdk.dir=/path/to/android-sdk + appcenter.key= # Optional, from "appcenter.ms" + ``` + +4. Create `keystore.properties` in project root with + + ```properties + storeFile=/path/to/keystore/file + storePassword= + keyAlias= + keyPassword= + ``` + +5. Build + + ```bash + ./gradlew app:assembleRelease + ``` + +6. Pick `app-release-.apk` in `app/build/outputs/apks` \ No newline at end of file diff --git a/app/build.gradle.kts b/app/build.gradle.kts new file mode 100644 index 00000000..a69f7149 --- /dev/null +++ b/app/build.gradle.kts @@ -0,0 +1,136 @@ +import java.util.* + +plugins { + id("com.android.application") + kotlin("android") + kotlin("kapt") +} + +android { + compileSdk = buildTargetSdkVersion + + flavorDimensions(buildFlavor) + + defaultConfig { + applicationId = "com.github.kr328.clash" + + minSdk = buildMinSdkVersion + targetSdk = buildTargetSdkVersion + + versionCode = buildVersionCode + versionName = buildVersionName + + resConfigs("zh-rCN", "zh-rHK", "zh-rTW") + + resValue("string", "release_name", "v$buildVersionName") + resValue("integer", "release_code", "$buildVersionCode") + } + + buildTypes { + named("release") { + isMinifyEnabled = true + isShrinkResources = true + proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") + } + } + + productFlavors { + create("open") { + dimension = "open" + versionNameSuffix = ".open-source" + } + create("premium") { + dimension = "premium" + versionNameSuffix = ".premium" + } + } + + buildFeatures { + dataBinding = true + } + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + + kotlinOptions { + jvmTarget = "1.8" + } + + splits { + abi { + isEnable = true + isUniversalApk = true + } + } + + buildTypes.apply { + val properties = Properties().apply { + rootProject.file("local.properties").inputStream().use { + load(it) + } + } + + val key = properties.getProperty("appcenter.key", null) + + forEach { + if (it.name == "debug" || key == null) { + it.buildConfigField("String", "APP_CENTER_KEY", "null") + } else { + it.buildConfigField("String", "APP_CENTER_KEY", "\"$key\"") + } + } + } + + signingConfigs.apply { + val signingFile = rootProject.file("keystore.properties") + if ( signingFile.exists() ) { + val properties = Properties().apply { + signingFile.inputStream().use { + load(it) + } + } + signingConfigs { + named("release") { + storeFile = rootProject.file(Objects.requireNonNull(properties.getProperty("storeFile"))) + storePassword = Objects.requireNonNull(properties.getProperty("storePassword")) + keyAlias = Objects.requireNonNull(properties.getProperty("keyAlias")) + keyPassword = Objects.requireNonNull(properties.getProperty("keyPassword")) + } + } + buildTypes { + named("release") { + this.signingConfig = signingConfigs.findByName("release") + } + } + } + } +} + +dependencies { + api(project(":core")) + api(project(":service")) + api(project(":design")) + api(project(":common")) + + implementation(kotlin("stdlib-jdk7")) + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutineVersion") + implementation("androidx.core:core-ktx:$ktxVersion") + implementation("androidx.activity:activity:$activityVersion") + implementation("androidx.appcompat:appcompat:$appcompatVersion") + implementation("androidx.coordinatorlayout:coordinatorlayout:$coordinatorlayoutVersion") + implementation("androidx.recyclerview:recyclerview:$recyclerviewVersion") + implementation("androidx.fragment:fragment:$fragmentVersion") + implementation("com.microsoft.appcenter:appcenter-analytics:$appcenterVersion") + implementation("com.microsoft.appcenter:appcenter-crashes:$appcenterVersion") + implementation("com.google.android.material:material:$materialVersion") +} + +task("cleanRelease", type = Delete::class) { + delete(file("release")) +} + +afterEvaluate { + tasks["clean"].dependsOn(tasks["cleanRelease"]) +} \ No newline at end of file diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 00000000..0d5ce2d4 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,33 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile + +-dontobfuscate + +-assumenosideeffects class kotlin.jvm.internal.Intrinsics { + public static void checkNotNull(...); + public static void checkExpressionValueIsNotNull(...); + public static void checkNotNullExpressionValue(...); + public static void checkReturnedValueIsNotNull(...); + public static void checkFieldIsNotNull(...); + public static void checkParameterIsNotNull(...); + public static void checkNotNullParameter(...); +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 00000000..d63f9653 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,179 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/ic_launcher-web.png b/app/src/main/ic_launcher-web.png new file mode 100644 index 0000000000000000000000000000000000000000..853d58dcc7bc1697abb9f9c57a0ed6dbe357159a GIT binary patch literal 16852 zcmeIaWmr_v*Eo8HMhQVeLPA;^rCUG*lvY$)KuSWoXG~POMOr{mlnuhU%$_5YL%Zmncj=>r1vZ{WCNMtzCu|=r z8u56a6W&0PvR}y3XhA3~*H!f5_eas)uw#$gG21!vFs;3VDNWpTRI(7hARz8JUSxj#iEW+wwV-^Vir|Re5;?J&GrQhKxjl4Q?_KN6@7Xg@) zeF&PdEDiMJ7;83HZ{jf0*VT26sFd6p*%FgJI1E_QZh z3Klu3yN*QEx+?GB+S=VeXy6dUdk1f|4$9F^iT-9>ae9$7_Y`lVWB8jf=F8W*6NYWD zDknpze_)`i3L>Ut2^}7LMqoHMTQI-0B>Cw8A5yYkzJNHVq^%vket|bCDyrC~BYt>K z<~d~eBOha%7P!~YA=94_%nCuP)aiB5QcqgK#>U3=Z|pmGhCgOqHu5?P3(r$*rpT(rdiU>8SXn$9Y$$KV++`HbbhF|^K9*V+VT3bTRt(JZlEuKMJF>VT zb`$02h)(|g1)3kAeb&FRo+adENP;tC+Rp%RQ(_1*+9xRN!5^*m%qz9)o2`%_wcth0nqwLiTxXOnzXNns%8*4SCi01jidHl0 zHit57BZlexU;=WRJ&)~1xH&nms{_M?9I}Munb;H*%)C%jg6!<<3-`>D~<0s;a4}$|?@5$^k z*5Tr%D~S*Z1f||5O~)(r+jZ!}LLtMye;dj#^Xx)T%@Ea}!XTspUSYtY8!dwAiFmUD z!v$C&0zzjUPtV*W0PrW&2xlg$+>5Q-sKE%WOGFmpO0*Fe^TZREm5+z`SYw`g0ZJjT zyNFO6bqL*dfEHo*ZP3#*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1i-;uMiONTaD95~|C4`|;Bze+?mki9!!G?A8}>sQYTBy#H!Pn2AABUf@Bjb+ literal 0 HcmV?d00001 diff --git a/app/src/main/java/com/github/kr328/clash/AccessControlActivity.kt b/app/src/main/java/com/github/kr328/clash/AccessControlActivity.kt new file mode 100644 index 00000000..546dfed4 --- /dev/null +++ b/app/src/main/java/com/github/kr328/clash/AccessControlActivity.kt @@ -0,0 +1,142 @@ +package com.github.kr328.clash + +import android.Manifest.permission.INTERNET +import android.content.ClipData +import android.content.ClipboardManager +import android.content.pm.ApplicationInfo +import android.content.pm.PackageInfo +import android.content.pm.PackageManager +import androidx.core.content.getSystemService +import com.github.kr328.clash.design.AccessControlDesign +import com.github.kr328.clash.design.model.AppInfo +import com.github.kr328.clash.design.util.toAppInfo +import com.github.kr328.clash.service.store.ServiceStore +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.isActive +import kotlinx.coroutines.selects.select +import kotlinx.coroutines.withContext + +class AccessControlActivity : BaseActivity() { + override suspend fun main() { + val service = ServiceStore(this) + + val selected = withContext(Dispatchers.IO) { + service.accessControlPackages.toMutableSet() + } + + defer { + withContext(Dispatchers.IO) { + service.accessControlPackages = selected + } + } + + val design = AccessControlDesign(this, uiStore, selected) + + setContentDesign(design) + + design.requests.send(AccessControlDesign.Request.ReloadApps) + + while (isActive) { + select { + events.onReceive { + + } + design.requests.onReceive { + when (it) { + AccessControlDesign.Request.ReloadApps -> { + design.patchApps(loadApps(selected)) + } + AccessControlDesign.Request.SelectAll -> { + val all = withContext(Dispatchers.Default) { + design.apps.map(AppInfo::packageName) + } + + selected.clear() + selected.addAll(all) + + design.rebindAll() + } + AccessControlDesign.Request.SelectNone -> { + selected.clear() + + design.rebindAll() + } + AccessControlDesign.Request.SelectInvert -> { + val all = withContext(Dispatchers.Default) { + design.apps.map(AppInfo::packageName).toSet() - selected + } + + selected.clear() + selected.addAll(all) + + design.rebindAll() + } + AccessControlDesign.Request.Import -> { + val clipboard = getSystemService() + val data = clipboard?.primaryClip + + if (data != null && data.itemCount > 0) { + val all = withContext(Dispatchers.IO) { + val packages = data.getItemAt(0).text.split("\n").toSet() + + design.apps.map(AppInfo::packageName).intersect(packages) + } + + selected.clear() + selected.addAll(all) + } + + design.rebindAll() + } + AccessControlDesign.Request.Export -> { + val clipboard = getSystemService() + + withContext(Dispatchers.IO) { + val data = ClipData.newPlainText( + "packages", + selected.joinToString("\n") + ) + + clipboard?.setPrimaryClip(data) + } + } + } + } + } + } + } + + private suspend fun loadApps(selected: Set): List = + withContext(Dispatchers.IO) { + val reverse = uiStore.accessControlReverse + val sort = uiStore.accessControlSort + val systemApp = uiStore.accessControlSystemApp + + val base = compareByDescending { it.packageName in selected } + val comparator = if (reverse) base.thenDescending(sort) else base.then(sort) + + val pm = packageManager + val packages = pm.getInstalledPackages(PackageManager.GET_PERMISSIONS) + + packages.asSequence() + .filter { + it.packageName != packageName + } + .filter { + it.packageName == "android" || it.requestedPermissions?.contains(INTERNET) == true + } + .filter { + systemApp || !it.isSystemApp + } + .map { + it.toAppInfo(pm) + } + .sortedWith(comparator) + .toList() + } + + private val PackageInfo.isSystemApp: Boolean + get() { + return applicationInfo.flags and ApplicationInfo.FLAG_SYSTEM != 0 + } +} \ No newline at end of file diff --git a/app/src/main/java/com/github/kr328/clash/ApkBrokenActivity.kt b/app/src/main/java/com/github/kr328/clash/ApkBrokenActivity.kt new file mode 100644 index 00000000..33f41452 --- /dev/null +++ b/app/src/main/java/com/github/kr328/clash/ApkBrokenActivity.kt @@ -0,0 +1,20 @@ +package com.github.kr328.clash + +import android.content.Intent +import android.net.Uri +import com.github.kr328.clash.design.ApkBrokenDesign +import kotlinx.coroutines.isActive + +class ApkBrokenActivity : BaseActivity() { + override suspend fun main() { + val design = ApkBrokenDesign(this) + + setContentDesign(design) + + while (isActive) { + val req = design.requests.receive() + + startActivity(Intent(Intent.ACTION_VIEW).setData(Uri.parse(req.url))) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/github/kr328/clash/AppCrashedActivity.kt b/app/src/main/java/com/github/kr328/clash/AppCrashedActivity.kt new file mode 100644 index 00000000..b94d2858 --- /dev/null +++ b/app/src/main/java/com/github/kr328/clash/AppCrashedActivity.kt @@ -0,0 +1,46 @@ +package com.github.kr328.clash + +import android.os.DeadObjectException +import com.github.kr328.clash.common.compat.versionCodeCompat +import com.github.kr328.clash.common.log.Log +import com.github.kr328.clash.design.AppCrashedDesign +import com.github.kr328.clash.log.SystemLogcat +import com.microsoft.appcenter.crashes.Crashes +import com.microsoft.appcenter.crashes.ingestion.models.ErrorAttachmentLog +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.isActive +import kotlinx.coroutines.withContext + +class AppCrashedActivity : BaseActivity() { + override suspend fun main() { + val design = AppCrashedDesign(this) + + setContentDesign(design) + + val packageInfo = withContext(Dispatchers.IO) { + packageManager.getPackageInfo(packageName, 0) + } + + Log.i("App version: versionName = ${packageInfo.versionName} versionCode = ${packageInfo.versionCodeCompat}") + + val logs = withContext(Dispatchers.IO) { + SystemLogcat.dumpCrash() + } + + if (BuildConfig.APP_CENTER_KEY != null && !BuildConfig.DEBUG) { + if (logs.isNotBlank()) { + Crashes.trackError( + DeadObjectException(), + mapOf("type" to "app_crashed"), + listOf(ErrorAttachmentLog.attachmentWithText(logs, "logcat.txt")) + ) + } + } + + design.setAppLogs(logs) + + while (isActive) { + events.receive() + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/github/kr328/clash/AppSettingsActivity.kt b/app/src/main/java/com/github/kr328/clash/AppSettingsActivity.kt new file mode 100644 index 00000000..c600c4eb --- /dev/null +++ b/app/src/main/java/com/github/kr328/clash/AppSettingsActivity.kt @@ -0,0 +1,62 @@ +package com.github.kr328.clash + +import android.content.pm.PackageManager +import com.github.kr328.clash.common.util.componentName +import com.github.kr328.clash.design.AppSettingsDesign +import com.github.kr328.clash.design.model.Behavior +import com.github.kr328.clash.service.store.ServiceStore +import com.github.kr328.clash.util.ApplicationObserver +import kotlinx.coroutines.isActive +import kotlinx.coroutines.selects.select + +class AppSettingsActivity : BaseActivity(), Behavior { + override suspend fun main() { + val design = AppSettingsDesign( + this, + uiStore, + ServiceStore(this), + this, + clashRunning, + ) + + setContentDesign(design) + + while (isActive) { + select { + events.onReceive { + when (it) { + Event.ClashStart, Event.ClashStop, Event.ServiceRecreated -> + recreate() + else -> Unit + } + } + design.requests.onReceive { + ApplicationObserver.createdActivities.forEach { + it.recreate() + } + } + } + } + } + + override var autoRestart: Boolean + get() { + val status = packageManager.getComponentEnabledSetting( + RestartReceiver::class.componentName + ) + + return status == PackageManager.COMPONENT_ENABLED_STATE_ENABLED + } + set(value) { + val status = if (value) + PackageManager.COMPONENT_ENABLED_STATE_ENABLED + else + PackageManager.COMPONENT_ENABLED_STATE_DISABLED + + packageManager.setComponentEnabledSetting( + RestartReceiver::class.componentName, + status, + PackageManager.DONT_KILL_APP, + ) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/github/kr328/clash/BaseActivity.kt b/app/src/main/java/com/github/kr328/clash/BaseActivity.kt new file mode 100644 index 00000000..83073345 --- /dev/null +++ b/app/src/main/java/com/github/kr328/clash/BaseActivity.kt @@ -0,0 +1,249 @@ +package com.github.kr328.clash + +import android.content.res.Configuration +import android.os.Build +import android.os.Bundle +import android.view.View +import androidx.activity.result.contract.ActivityResultContract +import androidx.appcompat.app.AppCompatActivity +import com.github.kr328.clash.common.compat.isAllowForceDarkCompat +import com.github.kr328.clash.common.compat.isLightNavigationBarCompat +import com.github.kr328.clash.common.compat.isLightStatusBarsCompat +import com.github.kr328.clash.common.compat.isSystemBarsTranslucentCompat +import com.github.kr328.clash.core.bridge.ClashException +import com.github.kr328.clash.design.Design +import com.github.kr328.clash.design.model.DarkMode +import com.github.kr328.clash.design.store.UiStore +import com.github.kr328.clash.design.ui.DayNight +import com.github.kr328.clash.design.util.resolveThemedBoolean +import com.github.kr328.clash.design.util.resolveThemedColor +import com.github.kr328.clash.design.util.showExceptionToast +import com.github.kr328.clash.remote.Broadcasts +import com.github.kr328.clash.remote.Remote +import com.github.kr328.clash.util.ActivityResultLifecycle +import com.github.kr328.clash.util.ApplicationObserver +import kotlinx.coroutines.* +import kotlinx.coroutines.channels.Channel +import java.util.concurrent.atomic.AtomicInteger +import kotlin.coroutines.resume +import kotlin.coroutines.suspendCoroutine + +abstract class BaseActivity> : + AppCompatActivity(), + CoroutineScope by MainScope(), + Broadcasts.Observer { + enum class Event { + ServiceRecreated, + ActivityStart, + ActivityStop, + ClashStop, + ClashStart, + ProfileLoaded, + ProfileChanged + } + + + protected val uiStore by lazy { UiStore(this) } + protected val events = Channel(Channel.UNLIMITED) + protected var activityStarted: Boolean = false + protected val clashRunning: Boolean + get() = Remote.broadcasts.clashRunning + protected var design: D? = null + private set(value) { + field = value + + if (value != null) { + setContentView(value.root) + } else { + setContentView(View(this)) + } + } + + private var defer: suspend () -> Unit = {} + private var deferRunning = false + private val nextRequestKey = AtomicInteger(0) + private var dayNight: DayNight = DayNight.Day + + protected abstract suspend fun main() + + fun defer(operation: suspend () -> Unit) { + this.defer = operation + } + + suspend fun startActivityForResult( + contracts: ActivityResultContract, + input: I + ): O = withContext(Dispatchers.Main) { + val requestKey = nextRequestKey.getAndIncrement().toString() + + ActivityResultLifecycle().use { lifecycle, start -> + suspendCoroutine { c -> + activityResultRegistry.register(requestKey, lifecycle, contracts) { + c.resumeWith(Result.success(it)) + }.apply { start() }.launch(input) + } + } + } + + suspend fun setContentDesign(design: D) { + suspendCoroutine { + window.decorView.post { + this.design = design + + it.resume(Unit) + } + } + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + + applyDayNight() + + launch { + main() + + finish() + } + } + + override fun onStart() { + super.onStart() + + activityStarted = true + + Remote.broadcasts.addObserver(this) + + events.offer(Event.ActivityStart) + } + + override fun onStop() { + super.onStop() + + activityStarted = false + + Remote.broadcasts.removeObserver(this) + + events.offer(Event.ActivityStop) + } + + override fun onDestroy() { + design?.cancel() + + cancel() + + super.onDestroy() + } + + override fun finish() { + if (deferRunning) { + return + } + + deferRunning = true + + launch { + try { + defer() + } finally { + withContext(NonCancellable) { + super.finish() + } + } + } + } + + override fun onConfigurationChanged(newConfig: Configuration) { + super.onConfigurationChanged(newConfig) + + if (queryDayNight(newConfig) != dayNight) { + ApplicationObserver.createdActivities.forEach { + it.recreate() + } + } + } + + open fun shouldDisplayHomeAsUpEnabled(): Boolean { + return true + } + + override fun onSupportNavigateUp(): Boolean { + this.onBackPressed() + + return true + } + + override fun onProfileChanged() { + events.offer(Event.ProfileChanged) + } + + override fun onProfileLoaded() { + events.offer(Event.ProfileLoaded) + } + + override fun onServiceRecreated() { + events.offer(Event.ServiceRecreated) + } + + override fun onStarted() { + events.offer(Event.ClashStart) + } + + override fun onStopped(cause: String?) { + events.offer(Event.ClashStop) + + if (cause != null && activityStarted) { + launch { + design?.showExceptionToast(ClashException(cause)) + } + } + } + + private fun queryDayNight(config: Configuration = resources.configuration): DayNight { + return when (uiStore.darkMode) { + DarkMode.Auto -> { + if (config.uiMode and Configuration.UI_MODE_NIGHT_MASK == Configuration.UI_MODE_NIGHT_YES) + DayNight.Night + else + DayNight.Day + } + DarkMode.ForceLight -> { + DayNight.Day + } + DarkMode.ForceDark -> { + DayNight.Night + } + } + } + + private fun applyDayNight(config: Configuration = resources.configuration) { + val dayNight = queryDayNight(config) + + when (dayNight) { + DayNight.Night -> { + theme.applyStyle(R.style.AppThemeDark, true) + } + DayNight.Day -> { + theme.applyStyle(R.style.AppThemeLight, true) + } + } + + window.isAllowForceDarkCompat = false + window.isSystemBarsTranslucentCompat = true + + window.statusBarColor = resolveThemedColor(android.R.attr.statusBarColor) + window.navigationBarColor = resolveThemedColor(android.R.attr.navigationBarColor) + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + window.isLightStatusBarsCompat = + resolveThemedBoolean(android.R.attr.windowLightStatusBar) + } + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) { + window.isLightNavigationBarCompat = + resolveThemedBoolean(android.R.attr.windowLightNavigationBar) + } + + this.dayNight = dayNight + } +} diff --git a/app/src/main/java/com/github/kr328/clash/ExternalImportActivity.kt b/app/src/main/java/com/github/kr328/clash/ExternalImportActivity.kt new file mode 100644 index 00000000..619a9131 --- /dev/null +++ b/app/src/main/java/com/github/kr328/clash/ExternalImportActivity.kt @@ -0,0 +1,44 @@ +package com.github.kr328.clash + +import android.app.Activity +import android.content.Intent +import android.os.Bundle +import com.github.kr328.clash.common.util.intent +import com.github.kr328.clash.common.util.setUUID +import com.github.kr328.clash.service.model.Profile +import com.github.kr328.clash.util.withProfile +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.MainScope +import kotlinx.coroutines.launch +import java.util.* + +class ExternalImportActivity : Activity(), CoroutineScope by MainScope() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + + if (intent.action != Intent.ACTION_VIEW) + return finish() + + val uri = intent.data ?: return finish() + val url = uri.getQueryParameter("url") ?: return finish() + + launch { + val uuid = withProfile { + val type = when (uri.getQueryParameter("type")?.lowercase(Locale.getDefault())) { + "url" -> Profile.Type.Url + "file" -> Profile.Type.File + else -> Profile.Type.Url + } + val name = uri.getQueryParameter("name") ?: getString(R.string.new_profile) + + create(type, name).also { + patch(it, name, url, 0) + } + } + + startActivity(PropertiesActivity::class.intent.setUUID(uuid)) + + finish() + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/github/kr328/clash/FilesActivity.kt b/app/src/main/java/com/github/kr328/clash/FilesActivity.kt new file mode 100644 index 00000000..e8ebb3d1 --- /dev/null +++ b/app/src/main/java/com/github/kr328/clash/FilesActivity.kt @@ -0,0 +1,160 @@ +@file:Suppress("BlockingMethodInNonBlockingContext") + +package com.github.kr328.clash + +import android.Manifest +import android.content.Intent +import android.content.pm.PackageManager +import android.net.Uri +import android.os.Build +import androidx.activity.result.contract.ActivityResultContracts +import androidx.core.content.ContextCompat +import com.github.kr328.clash.common.util.grantPermissions +import com.github.kr328.clash.common.util.ticker +import com.github.kr328.clash.common.util.uuid +import com.github.kr328.clash.design.FilesDesign +import com.github.kr328.clash.design.util.showExceptionToast +import com.github.kr328.clash.remote.FilesClient +import com.github.kr328.clash.service.model.Profile +import com.github.kr328.clash.util.fileName +import com.github.kr328.clash.util.withProfile +import kotlinx.coroutines.isActive +import kotlinx.coroutines.selects.select +import java.util.* +import java.util.concurrent.TimeUnit + +class FilesActivity : BaseActivity() { + override suspend fun main() { + val uuid = intent.uuid ?: return finish() + val profile = withProfile { queryByUUID(uuid) } ?: return finish() + val root = uuid.toString() + + val design = FilesDesign(this) + val client = FilesClient(this) + val stack = Stack() + + design.configurationEditable = profile.type != Profile.Type.Url + design.fetch(client, stack, root) + + setContentDesign(design) + + val ticker = ticker(TimeUnit.MINUTES.toMillis(1)) + + while (isActive) { + select { + events.onReceive { + when (it) { + Event.ActivityStart, Event.ActivityStop -> { + design.fetch(client, stack, root) + } + else -> Unit + } + } + design.requests.onReceive { + try { + when (it) { + FilesDesign.Request.PopStack -> { + if (stack.empty()) { + finish() + } else { + stack.pop() + } + } + is FilesDesign.Request.OpenDirectory -> { + stack.push(it.file.id) + } + is FilesDesign.Request.OpenFile -> { + startActivityForResult( + ActivityResultContracts.StartActivityForResult(), + Intent(Intent.ACTION_VIEW).setDataAndType( + client.buildDocumentUri(it.file.id), + "text/plain" + ).grantPermissions() + ) + } + is FilesDesign.Request.DeleteFile -> { + client.deleteDocument(it.file.id) + } + is FilesDesign.Request.RenameFile -> { + val newName = design.requestFileName(it.file.name) + + client.renameDocument(it.file.id, newName) + } + is FilesDesign.Request.ImportFile -> { + if (Build.VERSION.SDK_INT >= 23) { + val hasPermission = ContextCompat.checkSelfPermission( + this@FilesActivity, + Manifest.permission.READ_EXTERNAL_STORAGE + ) == PackageManager.PERMISSION_GRANTED + + if (!hasPermission) { + val granted = startActivityForResult( + ActivityResultContracts.RequestPermission(), + Manifest.permission.READ_EXTERNAL_STORAGE, + ) + + if (!granted) { + return@onReceive + } + } + } + + val uri: Uri? = startActivityForResult( + ActivityResultContracts.GetContent(), + "*/*" + ) + + if (uri != null) { + if (it.file == null) { + val name = design.requestFileName(uri.fileName ?: "File") + + client.importDocument(stack.last(), uri, name) + } else { + client.copyDocument(it.file!!.id, uri) + } + } + } + is FilesDesign.Request.ExportFile -> { + val uri: Uri? = startActivityForResult( + ActivityResultContracts.CreateDocument(), + it.file.name + ) + + if (uri != null) { + client.copyDocument(uri, it.file.id) + } + } + } + } catch (e: Exception) { + design.showExceptionToast(e) + } + + design.fetch(client, stack, root) + } + if (activityStarted) { + ticker.onReceive { + design.updateElapsed() + } + } + } + } + } + + override fun onBackPressed() { + design?.requests?.offer(FilesDesign.Request.PopStack) + } + + private suspend fun FilesDesign.fetch(client: FilesClient, stack: Stack, root: String) { + val documentId = stack.lastOrNull() ?: root + val files = if (stack.empty()) { + val list = client.list(documentId) + val config = list.firstOrNull { it.id.endsWith("config.yaml") } + + if (config == null || config.size > 0) list else listOf(config) + } else { + client.list(documentId) + } + + swapFiles(files, stack.empty()) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/github/kr328/clash/HelpActivity.kt b/app/src/main/java/com/github/kr328/clash/HelpActivity.kt new file mode 100644 index 00000000..af25b816 --- /dev/null +++ b/app/src/main/java/com/github/kr328/clash/HelpActivity.kt @@ -0,0 +1,19 @@ +package com.github.kr328.clash + +import android.content.Intent +import com.github.kr328.clash.design.HelpDesign +import kotlinx.coroutines.isActive + +class HelpActivity : BaseActivity() { + override suspend fun main() { + val design = HelpDesign(this) { + startActivity(Intent(Intent.ACTION_VIEW).setData(it)) + } + + setContentDesign(design) + + while (isActive) { + events.receive() + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/github/kr328/clash/LogcatActivity.kt b/app/src/main/java/com/github/kr328/clash/LogcatActivity.kt new file mode 100644 index 00000000..0276852e --- /dev/null +++ b/app/src/main/java/com/github/kr328/clash/LogcatActivity.kt @@ -0,0 +1,185 @@ +package com.github.kr328.clash + +import android.content.ComponentName +import android.content.Context +import android.content.ServiceConnection +import android.net.Uri +import android.os.IBinder +import android.widget.Toast +import androidx.activity.result.contract.ActivityResultContracts +import com.github.kr328.clash.common.compat.startForegroundServiceCompat +import com.github.kr328.clash.common.util.fileName +import com.github.kr328.clash.common.util.intent +import com.github.kr328.clash.common.util.ticker +import com.github.kr328.clash.core.model.LogMessage +import com.github.kr328.clash.design.LogcatDesign +import com.github.kr328.clash.design.dialog.withModelProgressBar +import com.github.kr328.clash.design.model.LogFile +import com.github.kr328.clash.design.ui.ToastDuration +import com.github.kr328.clash.design.util.showExceptionToast +import com.github.kr328.clash.log.LogcatFilter +import com.github.kr328.clash.log.LogcatReader +import com.github.kr328.clash.util.logsDir +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.isActive +import kotlinx.coroutines.selects.select +import kotlinx.coroutines.withContext +import java.io.OutputStreamWriter +import kotlin.coroutines.resume +import kotlin.coroutines.suspendCoroutine + +class LogcatActivity : BaseActivity() { + private var conn: ServiceConnection? = null + + override suspend fun main() { + val fileName = intent?.fileName + + if (fileName != null) { + val file = LogFile.parseFromFileName(fileName) ?: return showInvalid() + + return mainLocalFile(file) + } + + return mainStreaming() + } + + private suspend fun mainLocalFile(file: LogFile) { + val messages = try { + LogcatReader(this, file).readAll() + } catch (e: Exception) { + return showInvalid() + } + + val design = LogcatDesign(this, false) + + setContentDesign(design) + + design.patchMessages(messages, 0, messages.size) + + while (isActive) { + when (design.requests.receive()) { + LogcatDesign.Request.Delete -> { + withContext(Dispatchers.IO) { + logsDir.resolve(file.fileName).delete() + } + + finish() + } + LogcatDesign.Request.Export -> { + val output = startActivityForResult( + ActivityResultContracts.CreateDocument(), + file.fileName + ) + + if (output != null) { + try { + withContext(Dispatchers.IO) { + writeLogTo(messages, file, output) + } + + design.showToast(R.string.file_exported, ToastDuration.Long) + } catch (e: Exception) { + design.showExceptionToast(e) + } + } + } + else -> Unit + } + } + } + + private suspend fun mainStreaming() { + val design = LogcatDesign(this, true) + + setContentDesign(design) + + startForegroundServiceCompat(LogcatService::class.intent) + + val logcat = bindLogcatService() + val ticker = ticker(500) + + var initial = true + + while (isActive) { + select { + events.onReceive { + + } + design.requests.onReceive { + when (it) { + LogcatDesign.Request.Close -> { + stopService(LogcatService::class.intent) + + finish() + } + else -> Unit + } + } + if (activityStarted) { + ticker.onReceive { + val snapshot = logcat.snapshot(initial) ?: return@onReceive + + design.patchMessages(snapshot.messages, snapshot.removed, snapshot.appended) + + initial = false + } + } + } + } + } + + override fun onDestroy() { + conn?.apply(this::unbindService) + + super.onDestroy() + } + + private suspend fun bindLogcatService(): LogcatService { + return suspendCoroutine { ctx -> + bindService(LogcatService::class.intent, object : ServiceConnection { + override fun onServiceConnected(name: ComponentName?, service: IBinder?) { + val srv = service!!.queryLocalInterface("") as LogcatService + + ctx.resume(srv) + + conn = this + } + + override fun onServiceDisconnected(name: ComponentName?) { + conn = null + } + }, Context.BIND_AUTO_CREATE) + } + } + + @Suppress("BlockingMethodInNonBlockingContext") + private suspend fun writeLogTo(messages: List, file: LogFile, uri: Uri) { + LogcatFilter(OutputStreamWriter(contentResolver.openOutputStream(uri)), this).use { + withContext(Dispatchers.Main) { + withModelProgressBar { + configure { + isIndeterminate = true + max = messages.size + } + + withContext(Dispatchers.IO) { + it.writeHeader(file.date) + + messages.forEachIndexed { idx, msg -> + configure { + isIndeterminate = false + progress = idx + } + + it.writeMessage(msg) + } + } + } + } + } + } + + private fun showInvalid() { + Toast.makeText(this, R.string.invalid_log_file, Toast.LENGTH_LONG).show() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/github/kr328/clash/LogcatService.kt b/app/src/main/java/com/github/kr328/clash/LogcatService.kt new file mode 100644 index 00000000..bb17c24e --- /dev/null +++ b/app/src/main/java/com/github/kr328/clash/LogcatService.kt @@ -0,0 +1,169 @@ +package com.github.kr328.clash + +import android.app.NotificationChannel +import android.app.NotificationManager +import android.app.PendingIntent +import android.app.Service +import android.content.ComponentName +import android.content.Context +import android.content.Intent +import android.content.ServiceConnection +import android.os.Binder +import android.os.Build +import android.os.IBinder +import android.os.IInterface +import androidx.core.app.NotificationCompat +import androidx.core.app.NotificationManagerCompat +import com.github.kr328.clash.common.compat.getColorCompat +import com.github.kr328.clash.common.log.Log +import com.github.kr328.clash.common.util.intent +import com.github.kr328.clash.core.model.LogMessage +import com.github.kr328.clash.log.LogcatCache +import com.github.kr328.clash.log.LogcatWriter +import com.github.kr328.clash.service.ClashManager +import com.github.kr328.clash.service.remote.IClashManager +import com.github.kr328.clash.service.remote.ILogObserver +import com.github.kr328.clash.service.remote.unwrap +import com.github.kr328.clash.util.logsDir +import kotlinx.coroutines.* +import kotlinx.coroutines.channels.Channel +import java.io.IOException +import java.util.* + +class LogcatService : Service(), CoroutineScope by CoroutineScope(Dispatchers.Default), IInterface { + private val cache = LogcatCache() + + private val connection = object : ServiceConnection { + override fun onServiceDisconnected(name: ComponentName?) { + stopSelf() + } + + override fun onServiceConnected(name: ComponentName?, service: IBinder?) { + startObserver(service ?: return stopSelf()) + } + } + + override fun onCreate() { + super.onCreate() + + running = true + + createNotificationChannel() + + showNotification() + + bindService(ClashManager::class.intent, connection, Context.BIND_AUTO_CREATE) + } + + override fun onDestroy() { + cancel() + + unbindService(connection) + + stopForeground(true) + + running = false + + super.onDestroy() + } + + override fun onBind(intent: Intent?): IBinder { + return this.asBinder() + } + + override fun asBinder(): IBinder { + return object : Binder() { + override fun queryLocalInterface(descriptor: String): IInterface { + return this@LogcatService + } + } + } + + suspend fun snapshot(full: Boolean): LogcatCache.Snapshot? { + return cache.snapshot(full) + } + + private fun startObserver(binder: IBinder) { + if (!binder.isBinderAlive) + return stopSelf() + + launch(Dispatchers.IO) { + val service = binder.unwrap(IClashManager::class) + val channel = Channel(CACHE_CAPACITY) + + try { + logsDir.mkdirs() + + LogcatWriter(this@LogcatService).use { + val observer = object : ILogObserver { + override fun newItem(log: LogMessage) { + channel.offer(log) + } + } + + service.setLogObserver(observer) + + while (isActive) { + val msg = channel.receive() + + it.appendMessage(msg) + + cache.append(msg) + } + } + } catch (e: IOException) { + Log.e("Write log file: $e", e) + } finally { + withContext(NonCancellable) { + if (binder.isBinderAlive) { + service.setLogObserver(null) + } + + stopSelf() + } + } + } + } + + private fun createNotificationChannel() { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) + return + + NotificationManagerCompat.from(this) + .createNotificationChannel( + NotificationChannel( + CHANNEL_ID, + getString(R.string.clash_logcat), + NotificationManager.IMPORTANCE_DEFAULT + ) + ) + } + + private fun showNotification() { + val notification = NotificationCompat + .Builder(this, CHANNEL_ID) + .setSmallIcon(R.drawable.ic_logo_service) + .setColor(getColorCompat(R.color.color_clash_light)) + .setContentTitle(getString(R.string.clash_logcat)) + .setContentText(getString(R.string.running)) + .setContentIntent( + PendingIntent.getActivity( + this, + R.id.nf_logcat_status, + LogcatActivity::class.intent + .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP), + PendingIntent.FLAG_UPDATE_CURRENT + ) + ) + .build() + + startForeground(R.id.nf_logcat_status, notification) + } + + companion object { + private const val CHANNEL_ID = "clash_logcat_channel" + private const val CACHE_CAPACITY = 128 + + var running: Boolean = false + } +} \ No newline at end of file diff --git a/app/src/main/java/com/github/kr328/clash/LogsActivity.kt b/app/src/main/java/com/github/kr328/clash/LogsActivity.kt new file mode 100644 index 00000000..d3a36242 --- /dev/null +++ b/app/src/main/java/com/github/kr328/clash/LogsActivity.kt @@ -0,0 +1,71 @@ +package com.github.kr328.clash + +import com.github.kr328.clash.common.util.intent +import com.github.kr328.clash.common.util.setFileName +import com.github.kr328.clash.design.LogsDesign +import com.github.kr328.clash.design.model.LogFile +import com.github.kr328.clash.util.logsDir +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.isActive +import kotlinx.coroutines.selects.select +import kotlinx.coroutines.withContext + +class LogsActivity : BaseActivity() { + override suspend fun main() { + if (LogcatService.running) { + return startActivity(LogcatActivity::class.intent) + } + + val design = LogsDesign(this) + + setContentDesign(design) + + while (isActive) { + select { + events.onReceive { + when (it) { + Event.ActivityStart -> { + val files = withContext(Dispatchers.IO) { + loadFiles() + } + + design.patchLogs(files) + } + else -> Unit + } + } + design.requests.onReceive { + when (it) { + LogsDesign.Request.StartLogcat -> { + startActivity(LogcatActivity::class.intent) + + finish() + } + LogsDesign.Request.DeleteAll -> { + if (design.requestDeleteAll()) { + withContext(Dispatchers.IO) { + deleteAllLogs() + } + + events.offer(Event.ActivityStart) + } + } + is LogsDesign.Request.OpenFile -> { + startActivity(LogcatActivity::class.intent.setFileName(it.file.fileName)) + } + } + } + } + } + } + + private fun loadFiles(): List { + val list = cacheDir.resolve("logs").listFiles()?.toList() ?: emptyList() + + return list.mapNotNull { LogFile.parseFromFileName(it.name) } + } + + private fun deleteAllLogs() { + logsDir.deleteRecursively() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/github/kr328/clash/MainActivity.kt b/app/src/main/java/com/github/kr328/clash/MainActivity.kt new file mode 100644 index 00000000..6f599f5b --- /dev/null +++ b/app/src/main/java/com/github/kr328/clash/MainActivity.kt @@ -0,0 +1,151 @@ +package com.github.kr328.clash + +import androidx.activity.result.contract.ActivityResultContracts +import com.github.kr328.clash.common.util.intent +import com.github.kr328.clash.common.util.ticker +import com.github.kr328.clash.design.MainDesign +import com.github.kr328.clash.design.ui.ToastDuration +import com.github.kr328.clash.store.TipsStore +import com.github.kr328.clash.util.startClashService +import com.github.kr328.clash.util.stopClashService +import com.github.kr328.clash.util.withClash +import com.github.kr328.clash.util.withProfile +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.isActive +import kotlinx.coroutines.launch +import kotlinx.coroutines.selects.select +import kotlinx.coroutines.withContext +import java.util.concurrent.TimeUnit + +class MainActivity : BaseActivity() { + override suspend fun main() { + val design = MainDesign(this) + + setContentDesign(design) + + launch(Dispatchers.IO) { + showUpdatedTips(design) + } + + design.fetch() + + val ticker = ticker(TimeUnit.SECONDS.toMillis(1)) + + while (isActive) { + select { + events.onReceive { + when (it) { + Event.ActivityStart, + Event.ServiceRecreated, + Event.ClashStop, Event.ClashStart, + Event.ProfileLoaded, Event.ProfileChanged -> design.fetch() + else -> Unit + } + } + design.requests.onReceive { + when (it) { + MainDesign.Request.ToggleStatus -> { + if (clashRunning) + stopClashService() + else + design.startClash() + } + MainDesign.Request.OpenProxy -> + startActivity(ProxyActivity::class.intent) + MainDesign.Request.OpenProfiles -> + startActivity(ProfilesActivity::class.intent) + MainDesign.Request.OpenProviders -> + startActivity(ProvidersActivity::class.intent) + MainDesign.Request.OpenLogs -> + startActivity(LogsActivity::class.intent) + MainDesign.Request.OpenSettings -> + startActivity(SettingsActivity::class.intent) + MainDesign.Request.OpenHelp -> + startActivity(HelpActivity::class.intent) + MainDesign.Request.OpenAbout -> + design.showAbout(queryAppVersionName()) + } + } + if (clashRunning) { + ticker.onReceive { + design.fetchTraffic() + } + } + } + } + } + + private suspend fun showUpdatedTips(design: MainDesign) { + val tips = TipsStore(this) + + if (tips.primaryVersion != TipsStore.CURRENT_PRIMARY_VERSION) { + tips.primaryVersion = TipsStore.CURRENT_PRIMARY_VERSION + + val pkg = packageManager.getPackageInfo(packageName, 0) + + if (pkg.firstInstallTime != pkg.lastUpdateTime) { + design.showUpdatedTips() + } + } + } + + private suspend fun MainDesign.fetch() { + setClashRunning(clashRunning) + + val state = withClash { + queryTunnelState() + } + val providers = withClash { + queryProviders() + } + + setMode(state.mode) + setHasProviders(providers.isNotEmpty()) + + withProfile { + setProfileName(queryActive()?.name) + } + } + + private suspend fun MainDesign.fetchTraffic() { + withClash { + setForwarded(queryTrafficTotal()) + } + } + + private suspend fun MainDesign.startClash() { + val active = withProfile { queryActive() } + + if (active == null || !active.imported) { + showToast(R.string.no_profile_selected, ToastDuration.Long) { + setAction(R.string.profiles) { + startActivity(ProfilesActivity::class.intent) + } + } + + return + } + + val vpnRequest = startClashService() + + try { + if (vpnRequest != null) { + val result = startActivityForResult( + ActivityResultContracts.StartActivityForResult(), + vpnRequest + ) + + if (result.resultCode == RESULT_OK) + startClashService() + } + } catch (e: Exception) { + design?.showToast(R.string.unable_to_start_vpn, ToastDuration.Long) + } + } + + private suspend fun queryAppVersionName(): String { + return withContext(Dispatchers.IO) { + packageManager.getPackageInfo(packageName, 0).versionName + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/github/kr328/clash/MainApplication.kt b/app/src/main/java/com/github/kr328/clash/MainApplication.kt new file mode 100644 index 00000000..63c07893 --- /dev/null +++ b/app/src/main/java/com/github/kr328/clash/MainApplication.kt @@ -0,0 +1,44 @@ +package com.github.kr328.clash + +import android.app.Application +import android.content.Context +import com.github.kr328.clash.common.Global +import com.github.kr328.clash.common.compat.currentProcessName +import com.github.kr328.clash.common.log.Log +import com.github.kr328.clash.remote.Remote +import com.github.kr328.clash.service.util.sendServiceRecreated +import com.microsoft.appcenter.AppCenter +import com.microsoft.appcenter.analytics.Analytics +import com.microsoft.appcenter.crashes.Crashes + +@Suppress("unused") +class MainApplication : Application() { + override fun attachBaseContext(base: Context?) { + super.attachBaseContext(base) + + Global.init(this) + } + + override fun onCreate() { + super.onCreate() + + // Initialize AppCenter + if (BuildConfig.APP_CENTER_KEY != null && !BuildConfig.DEBUG) { + AppCenter.start( + this, + BuildConfig.APP_CENTER_KEY, + Analytics::class.java, Crashes::class.java + ) + } + + val processName = currentProcessName + + Log.d("Process $processName started") + + if (processName == packageName) { + Remote.launch() + } else { + sendServiceRecreated() + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/github/kr328/clash/NetworkSettingsActivity.kt b/app/src/main/java/com/github/kr328/clash/NetworkSettingsActivity.kt new file mode 100644 index 00000000..c7cc7245 --- /dev/null +++ b/app/src/main/java/com/github/kr328/clash/NetworkSettingsActivity.kt @@ -0,0 +1,39 @@ +package com.github.kr328.clash + +import com.github.kr328.clash.common.util.intent +import com.github.kr328.clash.design.NetworkSettingsDesign +import com.github.kr328.clash.service.store.ServiceStore +import kotlinx.coroutines.isActive +import kotlinx.coroutines.selects.select + +class NetworkSettingsActivity : BaseActivity() { + override suspend fun main() { + val design = NetworkSettingsDesign( + this, + uiStore, + ServiceStore(this), + clashRunning, + ) + + setContentDesign(design) + + while (isActive) { + select { + events.onReceive { + when (it) { + Event.ClashStart, Event.ClashStop, Event.ServiceRecreated -> + recreate() + else -> Unit + } + } + design.requests.onReceive { + when (it) { + NetworkSettingsDesign.Request.StartAccessControlList -> + startActivity(AccessControlActivity::class.intent) + } + } + } + } + } + +} diff --git a/app/src/main/java/com/github/kr328/clash/NewProfileActivity.kt b/app/src/main/java/com/github/kr328/clash/NewProfileActivity.kt new file mode 100644 index 00000000..8df167d1 --- /dev/null +++ b/app/src/main/java/com/github/kr328/clash/NewProfileActivity.kt @@ -0,0 +1,143 @@ +package com.github.kr328.clash + +import android.app.Activity +import android.content.ComponentName +import android.content.Intent +import android.net.Uri +import android.provider.Settings +import androidx.activity.result.contract.ActivityResultContracts +import com.github.kr328.clash.common.constants.Intents +import com.github.kr328.clash.common.util.intent +import com.github.kr328.clash.common.util.setUUID +import com.github.kr328.clash.design.NewProfileDesign +import com.github.kr328.clash.design.model.ProfileProvider +import com.github.kr328.clash.service.model.Profile +import com.github.kr328.clash.util.withProfile +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.isActive +import kotlinx.coroutines.selects.select +import kotlinx.coroutines.withContext +import java.util.* + +class NewProfileActivity : BaseActivity() { + private val self: NewProfileActivity + get() = this + + override suspend fun main() { + val design = NewProfileDesign(this) + + design.patchProviders(queryProfileProviders()) + + setContentDesign(design) + + while (isActive) { + select { + events.onReceive { + + } + design.requests.onReceive { + when (it) { + is NewProfileDesign.Request.Create -> { + withProfile { + val name = getString(R.string.new_profile) + + val uuid: UUID? = when (val p = it.provider) { + is ProfileProvider.File -> + create(Profile.Type.File, name) + is ProfileProvider.Url -> + create(Profile.Type.Url, name) + is ProfileProvider.External -> { + val data = p.get() + + if (data != null) { + val (uri, initialName) = data + + create( + Profile.Type.External, + initialName ?: name, + uri.toString() + ) + } else { + null + } + } + } + + if (uuid != null) + launchProperties(uuid) + } + } + is NewProfileDesign.Request.OpenDetail -> { + launchAppDetailed(it.provider) + } + } + } + } + } + } + + private fun launchAppDetailed(provider: ProfileProvider.External) { + val data = Uri.fromParts( + "package", + provider.intent.component?.packageName ?: return, + null + ) + + startActivity(Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS).setData(data)) + } + + private suspend fun launchProperties(uuid: UUID) { + val r = startActivityForResult( + ActivityResultContracts.StartActivityForResult(), + PropertiesActivity::class.intent.setUUID(uuid) + ) + + if (r.resultCode == Activity.RESULT_OK) + finish() + } + + private suspend fun ProfileProvider.External.get(): Pair? { + val result = startActivityForResult( + ActivityResultContracts.StartActivityForResult(), + intent + ) + + if (result.resultCode != RESULT_OK) + return null + + val uri = result.data?.data + val name = result.data?.getStringExtra(Intents.EXTRA_NAME) + + if (uri != null) { + return uri to name + } + + return null + } + + private suspend fun queryProfileProviders(): List { + return withContext(Dispatchers.IO) { + val providers = packageManager.queryIntentActivities( + Intent(Intents.ACTION_PROVIDE_URL), + 0 + ).map { + val activity = it.activityInfo + + val name = activity.applicationInfo.loadLabel(packageManager) + val summary = activity.loadLabel(packageManager) + val icon = activity.loadIcon(packageManager) + val intent = Intent(Intents.ACTION_PROVIDE_URL) + .setComponent( + ComponentName( + activity.packageName, + activity.name + ) + ) + + ProfileProvider.External(name.toString(), summary.toString(), icon, intent) + } + + listOf(ProfileProvider.File(self), ProfileProvider.Url(self)) + providers + } + } +} diff --git a/app/src/main/java/com/github/kr328/clash/OverrideSettingsActivity.kt b/app/src/main/java/com/github/kr328/clash/OverrideSettingsActivity.kt new file mode 100644 index 00000000..c1636c86 --- /dev/null +++ b/app/src/main/java/com/github/kr328/clash/OverrideSettingsActivity.kt @@ -0,0 +1,89 @@ +package com.github.kr328.clash + +import android.content.pm.PackageManager +import com.github.kr328.clash.common.compat.getDrawableCompat +import com.github.kr328.clash.common.constants.Metadata +import com.github.kr328.clash.core.Clash +import com.github.kr328.clash.design.OverrideSettingsDesign +import com.github.kr328.clash.design.model.AppInfo +import com.github.kr328.clash.design.util.toAppInfo +import com.github.kr328.clash.service.store.ServiceStore +import com.github.kr328.clash.util.withClash +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.isActive +import kotlinx.coroutines.selects.select +import kotlinx.coroutines.withContext + +class OverrideSettingsActivity : BaseActivity() { + override suspend fun main() { + val configuration = withClash { queryOverride(Clash.OverrideSlot.Persist) } + val service = ServiceStore(this) + + defer { + withClash { + patchOverride(Clash.OverrideSlot.Persist, configuration) + } + } + + val design = OverrideSettingsDesign( + this, + configuration + ) + + setContentDesign(design) + + while (isActive) { + select { + events.onReceive { + + } + design.requests.onReceive { + when (it) { + OverrideSettingsDesign.Request.ResetOverride -> { + if (design.requestResetConfirm()) { + defer { + withClash { + clearOverride(Clash.OverrideSlot.Persist) + } + + service.sideloadGeoip = "" + } + + finish() + } + } + OverrideSettingsDesign.Request.EditSideloadGeoip -> { + withContext(Dispatchers.IO) { + val list = querySideloadProviders() + val initial = service.sideloadGeoip + val exist = list.any { info -> info.packageName == initial } + + service.sideloadGeoip = + design.requestSelectSideload(if (exist) initial else "", list) + } + } + } + } + } + } + } + + private fun querySideloadProviders(): List { + val apps = packageManager.getInstalledPackages(PackageManager.GET_META_DATA) + .filter { + it.applicationInfo.metaData?.containsKey(Metadata.GEOIP_FILE_NAME) + ?: false + } + .map { it.toAppInfo(packageManager) } + + return listOf( + AppInfo( + packageName = "", + label = getString(R.string.use_built_in), + icon = getDrawableCompat(R.drawable.ic_baseline_work)!!, + installTime = 0, + updateDate = 0, + ) + ) + apps + } +} \ No newline at end of file diff --git a/app/src/main/java/com/github/kr328/clash/ProfilesActivity.kt b/app/src/main/java/com/github/kr328/clash/ProfilesActivity.kt new file mode 100644 index 00000000..751dcb11 --- /dev/null +++ b/app/src/main/java/com/github/kr328/clash/ProfilesActivity.kt @@ -0,0 +1,77 @@ +package com.github.kr328.clash + +import com.github.kr328.clash.common.util.intent +import com.github.kr328.clash.common.util.setUUID +import com.github.kr328.clash.common.util.ticker +import com.github.kr328.clash.design.ProfilesDesign +import com.github.kr328.clash.service.model.Profile +import com.github.kr328.clash.util.withProfile +import kotlinx.coroutines.isActive +import kotlinx.coroutines.selects.select +import java.util.concurrent.TimeUnit + +class ProfilesActivity : BaseActivity() { + override suspend fun main() { + val design = ProfilesDesign(this) + + setContentDesign(design) + + val ticker = ticker(TimeUnit.MINUTES.toMillis(1)) + + while (isActive) { + select { + events.onReceive { + when (it) { + Event.ActivityStart, Event.ProfileChanged -> { + design.fetch() + } + else -> Unit + } + } + design.requests.onReceive { + when (it) { + ProfilesDesign.Request.Create -> + startActivity(NewProfileActivity::class.intent) + ProfilesDesign.Request.UpdateAll -> + withProfile { + queryAll().forEach { p -> + if (p.imported && p.type != Profile.Type.File) + update(p.uuid) + } + } + is ProfilesDesign.Request.Update -> + withProfile { update(it.profile.uuid) } + is ProfilesDesign.Request.Delete -> + withProfile { delete(it.profile.uuid) } + is ProfilesDesign.Request.Edit -> + startActivity(PropertiesActivity::class.intent.setUUID(it.profile.uuid)) + is ProfilesDesign.Request.Active -> { + withProfile { + if (it.profile.imported) + setActive(it.profile) + else + design.requestSave(it.profile) + } + } + is ProfilesDesign.Request.Duplicate -> { + val uuid = withProfile { clone(it.profile.uuid) } + + startActivity(PropertiesActivity::class.intent.setUUID(uuid)) + } + } + } + if (activityStarted) { + ticker.onReceive { + design.updateElapsed() + } + } + } + } + } + + private suspend fun ProfilesDesign.fetch() { + withProfile { + patchProfiles(queryAll()) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/github/kr328/clash/PropertiesActivity.kt b/app/src/main/java/com/github/kr328/clash/PropertiesActivity.kt new file mode 100644 index 00000000..93e6ecce --- /dev/null +++ b/app/src/main/java/com/github/kr328/clash/PropertiesActivity.kt @@ -0,0 +1,114 @@ +package com.github.kr328.clash + +import com.github.kr328.clash.common.util.intent +import com.github.kr328.clash.common.util.setUUID +import com.github.kr328.clash.common.util.uuid +import com.github.kr328.clash.design.PropertiesDesign +import com.github.kr328.clash.design.ui.ToastDuration +import com.github.kr328.clash.design.util.showExceptionToast +import com.github.kr328.clash.service.model.Profile +import com.github.kr328.clash.util.withProfile +import kotlinx.coroutines.coroutineScope +import kotlinx.coroutines.isActive +import kotlinx.coroutines.launch +import kotlinx.coroutines.selects.select + +class PropertiesActivity : BaseActivity() { + private var canceled: Boolean = false + + override suspend fun main() { + setResult(RESULT_CANCELED) + + val uuid = intent.uuid ?: return finish() + val design = PropertiesDesign(this) + + val original = withProfile { queryByUUID(uuid) } ?: return finish() + + design.profile = original + + setContentDesign(design) + + defer { + canceled = true + + withProfile { release(uuid) } + } + + while (isActive) { + select { + events.onReceive { + when (it) { + Event.ActivityStop -> { + val profile = design.profile + + if (!canceled && profile != original) { + withProfile { + patch(profile.uuid, profile.name, profile.source, profile.interval) + } + } + } + Event.ServiceRecreated -> { + finish() + } + else -> Unit + } + } + design.requests.onReceive { + when (it) { + PropertiesDesign.Request.BrowseFiles -> { + startActivity(FilesActivity::class.intent.setUUID(uuid)) + } + PropertiesDesign.Request.Commit -> { + design.verifyAndCommit() + } + } + } + } + } + } + + override fun onBackPressed() { + design?.apply { + launch { + if (!progressing) { + if (requestExitWithoutSaving()) + finish() + } + } + } ?: return super.onBackPressed() + } + + private suspend fun PropertiesDesign.verifyAndCommit() { + when { + profile.name.isBlank() -> { + showToast(R.string.empty_name, ToastDuration.Long) + } + profile.type != Profile.Type.File && profile.source.isBlank() -> { + showToast(R.string.invalid_url, ToastDuration.Long) + } + else -> { + try { + withProcessing { updateStatus -> + withProfile { + patch(profile.uuid, profile.name, profile.source, profile.interval) + + coroutineScope { + commit(profile.uuid) { + launch { + updateStatus(it) + } + } + } + } + } + + setResult(RESULT_OK) + + finish() + } catch (e: Exception) { + showExceptionToast(e) + } + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/github/kr328/clash/ProvidersActivity.kt b/app/src/main/java/com/github/kr328/clash/ProvidersActivity.kt new file mode 100644 index 00000000..22bdbd07 --- /dev/null +++ b/app/src/main/java/com/github/kr328/clash/ProvidersActivity.kt @@ -0,0 +1,71 @@ +package com.github.kr328.clash + +import com.github.kr328.clash.common.util.intent +import com.github.kr328.clash.common.util.ticker +import com.github.kr328.clash.design.ProvidersDesign +import com.github.kr328.clash.design.util.showExceptionToast +import com.github.kr328.clash.util.withClash +import kotlinx.coroutines.isActive +import kotlinx.coroutines.launch +import kotlinx.coroutines.selects.select +import java.util.concurrent.TimeUnit + +class ProvidersActivity : BaseActivity() { + override suspend fun main() { + val providers = withClash { queryProviders().sorted() } + val design = ProvidersDesign(this, providers) + + setContentDesign(design) + + val ticker = ticker(TimeUnit.MINUTES.toMillis(1)) + + while (isActive) { + select { + events.onReceive { + when (it) { + Event.ProfileLoaded -> { + val newList = withClash { queryProviders().sorted() } + + if (newList != providers) { + startActivity(ProvidersActivity::class.intent) + + finish() + } + } + else -> Unit + } + } + design.requests.onReceive { + when (it) { + is ProvidersDesign.Request.Update -> { + launch { + try { + withClash { + updateProvider(it.provider.type, it.provider.name) + } + + design.notifyChanged(it.index) + } catch (e: Exception) { + design.showExceptionToast( + getString( + R.string.format_update_provider_failure, + it.provider.name, + e.message + ) + ) + + design.notifyUpdated(it.index) + } + } + } + } + } + if (activityStarted) { + ticker.onReceive { + design.updateElapsed() + } + } + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/github/kr328/clash/ProxyActivity.kt b/app/src/main/java/com/github/kr328/clash/ProxyActivity.kt new file mode 100644 index 00000000..a57cd073 --- /dev/null +++ b/app/src/main/java/com/github/kr328/clash/ProxyActivity.kt @@ -0,0 +1,133 @@ +package com.github.kr328.clash + +import com.github.kr328.clash.common.util.intent +import com.github.kr328.clash.core.Clash +import com.github.kr328.clash.core.model.Proxy +import com.github.kr328.clash.design.ProxyDesign +import com.github.kr328.clash.design.model.ProxyState +import com.github.kr328.clash.store.TipsStore +import com.github.kr328.clash.util.withClash +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.isActive +import kotlinx.coroutines.launch +import kotlinx.coroutines.selects.select +import kotlinx.coroutines.sync.Semaphore +import kotlinx.coroutines.sync.withPermit +import java.util.concurrent.TimeUnit + +class ProxyActivity : BaseActivity() { + override suspend fun main() { + val mode = withClash { queryOverride(Clash.OverrideSlot.Session).mode } + val names = withClash { queryProxyGroupNames(uiStore.proxyExcludeNotSelectable) } + val states = List(names.size) { ProxyState("?") } + val unorderedStates = names.indices.map { names[it] to states[it] }.toMap() + val reloadLock = Semaphore(10) + val tips = TipsStore(this) + + val design = ProxyDesign( + this, + mode, + names, + uiStore + ) + + setContentDesign(design) + + launch(Dispatchers.IO) { + val pkg = packageManager.getPackageInfo(packageName, 0) + val validate = System.currentTimeMillis() - pkg.firstInstallTime > TimeUnit.DAYS.toMillis(5) + + if (tips.requestDonate && validate) { + tips.requestDonate = false + + design.requestDonate() + } + } + + design.requests.send(ProxyDesign.Request.ReloadAll) + + while (isActive) { + select { + events.onReceive { + when (it) { + Event.ProfileLoaded -> { + val newNames = withClash { + queryProxyGroupNames(uiStore.proxyExcludeNotSelectable) + } + + if (newNames != names) { + startActivity(ProxyActivity::class.intent) + + finish() + } + } + else -> Unit + } + } + design.requests.onReceive { + when (it) { + ProxyDesign.Request.ReLaunch -> { + startActivity(ProxyActivity::class.intent) + + finish() + } + ProxyDesign.Request.ReloadAll -> { + names.indices.forEach { idx -> + design.requests.offer(ProxyDesign.Request.Reload(idx)) + } + } + is ProxyDesign.Request.Reload -> { + launch { + val group = reloadLock.withPermit { + withClash { + queryProxyGroup(names[it.index], uiStore.proxySort) + } + } + val state = states[it.index] + + state.now = group.now + + design.updateGroup( + it.index, + group.proxies, + group.type == Proxy.Type.Selector, + state, + unorderedStates + ) + } + } + is ProxyDesign.Request.Select -> { + withClash { + patchSelector(names[it.index], it.name) + + states[it.index].now = it.name + } + + design.requestRedrawVisible() + } + is ProxyDesign.Request.UrlTest -> { + launch { + withClash { + healthCheck(names[it.index]) + } + + design.requests.send(ProxyDesign.Request.Reload(it.index)) + } + } + is ProxyDesign.Request.PatchMode -> { + design.showModeSwitchTips() + + withClash { + val o = queryOverride(Clash.OverrideSlot.Session) + + o.mode = it.mode + + patchOverride(Clash.OverrideSlot.Session, o) + } + } + } + } + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/github/kr328/clash/RestartReceiver.kt b/app/src/main/java/com/github/kr328/clash/RestartReceiver.kt new file mode 100644 index 00000000..27402e22 --- /dev/null +++ b/app/src/main/java/com/github/kr328/clash/RestartReceiver.kt @@ -0,0 +1,18 @@ +package com.github.kr328.clash + +import android.content.BroadcastReceiver +import android.content.Context +import android.content.Intent +import com.github.kr328.clash.service.StatusProvider +import com.github.kr328.clash.util.startClashService + +class RestartReceiver : BroadcastReceiver() { + override fun onReceive(context: Context, intent: Intent) { + when (intent.action) { + Intent.ACTION_BOOT_COMPLETED, Intent.ACTION_MY_PACKAGE_REPLACED -> { + if (StatusProvider.shouldStartClashOnBoot) + context.startClashService() + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/github/kr328/clash/SettingsActivity.kt b/app/src/main/java/com/github/kr328/clash/SettingsActivity.kt new file mode 100644 index 00000000..0d5fcb9b --- /dev/null +++ b/app/src/main/java/com/github/kr328/clash/SettingsActivity.kt @@ -0,0 +1,32 @@ +package com.github.kr328.clash + +import com.github.kr328.clash.common.util.intent +import com.github.kr328.clash.design.SettingsDesign +import kotlinx.coroutines.isActive +import kotlinx.coroutines.selects.select + +class SettingsActivity : BaseActivity() { + override suspend fun main() { + val design = SettingsDesign(this) + + setContentDesign(design) + + while (isActive) { + select { + events.onReceive { + + } + design.requests.onReceive { + when (it) { + SettingsDesign.Request.StartApp -> + startActivity(AppSettingsActivity::class.intent) + SettingsDesign.Request.StartNetwork -> + startActivity(NetworkSettingsActivity::class.intent) + SettingsDesign.Request.StartOverride -> + startActivity(OverrideSettingsActivity::class.intent) + } + } + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/github/kr328/clash/TileService.kt b/app/src/main/java/com/github/kr328/clash/TileService.kt new file mode 100644 index 00000000..d00f2ad5 --- /dev/null +++ b/app/src/main/java/com/github/kr328/clash/TileService.kt @@ -0,0 +1,104 @@ +package com.github.kr328.clash + +import android.content.BroadcastReceiver +import android.content.Context +import android.content.Intent +import android.content.IntentFilter +import android.graphics.drawable.Icon +import android.os.Build +import android.service.quicksettings.Tile +import android.service.quicksettings.TileService +import androidx.annotation.RequiresApi +import com.github.kr328.clash.common.constants.Intents +import com.github.kr328.clash.common.constants.Permissions +import com.github.kr328.clash.remote.StatusClient +import com.github.kr328.clash.util.startClashService +import com.github.kr328.clash.util.stopClashService + +@RequiresApi(Build.VERSION_CODES.N) +class TileService : TileService() { + private var currentProfile = "" + private var clashRunning = false + + override fun onClick() { + val tile = qsTile ?: return + + when (tile.state) { + Tile.STATE_INACTIVE -> { + startClashService() + } + Tile.STATE_ACTIVE -> { + stopClashService() + } + } + } + + override fun onStartListening() { + super.onStartListening() + + registerReceiver( + receiver, + IntentFilter().apply { + addAction(Intents.ACTION_CLASH_STARTED) + addAction(Intents.ACTION_CLASH_STOPPED) + addAction(Intents.ACTION_PROFILE_LOADED) + addAction(Intents.ACTION_SERVICE_RECREATED) + }, + Permissions.RECEIVE_SELF_BROADCASTS, + null + ) + + val name = StatusClient(this).currentProfile() + + clashRunning = name != null + currentProfile = name ?: "" + + updateTile() + } + + override fun onStopListening() { + super.onStopListening() + + unregisterReceiver(receiver) + } + + private fun updateTile() { + val tile = qsTile ?: return + + tile.state = if (clashRunning) + Tile.STATE_ACTIVE + else + Tile.STATE_INACTIVE + + tile.label = if (currentProfile.isEmpty()) + getText(R.string.launch_name) + else + currentProfile + + tile.icon = Icon.createWithResource(this, R.drawable.ic_logo_service) + + tile.updateTile() + } + + private val receiver = object : BroadcastReceiver() { + override fun onReceive(context: Context?, intent: Intent?) { + when (intent?.action) { + Intents.ACTION_CLASH_STARTED -> { + clashRunning = true + + currentProfile = "" + } + Intents.ACTION_CLASH_STOPPED, Intents.ACTION_SERVICE_RECREATED -> { + clashRunning = false + + currentProfile = "" + } + Intents.ACTION_PROFILE_LOADED -> { + currentProfile = StatusClient(this@TileService).currentProfile() ?: "" + } + } + + updateTile() + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/github/kr328/clash/log/LogcatCache.kt b/app/src/main/java/com/github/kr328/clash/log/LogcatCache.kt new file mode 100644 index 00000000..ae75bfad --- /dev/null +++ b/app/src/main/java/com/github/kr328/clash/log/LogcatCache.kt @@ -0,0 +1,52 @@ +package com.github.kr328.clash.log + +import androidx.collection.CircularArray +import com.github.kr328.clash.core.model.LogMessage +import kotlinx.coroutines.sync.Mutex +import kotlinx.coroutines.sync.withLock + +class LogcatCache { + data class Snapshot(val messages: List, val removed: Int, val appended: Int) + + private val array = CircularArray(CAPACITY) + private val lock = Mutex() + + private var removed: Int = 0 + private var appended: Int = 0 + + suspend fun append(msg: LogMessage) { + lock.withLock { + if (array.size() >= CAPACITY) { + array.removeFromStart(1) + + removed++ + appended-- + } + + array.addLast(msg) + + appended++ + } + } + + suspend fun snapshot(full: Boolean): Snapshot? { + return lock.withLock { + if (!full && removed == 0 && appended == 0) { + return@withLock null + } + + Snapshot( + List(array.size()) { array[it] }, + removed, + if (full) array.size() + appended else appended + ).also { + removed = 0 + appended = 0 + } + } + } + + companion object { + const val CAPACITY = 128 + } +} diff --git a/app/src/main/java/com/github/kr328/clash/log/LogcatFilter.kt b/app/src/main/java/com/github/kr328/clash/log/LogcatFilter.kt new file mode 100644 index 00000000..08b99533 --- /dev/null +++ b/app/src/main/java/com/github/kr328/clash/log/LogcatFilter.kt @@ -0,0 +1,25 @@ +package com.github.kr328.clash.log + +import android.content.Context +import com.github.kr328.clash.core.model.LogMessage +import com.github.kr328.clash.design.util.format +import java.io.BufferedWriter +import java.io.Writer +import java.util.* + +class LogcatFilter(output: Writer, private val context: Context) : BufferedWriter(output) { + fun writeHeader(time: Date) { + appendLine("# Capture on ${time.format(context)}") + } + + fun writeMessage(message: LogMessage) { + val time = message.time.format(context, includeDate = false) + val level = message.level.name + + appendLine(FORMAT.format(time, level, message.message)) + } + + companion object { + private const val FORMAT = "%12s %7s: %s" + } +} \ No newline at end of file diff --git a/app/src/main/java/com/github/kr328/clash/log/LogcatReader.kt b/app/src/main/java/com/github/kr328/clash/log/LogcatReader.kt new file mode 100644 index 00000000..f26d795d --- /dev/null +++ b/app/src/main/java/com/github/kr328/clash/log/LogcatReader.kt @@ -0,0 +1,32 @@ +package com.github.kr328.clash.log + +import android.content.Context +import com.github.kr328.clash.core.model.LogMessage +import com.github.kr328.clash.design.model.LogFile +import com.github.kr328.clash.util.logsDir +import java.io.BufferedReader +import java.io.FileReader +import java.util.* + +class LogcatReader(context: Context, file: LogFile) : AutoCloseable { + private val reader = BufferedReader(FileReader(context.logsDir.resolve(file.fileName))) + + override fun close() { + reader.close() + } + + fun readAll(): List { + return reader.lineSequence() + .map { it.trim() } + .filter { !it.startsWith("#") } + .map { it.split(":", limit = 3) } + .map { + LogMessage( + time = Date(it[0].toLong()), + level = LogMessage.Level.valueOf(it[1]), + message = it[2] + ) + } + .toList() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/github/kr328/clash/log/LogcatWriter.kt b/app/src/main/java/com/github/kr328/clash/log/LogcatWriter.kt new file mode 100644 index 00000000..4f8c4220 --- /dev/null +++ b/app/src/main/java/com/github/kr328/clash/log/LogcatWriter.kt @@ -0,0 +1,25 @@ +package com.github.kr328.clash.log + +import android.content.Context +import com.github.kr328.clash.core.model.LogMessage +import com.github.kr328.clash.design.model.LogFile +import com.github.kr328.clash.util.logsDir +import java.io.BufferedWriter +import java.io.FileWriter + +class LogcatWriter(context: Context) : AutoCloseable { + private val file = LogFile.generate() + private val writer = BufferedWriter(FileWriter(context.logsDir.resolve(file.fileName))) + + override fun close() { + writer.close() + } + + fun appendMessage(message: LogMessage) { + writer.appendLine(FORMAT.format(message.time.time, message.level.name, message.message)) + } + + companion object { + private const val FORMAT = "%d:%s:%s" + } +} \ No newline at end of file diff --git a/app/src/main/java/com/github/kr328/clash/log/SystemLogcat.kt b/app/src/main/java/com/github/kr328/clash/log/SystemLogcat.kt new file mode 100644 index 00000000..bbead046 --- /dev/null +++ b/app/src/main/java/com/github/kr328/clash/log/SystemLogcat.kt @@ -0,0 +1,31 @@ +package com.github.kr328.clash.log + +object SystemLogcat { + private val command = arrayOf( + "logcat", + "-d", + "-s", + "Go", + "DEBUG", + "AndroidRuntime", + "ClashForAndroid" + ) + + fun dumpCrash(): String { + return try { + val process = Runtime.getRuntime().exec(command) + + val result = process.inputStream.use { stream -> + stream.reader().readLines() + .filterNot { it.startsWith("------") } + .joinToString("\n") + } + + process.waitFor() + + result.trim() + } catch (e: Exception) { + "" + } + } +} diff --git a/app/src/main/java/com/github/kr328/clash/remote/Broadcasts.kt b/app/src/main/java/com/github/kr328/clash/remote/Broadcasts.kt new file mode 100644 index 00000000..d2b4ea11 --- /dev/null +++ b/app/src/main/java/com/github/kr328/clash/remote/Broadcasts.kt @@ -0,0 +1,103 @@ +package com.github.kr328.clash.remote + +import android.app.Application +import android.content.BroadcastReceiver +import android.content.Context +import android.content.Intent +import android.content.IntentFilter +import com.github.kr328.clash.common.constants.Intents +import com.github.kr328.clash.common.log.Log + +class Broadcasts(private val context: Application) { + interface Observer { + fun onServiceRecreated() + fun onStarted() + fun onStopped(cause: String?) + fun onProfileChanged() + fun onProfileLoaded() + } + + var clashRunning: Boolean = false + + private var registered = false + private val receivers = mutableListOf() + private val broadcastReceiver = object : BroadcastReceiver() { + override fun onReceive(context: Context?, intent: Intent?) { + if (intent?.`package` != context?.packageName) + return + + when (intent?.action) { + Intents.ACTION_SERVICE_RECREATED -> { + clashRunning = false + + receivers.forEach { + it.onServiceRecreated() + } + } + Intents.ACTION_CLASH_STARTED -> { + clashRunning = true + + receivers.forEach { + it.onStarted() + } + } + Intents.ACTION_CLASH_STOPPED -> { + clashRunning = false + + receivers.forEach { + it.onStopped(intent.getStringExtra(Intents.EXTRA_STOP_REASON)) + } + } + Intents.ACTION_PROFILE_CHANGED -> + receivers.forEach { + it.onProfileChanged() + } + Intents.ACTION_PROFILE_LOADED -> { + receivers.forEach { + it.onProfileLoaded() + } + } + } + } + } + + fun addObserver(observer: Observer) { + receivers.add(observer) + } + + fun removeObserver(observer: Observer) { + receivers.remove(observer) + } + + fun register() { + if (registered) + return + + try { + context.registerReceiver(broadcastReceiver, IntentFilter().apply { + addAction(Intents.ACTION_SERVICE_RECREATED) + addAction(Intents.ACTION_CLASH_STARTED) + addAction(Intents.ACTION_CLASH_STOPPED) + addAction(Intents.ACTION_PROFILE_CHANGED) + addAction(Intents.ACTION_PROFILE_LOADED) + }) + + clashRunning = StatusClient(context).currentProfile() != null + } catch (e: Exception) { + Log.w("Register global receiver: $e", e) + } + } + + fun unregister() { + if (!registered) + return + + try { + context.unregisterReceiver(broadcastReceiver) + + clashRunning = false + } catch (e: Exception) { + Log.w("Unregister global receiver: $e", e) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/github/kr328/clash/remote/FilesClient.kt b/app/src/main/java/com/github/kr328/clash/remote/FilesClient.kt new file mode 100644 index 00000000..1adde3b5 --- /dev/null +++ b/app/src/main/java/com/github/kr328/clash/remote/FilesClient.kt @@ -0,0 +1,94 @@ +@file:Suppress("BlockingMethodInNonBlockingContext") + +package com.github.kr328.clash.remote + +import android.content.Context +import android.net.Uri +import com.github.kr328.clash.common.constants.Authorities +import com.github.kr328.clash.design.model.File +import com.github.kr328.clash.util.copyContentTo +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.withContext +import android.provider.DocumentsContract as DC + +class FilesClient(private val context: Context) { + suspend fun list(parentDocumentId: String): List = withContext(Dispatchers.IO) { + val uri = DC.buildChildDocumentsUri(Authorities.FILES_PROVIDER, parentDocumentId) + + context.contentResolver.query(uri, FilesProjection, null, null, null)?.use { cursor -> + val idIndex = cursor.getColumnIndex(DC.Document.COLUMN_DOCUMENT_ID) + val nameIndex = cursor.getColumnIndex(DC.Document.COLUMN_DISPLAY_NAME) + val sizeIndex = cursor.getColumnIndex(DC.Document.COLUMN_SIZE) + val lastModified = cursor.getColumnIndex(DC.Document.COLUMN_LAST_MODIFIED) + val mimeTypeIndex = cursor.getColumnIndex(DC.Document.COLUMN_MIME_TYPE) + + cursor.moveToFirst() + + List(cursor.count) { + File( + id = cursor.getString(idIndex), + name = cursor.getString(nameIndex), + size = cursor.getLong(sizeIndex), + lastModified = cursor.getLong(lastModified), + isDirectory = cursor.getString(mimeTypeIndex) == DC.Document.MIME_TYPE_DIR, + ).also { + cursor.moveToNext() + } + }.sortedWith(compareBy({ !it.isDirectory }, { it.name })) + } ?: emptyList() + } + + suspend fun renameDocument(documentId: String, name: String) = withContext(Dispatchers.IO) { + val uri = buildDocumentUri(documentId) + + DC.renameDocument(context.contentResolver, uri, name) + } + + suspend fun deleteDocument(documentId: String) = withContext(Dispatchers.IO) { + val uri = buildDocumentUri(documentId) + + DC.deleteDocument(context.contentResolver, uri) + } + + suspend fun importDocument( + parentDocumentId: String, + source: Uri, + name: String + ) = withContext(Dispatchers.IO) { + val target = buildDocumentUri("$parentDocumentId/$name") + + context.contentResolver.copyContentTo(source, target) + } + + suspend fun copyDocument( + documentId: String, + source: Uri + ) { + val target = buildDocumentUri(documentId) + + context.contentResolver.copyContentTo(source, target) + } + + suspend fun copyDocument( + target: Uri, + documentId: String + ) { + val source = buildDocumentUri(documentId) + + context.contentResolver.copyContentTo(source, target) + } + + fun buildDocumentUri(documentId: String): Uri { + return DC.buildDocumentUri(Authorities.FILES_PROVIDER, documentId) + } + + companion object { + private val FilesProjection = arrayOf( + DC.Document.COLUMN_DOCUMENT_ID, + DC.Document.COLUMN_DISPLAY_NAME, + DC.Document.COLUMN_SIZE, + DC.Document.COLUMN_LAST_MODIFIED, + DC.Document.COLUMN_MIME_TYPE, + ) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/github/kr328/clash/remote/Remote.kt b/app/src/main/java/com/github/kr328/clash/remote/Remote.kt new file mode 100644 index 00000000..53f78f36 --- /dev/null +++ b/app/src/main/java/com/github/kr328/clash/remote/Remote.kt @@ -0,0 +1,72 @@ +package com.github.kr328.clash.remote + +import android.content.Context +import android.content.Intent +import com.github.kr328.clash.ApkBrokenActivity +import com.github.kr328.clash.AppCrashedActivity +import com.github.kr328.clash.common.Global +import com.github.kr328.clash.common.util.intent +import com.github.kr328.clash.store.AppStore +import com.github.kr328.clash.util.ApplicationObserver +import com.github.kr328.clash.util.verifyApk +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.GlobalScope +import kotlinx.coroutines.channels.Channel +import kotlinx.coroutines.launch + +object Remote { + val broadcasts: Broadcasts = Broadcasts(Global.application) + val services: Services = Services(Global.application) { + ApplicationObserver.createdActivities.forEach { it.finish() } + + val intent = AppCrashedActivity::class.intent + .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) + + Global.application.startActivity(intent) + } + + private val visible = Channel(Channel.CONFLATED) + + fun launch() { + ApplicationObserver.attach(Global.application) + + ApplicationObserver.onVisibleChanged(visible::offer) + + GlobalScope.launch(Dispatchers.IO) { + run() + } + } + + private suspend fun run() { + val context = Global.application + val store = AppStore(context) + val updatedAt = getLastUpdated(context) + + if (store.updatedAt != updatedAt) { + if (!context.verifyApk()) { + ApplicationObserver.createdActivities.forEach { it.finish() } + + val intent = ApkBrokenActivity::class.intent + .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) + + return context.startActivity(intent) + } else { + store.updatedAt = updatedAt + } + } + + while (true) { + if (visible.receive()) { + services.bind() + broadcasts.register() + } else { + services.unbind() + broadcasts.unregister() + } + } + } + + private fun getLastUpdated(context: Context): Long { + return context.packageManager.getPackageInfo(context.packageName, 0).lastUpdateTime + } +} \ No newline at end of file diff --git a/app/src/main/java/com/github/kr328/clash/remote/Resource.kt b/app/src/main/java/com/github/kr328/clash/remote/Resource.kt new file mode 100644 index 00000000..a718adf8 --- /dev/null +++ b/app/src/main/java/com/github/kr328/clash/remote/Resource.kt @@ -0,0 +1,74 @@ +package com.github.kr328.clash.remote + +import kotlinx.coroutines.suspendCancellableCoroutine +import kotlin.coroutines.resume + +class Resource { + private interface Callback { + fun accept(value: T) + } + + private val pending: MutableSet> = mutableSetOf() + + private var value: T? = null + + suspend fun get(): T { + return suspendCancellableCoroutine { ctx -> + val callback = object : Callback { + override fun accept(value: T) { + ctx.resume(value) + } + } + + ctx.invokeOnCancellation { + cancel(callback) + } + + get(callback) + } + } + + fun set(v: T?) { + setAndNotify(v) + } + + fun reset(v: T) { + resetIfMatched(v) + } + + @Synchronized + private fun get(callback: Callback) { + val v = value + + if (v == null) { + pending.add(callback) + } else { + callback.accept(v) + } + } + + @Synchronized + private fun setAndNotify(value: T?) { + this.value = value + + if (value != null) { + pending.forEach { + it.accept(value) + } + + pending.clear() + } + } + + @Synchronized + private fun resetIfMatched(value: T) { + if (this.value === value) { + this.value = null + } + } + + @Synchronized + private fun cancel(callback: Callback) { + pending.remove(callback) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/github/kr328/clash/remote/Services.kt b/app/src/main/java/com/github/kr328/clash/remote/Services.kt new file mode 100644 index 00000000..3d9d7f10 --- /dev/null +++ b/app/src/main/java/com/github/kr328/clash/remote/Services.kt @@ -0,0 +1,88 @@ +package com.github.kr328.clash.remote + +import android.app.Application +import android.content.ComponentName +import android.content.Context +import android.content.ServiceConnection +import android.os.IBinder +import com.github.kr328.clash.common.log.Log +import com.github.kr328.clash.common.util.intent +import com.github.kr328.clash.service.ClashManager +import com.github.kr328.clash.service.ProfileService +import com.github.kr328.clash.service.remote.IClashManager +import com.github.kr328.clash.service.remote.IProfileManager +import com.github.kr328.clash.service.remote.unwrap +import com.github.kr328.clash.util.unbindServiceSilent +import java.util.concurrent.TimeUnit + +class Services(private val context: Application, val crashed: () -> Unit) { + val clash = Resource() + val profile = Resource() + + private val clashConnection = object : ServiceConnection { + private var lastCrashed: Long = -1 + + override fun onServiceConnected(name: ComponentName?, service: IBinder?) { + clash.set(service?.unwrap(IClashManager::class)) + } + + override fun onServiceDisconnected(name: ComponentName?) { + clash.set(null) + + if (System.currentTimeMillis() - lastCrashed < TOGGLE_CRASHED_INTERVAL) { + unbind() + + crashed() + } + + lastCrashed = System.currentTimeMillis() + + Log.w("ClashManager crashed") + } + } + + private val profileConnection = object : ServiceConnection { + private var lastCrashed: Long = -1 + + override fun onServiceConnected(name: ComponentName?, service: IBinder?) { + profile.set(service?.unwrap(IProfileManager::class)) + } + + override fun onServiceDisconnected(name: ComponentName?) { + profile.set(null) + + if (System.currentTimeMillis() - lastCrashed < TOGGLE_CRASHED_INTERVAL) { + unbind() + + crashed() + } + + lastCrashed = System.currentTimeMillis() + + Log.w("ProfileService crashed") + } + } + + fun bind() { + try { + context.bindService(ClashManager::class.intent, clashConnection, Context.BIND_AUTO_CREATE) + context.bindService(ProfileService::class.intent, profileConnection, Context.BIND_AUTO_CREATE) + } catch (e: Exception) { + unbind() + + crashed() + } + } + + fun unbind() { + context.unbindServiceSilent(clashConnection) + context.unbindServiceSilent(profileConnection) + + clash.set(null) + profile.set(null) + } + + companion object { + private val TOGGLE_CRASHED_INTERVAL = TimeUnit.SECONDS.toMillis(10) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/github/kr328/clash/remote/StatusClient.kt b/app/src/main/java/com/github/kr328/clash/remote/StatusClient.kt new file mode 100644 index 00000000..fd3625be --- /dev/null +++ b/app/src/main/java/com/github/kr328/clash/remote/StatusClient.kt @@ -0,0 +1,34 @@ +package com.github.kr328.clash.remote + +import android.content.Context +import android.net.Uri +import com.github.kr328.clash.common.constants.Authorities +import com.github.kr328.clash.common.log.Log +import com.github.kr328.clash.service.StatusProvider + +class StatusClient(private val context: Context) { + private val uri: Uri + get() { + return Uri.Builder() + .scheme("content") + .authority(Authorities.STATUS_PROVIDER) + .build() + } + + fun currentProfile(): String? { + return try { + val result = context.contentResolver.call( + uri, + StatusProvider.METHOD_CURRENT_PROFILE, + null, + null + ) + + result?.getString("name") + } catch (e: Exception) { + Log.w("Query current profile: $e", e) + + null + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/github/kr328/clash/store/AppStore.kt b/app/src/main/java/com/github/kr328/clash/store/AppStore.kt new file mode 100644 index 00000000..86c7f865 --- /dev/null +++ b/app/src/main/java/com/github/kr328/clash/store/AppStore.kt @@ -0,0 +1,22 @@ +package com.github.kr328.clash.store + +import android.content.Context +import com.github.kr328.clash.common.store.Store +import com.github.kr328.clash.common.store.asStoreProvider + +class AppStore(context: Context) { + private val store = Store( + context + .getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE) + .asStoreProvider() + ) + + var updatedAt: Long by store.long( + key = "updated_at", + defaultValue = -1, + ) + + companion object { + private const val FILE_NAME = "app" + } +} \ No newline at end of file diff --git a/app/src/main/java/com/github/kr328/clash/store/TipsStore.kt b/app/src/main/java/com/github/kr328/clash/store/TipsStore.kt new file mode 100644 index 00000000..562cfeed --- /dev/null +++ b/app/src/main/java/com/github/kr328/clash/store/TipsStore.kt @@ -0,0 +1,29 @@ +package com.github.kr328.clash.store + +import android.content.Context +import com.github.kr328.clash.common.store.Store +import com.github.kr328.clash.common.store.asStoreProvider + +class TipsStore(context: Context) { + private val store = Store( + context + .getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE) + .asStoreProvider() + ) + + var requestDonate: Boolean by store.boolean( + key = "request_donate", + defaultValue = true, + ) + + var primaryVersion: Int by store.int( + key = "primary_version", + defaultValue = -1, + ) + + companion object { + const val CURRENT_PRIMARY_VERSION = 1 + + private const val FILE_NAME = "tips" + } +} \ No newline at end of file diff --git a/app/src/main/java/com/github/kr328/clash/util/Activity.kt b/app/src/main/java/com/github/kr328/clash/util/Activity.kt new file mode 100644 index 00000000..61092487 --- /dev/null +++ b/app/src/main/java/com/github/kr328/clash/util/Activity.kt @@ -0,0 +1,44 @@ +package com.github.kr328.clash.util + +import androidx.lifecycle.Lifecycle +import androidx.lifecycle.LifecycleOwner +import androidx.lifecycle.LifecycleRegistry +import kotlinx.coroutines.NonCancellable +import kotlinx.coroutines.withContext + +class ActivityResultLifecycle : LifecycleOwner { + private val lifecycle = LifecycleRegistry(this) + + init { + lifecycle.currentState = Lifecycle.State.INITIALIZED + } + + override fun getLifecycle(): Lifecycle { + return lifecycle + } + + suspend fun use(block: suspend (lifecycle: ActivityResultLifecycle, start: () -> Unit) -> T): T { + return try { + markCreated() + + block(this, this::markStarted) + } finally { + withContext(NonCancellable) { + markDestroy() + } + } + } + + private fun markCreated() { + lifecycle.currentState = Lifecycle.State.CREATED + } + + private fun markStarted() { + lifecycle.currentState = Lifecycle.State.STARTED + lifecycle.currentState = Lifecycle.State.RESUMED + } + + private fun markDestroy() { + lifecycle.currentState = Lifecycle.State.DESTROYED + } +} \ No newline at end of file diff --git a/app/src/main/java/com/github/kr328/clash/util/Application.kt b/app/src/main/java/com/github/kr328/clash/util/Application.kt new file mode 100644 index 00000000..3c2e86e7 --- /dev/null +++ b/app/src/main/java/com/github/kr328/clash/util/Application.kt @@ -0,0 +1,78 @@ +package com.github.kr328.clash.util + +import android.app.Activity +import android.app.Application +import android.content.Context +import android.os.Build +import android.os.Bundle +import java.io.File +import java.util.zip.ZipFile + +object ApplicationObserver { + private val activities: MutableSet = mutableSetOf() + + private var visibleChanged: (Boolean) -> Unit = {} + + private var appVisible = false + private set(value) { + if (field != value) { + field = value + + visibleChanged(value) + } + } + + val createdActivities: Set + get() = activities + + private val activityObserver = object : Application.ActivityLifecycleCallbacks { + @Synchronized + override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) { + activities.add(activity) + + appVisible = true + } + + @Synchronized + override fun onActivityDestroyed(activity: Activity) { + activities.remove(activity) + + appVisible = activities.isNotEmpty() + } + + override fun onActivityStarted(activity: Activity) {} + override fun onActivityStopped(activity: Activity) {} + override fun onActivityPaused(activity: Activity) {} + override fun onActivityResumed(activity: Activity) {} + override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) {} + } + + fun onVisibleChanged(visibleChanged: (Boolean) -> Unit) { + this.visibleChanged = visibleChanged + } + + fun attach(application: Application) { + application.registerActivityLifecycleCallbacks(activityObserver) + } +} + +fun Context.verifyApk(): Boolean { + return try { + val info = applicationInfo + val sources = info.splitSourceDirs ?: arrayOf(info.sourceDir) ?: return false + + val regexNativeLibrary = Regex("lib/(\\S+)/libclash.so") + val availableAbi = Build.SUPPORTED_ABIS.toSet() + val apkAbi = sources + .asSequence() + .filter { File(it).exists() } + .flatMap { ZipFile(it).entries().asSequence() } + .mapNotNull { regexNativeLibrary.matchEntire(it.name) } + .mapNotNull { it.groups[1]?.value } + .toSet() + + availableAbi.intersect(apkAbi).isNotEmpty() + } catch (e: Exception) { + false + } +} \ No newline at end of file diff --git a/app/src/main/java/com/github/kr328/clash/util/Clash.kt b/app/src/main/java/com/github/kr328/clash/util/Clash.kt new file mode 100644 index 00000000..777fb12d --- /dev/null +++ b/app/src/main/java/com/github/kr328/clash/util/Clash.kt @@ -0,0 +1,32 @@ +package com.github.kr328.clash.util + +import android.content.Context +import android.content.Intent +import android.net.VpnService +import com.github.kr328.clash.common.compat.startForegroundServiceCompat +import com.github.kr328.clash.common.constants.Intents +import com.github.kr328.clash.common.util.intent +import com.github.kr328.clash.design.store.UiStore +import com.github.kr328.clash.service.ClashService +import com.github.kr328.clash.service.TunService +import com.github.kr328.clash.service.util.sendBroadcastSelf + +fun Context.startClashService(): Intent? { + val startTun = UiStore(this).enableVpn + + if (startTun) { + val vpnRequest = VpnService.prepare(this) + if (vpnRequest != null) + return vpnRequest + + startForegroundServiceCompat(TunService::class.intent) + } else { + startForegroundServiceCompat(ClashService::class.intent) + } + + return null +} + +fun Context.stopClashService() { + sendBroadcastSelf(Intent(Intents.ACTION_CLASH_REQUEST_STOP)) +} \ No newline at end of file diff --git a/app/src/main/java/com/github/kr328/clash/util/Content.kt b/app/src/main/java/com/github/kr328/clash/util/Content.kt new file mode 100644 index 00000000..94f5f486 --- /dev/null +++ b/app/src/main/java/com/github/kr328/clash/util/Content.kt @@ -0,0 +1,25 @@ +package com.github.kr328.clash.util + +import android.content.ContentResolver +import android.net.Uri +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.withContext +import java.io.FileNotFoundException + +private fun fileNotFound(file: Uri): FileNotFoundException { + return FileNotFoundException("$file not found") +} + +@Suppress("BlockingMethodInNonBlockingContext") +suspend fun ContentResolver.copyContentTo( + source: Uri, + target: Uri +) { + withContext(Dispatchers.IO) { + (openInputStream(source) ?: throw fileNotFound(source)).use { input -> + (openOutputStream(target, "rwt") ?: throw fileNotFound(target)).use { output -> + input.copyTo(output) + } + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/github/kr328/clash/util/Files.kt b/app/src/main/java/com/github/kr328/clash/util/Files.kt new file mode 100644 index 00000000..b684a27a --- /dev/null +++ b/app/src/main/java/com/github/kr328/clash/util/Files.kt @@ -0,0 +1,7 @@ +package com.github.kr328.clash.util + +import android.content.Context +import java.io.File + +val Context.logsDir: File + get() = cacheDir.resolve("logs") \ No newline at end of file diff --git a/app/src/main/java/com/github/kr328/clash/util/Remote.kt b/app/src/main/java/com/github/kr328/clash/util/Remote.kt new file mode 100644 index 00000000..ffc9c8bc --- /dev/null +++ b/app/src/main/java/com/github/kr328/clash/util/Remote.kt @@ -0,0 +1,44 @@ +package com.github.kr328.clash.util + +import android.os.DeadObjectException +import com.github.kr328.clash.common.log.Log +import com.github.kr328.clash.remote.Remote +import com.github.kr328.clash.service.remote.IClashManager +import com.github.kr328.clash.service.remote.IProfileManager +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.withContext +import kotlin.coroutines.CoroutineContext + +suspend fun withClash( + context: CoroutineContext = Dispatchers.IO, + block: suspend IClashManager.() -> T +): T { + while (true) { + val client = Remote.services.clash.get() + + try { + return withContext(context) { client.block() } + } catch (e: DeadObjectException) { + Log.w("Remote services panic") + + Remote.services.clash.reset(client) + } + } +} + +suspend fun withProfile( + context: CoroutineContext = Dispatchers.IO, + block: suspend IProfileManager.() -> T +): T { + while (true) { + val client = Remote.services.profile.get() + + try { + return withContext(context) { client.block() } + } catch (e: DeadObjectException) { + Log.w("Remote services panic") + + Remote.services.profile.reset(client) + } + } +} diff --git a/app/src/main/java/com/github/kr328/clash/util/Service.kt b/app/src/main/java/com/github/kr328/clash/util/Service.kt new file mode 100644 index 00000000..a23d6eef --- /dev/null +++ b/app/src/main/java/com/github/kr328/clash/util/Service.kt @@ -0,0 +1,12 @@ +package com.github.kr328.clash.util + +import android.content.Context +import android.content.ServiceConnection + +fun Context.unbindServiceSilent(connection: ServiceConnection) { + try { + unbindService(connection) + } catch (e: Exception) { + // ignore + } +} \ No newline at end of file diff --git a/app/src/main/java/com/github/kr328/clash/util/Uri.kt b/app/src/main/java/com/github/kr328/clash/util/Uri.kt new file mode 100644 index 00000000..5cfb7746 --- /dev/null +++ b/app/src/main/java/com/github/kr328/clash/util/Uri.kt @@ -0,0 +1,6 @@ +package com.github.kr328.clash.util + +import android.net.Uri + +val Uri.fileName: String? + get() = schemeSpecificPart.split("/").lastOrNull() \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_launcher_foreground.xml b/app/src/main/res/drawable/ic_launcher_foreground.xml new file mode 100644 index 00000000..a359a5fa --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_foreground.xml @@ -0,0 +1,15 @@ + + + + + diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 00000000..07265db4 --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 00000000..07265db4 --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..f4f8dcebf89f3222e48e3130033e2518343dbbb5 GIT binary patch literal 1778 zcmVdZ#ML@(S3dqA3 z6ctpef)A*Q79~Ng6onuOSWr;}U(kSwAt2cVPw%-VnIt&VB#@olb??l7He`2Ca(sJW~Y3 z8X$wA6G$=ABewK<1GOh8K<8vvVN+%SXteF!vV-Txrk{X{ng-zjBDP@a&zr$#bST7U z{7L_I)>dk^6#9(`gT?Fj3kOhbeG?3s90jlYhrrOO(NKJ;)+syncbnnkuh&vLV;3Yq zYuiI%0Lm*Yhd0J8rH-LyEZGjK2U>^iL~qW6z9b6K#`|BchO0Llg#lz^*5~P)&ue zFW26I2GXsXRT@|jnE^f)=VK)0Ny^y=gbDe>uhw({gu;jzIcEdBH*F=n`Pnk7eLkZ@ z;B68mpM0|pK3|wb6SM94$$L(-4@h}m0|Uk{dm^Cj>iZR$>;o#RsF&VRfu8~3Nlk&!*wfo>;K`G1)-)VOj!(4XwR2j@# znohf^>3!eHE6nhi10=mr<8b1|F6ZOG@o!C74wYALvk55c=-+lbiq$sOHLJHDgULUo zkUSG<*Lm25aZJY~p!L7y+YM-7KsX)L4i8!d(|_4Ya#gHd=V7#M-6vrW5Xb4^*Y*2d zRs&foBrb=`GxF?|dYAtLbR}ma@El)fQ+V&3men~|wFK|rbyW>R_ z?gyxubfYQ8^{x+QtcH_k73O_d_3{M>m3lzxUV!j2Zko!#k#^l}rPcn;S%tg;icHS6 zXF-xbKn?d=X!VO@t0yf3hi^K>E1>xi8KC3z?gI$B6J6n)9}lfs>lMz29UOcYmB}lh zi3^j+=jz-CQ0{3N{bD$QWqU({TGIy87H#1b5H2mX87~lS0Z4ZFCSAM2E_RGuLGYFo z)4rzW2XwuQPe8b?X2)_ie}J^4=J7X9e-4|z5_TOqM^_jy58y-?Uqzy&s;}R5A3%5m z(;t#cFmQahxmd%f!DRWv%01?r4ER)G@n!cb6f<-GqEn!*TKjTDIVUf==THML`3P#! zn&0UF73X#k7)Fr~m5VB9V-=0U&pS#Ynu) z3!(8jbY41m)n1sle5aM>gzxC`UU1A_dVFYH4m}?y;;<0iop+wz;c=$)3e7*9JJmtm zSxm$$9Ak4d5#oK^IKq4R$pwy=Tkn_)KD3waVMv&=o zsLIMp=Od`Gu`yBT57d>El%zQgsJOUzw#k^Ghn}r)ljxz3WNI`T$jZuEh`yGUmGyG; zq26bRUa70AE5}eog9u6pLSN7)nM@`pKE8&&I{ZTe+1c3$sCQss;7El+Ay=tXq;S)L zo)&5B3cHnBt%lOlQbj;OfIs>e9UblM;Y=GfYSgo2^D5EM#Kgq#{QUf^qN1Whg@uJV zQmOQyr6dxG)oa_o?LEd7HjUdH{O;%j`hq^8ZzD#Gc&zDzWLXb{n0 z#x=<3%S*n#zAvDU-TsXW0;v~?rru=RhZud4WuXs7UwV1Cpm_>JViTL##KuJX4?)d8 UfSf7_sQ>@~07*qoM6N<$g441`FaQ7m literal 0 HcmV?d00001 diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000000000000000000000000000000000000..dea32ffe3784a116cdf003dd4d36462466ac3638 GIT binary patch literal 3625 zcmV+^4%YFBP)Em*{;6{q6rDiUrnOoOPO>s$6)X0n!4NEbX+zNLo z*@YlbGDQXDN+P?gg1|xGupIvTy>tJeIfrxP49qzPyYoEXbC#L^pYMC;+vlIT?>-A| zjImantPGH_|Gxj1jSJkG$QqwA#?_Dc%K^qU0m4}s*x#0@15sz9Zk#&v|JpWX&U*zI z;i~KW_b8DI(GsHlL}!RnhzjfK>dJ|#IN^IC-*<)|>(0kMsxzl7ZEOj^SWC@-zCTX% zKG9D^`6M_4X*3#HB#y%zME-ov$92rtx}|H3mE?CnqTNKdbwJV7@{NDh@U2dVG<;vJ zL`S5+ z=w5XbP#r&q6e#fEpv#{nz_F2hpHEcDfvGbCFou8<&PkgZJn7@rtl-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PB*c9neZ{ zAxlX~3EQ)0&w9wXaN)uSnzGQf)qnv5aQnkCAt50I>Ik(oZ$Xdjs!q7gw%aNwu@H>kZjv z&6?G`M-pg)cJ%T1)TvY5s7_PCc9m#{;A-N&6&hMaC3je1aT&`cK#}!I34uWOKM;<` zI3%N(M_T_G3hCfIH8r)2s)f;ziObgfZSv&Fw)F9or>E!iTeog$lmf||&uQ>-LPH7R zY?7rjmr1dg6to&MX3RtM+11Y8p{raIHZ?Xq{tp*Psj5i-R zOqnue)U|8ZQhBzmQF_5cGr`e-C#?60kB?6sKYsih;FVBqiIoZ~uaL!^6CtIIm`ZYfP)&y?eK_x3|Zl#~v;&F0Nr=VW$cT3WP@= zIZ(BxG(GXv6+Eiqt|;zG1UNf8;{o0t;0-)l0vzdP-KS3<*mf79=P7M}FD51?3Xu-} ziEs69lxU7-VJx2mplC#m!MSiwI`{kF0laXYTFlE%1Z{F~aKPJG9Ep0(o;`a?U|`_k zl$4Y_+)fd-iod#|R{D+;+Na@y*OTNw;aH3j$73#)O2sfY&M|Z5OtdSoWW^CYv;?g& zw6*Trx34WXI{@`OZ7x1OKA%QLMusFOC*MT(4h?c%+p)$rglQaGUS5u+DeT6L8#k$r z3dWq6n`?|C&WUq_hkM~QLak8*IypH(qdF5|#nuaSb^p0&(V`jOfB(H#XlUrMxVX4j zN)@h?Q_acF&MqQTDFxv>IsKfZq@?ROhJ4$xy?gh1VJzn0+JZT|;2gZ*ymwx*Buxpr zckkX72_`o`to`do^bDe(jg8GqM6W>T{{8z88#HLpa1g%ZKic;)j=`~f48}f%xiBZ@ zHfQKIIap*8ZE&@b&Gzcm>#>doZLt&?gzxwd`#2aDbGZKnGMJaJm9Af200000NkvXXu0mjf5S;%+ literal 0 HcmV?d00001 diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..c42d553cc3f003bbc95c959c12395f2ad8a60d7e GIT binary patch literal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x%nX#^>P^Aj|1zND9gREDA|N~IlBcn!5dZBd(E`FS;FgLiT{+VyC+&zm=ICZ^+S zFd0lk85C2_g4@1E3_vYpbYE9jSBdf~rZQBP>R{b*yp7AL&FJXpi}IfdB6BqdLJMzv zaB%RXu&}VHvuDqqK}PrVjDF)~uIF`v{`Wt7xSA326vvMrzm%^NX?E!U4_9%!l0OUL f`VOKxYUuo5$lzL)3`MV100000NkvXXu0mjf;5ldk literal 0 HcmV?d00001 diff --git a/app/src/main/res/mipmap-xhdpi/ic_banner.png b/app/src/main/res/mipmap-xhdpi/ic_banner.png new file mode 100644 index 0000000000000000000000000000000000000000..041a6f0455b23938bf7d7587077e741b1434585a GIT binary patch literal 6383 zcmeHMRajJQ*WNP@-604PgS<+2iPTVzGz3{Ygd?)+b*S`09p0)3FuV-Cr?Py(XI0Y#)DF6TzYEM)U004sF@9T*P z@z;%Y91Q^6X;f2DMEaQTWf8g4_fPhlT2mWar@b8*L}!EOoQ0)1g+JKmkr0024x@eJ zchdDeD~+wHxw-kF5(q>Mfaqv{hXU!s+wM#d7>ok|slWjcwXgt)ILASms$UU+K+#*b zpa8h=J^&JT*;;)_j0PaofdB;7U602KDdbp)K-6d;j|vSCe@Fo!jgrI{Ja?Mj6=XGNbz zn3g`8%=*q*YDG&0&jo|!0*;hQxK&AoT06PK50moI5M{-l#JZ|OoJwQ{pSu+7knH0WW^=-2=C7E5Q&Qwaej{?ATl?Gg%;^?hx-mApw~ zk(A|kT&o*jryXxiRe3;F;r+$DcUHQjy`6B1pLzQXpq5H_`GqM~&Dbz6HDAMyOR>H4 zhy_9e@>%=E0L)OJ_=|J%HZs0sURcJjKT_r#l>jIauVH5LfQg8FEY1lx!1q`0+i;BF zK5=fn1A?jCU{UtMoBUjY6xk70ZLjpeKVBd=P=hZB#WODpf)2Df`lNh!2 zjh{}H}7_M|Vv>!3&f=Z1JqjfeI3uU}2S2fVP$zjyuu(U)*uViJB2Sq>9a zPZgx#8FsE*%8lr-+i7gnuPYU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MS}pH z_-al^(xq=@El2f@M{h*!Y;ahTg4W$7cI7h8z6gsk$}`34L@DFvlRnDb;@|-cWp>TS z*>F}dmtAR^FF3i}LL7T+7+L_NPXd)0i*!F_Y0DH`YPK6%b`NwbPH>|nz)vTwIbl2K zW9NgaqN<7cEI2lG$|zaPL0YTRyEK4F=E>QzZe--)z?M(|7-R?0lmbuhP-Ye%;d{9~ z=_9VaM*)U3{U1I&eG~nTQ@(QiD3Q*l)pT`g>MVdn`)o*|&hGHR%HsE=IuYJvL70|f zY7sxvRGVqt1RM1eNicOcByZC!j6u3@0n|D%U1h3NN_{y*|nbnrhi05w%@l}aVc(Ek8muLP?A literal 0 HcmV?d00001 diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..cc59d821da4dc6c04371b5fb6e1280c108397ba1 GIT binary patch literal 2425 zcmV-<35NEGP)@Klzaqn`^H}ju$bUkP8|99`X=ljmN zdu?o3uwcQ01q&7|Sg^330Dyr+gP5oW-b&+Xr|cB8fG?zj!FqolLi7mHa3V*MYB=Y? z5Mv(kPMG_=hbWLJi%3DFB&y{;#U$-9D>yIElY8{N;{D7gpUy;5B4}@KhqkshCQj%F zk+iGZLORaE$9sake{BO{s3=Rg0>NjMza>r zeA1bkbk@$!dIO;+YL!X_MMXs$cmbfDUZtd@3?+?AkTBwAW*e8*8@XJbghev9Zp*z6!YiJRmbOb2RCoo&o3{fQpKWhUn<% z=g>Po01Qk`O&!AkbRU31p{S3HjC>xw;{(8;q@*Ml2EZ%;4WXf-FQRu000Y1PFaQhy z1Hb?<0OqT(v>bjv{5RCrHTFsSsune*oXUptm##7Zh6mFI3w^hPgX?lw8<_-6sute+ zI84lceELe5_Gt*TsMQRBzOKqDVC1wF@aXH_;Pj?1JyZE?zr0cjZcD;w``FI~X(I#U`C*0JPGyw!#;|dvxY&6%c*^`{(8A zdgX)Q4sH8~?q>kBY9TkrNek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;eShldBg5y;Nl+j|bV5@fZtHy__& zaWin(Q7V;?m6cVtbm`I$&?`4Lx4Y0g8=hkDs8OTtC!ZrGO`7DIkdUyOkS-`LF0Pfy zWQ{}(+^3jCkGZ6zM2TL+$H(uPIC0`s^oRt$$c@)`N+QXjPEJm?*a6W~wzjq}lVQo- z)6;YA{Q2|eh*5a#=mGKK74!tX;XE43=h?3foDtpb=;-($2}knhkwi}rIg4EA!ASH3 zy+MySulgjAD&Cauu(Pwf&%wdrA$xoKhldRtW-CVFv7-m*1$x4HGr;B+1a>lr8|Q|I rT!T3;Zi(?MSg>Hhf&~i}{UiPZi!QSD$(+&_00000NkvXXu0mjf6>*D^ literal 0 HcmV?d00001 diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000000000000000000000000000000000000..66a9d6dec04f90c6e7a217c52367fd4fffd34da3 GIT binary patch literal 5102 zcmVxQ;*918I=0Mb*s4I~R zkt-(`{vCdE(83UV{`p{r$VRA5gYTOY^&)zm$ctzTQ7F+Bq70%UqB5d#PG$VN8~mP7 z{)`td17$T=!E}RWm^B06sN?j1C!$G2engjuN{Lu)ZEYRZ)YRxq^5=M27kSyJqm!zE zaKDUrJK6t_5WPXPlPE_HxD3o{BBhL~IW@eh)!f^NDZH+oyzWQTweMaA-igSEC{YFI za)4`_GV0Y(Z36~1WJV%yi_<;F2q9->|2q?XPgE>`=Kxh15pZ1@QYGr+j40-9b8a9i zZLC(#%l>Xl1unQU)upsB9_|YDg)w?CfkGlg>pgxRTfZl~$<`6q2P`!;b(~2oBcWi*%E~%W zWj9Q1=kGlp!+MVKWKWIw4;%Br3U)0$*Q5-HzH*%nn7Bx)Z|p~_Sn;j0rs{)gU_zoO zBQi3wi&2#_53WJJ*-$+J=1{ut&)+J6A?TAYce2VVrAg|#Q(48Pd2Xt!>)AIJu&CG+ zy+RjsK@`v$Y#vjDt-U_yI-?mlb6)d zD>TYK@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T+r`-8ZcnM zOCv^%7)#f95dOw@^xJUU!|(0OWx5+Lt2@d@9bCS*=5^cMYobOUM%Z$h3qV@Y=xmD( z&9J>89{3D#<|5050}ARTqo?_AxW^gK;8|WqN0iA$%)`7c+xs1OT^NE`OG^L;FB>Zj zI(6#w2d+ap$_d}$H{64JIoK_E84mzAkRgI8wp?V`aZu$XzPFWuZSjEr514C#^Hi(A Q)c^nh07*qoM6N<$f|Nkl3jhEB literal 0 HcmV?d00001 diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..b82930a721e885620e0dbeea28edf76506c923b5 GIT binary patch literal 3666 zcmZ`+WmMGNyZy~DbR!@PH6UHm-8mp7A|;FVieHmT+NacG}5w{Ux0l2fza_xjq*dro-9`IZbP^Ws!w3b{zJ74L^9 zpJK3yn<$nyAE2OFD-8jI!odtc)M&X`-!|_O{y=4-*2S?4A45pLOi6gyybY z4?0K>yIpn4uPLt~N90AUP5wKi1c0vCQl58`=zI<8tU`#Pkf+pTl-8Qzy#*G&FETX` z+f~0h2fr_6dB=k0-1vdS%w$@%F zo=ejrMvA5TL1e<6SZle8aO=v~5fKrxtSPscCC+}A7`KYK){?USqaIaVR8$m%Kp^le zNI}QlmBLY16)9+AKND%}s~k#)Z#wq4>^y_lI;gEf4TYiREMD^ z2?wO@P$(9|+>(~`V4PHn@*O#0gPzL(@U~RX9R#wI%C><}mO3k8s5`h(o_ zj7D$b&t(lSp4~f04+%V|Y))wGk#*$&am#om8iRg@96FC0m+UeD(xnOj|4^etwQO9v~1xETcoo_5_6)@x*h z*_7t|Jm9opNK{NGTpC5!Z2Z*}LpsriC|x6u8|q@6@4j%-M;vujupXLihdTk_s) zE~jhVHYyG0(LFV)qHGeiqUuIVPL_?*KQ?5rP+AZ-T~U?@3ekgm_Jd#9(dK%eQ`I4IV5|Rv$Y6rmfgPzkT>RbT^sP@U;Hp##Xbp(>y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*gUloPJTnbQ^3TvJ1n$SQA&TUn80QC?~H7(q_gzCtba1_Z%(?rhI~-9;mibwtfV z^l$vd#l`>WOXBDZzPbo9yvgWZMn;J_+-*L-z8;d2lG2{FzS0T`3fadBWH{QYvm=}` zG768;?qBF@y8X@ZeAgiR%(3EQT-<=9!HECvLMXQX?VY~Bz`%GHW)(CDD*JTql=hBJ z{Ps-4rW#I9^@vD$xqV|0xhCkh>o7+ye>l$}Q~0jD+#@NP<7JaYri|BljVgZ0o=e_x zoiI3JAy0RmVb{uIL9>LBip(MA>gN&7E#8TFOU+!**~aY$|I%vvWMK$!-*2sx?ha|T zSx`lnsA!$Sc0e7^)6)F0eN%~T3U47FmXKjlc(C#r%kF6Clkh$!E&{mdMN_cq;*?C= zOv?YhqwwE8;D1c_-yMCGZ!Z!g|4xfDlH(I$ADszz->~aL0lVpl literal 0 HcmV?d00001 diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 0000000000000000000000000000000000000000..68b040325e34e36f484c888ec16a851e668f49e7 GIT binary patch literal 8014 zcmV-UAF<$xP)F|ouXwj@TAm%JB^<)7GMVvSS6-10 z>5vZTkPhjP4t+fcAx2b;nbcDv{O63MnKMj~00bsX>eU1Y?40uFlfYHS0K+L(h0j`0 zv8G~6r3;nbR9<7!oBhp}ea1o=NCd!=0HtT3saF|b=-*pX89-$!m1R_1sa&QKLM5I` z7L{TuGAhr=|Bh$uZ^i60@$5U7**TW6bK=}Bs{m9z2~2td8urVF)%c9cPAUOZ(ujiN z`Sa)176k{c;ZJ1;yEevPEP+Y)fWx^bxxc}+45#8uG3DfWiZWh$PPi;Nq^Sz)Hoi zu?`dd03@pCl=EO*{Mhdu&;Qb($GpVbts-~{(j+|SoXXxND z6}(>|Fx&bPQE4r5!;eWYKPwc?p}{2t*?W5`*X68^1e(hE5kFO!GkZm;jyk^t!M`sr zFaMbSJ4ax3o=YH6?$!j>D5tc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}7*(?b&n;9ctft003NuF5RY)4 zR0gG^nD?`}o~|^R!m?{+^ji|253oazJSKg?oKAMk81ZA|YY6{B0$v42Ejh=snoo53 zK+~ZJn-dWQM&%h#1u71`ZAc;n&9V){2tYmMCC;UzFX|%@m&v#o#1ponAw&AG{B1K z3ju0D{I-J=b{59|Kr87?NK>=&a1?z9!8s+Azs2G%5B2d8y-+0X=v;SuwvvWH%8U^& z=ev+DFql0N|CUXABUvHZ9y3~mgsZN$n~8n|V`7%5swS|rM^V7g*sGJ6d@|Q;|EPCr zJ;qmC=N5WD zJnoqMEI6Pp-+aiDj#hzp6tiGr;LYLvL;Dau@u7 G2mTK;7o5ld literal 0 HcmV?d00001 diff --git a/app/src/main/res/values-night/themes.xml b/app/src/main/res/values-night/themes.xml new file mode 100644 index 00000000..a2f025b7 --- /dev/null +++ b/app/src/main/res/values-night/themes.xml @@ -0,0 +1,4 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/design/src/main/res/values-v27/themes.xml b/design/src/main/res/values-v27/themes.xml new file mode 100644 index 00000000..c7218f07 --- /dev/null +++ b/design/src/main/res/values-v27/themes.xml @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/design/src/main/res/values-v29/themes.xml b/design/src/main/res/values-v29/themes.xml new file mode 100644 index 00000000..97b42098 --- /dev/null +++ b/design/src/main/res/values-v29/themes.xml @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/design/src/main/res/values-zh-rHK/strings.xml b/design/src/main/res/values-zh-rHK/strings.xml new file mode 100644 index 00000000..b5e420bb --- /dev/null +++ b/design/src/main/res/values-zh-rHK/strings.xml @@ -0,0 +1,211 @@ + + + 為應用配置訪問權限 + 關於 + 訪問控制模式 + 訪問控制應用包列表 + 追加系統 DNS + 應用損壞 + Clash for Android + 自動更新 + 行為 + 繞過私有網絡 + 繞過私有網絡地址 + 取消 + Clash 日誌捕捉工具 + 創建配置 + 暗黑模式 + 默認 + 延遲 + 刪除 + 刪除所有日誌 + 所有歷史日誌將丟失 + 詳情 + 直連模式 + 已禁用 + DNS 劫持 + 處理所有 DNS 數據包 + 複製 + 編輯 + 空名稱 + 退出而不保存 + 所有變更將會丟失 + 導出 + 外部 + 文件 + 文件已導出 + %d 分鐘 + %s 已激活 + %s 已轉發 + 全局模式 + 歷史 + 從文件導入 + 從 URL 導入 + 界面 + 無效的 URL + Clash + Logcat + 日誌 + 模式 + 名稱 + 網絡 + 新配置 + 未選擇 + 確認 + 配置 + 配置名稱 + 配置 + 參數 + 代理 + 近期 + 自動路由系統流量 + 通過 VpnService 自動路由所有系統流量 + 規則模式 + 運行中 + 設置 + 顯示流量 + 在通知中自動刷新流量 + 允許 Clash 自動重啓 + 自動重啓 + 已停止 + 幫助 + 點此啓動 + 更新 + URL + VpnService 選項 + 選項在 Clash 運行時不可用 + 查找 + 系統應用 + 更新時間 + 應用包名稱 + 安裝時間 + Clash for Android + 反饋 + Github Issues + Clash 配置文件(包含代理/規則)]]> + 載入中 + 免費軟件並且我們為其提供任何服務, 請務必不要反饋非應用自身引起的問題]]> + 捐贈 + 允許所有應用 + 僅允許已選擇的應用 + 不允許已選擇的應用 + 沒有選擇配置文件 + 已複製 + 腳本模式 + Google Play + 過濾 + 全選 + 反選 + 清除 + 應用 + 跟隨系統 (Android 10+) + 總是暗黑模式 + 總是明亮模式 + 服務 + 僅接受 http(s) 和 content 類型 + 至少 15 分鐘 + 覆寫 + 常規 + DNS + HTTP 端口 + Socks 端口 + 複合端口 + 允許來自局域網的連接 + 監聽地址 + 日誌級別 + IPv6 + Hosts + 已啓用 + 消息 + 警告 + 錯誤 + 調試 + 停用 + %d 個條目 + 策略 + 增強模式 + Name Server + Fallback Name Server + Default Name Server + FakeIP 過濾器 + GeoIP Fallback + IPCIDR Fallback + 使用內置 + Real-IP 至 域名映射 + Fake-IP 至 域名映射 + 排序 + 佈局 + 單列 + 多列 + 不可選擇 + 外部資源 + 不可用 + 新建 + + 監聽 + 文件 + 瀏覽文件 + 瀏覽配置文件和外部資源 + 重命名 + 文件名 + %s (未保存) + %d 分鐘前 + %d 小時前 + %d 天前 + %d 月前 + %d 年前 + 系統代理 + 為 VpnService 附加 HTTP 代理 + 不修改 + Redirect 端口 + TProxy 端口 + 重置 + 使用 Hosts + 認證 + 域名 Fallback + 置空 + 從剪切板導入 + 導出至剪切板 + 自動更新 (分鐘) + 配置 URL + 不能為空 + 正在從 %s 下載配置文件 + 正在下載外部資源 %s + 正在初始化 + 正在校驗 + 旁加載 GEOIP + 外部 GEOIP 數據庫 + 強制啓用 + 文檔 + Clash Wiki + 非法的文件名稱 + 重置覆寫設置 + 所有的覆寫設置將會被擦除 + + 更多 + 保存 + 延遲測試 + %1$s(%2$s) + 規則 + HTTP + 兼容 + 更新 %1$s: %2$s + 更新全部 + 沒有可以顯示的組 + 反轉 + 關閉 + 關鍵詞 + 無效的日誌文件 + 應用崩潰 + 應用缺少必要的運行組件,這通常由於下載不完整的 apk 導致。 + 重新安裝 + Github Releases + 無法啓動 VPN 組件 + 如果您覺得本應用對您有幫助歡迎在 [幫助] 中給予開發者一點捐贈 + 捐贈 + 應用已更新 + 設置已被清除,舊的配置文件需要再次保存。 + 配置文件需要在激活之前保存 + 僅在本次會話中有效 + 導入 + \ No newline at end of file diff --git a/design/src/main/res/values-zh-rTW/strings.xml b/design/src/main/res/values-zh-rTW/strings.xml new file mode 100644 index 00000000..e91dda22 --- /dev/null +++ b/design/src/main/res/values-zh-rTW/strings.xml @@ -0,0 +1,211 @@ + + + 為應用配置訪問權限 + 關於 + 訪問控制模式 + 訪問控制應用包列表 + 追加系統 DNS + 應用損壞 + Clash for Android + 自動更新 + 行為 + 繞過私有網絡 + 繞過私有網絡地址 + 取消 + Clash 日誌捕捉工具 + 創建配置 + 暗黑模式 + 默認 + 延遲 + 刪除 + 刪除所有日誌 + 所有歷史日誌將丟失 + 詳情 + 直連模式 + 已禁用 + DNS 劫持 + 處理所有 DNS 數據包 + 複製 + 編輯 + 空名稱 + 退出而不保存 + 所有變更將會丟失 + 導出 + 外部 + 文件 + 文件已導出 + %d 分鐘 + %s 已激活 + %s 已轉發 + 全局模式 + 歷史 + 從文件導入 + 從 URL 導入 + 界面 + 無效的 URL + Clash + Logcat + 日誌 + 模式 + 名稱 + 網絡 + 新配置 + 未選擇 + 確認 + 配置 + 配置名稱 + 配置 + 參數 + 代理 + 近期 + 自動路由系統流量 + 通過 VpnService 自動路由所有系統流量 + 規則模式 + 運行中 + 設置 + 顯示流量 + 在通知中自動刷新流量 + 允許 Clash 自動重啟 + 自動重啟 + 已停止 + 幫助 + 點此啟動 + 更新 + URL + VpnService 選項 + 選項在 Clash 運行時不可用 + 查找 + 系統應用 + 更新時間 + 應用包名稱 + 安裝時間 + Clash for Android + 反饋 + Github Issues + Clash 配置文件(包含代理/規則)]]> + 載入中 + 免費軟件並且我們為其提供任何服務, 請務必不要反饋非應用自身引起的問題]]> + 捐贈 + 允許所有應用 + 僅允許已選擇的應用 + 不允許已選擇的應用 + 沒有選擇配置文件 + 已複製 + 腳本模式 + Google Play + 過濾 + 全選 + 反選 + 清除 + 應用 + 跟隨系統 (Android 10+) + 總是暗黑模式 + 總是明亮模式 + 服務 + 僅接受 http(s) 和 content 類型 + 至少 15 分鐘 + 覆寫 + 常規 + DNS + HTTP 端口 + Socks 端口 + 複合端口 + 允許來自局域網的連接 + 監聽地址 + 日誌級別 + IPv6 + Hosts + 已啟用 + 消息 + 警告 + 錯誤 + 調試 + 停用 + %d 個條目 + 策略 + 增強模式 + Name Server + Fallback Name Server + Default Name Server + FakeIP 過濾器 + GeoIP Fallback + IPCIDR Fallback + 使用內置 + Real-IP 至 域名映射 + Fake-IP 至 域名映射 + 排序 + 佈局 + 單列 + 多列 + 不可選擇 + 外部資源 + 不可用 + 新建 + + 監聽 + 文件 + 瀏覽文件 + 瀏覽配置文件和外部資源 + 重命名 + 文件名 + %s (未保存) + %d 分鐘前 + %d 小時前 + %d 天前 + %d 月前 + %d 年前 + 系統代理 + 為 VpnService 附加 HTTP 代理 + 不修改 + Redirect 端口 + TProxy 端口 + 重置 + 使用 Hosts + 認證 + 域名 Fallback + 置空 + 從剪切板導入 + 導出至剪切板 + 自動更新 (分鐘) + 配置 URL + 不能為空 + 正在從 %s 下載配置文件 + 正在下載外部資源 %s + 正在初始化 + 正在校驗 + 旁加載 GEOIP + 外部 GEOIP 數據庫 + 強制啟用 + 文檔 + Clash Wiki + 非法的文件名稱 + 重置覆寫設置 + 所有的覆寫設置將會被擦除 + + 更多 + 保存 + 延遲測試 + %1$s(%2$s) + 規則 + HTTP + 兼容 + 更新 %1$s: %2$s + 更新全部 + 沒有可以顯示的組 + 反轉 + 關閉 + 關鍵詞 + 無效的日誌文件 + 應用崩潰 + 應用缺少必要的運行組件,這通常由於下載不完整的 apk 導致。 + 重新安裝 + Github Releases + 無法啟動 VPN 組件 + 如果您覺得本應用對您有幫助歡迎在 [幫助] 中給予開發者一點捐贈 + 捐贈 + 應用已更新 + 設置已被清除,舊的配置文件需要再次保存。 + 配置文件需要在激活之前保存 + 僅在本次會話中有效 + 導入 + \ No newline at end of file diff --git a/design/src/main/res/values-zh/strings.xml b/design/src/main/res/values-zh/strings.xml new file mode 100644 index 00000000..ca171514 --- /dev/null +++ b/design/src/main/res/values-zh/strings.xml @@ -0,0 +1,211 @@ + + + 为应用配置访问权限 + 关于 + 访问控制模式 + 访问控制应用包列表 + 追加系统 DNS + 应用损坏 + Clash for Android + 自动更新 + 行为 + 绕过私有网络 + 绕过私有网络地址 + 取消 + Clash 日志捕捉工具 + 创建配置 + 暗黑模式 + 默认 + 延迟 + 删除 + 删除所有日志 + 所有历史日志将丢失 + 详情 + 直连模式 + 已禁用 + DNS 劫持 + 处理所有 DNS 数据包 + 复制 + 编辑 + 空名称 + 退出而不保存 + 所有变更将会丢失 + 导出 + 外部 + 文件 + 文件已导出 + %d 分钟 + %s 已激活 + %s 已转发 + 全局模式 + 历史 + 从文件导入 + 从 URL 导入 + 界面 + 无效的 URL + Clash + Logcat + 日志 + 模式 + 名称 + 网络 + 新配置 + 未选择 + 确认 + 配置 + 配置名称 + 配置 + 参数 + 代理 + 近期 + 自动路由系统流量 + 通过 VpnService 自动路由所有系统流量 + 规则模式 + 运行中 + 设置 + 显示流量 + 在通知中自动刷新流量 + 允许 Clash 自动重启 + 自动重启 + 已停止 + 帮助 + 点此启动 + 更新 + URL + VpnService 选项 + 选项在 Clash 运行时不可用 + 查找 + 系统应用 + 更新时间 + 应用包名称 + 安装时间 + Clash for Android + 反馈 + Github Issues + Clash 配置文件(包含代理/规则)]]> + 载入中 + 免费软件并且我们为其提供任何服务, 请务必不要反馈非应用自身引起的问题]]> + 捐赠 + 允许所有应用 + 仅允许已选择的应用 + 不允许已选择的应用 + 没有选择配置文件 + 已复制 + 脚本模式 + Google Play + 过滤 + 全选 + 反选 + 清除 + 应用 + 跟随系统 (Android 10+) + 总是暗黑模式 + 总是明亮模式 + 服务 + 仅接受 http(s) 和 content 类型 + 至少 15 分钟 + 覆写 + 常规 + DNS + HTTP 端口 + Socks 端口 + 复合端口 + 允许来自局域网的连接 + 监听地址 + 日志级别 + IPv6 + Hosts + 已启用 + 消息 + 警告 + 错误 + 调试 + 停用 + %d 个条目 + 策略 + 增强模式 + Name Server + Fallback Name Server + Default Name Server + FakeIP 过滤器 + GeoIP Fallback + IPCIDR Fallback + 使用内置 + Real-IP 至 域名映射 + Fake-IP 至 域名映射 + 排序 + 布局 + 单列 + 多列 + 不可选择 + 外部资源 + 不可用 + 新建 + + 监听 + 文件 + 浏览文件 + 浏览配置文件和外部资源 + 重命名 + 文件名 + %s (未保存) + %d 分钟前 + %d 小时前 + %d 天前 + %d 月前 + %d 年前 + 系统代理 + 为 VpnService 附加 HTTP 代理 + 不修改 + Redirect 端口 + TProxy 端口 + 重置 + 使用 Hosts + 认证 + 域名 Fallback + 置空 + 从剪切板导入 + 导出至剪切板 + 自动更新 (分钟) + 配置 URL + 不能为空 + 正在从 %s 下载配置文件 + 正在下载外部资源 %s + 正在初始化 + 正在校验 + 旁加载 GEOIP + 外部 GEOIP 数据库 + 强制启用 + 文档 + Clash Wiki + 非法的文件名称 + 重置覆写设置 + 所有的覆写设置将会被擦除 + + 更多 + 保存 + 延迟测试 + %1$s(%2$s) + 规则 + HTTP + 兼容 + 更新 %1$s: %2$s + 更新全部 + 没有可以显示的组 + 反转 + 关闭 + 关键词 + 无效的日志文件 + 应用崩溃 + 应用缺少必要的运行组件,这通常由于下载不完整的 apk 导致。 + 重新安装 + Github Releases + 无法启动 VPN 组件 + 如果您觉得本应用对您有帮助欢迎在 [帮助] 中给予开发者一点捐赠 + 捐赠 + 应用已更新 + 设置已被清除,旧的配置文件需要再次保存。 + 配置文件需要在激活之前保存 + 仅在本次会话中有效 + 导入 + \ No newline at end of file diff --git a/design/src/main/res/values/attrs.xml b/design/src/main/res/values/attrs.xml new file mode 100644 index 00000000..d0137325 --- /dev/null +++ b/design/src/main/res/values/attrs.xml @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/design/src/main/res/values/colors.xml b/design/src/main/res/values/colors.xml new file mode 100644 index 00000000..27d3e5d1 --- /dev/null +++ b/design/src/main/res/values/colors.xml @@ -0,0 +1,13 @@ + + + #1e4376 + #1976d2 + #50000000 + #FFFAFAFA + #FF121212 + #FF202020 + #FF808080 + #FFD3D3D3 + #FF808080 + #FFB00020 + diff --git a/design/src/main/res/values/dimens.xml b/design/src/main/res/values/dimens.xml new file mode 100644 index 00000000..a967936c --- /dev/null +++ b/design/src/main/res/values/dimens.xml @@ -0,0 +1,84 @@ + + + + 1dp + + + 20dp + 5dp + 150dp + + + 500dp + + + 56dp + 5dp + 5dp + + + 48dp + 5dp + + + 10dp + 5dp + 5dp + + + 15dp + 30dp + 20dp + + 70dp + 20dp + 5dp + + + 75dp + 30dp + 17.5dp + 30dp + 17.5dp + 16dp + 5dp + 10dp + + + 8dp + 5dp + 85dp + + + 25dp + 20dp + + + 20dp + + + 5dp + 2dp + 30dp + 50dp + 90dp + + + 5dp + 15dp + 10dp + 12sp + 5dp + 0dp + + + 2.5dp + + + 50dp + 15dp + + + 12dp + 12dp + \ No newline at end of file diff --git a/design/src/main/res/values/ids.xml b/design/src/main/res/values/ids.xml new file mode 100644 index 00000000..d03b8eb3 --- /dev/null +++ b/design/src/main/res/values/ids.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/design/src/main/res/values/strings.xml b/design/src/main/res/values/strings.xml new file mode 100644 index 00000000..bce0365b --- /dev/null +++ b/design/src/main/res/values/strings.xml @@ -0,0 +1,270 @@ + + Clash + Clash for Android + + Stopped + Tap to start + Running + %s Forwarded + + Proxy + Direct Mode + Rule Mode + Global Mode + Script Mode + No groups can be displayed + + Profiles + Not selected + %s Activated + + Logs + Settings + Help + About + + Copied + + Recently + + %d min + %d elements + + %d min ago + %d hours ago + %d days ago + %d months ago + %d years ago + + Create Profile + File + Import from File + URL + Import from URL + External + %s (Unsaved) + + Application Broken + Application Crashed + App lacks the necessary runtime components, which is usually caused by downloading an incomplete apk. + Reinstall + Github Releases + https://github.com/kr328/clashforandroid/releases + + Profile + Name + Profile Name + Profile URL + Auto Update + Auto Update (Minutes) + + Accept only http(s) + At least 15 minutes or empty + Should not be blank + Detail + Update + Edit + Delete + Export + Import + Properties + Duplicate + Profile needs to be saved before activation + + Exit without Save + All changed will *LOST* + + Disabled + Unavailable + Empty Name + Invalid URL + Loading + + Fetching configuration from \'%s\' + Fetching provider \'%s\' + Initializing + Verifying + + New Profile + + Delay + Sort + Default + + OK + Cancel + Reset + + Clash Logcat + History + Logcat + + Delete All Logs + All historical logs will *LOST* + File Exported + + Behavior + Network + Interface + Override + + Auto Restart + Allow clash auto restart + + Route System Traffic + Auto routing all system traffic via VpnService + + VpnService Options + Bypass Private Network + Bypass private network addresses + DNS Hijacking + Handle all dns packet + System Proxy + Attach http proxy to VpnService + Access Control Mode + Access Control Packages + Configure access permission for apps + + Options Unavailable until Clash Stopped + + General + DNS + + HTTP Port + Socks Port + Redirect Port + Mixed Port + TProxy Port + Authentication + Allow LAN + Bind Address + Mode + Log Level + IPv6 + Hosts + Sideload GEOIP + External GEOIP database + New + Value + + Strategy + Listen + Append System DNS + Use Hosts + Enhanced Mode + Name Server + Fallback Name Server + Default Name Server + Fake-IP Filter + GeoIP Fallback + IPCIDR Fallback + Domain Fallback + + Do not modify + Empty + + Enabled + + Info + Warning + Error + Debug + Silent + + Force Enable + + Real-IP to domain mapping + Fake-IP to domain mapping + + System Apps + Filter + Package Name + Update Time + Install Time + Reverse + Search + Select All + Select Invert + Select None + Import from Clipboard + Export to Clipboard + + Clash for Android + + Document + Feedback + Donate + Clash Wiki + Github Issues + Google Play + https://github.com/Dreamacro/clash/wiki + https://github.com/Kr328/ClashForAndroid/issues + https://donate.kr328.app + + Clash Config(including Proxy/Rules)]]> + freeware and we do NOT provide any service for it]]> + + https://play.google.com/store/apps/details?id=com.github.kr328.clash + + App + Service + + Dark Mode + + Show Traffic + Auto refresh traffic in notification + + Follow System (Android 10+) + Always Dark + Always Light + + Allow all apps + Allow selected apps + Deny selected apps + + No profile selected + + Layout + Single + Multiple + Not Selectable + + Providers + + Files + Browse Files + + Rename + File Name + Invalid file name + + Reset Override Settings + All override settings will be discarded + Key + + Use Built-in + More + Save + Delay Test + + %1$s(%2$s) + Rule + HTTP + Compatible + Update %1$s: %2$s + Update All + + Close + Keyword + + Invalid log file + Unable to start VPN component + + + + + App Updated + The settings have been reseted and the old profiles needs to be saved again. + + Valid only for current session + diff --git a/design/src/main/res/values/styles.xml b/design/src/main/res/values/styles.xml new file mode 100644 index 00000000..e3ad40e1 --- /dev/null +++ b/design/src/main/res/values/styles.xml @@ -0,0 +1,10 @@ + + + + + \ No newline at end of file diff --git a/design/src/main/res/values/themes.xml b/design/src/main/res/values/themes.xml new file mode 100644 index 00000000..82d685f2 --- /dev/null +++ b/design/src/main/res/values/themes.xml @@ -0,0 +1,169 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/design/src/open/java/com/github/kr328/clash/design/OverrideSettingsDesign.kt b/design/src/open/java/com/github/kr328/clash/design/OverrideSettingsDesign.kt new file mode 100644 index 00000000..4df91153 --- /dev/null +++ b/design/src/open/java/com/github/kr328/clash/design/OverrideSettingsDesign.kt @@ -0,0 +1,390 @@ +package com.github.kr328.clash.design + +import android.content.Context +import android.view.View +import com.github.kr328.clash.core.model.ConfigurationOverride +import com.github.kr328.clash.core.model.LogMessage +import com.github.kr328.clash.core.model.TunnelState +import com.github.kr328.clash.design.adapter.SideloadProviderAdapter +import com.github.kr328.clash.design.databinding.DesignSettingsOverideBinding +import com.github.kr328.clash.design.databinding.DialogPreferenceListBinding +import com.github.kr328.clash.design.dialog.FullScreenDialog +import com.github.kr328.clash.design.model.AppInfo +import com.github.kr328.clash.design.preference.* +import com.github.kr328.clash.design.util.* +import com.google.android.material.dialog.MaterialAlertDialogBuilder +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.suspendCancellableCoroutine +import kotlinx.coroutines.withContext +import kotlin.coroutines.resume + +class OverrideSettingsDesign( + context: Context, + configuration: ConfigurationOverride +) : Design(context) { + enum class Request { + ResetOverride, EditSideloadGeoip + } + + private val binding = DesignSettingsOverideBinding + .inflate(context.layoutInflater, context.root, false) + + override val root: View + get() = binding.root + + suspend fun requestResetConfirm(): Boolean { + return suspendCancellableCoroutine { ctx -> + val dialog = MaterialAlertDialogBuilder(context) + .setTitle(R.string.reset_override_settings) + .setMessage(R.string.reset_override_settings_message) + .setPositiveButton(R.string.ok) { _, _ -> ctx.resume(true) } + .setNegativeButton(R.string.cancel) { _, _ -> } + .show() + + dialog.setOnDismissListener { + if (!ctx.isCompleted) + ctx.resume(false) + } + + ctx.invokeOnCancellation { + dialog.dismiss() + } + } + } + + suspend fun requestSelectSideload(initial: String, apps: List): String = + withContext(Dispatchers.Main) { + suspendCancellableCoroutine { ctx -> + val binding = DialogPreferenceListBinding + .inflate(context.layoutInflater, context.root, false) + val adapter = SideloadProviderAdapter(context, apps, initial) + val dialog = FullScreenDialog(context) + + dialog.setContentView(binding.root) + + binding.surface = dialog.surface + + binding.titleView.text = context.getString(R.string.sideload_geoip) + + binding.newView.visibility = View.INVISIBLE + + binding.mainList.applyLinearAdapter(context, adapter) + + binding.resetView.setOnClickListener { + ctx.resume("") + + dialog.dismiss() + } + + binding.cancelView.setOnClickListener { + dialog.dismiss() + } + + binding.okView.setOnClickListener { + ctx.resume(adapter.selectedPackageName) + + dialog.dismiss() + } + + dialog.setOnDismissListener { + if (!ctx.isCompleted) + ctx.resume(initial) + } + + dialog.show() + } + } + + init { + binding.self = this + + binding.activityBarLayout.applyFrom(context) + + binding.scrollRoot.bindAppBarElevation(binding.activityBarLayout) + + val booleanValues: Array = arrayOf( + null, + true, + false + ) + val booleanValuesText: Array = arrayOf( + R.string.dont_modify, + R.string.enabled, + R.string.disabled + ) + + val screen = preferenceScreen(context) { + category(R.string.general) + + editableText( + value = configuration::httpPort, + adapter = NullableTextAdapter.Port, + title = R.string.http_port, + placeholder = R.string.dont_modify, + empty = R.string.disabled, + ) + + editableText( + value = configuration::socksPort, + adapter = NullableTextAdapter.Port, + title = R.string.socks_port, + placeholder = R.string.dont_modify, + empty = R.string.disabled, + ) + + editableText( + value = configuration::redirectPort, + adapter = NullableTextAdapter.Port, + title = R.string.redirect_port, + placeholder = R.string.dont_modify, + empty = R.string.disabled, + ) + + editableText( + value = configuration::tproxyPort, + adapter = NullableTextAdapter.Port, + title = R.string.tproxy_port, + placeholder = R.string.dont_modify, + empty = R.string.disabled, + ) + + editableText( + value = configuration::mixedPort, + adapter = NullableTextAdapter.Port, + title = R.string.mixed_port, + placeholder = R.string.dont_modify, + empty = R.string.disabled, + ) + + editableTextList( + value = configuration::authentication, + adapter = TextAdapter.String, + title = R.string.authentication, + placeholder = R.string.dont_modify, + ) + + selectableList( + value = configuration::allowLan, + values = booleanValues, + valuesText = booleanValuesText, + title = R.string.allow_lan, + ) + + selectableList( + value = configuration::ipv6, + values = booleanValues, + valuesText = booleanValuesText, + title = R.string.ipv6, + ) + + editableText( + value = configuration::bindAddress, + adapter = NullableTextAdapter.String, + title = R.string.bind_address, + placeholder = R.string.dont_modify, + empty = R.string.default_ + ) + + selectableList( + value = configuration::mode, + values = arrayOf( + null, + TunnelState.Mode.Direct, + TunnelState.Mode.Global, + TunnelState.Mode.Rule, + ), + valuesText = arrayOf( + R.string.dont_modify, + R.string.direct_mode, + R.string.global_mode, + R.string.rule_mode, + ), + title = R.string.mode + ) + + selectableList( + value = configuration::logLevel, + values = arrayOf( + null, + LogMessage.Level.Info, + LogMessage.Level.Warning, + LogMessage.Level.Error, + LogMessage.Level.Debug, + LogMessage.Level.Silent, + ), + valuesText = arrayOf( + R.string.dont_modify, + R.string.info, + R.string.warning, + R.string.error, + R.string.debug, + R.string.silent, + ), + title = R.string.log_level, + ) + + editableTextMap( + value = configuration::hosts, + keyAdapter = TextAdapter.String, + valueAdapter = TextAdapter.String, + title = R.string.hosts, + placeholder = R.string.dont_modify, + ) + + clickable( + title = R.string.sideload_geoip, + summary = R.string.sideload_geoip_summary + ) { + clicked { + requests.offer(Request.EditSideloadGeoip) + } + } + + category(R.string.dns) + + val dnsDependencies: MutableList = mutableListOf() + + val dns = selectableList( + value = configuration.dns::enable, + values = arrayOf( + null, + true, + false + ), + valuesText = arrayOf( + R.string.dont_modify, + R.string.force_enable, + R.string.use_built_in, + ), + title = R.string.strategy + ) { + listener = OnChangedListener { + if (configuration.dns.enable == false) { + dnsDependencies.forEach { + it.enabled = false + } + } else { + dnsDependencies.forEach { + it.enabled = true + } + } + } + } + + editableText( + value = configuration.dns::listen, + adapter = NullableTextAdapter.String, + title = R.string.listen, + placeholder = R.string.dont_modify, + empty = R.string.disabled, + configure = dnsDependencies::add, + ) + + selectableList( + value = configuration.app::appendSystemDns, + values = booleanValues, + valuesText = booleanValuesText, + title = R.string.append_system_dns, + configure = dnsDependencies::add, + ) + + selectableList( + value = configuration.dns::ipv6, + values = booleanValues, + valuesText = booleanValuesText, + title = R.string.ipv6, + configure = dnsDependencies::add, + ) + + selectableList( + value = configuration.dns::useHosts, + values = booleanValues, + valuesText = booleanValuesText, + title = R.string.use_hosts, + configure = dnsDependencies::add, + ) + + selectableList( + value = configuration.dns::enhancedMode, + values = arrayOf( + null, + ConfigurationOverride.DnsEnhancedMode.None, + ConfigurationOverride.DnsEnhancedMode.FakeIp, + ConfigurationOverride.DnsEnhancedMode.Mapping + ), + valuesText = arrayOf( + R.string.dont_modify, + R.string.disabled, + R.string.fakeip, + R.string.mapping + ), + title = R.string.enhanced_mode, + configure = dnsDependencies::add, + ) + + editableTextList( + value = configuration.dns::nameServer, + adapter = TextAdapter.String, + title = R.string.name_server, + placeholder = R.string.dont_modify, + configure = dnsDependencies::add, + ) + + editableTextList( + value = configuration.dns::fallback, + adapter = TextAdapter.String, + title = R.string.fallback, + placeholder = R.string.dont_modify, + configure = dnsDependencies::add, + ) + + editableTextList( + value = configuration.dns::defaultServer, + adapter = TextAdapter.String, + title = R.string.default_name_server, + placeholder = R.string.dont_modify, + configure = dnsDependencies::add, + ) + + editableTextList( + value = configuration.dns::fakeIpFilter, + adapter = TextAdapter.String, + title = R.string.fakeip_filter, + placeholder = R.string.dont_modify, + configure = dnsDependencies::add, + ) + + selectableList( + value = configuration.dns.fallbackFilter::geoIp, + values = booleanValues, + valuesText = booleanValuesText, + title = R.string.geoip_fallback, + configure = dnsDependencies::add, + ) + + editableTextList( + value = configuration.dns.fallbackFilter::domain, + adapter = TextAdapter.String, + title = R.string.domain_fallback, + placeholder = R.string.dont_modify, + configure = dnsDependencies::add, + ) + + editableTextList( + value = configuration.dns.fallbackFilter::ipcidr, + adapter = TextAdapter.String, + title = R.string.ipcidr_fallback, + placeholder = R.string.dont_modify, + configure = dnsDependencies::add, + ) + + dns.listener?.onChanged() + } + + binding.content.addView(screen.root) + } + + fun requestClear() { + requests.offer(Request.ResetOverride) + } +} \ No newline at end of file diff --git a/design/src/open/java/com/github/kr328/clash/design/component/ProxyMenu.kt b/design/src/open/java/com/github/kr328/clash/design/component/ProxyMenu.kt new file mode 100644 index 00000000..52f6be0a --- /dev/null +++ b/design/src/open/java/com/github/kr328/clash/design/component/ProxyMenu.kt @@ -0,0 +1,113 @@ +package com.github.kr328.clash.design.component + +import android.content.Context +import android.view.MenuItem +import android.view.View +import androidx.appcompat.widget.PopupMenu +import com.github.kr328.clash.core.model.ProxySort +import com.github.kr328.clash.core.model.TunnelState +import com.github.kr328.clash.design.ProxyDesign +import com.github.kr328.clash.design.R +import com.github.kr328.clash.design.store.UiStore +import kotlinx.coroutines.channels.Channel + +class ProxyMenu( + context: Context, + menuView: View, + mode: TunnelState.Mode?, + private val uiStore: UiStore, + private val requests: Channel, + private val updateConfig: () -> Unit, +) : PopupMenu.OnMenuItemClickListener { + private val menu = PopupMenu(context, menuView) + + fun show() { + menu.show() + } + + override fun onMenuItemClick(item: MenuItem): Boolean { + item.isChecked = !item.isChecked + + when (item.itemId) { + R.id.not_selectable -> { + uiStore.proxyExcludeNotSelectable = item.isChecked + + requests.offer(ProxyDesign.Request.ReLaunch) + } + R.id.single -> { + uiStore.proxySingleLine = true + + updateConfig() + + requests.offer(ProxyDesign.Request.ReloadAll) + } + R.id.multiple -> { + uiStore.proxySingleLine = false + + updateConfig() + + requests.offer(ProxyDesign.Request.ReloadAll) + } + R.id.default_ -> { + uiStore.proxySort = ProxySort.Default + + requests.offer(ProxyDesign.Request.ReloadAll) + } + R.id.name -> { + uiStore.proxySort = ProxySort.Title + + requests.offer(ProxyDesign.Request.ReloadAll) + } + R.id.delay -> { + uiStore.proxySort = ProxySort.Delay + + requests.offer(ProxyDesign.Request.ReloadAll) + } + R.id.dont_modify -> { + requests.offer(ProxyDesign.Request.PatchMode(null)) + } + R.id.direct_mode -> { + requests.offer(ProxyDesign.Request.PatchMode(TunnelState.Mode.Direct)) + } + R.id.global_mode -> { + requests.offer(ProxyDesign.Request.PatchMode(TunnelState.Mode.Global)) + } + R.id.rule_mode -> { + requests.offer(ProxyDesign.Request.PatchMode(TunnelState.Mode.Rule)) + } + else -> return false + } + + return true + } + + init { + menu.menuInflater.inflate(R.menu.menu_proxy, menu.menu) + + menu.menu.apply { + findItem(R.id.not_selectable).isChecked = uiStore.proxyExcludeNotSelectable + + if (uiStore.proxySingleLine) { + findItem(R.id.single).isChecked = true + } else { + findItem(R.id.multiple).isChecked = true + } + + when (uiStore.proxySort) { + ProxySort.Default -> findItem(R.id.default_).isChecked = true + ProxySort.Title -> findItem(R.id.name).isChecked = true + ProxySort.Delay -> findItem(R.id.delay).isChecked = true + } + + when (mode) { + null -> findItem(R.id.dont_modify).isChecked = true + TunnelState.Mode.Direct -> findItem(R.id.direct_mode).isChecked = true + TunnelState.Mode.Global -> findItem(R.id.global_mode).isChecked = true + TunnelState.Mode.Rule -> findItem(R.id.rule_mode).isChecked = true + TunnelState.Mode.Script -> throw IllegalStateException("invalid mode") + } + } + + menu.setOnMenuItemClickListener(this) + } +} \ No newline at end of file diff --git a/design/src/open/res/menu/menu_proxy.xml b/design/src/open/res/menu/menu_proxy.xml new file mode 100644 index 00000000..aefb5f93 --- /dev/null +++ b/design/src/open/res/menu/menu_proxy.xml @@ -0,0 +1,56 @@ + +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/design/src/premium/java/com/github/kr328/clash/design/OverrideSettingsDesign.kt b/design/src/premium/java/com/github/kr328/clash/design/OverrideSettingsDesign.kt new file mode 100644 index 00000000..6850917d --- /dev/null +++ b/design/src/premium/java/com/github/kr328/clash/design/OverrideSettingsDesign.kt @@ -0,0 +1,392 @@ +package com.github.kr328.clash.design + +import android.content.Context +import android.view.View +import com.github.kr328.clash.core.model.ConfigurationOverride +import com.github.kr328.clash.core.model.LogMessage +import com.github.kr328.clash.core.model.TunnelState +import com.github.kr328.clash.design.adapter.SideloadProviderAdapter +import com.github.kr328.clash.design.databinding.DesignSettingsOverideBinding +import com.github.kr328.clash.design.databinding.DialogPreferenceListBinding +import com.github.kr328.clash.design.dialog.FullScreenDialog +import com.github.kr328.clash.design.model.AppInfo +import com.github.kr328.clash.design.preference.* +import com.github.kr328.clash.design.util.* +import com.google.android.material.dialog.MaterialAlertDialogBuilder +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.suspendCancellableCoroutine +import kotlinx.coroutines.withContext +import kotlin.coroutines.resume + +class OverrideSettingsDesign( + context: Context, + configuration: ConfigurationOverride +) : Design(context) { + enum class Request { + ResetOverride, EditSideloadGeoip + } + + private val binding = DesignSettingsOverideBinding + .inflate(context.layoutInflater, context.root, false) + + override val root: View + get() = binding.root + + suspend fun requestResetConfirm(): Boolean { + return suspendCancellableCoroutine { ctx -> + val dialog = MaterialAlertDialogBuilder(context) + .setTitle(R.string.reset_override_settings) + .setMessage(R.string.reset_override_settings_message) + .setPositiveButton(R.string.ok) { _, _ -> ctx.resume(true) } + .setNegativeButton(R.string.cancel) { _, _ -> } + .show() + + dialog.setOnDismissListener { + if (!ctx.isCompleted) + ctx.resume(false) + } + + ctx.invokeOnCancellation { + dialog.dismiss() + } + } + } + + suspend fun requestSelectSideload(initial: String, apps: List): String = + withContext(Dispatchers.Main) { + suspendCancellableCoroutine { ctx -> + val binding = DialogPreferenceListBinding + .inflate(context.layoutInflater, context.root, false) + val adapter = SideloadProviderAdapter(context, apps, initial) + val dialog = FullScreenDialog(context) + + dialog.setContentView(binding.root) + + binding.surface = dialog.surface + + binding.titleView.text = context.getString(R.string.sideload_geoip) + + binding.newView.visibility = View.INVISIBLE + + binding.mainList.applyLinearAdapter(context, adapter) + + binding.resetView.setOnClickListener { + ctx.resume("") + + dialog.dismiss() + } + + binding.cancelView.setOnClickListener { + dialog.dismiss() + } + + binding.okView.setOnClickListener { + ctx.resume(adapter.selectedPackageName) + + dialog.dismiss() + } + + dialog.setOnDismissListener { + if (!ctx.isCompleted) + ctx.resume(initial) + } + + dialog.show() + } + } + + init { + binding.self = this + + binding.activityBarLayout.applyFrom(context) + + binding.scrollRoot.bindAppBarElevation(binding.activityBarLayout) + + val booleanValues: Array = arrayOf( + null, + true, + false + ) + val booleanValuesText: Array = arrayOf( + R.string.dont_modify, + R.string.enabled, + R.string.disabled + ) + + val screen = preferenceScreen(context) { + category(R.string.general) + + editableText( + value = configuration::httpPort, + adapter = NullableTextAdapter.Port, + title = R.string.http_port, + placeholder = R.string.dont_modify, + empty = R.string.disabled, + ) + + editableText( + value = configuration::socksPort, + adapter = NullableTextAdapter.Port, + title = R.string.socks_port, + placeholder = R.string.dont_modify, + empty = R.string.disabled, + ) + + editableText( + value = configuration::redirectPort, + adapter = NullableTextAdapter.Port, + title = R.string.redirect_port, + placeholder = R.string.dont_modify, + empty = R.string.disabled, + ) + + editableText( + value = configuration::tproxyPort, + adapter = NullableTextAdapter.Port, + title = R.string.tproxy_port, + placeholder = R.string.dont_modify, + empty = R.string.disabled, + ) + + editableText( + value = configuration::mixedPort, + adapter = NullableTextAdapter.Port, + title = R.string.mixed_port, + placeholder = R.string.dont_modify, + empty = R.string.disabled, + ) + + editableTextList( + value = configuration::authentication, + adapter = TextAdapter.String, + title = R.string.authentication, + placeholder = R.string.dont_modify, + ) + + selectableList( + value = configuration::allowLan, + values = booleanValues, + valuesText = booleanValuesText, + title = R.string.allow_lan, + ) + + selectableList( + value = configuration::ipv6, + values = booleanValues, + valuesText = booleanValuesText, + title = R.string.ipv6, + ) + + editableText( + value = configuration::bindAddress, + adapter = NullableTextAdapter.String, + title = R.string.bind_address, + placeholder = R.string.dont_modify, + empty = R.string.default_ + ) + + selectableList( + value = configuration::mode, + values = arrayOf( + null, + TunnelState.Mode.Direct, + TunnelState.Mode.Global, + TunnelState.Mode.Rule, + TunnelState.Mode.Script + ), + valuesText = arrayOf( + R.string.dont_modify, + R.string.direct_mode, + R.string.global_mode, + R.string.rule_mode, + R.string.script_mode + ), + title = R.string.mode + ) + + selectableList( + value = configuration::logLevel, + values = arrayOf( + null, + LogMessage.Level.Info, + LogMessage.Level.Warning, + LogMessage.Level.Error, + LogMessage.Level.Debug, + LogMessage.Level.Silent, + ), + valuesText = arrayOf( + R.string.dont_modify, + R.string.info, + R.string.warning, + R.string.error, + R.string.debug, + R.string.silent, + ), + title = R.string.log_level, + ) + + editableTextMap( + value = configuration::hosts, + keyAdapter = TextAdapter.String, + valueAdapter = TextAdapter.String, + title = R.string.hosts, + placeholder = R.string.dont_modify, + ) + + clickable( + title = R.string.sideload_geoip, + summary = R.string.sideload_geoip_summary + ) { + clicked { + requests.offer(Request.EditSideloadGeoip) + } + } + + category(R.string.dns) + + val dnsDependencies: MutableList = mutableListOf() + + val dns = selectableList( + value = configuration.dns::enable, + values = arrayOf( + null, + true, + false + ), + valuesText = arrayOf( + R.string.dont_modify, + R.string.force_enable, + R.string.use_built_in, + ), + title = R.string.strategy + ) { + listener = OnChangedListener { + if (configuration.dns.enable == false) { + dnsDependencies.forEach { + it.enabled = false + } + } else { + dnsDependencies.forEach { + it.enabled = true + } + } + } + } + + editableText( + value = configuration.dns::listen, + adapter = NullableTextAdapter.String, + title = R.string.listen, + placeholder = R.string.dont_modify, + empty = R.string.disabled, + configure = dnsDependencies::add, + ) + + selectableList( + value = configuration.app::appendSystemDns, + values = booleanValues, + valuesText = booleanValuesText, + title = R.string.append_system_dns, + configure = dnsDependencies::add, + ) + + selectableList( + value = configuration.dns::ipv6, + values = booleanValues, + valuesText = booleanValuesText, + title = R.string.ipv6, + configure = dnsDependencies::add, + ) + + selectableList( + value = configuration.dns::useHosts, + values = booleanValues, + valuesText = booleanValuesText, + title = R.string.use_hosts, + configure = dnsDependencies::add, + ) + + selectableList( + value = configuration.dns::enhancedMode, + values = arrayOf( + null, + ConfigurationOverride.DnsEnhancedMode.None, + ConfigurationOverride.DnsEnhancedMode.FakeIp, + ConfigurationOverride.DnsEnhancedMode.Mapping + ), + valuesText = arrayOf( + R.string.dont_modify, + R.string.disabled, + R.string.fakeip, + R.string.mapping + ), + title = R.string.enhanced_mode, + configure = dnsDependencies::add, + ) + + editableTextList( + value = configuration.dns::nameServer, + adapter = TextAdapter.String, + title = R.string.name_server, + placeholder = R.string.dont_modify, + configure = dnsDependencies::add, + ) + + editableTextList( + value = configuration.dns::fallback, + adapter = TextAdapter.String, + title = R.string.fallback, + placeholder = R.string.dont_modify, + configure = dnsDependencies::add, + ) + + editableTextList( + value = configuration.dns::defaultServer, + adapter = TextAdapter.String, + title = R.string.default_name_server, + placeholder = R.string.dont_modify, + configure = dnsDependencies::add, + ) + + editableTextList( + value = configuration.dns::fakeIpFilter, + adapter = TextAdapter.String, + title = R.string.fakeip_filter, + placeholder = R.string.dont_modify, + configure = dnsDependencies::add, + ) + + selectableList( + value = configuration.dns.fallbackFilter::geoIp, + values = booleanValues, + valuesText = booleanValuesText, + title = R.string.geoip_fallback, + configure = dnsDependencies::add, + ) + + editableTextList( + value = configuration.dns.fallbackFilter::domain, + adapter = TextAdapter.String, + title = R.string.domain_fallback, + placeholder = R.string.dont_modify, + configure = dnsDependencies::add, + ) + + editableTextList( + value = configuration.dns.fallbackFilter::ipcidr, + adapter = TextAdapter.String, + title = R.string.ipcidr_fallback, + placeholder = R.string.dont_modify, + configure = dnsDependencies::add, + ) + + dns.listener?.onChanged() + } + + binding.content.addView(screen.root) + } + + fun requestClear() { + requests.offer(Request.ResetOverride) + } +} \ No newline at end of file diff --git a/design/src/premium/java/com/github/kr328/clash/design/component/ProxyMenu.kt b/design/src/premium/java/com/github/kr328/clash/design/component/ProxyMenu.kt new file mode 100644 index 00000000..8f88e10b --- /dev/null +++ b/design/src/premium/java/com/github/kr328/clash/design/component/ProxyMenu.kt @@ -0,0 +1,116 @@ +package com.github.kr328.clash.design.component + +import android.content.Context +import android.view.MenuItem +import android.view.View +import androidx.appcompat.widget.PopupMenu +import com.github.kr328.clash.core.model.ProxySort +import com.github.kr328.clash.core.model.TunnelState +import com.github.kr328.clash.design.ProxyDesign +import com.github.kr328.clash.design.R +import com.github.kr328.clash.design.store.UiStore +import kotlinx.coroutines.channels.Channel + +class ProxyMenu( + context: Context, + menuView: View, + mode: TunnelState.Mode?, + private val uiStore: UiStore, + private val requests: Channel, + private val updateConfig: () -> Unit, +) : PopupMenu.OnMenuItemClickListener { + private val menu = PopupMenu(context, menuView) + + fun show() { + menu.show() + } + + override fun onMenuItemClick(item: MenuItem): Boolean { + item.isChecked = !item.isChecked + + when (item.itemId) { + R.id.not_selectable -> { + uiStore.proxyExcludeNotSelectable = item.isChecked + + requests.offer(ProxyDesign.Request.ReLaunch) + } + R.id.single -> { + uiStore.proxySingleLine = true + + updateConfig() + + requests.offer(ProxyDesign.Request.ReloadAll) + } + R.id.multiple -> { + uiStore.proxySingleLine = false + + updateConfig() + + requests.offer(ProxyDesign.Request.ReloadAll) + } + R.id.default_ -> { + uiStore.proxySort = ProxySort.Default + + requests.offer(ProxyDesign.Request.ReloadAll) + } + R.id.name -> { + uiStore.proxySort = ProxySort.Title + + requests.offer(ProxyDesign.Request.ReloadAll) + } + R.id.delay -> { + uiStore.proxySort = ProxySort.Delay + + requests.offer(ProxyDesign.Request.ReloadAll) + } + R.id.dont_modify -> { + requests.offer(ProxyDesign.Request.PatchMode(null)) + } + R.id.direct_mode -> { + requests.offer(ProxyDesign.Request.PatchMode(TunnelState.Mode.Direct)) + } + R.id.global_mode -> { + requests.offer(ProxyDesign.Request.PatchMode(TunnelState.Mode.Global)) + } + R.id.rule_mode -> { + requests.offer(ProxyDesign.Request.PatchMode(TunnelState.Mode.Rule)) + } + R.id.script_mode -> { + requests.offer(ProxyDesign.Request.PatchMode(TunnelState.Mode.Script)) + } + else -> return false + } + + return true + } + + init { + menu.menuInflater.inflate(R.menu.menu_proxy, menu.menu) + + menu.menu.apply { + findItem(R.id.not_selectable).isChecked = uiStore.proxyExcludeNotSelectable + + if (uiStore.proxySingleLine) { + findItem(R.id.single).isChecked = true + } else { + findItem(R.id.multiple).isChecked = true + } + + when (uiStore.proxySort) { + ProxySort.Default -> findItem(R.id.default_).isChecked = true + ProxySort.Title -> findItem(R.id.name).isChecked = true + ProxySort.Delay -> findItem(R.id.delay).isChecked = true + } + + when (mode) { + null -> findItem(R.id.dont_modify).isChecked = true + TunnelState.Mode.Direct -> findItem(R.id.direct_mode).isChecked = true + TunnelState.Mode.Global -> findItem(R.id.global_mode).isChecked = true + TunnelState.Mode.Rule -> findItem(R.id.rule_mode).isChecked = true + TunnelState.Mode.Script -> findItem(R.id.script_mode).isChecked = true + } + } + + menu.setOnMenuItemClickListener(this) + } +} diff --git a/design/src/premium/res/menu/menu_proxy.xml b/design/src/premium/res/menu/menu_proxy.xml new file mode 100644 index 00000000..304be2ba --- /dev/null +++ b/design/src/premium/res/menu/menu_proxy.xml @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 00000000..cb092798 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,23 @@ +# Project-wide Gradle settings. +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +org.gradle.jvmargs=-Xmx4608m +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true +# AndroidX package structure to make it clearer which packages are bundled with the +# Android operating system, and which are packaged with your app's APK +# https://developer.android.com/topic/libraries/support-library/androidx-rn +android.useAndroidX=true +# Automatically convert third-party libraries to use AndroidX +android.enableJetifier=true +# Kotlin code style for this project: "official" or "obsolete": +kotlin.code.style=official +# Gradle parallel build +org.gradle.parallel=true \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000000000000000000000000000000000000..f6b961fd5a86aa5fbfe90f707c3138408be7c718 GIT binary patch literal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Gz330}s}Jrjtf{(lnuuNHe5(ezA(pYa=1|Ff-LhPFK8 zyJh_b{yzu0yll6ZkpRzRjezyYivjyjW7QwO;@6X`m;2Apn2EK2!~7S}-*=;5*7K$B z`x(=!^?zgj(-`&ApZJXI09aDLXaT@<;CH=?fBOY5d|b~wBA@@p^K#nxr`)?i?SqTupI_PJ(A3cx`z~9mX_*)>L F{|7XC?P&l2 literal 0 HcmV?d00001 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000..c494a10e --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Mon Jan 25 14:09:10 CST 2021 +distributionBase=GRADLE_USER_HOME +distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.1-bin.zip +distributionPath=wrapper/dists +zipStorePath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew new file mode 100755 index 00000000..cccdd3d5 --- /dev/null +++ b/gradlew @@ -0,0 +1,172 @@ +#!/usr/bin/env sh + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=$(save "$@") + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 00000000..f9553162 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,84 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/hideapi/build.gradle.kts b/hideapi/build.gradle.kts new file mode 100644 index 00000000..b41794c7 --- /dev/null +++ b/hideapi/build.gradle.kts @@ -0,0 +1,28 @@ +plugins { + id("com.android.library") +} + +android { + compileSdk = buildTargetSdkVersion + + defaultConfig { + minSdk = buildMinSdkVersion + targetSdk = buildTargetSdkVersion + + versionCode = buildVersionCode + versionName = buildVersionName + + consumerProguardFiles("consumer-rules.pro") + } + + buildTypes { + named("release") { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") + } + } +} + +dependencies { + +} \ No newline at end of file diff --git a/hideapi/consumer-rules.pro b/hideapi/consumer-rules.pro new file mode 100644 index 00000000..e69de29b diff --git a/hideapi/proguard-rules.pro b/hideapi/proguard-rules.pro new file mode 100644 index 00000000..ff59496d --- /dev/null +++ b/hideapi/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle.kts. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/hideapi/src/main/AndroidManifest.xml b/hideapi/src/main/AndroidManifest.xml new file mode 100644 index 00000000..f7d0ec35 --- /dev/null +++ b/hideapi/src/main/AndroidManifest.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/hideapi/src/main/java/android/app/ActivityThread.java b/hideapi/src/main/java/android/app/ActivityThread.java new file mode 100644 index 00000000..720d4221 --- /dev/null +++ b/hideapi/src/main/java/android/app/ActivityThread.java @@ -0,0 +1,7 @@ +package android.app; + +public class ActivityThread { + public static String currentProcessName() { + throw new IllegalArgumentException("Stub!"); + } +} diff --git a/service/build.gradle.kts b/service/build.gradle.kts new file mode 100644 index 00000000..173beed9 --- /dev/null +++ b/service/build.gradle.kts @@ -0,0 +1,79 @@ +plugins { + id("com.android.library") + kotlin("android") + kotlin("kapt") + id("kotlinx-serialization") + id("com.google.devtools.ksp") +} + +android { + compileSdk = buildTargetSdkVersion + + flavorDimensions(buildFlavor) + + defaultConfig { + minSdk = buildMinSdkVersion + targetSdk = buildTargetSdkVersion + + versionCode = buildVersionCode + versionName = buildVersionName + + consumerProguardFiles("consumer-rules.pro") + } + + buildTypes { + named("release") { + isMinifyEnabled = false + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" + ) + } + } + + productFlavors { + create("open") { + dimension = "open" + } + create("premium") { + dimension = "premium" + } + } + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + + kotlinOptions { + jvmTarget = "1.8" + } + + sourceSets { + named("debug") { + java.srcDir(buildDir.resolve("generated/ksp/debug/kotlin")) + } + named("release") { + java.srcDir(buildDir.resolve("generated/ksp/release/kotlin")) + } + } +} + +dependencies { + ksp("com.github.kr328.kaidl:kaidl:$kaidlVersion") + kapt("androidx.room:room-compiler:$roomVersion") + + api(project(":core")) + api(project(":common")) + + implementation(kotlin("stdlib-jdk7")) + implementation("com.github.kr328.kaidl:kaidl-runtime:$kaidlVersion") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutineVersion") + implementation("androidx.room:room-runtime:$roomVersion") + implementation("androidx.room:room-ktx:$roomVersion") + implementation("androidx.core:core-ktx:$ktxVersion") + implementation("com.microsoft.appcenter:appcenter-analytics:$appcenterVersion") + implementation("com.microsoft.appcenter:appcenter-crashes:$appcenterVersion") + implementation("dev.rikka.rikkax.preference:multiprocess:$muiltprocessVersion") + implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:$serializationVersion") +} \ No newline at end of file diff --git a/service/consumer-rules.pro b/service/consumer-rules.pro new file mode 100644 index 00000000..e69de29b diff --git a/service/proguard-rules.pro b/service/proguard-rules.pro new file mode 100644 index 00000000..f1b42451 --- /dev/null +++ b/service/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/service/src/main/AndroidManifest.xml b/service/src/main/AndroidManifest.xml new file mode 100644 index 00000000..60d3dbfd --- /dev/null +++ b/service/src/main/AndroidManifest.xml @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/service/src/main/java/com/github/kr328/clash/service/BaseService.kt b/service/src/main/java/com/github/kr328/clash/service/BaseService.kt new file mode 100644 index 00000000..b15e032b --- /dev/null +++ b/service/src/main/java/com/github/kr328/clash/service/BaseService.kt @@ -0,0 +1,14 @@ +package com.github.kr328.clash.service + +import android.app.Service +import com.github.kr328.clash.service.util.cancelAndJoinBlocking +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers + +abstract class BaseService : Service(), CoroutineScope by CoroutineScope(Dispatchers.Default) { + override fun onDestroy() { + super.onDestroy() + + cancelAndJoinBlocking() + } +} \ No newline at end of file diff --git a/service/src/main/java/com/github/kr328/clash/service/ClashManager.kt b/service/src/main/java/com/github/kr328/clash/service/ClashManager.kt new file mode 100644 index 00000000..33670558 --- /dev/null +++ b/service/src/main/java/com/github/kr328/clash/service/ClashManager.kt @@ -0,0 +1,118 @@ +package com.github.kr328.clash.service + +import android.content.Intent +import android.os.IBinder +import com.github.kr328.clash.common.log.Log +import com.github.kr328.clash.core.Clash +import com.github.kr328.clash.core.model.* +import com.github.kr328.clash.service.data.Selection +import com.github.kr328.clash.service.data.SelectionDao +import com.github.kr328.clash.service.remote.IClashManager +import com.github.kr328.clash.service.remote.ILogObserver +import com.github.kr328.clash.service.remote.wrap +import com.github.kr328.clash.service.store.ServiceStore +import com.github.kr328.clash.service.util.sendOverrideChanged +import kotlinx.coroutines.* +import kotlinx.coroutines.channels.ReceiveChannel +import java.util.* + +class ClashManager : BaseService(), IClashManager { + private val store by lazy { ServiceStore(this) } + private val binder = this.wrap() + private var logReceiver: ReceiveChannel? = null + + override fun onBind(intent: Intent?): IBinder { + return binder + } + + override fun queryTunnelState(): TunnelState { + return Clash.queryTunnelState() + } + + override fun queryTrafficTotal(): Long { + return Clash.queryTrafficTotal() + } + + override fun queryProxyGroupNames(excludeNotSelectable: Boolean): List { + return Clash.queryGroupNames(excludeNotSelectable) + } + + override fun queryProxyGroup(name: String, proxySort: ProxySort): ProxyGroup { + return Clash.queryGroup(name, proxySort) + } + + override fun queryConfiguration(): UiConfiguration { + return Clash.queryConfiguration() + } + + override fun queryProviders(): ProviderList { + return ProviderList(Clash.queryProviders()) + } + + override fun queryOverride(slot: Clash.OverrideSlot): ConfigurationOverride { + return Clash.queryOverride(slot) + } + + override fun patchSelector(group: String, name: String): Boolean { + return Clash.patchSelector(group, name).also { + val current = store.activeProfile ?: return@also + + if (it) { + SelectionDao().setSelected(Selection(current, group, name)) + } else { + SelectionDao().removeSelected(current, group) + } + } + } + + override fun patchOverride(slot: Clash.OverrideSlot, configuration: ConfigurationOverride) { + Clash.patchOverride(slot, configuration) + + sendOverrideChanged() + } + + override fun clearOverride(slot: Clash.OverrideSlot) { + Clash.clearOverride(slot) + } + + override suspend fun healthCheck(group: String) { + return Clash.healthCheck(group).await() + } + + override suspend fun updateProvider(type: Provider.Type, name: String) { + return Clash.updateProvider(type, name).await() + } + + override fun setLogObserver(observer: ILogObserver?) { + synchronized(this) { + logReceiver?.apply { + cancel() + + Clash.forceGc() + } + + if (observer != null) { + logReceiver = Clash.subscribeLogcat().also { c -> + launch { + try { + while (isActive) { + observer.newItem(c.receive()) + } + } catch (e: CancellationException) { + // intended behavior + // ignore + } catch (e: Exception) { + Log.w("UI crashed", e) + } finally { + withContext(NonCancellable) { + c.cancel() + + Clash.forceGc() + } + } + } + } + } + } + } +} \ No newline at end of file diff --git a/service/src/main/java/com/github/kr328/clash/service/ClashService.kt b/service/src/main/java/com/github/kr328/clash/service/ClashService.kt new file mode 100644 index 00000000..48764bfc --- /dev/null +++ b/service/src/main/java/com/github/kr328/clash/service/ClashService.kt @@ -0,0 +1,117 @@ +package com.github.kr328.clash.service + +import android.content.Intent +import android.os.Binder +import android.os.IBinder +import com.github.kr328.clash.common.log.Log +import com.github.kr328.clash.service.clash.clashRuntime +import com.github.kr328.clash.service.clash.module.* +import com.github.kr328.clash.service.store.ServiceStore +import com.github.kr328.clash.service.util.cancelAndJoinBlocking +import com.github.kr328.clash.service.util.sendClashStarted +import com.github.kr328.clash.service.util.sendClashStopped +import kotlinx.coroutines.NonCancellable +import kotlinx.coroutines.isActive +import kotlinx.coroutines.selects.select +import kotlinx.coroutines.withContext + +class ClashService : BaseService() { + private val self: ClashService + get() = this + + private var reason: String? = null + + private val runtime = clashRuntime { + val store = ServiceStore(self) + + val close = install(CloseModule(self)) + val config = install(ConfigurationModule(self)) + val network = install(NetworkObserveModule(self)) + val sideload = install(SideloadDatabaseModule(self)) + + if (store.dynamicNotification) + install(DynamicNotificationModule(self)) + else + install(StaticNotificationModule(self)) + + install(AppListCacheModule(self)) + install(SuspendModule(self)) + + try { + while (isActive) { + val quit = select { + close.onEvent { + true + } + config.onEvent { + reason = it.message + + true + } + sideload.onEvent { + reason = it.message + + true + } + network.onEvent { + config.reload() + + false + } + } + + if (quit) break + } + } catch (e: Exception) { + Log.e("Create clash runtime: ${e.message}", e) + + reason = e.message + } finally { + withContext(NonCancellable) { + stopSelf() + } + } + } + + override fun onCreate() { + super.onCreate() + + if (StatusProvider.serviceRunning) + return stopSelf() + + StatusProvider.serviceRunning = true + + StaticNotificationModule.createNotificationChannel(this) + StaticNotificationModule.notifyLoadingNotification(this) + + runtime.launch() + } + + override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { + sendClashStarted() + + return START_STICKY + } + + override fun onBind(intent: Intent?): IBinder { + return Binder() + } + + override fun onDestroy() { + StatusProvider.serviceRunning = false + + sendClashStopped(reason) + + cancelAndJoinBlocking() + + Log.i("ClashService destroyed: ${reason ?: "successfully"}") + + super.onDestroy() + } + + override fun onTrimMemory(level: Int) { + super.onTrimMemory(level) + + runtime.requestGc() + } +} \ No newline at end of file diff --git a/service/src/main/java/com/github/kr328/clash/service/FilesProvider.kt b/service/src/main/java/com/github/kr328/clash/service/FilesProvider.kt new file mode 100644 index 00000000..d88e9f30 --- /dev/null +++ b/service/src/main/java/com/github/kr328/clash/service/FilesProvider.kt @@ -0,0 +1,208 @@ +package com.github.kr328.clash.service + +import android.database.Cursor +import android.database.MatrixCursor +import android.os.Build +import android.os.CancellationSignal +import android.os.ParcelFileDescriptor +import android.provider.DocumentsContract.Root +import android.provider.DocumentsProvider +import com.github.kr328.clash.common.util.PatternFileName +import com.github.kr328.clash.service.document.* +import kotlinx.coroutines.runBlocking +import java.io.FileNotFoundException +import android.provider.DocumentsContract.Document as D + +class FilesProvider : DocumentsProvider() { + companion object { + private const val DEFAULT_ROOT_ID = "0" + + private val DEFAULT_DOCUMENT_COLUMNS = arrayOf( + D.COLUMN_DOCUMENT_ID, + D.COLUMN_DISPLAY_NAME, + D.COLUMN_MIME_TYPE, + D.COLUMN_LAST_MODIFIED, + D.COLUMN_SIZE, + D.COLUMN_FLAGS + ) + private val DEFAULT_ROOT_COLUMNS = arrayOf( + Root.COLUMN_ROOT_ID, + Root.COLUMN_FLAGS, + Root.COLUMN_ICON, + Root.COLUMN_TITLE, + Root.COLUMN_SUMMARY, + Root.COLUMN_DOCUMENT_ID + ) + + private val FLAG_VIRTUAL: Int = + if (Build.VERSION.SDK_INT >= 24) D.FLAG_VIRTUAL_DOCUMENT else 0 + } + + private val picker: Picker by lazy { + Picker(context!!) + } + + override fun openDocument( + documentId: String?, + mode: String?, + signal: CancellationSignal? + ): ParcelFileDescriptor { + val m = ParcelFileDescriptor.parseMode(mode) + + return runBlocking { + val path = Paths.resolve(documentId ?: "/") + + val document = picker.pick(path, mode?.requestWrite ?: true) + + require(document is FileDocument) { + throw FileNotFoundException("invalid path $documentId") + } + + ParcelFileDescriptor.open(document.file, m) + } + } + + override fun deleteDocument(documentId: String?) { + val documentPath = documentId ?: "/" + + runBlocking { + val path = Paths.resolve(documentPath) + + if (path.relative == null) + throw IllegalArgumentException("invalid path $documentId") + + val document = picker.pick(path, true) + + require(document is FileDocument) { + throw FileNotFoundException("invalid path $documentId") + } + + document.file.deleteRecursively() + } + } + + override fun renameDocument(documentId: String?, displayName: String?): String { + val name = displayName ?: "" + + if (!PatternFileName.matches(name)) + throw IllegalArgumentException("invalid name $displayName") + + return runBlocking { + val path = Paths.resolve(documentId ?: "/") + + if (path.relative == null) + throw IllegalArgumentException("unable to rename $documentId") + + val document = picker.pick(path, true) + + require(document is FileDocument) { + throw IllegalArgumentException("unable to rename $document") + } + + val parent = document.file.parentFile + + require(parent != null) { + throw IllegalArgumentException("unable to rename $document") + } + + document.file.renameTo(parent.resolve(name)) + + path.copy(relative = path.relative.dropLast(1) + name).toString() + } + } + + override fun queryChildDocuments( + parentDocumentId: String?, + projection: Array?, + sortOrder: String? + ): Cursor { + return runBlocking { + try { + val doc = parentDocumentId ?: "/" + val path = Paths.resolve(doc) + val documents = picker.list(path) + + MatrixCursor(resolveDocumentProjection(projection)).apply { + documents.forEach { + newRow().applyDocument(it) + .add(D.COLUMN_DOCUMENT_ID, "$doc/${it.id}") + } + } + } catch (e: Exception) { + MatrixCursor(resolveDocumentProjection(projection)) + } + } + } + + override fun queryDocument(documentId: String?, projection: Array?): Cursor { + return runBlocking { + try { + val doc = documentId ?: "/" + val path = Paths.resolve(doc) + val document = picker.pick(path, false) + + MatrixCursor(resolveDocumentProjection(projection)).apply { + newRow().applyDocument(document).add(D.COLUMN_DOCUMENT_ID, doc) + } + } catch (e: Exception) { + MatrixCursor(resolveDocumentProjection(projection)) + } + } + } + + override fun onCreate(): Boolean { + return true + } + + override fun queryRoots(projection: Array?): Cursor { + val flags = Root.FLAG_LOCAL_ONLY or Root.FLAG_SUPPORTS_IS_CHILD + + return MatrixCursor(projection ?: DEFAULT_ROOT_COLUMNS).apply { + newRow().apply { + add(Root.COLUMN_ROOT_ID, DEFAULT_ROOT_ID) + add(Root.COLUMN_FLAGS, flags) + add(Root.COLUMN_ICON, R.drawable.ic_logo_service) + add(Root.COLUMN_TITLE, context!!.getString(R.string.clash_for_android)) + add(Root.COLUMN_SUMMARY, context!!.getString(R.string.profiles_and_providers)) + add(Root.COLUMN_DOCUMENT_ID, "/") + add(Root.COLUMN_MIME_TYPES, D.MIME_TYPE_DIR) + } + } + } + + override fun isChildDocument(parentDocumentId: String?, documentId: String?): Boolean { + if (parentDocumentId == null || documentId == null) + return false + + return documentId.startsWith(parentDocumentId) + } + + private fun MatrixCursor.RowBuilder.applyDocument(document: Document): MatrixCursor.RowBuilder { + var flags = 0 + + document.flags.forEach { + flags = when (it) { + Flag.Writable -> flags or D.FLAG_SUPPORTS_WRITE + Flag.Deletable -> flags or D.FLAG_SUPPORTS_DELETE + Flag.Virtual -> flags or FLAG_VIRTUAL + } + } + + add(D.COLUMN_DISPLAY_NAME, document.name) + add(D.COLUMN_MIME_TYPE, document.mimeType) + add(D.COLUMN_LAST_MODIFIED, document.updatedAt) + add(D.COLUMN_SIZE, document.size) + add(D.COLUMN_FLAGS, flags) + + return this + } + + private fun resolveDocumentProjection(projection: Array?): Array { + return projection ?: DEFAULT_DOCUMENT_COLUMNS + } + + private val String.requestWrite: Boolean + get() { + return contains("w", ignoreCase = true) + } +} \ No newline at end of file diff --git a/service/src/main/java/com/github/kr328/clash/service/PreferenceProvider.kt b/service/src/main/java/com/github/kr328/clash/service/PreferenceProvider.kt new file mode 100644 index 00000000..03b002fe --- /dev/null +++ b/service/src/main/java/com/github/kr328/clash/service/PreferenceProvider.kt @@ -0,0 +1,32 @@ +package com.github.kr328.clash.service + +import android.content.Context +import android.content.SharedPreferences +import com.github.kr328.clash.common.constants.Authorities +import rikka.preference.MultiProcessPreference +import rikka.preference.PreferenceProvider + +class PreferenceProvider : PreferenceProvider() { + override fun onCreatePreference(context: Context): SharedPreferences { + return context.getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE) + } + + companion object { + private const val FILE_NAME = "service" + + fun createSharedPreferencesFromContext(context: Context): SharedPreferences { + return when (context) { + is BaseService, is TunService -> + context.getSharedPreferences( + FILE_NAME, + Context.MODE_PRIVATE + ) + else -> + MultiProcessPreference( + context, + Authorities.SETTINGS_PROVIDER + ) + } + } + } +} \ No newline at end of file diff --git a/service/src/main/java/com/github/kr328/clash/service/ProfileProcessor.kt b/service/src/main/java/com/github/kr328/clash/service/ProfileProcessor.kt new file mode 100644 index 00000000..f7d13f12 --- /dev/null +++ b/service/src/main/java/com/github/kr328/clash/service/ProfileProcessor.kt @@ -0,0 +1,192 @@ +package com.github.kr328.clash.service + +import android.content.Context +import android.net.Uri +import com.github.kr328.clash.common.log.Log +import com.github.kr328.clash.core.Clash +import com.github.kr328.clash.service.data.Imported +import com.github.kr328.clash.service.data.ImportedDao +import com.github.kr328.clash.service.data.Pending +import com.github.kr328.clash.service.data.PendingDao +import com.github.kr328.clash.service.model.Profile +import com.github.kr328.clash.service.remote.IFetchObserver +import com.github.kr328.clash.service.store.ServiceStore +import com.github.kr328.clash.service.util.importedDir +import com.github.kr328.clash.service.util.pendingDir +import com.github.kr328.clash.service.util.processingDir +import com.github.kr328.clash.service.util.sendProfileChanged +import kotlinx.coroutines.NonCancellable +import kotlinx.coroutines.sync.Mutex +import kotlinx.coroutines.sync.withLock +import kotlinx.coroutines.withContext +import java.util.* +import java.util.concurrent.TimeUnit + +object ProfileProcessor { + private val profileLock = Mutex() + private val processLock = Mutex() + + suspend fun apply(context: Context, uuid: UUID, callback: IFetchObserver? = null) { + withContext(NonCancellable) { + processLock.withLock { + val snapshot = profileLock.withLock { + val pending = PendingDao().queryByUUID(uuid) + ?: throw IllegalArgumentException("profile $uuid not found") + + pending.enforceFieldValid() + + context.processingDir.deleteRecursively() + context.processingDir.mkdirs() + + context.pendingDir.resolve(pending.uuid.toString()) + .copyRecursively(context.processingDir, overwrite = true) + + pending + } + + val force = snapshot.type != Profile.Type.File + var cb = callback + + Clash.fetchAndValid(context.processingDir, snapshot.source, force) { + try { + cb?.updateStatus(it) + } catch (e: Exception) { + cb = null + + Log.w("Report fetch status: $e", e) + } + }.await() + + profileLock.withLock { + if (PendingDao().queryByUUID(snapshot.uuid) == snapshot) { + context.importedDir.resolve(snapshot.uuid.toString()) + .deleteRecursively() + context.processingDir + .copyRecursively(context.importedDir.resolve(snapshot.uuid.toString())) + + val old = ImportedDao().queryByUUID(snapshot.uuid) + + val new = Imported( + snapshot.uuid, + snapshot.name, + snapshot.type, + snapshot.source, + snapshot.interval, + old?.createdAt ?: System.currentTimeMillis() + ) + + if (old != null) { + ImportedDao().update(new) + } else { + ImportedDao().insert(new) + } + + PendingDao().remove(snapshot.uuid) + + context.pendingDir.resolve(snapshot.uuid.toString()) + .deleteRecursively() + + context.sendProfileChanged(snapshot.uuid) + } + } + } + } + } + + suspend fun update(context: Context, uuid: UUID, callback: IFetchObserver?) { + withContext(NonCancellable) { + processLock.withLock { + val snapshot = profileLock.withLock { + val imported = ImportedDao().queryByUUID(uuid) + ?: throw IllegalArgumentException("profile $uuid not found") + + context.processingDir.deleteRecursively() + context.processingDir.mkdirs() + + context.importedDir.resolve(imported.uuid.toString()) + .copyRecursively(context.processingDir, overwrite = true) + + imported + } + + var cb = callback + + Clash.fetchAndValid(context.processingDir, snapshot.source, true) { + try { + cb?.updateStatus(it) + } catch (e: Exception) { + cb = null + + Log.w("Report fetch status: $e", e) + } + }.await() + + profileLock.withLock { + if (ImportedDao().exists(snapshot.uuid)) { + context.importedDir.resolve(snapshot.uuid.toString()).deleteRecursively() + context.processingDir + .copyRecursively(context.importedDir.resolve(snapshot.uuid.toString())) + + context.sendProfileChanged(snapshot.uuid) + } + } + } + } + } + + suspend fun delete(context: Context, uuid: UUID) { + withContext(NonCancellable) { + profileLock.withLock { + ImportedDao().remove(uuid) + PendingDao().remove(uuid) + + val pending = context.pendingDir.resolve(uuid.toString()) + val imported = context.importedDir.resolve(uuid.toString()) + + pending.deleteRecursively() + imported.deleteRecursively() + + context.sendProfileChanged(uuid) + } + } + } + + suspend fun release(context: Context, uuid: UUID): Boolean { + return withContext(NonCancellable) { + profileLock.withLock { + PendingDao().remove(uuid) + + context.pendingDir.resolve(uuid.toString()).deleteRecursively() + } + } + } + + suspend fun active(context: Context, uuid: UUID) { + withContext(NonCancellable) { + profileLock.withLock { + if (ImportedDao().exists(uuid)) { + val store = ServiceStore(context) + + store.activeProfile = uuid + + context.sendProfileChanged(uuid) + } + } + } + } + + private fun Pending.enforceFieldValid() { + val scheme = Uri.parse(source)?.scheme?.lowercase(Locale.getDefault()) + + when { + name.isBlank() -> + throw IllegalArgumentException("Empty name") + source.isEmpty() && type != Profile.Type.File -> + throw IllegalArgumentException("Invalid url") + source.isNotEmpty() && scheme != "https" && scheme != "http" && scheme != "content" -> + throw IllegalArgumentException("Unsupported url $source") + interval != 0L && TimeUnit.MILLISECONDS.toMinutes(interval) < 15 -> + throw IllegalArgumentException("Invalid interval") + } + } +} \ No newline at end of file diff --git a/service/src/main/java/com/github/kr328/clash/service/ProfileReceiver.kt b/service/src/main/java/com/github/kr328/clash/service/ProfileReceiver.kt new file mode 100644 index 00000000..f81a817d --- /dev/null +++ b/service/src/main/java/com/github/kr328/clash/service/ProfileReceiver.kt @@ -0,0 +1,120 @@ +package com.github.kr328.clash.service + +import android.app.AlarmManager +import android.app.PendingIntent +import android.content.BroadcastReceiver +import android.content.Context +import android.content.Intent +import androidx.core.content.getSystemService +import com.github.kr328.clash.common.compat.pendingIntentFlags +import com.github.kr328.clash.common.compat.startForegroundServiceCompat +import com.github.kr328.clash.common.constants.Intents +import com.github.kr328.clash.common.log.Log +import com.github.kr328.clash.common.util.componentName +import com.github.kr328.clash.common.util.setUUID +import com.github.kr328.clash.service.data.Imported +import com.github.kr328.clash.service.data.ImportedDao +import com.github.kr328.clash.service.model.Profile +import com.github.kr328.clash.service.util.importedDir +import kotlinx.coroutines.GlobalScope +import kotlinx.coroutines.launch +import kotlinx.coroutines.sync.Mutex +import kotlinx.coroutines.sync.withLock +import java.util.concurrent.TimeUnit + +class ProfileReceiver : BroadcastReceiver() { + override fun onReceive(context: Context, intent: Intent) { + when (intent.action) { + Intent.ACTION_BOOT_COMPLETED, Intent.ACTION_MY_PACKAGE_REPLACED, + Intent.ACTION_TIMEZONE_CHANGED, Intent.ACTION_TIME_CHANGED -> { + GlobalScope.launch { + reset() + + val service = Intent(Intents.ACTION_PROFILE_SCHEDULE_UPDATES) + .setComponent(ProfileWorker::class.componentName) + + context.startForegroundServiceCompat(service) + } + } + Intents.ACTION_PROFILE_REQUEST_UPDATE -> { + val redirect = intent.setComponent(ProfileWorker::class.componentName) + + context.startForegroundServiceCompat(redirect) + } + } + } + + companion object { + private val lock = Mutex() + private var initialized: Boolean = false + + suspend fun rescheduleAll(context: Context) = lock.withLock { + if (initialized) + return + + initialized = true + + Log.i("Reschedule all profiles update") + + ImportedDao().queryAllUUIDs() + .mapNotNull { ImportedDao().queryByUUID(it) } + .filter { it.type != Profile.Type.File } + .forEach { scheduleNext(context, it) } + } + + fun cancelNext(context: Context, imported: Imported) { + val intent = pendingIntentOf(context, imported) + + context.getSystemService()?.cancel(intent) + } + + fun schedule(context: Context, imported: Imported) { + val intent = pendingIntentOf(context, imported) + + context.getSystemService()?.cancel(intent) + + intent.send(context, 0, null) + } + + fun scheduleNext(context: Context, imported: Imported) { + val intent = pendingIntentOf(context, imported) + + context.getSystemService()?.cancel(intent) + + if (imported.interval < TimeUnit.MINUTES.toMillis(15)) + return + + val current = System.currentTimeMillis() + val last = context.importedDir + .resolve(imported.uuid.toString()) + .resolve("config.yaml") + .lastModified() + + // file not existed + if (last < 0) + return + + val interval = (imported.interval - (current - last)).coerceAtLeast(0) + + context.getSystemService() + ?.set(AlarmManager.RTC, current + interval, intent) + } + + private suspend fun reset() = lock.withLock { + initialized = false + } + + private fun pendingIntentOf(context: Context, imported: Imported): PendingIntent { + val intent = Intent(Intents.ACTION_PROFILE_REQUEST_UPDATE) + .setComponent(ProfileReceiver::class.componentName) + .setUUID(imported.uuid) + + return PendingIntent.getBroadcast( + context, + 0, + intent, + pendingIntentFlags(PendingIntent.FLAG_UPDATE_CURRENT) + ) + } + } +} \ No newline at end of file diff --git a/service/src/main/java/com/github/kr328/clash/service/ProfileService.kt b/service/src/main/java/com/github/kr328/clash/service/ProfileService.kt new file mode 100644 index 00000000..699bec8c --- /dev/null +++ b/service/src/main/java/com/github/kr328/clash/service/ProfileService.kt @@ -0,0 +1,215 @@ +package com.github.kr328.clash.service + +import android.content.Intent +import android.os.IBinder +import com.github.kr328.clash.service.data.Database +import com.github.kr328.clash.service.data.ImportedDao +import com.github.kr328.clash.service.data.Pending +import com.github.kr328.clash.service.data.PendingDao +import com.github.kr328.clash.service.model.Profile +import com.github.kr328.clash.service.remote.IFetchObserver +import com.github.kr328.clash.service.remote.IProfileManager +import com.github.kr328.clash.service.remote.wrap +import com.github.kr328.clash.service.store.ServiceStore +import com.github.kr328.clash.service.util.directoryLastModified +import com.github.kr328.clash.service.util.generateProfileUUID +import com.github.kr328.clash.service.util.importedDir +import com.github.kr328.clash.service.util.pendingDir +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.launch +import kotlinx.coroutines.withContext +import java.io.FileNotFoundException +import java.util.* + +class ProfileService : BaseService(), IProfileManager { + private val service = this + private val store by lazy { ServiceStore(this) } + private val binder = this.wrap() + + override fun onBind(intent: Intent?): IBinder { + return binder + } + + override fun onCreate() { + super.onCreate() + + Database.database //.init + + launch { + ProfileReceiver.rescheduleAll(service) + } + } + + override suspend fun create(type: Profile.Type, name: String, source: String): UUID { + val uuid = generateProfileUUID() + val pending = Pending( + uuid = uuid, + name = name, + type = type, + source = source, + interval = 0, + ) + + PendingDao().insert(pending) + + pendingDir.resolve(uuid.toString()).apply { + deleteRecursively() + mkdirs() + + @Suppress("BlockingMethodInNonBlockingContext") + resolve("config.yaml").createNewFile() + resolve("providers").mkdir() + } + + return uuid + } + + override suspend fun clone(uuid: UUID): UUID { + val newUUID = generateProfileUUID() + + val imported = ImportedDao().queryByUUID(uuid) + ?: throw FileNotFoundException("profile $uuid not found") + + val pending = Pending( + uuid = newUUID, + name = imported.name, + type = Profile.Type.File, + source = imported.source, + interval = imported.interval, + ) + + cloneImportedFiles(uuid, newUUID) + + PendingDao().insert(pending) + + return newUUID + } + + override suspend fun patch(uuid: UUID, name: String, source: String, interval: Long) { + val pending = PendingDao().queryByUUID(uuid) + + if (pending == null) { + val imported = ImportedDao().queryByUUID(uuid) + ?: throw FileNotFoundException("profile $uuid not found") + + cloneImportedFiles(uuid) + + PendingDao().insert( + Pending( + uuid = imported.uuid, + name = name, + type = imported.type, + source = source, + interval = interval, + ) + ) + } else { + val newPending = pending.copy( + name = name, + source = source, + interval = interval + ) + + PendingDao().update(newPending) + } + } + + override suspend fun update(uuid: UUID) { + scheduleUpdate(uuid, true) + } + + override suspend fun commit(uuid: UUID, callback: IFetchObserver?) { + ProfileProcessor.apply(service, uuid, callback) + + scheduleUpdate(uuid, false) + } + + override suspend fun release(uuid: UUID) { + ProfileProcessor.release(this, uuid) + } + + override suspend fun delete(uuid: UUID) { + ImportedDao().queryByUUID(uuid)?.also { + ProfileReceiver.cancelNext(service, it) + } + + ProfileProcessor.delete(service, uuid) + } + + override suspend fun queryByUUID(uuid: UUID): Profile? { + return resolveProfile(uuid) + } + + override suspend fun queryAll(): List { + val uuids = withContext(Dispatchers.IO) { + (ImportedDao().queryAllUUIDs() + PendingDao().queryAllUUIDs()).distinct() + } + + return uuids.mapNotNull { resolveProfile(it) } + } + + override suspend fun queryActive(): Profile? { + val active = store.activeProfile ?: return null + + return if (ImportedDao().exists(active)) { + resolveProfile(active) + } else { + null + } + } + + override suspend fun setActive(profile: Profile) { + ProfileProcessor.active(this, profile.uuid) + } + + private suspend fun resolveProfile(uuid: UUID): Profile? { + val imported = ImportedDao().queryByUUID(uuid) + val pending = PendingDao().queryByUUID(uuid) + + val active = store.activeProfile + val name = pending?.name ?: imported?.name ?: return null + val type = pending?.type ?: imported?.type ?: return null + val source = pending?.source ?: imported?.source ?: return null + val interval = pending?.interval ?: imported?.interval ?: return null + + return Profile( + uuid, + name, + type, + source, + active != null && imported?.uuid == active, + interval, + resolveUpdatedAt(uuid), + imported != null, + pending != null + ) + } + + private fun resolveUpdatedAt(uuid: UUID): Long { + return pendingDir.resolve(uuid.toString()).directoryLastModified + ?: importedDir.resolve(uuid.toString()).directoryLastModified + ?: -1 + } + + private fun cloneImportedFiles(source: UUID, target: UUID = source) { + val s = importedDir.resolve(source.toString()) + val t = pendingDir.resolve(target.toString()) + + if (!s.exists()) + throw FileNotFoundException("profile $source not found") + + t.deleteRecursively() + + s.copyRecursively(t) + } + + private suspend fun scheduleUpdate(uuid: UUID, startImmediately: Boolean) { + val imported = ImportedDao().queryByUUID(uuid) ?: return + + if (startImmediately) { + ProfileReceiver.schedule(service, imported) + } else { + ProfileReceiver.scheduleNext(service, imported) + } + } +} \ No newline at end of file diff --git a/service/src/main/java/com/github/kr328/clash/service/ProfileWorker.kt b/service/src/main/java/com/github/kr328/clash/service/ProfileWorker.kt new file mode 100644 index 00000000..4c6fa80f --- /dev/null +++ b/service/src/main/java/com/github/kr328/clash/service/ProfileWorker.kt @@ -0,0 +1,223 @@ +package com.github.kr328.clash.service + +import android.app.NotificationChannel +import android.app.NotificationManager +import android.app.PendingIntent +import android.content.Intent +import android.os.Binder +import android.os.Build +import android.os.IBinder +import androidx.core.app.NotificationCompat +import androidx.core.app.NotificationManagerCompat +import com.github.kr328.clash.common.compat.getColorCompat +import com.github.kr328.clash.common.compat.pendingIntentFlags +import com.github.kr328.clash.common.constants.Components +import com.github.kr328.clash.common.constants.Intents +import com.github.kr328.clash.common.id.UndefinedIds +import com.github.kr328.clash.common.log.Log +import com.github.kr328.clash.common.util.setUUID +import com.github.kr328.clash.common.util.uuid +import com.github.kr328.clash.service.data.ImportedDao +import kotlinx.coroutines.* +import java.util.* +import java.util.concurrent.TimeUnit + +class ProfileWorker : BaseService() { + private val service: ProfileWorker + get() = this + + private val jobs = mutableListOf() + + override fun onCreate() { + super.onCreate() + + createChannels() + + foreground() + + launch { + delay(TimeUnit.SECONDS.toMillis(10)) + + while (true) { + jobs.removeFirstOrNull()?.join() ?: break + } + + stopSelf() + } + } + + override fun onDestroy() { + stopForeground(true) + + super.onDestroy() + } + + override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { + super.onStartCommand(intent, flags, startId) + + when (intent?.action) { + Intents.ACTION_PROFILE_REQUEST_UPDATE -> { + intent.uuid?.also { + val job = launch { + run(it) + } + + jobs.add(job) + } + } + Intents.ACTION_PROFILE_SCHEDULE_UPDATES -> { + val job = launch { + ProfileReceiver.rescheduleAll(service) + + delay(TimeUnit.SECONDS.toMillis(30)) + } + + jobs.add(job) + } + } + + return START_NOT_STICKY + } + + private suspend fun run(uuid: UUID) { + val imported = ImportedDao().queryByUUID(uuid) ?: return + + try { + processing(imported.name) { + ProfileProcessor.update(this, imported.uuid, null) + } + + completed(imported.uuid, imported.name) + + ProfileReceiver.scheduleNext(this, imported) + } catch (e: Exception) { + failed(imported.uuid, imported.name, e.message ?: "Unknown") + } + } + + private fun createChannels() { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) + return + + NotificationManagerCompat.from(this).createNotificationChannels( + listOf( + NotificationChannel( + SERVICE_CHANNEL, + getString(R.string.profile_service_status), + NotificationManager.IMPORTANCE_LOW + ), + NotificationChannel( + STATUS_CHANNEL, + getString(R.string.profile_process_status), + NotificationManager.IMPORTANCE_LOW + ), + NotificationChannel( + RESULT_CHANNEL, + getString(R.string.profile_process_result), + NotificationManager.IMPORTANCE_DEFAULT + ) + ) + ) + } + + private fun foreground() { + val notification = NotificationCompat.Builder(this, SERVICE_CHANNEL) + .setContentTitle(getString(R.string.profile_updater)) + .setContentText(getString(R.string.running)) + .setColor(getColorCompat(R.color.color_clash)) + .setSmallIcon(R.drawable.ic_logo_service) + .setOngoing(true) + .setOnlyAlertOnce(true) + .build() + + startForeground(R.id.nf_profile_worker, notification) + } + + private suspend inline fun processing(name: String, block: () -> Unit) { + val id = UndefinedIds.next() + + val notification = NotificationCompat.Builder(this, STATUS_CHANNEL) + .setContentTitle(getString(R.string.profile_updating)) + .setContentText(name) + .setColor(getColorCompat(R.color.color_clash)) + .setSmallIcon(R.drawable.ic_logo_service) + .setOngoing(true) + .setOnlyAlertOnce(true) + .setGroup(STATUS_CHANNEL) + .build() + + NotificationManagerCompat.from(applicationContext) + .notify(id, notification) + + Log.d("notify processing $name: id = $id") + + try { + block() + } finally { + withContext(NonCancellable) { + NotificationManagerCompat.from(applicationContext) + .cancel(id) + + Log.d("notify processed $name: id = $id") + } + } + } + + private fun resultBuilder(id: Int, uuid: UUID): NotificationCompat.Builder { + val intent = PendingIntent.getActivity( + this, + id, + Intent().setComponent(Components.PROPERTIES_ACTIVITY).setUUID(uuid), + pendingIntentFlags(PendingIntent.FLAG_UPDATE_CURRENT) + ) + + return NotificationCompat.Builder(this, RESULT_CHANNEL) + .setColor(getColorCompat(R.color.color_clash)) + .setSmallIcon(R.drawable.ic_logo_service) + .setOnlyAlertOnce(true) + .setContentIntent(intent) + .setAutoCancel(true) + .setGroup(RESULT_CHANNEL) + } + + private fun completed(uuid: UUID, name: String) { + val id = UndefinedIds.next() + + val notification = resultBuilder(id, uuid) + .setContentTitle(getString(R.string.update_successfully)) + .setContentText(getString(R.string.format_update_complete, name)) + .build() + + NotificationManagerCompat.from(this) + .notify(id, notification) + + Log.d("notify completed $name: id = $id") + } + + private fun failed(uuid: UUID, name: String, reason: String) { + val id = UndefinedIds.next() + + val content = getString(R.string.format_update_failure, name, reason) + + val notification = resultBuilder(id, uuid) + .setContentTitle(getString(R.string.update_failure)) + .setContentText(content) + .setStyle(NotificationCompat.BigTextStyle().bigText(content)) + .build() + + NotificationManagerCompat.from(this) + .notify(id, notification) + + Log.d("notify failed $name: id = $id") + } + + companion object { + private const val SERVICE_CHANNEL = "profile_service_channel" + private const val STATUS_CHANNEL = "profile_status_channel" + private const val RESULT_CHANNEL = "profile_result_channel" + } + + override fun onBind(intent: Intent?): IBinder { + return Binder() + } +} \ No newline at end of file diff --git a/service/src/main/java/com/github/kr328/clash/service/StatusProvider.kt b/service/src/main/java/com/github/kr328/clash/service/StatusProvider.kt new file mode 100644 index 00000000..bd3eb8a9 --- /dev/null +++ b/service/src/main/java/com/github/kr328/clash/service/StatusProvider.kt @@ -0,0 +1,83 @@ +package com.github.kr328.clash.service + +import android.content.ContentProvider +import android.content.ContentValues +import android.database.Cursor +import android.net.Uri +import android.os.Bundle +import com.github.kr328.clash.common.Global + +class StatusProvider : ContentProvider() { + override fun call(method: String, arg: String?, extras: Bundle?): Bundle? { + return when (method) { + METHOD_CURRENT_PROFILE -> { + return if (serviceRunning) + Bundle().apply { + putString("name", currentProfile) + } + else + null + } + else -> super.call(method, arg, extras) + } + } + + override fun insert(uri: Uri, values: ContentValues?): Uri? { + throw IllegalArgumentException("Stub!") + } + + override fun query( + uri: Uri, + projection: Array?, + selection: String?, + selectionArgs: Array?, + sortOrder: String? + ): Cursor? { + throw IllegalArgumentException("Stub!") + } + + override fun update( + uri: Uri, + values: ContentValues?, + selection: String?, + selectionArgs: Array? + ): Int { + throw IllegalArgumentException("Stub!") + } + + override fun delete(uri: Uri, selection: String?, selectionArgs: Array?): Int { + throw IllegalArgumentException("Stub!") + } + + override fun getType(uri: Uri): String? { + throw IllegalArgumentException("Stub!") + } + + override fun onCreate(): Boolean { + return true + } + + companion object { + const val METHOD_CURRENT_PROFILE = "currentProfile" + + private const val CLASH_SERVICE_RUNNING_FILE = "service_running.lock" + + var serviceRunning: Boolean = false + set(value) { + field = value + + shouldStartClashOnBoot = value + } + var shouldStartClashOnBoot: Boolean + get() = Global.application.filesDir.resolve(CLASH_SERVICE_RUNNING_FILE).exists() + set(value) { + Global.application.filesDir.resolve(CLASH_SERVICE_RUNNING_FILE).apply { + if (value) + createNewFile() + else + delete() + } + } + var currentProfile: String? = null + } +} \ No newline at end of file diff --git a/service/src/main/java/com/github/kr328/clash/service/TunService.kt b/service/src/main/java/com/github/kr328/clash/service/TunService.kt new file mode 100644 index 00000000..0b731c4f --- /dev/null +++ b/service/src/main/java/com/github/kr328/clash/service/TunService.kt @@ -0,0 +1,237 @@ +package com.github.kr328.clash.service + +import android.app.PendingIntent +import android.content.Intent +import android.net.ProxyInfo +import android.net.VpnService +import android.os.Build +import com.github.kr328.clash.common.compat.pendingIntentFlags +import com.github.kr328.clash.common.constants.Components +import com.github.kr328.clash.common.log.Log +import com.github.kr328.clash.service.clash.clashRuntime +import com.github.kr328.clash.service.clash.module.* +import com.github.kr328.clash.service.model.AccessControlMode +import com.github.kr328.clash.service.store.ServiceStore +import com.github.kr328.clash.service.util.cancelAndJoinBlocking +import com.github.kr328.clash.service.util.parseCIDR +import com.github.kr328.clash.service.util.sendClashStarted +import com.github.kr328.clash.service.util.sendClashStopped +import kotlinx.coroutines.* +import kotlinx.coroutines.selects.select + +class TunService : VpnService(), CoroutineScope by CoroutineScope(Dispatchers.Default) { + private val self: TunService + get() = this + + private var reason: String? = null + + private val runtime = clashRuntime { + val store = ServiceStore(self) + + val close = install(CloseModule(self)) + val tun = install(TunModule(self)) + val config = install(ConfigurationModule(self)) + val network = install(NetworkObserveModule(self)) + val sideload = install(SideloadDatabaseModule(self)) + + if (store.dynamicNotification) + install(DynamicNotificationModule(self)) + else + install(StaticNotificationModule(self)) + + install(AppListCacheModule(self)) + install(SuspendModule(self)) + + try { + tun.open() + + while (isActive) { + val quit = select { + close.onEvent { + true + } + config.onEvent { + reason = it.message + + true + } + sideload.onEvent { + reason = it.message + + true + } + network.onEvent { e -> + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) { + setUnderlyingNetworks(e.network?.let { arrayOf(it) }) + } + + config.reload() + + false + } + } + + if (quit) break + } + } catch (e: Exception) { + Log.e("Create clash runtime: ${e.message}", e) + + reason = e.message + } finally { + withContext(NonCancellable) { + tun.close() + + stopSelf() + } + } + } + + override fun onCreate() { + super.onCreate() + + if (StatusProvider.serviceRunning) + return stopSelf() + + StatusProvider.serviceRunning = true + + StaticNotificationModule.createNotificationChannel(this) + StaticNotificationModule.notifyLoadingNotification(this) + + runtime.launch() + } + + override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { + sendClashStarted() + + return super.onStartCommand(intent, flags, startId) + } + + override fun onDestroy() { + TunModule.requestStop() + + StatusProvider.serviceRunning = false + + sendClashStopped(reason) + + cancelAndJoinBlocking() + + Log.i("TunService destroyed: ${reason ?: "successfully"}") + + super.onDestroy() + } + + override fun onTrimMemory(level: Int) { + super.onTrimMemory(level) + + runtime.requestGc() + } + + private fun TunModule.open() { + val store = ServiceStore(self) + + val device = with(Builder()) { + // Interface address + addAddress(TUN_GATEWAY, TUN_SUBNET_PREFIX) + + // Route + if (store.bypassPrivateNetwork) { + resources.getStringArray(R.array.bypass_private_route).map(::parseCIDR).forEach { + addRoute(it.ip, it.prefix) + } + } else { + addRoute(NET_ANY, 0) + } + + // Access Control + when (store.accessControlMode) { + AccessControlMode.AcceptAll -> Unit + AccessControlMode.AcceptSelected -> { + (store.accessControlPackages + packageName).forEach { + runCatching { addAllowedApplication(it) } + } + } + AccessControlMode.DenySelected -> { + (store.accessControlPackages - packageName).forEach { + runCatching { addDisallowedApplication(it) } + } + } + } + + // Blocking + setBlocking(false) + + // Mtu + setMtu(TUN_MTU) + + // Session Name + setSession("Clash") + + // Virtual Dns Server + addDnsServer(TUN_DNS) + + // Open MainActivity + setConfigureIntent( + PendingIntent.getActivity( + self, + R.id.nf_vpn_status, + Intent().setComponent(Components.MAIN_ACTIVITY), + pendingIntentFlags(PendingIntent.FLAG_UPDATE_CURRENT) + ) + ) + + // Metered + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { + setMetered(false) + } + + // System Proxy + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && store.systemProxy) { + listenHttp()?.let { + setHttpProxy( + ProxyInfo.buildDirectProxy( + it.address.hostAddress, + it.port, + if (store.bypassPrivateNetwork) + listOf( + "localhost", + "*.local", + "127.*", + "10.*", + "172.16.*", + "172.17.*", + "172.18.*", + "172.19.*", + "172.2*", + "172.30.*", + "172.31.*", + "192.168.*" + ) + else + emptyList() + ) + ) + } + } + + TunModule.TunDevice( + fd = establish()?.detachFd() + ?: throw NullPointerException("Establish VPN rejected by system"), + mtu = TUN_MTU, + gateway = TUN_GATEWAY, + mirror = TUN_MIRROR, + dns = if (store.dnsHijacking) NET_ANY else TUN_DNS, + ) + } + + attach(device) + } + + companion object { + private const val TUN_MTU = 9000 + private const val TUN_SUBNET_PREFIX = 30 + private const val TUN_GATEWAY = "172.31.255.253" + private const val TUN_MIRROR = "172.31.255.254" + private const val TUN_DNS = "198.18.0.1" + private const val NET_ANY = "0.0.0.0" + } +} \ No newline at end of file diff --git a/service/src/main/java/com/github/kr328/clash/service/clash/ClashRuntime.kt b/service/src/main/java/com/github/kr328/clash/service/clash/ClashRuntime.kt new file mode 100644 index 00000000..8c61275d --- /dev/null +++ b/service/src/main/java/com/github/kr328/clash/service/clash/ClashRuntime.kt @@ -0,0 +1,65 @@ +package com.github.kr328.clash.service.clash + +import com.github.kr328.clash.common.log.Log +import com.github.kr328.clash.core.Clash +import com.github.kr328.clash.service.clash.module.Module +import kotlinx.coroutines.* +import kotlinx.coroutines.sync.Mutex +import kotlinx.coroutines.sync.withLock + +private val globalLock = Mutex() + +interface ClashRuntimeScope { + fun > install(module: T): T +} + +interface ClashRuntime { + fun launch() + fun requestGc() +} + +fun CoroutineScope.clashRuntime(block: suspend ClashRuntimeScope.() -> Unit): ClashRuntime { + return object : ClashRuntime { + override fun launch() { + launch(Dispatchers.IO) { + globalLock.withLock { + Log.d("ClashRuntime: initialize") + + try { + val modules = mutableListOf>() + + Clash.reset() + Clash.clearOverride(Clash.OverrideSlot.Session) + + val scope = object : ClashRuntimeScope { + override fun > install(module: T): T { + launch { + modules.add(module) + + module.execute() + } + + return module + } + } + + scope.block() + + cancel() + } finally { + withContext(NonCancellable) { + Clash.reset() + Clash.clearOverride(Clash.OverrideSlot.Session) + + Log.d("ClashRuntime: destroyed") + } + } + } + } + } + + override fun requestGc() { + Clash.forceGc() + } + } +} \ No newline at end of file diff --git a/service/src/main/java/com/github/kr328/clash/service/clash/module/AppListCacheModule.kt b/service/src/main/java/com/github/kr328/clash/service/clash/module/AppListCacheModule.kt new file mode 100644 index 00000000..97697594 --- /dev/null +++ b/service/src/main/java/com/github/kr328/clash/service/clash/module/AppListCacheModule.kt @@ -0,0 +1,40 @@ +package com.github.kr328.clash.service.clash.module + +import android.app.Service +import android.content.Intent +import android.content.pm.PackageInfo +import com.github.kr328.clash.common.log.Log +import com.github.kr328.clash.core.Clash +import kotlinx.coroutines.channels.Channel +import kotlinx.coroutines.delay +import java.util.concurrent.TimeUnit + +class AppListCacheModule(service: Service) : Module(service) { + private fun PackageInfo.uniqueUidName(): String = + if (sharedUserId != null && sharedUserId.isNotBlank()) sharedUserId else packageName + + private fun reload() { + val packages = service.packageManager.getInstalledPackages(0) + .map { it.applicationInfo.uid to it.uniqueUidName() } + + Clash.notifyInstalledAppsChanged(packages) + + Log.d("Installed ${packages.size} packages cached") + } + + override suspend fun run() { + val packageChanged = receiveBroadcast(false, Channel.CONFLATED) { + addAction(Intent.ACTION_PACKAGE_ADDED) + addAction(Intent.ACTION_PACKAGE_REMOVED) + addDataScheme("package") + } + + while (true) { + reload() + + packageChanged.receive() + + delay(TimeUnit.SECONDS.toMillis(10)) + } + } +} \ No newline at end of file diff --git a/service/src/main/java/com/github/kr328/clash/service/clash/module/CloseModule.kt b/service/src/main/java/com/github/kr328/clash/service/clash/module/CloseModule.kt new file mode 100644 index 00000000..1fd5de29 --- /dev/null +++ b/service/src/main/java/com/github/kr328/clash/service/clash/module/CloseModule.kt @@ -0,0 +1,21 @@ +package com.github.kr328.clash.service.clash.module + +import android.app.Service +import com.github.kr328.clash.common.constants.Intents +import com.github.kr328.clash.common.log.Log + +class CloseModule(service: Service) : Module(service) { + object RequestClose + + override suspend fun run() { + val broadcasts = receiveBroadcast { + addAction(Intents.ACTION_CLASH_REQUEST_STOP) + } + + broadcasts.receive() + + Log.d("User request close") + + return enqueueEvent(RequestClose) + } +} \ No newline at end of file diff --git a/service/src/main/java/com/github/kr328/clash/service/clash/module/ConfigurationModule.kt b/service/src/main/java/com/github/kr328/clash/service/clash/module/ConfigurationModule.kt new file mode 100644 index 00000000..202643c9 --- /dev/null +++ b/service/src/main/java/com/github/kr328/clash/service/clash/module/ConfigurationModule.kt @@ -0,0 +1,80 @@ +package com.github.kr328.clash.service.clash.module + +import android.app.Service +import com.github.kr328.clash.common.constants.Intents +import com.github.kr328.clash.common.log.Log +import com.github.kr328.clash.core.Clash +import com.github.kr328.clash.service.StatusProvider +import com.github.kr328.clash.service.data.ImportedDao +import com.github.kr328.clash.service.data.SelectionDao +import com.github.kr328.clash.service.store.ServiceStore +import com.github.kr328.clash.service.util.importedDir +import com.github.kr328.clash.service.util.sendProfileLoaded +import kotlinx.coroutines.channels.Channel +import kotlinx.coroutines.selects.select +import java.util.* + +class ConfigurationModule(service: Service) : Module(service) { + data class LoadException(val message: String) + + private val store = ServiceStore(service) + private val reload = Channel(Channel.CONFLATED) + + override suspend fun run() { + val broadcasts = receiveBroadcast { + addAction(Intents.ACTION_PROFILE_CHANGED) + addAction(Intents.ACTION_OVERRIDE_CHANGED) + } + + var loaded: UUID? = null + + reload.offer(Unit) + + while (true) { + val changed: UUID? = select { + broadcasts.onReceive { + if (it.action == Intents.ACTION_PROFILE_CHANGED) + UUID.fromString(it.getStringExtra(Intents.EXTRA_UUID)) + else + null + } + reload.onReceive { + null + } + } + + try { + val current = store.activeProfile + ?: throw NullPointerException("No profile selected") + + if (current == loaded && changed != null && changed != loaded) + continue + + loaded = current + + val active = ImportedDao().queryByUUID(current) + ?: throw NullPointerException("No profile selected") + + Clash.load(service.importedDir.resolve(active.uuid.toString())).await() + + val remove = SelectionDao().querySelections(active.uuid) + .filterNot { Clash.patchSelector(it.proxy, it.selected) } + .map { it.proxy } + + SelectionDao().removeSelections(active.uuid, remove) + + StatusProvider.currentProfile = active.name + + service.sendProfileLoaded(current) + + Log.d("Profile ${active.name} loaded") + } catch (e: Exception) { + return enqueueEvent(LoadException(e.message ?: "Unknown")) + } + } + } + + fun reload() { + reload.offer(Unit) + } +} \ No newline at end of file diff --git a/service/src/main/java/com/github/kr328/clash/service/clash/module/DynamicNotificationModule.kt b/service/src/main/java/com/github/kr328/clash/service/clash/module/DynamicNotificationModule.kt new file mode 100644 index 00000000..96d5bc11 --- /dev/null +++ b/service/src/main/java/com/github/kr328/clash/service/clash/module/DynamicNotificationModule.kt @@ -0,0 +1,104 @@ +package com.github.kr328.clash.service.clash.module + +import android.app.PendingIntent +import android.app.Service +import android.content.Intent +import android.os.PowerManager +import androidx.core.app.NotificationCompat +import androidx.core.content.getSystemService +import com.github.kr328.clash.common.compat.getColorCompat +import com.github.kr328.clash.common.compat.pendingIntentFlags +import com.github.kr328.clash.common.constants.Components +import com.github.kr328.clash.common.constants.Intents +import com.github.kr328.clash.common.util.ticker +import com.github.kr328.clash.core.Clash +import com.github.kr328.clash.core.util.trafficDownload +import com.github.kr328.clash.core.util.trafficUpload +import com.github.kr328.clash.service.R +import com.github.kr328.clash.service.StatusProvider +import kotlinx.coroutines.channels.Channel +import kotlinx.coroutines.coroutineScope +import kotlinx.coroutines.selects.select +import java.util.concurrent.TimeUnit + +class DynamicNotificationModule(service: Service) : Module(service) { + private val builder = NotificationCompat.Builder(service, StaticNotificationModule.CHANNEL_ID) + .setSmallIcon(R.drawable.ic_logo_service) + .setOngoing(true) + .setColor(service.getColorCompat(R.color.color_clash)) + .setOnlyAlertOnce(true) + .setShowWhen(false) + .setContentTitle("Not Selected") + .setContentIntent( + PendingIntent.getActivity( + service, + R.id.nf_clash_status, + Intent().setComponent(Components.MAIN_ACTIVITY) + .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP), + pendingIntentFlags(PendingIntent.FLAG_UPDATE_CURRENT) + ) + ) + + private fun update() { + val now = Clash.queryTrafficNow() + val total = Clash.queryTrafficTotal() + + val uploading = now.trafficUpload() + val downloading = now.trafficDownload() + val uploaded = total.trafficUpload() + val downloaded = total.trafficDownload() + + val notification = builder + .setContentText( + service.getString( + R.string.clash_notification_content, + "$uploading/s", "$downloading/s" + ) + ) + .setSubText( + service.getString( + R.string.clash_notification_content, + uploaded, downloaded + ) + ) + .build() + + service.startForeground(R.id.nf_clash_status, notification) + } + + override suspend fun run() = coroutineScope { + var shouldUpdate = service.getSystemService()?.isInteractive ?: true + + val screenToggle = receiveBroadcast(false, Channel.CONFLATED) { + addAction(Intent.ACTION_SCREEN_ON) + addAction(Intent.ACTION_SCREEN_OFF) + } + + val profileLoaded = receiveBroadcast(capacity = Channel.CONFLATED) { + addAction(Intents.ACTION_PROFILE_LOADED) + } + + val ticker = ticker(TimeUnit.SECONDS.toMillis(1)) + + while (true) { + select { + screenToggle.onReceive { + when (it.action) { + Intent.ACTION_SCREEN_ON -> + shouldUpdate = true + Intent.ACTION_SCREEN_OFF -> + shouldUpdate = false + } + } + profileLoaded.onReceive { + builder.setContentTitle(StatusProvider.currentProfile ?: "Not selected") + } + if (shouldUpdate) { + ticker.onReceive { + update() + } + } + } + } + } +} \ No newline at end of file diff --git a/service/src/main/java/com/github/kr328/clash/service/clash/module/Module.kt b/service/src/main/java/com/github/kr328/clash/service/clash/module/Module.kt new file mode 100644 index 00000000..75dd61b1 --- /dev/null +++ b/service/src/main/java/com/github/kr328/clash/service/clash/module/Module.kt @@ -0,0 +1,78 @@ +package com.github.kr328.clash.service.clash.module + +import android.app.Service +import android.content.BroadcastReceiver +import android.content.Context +import android.content.Intent +import android.content.IntentFilter +import com.github.kr328.clash.common.constants.Permissions +import com.github.kr328.clash.common.log.Log +import kotlinx.coroutines.NonCancellable +import kotlinx.coroutines.channels.Channel +import kotlinx.coroutines.channels.ReceiveChannel +import kotlinx.coroutines.selects.SelectClause1 +import kotlinx.coroutines.withContext + +abstract class Module(val service: Service) { + private val events: Channel = Channel(Channel.UNLIMITED) + private val receivers: MutableList = mutableListOf() + + val onEvent: SelectClause1 + get() = events.onReceive + + protected suspend fun enqueueEvent(event: E) { + events.send(event) + } + + protected fun receiveBroadcast( + requireSelf: Boolean = true, + capacity: Int = Channel.UNLIMITED, + configure: IntentFilter.() -> Unit + ): ReceiveChannel { + val filter = IntentFilter().apply(configure) + val channel = Channel(capacity) + val receiver = object : BroadcastReceiver() { + override fun onReceive(context: Context?, intent: Intent?) { + if (context == null || intent == null) { + channel.close() + + return + } + + channel.offer(intent) + } + } + + if (requireSelf) { + service.registerReceiver(receiver, filter, Permissions.RECEIVE_SELF_BROADCASTS, null) + } else { + service.registerReceiver(receiver, filter) + } + + receivers.add(receiver) + + return channel + } + + suspend fun execute() { + val moduleName = this.javaClass.simpleName + + try { + Log.d("$moduleName: initialize") + + run() + } finally { + withContext(NonCancellable) { + receivers.forEach { + it.onReceive(null, null) + + service.unregisterReceiver(it) + } + + Log.d("$moduleName: destroyed") + } + } + } + + protected abstract suspend fun run() +} \ No newline at end of file diff --git a/service/src/main/java/com/github/kr328/clash/service/clash/module/NetworkObserveModule.kt b/service/src/main/java/com/github/kr328/clash/service/clash/module/NetworkObserveModule.kt new file mode 100644 index 00000000..877662b6 --- /dev/null +++ b/service/src/main/java/com/github/kr328/clash/service/clash/module/NetworkObserveModule.kt @@ -0,0 +1,104 @@ +package com.github.kr328.clash.service.clash.module + +import android.annotation.TargetApi +import android.app.Service +import android.net.* +import android.os.Build +import androidx.core.content.getSystemService +import com.github.kr328.clash.common.log.Log +import com.github.kr328.clash.core.Clash +import com.github.kr328.clash.service.util.resolveDns +import kotlinx.coroutines.NonCancellable +import kotlinx.coroutines.channels.Channel +import kotlinx.coroutines.delay +import kotlinx.coroutines.withContext +import java.util.concurrent.TimeUnit + +class NetworkObserveModule(service: Service) : + Module(service) { + data class NetworkChanged(val network: Network?) + + private val connectivity = service.getSystemService()!! + private val networks: Channel = Channel(Channel.CONFLATED) + private val request = NetworkRequest.Builder().apply { + addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) + addCapability(NetworkCapabilities.NET_CAPABILITY_NOT_RESTRICTED) + if (Build.VERSION.SDK_INT == 23) { // workarounds for OEM bugs + removeCapability(NetworkCapabilities.NET_CAPABILITY_VALIDATED) + removeCapability(NetworkCapabilities.NET_CAPABILITY_CAPTIVE_PORTAL) + } + }.build() + + private val callback = object : ConnectivityManager.NetworkCallback() { + private var internet: Boolean = false + private var network: Network? = null + + override fun onAvailable(network: Network) { + this.network = network + + networks.offer(network) + } + + override fun onCapabilitiesChanged( + network: Network, + networkCapabilities: NetworkCapabilities + ) { + val internet = networkCapabilities + .hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) + + if (this.network == network && this.internet != internet) { + this.internet = internet + + networks.offer(network) + } + } + + override fun onLost(network: Network) { + if (this.network == network) { + networks.offer(null) + } + } + + override fun onLinkPropertiesChanged(network: Network, linkProperties: LinkProperties) { + if (this.network == network) { + networks.offer(network) + } + } + } + + override suspend fun run() { + try { + if (Build.VERSION.SDK_INT in 24..27) @TargetApi(24) { + connectivity.registerDefaultNetworkCallback(callback) + } else { + connectivity.requestNetwork(request, callback) + } + } catch (e: Exception) { + Log.w("Observe network changed: $e", e) + + return + } + + try { + delay(TimeUnit.SECONDS.toMillis(10)) + + while (true) { + val network = networks.receive() + + val dns = connectivity.resolveDns(network) + + Clash.notifyDnsChanged(dns) + + Log.d("Network changed, system dns = $dns") + + enqueueEvent(NetworkChanged(network)) + } + } finally { + withContext(NonCancellable) { + connectivity.unregisterNetworkCallback(callback) + + Clash.notifyDnsChanged(emptyList()) + } + } + } +} \ No newline at end of file diff --git a/service/src/main/java/com/github/kr328/clash/service/clash/module/SideloadDatabaseModule.kt b/service/src/main/java/com/github/kr328/clash/service/clash/module/SideloadDatabaseModule.kt new file mode 100644 index 00000000..2d06222b --- /dev/null +++ b/service/src/main/java/com/github/kr328/clash/service/clash/module/SideloadDatabaseModule.kt @@ -0,0 +1,87 @@ +package com.github.kr328.clash.service.clash.module + +import android.app.Service +import android.content.Intent +import com.github.kr328.clash.common.constants.Intents +import com.github.kr328.clash.common.log.Log +import com.github.kr328.clash.core.Clash +import com.github.kr328.clash.service.sideload.readGeoipDatabaseFrom +import com.github.kr328.clash.service.store.ServiceStore +import com.github.kr328.clash.service.util.packageName +import kotlinx.coroutines.channels.Channel +import kotlinx.coroutines.selects.select +import java.io.FileNotFoundException +import java.io.IOException + +class SideloadDatabaseModule(service: Service) : + Module(service) { + data class LoadException(val message: String) + + private val store = ServiceStore(service) + + private var current: String = "" + + override suspend fun run() { + val packagesChanged = receiveBroadcast(false) { + addAction(Intent.ACTION_PACKAGE_ADDED) + addAction(Intent.ACTION_PACKAGE_REPLACED) + addAction(Intent.ACTION_PACKAGE_FULLY_REMOVED) + addDataScheme("package") + } + val profileChanged = receiveBroadcast(capacity = Channel.CONFLATED) { + addAction(Intents.ACTION_PROFILE_CHANGED) + } + val initial = Channel(1).apply { send(Unit) } + + while (true) { + val (reload, force) = select> { + packagesChanged.onReceive { + when (it.action) { + Intent.ACTION_PACKAGE_ADDED -> + (it.packageName == store.sideloadGeoip) to true + Intent.ACTION_PACKAGE_REPLACED -> + (it.packageName == current) to true + Intent.ACTION_PACKAGE_FULLY_REMOVED -> + (it.packageName == current) to true + else -> false to false + } + } + profileChanged.onReceive { + true to false + } + initial.onReceive { + true to true + } + } + + if (!reload) continue + + val pkg = store.sideloadGeoip + + try { + if (!force && pkg == current) + continue + + current = pkg + + if (pkg.isNotBlank()) { + val data = service.readGeoipDatabaseFrom(pkg) + + Clash.installSideloadGeoip(data) + + if (data != null) { + Log.d("Sideload geoip loaded, pkg = $pkg") + } else { + Log.d("Sideload geoip not found") + } + } + } catch (e: FileNotFoundException) { + return enqueueEvent(LoadException("file $pkg/assets/${e.message} not found")) + } catch (e: IOException) { + return enqueueEvent(LoadException("read data from $pkg: ${e.message}")) + } catch (e: Exception) { + return enqueueEvent(LoadException(e.toString())) + } + } + } +} \ No newline at end of file diff --git a/service/src/main/java/com/github/kr328/clash/service/clash/module/StaticNotificationModule.kt b/service/src/main/java/com/github/kr328/clash/service/clash/module/StaticNotificationModule.kt new file mode 100644 index 00000000..ee78a779 --- /dev/null +++ b/service/src/main/java/com/github/kr328/clash/service/clash/module/StaticNotificationModule.kt @@ -0,0 +1,84 @@ +package com.github.kr328.clash.service.clash.module + +import android.app.NotificationChannel +import android.app.NotificationManager +import android.app.PendingIntent +import android.app.Service +import android.content.Intent +import android.os.Build +import androidx.core.app.NotificationCompat +import androidx.core.app.NotificationManagerCompat +import com.github.kr328.clash.common.compat.getColorCompat +import com.github.kr328.clash.common.compat.pendingIntentFlags +import com.github.kr328.clash.common.constants.Components +import com.github.kr328.clash.common.constants.Intents +import com.github.kr328.clash.service.R +import com.github.kr328.clash.service.StatusProvider +import kotlinx.coroutines.channels.Channel + +class StaticNotificationModule(service: Service) : Module(service) { + private val builder = NotificationCompat.Builder(service, CHANNEL_ID) + .setSmallIcon(R.drawable.ic_logo_service) + .setOngoing(true) + .setColor(service.getColorCompat(R.color.color_clash)) + .setOnlyAlertOnce(true) + .setShowWhen(false) + .setContentIntent( + PendingIntent.getActivity( + service, + R.id.nf_clash_status, + Intent().setComponent(Components.MAIN_ACTIVITY) + .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP), + pendingIntentFlags(PendingIntent.FLAG_UPDATE_CURRENT) + ) + ) + + override suspend fun run() { + val loaded = receiveBroadcast(capacity = Channel.CONFLATED) { + addAction(Intents.ACTION_PROFILE_LOADED) + } + + while (true) { + loaded.receive() + + val profileName = StatusProvider.currentProfile ?: "Not selected" + + val notification = builder + .setContentTitle(profileName) + .setContentText(service.getText(R.string.running)) + .build() + + service.startForeground(R.id.nf_clash_status, notification) + } + } + + companion object { + const val CHANNEL_ID = "clash_status_channel" + + fun createNotificationChannel(service: Service) { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) + return + NotificationManagerCompat.from(service).createNotificationChannel( + NotificationChannel( + CHANNEL_ID, + service.getText(R.string.clash_service_status_channel), + NotificationManager.IMPORTANCE_LOW + ) + ) + } + + fun notifyLoadingNotification(service: Service) { + val notification = + NotificationCompat.Builder(service, CHANNEL_ID) + .setSmallIcon(R.drawable.ic_logo_service) + .setOngoing(true) + .setColor(service.getColorCompat(R.color.color_clash)) + .setOnlyAlertOnce(true) + .setShowWhen(false) + .setContentTitle(service.getText(R.string.loading)) + .build() + + service.startForeground(R.id.nf_clash_status, notification) + } + } +} \ No newline at end of file diff --git a/service/src/main/java/com/github/kr328/clash/service/clash/module/SuspendModule.kt b/service/src/main/java/com/github/kr328/clash/service/clash/module/SuspendModule.kt new file mode 100644 index 00000000..87f50d98 --- /dev/null +++ b/service/src/main/java/com/github/kr328/clash/service/clash/module/SuspendModule.kt @@ -0,0 +1,50 @@ +package com.github.kr328.clash.service.clash.module + +import android.app.Service +import android.content.Intent +import android.os.PowerManager +import androidx.core.content.getSystemService +import com.github.kr328.clash.common.log.Log +import com.github.kr328.clash.core.Clash +import kotlinx.coroutines.NonCancellable +import kotlinx.coroutines.channels.Channel +import kotlinx.coroutines.withContext + +class SuspendModule(service: Service) : Module(service) { + override suspend fun run() { + val interactive = service.getSystemService()?.isInteractive ?: true + + Clash.suspendCore(!interactive) + + val screenToggle = receiveBroadcast(false, Channel.CONFLATED) { + addAction(Intent.ACTION_SCREEN_ON) + addAction(Intent.ACTION_SCREEN_OFF) + } + + try { + while (true) { + when (screenToggle.receive().action) { + Intent.ACTION_SCREEN_ON -> { + Clash.suspendCore(false) + + Log.d("Clash resumed") + } + Intent.ACTION_SCREEN_OFF -> { + Clash.suspendCore(true) + + Log.d("Clash suspended") + } + else -> { + // unreachable + + Clash.healthCheckAll() + } + } + } + } finally { + withContext(NonCancellable) { + Clash.suspendCore(false) + } + } + } +} \ No newline at end of file diff --git a/service/src/main/java/com/github/kr328/clash/service/clash/module/TunModule.kt b/service/src/main/java/com/github/kr328/clash/service/clash/module/TunModule.kt new file mode 100644 index 00000000..ad7c5021 --- /dev/null +++ b/service/src/main/java/com/github/kr328/clash/service/clash/module/TunModule.kt @@ -0,0 +1,81 @@ +package com.github.kr328.clash.service.clash.module + +import android.net.ConnectivityManager +import android.net.VpnService +import android.os.Build +import androidx.core.content.getSystemService +import com.github.kr328.clash.core.Clash +import com.github.kr328.clash.core.util.parseInetSocketAddress +import kotlinx.coroutines.NonCancellable +import kotlinx.coroutines.channels.Channel +import kotlinx.coroutines.withContext +import java.net.InetSocketAddress +import java.security.SecureRandom + +class TunModule(private val vpn: VpnService) : Module(vpn) { + data class TunDevice( + val fd: Int, + val mtu: Int, + val gateway: String, + val mirror: String, + val dns: String + ) + + private val connectivity = service.getSystemService()!! + private val close = Channel(Channel.CONFLATED) + + private fun queryUid( + protocol: Int, + source: InetSocketAddress, + target: InetSocketAddress, + ): Int { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) + return -1 + + return runCatching { connectivity.getConnectionOwnerUid(protocol, source, target) } + .getOrElse { -1 } + } + + override suspend fun run() { + try { + return close.receive() + } finally { + withContext(NonCancellable) { + requestStop() + } + } + } + + fun listenHttp(): InetSocketAddress? { + val r = { 1 + random.nextInt(199) } + val listenAt = "127.${r()}.${r()}.${r()}:0" + val address = Clash.startHttp(listenAt) + + return address?.let(::parseInetSocketAddress) + } + + fun attach(device: TunDevice) { + Clash.startTun( + fd = device.fd, + mtu = device.mtu, + gateway = device.gateway, + mirror = device.mirror, + dns = device.dns, + markSocket = vpn::protect, + querySocketUid = this::queryUid + ) + } + + suspend fun close() { + close.send(Unit) + } + + companion object { + private val random = SecureRandom() + + fun requestStop() { + Clash.stopHttp() + Clash.stopTun() + } + } +} \ No newline at end of file diff --git a/service/src/main/java/com/github/kr328/clash/service/data/Converters.kt b/service/src/main/java/com/github/kr328/clash/service/data/Converters.kt new file mode 100644 index 00000000..8c88d14f --- /dev/null +++ b/service/src/main/java/com/github/kr328/clash/service/data/Converters.kt @@ -0,0 +1,27 @@ +package com.github.kr328.clash.service.data + +import androidx.room.TypeConverter +import com.github.kr328.clash.service.model.Profile +import java.util.* + +class Converters { + @TypeConverter + fun fromUUID(uuid: UUID): String { + return uuid.toString() + } + + @TypeConverter + fun toUUID(uuid: String): UUID { + return UUID.fromString(uuid) + } + + @TypeConverter + fun fromProfileType(type: Profile.Type): String { + return type.name + } + + @TypeConverter + fun toProfileType(type: String): Profile.Type { + return Profile.Type.valueOf(type) + } +} \ No newline at end of file diff --git a/service/src/main/java/com/github/kr328/clash/service/data/Daos.kt b/service/src/main/java/com/github/kr328/clash/service/data/Daos.kt new file mode 100644 index 00000000..8098781b --- /dev/null +++ b/service/src/main/java/com/github/kr328/clash/service/data/Daos.kt @@ -0,0 +1,13 @@ +package com.github.kr328.clash.service.data + +fun ImportedDao(): ImportedDao { + return Database.database.openImportedDao() +} + +fun PendingDao(): PendingDao { + return Database.database.openPendingDao() +} + +fun SelectionDao(): SelectionDao { + return Database.database.openSelectionProxyDao() +} \ No newline at end of file diff --git a/service/src/main/java/com/github/kr328/clash/service/data/Database.kt b/service/src/main/java/com/github/kr328/clash/service/data/Database.kt new file mode 100644 index 00000000..550c976f --- /dev/null +++ b/service/src/main/java/com/github/kr328/clash/service/data/Database.kt @@ -0,0 +1,49 @@ +package com.github.kr328.clash.service.data + +import android.content.Context +import androidx.room.Room +import androidx.room.RoomDatabase +import com.github.kr328.clash.common.Global +import com.github.kr328.clash.service.data.migrations.LEGACY_MIGRATION +import com.github.kr328.clash.service.data.migrations.MIGRATIONS +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.GlobalScope +import kotlinx.coroutines.launch +import java.lang.ref.SoftReference +import androidx.room.Database as DB + +@DB( + version = 1, + entities = [Imported::class, Pending::class, Selection::class], + exportSchema = false, +) +abstract class Database : RoomDatabase() { + abstract fun openImportedDao(): ImportedDao + abstract fun openPendingDao(): PendingDao + abstract fun openSelectionProxyDao(): SelectionDao + + companion object { + val database: Database + @Synchronized get() { + return softDatabase.get() ?: open(Global.application).apply { + softDatabase = SoftReference(this) + } + } + + private var softDatabase: SoftReference = SoftReference(null) + + private fun open(context: Context): Database { + return Room.databaseBuilder( + context.applicationContext, + Database::class.java, + "profiles" + ).addMigrations(*MIGRATIONS).build() + } + + init { + GlobalScope.launch(Dispatchers.IO) { + LEGACY_MIGRATION(Global.application) + } + } + } +} \ No newline at end of file diff --git a/service/src/main/java/com/github/kr328/clash/service/data/Imported.kt b/service/src/main/java/com/github/kr328/clash/service/data/Imported.kt new file mode 100644 index 00000000..4d5dc0bf --- /dev/null +++ b/service/src/main/java/com/github/kr328/clash/service/data/Imported.kt @@ -0,0 +1,18 @@ +package com.github.kr328.clash.service.data + +import androidx.room.ColumnInfo +import androidx.room.Entity +import androidx.room.TypeConverters +import com.github.kr328.clash.service.model.Profile +import java.util.* + +@Entity(tableName = "imported", primaryKeys = ["uuid"]) +@TypeConverters(Converters::class) +data class Imported( + @ColumnInfo(name = "uuid") val uuid: UUID, + @ColumnInfo(name = "name") val name: String, + @ColumnInfo(name = "type") val type: Profile.Type, + @ColumnInfo(name = "source") val source: String, + @ColumnInfo(name = "interval") val interval: Long, + @ColumnInfo(name = "createdAt") val createdAt: Long, +) \ No newline at end of file diff --git a/service/src/main/java/com/github/kr328/clash/service/data/ImportedDao.kt b/service/src/main/java/com/github/kr328/clash/service/data/ImportedDao.kt new file mode 100644 index 00000000..5ebeb0d2 --- /dev/null +++ b/service/src/main/java/com/github/kr328/clash/service/data/ImportedDao.kt @@ -0,0 +1,26 @@ +package com.github.kr328.clash.service.data + +import androidx.room.* +import java.util.* + +@Dao +@TypeConverters(Converters::class) +interface ImportedDao { + @Query("SELECT * FROM imported WHERE uuid = :uuid") + suspend fun queryByUUID(uuid: UUID): Imported? + + @Query("SELECT uuid FROM imported ORDER BY createdAt") + suspend fun queryAllUUIDs(): List + + @Insert(onConflict = OnConflictStrategy.ABORT) + suspend fun insert(imported: Imported): Long + + @Update(onConflict = OnConflictStrategy.ABORT) + suspend fun update(imported: Imported) + + @Query("DELETE FROM imported WHERE uuid = :uuid") + suspend fun remove(uuid: UUID) + + @Query("SELECT EXISTS(SELECT 1 FROM imported WHERE uuid = :uuid)") + suspend fun exists(uuid: UUID): Boolean +} \ No newline at end of file diff --git a/service/src/main/java/com/github/kr328/clash/service/data/Pending.kt b/service/src/main/java/com/github/kr328/clash/service/data/Pending.kt new file mode 100644 index 00000000..d9ba780b --- /dev/null +++ b/service/src/main/java/com/github/kr328/clash/service/data/Pending.kt @@ -0,0 +1,18 @@ +package com.github.kr328.clash.service.data + +import androidx.room.ColumnInfo +import androidx.room.Entity +import androidx.room.TypeConverters +import com.github.kr328.clash.service.model.Profile +import java.util.* + +@Entity(tableName = "pending", primaryKeys = ["uuid"]) +@TypeConverters(Converters::class) +data class Pending( + @ColumnInfo(name = "uuid") val uuid: UUID, + @ColumnInfo(name = "name") val name: String, + @ColumnInfo(name = "type") val type: Profile.Type, + @ColumnInfo(name = "source") val source: String, + @ColumnInfo(name = "interval") val interval: Long, + @ColumnInfo(name = "createdAt") val createdAt: Long = System.currentTimeMillis(), +) \ No newline at end of file diff --git a/service/src/main/java/com/github/kr328/clash/service/data/PendingDao.kt b/service/src/main/java/com/github/kr328/clash/service/data/PendingDao.kt new file mode 100644 index 00000000..3a4c1e2a --- /dev/null +++ b/service/src/main/java/com/github/kr328/clash/service/data/PendingDao.kt @@ -0,0 +1,26 @@ +package com.github.kr328.clash.service.data + +import androidx.room.* +import java.util.* + +@Dao +@TypeConverters(Converters::class) +interface PendingDao { + @Query("SELECT * FROM pending WHERE uuid = :uuid") + suspend fun queryByUUID(uuid: UUID): Pending? + + @Query("DELETE FROM pending WHERE uuid = :uuid") + suspend fun remove(uuid: UUID) + + @Query("SELECT EXISTS(SELECT 1 FROM pending WHERE uuid = :uuid)") + suspend fun exists(uuid: UUID): Boolean + + @Query("SELECT uuid FROM pending ORDER BY createdAt") + suspend fun queryAllUUIDs(): List + + @Insert(onConflict = OnConflictStrategy.REPLACE) + suspend fun insert(pending: Pending) + + @Update(onConflict = OnConflictStrategy.REPLACE) + suspend fun update(pending: Pending) +} diff --git a/service/src/main/java/com/github/kr328/clash/service/data/Selection.kt b/service/src/main/java/com/github/kr328/clash/service/data/Selection.kt new file mode 100644 index 00000000..fd7abdb5 --- /dev/null +++ b/service/src/main/java/com/github/kr328/clash/service/data/Selection.kt @@ -0,0 +1,25 @@ +package com.github.kr328.clash.service.data + +import androidx.room.ColumnInfo +import androidx.room.Entity +import androidx.room.ForeignKey +import androidx.room.TypeConverters +import java.util.* + +@Entity( + tableName = "selections", + foreignKeys = [ForeignKey( + entity = Imported::class, + childColumns = ["uuid"], + parentColumns = ["uuid"], + onDelete = ForeignKey.CASCADE, + onUpdate = ForeignKey.CASCADE + )], + primaryKeys = ["uuid", "proxy"] +) +@TypeConverters(Converters::class) +data class Selection( + @ColumnInfo(name = "uuid") val uuid: UUID, + @ColumnInfo(name = "proxy") val proxy: String, + @ColumnInfo(name = "selected") val selected: String, +) \ No newline at end of file diff --git a/service/src/main/java/com/github/kr328/clash/service/data/SelectionDao.kt b/service/src/main/java/com/github/kr328/clash/service/data/SelectionDao.kt new file mode 100644 index 00000000..2d68d456 --- /dev/null +++ b/service/src/main/java/com/github/kr328/clash/service/data/SelectionDao.kt @@ -0,0 +1,20 @@ +package com.github.kr328.clash.service.data + +import androidx.room.* +import java.util.* + +@Dao +@TypeConverters(Converters::class) +interface SelectionDao { + @Insert(onConflict = OnConflictStrategy.REPLACE) + fun setSelected(selection: Selection) + + @Query("DELETE FROM selections WHERE uuid = :uuid AND proxy = :proxy") + fun removeSelected(uuid: UUID, proxy: String) + + @Query("SELECT * FROM selections WHERE uuid = :uuid") + suspend fun querySelections(uuid: UUID): List + + @Query("DELETE FROM selections WHERE uuid = :uuid AND proxy in (:proxies)") + suspend fun removeSelections(uuid: UUID, proxies: List) +} diff --git a/service/src/main/java/com/github/kr328/clash/service/data/migrations/LegacyMigration.kt b/service/src/main/java/com/github/kr328/clash/service/data/migrations/LegacyMigration.kt new file mode 100644 index 00000000..17a4fc5d --- /dev/null +++ b/service/src/main/java/com/github/kr328/clash/service/data/migrations/LegacyMigration.kt @@ -0,0 +1,199 @@ +@file:Suppress("BlockingMethodInNonBlockingContext") + +package com.github.kr328.clash.service.data.migrations + +import android.content.Context +import android.database.sqlite.SQLiteDatabase +import androidx.core.text.isDigitsOnly +import com.github.kr328.clash.common.log.Log +import com.github.kr328.clash.service.data.Pending +import com.github.kr328.clash.service.data.PendingDao +import com.github.kr328.clash.service.model.Profile +import com.github.kr328.clash.service.util.generateProfileUUID +import com.github.kr328.clash.service.util.pendingDir +import com.github.kr328.clash.service.util.sendProfileChanged +import com.microsoft.appcenter.crashes.Crashes +import java.io.File + +internal suspend fun migrationFromLegacy(context: Context) { + val file = context.getDatabasePath("clash-config") + + if (!file.exists()) { + return + } + + Log.i("Migration from legacy database") + + try { + SQLiteDatabase.openDatabase(file.absolutePath, null, SQLiteDatabase.OPEN_READONLY) + .use { db -> + val v = db.version + + Log.i("Legacy database version = $v") + + when (v) { + 1 -> migrationFromLegacy1(context, db) + 2, 3, 4 -> migrationFromLegacy234(context, db, v) + } + } + } catch (e: Exception) { + Crashes.trackError(e) + + Log.w("Migration legacy database: $e", e) + } + + context.deleteDatabase("clash-config") + + Log.i("Legacy database migrated") +} + +private suspend fun migrationFromLegacy234( + context: Context, + legacy: SQLiteDatabase, + version: Int, +) { + legacy.query( + "profiles", + arrayOf("id", "name", "type", "uri", if (version == 2) "update_interval" else "interval"), + null, + null, + null, + null, + "id" + ).use { cursor -> + val id = cursor.getColumnIndex("id") + val name = cursor.getColumnIndex("name") + val type = cursor.getColumnIndex("type") + val uri = cursor.getColumnIndex("uri") + val interval = cursor.getColumnIndex(if (version == 2) "update_interval" else "interval") + + if (!cursor.moveToFirst()) + return + + do { + val newType = when (cursor.getInt(type)) { + 1 -> { // TYPE_FILE + Profile.Type.File + } + 2 -> { // TYPE_URL + Profile.Type.Url + } + 3 -> { // TYPE_EXTERNAL + Profile.Type.External + } + else -> { // unknown + continue + } + } + + val idValue = cursor.getInt(id) + val intervalValue = cursor.getLong(interval) + + val pending = Pending( + uuid = generateProfileUUID(), + name = cursor.getString(name), + type = newType, + source = if (newType != Profile.Type.File) cursor.getString(uri) else "", + interval = if (version == 2) intervalValue * 1000 else intervalValue, + ) + + val base = context.pendingDir.resolve(pending.uuid.toString()) + + base.apply { + mkdirs() + + resolve("config.yaml").createNewFile() + resolve("providers").mkdir() + } + + if (newType == Profile.Type.File) { + val legacyFile = context.filesDir.resolve("profiles/$idValue.yaml") + + if (legacyFile.isFile) { + legacyFile.copyTo(base.resolve("config.yaml"), overwrite = true) + } + } + + PendingDao().insert(pending) + + context.sendProfileChanged(pending.uuid) + + Log.i("${pending.name} migrated") + } while (cursor.moveToNext()) + } + + context.filesDir.resolve("profiles").deleteRecursively() + context.filesDir.resolve("clash").listFiles()?.forEach { + if (it.name.isDigitsOnly()) { + it.deleteRecursively() + } + } +} + +private suspend fun migrationFromLegacy1(context: Context, legacy: SQLiteDatabase) { + legacy.query( + "profiles", + arrayOf("name", "token", "id", "file"), + null, + null, + null, + null, + "id", + ).use { cursor -> + val name = cursor.getColumnIndex("name") + val token = cursor.getColumnIndex("token") + val file = cursor.getColumnIndex("file") + + if (!cursor.moveToFirst()) + return + + do { + val legacyToken = cursor.getString(token) + + val newType = when { + legacyToken.startsWith("file|") -> Profile.Type.File + legacyToken.startsWith("url|") -> Profile.Type.Url + else -> continue + } + + val source = if (newType == Profile.Type.Url) { + legacyToken.removePrefix("url|") + } else { + "" + } + + val pending = Pending( + uuid = generateProfileUUID(), + name = cursor.getString(name), + type = newType, + source = source, + interval = 0, + ) + + val base = context.pendingDir.resolve(pending.uuid.toString()) + + base.apply { + mkdirs() + + resolve("config.yaml").createNewFile() + resolve("providers").mkdir() + } + + val legacyFile = File(cursor.getString(file)) + + if (newType == Profile.Type.File) { + if (legacyFile.isFile) { + legacyFile.copyTo(base.resolve("config.yaml"), overwrite = true) + } + } + + legacyFile.delete() + + PendingDao().insert(pending) + + context.sendProfileChanged(pending.uuid) + + Log.i("${pending.name} migrated") + } while (cursor.moveToNext()) + } +} diff --git a/service/src/main/java/com/github/kr328/clash/service/data/migrations/Migrations.kt b/service/src/main/java/com/github/kr328/clash/service/data/migrations/Migrations.kt new file mode 100644 index 00000000..bbe77529 --- /dev/null +++ b/service/src/main/java/com/github/kr328/clash/service/data/migrations/Migrations.kt @@ -0,0 +1,7 @@ +package com.github.kr328.clash.service.data.migrations + +import androidx.room.migration.Migration + +val MIGRATIONS: Array = arrayOf() + +val LEGACY_MIGRATION = ::migrationFromLegacy \ No newline at end of file diff --git a/service/src/main/java/com/github/kr328/clash/service/document/Document.kt b/service/src/main/java/com/github/kr328/clash/service/document/Document.kt new file mode 100644 index 00000000..c23dabea --- /dev/null +++ b/service/src/main/java/com/github/kr328/clash/service/document/Document.kt @@ -0,0 +1,10 @@ +package com.github.kr328.clash.service.document + +interface Document { + val id: String + val name: String + val mimeType: String + val size: Long + val updatedAt: Long + val flags: Set +} \ No newline at end of file diff --git a/service/src/main/java/com/github/kr328/clash/service/document/FileDocument.kt b/service/src/main/java/com/github/kr328/clash/service/document/FileDocument.kt new file mode 100644 index 00000000..af09f8da --- /dev/null +++ b/service/src/main/java/com/github/kr328/clash/service/document/FileDocument.kt @@ -0,0 +1,22 @@ +package com.github.kr328.clash.service.document + +import android.provider.DocumentsContract +import java.io.File + +class FileDocument( + val file: File, + override val flags: Set, + private val idOverride: String? = null, + private val nameOverride: String? = null, +) : Document { + override val id: String + get() = idOverride ?: file.name + override val name: String + get() = nameOverride ?: file.name + override val mimeType: String + get() = if (file.isDirectory) DocumentsContract.Document.MIME_TYPE_DIR else "text/plain" + override val size: Long + get() = file.length() + override val updatedAt: Long + get() = file.lastModified() +} \ No newline at end of file diff --git a/service/src/main/java/com/github/kr328/clash/service/document/Flag.kt b/service/src/main/java/com/github/kr328/clash/service/document/Flag.kt new file mode 100644 index 00000000..3102c431 --- /dev/null +++ b/service/src/main/java/com/github/kr328/clash/service/document/Flag.kt @@ -0,0 +1,5 @@ +package com.github.kr328.clash.service.document + +enum class Flag { + Writable, Deletable, Virtual +} \ No newline at end of file diff --git a/service/src/main/java/com/github/kr328/clash/service/document/Path.kt b/service/src/main/java/com/github/kr328/clash/service/document/Path.kt new file mode 100644 index 00000000..8f71b29e --- /dev/null +++ b/service/src/main/java/com/github/kr328/clash/service/document/Path.kt @@ -0,0 +1,31 @@ +package com.github.kr328.clash.service.document + +import java.util.* + +data class Path( + val uuid: UUID?, + val scope: Scope?, + val relative: List? +) { + enum class Scope { + Configuration, Providers + } + + override fun toString(): String { + if (uuid == null) + return "/" + + if (scope == null) + return "/$uuid" + + val sc = when (scope) { + Scope.Configuration -> Paths.CONFIGURATION_ID + Scope.Providers -> Paths.PROVIDERS_ID + } + + if (relative == null) + return "/$uuid/$sc" + + return "/$uuid/$sc/${relative.joinToString(separator = "/")}" + } +} \ No newline at end of file diff --git a/service/src/main/java/com/github/kr328/clash/service/document/Paths.kt b/service/src/main/java/com/github/kr328/clash/service/document/Paths.kt new file mode 100644 index 00000000..f099658c --- /dev/null +++ b/service/src/main/java/com/github/kr328/clash/service/document/Paths.kt @@ -0,0 +1,43 @@ +package com.github.kr328.clash.service.document + +import java.util.* + +object Paths { + const val CONFIGURATION_ID = "config.yaml" + const val PROVIDERS_ID = "providers" + + fun resolve(path: String): Path { + val segments = path.split("/").filter { it.isNotBlank() && it != "." && it != ".." } + + return when (segments.size) { + 0 -> Path( + uuid = null, + scope = null, + relative = null, + ) + 1 -> Path( + uuid = UUID.fromString(segments[0]), + scope = null, + relative = null, + ) + 2 -> Path( + uuid = UUID.fromString(segments[0]), + scope = when (segments[1]) { + CONFIGURATION_ID -> Path.Scope.Configuration + PROVIDERS_ID -> Path.Scope.Providers + else -> throw IllegalArgumentException("unknown scope ${segments[1]}") + }, + relative = null, + ) + else -> Path( + uuid = UUID.fromString(segments[0]), + scope = when (segments[1]) { + CONFIGURATION_ID -> Path.Scope.Configuration + PROVIDERS_ID -> Path.Scope.Providers + else -> throw IllegalArgumentException("unknown scope ${segments[1]}") + }, + relative = segments.drop(2), + ) + } + } +} \ No newline at end of file diff --git a/service/src/main/java/com/github/kr328/clash/service/document/Picker.kt b/service/src/main/java/com/github/kr328/clash/service/document/Picker.kt new file mode 100644 index 00000000..4436bc68 --- /dev/null +++ b/service/src/main/java/com/github/kr328/clash/service/document/Picker.kt @@ -0,0 +1,146 @@ +package com.github.kr328.clash.service.document + +import android.content.Context +import android.provider.DocumentsContract +import com.github.kr328.clash.service.R +import com.github.kr328.clash.service.data.ImportedDao +import com.github.kr328.clash.service.data.Pending +import com.github.kr328.clash.service.data.PendingDao +import com.github.kr328.clash.service.model.Profile +import com.github.kr328.clash.service.util.importedDir +import com.github.kr328.clash.service.util.pendingDir +import java.io.FileNotFoundException +import java.util.* + +class Picker(private val context: Context) { + suspend fun list(path: Path): List { + if (path.uuid == null) { + return ImportedDao().queryAllUUIDs().map { + pick(path.copy(uuid = it), false) + } + } + + if (path.scope == null) { + return listOf(Path.Scope.Configuration, Path.Scope.Providers).map { + pick(path.copy(scope = it), false) + } + } + + val parent = pick(path, false) + + if (parent !is FileDocument) + return emptyList() + + return (parent.file.list() ?: emptyArray()).map { + pick(path.copy(relative = (path.relative ?: emptyList()) + it), false) + } + } + + suspend fun pick(path: Path, writable: Boolean): Document { + if (path.uuid == null) { + return VirtualDocument( + "", + context.getString(R.string.clash_for_android), + DocumentsContract.Document.MIME_TYPE_DIR, + 0, + 0, + setOf(Flag.Virtual), + ) + } + + if (writable) { + cloneToPending(path.uuid) + } + + val imported = ImportedDao().queryByUUID(path.uuid) + val pending = PendingDao().queryByUUID(path.uuid) + + if (path.scope == null) { + if (writable) + throw IllegalArgumentException("invalid open mode") + + return VirtualDocument( + id = path.uuid.toString(), + name = pending?.name ?: imported?.name + ?: throw FileNotFoundException("profile not found"), + mimeType = DocumentsContract.Document.MIME_TYPE_DIR, + size = 0, + updatedAt = 0, + flags = setOf(Flag.Virtual), + ) + } + + if (path.relative == null) { + if (path.scope == Path.Scope.Configuration) { + val type = pending?.type ?: imported?.type + ?: throw FileNotFoundException("profile not found") + + if (writable && type != Profile.Type.File) + throw IllegalArgumentException("invalid open mode") + + val flags: Set = if (type == Profile.Type.Url) + emptySet() + else + setOf(Flag.Writable) + + return FileDocument( + file = when { + pending != null -> context.pendingDir.resolve(pending.uuid.toString()) + imported != null -> context.importedDir.resolve(imported.uuid.toString()) + else -> throw FileNotFoundException("profile not found") + }.resolve("config.yaml"), + flags = flags, + idOverride = Paths.CONFIGURATION_ID, + nameOverride = context.getString(R.string.configuration_yaml) + ) + } else { + return FileDocument( + file = when { + pending != null -> context.pendingDir.resolve(pending.uuid.toString()) + imported != null -> context.importedDir.resolve(imported.uuid.toString()) + else -> throw FileNotFoundException("profile not found") + }.resolve("providers"), + idOverride = Paths.PROVIDERS_ID, + nameOverride = context.getString(R.string.provider_files), + flags = setOf(Flag.Virtual) + ) + } + } + + if (path.scope != Path.Scope.Providers) + throw FileNotFoundException("invalid path") + + return FileDocument( + file = when { + pending != null -> context.pendingDir.resolve(pending.uuid.toString()) + imported != null -> context.importedDir.resolve(imported.uuid.toString()) + else -> throw FileNotFoundException("profile not found") + }.resolve("providers").resolve(path.relative.joinToString(separator = "/")), + flags = setOf(Flag.Writable, Flag.Deletable) + ) + } + + private suspend fun cloneToPending(uuid: UUID) { + if (PendingDao().queryByUUID(uuid) != null) + return + + val imported = + ImportedDao().queryByUUID(uuid) ?: throw FileNotFoundException("profile not found") + + PendingDao().insert( + Pending( + imported.uuid, + imported.name, + imported.type, + imported.source, + imported.interval + ) + ) + + val source = context.importedDir.resolve(uuid.toString()) + val target = context.pendingDir.resolve(uuid.toString()) + + target.deleteRecursively() + source.copyRecursively(target) + } +} \ No newline at end of file diff --git a/service/src/main/java/com/github/kr328/clash/service/document/VirtualDocument.kt b/service/src/main/java/com/github/kr328/clash/service/document/VirtualDocument.kt new file mode 100644 index 00000000..64f63e44 --- /dev/null +++ b/service/src/main/java/com/github/kr328/clash/service/document/VirtualDocument.kt @@ -0,0 +1,10 @@ +package com.github.kr328.clash.service.document + +class VirtualDocument( + override val id: String, + override val name: String, + override val mimeType: String, + override val size: Long, + override val updatedAt: Long, + override val flags: Set, +) : Document diff --git a/service/src/main/java/com/github/kr328/clash/service/model/AccessControlMode.kt b/service/src/main/java/com/github/kr328/clash/service/model/AccessControlMode.kt new file mode 100644 index 00000000..abd07fe7 --- /dev/null +++ b/service/src/main/java/com/github/kr328/clash/service/model/AccessControlMode.kt @@ -0,0 +1,5 @@ +package com.github.kr328.clash.service.model + +enum class AccessControlMode { + AcceptAll, AcceptSelected, DenySelected +} diff --git a/service/src/main/java/com/github/kr328/clash/service/model/Profile.kt b/service/src/main/java/com/github/kr328/clash/service/model/Profile.kt new file mode 100644 index 00000000..d8363a3a --- /dev/null +++ b/service/src/main/java/com/github/kr328/clash/service/model/Profile.kt @@ -0,0 +1,47 @@ +@file:UseSerializers(UUIDSerializer::class) + +package com.github.kr328.clash.service.model + +import android.os.Parcel +import android.os.Parcelable +import com.github.kr328.clash.core.util.Parcelizer +import com.github.kr328.clash.service.util.UUIDSerializer +import kotlinx.serialization.Serializable +import kotlinx.serialization.UseSerializers +import java.util.* + +@Serializable +data class Profile( + val uuid: UUID, + val name: String, + val type: Type, + val source: String, + val active: Boolean, + val interval: Long, + + val updatedAt: Long, + val imported: Boolean, + val pending: Boolean, +) : Parcelable { + enum class Type { + File, Url, External + } + + override fun writeToParcel(parcel: Parcel, flags: Int) { + Parcelizer.encodeToParcel(serializer(), parcel, this) + } + + override fun describeContents(): Int { + return 0 + } + + companion object CREATOR : Parcelable.Creator { + override fun createFromParcel(parcel: Parcel): Profile { + return Parcelizer.decodeFromParcel(serializer(), parcel) + } + + override fun newArray(size: Int): Array { + return arrayOfNulls(size) + } + } +} \ No newline at end of file diff --git a/service/src/main/java/com/github/kr328/clash/service/remote/IClashManager.kt b/service/src/main/java/com/github/kr328/clash/service/remote/IClashManager.kt new file mode 100644 index 00000000..f60c2edb --- /dev/null +++ b/service/src/main/java/com/github/kr328/clash/service/remote/IClashManager.kt @@ -0,0 +1,26 @@ +package com.github.kr328.clash.service.remote + +import com.github.kr328.clash.core.Clash +import com.github.kr328.clash.core.model.* +import com.github.kr328.kaidl.BinderInterface + +@BinderInterface +interface IClashManager { + fun queryTunnelState(): TunnelState + fun queryTrafficTotal(): Long + fun queryProxyGroupNames(excludeNotSelectable: Boolean): List + fun queryProxyGroup(name: String, proxySort: ProxySort): ProxyGroup + fun queryConfiguration(): UiConfiguration + fun queryProviders(): ProviderList + + fun patchSelector(group: String, name: String): Boolean + + suspend fun healthCheck(group: String) + suspend fun updateProvider(type: Provider.Type, name: String) + + fun queryOverride(slot: Clash.OverrideSlot): ConfigurationOverride + fun patchOverride(slot: Clash.OverrideSlot, configuration: ConfigurationOverride) + fun clearOverride(slot: Clash.OverrideSlot) + + fun setLogObserver(observer: ILogObserver?) +} \ No newline at end of file diff --git a/service/src/main/java/com/github/kr328/clash/service/remote/IFetchObserver.kt b/service/src/main/java/com/github/kr328/clash/service/remote/IFetchObserver.kt new file mode 100644 index 00000000..f5315e89 --- /dev/null +++ b/service/src/main/java/com/github/kr328/clash/service/remote/IFetchObserver.kt @@ -0,0 +1,9 @@ +package com.github.kr328.clash.service.remote + +import com.github.kr328.clash.core.model.FetchStatus +import com.github.kr328.kaidl.BinderInterface + +@BinderInterface +fun interface IFetchObserver { + fun updateStatus(status: FetchStatus) +} \ No newline at end of file diff --git a/service/src/main/java/com/github/kr328/clash/service/remote/ILogObserver.kt b/service/src/main/java/com/github/kr328/clash/service/remote/ILogObserver.kt new file mode 100644 index 00000000..65814434 --- /dev/null +++ b/service/src/main/java/com/github/kr328/clash/service/remote/ILogObserver.kt @@ -0,0 +1,9 @@ +package com.github.kr328.clash.service.remote + +import com.github.kr328.clash.core.model.LogMessage +import com.github.kr328.kaidl.BinderInterface + +@BinderInterface +interface ILogObserver { + fun newItem(log: LogMessage) +} \ No newline at end of file diff --git a/service/src/main/java/com/github/kr328/clash/service/remote/IProfileManager.kt b/service/src/main/java/com/github/kr328/clash/service/remote/IProfileManager.kt new file mode 100644 index 00000000..f5915f0f --- /dev/null +++ b/service/src/main/java/com/github/kr328/clash/service/remote/IProfileManager.kt @@ -0,0 +1,20 @@ +package com.github.kr328.clash.service.remote + +import com.github.kr328.clash.service.model.Profile +import com.github.kr328.kaidl.BinderInterface +import java.util.* + +@BinderInterface +interface IProfileManager { + suspend fun create(type: Profile.Type, name: String, source: String = ""): UUID + suspend fun clone(uuid: UUID): UUID + suspend fun commit(uuid: UUID, callback: IFetchObserver? = null) + suspend fun release(uuid: UUID) + suspend fun delete(uuid: UUID) + suspend fun patch(uuid: UUID, name: String, source: String, interval: Long) + suspend fun update(uuid: UUID) + suspend fun queryByUUID(uuid: UUID): Profile? + suspend fun queryAll(): List + suspend fun queryActive(): Profile? + suspend fun setActive(profile: Profile) +} \ No newline at end of file diff --git a/service/src/main/java/com/github/kr328/clash/service/sideload/ExternalGeoip.kt b/service/src/main/java/com/github/kr328/clash/service/sideload/ExternalGeoip.kt new file mode 100644 index 00000000..4359ba10 --- /dev/null +++ b/service/src/main/java/com/github/kr328/clash/service/sideload/ExternalGeoip.kt @@ -0,0 +1,21 @@ +package com.github.kr328.clash.service.sideload + +import android.content.Context +import android.content.pm.PackageManager +import com.github.kr328.clash.common.constants.Metadata +import com.github.kr328.clash.common.log.Log +import java.io.InputStream + +fun Context.readGeoipDatabaseFrom(packageName: String): ByteArray? { + return try { + val appInfo = packageManager.getApplicationInfo(packageName, PackageManager.GET_META_DATA) + val path = appInfo.metaData.getString(Metadata.GEOIP_FILE_NAME) ?: return null + + createPackageContext(packageName, 0) + .resources.assets.open(path).use(InputStream::readBytes) + } catch (e: PackageManager.NameNotFoundException) { + Log.w("Sideload geoip: $packageName not found", e) + + null + } +} \ No newline at end of file diff --git a/service/src/main/java/com/github/kr328/clash/service/store/ServiceStore.kt b/service/src/main/java/com/github/kr328/clash/service/store/ServiceStore.kt new file mode 100644 index 00000000..f1c32190 --- /dev/null +++ b/service/src/main/java/com/github/kr328/clash/service/store/ServiceStore.kt @@ -0,0 +1,58 @@ +package com.github.kr328.clash.service.store + +import android.content.Context +import com.github.kr328.clash.common.store.Store +import com.github.kr328.clash.common.store.asStoreProvider +import com.github.kr328.clash.service.PreferenceProvider +import com.github.kr328.clash.service.model.AccessControlMode +import java.util.* + +class ServiceStore(context: Context) { + private val store = Store( + PreferenceProvider + .createSharedPreferencesFromContext(context) + .asStoreProvider() + ) + + var activeProfile: UUID? by store.typedString( + key = "active_profile", + from = { if (it.isBlank()) null else UUID.fromString(it) }, + to = { it?.toString() ?: "" } + ) + + var bypassPrivateNetwork: Boolean by store.boolean( + key = "bypass_private_network", + defaultValue = true + ) + + var accessControlMode: AccessControlMode by store.enum( + key = "access_control_mode", + defaultValue = AccessControlMode.AcceptAll, + values = AccessControlMode.values() + ) + + var accessControlPackages by store.stringSet( + key = "access_control_packages", + defaultValue = emptySet() + ) + + var dnsHijacking by store.boolean( + key = "dns_hijacking", + defaultValue = true + ) + + var systemProxy by store.boolean( + key = "system_proxy", + defaultValue = false + ) + + var dynamicNotification by store.boolean( + key = "dynamic_notification", + defaultValue = true + ) + + var sideloadGeoip by store.string( + key = "sideload_geoip", + defaultValue = "" + ) +} \ No newline at end of file diff --git a/service/src/main/java/com/github/kr328/clash/service/util/Address.kt b/service/src/main/java/com/github/kr328/clash/service/util/Address.kt new file mode 100644 index 00000000..d1c54c56 --- /dev/null +++ b/service/src/main/java/com/github/kr328/clash/service/util/Address.kt @@ -0,0 +1,34 @@ +package com.github.kr328.clash.service.util + +import java.net.Inet4Address +import java.net.Inet6Address +import java.net.InetAddress + +fun InetAddress.asSocketAddressText(port: Int): String { + return when (this) { + is Inet6Address -> + "[${numericToTextFormat(this.address)}]:$port" + is Inet4Address -> + "${this.hostAddress}:$port" + else -> throw IllegalArgumentException("Unsupported Inet type ${this.javaClass}") + } +} + +private const val INT16SZ = 2 +private const val INADDRSZ = 16 +private fun numericToTextFormat(src: ByteArray): String { + val sb = StringBuilder(39) + for (i in 0 until INADDRSZ / INT16SZ) { + sb.append( + Integer.toHexString( + src[i shl 1].toInt() shl 8 and 0xff00 + or (src[(i shl 1) + 1].toInt() and 0xff) + ) + ) + if (i < INADDRSZ / INT16SZ - 1) { + sb.append(":") + } + } + return sb.toString() +} + diff --git a/service/src/main/java/com/github/kr328/clash/service/util/Broadcast.kt b/service/src/main/java/com/github/kr328/clash/service/util/Broadcast.kt new file mode 100644 index 00000000..02b3a4f3 --- /dev/null +++ b/service/src/main/java/com/github/kr328/clash/service/util/Broadcast.kt @@ -0,0 +1,51 @@ +package com.github.kr328.clash.service.util + +import android.content.Context +import android.content.Intent +import com.github.kr328.clash.common.constants.Intents +import com.github.kr328.clash.common.constants.Permissions +import java.util.* + +fun Context.sendBroadcastSelf(intent: Intent) { + sendBroadcast( + intent.setPackage(this.packageName), + Permissions.RECEIVE_SELF_BROADCASTS + ) +} + +fun Context.sendProfileChanged(uuid: UUID) { + val intent = Intent(Intents.ACTION_PROFILE_CHANGED) + .putExtra(Intents.EXTRA_UUID, uuid.toString()) + + sendBroadcastSelf(intent) +} + +fun Context.sendProfileLoaded(uuid: UUID) { + val intent = Intent(Intents.ACTION_PROFILE_LOADED) + .putExtra(Intents.EXTRA_UUID, uuid.toString()) + + sendBroadcastSelf(intent) +} + +fun Context.sendOverrideChanged() { + val intent = Intent(Intents.ACTION_OVERRIDE_CHANGED) + + sendBroadcastSelf(intent) +} + +fun Context.sendServiceRecreated() { + sendBroadcastSelf(Intent(Intents.ACTION_SERVICE_RECREATED)) +} + +fun Context.sendClashStarted() { + sendBroadcastSelf(Intent(Intents.ACTION_CLASH_STARTED)) +} + +fun Context.sendClashStopped(reason: String?) { + sendBroadcastSelf( + Intent(Intents.ACTION_CLASH_STOPPED).putExtra( + Intents.EXTRA_STOP_REASON, + reason + ) + ) +} diff --git a/service/src/main/java/com/github/kr328/clash/service/util/Connectivity.kt b/service/src/main/java/com/github/kr328/clash/service/util/Connectivity.kt new file mode 100644 index 00000000..ba4b1bc9 --- /dev/null +++ b/service/src/main/java/com/github/kr328/clash/service/util/Connectivity.kt @@ -0,0 +1,11 @@ +package com.github.kr328.clash.service.util + +import android.net.ConnectivityManager +import android.net.Network + +fun ConnectivityManager.resolveDns(network: Network?): List { + return network?.run(this::getLinkProperties) + ?.dnsServers + ?.map { it.asSocketAddressText(53) } + ?: emptyList() +} \ No newline at end of file diff --git a/service/src/main/java/com/github/kr328/clash/service/util/Coroutine.kt b/service/src/main/java/com/github/kr328/clash/service/util/Coroutine.kt new file mode 100644 index 00000000..b203d1cf --- /dev/null +++ b/service/src/main/java/com/github/kr328/clash/service/util/Coroutine.kt @@ -0,0 +1,14 @@ +package com.github.kr328.clash.service.util + +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.job +import kotlinx.coroutines.runBlocking + +fun CoroutineScope.cancelAndJoinBlocking() { + val scope = this + + runBlocking { + scope.coroutineContext.job.cancel() + scope.coroutineContext.job.join() + } +} \ No newline at end of file diff --git a/service/src/main/java/com/github/kr328/clash/service/util/Database.kt b/service/src/main/java/com/github/kr328/clash/service/util/Database.kt new file mode 100644 index 00000000..3443a75d --- /dev/null +++ b/service/src/main/java/com/github/kr328/clash/service/util/Database.kt @@ -0,0 +1,15 @@ +package com.github.kr328.clash.service.util + +import com.github.kr328.clash.service.data.ImportedDao +import com.github.kr328.clash.service.data.PendingDao +import java.util.* + +suspend fun generateProfileUUID(): UUID { + var result = UUID.randomUUID() + + while (ImportedDao().exists(result) || PendingDao().exists(result)) { + result = UUID.randomUUID() + } + + return result +} diff --git a/service/src/main/java/com/github/kr328/clash/service/util/Files.kt b/service/src/main/java/com/github/kr328/clash/service/util/Files.kt new file mode 100644 index 00000000..1ee3ee57 --- /dev/null +++ b/service/src/main/java/com/github/kr328/clash/service/util/Files.kt @@ -0,0 +1,18 @@ +package com.github.kr328.clash.service.util + +import android.content.Context +import java.io.File + +val Context.importedDir: File + get() = filesDir.resolve("imported") + +val Context.pendingDir: File + get() = filesDir.resolve("pending") + +val Context.processingDir: File + get() = filesDir.resolve("processing") + +val File.directoryLastModified: Long? + get() { + return walk().map { it.lastModified() }.maxOrNull() + } \ No newline at end of file diff --git a/service/src/main/java/com/github/kr328/clash/service/util/Intent.kt b/service/src/main/java/com/github/kr328/clash/service/util/Intent.kt new file mode 100644 index 00000000..83b84fe5 --- /dev/null +++ b/service/src/main/java/com/github/kr328/clash/service/util/Intent.kt @@ -0,0 +1,8 @@ +package com.github.kr328.clash.service.util + +import android.content.Intent + +val Intent.packageName: String? + get() { + return data?.takeIf { it.scheme == "package" }?.schemeSpecificPart + } \ No newline at end of file diff --git a/service/src/main/java/com/github/kr328/clash/service/util/Net.kt b/service/src/main/java/com/github/kr328/clash/service/util/Net.kt new file mode 100644 index 00000000..0d04cc9e --- /dev/null +++ b/service/src/main/java/com/github/kr328/clash/service/util/Net.kt @@ -0,0 +1,15 @@ +package com.github.kr328.clash.service.util + +data class IPNet(val ip: String, val prefix: Int) + +fun parseCIDR(cidr: String): IPNet { + val s = cidr.split("/", limit = 2) + + if (s.size != 2) + throw IllegalArgumentException("Invalid address") + + val address = s[0] + val prefix = s[1].toInt() + + return IPNet(address, prefix) +} \ No newline at end of file diff --git a/service/src/main/java/com/github/kr328/clash/service/util/Serializers.kt b/service/src/main/java/com/github/kr328/clash/service/util/Serializers.kt new file mode 100644 index 00000000..5cbe51c0 --- /dev/null +++ b/service/src/main/java/com/github/kr328/clash/service/util/Serializers.kt @@ -0,0 +1,22 @@ +package com.github.kr328.clash.service.util + +import kotlinx.serialization.KSerializer +import kotlinx.serialization.descriptors.PrimitiveKind +import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor +import kotlinx.serialization.descriptors.SerialDescriptor +import kotlinx.serialization.encoding.Decoder +import kotlinx.serialization.encoding.Encoder +import java.util.* + +class UUIDSerializer : KSerializer { + override val descriptor: SerialDescriptor = + PrimitiveSerialDescriptor("UUID", PrimitiveKind.STRING) + + override fun deserialize(decoder: Decoder): UUID { + return UUID.fromString(decoder.decodeString()) + } + + override fun serialize(encoder: Encoder, value: UUID) { + encoder.encodeString(value.toString()) + } +} \ No newline at end of file diff --git a/service/src/main/res/drawable/ic_logo_service.xml b/service/src/main/res/drawable/ic_logo_service.xml new file mode 100644 index 00000000..e2d640ac --- /dev/null +++ b/service/src/main/res/drawable/ic_logo_service.xml @@ -0,0 +1,12 @@ + + + diff --git a/service/src/main/res/values-zh-rHK/strings.xml b/service/src/main/res/values-zh-rHK/strings.xml new file mode 100644 index 00000000..835cedde --- /dev/null +++ b/service/src/main/res/values-zh-rHK/strings.xml @@ -0,0 +1,19 @@ + + + Clash 狀態 + 正在運行 + 更新 %s 成功 + "更新 %1$s: %2$s " + Clash for Android + 配置文件和外部資源 + 配置文件.yaml + 外部資源文件列表 + 載入中 + 配置文件處理狀態 + 更新成功 + 更新失敗 + 配置更新服務 + 配置更新中 + 配置文件服務狀態 + 配置文件處理結果 + \ No newline at end of file diff --git a/service/src/main/res/values-zh-rTW/strings.xml b/service/src/main/res/values-zh-rTW/strings.xml new file mode 100644 index 00000000..835cedde --- /dev/null +++ b/service/src/main/res/values-zh-rTW/strings.xml @@ -0,0 +1,19 @@ + + + Clash 狀態 + 正在運行 + 更新 %s 成功 + "更新 %1$s: %2$s " + Clash for Android + 配置文件和外部資源 + 配置文件.yaml + 外部資源文件列表 + 載入中 + 配置文件處理狀態 + 更新成功 + 更新失敗 + 配置更新服務 + 配置更新中 + 配置文件服務狀態 + 配置文件處理結果 + \ No newline at end of file diff --git a/service/src/main/res/values-zh/strings.xml b/service/src/main/res/values-zh/strings.xml new file mode 100644 index 00000000..80a79b16 --- /dev/null +++ b/service/src/main/res/values-zh/strings.xml @@ -0,0 +1,19 @@ + + + Clash 状态 + 正在运行 + 更新 %s 成功 + "更新 %1$s: %2$s " + Clash for Android + 配置文件和外部资源 + 配置文件.yaml + 外部资源文件列表 + 载入中 + 配置文件处理状态 + 更新成功 + 更新失败 + 配置更新服务 + 配置更新中 + 配置文件服务状态 + 配置文件处理结果 + \ No newline at end of file diff --git a/service/src/main/res/values/arrays.xml b/service/src/main/res/values/arrays.xml new file mode 100644 index 00000000..470161f1 --- /dev/null +++ b/service/src/main/res/values/arrays.xml @@ -0,0 +1,81 @@ + + + + + 1.0.0.0/8 + 2.0.0.0/7 + 4.0.0.0/6 + 8.0.0.0/7 + 11.0.0.0/8 + 12.0.0.0/6 + 16.0.0.0/4 + 32.0.0.0/3 + 64.0.0.0/3 + 96.0.0.0/4 + 112.0.0.0/5 + 120.0.0.0/6 + 124.0.0.0/7 + 126.0.0.0/8 + 128.0.0.0/3 + 160.0.0.0/5 + 168.0.0.0/8 + 169.0.0.0/9 + 169.128.0.0/10 + 169.192.0.0/11 + 169.224.0.0/12 + 169.240.0.0/13 + 169.248.0.0/14 + 169.252.0.0/15 + 169.255.0.0/16 + 170.0.0.0/7 + 172.0.0.0/12 + 172.32.0.0/11 + 172.64.0.0/10 + 172.128.0.0/9 + 173.0.0.0/8 + 174.0.0.0/7 + 176.0.0.0/4 + 192.0.0.0/9 + 192.128.0.0/11 + 192.160.0.0/13 + 192.169.0.0/16 + 192.170.0.0/15 + 192.172.0.0/14 + 192.176.0.0/12 + 192.192.0.0/10 + 193.0.0.0/8 + 194.0.0.0/7 + 196.0.0.0/6 + 200.0.0.0/5 + 208.0.0.0/4 + 240.0.0.0/5 + 248.0.0.0/6 + 252.0.0.0/7 + 254.0.0.0/8 + 255.0.0.0/9 + 255.128.0.0/10 + 255.192.0.0/11 + 255.224.0.0/12 + 255.240.0.0/13 + 255.248.0.0/14 + 255.252.0.0/15 + 255.254.0.0/16 + 255.255.0.0/17 + 255.255.128.0/18 + 255.255.192.0/19 + 255.255.224.0/20 + 255.255.240.0/21 + 255.255.248.0/22 + 255.255.252.0/23 + 255.255.254.0/24 + 255.255.255.0/25 + 255.255.255.128/26 + 255.255.255.192/27 + 255.255.255.224/28 + 255.255.255.240/29 + 255.255.255.248/30 + 255.255.255.252/31 + 255.255.255.254/32 + 172.31.255.252/30 + + diff --git a/service/src/main/res/values/colors.xml b/service/src/main/res/values/colors.xml new file mode 100644 index 00000000..96f517a4 --- /dev/null +++ b/service/src/main/res/values/colors.xml @@ -0,0 +1,4 @@ + + + #1E4376 + \ No newline at end of file diff --git a/service/src/main/res/values/ids.xml b/service/src/main/res/values/ids.xml new file mode 100644 index 00000000..b7bec6dd --- /dev/null +++ b/service/src/main/res/values/ids.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/service/src/main/res/values/strings.xml b/service/src/main/res/values/strings.xml new file mode 100644 index 00000000..9eb0fb34 --- /dev/null +++ b/service/src/main/res/values/strings.xml @@ -0,0 +1,21 @@ + + + "%1$s↑\t%2$s↓" + + Clash Status + Profile Service Status + Profile Processing Status + Profile Process Result + Update Successfully + Update Failure + Update %s completed + Update %1$s: %2$s + Running + Loading + Clash for Android + Profiles and Providers + Configuration.yaml + Provider Files + Profile Updater + Profile Updating + diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 00000000..a61c880b --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,15 @@ +rootProject.name = "ClashForAndroid" + +include(":app") +include(":core") +include(":service") +include(":design") +include(":common") +include(":hideapi") + +pluginManagement { + repositories { + mavenCentral() + google() + } +} \ No newline at end of file