Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 86061f28 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Hide the Battery Stats Viewer launcher by default" into main

parents f460e5cf 02f76e76
Loading
Loading
Loading
Loading
+23 −1
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@

    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.BATTERY_STATS"/>
    <uses-permission android:name="android.permission.CHANGE_COMPONENT_ENABLED_STATE"/>
    <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS"/>
    <uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"/>

@@ -31,7 +32,8 @@
        <activity android:name=".BatteryConsumerPickerActivity"
                  android:label="Battery Stats"
                  android:launchMode="singleTop"
                  android:exported="true">
                  android:exported="true"
                  android:enabled="false">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
@@ -41,5 +43,25 @@
        <activity android:name=".BatteryStatsViewerActivity"
                  android:label="Battery Stats"
                  android:parentActivityName=".BatteryConsumerPickerActivity"/>

        <activity android:name=".TrampolineActivity"
            android:exported="true"
            android:theme="@android:style/Theme.NoDisplay">
            <intent-filter>
                <action android:name="com.android.settings.action.IA_SETTINGS"/>
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>

            <meta-data android:name="com.android.settings.category"
                android:value="com.android.settings.category.ia.development" />
            <meta-data android:name="com.android.settings.title"
                android:resource="@string/settings_title" />
            <meta-data android:name="com.android.settings.summary"
                android:resource="@string/settings_summary" />
            <meta-data android:name="com.android.settings.group_key"
                android:value="debug_debugging_category" />
            <meta-data android:name="com.android.settings.order"
                android:value="2" />
        </activity>
    </application>
</manifest>
+20 −0
Original line number Diff line number Diff line
<!--
  ~ 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.
  -->

<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
    <string name="settings_title">Launch Battery Stats Viewer</string>
    <string name="settings_summary">The Battery Stats Viewer will be visible in the Launcher after it is opened once.</string>
</resources>
+46 −0
Original line number Diff line number Diff line
/*
 * 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));
    }
}