Loading apex/jobscheduler/framework/java/com/android/server/usage/AppStandbyInternal.java +2 −0 Original line number Diff line number Diff line Loading @@ -157,6 +157,8 @@ public interface AppStandbyInternal { void setActiveAdminApps(Set<String> adminPkgs, int userId); void setAdminProtectedPackages(Set<String> packageNames, int userId); void onAdminDataAvailable(); void clearCarrierPrivilegedApps(); Loading apex/jobscheduler/service/java/com/android/server/job/JobStore.java +15 −2 Original line number Diff line number Diff line Loading @@ -733,6 +733,10 @@ public final class JobStore { } } catch (XmlPullParserException | IOException 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 { if (mPersistInfo.countAllJobsLoaded < 0) { // Only set them once. mPersistInfo.countAllJobsLoaded = numJobs; Loading Loading @@ -869,6 +873,9 @@ public final class JobStore { } 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> Loading Loading @@ -965,8 +972,14 @@ public final class JobStore { return null; } PersistableBundle extras = PersistableBundle.restoreFromXml(parser); final PersistableBundle extras; try { extras = PersistableBundle.restoreFromXml(parser); jobBuilder.setExtras(extras); } catch (IllegalArgumentException e) { Slog.e(TAG, "Persisted extras contained invalid data", e); return null; } parser.nextTag(); // Consume </extras> final JobInfo builtJob; Loading apex/jobscheduler/service/java/com/android/server/usage/AppStandbyController.java +40 −0 Original line number Diff line number Diff line Loading @@ -247,6 +247,10 @@ public class AppStandbyController @GuardedBy("mActiveAdminApps") 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 * disabled). Presence in this map indicates that the app is a headless system app. Loading Loading @@ -1088,6 +1092,9 @@ public class AppStandbyController synchronized (mActiveAdminApps) { mActiveAdminApps.remove(userId); } synchronized (mAdminProtectedPackages) { mAdminProtectedPackages.remove(userId); } } } Loading Loading @@ -1177,6 +1184,10 @@ public class AppStandbyController return STANDBY_BUCKET_EXEMPTED; } if (isAdminProtectedPackages(packageName, userId)) { return STANDBY_BUCKET_EXEMPTED; } if (isActiveNetworkScorer(packageName)) { return STANDBY_BUCKET_EXEMPTED; } Loading Loading @@ -1583,6 +1594,17 @@ public class AppStandbyController } } 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 public void addActiveDeviceAdmin(String adminPkg, int userId) { synchronized (mActiveAdminApps) { Loading @@ -1606,6 +1628,17 @@ public class AppStandbyController } } @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 public void onAdminDataAvailable() { mAdminDataAvailableLatch.countDown(); Loading @@ -1628,6 +1661,13 @@ public class AppStandbyController } } @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 false}. Loading core/java/android/app/admin/DevicePolicyManager.java +2 −1 Original line number Diff line number Diff line Loading @@ -13573,7 +13573,8 @@ public class DevicePolicyManager { /** * 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 packages The package names for the apps. core/java/android/appwidget/AppWidgetHostView.java +29 −10 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import android.content.pm.LauncherActivityInfo; import android.content.pm.LauncherApps; import android.content.pm.PackageManager.NameNotFoundException; import android.content.res.Resources; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.PointF; import android.graphics.Rect; Loading Loading @@ -312,6 +313,14 @@ public class AppWidgetHostView extends FrameLayout { super.onLayout(changed, left, top, right, bottom); } catch (final RuntimeException 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); View child = getErrorView(); prepareView(child); Loading @@ -323,7 +332,6 @@ public class AppWidgetHostView extends FrameLayout { mView = child; mViewMode = VIEW_MODE_ERROR; } } /** * Provide guidance about the size of this widget to the AppWidgetManager. The widths and Loading Loading @@ -940,4 +948,15 @@ public class AppWidgetHostView extends FrameLayout { reapplyLastRemoteViews(); } } @Override protected void dispatchDraw(@NonNull 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 Diff line number Diff line Loading @@ -157,6 +157,8 @@ public interface AppStandbyInternal { void setActiveAdminApps(Set<String> adminPkgs, int userId); void setAdminProtectedPackages(Set<String> packageNames, int userId); void onAdminDataAvailable(); void clearCarrierPrivilegedApps(); Loading
apex/jobscheduler/service/java/com/android/server/job/JobStore.java +15 −2 Original line number Diff line number Diff line Loading @@ -733,6 +733,10 @@ public final class JobStore { } } catch (XmlPullParserException | IOException 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 { if (mPersistInfo.countAllJobsLoaded < 0) { // Only set them once. mPersistInfo.countAllJobsLoaded = numJobs; Loading Loading @@ -869,6 +873,9 @@ public final class JobStore { } 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> Loading Loading @@ -965,8 +972,14 @@ public final class JobStore { return null; } PersistableBundle extras = PersistableBundle.restoreFromXml(parser); final PersistableBundle extras; try { extras = PersistableBundle.restoreFromXml(parser); jobBuilder.setExtras(extras); } catch (IllegalArgumentException e) { Slog.e(TAG, "Persisted extras contained invalid data", e); return null; } parser.nextTag(); // Consume </extras> final JobInfo builtJob; Loading
apex/jobscheduler/service/java/com/android/server/usage/AppStandbyController.java +40 −0 Original line number Diff line number Diff line Loading @@ -247,6 +247,10 @@ public class AppStandbyController @GuardedBy("mActiveAdminApps") 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 * disabled). Presence in this map indicates that the app is a headless system app. Loading Loading @@ -1088,6 +1092,9 @@ public class AppStandbyController synchronized (mActiveAdminApps) { mActiveAdminApps.remove(userId); } synchronized (mAdminProtectedPackages) { mAdminProtectedPackages.remove(userId); } } } Loading Loading @@ -1177,6 +1184,10 @@ public class AppStandbyController return STANDBY_BUCKET_EXEMPTED; } if (isAdminProtectedPackages(packageName, userId)) { return STANDBY_BUCKET_EXEMPTED; } if (isActiveNetworkScorer(packageName)) { return STANDBY_BUCKET_EXEMPTED; } Loading Loading @@ -1583,6 +1594,17 @@ public class AppStandbyController } } 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 public void addActiveDeviceAdmin(String adminPkg, int userId) { synchronized (mActiveAdminApps) { Loading @@ -1606,6 +1628,17 @@ public class AppStandbyController } } @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 public void onAdminDataAvailable() { mAdminDataAvailableLatch.countDown(); Loading @@ -1628,6 +1661,13 @@ public class AppStandbyController } } @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 false}. Loading
core/java/android/app/admin/DevicePolicyManager.java +2 −1 Original line number Diff line number Diff line Loading @@ -13573,7 +13573,8 @@ public class DevicePolicyManager { /** * 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 packages The package names for the apps.
core/java/android/appwidget/AppWidgetHostView.java +29 −10 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import android.content.pm.LauncherActivityInfo; import android.content.pm.LauncherApps; import android.content.pm.PackageManager.NameNotFoundException; import android.content.res.Resources; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.PointF; import android.graphics.Rect; Loading Loading @@ -312,6 +313,14 @@ public class AppWidgetHostView extends FrameLayout { super.onLayout(changed, left, top, right, bottom); } catch (final RuntimeException 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); View child = getErrorView(); prepareView(child); Loading @@ -323,7 +332,6 @@ public class AppWidgetHostView extends FrameLayout { mView = child; mViewMode = VIEW_MODE_ERROR; } } /** * Provide guidance about the size of this widget to the AppWidgetManager. The widths and Loading Loading @@ -940,4 +948,15 @@ public class AppWidgetHostView extends FrameLayout { reapplyLastRemoteViews(); } } @Override protected void dispatchDraw(@NonNull 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); } } }