-
-
Notifications
You must be signed in to change notification settings - Fork 352
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 #82 from SourceCodeTrace/master
支持360OS手机OAID
- Loading branch information
Showing
6 changed files
with
609 additions
and
0 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
74 changes: 74 additions & 0 deletions
74
library/src/main/java/com/github/gzuliyujiang/oaid/impl/QikuImpl.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,74 @@ | ||
package com.github.gzuliyujiang.oaid.impl; | ||
|
||
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.IOAID; | ||
import com.github.gzuliyujiang.oaid.OAIDException; | ||
import com.github.gzuliyujiang.oaid.OAIDLog; | ||
|
||
import repeackage.com.qiku.id.IOAIDInterface; | ||
import repeackage.com.qiku.id.QikuIdmanager; | ||
|
||
public class QikuImpl implements IOAID { | ||
private final Context context; | ||
private boolean mUseQikuId = true; | ||
|
||
public QikuImpl(Context context){ | ||
this.context = context; | ||
} | ||
|
||
@Override | ||
public boolean supported() { | ||
if (context == null) { | ||
return false; | ||
} | ||
try { | ||
PackageInfo pi = context.getPackageManager().getPackageInfo("com.qiku.id", 0); | ||
if (pi != null){ | ||
return true; | ||
}else{ | ||
mUseQikuId = false; | ||
return new QikuIdmanager().isSupported(); | ||
} | ||
} catch (Exception e) { | ||
OAIDLog.print(e); | ||
return false; | ||
} | ||
} | ||
|
||
@Override | ||
public void doGet(IGetter getter) { | ||
if (context == null || getter == null) { | ||
return; | ||
} | ||
if (mUseQikuId){ | ||
Intent intent = new Intent("qiku.service.action.id"); | ||
intent.setPackage("com.qiku.id"); | ||
OAIDService.bind(context, intent, getter, new OAIDService.RemoteCaller() { | ||
@Override | ||
public String callRemoteInterface(IBinder service) throws OAIDException, RemoteException { | ||
IOAIDInterface anInterface = IOAIDInterface.Stub.asInterface(service); | ||
if (anInterface == null) { | ||
throw new OAIDException("IdsSupplier is null"); | ||
} | ||
return anInterface.getOAID(); | ||
} | ||
}); | ||
}else{ | ||
try { | ||
String oaid = new QikuIdmanager().getOAID(); | ||
if (oaid == null || oaid.length() == 0) { | ||
throw new OAIDException("OAID/AAID acquire failed"); | ||
} | ||
getter.onOAIDGetComplete(oaid); | ||
} catch (Exception e) { | ||
getter.onOAIDGetError(e); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.