resolve merge conflicts of 696ce1c4a44be6f3c3c340dba2a16c3e8ea628ba to master
Test: I solemnly swear I tested this conflict resolution.
Bug: None
Change-Id: Iab1e8ba7453b3c40421c4ee0fdbf9d8ad70989ce
diff --git a/src/com/android/phone/EmergencyDialer.java b/src/com/android/phone/EmergencyDialer.java
index b91f927..fc4ef6a 100644
--- a/src/com/android/phone/EmergencyDialer.java
+++ b/src/com/android/phone/EmergencyDialer.java
@@ -25,12 +25,9 @@
import android.app.Dialog;
import android.app.WallpaperManager;
import android.content.BroadcastReceiver;
-import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
-import android.database.ContentObserver;
-import android.database.Cursor;
import android.graphics.Color;
import android.graphics.Point;
import android.media.AudioManager;
@@ -38,7 +35,6 @@
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
-import android.os.Handler;
import android.os.PersistableBundle;
import android.provider.Settings;
import android.telecom.PhoneAccount;
@@ -177,25 +173,6 @@
private boolean mAreEmergencyDialerShortcutsEnabled;
- /** Key of emergency information user name */
- private static final String KEY_EMERGENCY_INFO_NAME = "name";
-
- /** Authority of emergency information */
- private static final String AUTHORITY = "com.android.emergency.info.name";
-
- /** Content path of emergency information name */
- private static final String CONTENT_PATH = "name";
-
- /** Content URI of emergency information */
- private static final Uri CONTENT_URI = new Uri.Builder()
- .scheme(ContentResolver.SCHEME_CONTENT)
- .authority(AUTHORITY)
- .path(CONTENT_PATH)
- .build();
-
- /** ContentObserver for monitoring emergency info name changes */
- private ContentObserver mEmergencyInfoNameObserver;
-
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
// Do nothing
@@ -348,10 +325,6 @@
}
}
unregisterReceiver(mBroadcastReceiver);
- if (mEmergencyInfoNameObserver != null) {
- getContentResolver().unregisterContentObserver(mEmergencyInfoNameObserver);
- mEmergencyInfoNameObserver = null;
- }
}
@Override
@@ -930,19 +903,6 @@
setupEmergencyCallShortcutButton();
switchView(mEmergencyShortcutView, mDialpadView, false);
-
- mEmergencyInfoNameObserver = new ContentObserver(new Handler()) {
- @Override
- public void onChange(boolean selfChange) {
- super.onChange(selfChange);
- getEmergencyInfoNameAsync();
- }
- };
- // Register ContentProvider for monitoring emergency info name changes.
- getContentResolver().registerContentObserver(CONTENT_URI, false,
- mEmergencyInfoNameObserver);
- // Query emergency info name.
- getEmergencyInfoNameAsync();
}
private void setLocationInfo(String country) {
@@ -1063,38 +1023,4 @@
}
});
}
-
- /**
- * Get emergency info name from EmergencyInfo and then update EmergencyInfoGroup.
- */
- private void getEmergencyInfoNameAsync() {
- new AsyncTask<Void, Void, String>() {
- @Override
- protected String doInBackground(Void... params) {
- String name = "";
- try (Cursor cursor = getContentResolver().query(CONTENT_URI, null, null, null,
- null)) {
- if (cursor != null && cursor.moveToFirst()) {
- int index = cursor.getColumnIndex(KEY_EMERGENCY_INFO_NAME);
- name = index > -1 ? cursor.getString(index) : "";
- }
- } catch (IllegalArgumentException ex) {
- Log.w(LOG_TAG, "getEmergencyInfoNameAsync failed", ex);
- }
- return name;
- }
-
- @Override
- protected void onPostExecute(String result) {
- super.onPostExecute(result);
- if (!isFinishing() && !isDestroyed()) {
- // Update emergency info with emergency info name
- EmergencyInfoGroup group = findViewById(R.id.emergency_info_button);
- if (group != null) {
- group.updateEmergencyInfo(result);
- }
- }
- }
- }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
- }
}
diff --git a/src/com/android/phone/EmergencyInfoGroup.java b/src/com/android/phone/EmergencyInfoGroup.java
index 73fa92a..898af32 100644
--- a/src/com/android/phone/EmergencyInfoGroup.java
+++ b/src/com/android/phone/EmergencyInfoGroup.java
@@ -30,6 +30,7 @@
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
+import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.core.graphics.drawable.RoundedBitmapDrawable;
@@ -46,6 +47,7 @@
public class EmergencyInfoGroup extends FrameLayout {
private ImageView mEmergencyInfoImage;
private TextView mEmergencyInfoName;
+ private TextView mEmergencyInfoHint;
private View mEmergencyInfoButton;
public EmergencyInfoGroup(Context context, @Nullable AttributeSet attrs) {
@@ -58,6 +60,7 @@
mEmergencyInfoButton = findViewById(R.id.emergency_info_button);
mEmergencyInfoImage = (ImageView) findViewById(R.id.emergency_info_image);
mEmergencyInfoName = (TextView) findViewById(R.id.emergency_info_name);
+ mEmergencyInfoHint = (TextView) findViewById(R.id.emergency_info_hint);
}
@Override
@@ -68,6 +71,12 @@
}
}
+ @Override
+ protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
+ super.onLayout(changed, left, top, right, bottom);
+ updateLayoutHeight();
+ }
+
private void setupButtonInfo() {
List<ResolveInfo> infos;
@@ -88,6 +97,7 @@
visible = true;
}
+ mEmergencyInfoName.setText(getUserName());
setVisibility(visible ? View.VISIBLE : View.GONE);
}
@@ -95,34 +105,19 @@
/**
* Get user icon.
*
- * @return user icon, or anonymous avatar if user do not set photo.
+ * @return user icon, or default user icon if user do not set photo.
*/
private Drawable getCircularUserIcon() {
- final int userId = UserHandle.getCallingUserId();
-
final UserManager userManager = (UserManager) getContext().getSystemService(
Context.USER_SERVICE);
-
- // get user icon.
- Bitmap bitmapUserIcon = userManager.getUserIcon(userId);
+ Bitmap bitmapUserIcon = userManager.getUserIcon(UserHandle.getCallingUserId());
if (bitmapUserIcon == null) {
- // use anonymous avatar.
- return getContext().getDrawable(R.drawable.logo_avatar_anonymous_120);
+ // get default user icon.
+ final Drawable defaultUserIcon = UserIcons.getDefaultUserIcon(
+ getContext().getResources(), UserHandle.myUserId(), false);
+ bitmapUserIcon = UserIcons.convertToBitmap(defaultUserIcon);
}
-
- // get default user icon.
- Drawable drawableDefaultUserIcon = UserIcons.getDefaultUserIcon(
- getContext().getResources(), userId, false);
- Bitmap bitmapDefaultUserIcon = UserIcons.convertToBitmap(drawableDefaultUserIcon);
-
- // User icon is default icon that means user do not set photo, replacing default icon
- // with anonymous avatar on emergency info button.
- if (bitmapUserIcon.sameAs(bitmapDefaultUserIcon)) {
- return getContext().getDrawable(R.drawable.logo_avatar_anonymous_120);
- }
-
- // set user icon circular.
RoundedBitmapDrawable drawableUserIcon = RoundedBitmapDrawableFactory.create(
getContext().getResources(), bitmapUserIcon);
drawableUserIcon.setCircular(true);
@@ -130,14 +125,24 @@
return drawableUserIcon;
}
- void updateEmergencyInfo(String emergencyInfoName) {
- if (TextUtils.isEmpty(emergencyInfoName)) {
- emergencyInfoName = getContext().getString(R.string.emergency_information_owner_hint);
- }
- mEmergencyInfoName.setText(emergencyInfoName);
+ private CharSequence getUserName() {
+ final UserManager userManager = (UserManager) getContext().getSystemService(
+ Context.USER_SERVICE);
+ final String userName = userManager.getUserName();
- final String infoNameDescription = getContext().getString(
- R.string.emergency_information_owner_content_description, emergencyInfoName);
- mEmergencyInfoName.setContentDescription(infoNameDescription);
+ return TextUtils.isEmpty(userName) ? getContext().getText(
+ R.string.emergency_information_owner_hint) : userName;
}
-}
\ No newline at end of file
+
+ private void updateLayoutHeight() {
+ LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) getLayoutParams();
+ // Update height if mEmergencyInfoHint text line more than 1.
+ // EmergencyInfoGroup max line is 2, eclipse type "end" will be adopt if string too long.
+ params.height =
+ mEmergencyInfoHint.getLineCount() > 1 ? getResources().getDimensionPixelSize(
+ R.dimen.emergency_info_button_multiline_height)
+ : getResources().getDimensionPixelSize(
+ R.dimen.emergency_info_button_singleline_height);
+ setLayoutParams(params);
+ }
+}