Skip to content

Commit

Permalink
Merge pull request #475 from joeloewi7178/hotfix-zzz
Browse files Browse the repository at this point in the history
Hotfix zzz
  • Loading branch information
joeloewi7178 authored Jul 8, 2024
2 parents 9ceb91f + e7af2a8 commit 555ee44
Show file tree
Hide file tree
Showing 23 changed files with 169 additions and 43 deletions.
25 changes: 16 additions & 9 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,18 @@ jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: macos-latest
runs-on: ubuntu-latest
timeout-minutes: 120

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Enable KVM group perms
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
ls /dev/kvm
- name: Checkout
uses: actions/checkout@v4

Expand All @@ -32,7 +39,7 @@ jobs:
java-version: '17'

- name: Install GMD image for baseline profile generation
run: yes | "$ANDROID_HOME"/cmdline-tools/latest/bin/sdkmanager "system-images;android-34;aosp_atd;x86_64"
run: yes | "$ANDROID_HOME"/cmdline-tools/latest/bin/sdkmanager "system-images;android-33;aosp_atd;x86_64"

- name: Accept Android licenses
run: yes | "$ANDROID_HOME"/cmdline-tools/latest/bin/sdkmanager --licenses || true
Expand All @@ -50,13 +57,13 @@ jobs:
fileDir: './'
encodedString: ${{ secrets.SIGNING_KEY }}

- name: Generate baseline profile
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 34
target: aosp_atd
arch: x86_64
script: ./gradlew :app:bundleRelease
- name: Build release variant including baseline profile generation
run: ./gradlew :app:assembleRelease
-Pandroid.testInstrumentationRunnerArguments.androidx.benchmark.enabledRules=BaselineProfile
-Pandroid.testoptions.manageddevices.emulator.gpu="swiftshader_indirect"
-Pandroid.experimental.testOptions.managedDevices.emulator.showKernelLogging=true
-Pandroid.experimental.androidTest.numManagedDeviceShards=1
-Pandroid.experimental.testOptions.managedDevices.maxConcurrentDevices=1

- name: Upload Android Release to Play Store
uses: r0adkll/upload-google-play@v1
Expand Down
25 changes: 16 additions & 9 deletions .github/workflows/on_pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,18 @@ jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: macos-latest
runs-on: ubuntu-latest
timeout-minutes: 120

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Enable KVM group perms
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
ls /dev/kvm
- name: Checkout
uses: actions/checkout@v4

Expand All @@ -32,7 +39,7 @@ jobs:
java-version: '17'

- name: Install GMD image for baseline profile generation
run: yes | "$ANDROID_HOME"/cmdline-tools/latest/bin/sdkmanager "system-images;android-34;aosp_atd;x86_64"
run: yes | "$ANDROID_HOME"/cmdline-tools/latest/bin/sdkmanager "system-images;android-33;aosp_atd;x86_64"

- name: Accept Android licenses
run: yes | "$ANDROID_HOME"/cmdline-tools/latest/bin/sdkmanager --licenses || true
Expand All @@ -50,10 +57,10 @@ jobs:
fileDir: './'
encodedString: ${{ secrets.SIGNING_KEY }}

