diff options
author | Neil Fuller <nfuller@google.com> | 2017-09-22 17:21:47 +0100 |
---|---|---|
committer | Neil Fuller <nfuller@google.com> | 2017-09-25 16:42:48 +0100 |
commit | fd43ac2097fe9104acdeaea23dcd45acce69cbfc (patch) | |
tree | 9a29efcd6e14f44634331007acafcb0259a51660 | |
parent | 9aa9079aa811ac07552ba258a021a849cd5c4e63 (diff) | |
download | TimeZoneUpdater-fd43ac2097fe9104acdeaea23dcd45acce69cbfc.tar.gz |
Explicitly disallow multiple user execute
Explicitly disallow multiple user execution:
it's not expected because everything runs as system
but this change explicitly rules out execution.
Test: Manual testing installing updates as secondary device user
Test: PTS: run pts -m PtsTimeZoneTestCases
Bug: 64111659
Change-Id: I8cde1dc38061f47fc70821cc44d05372227a1104
-rw-r--r-- | src/main/com/android/timezone/updater/RulesCheckReceiver.java | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/main/com/android/timezone/updater/RulesCheckReceiver.java b/src/main/com/android/timezone/updater/RulesCheckReceiver.java index 92a8bd5..003b2e4 100644 --- a/src/main/com/android/timezone/updater/RulesCheckReceiver.java +++ b/src/main/com/android/timezone/updater/RulesCheckReceiver.java @@ -30,6 +30,7 @@ import android.content.pm.ProviderInfo; import android.database.Cursor; import android.net.Uri; import android.os.ParcelFileDescriptor; +import android.os.UserHandle; import android.provider.TimeZoneRulesDataContract; import android.util.Log; @@ -85,6 +86,17 @@ public class RulesCheckReceiver extends BroadcastReceiver { + ", action=" + intent.getAction()); return; } + + // The time zone update process should run as the system user exclusively as it's a + // system feature, not user dependent. + UserHandle currentUserHandle = android.os.Process.myUserHandle(); + if (!currentUserHandle.isSystem()) { + // Just do nothing. + Log.w(TAG, "Supposed to be running as the system user," + + " instead running as user=" + currentUserHandle); + return; + } + mRulesManager = (RulesManager) context.getSystemService("timezone"); byte[] token = intent.getByteArrayExtra(RulesUpdaterContract.EXTRA_CHECK_TOKEN); |