Remove unused code (3/n)

(Cherry-picked from 2f777b39b7)

Bug: 149663536
Test: m
Merged-In: Ia233ca642d58b7b6a0984359ea11958f8d9a8ff8
Change-Id: Ia233ca642d58b7b6a0984359ea11958f8d9a8ff8
This commit is contained in:
JW Wang
2020-02-17 17:08:02 +08:00
parent 635382efc6
commit 298239b59e
4 changed files with 6 additions and 91 deletions

View File

@@ -844,20 +844,6 @@ public abstract class PackageManagerInternal {
public static final String 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
* for a package.

View File

@@ -1982,9 +1982,6 @@ public class PackageManagerService extends IPackageManager.Stub
params.handleRollbackEnabled();
Intent rollbackTimeoutIntent = new Intent(
Intent.ACTION_CANCEL_ENABLE_ROLLBACK);
rollbackTimeoutIntent.putExtra(
PackageManagerInternal.EXTRA_ENABLE_ROLLBACK_TOKEN,
enableRollbackToken);
rollbackTimeoutIntent.putExtra(
PackageManagerInternal.EXTRA_ENABLE_ROLLBACK_SESSION_ID,
sessionId);
@@ -14538,17 +14535,10 @@ public class PackageManagerService extends IPackageManager.Stub
enableRollbackIntent.putExtra(
PackageManagerInternal.EXTRA_ENABLE_ROLLBACK_TOKEN,
enableRollbackToken);
enableRollbackIntent.putExtra(
PackageManagerInternal.EXTRA_ENABLE_ROLLBACK_INSTALL_FLAGS,
installFlags);
enableRollbackIntent.putExtra(
PackageManagerInternal.EXTRA_ENABLE_ROLLBACK_USER,
getRollbackUser().getIdentifier());
enableRollbackIntent.putExtra(
PackageManagerInternal.EXTRA_ENABLE_ROLLBACK_SESSION_ID,
mSessionId);
enableRollbackIntent.setDataAndType(Uri.fromFile(new File(origin.resolvedPath)),
PACKAGE_MIME_TYPE);
enableRollbackIntent.setType(PACKAGE_MIME_TYPE);
enableRollbackIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
// Allow the broadcast to be sent before boot complete.

View File

@@ -158,13 +158,6 @@ class Rollback {
*/
@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
* 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}.
*/

View File

@@ -20,7 +20,6 @@ import android.Manifest;
import android.annotation.AnyThread;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.UserIdInt;
import android.annotation.WorkerThread;
import android.app.AppOpsManager;
import android.content.BroadcastReceiver;
@@ -201,20 +200,13 @@ class RollbackManagerServiceImpl extends IRollbackManager.Stub {
if (Intent.ACTION_PACKAGE_ENABLE_ROLLBACK.equals(intent.getAction())) {
int token = intent.getIntExtra(
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(
PackageManagerInternal.EXTRA_ENABLE_ROLLBACK_SESSION_ID, -1);
File newPackageCodePath = new File(intent.getData().getPath());
queueSleepIfNeeded();
getHandler().post(() -> {
boolean success = enableRollback(
sessionId, installFlags, newPackageCodePath, user, token);
boolean success = enableRollback(sessionId);
int ret = PackageManagerInternal.ENABLE_ROLLBACK_SUCCEEDED;
if (!success) {
ret = PackageManagerInternal.ENABLE_ROLLBACK_FAILED;
@@ -240,12 +232,10 @@ class RollbackManagerServiceImpl extends IRollbackManager.Stub {
@Override
public void onReceive(Context context, Intent intent) {
if (Intent.ACTION_CANCEL_ENABLE_ROLLBACK.equals(intent.getAction())) {
int token = intent.getIntExtra(
PackageManagerInternal.EXTRA_ENABLE_ROLLBACK_TOKEN, -1);
int sessionId = intent.getIntExtra(
PackageManagerInternal.EXTRA_ENABLE_ROLLBACK_SESSION_ID, -1);
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) {
Rollback rollback = getRollbackForSessionLocked(sessionId);
@@ -685,24 +675,6 @@ class RollbackManagerServiceImpl extends IRollbackManager.Stub {
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
private Context getContextAsUser(UserHandle user) {
try {
@@ -717,18 +689,13 @@ class RollbackManagerServiceImpl extends IRollbackManager.Stub {
* staged for install with rollback enabled. Called before the package has
* been installed.
*
* @param installFlags information about what is being installed.
* @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.
* @param sessionId the id of the install session
* @return true if enabling the rollback succeeds, false otherwise.
*/
@WorkerThread
private boolean enableRollback(int sessionId,
int installFlags, File newPackageCodePath, @UserIdInt int user, int token) {
private boolean enableRollback(int sessionId) {
if (LOCAL_LOGV) {
Slog.v(TAG, "enableRollback user=" + user + " token=" + token
+ " path=" + newPackageCodePath.getAbsolutePath());
Slog.v(TAG, "enableRollback sessionId=" + sessionId);
}
PackageInstaller installer = mContext.getPackageManager().getPackageInstaller();
@@ -778,7 +745,6 @@ class RollbackManagerServiceImpl extends IRollbackManager.Stub {
newRollback = createNewRollbackLocked(parentSession);
}
}
newRollback.addToken(token);
return enableRollbackForPackageSession(newRollback, packageSession);
}