Professional Documents
Culture Documents
Royole Corporation
Restricted Distribution
Not to be distributed, used, copied, reproduced, or modified in whole or in part, nor its contents
revealed in any manner to others without the express written permission of Royole Corporation.
FlexPai, based on Android P system, continues using the framework and system applications
with in-depth customization. Combining characteristics of the smartphone, it designs new UI
interface effect, defines new interaction mode, upgrades support for multi-screen application
display from single screen display, and is equipped with two sets of sensors to ensure
accuracy of data in different usage scenarios.
When FlexPai is folded, the screen is divided into four parts – primary screen, primary edge
screen, secondary edge screen and secondary screen. You can choose to show wallpaper on
the other screen or not.
Wallpaper on back on: When the primary screen is facing up, it displays the functional area
while the secondary screen displays the wallpaper; when the secondary screen is facing up, it
displays the functional area while the primary screen displays the wallpaper
Wallpaper on back off: When the primary screen is facing up, it displays the functional area
while the secondary screen turns off; when the secondary screen is facing up, it displays the
functional area while the primary screen turns off. If FlexPai is unfolded, it displays as a full
screen.
If FlexPai is folded to form primary screen and secondary screen, the primary screen displays
with resolution of 1440*810 and screen scale of 16:9, while the secondary screen displays
with resolution of 1440*720 and screen scale of 18:9. If FlexPai is unfolded to a full screen,
the screen displays with resolution of 1920*1440 and screen scale of 4:3.
The phone is in folded screen state in case that the screen angle is [0°, 60°], and in full screen
state in case that the screen angle is (60°, 180°]. In the process of switching of full screen, the
screen with angle (60°, 150°) is in full-screen intermediate state with the wallpaper displayed
across the whole screen and the functional area displayed on the primary or secondary screen
before switching.
FlexPai provides monitoring for two sets of sensors (acceleration sensor, gyroscopic sensor,
geomagnetic sensor, optical proximity sensor, ambient light sensor, gravity sensor and
rotation vector sensor).
FlexPai is the first foldable flexible-screen smartphone. The screen can be bent from 0°to
180°, which provides many new features, including the included angle of screens, the addition
of the second set of sensors for primary screen, display of multiple screens, change and
control of the state. To make a third-party application use these features flexibly and
conveniently, FlexPai provides a set of interfaces, called FlexPai SDK. By integrating FlexPai
SDK and calling relevant interfaces, the third-party application can access these features for
personalized functions.
The SDK interfaces are divided by modules such as screen angle, two sets of sensors and
screen information. Different modules are encapsulated by different packages. See the FlexPai
API List for a detailed description of the interfaces.
Method 1:
a) Copy the library file flexpaideveloperlib-vx.x.aar to the libs directory of the application
module.
android {
repositories {
flatDir {
dirs 'libs'
}
}
dependencies {
compile(name:'flexpaideveloperlib-vx.x', ext:'aar')
Android Gradle Plugin Version 3.0.0 or later
implementation (name:'flexpaideveloperlib-vx.x', ext:'aar')
b) Ensure that the library is listed at the top of the file settings.gradle, as shown in the
following library named flexpaideveloperlib-vx.x:
c) Open the file build.gradle of the application module and add a new line of code to the
dependencies block, as shown in the following segment:
dependencies {
<uses-sdk android:minSdkVersion="21"/>
</manifest>
Screen angle is the included angle of screens when the phone is folded or unfolded. It is 0
degree when the phone is folded and 180 degrees when unfolded fully. (Note: Error exists in
screen angle)
The angle can be acquired with two methods: directly calling an interface, and using listener.
To make it easier to acquire the angle, SDK provides some interfaces through which you can
monitor or acquire the angle to realize some personalized functions. For example, when you
fold a phone for switching between large and half screens, as the angle changes, the icons on
the desktop present an animation effect of linear flow and screen switching is realized
smoothly when the phone reach the screen switching threshold.
Example:
import com.water.flexpaidev.angle.AngleAgent;
AngleAgent.getInstance();
Example:
import com.water.flexpaidev.angle.AngleAgent;
Note:
Make sure to call the initialization interface prior to other angle-related interfaces, or it may
report an error.
Example:
import com.water.flexpaidev.angle.AngleAgent;
Note:
Make sure to call the destruction interface after calling all angle-related interfaces to release the
resource.
Example:
import com.water.flexpaidev.angle.AngleAgent;
}
};
AngleAgent.getInstance().registerAngleListener (mScreenAngleListener);
Example:
import com.water.flexpaidev.angle.AngleAgent;
}
};
AngleAgent.getInstance(). unregisterAngleListener (mScreenAngleListener);
AngleAgent.getInstance().getAngle();
FlexPai has two sets of sensors (see Section 1.1 Introduction of FlexPai). The first is the
sensor set for secondary screen, the data of which are acquired via the native standard
interface of Android. The second is the sensor set for primary screen, the data of which can be
acquired via both the native interface and the extensive API.
When switching among full screen, primary screen and secondary screen, the data of sensors
are acquired via two sets of interfaces with the following corresponding relationship:
Secondary screen
Interface Full screen state Primary screen state
state
Native standard Data of sensor set Data of sensor set for Data of sensor set
interface for for secondary primary screen for secondary
sensors screen screen
Interface for the Data of sensor set Data of sensor set for Data of sensor set
second set of for primary screen primary screen for primary screen
sensors
The use of native standard interface is not described here, and only the interface for the
second set of sensors is described below. As all the sensors at the interfaces used for
registering and deregistering the listener are the same in type, they are introduced here and
will be demonstrated later based on the difference in the type.
Example:
import com.water.flexpaidev.sensor.SensorAgent;
SensorAgent.getInstance(this);
Note:
It is recommended to call in the life cycle function of an Android component, such as onCreate()
and onDestroy(), or onResume() and onPause() in Activity.
@Override
public void onAccuracyChanged(Sensor arg0,int arg1){
}
};
SensorAgent.getInstance(this).registerSecondListener(mAccelerometerSensorEventListener,Sensor.TYPE_AC
CELEROMETER);
SensorAgent.getInstance(this).unregisterSecondListener(mAccelerometerSensorEventListener);
Example:
import com.water.flexpaidev.sensor.SensorAgent;
@Override
public void onAccuracyChanged(Sensor arg0,int arg1){
}
};
SensorAgent.getInstance(this).unregisterSecondListener(mGyroscopeSensorEventListener);
Example:
import com.water.flexpaidev.sensor.SensorAgent;
@Override
public void onAccuracyChanged(Sensor arg0,int arg1){
}
};
SensorAgent.getInstance(this).registerSecondListener(mMagneticFieldSensorEventListener,
Sensor.TYPE_MAGNETIC_FIELD);
SensorAgent.getInstance(this).unregisterSecondListener(mMagneticFieldSensorEventListener);
Example:
@Override
public void onAccuracyChanged(Sensor arg0,int arg1){
}
};
SensorAgent.getInstance(this).registerSecondListener(mProximitySensorEventListener,
Sensor.TYPE_PROXIMITY);
SensorAgent.getInstance(this).unregisterSecondListener(mProximitySensorEventListener);
When you register an ambient light sensor, the type imported is Sensor.TYPE_LIGHT. The
result returned by onSensorChanged() is the value of the ambient light sensor corresponding
to the primary screen.
Example:
import com.water.flexpaidev.sensor.SensorAgent;
@Override
public void onAccuracyChanged(Sensor arg0,int arg1){
}
};
SensorAgent.getInstance(this).unregisterSecondListener(mProximitySensorEventListener);
When you register a gravity sensor, the type imported is Sensor.TYPE_GRAVITY. The result
returned by onSensorChanged() is the value of the gravity sensor corresponding to the
primary screen.
Example:
import com.water.flexpaidev.sensor.SensorAgent;
@Override
public void onAccuracyChanged(Sensor arg0,int arg1){
}
};
SensorAgent.getInstance(this).registerSecondListener(mGravitySensorEventListener,
Sensor.TYPE_GRAVITY);
SensorAgent.getInstance(this).unregisterSecondListener(mGravitySensorEventListener);
Example:
import com.water.flexpaidev.sensor.SensorAgent;
@Override
public void onAccuracyChanged(Sensor arg0,int arg1){
}
};
SensorAgent.getInstance(this).registerSecondListener(mRotationvectorSensorEventListener,
Sensor.TYPE_ROTATION_VECTOR);
SensorAgent.getInstance(this).unregisterSecondListener(mRotationvectorSensorEventListener);
In addition to standard screen information such as resolution, landscape and portrait and pixel
density, FlexPai also includes features such as screen mode (full screen and half screen), half
screen state (primary screen and secondary screen),wallpaper on back switch (other screen on
and other screen off) and half screen flip lock (locked and unlocked) due to screen folding.
In case of switching between full and half screens, when you switch a full landscape to a half
screen, the default state is small portrait, and vice versa; when you switch a full portrait to a
half screen, the default state is small landscape, and vice versa. At the same time, the
application will switch to the corresponding screen position by default unless the application
has set the screen orientation.
The method to acquire standard screen information is also standard. See “Screen information -
standard information” section in Demo for specific information on how to get screen
information.
Example:
import com.water.flexpaidev.screen.ScreenModeAgent;
ScreenModeAgent.getInstance(this);
The screen is in Full Screen Mode when it is unfolded and in Half Screen Mode when it is
folded. Please refer to the section “Introduction of FlexPai” for the angle range corresponding
to a specific state. The interfaces can be used to actively get the full/half screen state value,
register and deregister full/half screen state listener.
Example:
import com.water.flexpaidev.screen.ScreenModeAgent;
ScreenModeAgent.getInstance(this).getScreenModeValue();
Parameter Meaning
screenFeatureListener A custom interface. When the state value changes, call back the interface.
Returned result Meaning
boolean True for successful registration and false for failed registration.
Example:
import com.water.flexpaidev.screen.ScreenModeAgent;
import com.water.flexpaidev.screen.ScreenFeatureListener;
}
};
}
ScreenModeAgent.getInstance(this).registerScreenModeListener(mScreenModeListener);
Parameter Meaning
screenFeatureListener Listener object used when registering.
Returned result Meaning
void No return.
Example:
import com.water.flexpaidev.screen.ScreenModeAgent;
import com.water.flexpaidev.screen.ScreenFeatureListener;
}
};
}
ScreenModeAgent.getInstance(this).unregisterScreenModeListener(mScreenModeListener);
When the screen is folded, it is divided into two half screens. The larger one, which is on the
back side of camera is Primary Screen, and the smaller one, which is on the same side of
camera is Secondary Screen. Please refer to “Introduction of FlexPai” for details. The
interfaces can be used to actively get the primary/secondary screen state value, register and
deregister primary/secondary screen state listener.
Example:
import com.water.flexpaidev.screen.ScreenModeAgent;
ScreenModeAgent.getInstance(this).getScreenActiveValue();
Example:
import com.water.flexpaidev.screen.ScreenModeAgent;
import com.water.flexpaidev.screen.ScreenFeatureListener;
}
};
}
ScreenModeAgent.getInstance(this).registerScreenActiveListener(mScreenActiveListener);
Example:
}
};
}
ScreenModeAgent.getInstance(this).unregisterScreenActiveListener(mScreenActiveListener);
In case that the phone is folded to form half screens, the switching on and off of the wallpaper on the
other screen can be done on the navigation bar. When using virtual navigation, directly tap the
switch icon to turn it on and off. When using gesture navigation, press and hold the gesture
navigation bar to call out the switch menu.
For the other screen, when the primary screen displays, the secondary screen and secondary edge
screen constitute the other screen; when the secondary screen displays, the primary screen and
primary edge screen constitute the other screen. The interfaces can be used to actively get the on/off
state value of wallpaper on back switch, register and deregister state listener of wallpaper on back
switch.
Interface 1: Actively getting the state value of wallpaper on back switch
Interface: public int getWallpaperOnBackSwitchValue() throws Settings.SettingNotFoundException
Parameter Meaning
null No parameter.
Exception Meaning
SettingNotFoundException It appears when the feature name does not exist in settings
Returned result Meaning
int State value of wallpaper on back switch (0 for wallpaper on back on and 1 for wallpaper on
back off)
Example:
import com.water.flexpaidev.screen.ScreenModeAgent;
ScreenModeAgent.getInstance(this).getWallpaperOnBackSwitchValue();
Example:
import com.water.flexpaidev.screen.ScreenModeAgent;
import com.water.flexpaidev.screen.screenFeatureListener;
}
};
}
ScreenModeAgent.getInstance(this). registerWallpaperOnBackSwitchListener
(mScreenWallpaperOnBackSwitchListener);
Parameter Meaning
screenFeatureListener Listener object used when registering.
Returned result Meaning
void No return.
Example:
import com.water.flexpaidev.screen.ScreenModeAgent;
import com.water.flexpaidev.screen.screenFeatureListener;
}
};
}
ScreenModeAgent.getInstance(this). unregisterWallpaperOnBackSwitchListener
(mScreenWallpaperOnBackSwitchListener);
In case that the phone is folded to form half screens, the display interface can switch between
primary screen and secondary screen following the flip of the device. If the flip function is
locked, it will not switch after flipping, but always shows on the screen where the flip
function is locked. The locking depends on the Auto Flip button in Control Center. The
interfaces can be used to actively get the lock state value, register and deregister lock state
listener.
Example:
import com.water.flexpaidev.screen.ScreenModeAgent;
ScreenModeAgent.getInstance(this). getScreenActiveLockedValue();
Example:
import com.water.flexpaidev.screen.ScreenModeAgent;
import com.water.flexpaidev.screen.screenFeatureListener;
ScreenModeAgent.getInstance(this).registerScreenActiveListener(mScreenLockedListener);
Parameter Meaning
screenFeatureListener Listener object used when registering.
Returned result Meaning
void No return.
Example:
import com.water.flexpaidev.screen.ScreenModeAgent;
import com.water.flexpaidev.screen.ScreenFeatureListener;
}
};
}
ScreenModeAgent.getInstance(this).unregisterScreenActiveListener(mScreenLockedListener);
Application adaptation focuses on screen adaptation, enabling the application to display well
on full screen, primary screen and secondary screen. Further, screen adaptation mainly refers
to adaptation of the application to a device with any size and density of the screen. The screen
of FlexPai includes full screen, primary screen and secondary screen (please refer to the
section “Introduction of FlexPai” in “Document Description” for concept of screen) with
resolution of 1920*1440, 1440*810 and 1440*720 in px respectively, and with density of 308.
The application adaptation is detailed in terms of screen size and screen density as below.
1> Ensure that the layout can resize appropriately to fit the size of the screen
The configuration qualifier provides a variety of layout resources, allowing the running
component to automatically select appropriate resources based on the current device
configuration (e.g. different layout designs for different screen sizes).
res/layout-land/layouts.xml
res/layout-port/layouts.xml
Use a nine-rectangle-grid bitmap, which is a bitmap with extension of .9.png. This kind
of picture resource can be created through the SDK's draw9patch utility (located in the
tools/ directory).
Because the device running Android has multiple screen densities, you should always
provide bitmap resources that can be customized based on a variety of common density
xhdpi:2.0
hdpi:1.5
mdpi:1.0 (baseline)
ldpi:0.75
Place the resulting picture file in the appropriate subdirectory under res/ and the system
will automatically select the correct file based on the screen density of the device
running the application:
MyProject/
res/
drawable-xhdpi/
awesomeimage.png
drawable-hdpi/
awesomeimage.png
drawable-mdpi/
awesomeimage.png
drawable-ldpi/
awesomeimage.png
The density of full screen, primary screen and secondary screen is 308, thus the
corresponding picture resources are under the drawable-xhdpi directory.
The switching among full screen, primary screen and secondary screen can cause destruction
and rebuilding of Activity. To avoid loss of data, it can be resolved in the following two ways:
a. Save the state data in onSaveInstanceState(), restore the state data in onCreate() or
onRestoreInstanceState().
b. Configure the Activity as follows in the inventory file to prevent destruction and
rebuilding of Activity:
</activity>
onConfigurationChanged() will be called in case of configuration change due to screen
switching.
Without a foldable-screen smartphone, the developer can perform simulation and debugging
by modifying the screen resolution:
a. Fold a full screen to a primary screen with the following method of simulation:
Preset the phone to the full screen resolution: adb shell wm size 1440x1920
Then set the resolution to the primary screen resolution: adb shell wm size 1440x810
b. Unfold the primary screen to the full screen with the following method of simulation:
Preset the phone to the primary screen resolution: adb shell wm size 1440x810
Then set the resolution to the full screen resolution: adb shell wm size 1440x1920
c. Unfold the secondary screen to the full screen with the following method of simulation:
Pre-set the phone to the secondary screen resolution: adb shell wm size 1440x720
Then set the resolution to the full screen resolution: adb shell wm size 1440x1920