-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #46 from DtHnAme/3.0-preview
fix: android 14 white screen issues
- Loading branch information
Showing
9 changed files
with
205 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
115 changes: 115 additions & 0 deletions
115
freeform-server/src/main/java/com/android/server/display/MiFreeformUDisplayAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
package com.android.server.display; | ||
|
||
import android.content.Context; | ||
import android.os.Handler; | ||
import android.os.IBinder; | ||
import android.os.RemoteException; | ||
import android.util.Log; | ||
import android.view.DisplayShapeHidden; | ||
import android.view.Surface; | ||
|
||
import io.sunshine0523.freeform.IMiFreeformDisplayCallback; | ||
|
||
/** | ||
* A display adapter that provides freeform displays on behalf of applications. | ||
* <p> | ||
* Display adapters are guarded by the {@link DisplayManagerService.SyncRoot} lock. | ||
* </p> | ||
* This adapter only support Android U | ||
*/ | ||
public final class MiFreeformUDisplayAdapter extends MiFreeformDisplayAdapter { | ||
private final LogicalDisplayMapper mLogicalDisplayMapper; | ||
|
||
public MiFreeformUDisplayAdapter( | ||
DisplayManagerService.SyncRoot syncRoot, | ||
Context context, | ||
Handler handler, | ||
DisplayDeviceRepository listener, | ||
LogicalDisplayMapper logicalDisplayMapper, | ||
Handler uiHandler | ||
) { | ||
super(syncRoot, context, handler, listener, uiHandler, TAG); | ||
mLogicalDisplayMapper = logicalDisplayMapper; | ||
} | ||
|
||
@Override | ||
public void createFreeformLocked(String name, IMiFreeformDisplayCallback callback, | ||
int width, int height, int densityDpi, | ||
boolean secure, boolean ownContentOnly, boolean shouldShowSystemDecorations, | ||
Surface surface, float refreshRate, long presentationDeadlineNanos) { | ||
synchronized (getSyncRoot()) { | ||
IBinder appToken = callback.asBinder(); | ||
FreeformFlags flags = new FreeformFlags(secure, ownContentOnly, shouldShowSystemDecorations); | ||
IBinder displayToken = DisplayControl.createDisplay(UNIQUE_ID_PREFIX + name, flags.mSecure, refreshRate); | ||
FreeformDisplayDevice device = new FreeformUDisplayDevice(displayToken, UNIQUE_ID_PREFIX + name, width, height, densityDpi, | ||
refreshRate, presentationDeadlineNanos, | ||
flags, surface, new Callback(callback, mHandler), callback.asBinder()); | ||
|
||
sendDisplayDeviceEventLocked(device, DISPLAY_DEVICE_EVENT_ADDED); | ||
mFreeformDisplayDevices.put(appToken, device); | ||
miFreeformDisplayCallbackArrayMap.put(device, callback); | ||
|
||
mHandler.postDelayed(() -> { | ||
LogicalDisplay display = mLogicalDisplayMapper.getDisplayLocked(device); | ||
Log.i(TAG, "findLogicalDisplayForDevice " + display); | ||
try { | ||
callback.onDisplayAdd(display.getDisplayIdLocked()); | ||
} catch (Exception ignored) { | ||
|
||
} | ||
}, 500); | ||
|
||
try { | ||
appToken.linkToDeath(device, 0); | ||
} catch (RemoteException ex) { | ||
mFreeformDisplayDevices.remove(appToken); | ||
device.destroyLocked(false); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public void resizeFreeform(IBinder appToken, int width, int height, int densityDpi) { | ||
super.resizeFreeform(appToken, width, height, densityDpi); | ||
} | ||
|
||
@Override | ||
public void releaseFreeform(IBinder appToken) { | ||
super.releaseFreeform(appToken); | ||
} | ||
|
||
private class FreeformUDisplayDevice extends FreeformDisplayDevice { | ||
|
||
FreeformUDisplayDevice(IBinder displayToken, String uniqueId, | ||
int width, int height, int density, | ||
float refreshRate, long presentationDeadlineNanos, | ||
FreeformFlags flags, Surface surface, | ||
Callback callback, IBinder appToken) { | ||
super(displayToken, uniqueId, | ||
width, height, density, | ||
refreshRate, presentationDeadlineNanos, | ||
flags, surface, callback, appToken); | ||
} | ||
|
||
@Override | ||
public DisplayDeviceInfo getDisplayDeviceInfoLocked() { | ||
super.getDisplayDeviceInfoLocked(); | ||
mInfo.displayShape = DisplayShapeHidden.createDefaultDisplayShape(mInfo.width, mInfo.height, false); | ||
|
||
return mInfo; | ||
} | ||
|
||
@Override | ||
public void destroyLocked(boolean binderAlive) { | ||
if (mSurface != null) { | ||
mSurface.release(); | ||
mSurface = null; | ||
} | ||
DisplayControl.destroyDisplay(getDisplayTokenLocked()); | ||
if (binderAlive) { | ||
mCallback.dispatchDisplayStopped(); | ||
} | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
hidden-api/src/main/java/android/view/DisplayShapeHidden.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package android.view; | ||
|
||
import dev.rikka.tools.refine.RefineAs; | ||
|
||
@RefineAs(DisplayShape.class) | ||
public class DisplayShapeHidden { | ||
|
||
public static DisplayShape createDefaultDisplayShape( | ||
int displayWidth, int displayHeight, boolean isScreenRound) { | ||
throw new RuntimeException("Stub!"); | ||
} | ||
|
||
} |
44 changes: 44 additions & 0 deletions
44
hidden-api/src/main/java/com/android/server/display/DisplayControl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.android.server.display; | ||
|
||
import android.os.IBinder; | ||
|
||
public class DisplayControl { | ||
|
||
/** | ||
* Create a display in SurfaceFlinger. | ||
* | ||
* @param name The name of the display | ||
* @param secure Whether this display is secure. | ||
* @return The token reference for the display in SurfaceFlinger. | ||
*/ | ||
public static IBinder createDisplay(String name, boolean secure) { | ||
throw new RuntimeException("Stub!"); | ||
} | ||
|
||
/** | ||
* Create a display in SurfaceFlinger. | ||
* | ||
* @param name The name of the display | ||
* @param secure Whether this display is secure. | ||
* @param requestedRefreshRate The requested refresh rate in frames per second. | ||
* For best results, specify a divisor of the physical refresh rate, e.g., 30 or 60 on | ||
* 120hz display. If an arbitrary refresh rate is specified, the rate will be rounded | ||
* up or down to a divisor of the physical display. If 0 is specified, the virtual | ||
* display is refreshed at the physical display refresh rate. | ||
* @return The token reference for the display in SurfaceFlinger. | ||
*/ | ||
public static IBinder createDisplay(String name, boolean secure, | ||
float requestedRefreshRate) { | ||
throw new RuntimeException("Stub!"); | ||
} | ||
|
||
/** | ||
* Destroy a display in SurfaceFlinger. | ||
* | ||
* @param displayToken The display token for the display to be destroyed. | ||
*/ | ||
public static void destroyDisplay(IBinder displayToken) { | ||
throw new RuntimeException("Stub!"); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters