Loading packages/SettingsLib/Tile/src/com/android/settingslib/drawer/MasterSwitchController.java→packages/SettingsLib/Tile/src/com/android/settingslib/drawer/PrimarySwitchController.java +2 −2 Original line number Diff line number Diff line Loading @@ -19,9 +19,9 @@ package com.android.settingslib.drawer; import android.os.Bundle; /** * A controller that manages event for master switch. * A controller that manages event for Primary switch. */ public abstract class MasterSwitchController extends SwitchController { public abstract class PrimarySwitchController extends SwitchController { @Override protected final MetaData getMetaData() { Loading packages/SettingsLib/Tile/src/com/android/settingslib/drawer/SwitchesProvider.java +2 −2 Original line number Diff line number Diff line Loading @@ -88,7 +88,7 @@ public abstract class SwitchesProvider extends ContentProvider { controller.setAuthority(mAuthority); mControllerMap.put(key, controller); if (!(controller instanceof MasterSwitchController)) { if (!(controller instanceof PrimarySwitchController)) { mSwitchDataList.add(controller.getBundle()); } }); Loading Loading @@ -116,7 +116,7 @@ public abstract class SwitchesProvider extends ContentProvider { switch (method) { case METHOD_GET_SWITCH_DATA: if (!(controller instanceof MasterSwitchController)) { if (!(controller instanceof PrimarySwitchController)) { return controller.getBundle(); } break; Loading packages/SettingsLib/src/com/android/settingslib/development/DeveloperOptionsPreferenceController.java +1 −1 Original line number Diff line number Diff line Loading @@ -24,7 +24,7 @@ import androidx.preference.PreferenceScreen; import com.android.settingslib.core.AbstractPreferenceController; /** * This controller is used handle changes for the master switch in the developer options page. * This controller is used handle changes for the primary switch in the developer options page. * * All Preference Controllers that are a part of the developer options page should inherit this * class. Loading packages/SettingsLib/src/com/android/settingslib/fuelgauge/PowerWhitelistBackend.java→packages/SettingsLib/src/com/android/settingslib/fuelgauge/PowerAllowlistBackend.java +55 −29 Original line number Diff line number Diff line Loading @@ -34,44 +34,50 @@ import com.android.internal.telephony.SmsApplication; import com.android.internal.util.ArrayUtils; /** * Handles getting/changing the whitelist for the exceptions to battery saving features. * Handles getting/changing the allowlist for the exceptions to battery saving features. */ public class PowerWhitelistBackend { public class PowerAllowlistBackend { private static final String TAG = "PowerWhitelistBackend"; private static final String TAG = "PowerAllowlistBackend"; private static final String DEVICE_IDLE_SERVICE = "deviceidle"; private static PowerWhitelistBackend sInstance; private static PowerAllowlistBackend sInstance; private final Context mAppContext; private final IDeviceIdleController mDeviceIdleService; private final ArraySet<String> mWhitelistedApps = new ArraySet<>(); private final ArraySet<String> mSysWhitelistedApps = new ArraySet<>(); private final ArraySet<String> mAllowlistedApps = new ArraySet<>(); private final ArraySet<String> mSysAllowlistedApps = new ArraySet<>(); private final ArraySet<String> mDefaultActiveApps = new ArraySet<>(); public PowerWhitelistBackend(Context context) { public PowerAllowlistBackend(Context context) { this(context, IDeviceIdleController.Stub.asInterface( ServiceManager.getService(DEVICE_IDLE_SERVICE))); } @VisibleForTesting PowerWhitelistBackend(Context context, IDeviceIdleController deviceIdleService) { PowerAllowlistBackend(Context context, IDeviceIdleController deviceIdleService) { mAppContext = context.getApplicationContext(); mDeviceIdleService = deviceIdleService; refreshList(); } public int getWhitelistSize() { return mWhitelistedApps.size(); public int getAllowlistSize() { return mAllowlistedApps.size(); } public boolean isSysWhitelisted(String pkg) { return mSysWhitelistedApps.contains(pkg); /** * Check if target package is in System allow list */ public boolean isSysAllowlisted(String pkg) { return mSysAllowlistedApps.contains(pkg); } public boolean isWhitelisted(String pkg) { if (mWhitelistedApps.contains(pkg)) { /** * Check if target package is in allow list */ public boolean isAllowlisted(String pkg) { if (mAllowlistedApps.contains(pkg)) { return true; } Loading @@ -87,7 +93,7 @@ public class PowerWhitelistBackend { */ public boolean isDefaultActiveApp(String pkg) { // Additionally, check if pkg is default dialer/sms. They are considered essential apps and // should be automatically whitelisted (otherwise user may be able to set restriction on // should be automatically allowlisted (otherwise user may be able to set restriction on // them, leading to bad device behavior.) if (mDefaultActiveApps.contains(pkg)) { Loading @@ -103,12 +109,17 @@ public class PowerWhitelistBackend { return false; } public boolean isWhitelisted(String[] pkgs) { /** * * @param pkgs a list of packageName * @return true when one of package is in allow list */ public boolean isAllowlisted(String[] pkgs) { if (ArrayUtils.isEmpty(pkgs)) { return false; } for (String pkg : pkgs) { if (isWhitelisted(pkg)) { if (isAllowlisted(pkg)) { return true; } } Loading @@ -116,40 +127,51 @@ public class PowerWhitelistBackend { return false; } /** * Add app into power save allow list. * @param pkg packageName */ public void addApp(String pkg) { try { mDeviceIdleService.addPowerSaveWhitelistApp(pkg); mWhitelistedApps.add(pkg); mAllowlistedApps.add(pkg); } catch (RemoteException e) { Log.w(TAG, "Unable to reach IDeviceIdleController", e); } } /** * Remove package from power save allow list. * @param pkg */ public void removeApp(String pkg) { try { mDeviceIdleService.removePowerSaveWhitelistApp(pkg); mWhitelistedApps.remove(pkg); mAllowlistedApps.remove(pkg); } catch (RemoteException e) { Log.w(TAG, "Unable to reach IDeviceIdleController", e); } } /** * Refresh all of lists */ @VisibleForTesting public void refreshList() { mSysWhitelistedApps.clear(); mWhitelistedApps.clear(); mSysAllowlistedApps.clear(); mAllowlistedApps.clear(); mDefaultActiveApps.clear(); if (mDeviceIdleService == null) { return; } try { final String[] whitelistedApps = mDeviceIdleService.getFullPowerWhitelist(); for (String app : whitelistedApps) { mWhitelistedApps.add(app); final String[] allowlistedApps = mDeviceIdleService.getFullPowerWhitelist(); for (String app : allowlistedApps) { mAllowlistedApps.add(app); } final String[] sysWhitelistedApps = mDeviceIdleService.getSystemPowerWhitelist(); for (String app : sysWhitelistedApps) { mSysWhitelistedApps.add(app); final String[] sysAllowlistedApps = mDeviceIdleService.getSystemPowerWhitelist(); for (String app : sysAllowlistedApps) { mSysAllowlistedApps.add(app); } final boolean hasTelephony = mAppContext.getPackageManager().hasSystemFeature( PackageManager.FEATURE_TELEPHONY); Loading @@ -171,9 +193,13 @@ public class PowerWhitelistBackend { } } public static PowerWhitelistBackend getInstance(Context context) { /** * @param context * @return a PowerAllowlistBackend object */ public static PowerAllowlistBackend getInstance(Context context) { if (sInstance == null) { sInstance = new PowerWhitelistBackend(context); sInstance = new PowerAllowlistBackend(context); } return sInstance; } Loading packages/SettingsLib/src/com/android/settingslib/users/AppRestrictionsHelper.java +5 −5 Original line number Diff line number Diff line Loading @@ -135,7 +135,7 @@ public class AppRestrictionsHelper { // Ignore } } else { // Blacklist all other apps, system or downloaded // Denylist all other apps, system or downloaded try { ApplicationInfo info = mIPm.getApplicationInfo(packageName, 0, userId); if (info != null) { Loading Loading @@ -258,11 +258,11 @@ public class AppRestrictionsHelper { } } // Establish master/slave relationship for entries that share a package name // Establish primary/secondary relationship for entries that share a package name HashMap<String,SelectableAppInfo> packageMap = new HashMap<String,SelectableAppInfo>(); for (SelectableAppInfo info : mVisibleApps) { if (packageMap.containsKey(info.packageName)) { info.masterEntry = packageMap.get(info.packageName); info.primaryEntry = packageMap.get(info.packageName); } else { packageMap.put(info.packageName, info); } Loading Loading @@ -366,12 +366,12 @@ public class AppRestrictionsHelper { public CharSequence appName; public CharSequence activityName; public Drawable icon; public SelectableAppInfo masterEntry; public SelectableAppInfo primaryEntry; @Override public String toString() { return packageName + ": appName=" + appName + "; activityName=" + activityName + "; icon=" + icon + "; masterEntry=" + masterEntry; + "; icon=" + icon + "; primaryEntry=" + primaryEntry; } } Loading Loading
packages/SettingsLib/Tile/src/com/android/settingslib/drawer/MasterSwitchController.java→packages/SettingsLib/Tile/src/com/android/settingslib/drawer/PrimarySwitchController.java +2 −2 Original line number Diff line number Diff line Loading @@ -19,9 +19,9 @@ package com.android.settingslib.drawer; import android.os.Bundle; /** * A controller that manages event for master switch. * A controller that manages event for Primary switch. */ public abstract class MasterSwitchController extends SwitchController { public abstract class PrimarySwitchController extends SwitchController { @Override protected final MetaData getMetaData() { Loading
packages/SettingsLib/Tile/src/com/android/settingslib/drawer/SwitchesProvider.java +2 −2 Original line number Diff line number Diff line Loading @@ -88,7 +88,7 @@ public abstract class SwitchesProvider extends ContentProvider { controller.setAuthority(mAuthority); mControllerMap.put(key, controller); if (!(controller instanceof MasterSwitchController)) { if (!(controller instanceof PrimarySwitchController)) { mSwitchDataList.add(controller.getBundle()); } }); Loading Loading @@ -116,7 +116,7 @@ public abstract class SwitchesProvider extends ContentProvider { switch (method) { case METHOD_GET_SWITCH_DATA: if (!(controller instanceof MasterSwitchController)) { if (!(controller instanceof PrimarySwitchController)) { return controller.getBundle(); } break; Loading
packages/SettingsLib/src/com/android/settingslib/development/DeveloperOptionsPreferenceController.java +1 −1 Original line number Diff line number Diff line Loading @@ -24,7 +24,7 @@ import androidx.preference.PreferenceScreen; import com.android.settingslib.core.AbstractPreferenceController; /** * This controller is used handle changes for the master switch in the developer options page. * This controller is used handle changes for the primary switch in the developer options page. * * All Preference Controllers that are a part of the developer options page should inherit this * class. Loading
packages/SettingsLib/src/com/android/settingslib/fuelgauge/PowerWhitelistBackend.java→packages/SettingsLib/src/com/android/settingslib/fuelgauge/PowerAllowlistBackend.java +55 −29 Original line number Diff line number Diff line Loading @@ -34,44 +34,50 @@ import com.android.internal.telephony.SmsApplication; import com.android.internal.util.ArrayUtils; /** * Handles getting/changing the whitelist for the exceptions to battery saving features. * Handles getting/changing the allowlist for the exceptions to battery saving features. */ public class PowerWhitelistBackend { public class PowerAllowlistBackend { private static final String TAG = "PowerWhitelistBackend"; private static final String TAG = "PowerAllowlistBackend"; private static final String DEVICE_IDLE_SERVICE = "deviceidle"; private static PowerWhitelistBackend sInstance; private static PowerAllowlistBackend sInstance; private final Context mAppContext; private final IDeviceIdleController mDeviceIdleService; private final ArraySet<String> mWhitelistedApps = new ArraySet<>(); private final ArraySet<String> mSysWhitelistedApps = new ArraySet<>(); private final ArraySet<String> mAllowlistedApps = new ArraySet<>(); private final ArraySet<String> mSysAllowlistedApps = new ArraySet<>(); private final ArraySet<String> mDefaultActiveApps = new ArraySet<>(); public PowerWhitelistBackend(Context context) { public PowerAllowlistBackend(Context context) { this(context, IDeviceIdleController.Stub.asInterface( ServiceManager.getService(DEVICE_IDLE_SERVICE))); } @VisibleForTesting PowerWhitelistBackend(Context context, IDeviceIdleController deviceIdleService) { PowerAllowlistBackend(Context context, IDeviceIdleController deviceIdleService) { mAppContext = context.getApplicationContext(); mDeviceIdleService = deviceIdleService; refreshList(); } public int getWhitelistSize() { return mWhitelistedApps.size(); public int getAllowlistSize() { return mAllowlistedApps.size(); } public boolean isSysWhitelisted(String pkg) { return mSysWhitelistedApps.contains(pkg); /** * Check if target package is in System allow list */ public boolean isSysAllowlisted(String pkg) { return mSysAllowlistedApps.contains(pkg); } public boolean isWhitelisted(String pkg) { if (mWhitelistedApps.contains(pkg)) { /** * Check if target package is in allow list */ public boolean isAllowlisted(String pkg) { if (mAllowlistedApps.contains(pkg)) { return true; } Loading @@ -87,7 +93,7 @@ public class PowerWhitelistBackend { */ public boolean isDefaultActiveApp(String pkg) { // Additionally, check if pkg is default dialer/sms. They are considered essential apps and // should be automatically whitelisted (otherwise user may be able to set restriction on // should be automatically allowlisted (otherwise user may be able to set restriction on // them, leading to bad device behavior.) if (mDefaultActiveApps.contains(pkg)) { Loading @@ -103,12 +109,17 @@ public class PowerWhitelistBackend { return false; } public boolean isWhitelisted(String[] pkgs) { /** * * @param pkgs a list of packageName * @return true when one of package is in allow list */ public boolean isAllowlisted(String[] pkgs) { if (ArrayUtils.isEmpty(pkgs)) { return false; } for (String pkg : pkgs) { if (isWhitelisted(pkg)) { if (isAllowlisted(pkg)) { return true; } } Loading @@ -116,40 +127,51 @@ public class PowerWhitelistBackend { return false; } /** * Add app into power save allow list. * @param pkg packageName */ public void addApp(String pkg) { try { mDeviceIdleService.addPowerSaveWhitelistApp(pkg); mWhitelistedApps.add(pkg); mAllowlistedApps.add(pkg); } catch (RemoteException e) { Log.w(TAG, "Unable to reach IDeviceIdleController", e); } } /** * Remove package from power save allow list. * @param pkg */ public void removeApp(String pkg) { try { mDeviceIdleService.removePowerSaveWhitelistApp(pkg); mWhitelistedApps.remove(pkg); mAllowlistedApps.remove(pkg); } catch (RemoteException e) { Log.w(TAG, "Unable to reach IDeviceIdleController", e); } } /** * Refresh all of lists */ @VisibleForTesting public void refreshList() { mSysWhitelistedApps.clear(); mWhitelistedApps.clear(); mSysAllowlistedApps.clear(); mAllowlistedApps.clear(); mDefaultActiveApps.clear(); if (mDeviceIdleService == null) { return; } try { final String[] whitelistedApps = mDeviceIdleService.getFullPowerWhitelist(); for (String app : whitelistedApps) { mWhitelistedApps.add(app); final String[] allowlistedApps = mDeviceIdleService.getFullPowerWhitelist(); for (String app : allowlistedApps) { mAllowlistedApps.add(app); } final String[] sysWhitelistedApps = mDeviceIdleService.getSystemPowerWhitelist(); for (String app : sysWhitelistedApps) { mSysWhitelistedApps.add(app); final String[] sysAllowlistedApps = mDeviceIdleService.getSystemPowerWhitelist(); for (String app : sysAllowlistedApps) { mSysAllowlistedApps.add(app); } final boolean hasTelephony = mAppContext.getPackageManager().hasSystemFeature( PackageManager.FEATURE_TELEPHONY); Loading @@ -171,9 +193,13 @@ public class PowerWhitelistBackend { } } public static PowerWhitelistBackend getInstance(Context context) { /** * @param context * @return a PowerAllowlistBackend object */ public static PowerAllowlistBackend getInstance(Context context) { if (sInstance == null) { sInstance = new PowerWhitelistBackend(context); sInstance = new PowerAllowlistBackend(context); } return sInstance; } Loading
packages/SettingsLib/src/com/android/settingslib/users/AppRestrictionsHelper.java +5 −5 Original line number Diff line number Diff line Loading @@ -135,7 +135,7 @@ public class AppRestrictionsHelper { // Ignore } } else { // Blacklist all other apps, system or downloaded // Denylist all other apps, system or downloaded try { ApplicationInfo info = mIPm.getApplicationInfo(packageName, 0, userId); if (info != null) { Loading Loading @@ -258,11 +258,11 @@ public class AppRestrictionsHelper { } } // Establish master/slave relationship for entries that share a package name // Establish primary/secondary relationship for entries that share a package name HashMap<String,SelectableAppInfo> packageMap = new HashMap<String,SelectableAppInfo>(); for (SelectableAppInfo info : mVisibleApps) { if (packageMap.containsKey(info.packageName)) { info.masterEntry = packageMap.get(info.packageName); info.primaryEntry = packageMap.get(info.packageName); } else { packageMap.put(info.packageName, info); } Loading Loading @@ -366,12 +366,12 @@ public class AppRestrictionsHelper { public CharSequence appName; public CharSequence activityName; public Drawable icon; public SelectableAppInfo masterEntry; public SelectableAppInfo primaryEntry; @Override public String toString() { return packageName + ": appName=" + appName + "; activityName=" + activityName + "; icon=" + icon + "; masterEntry=" + masterEntry; + "; icon=" + icon + "; primaryEntry=" + primaryEntry; } } Loading