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

Commit dcc0af50 authored by Fan Zhang's avatar Fan Zhang
Browse files

Remove deep link to app store from app header.

The link doesn't actually work and uses wrong icon. There is a working
version at the app info screen already.

Change-Id: I16890bd66e095c3185e12d604d8daba5036ab24c
Fix: 37544209
Test: robotests
parent 552fc292
Loading
Loading
Loading
Loading
+2 −27
Original line number Original line Diff line number Diff line
@@ -52,15 +52,13 @@ public class AppHeaderController {
    @IntDef({ActionType.ACTION_NONE,
    @IntDef({ActionType.ACTION_NONE,
            ActionType.ACTION_APP_INFO,
            ActionType.ACTION_APP_INFO,
            ActionType.ACTION_APP_PREFERENCE,
            ActionType.ACTION_APP_PREFERENCE,
            ActionType.ACTION_STORE_DEEP_LINK,
            ActionType.ACTION_NOTIF_PREFERENCE})
            ActionType.ACTION_NOTIF_PREFERENCE})
    @Retention(RetentionPolicy.SOURCE)
    @Retention(RetentionPolicy.SOURCE)
    public @interface ActionType {
    public @interface ActionType {
        int ACTION_NONE = 0;
        int ACTION_NONE = 0;
        int ACTION_APP_INFO = 1;
        int ACTION_APP_INFO = 1;
        int ACTION_STORE_DEEP_LINK = 2;
        int ACTION_APP_PREFERENCE = 2;
        int ACTION_APP_PREFERENCE = 3;
        int ACTION_NOTIF_PREFERENCE = 3;
        int ACTION_NOTIF_PREFERENCE = 4;
    }
    }


    public static final String PREF_KEY_APP_HEADER = "pref_app_header";
    public static final String PREF_KEY_APP_HEADER = "pref_app_header";
@@ -254,20 +252,6 @@ public class AppHeaderController {
                }
                }
                return;
                return;
            }
            }
            case ActionType.ACTION_STORE_DEEP_LINK: {
                final Intent intent = new Intent(Intent.ACTION_SHOW_APP_INFO)
                        .setPackage(getInstallerPackageName(mContext, mPackageName));
                final Intent result = resolveIntent(intent);
                if (result == null) {
                    button.setVisibility(View.GONE);
                } else {
                    result.putExtra(Intent.EXTRA_PACKAGE_NAME, mPackageName);
                    button.setImageResource(R.drawable.ic_sim_sd);
                    button.setOnClickListener(v -> mFragment.startActivity(intent));
                    button.setVisibility(View.VISIBLE);
                }
                return;
            }
            case ActionType.ACTION_NOTIF_PREFERENCE: {
            case ActionType.ACTION_NOTIF_PREFERENCE: {
                if (mAppNotifPrefIntent == null) {
                if (mAppNotifPrefIntent == null) {
                    button.setVisibility(View.GONE);
                    button.setVisibility(View.GONE);
@@ -295,15 +279,6 @@ public class AppHeaderController {
        }
        }
    }
    }


    private String getInstallerPackageName(Context context, String packageName) {
        try {
            return context.getPackageManager().getInstallerPackageName(packageName);
        } catch (IllegalArgumentException e) {
            Log.e(TAG, "Exception while retrieving the package installer of " + packageName, e);
            return null;
        }
    }

    private Intent resolveIntent(Intent i) {
    private Intent resolveIntent(Intent i) {
        ResolveInfo result = mContext.getPackageManager().resolveActivity(i, 0);
        ResolveInfo result = mContext.getPackageManager().resolveActivity(i, 0);
        if (result != null) {
        if (result != null) {
+2 −2
Original line number Original line Diff line number Diff line
@@ -415,8 +415,8 @@ public class InstalledAppDetails extends AppInfoBase
                .getApplicationFeatureProvider(activity)
                .getApplicationFeatureProvider(activity)
                .newAppHeaderController(this, mHeader.findViewById(R.id.app_snippet))
                .newAppHeaderController(this, mHeader.findViewById(R.id.app_snippet))
                .setPackageName(mPackageName)
                .setPackageName(mPackageName)
                .setButtonActions(AppHeaderController.ActionType.ACTION_STORE_DEEP_LINK,
                .setButtonActions(AppHeaderController.ActionType.ACTION_APP_PREFERENCE,
                        AppHeaderController.ActionType.ACTION_APP_PREFERENCE)
                        AppHeaderController.ActionType.ACTION_NONE)
                .styleActionBar(activity)
                .styleActionBar(activity)
                .bindAppHeaderButtons();
                .bindAppHeaderButtons();
        prepareUninstallAndStop();
        prepareUninstallAndStop();
+0 −20
Original line number Original line Diff line number Diff line
@@ -18,7 +18,6 @@ package com.android.settings.applications;




import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertThat;

import static org.mockito.Matchers.any;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.eq;
import static org.mockito.Matchers.eq;
@@ -171,25 +170,6 @@ public class AppHeaderControllerTest {
                .isEqualTo(View.GONE);
                .isEqualTo(View.GONE);
    }
    }


    @Test
    public void bindButton_noStoreLink_shouldNotShowButton() {
        final View appLinks = mLayoutInflater
                .inflate(R.layout.app_details, null /* root */);
        when(mContext.getPackageManager().resolveActivity(any(Intent.class), anyInt()))
                .thenReturn(null);

        mController = new AppHeaderController(mContext, mFragment, appLinks);
        mController.setButtonActions(
                AppHeaderController.ActionType.ACTION_STORE_DEEP_LINK,
                AppHeaderController.ActionType.ACTION_NONE);
        mController.done(mActivity);

        assertThat(appLinks.findViewById(R.id.left_button).getVisibility())
                .isEqualTo(View.GONE);
        assertThat(appLinks.findViewById(R.id.right_button).getVisibility())
                .isEqualTo(View.GONE);
    }

    @Test
    @Test
    public void bindButton_noAppInfo_shouldNotShowButton() {
    public void bindButton_noAppInfo_shouldNotShowButton() {
        final View appLinks = mLayoutInflater
        final View appLinks = mLayoutInflater