diff --git a/core/tests/batterystatstests/BatteryStatsViewer/AndroidManifest.xml b/core/tests/batterystatstests/BatteryStatsViewer/AndroidManifest.xml index 94bde68fdf119..127dbfd25b092 100644 --- a/core/tests/batterystatstests/BatteryStatsViewer/AndroidManifest.xml +++ b/core/tests/batterystatstests/BatteryStatsViewer/AndroidManifest.xml @@ -20,6 +20,7 @@ + @@ -31,7 +32,8 @@ + android:exported="true" + android:enabled="false"> @@ -41,5 +43,25 @@ + + + + + + + + + + + + + diff --git a/core/tests/batterystatstests/BatteryStatsViewer/res/values/strings.xml b/core/tests/batterystatstests/BatteryStatsViewer/res/values/strings.xml new file mode 100644 index 0000000000000..c23c1484cf59d --- /dev/null +++ b/core/tests/batterystatstests/BatteryStatsViewer/res/values/strings.xml @@ -0,0 +1,20 @@ + + + + Launch Battery Stats Viewer + The Battery Stats Viewer will be visible in the Launcher after it is opened once. + diff --git a/core/tests/batterystatstests/BatteryStatsViewer/src/com/android/frameworks/core/batterystatsviewer/TrampolineActivity.java b/core/tests/batterystatstests/BatteryStatsViewer/src/com/android/frameworks/core/batterystatsviewer/TrampolineActivity.java new file mode 100644 index 0000000000000..b01648838695b --- /dev/null +++ b/core/tests/batterystatstests/BatteryStatsViewer/src/com/android/frameworks/core/batterystatsviewer/TrampolineActivity.java @@ -0,0 +1,46 @@ +/* + * 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.frameworks.core.batterystatsviewer; + +import android.app.Activity; +import android.content.ComponentName; +import android.content.Intent; +import android.content.pm.PackageManager; +import android.os.Bundle; + +import androidx.annotation.Nullable; + +public class TrampolineActivity extends Activity { + + @Override + protected void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + showLauncherIcon(); + launchMainActivity(); + } + + private void showLauncherIcon() { + PackageManager pm = getPackageManager(); + pm.setComponentEnabledSetting(new ComponentName(this, BatteryConsumerPickerActivity.class), + PackageManager.COMPONENT_ENABLED_STATE_ENABLED, + PackageManager.DONT_KILL_APP); + } + + private void launchMainActivity() { + startActivity(new Intent(this, BatteryConsumerPickerActivity.class)); + } +}