[pm] remove incremental startable/unstartable code
Also remove streaming health status reporting which could cause
startable state change because it is also not needed any more.
BUG: 171920377
Test: builds
Change-Id: I7284e7a63df79da7dbf3d16ff64302b3d1ce1348
diff --git a/core/api/current.txt b/core/api/current.txt
index 4b12d54..49113c5 100644
--- a/core/api/current.txt
+++ b/core/api/current.txt
@@ -11262,7 +11262,6 @@
field public static final String EXTRA_TIMEZONE = "time-zone";
field public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
field public static final String EXTRA_UID = "android.intent.extra.UID";
- field public static final String EXTRA_UNSTARTABLE_REASON = "android.intent.extra.UNSTARTABLE_REASON";
field public static final String EXTRA_USER = "android.intent.extra.USER";
field public static final String EXTRA_USER_INITIATED = "android.intent.extra.USER_INITIATED";
field public static final int FILL_IN_ACTION = 1; // 0x1
diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java
index f8d407d..7fdbf15 100644
--- a/core/java/android/content/Intent.java
+++ b/core/java/android/content/Intent.java
@@ -2829,55 +2829,6 @@
public static final String ACTION_MY_PACKAGE_UNSUSPENDED = "android.intent.action.MY_PACKAGE_UNSUSPENDED";
/**
- * Broadcast Action: Sent to indicate that the package becomes startable.
- * The intent will have the following extra values:
- * <ul>
- * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. </li>
- * <li> {@link #EXTRA_PACKAGE_NAME} containing the package name. </li>
- * </li>
- * </ul>
- *
- * <p class="note">This is a protected intent that can only be sent by the system.
- * @hide
- */
- @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
- public static final String ACTION_PACKAGE_STARTABLE = "android.intent.action.PACKAGE_STARTABLE";
-
- /**
- * Broadcast Action: Sent to indicate that the package becomes unstartable.
- * The intent will have the following extra values:
- * <ul>
- * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. </li>
- * <li> {@link #EXTRA_PACKAGE_NAME} containing the package name. </li>
- * <li> {@link #EXTRA_UNSTARTABLE_REASON} containing the integer indicating the reason for
- * the state change,
- * @see PackageManager.UnstartableReason
- * </li>
- * </ul>
- *
- * <p class="note">This is a protected intent that can only be sent by the system.
- * @hide
- */
- @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
- public static final String ACTION_PACKAGE_UNSTARTABLE =
- "android.intent.action.PACKAGE_UNSTARTABLE";
-
- /**
- * Broadcast Action: Sent to indicate that the package is fully loaded.
- * <ul>
- * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. </li>
- * <li> {@link #EXTRA_PACKAGE_NAME} containing the package name. </li>
- * </li>
- * </ul>
- *
- * <p class="note">This is a protected intent that can only be sent by the system.
- * @hide
- */
- @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
- public static final String ACTION_PACKAGE_FULLY_LOADED =
- "android.intent.action.PACKAGE_FULLY_LOADED";
-
- /**
* Broadcast Action: A user ID has been removed from the system. The user
* ID number is stored in the extra data under {@link #EXTRA_UID}.
*
@@ -6171,13 +6122,6 @@
*/
public static final String EXTRA_LOCUS_ID = "android.intent.extra.LOCUS_ID";
- /**
- * Intent extra: the reason that the package associated with this intent has become unstartable.
- *
- * <p>Type: String
- */
- public static final String EXTRA_UNSTARTABLE_REASON = "android.intent.extra.UNSTARTABLE_REASON";
-
// ---------------------------------------------------------------------
// ---------------------------------------------------------------------
// Intent flags (see mFlags variable).
diff --git a/core/java/android/content/pm/IDataLoaderStatusListener.aidl b/core/java/android/content/pm/IDataLoaderStatusListener.aidl
index 79b70f2..9d8d0a4 100644
--- a/core/java/android/content/pm/IDataLoaderStatusListener.aidl
+++ b/core/java/android/content/pm/IDataLoaderStatusListener.aidl
@@ -52,30 +52,7 @@
* fail and all retry limits are exceeded. */
const int DATA_LOADER_UNRECOVERABLE = 9;
- /** There are no known issues with the data stream. */
- const int STREAM_HEALTHY = 0;
-
- /** There are issues with the current transport layer (network, adb connection, etc.) that may
- * recover automatically or could eventually require user intervention. */
- const int STREAM_TRANSPORT_ERROR = 1;
-
- /** Integrity failures in the data stream, this could be due to file corruption, decompression
- * issues or similar. This indicates a likely unrecoverable error. */
- const int STREAM_INTEGRITY_ERROR = 2;
-
- /** There are issues with the source of the data, e.g., backend availability issues, account
- * issues. This indicates a potentially recoverable error, but one that may take a long time to
- * resolve. */
- const int STREAM_SOURCE_ERROR = 3;
-
- /** The device or app is low on storage and cannot complete the stream as a result.
- * A subsequent page miss resulting in app failure will transition app to unstartable state. */
- const int STREAM_STORAGE_ERROR = 4;
-
/** Data loader status callback */
void onStatusChanged(in int dataLoaderId, in int status);
-
- /** Callback to report streaming health status of a specific data loader */
- void reportStreamHealth(in int dataLoaderId, in int streamStatus);
}
diff --git a/core/java/android/content/pm/IncrementalStatesInfo.java b/core/java/android/content/pm/IncrementalStatesInfo.java
index 6e91c19..0393d34b 100644
--- a/core/java/android/content/pm/IncrementalStatesInfo.java
+++ b/core/java/android/content/pm/IncrementalStatesInfo.java
@@ -24,26 +24,19 @@
* @hide
*/
public class IncrementalStatesInfo implements Parcelable {
- private boolean mIsStartable;
private boolean mIsLoading;
private float mProgress;
- public IncrementalStatesInfo(boolean isStartable, boolean isLoading, float progress) {
- mIsStartable = isStartable;
+ public IncrementalStatesInfo(boolean isLoading, float progress) {
mIsLoading = isLoading;
mProgress = progress;
}
private IncrementalStatesInfo(Parcel source) {
- mIsStartable = source.readBoolean();
mIsLoading = source.readBoolean();
mProgress = source.readFloat();
}
- public boolean isStartable() {
- return mIsStartable;
- }
-
public boolean isLoading() {
return mIsLoading;
}
@@ -59,7 +52,6 @@
@Override
public void writeToParcel(Parcel dest, int flags) {
- dest.writeBoolean(mIsStartable);
dest.writeBoolean(mIsLoading);
dest.writeFloat(mProgress);
}
diff --git a/core/java/android/content/pm/LauncherApps.java b/core/java/android/content/pm/LauncherApps.java
index 8b9b736..a8a5837 100644
--- a/core/java/android/content/pm/LauncherApps.java
+++ b/core/java/android/content/pm/LauncherApps.java
@@ -225,7 +225,6 @@
* Indicates that a package was modified in the specified profile.
* This can happen, for example, when the package is updated or when
* one or more components are enabled or disabled.
- * It can also happen if package state has changed, i.e., package becomes unstartable.
*
* @param packageName The name of the package that has changed.
* @param user The UserHandle of the profile that generated the change.
diff --git a/core/java/android/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java
index bba2fd0..c4d7a0a 100644
--- a/core/java/android/content/pm/PackageManager.java
+++ b/core/java/android/content/pm/PackageManager.java
@@ -4370,39 +4370,6 @@
public static final int SYSTEM_APP_STATE_UNINSTALLED = 3;
/**
- * Reasons for why a package is unstartable.
- * @hide
- */
- @IntDef({UNSTARTABLE_REASON_UNKNOWN,
- UNSTARTABLE_REASON_CONNECTION_ERROR,
- UNSTARTABLE_REASON_INSUFFICIENT_STORAGE
- })
- @Retention(RetentionPolicy.SOURCE)
- public @interface UnstartableReason {}
-
- /**
- * Unstartable state with no root cause specified. E.g., data loader seeing missing pages but
- * unclear about the cause. This corresponds to a generic alert window shown to the user when
- * the user attempts to launch the app.
- * @hide
- */
- public static final int UNSTARTABLE_REASON_UNKNOWN = 0;
-
- /**
- * Unstartable state due to connection issues that interrupt package loading.
- * This corresponds to an alert window shown to the user indicating connection errors.
- * @hide
- */
- public static final int UNSTARTABLE_REASON_CONNECTION_ERROR = 1;
-
- /**
- * Unstartable state after encountering storage limitations.
- * This corresponds to an alert window indicating limited storage.
- * @hide
- */
- public static final int UNSTARTABLE_REASON_INSUFFICIENT_STORAGE = 2;
-
- /**
* A manifest property to control app's participation in {@code adb backup}. Should only
* be used by system / privileged apps.
*
diff --git a/core/java/android/os/incremental/IIncrementalService.aidl b/core/java/android/os/incremental/IIncrementalService.aidl
index ba6fc6e..fe3197a 100644
--- a/core/java/android/os/incremental/IIncrementalService.aidl
+++ b/core/java/android/os/incremental/IIncrementalService.aidl
@@ -163,16 +163,6 @@
boolean unregisterLoadingProgressListener(int storageId);
/**
- * Register storage health status listener.
- */
- boolean registerStorageHealthListener(int storageId, in StorageHealthCheckParams params, in IStorageHealthListener listener);
-
- /**
- * Register storage health status listener.
- */
- void unregisterStorageHealthListener(int storageId);
-
- /**
* Metrics key for the duration in milliseconds between now and the oldest pending read. The value is a long.
*/
const @utf8InCpp String METRICS_MILLIS_SINCE_OLDEST_PENDING_READ = "millisSinceOldestPendingRead";
diff --git a/core/java/android/os/incremental/IStorageHealthListener.aidl b/core/java/android/os/incremental/IStorageHealthListener.aidl
index c71e73f..dc533a0 100644
--- a/core/java/android/os/incremental/IStorageHealthListener.aidl
+++ b/core/java/android/os/incremental/IStorageHealthListener.aidl
@@ -29,12 +29,6 @@
/** There are reads pending for params.unhealthyTimeoutMs,
* marking storage as unhealthy due to unknown issues. */
const int HEALTH_STATUS_UNHEALTHY = 3;
- /** There are reads pending for params.unhealthyTimeoutMs,
- * due to data transportation issues. */
- const int HEALTH_STATUS_UNHEALTHY_TRANSPORT = 4;
- /** There are reads pending for params.unhealthyTimeoutMs,
- * due to limited storage space. */
- const int HEALTH_STATUS_UNHEALTHY_STORAGE = 5;
/** Health status callback. */
void onHealthStatus(in int storageId, in int status);
diff --git a/core/java/android/os/incremental/IncrementalManager.java b/core/java/android/os/incremental/IncrementalManager.java
index 7fb9ae0..9c8ee56 100644
--- a/core/java/android/os/incremental/IncrementalManager.java
+++ b/core/java/android/os/incremental/IncrementalManager.java
@@ -294,7 +294,6 @@
return;
}
mLoadingProgressCallbacks.cleanUpCallbacks(storage);
- unregisterHealthListener(codePath);
storage.unBind(codePath);
} catch (IOException e) {
Slog.w(TAG, "Failed to remove code path", e);
@@ -397,38 +396,6 @@
}
/**
- * Specify the health check params and listener for listening to Incremental Storage health
- * status changes. Notice that this will overwrite the previously registered listener.
- * @param codePath Path of the installed package. This path is on an Incremental Storage.
- * @param healthCheckParams The params for health state change timeouts.
- * @param listener To report health status change.
- * @return True if listener was successfully registered.
- */
- public boolean registerHealthListener(@NonNull String codePath,
- @NonNull StorageHealthCheckParams healthCheckParams,
- @NonNull IStorageHealthListener.Stub listener) {
- final IncrementalStorage storage = openStorage(codePath);
- if (storage == null) {
- // storage does not exist, package not installed
- return false;
- }
- return storage.registerStorageHealthListener(healthCheckParams, listener);
- }
-
- /**
- * Stop listening to health status changes on an Incremental Storage.
- * @param codePath Path of the installed package. This path is on an Incremental Storage.
- */
- public void unregisterHealthListener(@NonNull String codePath) {
- final IncrementalStorage storage = openStorage(codePath);
- if (storage == null) {
- // storage does not exist, package not installed
- return;
- }
- storage.unregisterStorageHealthListener();
- }
-
- /**
* Returns the metrics of an Incremental Storage.
*/
public IncrementalMetrics getMetrics(@NonNull String codePath) {
diff --git a/core/java/android/os/incremental/IncrementalStorage.java b/core/java/android/os/incremental/IncrementalStorage.java
index c19e29f..4d46325 100644
--- a/core/java/android/os/incremental/IncrementalStorage.java
+++ b/core/java/android/os/incremental/IncrementalStorage.java
@@ -589,33 +589,6 @@
}
/**
- * Register to listen to the status changes of the storage health.
- * @param healthCheckParams Params to specify status change timeouts.
- * @param listener To report health status change from Incremental Service to the caller.
- */
- public boolean registerStorageHealthListener(StorageHealthCheckParams healthCheckParams,
- IStorageHealthListener listener) {
- try {
- return mService.registerStorageHealthListener(mId, healthCheckParams, listener);
- } catch (RemoteException e) {
- e.rethrowFromSystemServer();
- return false;
- }
- }
-
- /**
- * Stops listening to the status changes of the storage health.
- */
- public void unregisterStorageHealthListener() {
- try {
- mService.unregisterStorageHealthListener(mId);
- } catch (RemoteException e) {
- e.rethrowFromSystemServer();
- return;
- }
- }
-
- /**
* Returns the metrics of the current storage.
* {@see IIncrementalService} for metrics keys.
*/
diff --git a/core/java/com/android/internal/content/PackageMonitor.java b/core/java/com/android/internal/content/PackageMonitor.java
index 9a44c05..7c975e1 100644
--- a/core/java/com/android/internal/content/PackageMonitor.java
+++ b/core/java/com/android/internal/content/PackageMonitor.java
@@ -50,9 +50,6 @@
sPackageFilt.addAction(Intent.ACTION_QUERY_PACKAGE_RESTART);
sPackageFilt.addAction(Intent.ACTION_PACKAGE_RESTARTED);
sPackageFilt.addAction(Intent.ACTION_PACKAGE_DATA_CLEARED);
- sPackageFilt.addAction(Intent.ACTION_PACKAGE_STARTABLE);
- sPackageFilt.addAction(Intent.ACTION_PACKAGE_UNSTARTABLE);
- sPackageFilt.addAction(Intent.ACTION_PACKAGE_FULLY_LOADED);
sPackageFilt.addDataScheme("package");
sNonDataFilt.addAction(Intent.ACTION_UID_REMOVED);
sNonDataFilt.addAction(Intent.ACTION_USER_STOPPED);
@@ -464,15 +461,6 @@
String[] pkgList = intent.getStringArrayExtra(Intent.EXTRA_CHANGED_PACKAGE_LIST);
mSomePackagesChanged = true;
onPackagesUnsuspended(pkgList);
- } else if (Intent.ACTION_PACKAGE_STARTABLE.equals(action)
- || Intent.ACTION_PACKAGE_UNSTARTABLE.equals(action)
- || Intent.ACTION_PACKAGE_FULLY_LOADED.equals(action)) {
- String pkg = intent.getStringExtra(Intent.EXTRA_PACKAGE_NAME);
- int uid = intent.getIntExtra(Intent.EXTRA_UID, 0);
- mSomePackagesChanged = false;
- if (pkg != null) {
- onPackageStateChanged(pkg, uid);
- }
}
if (mSomePackagesChanged) {
diff --git a/core/proto/android/service/package.proto b/core/proto/android/service/package.proto
index 5567109..48feb4d 100644
--- a/core/proto/android/service/package.proto
+++ b/core/proto/android/service/package.proto
@@ -125,7 +125,7 @@
}
message StatesProto {
- optional bool is_startable = 1;
+ reserved 1;
optional bool is_loading = 2;
}
@@ -160,7 +160,7 @@
repeated UserInfoProto users = 9;
// Where the request to install this package came from,
optional InstallSourceProto install_source = 10;
- // Whether the package is startable or is still loading
+ // Whether the package is still loading
optional StatesProto states = 11;
// Granted runtime permissions for users.
repeated UserPermissionsProto user_permissions = 12;
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index 925a212..69e3d24 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -42,8 +42,6 @@
<protected-broadcast android:name="android.intent.action.PACKAGE_REMOVED" />
<protected-broadcast android:name="android.intent.action.PACKAGE_FULLY_REMOVED" />
<protected-broadcast android:name="android.intent.action.PACKAGE_CHANGED" />
- <protected-broadcast android:name="android.intent.action.PACKAGE_STARTABLE" />
- <protected-broadcast android:name="android.intent.action.PACKAGE_UNSTARTABLE" />
<protected-broadcast android:name="android.intent.action.PACKAGE_FULLY_LOADED" />
<protected-broadcast android:name="android.intent.action.PACKAGE_ENABLE_ROLLBACK" />
<protected-broadcast android:name="android.intent.action.CANCEL_ENABLE_ROLLBACK" />
diff --git a/services/core/java/android/content/pm/PackageManagerInternal.java b/services/core/java/android/content/pm/PackageManagerInternal.java
index a9eb2c1..b7adf57 100644
--- a/services/core/java/android/content/pm/PackageManagerInternal.java
+++ b/services/core/java/android/content/pm/PackageManagerInternal.java
@@ -1114,11 +1114,6 @@
int filterCallingUid, int userId);
/**
- * Notifies that a package has crashed or ANR'd.
- */
- public abstract void notifyPackageCrashOrAnr(String packageName);
-
- /**
* Requesting the checksums for APKs within a package.
* See {@link PackageManager#requestChecksums} for details.
*
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index e3b06d6..44e5460 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -7678,7 +7678,6 @@
// Notify package manager service to possibly update package state
if (r != null && r.info != null && r.info.packageName != null) {
final String codePath = r.info.getCodePath();
- mPackageManagerInt.notifyPackageCrashOrAnr(r.info.packageName);
IncrementalStatesInfo incrementalStatesInfo =
mPackageManagerInt.getIncrementalStatesInfo(r.info.packageName, r.uid,
r.userId);
@@ -12977,11 +12976,6 @@
case Intent.ACTION_PRE_BOOT_COMPLETED:
timeoutExempt = true;
break;
- case Intent.ACTION_PACKAGE_UNSTARTABLE:
- final String packageName = intent.getStringExtra(Intent.EXTRA_PACKAGE_NAME);
- forceStopPackageLocked(packageName, -1, false, true, true,
- false, false, userId, "package unstartable");
- break;
case Intent.ACTION_CLOSE_SYSTEM_DIALOGS:
if (!mAtmInternal.checkCanCloseSystemDialogs(callingPid, callingUid,
callerPackage)) {
diff --git a/services/core/java/com/android/server/am/ProcessErrorStateRecord.java b/services/core/java/com/android/server/am/ProcessErrorStateRecord.java
index 00184f9..6ff3bf6 100644
--- a/services/core/java/com/android/server/am/ProcessErrorStateRecord.java
+++ b/services/core/java/com/android/server/am/ProcessErrorStateRecord.java
@@ -472,11 +472,6 @@
mDialogController.setAnrController(anrController);
}
- // Notify package manager service to possibly update package state
- if (aInfo != null && aInfo.packageName != null) {
- packageManagerInternal.notifyPackageCrashOrAnr(aInfo.packageName);
- }
-
// mUiHandler can be null if the AMS is constructed with injector only. This will only
// happen in tests.
if (mService.mUiHandler != null) {
diff --git a/services/core/java/com/android/server/pm/IncrementalStates.java b/services/core/java/com/android/server/pm/IncrementalStates.java
index 4fd360b..7627281 100644
--- a/services/core/java/com/android/server/pm/IncrementalStates.java
+++ b/services/core/java/com/android/server/pm/IncrementalStates.java
@@ -16,13 +16,7 @@
package com.android.server.pm;
-import static android.os.incremental.IStorageHealthListener.HEALTH_STATUS_OK;
-import static android.os.incremental.IStorageHealthListener.HEALTH_STATUS_UNHEALTHY;
-import static android.os.incremental.IStorageHealthListener.HEALTH_STATUS_UNHEALTHY_STORAGE;
-import static android.os.incremental.IStorageHealthListener.HEALTH_STATUS_UNHEALTHY_TRANSPORT;
-
import android.content.pm.IncrementalStatesInfo;
-import android.content.pm.PackageManager;
import android.os.Handler;
import android.util.Slog;
@@ -30,17 +24,13 @@
import com.android.internal.os.BackgroundThread;
import com.android.internal.util.function.pooled.PooledLambda;
-import java.util.function.Consumer;
-
/**
* Manages state transitions of a package installed on Incremental File System. Currently manages:
- * 1. startable state (whether a package is allowed to be launched), and
- * 2. loading state (whether a package is still loading or has been fully loaded).
+ * 1. loading state (whether a package is still loading or has been fully loaded).
*
* The following events might change the states of a package:
* 1. Installation commit
- * 2. Incremental storage health changes
- * 4. Loading progress changes
+ * 2. Loading progress changes
*
* @hide
*/
@@ -50,41 +40,24 @@
private final Handler mHandler = BackgroundThread.getHandler();
private final Object mLock = new Object();
@GuardedBy("mLock")
- private int mStorageHealthStatus = HEALTH_STATUS_OK;
- @GuardedBy("mLock")
private final LoadingState mLoadingState;
@GuardedBy("mLock")
- private StartableState mStartableState;
- @GuardedBy("mLock")
private Callback mCallback = null;
- private final Consumer<Integer> mStatusConsumer;
public IncrementalStates() {
- // By default the package is not startable and not fully loaded (i.e., is loading)
- this(false, true, 0);
+ // By default the package is not fully loaded (i.e., is loading)
+ this(true, 0);
}
- public IncrementalStates(boolean isStartable, boolean isLoading, float loadingProgress) {
- mStartableState = new StartableState(isStartable);
+ public IncrementalStates(boolean isLoading, float loadingProgress) {
mLoadingState = new LoadingState(isLoading, loadingProgress);
- mStatusConsumer = new StatusConsumer();
}
/**
- * Callback interface to report that the startable state of this package has changed.
+ * Callback interface to report that the loading state of this package has changed.
*/
public interface Callback {
/**
- * Reports that the package is now unstartable and the unstartable reason.
- */
- void onPackageUnstartable(int reason);
-
- /**
- * Reports that the package is now startable.
- */
- void onPackageStartable();
-
- /**
* Reports that package is fully loaded.
*/
void onPackageFullyLoaded();
@@ -92,7 +65,7 @@
/**
* By calling this method, the caller indicates that package installation has just been
- * committed. The package becomes startable. Set the initial loading state after the package
+ * committed. Set the initial loading state after the package
* is committed. Incremental packages are by-default loading; non-Incremental packages are not.
*
* @param isIncremental whether a package is installed on Incremental or not.
@@ -101,66 +74,11 @@
if (DEBUG) {
Slog.i(TAG, "received package commit event");
}
- final boolean startableStateChanged;
- synchronized (mLock) {
- startableStateChanged = mStartableState.adoptNewStartableStateLocked(true);
- if (!isIncremental) {
- updateProgressLocked(1);
- }
- }
- if (startableStateChanged) {
- onStartableStateChanged();
- }
if (!isIncremental) {
- onLoadingStateChanged();
- }
- }
-
- /**
- * Change the startable state if the app has crashed or ANR'd during loading.
- * If the app is not loading (i.e., fully loaded), this event doesn't change startable state.
- */
- public void onCrashOrAnr() {
- if (DEBUG) {
- Slog.i(TAG, "received package crash or ANR event");
- }
- final boolean startableStateChanged;
- synchronized (mLock) {
- if (mStartableState.isStartable() && mLoadingState.isLoading()) {
- // Changing from startable -> unstartable only if app is still loading.
- startableStateChanged = mStartableState.adoptNewStartableStateLocked(false);
- } else {
- // If the app is fully loaded, the crash or ANR is caused by the app itself, so
- // we do not change the startable state.
- startableStateChanged = false;
+ synchronized (mLock) {
+ updateProgressLocked(1.0f);
}
- }
- if (startableStateChanged) {
- onStartableStateChanged();
- }
- }
-
- private void onStartableStateChanged() {
- // Disable startable state broadcasts
- // TODO(b/171920377): completely remove unstartable state.
- }
-
- private void reportStartableState() {
- final Callback callback;
- final boolean startable;
- final int reason;
- synchronized (mLock) {
- callback = mCallback;
- startable = mStartableState.isStartable();
- reason = mStartableState.getUnstartableReason();
- }
- if (callback == null) {
- return;
- }
- if (startable) {
- callback.onPackageStartable();
- } else {
- callback.onPackageUnstartable(reason);
+ onLoadingStateChanged();
}
}
@@ -180,38 +98,6 @@
}
}
- private class StatusConsumer implements Consumer<Integer> {
- @Override
- public void accept(Integer storageStatus) {
- final boolean startableStateChanged;
- synchronized (mLock) {
- if (!mLoadingState.isLoading()) {
- // Do nothing if the package is already fully loaded
- return;
- }
- mStorageHealthStatus = storageStatus;
- startableStateChanged = updateStartableStateLocked();
- }
- if (startableStateChanged) {
- onStartableStateChanged();
- }
- }
- }
-
- /**
- * By calling this method, the caller indicates that there issues with the Incremental
- * Storage,
- * on which the package is installed. The state will change according to the status
- * code defined in {@code IStorageHealthListener}.
- */
- public void onStorageHealthStatusChanged(int storageHealthStatus) {
- if (DEBUG) {
- Slog.i(TAG, "received storage health status changed event : storageHealthStatus="
- + storageHealthStatus);
- }
- mStatusConsumer.accept(storageHealthStatus);
- }
-
/**
* Use the specified callback to report state changing events.
*
@@ -227,25 +113,19 @@
}
/**
- * Update the package loading progress to specified value. This might change startable state.
+ * Update the package loading progress to specified value.
*
* @param progress Value between [0, 1].
*/
public void setProgress(float progress) {
final boolean newLoadingState;
- final boolean oldStartableState, newStartableState;
synchronized (mLock) {
- oldStartableState = mStartableState.isStartable();
updateProgressLocked(progress);
newLoadingState = mLoadingState.isLoading();
- newStartableState = mStartableState.isStartable();
}
if (!newLoadingState) {
onLoadingStateChanged();
}
- if (newStartableState != oldStartableState) {
- onStartableStateChanged();
- }
}
/**
@@ -253,41 +133,12 @@
*/
public IncrementalStatesInfo getIncrementalStatesInfo() {
synchronized (mLock) {
- return new IncrementalStatesInfo(mStartableState.isStartable(),
+ return new IncrementalStatesInfo(
mLoadingState.isLoading(),
mLoadingState.getProgress());
}
}
- /**
- * Determine the next state based on the current state, current stream status and storage
- * health
- * status. If the next state is different from the current state, proceed with state
- * change.
- * @return True if the new startable state is different from the old one.
- */
- private boolean updateStartableStateLocked() {
- final boolean currentState = mStartableState.isStartable();
- boolean nextState = currentState;
- if (!currentState) {
- if (mStorageHealthStatus == HEALTH_STATUS_OK) {
- // change from unstartable -> startable
- nextState = true;
- }
- } else {
- if (mStorageHealthStatus == HEALTH_STATUS_UNHEALTHY
- || mStorageHealthStatus == HEALTH_STATUS_UNHEALTHY_STORAGE
- || mStorageHealthStatus == HEALTH_STATUS_UNHEALTHY_TRANSPORT) {
- // change from startable -> unstartable
- nextState = false;
- }
- }
- if (nextState == currentState) {
- return false;
- }
- return mStartableState.adoptNewStartableStateLocked(nextState);
- }
-
private void updateProgressLocked(float progress) {
if (DEBUG) {
Slog.i(TAG, "received progress update: " + progress);
@@ -301,85 +152,6 @@
if (mLoadingState.isLoading()) {
mLoadingState.adoptNewLoadingStateLocked(false);
}
- // Also updates startable state if necessary
- if (!mStartableState.isStartable()) {
- mStartableState.adoptNewStartableStateLocked(true);
- }
- }
- }
-
- private class StartableState {
- private boolean mIsStartable;
- private int mUnstartableReason = PackageManager.UNSTARTABLE_REASON_UNKNOWN;
-
- StartableState(boolean isStartable) {
- mIsStartable = isStartable;
- }
-
- public boolean isStartable() {
- return mIsStartable;
- }
-
- public int getUnstartableReason() {
- return mUnstartableReason;
- }
-
- /**
- * Adopt new startable state if it is different from the current state.
- * @param nextState True if startable, false if unstartable.
- * @return True if the state has changed, false otherwise.
- */
- public boolean adoptNewStartableStateLocked(boolean nextState) {
- if (mIsStartable == nextState) {
- return false;
- }
- if (!nextState) {
- // Do nothing if the next state is "unstartable"; keep package always startable.
- // TODO(b/171920377): completely remove unstartable state.
- if (DEBUG) {
- Slog.i(TAG, "Attempting to set startable state to false. Abort.");
- }
- return false;
- }
- if (DEBUG) {
- Slog.i(TAG,
- "startable state changed from " + mIsStartable + " to " + nextState);
- }
- mIsStartable = nextState;
- mUnstartableReason = getUnstartableReasonLocked();
- return true;
- }
-
- private int getUnstartableReasonLocked() {
- if (mIsStartable) {
- return PackageManager.UNSTARTABLE_REASON_UNKNOWN;
- }
- // Translate stream status to reason for unstartable state
- switch (mStorageHealthStatus) {
- case HEALTH_STATUS_UNHEALTHY_STORAGE:
- return PackageManager.UNSTARTABLE_REASON_INSUFFICIENT_STORAGE;
- case HEALTH_STATUS_UNHEALTHY_TRANSPORT:
- return PackageManager.UNSTARTABLE_REASON_CONNECTION_ERROR;
- default:
- return PackageManager.UNSTARTABLE_REASON_UNKNOWN;
- }
- }
-
- @Override
- public boolean equals(Object o) {
- if (o == this) {
- return true;
- }
- if (!(o instanceof StartableState)) {
- return false;
- }
- StartableState l = (StartableState) o;
- return l.mIsStartable == mIsStartable;
- }
-
- @Override
- public int hashCode() {
- return Boolean.hashCode(mIsStartable);
}
}
@@ -443,16 +215,11 @@
return false;
}
IncrementalStates l = (IncrementalStates) o;
- return l.mStorageHealthStatus == mStorageHealthStatus
- && l.mStartableState.equals(mStartableState)
- && l.mLoadingState.equals(mLoadingState);
+ return l.mLoadingState.equals(mLoadingState);
}
@Override
public int hashCode() {
- int hashCode = mStartableState.hashCode();
- hashCode = 31 * hashCode + mLoadingState.hashCode();
- hashCode = 31 * hashCode + mStorageHealthStatus;
- return hashCode;
+ return mLoadingState.hashCode();
}
}
diff --git a/services/core/java/com/android/server/pm/PackageInstallerSession.java b/services/core/java/com/android/server/pm/PackageInstallerSession.java
index e532790..41022f4 100644
--- a/services/core/java/com/android/server/pm/PackageInstallerSession.java
+++ b/services/core/java/com/android/server/pm/PackageInstallerSession.java
@@ -3835,13 +3835,6 @@
sendPendingStreaming(mContext, statusReceiver, sessionId, e.getMessage());
}
}
- @Override
- public void reportStreamHealth(int dataLoaderId, int streamStatus) {
- // Currently the stream status is not used during package installation. It is
- // technically possible for the data loader to report stream status via this
- // callback, but if something is wrong with the streaming, it is more likely that
- // prepareDataLoaderLocked will return false and the installation will be aborted.
- }
};
if (!manualStartAndDestroy) {
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index 85c5a5e..d3e0e97 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -287,11 +287,9 @@
import android.os.Trace;
import android.os.UserHandle;
import android.os.UserManager;
-import android.os.incremental.IStorageHealthListener;
import android.os.incremental.IncrementalManager;
import android.os.incremental.IncrementalStorage;
import android.os.incremental.PerUidReadTimeouts;
-import android.os.incremental.StorageHealthCheckParams;
import android.os.storage.DiskInfo;
import android.os.storage.IStorageManager;
import android.os.storage.StorageEventListener;
@@ -818,14 +816,6 @@
private static final String RANDOM_DIR_PREFIX = "~~";
- /**
- * Timeout configurations for incremental storage health monitor.
- * See {@link IStorageHealthListener}
- */
- private static final int INCREMENTAL_STORAGE_BLOCKED_TIMEOUT_MS = 2000;
- private static final int INCREMENTAL_STORAGE_UNHEALTHY_TIMEOUT_MS = 7000;
- private static final int INCREMENTAL_STORAGE_UNHEALTHY_MONITORING_MS = 60000;
-
final Handler mHandler;
private final ProcessLoggingHandler mProcessLoggingHandler;
@@ -11721,15 +11711,7 @@
}
if (mIncrementalManager != null && isIncrementalPath(parsedPackage.getPath())) {
if (pkgSetting != null && pkgSetting.isPackageLoading()) {
- final StorageHealthCheckParams healthCheckParams = new StorageHealthCheckParams();
- healthCheckParams.blockedTimeoutMs = INCREMENTAL_STORAGE_BLOCKED_TIMEOUT_MS;
- healthCheckParams.unhealthyTimeoutMs = INCREMENTAL_STORAGE_UNHEALTHY_TIMEOUT_MS;
- healthCheckParams.unhealthyMonitoringMs =
- INCREMENTAL_STORAGE_UNHEALTHY_MONITORING_MS;
- // Continue monitoring health and loading progress of active incremental packages
- mIncrementalManager.registerHealthListener(parsedPackage.getPath(),
- healthCheckParams,
- new IncrementalHealthListener(parsedPackage.getPackageName()));
+ // Continue monitoring loading progress of active incremental packages
final IncrementalStatesCallback incrementalStatesCallback =
new IncrementalStatesCallback(parsedPackage.getPackageName(),
UserHandle.getUid(UserHandle.USER_ALL, pkgSetting.appId),
@@ -18554,16 +18536,6 @@
ps.setIncrementalStatesCallback(incrementalStatesCallback);
mIncrementalManager.registerLoadingProgressCallback(codePath,
new IncrementalProgressListener(ps.name));
- final IncrementalHealthListener incrementalHealthListener =
- new IncrementalHealthListener(ps.name);
- final StorageHealthCheckParams healthCheckParams =
- new StorageHealthCheckParams();
- healthCheckParams.blockedTimeoutMs = INCREMENTAL_STORAGE_BLOCKED_TIMEOUT_MS;
- healthCheckParams.unhealthyTimeoutMs = INCREMENTAL_STORAGE_UNHEALTHY_TIMEOUT_MS;
- healthCheckParams.unhealthyMonitoringMs =
- INCREMENTAL_STORAGE_UNHEALTHY_MONITORING_MS;
- mIncrementalManager.registerHealthListener(codePath, healthCheckParams,
- incrementalHealthListener);
}
// Ensure that the uninstall reason is UNKNOWN for users with the package installed.
@@ -19555,65 +19527,11 @@
ps, mInstalledUserIds, mSettings.getPackagesLocked());
codePath = ps.getPathString();
}
- Bundle extras = new Bundle();
- extras.putInt(Intent.EXTRA_UID, mUid);
- extras.putString(Intent.EXTRA_PACKAGE_NAME, mPackageName);
- sendPackageBroadcast(Intent.ACTION_PACKAGE_FULLY_LOADED, mPackageName,
- extras, 0 /*flags*/,
- null /*targetPackage*/, null /*finishedReceiver*/,
- mInstalledUserIds, null /* instantUserIds */, newBroadcastAllowList, null);
// Unregister progress listener
mIncrementalManager.unregisterLoadingProgressCallbacks(codePath);
- // Unregister health listener as it will always be healthy from now
- mIncrementalManager.unregisterHealthListener(codePath);
// Make sure the information is preserved
scheduleWriteSettingsLocked();
}
-
- @Override
- public void onPackageUnstartable(int reason) {
- final SparseArray<int[]> newBroadcastAllowList;
- synchronized (mLock) {
- final PackageSetting ps = mSettings.getPackageLPr(mPackageName);
- if (ps == null) {
- return;
- }
- newBroadcastAllowList = mAppsFilter.getVisibilityAllowList(
- ps, mInstalledUserIds, mSettings.getPackagesLocked());
- }
- Bundle extras = new Bundle();
- extras.putInt(Intent.EXTRA_UID, mUid);
- extras.putString(Intent.EXTRA_PACKAGE_NAME, mPackageName);
- extras.putInt(Intent.EXTRA_UNSTARTABLE_REASON, reason);
- // send broadcast to users with this app installed
- sendPackageBroadcast(Intent.ACTION_PACKAGE_UNSTARTABLE, mPackageName,
- extras, 0 /*flags*/,
- null /*targetPackage*/, null /*finishedReceiver*/,
- mInstalledUserIds, null /* instantUserIds */,
- newBroadcastAllowList, null);
- }
-
- @Override
- public void onPackageStartable() {
- final SparseArray<int[]> newBroadcastAllowList;
- synchronized (mLock) {
- final PackageSetting ps = mSettings.getPackageLPr(mPackageName);
- if (ps == null) {
- return;
- }
- newBroadcastAllowList = mAppsFilter.getVisibilityAllowList(
- ps, mInstalledUserIds, mSettings.getPackagesLocked());
- }
- Bundle extras = new Bundle();
- extras.putInt(Intent.EXTRA_UID, mUid);
- extras.putString(Intent.EXTRA_PACKAGE_NAME, mPackageName);
- // send broadcast to users with this app installed
- sendPackageBroadcast(Intent.ACTION_PACKAGE_STARTABLE, mPackageName,
- extras, 0 /*flags*/,
- null /*targetPackage*/, null /*finishedReceiver*/,
- mInstalledUserIds, null /* instantUserIds */,
- newBroadcastAllowList, null);
- }
}
/**
@@ -19638,29 +19556,6 @@
}
}
- /**
- * Incremental storage health status callback, used to listen for monitoring changes and update
- * package setting.
- */
- private class IncrementalHealthListener extends IStorageHealthListener.Stub {
- private final String mPackageName;
- IncrementalHealthListener(String packageName) {
- mPackageName = packageName;
- }
-
- @Override
- public void onHealthStatus(int storageId, int status) throws RemoteException {
- final PackageSetting ps;
- synchronized (mLock) {
- ps = mSettings.getPackageLPr(mPackageName);
- }
- if (ps == null) {
- return;
- }
- ps.setStorageHealthStatus(status);
- }
- }
-
@Nullable PackageSetting getPackageSettingForUser(String packageName, int callingUid,
int userId) {
final PackageSetting ps;
@@ -27350,20 +27245,6 @@
}
@Override
- public void notifyPackageCrashOrAnr(@NonNull String packageName) {
- final PackageSetting ps;
- synchronized (mLock) {
- ps = mSettings.getPackageLPr(packageName);
- if (ps == null) {
- Slog.w(TAG, "Failed notifyPackageCrash. Package " + packageName
- + " is not installed");
- return;
- }
- }
- ps.setStatesOnCrashOrAnr();
- }
-
- @Override
public void requestChecksums(@NonNull String packageName, boolean includeSplits,
@Checksum.Type int optional, @Checksum.Type int required,
@Nullable List trustedInstallers,
diff --git a/services/core/java/com/android/server/pm/PackageSetting.java b/services/core/java/com/android/server/pm/PackageSetting.java
index ca5d2b4..81ea465 100644
--- a/services/core/java/com/android/server/pm/PackageSetting.java
+++ b/services/core/java/com/android/server/pm/PackageSetting.java
@@ -344,7 +344,6 @@
installSource.originatingPackageName);
proto.end(sourceToken);
}
- proto.write(PackageProto.StatesProto.IS_STARTABLE, isPackageStartable());
proto.write(PackageProto.StatesProto.IS_LOADING, isPackageLoading());
writeUsersInfoToProto(proto, PackageProto.USERS);
writePackageUserPermissionsProto(proto, PackageProto.USER_PERMISSIONS, users, dataProvider);
diff --git a/services/core/java/com/android/server/pm/PackageSettingBase.java b/services/core/java/com/android/server/pm/PackageSettingBase.java
index 38e100e..19b56b7 100644
--- a/services/core/java/com/android/server/pm/PackageSettingBase.java
+++ b/services/core/java/com/android/server/pm/PackageSettingBase.java
@@ -723,13 +723,6 @@
}
/**
- * @return True if package is startable, false otherwise.
- */
- public boolean isPackageStartable() {
- return getIncrementalStates().isStartable();
- }
-
- /**
* @return True if package is still being loaded, false if the package is fully loaded.
*/
public boolean isPackageLoading() {
@@ -745,8 +738,8 @@
/**
* Called to indicate that the package installation has been committed. This will create a
- * new startable state and a new loading state with default values. By default, the package is
- * startable after commit. For a package installed on Incremental, the loading state is true.
+ * new loading state with default values.
+ * For a package installed on Incremental, the loading state is true.
* For non-Incremental packages, the loading state is false.
*/
public void setStatesOnCommit() {
@@ -754,15 +747,7 @@
}
/**
- * Called to indicate that the running app has crashed or ANR'd. This might change the startable
- * state of the package, depending on whether the package is fully loaded.
- */
- public void setStatesOnCrashOrAnr() {
- incrementalStates.onCrashOrAnr();
- }
-
- /**
- * Called to set the callback to listen for startable state changes.
+ * Called to set the callback to listen for loading state changes.
*/
public void setIncrementalStatesCallback(IncrementalStates.Callback callback) {
incrementalStates.setCallback(callback);
@@ -776,13 +761,6 @@
incrementalStates.setProgress(progress);
}
- /**
- * @see IncrementalStates#onStorageHealthStatusChanged(int)
- */
- public void setStorageHealthStatus(int status) {
- incrementalStates.onStorageHealthStatusChanged(status);
- }
-
public long getFirstInstallTime() {
return firstInstallTime;
}
diff --git a/services/core/java/com/android/server/pm/Settings.java b/services/core/java/com/android/server/pm/Settings.java
index 24f3930..e409019 100644
--- a/services/core/java/com/android/server/pm/Settings.java
+++ b/services/core/java/com/android/server/pm/Settings.java
@@ -2698,9 +2698,6 @@
if (pkg.forceQueryableOverride) {
serializer.attributeBoolean(null, "forceQueryable", true);
}
- if (pkg.isPackageStartable()) {
- serializer.attributeBoolean(null, "isStartable", true);
- }
if (pkg.isPackageLoading()) {
serializer.attributeBoolean(null, "isLoading", true);
}
@@ -3459,7 +3456,6 @@
PackageSetting packageSetting = null;
long versionCode = 0;
boolean installedForceQueryable = false;
- boolean isStartable = false;
boolean isLoading = false;
float loadingProgress = 0;
UUID domainSetId;
@@ -3479,7 +3475,6 @@
cpuAbiOverrideString = parser.getAttributeValue(null, "cpuAbiOverride");
updateAvailable = parser.getAttributeBoolean(null, "updateAvailable", false);
installedForceQueryable = parser.getAttributeBoolean(null, "forceQueryable", false);
- isStartable = parser.getAttributeBoolean(null, "isStartable", false);
isLoading = parser.getAttributeBoolean(null, "isLoading", false);
loadingProgress = parser.getAttributeFloat(null, "loadingProgress", 0);
@@ -3638,8 +3633,7 @@
packageSetting.secondaryCpuAbiString = secondaryCpuAbiString;
packageSetting.updateAvailable = updateAvailable;
packageSetting.forceQueryableOverride = installedForceQueryable;
- packageSetting.incrementalStates = new IncrementalStates(isStartable, isLoading,
- loadingProgress);
+ packageSetting.incrementalStates = new IncrementalStates(isLoading, loadingProgress);
// Handle legacy string here for single-user mode
final String enabledStr = parser.getAttributeValue(null, ATTR_ENABLED);
if (enabledStr != null) {
diff --git a/services/incremental/BinderIncrementalService.cpp b/services/incremental/BinderIncrementalService.cpp
index f843ea4..2f031bf 100644
--- a/services/incremental/BinderIncrementalService.cpp
+++ b/services/incremental/BinderIncrementalService.cpp
@@ -335,20 +335,6 @@
return ok();
}
-binder::Status BinderIncrementalService::registerStorageHealthListener(
- int32_t storageId,
- const ::android::os::incremental::StorageHealthCheckParams& healthCheckParams,
- const ::android::sp<IStorageHealthListener>& healthListener, bool* _aidl_return) {
- *_aidl_return =
- mImpl.registerStorageHealthListener(storageId, healthCheckParams, healthListener);
- return ok();
-}
-
-binder::Status BinderIncrementalService::unregisterStorageHealthListener(int32_t storageId) {
- mImpl.unregisterStorageHealthListener(storageId);
- return ok();
-}
-
binder::Status BinderIncrementalService::getMetrics(int32_t storageId,
android::os::PersistableBundle* _aidl_return) {
mImpl.getMetrics(storageId, _aidl_return);
diff --git a/services/incremental/BinderIncrementalService.h b/services/incremental/BinderIncrementalService.h
index 5c8741b..39f1bcb 100644
--- a/services/incremental/BinderIncrementalService.h
+++ b/services/incremental/BinderIncrementalService.h
@@ -95,11 +95,6 @@
progressListener,
bool* _aidl_return) final;
binder::Status unregisterLoadingProgressListener(int32_t storageId, bool* _aidl_return) final;
- binder::Status registerStorageHealthListener(
- int32_t storageId,
- const ::android::os::incremental::StorageHealthCheckParams& healthCheckParams,
- const ::android::sp<IStorageHealthListener>& healthListener, bool* _aidl_return) final;
- binder::Status unregisterStorageHealthListener(int32_t storageId) final;
binder::Status getMetrics(int32_t storageId,
android::os::PersistableBundle* _aidl_return) final;
diff --git a/services/incremental/IncrementalService.cpp b/services/incremental/IncrementalService.cpp
index 11a700c..4ce336d 100644
--- a/services/incremental/IncrementalService.cpp
+++ b/services/incremental/IncrementalService.cpp
@@ -2189,29 +2189,6 @@
return removeTimedJobs(*mProgressUpdateJobQueue, storage);
}
-bool IncrementalService::registerStorageHealthListener(
- StorageId storage, const StorageHealthCheckParams& healthCheckParams,
- StorageHealthListener healthListener) {
- DataLoaderStubPtr dataLoaderStub;
- {
- const auto& ifs = getIfs(storage);
- if (!ifs) {
- return false;
- }
- std::unique_lock l(ifs->lock);
- dataLoaderStub = ifs->dataLoaderStub;
- if (!dataLoaderStub) {
- return false;
- }
- }
- dataLoaderStub->setHealthListener(healthCheckParams, std::move(healthListener));
- return true;
-}
-
-void IncrementalService::unregisterStorageHealthListener(StorageId storage) {
- registerStorageHealthListener(storage, {}, {});
-}
-
bool IncrementalService::perfLoggingEnabled() {
static const bool enabled = base::GetBoolProperty("incremental.perflogging", false);
return enabled;
@@ -2779,25 +2756,6 @@
mStatusCondition.notify_all();
}
-binder::Status IncrementalService::DataLoaderStub::reportStreamHealth(MountId mountId,
- int newStatus) {
- if (!isValid()) {
- return binder::Status::
- fromServiceSpecificError(-EINVAL,
- "reportStreamHealth came to invalid DataLoaderStub");
- }
- if (id() != mountId) {
- LOG(ERROR) << "reportStreamHealth: mount ID mismatch: expected " << id()
- << ", but got: " << mountId;
- return binder::Status::fromServiceSpecificError(-EPERM, "Mount ID mismatch.");
- }
- {
- std::lock_guard lock(mMutex);
- mStreamStatus = newStatus;
- }
- return binder::Status::ok();
-}
-
bool IncrementalService::DataLoaderStub::isHealthParamsValid() const {
return mHealthCheckParams.blockedTimeoutMs > 0 &&
mHealthCheckParams.blockedTimeoutMs < mHealthCheckParams.unhealthyTimeoutMs;
@@ -2811,33 +2769,6 @@
}
}
-static int adjustHealthStatus(int healthStatus, int streamStatus) {
- if (healthStatus == IStorageHealthListener::HEALTH_STATUS_OK) {
- // everything is good; no need to change status
- return healthStatus;
- }
- int newHeathStatus = healthStatus;
- switch (streamStatus) {
- case IDataLoaderStatusListener::STREAM_STORAGE_ERROR:
- // storage is limited and storage not healthy
- newHeathStatus = IStorageHealthListener::HEALTH_STATUS_UNHEALTHY_STORAGE;
- break;
- case IDataLoaderStatusListener::STREAM_INTEGRITY_ERROR:
- // fall through
- case IDataLoaderStatusListener::STREAM_SOURCE_ERROR:
- // fall through
- case IDataLoaderStatusListener::STREAM_TRANSPORT_ERROR:
- if (healthStatus == IStorageHealthListener::HEALTH_STATUS_UNHEALTHY) {
- newHeathStatus = IStorageHealthListener::HEALTH_STATUS_UNHEALTHY_TRANSPORT;
- }
- // pending/blocked status due to transportation issues is not regarded as unhealthy
- break;
- default:
- break;
- }
- return newHeathStatus;
-}
-
void IncrementalService::DataLoaderStub::updateHealthStatus(bool baseline) {
LOG(DEBUG) << id() << ": updateHealthStatus" << (baseline ? " (baseline)" : "");
@@ -2915,8 +2846,6 @@
checkBackAfter = unhealthyMonitoring;
healthStatusToReport = IStorageHealthListener::HEALTH_STATUS_UNHEALTHY;
}
- // Adjust health status based on stream status
- healthStatusToReport = adjustHealthStatus(healthStatusToReport, mStreamStatus);
LOG(DEBUG) << id() << ": updateHealthStatus in " << double(checkBackAfter.count()) / 1000.0
<< "secs";
mService.addTimedJob(*mService.mTimedQueue, id(), checkBackAfter,
diff --git a/services/incremental/IncrementalService.h b/services/incremental/IncrementalService.h
index e3b1e6f..95a17d1 100644
--- a/services/incremental/IncrementalService.h
+++ b/services/incremental/IncrementalService.h
@@ -189,10 +189,7 @@
bool registerLoadingProgressListener(StorageId storage,
StorageLoadingProgressListener progressListener);
bool unregisterLoadingProgressListener(StorageId storage);
- bool registerStorageHealthListener(StorageId storage,
- const StorageHealthCheckParams& healthCheckParams,
- StorageHealthListener healthListener);
- void unregisterStorageHealthListener(StorageId storage);
+
RawMetadata getMetadata(StorageId storage, std::string_view path) const;
RawMetadata getMetadata(StorageId storage, FileId node) const;
@@ -256,7 +253,6 @@
private:
binder::Status onStatusChanged(MountId mount, int newStatus) final;
- binder::Status reportStreamHealth(MountId mount, int newStatus) final;
void setCurrentStatus(int newStatus);
@@ -319,7 +315,6 @@
BootClockTsUs kernelTsUs;
} mHealthBase = {TimePoint::max(), kMaxBootClockTsUs};
StorageHealthCheckParams mHealthCheckParams;
- int mStreamStatus = content::pm::IDataLoaderStatusListener::STREAM_HEALTHY;
std::vector<incfs::ReadInfoWithUid> mLastPendingReads;
};
using DataLoaderStubPtr = sp<DataLoaderStub>;
diff --git a/services/incremental/test/IncrementalServiceTest.cpp b/services/incremental/test/IncrementalServiceTest.cpp
index 14bcd4e..6a3d953 100644
--- a/services/incremental/test/IncrementalServiceTest.cpp
+++ b/services/incremental/test/IncrementalServiceTest.cpp
@@ -184,18 +184,6 @@
setAndReportStatus(id, IDataLoaderStatusListener::DATA_LOADER_IMAGE_READY);
return binder::Status::ok();
}
- binder::Status storageError(int32_t id) {
- if (mListener) {
- mListener->reportStreamHealth(id, IDataLoaderStatusListener::STREAM_STORAGE_ERROR);
- }
- return binder::Status::ok();
- }
- binder::Status transportError(int32_t id) {
- if (mListener) {
- mListener->reportStreamHealth(id, IDataLoaderStatusListener::STREAM_INTEGRITY_ERROR);
- }
- return binder::Status::ok();
- }
int32_t setStorageParams(bool enableReadLogs) {
int32_t result = -1;
EXPECT_NE(mServiceConnector.get(), nullptr);
@@ -1904,87 +1892,6 @@
ASSERT_EQ(mDataLoader->status(), IDataLoaderStatusListener::DATA_LOADER_DESTROYED);
}
-TEST_F(IncrementalServiceTest, testRegisterStorageHealthListenerSuccess) {
- mIncFs->openMountSuccess();
- sp<NiceMock<MockStorageHealthListener>> listener{new NiceMock<MockStorageHealthListener>};
- sp<NiceMock<MockStorageHealthListener>> newListener{new NiceMock<MockStorageHealthListener>};
- NiceMock<MockStorageHealthListener>* newListenerMock = newListener.get();
-
- TemporaryDir tempDir;
- int storageId =
- mIncrementalService->createStorage(tempDir.path, mDataLoaderParcel,
- IncrementalService::CreateOptions::CreateNew);
- ASSERT_GE(storageId, 0);
- mIncrementalService->startLoading(storageId, std::move(mDataLoaderParcel), {}, {}, listener,
- {});
-
- StorageHealthCheckParams newParams;
- newParams.blockedTimeoutMs = 10000;
- newParams.unhealthyTimeoutMs = 20000;
- newParams.unhealthyMonitoringMs = 30000;
- ASSERT_TRUE(mIncrementalService->registerStorageHealthListener(storageId, std::move(newParams),
- newListener));
-
- using MS = std::chrono::milliseconds;
- using MCS = std::chrono::microseconds;
-
- const auto blockedTimeout = MS(newParams.blockedTimeoutMs);
- const auto unhealthyTimeout = MS(newParams.unhealthyTimeoutMs);
-
- const uint64_t kFirstTimestampUs = 1000000000ll;
- const uint64_t kBlockedTimestampUs =
- kFirstTimestampUs - std::chrono::duration_cast<MCS>(blockedTimeout).count();
- const uint64_t kUnhealthyTimestampUs =
- kFirstTimestampUs - std::chrono::duration_cast<MCS>(unhealthyTimeout).count();
-
- // test that old listener was not called
- EXPECT_CALL(*listener.get(),
- onHealthStatus(_, IStorageHealthListener::HEALTH_STATUS_READS_PENDING))
- .Times(0);
- EXPECT_CALL(*newListenerMock,
- onHealthStatus(_, IStorageHealthListener::HEALTH_STATUS_READS_PENDING))
- .Times(1);
- EXPECT_CALL(*newListenerMock, onHealthStatus(_, IStorageHealthListener::HEALTH_STATUS_BLOCKED))
- .Times(1);
- EXPECT_CALL(*newListenerMock,
- onHealthStatus(_, IStorageHealthListener::HEALTH_STATUS_UNHEALTHY_STORAGE))
- .Times(1);
- EXPECT_CALL(*newListenerMock,
- onHealthStatus(_, IStorageHealthListener::HEALTH_STATUS_UNHEALTHY_TRANSPORT))
- .Times(1);
- mIncFs->waitForPendingReadsSuccess(kFirstTimestampUs);
- mLooper->mCallback(-1, -1, mLooper->mCallbackData);
-
- ASSERT_EQ(IStorageHealthListener::HEALTH_STATUS_READS_PENDING, newListener->mStatus);
- ASSERT_EQ(storageId, newListener->mStorageId);
-
- auto timedCallback = mTimedQueue->mWhat;
- mTimedQueue->clearJob(storageId);
-
- // test when health status is blocked with transport error
- mDataLoader->transportError(storageId);
- mIncFs->waitForPendingReadsSuccess(kBlockedTimestampUs);
- timedCallback();
- ASSERT_EQ(IStorageHealthListener::HEALTH_STATUS_BLOCKED, newListener->mStatus);
- timedCallback = mTimedQueue->mWhat;
- mTimedQueue->clearJob(storageId);
-
- // test when health status is blocked with storage error
- mDataLoader->storageError(storageId);
- mIncFs->waitForPendingReadsSuccess(kBlockedTimestampUs);
- timedCallback();
- ASSERT_EQ(IStorageHealthListener::HEALTH_STATUS_UNHEALTHY_STORAGE, newListener->mStatus);
- timedCallback = mTimedQueue->mWhat;
- mTimedQueue->clearJob(storageId);
-
- // test when health status is unhealthy with transport error
- mDataLoader->transportError(storageId);
- mIncFs->waitForPendingReadsSuccess(kUnhealthyTimestampUs);
- timedCallback();
- ASSERT_EQ(IStorageHealthListener::HEALTH_STATUS_UNHEALTHY_TRANSPORT, newListener->mStatus);
- mTimedQueue->clearJob(storageId);
-}
-
static std::vector<PerUidReadTimeouts> createPerUidTimeouts(
std::initializer_list<std::tuple<int, int, int, int>> tuples) {
std::vector<PerUidReadTimeouts> result;
diff --git a/services/tests/servicestests/src/com/android/server/pm/IncrementalStatesTest.java b/services/tests/servicestests/src/com/android/server/pm/IncrementalStatesTest.java
deleted file mode 100644
index 7b9a00d..0000000
--- a/services/tests/servicestests/src/com/android/server/pm/IncrementalStatesTest.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * Copyright (C) 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.server.pm;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import android.content.pm.PackageManager;
-import android.os.ConditionVariable;
-import android.os.incremental.IStorageHealthListener;
-import android.platform.test.annotations.Presubmit;
-
-import androidx.test.filters.MediumTest;
-import androidx.test.runner.AndroidJUnit4;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import java.util.concurrent.atomic.AtomicInteger;
-
-/**
- * Unit tests for {@link IncrementalStates}.
- * Run with: atest -c FrameworksServicesTests:com.android.server.pm.IncrementalStatesTest
- */
-@Presubmit
-@RunWith(AndroidJUnit4.class)
-@MediumTest
-public class IncrementalStatesTest {
- private IncrementalStates mIncrementalStates;
- private ConditionVariable mUnstartableCalled = new ConditionVariable();
- private ConditionVariable mFullyLoadedCalled = new ConditionVariable();
- private AtomicInteger mUnstartableReason = new AtomicInteger(0);
- private static final int WAIT_TIMEOUT_MILLIS = 1000; /* 1 second */
- private IncrementalStates.Callback mCallback = new IncrementalStates.Callback() {
- @Override
- public void onPackageUnstartable(int reason) {
- mUnstartableCalled.open();
- mUnstartableReason.set(reason);
- }
-
- @Override
- public void onPackageStartable() {
- }
-
- @Override
- public void onPackageFullyLoaded() {
- mFullyLoadedCalled.open();
- }
- };
-
- /**
- * Setup the tests as if the package has just been committed.
- * By default the package is now startable and is loading.
- */
- @Before
- public void setUp() {
- mIncrementalStates = new IncrementalStates();
- assertFalse(mIncrementalStates.getIncrementalStatesInfo().isStartable());
- mIncrementalStates.setCallback(mCallback);
- mIncrementalStates.onCommit(true);
- // Test that package is now startable and loading
- assertTrue(mIncrementalStates.getIncrementalStatesInfo().isStartable());
- assertTrue(mIncrementalStates.getIncrementalStatesInfo().isLoading());
- mUnstartableCalled.close();
- mFullyLoadedCalled.close();
- }
-
- /**
- * Test that the package is still startable when Incremental Storage is unhealthy.
- */
- @Test
- public void testStartableTransition_IncrementalStorageUnhealthy() {
- mIncrementalStates.onStorageHealthStatusChanged(
- IStorageHealthListener.HEALTH_STATUS_UNHEALTHY);
- // Test that package is still startable
- assertFalse(mUnstartableCalled.block(WAIT_TIMEOUT_MILLIS));
- assertTrue(mIncrementalStates.getIncrementalStatesInfo().isStartable());
- assertEquals(PackageManager.UNSTARTABLE_REASON_UNKNOWN, mUnstartableReason.get());
- }
-
- /**
- * Test that the package is still startable when Incremental Storage has pending reads.
- */
- @Test
- public void testStartableTransition_IncrementalStorageReadsPending()
- throws InterruptedException {
- mIncrementalStates.onStorageHealthStatusChanged(
- IStorageHealthListener.HEALTH_STATUS_READS_PENDING);
- // Test that package is still startable
- assertFalse(mUnstartableCalled.block(WAIT_TIMEOUT_MILLIS));
- assertTrue(mIncrementalStates.getIncrementalStatesInfo().isStartable());
- }
-
- /**
- * Test that the package is still startable when health status indicate storage issues.
- */
- @Test
- public void testStartableTransition_IncrementalStorageBlocked() {
- mIncrementalStates.onStorageHealthStatusChanged(
- IStorageHealthListener.HEALTH_STATUS_UNHEALTHY_STORAGE);
- // Test that package is still startable
- assertFalse(mUnstartableCalled.block(WAIT_TIMEOUT_MILLIS));
- assertTrue(mIncrementalStates.getIncrementalStatesInfo().isStartable());
- assertEquals(PackageManager.UNSTARTABLE_REASON_UNKNOWN,
- mUnstartableReason.get());
- }
-
- /**
- * Test that the package is still startable when health status indicates transport issues.
- */
- @Test
- public void testStartableTransition_DataLoaderIntegrityError() {
- mIncrementalStates.onStorageHealthStatusChanged(
- IStorageHealthListener.HEALTH_STATUS_UNHEALTHY_TRANSPORT);
- // Test that package is still startable
- assertFalse(mUnstartableCalled.block(WAIT_TIMEOUT_MILLIS));
- assertTrue(mIncrementalStates.getIncrementalStatesInfo().isStartable());
- assertEquals(PackageManager.UNSTARTABLE_REASON_UNKNOWN,
- mUnstartableReason.get());
- }
-
- /**
- * Test that when loading progress is 1, the package becomes fully loaded, and the change of
- * Incremental Storage health status does not affect the startable state.
- */
- @Test
- public void testStartableTransition_HealthStatusChangeWhenFullyLoaded()
- throws InterruptedException {
- mIncrementalStates.setProgress(1.0f);
- // Test that package is now fully loaded
- assertTrue(mFullyLoadedCalled.block(WAIT_TIMEOUT_MILLIS));
- assertFalse(mIncrementalStates.getIncrementalStatesInfo().isLoading());
- mIncrementalStates.onStorageHealthStatusChanged(
- IStorageHealthListener.HEALTH_STATUS_UNHEALTHY);
- // Test that package is still startable
- assertFalse(mUnstartableCalled.block(WAIT_TIMEOUT_MILLIS));
- assertTrue(mIncrementalStates.getIncrementalStatesInfo().isStartable());
- }
-
- /**
- * Test startability transitions if app crashes or anrs
- */
- @Test
- public void testStartableTransition_AppCrashOrAnr() {
- mIncrementalStates.onCrashOrAnr();
- assertTrue(mIncrementalStates.getIncrementalStatesInfo().isStartable());
- }
-}