Loading Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -456,6 +456,7 @@ java_defaults { "core/java/com/android/internal/widget/ICheckCredentialProgressCallback.aidl", "core/java/com/android/internal/widget/ILockSettings.aidl", "core/java/com/android/internal/widget/IRemoteViewsFactory.aidl", "core/java/com/nvidia/NvCPLSvc/INvCPLRemoteService.aidl", "keystore/java/android/security/IKeyChainAliasCallback.aidl", "keystore/java/android/security/IKeyChainService.aidl", "location/java/android/location/IBatchedLocationCallback.aidl", Loading core/java/android/app/ApplicationPackageManager.java +12 −0 Original line number Diff line number Diff line Loading @@ -101,6 +101,8 @@ import com.android.internal.os.SomeArgs; import com.android.internal.util.Preconditions; import com.android.internal.util.UserIcons; import com.nvidia.NvAppProfileService; import dalvik.system.VMRuntime; import libcore.util.EmptyArray; Loading Loading @@ -130,6 +132,7 @@ public class ApplicationPackageManager extends PackageManager { private UserManager mUserManager; @GuardedBy("mLock") private PackageInstaller mInstaller; private NvAppProfileService mAppProfileService; @GuardedBy("mLock") private ArtManager mArtManager; Loading Loading @@ -389,6 +392,15 @@ public class ApplicationPackageManager extends PackageManager { } } /** @hide */ @Override public NvAppProfileService getAppProfileService() { if (mAppProfileService == null) { mAppProfileService = new NvAppProfileService(mContext); } return mAppProfileService; } @Override public ApplicationInfo getApplicationInfo(String packageName, int flags) throws NameNotFoundException { Loading core/java/android/content/pm/PackageManager.java +5 −0 Original line number Diff line number Diff line Loading @@ -64,6 +64,8 @@ import android.util.Log; import com.android.internal.util.ArrayUtils; import com.nvidia.NvAppProfileService; import dalvik.system.VMRuntime; import java.io.File; Loading Loading @@ -3643,6 +3645,9 @@ public abstract class PackageManager { 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. Loading core/java/android/content/pm/PackageParser.java +7 −0 Original line number Diff line number Diff line Loading @@ -107,6 +107,8 @@ import com.android.internal.util.ArrayUtils; import com.android.internal.util.XmlUtils; import com.android.server.SystemConfig; import com.nvidia.NvAppProfileService; import libcore.io.IoUtils; import libcore.util.EmptyArray; Loading Loading @@ -575,6 +577,7 @@ public class PackageParser { * a package. */ public interface Callback { NvAppProfileService getAppProfileService(); boolean hasFeature(String feature); String[] getOverlayPaths(String targetPackageName, String targetPath); String[] getOverlayApks(String targetPackageName); Loading @@ -591,6 +594,10 @@ public class PackageParser { mPm = pm; } @Override public NvAppProfileService getAppProfileService() { return mPm.getAppProfileService(); } @Override public boolean hasFeature(String feature) { return mPm.hasSystemFeature(feature); } Loading core/java/com/nvidia/NvAppProfileService.java 0 → 100644 +246 −0 Original line number Diff line number Diff line /* * 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
Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -456,6 +456,7 @@ java_defaults { "core/java/com/android/internal/widget/ICheckCredentialProgressCallback.aidl", "core/java/com/android/internal/widget/ILockSettings.aidl", "core/java/com/android/internal/widget/IRemoteViewsFactory.aidl", "core/java/com/nvidia/NvCPLSvc/INvCPLRemoteService.aidl", "keystore/java/android/security/IKeyChainAliasCallback.aidl", "keystore/java/android/security/IKeyChainService.aidl", "location/java/android/location/IBatchedLocationCallback.aidl", Loading
core/java/android/app/ApplicationPackageManager.java +12 −0 Original line number Diff line number Diff line Loading @@ -101,6 +101,8 @@ import com.android.internal.os.SomeArgs; import com.android.internal.util.Preconditions; import com.android.internal.util.UserIcons; import com.nvidia.NvAppProfileService; import dalvik.system.VMRuntime; import libcore.util.EmptyArray; Loading Loading @@ -130,6 +132,7 @@ public class ApplicationPackageManager extends PackageManager { private UserManager mUserManager; @GuardedBy("mLock") private PackageInstaller mInstaller; private NvAppProfileService mAppProfileService; @GuardedBy("mLock") private ArtManager mArtManager; Loading Loading @@ -389,6 +392,15 @@ public class ApplicationPackageManager extends PackageManager { } } /** @hide */ @Override public NvAppProfileService getAppProfileService() { if (mAppProfileService == null) { mAppProfileService = new NvAppProfileService(mContext); } return mAppProfileService; } @Override public ApplicationInfo getApplicationInfo(String packageName, int flags) throws NameNotFoundException { Loading
core/java/android/content/pm/PackageManager.java +5 −0 Original line number Diff line number Diff line Loading @@ -64,6 +64,8 @@ import android.util.Log; import com.android.internal.util.ArrayUtils; import com.nvidia.NvAppProfileService; import dalvik.system.VMRuntime; import java.io.File; Loading Loading @@ -3643,6 +3645,9 @@ public abstract class PackageManager { 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. Loading
core/java/android/content/pm/PackageParser.java +7 −0 Original line number Diff line number Diff line Loading @@ -107,6 +107,8 @@ import com.android.internal.util.ArrayUtils; import com.android.internal.util.XmlUtils; import com.android.server.SystemConfig; import com.nvidia.NvAppProfileService; import libcore.io.IoUtils; import libcore.util.EmptyArray; Loading Loading @@ -575,6 +577,7 @@ public class PackageParser { * a package. */ public interface Callback { NvAppProfileService getAppProfileService(); boolean hasFeature(String feature); String[] getOverlayPaths(String targetPackageName, String targetPath); String[] getOverlayApks(String targetPackageName); Loading @@ -591,6 +594,10 @@ public class PackageParser { mPm = pm; } @Override public NvAppProfileService getAppProfileService() { return mPm.getAppProfileService(); } @Override public boolean hasFeature(String feature) { return mPm.hasSystemFeature(feature); } Loading
core/java/com/nvidia/NvAppProfileService.java 0 → 100644 +246 −0 Original line number Diff line number Diff line /* * 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"); } }