Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 376ce87f authored by Raff Tsai's avatar Raff Tsai
Browse files

Fix battery tip app name is empty

- Top waste app is linux process not android process. Therefore
it doesn't contains application label. Fixed by return the process
name if packages label is empty.

Fixes: 146558570
Test: follow the steps:
1. adb shell settings put global battery_tip_constants test_low_battery_tip=true
2. Unplug usb. Go to Settings -> Battery, it should show an item
"Phone used more than usual"
3. Click "phone used more than usual" item, all the items should
have title and icon.

Change-Id: I85c232bc6a048b3104c4fce0fcec2b944e8ac1b4
parent fdf29da1
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -749,7 +749,7 @@ public final class Utils extends com.android.settingslib.Utils {
                    | PackageManager.MATCH_ANY_USER);
            return appInfo.loadLabel(context.getPackageManager());
        } catch (PackageManager.NameNotFoundException e) {
            Log.w(TAG, "Unable to find info for package: " + packageName);
            Log.e(TAG, "Unable to find info for package: " + packageName);
        }
        return null;
    }
+6 −2
Original line number Diff line number Diff line
@@ -30,7 +30,6 @@ import androidx.recyclerview.widget.RecyclerView;

import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settingslib.utils.StringUtil;

import java.util.List;

@@ -78,7 +77,12 @@ public class HighUsageAdapter extends RecyclerView.Adapter<HighUsageAdapter.View
        holder.appIcon.setImageDrawable(
                Utils.getBadgedIcon(mIconDrawableFactory, mPackageManager, app.packageName,
                        UserHandle.getUserId(app.uid)));
        holder.appName.setText(Utils.getApplicationLabel(mContext, app.packageName));
        CharSequence label = Utils.getApplicationLabel(mContext, app.packageName);
        if (label == null) {
            label = app.packageName;
        }

        holder.appName.setText(label);
    }

    @Override