diff --git a/native/android/tests/activitymanager/UidImportanceHelperApps/Android.bp b/native/android/tests/activitymanager/UidImportanceHelperApps/Android.bp new file mode 100644 index 0000000000000..1a51218616d27 --- /dev/null +++ b/native/android/tests/activitymanager/UidImportanceHelperApps/Android.bp @@ -0,0 +1,11 @@ +android_test_helper_app { + name: "UidImportanceHelperApp", + manifest: "HelperAppManifest.xml", + static_libs: ["androidx.test.rules"], + sdk_version: "test_current", + srcs: ["src/**/*.java"], + test_suites: [ + "general-tests", + ], +} + diff --git a/native/android/tests/activitymanager/UidImportanceHelperApps/HelperAppManifest.xml b/native/android/tests/activitymanager/UidImportanceHelperApps/HelperAppManifest.xml new file mode 100644 index 0000000000000..3583b33756e9c --- /dev/null +++ b/native/android/tests/activitymanager/UidImportanceHelperApps/HelperAppManifest.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + diff --git a/native/android/tests/activitymanager/UidImportanceHelperApps/src/com/android/tests/UidImportanceHelper/MainActivity.java b/native/android/tests/activitymanager/UidImportanceHelperApps/src/com/android/tests/UidImportanceHelper/MainActivity.java new file mode 100644 index 0000000000000..db0f2b5ed9670 --- /dev/null +++ b/native/android/tests/activitymanager/UidImportanceHelperApps/src/com/android/tests/UidImportanceHelper/MainActivity.java @@ -0,0 +1,107 @@ +/* + * Copyright (C) 2020 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.tests.UidImportanceHelper; + +import android.app.Activity; +import android.content.Intent; +import android.os.Bundle; +import android.util.Log; + +/** + * This is an empty activity for testing the UID policy of media transcoding service. + */ +public class MainActivity extends Activity { + private static final String TAG = "MainActivity"; + + // Called at the start of the full lifetime. + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + // Initialize Activity and inflate the UI. + } + + // Called after onCreate has finished, use to restore UI state + @Override + public void onRestoreInstanceState(Bundle savedInstanceState) { + super.onRestoreInstanceState(savedInstanceState); + // Restore UI state from the savedInstanceState. + // This bundle has also been passed to onCreate. + // Will only be called if the Activity has been + // killed by the system since it was last visible. + } + + // Called before subsequent visible lifetimes + // for an activity process. + @Override + public void onRestart() { + super.onRestart(); + // Load changes knowing that the Activity has already + // been visible within this process. + } + + // Called at the start of the visible lifetime. + @Override + public void onStart() { + super.onStart(); + // Apply any required UI change now that the Activity is visible. + } + + // Called at the start of the active lifetime. + @Override + public void onResume() { + super.onResume(); + // Resume any paused UI updates, threads, or processes required + // by the Activity but suspended when it was inactive. + } + + // Called to save UI state changes at the + // end of the active lifecycle. + @Override + public void onSaveInstanceState(Bundle savedInstanceState) { + // Save UI state changes to the savedInstanceState. + // This bundle will be passed to onCreate and + // onRestoreInstanceState if the process is + // killed and restarted by the run time. + super.onSaveInstanceState(savedInstanceState); + } + + // Called at the end of the active lifetime. + @Override + public void onPause() { + // Suspend UI updates, threads, or CPU intensive processes + // that don't need to be updated when the Activity isn't + // the active foreground Activity. + super.onPause(); + } + + // Called at the end of the visible lifetime. + @Override + public void onStop() { + // Suspend remaining UI updates, threads, or processing + // that aren't required when the Activity isn't visible. + // Persist all edits or state changes + // as after this call the process is likely to be killed. + super.onStop(); + } + + // Sometimes called at the end of the full lifetime. + @Override + public void onDestroy() { + // Clean up any resources including ending threads, + // closing database connections etc. + super.onDestroy(); + } +} diff --git a/native/android/tests/activitymanager/nativeTests/Android.bp b/native/android/tests/activitymanager/nativeTests/Android.bp new file mode 100644 index 0000000000000..d4b5015ad8f3e --- /dev/null +++ b/native/android/tests/activitymanager/nativeTests/Android.bp @@ -0,0 +1,39 @@ +cc_test { + name: "ActivityManagerNativeTestCases", + + multilib: { + lib32: { + suffix: "32", + }, + lib64: { + suffix: "64", + }, + }, + + srcs: ["src/ActivityManagerNativeTest.cpp"], + + shared_libs: [ + "liblog", + "libutils", + "libandroid", + "libbinder", + ], + + static_libs: [ + "libbase", + "libgtest", + ], + stl: "c++_shared", + + test_suites: [ + "general-tests", + ], + + cflags: [ + "-Werror", + "-Wall", + ], + required: [ + "UidImportanceHelperApp", + ], +} diff --git a/native/android/tests/activitymanager/nativeTests/AndroidTest.xml b/native/android/tests/activitymanager/nativeTests/AndroidTest.xml new file mode 100644 index 0000000000000..bf6287ad48831 --- /dev/null +++ b/native/android/tests/activitymanager/nativeTests/AndroidTest.xml @@ -0,0 +1,53 @@ + + + +