Loading apex/jobscheduler/framework/java/com/android/server/usage/AppStandbyInternal.java +2 −0 Original line number Original line Diff line number Diff line Loading @@ -146,6 +146,8 @@ public interface AppStandbyInternal { void setActiveAdminApps(Set<String> adminPkgs, int userId); void setActiveAdminApps(Set<String> adminPkgs, int userId); void setAdminProtectedPackages(Set<String> packageNames, int userId); void onAdminDataAvailable(); void onAdminDataAvailable(); void clearCarrierPrivilegedApps(); void clearCarrierPrivilegedApps(); Loading apex/jobscheduler/service/java/com/android/server/job/JobStore.java +23 −3 Original line number Original line Diff line number Diff line Loading @@ -687,6 +687,10 @@ public final class JobStore { } } } catch (XmlPullParserException | IOException e) { } catch (XmlPullParserException | IOException e) { Slog.wtf(TAG, "Error jobstore xml.", e); Slog.wtf(TAG, "Error jobstore xml.", e); } catch (Exception e) { // Crashing at this point would result in a boot loop, so live with a general // Exception for system stability's sake. Slog.wtf(TAG, "Unexpected exception", e); } finally { } finally { if (mPersistInfo.countAllJobsLoaded < 0) { // Only set them once. if (mPersistInfo.countAllJobsLoaded < 0) { // Only set them once. mPersistInfo.countAllJobsLoaded = numJobs; mPersistInfo.countAllJobsLoaded = numJobs; Loading Loading @@ -817,6 +821,15 @@ public final class JobStore { } catch (NumberFormatException e) { } catch (NumberFormatException e) { Slog.d(TAG, "Error reading constraints, skipping."); Slog.d(TAG, "Error reading constraints, skipping."); return null; return null; } catch (XmlPullParserException e) { Slog.d(TAG, "Error Parser Exception.", e); return null; } catch (IOException e) { Slog.d(TAG, "Error I/O Exception.", e); return null; } catch (IllegalArgumentException e) { Slog.e(TAG, "Constraints contained invalid data", e); return null; } } parser.next(); // Consume </constraints> parser.next(); // Consume </constraints> Loading Loading @@ -912,8 +925,14 @@ public final class JobStore { return null; return null; } } PersistableBundle extras = PersistableBundle.restoreFromXml(parser); final PersistableBundle extras; try { extras = PersistableBundle.restoreFromXml(parser); jobBuilder.setExtras(extras); jobBuilder.setExtras(extras); } catch (IllegalArgumentException e) { Slog.e(TAG, "Persisted extras contained invalid data", e); return null; } parser.nextTag(); // Consume </extras> parser.nextTag(); // Consume </extras> final JobInfo builtJob; final JobInfo builtJob; Loading Loading @@ -959,7 +978,8 @@ public final class JobStore { return new JobInfo.Builder(jobId, cname); return new JobInfo.Builder(jobId, cname); } } private void buildConstraintsFromXml(JobInfo.Builder jobBuilder, XmlPullParser parser) { private void buildConstraintsFromXml(JobInfo.Builder jobBuilder, XmlPullParser parser) throws XmlPullParserException, IOException { String val; String val; final String netCapabilities = parser.getAttributeValue(null, "net-capabilities"); final String netCapabilities = parser.getAttributeValue(null, "net-capabilities"); Loading apex/jobscheduler/service/java/com/android/server/usage/AppStandbyController.java +40 −0 Original line number Original line Diff line number Diff line Loading @@ -233,6 +233,10 @@ public class AppStandbyController implements AppStandbyInternal { @GuardedBy("mActiveAdminApps") @GuardedBy("mActiveAdminApps") private final SparseArray<Set<String>> mActiveAdminApps = new SparseArray<>(); private final SparseArray<Set<String>> mActiveAdminApps = new SparseArray<>(); /** List of admin protected packages. Can contain {@link android.os.UserHandle#USER_ALL}. */ @GuardedBy("mAdminProtectedPackages") private final SparseArray<Set<String>> mAdminProtectedPackages = new SparseArray<>(); /** /** * Set of system apps that are headless (don't have any declared activities, enabled or * Set of system apps that are headless (don't have any declared activities, enabled or * disabled). Presence in this map indicates that the app is a headless system app. * disabled). Presence in this map indicates that the app is a headless system app. Loading Loading @@ -1019,6 +1023,9 @@ public class AppStandbyController implements AppStandbyInternal { synchronized (mActiveAdminApps) { synchronized (mActiveAdminApps) { mActiveAdminApps.remove(userId); mActiveAdminApps.remove(userId); } } synchronized (mAdminProtectedPackages) { mAdminProtectedPackages.remove(userId); } } } } } Loading Loading @@ -1108,6 +1115,10 @@ public class AppStandbyController implements AppStandbyInternal { return STANDBY_BUCKET_EXEMPTED; return STANDBY_BUCKET_EXEMPTED; } } if (isAdminProtectedPackages(packageName, userId)) { return STANDBY_BUCKET_EXEMPTED; } if (isActiveNetworkScorer(packageName)) { if (isActiveNetworkScorer(packageName)) { return STANDBY_BUCKET_EXEMPTED; return STANDBY_BUCKET_EXEMPTED; } } Loading Loading @@ -1510,6 +1521,17 @@ public class AppStandbyController implements AppStandbyInternal { } } } } private boolean isAdminProtectedPackages(String packageName, int userId) { synchronized (mAdminProtectedPackages) { if (mAdminProtectedPackages.contains(UserHandle.USER_ALL) && mAdminProtectedPackages.get(UserHandle.USER_ALL).contains(packageName)) { return true; } return mAdminProtectedPackages.contains(userId) && mAdminProtectedPackages.get(userId).contains(packageName); } } @Override @Override public void addActiveDeviceAdmin(String adminPkg, int userId) { public void addActiveDeviceAdmin(String adminPkg, int userId) { synchronized (mActiveAdminApps) { synchronized (mActiveAdminApps) { Loading @@ -1533,6 +1555,17 @@ public class AppStandbyController implements AppStandbyInternal { } } } } @Override public void setAdminProtectedPackages(Set<String> packageNames, int userId) { synchronized (mAdminProtectedPackages) { if (packageNames == null || packageNames.isEmpty()) { mAdminProtectedPackages.remove(userId); } else { mAdminProtectedPackages.put(userId, packageNames); } } } @Override @Override public void onAdminDataAvailable() { public void onAdminDataAvailable() { mAdminDataAvailableLatch.countDown(); mAdminDataAvailableLatch.countDown(); Loading @@ -1555,6 +1588,13 @@ public class AppStandbyController implements AppStandbyInternal { } } } } @VisibleForTesting Set<String> getAdminProtectedPackagesForTest(int userId) { synchronized (mAdminProtectedPackages) { return mAdminProtectedPackages.get(userId); } } /** /** * Returns {@code true} if the supplied package is the device provisioning app. Otherwise, * Returns {@code true} if the supplied package is the device provisioning app. Otherwise, * returns {@code false}. * returns {@code false}. Loading core/java/android/app/admin/DevicePolicyManager.java +2 −1 Original line number Original line Diff line number Diff line Loading @@ -11996,7 +11996,8 @@ public class DevicePolicyManager { /** /** * Called by Device owner to disable user control over apps. User will not be able to clear * Called by Device owner to disable user control over apps. User will not be able to clear * app data or force-stop packages. * app data or force-stop packages. Packages with user control disabled are exempted from * App Standby Buckets. * * * @param admin which {@link DeviceAdminReceiver} this request is associated with * @param admin which {@link DeviceAdminReceiver} this request is associated with * @param packages The package names for the apps. * @param packages The package names for the apps. core/java/android/appwidget/AppWidgetHostView.java +29 −10 Original line number Original line Diff line number Diff line Loading @@ -28,6 +28,7 @@ import android.content.pm.LauncherActivityInfo; import android.content.pm.LauncherApps; import android.content.pm.LauncherApps; import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.PackageManager.NameNotFoundException; import android.content.res.Resources; import android.content.res.Resources; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Color; import android.graphics.Rect; import android.graphics.Rect; import android.os.Bundle; import android.os.Bundle; Loading Loading @@ -250,6 +251,14 @@ public class AppWidgetHostView extends FrameLayout { super.onLayout(changed, left, top, right, bottom); super.onLayout(changed, left, top, right, bottom); } catch (final RuntimeException e) { } catch (final RuntimeException e) { Log.e(TAG, "Remote provider threw runtime exception, using error view instead.", e); Log.e(TAG, "Remote provider threw runtime exception, using error view instead.", e); handleViewError(); } } /** * Remove bad view and replace with error message view */ private void handleViewError() { removeViewInLayout(mView); removeViewInLayout(mView); View child = getErrorView(); View child = getErrorView(); prepareView(child); prepareView(child); Loading @@ -261,7 +270,6 @@ public class AppWidgetHostView extends FrameLayout { mView = child; mView = child; mViewMode = VIEW_MODE_ERROR; mViewMode = VIEW_MODE_ERROR; } } } /** /** * Provide guidance about the size of this widget to the AppWidgetManager. The widths and * Provide guidance about the size of this widget to the AppWidgetManager. The widths and Loading Loading @@ -725,4 +733,15 @@ public class AppWidgetHostView extends FrameLayout { } } }; }; } } @Override protected void dispatchDraw(Canvas canvas) { try { super.dispatchDraw(canvas); } catch (Exception e) { // Catch draw exceptions that may be caused by RemoteViews Log.e(TAG, "Drawing view failed: " + e); post(this::handleViewError); } } } } Loading
apex/jobscheduler/framework/java/com/android/server/usage/AppStandbyInternal.java +2 −0 Original line number Original line Diff line number Diff line Loading @@ -146,6 +146,8 @@ public interface AppStandbyInternal { void setActiveAdminApps(Set<String> adminPkgs, int userId); void setActiveAdminApps(Set<String> adminPkgs, int userId); void setAdminProtectedPackages(Set<String> packageNames, int userId); void onAdminDataAvailable(); void onAdminDataAvailable(); void clearCarrierPrivilegedApps(); void clearCarrierPrivilegedApps(); Loading
apex/jobscheduler/service/java/com/android/server/job/JobStore.java +23 −3 Original line number Original line Diff line number Diff line Loading @@ -687,6 +687,10 @@ public final class JobStore { } } } catch (XmlPullParserException | IOException e) { } catch (XmlPullParserException | IOException e) { Slog.wtf(TAG, "Error jobstore xml.", e); Slog.wtf(TAG, "Error jobstore xml.", e); } catch (Exception e) { // Crashing at this point would result in a boot loop, so live with a general // Exception for system stability's sake. Slog.wtf(TAG, "Unexpected exception", e); } finally { } finally { if (mPersistInfo.countAllJobsLoaded < 0) { // Only set them once. if (mPersistInfo.countAllJobsLoaded < 0) { // Only set them once. mPersistInfo.countAllJobsLoaded = numJobs; mPersistInfo.countAllJobsLoaded = numJobs; Loading Loading @@ -817,6 +821,15 @@ public final class JobStore { } catch (NumberFormatException e) { } catch (NumberFormatException e) { Slog.d(TAG, "Error reading constraints, skipping."); Slog.d(TAG, "Error reading constraints, skipping."); return null; return null; } catch (XmlPullParserException e) { Slog.d(TAG, "Error Parser Exception.", e); return null; } catch (IOException e) { Slog.d(TAG, "Error I/O Exception.", e); return null; } catch (IllegalArgumentException e) { Slog.e(TAG, "Constraints contained invalid data", e); return null; } } parser.next(); // Consume </constraints> parser.next(); // Consume </constraints> Loading Loading @@ -912,8 +925,14 @@ public final class JobStore { return null; return null; } } PersistableBundle extras = PersistableBundle.restoreFromXml(parser); final PersistableBundle extras; try { extras = PersistableBundle.restoreFromXml(parser); jobBuilder.setExtras(extras); jobBuilder.setExtras(extras); } catch (IllegalArgumentException e) { Slog.e(TAG, "Persisted extras contained invalid data", e); return null; } parser.nextTag(); // Consume </extras> parser.nextTag(); // Consume </extras> final JobInfo builtJob; final JobInfo builtJob; Loading Loading @@ -959,7 +978,8 @@ public final class JobStore { return new JobInfo.Builder(jobId, cname); return new JobInfo.Builder(jobId, cname); } } private void buildConstraintsFromXml(JobInfo.Builder jobBuilder, XmlPullParser parser) { private void buildConstraintsFromXml(JobInfo.Builder jobBuilder, XmlPullParser parser) throws XmlPullParserException, IOException { String val; String val; final String netCapabilities = parser.getAttributeValue(null, "net-capabilities"); final String netCapabilities = parser.getAttributeValue(null, "net-capabilities"); Loading
apex/jobscheduler/service/java/com/android/server/usage/AppStandbyController.java +40 −0 Original line number Original line Diff line number Diff line Loading @@ -233,6 +233,10 @@ public class AppStandbyController implements AppStandbyInternal { @GuardedBy("mActiveAdminApps") @GuardedBy("mActiveAdminApps") private final SparseArray<Set<String>> mActiveAdminApps = new SparseArray<>(); private final SparseArray<Set<String>> mActiveAdminApps = new SparseArray<>(); /** List of admin protected packages. Can contain {@link android.os.UserHandle#USER_ALL}. */ @GuardedBy("mAdminProtectedPackages") private final SparseArray<Set<String>> mAdminProtectedPackages = new SparseArray<>(); /** /** * Set of system apps that are headless (don't have any declared activities, enabled or * Set of system apps that are headless (don't have any declared activities, enabled or * disabled). Presence in this map indicates that the app is a headless system app. * disabled). Presence in this map indicates that the app is a headless system app. Loading Loading @@ -1019,6 +1023,9 @@ public class AppStandbyController implements AppStandbyInternal { synchronized (mActiveAdminApps) { synchronized (mActiveAdminApps) { mActiveAdminApps.remove(userId); mActiveAdminApps.remove(userId); } } synchronized (mAdminProtectedPackages) { mAdminProtectedPackages.remove(userId); } } } } } Loading Loading @@ -1108,6 +1115,10 @@ public class AppStandbyController implements AppStandbyInternal { return STANDBY_BUCKET_EXEMPTED; return STANDBY_BUCKET_EXEMPTED; } } if (isAdminProtectedPackages(packageName, userId)) { return STANDBY_BUCKET_EXEMPTED; } if (isActiveNetworkScorer(packageName)) { if (isActiveNetworkScorer(packageName)) { return STANDBY_BUCKET_EXEMPTED; return STANDBY_BUCKET_EXEMPTED; } } Loading Loading @@ -1510,6 +1521,17 @@ public class AppStandbyController implements AppStandbyInternal { } } } } private boolean isAdminProtectedPackages(String packageName, int userId) { synchronized (mAdminProtectedPackages) { if (mAdminProtectedPackages.contains(UserHandle.USER_ALL) && mAdminProtectedPackages.get(UserHandle.USER_ALL).contains(packageName)) { return true; } return mAdminProtectedPackages.contains(userId) && mAdminProtectedPackages.get(userId).contains(packageName); } } @Override @Override public void addActiveDeviceAdmin(String adminPkg, int userId) { public void addActiveDeviceAdmin(String adminPkg, int userId) { synchronized (mActiveAdminApps) { synchronized (mActiveAdminApps) { Loading @@ -1533,6 +1555,17 @@ public class AppStandbyController implements AppStandbyInternal { } } } } @Override public void setAdminProtectedPackages(Set<String> packageNames, int userId) { synchronized (mAdminProtectedPackages) { if (packageNames == null || packageNames.isEmpty()) { mAdminProtectedPackages.remove(userId); } else { mAdminProtectedPackages.put(userId, packageNames); } } } @Override @Override public void onAdminDataAvailable() { public void onAdminDataAvailable() { mAdminDataAvailableLatch.countDown(); mAdminDataAvailableLatch.countDown(); Loading @@ -1555,6 +1588,13 @@ public class AppStandbyController implements AppStandbyInternal { } } } } @VisibleForTesting Set<String> getAdminProtectedPackagesForTest(int userId) { synchronized (mAdminProtectedPackages) { return mAdminProtectedPackages.get(userId); } } /** /** * Returns {@code true} if the supplied package is the device provisioning app. Otherwise, * Returns {@code true} if the supplied package is the device provisioning app. Otherwise, * returns {@code false}. * returns {@code false}. Loading
core/java/android/app/admin/DevicePolicyManager.java +2 −1 Original line number Original line Diff line number Diff line Loading @@ -11996,7 +11996,8 @@ public class DevicePolicyManager { /** /** * Called by Device owner to disable user control over apps. User will not be able to clear * Called by Device owner to disable user control over apps. User will not be able to clear * app data or force-stop packages. * app data or force-stop packages. Packages with user control disabled are exempted from * App Standby Buckets. * * * @param admin which {@link DeviceAdminReceiver} this request is associated with * @param admin which {@link DeviceAdminReceiver} this request is associated with * @param packages The package names for the apps. * @param packages The package names for the apps.
core/java/android/appwidget/AppWidgetHostView.java +29 −10 Original line number Original line Diff line number Diff line Loading @@ -28,6 +28,7 @@ import android.content.pm.LauncherActivityInfo; import android.content.pm.LauncherApps; import android.content.pm.LauncherApps; import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.PackageManager.NameNotFoundException; import android.content.res.Resources; import android.content.res.Resources; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Color; import android.graphics.Rect; import android.graphics.Rect; import android.os.Bundle; import android.os.Bundle; Loading Loading @@ -250,6 +251,14 @@ public class AppWidgetHostView extends FrameLayout { super.onLayout(changed, left, top, right, bottom); super.onLayout(changed, left, top, right, bottom); } catch (final RuntimeException e) { } catch (final RuntimeException e) { Log.e(TAG, "Remote provider threw runtime exception, using error view instead.", e); Log.e(TAG, "Remote provider threw runtime exception, using error view instead.", e); handleViewError(); } } /** * Remove bad view and replace with error message view */ private void handleViewError() { removeViewInLayout(mView); removeViewInLayout(mView); View child = getErrorView(); View child = getErrorView(); prepareView(child); prepareView(child); Loading @@ -261,7 +270,6 @@ public class AppWidgetHostView extends FrameLayout { mView = child; mView = child; mViewMode = VIEW_MODE_ERROR; mViewMode = VIEW_MODE_ERROR; } } } /** /** * Provide guidance about the size of this widget to the AppWidgetManager. The widths and * Provide guidance about the size of this widget to the AppWidgetManager. The widths and Loading Loading @@ -725,4 +733,15 @@ public class AppWidgetHostView extends FrameLayout { } } }; }; } } @Override protected void dispatchDraw(Canvas canvas) { try { super.dispatchDraw(canvas); } catch (Exception e) { // Catch draw exceptions that may be caused by RemoteViews Log.e(TAG, "Drawing view failed: " + e); post(this::handleViewError); } } } }