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

Commit 04056a84 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Uninstaller: For result lifecycle safe"

parents 181bec75 4f78e1fa
Loading
Loading
Loading
Loading
+17 −1
Original line number Diff line number Diff line
@@ -95,10 +95,26 @@
            </intent-filter>
        </activity>

        <receiver android:name=".UninstallEventReceiver"
            android:permission="android.permission.INSTALL_PACKAGES"
            android:exported="true">
            <intent-filter android:priority="1">
                <action android:name="com.android.packageinstaller.ACTION_UNINSTALL_COMMIT" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
            </intent-filter>
        </receiver>

        <activity android:name=".UninstallUninstalling"
            android:excludeFromRecents="true"
            android:theme="@style/AlertDialogActivity"
            android:exported="false" />

        <receiver android:name=".UninstallFinish"
                android:exported="false" />

        <activity android:name=".UninstallAppProgress"
        <activity android:name=".television.UninstallAppProgress"
                android:configChanges="mnc|mnc|touchscreen|navigation|screenLayout|screenSize|smallestScreenSize|orientation|locale|keyboard|keyboardHidden|fontScale|uiMode|layoutDirection|density"
                android:exported="false" />

+2 −0
Original line number Diff line number Diff line
@@ -100,6 +100,8 @@
    <string name="app_not_found_dlg_text"> The app wasn\'t found in the list of installed apps.</string>
    <string name="user_is_not_allowed_dlg_title">Not allowed</string>
    <string name="user_is_not_allowed_dlg_text">The current user is not allowed to perform this uninstallation.</string>
    <string name="generic_error_dlg_title">Error</string>
    <string name="generic_error_dlg_text">App could not be uninstalled.</string>
    <string name="uninstall_application_title">Uninstall app</string>
    <string name="uninstall_update_title">Uninstall update</string>
    <string name="uninstall_activity_text"><xliff:g id="activity_name">%1$s</xliff:g> is part of the following app:</string>
+18 −15
Original line number Diff line number Diff line
@@ -79,6 +79,22 @@ class EventResultPersister {
    @GuardedBy("mLock")
    private boolean mIsPersistingStateValid;

    /**
     * @return a new event id.
     */
    public int getNewId() throws OutOfIdsException {
        synchronized (mLock) {
            if (mCounter == Integer.MAX_VALUE) {
                throw new OutOfIdsException();
            }

            mCounter++;
            writeState();

            return mCounter - 1;
        }
    }

    /** Call back when a result is received. Observer is removed when onResult it called. */
    interface EventResultObserver {
        void onResult(int status, int legacyStatus, @Nullable String message);
@@ -253,20 +269,11 @@ class EventResultPersister {
     */
    int addObserver(int id, @NonNull EventResultObserver observer)
            throws OutOfIdsException {
        boolean stateChanged = false;

        synchronized (mLock) {
            int resultIndex = -1;

            if (id == GENERATE_NEW_ID) {
                if (mCounter == Integer.MAX_VALUE) {
                    throw new OutOfIdsException();
                } else {
                    id = mCounter;
                    mCounter++;

                    stateChanged = true;
                }
                id = getNewId();
            } else {
                resultIndex = mResults.indexOfKey(id);
            }
@@ -277,14 +284,10 @@ class EventResultPersister {

                observer.onResult(result.status, result.legacyStatus, result.message);
                mResults.removeAt(resultIndex);
                stateChanged = true;
                writeState();
            } else {
                mObservers.put(id, observer);
            }

            if (stateChanged) {
                writeState();
            }
        }


Loading