-
-
Notifications
You must be signed in to change notification settings - Fork 337
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 #70 from luoyesiqiu/master
Support older oppo devices
- Loading branch information
Showing
4 changed files
with
186 additions
and
3 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
82 changes: 82 additions & 0 deletions
82
library/src/main/java/com/github/gzuliyujiang/oaid/impl/OppoExtImpl.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,82 @@ | ||
/* | ||
* Copyright (c) 2016-present 贵州纳雍穿青人李裕江<1032694760@qq.com> | ||
* | ||
* The software is licensed under the Mulan PSL v2. | ||
* You can use this software according to the terms and conditions of the Mulan PSL v2. | ||
* You may obtain a copy of Mulan PSL v2 at: | ||
* http://license.coscl.org.cn/MulanPSL2 | ||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR | ||
* PURPOSE. | ||
* See the Mulan PSL v2 for more details. | ||
*/ | ||
|
||
package com.github.gzuliyujiang.oaid.impl; | ||
|
||
import android.content.ComponentName; | ||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.content.pm.PackageInfo; | ||
import android.os.IBinder; | ||
import android.os.RemoteException; | ||
|
||
import com.github.gzuliyujiang.oaid.IGetter; | ||
import com.github.gzuliyujiang.oaid.OAIDException; | ||
import com.github.gzuliyujiang.oaid.OAIDLog; | ||
|
||
import repeackage.com.oplus.stdid.IStdID; | ||
|
||
public class OppoExtImpl extends OppoImpl{ | ||
private final static String ACTION = "action.com.oplus.stdid.ID_SERVICE"; | ||
private final static String PACKAGE_NAME = "com.coloros.mcs"; | ||
private final static String CLASS_NAME = "com.oplus.stdid.IdentifyService"; | ||
|
||
private final Context context; | ||
public OppoExtImpl(Context context) { | ||
super(context); | ||
this.context = context; | ||
} | ||
|
||
@Override | ||
public boolean supported() { | ||
if (context == null) { | ||
return false; | ||
} | ||
try { | ||
PackageInfo pi = context.getPackageManager().getPackageInfo(PACKAGE_NAME, 0); | ||
return pi != null; | ||
} catch (Exception e) { | ||
OAIDLog.print(e); | ||
return false; | ||
} | ||
} | ||
|
||
@Override | ||
public void doGet(IGetter getter) { | ||
if (context == null || getter == null) { | ||
return; | ||
} | ||
Intent intent = new Intent(ACTION); | ||
intent.setComponent(new ComponentName(PACKAGE_NAME, CLASS_NAME)); | ||
OAIDService.bind(context, intent, getter, new OAIDService.RemoteCaller() { | ||
@Override | ||
public String callRemoteInterface(IBinder service) throws OAIDException, RemoteException { | ||
try { | ||
return realGetOUID(service); | ||
} catch (OAIDException | RemoteException e) { | ||
throw e; | ||
} catch (Exception e) { | ||
throw new OAIDException(e); | ||
} | ||
} | ||
}); | ||
} | ||
|
||
protected String getSerId(IBinder service, String pkgName, String sign) throws RemoteException, OAIDException { | ||
IStdID anInterface = IStdID.Stub.asInterface(service); | ||
if (anInterface == null) { | ||
throw new OAIDException("IStdID is null"); | ||
} | ||
return anInterface.getSerID(pkgName, sign, "OUID"); | ||
} | ||
} |
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
95 changes: 95 additions & 0 deletions
95
library/src/main/java/repeackage/com/oplus/stdid/IStdID.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,95 @@ | ||
/* | ||
* Copyright (c) 2016-present 贵州纳雍穿青人李裕江<1032694760@qq.com> | ||
* | ||
* The software is licensed under the Mulan PSL v2. | ||
* You can use this software according to the terms and conditions of the Mulan PSL v2. | ||
* You may obtain a copy of Mulan PSL v2 at: | ||
* http://license.coscl.org.cn/MulanPSL2 | ||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR | ||
* PURPOSE. | ||
* See the Mulan PSL v2 for more details. | ||
*/ | ||
|
||
package repeackage.com.oplus.stdid; | ||
|
||
|
||
import repeackage.com.heytap.openid.IOpenID; | ||
|
||
public interface IStdID extends IOpenID { | ||
public static abstract class Stub extends IOpenID.Stub { | ||
private static final java.lang.String DESCRIPTOR = "com.oplus.stdid.IStdID"; | ||
|
||
public Stub() { | ||
this.attachInterface(this, DESCRIPTOR); | ||
} | ||
|
||
public static IStdID asInterface(android.os.IBinder obj) { | ||
if ((obj == null)) { | ||
return null; | ||
} | ||
android.os.IInterface iin = obj.queryLocalInterface(DESCRIPTOR); | ||
if (((iin != null) && (iin instanceof IStdID))) { | ||
return ((IStdID) iin); | ||
} | ||
return (IStdID)new IStdID.Stub.Proxy(obj); | ||
} | ||
|
||
|
||
private static class Proxy implements IStdID { | ||
private android.os.IBinder mRemote; | ||
|
||
Proxy(android.os.IBinder remote) { | ||
mRemote = remote; | ||
} | ||
|
||
@Override | ||
public android.os.IBinder asBinder() { | ||
return mRemote; | ||
} | ||
|
||
public java.lang.String getInterfaceDescriptor() { | ||
return DESCRIPTOR; | ||
} | ||
|
||
@Override | ||
public java.lang.String getSerID(java.lang.String pkgName, java.lang.String sign, java.lang.String type) throws android.os.RemoteException { | ||
android.os.Parcel _data = android.os.Parcel.obtain(); | ||
android.os.Parcel _reply = android.os.Parcel.obtain(); | ||
java.lang.String _result; | ||
try { | ||
_data.writeInterfaceToken(DESCRIPTOR); | ||
_data.writeString(pkgName); | ||
_data.writeString(sign); | ||
_data.writeString(type); | ||
boolean _status = mRemote.transact(IStdID.Stub.TRANSACTION_getSerID, _data, _reply, 0); | ||
if (!_status && getDefaultImpl() != null) { | ||
return getDefaultImpl().getSerID(pkgName, sign, type); | ||
} | ||
_reply.readException(); | ||
_result = _reply.readString(); | ||
} finally { | ||
_reply.recycle(); | ||
_data.recycle(); | ||
} | ||
return _result; | ||
} | ||
public static IOpenID sDefaultImpl; | ||
} | ||
|
||
static final int TRANSACTION_getSerID = (android.os.IBinder.FIRST_CALL_TRANSACTION + 0); | ||
|
||
public static boolean setDefaultImpl(IOpenID impl) { | ||
if (Proxy.sDefaultImpl == null && impl != null) { | ||
Proxy.sDefaultImpl = impl; | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
public static IOpenID getDefaultImpl() { | ||
return Proxy.sDefaultImpl; | ||
} | ||
} | ||
|
||
} |