Loading apex/media/framework/java/android/media/MediaTranscodeManager.java +14 −1 Original line number Original line Diff line number Diff line Loading @@ -22,6 +22,7 @@ import android.annotation.IntRange; import android.annotation.NonNull; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.Nullable; import android.annotation.SystemApi; import android.annotation.SystemApi; import android.app.ActivityManager; import android.content.ContentResolver; import android.content.ContentResolver; import android.content.Context; import android.content.Context; import android.content.res.AssetFileDescriptor; import android.content.res.AssetFileDescriptor; Loading @@ -36,6 +37,7 @@ import android.util.Log; import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.annotations.VisibleForTesting; import com.android.modules.annotation.MinSdk; import com.android.modules.annotation.MinSdk; import com.android.modules.utils.build.SdkLevel; import java.io.FileNotFoundException; import java.io.FileNotFoundException; import java.lang.annotation.Retention; import java.lang.annotation.Retention; Loading Loading @@ -119,6 +121,7 @@ public final class MediaTranscodeManager { private final String mPackageName; private final String mPackageName; private final int mPid; private final int mPid; private final int mUid; private final int mUid; private final boolean mIsLowRamDevice; private final ExecutorService mExecutor = Executors.newSingleThreadExecutor(); private final ExecutorService mExecutor = Executors.newSingleThreadExecutor(); private final HashMap<Integer, TranscodingSession> mPendingTranscodingSessions = new HashMap(); private final HashMap<Integer, TranscodingSession> mPendingTranscodingSessions = new HashMap(); private final Object mLock = new Object(); private final Object mLock = new Object(); Loading Loading @@ -199,7 +202,16 @@ public final class MediaTranscodeManager { } } } } private static IMediaTranscodingService getService(boolean retry) { private IMediaTranscodingService getService(boolean retry) { // Do not try to get the service on pre-S. The service is lazy-start and getting the // service could block. if (!SdkLevel.isAtLeastS()) { return null; } // Do not try to get the service on AndroidGo (low-ram) devices. if (mIsLowRamDevice) { return null; } int retryCount = !retry ? 1 : CONNECT_SERVICE_RETRY_COUNT; int retryCount = !retry ? 1 : CONNECT_SERVICE_RETRY_COUNT; Log.i(TAG, "get service with retry " + retryCount); Log.i(TAG, "get service with retry " + retryCount); for (int count = 1; count <= retryCount; count++) { for (int count = 1; count <= retryCount; count++) { Loading Loading @@ -417,6 +429,7 @@ public final class MediaTranscodeManager { mPackageName = mContext.getPackageName(); mPackageName = mContext.getPackageName(); mUid = Os.getuid(); mUid = Os.getuid(); mPid = Os.getpid(); mPid = Os.getpid(); mIsLowRamDevice = mContext.getSystemService(ActivityManager.class).isLowRamDevice(); IMediaTranscodingService service = getService(false /*retry*/); IMediaTranscodingService service = getService(false /*retry*/); if (service != null) { if (service != null) { mTranscodingClient = registerClient(service); mTranscodingClient = registerClient(service); Loading media/java/android/media/MediaServiceManager.java +14 −2 Original line number Original line Diff line number Diff line Loading @@ -45,12 +45,21 @@ public class MediaServiceManager { */ */ public static final class ServiceRegisterer { public static final class ServiceRegisterer { private final String mServiceName; private final String mServiceName; private final boolean mLazyStart; /** /** * @hide * @hide */ */ public ServiceRegisterer(String serviceName) { public ServiceRegisterer(String serviceName, boolean lazyStart) { mServiceName = serviceName; mServiceName = serviceName; mLazyStart = lazyStart; } /** * @hide */ public ServiceRegisterer(String serviceName) { this(serviceName, false /*lazyStart*/); } } /** /** Loading @@ -61,6 +70,9 @@ public class MediaServiceManager { */ */ @Nullable @Nullable public IBinder get() { public IBinder get() { if (mLazyStart) { return ServiceManager.waitForService(mServiceName); } return ServiceManager.getService(mServiceName); return ServiceManager.getService(mServiceName); } } } } Loading @@ -78,7 +90,7 @@ public class MediaServiceManager { */ */ @NonNull @NonNull public ServiceRegisterer getMediaTranscodingServiceRegisterer() { public ServiceRegisterer getMediaTranscodingServiceRegisterer() { return new ServiceRegisterer(MEDIA_TRANSCODING_SERVICE); return new ServiceRegisterer(MEDIA_TRANSCODING_SERVICE, true /*lazyStart*/); } } /** /** Loading Loading
apex/media/framework/java/android/media/MediaTranscodeManager.java +14 −1 Original line number Original line Diff line number Diff line Loading @@ -22,6 +22,7 @@ import android.annotation.IntRange; import android.annotation.NonNull; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.Nullable; import android.annotation.SystemApi; import android.annotation.SystemApi; import android.app.ActivityManager; import android.content.ContentResolver; import android.content.ContentResolver; import android.content.Context; import android.content.Context; import android.content.res.AssetFileDescriptor; import android.content.res.AssetFileDescriptor; Loading @@ -36,6 +37,7 @@ import android.util.Log; import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.annotations.VisibleForTesting; import com.android.modules.annotation.MinSdk; import com.android.modules.annotation.MinSdk; import com.android.modules.utils.build.SdkLevel; import java.io.FileNotFoundException; import java.io.FileNotFoundException; import java.lang.annotation.Retention; import java.lang.annotation.Retention; Loading Loading @@ -119,6 +121,7 @@ public final class MediaTranscodeManager { private final String mPackageName; private final String mPackageName; private final int mPid; private final int mPid; private final int mUid; private final int mUid; private final boolean mIsLowRamDevice; private final ExecutorService mExecutor = Executors.newSingleThreadExecutor(); private final ExecutorService mExecutor = Executors.newSingleThreadExecutor(); private final HashMap<Integer, TranscodingSession> mPendingTranscodingSessions = new HashMap(); private final HashMap<Integer, TranscodingSession> mPendingTranscodingSessions = new HashMap(); private final Object mLock = new Object(); private final Object mLock = new Object(); Loading Loading @@ -199,7 +202,16 @@ public final class MediaTranscodeManager { } } } } private static IMediaTranscodingService getService(boolean retry) { private IMediaTranscodingService getService(boolean retry) { // Do not try to get the service on pre-S. The service is lazy-start and getting the // service could block. if (!SdkLevel.isAtLeastS()) { return null; } // Do not try to get the service on AndroidGo (low-ram) devices. if (mIsLowRamDevice) { return null; } int retryCount = !retry ? 1 : CONNECT_SERVICE_RETRY_COUNT; int retryCount = !retry ? 1 : CONNECT_SERVICE_RETRY_COUNT; Log.i(TAG, "get service with retry " + retryCount); Log.i(TAG, "get service with retry " + retryCount); for (int count = 1; count <= retryCount; count++) { for (int count = 1; count <= retryCount; count++) { Loading Loading @@ -417,6 +429,7 @@ public final class MediaTranscodeManager { mPackageName = mContext.getPackageName(); mPackageName = mContext.getPackageName(); mUid = Os.getuid(); mUid = Os.getuid(); mPid = Os.getpid(); mPid = Os.getpid(); mIsLowRamDevice = mContext.getSystemService(ActivityManager.class).isLowRamDevice(); IMediaTranscodingService service = getService(false /*retry*/); IMediaTranscodingService service = getService(false /*retry*/); if (service != null) { if (service != null) { mTranscodingClient = registerClient(service); mTranscodingClient = registerClient(service); Loading
media/java/android/media/MediaServiceManager.java +14 −2 Original line number Original line Diff line number Diff line Loading @@ -45,12 +45,21 @@ public class MediaServiceManager { */ */ public static final class ServiceRegisterer { public static final class ServiceRegisterer { private final String mServiceName; private final String mServiceName; private final boolean mLazyStart; /** /** * @hide * @hide */ */ public ServiceRegisterer(String serviceName) { public ServiceRegisterer(String serviceName, boolean lazyStart) { mServiceName = serviceName; mServiceName = serviceName; mLazyStart = lazyStart; } /** * @hide */ public ServiceRegisterer(String serviceName) { this(serviceName, false /*lazyStart*/); } } /** /** Loading @@ -61,6 +70,9 @@ public class MediaServiceManager { */ */ @Nullable @Nullable public IBinder get() { public IBinder get() { if (mLazyStart) { return ServiceManager.waitForService(mServiceName); } return ServiceManager.getService(mServiceName); return ServiceManager.getService(mServiceName); } } } } Loading @@ -78,7 +90,7 @@ public class MediaServiceManager { */ */ @NonNull @NonNull public ServiceRegisterer getMediaTranscodingServiceRegisterer() { public ServiceRegisterer getMediaTranscodingServiceRegisterer() { return new ServiceRegisterer(MEDIA_TRANSCODING_SERVICE); return new ServiceRegisterer(MEDIA_TRANSCODING_SERVICE, true /*lazyStart*/); } } /** /** Loading