Update docs and ensure PHONE_STATE is more predictable for unknown numbers.

In P the PHONE_STATE broadcast behavior changed due to new permission
requirements.  Updating the API docs for this broadcast to make it more
clear to developers how the broadcast will work given different permission
scenarios.

Also, made a minor change to how the "EXTRA_INCOMING_NUMBER" is populated
on the phone state broadcast.  Originally we opted to remove
EXTRA_INCOMING_NUMBER when the number is empty.  Developer feedback reveals
it is difficult to know for an unknown caller (where numer is empty)
whether the broadcast they're receiving is the one associated with the
broadcast for receivers with READ_CALL_LOG, or the one for receivers
without it.  This minor change eliminates the need to count broadcasts and
instead allows the developer to just focus on whether the extra is present
or not.

Test: make docs and verify the javadoc appears as expected.
Test: Used test app to confirm functionality.
Bug: 110190165
Change-Id: I35967d53274b99d66b63f4ff5acb60a689745f9d
diff --git a/services/core/java/com/android/server/TelephonyRegistry.java b/services/core/java/com/android/server/TelephonyRegistry.java
index 607db4e..ad9fa40 100644
--- a/services/core/java/com/android/server/TelephonyRegistry.java
+++ b/services/core/java/com/android/server/TelephonyRegistry.java
@@ -1588,10 +1588,10 @@
         // Wakeup apps for the (SUBSCRIPTION_)PHONE_STATE broadcast.
         intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
 
+        // Create a version of the intent with the number always populated.
         Intent intentWithPhoneNumber = new Intent(intent);
-        if (!TextUtils.isEmpty(incomingNumber)) {
-            intentWithPhoneNumber.putExtra(TelephonyManager.EXTRA_INCOMING_NUMBER, incomingNumber);
-        }
+        intentWithPhoneNumber.putExtra(TelephonyManager.EXTRA_INCOMING_NUMBER, incomingNumber);
+
         // Send broadcast twice, once for apps that have PRIVILEGED permission and once for those
         // that have the runtime one
         mContext.sendBroadcastAsUser(intentWithPhoneNumber, UserHandle.ALL,