import android.util.Log;
import java.util.ArrayList;
+import java.util.Objects;
/**
* Container of data passed to the {@link android.app.job.JobScheduler} fully encapsulating the
return mFlags;
}
+ @Override
+ public boolean equals(Object o) {
+ if (!(o instanceof TriggerContentUri)) {
+ return false;
+ }
+ TriggerContentUri t = (TriggerContentUri) o;
+ return Objects.equals(t.mUri, mUri) && t.mFlags == mFlags;
+ }
+
+ @Override
+ public int hashCode() {
+ return (mUri == null ? 0 : mUri.hashCode()) ^ mFlags;
+ }
+
private TriggerContentUri(Parcel in) {
mUri = Uri.CREATOR.createFromParcel(in);
mFlags = in.readInt();
* @hide
*/
interface IQSService {
+ Tile getTile(in ComponentName component);
void updateQsTile(in Tile tile);
void updateStatusIcon(in Tile tile, in Icon icon,
String contentDescription);
/**
* @hide
*/
- public static final String EXTRA_TILE = "tile";
-
- /**
- * @hide
- */
public static final String EXTRA_COMPONENT = "android.service.quicksettings.extra.COMPONENT";
private final H mHandler = new H(Looper.getMainLooper());
@Override
public IBinder onBind(Intent intent) {
- mTile = intent.getParcelableExtra(EXTRA_TILE);
mService = IQSService.Stub.asInterface(intent.getIBinderExtra(EXTRA_SERVICE));
- mTile.setService(mService);
+ try {
+ mTile = mService.getTile(new ComponentName(getPackageName(), getClass().getName()));
+ } catch (RemoteException e) {
+ throw new RuntimeException("Unable to reach IQSService", e);
+ }
+ if (mTile != null) {
+ mTile.setService(mService);
+ mHandler.sendEmptyMessage(H.MSG_START_SUCCESS);
+ }
return new IQSTileService.Stub() {
@Override
public void onTileRemoved() throws RemoteException {
private static final int MSG_TILE_REMOVED = 4;
private static final int MSG_TILE_CLICKED = 5;
private static final int MSG_UNLOCK_COMPLETE = 6;
+ private static final int MSG_START_SUCCESS = 7;
public H(Looper looper) {
super(looper);
mUnlockRunnable.run();
}
break;
+ case MSG_START_SUCCESS:
+ try {
+ mService.onStartSuccessful(mTile);
+ } catch (RemoteException e) {
+ }
+ break;
}
}
}
<string name="font_roboto_regular" translatable="false">sans-serif</string>
<!-- DO NOT TRANSLATE -->
<string name="font_roboto_light" translatable="false">sans-serif-light</string>
+ <!-- Package names to be blacklisted in Recents, add package names into overlay as needed -->
+ <string-array name="recents_tv_blacklist_array">
+ </string-array>
+
</resources>
setVisibility(View.GONE);
}
mNotifQsContainer.setCustomizerAnimating(false);
+ mRecyclerView.setAdapter(mTileAdapter);
}
@Override
}
public void setTileSpecs(List<String> currentSpecs) {
+ if (currentSpecs.equals(mCurrentSpecs)) {
+ return;
+ }
mCurrentSpecs = currentSpecs;
recalcSpecs();
}
}
holder.mTileView.onStateChanged(info.state);
holder.mTileView.setAppLabel(info.appLabel);
- holder.mTileView.setShowAppLabel(mTileDividerIndex > -1 && position > mTileDividerIndex);
+ holder.mTileView.setShowAppLabel(position > mEditIndex && !info.isSystem);
if (mAccessibilityManager.isTouchExplorationEnabled()) {
final boolean selectable = !mAccessibilityMoving || position < mEditIndex;
mTiles.remove(mEditIndex--);
notifyItemRemoved(mEditIndex - 1);
move(mAccessibilityFromIndex, position, v);
- updateDividerLocations();
notifyDataSetChanged();
- saveSpecs(mHost);
}
private void showAccessibilityDialog(final int position, final View v) {
- TileInfo info = mTiles.get(position);
+ final TileInfo info = mTiles.get(position);
CharSequence[] options = new CharSequence[] {
mContext.getString(R.string.accessibility_qs_edit_move_tile, info.state.label),
mContext.getString(R.string.accessibility_qs_edit_remove_tile, info.state.label),
if (which == 0) {
startAccessibleDrag(position);
} else {
- move(position, mEditIndex, v);
+ move(position, info.isSystem ? mEditIndex : mTileDividerIndex, v);
+ notifyItemChanged(mTileDividerIndex);
+ notifyDataSetChanged();
}
}
}).setNegativeButton(android.R.string.cancel, null)
}
private boolean move(int from, int to, View v) {
- if (to >= mEditIndex) {
- if (from < mEditIndex) {
- // Removing a tile.
- // Sort tiles into system/non-system groups.
- TileInfo tile = mTiles.get(from);
- if (tile.isSystem) {
- if (to > mTileDividerIndex) {
- to = mTileDividerIndex;
- }
- } else {
- if (mTileDividerIndex == mTiles.size() - 1) {
- notifyItemChanged(mTileDividerIndex);
- }
- if (to <= mTileDividerIndex) {
- to = mTileDividerIndex;
- }
- }
- } else {
- if (to > mEditIndex) {
- // Don't allow tiles to be dragged around when they aren't added.
- to = from;
- }
- // Allow the case where to == mEditIndex to fall through and swap which
- // side the tile is currently on.
- // This lets the the cases where all tiles are on one side of the line
- // work.
- }
+ if (to == from) {
+ return true;
}
CharSequence fromLabel = mTiles.get(from).state.label;
move(from, to, mTiles);
updateDividerLocations();
- if (to == from) {
- return true;
- }
CharSequence announcement;
if (to >= mEditIndex) {
MetricsLogger.action(mContext, MetricsProto.MetricsEvent.ACTION_QS_EDIT_REMOVE_SPEC,
private <T> void move(int from, int to, List<T> list) {
list.add(to, list.remove(from));
notifyItemMoved(from, to);
- notifyItemChanged(to);
}
public class Holder extends ViewHolder {
for (int i = 0; i < childCount; i++) {
final View child = parent.getChildAt(i);
final ViewHolder holder = parent.getChildViewHolder(child);
- if (holder.getAdapterPosition() < mEditIndex) {
+ if (holder.getAdapterPosition() < mEditIndex && !(child instanceof TextView)) {
continue;
}
@Override
public void onSelectedChanged(ViewHolder viewHolder, int actionState) {
super.onSelectedChanged(viewHolder, actionState);
+ if (actionState != ItemTouchHelper.ACTION_STATE_DRAG) {
+ viewHolder = null;
+ }
+ if (viewHolder == mCurrentDrag) return;
if (mCurrentDrag != null) {
+ int position = mCurrentDrag.getAdapterPosition();
+ TileInfo info = mTiles.get(position);
+ mCurrentDrag.mTileView.setShowAppLabel(
+ position > mEditIndex && !info.isSystem);
mCurrentDrag.stopDrag();
mCurrentDrag = null;
}
}
@Override
+ public boolean canDropOver(RecyclerView recyclerView, ViewHolder current,
+ ViewHolder target) {
+ return target.getAdapterPosition() <= mEditIndex + 1;
+ }
+
+ @Override
public int getMovementFlags(RecyclerView recyclerView, ViewHolder viewHolder) {
if (viewHolder.getItemViewType() == TYPE_EDIT) {
return makeMovementFlags(0, 0);
addTile(spec, appLabel, state, false);
continue;
}
- if (info.serviceInfo.icon == 0) {
+ if (info.serviceInfo.icon == 0 && info.serviceInfo.applicationInfo.icon == 0) {
continue;
}
Drawable icon = info.serviceInfo.loadIcon(pm);
PackageManager pm = mContext.getPackageManager();
ServiceInfo info = pm.getServiceInfo(mComponent,
PackageManager.MATCH_ENCRYPTION_AWARE_AND_UNAWARE);
+ int icon = info.icon != 0 ? info.icon
+ : info.applicationInfo.icon;
// Update the icon if its not set or is the default icon.
boolean updateIcon = mTile.getIcon() == null
|| iconEquals(mTile.getIcon(), mDefaultIcon);
- mDefaultIcon = info.icon != 0 ? android.graphics.drawable.Icon
- .createWithResource(mComponent.getPackageName(), info.icon) : null;
+ mDefaultIcon = icon != 0 ? android.graphics.drawable.Icon
+ .createWithResource(mComponent.getPackageName(), icon) : null;
if (updateIcon) {
mTile.setIcon(mDefaultIcon);
}
mHandler = handler;
mIntent = intent;
mIntent.putExtra(TileService.EXTRA_SERVICE, service.asBinder());
- mIntent.putExtra(TileService.EXTRA_TILE, tile);
mUser = user;
if (DEBUG) Log.d(TAG, "Creating " + mIntent + " " + mUser);
}
}
@Override
+ public Tile getTile(ComponentName componentName) {
+ verifyCaller(componentName.getPackageName());
+ CustomTile customTile = getTileForComponent(componentName);
+ if (customTile != null) {
+ return customTile.getQsTile();
+ }
+ return null;
+ }
+
+ @Override
public void startUnlockAndRun(Tile tile) {
ComponentName componentName = tile.getComponentName();
verifyCaller(componentName.getPackageName());
import android.app.AppGlobals;
import android.app.IActivityManager;
import android.app.ITaskStackListener;
+import android.app.UiModeManager;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
import android.content.pm.IPackageManager;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
+import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
mDummyIcon = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888);
mDummyIcon.eraseColor(0xFF999999);
}
+
+ UiModeManager uiModeManager = (UiModeManager) context.
+ getSystemService(Context.UI_MODE_SERVICE);
+ if (uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION) {
+ Collections.addAll(sRecentsBlacklist,
+ res.getStringArray(R.array.recents_tv_blacklist_array));
+ }
}
/**
package com.android.systemui.statusbar.policy;
+import android.app.ActivityManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.ConnectivityManager;
import android.net.wifi.WifiManager;
+import android.os.UserManager;
import android.util.Log;
import java.io.FileDescriptor;
@Override
public boolean isHotspotSupported() {
return mConnectivityManager.isTetheringSupported()
- && mConnectivityManager.getTetherableWifiRegexs().length != 0;
+ && mConnectivityManager.getTetherableWifiRegexs().length != 0
+ && UserManager.get(mContext).isUserAdmin(ActivityManager.getCurrentUser());
}
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
float newYTranslation = state.yTranslation;
float newHeight = state.height;
float newNotificationEnd = newYTranslation + newHeight;
-
- if (newYTranslation < previousNotificationEnd) {
+ boolean isHeadsUp = (child instanceof ExpandableNotificationRow)
+ && ((ExpandableNotificationRow) child).isPinned();
+ if (newYTranslation < previousNotificationEnd && ambientState.isShadeExpanded()
+ && !isHeadsUp) {
// The previous view is overlapping on top, clip!
float overlapAmount = previousNotificationEnd - newYTranslation;
state.clipTopAmount = (int) overlapAmount;
/** Checks whether the activity should be shown for current user. */
boolean okToShowLocked(ActivityRecord r) {
- return r != null && (isCurrentProfileLocked(r.userId)
- || (r.info.flags & FLAG_SHOW_FOR_ALL_USERS) != 0);
+ return r != null && ((r.info.flags & FLAG_SHOW_FOR_ALL_USERS) != 0
+ || (isCurrentProfileLocked(r.userId)
+ && !mService.mUserController.isUserStoppingOrShuttingDownLocked(r.userId)));
}
final ArrayList<ActivityRecord> processStoppingActivitiesLocked(boolean remove) {
return mStartedUserArray;
}
+ boolean isUserStoppingOrShuttingDownLocked(int userId) {
+ UserState state = getStartedUserStateLocked(userId);
+ if (state == null) {
+ return false;
+ }
+ return state.state == UserState.STATE_STOPPING
+ || state.state == UserState.STATE_SHUTDOWN;
+ }
+
boolean isUserRunningLocked(int userId, int flags) {
UserState state = getStartedUserStateLocked(userId);
if (state == null) {
private static volatile ContentObserverController sController;
final private List<JobStatus> mTrackedTasks = new ArrayList<JobStatus>();
- ArrayMap<Uri, ObserverInstance> mObservers = new ArrayMap<>();
+ ArrayMap<JobInfo.TriggerContentUri, ObserverInstance> mObservers = new ArrayMap<>();
final Handler mHandler;
public static ContentObserverController get(JobSchedulerService taskManagerService) {
final JobInfo.TriggerContentUri[] uris = jobStatus.getJob().getTriggerContentUris();
if (uris != null) {
for (JobInfo.TriggerContentUri uri : uris) {
- ObserverInstance obs = mObservers.get(uri.getUri());
+ ObserverInstance obs = mObservers.get(uri);
if (obs == null) {
obs = new ObserverInstance(mHandler, uri.getUri());
- mObservers.put(uri.getUri(), obs);
+ mObservers.put(uri, obs);
mContext.getContentResolver().registerContentObserver(
uri.getUri(),
(uri.getFlags() &
obs.mJobs.remove(this);
if (obs.mJobs.size() == 0) {
mContext.getContentResolver().unregisterContentObserver(obs);
- mObservers.remove(obs.mUri);
+ mObservers.remove(obs);
}
}
}
continue;
}
pw.print(" ");
- pw.print(mObservers.keyAt(i));
+ JobInfo.TriggerContentUri trigger = mObservers.keyAt(i);
+ pw.print(trigger.getUri());
+ pw.print(" 0x");
+ pw.print(Integer.toHexString(trigger.getFlags()));
pw.print(" (");
pw.print(System.identityHashCode(obs));
pw.println("):");
@Override
public void onUserSwitched(int user) {
synchronized (mNotificationList) {
- for (ManagedServiceInfo info : mServices) {
+ int i = mServices.size()-1;
+ while (i --> 0) {
+ final ManagedServiceInfo info = mServices.get(i);
unregisterService(info.service, info.userid);
}
}
long identity = Binder.clearCallingIdentity();
try {
if (enableQuietMode) {
+ ActivityManagerNative.getDefault().stopUser(userHandle, /* force */true, null);
LocalServices.getService(ActivityManagerInternal.class)
.killForegroundAppsForUser(userHandle);
- ActivityManagerNative.getDefault().stopUser(userHandle, /* force */true, null);
} else {
ActivityManagerNative.getDefault().startUserInBackground(userHandle);
}