Search in sources :

Example 1 with DataHolder

use of com.google.android.gms.common.data.DataHolder in project android_packages_apps_GmsCore by microg.

the class PeopleServiceImpl method loadOwners.

@SuppressWarnings("MissingPermission")
@Override
public void loadOwners(final IPeopleCallbacks callbacks, boolean var2, boolean var3, final String accountName, String var5, int sortOrder) {
    Log.d(TAG, "loadOwners: " + var2 + ", " + var3 + ", " + accountName + ", " + var5 + ", " + sortOrder);
    if (context.checkCallingPermission(Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED) {
        PackageUtils.assertExtendedAccess(context);
    }
    AccountManager accountManager = AccountManager.get(context);
    Bundle accountMetadata = new Bundle();
    String accountType = AuthConstants.DEFAULT_ACCOUNT_TYPE;
    for (Account account : accountManager.getAccountsByType(accountType)) {
        if (accountName == null || account.name.equals(accountName)) {
            accountMetadata.putParcelable(account.name, new AccountMetadata());
        }
    }
    Bundle extras = new Bundle();
    extras.putBundle("account_metadata", accountMetadata);
    try {
        DatabaseHelper databaseHelper = new DatabaseHelper(context);
        DataHolder dataHolder = new DataHolder(databaseHelper.getOwners(), 0, extras);
        Log.d(TAG, "loadOwners[result]: " + dataHolder);
        callbacks.onDataHolder(0, extras, dataHolder);
        databaseHelper.close();
    } catch (Exception e) {
        Log.w(TAG, e);
    }
}
Also used : Account(android.accounts.Account) Bundle(android.os.Bundle) DataHolder(com.google.android.gms.common.data.DataHolder) AccountMetadata(com.google.android.gms.people.model.AccountMetadata) AccountManager(android.accounts.AccountManager) RemoteException(android.os.RemoteException)

Example 2 with DataHolder

use of com.google.android.gms.common.data.DataHolder in project android_packages_apps_GmsCore by microg.

the class PeopleServiceImpl method loadCircles.

@Override
public void loadCircles(IPeopleCallbacks callbacks, String account, String pageGaiaId, String circleId, int type, String var6, boolean var7) throws RemoteException {
    Log.d(TAG, "loadCircles: " + account + ", " + pageGaiaId + ", " + circleId + ", " + type + ", " + var6 + ", " + var7);
    PackageUtils.assertExtendedAccess(context);
    try {
        DatabaseHelper databaseHelper = new DatabaseHelper(context);
        Cursor owner = databaseHelper.getOwner(account);
        int ownerId = -1;
        if (owner.moveToNext()) {
            ownerId = owner.getInt(0);
        }
        owner.close();
        Bundle extras = new Bundle();
        DataHolder dataHolder = new DataHolder(databaseHelper.getCircles(ownerId, circleId, type), 0, extras);
        callbacks.onDataHolder(0, new Bundle(), dataHolder);
        databaseHelper.close();
    } catch (Exception e) {
        Log.w(TAG, e);
    }
}
Also used : Bundle(android.os.Bundle) DataHolder(com.google.android.gms.common.data.DataHolder) Cursor(android.database.Cursor) RemoteException(android.os.RemoteException)

Example 3 with DataHolder

use of com.google.android.gms.common.data.DataHolder in project GmsCore by microg.

the class WearableImpl method getDataItemsByUriAsHolder.

public DataHolder getDataItemsByUriAsHolder(Uri uri, String packageName) {
    String firstSignature;
    try {
        firstSignature = PackageUtils.firstSignatureDigest(context, packageName);
    } catch (Exception e) {
        return null;
    }
    Cursor dataHolderItems = nodeDatabase.getDataItemsForDataHolderByHostAndPath(packageName, firstSignature, fixHost(uri.getHost(), false), uri.getPath());
    DataHolder dataHolder = new DataHolder(dataHolderItems, 0, null);
    Log.d(TAG, "Returning data holder of size " + dataHolder.getCount() + " for query " + uri);
    return dataHolder;
}
Also used : DataHolder(com.google.android.gms.common.data.DataHolder) ByteString(okio.ByteString) Cursor(android.database.Cursor) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) RemoteException(android.os.RemoteException) IOException(java.io.IOException)

