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

Commit 794f03d4 authored by Mohammad Samiul Islam's avatar Mohammad Samiul Islam Committed by shafik
Browse files

Make ENABLE_ROLLBACK_TIMEOUT configurable

Bug: 112431924
Test: atest RollbackTest
Test: manual testing
      - disable the RollbackManagerService by commenting out
        BroadcastReceiver for ACTION_PACKAGE_ENABLE_ROLLBACK
      - configure timeout: adb shell device_config put rollback
        enable_rollback_timeout 60000
      - install apk: adb install --enable-rollback
        out/target/product/taimen/data/app/RollbackTest/
        RollbackTest.apk
      - search for "rollback timed out" in `adb logcat`

Change-Id: I61600cf376755d80c735ad954a80ca98de508bda
parent 26ebfe89
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -5779,6 +5779,11 @@ package android.provider {
    field public static final String PROPERTY_PERMISSIONS_HUB_ENABLED = "permissions_hub_enabled";
  }
  public static interface DeviceConfig.Rollback {
    field public static final String ENABLE_ROLLBACK_TIMEOUT = "enable_rollback_timeout";
    field public static final String NAMESPACE = "rollback";
  }
  public static interface DeviceConfig.Runtime {
    field public static final String NAMESPACE = "runtime";
    field public static final String USE_PRECOMPILED_LAYOUT = "view.precompiled_layout_enabled";
+15 −0
Original line number Diff line number Diff line
@@ -307,6 +307,21 @@ public final class DeviceConfig {
        String COMPONENT_NAME = "component_name";
    }

    /**
     * Namespace for Rollback.
     *
     * @hide
     */
    @SystemApi
    public interface Rollback {
        String NAMESPACE = "rollback";

        /**
         * Timeout in milliseconds for enabling package rollback.
         */
        String ENABLE_ROLLBACK_TIMEOUT = "enable_rollback_timeout";
    }

    /**
     * Namespace for storage-related features.
     *
+11 −5
Original line number Diff line number Diff line
@@ -241,6 +241,7 @@ import android.os.storage.StorageManagerInternal;
import android.os.storage.VolumeInfo;
import android.os.storage.VolumeRecord;
import android.permission.PermissionControllerManager;
import android.provider.DeviceConfig;
import android.provider.MediaStore;
import android.provider.Settings.Global;
import android.provider.Settings.Secure;
@@ -14604,14 +14605,19 @@ public class PackageManagerService extends IPackageManager.Stub
                            new BroadcastReceiver() {
                                @Override
                                public void onReceive(Context context, Intent intent) {
                                    // TODO(ruhler) b/112431924 Have a configurable setting to
                                    // allow changing the timeout and fall back to the default
                                    // if no such specified.
                                    // the duration to wait for rollback to be enabled, in millis
                                    long rollbackTimeout = DEFAULT_ENABLE_ROLLBACK_TIMEOUT;
                                    try {
                                        rollbackTimeout = Long.valueOf(
                                            DeviceConfig.getProperty(
                                                DeviceConfig.Rollback.NAMESPACE,
                                                DeviceConfig.Rollback.ENABLE_ROLLBACK_TIMEOUT));
                                    } catch (NumberFormatException ignore) {
                                    }
                                    final Message msg = mHandler.obtainMessage(
                                            ENABLE_ROLLBACK_TIMEOUT);
                                    msg.arg1 = enableRollbackToken;
                                    mHandler.sendMessageDelayed(msg,
                                            DEFAULT_ENABLE_ROLLBACK_TIMEOUT);
                                    mHandler.sendMessageDelayed(msg, rollbackTimeout);
                                }
                            }, null, 0, null, null);