鸿蒙OS IPCSkeleton

2022-04-27 15:17 更新

IPCSkeleton

java.lang.Object

|---ohos.rpc.IPCSkeleton

public class IPCSkeleton
extends Object

在IPC骨架中提供静态接口,用于获取服务、读写对象、获取UID和PID、获取本地和对端设备的ID、检查是否在同一设备上进行了接口调用。

构造函数摘要

构造函数 描述
IPCSkeleton()

方法总结

修饰符和类型 方法 描述
static int flushCommands(IRemoteObject object) 将所有挂起的命令从指定的 RemoteProxy 刷新到相应的 RemoteObject。
static String getCallingDeviceID() 获取对端进程所在设备的ID。
static int getCallingPid() 获取代理的PID。
static int getCallingUid() 获取代理的 UID。
static IRemoteObject getContextObject() 获取已注册服务的本地 IRemoteObject 引用。
static String getLocalDeviceID() 获取本地设备的ID。
static boolean isLocalCalling() 检查是否在同一设备上进行了呼叫。
static String resetCallingIdentity() 将远程用户的 UID 和 PID 替换为本地用户的 UID 和 PID。
static boolean setCallingIdentity(String identity) 将 UID 和 PID 恢复为远程用户的 UID 和 PID。
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

构造函数详细信息

IPCSkeleton

public IPCSkeleton()

方法详情

getContextObject

public static IRemoteObject getContextObject()

获取已注册服务的本地 IRemoteObject 引用。

此方法是静态的。

返回:

返回已注册服务的 IRemoteObject 引用。

getCallingPid

public static int getCallingPid()

获取代理的PID。

此方法是静态的。 RemoteProxy对象与RemoteObject对象通信时PID为正整数,通信结束后恢复为0。 如果从 RemoteProxy 对象调用该方法,则返回 0; 如果从 RemoteObject 对象调用该方法,则返回对应的 RemoteProxy 对象的 PID。

返回:

返回代理的 PID。

getCallingUid

public static int getCallingUid()

获取代理的 UID。

此方法是静态的。 RemoteProxy对象与RemoteObject对象通信时UID为正整数,通信结束后恢复为0。 如果从 RemoteProxy 对象调用该方法,则返回 0; 如果从 RemoteObject 对象调用该方法,则返回对应的 RemoteProxy 对象的 UID。

返回:

返回代理的 UID。

getCallingDeviceID

public static String getCallingDeviceID()

获取对端进程所在设备的ID。

此方法是静态的。

返回:

返回对等进程所在设备的ID。

getLocalDeviceID

public static String getLocalDeviceID()

获取本地设备的ID。

此方法是静态的。

返回:

返回本地设备的 ID。

isLocalCalling

public static boolean isLocalCalling()

检查是否在同一设备上进行了呼叫。

此方法是静态的。

返回:

如果在同一设备上进行调用,则返回 true; 否则返回 false。

flushCommands

public static int flushCommands(IRemoteObject object)

将所有挂起的命令从指定的 RemoteProxy 刷新到相应的 RemoteObject。

此方法是静态的。 建议您在执行任何对时间敏感的操作之前调用该方法。

参数:

参数名称 参数描述
object 表示指定的 RemoteProxy。

返回:

如果操作成功,则返回 0; 如果输入对象为空或RemoteObject,或操作失败,则返回错误代码。

resetCallingIdentity

public static String resetCallingIdentity()

将远程用户的 UID 和 PID 替换为本地用户的 UID 和 PID。

此方法是静态的。 它可以用于身份验证等场景。

返回:

返回包含远程用户的 UID 和 PID 的字符串。

setCallingIdentity

public static boolean setCallingIdentity(String identity)

将 UID 和 PID 恢复为远程用户的 UID 和 PID。

此方法是静态的。 它通常在使用resetCallingIdentity 后调用,需要resetCallingIdentity 返回的远程用户的UID 和PID。

参数:

参数名称 参数描述
identity 表示远程用户的UID和PID的字符串,resetCallingIdentity返回。

返回:

如果操作成功,则返回 true; 否则返回 false。

以上内容是否对您有帮助:
在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号