Example 4 with DataHolder

use of com.google.android.gms.common.data.DataHolder in project GmsCore by microg.

the class PeopleServiceImpl method loadOwners.

@SuppressWarnings("MissingPermission")
@Override
public void loadOwners(final IPeopleCallbacks callbacks, boolean var2, boolean var3, final String accountName, String var5, int sortOrder) {
    Log.d(TAG, "loadOwners: " + var2 + ", " + var3 + ", " + accountName + ", " + var5 + ", " + sortOrder);
    if (context.checkCallingPermission(Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED) {
        PackageUtils.assertExtendedAccess(context);
    }
    AccountManager accountManager = AccountManager.get(context);
    Bundle accountMetadata = new Bundle();
    String accountType = AuthConstants.DEFAULT_ACCOUNT_TYPE;
    for (Account account : accountManager.getAccountsByType(accountType)) {
        if (accountName == null || account.name.equals(accountName)) {
            accountMetadata.putParcelable(account.name, new AccountMetadata());
        }
    }
    Bundle extras = new Bundle();
    extras.putBundle("account_metadata", accountMetadata);
    try {
        DatabaseHelper databaseHelper = new DatabaseHelper(context);
        DataHolder dataHolder = new DataHolder(databaseHelper.getOwners(), 0, extras);
        Log.d(TAG, "loadOwners[result]: " + dataHolder);
        callbacks.onDataHolder(0, extras, dataHolder);
        databaseHelper.close();
    } catch (Exception e) {
        Log.w(TAG, e);
    }
}
Also used : Account(android.accounts.Account) Bundle(android.os.Bundle) DataHolder(com.google.android.gms.common.data.DataHolder) AccountMetadata(com.google.android.gms.people.model.AccountMetadata) AccountManager(android.accounts.AccountManager) RemoteException(android.os.RemoteException)

Example 5 with DataHolder

use of com.google.android.gms.common.data.DataHolder in project GmsCore by microg.

the class PeopleServiceImpl method loadCircles.

@Override
public void loadCircles(IPeopleCallbacks callbacks, String account, String pageGaiaId, String circleId, int type, String var6, boolean var7) throws RemoteException {
    Log.d(TAG, "loadCircles: " + account + ", " + pageGaiaId + ", " + circleId + ", " + type + ", " + var6 + ", " + var7);
    PackageUtils.assertExtendedAccess(context);
    try {
        DatabaseHelper databaseHelper = new DatabaseHelper(context);
        Cursor owner = databaseHelper.getOwner(account);
        int ownerId = -1;
        if (owner.moveToNext()) {
            ownerId = owner.getInt(0);
        }
        owner.close();
        Bundle extras = new Bundle();
        DataHolder dataHolder = new DataHolder(databaseHelper.getCircles(ownerId, circleId, type), 0, extras);
        callbacks.onDataHolder(0, new Bundle(), dataHolder);
        databaseHelper.close();
    } catch (Exception e) {
        Log.w(TAG, e);
    }
}
Also used : Bundle(android.os.Bundle) DataHolder(com.google.android.gms.common.data.DataHolder) Cursor(android.database.Cursor) RemoteException(android.os.RemoteException)

Aggregations

DataHolder (com.google.android.gms.common.data.DataHolder)9 RemoteException (android.os.RemoteException)6 Cursor (android.database.Cursor)5 Bundle (android.os.Bundle)4 Account (android.accounts.Account)2 AccountManager (android.accounts.AccountManager)2 AccountMetadata (com.google.android.gms.people.model.AccountMetadata)2 IOException (java.io.IOException)2 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)2 HashSet (java.util.HashSet)2 ByteString (okio.ByteString)2