Merge changes Ia233ca64,I2d0bc216,I94003873 into rvc-dev am: f8d52afa16
Change-Id: I91b06d0003914645f1b155ffbc6ce2e19210a5eb
This commit is contained in:
@@ -844,20 +844,6 @@ public abstract class PackageManagerInternal {
|
|||||||
public static final String EXTRA_ENABLE_ROLLBACK_TOKEN =
|
public static final String EXTRA_ENABLE_ROLLBACK_TOKEN =
|
||||||
"android.content.pm.extra.ENABLE_ROLLBACK_TOKEN";
|
"android.content.pm.extra.ENABLE_ROLLBACK_TOKEN";
|
||||||
|
|
||||||
/**
|
|
||||||
* Extra field name for the installFlags of a request to enable rollback
|
|
||||||
* for a package.
|
|
||||||
*/
|
|
||||||
public static final String EXTRA_ENABLE_ROLLBACK_INSTALL_FLAGS =
|
|
||||||
"android.content.pm.extra.ENABLE_ROLLBACK_INSTALL_FLAGS";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Extra field name for the user id an install is associated with when
|
|
||||||
* enabling rollback.
|
|
||||||
*/
|
|
||||||
public static final String EXTRA_ENABLE_ROLLBACK_USER =
|
|
||||||
"android.content.pm.extra.ENABLE_ROLLBACK_USER";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extra field name for the session id of a request to enable rollback
|
* Extra field name for the session id of a request to enable rollback
|
||||||
* for a package.
|
* for a package.
|
||||||
|
|||||||
@@ -1982,9 +1982,6 @@ public class PackageManagerService extends IPackageManager.Stub
|
|||||||
params.handleRollbackEnabled();
|
params.handleRollbackEnabled();
|
||||||
Intent rollbackTimeoutIntent = new Intent(
|
Intent rollbackTimeoutIntent = new Intent(
|
||||||
Intent.ACTION_CANCEL_ENABLE_ROLLBACK);
|
Intent.ACTION_CANCEL_ENABLE_ROLLBACK);
|
||||||
rollbackTimeoutIntent.putExtra(
|
|
||||||
PackageManagerInternal.EXTRA_ENABLE_ROLLBACK_TOKEN,
|
|
||||||
enableRollbackToken);
|
|
||||||
rollbackTimeoutIntent.putExtra(
|
rollbackTimeoutIntent.putExtra(
|
||||||
PackageManagerInternal.EXTRA_ENABLE_ROLLBACK_SESSION_ID,
|
PackageManagerInternal.EXTRA_ENABLE_ROLLBACK_SESSION_ID,
|
||||||
sessionId);
|
sessionId);
|
||||||
@@ -14555,17 +14552,10 @@ public class PackageManagerService extends IPackageManager.Stub
|
|||||||
enableRollbackIntent.putExtra(
|
enableRollbackIntent.putExtra(
|
||||||
PackageManagerInternal.EXTRA_ENABLE_ROLLBACK_TOKEN,
|
PackageManagerInternal.EXTRA_ENABLE_ROLLBACK_TOKEN,
|
||||||
enableRollbackToken);
|
enableRollbackToken);
|
||||||
enableRollbackIntent.putExtra(
|
|
||||||
PackageManagerInternal.EXTRA_ENABLE_ROLLBACK_INSTALL_FLAGS,
|
|
||||||
installFlags);
|
|
||||||
enableRollbackIntent.putExtra(
|
|
||||||
PackageManagerInternal.EXTRA_ENABLE_ROLLBACK_USER,
|
|
||||||
getRollbackUser().getIdentifier());
|
|
||||||
enableRollbackIntent.putExtra(
|
enableRollbackIntent.putExtra(
|
||||||
PackageManagerInternal.EXTRA_ENABLE_ROLLBACK_SESSION_ID,
|
PackageManagerInternal.EXTRA_ENABLE_ROLLBACK_SESSION_ID,
|
||||||
mSessionId);
|
mSessionId);
|
||||||
enableRollbackIntent.setDataAndType(Uri.fromFile(new File(origin.resolvedPath)),
|
enableRollbackIntent.setType(PACKAGE_MIME_TYPE);
|
||||||
PACKAGE_MIME_TYPE);
|
|
||||||
enableRollbackIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
enableRollbackIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||||
|
|
||||||
// Allow the broadcast to be sent before boot complete.
|
// Allow the broadcast to be sent before boot complete.
|
||||||
|
|||||||
@@ -158,13 +158,6 @@ class Rollback {
|
|||||||
*/
|
*/
|
||||||
@Nullable public final String mInstallerPackageName;
|
@Nullable public final String mInstallerPackageName;
|
||||||
|
|
||||||
/**
|
|
||||||
* This array holds all of the rollback tokens associated with package sessions included in
|
|
||||||
* this rollback.
|
|
||||||
*/
|
|
||||||
@GuardedBy("mLock")
|
|
||||||
private final IntArray mTokens = new IntArray();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Session ids for all packages in the install. For multi-package sessions, this is the list
|
* Session ids for all packages in the install. For multi-package sessions, this is the list
|
||||||
* of child session ids. For normal sessions, this list is a single element with the normal
|
* of child session ids. For normal sessions, this list is a single element with the normal
|
||||||
@@ -768,26 +761,6 @@ class Rollback {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds a rollback token to be associated with this rollback. This may be used to
|
|
||||||
* identify which rollback should be removed in case {@link PackageManager} sends an
|
|
||||||
* {@link Intent#ACTION_CANCEL_ENABLE_ROLLBACK} intent.
|
|
||||||
*/
|
|
||||||
void addToken(int token) {
|
|
||||||
synchronized (mLock) {
|
|
||||||
mTokens.add(token);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if this rollback is associated with the provided {@code token}.
|
|
||||||
*/
|
|
||||||
boolean hasToken(int token) {
|
|
||||||
synchronized (mLock) {
|
|
||||||
return mTokens.indexOf(token) != -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if this rollback contains the provided {@code packageSessionId}.
|
* Returns true if this rollback contains the provided {@code packageSessionId}.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ import android.Manifest;
|
|||||||
import android.annotation.AnyThread;
|
import android.annotation.AnyThread;
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
import android.annotation.UserIdInt;
|
|
||||||
import android.annotation.WorkerThread;
|
import android.annotation.WorkerThread;
|
||||||
import android.app.AppOpsManager;
|
import android.app.AppOpsManager;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
@@ -201,20 +200,13 @@ class RollbackManagerServiceImpl extends IRollbackManager.Stub {
|
|||||||
if (Intent.ACTION_PACKAGE_ENABLE_ROLLBACK.equals(intent.getAction())) {
|
if (Intent.ACTION_PACKAGE_ENABLE_ROLLBACK.equals(intent.getAction())) {
|
||||||
int token = intent.getIntExtra(
|
int token = intent.getIntExtra(
|
||||||
PackageManagerInternal.EXTRA_ENABLE_ROLLBACK_TOKEN, -1);
|
PackageManagerInternal.EXTRA_ENABLE_ROLLBACK_TOKEN, -1);
|
||||||
int installFlags = intent.getIntExtra(
|
|
||||||
PackageManagerInternal.EXTRA_ENABLE_ROLLBACK_INSTALL_FLAGS, 0);
|
|
||||||
int user = intent.getIntExtra(
|
|
||||||
PackageManagerInternal.EXTRA_ENABLE_ROLLBACK_USER, 0);
|
|
||||||
int sessionId = intent.getIntExtra(
|
int sessionId = intent.getIntExtra(
|
||||||
PackageManagerInternal.EXTRA_ENABLE_ROLLBACK_SESSION_ID, -1);
|
PackageManagerInternal.EXTRA_ENABLE_ROLLBACK_SESSION_ID, -1);
|
||||||
|
|
||||||
File newPackageCodePath = new File(intent.getData().getPath());
|
|
||||||
|
|
||||||
queueSleepIfNeeded();
|
queueSleepIfNeeded();
|
||||||
|
|
||||||
getHandler().post(() -> {
|
getHandler().post(() -> {
|
||||||
boolean success = enableRollback(
|
boolean success = enableRollback(sessionId);
|
||||||
sessionId, installFlags, newPackageCodePath, user, token);
|
|
||||||
int ret = PackageManagerInternal.ENABLE_ROLLBACK_SUCCEEDED;
|
int ret = PackageManagerInternal.ENABLE_ROLLBACK_SUCCEEDED;
|
||||||
if (!success) {
|
if (!success) {
|
||||||
ret = PackageManagerInternal.ENABLE_ROLLBACK_FAILED;
|
ret = PackageManagerInternal.ENABLE_ROLLBACK_FAILED;
|
||||||
@@ -240,12 +232,10 @@ class RollbackManagerServiceImpl extends IRollbackManager.Stub {
|
|||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
if (Intent.ACTION_CANCEL_ENABLE_ROLLBACK.equals(intent.getAction())) {
|
if (Intent.ACTION_CANCEL_ENABLE_ROLLBACK.equals(intent.getAction())) {
|
||||||
int token = intent.getIntExtra(
|
|
||||||
PackageManagerInternal.EXTRA_ENABLE_ROLLBACK_TOKEN, -1);
|
|
||||||
int sessionId = intent.getIntExtra(
|
int sessionId = intent.getIntExtra(
|
||||||
PackageManagerInternal.EXTRA_ENABLE_ROLLBACK_SESSION_ID, -1);
|
PackageManagerInternal.EXTRA_ENABLE_ROLLBACK_SESSION_ID, -1);
|
||||||
if (LOCAL_LOGV) {
|
if (LOCAL_LOGV) {
|
||||||
Slog.v(TAG, "broadcast=ACTION_CANCEL_ENABLE_ROLLBACK token=" + token);
|
Slog.v(TAG, "broadcast=ACTION_CANCEL_ENABLE_ROLLBACK id=" + sessionId);
|
||||||
}
|
}
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
Rollback rollback = getRollbackForSessionLocked(sessionId);
|
Rollback rollback = getRollbackForSessionLocked(sessionId);
|
||||||
@@ -685,24 +675,6 @@ class RollbackManagerServiceImpl extends IRollbackManager.Stub {
|
|||||||
return mHandlerThread.getThreadHandler();
|
return mHandlerThread.getThreadHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns true if <code>session</code> has installFlags and code path
|
|
||||||
// matching the installFlags and new package code path given to
|
|
||||||
// enableRollback.
|
|
||||||
@WorkerThread
|
|
||||||
private boolean sessionMatchesForEnableRollback(PackageInstaller.SessionInfo session,
|
|
||||||
int installFlags, File newPackageCodePath) {
|
|
||||||
if (session == null || session.resolvedBaseCodePath == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
File packageCodePath = new File(session.resolvedBaseCodePath).getParentFile();
|
|
||||||
if (newPackageCodePath.equals(packageCodePath) && installFlags == session.installFlags) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@AnyThread
|
@AnyThread
|
||||||
private Context getContextAsUser(UserHandle user) {
|
private Context getContextAsUser(UserHandle user) {
|
||||||
try {
|
try {
|
||||||
@@ -717,18 +689,13 @@ class RollbackManagerServiceImpl extends IRollbackManager.Stub {
|
|||||||
* staged for install with rollback enabled. Called before the package has
|
* staged for install with rollback enabled. Called before the package has
|
||||||
* been installed.
|
* been installed.
|
||||||
*
|
*
|
||||||
* @param installFlags information about what is being installed.
|
* @param sessionId the id of the install session
|
||||||
* @param newPackageCodePath path to the package about to be installed.
|
|
||||||
* @param user the user that owns the install session to enable rollback on.
|
|
||||||
* @param token the distinct rollback token sent by package manager.
|
|
||||||
* @return true if enabling the rollback succeeds, false otherwise.
|
* @return true if enabling the rollback succeeds, false otherwise.
|
||||||
*/
|
*/
|
||||||
@WorkerThread
|
@WorkerThread
|
||||||
private boolean enableRollback(int sessionId,
|
private boolean enableRollback(int sessionId) {
|
||||||
int installFlags, File newPackageCodePath, @UserIdInt int user, int token) {
|
|
||||||
if (LOCAL_LOGV) {
|
if (LOCAL_LOGV) {
|
||||||
Slog.v(TAG, "enableRollback user=" + user + " token=" + token
|
Slog.v(TAG, "enableRollback sessionId=" + sessionId);
|
||||||
+ " path=" + newPackageCodePath.getAbsolutePath());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PackageInstaller installer = mContext.getPackageManager().getPackageInstaller();
|
PackageInstaller installer = mContext.getPackageManager().getPackageInstaller();
|
||||||
@@ -778,7 +745,6 @@ class RollbackManagerServiceImpl extends IRollbackManager.Stub {
|
|||||||
newRollback = createNewRollbackLocked(parentSession);
|
newRollback = createNewRollbackLocked(parentSession);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
newRollback.addToken(token);
|
|
||||||
|
|
||||||
return enableRollbackForPackageSession(newRollback, packageSession);
|
return enableRollbackForPackageSession(newRollback, packageSession);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user