-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactoring and boilerplate changes. Bug: 311377497 Test: m Change-Id: Ibe9870bc60918c572ce75aa46bd885d2bc71fe00
- Loading branch information
Showing
6 changed files
with
157 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
libartservice/service/java/com/android/server/art/PreRebootDexoptJob.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/* | ||
* Copyright (C) 2024 The Android Open Source Project | ||
* | ||
* 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. | ||
*/ | ||
|
||
package com.android.server.art; | ||
|
||
import static com.android.server.art.model.ArtFlags.ScheduleStatus; | ||
|
||
import android.annotation.NonNull; | ||
import android.app.job.JobParameters; | ||
import android.content.Context; | ||
import android.os.Build; | ||
|
||
import androidx.annotation.RequiresApi; | ||
|
||
import com.android.internal.annotations.VisibleForTesting; | ||
import com.android.server.art.model.ArtFlags; | ||
import com.android.server.art.model.ArtServiceJobInterface; | ||
|
||
/** @hide */ | ||
@RequiresApi(Build.VERSION_CODES.UPSIDE_DOWN_CAKE) | ||
public class PreRebootDexoptJob implements ArtServiceJobInterface { | ||
private static final String TAG = ArtManagerLocal.TAG; | ||
|
||
/** | ||
* "android" is the package name for a <service> declared in | ||
* frameworks/base/core/res/AndroidManifest.xml | ||
*/ | ||
private static final String JOB_PKG_NAME = Utils.PLATFORM_PACKAGE_NAME; | ||
/** An arbitrary number. Must be unique among all jobs owned by the system uid. */ | ||
public static final int JOB_ID = 27873781; | ||
|
||
@NonNull private final Injector mInjector; | ||
|
||
public PreRebootDexoptJob(@NonNull Context context) { | ||
this(new Injector(context)); | ||
} | ||
|
||
@VisibleForTesting | ||
public PreRebootDexoptJob(@NonNull Injector injector) { | ||
mInjector = injector; | ||
} | ||
|
||
@Override | ||
public boolean onStartJob( | ||
@NonNull BackgroundDexoptJobService jobService, @NonNull JobParameters params) { | ||
// "true" means the job will continue running until `jobFinished` is called. | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean onStopJob(@NonNull JobParameters params) { | ||
// "true" means to execute again in the same interval with the default retry policy. | ||
return true; | ||
} | ||
|
||
public @ScheduleStatus int schedule() { | ||
// TODO(b/311377497): Schedule the job. | ||
return ArtFlags.SCHEDULE_SUCCESS; | ||
} | ||
|
||
/** | ||
* Injector pattern for testing purpose. | ||
* | ||
* @hide | ||
*/ | ||
@VisibleForTesting | ||
public static class Injector { | ||
@NonNull private final Context mContext; | ||
|
||
Injector(@NonNull Context context) { | ||
mContext = context; | ||
} | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
libartservice/service/java/com/android/server/art/model/ArtServiceJobInterface.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright (C) 2024 The Android Open Source Project | ||
* | ||
* 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. | ||
*/ | ||
|
||
package com.android.server.art.model; | ||
|
||
import android.annotation.NonNull; | ||
import android.app.job.JobParameters; | ||
|
||
import com.android.server.art.BackgroundDexoptJobService; | ||
|
||
/** @hide */ | ||
public interface ArtServiceJobInterface { | ||
boolean onStartJob( | ||
@NonNull BackgroundDexoptJobService jobService, @NonNull JobParameters params); | ||
|
||
boolean onStopJob(@NonNull JobParameters params); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters