Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6c40dfe7 authored by Nishith  Khanna's avatar Nishith Khanna
Browse files

Merge remote-tracking branch 'origin/lineage-19.1' into v1-s

parents f4067a81 fad839e2
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -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();
+15 −2
Original line number Diff line number Diff line
@@ -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;
@@ -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>
@@ -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;
+40 −0
Original line number Diff line number Diff line
@@ -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.
@@ -1088,6 +1092,9 @@ public class AppStandbyController
            synchronized (mActiveAdminApps) {
                mActiveAdminApps.remove(userId);
            }
            synchronized (mAdminProtectedPackages) {
                mAdminProtectedPackages.remove(userId);
            }
        }
    }

@@ -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;
            }
@@ -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) {
@@ -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();
@@ -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}.
+2 −1
Original line number Diff line number Diff line
@@ -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.
+29 −10
Original line number Diff line number Diff line
@@ -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;
@@ -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);
@@ -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
@@ -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