Loading core/java/android/app/ActivityView.java +112 −60 Original line number Original line Diff line number Diff line Loading @@ -24,8 +24,6 @@ import android.content.IIntentSender; import android.content.Intent; import android.content.Intent; import android.content.IntentSender; import android.content.IntentSender; import android.graphics.SurfaceTexture; import android.graphics.SurfaceTexture; import android.os.Handler; import android.os.HandlerThread; import android.os.IBinder; import android.os.IBinder; import android.os.Message; import android.os.Message; import android.os.OperationCanceledException; import android.os.OperationCanceledException; Loading @@ -45,6 +43,17 @@ import android.view.WindowManager; import dalvik.system.CloseGuard; import dalvik.system.CloseGuard; import java.lang.ref.WeakReference; import java.lang.ref.WeakReference; import java.util.ArrayDeque; import java.util.concurrent.Executor; import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ThreadFactory; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; import com.android.internal.annotations.GuardedBy; /** @hide */ /** @hide */ public class ActivityView extends ViewGroup { public class ActivityView extends ViewGroup { Loading @@ -53,9 +62,64 @@ public class ActivityView extends ViewGroup { private static final int MSG_SET_SURFACE = 1; private static final int MSG_SET_SURFACE = 1; DisplayMetrics mMetrics = new DisplayMetrics(); private static final int CPU_COUNT = Runtime.getRuntime().availableProcessors(); private static final int MINIMUM_POOL_SIZE = 1; private static final int MAXIMUM_POOL_SIZE = CPU_COUNT * 2 + 1; private static final int KEEP_ALIVE = 1; private static final ThreadFactory sThreadFactory = new ThreadFactory() { private final AtomicInteger mCount = new AtomicInteger(1); public Thread newThread(Runnable r) { return new Thread(r, "ActivityView #" + mCount.getAndIncrement()); } }; private static final BlockingQueue<Runnable> sPoolWorkQueue = new LinkedBlockingQueue<Runnable>(128); /** * An {@link Executor} that can be used to execute tasks in parallel. */ private static final Executor sExecutor = new ThreadPoolExecutor(MINIMUM_POOL_SIZE, MAXIMUM_POOL_SIZE, KEEP_ALIVE, TimeUnit.SECONDS, sPoolWorkQueue, sThreadFactory); private static class SerialExecutor implements Executor { private final ArrayDeque<Runnable> mTasks = new ArrayDeque<Runnable>(); private Runnable mActive; public synchronized void execute(final Runnable r) { mTasks.offer(new Runnable() { public void run() { try { r.run(); } finally { scheduleNext(); } } }); if (mActive == null) { scheduleNext(); } } protected synchronized void scheduleNext() { if ((mActive = mTasks.poll()) != null) { sExecutor.execute(mActive); } } } private final SerialExecutor mExecutor = new SerialExecutor(); private final int mDensityDpi; private final TextureView mTextureView; private final TextureView mTextureView; @GuardedBy("mActivityContainerLock") private ActivityContainerWrapper mActivityContainer; private ActivityContainerWrapper mActivityContainer; private Object mActivityContainerLock = new Object(); private Activity mActivity; private Activity mActivity; private int mWidth; private int mWidth; private int mHeight; private int mHeight; Loading @@ -63,8 +127,6 @@ public class ActivityView extends ViewGroup { private int mLastVisibility; private int mLastVisibility; private ActivityViewCallback mActivityViewCallback; private ActivityViewCallback mActivityViewCallback; private HandlerThread mThread = new HandlerThread("ActivityViewThread"); private Handler mHandler; public ActivityView(Context context) { public ActivityView(Context context) { this(context, null); this(context, null); Loading Loading @@ -97,28 +159,14 @@ public class ActivityView extends ViewGroup { + e); + e); } } mThread.start(); mHandler = new Handler(mThread.getLooper()) { @Override public void handleMessage(Message msg) { super.handleMessage(msg); if (msg.what == MSG_SET_SURFACE) { try { mActivityContainer.setSurface((Surface) msg.obj, msg.arg1, msg.arg2, mMetrics.densityDpi); } catch (RemoteException e) { throw new RuntimeException( "ActivityView: Unable to set surface of ActivityContainer. " + e); } } } }; mTextureView = new TextureView(context); mTextureView = new TextureView(context); mTextureView.setSurfaceTextureListener(new ActivityViewSurfaceTextureListener()); mTextureView.setSurfaceTextureListener(new ActivityViewSurfaceTextureListener()); addView(mTextureView); addView(mTextureView); WindowManager wm = (WindowManager)mActivity.getSystemService(Context.WINDOW_SERVICE); WindowManager wm = (WindowManager)mActivity.getSystemService(Context.WINDOW_SERVICE); wm.getDefaultDisplay().getMetrics(mMetrics); DisplayMetrics metrics = new DisplayMetrics(); wm.getDefaultDisplay().getMetrics(metrics); mDensityDpi = metrics.densityDpi; mLastVisibility = getVisibility(); mLastVisibility = getVisibility(); Loading @@ -131,15 +179,13 @@ public class ActivityView extends ViewGroup { } } @Override @Override protected void onVisibilityChanged(View changedView, int visibility) { protected void onVisibilityChanged(View changedView, final int visibility) { super.onVisibilityChanged(changedView, visibility); super.onVisibilityChanged(changedView, visibility); if (mSurface != null && (visibility == View.GONE || mLastVisibility == View.GONE)) { if (mSurface != null && (visibility == View.GONE || mLastVisibility == View.GONE)) { Message msg = Message.obtain(mHandler, MSG_SET_SURFACE); if (DEBUG) Log.v(TAG, "visibility changed; enqueing runnable"); msg.obj = (visibility == View.GONE) ? null : mSurface; final Surface surface = (visibility == View.GONE) ? null : mSurface; msg.arg1 = mWidth; setSurfaceAsync(surface, mWidth, mHeight, mDensityDpi, false); msg.arg2 = mHeight; mHandler.sendMessage(msg); } } mLastVisibility = visibility; mLastVisibility = visibility; } } Loading Loading @@ -230,8 +276,10 @@ public class ActivityView extends ViewGroup { Log.e(TAG, "Duplicate call to release"); Log.e(TAG, "Duplicate call to release"); return; return; } } synchronized (mActivityContainerLock) { mActivityContainer.release(); mActivityContainer.release(); mActivityContainer = null; mActivityContainer = null; } if (mSurface != null) { if (mSurface != null) { mSurface.release(); mSurface.release(); Loading @@ -239,26 +287,40 @@ public class ActivityView extends ViewGroup { } } mTextureView.setSurfaceTextureListener(null); mTextureView.setSurfaceTextureListener(null); mThread.quit(); } } private void attachToSurfaceWhenReady() { private void setSurfaceAsync(final Surface surface, final int width, final int height, final SurfaceTexture surfaceTexture = mTextureView.getSurfaceTexture(); final int densityDpi, final boolean callback) { if (surfaceTexture == null || mSurface != null) { mExecutor.execute(new Runnable() { // Either not ready to attach, or already attached. public void run() { return; } mSurface = new Surface(surfaceTexture); try { try { mActivityContainer.setSurface(mSurface, mWidth, mHeight, mMetrics.densityDpi); synchronized (mActivityContainerLock) { if (mActivityContainer != null) { mActivityContainer.setSurface(surface, width, height, densityDpi); } } } catch (RemoteException e) { } catch (RemoteException e) { mSurface.release(); throw new RuntimeException( mSurface = null; "ActivityView: Unable to set surface of ActivityContainer. ", throw new RuntimeException("ActivityView: Unable to create ActivityContainer. " + e); e); } if (callback) { post(new Runnable() { @Override public void run() { if (mActivityViewCallback != null) { if (surface != null) { mActivityViewCallback.onSurfaceAvailable(ActivityView.this); } else { mActivityViewCallback.onSurfaceDestroyed(ActivityView.this); } } } }); } } } } }); } /** /** * Set the callback to use to report certain state changes. * Set the callback to use to report certain state changes. Loading Loading @@ -308,10 +370,8 @@ public class ActivityView extends ViewGroup { + height); + height); mWidth = width; mWidth = width; mHeight = height; mHeight = height; attachToSurfaceWhenReady(); mSurface = new Surface(surfaceTexture); if (mActivityViewCallback != null) { setSurfaceAsync(mSurface, mWidth, mHeight, mDensityDpi, true); mActivityViewCallback.onSurfaceAvailable(ActivityView.this); } } } @Override @Override Loading @@ -331,15 +391,7 @@ public class ActivityView extends ViewGroup { if (DEBUG) Log.d(TAG, "onSurfaceTextureDestroyed"); if (DEBUG) Log.d(TAG, "onSurfaceTextureDestroyed"); mSurface.release(); mSurface.release(); mSurface = null; mSurface = null; try { setSurfaceAsync(null, mWidth, mHeight, mDensityDpi, true); mActivityContainer.setSurface(null, mWidth, mHeight, mMetrics.densityDpi); } catch (RemoteException e) { throw new RuntimeException( "ActivityView: Unable to set surface of ActivityContainer. " + e); } if (mActivityViewCallback != null) { mActivityViewCallback.onSurfaceDestroyed(ActivityView.this); } return true; return true; } } Loading core/java/android/app/Notification.java +24 −6 Original line number Original line Diff line number Diff line Loading @@ -45,6 +45,7 @@ import android.os.UserHandle; import android.text.TextUtils; import android.text.TextUtils; import android.util.Log; import android.util.Log; import android.util.MathUtils; import android.util.MathUtils; import android.util.SparseArray; import android.util.TypedValue; import android.util.TypedValue; import android.view.Gravity; import android.view.Gravity; import android.view.View; import android.view.View; Loading @@ -62,6 +63,8 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Arrays; import java.util.Collections; import java.util.Collections; import java.util.List; import java.util.List; import java.util.Objects; import java.util.Set; /** /** * A class that represents how a persistent notification is to be presented to * A class that represents how a persistent notification is to be presented to Loading Loading @@ -1603,13 +1606,23 @@ public class Notification implements Parcelable bigContentView = null; bigContentView = null; headsUpContentView = null; headsUpContentView = null; mLargeIcon = null; mLargeIcon = null; if (extras != null) { if (extras != null && !extras.isEmpty()) { extras.remove(Notification.EXTRA_LARGE_ICON); extras.remove(Notification.EXTRA_LARGE_ICON_BIG); extras.remove(Notification.EXTRA_PICTURE); extras.remove(Notification.EXTRA_BIG_TEXT); // Prevent light notifications from being rebuilt. // Prevent light notifications from being rebuilt. extras.remove(Builder.EXTRA_NEEDS_REBUILD); extras.remove(Builder.EXTRA_NEEDS_REBUILD); final Set<String> keyset = extras.keySet(); final int N = keyset.size(); final String[] keys = keyset.toArray(new String[N]); for (int i=0; i<N; i++) { final String key = keys[i]; final Object obj = extras.get(key); if (obj != null && ( obj instanceof Parcelable || obj instanceof Parcelable[] || obj instanceof SparseArray || obj instanceof ArrayList)) { extras.remove(key); } } } } } } Loading Loading @@ -3966,13 +3979,18 @@ public class Notification implements Parcelable return this; return this; } } /** @hide */ public static final int MIN_ASHMEM_BITMAP_SIZE = 128 * (1 << 10); /** /** * @hide * @hide */ */ @Override @Override public void purgeResources() { public void purgeResources() { super.purgeResources(); super.purgeResources(); if (mPicture != null && mPicture.isMutable()) { if (mPicture != null && mPicture.isMutable() && mPicture.getAllocationByteCount() >= MIN_ASHMEM_BITMAP_SIZE) { mPicture = mPicture.createAshmemBitmap(); mPicture = mPicture.createAshmemBitmap(); } } if (mBigLargeIcon != null) { if (mBigLargeIcon != null) { Loading core/java/android/app/usage/UsageStatsManagerInternal.java +2 −1 Original line number Original line Diff line number Diff line Loading @@ -71,10 +71,11 @@ public abstract class UsageStatsManagerInternal { * Could be hours, could be days, who knows? * Could be hours, could be days, who knows? * * * @param packageName * @param packageName * @param uidForAppId The uid of the app, which will be used for its app id * @param userId * @param userId * @return * @return */ */ public abstract boolean isAppIdle(String packageName, int userId); public abstract boolean isAppIdle(String packageName, int uidForAppId, int userId); /** /** * Returns all of the uids for a given user where all packages associating with that uid * Returns all of the uids for a given user where all packages associating with that uid Loading core/java/android/bluetooth/BluetoothDevice.java +13 −0 Original line number Original line Diff line number Diff line Loading @@ -25,6 +25,7 @@ import android.content.Context; import android.os.Parcel; import android.os.Parcel; import android.os.Parcelable; import android.os.Parcelable; import android.os.ParcelUuid; import android.os.ParcelUuid; import android.os.Process; import android.os.RemoteException; import android.os.RemoteException; import android.util.Log; import android.util.Log; Loading Loading @@ -823,6 +824,9 @@ public final class BluetoothDevice implements Parcelable { return false; return false; } } try { try { Log.i(TAG, "createBond() for device " + getAddress() + " called by pid: " + Process.myPid() + " tid: " + Process.myTid()); return sService.createBond(this, TRANSPORT_AUTO); return sService.createBond(this, TRANSPORT_AUTO); } catch (RemoteException e) {Log.e(TAG, "", e);} } catch (RemoteException e) {Log.e(TAG, "", e);} return false; return false; Loading Loading @@ -854,6 +858,9 @@ public final class BluetoothDevice implements Parcelable { throw new IllegalArgumentException(transport + " is not a valid Bluetooth transport"); throw new IllegalArgumentException(transport + " is not a valid Bluetooth transport"); } } try { try { Log.i(TAG, "createBond() for device " + getAddress() + " called by pid: " + Process.myPid() + " tid: " + Process.myTid()); return sService.createBond(this, transport); return sService.createBond(this, transport); } catch (RemoteException e) {Log.e(TAG, "", e);} } catch (RemoteException e) {Log.e(TAG, "", e);} return false; return false; Loading Loading @@ -920,6 +927,9 @@ public final class BluetoothDevice implements Parcelable { return false; return false; } } try { try { Log.i(TAG, "cancelBondProcess() for device " + getAddress() + " called by pid: " + Process.myPid() + " tid: " + Process.myTid()); return sService.cancelBondProcess(this); return sService.cancelBondProcess(this); } catch (RemoteException e) {Log.e(TAG, "", e);} } catch (RemoteException e) {Log.e(TAG, "", e);} return false; return false; Loading @@ -941,6 +951,9 @@ public final class BluetoothDevice implements Parcelable { return false; return false; } } try { try { Log.i(TAG, "removeBond() for device " + getAddress() + " called by pid: " + Process.myPid() + " tid: " + Process.myTid()); return sService.removeBond(this); return sService.removeBond(this); } catch (RemoteException e) {Log.e(TAG, "", e);} } catch (RemoteException e) {Log.e(TAG, "", e);} return false; return false; Loading core/java/android/bluetooth/BluetoothHeadset.java +42 −0 Original line number Original line Diff line number Diff line Loading @@ -684,6 +684,48 @@ public final class BluetoothHeadset implements BluetoothProfile { return BluetoothHeadset.STATE_AUDIO_DISCONNECTED; return BluetoothHeadset.STATE_AUDIO_DISCONNECTED; } } /** * Sets whether audio routing is allowed. When set to {@code false}, the AG will not route any * audio to the HF unless explicitly told to. * This method should be used in cases where the SCO channel is shared between multiple profiles * and must be delegated by a source knowledgeable * Note: This is an internal function and shouldn't be exposed * * @param allowed {@code true} if the profile can reroute audio, {@code false} otherwise. * * @hide */ public void setAudioRouteAllowed(boolean allowed) { if (VDBG) log("setAudioRouteAllowed"); if (mService != null && isEnabled()) { try { mService.setAudioRouteAllowed(allowed); } catch (RemoteException e) {Log.e(TAG, e.toString());} } else { Log.w(TAG, "Proxy not attached to service"); if (DBG) Log.d(TAG, Log.getStackTraceString(new Throwable())); } } /** * Returns whether audio routing is allowed. see {@link #setAudioRouteAllowed(boolean)}. * Note: This is an internal function and shouldn't be exposed * * @hide */ public boolean getAudioRouteAllowed() { if (VDBG) log("getAudioRouteAllowed"); if (mService != null && isEnabled()) { try { return mService.getAudioRouteAllowed(); } catch (RemoteException e) {Log.e(TAG, e.toString());} } else { Log.w(TAG, "Proxy not attached to service"); if (DBG) Log.d(TAG, Log.getStackTraceString(new Throwable())); } return false; } /** /** * Check if Bluetooth SCO audio is connected. * Check if Bluetooth SCO audio is connected. * * Loading Loading
core/java/android/app/ActivityView.java +112 −60 Original line number Original line Diff line number Diff line Loading @@ -24,8 +24,6 @@ import android.content.IIntentSender; import android.content.Intent; import android.content.Intent; import android.content.IntentSender; import android.content.IntentSender; import android.graphics.SurfaceTexture; import android.graphics.SurfaceTexture; import android.os.Handler; import android.os.HandlerThread; import android.os.IBinder; import android.os.IBinder; import android.os.Message; import android.os.Message; import android.os.OperationCanceledException; import android.os.OperationCanceledException; Loading @@ -45,6 +43,17 @@ import android.view.WindowManager; import dalvik.system.CloseGuard; import dalvik.system.CloseGuard; import java.lang.ref.WeakReference; import java.lang.ref.WeakReference; import java.util.ArrayDeque; import java.util.concurrent.Executor; import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ThreadFactory; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; import com.android.internal.annotations.GuardedBy; /** @hide */ /** @hide */ public class ActivityView extends ViewGroup { public class ActivityView extends ViewGroup { Loading @@ -53,9 +62,64 @@ public class ActivityView extends ViewGroup { private static final int MSG_SET_SURFACE = 1; private static final int MSG_SET_SURFACE = 1; DisplayMetrics mMetrics = new DisplayMetrics(); private static final int CPU_COUNT = Runtime.getRuntime().availableProcessors(); private static final int MINIMUM_POOL_SIZE = 1; private static final int MAXIMUM_POOL_SIZE = CPU_COUNT * 2 + 1; private static final int KEEP_ALIVE = 1; private static final ThreadFactory sThreadFactory = new ThreadFactory() { private final AtomicInteger mCount = new AtomicInteger(1); public Thread newThread(Runnable r) { return new Thread(r, "ActivityView #" + mCount.getAndIncrement()); } }; private static final BlockingQueue<Runnable> sPoolWorkQueue = new LinkedBlockingQueue<Runnable>(128); /** * An {@link Executor} that can be used to execute tasks in parallel. */ private static final Executor sExecutor = new ThreadPoolExecutor(MINIMUM_POOL_SIZE, MAXIMUM_POOL_SIZE, KEEP_ALIVE, TimeUnit.SECONDS, sPoolWorkQueue, sThreadFactory); private static class SerialExecutor implements Executor { private final ArrayDeque<Runnable> mTasks = new ArrayDeque<Runnable>(); private Runnable mActive; public synchronized void execute(final Runnable r) { mTasks.offer(new Runnable() { public void run() { try { r.run(); } finally { scheduleNext(); } } }); if (mActive == null) { scheduleNext(); } } protected synchronized void scheduleNext() { if ((mActive = mTasks.poll()) != null) { sExecutor.execute(mActive); } } } private final SerialExecutor mExecutor = new SerialExecutor(); private final int mDensityDpi; private final TextureView mTextureView; private final TextureView mTextureView; @GuardedBy("mActivityContainerLock") private ActivityContainerWrapper mActivityContainer; private ActivityContainerWrapper mActivityContainer; private Object mActivityContainerLock = new Object(); private Activity mActivity; private Activity mActivity; private int mWidth; private int mWidth; private int mHeight; private int mHeight; Loading @@ -63,8 +127,6 @@ public class ActivityView extends ViewGroup { private int mLastVisibility; private int mLastVisibility; private ActivityViewCallback mActivityViewCallback; private ActivityViewCallback mActivityViewCallback; private HandlerThread mThread = new HandlerThread("ActivityViewThread"); private Handler mHandler; public ActivityView(Context context) { public ActivityView(Context context) { this(context, null); this(context, null); Loading Loading @@ -97,28 +159,14 @@ public class ActivityView extends ViewGroup { + e); + e); } } mThread.start(); mHandler = new Handler(mThread.getLooper()) { @Override public void handleMessage(Message msg) { super.handleMessage(msg); if (msg.what == MSG_SET_SURFACE) { try { mActivityContainer.setSurface((Surface) msg.obj, msg.arg1, msg.arg2, mMetrics.densityDpi); } catch (RemoteException e) { throw new RuntimeException( "ActivityView: Unable to set surface of ActivityContainer. " + e); } } } }; mTextureView = new TextureView(context); mTextureView = new TextureView(context); mTextureView.setSurfaceTextureListener(new ActivityViewSurfaceTextureListener()); mTextureView.setSurfaceTextureListener(new ActivityViewSurfaceTextureListener()); addView(mTextureView); addView(mTextureView); WindowManager wm = (WindowManager)mActivity.getSystemService(Context.WINDOW_SERVICE); WindowManager wm = (WindowManager)mActivity.getSystemService(Context.WINDOW_SERVICE); wm.getDefaultDisplay().getMetrics(mMetrics); DisplayMetrics metrics = new DisplayMetrics(); wm.getDefaultDisplay().getMetrics(metrics); mDensityDpi = metrics.densityDpi; mLastVisibility = getVisibility(); mLastVisibility = getVisibility(); Loading @@ -131,15 +179,13 @@ public class ActivityView extends ViewGroup { } } @Override @Override protected void onVisibilityChanged(View changedView, int visibility) { protected void onVisibilityChanged(View changedView, final int visibility) { super.onVisibilityChanged(changedView, visibility); super.onVisibilityChanged(changedView, visibility); if (mSurface != null && (visibility == View.GONE || mLastVisibility == View.GONE)) { if (mSurface != null && (visibility == View.GONE || mLastVisibility == View.GONE)) { Message msg = Message.obtain(mHandler, MSG_SET_SURFACE); if (DEBUG) Log.v(TAG, "visibility changed; enqueing runnable"); msg.obj = (visibility == View.GONE) ? null : mSurface; final Surface surface = (visibility == View.GONE) ? null : mSurface; msg.arg1 = mWidth; setSurfaceAsync(surface, mWidth, mHeight, mDensityDpi, false); msg.arg2 = mHeight; mHandler.sendMessage(msg); } } mLastVisibility = visibility; mLastVisibility = visibility; } } Loading Loading @@ -230,8 +276,10 @@ public class ActivityView extends ViewGroup { Log.e(TAG, "Duplicate call to release"); Log.e(TAG, "Duplicate call to release"); return; return; } } synchronized (mActivityContainerLock) { mActivityContainer.release(); mActivityContainer.release(); mActivityContainer = null; mActivityContainer = null; } if (mSurface != null) { if (mSurface != null) { mSurface.release(); mSurface.release(); Loading @@ -239,26 +287,40 @@ public class ActivityView extends ViewGroup { } } mTextureView.setSurfaceTextureListener(null); mTextureView.setSurfaceTextureListener(null); mThread.quit(); } } private void attachToSurfaceWhenReady() { private void setSurfaceAsync(final Surface surface, final int width, final int height, final SurfaceTexture surfaceTexture = mTextureView.getSurfaceTexture(); final int densityDpi, final boolean callback) { if (surfaceTexture == null || mSurface != null) { mExecutor.execute(new Runnable() { // Either not ready to attach, or already attached. public void run() { return; } mSurface = new Surface(surfaceTexture); try { try { mActivityContainer.setSurface(mSurface, mWidth, mHeight, mMetrics.densityDpi); synchronized (mActivityContainerLock) { if (mActivityContainer != null) { mActivityContainer.setSurface(surface, width, height, densityDpi); } } } catch (RemoteException e) { } catch (RemoteException e) { mSurface.release(); throw new RuntimeException( mSurface = null; "ActivityView: Unable to set surface of ActivityContainer. ", throw new RuntimeException("ActivityView: Unable to create ActivityContainer. " + e); e); } if (callback) { post(new Runnable() { @Override public void run() { if (mActivityViewCallback != null) { if (surface != null) { mActivityViewCallback.onSurfaceAvailable(ActivityView.this); } else { mActivityViewCallback.onSurfaceDestroyed(ActivityView.this); } } } }); } } } } }); } /** /** * Set the callback to use to report certain state changes. * Set the callback to use to report certain state changes. Loading Loading @@ -308,10 +370,8 @@ public class ActivityView extends ViewGroup { + height); + height); mWidth = width; mWidth = width; mHeight = height; mHeight = height; attachToSurfaceWhenReady(); mSurface = new Surface(surfaceTexture); if (mActivityViewCallback != null) { setSurfaceAsync(mSurface, mWidth, mHeight, mDensityDpi, true); mActivityViewCallback.onSurfaceAvailable(ActivityView.this); } } } @Override @Override Loading @@ -331,15 +391,7 @@ public class ActivityView extends ViewGroup { if (DEBUG) Log.d(TAG, "onSurfaceTextureDestroyed"); if (DEBUG) Log.d(TAG, "onSurfaceTextureDestroyed"); mSurface.release(); mSurface.release(); mSurface = null; mSurface = null; try { setSurfaceAsync(null, mWidth, mHeight, mDensityDpi, true); mActivityContainer.setSurface(null, mWidth, mHeight, mMetrics.densityDpi); } catch (RemoteException e) { throw new RuntimeException( "ActivityView: Unable to set surface of ActivityContainer. " + e); } if (mActivityViewCallback != null) { mActivityViewCallback.onSurfaceDestroyed(ActivityView.this); } return true; return true; } } Loading
core/java/android/app/Notification.java +24 −6 Original line number Original line Diff line number Diff line Loading @@ -45,6 +45,7 @@ import android.os.UserHandle; import android.text.TextUtils; import android.text.TextUtils; import android.util.Log; import android.util.Log; import android.util.MathUtils; import android.util.MathUtils; import android.util.SparseArray; import android.util.TypedValue; import android.util.TypedValue; import android.view.Gravity; import android.view.Gravity; import android.view.View; import android.view.View; Loading @@ -62,6 +63,8 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Arrays; import java.util.Collections; import java.util.Collections; import java.util.List; import java.util.List; import java.util.Objects; import java.util.Set; /** /** * A class that represents how a persistent notification is to be presented to * A class that represents how a persistent notification is to be presented to Loading Loading @@ -1603,13 +1606,23 @@ public class Notification implements Parcelable bigContentView = null; bigContentView = null; headsUpContentView = null; headsUpContentView = null; mLargeIcon = null; mLargeIcon = null; if (extras != null) { if (extras != null && !extras.isEmpty()) { extras.remove(Notification.EXTRA_LARGE_ICON); extras.remove(Notification.EXTRA_LARGE_ICON_BIG); extras.remove(Notification.EXTRA_PICTURE); extras.remove(Notification.EXTRA_BIG_TEXT); // Prevent light notifications from being rebuilt. // Prevent light notifications from being rebuilt. extras.remove(Builder.EXTRA_NEEDS_REBUILD); extras.remove(Builder.EXTRA_NEEDS_REBUILD); final Set<String> keyset = extras.keySet(); final int N = keyset.size(); final String[] keys = keyset.toArray(new String[N]); for (int i=0; i<N; i++) { final String key = keys[i]; final Object obj = extras.get(key); if (obj != null && ( obj instanceof Parcelable || obj instanceof Parcelable[] || obj instanceof SparseArray || obj instanceof ArrayList)) { extras.remove(key); } } } } } } Loading Loading @@ -3966,13 +3979,18 @@ public class Notification implements Parcelable return this; return this; } } /** @hide */ public static final int MIN_ASHMEM_BITMAP_SIZE = 128 * (1 << 10); /** /** * @hide * @hide */ */ @Override @Override public void purgeResources() { public void purgeResources() { super.purgeResources(); super.purgeResources(); if (mPicture != null && mPicture.isMutable()) { if (mPicture != null && mPicture.isMutable() && mPicture.getAllocationByteCount() >= MIN_ASHMEM_BITMAP_SIZE) { mPicture = mPicture.createAshmemBitmap(); mPicture = mPicture.createAshmemBitmap(); } } if (mBigLargeIcon != null) { if (mBigLargeIcon != null) { Loading
core/java/android/app/usage/UsageStatsManagerInternal.java +2 −1 Original line number Original line Diff line number Diff line Loading @@ -71,10 +71,11 @@ public abstract class UsageStatsManagerInternal { * Could be hours, could be days, who knows? * Could be hours, could be days, who knows? * * * @param packageName * @param packageName * @param uidForAppId The uid of the app, which will be used for its app id * @param userId * @param userId * @return * @return */ */ public abstract boolean isAppIdle(String packageName, int userId); public abstract boolean isAppIdle(String packageName, int uidForAppId, int userId); /** /** * Returns all of the uids for a given user where all packages associating with that uid * Returns all of the uids for a given user where all packages associating with that uid Loading
core/java/android/bluetooth/BluetoothDevice.java +13 −0 Original line number Original line Diff line number Diff line Loading @@ -25,6 +25,7 @@ import android.content.Context; import android.os.Parcel; import android.os.Parcel; import android.os.Parcelable; import android.os.Parcelable; import android.os.ParcelUuid; import android.os.ParcelUuid; import android.os.Process; import android.os.RemoteException; import android.os.RemoteException; import android.util.Log; import android.util.Log; Loading Loading @@ -823,6 +824,9 @@ public final class BluetoothDevice implements Parcelable { return false; return false; } } try { try { Log.i(TAG, "createBond() for device " + getAddress() + " called by pid: " + Process.myPid() + " tid: " + Process.myTid()); return sService.createBond(this, TRANSPORT_AUTO); return sService.createBond(this, TRANSPORT_AUTO); } catch (RemoteException e) {Log.e(TAG, "", e);} } catch (RemoteException e) {Log.e(TAG, "", e);} return false; return false; Loading Loading @@ -854,6 +858,9 @@ public final class BluetoothDevice implements Parcelable { throw new IllegalArgumentException(transport + " is not a valid Bluetooth transport"); throw new IllegalArgumentException(transport + " is not a valid Bluetooth transport"); } } try { try { Log.i(TAG, "createBond() for device " + getAddress() + " called by pid: " + Process.myPid() + " tid: " + Process.myTid()); return sService.createBond(this, transport); return sService.createBond(this, transport); } catch (RemoteException e) {Log.e(TAG, "", e);} } catch (RemoteException e) {Log.e(TAG, "", e);} return false; return false; Loading Loading @@ -920,6 +927,9 @@ public final class BluetoothDevice implements Parcelable { return false; return false; } } try { try { Log.i(TAG, "cancelBondProcess() for device " + getAddress() + " called by pid: " + Process.myPid() + " tid: " + Process.myTid()); return sService.cancelBondProcess(this); return sService.cancelBondProcess(this); } catch (RemoteException e) {Log.e(TAG, "", e);} } catch (RemoteException e) {Log.e(TAG, "", e);} return false; return false; Loading @@ -941,6 +951,9 @@ public final class BluetoothDevice implements Parcelable { return false; return false; } } try { try { Log.i(TAG, "removeBond() for device " + getAddress() + " called by pid: " + Process.myPid() + " tid: " + Process.myTid()); return sService.removeBond(this); return sService.removeBond(this); } catch (RemoteException e) {Log.e(TAG, "", e);} } catch (RemoteException e) {Log.e(TAG, "", e);} return false; return false; Loading
core/java/android/bluetooth/BluetoothHeadset.java +42 −0 Original line number Original line Diff line number Diff line Loading @@ -684,6 +684,48 @@ public final class BluetoothHeadset implements BluetoothProfile { return BluetoothHeadset.STATE_AUDIO_DISCONNECTED; return BluetoothHeadset.STATE_AUDIO_DISCONNECTED; } } /** * Sets whether audio routing is allowed. When set to {@code false}, the AG will not route any * audio to the HF unless explicitly told to. * This method should be used in cases where the SCO channel is shared between multiple profiles * and must be delegated by a source knowledgeable * Note: This is an internal function and shouldn't be exposed * * @param allowed {@code true} if the profile can reroute audio, {@code false} otherwise. * * @hide */ public void setAudioRouteAllowed(boolean allowed) { if (VDBG) log("setAudioRouteAllowed"); if (mService != null && isEnabled()) { try { mService.setAudioRouteAllowed(allowed); } catch (RemoteException e) {Log.e(TAG, e.toString());} } else { Log.w(TAG, "Proxy not attached to service"); if (DBG) Log.d(TAG, Log.getStackTraceString(new Throwable())); } } /** * Returns whether audio routing is allowed. see {@link #setAudioRouteAllowed(boolean)}. * Note: This is an internal function and shouldn't be exposed * * @hide */ public boolean getAudioRouteAllowed() { if (VDBG) log("getAudioRouteAllowed"); if (mService != null && isEnabled()) { try { return mService.getAudioRouteAllowed(); } catch (RemoteException e) {Log.e(TAG, e.toString());} } else { Log.w(TAG, "Proxy not attached to service"); if (DBG) Log.d(TAG, Log.getStackTraceString(new Throwable())); } return false; } /** /** * Check if Bluetooth SCO audio is connected. * Check if Bluetooth SCO audio is connected. * * Loading