Updated project directories for unified 'systemUI' folder (#5034)
This commit is contained in:
1 parent
46f8e92df9
commit
f9dbf334aa
293 files changed
+44
-27
No files matched your search
@@ -0,0 +1,185 @@
|
||||
/*
|
||||
* Copyright (C) 2017 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the
|
||||
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.systemui.plugins;
|
||||
|
||||
import android.annotation.Nullable;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.UserHandle;
|
||||
import android.view.View;
|
||||
|
||||
import com.android.systemui.animation.ActivityTransitionAnimator;
|
||||
import com.android.systemui.plugins.annotations.ProvidesInterface;
|
||||
|
||||
/**
|
||||
* An interface to start activities. This is used as a callback from the views to
|
||||
* {@link PhoneStatusBar} to allow custom handling for starting the activity, i.e. dismissing the
|
||||
* Keyguard.
|
||||
*/
|
||||
@ProvidesInterface(version = ActivityStarter.VERSION)
|
||||
public interface ActivityStarter {
|
||||
int VERSION = 2;
|
||||
|
||||
void startPendingIntentDismissingKeyguard(PendingIntent intent);
|
||||
|
||||
/**
|
||||
* Similar to {@link #startPendingIntentDismissingKeyguard(PendingIntent)}, but allows
|
||||
* you to specify the callback that is executed on the UI thread after the intent is sent.
|
||||
*/
|
||||
void startPendingIntentDismissingKeyguard(PendingIntent intent,
|
||||
Runnable intentSentUiThreadCallback);
|
||||
|
||||
/**
|
||||
* Similar to {@link #startPendingIntentDismissingKeyguard(PendingIntent, Runnable)}, but also
|
||||
* specifies an associated view that should be used for the activity launch animation.
|
||||
*/
|
||||
void startPendingIntentDismissingKeyguard(PendingIntent intent,
|
||||
Runnable intentSentUiThreadCallback, @Nullable View associatedView);
|
||||
|
||||
/**
|
||||
* Similar to {@link #startPendingIntentDismissingKeyguard(PendingIntent, Runnable)}, but also
|
||||
* specifies an animation controller that should be used for the activity launch animation.
|
||||
*/
|
||||
void startPendingIntentDismissingKeyguard(PendingIntent intent,
|
||||
Runnable intentSentUiThreadCallback,
|
||||
@Nullable ActivityTransitionAnimator.Controller animationController);
|
||||
|
||||
/**
|
||||
* Similar to {@link #startPendingIntentMaybeDismissingKeyguard(PendingIntent, Runnable,
|
||||
* ActivityTransitionAnimator.Controller)} but will always not dismiss the keyguard when
|
||||
* launching activities. This should be avoided and other alternatives should be used.
|
||||
*/
|
||||
void startPendingIntentWithoutDismissing(
|
||||
PendingIntent intent,
|
||||
boolean dismissShade,
|
||||
Runnable intentSentUiThreadCallback,
|
||||
@Nullable ActivityTransitionAnimator.Controller animationController,
|
||||
@Nullable Intent fillInIntent,
|
||||
@Nullable Bundle extraOptions);
|
||||
|
||||
/**
|
||||
* Similar to {@link #startPendingIntentDismissingKeyguard}, except that it supports launching
|
||||
* activities on top of the keyguard. If the activity supports {@code showOverLockscreen}, it
|
||||
* will show over keyguard without first dimissing it. If it doesn't support it, calling this
|
||||
* method is exactly the same as calling {@link #startPendingIntentDismissingKeyguard}.
|
||||
*/
|
||||
void startPendingIntentMaybeDismissingKeyguard(PendingIntent intent,
|
||||
@Nullable Runnable intentSentUiThreadCallback,
|
||||
@Nullable ActivityTransitionAnimator.Controller animationController);
|
||||
|
||||
/**
|
||||
* Similar to {@link #startPendingIntentMaybeDismissingKeyguard(PendingIntent, Runnable,
|
||||
* ActivityTransitionAnimator.Controller)}, but also specifies a fill-in intent and extra
|
||||
* option that could be used to populate the pending intent and launch the activity. This also
|
||||
* allows the caller to avoid dismissing the shade.
|
||||
*/
|
||||
void startPendingIntentMaybeDismissingKeyguard(PendingIntent intent,
|
||||
boolean dismissShade,
|
||||
@Nullable Runnable intentSentUiThreadCallback,
|
||||
@Nullable ActivityTransitionAnimator.Controller animationController,
|
||||
@Nullable Intent fillInIntent,
|
||||
@Nullable Bundle extraOptions);
|
||||
|
||||
/**
|
||||
* The intent flag can be specified in startActivity().
|
||||
*/
|
||||
void startActivity(Intent intent, boolean onlyProvisioned, boolean dismissShade, int flags);
|
||||
void startActivity(Intent intent, boolean dismissShade);
|
||||
default void startActivity(Intent intent, boolean dismissShade,
|
||||
@Nullable ActivityTransitionAnimator.Controller animationController) {
|
||||
startActivity(intent, dismissShade, animationController,
|
||||
false /* showOverLockscreenWhenLocked */);
|
||||
}
|
||||
|
||||
void startActivity(Intent intent, boolean dismissShade,
|
||||
@Nullable ActivityTransitionAnimator.Controller animationController,
|
||||
boolean showOverLockscreenWhenLocked);
|
||||
void startActivity(Intent intent, boolean dismissShade,
|
||||
@Nullable ActivityTransitionAnimator.Controller animationController,
|
||||
boolean showOverLockscreenWhenLocked, UserHandle userHandle);
|
||||
void startActivity(Intent intent, boolean onlyProvisioned, boolean dismissShade);
|
||||
void startActivity(Intent intent, boolean dismissShade, Callback callback);
|
||||
void postStartActivityDismissingKeyguard(Intent intent, int delay);
|
||||
void postStartActivityDismissingKeyguard(Intent intent, int delay,
|
||||
@Nullable ActivityTransitionAnimator.Controller animationController);
|
||||
|
||||
/** Posts a start activity intent that dismisses keyguard. */
|
||||
void postStartActivityDismissingKeyguard(Intent intent, int delay,
|
||||
@Nullable ActivityTransitionAnimator.Controller animationController,
|
||||
@Nullable String customMessage);
|
||||
void postStartActivityDismissingKeyguard(PendingIntent intent);
|
||||
|
||||
/**
|
||||
* Similar to {@link #postStartActivityDismissingKeyguard(PendingIntent)}, but also specifies an
|
||||
* animation controller that should be used for the activity launch animation.
|
||||
*/
|
||||
void postStartActivityDismissingKeyguard(PendingIntent intent,
|
||||
@Nullable ActivityTransitionAnimator.Controller animationController);
|
||||
|
||||
void postQSRunnableDismissingKeyguard(Runnable runnable);
|
||||
|
||||
void dismissKeyguardThenExecute(OnDismissAction action, @Nullable Runnable cancel,
|
||||
boolean afterKeyguardGone);
|
||||
|
||||
/** Authenticates if needed and dismisses keyguard to execute an action. */
|
||||
void dismissKeyguardThenExecute(OnDismissAction action, @Nullable Runnable cancel,
|
||||
boolean afterKeyguardGone, @Nullable String customMessage);
|
||||
|
||||
/** Starts an activity and dismisses keyguard. */
|
||||
void startActivityDismissingKeyguard(Intent intent,
|
||||
boolean onlyProvisioned,
|
||||
boolean dismissShade);
|
||||
|
||||
/** Starts an activity and dismisses keyguard. */
|
||||
void startActivityDismissingKeyguard(Intent intent,
|
||||
boolean onlyProvisioned,
|
||||
boolean dismissShade,
|
||||
boolean disallowEnterPictureInPictureWhileLaunching,
|
||||
Callback callback,
|
||||
int flags,
|
||||
@Nullable ActivityTransitionAnimator.Controller animationController,
|
||||
UserHandle userHandle);
|
||||
|
||||
/** Execute a runnable after dismissing keyguard. */
|
||||
void executeRunnableDismissingKeyguard(Runnable runnable,
|
||||
Runnable cancelAction,
|
||||
boolean dismissShade,
|
||||
boolean afterKeyguardGone,
|
||||
boolean deferred);
|
||||
|
||||
/** Whether we should animate an activity launch. */
|
||||
boolean shouldAnimateLaunch(boolean isActivityIntent);
|
||||
|
||||
interface Callback {
|
||||
void onActivityStarted(int resultCode);
|
||||
}
|
||||
|
||||
interface OnDismissAction {
|
||||
/**
|
||||
* @return {@code true} if the dismiss should be deferred. When returning true, make sure to
|
||||
* call {@link com.android.keyguard.ViewMediatorCallback#readyForKeyguardDone()}
|
||||
* *after* returning to start hiding the keyguard.
|
||||
*/
|
||||
boolean onDismiss();
|
||||
|
||||
/**
|
||||
* Whether running this action when we are locked will start an animation on the keyguard.
|
||||
*/
|
||||
default boolean willRunAnimationOnKeyguard() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,204 @@
|
||||
/*
|
||||
* Copyright (C) 2018 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.systemui.plugins;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Rect;
|
||||
import android.view.View;
|
||||
|
||||
import com.android.systemui.plugins.DarkIconDispatcher.DarkReceiver;
|
||||
import com.android.systemui.plugins.annotations.DependsOn;
|
||||
import com.android.systemui.plugins.annotations.ProvidesInterface;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* Dispatches events to {@link DarkReceiver}s about changes in darkness, tint area and dark
|
||||
* intensity. Accessible through {@link PluginDependency}
|
||||
*/
|
||||
@ProvidesInterface(version = DarkIconDispatcher.VERSION)
|
||||
@DependsOn(target = DarkReceiver.class)
|
||||
public interface DarkIconDispatcher {
|
||||
int VERSION = 2;
|
||||
|
||||
/**
|
||||
* Sets the dark area so {@link #applyDark} only affects the icons in the specified area.
|
||||
*
|
||||
* @param r the areas in which icons should change its tint, in logical screen
|
||||
* coordinates
|
||||
*/
|
||||
void setIconsDarkArea(ArrayList<Rect> r);
|
||||
|
||||
/**
|
||||
* Adds a receiver to receive callbacks onDarkChanged
|
||||
*/
|
||||
void addDarkReceiver(DarkReceiver receiver);
|
||||
|
||||
/**
|
||||
* Must have been previously been added through one of the addDarkReceive methods above.
|
||||
*/
|
||||
void removeDarkReceiver(DarkReceiver object);
|
||||
|
||||
/**
|
||||
* Used to reapply darkness on an object, must have previously been added through
|
||||
* addDarkReceiver.
|
||||
*/
|
||||
void applyDark(DarkReceiver object);
|
||||
|
||||
/** The default tint (applicable for dark backgrounds) is white */
|
||||
int DEFAULT_ICON_TINT = Color.WHITE;
|
||||
/** To support an icon which wants to create contrast, the default tint is black-on-white. */
|
||||
int DEFAULT_INVERSE_ICON_TINT = Color.BLACK;
|
||||
|
||||
Rect sTmpRect = new Rect();
|
||||
int[] sTmpInt2 = new int[2];
|
||||
|
||||
/**
|
||||
* @return the tint to apply to view depending on the desired tint color and
|
||||
* the screen tintArea in which to apply that tint
|
||||
*/
|
||||
static int getTint(Collection<Rect> tintAreas, View view, int color) {
|
||||
if (isInAreas(tintAreas, view)) {
|
||||
return color;
|
||||
} else {
|
||||
return DEFAULT_ICON_TINT;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the tint to apply to a foreground, given that the background is tinted
|
||||
* per {@link #getTint}
|
||||
*/
|
||||
static int getInverseTint(Collection<Rect> tintAreas, View view, int inverseColor) {
|
||||
if (isInAreas(tintAreas, view)) {
|
||||
return inverseColor;
|
||||
} else {
|
||||
return DEFAULT_INVERSE_ICON_TINT;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if more than half of the view's area is in any of the given area Rects, false
|
||||
* otherwise
|
||||
*/
|
||||
static boolean isInAreas(Collection<Rect> areas, View view) {
|
||||
if (areas.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
for (Rect area : areas) {
|
||||
if (isInArea(area, view)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if more than half of the viewBounds are in any of the given area Rects, false
|
||||
* otherwise
|
||||
*/
|
||||
static boolean isInAreas(Collection<Rect> areas, Rect viewBounds) {
|
||||
if (areas.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
for (Rect area : areas) {
|
||||
if (isInArea(area, viewBounds)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** @return true if more than half of the viewBounds are in the area Rect, false otherwise */
|
||||
static boolean isInArea(Rect area, Rect viewBounds) {
|
||||
if (area.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
sTmpRect.set(area);
|
||||
int left = viewBounds.left;
|
||||
int width = viewBounds.width();
|
||||
|
||||
int intersectStart = Math.max(left, area.left);
|
||||
int intersectEnd = Math.min(left + width, area.right);
|
||||
int intersectAmount = Math.max(0, intersectEnd - intersectStart);
|
||||
|
||||
boolean coversFullStatusBar = area.top <= 0;
|
||||
boolean majorityOfWidth = 2 * intersectAmount > width;
|
||||
return majorityOfWidth && coversFullStatusBar;
|
||||
}
|
||||
|
||||
/** @return true if more than half of the view's area is in the area Rect, false otherwise */
|
||||
static boolean isInArea(Rect area, View view) {
|
||||
if (area.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
sTmpRect.set(area);
|
||||
view.getLocationOnScreen(sTmpInt2);
|
||||
int left = sTmpInt2[0];
|
||||
|
||||
int intersectStart = Math.max(left, area.left);
|
||||
int intersectEnd = Math.min(left + view.getWidth(), area.right);
|
||||
int intersectAmount = Math.max(0, intersectEnd - intersectStart);
|
||||
|
||||
boolean coversFullStatusBar = area.top <= 0;
|
||||
boolean majorityOfWidth = 2 * intersectAmount > view.getWidth();
|
||||
return majorityOfWidth && coversFullStatusBar;
|
||||
}
|
||||
|
||||
/**
|
||||
* Receives a callback on darkness changes
|
||||
*/
|
||||
@ProvidesInterface(version = DarkReceiver.VERSION)
|
||||
interface DarkReceiver {
|
||||
int VERSION = 3;
|
||||
|
||||
/**
|
||||
* @param areas list of regions on screen where the tint applies
|
||||
* @param darkIntensity float representing the level of tint. In the range [0,1]
|
||||
* @param tint the tint applicable as a foreground contrast to the dark regions. This value
|
||||
* is interpolated between a default light and dark tone, and is therefore
|
||||
* usable as-is, as long as the view is in one of the areas defined in
|
||||
* {@code areas}.
|
||||
*
|
||||
* @see DarkIconDispatcher#isInArea(Rect, View) for utilizing {@code areas}
|
||||
*
|
||||
* Note: only one of {@link #onDarkChanged(ArrayList, float, int)} or
|
||||
* {@link #onDarkChangedWithContrast(ArrayList, int, int)} need to be implemented, as both
|
||||
* will be called in the same circumstances.
|
||||
*/
|
||||
void onDarkChanged(ArrayList<Rect> areas, float darkIntensity, int tint);
|
||||
|
||||
/**
|
||||
* New version of onDarkChanged, which describes a tint plus an optional contrastTint
|
||||
* that can be used if the tint is applied to the background of an icon.
|
||||
*
|
||||
* We use the 2 here to avoid the case where an existing override of onDarkChanged
|
||||
* might pass in parameters as bare numbers (e.g. 0 instead of 0f) which might get
|
||||
* mistakenly cast to (int) and therefore trigger this method.
|
||||
*
|
||||
* @param areas list of areas where dark tint applies
|
||||
* @param tint int describing the tint color to use
|
||||
* @param contrastTint if desired, a contrasting color that can be used for a foreground
|
||||
*
|
||||
* Note: only one of {@link #onDarkChanged(ArrayList, float, int)} or
|
||||
* {@link #onDarkChangedWithContrast(ArrayList, int, int)} need to be implemented, as both
|
||||
* will be called in the same circumstances.
|
||||
*/
|
||||
default void onDarkChangedWithContrast(ArrayList<Rect> areas, int tint, int contrastTint) {}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.android.systemui.plugins;
|
||||
|
||||
import com.android.systemui.plugins.annotations.ProvidesInterface;
|
||||
|
||||
@ProvidesInterface(action = DozeServicePlugin.ACTION, version = DozeServicePlugin.VERSION)
|
||||
public interface DozeServicePlugin extends Plugin {
|
||||
String ACTION = "com.android.systemui.action.PLUGIN_DOZE";
|
||||
int VERSION = 1;
|
||||
|
||||
public interface RequestDoze {
|
||||
void onRequestShowDoze();
|
||||
|
||||
void onRequestHideDoze();
|
||||
}
|
||||
|
||||
void onDreamingStarted();
|
||||
|
||||
void onDreamingStopped();
|
||||
|
||||
void setDozeRequester(RequestDoze requester);
|
||||
}
|
||||
@@ -0,0 +1,176 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.systemui.plugins;
|
||||
|
||||
import android.annotation.IntDef;
|
||||
import android.net.Uri;
|
||||
import android.view.MotionEvent;
|
||||
|
||||
import com.android.systemui.plugins.annotations.ProvidesInterface;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
/**
|
||||
* Interface that decides whether a touch on the phone was accidental. i.e. Pocket Dialing.
|
||||
*
|
||||
* {@see com.android.systemui.classifier.BrightLineFalsingManager}
|
||||
*/
|
||||
@ProvidesInterface(version = FalsingManager.VERSION)
|
||||
public interface FalsingManager {
|
||||
int VERSION = 6;
|
||||
|
||||
int NO_PENALTY = 0;
|
||||
int LOW_PENALTY = 1;
|
||||
int MODERATE_PENALTY = 2;
|
||||
int HIGH_PENALTY = 3;
|
||||
|
||||
@IntDef({
|
||||
NO_PENALTY,
|
||||
LOW_PENALTY,
|
||||
MODERATE_PENALTY,
|
||||
HIGH_PENALTY
|
||||
})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface Penalty {}
|
||||
|
||||
void onSuccessfulUnlock();
|
||||
|
||||
boolean isUnlockingDisabled();
|
||||
|
||||
/** Returns true if the gesture should be rejected. */
|
||||
boolean isFalseTouch(int interactionType);
|
||||
|
||||
/**
|
||||
* Does basic checking to see if gesture looks like a tap.
|
||||
*
|
||||
* Only does the most basic of checks. No penalty is applied if this method returns false.
|
||||
*
|
||||
* For more robust analysis, use {@link #isFalseTap(int)}.
|
||||
*/
|
||||
boolean isSimpleTap();
|
||||
|
||||
/**
|
||||
* Returns true if the FalsingManager thinks the last gesture was not a valid tap.
|
||||
*
|
||||
* This method runs a more thorough analysis than the similar {@link #isSimpleTap()},
|
||||
* that can include historical interactions and other contextual cues to see
|
||||
* if the tap looks accidental.
|
||||
*
|
||||
* Use this method to validate a tap for launching an action, like opening
|
||||
* a notification.
|
||||
*
|
||||
* The only parameter, penalty, indicates how much this should affect future gesture
|
||||
* classifications if this tap looks like a false. As single taps are hard to confirm as false
|
||||
* or otherwise, a low penalty value is encouraged unless context indicates otherwise.
|
||||
*/
|
||||
boolean isFalseTap(@Penalty int penalty);
|
||||
|
||||
/**
|
||||
* Returns true if the FalsingManager thinks the last gesture was not a valid long tap.
|
||||
*
|
||||
* Use this method to validate a long tap for launching an action, like long press on a UMO
|
||||
*
|
||||
* The only parameter, penalty, indicates how much this should affect future gesture
|
||||
* classifications if this long tap looks like a false.
|
||||
* As long taps are hard to confirm as false or otherwise,
|
||||
* a low penalty value is encouraged unless context indicates otherwise.
|
||||
*/
|
||||
boolean isFalseLongTap(@Penalty int penalty);
|
||||
|
||||
/**
|
||||
* Returns true if the last two gestures do not look like a double tap.
|
||||
*
|
||||
* Only works on data that has already been reported to the FalsingManager. Be sure that
|
||||
* {@link com.android.systemui.classifier.FalsingCollector#onTouchEvent(MotionEvent)}
|
||||
* has already been called for all of the taps you want considered.
|
||||
*
|
||||
* This looks at the last two gestures on the screen, ensuring that they meet the following
|
||||
* criteria:
|
||||
*
|
||||
* a) There are at least two gestures.
|
||||
* b) The last two gestures look like taps.
|
||||
* c) The last two gestures look like a double tap taken together.
|
||||
*
|
||||
* This method is _not_ context aware. That is to say, if two taps occur on two neighboring
|
||||
* views, but are otherwise close to one another, this will report a successful double tap.
|
||||
* It is up to the caller to decide
|
||||
* @return
|
||||
*/
|
||||
boolean isFalseDoubleTap();
|
||||
|
||||
/**
|
||||
* Whether the last proximity event reported NEAR. May be used to short circuit motion events
|
||||
* that require the proximity sensor is not covered.
|
||||
*/
|
||||
boolean isProximityNear();
|
||||
|
||||
boolean isClassifierEnabled();
|
||||
|
||||
boolean shouldEnforceBouncer();
|
||||
|
||||
Uri reportRejectedTouch();
|
||||
|
||||
boolean isReportingEnabled();
|
||||
|
||||
/** From com.android.systemui.Dumpable. */
|
||||
void dump(PrintWriter pw, String[] args);
|
||||
|
||||
/**
|
||||
* Don't call this. It's meant for internal use to allow switching between implementations.
|
||||
*
|
||||
* Tests may also call it.
|
||||
**/
|
||||
void cleanupInternal();
|
||||
|
||||
/** Call to report a ProximityEvent to the FalsingManager. */
|
||||
void onProximityEvent(ProximityEvent proximityEvent);
|
||||
|
||||
/** Adds a {@link FalsingBeliefListener}. */
|
||||
void addFalsingBeliefListener(FalsingBeliefListener listener);
|
||||
|
||||
/** Removes a {@link FalsingBeliefListener}. */
|
||||
void removeFalsingBeliefListener(FalsingBeliefListener listener);
|
||||
|
||||
/** Adds a {@link FalsingTapListener}. */
|
||||
void addTapListener(FalsingTapListener falsingTapListener);
|
||||
|
||||
/** Removes a {@link FalsingTapListener}. */
|
||||
void removeTapListener(FalsingTapListener falsingTapListener);
|
||||
|
||||
/** Listener that is alerted when falsing belief level crosses a predfined threshold. */
|
||||
interface FalsingBeliefListener {
|
||||
void onFalse();
|
||||
}
|
||||
|
||||
/**
|
||||
* Listener that is alerted when an additional tap is required to confirm a single tap.
|
||||
**/
|
||||
interface FalsingTapListener {
|
||||
void onAdditionalTapRequired();
|
||||
}
|
||||
|
||||
/** Passed to {@link FalsingManager#onProximityEvent}. */
|
||||
interface ProximityEvent {
|
||||
/** Returns true when the proximity sensor was covered. */
|
||||
boolean getCovered();
|
||||
|
||||
/** Returns when the proximity sensor was covered in nanoseconds. */
|
||||
long getTimestampNs();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (C) 2018 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.systemui.plugins;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.android.systemui.plugins.annotations.DependsOn;
|
||||
import com.android.systemui.plugins.annotations.ProvidesInterface;
|
||||
|
||||
/**
|
||||
* Used to capture Falsing data (related to unlocking the screen).
|
||||
*
|
||||
* The intent is that the data can later be analyzed to validate the quality of the
|
||||
* {@link FalsingManager}.
|
||||
*/
|
||||
@ProvidesInterface(action = FalsingPlugin.ACTION, version = FalsingPlugin.VERSION)
|
||||
@DependsOn(target = FalsingManager.class)
|
||||
public interface FalsingPlugin extends Plugin {
|
||||
String ACTION = "com.android.systemui.action.FALSING_PLUGIN";
|
||||
int VERSION = 2;
|
||||
|
||||
/**
|
||||
* Called when there is data to be recorded.
|
||||
*
|
||||
* @param success Indicates whether the action is considered a success.
|
||||
* @param data The raw data to be recorded for analysis.
|
||||
*/
|
||||
default void dataCollected(boolean success, byte[] data) { }
|
||||
|
||||
/**
|
||||
* Return a {@link FalsingManager} to be used in place of the system's default.
|
||||
*
|
||||
* @param context
|
||||
*/
|
||||
default FalsingManager getFalsingManager(Context context) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (C) 2016 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the
|
||||
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.systemui.plugins;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
|
||||
/**
|
||||
* Interface to deal with lack of multiple inheritance
|
||||
*
|
||||
* This interface is designed to be used as a base class for plugin interfaces
|
||||
* that need fragment methods. Plugins should not extend Fragment directly, so
|
||||
* plugins that are fragments should be extending PluginFragment, but in SysUI
|
||||
* these same versions should extend Fragment directly.
|
||||
*
|
||||
* Only methods that are on Fragment should be included here.
|
||||
*/
|
||||
public interface FragmentBase {
|
||||
View getView();
|
||||
Context getContext();
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (C) 2017 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the
|
||||
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.systemui.plugins;
|
||||
|
||||
import com.android.systemui.plugins.GlobalActions.GlobalActionsManager;
|
||||
import com.android.systemui.plugins.annotations.DependsOn;
|
||||
import com.android.systemui.plugins.annotations.ProvidesInterface;
|
||||
|
||||
@ProvidesInterface(action = GlobalActions.ACTION, version = GlobalActions.VERSION)
|
||||
@DependsOn(target = GlobalActionsManager.class)
|
||||
public interface GlobalActions extends Plugin {
|
||||
|
||||
String ACTION = "com.android.systemui.action.PLUGIN_GLOBAL_ACTIONS";
|
||||
int VERSION = 1;
|
||||
|
||||
void showGlobalActions(GlobalActionsManager manager);
|
||||
default void showShutdownUi(boolean isReboot, String reason) {
|
||||
}
|
||||
|
||||
default void destroy() {
|
||||
}
|
||||
|
||||
@ProvidesInterface(version = GlobalActionsManager.VERSION)
|
||||
public interface GlobalActionsManager {
|
||||
int VERSION = 1;
|
||||
|
||||
void onGlobalActionsShown();
|
||||
void onGlobalActionsHidden();
|
||||
|
||||
void shutdown();
|
||||
void reboot(boolean safeMode);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.systemui.plugins;
|
||||
|
||||
import android.annotation.Nullable;
|
||||
import android.app.BroadcastOptions;
|
||||
import android.app.PendingIntent;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.view.View;
|
||||
|
||||
import com.android.systemui.plugins.annotations.DependsOn;
|
||||
import com.android.systemui.plugins.annotations.ProvidesInterface;
|
||||
|
||||
/**
|
||||
* Plugin which provides a "Panel" {@link View} to be rendered inside of the GlobalActions menu.
|
||||
*
|
||||
* Implementations should construct a new {@link PanelViewController} with the given
|
||||
* {@link Callbacks} instance inside of {@link #onPanelShown(Callbacks, boolean)}, and should not
|
||||
* hold onto a reference, instead allowing Global Actions to manage the lifetime of the object.
|
||||
*
|
||||
* Under this assumption, {@link PanelViewController} represents the lifetime of a single invocation
|
||||
* of the Global Actions menu. The {@link View} for the Panel is generated when the
|
||||
* {@link PanelViewController} is constructed, and {@link PanelViewController#getPanelContent()}
|
||||
* serves as a simple getter. When Global Actions is dismissed,
|
||||
* {@link PanelViewController#onDismissed()} can be used to cleanup any resources allocated when
|
||||
* constructed. Global Actions will then release the reference, and the {@link PanelViewController}
|
||||
* will be garbage-collected.
|
||||
*/
|
||||
@ProvidesInterface(
|
||||
action = GlobalActionsPanelPlugin.ACTION, version = GlobalActionsPanelPlugin.VERSION)
|
||||
@DependsOn(target = GlobalActionsPanelPlugin.Callbacks.class)
|
||||
@DependsOn(target = GlobalActionsPanelPlugin.PanelViewController.class)
|
||||
public interface GlobalActionsPanelPlugin extends Plugin {
|
||||
String ACTION = "com.android.systemui.action.PLUGIN_GLOBAL_ACTIONS_PANEL";
|
||||
int VERSION = 0;
|
||||
|
||||
/**
|
||||
* Invoked when the GlobalActions menu is shown.
|
||||
*
|
||||
* @param callbacks {@link Callbacks} instance that can be used by the Panel to interact with
|
||||
* the Global Actions menu.
|
||||
* @param deviceLocked Indicates whether or not the device is currently locked.
|
||||
* @return A {@link PanelViewController} instance used to receive Global Actions events.
|
||||
*/
|
||||
PanelViewController onPanelShown(Callbacks callbacks, boolean deviceLocked);
|
||||
|
||||
/**
|
||||
* Provides methods to interact with the Global Actions menu.
|
||||
*/
|
||||
@ProvidesInterface(version = Callbacks.VERSION)
|
||||
interface Callbacks {
|
||||
int VERSION = 0;
|
||||
|
||||
/** Dismisses the Global Actions menu. */
|
||||
void dismissGlobalActionsMenu();
|
||||
|
||||
/** Starts a PendingIntent, dismissing the keyguard if necessary. */
|
||||
default void startPendingIntentDismissingKeyguard(PendingIntent pendingIntent) {
|
||||
try {
|
||||
BroadcastOptions options = BroadcastOptions.makeBasic();
|
||||
options.setInteractive(true);
|
||||
pendingIntent.send(options.toBundle());
|
||||
} catch (PendingIntent.CanceledException e) {
|
||||
// no-op
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Receives Global Actions events, and provides the Panel {@link View}.
|
||||
*/
|
||||
@ProvidesInterface(version = PanelViewController.VERSION)
|
||||
interface PanelViewController {
|
||||
int VERSION = 0;
|
||||
|
||||
/**
|
||||
* Returns the {@link View} for the Panel to be rendered in Global Actions. This View can be
|
||||
* any size, and will be rendered above the Global Actions menu when z-ordered.
|
||||
*/
|
||||
View getPanelContent();
|
||||
|
||||
/**
|
||||
* Invoked when the Global Actions menu (containing the View returned from
|
||||
* {@link #getPanelContent()}) is dismissed.
|
||||
*/
|
||||
void onDismissed();
|
||||
|
||||
/**
|
||||
* Invoked when the device is either locked or unlocked.
|
||||
*/
|
||||
void onDeviceLockStateChanged(boolean locked);
|
||||
|
||||
/**
|
||||
* Optionally returns a drawable to be used as the background for Global Actions.
|
||||
*/
|
||||
@Nullable
|
||||
default Drawable getBackgroundDrawable() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (C) 2016 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the
|
||||
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.systemui.plugins;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
import com.android.systemui.plugins.annotations.ProvidesInterface;
|
||||
|
||||
/**
|
||||
* An Intent Button represents a triggerable element in SysUI that consists of an
|
||||
* Icon and an intent to trigger when it is activated (clicked, swiped, etc.).
|
||||
*/
|
||||
@ProvidesInterface(version = IntentButtonProvider.VERSION)
|
||||
public interface IntentButtonProvider extends Plugin {
|
||||
|
||||
public static final int VERSION = 1;
|
||||
|
||||
public IntentButton getIntentButton();
|
||||
|
||||
public interface IntentButton {
|
||||
public static class IconState {
|
||||
public boolean isVisible = true;
|
||||
public CharSequence contentDescription = null;
|
||||
public Drawable drawable;
|
||||
public boolean tint = true;
|
||||
}
|
||||
|
||||
public IconState getIcon();
|
||||
|
||||
public Intent getIntent();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.systemui.plugins;
|
||||
|
||||
import android.graphics.Point;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import com.android.systemui.plugins.annotations.ProvidesInterface;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
|
||||
/** Plugin to handle navigation edge gestures for Back. */
|
||||
@ProvidesInterface(
|
||||
action = NavigationEdgeBackPlugin.ACTION,
|
||||
version = NavigationEdgeBackPlugin.VERSION)
|
||||
public interface NavigationEdgeBackPlugin extends Plugin {
|
||||
String ACTION = "com.android.systemui.action.PLUGIN_NAVIGATION_EDGE_BACK_ACTION";
|
||||
int VERSION = 1;
|
||||
|
||||
|
||||
/** Specifies if the UI should be rendered on the left side of the screen. */
|
||||
void setIsLeftPanel(boolean isLeftPanel);
|
||||
|
||||
/** Sets the insets for the gesture handling area. */
|
||||
void setInsets(int leftInset, int rightInset);
|
||||
|
||||
/** Sets the display size. */
|
||||
void setDisplaySize(Point displaySize);
|
||||
|
||||
/** Sets the callback that should be invoked when a Back gesture is detected. */
|
||||
void setBackCallback(BackCallback callback);
|
||||
|
||||
/** Sets the base LayoutParams for the UI. */
|
||||
void setLayoutParams(WindowManager.LayoutParams layoutParams);
|
||||
|
||||
/** Updates the UI based on the motion events passed in device coordinates. */
|
||||
void onMotionEvent(MotionEvent motionEvent);
|
||||
|
||||
/** Dumps info about the back gesture plugin. */
|
||||
void dump(PrintWriter pw);
|
||||
|
||||
/** Callback to let the system react to the detected back gestures. */
|
||||
interface BackCallback {
|
||||
/** Indicates that a Back gesture was recognized and the system should go back. */
|
||||
void triggerBack();
|
||||
|
||||
/** Indicates that the gesture was cancelled and the system should not go back. */
|
||||
void cancelBack();
|
||||
|
||||
/**
|
||||
* Indicates if back will be triggered if committed in current state.
|
||||
*
|
||||
* @param triggerBack if back will be triggered in current state.
|
||||
*/
|
||||
void setTriggerBack(boolean triggerBack);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright (C) 2017 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the
|
||||
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.systemui.plugins;
|
||||
|
||||
import android.app.NotificationChannel;
|
||||
import android.os.UserHandle;
|
||||
import android.service.notification.NotificationListenerService.RankingMap;
|
||||
import android.service.notification.StatusBarNotification;
|
||||
|
||||
import com.android.systemui.plugins.NotificationListenerController.NotificationProvider;
|
||||
import com.android.systemui.plugins.annotations.DependsOn;
|
||||
import com.android.systemui.plugins.annotations.ProvidesInterface;
|
||||
|
||||
@ProvidesInterface(action = NotificationListenerController.ACTION,
|
||||
version = NotificationListenerController.VERSION)
|
||||
@DependsOn(target = NotificationProvider.class)
|
||||
public interface NotificationListenerController extends Plugin {
|
||||
String ACTION = "com.android.systemui.action.PLUGIN_NOTIFICATION_ASSISTANT";
|
||||
int VERSION = 1;
|
||||
|
||||
void onListenerConnected(NotificationProvider provider);
|
||||
|
||||
/**
|
||||
* @return whether plugin wants to skip the default callbacks.
|
||||
*/
|
||||
default boolean onNotificationPosted(StatusBarNotification sbn, RankingMap rankingMap) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return whether plugin wants to skip the default callbacks.
|
||||
*/
|
||||
default boolean onNotificationRemoved(StatusBarNotification sbn, RankingMap rankingMap) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a notification channel is modified.
|
||||
* @param modificationType One of {@link #NOTIFICATION_CHANNEL_OR_GROUP_ADDED},
|
||||
* {@link #NOTIFICATION_CHANNEL_OR_GROUP_UPDATED},
|
||||
* {@link #NOTIFICATION_CHANNEL_OR_GROUP_DELETED}.
|
||||
* @return whether a plugin wants to skip the default callbacks.
|
||||
*/
|
||||
default boolean onNotificationChannelModified(
|
||||
String pkgName, UserHandle user, NotificationChannel channel, int modificationType) {
|
||||
return false;
|
||||
}
|
||||
|
||||
default StatusBarNotification[] getActiveNotifications(
|
||||
StatusBarNotification[] activeNotifications) {
|
||||
return activeNotifications;
|
||||
}
|
||||
|
||||
default RankingMap getCurrentRanking(RankingMap currentRanking) {
|
||||
return currentRanking;
|
||||
}
|
||||
|
||||
@ProvidesInterface(version = NotificationProvider.VERSION)
|
||||
interface NotificationProvider {
|
||||
int VERSION = 1;
|
||||
|
||||
// Methods to get info about current notifications
|
||||
StatusBarNotification[] getActiveNotifications();
|
||||
RankingMap getRankingMap();
|
||||
|
||||
// Methods to notify sysui of changes to notification list.
|
||||
void addNotification(StatusBarNotification sbn);
|
||||
void removeNotification(StatusBarNotification sbn);
|
||||
void updateRanking();
|
||||
}
|
||||
}
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.systemui.plugins;
|
||||
|
||||
import android.annotation.Nullable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.service.notification.StatusBarNotification;
|
||||
|
||||
import com.android.systemui.plugins.annotations.DependsOn;
|
||||
import com.android.systemui.plugins.annotations.ProvidesInterface;
|
||||
|
||||
/** Custom logic that can extract a PeopleHub "person" from a notification. */
|
||||
@ProvidesInterface(
|
||||
action = NotificationPersonExtractorPlugin.ACTION,
|
||||
version = NotificationPersonExtractorPlugin.VERSION)
|
||||
@DependsOn(target = NotificationPersonExtractorPlugin.PersonData.class)
|
||||
public interface NotificationPersonExtractorPlugin extends Plugin {
|
||||
|
||||
String ACTION = "com.android.systemui.action.PEOPLE_HUB_PERSON_EXTRACTOR";
|
||||
int VERSION = 1;
|
||||
|
||||
/**
|
||||
* Attempts to extract a person from a notification. Returns {@code null} if one is not found.
|
||||
*/
|
||||
@Nullable
|
||||
PersonData extractPerson(StatusBarNotification sbn);
|
||||
|
||||
/**
|
||||
* Attempts to extract a person id from a notification. Returns {@code null} if one is not
|
||||
* found.
|
||||
*
|
||||
* This method can be overridden in order to provide a faster implementation.
|
||||
*/
|
||||
@Nullable
|
||||
default String extractPersonKey(StatusBarNotification sbn) {
|
||||
return extractPerson(sbn).key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether or not a notification should be treated as having a person. Used for
|
||||
* appropriate positioning in the notification shade.
|
||||
*/
|
||||
default boolean isPersonNotification(StatusBarNotification sbn) {
|
||||
return extractPersonKey(sbn) != null;
|
||||
}
|
||||
|
||||
/** A person to be surfaced in PeopleHub. */
|
||||
@ProvidesInterface(version = PersonData.VERSION)
|
||||
final class PersonData {
|
||||
|
||||
public static final int VERSION = 0;
|
||||
|
||||
public final String key;
|
||||
public final CharSequence name;
|
||||
public final Drawable avatar;
|
||||
public final Runnable clickRunnable;
|
||||
|
||||
public PersonData(String key, CharSequence name, Drawable avatar,
|
||||
Runnable clickRunnable) {
|
||||
this.key = key;
|
||||
this.name = name;
|
||||
this.avatar = avatar;
|
||||
this.clickRunnable = clickRunnable;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (C) 2016 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the
|
||||
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
package com.android.systemui.plugins;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import com.android.systemui.plugins.annotations.ProvidesInterface;
|
||||
import com.android.systemui.plugins.statusbar.DozeParameters;
|
||||
|
||||
@ProvidesInterface(action = OverlayPlugin.ACTION, version = OverlayPlugin.VERSION)
|
||||
public interface OverlayPlugin extends Plugin {
|
||||
|
||||
String ACTION = "com.android.systemui.action.PLUGIN_OVERLAY";
|
||||
int VERSION = 4;
|
||||
|
||||
/**
|
||||
* Setup overlay plugin
|
||||
*/
|
||||
void setup(View statusBar, View navBar);
|
||||
|
||||
/**
|
||||
* Setup overlay plugin with callback and DozeParameters
|
||||
*/
|
||||
default void setup(View statusBar, View navBar, Callback callback,
|
||||
DozeParameters dozeParameters) {
|
||||
setup(statusBar, navBar);
|
||||
}
|
||||
|
||||
default boolean holdStatusBarOpen() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Only called if the plugin has returned true to holdStatusBarOpen().
|
||||
*/
|
||||
default void setCollapseDesired(boolean collapseDesired) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to update system ui whether to hold status bar open
|
||||
*/
|
||||
interface Callback {
|
||||
void onHoldStatusBarOpenChange();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (C) 2017 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the
|
||||
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.systemui.plugins;
|
||||
|
||||
import com.android.systemui.plugins.annotations.ProvidesInterface;
|
||||
|
||||
@ProvidesInterface(version = PluginDependency.VERSION)
|
||||
public class PluginDependency {
|
||||
public static final int VERSION = 1;
|
||||
static DependencyProvider sProvider;
|
||||
|
||||
public static <T> T get(Plugin p, Class<T> cls) {
|
||||
return sProvider.get(p, cls);
|
||||
}
|
||||
|
||||
static abstract class DependencyProvider {
|
||||
abstract <T> T get(Plugin p, Class<T> cls);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (C) 2016 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the
|
||||
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.systemui.plugins;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
|
||||
public class PluginUtils {
|
||||
|
||||
public static void setId(Context sysuiContext, View view, String id) {
|
||||
int i = sysuiContext.getResources().getIdentifier(id, "id", sysuiContext.getPackageName());
|
||||
view.setId(i);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
* Copyright (C) 2018 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.systemui.plugins;
|
||||
|
||||
import android.hardware.SensorListener;
|
||||
|
||||
import com.android.systemui.plugins.annotations.ProvidesInterface;
|
||||
|
||||
/**
|
||||
* Allows for additional sensors to be retrieved from
|
||||
* {@link com.android.systemui.util.sensors.AsyncSensorManager}.
|
||||
*/
|
||||
@ProvidesInterface(action = SensorManagerPlugin.ACTION, version = SensorManagerPlugin.VERSION)
|
||||
public interface SensorManagerPlugin extends Plugin {
|
||||
String ACTION = "com.android.systemui.action.PLUGIN_SENSOR_MANAGER";
|
||||
int VERSION = 1;
|
||||
|
||||
/**
|
||||
* Registers for sensor events. Events will be sent until the listener is unregistered.
|
||||
* @param sensor
|
||||
* @param listener
|
||||
* @see android.hardware.SensorManager#registerListener(SensorListener, int)
|
||||
*/
|
||||
void registerListener(Sensor sensor, SensorEventListener listener);
|
||||
|
||||
/**
|
||||
* Unregisters events from the sensor.
|
||||
* @param sensor
|
||||
* @param listener
|
||||
*/
|
||||
void unregisterListener(Sensor sensor, SensorEventListener listener);
|
||||
|
||||
/**
|
||||
* Listener triggered whenever the Sensor has new data.
|
||||
*/
|
||||
interface SensorEventListener {
|
||||
void onSensorChanged(SensorEvent event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sensor that can be defined in a plugin.
|
||||
*/
|
||||
class Sensor {
|
||||
public static final int TYPE_WAKE_LOCK_SCREEN = 1;
|
||||
public static final int TYPE_WAKE_DISPLAY = 2;
|
||||
public static final int TYPE_SWIPE = 3;
|
||||
public static final int TYPE_SKIP_STATUS = 4;
|
||||
|
||||
private int mType;
|
||||
|
||||
public Sensor(int type) {
|
||||
mType = type;
|
||||
}
|
||||
public int getType() {
|
||||
return mType;
|
||||
}
|
||||
public String toString() {
|
||||
return "{PluginSensor type=\"" + mType + "\"}";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Event sent by a {@link Sensor}.
|
||||
*/
|
||||
class SensorEvent {
|
||||
Sensor mSensor;
|
||||
int mVendorType;
|
||||
float[] mValues;
|
||||
|
||||
/**
|
||||
* Creates a sensor event.
|
||||
* @param sensor The type of sensor, e.g. TYPE_WAKE_LOCK_SCREEN
|
||||
* @param vendorType The vendor type, which should be unique for each type of sensor,
|
||||
* e.g. SINGLE_TAP = 1, DOUBLE_TAP = 2, etc.
|
||||
*/
|
||||
public SensorEvent(Sensor sensor, int vendorType) {
|
||||
this(sensor, vendorType, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a sensor event.
|
||||
* @param sensor The type of sensor, e.g. TYPE_WAKE_LOCK_SCREEN
|
||||
* @param vendorType The vendor type, which should be unique for each type of sensor,
|
||||
* e.g. SINGLE_TAP = 1, DOUBLE_TAP = 2, etc.
|
||||
* @param values Values captured by the sensor.
|
||||
*/
|
||||
public SensorEvent(Sensor sensor, int vendorType, float[] values) {
|
||||
mSensor = sensor;
|
||||
mVendorType = vendorType;
|
||||
mValues = values;
|
||||
}
|
||||
|
||||
public Sensor getSensor() {
|
||||
return mSensor;
|
||||
}
|
||||
|
||||
public float[] getValues() {
|
||||
return mValues;
|
||||
}
|
||||
|
||||
public int getVendorType() {
|
||||
return mVendorType;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.systemui.plugins;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.annotation.NonNull;
|
||||
import android.view.View;
|
||||
|
||||
import com.android.systemui.plugins.annotations.ProvidesInterface;
|
||||
|
||||
/**
|
||||
* Customize toasts displayed by SystemUI (via Toast#makeText)
|
||||
*/
|
||||
@ProvidesInterface(action = ToastPlugin.ACTION, version = ToastPlugin.VERSION)
|
||||
public interface ToastPlugin extends Plugin {
|
||||
|
||||
String ACTION = "com.android.systemui.action.PLUGIN_TOAST";
|
||||
int VERSION = 1;
|
||||
|
||||
/**
|
||||
* Creates a CustomPluginToast.
|
||||
*/
|
||||
@NonNull Toast createToast(CharSequence text, String packageName, int userId);
|
||||
|
||||
/**
|
||||
* Custom Toast with the ability to change toast positioning, styling and animations.
|
||||
*/
|
||||
interface Toast {
|
||||
/**
|
||||
* Retrieve the Toast view's gravity.
|
||||
* If no changes, returns null.
|
||||
*/
|
||||
default Integer getGravity() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the Toast view's X-offset.
|
||||
* If no changes, returns null.
|
||||
*/
|
||||
default Integer getXOffset() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the Toast view's Y-offset.
|
||||
* If no changes, returns null.
|
||||
*/
|
||||
default Integer getYOffset() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the Toast view's horizontal margin.
|
||||
* If no changes, returns null.
|
||||
*/
|
||||
default Integer getHorizontalMargin() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the Toast view's vertical margin.
|
||||
* If no changes, returns null.
|
||||
*/
|
||||
default Integer getVerticalMargin() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the Toast view to show.
|
||||
* If no changes, returns null.
|
||||
*/
|
||||
default View getView() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the Toast's animate in.
|
||||
* If no changes, returns null.
|
||||
*/
|
||||
default Animator getInAnimation() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the Toast's animate out.
|
||||
* If no changes, returns null.
|
||||
*/
|
||||
default Animator getOutAnimation() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on orientation changes.
|
||||
*/
|
||||
default void onOrientationChange(int orientation) { }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright (C) 2016 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the
|
||||
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.systemui.plugins;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
public interface ViewProvider extends Plugin {
|
||||
View getView();
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (C) 2017 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the
|
||||
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.systemui.plugins;
|
||||
|
||||
import com.android.systemui.plugins.VolumeDialog.Callback;
|
||||
import com.android.systemui.plugins.annotations.DependsOn;
|
||||
import com.android.systemui.plugins.annotations.ProvidesInterface;
|
||||
|
||||
/**
|
||||
* This interface is really just a stub for initialization/teardown, actual handling of
|
||||
* when to show will be done through {@link VolumeDialogController}
|
||||
*/
|
||||
@ProvidesInterface(action = VolumeDialog.ACTION, version = VolumeDialog.VERSION)
|
||||
@DependsOn(target = Callback.class)
|
||||
public interface VolumeDialog extends Plugin {
|
||||
String ACTION = "com.android.systemui.action.PLUGIN_VOLUME";
|
||||
int VERSION = 1;
|
||||
|
||||
void init(int windowType, Callback callback);
|
||||
void destroy();
|
||||
|
||||
@ProvidesInterface(version = VERSION)
|
||||
public interface Callback {
|
||||
int VERSION = 1;
|
||||
|
||||
void onZenSettingsClicked();
|
||||
void onZenPrioritySettingsClicked();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,236 @@
|
||||
/*
|
||||
* Copyright (C) 2017 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the
|
||||
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.systemui.plugins;
|
||||
|
||||
import android.annotation.IntegerRes;
|
||||
import android.content.ComponentName;
|
||||
import android.media.AudioManager;
|
||||
import android.media.AudioSystem;
|
||||
import android.os.Handler;
|
||||
import android.os.VibrationEffect;
|
||||
import android.util.SparseArray;
|
||||
|
||||
import com.android.systemui.plugins.VolumeDialogController.Callbacks;
|
||||
import com.android.systemui.plugins.VolumeDialogController.State;
|
||||
import com.android.systemui.plugins.VolumeDialogController.StreamState;
|
||||
import com.android.systemui.plugins.annotations.DependsOn;
|
||||
import com.android.systemui.plugins.annotations.ProvidesInterface;
|
||||
|
||||
/**
|
||||
* Manages the VolumeDialog.
|
||||
*
|
||||
* Accessible through {@link PluginDependency}
|
||||
*/
|
||||
@ProvidesInterface(version = VolumeDialogController.VERSION)
|
||||
@DependsOn(target = StreamState.class)
|
||||
@DependsOn(target = State.class)
|
||||
@DependsOn(target = Callbacks.class)
|
||||
public interface VolumeDialogController {
|
||||
int VERSION = 1;
|
||||
|
||||
void setActiveStream(int stream);
|
||||
void setStreamVolume(int stream, int userLevel);
|
||||
void setRingerMode(int ringerModeNormal, boolean external);
|
||||
|
||||
boolean hasVibrator();
|
||||
void vibrate(VibrationEffect effect);
|
||||
void scheduleTouchFeedback();
|
||||
|
||||
AudioManager getAudioManager();
|
||||
|
||||
void notifyVisible(boolean visible);
|
||||
|
||||
void addCallback(Callbacks callbacks, Handler handler);
|
||||
void removeCallback(Callbacks callbacks);
|
||||
|
||||
void userActivity();
|
||||
void getState();
|
||||
|
||||
/**
|
||||
* Get Captions enabled state
|
||||
*
|
||||
* @param checkForSwitchState set true when we'd like to switch captions enabled state after
|
||||
* getting the latest captions state.
|
||||
*/
|
||||
void getCaptionsEnabledState(boolean checkForSwitchState);
|
||||
|
||||
/**
|
||||
* Set Captions enabled state
|
||||
*
|
||||
* @param enabled the captions enabled state we'd like to update.
|
||||
*/
|
||||
void setCaptionsEnabledState(boolean enabled);
|
||||
|
||||
/**
|
||||
* Get Captions component state
|
||||
*
|
||||
* @param fromTooltip if it's triggered from tooltip.
|
||||
*/
|
||||
void getCaptionsComponentState(boolean fromTooltip);
|
||||
|
||||
@ProvidesInterface(version = StreamState.VERSION)
|
||||
public static final class StreamState {
|
||||
public static final int VERSION = 1;
|
||||
|
||||
public boolean dynamic;
|
||||
public int level;
|
||||
public int levelMin;
|
||||
public int levelMax;
|
||||
public boolean muted;
|
||||
public boolean muteSupported;
|
||||
public @IntegerRes int name;
|
||||
public String remoteLabel;
|
||||
public boolean routedToBluetooth;
|
||||
|
||||
public StreamState copy() {
|
||||
final StreamState rt = new StreamState();
|
||||
rt.dynamic = dynamic;
|
||||
rt.level = level;
|
||||
rt.levelMin = levelMin;
|
||||
rt.levelMax = levelMax;
|
||||
rt.muted = muted;
|
||||
rt.muteSupported = muteSupported;
|
||||
rt.name = name;
|
||||
rt.remoteLabel = remoteLabel;
|
||||
rt.routedToBluetooth = routedToBluetooth;
|
||||
return rt;
|
||||
}
|
||||
}
|
||||
|
||||
@ProvidesInterface(version = State.VERSION)
|
||||
public static final class State {
|
||||
public static final int VERSION = 1;
|
||||
|
||||
public static int NO_ACTIVE_STREAM = -1;
|
||||
|
||||
public final SparseArray<StreamState> states = new SparseArray<>();
|
||||
|
||||
public int ringerModeInternal;
|
||||
public int ringerModeExternal;
|
||||
public int zenMode;
|
||||
public ComponentName effectsSuppressor;
|
||||
public String effectsSuppressorName;
|
||||
public int activeStream = NO_ACTIVE_STREAM;
|
||||
public boolean disallowAlarms;
|
||||
public boolean disallowMedia;
|
||||
public boolean disallowSystem;
|
||||
public boolean disallowRinger;
|
||||
|
||||
public State copy() {
|
||||
final State rt = new State();
|
||||
for (int i = 0; i < states.size(); i++) {
|
||||
rt.states.put(states.keyAt(i), states.valueAt(i).copy());
|
||||
}
|
||||
rt.ringerModeExternal = ringerModeExternal;
|
||||
rt.ringerModeInternal = ringerModeInternal;
|
||||
rt.zenMode = zenMode;
|
||||
if (effectsSuppressor != null) {
|
||||
rt.effectsSuppressor = effectsSuppressor.clone();
|
||||
}
|
||||
rt.effectsSuppressorName = effectsSuppressorName;
|
||||
rt.activeStream = activeStream;
|
||||
rt.disallowAlarms = disallowAlarms;
|
||||
rt.disallowMedia = disallowMedia;
|
||||
rt.disallowSystem = disallowSystem;
|
||||
rt.disallowRinger = disallowRinger;
|
||||
return rt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return toString(0);
|
||||
}
|
||||
|
||||
public String toString(int indent) {
|
||||
final StringBuilder sb = new StringBuilder("{");
|
||||
if (indent > 0) sep(sb, indent);
|
||||
for (int i = 0; i < states.size(); i++) {
|
||||
if (i > 0) {
|
||||
sep(sb, indent);
|
||||
}
|
||||
final int stream = states.keyAt(i);
|
||||
final StreamState ss = states.valueAt(i);
|
||||
sb.append(AudioSystem.streamToString(stream)).append(":").append(ss.level)
|
||||
.append('[').append(ss.levelMin).append("..").append(ss.levelMax)
|
||||
.append(']');
|
||||
if (ss.muted) sb.append(" [MUTED]");
|
||||
if (ss.dynamic) sb.append(" [DYNAMIC]");
|
||||
}
|
||||
sep(sb, indent); sb.append("ringerModeExternal:").append(ringerModeExternal);
|
||||
sep(sb, indent); sb.append("ringerModeInternal:").append(ringerModeInternal);
|
||||
sep(sb, indent); sb.append("zenMode:").append(zenMode);
|
||||
sep(sb, indent); sb.append("effectsSuppressor:").append(effectsSuppressor);
|
||||
sep(sb, indent); sb.append("effectsSuppressorName:").append(effectsSuppressorName);
|
||||
sep(sb, indent); sb.append("activeStream:").append(activeStream);
|
||||
sep(sb, indent); sb.append("disallowAlarms:").append(disallowAlarms);
|
||||
sep(sb, indent); sb.append("disallowMedia:").append(disallowMedia);
|
||||
sep(sb, indent); sb.append("disallowSystem:").append(disallowSystem);
|
||||
sep(sb, indent); sb.append("disallowRinger:").append(disallowRinger);
|
||||
if (indent > 0) sep(sb, indent);
|
||||
return sb.append('}').toString();
|
||||
}
|
||||
|
||||
private static void sep(StringBuilder sb, int indent) {
|
||||
if (indent > 0) {
|
||||
sb.append('\n');
|
||||
for (int i = 0; i < indent; i++) {
|
||||
sb.append(' ');
|
||||
}
|
||||
} else {
|
||||
sb.append(',');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ProvidesInterface(version = Callbacks.VERSION)
|
||||
public interface Callbacks {
|
||||
int VERSION = 2;
|
||||
|
||||
// requires version 1
|
||||
void onShowRequested(int reason, boolean keyguardLocked, int lockTaskModeState);
|
||||
void onDismissRequested(int reason);
|
||||
void onStateChanged(State state);
|
||||
void onLayoutDirectionChanged(int layoutDirection);
|
||||
void onConfigurationChanged();
|
||||
void onShowVibrateHint();
|
||||
void onShowSilentHint();
|
||||
void onScreenOff();
|
||||
void onShowSafetyWarning(int flags);
|
||||
void onAccessibilityModeChanged(Boolean showA11yStream);
|
||||
|
||||
/**
|
||||
* Callback function for captions component state changed event
|
||||
*
|
||||
* @param isComponentEnabled the lateset captions component state.
|
||||
* @param fromTooltip if it's triggered from tooltip.
|
||||
*/
|
||||
void onCaptionComponentStateChanged(Boolean isComponentEnabled, Boolean fromTooltip);
|
||||
|
||||
/**
|
||||
* Callback function for captions enabled state changed event
|
||||
*
|
||||
* @param isEnabled the lateset captions enabled state.
|
||||
* @param checkBeforeSwitch intend to switch captions enabled state after the callback.
|
||||
*/
|
||||
void onCaptionEnabledStateChanged(Boolean isEnabled, Boolean checkBeforeSwitch);
|
||||
// requires version 2
|
||||
void onShowCsdWarning(@AudioManager.CsdWarning int csdWarning, int durationMs);
|
||||
|
||||
/**
|
||||
* Callback function for when the volume changed due to a physical key press.
|
||||
*/
|
||||
void onVolumeChangedFromKey();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.android.systemui.plugins.clocks
|
||||
|
||||
data class AlarmData(
|
||||
val nextAlarmMillis: Long?,
|
||||
val descriptionId: String?,
|
||||
)
|
||||
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* Copyright (C) 2022 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the
|
||||
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
package com.android.systemui.plugins.clocks
|
||||
|
||||
import com.android.internal.annotations.Keep
|
||||
import org.json.JSONObject
|
||||
|
||||
/** Identifies a clock design */
|
||||
typealias ClockId = String
|
||||
|
||||
data class AodClockBurnInModel(
|
||||
val scale: Float,
|
||||
val translationX: Float,
|
||||
val translationY: Float,
|
||||
)
|
||||
|
||||
/** Tick rates for clocks */
|
||||
enum class ClockTickRate(val value: Int) {
|
||||
PER_MINUTE(2), // Update the clock once per minute.
|
||||
PER_SECOND(1), // Update the clock once per second.
|
||||
PER_FRAME(0), // Update the clock every second.
|
||||
}
|
||||
|
||||
/** Some data about a clock design */
|
||||
data class ClockMetadata(
|
||||
val clockId: ClockId,
|
||||
)
|
||||
|
||||
/** Render configuration for the full clock. Modifies the way systemUI behaves with this clock. */
|
||||
data class ClockConfig(
|
||||
val id: String,
|
||||
|
||||
/** Localized name of the clock */
|
||||
val name: String,
|
||||
|
||||
/** Localized accessibility description for the clock */
|
||||
val description: String,
|
||||
|
||||
/** Transition to AOD should move smartspace like large clock instead of small clock */
|
||||
val useAlternateSmartspaceAODTransition: Boolean = false,
|
||||
|
||||
/** True if the clock will react to tone changes in the seed color. */
|
||||
val isReactiveToTone: Boolean = true,
|
||||
|
||||
/** True if the clock is large frame clock, which will use weather in compose. */
|
||||
val useCustomClockScene: Boolean = false,
|
||||
)
|
||||
|
||||
/** Render configuration options for a clock face. Modifies the way SystemUI behaves. */
|
||||
data class ClockFaceConfig(
|
||||
/** Expected interval between calls to onTimeTick. Can always reduce to PER_MINUTE in AOD. */
|
||||
val tickRate: ClockTickRate = ClockTickRate.PER_MINUTE,
|
||||
|
||||
/** Call to check whether the clock consumes weather data */
|
||||
val hasCustomWeatherDataDisplay: Boolean = false,
|
||||
|
||||
/**
|
||||
* Whether this clock has a custom position update animation. If true, the keyguard will call
|
||||
* `onPositionUpdated` to notify the clock of a position update animation. If false, a default
|
||||
* animation will be used (e.g. a simple translation).
|
||||
*/
|
||||
val hasCustomPositionUpdatedAnimation: Boolean = false,
|
||||
|
||||
/** True if the clock is large frame clock, which will use weatherBlueprint in compose. */
|
||||
val useCustomClockScene: Boolean = false,
|
||||
)
|
||||
|
||||
/** Structure for keeping clock-specific settings */
|
||||
@Keep
|
||||
data class ClockSettings(
|
||||
val clockId: ClockId? = null,
|
||||
val seedColor: Int? = null,
|
||||
) {
|
||||
// Exclude metadata from equality checks
|
||||
var metadata: JSONObject = JSONObject()
|
||||
|
||||
companion object {
|
||||
private val KEY_CLOCK_ID = "clockId"
|
||||
private val KEY_SEED_COLOR = "seedColor"
|
||||
private val KEY_METADATA = "metadata"
|
||||
|
||||
fun serialize(setting: ClockSettings?): String {
|
||||
if (setting == null) {
|
||||
return ""
|
||||
}
|
||||
|
||||
return JSONObject()
|
||||
.put(KEY_CLOCK_ID, setting.clockId)
|
||||
.put(KEY_SEED_COLOR, setting.seedColor)
|
||||
.put(KEY_METADATA, setting.metadata)
|
||||
.toString()
|
||||
}
|
||||
|
||||
fun deserialize(jsonStr: String?): ClockSettings? {
|
||||
if (jsonStr.isNullOrEmpty()) {
|
||||
return null
|
||||
}
|
||||
|
||||
val json = JSONObject(jsonStr)
|
||||
val result =
|
||||
ClockSettings(
|
||||
if (!json.isNull(KEY_CLOCK_ID)) json.getString(KEY_CLOCK_ID) else null,
|
||||
if (!json.isNull(KEY_SEED_COLOR)) json.getInt(KEY_SEED_COLOR) else null
|
||||
)
|
||||
if (!json.isNull(KEY_METADATA)) {
|
||||
result.metadata = json.getJSONObject(KEY_METADATA)
|
||||
}
|
||||
return result
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
package com.android.systemui.plugins.clocks
|
||||
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
import androidx.annotation.VisibleForTesting
|
||||
|
||||
typealias WeatherTouchAction = (View) -> Unit
|
||||
|
||||
data class WeatherData(
|
||||
val description: String,
|
||||
val state: WeatherStateIcon,
|
||||
val useCelsius: Boolean,
|
||||
val temperature: Int,
|
||||
val touchAction: WeatherTouchAction? = null,
|
||||
) {
|
||||
companion object {
|
||||
const val DEBUG = true
|
||||
private const val TAG = "WeatherData"
|
||||
@VisibleForTesting const val DESCRIPTION_KEY = "description"
|
||||
@VisibleForTesting const val STATE_KEY = "state"
|
||||
@VisibleForTesting const val USE_CELSIUS_KEY = "use_celsius"
|
||||
@VisibleForTesting const val TEMPERATURE_KEY = "temperature"
|
||||
private const val INVALID_WEATHER_ICON_STATE = -1
|
||||
|
||||
fun fromBundle(extras: Bundle, touchAction: WeatherTouchAction? = null): WeatherData? {
|
||||
val description = extras.getString(DESCRIPTION_KEY)
|
||||
val state =
|
||||
WeatherStateIcon.fromInt(extras.getInt(STATE_KEY, INVALID_WEATHER_ICON_STATE))
|
||||
val temperature = readIntFromBundle(extras, TEMPERATURE_KEY)
|
||||
if (
|
||||
description == null ||
|
||||
state == null ||
|
||||
!extras.containsKey(USE_CELSIUS_KEY) ||
|
||||
temperature == null
|
||||
) {
|
||||
if (DEBUG) {
|
||||
Log.w(TAG, "Weather data did not parse from $extras")
|
||||
}
|
||||
return null
|
||||
} else {
|
||||
val result =
|
||||
WeatherData(
|
||||
description = description,
|
||||
state = state,
|
||||
useCelsius = extras.getBoolean(USE_CELSIUS_KEY),
|
||||
temperature = temperature,
|
||||
touchAction = touchAction
|
||||
)
|
||||
if (DEBUG) {
|
||||
Log.i(TAG, "Weather data parsed $result from $extras")
|
||||
}
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
private fun readIntFromBundle(extras: Bundle, key: String): Int? =
|
||||
try {
|
||||
extras.getString(key)?.toInt()
|
||||
} catch (e: Exception) {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
// Values for WeatherStateIcon must stay in sync with go/g3-WeatherStateIcon
|
||||
enum class WeatherStateIcon(val id: Int) {
|
||||
UNKNOWN_ICON(0),
|
||||
|
||||
// Clear, day & night.
|
||||
SUNNY(1),
|
||||
CLEAR_NIGHT(2),
|
||||
|
||||
// Mostly clear, day & night.
|
||||
MOSTLY_SUNNY(3),
|
||||
MOSTLY_CLEAR_NIGHT(4),
|
||||
|
||||
// Partly cloudy, day & night.
|
||||
PARTLY_CLOUDY(5),
|
||||
PARTLY_CLOUDY_NIGHT(6),
|
||||
|
||||
// Mostly cloudy, day & night.
|
||||
MOSTLY_CLOUDY_DAY(7),
|
||||
MOSTLY_CLOUDY_NIGHT(8),
|
||||
CLOUDY(9),
|
||||
HAZE_FOG_DUST_SMOKE(10),
|
||||
DRIZZLE(11),
|
||||
HEAVY_RAIN(12),
|
||||
SHOWERS_RAIN(13),
|
||||
|
||||
// Scattered showers, day & night.
|
||||
SCATTERED_SHOWERS_DAY(14),
|
||||
SCATTERED_SHOWERS_NIGHT(15),
|
||||
|
||||
// Isolated scattered thunderstorms, day & night.
|
||||
ISOLATED_SCATTERED_TSTORMS_DAY(16),
|
||||
ISOLATED_SCATTERED_TSTORMS_NIGHT(17),
|
||||
STRONG_TSTORMS(18),
|
||||
BLIZZARD(19),
|
||||
BLOWING_SNOW(20),
|
||||
FLURRIES(21),
|
||||
HEAVY_SNOW(22),
|
||||
|
||||
// Scattered snow showers, day & night.
|
||||
SCATTERED_SNOW_SHOWERS_DAY(23),
|
||||
SCATTERED_SNOW_SHOWERS_NIGHT(24),
|
||||
SNOW_SHOWERS_SNOW(25),
|
||||
MIXED_RAIN_HAIL_RAIN_SLEET(26),
|
||||
SLEET_HAIL(27),
|
||||
TORNADO(28),
|
||||
TROPICAL_STORM_HURRICANE(29),
|
||||
WINDY_BREEZY(30),
|
||||
WINTRY_MIX_RAIN_SNOW(31);
|
||||
|
||||
companion object {
|
||||
fun fromInt(value: Int) = values().firstOrNull { it.id == value }
|
||||
}
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
val unit = if (useCelsius) "C" else "F"
|
||||
return "$state (\"$description\") $temperature°$unit"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.android.systemui.plugins.clocks
|
||||
|
||||
import android.provider.Settings.Global.ZEN_MODE_ALARMS
|
||||
import android.provider.Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS
|
||||
import android.provider.Settings.Global.ZEN_MODE_NO_INTERRUPTIONS
|
||||
import android.provider.Settings.Global.ZEN_MODE_OFF
|
||||
|
||||
data class ZenData(
|
||||
val zenMode: ZenMode,
|
||||
val descriptionId: String?,
|
||||
) {
|
||||
enum class ZenMode(val zenMode: Int) {
|
||||
OFF(ZEN_MODE_OFF),
|
||||
IMPORTANT_INTERRUPTIONS(ZEN_MODE_IMPORTANT_INTERRUPTIONS),
|
||||
NO_INTERRUPTIONS(ZEN_MODE_NO_INTERRUPTIONS),
|
||||
ALARMS(ZEN_MODE_ALARMS);
|
||||
|
||||
companion object {
|
||||
fun fromInt(zenMode: Int) = values().firstOrNull { it.zenMode == zenMode }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the
|
||||
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.systemui.plugins.log
|
||||
|
||||
/**
|
||||
* Base interface for a logger that logs changes in table format.
|
||||
*
|
||||
* This is a plugin interface for classes outside of SystemUI core.
|
||||
*/
|
||||
interface TableLogBufferBase {
|
||||
/**
|
||||
* Logs a String? change.
|
||||
*
|
||||
* For Java overloading.
|
||||
*/
|
||||
fun logChange(prefix: String, columnName: String, value: String?) {
|
||||
logChange(prefix, columnName, value, isInitial = false)
|
||||
}
|
||||
|
||||
/** Logs a String? change. */
|
||||
fun logChange(prefix: String, columnName: String, value: String?, isInitial: Boolean)
|
||||
|
||||
/**
|
||||
* Logs a Boolean change.
|
||||
*
|
||||
* For Java overloading.
|
||||
*/
|
||||
fun logChange(prefix: String, columnName: String, value: Boolean) {
|
||||
logChange(prefix, columnName, value, isInitial = false)
|
||||
}
|
||||
|
||||
/** Logs a Boolean change. */
|
||||
fun logChange(prefix: String, columnName: String, value: Boolean, isInitial: Boolean)
|
||||
|
||||
/**
|
||||
* Logs an Int? change.
|
||||
*
|
||||
* For Java overloading.
|
||||
*/
|
||||
fun logChange(prefix: String, columnName: String, value: Int?) {
|
||||
logChange(prefix, columnName, value, isInitial = false)
|
||||
}
|
||||
|
||||
/** Logs an Int? change. */
|
||||
fun logChange(prefix: String, columnName: String, value: Int?, isInitial: Boolean)
|
||||
}
|
||||
@@ -0,0 +1,183 @@
|
||||
/*
|
||||
* Copyright (C) 2016 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the
|
||||
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.systemui.plugins.qs;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.FloatRange;
|
||||
|
||||
import com.android.systemui.plugins.FragmentBase;
|
||||
import com.android.systemui.plugins.annotations.DependsOn;
|
||||
import com.android.systemui.plugins.annotations.ProvidesInterface;
|
||||
import com.android.systemui.plugins.qs.QS.HeightListener;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* Fragment that contains QS in the notification shade. Most of the interface is for
|
||||
* handling the expand/collapsing of the view interaction.
|
||||
*/
|
||||
@ProvidesInterface(action = QS.ACTION, version = QS.VERSION)
|
||||
@DependsOn(target = HeightListener.class)
|
||||
public interface QS extends FragmentBase {
|
||||
|
||||
String ACTION = "com.android.systemui.action.PLUGIN_QS";
|
||||
|
||||
int VERSION = 15;
|
||||
|
||||
String TAG = "QS";
|
||||
|
||||
void setPanelView(HeightListener notificationPanelView);
|
||||
|
||||
void hideImmediately();
|
||||
int getQsMinExpansionHeight();
|
||||
int getDesiredHeight();
|
||||
void setHeightOverride(int desiredHeight);
|
||||
void setHeaderClickable(boolean qsExpansionEnabled);
|
||||
boolean isCustomizing();
|
||||
/** Close the QS customizer, if it is open. */
|
||||
void closeCustomizer();
|
||||
void setOverscrolling(boolean overscrolling);
|
||||
void setExpanded(boolean qsExpanded);
|
||||
void setListening(boolean listening);
|
||||
|
||||
/**
|
||||
* Set whether QQS/QS is visible or not.
|
||||
*
|
||||
* This is different from setExpanded, as it will be true when QQS is visible. In particular,
|
||||
* it should be false when device is locked and only notifications (in lockscreen) are visible.
|
||||
*/
|
||||
void setQsVisible(boolean qsVisible);
|
||||
boolean isShowingDetail();
|
||||
void closeDetail();
|
||||
void animateHeaderSlidingOut();
|
||||
|
||||
/**
|
||||
* Asks QS to update its presentation, according to {@code NotificationPanelViewController}.
|
||||
* @param qsExpansionFraction How much each UI element in QS should be expanded (QQS to QS.)
|
||||
* @param panelExpansionFraction Whats the expansion of the whole shade.
|
||||
* @param headerTranslation How much we should vertically translate QS.
|
||||
* @param squishinessFraction Fraction that affects tile height. 0 when collapsed,
|
||||
* 1 when expanded.
|
||||
*/
|
||||
void setQsExpansion(float qsExpansionFraction, float panelExpansionFraction,
|
||||
float headerTranslation, float squishinessFraction);
|
||||
void setHeaderListening(boolean listening);
|
||||
void notifyCustomizeChanged();
|
||||
void setContainerController(QSContainerController controller);
|
||||
|
||||
/**
|
||||
* Provide an action to collapse if expanded or expand if collapsed.
|
||||
* @param action
|
||||
*/
|
||||
void setCollapseExpandAction(Runnable action);
|
||||
|
||||
/**
|
||||
* Returns the height difference between the QSPanel container and the QuickQSPanel container
|
||||
*/
|
||||
int getHeightDiff();
|
||||
|
||||
View getHeader();
|
||||
|
||||
default void setHasNotifications(boolean hasNotifications) {
|
||||
}
|
||||
|
||||
/** Sets whether the squishiness fraction should be updated on the media host. */
|
||||
default void setShouldUpdateSquishinessOnMedia(boolean shouldUpdate) {}
|
||||
|
||||
/**
|
||||
* Should touches from the notification panel be disallowed?
|
||||
* The notification panel might grab any touches rom QS at any time to collapse the shade.
|
||||
* We should disallow that in case we are showing the detail panel.
|
||||
*/
|
||||
default boolean disallowPanelTouches() {
|
||||
return isShowingDetail();
|
||||
}
|
||||
|
||||
/**
|
||||
* If QS should translate as we pull it down, or if it should be static.
|
||||
*/
|
||||
void setInSplitShade(boolean shouldTranslate);
|
||||
|
||||
/**
|
||||
* Sets the progress of the transition to full shade on the lockscreen.
|
||||
*
|
||||
* @param isTransitioningToFullShade
|
||||
* whether the transition to full shade is in progress. This might be {@code true}, even
|
||||
* though {@code qsTransitionFraction} is still 0.
|
||||
* The reason for that is that on some device configurations, the QS transition has a
|
||||
* start delay compared to the overall transition.
|
||||
*
|
||||
* @param qsTransitionFraction
|
||||
* the fraction of the QS transition progress, from 0 to 1.
|
||||
*
|
||||
* @param qsSquishinessFraction
|
||||
* the fraction of the QS "squish" transition progress, from 0 to 1.
|
||||
*/
|
||||
default void setTransitionToFullShadeProgress(
|
||||
boolean isTransitioningToFullShade,
|
||||
@FloatRange(from = 0.0, to = 1.0) float qsTransitionFraction,
|
||||
@FloatRange(from = 0.0, to = 1.0) float qsSquishinessFraction) {}
|
||||
|
||||
/**
|
||||
* A rounded corner clipping that makes QS feel as if it were behind everything.
|
||||
*/
|
||||
void setFancyClipping(int leftInset, int top, int rightInset, int bottom, int cornerRadius,
|
||||
boolean visible, boolean fullWidth);
|
||||
|
||||
/**
|
||||
* @return if quick settings is fully collapsed currently
|
||||
*/
|
||||
default boolean isFullyCollapsed() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a listener for when the collapsed media visibility changes.
|
||||
*/
|
||||
void setCollapsedMediaVisibilityChangedListener(Consumer<Boolean> listener);
|
||||
|
||||
/**
|
||||
* Set a scroll listener for the QSPanel container
|
||||
*/
|
||||
default void setScrollListener(ScrollListener scrollListener) {}
|
||||
|
||||
/**
|
||||
* Sets the amount of vertical over scroll that should be performed on QS.
|
||||
*/
|
||||
default void setOverScrollAmount(int overScrollAmount) {}
|
||||
|
||||
/**
|
||||
* Sets whether the notification panel is using the full width of the screen. Typically true on
|
||||
* small screens and false on large screens.
|
||||
*/
|
||||
void setIsNotificationPanelFullWidth(boolean isFullWidth);
|
||||
|
||||
/**
|
||||
* Callback for when QSPanel container is scrolled
|
||||
*/
|
||||
@ProvidesInterface(version = ScrollListener.VERSION)
|
||||
interface ScrollListener {
|
||||
int VERSION = 1;
|
||||
void onQsPanelScrollChanged(int scrollY);
|
||||
}
|
||||
|
||||
@ProvidesInterface(version = HeightListener.VERSION)
|
||||
interface HeightListener {
|
||||
int VERSION = 1;
|
||||
void onQsHeightChanged();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.android.systemui.plugins.qs
|
||||
|
||||
interface QSContainerController {
|
||||
fun setCustomizerAnimating(animating: Boolean)
|
||||
|
||||
fun setCustomizerShowing(showing: Boolean) = setCustomizerShowing(showing, 0L)
|
||||
|
||||
fun setCustomizerShowing(showing: Boolean, animationDuration: Long)
|
||||
|
||||
fun setDetailShowing(showing: Boolean)
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (C) 2017 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the
|
||||
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.systemui.plugins.qs;
|
||||
|
||||
import com.android.systemui.plugins.Plugin;
|
||||
import com.android.systemui.plugins.annotations.DependsOn;
|
||||
import com.android.systemui.plugins.annotations.ProvidesInterface;
|
||||
|
||||
/**
|
||||
* Plugin that has the ability to create or override any part of
|
||||
* QS tiles.
|
||||
*/
|
||||
@ProvidesInterface(action = QSFactory.ACTION, version = QSFactory.VERSION)
|
||||
@DependsOn(target = QSTile.class)
|
||||
@DependsOn(target = QSTileView.class)
|
||||
public interface QSFactory extends Plugin {
|
||||
|
||||
String ACTION = "com.android.systemui.action.PLUGIN_QS_FACTORY";
|
||||
int VERSION = 3;
|
||||
|
||||
QSTile createTile(String tileSpec);
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (C) 2017 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the
|
||||
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.systemui.plugins.qs;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.android.systemui.plugins.annotations.ProvidesInterface;
|
||||
import com.android.systemui.plugins.qs.QSTile.State;
|
||||
|
||||
@ProvidesInterface(version = QSIconView.VERSION)
|
||||
public abstract class QSIconView extends ViewGroup {
|
||||
public static final int VERSION = 1;
|
||||
|
||||
public QSIconView(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public abstract void setIcon(State state, boolean allowAnimations);
|
||||
public abstract void disableAnimation();
|
||||
public abstract View getIconView();
|
||||
}
|
||||
@@ -0,0 +1,314 @@
|
||||
/*
|
||||
* Copyright (C) 2017 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the
|
||||
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.systemui.plugins.qs;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.metrics.LogMaker;
|
||||
import android.service.quicksettings.Tile;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.android.internal.logging.InstanceId;
|
||||
import com.android.systemui.animation.Expandable;
|
||||
import com.android.systemui.plugins.annotations.DependsOn;
|
||||
import com.android.systemui.plugins.annotations.ProvidesInterface;
|
||||
import com.android.systemui.plugins.qs.QSTile.Callback;
|
||||
import com.android.systemui.plugins.qs.QSTile.Icon;
|
||||
import com.android.systemui.plugins.qs.QSTile.State;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@ProvidesInterface(version = QSTile.VERSION)
|
||||
@DependsOn(target = QSIconView.class)
|
||||
@DependsOn(target = Callback.class)
|
||||
@DependsOn(target = Icon.class)
|
||||
@DependsOn(target = State.class)
|
||||
public interface QSTile {
|
||||
int VERSION = 4;
|
||||
|
||||
String getTileSpec();
|
||||
|
||||
boolean isAvailable();
|
||||
void setTileSpec(String tileSpec);
|
||||
|
||||
@Deprecated default void clearState() {}
|
||||
void refreshState();
|
||||
|
||||
void addCallback(Callback callback);
|
||||
void removeCallback(Callback callback);
|
||||
void removeCallbacks();
|
||||
|
||||
/**
|
||||
* The tile was clicked.
|
||||
*
|
||||
* @param expandable {@link Expandable} that was clicked.
|
||||
*/
|
||||
void click(@Nullable Expandable expandable);
|
||||
|
||||
/**
|
||||
* The tile secondary click was triggered.
|
||||
*
|
||||
* @param expandable {@link Expandable} that was clicked.
|
||||
*/
|
||||
void secondaryClick(@Nullable Expandable expandable);
|
||||
|
||||
/**
|
||||
* The tile was long clicked.
|
||||
*
|
||||
* @param expandable {@link Expandable} that was clicked.
|
||||
*/
|
||||
void longClick(@Nullable Expandable expandable);
|
||||
|
||||
void userSwitch(int currentUser);
|
||||
|
||||
/**
|
||||
* @deprecated not needed as {@link com.android.internal.logging.UiEvent} will use
|
||||
* {@link #getMetricsSpec}
|
||||
*/
|
||||
@Deprecated
|
||||
int getMetricsCategory();
|
||||
|
||||
void setListening(Object client, boolean listening);
|
||||
void setDetailListening(boolean show);
|
||||
|
||||
void destroy();
|
||||
|
||||
CharSequence getTileLabel();
|
||||
|
||||
State getState();
|
||||
|
||||
default LogMaker populate(LogMaker logMaker) {
|
||||
return logMaker;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a string to be used to identify the tile in UiEvents.
|
||||
*/
|
||||
default String getMetricsSpec() {
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an {@link InstanceId} to be used to identify the tile in UiEvents.
|
||||
*/
|
||||
InstanceId getInstanceId();
|
||||
|
||||
default boolean isTileReady() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether the tile is set to its listening state and therefore receiving updates and
|
||||
* refreshes from controllers
|
||||
*/
|
||||
boolean isListening();
|
||||
|
||||
@ProvidesInterface(version = Callback.VERSION)
|
||||
interface Callback {
|
||||
static final int VERSION = 2;
|
||||
void onStateChanged(State state);
|
||||
}
|
||||
|
||||
@ProvidesInterface(version = Icon.VERSION)
|
||||
public static abstract class Icon {
|
||||
public static final int VERSION = 1;
|
||||
abstract public Drawable getDrawable(Context context);
|
||||
|
||||
public Drawable getInvisibleDrawable(Context context) {
|
||||
return getDrawable(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Icon.class.hashCode();
|
||||
}
|
||||
|
||||
public int getPadding() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
public String toString() {
|
||||
return "Icon";
|
||||
}
|
||||
}
|
||||
|
||||
@ProvidesInterface(version = State.VERSION)
|
||||
public static class State {
|
||||
public static final int VERSION = 1;
|
||||
public static final int DEFAULT_STATE = Tile.STATE_ACTIVE;
|
||||
|
||||
public Icon icon;
|
||||
public Supplier<Icon> iconSupplier;
|
||||
public int state = DEFAULT_STATE;
|
||||
public CharSequence label;
|
||||
@Nullable public CharSequence secondaryLabel;
|
||||
public CharSequence contentDescription;
|
||||
@Nullable public CharSequence stateDescription;
|
||||
public CharSequence dualLabelContentDescription;
|
||||
public boolean disabledByPolicy;
|
||||
public boolean dualTarget = false;
|
||||
public boolean isTransient = false;
|
||||
public String expandedAccessibilityClassName;
|
||||
public boolean handlesLongClick = true;
|
||||
@Nullable
|
||||
public Drawable sideViewCustomDrawable;
|
||||
public String spec;
|
||||
|
||||
/** Get the state text. */
|
||||
public CharSequence getStateText(int arrayResId, Resources resources) {
|
||||
if (state == Tile.STATE_UNAVAILABLE || this instanceof QSTile.BooleanState) {
|
||||
String[] array = resources.getStringArray(arrayResId);
|
||||
return array[state];
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/** Get the text for secondaryLabel. */
|
||||
public CharSequence getSecondaryLabel(CharSequence stateText) {
|
||||
// Use a local reference as the value might change from other threads
|
||||
CharSequence localSecondaryLabel = secondaryLabel;
|
||||
if (TextUtils.isEmpty(localSecondaryLabel)) {
|
||||
return stateText;
|
||||
}
|
||||
return localSecondaryLabel;
|
||||
}
|
||||
|
||||
public boolean copyTo(State other) {
|
||||
if (other == null) throw new IllegalArgumentException();
|
||||
if (!other.getClass().equals(getClass())) throw new IllegalArgumentException();
|
||||
final boolean changed = !Objects.equals(other.spec, spec)
|
||||
|| !Objects.equals(other.icon, icon)
|
||||
|| !Objects.equals(other.iconSupplier, iconSupplier)
|
||||
|| !Objects.equals(other.label, label)
|
||||
|| !Objects.equals(other.secondaryLabel, secondaryLabel)
|
||||
|| !Objects.equals(other.contentDescription, contentDescription)
|
||||
|| !Objects.equals(other.stateDescription, stateDescription)
|
||||
|| !Objects.equals(other.dualLabelContentDescription,
|
||||
dualLabelContentDescription)
|
||||
|| !Objects.equals(other.expandedAccessibilityClassName,
|
||||
expandedAccessibilityClassName)
|
||||
|| !Objects.equals(other.disabledByPolicy, disabledByPolicy)
|
||||
|| !Objects.equals(other.state, state)
|
||||
|| !Objects.equals(other.isTransient, isTransient)
|
||||
|| !Objects.equals(other.dualTarget, dualTarget)
|
||||
|| !Objects.equals(other.handlesLongClick, handlesLongClick)
|
||||
|| !Objects.equals(other.sideViewCustomDrawable, sideViewCustomDrawable);
|
||||
other.spec = spec;
|
||||
other.icon = icon;
|
||||
other.iconSupplier = iconSupplier;
|
||||
other.label = label;
|
||||
other.secondaryLabel = secondaryLabel;
|
||||
other.contentDescription = contentDescription;
|
||||
other.stateDescription = stateDescription;
|
||||
other.dualLabelContentDescription = dualLabelContentDescription;
|
||||
other.expandedAccessibilityClassName = expandedAccessibilityClassName;
|
||||
other.disabledByPolicy = disabledByPolicy;
|
||||
other.state = state;
|
||||
other.dualTarget = dualTarget;
|
||||
other.isTransient = isTransient;
|
||||
other.handlesLongClick = handlesLongClick;
|
||||
other.sideViewCustomDrawable = sideViewCustomDrawable;
|
||||
return changed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return toStringBuilder().toString();
|
||||
}
|
||||
|
||||
// Used in dumps to determine current state of a tile.
|
||||
// This string may be used for CTS testing of tiles, so removing elements is discouraged.
|
||||
protected StringBuilder toStringBuilder() {
|
||||
final StringBuilder sb = new StringBuilder(getClass().getSimpleName()).append('[');
|
||||
sb.append("spec=").append(spec);
|
||||
sb.append(",icon=").append(icon);
|
||||
sb.append(",iconSupplier=").append(iconSupplier);
|
||||
sb.append(",label=").append(label);
|
||||
sb.append(",secondaryLabel=").append(secondaryLabel);
|
||||
sb.append(",contentDescription=").append(contentDescription);
|
||||
sb.append(",stateDescription=").append(stateDescription);
|
||||
sb.append(",dualLabelContentDescription=").append(dualLabelContentDescription);
|
||||
sb.append(",expandedAccessibilityClassName=").append(expandedAccessibilityClassName);
|
||||
sb.append(",disabledByPolicy=").append(disabledByPolicy);
|
||||
sb.append(",dualTarget=").append(dualTarget);
|
||||
sb.append(",isTransient=").append(isTransient);
|
||||
sb.append(",state=").append(state);
|
||||
sb.append(",sideViewCustomDrawable=").append(sideViewCustomDrawable);
|
||||
return sb.append(']');
|
||||
}
|
||||
|
||||
public State copy() {
|
||||
State state = new State();
|
||||
copyTo(state);
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Distinguished from [BooleanState] for use-case purposes such as allowing null secondary label
|
||||
*/
|
||||
@ProvidesInterface(version = AdapterState.VERSION)
|
||||
class AdapterState extends State {
|
||||
public static final int VERSION = 1;
|
||||
public boolean value;
|
||||
public boolean forceExpandIcon;
|
||||
|
||||
@Override
|
||||
public boolean copyTo(State other) {
|
||||
final AdapterState o = (AdapterState) other;
|
||||
final boolean changed = super.copyTo(other)
|
||||
|| o.value != value
|
||||
|| o.forceExpandIcon != forceExpandIcon;
|
||||
o.value = value;
|
||||
o.forceExpandIcon = forceExpandIcon;
|
||||
return changed;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected StringBuilder toStringBuilder() {
|
||||
final StringBuilder rt = super.toStringBuilder();
|
||||
rt.insert(rt.length() - 1, ",value=" + value);
|
||||
rt.insert(rt.length() - 1, ",forceExpandIcon=" + forceExpandIcon);
|
||||
return rt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public State copy() {
|
||||
AdapterState state = new AdapterState();
|
||||
copyTo(state);
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
@ProvidesInterface(version = BooleanState.VERSION)
|
||||
class BooleanState extends AdapterState {
|
||||
public static final int VERSION = 1;
|
||||
|
||||
@Override
|
||||
public State copy() {
|
||||
BooleanState state = new BooleanState();
|
||||
copyTo(state);
|
||||
return state;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright (C) 2017 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the
|
||||
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.systemui.plugins.qs;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.view.ViewConfiguration;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import com.android.systemui.plugins.annotations.DependsOn;
|
||||
import com.android.systemui.plugins.annotations.ProvidesInterface;
|
||||
import com.android.systemui.plugins.qs.QSTile.State;
|
||||
|
||||
@ProvidesInterface(version = QSTileView.VERSION)
|
||||
@DependsOn(target = QSIconView.class)
|
||||
@DependsOn(target = QSTile.class)
|
||||
public abstract class QSTileView extends LinearLayout {
|
||||
public static final int VERSION = 3;
|
||||
|
||||
public QSTileView(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public abstract View updateAccessibilityOrder(View previousView);
|
||||
|
||||
/**
|
||||
* Returns a {@link QSIconView} containing only the icon for this tile. Use
|
||||
* {@link #getIconWithBackground()} to retrieve the entire tile (background & peripherals
|
||||
* included).
|
||||
*/
|
||||
public abstract QSIconView getIcon();
|
||||
|
||||
/**
|
||||
* Returns a {@link View} containing the icon for this tile along with the accompanying
|
||||
* background circle/peripherals. To retrieve only the inner icon, use {@link #getIcon()}.
|
||||
*/
|
||||
public abstract View getIconWithBackground();
|
||||
|
||||
/**
|
||||
* Returns the {@link View} containing the icon on the right
|
||||
*
|
||||
* @see com.android.systemui.qs.tileimpl.QSTileViewHorizontal#sideView
|
||||
*/
|
||||
public View getSecondaryIcon() {
|
||||
return null;
|
||||
}
|
||||
public abstract void init(QSTile tile);
|
||||
public abstract void onStateChanged(State state);
|
||||
|
||||
public abstract int getDetailY();
|
||||
|
||||
public View getLabel() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public View getLabelContainer() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public View getSecondaryLabel() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Sets the index of this tile in its layout */
|
||||
public abstract void setPosition(int position);
|
||||
|
||||
/** Get the duration of a visuo-haptic long-press effect */
|
||||
public int getLongPressEffectDuration() {
|
||||
return ViewConfiguration.getLongPressTimeout() - ViewConfiguration.getTapTimeout();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.systemui.plugins.statusbar;
|
||||
|
||||
import com.android.systemui.plugins.annotations.ProvidesInterface;
|
||||
|
||||
/**
|
||||
* Retrieve doze information
|
||||
*/
|
||||
@ProvidesInterface(version = DozeParameters.VERSION)
|
||||
public interface DozeParameters {
|
||||
int VERSION = 1;
|
||||
|
||||
/**
|
||||
* Whether to doze when the screen turns off
|
||||
*/
|
||||
boolean shouldControlScreenOff();
|
||||
}
|
||||
+255
@@ -0,0 +1,255 @@
|
||||
/*
|
||||
* Copyright (C) 2017 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the
|
||||
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.systemui.plugins.statusbar;
|
||||
|
||||
import android.annotation.Nullable;
|
||||
import android.content.Context;
|
||||
import android.graphics.Point;
|
||||
import android.service.notification.StatusBarNotification;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.android.systemui.plugins.Plugin;
|
||||
import com.android.systemui.plugins.annotations.DependsOn;
|
||||
import com.android.systemui.plugins.annotations.ProvidesInterface;
|
||||
import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin.MenuItem;
|
||||
import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin.OnMenuEventListener;
|
||||
import com.android.systemui.plugins.statusbar.NotificationSwipeActionHelper.SnoozeOption;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@ProvidesInterface(action = NotificationMenuRowPlugin.ACTION,
|
||||
version = NotificationMenuRowPlugin.VERSION)
|
||||
@DependsOn(target = OnMenuEventListener.class)
|
||||
@DependsOn(target = MenuItem.class)
|
||||
@DependsOn(target = NotificationSwipeActionHelper.class)
|
||||
@DependsOn(target = SnoozeOption.class)
|
||||
public interface NotificationMenuRowPlugin extends Plugin {
|
||||
|
||||
public static final String ACTION = "com.android.systemui.action.PLUGIN_NOTIFICATION_MENU_ROW";
|
||||
public static final int VERSION = 5;
|
||||
|
||||
@ProvidesInterface(version = OnMenuEventListener.VERSION)
|
||||
public interface OnMenuEventListener {
|
||||
public static final int VERSION = 1;
|
||||
|
||||
public void onMenuClicked(View row, int x, int y, MenuItem menu);
|
||||
|
||||
public void onMenuReset(View row);
|
||||
|
||||
public void onMenuShown(View row);
|
||||
}
|
||||
|
||||
@ProvidesInterface(version = MenuItem.VERSION)
|
||||
public interface MenuItem {
|
||||
public static final int VERSION = 1;
|
||||
|
||||
public View getMenuView();
|
||||
|
||||
public View getGutsView();
|
||||
|
||||
public String getContentDescription();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a list of items to populate the menu 'behind' a notification.
|
||||
*/
|
||||
public ArrayList<MenuItem> getMenuItems(Context context);
|
||||
|
||||
/**
|
||||
* @return the {@link MenuItem} to display when a notification is long pressed.
|
||||
*/
|
||||
public MenuItem getLongpressMenuItem(Context context);
|
||||
|
||||
/**
|
||||
* @return the {@link MenuItem} to display when feedback icon is pressed.
|
||||
*/
|
||||
public MenuItem getFeedbackMenuItem(Context context);
|
||||
|
||||
/**
|
||||
* @return the {@link MenuItem} to display when snooze item is pressed.
|
||||
*/
|
||||
public MenuItem getSnoozeMenuItem(Context context);
|
||||
|
||||
public void setMenuItems(ArrayList<MenuItem> items);
|
||||
|
||||
/**
|
||||
* If this returns {@code true}, then the menu row will bind and fade in the notification guts
|
||||
* view for the menu item it holds.
|
||||
*
|
||||
* @see #menuItemToExposeOnSnap()
|
||||
* @return whether or not to immediately expose the notification guts
|
||||
*/
|
||||
default boolean shouldShowGutsOnSnapOpen() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* When #shouldShowGutsOnExpose is true, this method must return the menu item to expose on
|
||||
* #onSnapOpen. Otherwise we will fall back to the default behavior of fading in the menu row
|
||||
*
|
||||
* @return the {@link MenuItem} containing the NotificationGuts that should be exposed
|
||||
*/
|
||||
@Nullable
|
||||
default MenuItem menuItemToExposeOnSnap() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the origin for the circular reveal animation when expanding the notification guts. Only
|
||||
* used when #shouldShowGutsOnSnapOpen is true
|
||||
* @return the x,y coordinates for the start of the animation
|
||||
*/
|
||||
@Nullable
|
||||
default Point getRevealAnimationOrigin() {
|
||||
return new Point(0, 0);
|
||||
}
|
||||
|
||||
public void setMenuClickListener(OnMenuEventListener listener);
|
||||
|
||||
public void setAppName(String appName);
|
||||
|
||||
public void createMenu(ViewGroup parent, StatusBarNotification sbn);
|
||||
|
||||
public void resetMenu();
|
||||
|
||||
public View getMenuView();
|
||||
|
||||
/**
|
||||
* Get the target position that a notification row should be snapped open to in order to reveal
|
||||
* the menu. This is generally determined by the number of icons in the notification menu and the
|
||||
* size of each icon. This method accounts for whether the menu appears on the left or ride side
|
||||
* of the parent notification row.
|
||||
*
|
||||
|
||||
* @return an int representing the x-offset in pixels that the notification should snap open to.
|
||||
* Positive values imply that the notification should be offset to the right to reveal the menu,
|
||||
* and negative alues imply that the notification should be offset to the right.
|
||||
*/
|
||||
public int getMenuSnapTarget();
|
||||
|
||||
/**
|
||||
* Determines whether or not the menu should be shown in response to user input.
|
||||
* @return true if the menu should be shown, false otherwise.
|
||||
*/
|
||||
public boolean shouldShowMenu();
|
||||
|
||||
/**
|
||||
* Determines whether the menu is currently visible.
|
||||
* @return true if the menu is visible, false otherwise.
|
||||
*/
|
||||
public boolean isMenuVisible();
|
||||
|
||||
/**
|
||||
* Determines whether a given movement is towards or away from the current location of the menu.
|
||||
* @param movement
|
||||
* @return true if the movement is towards the menu, false otherwise.
|
||||
*/
|
||||
public boolean isTowardsMenu(float movement);
|
||||
|
||||
/**
|
||||
* Determines whether the menu should snap closed instead of dismissing the
|
||||
* parent notification, as a function of its current state.
|
||||
*
|
||||
* @return true if the menu should snap closed, false otherwise.
|
||||
*/
|
||||
public boolean shouldSnapBack();
|
||||
|
||||
/**
|
||||
* Determines whether the menu was previously snapped open to the same side that it is currently
|
||||
* being shown on.
|
||||
* @return true if the menu is snapped open to the same side on which it currently appears,
|
||||
* false otherwise.
|
||||
*/
|
||||
public boolean isSnappedAndOnSameSide();
|
||||
|
||||
/**
|
||||
* Determines whether the notification the menu is attached to is able to be dismissed.
|
||||
* @return true if the menu's parent notification is dismissable, false otherwise.
|
||||
*/
|
||||
public boolean canBeDismissed();
|
||||
|
||||
/**
|
||||
* Determines whether the menu should remain open given its current state, or snap closed.
|
||||
* @return true if the menu should remain open, false otherwise.
|
||||
*/
|
||||
public boolean isWithinSnapMenuThreshold();
|
||||
|
||||
/**
|
||||
* Determines whether the menu has been swiped far enough to snap open.
|
||||
* @return true if the menu has been swiped far enough to open, false otherwise.
|
||||
*/
|
||||
public boolean isSwipedEnoughToShowMenu();
|
||||
|
||||
public default boolean onInterceptTouchEvent(View view, MotionEvent ev) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public default boolean shouldUseDefaultMenuItems() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback used to signal the menu that its parent's translation has changed.
|
||||
* @param translation The new x-translation of the menu as a position (not an offset).
|
||||
*/
|
||||
public void onParentTranslationUpdate(float translation);
|
||||
|
||||
/**
|
||||
* Callback used to signal the menu that its parent's height has changed.
|
||||
*/
|
||||
public void onParentHeightUpdate();
|
||||
|
||||
/**
|
||||
* Callback used to signal the menu that its parent notification has been updated.
|
||||
* @param sbn
|
||||
*/
|
||||
public void onNotificationUpdated(StatusBarNotification sbn);
|
||||
|
||||
/**
|
||||
* Callback used to signal the menu that a user is moving the parent notification.
|
||||
* @param delta The change in the parent notification's position.
|
||||
*/
|
||||
public void onTouchMove(float delta);
|
||||
|
||||
/**
|
||||
* Callback used to signal the menu that a user has begun touching its parent notification.
|
||||
*/
|
||||
public void onTouchStart();
|
||||
|
||||
/**
|
||||
* Callback used to signal the menu that a user has finished touching its parent notification.
|
||||
*/
|
||||
public void onTouchEnd();
|
||||
|
||||
/**
|
||||
* Callback used to signal the menu that it has been snapped closed.
|
||||
*/
|
||||
public void onSnapClosed();
|
||||
|
||||
/**
|
||||
* Callback used to signal the menu that it has been snapped open.
|
||||
*/
|
||||
public void onSnapOpen();
|
||||
|
||||
/**
|
||||
* Callback used to signal the menu that its parent notification has been dismissed.
|
||||
*/
|
||||
public void onDismiss();
|
||||
|
||||
public default void onConfigurationChanged() { }
|
||||
|
||||
}
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright (C) 2017 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the
|
||||
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.systemui.plugins.statusbar;
|
||||
|
||||
import android.service.notification.SnoozeCriterion;
|
||||
import android.service.notification.StatusBarNotification;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction;
|
||||
|
||||
import com.android.systemui.plugins.annotations.DependsOn;
|
||||
import com.android.systemui.plugins.annotations.ProvidesInterface;
|
||||
import com.android.systemui.plugins.statusbar.NotificationSwipeActionHelper.SnoozeOption;
|
||||
|
||||
@ProvidesInterface(version = NotificationSwipeActionHelper.VERSION)
|
||||
@DependsOn(target = SnoozeOption.class)
|
||||
public interface NotificationSwipeActionHelper {
|
||||
public static final String ACTION = "com.android.systemui.action.PLUGIN_NOTIFICATION_SWIPE_ACTION";
|
||||
|
||||
public static final int VERSION = 1;
|
||||
|
||||
/**
|
||||
* Call this to dismiss a notification.
|
||||
*/
|
||||
public void dismiss(View animView, float velocity);
|
||||
|
||||
/**
|
||||
* Call this to snap a notification to provided {@code targetLeft}.
|
||||
*/
|
||||
public void snapOpen(View animView, int targetLeft, float velocity);
|
||||
|
||||
/**
|
||||
* Call this to snooze a notification based on the provided {@link SnoozeOption}.
|
||||
*/
|
||||
public void snooze(StatusBarNotification sbn, SnoozeOption snoozeOption);
|
||||
|
||||
public float getMinDismissVelocity();
|
||||
|
||||
public boolean isDismissGesture(MotionEvent ev);
|
||||
|
||||
/** Returns true if the gesture should be rejected. */
|
||||
boolean isFalseGesture();
|
||||
|
||||
@ProvidesInterface(version = SnoozeOption.VERSION)
|
||||
public interface SnoozeOption {
|
||||
public static final int VERSION = 2;
|
||||
|
||||
public SnoozeCriterion getSnoozeCriterion();
|
||||
|
||||
public CharSequence getDescription();
|
||||
|
||||
public CharSequence getConfirmation();
|
||||
|
||||
public int getMinutesToSnoozeFor();
|
||||
|
||||
public AccessibilityAction getAccessibilityAction();
|
||||
}
|
||||
}
|
||||
+135
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.systemui.plugins.statusbar;
|
||||
|
||||
import com.android.systemui.plugins.annotations.DependsOn;
|
||||
import com.android.systemui.plugins.annotations.ProvidesInterface;
|
||||
|
||||
/**
|
||||
* Sends updates to {@link StateListener}s about changes to the status bar state and dozing state
|
||||
*/
|
||||
@ProvidesInterface(version = StatusBarStateController.VERSION)
|
||||
@DependsOn(target = StatusBarStateController.StateListener.class)
|
||||
public interface StatusBarStateController {
|
||||
int VERSION = 1;
|
||||
|
||||
/**
|
||||
* Current status bar state
|
||||
*/
|
||||
int getState();
|
||||
|
||||
/**
|
||||
* Is device dozing. Dozing is when the screen is in AOD or asleep given that
|
||||
* {@link com.android.systemui.doze.DozeService} is configured.
|
||||
*/
|
||||
boolean isDozing();
|
||||
|
||||
/**
|
||||
* Is the status bar panel expanded.
|
||||
*/
|
||||
boolean isExpanded();
|
||||
|
||||
/**
|
||||
* Is device pulsing.
|
||||
*/
|
||||
boolean isPulsing();
|
||||
|
||||
/**
|
||||
* Is device dreaming. This method is more inclusive than
|
||||
* {@link android.service.dreams.IDreamManager.isDreaming}, as it will return true during the
|
||||
* dream's wake-up phase.
|
||||
*/
|
||||
boolean isDreaming();
|
||||
|
||||
/**
|
||||
* Adds a state listener
|
||||
*/
|
||||
void addCallback(StateListener listener);
|
||||
|
||||
/**
|
||||
* Removes callback from listeners
|
||||
*/
|
||||
void removeCallback(StateListener listener);
|
||||
|
||||
/**
|
||||
* Get amount of doze
|
||||
*/
|
||||
float getDozeAmount();
|
||||
|
||||
/**
|
||||
* Listener for StatusBarState updates
|
||||
*/
|
||||
@ProvidesInterface(version = StateListener.VERSION)
|
||||
public interface StateListener {
|
||||
int VERSION = 1;
|
||||
|
||||
/**
|
||||
* Callback before the new state is applied, for those who need to preempt the change.
|
||||
*/
|
||||
default void onStatePreChange(int oldState, int newState) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback after all listeners have had a chance to update based on the state change
|
||||
*/
|
||||
default void onStatePostChange() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Required callback. Get the new state and do what you will with it. Keep in mind that
|
||||
* other listeners are typically unordered and don't rely on your work being done before
|
||||
* other peers.
|
||||
*
|
||||
* Only called if the state is actually different.
|
||||
*/
|
||||
default void onStateChanged(int newState) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to be notified about upcoming state changes. Typically, is immediately followed
|
||||
* by #onStateChanged, unless there was an intentional delay in updating the state changed.
|
||||
*/
|
||||
default void onUpcomingStateChanged(int upcomingState) {}
|
||||
|
||||
/**
|
||||
* Callback to be notified when Dozing changes. Dozing is stored separately from state.
|
||||
*/
|
||||
default void onDozingChanged(boolean isDozing) {}
|
||||
|
||||
/**
|
||||
* Callback to be notified when Dreaming changes. Dreaming is stored separately from state.
|
||||
*/
|
||||
default void onDreamingChanged(boolean isDreaming) {}
|
||||
|
||||
/**
|
||||
* Callback to be notified when the doze amount changes. Useful for animations.
|
||||
* Note: this will be called for each animation frame. Please be careful to avoid
|
||||
* performance regressions.
|
||||
*/
|
||||
default void onDozeAmountChanged(float linear, float eased) {}
|
||||
|
||||
/**
|
||||
* Callback to be notified when the pulsing state changes
|
||||
*/
|
||||
default void onPulsingChanged(boolean pulsing) {}
|
||||
|
||||
/**
|
||||
* Callback to be notified when the expanded state of the status bar changes
|
||||
*/
|
||||
default void onExpandedChanged(boolean isExpanded) {}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user