Android7.1 的服务注册类是 SystemServiceRegistry
@Override
public Object getSystemService(String name) {
return SystemServiceRegistry.getSystemService(this, name);
}
在静态代码块里注册服务,WindowManager的具体实现类是WindowManagerImpl
registerService(Context.WINDOW_SERVICE, WindowManager.class,
new CachedServiceFetcher<WindowManager>() {
@Override
public WindowManager createService(ContextImpl ctx) {
return new WindowManagerImpl(ctx);
}});
frameworks/base/core/java/android/view/Display.java
private void updateDisplayInfoLocked() {
// Note: The display manager caches display info objects on our behalf.
DisplayInfo newInfo = mGlobal.getDisplayInfo(mDisplayId);
if (newInfo == null) {
// Preserve the old mDisplayInfo after the display is removed.
if (mIsValid) {
mIsValid = false;
if (DEBUG) {
Log.d(TAG, "Logical display " + mDisplayId + " was removed.");
}
}
} else {
// Use the new display info. (It might be the same object if nothing changed.)
mDisplayInfo = newInfo;
if (!mIsValid) {
mIsValid = true;
if (DEBUG) {
Log.d(TAG, "Logical display " + mDisplayId + " was recreated.");
}
}
}
}
在此处
private void updateDisplayInfoLocked() {
// Note: The display manager caches display info objects on our behalf.
DisplayInfo newInfo = mGlobal.getDisplayInfo(mDisplayId);
//此处添加2行写死即可
newInfo.logicalWidth = 1220;
newInfo.logicalHeight = 2712;
if (newInfo == null) {
// Preserve the old mDisplayInfo after the display is removed.
if (mIsValid) {
mIsValid = false;
if (DEBUG) {
Log.d(TAG, "Logical display " + mDisplayId + " was removed.");
}
}
} else {
// Use the new display info. (It might be the same object if nothing changed.)
mDisplayInfo = newInfo;
if (!mIsValid) {
mIsValid = true;
if (DEBUG) {
Log.d(TAG, "Logical display " + mDisplayId + " was recreated.");
}
}
}
}