- name: Generate baseline profile
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 34
target: aosp_atd
arch: x86_64
script: ./gradlew :app:bundleRelease
- name: Build release variant including baseline profile generation
run: ./gradlew :app:assembleRelease
-Pandroid.testInstrumentationRunnerArguments.androidx.benchmark.enabledRules=BaselineProfile
-Pandroid.testoptions.manageddevices.emulator.gpu="swiftshader_indirect"
-Pandroid.experimental.testOptions.managedDevices.emulator.showKernelLogging=true
-Pandroid.experimental.androidTest.numManagedDeviceShards=1
-Pandroid.experimental.testOptions.managedDevices.maxConcurrentDevices=1
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ android {

defaultConfig {
applicationId = "com.joeloewi.croissant"
versionCode = 61
versionName = "1.3.0"
versionCode = 62
versionName = "1.3.1"
targetSdk = 34

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ fun SelectGames(
HoYoLABGame.HonkaiImpact3rd,
HoYoLABGame.GenshinImpact,
HoYoLABGame.TearsOfThemis,
HoYoLABGame.HonkaiStarRail
HoYoLABGame.HonkaiStarRail,
HoYoLABGame.ZenlessZoneZero
).toImmutableList()
}
val containsNotSupportedGame = stringResource(id = R.string.contains_not_supported_game)
Expand Down Expand Up @@ -424,7 +425,7 @@ fun ConnectedGamesContentListItem(

val enabled by remember(hoYoLABGame, gameRecord) {
derivedStateOf {
hoYoLABGame == HoYoLABGame.TearsOfThemis || hoYoLABGame == HoYoLABGame.HonkaiStarRail || currentGameRecord.value.gameId != GameRecord.INVALID_GAME_ID
hoYoLABGame == HoYoLABGame.TearsOfThemis || currentGameRecord.value.gameId != GameRecord.INVALID_GAME_ID
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,14 @@ fun SettingsContent(
value = !isUnusedAppRestrictionEnabled().getOrDefault(false),
role = Role.Switch,
onValueChange = {
activityResult.launch(
IntentCompat.createManageUnusedAppRestrictionsIntent(
activity,
activity.packageName
runCatching {
activityResult.launch(
IntentCompat.createManageUnusedAppRestrictionsIntent(
activity,
activity.packageName
)
)
)
}
}
),
leadingContent = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ fun HoYoLABGame.gameNameStringResId(): Int = when (this) {
R.string.honkai_star_rail_game_name
}

HoYoLABGame.ZenlessZoneZero -> {
R.string.zenless_zone_zero_game_name
}

HoYoLABGame.Unknown -> {
R.string.unknown_game_name
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ class AttendCheckInEventWorker @AssistedInject constructor(
private val attendCheckInGenshinImpactUseCase: CheckInUseCase.AttendCheckInGenshinImpact,
private val attendCheckInHonkaiImpact3rdUseCase: CheckInUseCase.AttendCheckInHonkaiImpact3rd,
private val attendCheckInTearsOfThemisUseCase: CheckInUseCase.AttendCheckInTearsOfThemis,
private val attendCheckInHonkaiStarRail: CheckInUseCase.AttendCheckInHonkaiStarRail,
private val attendCheckInHonkaiStarRailUseCase: CheckInUseCase.AttendCheckInHonkaiStarRailUseCase,
private val attendCheckInZenlessZoneZeroUseCase: CheckInUseCase.AttendCheckInZenlessZoneZeroUseCase,
private val insertWorkerExecutionLogUseCase: WorkerExecutionLogUseCase.Insert,
private val hasExecutedAtLeastOnce: WorkerExecutionLogUseCase.HasExecutedAtLeastOnce,
private val insertSuccessLogUseCase: SuccessLogUseCase.Insert,
Expand Down Expand Up @@ -159,7 +160,11 @@ class AttendCheckInEventWorker @AssistedInject constructor(
}

HoYoLABGame.HonkaiStarRail -> {
attendCheckInHonkaiStarRail(cookie = cookie)
attendCheckInHonkaiStarRailUseCase(cookie = cookie)
}

HoYoLABGame.ZenlessZoneZero -> {
attendCheckInZenlessZoneZeroUseCase(cookie = cookie)
}

HoYoLABGame.Unknown -> {
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-en-rUS/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,5 @@
<string name="execution_notice">To ensure accuracy, the scheduled task will be executed 30 seconds after the specified time. For example, if you schedule a task for 12:34 PM, it will actually be executed at 12:34:30 PM.</string>
<string name="attendance_retry_unknown_error">Attendance failed due to unknown error. Retry has scheduled.</string>
<string name="attendance_retry_too_many_requests_error">Attendance failed due to too many requests. Retry has scheduled.</string>
<string name="zenless_zone_zero_game_name">Zenless Zone Zero</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-ko-rKR/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,5 @@
<string name="execution_notice">작업을 정확하게 실행하기 위해, 지정된 시간보다 30초 늦게 실행됩니다. 예를 들어, 12시 34분에 작업을 예약하면 실제로는 12시 34분 30초에 실행됩니다.</string>
<string name="attendance_retry_unknown_error">알 수 없는 문제로 인해 출석하지 못했습니다. 재시도를 예약합니다.</string>
<string name="attendance_retry_too_many_requests_error">요청이 빈번하여 출석하지 못 했습니다. 재시도를 예약합니다.</string>
<string name="zenless_zone_zero_game_name">젠레스 존 제로</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,5 @@
<string name="execution_notice">To ensure accuracy, the scheduled task will be executed 30 seconds after the specified time. For example, if you schedule a task for 12:34 PM, it will actually be executed at 12:34:30 PM.</string>
<string name="attendance_retry_unknown_error">Attendance failed due to unknown error. Retry has scheduled.</string>
<string name="attendance_retry_too_many_requests_error">Attendance failed due to too many requests. Retry has scheduled.</string>
<string name="zenless_zone_zero_game_name">Zenless Zone Zero</string>
</resources>
10 changes: 6 additions & 4 deletions baselineprofile/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ android {
testOptions {
managedDevices {
devices {
create<ManagedVirtualDevice>("pixel2Api34") {
device = "Pixel 2"
apiLevel = 34
create<ManagedVirtualDevice>("pixel6Api33") {
device = "Pixel 6"
apiLevel = 33
systemImageSource = "aosp"
}
}
}
Expand All @@ -41,7 +42,8 @@ android {
// This is the configuration block for the Baseline Profile plugin.
// You can specify to run the generators on a managed devices or connected devices.
baselineProfile {
useConnectedDevices = true
managedDevices += "pixel6Api33"
useConnectedDevices = false
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import retrofit2.http.Query
interface ArcaLiveAppService {
@GET("view/article/{slug}/{articleId}")
suspend fun getArticle(
@Header("User-Agent") userAgent: String = "live.arca.android.playstore/0.8.331-playstore",
@Header("User-Agent") userAgent: String = "net.umanle.arca.android.playstore/0.9.57",
@Path("slug") slug: String,
@Path("articleId") articleId: Long,
@Query("viewCount") viewCount: Boolean = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@ import com.skydoves.sandwich.ApiResponse
import retrofit2.http.Body
import retrofit2.http.Header
import retrofit2.http.POST
import retrofit2.http.Query
import java.util.Locale

interface GenshinImpactCheckInService {

@POST("event/sol/sign")
suspend fun attend(
@Query("lang") language: String = Locale.getDefault().toLanguageTag().lowercase(),
@Header("Cookie") cookie: String,
@Body params: Map<String, String> = mapOf("act_id" to "e202102251931481")
@Body params: Map<String, String> = mapOf(
"act_id" to "e202102251931481",
"lang" to Locale.getDefault().toLanguageTag().lowercase()
)
): ApiResponse<AttendanceResponse>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.joeloewi.croissant.data.api.dao

import com.joeloewi.croissant.data.api.model.response.AttendanceResponse
import com.skydoves.sandwich.ApiResponse
import retrofit2.http.Body
import retrofit2.http.Header
import retrofit2.http.POST
import java.util.Locale

/*
* Copyright (C) 2024 joeloewi
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
interface ZenlessZoneZeroCheckInService {

@POST("event/luna/zzz/os/sign")
suspend fun attend(
@Header("Cookie") cookie: String,
@Body params: Map<String, String> = mapOf(
"act_id" to "e202406031448091",
"lang" to Locale.getDefault().toLanguageTag().lowercase()
)
): ApiResponse<AttendanceResponse>
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ fun generateGameIntent(
}
}

HoYoLABGame.ZenlessZoneZero -> {
with("com.HoYoverse.Nap") {
this to "market://details?id=${this}".toUri()
}
}

HoYoLABGame.Unknown -> {
"" to Uri.EMPTY
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import com.joeloewi.croissant.data.api.dao.ArcaLiveAppService
import com.joeloewi.croissant.data.api.dao.CheckInService
import com.joeloewi.croissant.data.api.dao.GenshinImpactCheckInService
import com.joeloewi.croissant.data.api.dao.HoYoLABService
import com.joeloewi.croissant.data.api.dao.ZenlessZoneZeroCheckInService
import com.joeloewi.croissant.data.api.model.response.AttendanceResponse
import com.joeloewi.croissant.data.api.model.response.ChangeDataSwitchResponse
import com.joeloewi.croissant.data.api.model.response.GameRecordCardResponse
Expand Down Expand Up @@ -145,4 +146,12 @@ object ApiModule {
.baseUrl("https://arca.live/api/app/")
.build()
.create()

@Singleton
@Provides
fun providesZenlessZoneZeroCheckInService(retrofitBuilder: Retrofit.Builder): ZenlessZoneZeroCheckInService =
retrofitBuilder
.baseUrl("https://sg-act-nap-api.hoyolab.com")
.build()
.create()
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,10 @@ class CheckInRepositoryImpl @Inject constructor(
): Result<BaseResponse> = checkInDataSource.runCatching {
attendCheckInHonkaiImpact3rd(cookie).getOrThrow().throwIfNotOk()
}

override suspend fun attendCheckInZenlessZoneZero(
cookie: String
): Result<BaseResponse> = checkInDataSource.runCatching {
attendCheckInZenlessZoneZero(cookie).getOrThrow().throwIfNotOk()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,6 @@ interface CheckInDataSource {
suspend fun attendCheckInGenshinImpact(cookie: String): ApiResponse<AttendanceResponse>

suspend fun attendCheckInHonkaiImpact3rd(cookie: String): ApiResponse<AttendanceResponse>

suspend fun attendCheckInZenlessZoneZero(cookie: String): ApiResponse<AttendanceResponse>
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,18 @@ class ArcaLiveAppDataSourceImpl @Inject constructor(
}
}

HoYoLABGame.ZenlessZoneZero -> {
arcaLiveAppService.getArticle(
slug = "zenlesszonezero",
articleId = 109976603
).mapSuccess {
Jsoup.parse(content)
.apply { select("img").remove() }
.html()
.replace("https://oo.pe/", "")
}
}

HoYoLABGame.TearsOfThemis, HoYoLABGame.Unknown -> throw IllegalStateException()
}
}
Expand Down
Loading

0 comments on commit 555ee44

Please sign in to comment.