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

Commit baa7a3d3 authored by Mohammed Althaf T's avatar Mohammed Althaf T 😊
Browse files

Merge branch '2785os-u-tabletrebase' into 'v1-u-tablet'

base: Rebase tablet changes for v1-u

See merge request e/os/android_frameworks_base!241
parents de00019b aac7997b
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -93,7 +93,13 @@ constructor(
    }

    private fun updateResources() {
        useSplitShade = splitShadeStateController.shouldUseSplitNotificationShade(context.resources)
        // Set this to false, we want to make only media controller think that we aren't
        // using split shade. Other components still will use split. This forces media to
        // place the tile under notifications in split mode
        // No checks here are necessary since split only applies to landscape keyguard which
        // is only available to tablets.
        // This change thus does not affect smartphones.
        useSplitShade = false
    }

    @VisibleForTesting
+0 −16
Original line number Diff line number Diff line
@@ -1755,22 +1755,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump

    @ClockSize
    private int computeDesiredClockSizeForSplitShade() {
        // Media is not visible to the user on AOD.
        boolean isMediaVisibleToUser =
                mMediaDataManager.hasActiveMediaOrRecommendation() && !isOnAod();
        if (isMediaVisibleToUser) {
            // When media is visible, it overlaps with the large clock. Use small clock instead.
            return SMALL;
        }
        // To prevent the weather clock from overlapping with the notification shelf on AOD, we use
        // the small clock here
        // With migrateClocksToBlueprint, weather clock will have behaviors similar to other clocks
        if (!migrateClocksToBlueprint()) {
            if (mKeyguardStatusViewController.isLargeClockBlockingNotificationShelf()
                    && hasVisibleNotifications() && isOnAod()) {
                return SMALL;
            }
        }
        return LARGE;
    }

+81 −2
Original line number Diff line number Diff line
@@ -20,13 +20,26 @@ package com.android.systemui.statusbar.phone;
import static com.android.systemui.Flags.truncatedStatusBarIconsFix;

import android.annotation.Nullable;
import android.app.ActivityTaskManager.RootTaskInfo;
import android.app.ActivityTaskManager;
import android.app.IActivityTaskManager;
import android.app.TaskStackListener;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.res.Configuration;
import android.database.ContentObserver;
import android.graphics.Insets;
import android.graphics.Rect;
import android.inputmethodservice.InputMethodService;
import android.net.Uri;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import android.os.RemoteException;
import android.os.UserHandle;
import android.provider.Settings;
import android.util.AttributeSet;
import android.util.Log;
import android.view.ContextThemeWrapper;
@@ -65,6 +78,7 @@ import java.util.Objects;

public class PhoneStatusBarView extends FrameLayout implements Callbacks {
    private static final String TAG = "PhoneStatusBarView";
    private static final String BLISS_LAUNCHER_DOCK_WIDTH = "bliss_launcher_dock_width";
    private final CommandQueue mCommandQueue;
    private final StatusBarContentInsetsProvider mContentInsetsProvider;
    private final StatusBarWindowController mStatusBarWindowController;
@@ -90,6 +104,29 @@ public class PhoneStatusBarView extends FrameLayout implements Callbacks {
     */
    private int mCutoutSideNudge = 0;

    private String mPreviousApp = "";
    private IActivityTaskManager mActivityTaskManager;
    private Handler mHandler = new Handler(Looper.getMainLooper());
    private final TaskStackListener mTaskListener = new TaskStackListener() {
        @Override
        public void onTaskStackChanged() {
            try {
                String foregroundApp = getForegroundApp();
                if (foregroundApp != null && !mPreviousApp.equals(foregroundApp)) {
                    mPreviousApp = foregroundApp;
                    mHandler.post(new Runnable() {
                        @Override
                        public void run() {
                            updateStatusBarHeight();
                        }
                    });
                }
            } catch (Exception e) {
                // Do nothing
            }
        }
    };

    public PhoneStatusBarView(Context context, AttributeSet attrs) {
        super(context, attrs);
        mCommandQueue = Dependency.get(CommandQueue.class);
@@ -124,6 +161,23 @@ public class PhoneStatusBarView extends FrameLayout implements Callbacks {
                    () -> getDisplay().getRotation());
            mRotationButtonController.setRotationButton(floatingRotationButton, null);
        }
        ContentObserver observer = new ContentObserver(new Handler()) {
            @Override
            public void onChange(boolean selfChange, Uri uri) {
                if (uri.equals(Settings.Secure.getUriFor(BLISS_LAUNCHER_DOCK_WIDTH))) {
                    updateStatusBarHeight();
                }
            }
        };
        context.getContentResolver().registerContentObserver(
                        Settings.Secure.getUriFor(BLISS_LAUNCHER_DOCK_WIDTH), false, observer, UserHandle.USER_ALL);

        try {
            mActivityTaskManager = ActivityTaskManager.getService();
            mActivityTaskManager.registerTaskStackListener(mTaskListener);
        } catch (RemoteException e) {
            // Do nothing
        }
    }

    @Override
@@ -336,10 +390,22 @@ public class PhoneStatusBarView extends FrameLayout implements Callbacks {
        int statusBarPaddingStart = getResources().getDimensionPixelSize(
                R.dimen.status_bar_padding_start);

        boolean isHomePackage = false;

        // Get the home launcher package name
        Intent intent = new Intent(Intent.ACTION_MAIN);
        intent.addCategory(Intent.CATEGORY_HOME);
        ResolveInfo resolveInfo = getContext().getPackageManager().resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY);
        if (resolveInfo != null) {
            String homePackageName = resolveInfo.activityInfo.packageName;
            isHomePackage = homePackageName != null && homePackageName.equals(getForegroundApp());
        }
        int dockWidth = !isHomePackage ? 0 : Settings.Secure.getInt(getContext().getContentResolver(), BLISS_LAUNCHER_DOCK_WIDTH, 0);

        findViewById(R.id.status_bar_contents).setPaddingRelative(
                statusBarPaddingStart,
                statusBarPaddingStart + (mRotationOrientation == RotationUtils.ROTATION_SEASCAPE ? dockWidth : 0),
                getResources().getDimensionPixelSize(R.dimen.status_bar_padding_top),
                getResources().getDimensionPixelSize(R.dimen.status_bar_padding_end),
                getResources().getDimensionPixelSize(R.dimen.status_bar_padding_end) + (mRotationOrientation == RotationUtils.ROTATION_LANDSCAPE ? dockWidth : 0),
                0);

        findViewById(R.id.notification_lights_out)
@@ -353,6 +419,19 @@ public class PhoneStatusBarView extends FrameLayout implements Callbacks {
        );
    }

    private String getForegroundApp() {
        RootTaskInfo info = null;
        try {
            info = mActivityTaskManager.getFocusedRootTaskInfo();
            if (info != null && info.topActivity != null) {
                return info.topActivity.getPackageName();
            }
        } catch (RemoteException e) {
            // Do nothing
        }
        return null;
    }

    private void updateLayoutForCutout() {
        updateStatusBarHeight();
        updateCutoutLocation();