Loading apex/media/framework/java/android/media/MediaTranscodeManager.java +13 −9 Original line number Original line Diff line number Diff line Loading @@ -295,8 +295,8 @@ public final class MediaTranscodeManager { /* ignore */ /* ignore */ } } } } Log.w(TAG, "Failed to get service"); throw new UnsupportedOperationException("Failed to connect to MediaTranscoding service"); return null; } } /* /* Loading Loading @@ -463,8 +463,7 @@ public final class MediaTranscodeManager { } } }; }; private ITranscodingClient registerClient(IMediaTranscodingService service) private ITranscodingClient registerClient(IMediaTranscodingService service) { throws UnsupportedOperationException { synchronized (mLock) { synchronized (mLock) { try { try { // Registers the client with MediaTranscoding service. // Registers the client with MediaTranscoding service. Loading @@ -476,13 +475,12 @@ public final class MediaTranscodeManager { if (mTranscodingClient != null) { if (mTranscodingClient != null) { mTranscodingClient.asBinder().linkToDeath(() -> onClientDied(), /* flags */ 0); mTranscodingClient.asBinder().linkToDeath(() -> onClientDied(), /* flags */ 0); } } return mTranscodingClient; } catch (Exception ex) { } catch (RemoteException re) { Log.e(TAG, "Failed to register new client due to exception " + ex); Log.e(TAG, "Failed to register new client due to exception " + re); mTranscodingClient = null; mTranscodingClient = null; } } } } throw new UnsupportedOperationException("Failed to register new client"); return mTranscodingClient; } } /** /** Loading @@ -495,8 +493,10 @@ public final class MediaTranscodeManager { mUid = Os.getuid(); mUid = Os.getuid(); mPid = Os.getpid(); mPid = Os.getpid(); IMediaTranscodingService service = getService(false /*retry*/); IMediaTranscodingService service = getService(false /*retry*/); if (service != null) { mTranscodingClient = registerClient(service); mTranscodingClient = registerClient(service); } } } public static final class TranscodingRequest { public static final class TranscodingRequest { /** Uri of the source media file. */ /** Uri of the source media file. */ Loading Loading @@ -1567,6 +1567,10 @@ public final class MediaTranscodeManager { if (mTranscodingClient == null) { if (mTranscodingClient == null) { // Try to register with the service again. // Try to register with the service again. IMediaTranscodingService service = getService(false /*retry*/); IMediaTranscodingService service = getService(false /*retry*/); if (service == null) { throw new MediaTranscodingException.ServiceNotAvailableException( "Service rebooting. Try again later"); } mTranscodingClient = registerClient(service); mTranscodingClient = registerClient(service); // If still fails, throws an exception to tell client to try later. // If still fails, throws an exception to tell client to try later. if (mTranscodingClient == null) { if (mTranscodingClient == null) { Loading Loading
apex/media/framework/java/android/media/MediaTranscodeManager.java +13 −9 Original line number Original line Diff line number Diff line Loading @@ -295,8 +295,8 @@ public final class MediaTranscodeManager { /* ignore */ /* ignore */ } } } } Log.w(TAG, "Failed to get service"); throw new UnsupportedOperationException("Failed to connect to MediaTranscoding service"); return null; } } /* /* Loading Loading @@ -463,8 +463,7 @@ public final class MediaTranscodeManager { } } }; }; private ITranscodingClient registerClient(IMediaTranscodingService service) private ITranscodingClient registerClient(IMediaTranscodingService service) { throws UnsupportedOperationException { synchronized (mLock) { synchronized (mLock) { try { try { // Registers the client with MediaTranscoding service. // Registers the client with MediaTranscoding service. Loading @@ -476,13 +475,12 @@ public final class MediaTranscodeManager { if (mTranscodingClient != null) { if (mTranscodingClient != null) { mTranscodingClient.asBinder().linkToDeath(() -> onClientDied(), /* flags */ 0); mTranscodingClient.asBinder().linkToDeath(() -> onClientDied(), /* flags */ 0); } } return mTranscodingClient; } catch (Exception ex) { } catch (RemoteException re) { Log.e(TAG, "Failed to register new client due to exception " + ex); Log.e(TAG, "Failed to register new client due to exception " + re); mTranscodingClient = null; mTranscodingClient = null; } } } } throw new UnsupportedOperationException("Failed to register new client"); return mTranscodingClient; } } /** /** Loading @@ -495,8 +493,10 @@ public final class MediaTranscodeManager { mUid = Os.getuid(); mUid = Os.getuid(); mPid = Os.getpid(); mPid = Os.getpid(); IMediaTranscodingService service = getService(false /*retry*/); IMediaTranscodingService service = getService(false /*retry*/); if (service != null) { mTranscodingClient = registerClient(service); mTranscodingClient = registerClient(service); } } } public static final class TranscodingRequest { public static final class TranscodingRequest { /** Uri of the source media file. */ /** Uri of the source media file. */ Loading Loading @@ -1567,6 +1567,10 @@ public final class MediaTranscodeManager { if (mTranscodingClient == null) { if (mTranscodingClient == null) { // Try to register with the service again. // Try to register with the service again. IMediaTranscodingService service = getService(false /*retry*/); IMediaTranscodingService service = getService(false /*retry*/); if (service == null) { throw new MediaTranscodingException.ServiceNotAvailableException( "Service rebooting. Try again later"); } mTranscodingClient = registerClient(service); mTranscodingClient = registerClient(service); // If still fails, throws an exception to tell client to try later. // If still fails, throws an exception to tell client to try later. if (mTranscodingClient == null) { if (mTranscodingClient == null) { Loading