Merge "Clean up the multi-client ror code" am: 1fb84f4d31
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1532260 MUST ONLY BE SUBMITTED BY AUTOMERGER Change-Id: Ibc4d753f99904567b57b29fcf2f20e2aef26f03d
This commit is contained in:
@@ -32,6 +32,8 @@ import android.os.RemoteException;
|
|||||||
import android.os.ResultReceiver;
|
import android.os.ResultReceiver;
|
||||||
import android.os.ShellCallback;
|
import android.os.ShellCallback;
|
||||||
import android.os.SystemProperties;
|
import android.os.SystemProperties;
|
||||||
|
import android.util.ArrayMap;
|
||||||
|
import android.util.ArraySet;
|
||||||
import android.util.Slog;
|
import android.util.Slog;
|
||||||
|
|
||||||
import com.android.internal.annotations.GuardedBy;
|
import com.android.internal.annotations.GuardedBy;
|
||||||
@@ -49,10 +51,6 @@ import java.io.FileDescriptor;
|
|||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The recovery system service is responsible for coordinating recovery related
|
* The recovery system service is responsible for coordinating recovery related
|
||||||
@@ -84,9 +82,9 @@ public class RecoverySystemService extends IRecoverySystem.Stub implements Reboo
|
|||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
|
|
||||||
@GuardedBy("this")
|
@GuardedBy("this")
|
||||||
private final Map<String, IntentSender> mCallerPendingRequest = new HashMap<>();
|
private final ArrayMap<String, IntentSender> mCallerPendingRequest = new ArrayMap<>();
|
||||||
@GuardedBy("this")
|
@GuardedBy("this")
|
||||||
private final Set<String> mCallerPreparedForReboot = new HashSet<>();
|
private final ArraySet<String> mCallerPreparedForReboot = new ArraySet<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Need to prepare for resume on reboot.
|
* Need to prepare for resume on reboot.
|
||||||
@@ -121,7 +119,7 @@ public class RecoverySystemService extends IRecoverySystem.Stub implements Reboo
|
|||||||
@IntDef({ ROR_NEED_PREPARATION,
|
@IntDef({ ROR_NEED_PREPARATION,
|
||||||
ROR_SKIP_PREPARATION_AND_NOTIFY,
|
ROR_SKIP_PREPARATION_AND_NOTIFY,
|
||||||
ROR_SKIP_PREPARATION_NOT_NOTIFY })
|
ROR_SKIP_PREPARATION_NOT_NOTIFY })
|
||||||
@interface ResumeOnRebootActionsOnRequest {}
|
private @interface ResumeOnRebootActionsOnRequest {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The action to perform upon resume on reboot clear request for a given client.
|
* The action to perform upon resume on reboot clear request for a given client.
|
||||||
@@ -129,7 +127,7 @@ public class RecoverySystemService extends IRecoverySystem.Stub implements Reboo
|
|||||||
@IntDef({ROR_NOT_REQUESTED,
|
@IntDef({ROR_NOT_REQUESTED,
|
||||||
ROR_REQUESTED_NEED_CLEAR,
|
ROR_REQUESTED_NEED_CLEAR,
|
||||||
ROR_REQUESTED_SKIP_CLEAR})
|
ROR_REQUESTED_SKIP_CLEAR})
|
||||||
@interface ResumeOnRebootActionsOnClear{}
|
private @interface ResumeOnRebootActionsOnClear{}
|
||||||
|
|
||||||
static class Injector {
|
static class Injector {
|
||||||
protected final Context mContext;
|
protected final Context mContext;
|
||||||
@@ -342,9 +340,8 @@ public class RecoverySystemService extends IRecoverySystem.Stub implements Reboo
|
|||||||
!= PackageManager.PERMISSION_GRANTED
|
!= PackageManager.PERMISSION_GRANTED
|
||||||
&& mContext.checkCallingOrSelfPermission(android.Manifest.permission.REBOOT)
|
&& mContext.checkCallingOrSelfPermission(android.Manifest.permission.REBOOT)
|
||||||
!= PackageManager.PERMISSION_GRANTED) {
|
!= PackageManager.PERMISSION_GRANTED) {
|
||||||
throw new SecurityException("Caller or self must have "
|
throw new SecurityException("Caller must have " + android.Manifest.permission.RECOVERY
|
||||||
+ android.Manifest.permission.RECOVERY + " or "
|
+ " or " + android.Manifest.permission.REBOOT + " for resume on reboot.");
|
||||||
+ android.Manifest.permission.REBOOT + " for resume on reboot.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -414,10 +411,14 @@ public class RecoverySystemService extends IRecoverySystem.Stub implements Reboo
|
|||||||
Slog.w(TAG, "onPreparedForReboot called when some clients have prepared.");
|
Slog.w(TAG, "onPreparedForReboot called when some clients have prepared.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mCallerPendingRequest.isEmpty()) {
|
||||||
|
Slog.w(TAG, "onPreparedForReboot called but no client has requested.");
|
||||||
|
}
|
||||||
|
|
||||||
// Send intents to notify callers
|
// Send intents to notify callers
|
||||||
for (Map.Entry<String, IntentSender> entry : mCallerPendingRequest.entrySet()) {
|
for (int i = 0; i < mCallerPendingRequest.size(); i++) {
|
||||||
sendPreparedForRebootIntentIfNeeded(entry.getValue());
|
sendPreparedForRebootIntentIfNeeded(mCallerPendingRequest.valueAt(i));
|
||||||
mCallerPreparedForReboot.add(entry.getKey());
|
mCallerPreparedForReboot.add(mCallerPendingRequest.keyAt(i));
|
||||||
}
|
}
|
||||||
mCallerPendingRequest.clear();
|
mCallerPendingRequest.clear();
|
||||||
}
|
}
|
||||||
@@ -499,10 +500,16 @@ public class RecoverySystemService extends IRecoverySystem.Stub implements Reboo
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override // Binder call
|
@Override // Binder call
|
||||||
public synchronized boolean isLskfCaptured(String packageName) {
|
public boolean isLskfCaptured(String packageName) {
|
||||||
enforcePermissionForResumeOnReboot();
|
enforcePermissionForResumeOnReboot();
|
||||||
if (!mCallerPreparedForReboot.contains(packageName)) {
|
boolean captured;
|
||||||
Slog.i(TAG, "Reboot requested before prepare completed for caller " + packageName);
|
synchronized (this) {
|
||||||
|
captured = mCallerPreparedForReboot.contains(packageName);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!captured) {
|
||||||
|
Slog.i(TAG, "Reboot requested before prepare completed for caller "
|
||||||
|
+ packageName);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user