Skip to content

Commit

Permalink
Merge remote-tracking branch 'sakura/11' into sakura/11-x86
Browse files Browse the repository at this point in the history
  • Loading branch information
hmtheboy154 committed Apr 4, 2022
2 parents f302d6b + c31af85 commit be56102
Show file tree
Hide file tree
Showing 120 changed files with 9,490 additions and 1,909 deletions.
19 changes: 18 additions & 1 deletion cmds/bootanimation/BootAnimation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,19 @@ status_t BootAnimation::readyToRun() {

mMaxWidth = android::base::GetIntProperty("ro.surface_flinger.max_graphics_width", 0);
mMaxHeight = android::base::GetIntProperty("ro.surface_flinger.max_graphics_height", 0);
ui::Size resolution = displayConfig.resolution;

// check for overridden ui resolution
ui::Size resolution;
char *endptr;
std::string size_override = android::base::GetProperty("ro.config.size_override", "");

resolution.width = strtoimax(size_override.c_str(), &endptr, 10);
if (endptr[0] == ',')
resolution.height = strtoimax(endptr+1, NULL, 10);

if (resolution.width <= 0 || resolution.height <= 0)
resolution = displayConfig.resolution;

resolution = limitSurfaceSize(resolution.width, resolution.height);
// create the native surface
sp<SurfaceControl> control = session()->createSurface(String8("BootAnimation"),
Expand Down Expand Up @@ -432,6 +444,11 @@ status_t BootAnimation::readyToRun() {
t.setLayerStack(control, LAYER_STACK);
}

// Scale forced resolution to physical resolution
Rect forcedRes(0, 0, resolution.width, resolution.height);
Rect physRes(0, 0, displayConfig.resolution.width, displayConfig.resolution.height);
t.setDisplayProjection(mDisplayToken, ui::ROTATION_0, forcedRes, physRes);

t.setLayer(control, 0x40000000)
.apply();

Expand Down
12 changes: 12 additions & 0 deletions core/java/android/app/ApplicationPackageManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@
import com.android.internal.os.SomeArgs;
import com.android.internal.util.UserIcons;

import com.nvidia.NvAppProfileService;

import dalvik.system.VMRuntime;

import libcore.util.EmptyArray;
Expand Down Expand Up @@ -149,6 +151,7 @@ public class ApplicationPackageManager extends PackageManager {
private UserManager mUserManager;
@GuardedBy("mLock")
private PackageInstaller mInstaller;
private NvAppProfileService mAppProfileService;
@GuardedBy("mLock")
private ArtManager mArtManager;

Expand Down Expand Up @@ -406,6 +409,15 @@ public boolean isWirelessConsentModeEnabled() {
com.android.internal.R.bool.config_wirelessConsentRequired);
}

/** @hide */
@Override
public NvAppProfileService getAppProfileService() {
if (mAppProfileService == null) {
mAppProfileService = new NvAppProfileService(mContext);
}
return mAppProfileService;
}

@Override
public ApplicationInfo getApplicationInfo(String packageName, int flags)
throws NameNotFoundException {
Expand Down
5 changes: 5 additions & 0 deletions core/java/android/content/pm/PackageManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@

import com.android.internal.util.ArrayUtils;

import com.nvidia.NvAppProfileService;

import dalvik.system.VMRuntime;

import java.io.File;
Expand Down Expand Up @@ -4048,6 +4050,9 @@ public abstract PermissionGroupInfo getPermissionGroupInfo(@NonNull String permN
public abstract List<PermissionGroupInfo> getAllPermissionGroups(
@PermissionGroupInfoFlags int flags);

/** @hide */
public abstract NvAppProfileService getAppProfileService();

/**
* Retrieve all of the information we know about a particular
* package/application.
Expand Down
7 changes: 7 additions & 0 deletions core/java/android/content/pm/PackageParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@
import com.android.internal.util.ArrayUtils;
import com.android.internal.util.XmlUtils;

import com.nvidia.NvAppProfileService;

import libcore.io.IoUtils;
import libcore.util.EmptyArray;
import libcore.util.HexEncoding;
Expand Down Expand Up @@ -578,6 +580,7 @@ public void setCacheDir(File cacheDir) {
* a package.
*/
public interface Callback {
NvAppProfileService getAppProfileService();
boolean hasFeature(String feature);
}

Expand All @@ -592,6 +595,10 @@ public CallbackImpl(PackageManager pm) {
mPm = pm;
}

@Override public NvAppProfileService getAppProfileService() {
return mPm.getAppProfileService();
}

@Override public boolean hasFeature(String feature) {
return mPm.hasSystemFeature(feature);
}
Expand Down
246 changes: 246 additions & 0 deletions core/java/com/nvidia/NvAppProfileService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,246 @@
/*
* Copyright (c) 2012 - 2014 NVIDIA Corporation. All rights reserved.
*
* 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.
*
* Class structure based upon Camera in Camera.java:
* Copyright (C) 2009 The Android Open Source Project
*/

package com.nvidia;

import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.util.Log;

import com.nvidia.profilemanager.NvAppProfileSettingId;

/**
* @hide
*/
public class NvAppProfileService {
private static final String TAG = "NvAppProfileService";
private static final String APP_START_ACTION =
"com.nvidia.NvAppProfileService.action.APP_START";
private static final String APP_START_TARGET_PACKAGE = "com.nvidia.peripheralservice";
private static final String FEATURE_POWER_BUDGET_CONTROL =
"nvidia.feature.power_budget_control";
private static final String FEATURE_FAN_ON_DEVICE = "nvidia.feature.fan_on_device";

private final NvAppProfiles mAppProfile;
private final NvWhitelistService mWhitelistService;
private final Context mContext;

private boolean mInitialisedAppProfiles = false;
private boolean mFanCapEnabled = false;
private boolean mPbcEnabled = false;

public NvAppProfileService(Context context) {
Context appContext = context.getApplicationContext();
if (appContext == null) {
mContext = context;
} else {
mContext = appContext;
}

mAppProfile = new NvAppProfiles(mContext);
mWhitelistService = new NvWhitelistService(mContext);
}

private static String getPackageName(String appName) {
int index = appName.indexOf('/');
if (index < 0) {
Log.e(TAG, "appName does not contain '/'. " +
"The packageName cannot be extracted from appName!");
return null;
}
return appName.substring(0, index);
}

/*
* These are functions that depend on NvAppProfiles and may or may not
* be supported for certain platforms. In the latter case, these methods
* should return -1.
*/
public boolean getAppProfileFRCEnable(String packageName) {
return packageName != null && mAppProfile.getApplicationProfile(packageName,
NvAppProfileSettingId.VIDEO_FRC_ENABLE) == 1;
}

public boolean getAppProfileCreateSecureDecoder(String packageName) {
return packageName != null && mAppProfile.getApplicationProfile(packageName,
NvAppProfileSettingId.VIDEO_SECURE_DECODE) == 1;
}

public boolean getAppProfileTSFilterEnable(String packageName) {
return packageName != null && mAppProfile.getApplicationProfile(packageName,
NvAppProfileSettingId.VIDEO_TS_FILTERING) == 1;
}

public boolean getAppProfileMediaEnableMsdHal(String packageName) {
return packageName != null && this.mAppProfile.getApplicationProfile(packageName,
NvAppProfileSettingId.MEDIA_ENABLE_MSD_HAL) == 1;
}

public boolean getAppProfileNvidiaCertification(String packageName) {
return packageName != null && mAppProfile.getApplicationProfile(packageName,
NvAppProfileSettingId.NVIDIA_VIDEO_CERTIFICATION_ENABLED) == 1;
}

public String customizeAppBanner(String packageName) {
if (packageName == null) return null;

final String bannerName = mAppProfile.getApplicationProfileString(packageName,
NvAppProfileSettingId.WHITELIST_CUSTOMIZE_BANNER);
if (bannerName != null) return bannerName;

return mWhitelistService.getBannerName(packageName);
}

public Drawable getBannerDrawable(String packageName) {
final String bannerName = customizeAppBanner(packageName);
if (bannerName == null || bannerName.length() == 0) {
return null;
}

final Resources systemResources = mContext.getResources().getSystem();
final int drawableResourceId = systemResources.getIdentifier(bannerName,
"drawable", "android");
if (drawableResourceId == 0) return null;

return systemResources.getDrawable(drawableResourceId);
}

public NvWhitelistService getWhitelistService() {
return mWhitelistService;
}

public boolean getAppProfileDisableApp(String packageName) {
return packageName != null && mAppProfile.getApplicationProfile(packageName,
NvAppProfileSettingId.DISABLE_APP) == 1;
}

private int getAppProfileCpuScalingMinFreq(String packageName) {
return mAppProfile.getApplicationProfile(packageName,
NvAppProfileSettingId.SCALING_MIN_FREQ);
}

private int getAppProfileCpuCoreBias(String packageName) {
return mAppProfile.getApplicationProfile(packageName, NvAppProfileSettingId.CORE_BIAS);
}

private int getAppProfileGpuScaling(String packageName) {
return mAppProfile.getApplicationProfile(packageName, NvAppProfileSettingId.GPU_SCALING);
}

private int getAppProfileCpuMaxNormalFreq(String packageName) {
return mAppProfile.getApplicationProfile(packageName, NvAppProfileSettingId.CPU_FREQ_BIAS);
}

private int getAppProfileCpuMaxNormalFreqPercent(String packageName) {
return mAppProfile.getApplicationProfile(packageName,
NvAppProfileSettingId.MAX_CPU_FREQ_PCT);
}

private int getAppProfileCpuMinCore(String packageName) {
return mAppProfile.getApplicationProfile(packageName, NvAppProfileSettingId.MIN_CPU_CORES);
}

private int getAppProfileCpuMaxCore(String packageName) {
return mAppProfile.getApplicationProfile(packageName, NvAppProfileSettingId.MAX_CPU_CORES);
}

private int getAppProfileGpuCbusCapLevel(String packageName) {
return mAppProfile.getApplicationProfile(packageName, NvAppProfileSettingId.GPU_CORE_CAP);
}

private int getAppProfileEdpMode(String packageName) {
return mAppProfile.getApplicationProfile(packageName, NvAppProfileSettingId.EDP_MODE);
}

private int getAppProfilePbcPwr(String packageName) {
if (!mPbcEnabled) return -1;

return mAppProfile.getApplicationProfile(packageName, NvAppProfileSettingId.PBC_PWR_LIMIT);
}

private int getAppProfileFanCap(String packageName) {
if (!mFanCapEnabled) return -1;

return mAppProfile.getApplicationProfile(packageName, NvAppProfileSettingId.FAN_PWM_CAP);
}

private int getAppProfileVoltTempMode(String packageName) {
return mAppProfile.getApplicationProfile(packageName, NvAppProfileSettingId.VOLT_TEMP_MODE);
}

private int getAppProfileAggresivePrismEnable(String packageName) {
return mAppProfile.getApplicationProfile(packageName,
NvAppProfileSettingId.AGGRESSIVE_PRISM_ENABLE);
}

private int getAppProfileDevicePowerMode(String packageName) {
return mAppProfile.getApplicationProfile(packageName,
NvAppProfileSettingId.SYSTEM_POWER_MODE);
}

public String getAppProfileRegionEnableList(String packageName) {
return mAppProfile.getApplicationProfileString(packageName,
NvAppProfileSettingId.SET_REGION_LIST);
}

public int getAppProfileNvidiaBBCApps(String packageName) {
return mAppProfile.getApplicationProfile(packageName, NvAppProfileSettingId.BBC_APPS);
}

private int retrievePowerMode() {
final String powerMode = SystemProperties.get(NvConstants.NvPowerModeProperty);
if (powerMode != null) {
try {
return Integer.parseInt(powerMode);
} catch (NumberFormatException ex) {
// Fallthrough to error case
}
}

return -1;
}

/**
* Interface for the caller
*/
public void setAppProfile(String packageName) {
// Greedy initialization of App Profiles
if (!mInitialisedAppProfiles) {
PackageManager pm = mContext.getPackageManager();
mPbcEnabled = pm.hasSystemFeature(FEATURE_POWER_BUDGET_CONTROL);
mFanCapEnabled = pm.hasSystemFeature(FEATURE_FAN_ON_DEVICE);

Log.w(TAG, "Enabled");
mInitialisedAppProfiles = true;
}

mAppProfile.powerHint(packageName);

Intent intent = new Intent(APP_START_ACTION);
intent.setPackage(APP_START_TARGET_PACKAGE);
intent.putExtra("AppStartId", packageName);
mContext.sendBroadcastAsUser(intent, UserHandle.CURRENT,
"nvidia.permission.READ_APP_START_INFO");
}
}
Loading

0 comments on commit be56102

Please sign in to comment.