Merge "Only allow the system server to connect to sync adapters" into qt-dev am: 99ccb4e5b0
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18701369 Change-Id: Ie919bc05747a1009507a29de429c3e8d043fed9d Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -21,6 +21,7 @@ import static com.android.internal.util.function.pooled.PooledLambda.obtainMessa
|
|||||||
import android.accounts.Account;
|
import android.accounts.Account;
|
||||||
import android.annotation.MainThread;
|
import android.annotation.MainThread;
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
|
import android.os.Binder;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
@@ -171,8 +172,20 @@ public abstract class AbstractThreadedSyncAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class ISyncAdapterImpl extends ISyncAdapter.Stub {
|
private class ISyncAdapterImpl extends ISyncAdapter.Stub {
|
||||||
|
private boolean isCallerSystem() {
|
||||||
|
final long callingUid = Binder.getCallingUid();
|
||||||
|
if (callingUid != Process.SYSTEM_UID) {
|
||||||
|
android.util.EventLog.writeEvent(0x534e4554, "203229608", -1, "");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onUnsyncableAccount(ISyncAdapterUnsyncableAccountCallback cb) {
|
public void onUnsyncableAccount(ISyncAdapterUnsyncableAccountCallback cb) {
|
||||||
|
if (!isCallerSystem()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
Handler.getMain().sendMessage(obtainMessage(
|
Handler.getMain().sendMessage(obtainMessage(
|
||||||
AbstractThreadedSyncAdapter::handleOnUnsyncableAccount,
|
AbstractThreadedSyncAdapter::handleOnUnsyncableAccount,
|
||||||
AbstractThreadedSyncAdapter.this, cb));
|
AbstractThreadedSyncAdapter.this, cb));
|
||||||
@@ -181,12 +194,16 @@ public abstract class AbstractThreadedSyncAdapter {
|
|||||||
@Override
|
@Override
|
||||||
public void startSync(ISyncContext syncContext, String authority, Account account,
|
public void startSync(ISyncContext syncContext, String authority, Account account,
|
||||||
Bundle extras) {
|
Bundle extras) {
|
||||||
|
if (!isCallerSystem()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (ENABLE_LOG) {
|
if (ENABLE_LOG) {
|
||||||
if (extras != null) {
|
if (extras != null) {
|
||||||
extras.size(); // Unparcel so its toString() will show the contents.
|
extras.size(); // Unparcel so its toString() will show the contents.
|
||||||
}
|
}
|
||||||
Log.d(TAG, "startSync() start " + authority + " " + account + " " + extras);
|
Log.d(TAG, "startSync() start " + authority + " " + account + " " + extras);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final SyncContext syncContextClient = new SyncContext(syncContext);
|
final SyncContext syncContextClient = new SyncContext(syncContext);
|
||||||
|
|
||||||
@@ -242,6 +259,9 @@ public abstract class AbstractThreadedSyncAdapter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void cancelSync(ISyncContext syncContext) {
|
public void cancelSync(ISyncContext syncContext) {
|
||||||
|
if (!isCallerSystem()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
// synchronize to make sure that mSyncThreads doesn't change between when we
|
// synchronize to make sure that mSyncThreads doesn't change between when we
|
||||||
// check it and when we use it
|
// check it and when we use it
|
||||||
|
|||||||
Reference in New Issue
Block a user