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

Commit 4c6e5036 authored by Jimmy Shiu's avatar Jimmy Shiu Committed by Wei Wang
Browse files

ADPF: PerformanceHintManager API implementation



Test: Manual test, run bouncy ball
Test: atest FrameworksCoreTests:android.os.PerformanceHintManagerTest
Bug: 158791282
Change-Id: Ia0bf2b06675b8cf57cdf1668ee90e98026416439
Signed-off-by: default avatarWei Wang <wvw@google.com>
parent badb432a
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -10644,6 +10644,7 @@ package android.content {
    field public static final String NOTIFICATION_SERVICE = "notification";
    field public static final String NSD_SERVICE = "servicediscovery";
    field public static final String PEOPLE_SERVICE = "people";
    field public static final String PERFORMANCE_HINT_SERVICE = "performance_hint";
    field public static final String POWER_SERVICE = "power";
    field public static final String PRINT_SERVICE = "print";
    field public static final int RECEIVER_VISIBLE_TO_INSTANT_APPS = 1; // 0x1
@@ -31559,6 +31560,17 @@ package android.os {
    field public static final int PATTERN_SUFFIX = 4; // 0x4
  }
  public final class PerformanceHintManager {
    method @Nullable public android.os.PerformanceHintManager.Session createHintSession(@NonNull int[], long);
    method public long getPreferredUpdateRateNanos();
  }
  public static class PerformanceHintManager.Session implements java.io.Closeable {
    method public void close();
    method public void reportActualWorkDuration(long);
    method public void updateTargetWorkDuration(long);
  }
  public final class PersistableBundle extends android.os.BaseBundle implements java.lang.Cloneable android.os.Parcelable {
    ctor public PersistableBundle();
    ctor public PersistableBundle(int);
+13 −0
Original line number Diff line number Diff line
@@ -158,12 +158,14 @@ import android.os.IBatteryPropertiesRegistrar;
import android.os.IBinder;
import android.os.IDumpstate;
import android.os.IHardwarePropertiesManager;
import android.os.IHintManager;
import android.os.IPowerManager;
import android.os.IRecoverySystem;
import android.os.ISystemUpdateManager;
import android.os.IThermalService;
import android.os.IUserManager;
import android.os.IncidentManager;
import android.os.PerformanceHintManager;
import android.os.PowerManager;
import android.os.RecoverySystem;
import android.os.ServiceManager;
@@ -592,6 +594,17 @@ public final class SystemServiceRegistry {
                        ctx.mMainThread.getHandler());
            }});

        registerService(Context.PERFORMANCE_HINT_SERVICE, PerformanceHintManager.class,
                new CachedServiceFetcher<PerformanceHintManager>() {
            @Override
            public PerformanceHintManager createService(ContextImpl ctx)
                    throws ServiceNotFoundException {
                IBinder hintBinder = ServiceManager.getServiceOrThrow(
                        Context.PERFORMANCE_HINT_SERVICE);
                IHintManager hintService = IHintManager.Stub.asInterface(hintBinder);
                return new PerformanceHintManager(hintService);
            }});

        registerService(Context.RECOVERY_SERVICE, RecoverySystem.class,
                new CachedServiceFetcher<RecoverySystem>() {
            @Override
+8 −0
Original line number Diff line number Diff line
@@ -5224,6 +5224,14 @@ public abstract class Context {
     */
    public static final String THERMAL_SERVICE = "thermalservice";

    /**
     * Use with {@link #getSystemService(String)} to retrieve a
     * {@link android.os.PerformanceHintManager} for accessing the performance hinting service.
     *
     * @see #getSystemService(String)
     */
    public static final String PERFORMANCE_HINT_SERVICE = "performance_hint";

    /**
     * Use with {@link #getSystemService(String)} to retrieve a
     * {@link android.content.pm.ShortcutManager} for accessing the launcher shortcut service.
+33 −0
Original line number Diff line number Diff line
/*
 *
 * Copyright 2021, 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 android.os;

import android.os.IHintSession;

/** {@hide} */
interface IHintManager {
    /**
     * Creates a {@link Session} for the given set of threads and associates to a binder token.
     */
   IHintSession createHintSession(in IBinder token, in int[] tids, long durationNanos);

    /**
     * Get preferred rate limit in nano second.
     */
   long getHintSessionPreferredRate();
}
+25 −0
Original line number Diff line number Diff line
/*
 *
 * Copyright 2021, 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 android.os;

/** {@hide} */
oneway interface IHintSession {
    void updateTargetWorkDuration(long targetDurationNanos);
    void reportActualWorkDuration(in long[] actualDurationNanos, in long[] timeStampNanos);
    void close();
}
Loading