Merge "Add null pointer judgment processing to prevent restarting" into main
diff --git a/ADPF_OWNERS b/ADPF_OWNERS
new file mode 100644
index 0000000..e6ca8f4
--- /dev/null
+++ b/ADPF_OWNERS
@@ -0,0 +1,3 @@
+lpy@google.com
+mattbuckley@google.com
+xwxw@google.com
diff --git a/OWNERS b/OWNERS
index 4860acc..8ee488d 100644
--- a/OWNERS
+++ b/OWNERS
@@ -31,9 +31,6 @@
per-file */res*/values*/*.xml = byi@google.com, delphij@google.com
per-file **.bp,**.mk = hansson@google.com
-per-file *.bp = file:platform/build/soong:/OWNERS #{LAST_RESORT_SUGGESTION}
-per-file Android.mk = file:platform/build/soong:/OWNERS #{LAST_RESORT_SUGGESTION}
-per-file framework-jarjar-rules.txt = file:platform/build/soong:/OWNERS #{LAST_RESORT_SUGGESTION}
per-file TestProtoLibraries.bp = file:platform/platform_testing:/libraries/health/OWNERS
per-file TestProtoLibraries.bp = file:platform/tools/tradefederation:/OWNERS
diff --git a/core/java/android/nfc/NfcAdapter.java b/core/java/android/nfc/NfcAdapter.java
index b749d69..7d0cf9c 100644
--- a/core/java/android/nfc/NfcAdapter.java
+++ b/core/java/android/nfc/NfcAdapter.java
@@ -642,6 +642,7 @@
try {
sTagService = sService.getNfcTagInterface();
} catch (RemoteException e) {
+ sTagService = null;
Log.e(TAG, "could not retrieve NFC Tag service");
throw new UnsupportedOperationException();
}
@@ -650,12 +651,14 @@
try {
sNfcFCardEmulationService = sService.getNfcFCardEmulationInterface();
} catch (RemoteException e) {
+ sNfcFCardEmulationService = null;
Log.e(TAG, "could not retrieve NFC-F card emulation service");
throw new UnsupportedOperationException();
}
try {
sCardEmulationService = sService.getNfcCardEmulationInterface();
} catch (RemoteException e) {
+ sCardEmulationService = null;
Log.e(TAG, "could not retrieve card emulation service");
throw new UnsupportedOperationException();
}
@@ -838,30 +841,54 @@
// assigning to sService is not thread-safe, but this is best-effort code
// and on a well-behaved system should never happen
sService = service;
- try {
- sTagService = service.getNfcTagInterface();
- } catch (RemoteException ee) {
- Log.e(TAG, "could not retrieve NFC tag service during service recovery");
- // nothing more can be done now, sService is still stale, we'll hit
- // this recovery path again later
- return;
+ if (sHasNfcFeature) {
+ try {
+ sTagService = service.getNfcTagInterface();
+ } catch (RemoteException ee) {
+ sTagService = null;
+ Log.e(TAG, "could not retrieve NFC tag service during service recovery");
+ // nothing more can be done now, sService is still stale, we'll hit
+ // this recovery path again later
+ return;
+ }
}
- try {
- sCardEmulationService = service.getNfcCardEmulationInterface();
- } catch (RemoteException ee) {
- Log.e(TAG, "could not retrieve NFC card emulation service during service recovery");
- }
+ if (sHasCeFeature) {
+ try {
+ sCardEmulationService = service.getNfcCardEmulationInterface();
+ } catch (RemoteException ee) {
+ sCardEmulationService = null;
+ Log.e(TAG,
+ "could not retrieve NFC card emulation service during service recovery");
+ }
- try {
- sNfcFCardEmulationService = service.getNfcFCardEmulationInterface();
- } catch (RemoteException ee) {
- Log.e(TAG, "could not retrieve NFC-F card emulation service during service recovery");
+ try {
+ sNfcFCardEmulationService = service.getNfcFCardEmulationInterface();
+ } catch (RemoteException ee) {
+ sNfcFCardEmulationService = null;
+ Log.e(TAG,
+ "could not retrieve NFC-F card emulation service during service recovery");
+ }
}
return;
}
+ private boolean isCardEmulationEnabled() {
+ if (sHasCeFeature) {
+ return (sCardEmulationService != null || sNfcFCardEmulationService != null);
+ }
+ return false;
+ }
+
+ private boolean isTagReadingEnabled() {
+ if (sHasNfcFeature) {
+ return sTagService != null;
+ }
+ return false;
+ }
+
+
/**
* Return true if this NFC Adapter has any features enabled.
*
@@ -875,8 +902,9 @@
* @return true if this NFC Adapter has any features enabled
*/
public boolean isEnabled() {
+ boolean serviceState = false;
try {
- return sService.getState() == STATE_ON;
+ serviceState = sService.getState() == STATE_ON;
} catch (RemoteException e) {
attemptDeadServiceRecovery(e);
// Try one more time
@@ -885,12 +913,12 @@
return false;
}
try {
- return sService.getState() == STATE_ON;
+ serviceState = sService.getState() == STATE_ON;
} catch (RemoteException ee) {
Log.e(TAG, "Failed to recover NFC Service.");
}
- return false;
}
+ return serviceState && (isTagReadingEnabled() || isCardEmulationEnabled());
}
/**
diff --git a/core/java/android/os/OWNERS b/core/java/android/os/OWNERS
index 4899a4d..abaa789 100644
--- a/core/java/android/os/OWNERS
+++ b/core/java/android/os/OWNERS
@@ -76,3 +76,7 @@
# PermissionEnforcer
per-file PermissionEnforcer.java = tweek@google.com, brufino@google.com
+
+# PerformanceHintManager
+per-file PerformanceHintManager.java = file:/ADPF_OWNERS
+
diff --git a/core/jni/OWNERS b/core/jni/OWNERS
index a17048c..921a45f 100644
--- a/core/jni/OWNERS
+++ b/core/jni/OWNERS
@@ -105,3 +105,6 @@
# SQLite
per-file android_database_SQLite* = file:/SQLITE_OWNERS
+
+# PerformanceHintManager
+per-file android_os_PerformanceHintManager.cpp = file:/ADPF_OWNERS
diff --git a/core/jni/com_android_internal_content_NativeLibraryHelper.cpp b/core/jni/com_android_internal_content_NativeLibraryHelper.cpp
index a50c011..9210498 100644
--- a/core/jni/com_android_internal_content_NativeLibraryHelper.cpp
+++ b/core/jni/com_android_internal_content_NativeLibraryHelper.cpp
@@ -174,6 +174,7 @@
static install_status_t
copyFileIfChanged(JNIEnv *env, void* arg, ZipFileRO* zipFile, ZipEntryRO zipEntry, const char* fileName)
{
+ static const size_t kPageSize = getpagesize();
void** args = reinterpret_cast<void**>(arg);
jstring* javaNativeLibPath = (jstring*) args[0];
jboolean extractNativeLibs = *(jboolean*) args[1];
@@ -200,9 +201,9 @@
return INSTALL_FAILED_INVALID_APK;
}
- if (offset % PAGE_SIZE != 0) {
- ALOGE("Library '%s' is not page-aligned - will not be able to open it directly from"
- " apk.\n", fileName);
+ if (offset % kPageSize != 0) {
+ ALOGE("Library '%s' is not PAGE(%zu)-aligned - will not be able to open it directly "
+ "from apk.\n", fileName, kPageSize);
return INSTALL_FAILED_INVALID_APK;
}
diff --git a/core/tests/coretests/src/android/os/OWNERS b/core/tests/coretests/src/android/os/OWNERS
index f2d6ff8..8b333f3 100644
--- a/core/tests/coretests/src/android/os/OWNERS
+++ b/core/tests/coretests/src/android/os/OWNERS
@@ -5,4 +5,7 @@
per-file *Vibrat*.java = file:/services/core/java/com/android/server/vibrator/OWNERS
# Power
-per-file PowerManager*.java = michaelwr@google.com, santoscordon@google.com
\ No newline at end of file
+per-file PowerManager*.java = michaelwr@google.com, santoscordon@google.com
+
+# PerformanceHintManager
+per-file PerformanceHintManagerTest.java = file:/ADPF_OWNERS
diff --git a/media/java/android/media/tv/tuner/Tuner.java b/media/java/android/media/tv/tuner/Tuner.java
index 13f7ee6..e6bcc95 100644
--- a/media/java/android/media/tv/tuner/Tuner.java
+++ b/media/java/android/media/tv/tuner/Tuner.java
@@ -443,6 +443,12 @@
acquireTRMSLock("shareFrontendFromTuner()");
mFrontendLock.lock();
try {
+ if (mFeOwnerTuner != null) {
+ // unregister self from the Frontend callback
+ mFeOwnerTuner.unregisterFrontendCallbackListener(this);
+ mFeOwnerTuner = null;
+ nativeUnshareFrontend();
+ }
mTunerResourceManager.shareFrontend(mClientId, tuner.mClientId);
mFeOwnerTuner = tuner;
mFeOwnerTuner.registerFrontendCallbackListener(this);
diff --git a/native/android/OWNERS b/native/android/OWNERS
index cfe9734..884f849 100644
--- a/native/android/OWNERS
+++ b/native/android/OWNERS
@@ -23,3 +23,6 @@
per-file native_window_jni.cpp = file:/graphics/java/android/graphics/OWNERS
per-file surface_control.cpp = file:/graphics/java/android/graphics/OWNERS
per-file surface_texture.cpp = file:/graphics/java/android/graphics/OWNERS
+
+# PerformanceHint
+per-file performance_hint.cpp = file:/ADPF_OWNERS
diff --git a/native/android/tests/performance_hint/OWNERS b/native/android/tests/performance_hint/OWNERS
new file mode 100644
index 0000000..e3bbee92
--- /dev/null
+++ b/native/android/tests/performance_hint/OWNERS
@@ -0,0 +1 @@
+include /ADPF_OWNERS
diff --git a/packages/EasterEgg/src/com/android/egg/quares/Quare.kt b/packages/EasterEgg/src/com/android/egg/quares/Quare.kt
index eb77362..f0cc2a1 100644
--- a/packages/EasterEgg/src/com/android/egg/quares/Quare.kt
+++ b/packages/EasterEgg/src/com/android/egg/quares/Quare.kt
@@ -137,14 +137,12 @@
return 0
}
- override fun writeToParcel(p: Parcel?, flags: Int) {
- p?.let {
- p.writeInt(width)
- p.writeInt(height)
- p.writeInt(depth)
- p.writeIntArray(data)
- p.writeIntArray(user)
- }
+ override fun writeToParcel(p: Parcel, flags: Int) {
+ p.writeInt(width)
+ p.writeInt(height)
+ p.writeInt(depth)
+ p.writeIntArray(data)
+ p.writeIntArray(user)
}
companion object CREATOR : Parcelable.Creator<Quare> {
diff --git a/packages/EasterEgg/src/com/android/egg/quares/QuaresActivity.kt b/packages/EasterEgg/src/com/android/egg/quares/QuaresActivity.kt
index 578de01..5fa6137 100644
--- a/packages/EasterEgg/src/com/android/egg/quares/QuaresActivity.kt
+++ b/packages/EasterEgg/src/com/android/egg/quares/QuaresActivity.kt
@@ -60,8 +60,8 @@
setContentView(R.layout.activity_quares)
- grid = findViewById(R.id.grid)
- label = findViewById(R.id.label)
+ grid = requireViewById(R.id.grid)
+ label = requireViewById(R.id.label)
if (savedInstanceState != null) {
Log.v(TAG, "restoring puzzle from state")
@@ -135,7 +135,7 @@
if (q.check()) {
val dp = resources.displayMetrics.density
- val label: Button = findViewById(R.id.label)
+ val label: Button = requireViewById(R.id.label)
label.text = resName.replace(Regex("^.*/"), "")
val drawable = icon?.loadDrawable(this)?.also {
it.setBounds(0, 0, (32 * dp).toInt(), (32 * dp).toInt())
diff --git a/packages/SettingsLib/src/com/android/settingslib/graph/ThemedBatteryDrawable.kt b/packages/SettingsLib/src/com/android/settingslib/graph/ThemedBatteryDrawable.kt
index faea5b2..61a45f7 100644
--- a/packages/SettingsLib/src/com/android/settingslib/graph/ThemedBatteryDrawable.kt
+++ b/packages/SettingsLib/src/com/android/settingslib/graph/ThemedBatteryDrawable.kt
@@ -324,7 +324,7 @@
return batteryLevel
}
- override fun onBoundsChange(bounds: Rect?) {
+ override fun onBoundsChange(bounds: Rect) {
super.onBoundsChange(bounds)
updateSize()
}
diff --git a/services/core/java/com/android/server/power/hint/OWNERS b/services/core/java/com/android/server/power/hint/OWNERS
new file mode 100644
index 0000000..c28c07a
--- /dev/null
+++ b/services/core/java/com/android/server/power/hint/OWNERS
@@ -0,0 +1,2 @@
+include /ADPF_OWNERS
+
diff --git a/services/core/java/com/android/server/security/rkp/RemoteProvisioningShellCommand.java b/services/core/java/com/android/server/security/rkp/RemoteProvisioningShellCommand.java
index bc39084..187b939 100644
--- a/services/core/java/com/android/server/security/rkp/RemoteProvisioningShellCommand.java
+++ b/services/core/java/com/android/server/security/rkp/RemoteProvisioningShellCommand.java
@@ -49,7 +49,7 @@
+ " Show this message.\n"
+ "dump\n"
+ " Dump service diagnostics.\n"
- + "list [--min-version MIN_VERSION]\n"
+ + "list\n"
+ " List the names of the IRemotelyProvisionedComponent instances.\n"
+ "csr [--challenge CHALLENGE] NAME\n"
+ " Generate and print a base64-encoded CSR from the named\n"
diff --git a/services/core/jni/com_android_server_am_CachedAppOptimizer.cpp b/services/core/jni/com_android_server_am_CachedAppOptimizer.cpp
index af5718f..9f1113c 100644
--- a/services/core/jni/com_android_server_am_CachedAppOptimizer.cpp
+++ b/services/core/jni/com_android_server_am_CachedAppOptimizer.cpp
@@ -224,6 +224,7 @@
// process_madvise on failure
int madviseVmasFromBatch(unique_fd& pidfd, VmaBatch& batch, int madviseType,
uint64_t* outBytesProcessed) {
+ static const size_t kPageSize = getpagesize();
if (batch.totalVmas == 0 || batch.totalBytes == 0) {
// No VMAs in Batch, skip.
*outBytesProcessed = 0;
@@ -249,7 +250,7 @@
} else if (bytesProcessedInSend < batch.totalBytes) {
// Partially processed the bytes requested
// skip last page which is where it failed.
- bytesProcessedInSend += PAGE_SIZE;
+ bytesProcessedInSend += kPageSize;
}
bytesProcessedInSend = consumeBytes(batch, bytesProcessedInSend);
diff --git a/tests/AttestationVerificationTest/src/android/security/attestationverification/PeerDeviceSystemAttestationVerificationTest.kt b/tests/AttestationVerificationTest/src/android/security/attestationverification/PeerDeviceSystemAttestationVerificationTest.kt
index 32c2230..ad95fbc 100644
--- a/tests/AttestationVerificationTest/src/android/security/attestationverification/PeerDeviceSystemAttestationVerificationTest.kt
+++ b/tests/AttestationVerificationTest/src/android/security/attestationverification/PeerDeviceSystemAttestationVerificationTest.kt
@@ -39,7 +39,7 @@
@Before
fun setup() {
rule.getScenario().onActivity {
- avm = it.getSystemService(AttestationVerificationManager::class.java)
+ avm = it.getSystemService(AttestationVerificationManager::class.java)!!
activity = it
}
invalidAttestationByteArray = TEST_ATTESTATION_CERT_FILENAME.fromPEMFileToByteArray()
diff --git a/tests/AttestationVerificationTest/src/android/security/attestationverification/SystemAttestationVerificationTest.kt b/tests/AttestationVerificationTest/src/android/security/attestationverification/SystemAttestationVerificationTest.kt
index 169effa..8f06b4a2 100644
--- a/tests/AttestationVerificationTest/src/android/security/attestationverification/SystemAttestationVerificationTest.kt
+++ b/tests/AttestationVerificationTest/src/android/security/attestationverification/SystemAttestationVerificationTest.kt
@@ -43,7 +43,7 @@
@Before
fun setup() {
rule.getScenario().onActivity {
- avm = it.getSystemService(AttestationVerificationManager::class.java)
+ avm = it.getSystemService(AttestationVerificationManager::class.java)!!
activity = it
androidKeystore = KeyStore.getInstance(ANDROID_KEYSTORE).apply { load(null) }
}
diff --git a/tests/Input/src/com/android/test/input/AnrTest.kt b/tests/Input/src/com/android/test/input/AnrTest.kt
index 8025406..1355fd2 100644
--- a/tests/Input/src/com/android/test/input/AnrTest.kt
+++ b/tests/Input/src/com/android/test/input/AnrTest.kt
@@ -134,7 +134,7 @@
private fun getExitReasons(): List<ApplicationExitInfo> {
lateinit var infos: List<ApplicationExitInfo>
instrumentation.runOnMainSync {
- val am = instrumentation.getContext().getSystemService(ActivityManager::class.java)
+ val am = instrumentation.getContext().getSystemService(ActivityManager::class.java)!!
infos = am.getHistoricalProcessExitReasons(PACKAGE_NAME, ALL_PIDS, NO_MAX)
}
return infos
diff --git a/tests/Input/src/com/android/test/input/UnresponsiveGestureMonitorActivity.kt b/tests/Input/src/com/android/test/input/UnresponsiveGestureMonitorActivity.kt
index d83a457..29d5c77 100644
--- a/tests/Input/src/com/android/test/input/UnresponsiveGestureMonitorActivity.kt
+++ b/tests/Input/src/com/android/test/input/UnresponsiveGestureMonitorActivity.kt
@@ -47,6 +47,6 @@
super.onCreate(savedInstanceState)
mInputMonitor = InputManager.getInstance().monitorGestureInput(MONITOR_NAME, displayId)
mInputEventReceiver = UnresponsiveReceiver(
- mInputMonitor.getInputChannel(), Looper.myLooper())
+ mInputMonitor.getInputChannel(), Looper.myLooper()!!)
}
}
diff --git a/tests/SilkFX/src/com/android/test/silkfx/materials/BackgroundBlurActivity.kt b/tests/SilkFX/src/com/android/test/silkfx/materials/BackgroundBlurActivity.kt
index 9d17d38..4d38660 100644
--- a/tests/SilkFX/src/com/android/test/silkfx/materials/BackgroundBlurActivity.kt
+++ b/tests/SilkFX/src/com/android/test/silkfx/materials/BackgroundBlurActivity.kt
@@ -132,7 +132,7 @@
mBlurForceDisabled = disabled
Settings.Global.putInt(getContentResolver(), Settings.Global.DISABLE_WINDOW_BLURS,
if (mBlurForceDisabled) 1 else 0)
- (findViewById(R.id.toggle_blur_enabled) as Button)
+ (requireViewById(R.id.toggle_blur_enabled) as Button)
.setText(if (mBlurForceDisabled) "Enable blurs" else "Disable blurs")
}
@@ -142,13 +142,13 @@
fun setBackgroundBlur(radius: Int) {
mBackgroundBlurRadius = radius
- (findViewById(R.id.background_blur_radius) as TextView).setText(radius.toString())
+ (requireViewById(R.id.background_blur_radius) as TextView).setText(radius.toString())
window.setBackgroundBlurRadius(mBackgroundBlurRadius)
}
fun setBlurBehind(radius: Int) {
mBlurBehindRadius = radius
- (findViewById(R.id.blur_behind_radius) as TextView).setText(radius.toString())
+ (requireViewById(R.id.blur_behind_radius) as TextView).setText(radius.toString())
window.getAttributes().setBlurBehindRadius(mBlurBehindRadius)
window.setAttributes(window.getAttributes())
}
@@ -159,7 +159,7 @@
} else {
mDimAmountNoBlur = amount
}
- (findViewById(R.id.dim_amount) as TextView).setText("%.2f".format(amount))
+ (requireViewById(R.id.dim_amount) as TextView).setText("%.2f".format(amount))
window.getAttributes().dimAmount = amount
window.setAttributes(window.getAttributes())
}
@@ -168,7 +168,7 @@
mBatterySavingModeOn = on
Settings.Global.putInt(getContentResolver(),
Settings.Global.LOW_POWER_MODE, if (on) 1 else 0)
- (findViewById(R.id.toggle_battery_saving_mode) as Button).setText(
+ (requireViewById(R.id.toggle_battery_saving_mode) as Button).setText(
if (on) "Exit low power mode" else "Enter low power mode")
}
@@ -182,7 +182,7 @@
} else {
mAlphaNoBlur = alpha
}
- (findViewById(R.id.background_alpha) as TextView).setText("%.2f".format(alpha))
+ (requireViewById(R.id.background_alpha) as TextView).setText("%.2f".format(alpha))
mBackgroundDrawable.setAlpha((alpha * 255f).toInt())
getWindowManager().updateViewLayout(window.getDecorView(), window.getAttributes())
}