[Samsung Gear Fit] cpvyb:
This is the log of opening an app with openfit:

09-25 14:49:18.439 1700-1700/? I/Timeline﹕ Timeline: Activity_launch_request id:com.openapp.gearfitphone time:24696648

09-25 14:49:18.441 833-1429/? I/ActivityManager﹕ START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.openapp.gearfitphone/.MainActivity (has extras)} from uid 1000 on display 0

09-25 14:49:18.579 9826-9826/? D/GEARFIT_PHONE_SERVICE﹕ Service onCreate()

09-25 14:49:18.615 9826-9826/? D/GEARFIT_PHONE_SERVICE﹕ Service onStartCommand()

09-25 14:49:18.639 9826-9826/? D/GEARFIT_PHONE_SERVICE﹕ Service onDestroy

09-25 14:49:18.639 9826-9826/? E/GEARFIT_PHONE_SERVICE﹕ Can't unregister Phone State Receiver

09-25 14:49:18.639 9826-9826/? W/System.err﹕ java.lang.IllegalArgumentException: Receiver not registered: com.openapp.gearfitphone.GearFitPhoneService$1@20818dbf

09-25 14:49:18.640 9826-9826/? W/System.err﹕ at com.openapp.gearfitphone.GearFitPhoneService.onDestroy(GearFitPhoneService.java:527)

09-25 14:49:18.713 833-863/? I/ActivityManager﹕ Displayed com.openapp.gearfitphone/.MainActivity: +227ms

09-25 14:49:18.994 833-863/? I/Timeline﹕ Timeline: Activity_windows_visible id: ActivityRecord{39725502 u0 com.openapp.gearfitphone/.MainActivity t1001} time:24697203

When gearfitmanager is installed we get:

09-25 14:57:30.558 1700-1700/? I/Timeline﹕ Timeline: Activity_launch_request id:com.openapp.gearfitphone time:25188767

09-25 14:57:30.559 833-1129/? I/ActivityManager﹕ START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 pkg=com.openapp.gearfitphone cmp=com.openapp.gearfitphone/.MainActivity bnds=[12,943][276,1275] (has extras)} from uid 1000 on display 0

09-25 14:57:30.668 833-852/? I/ActivityManager﹕ Start proc com.openapp.gearfitphone for activity com.openapp.gearfitphone/.MainActivity: pid=16536 uid=10110 gids={50110, 9997, 3003} abi=armeabi-v7a

09-25 14:57:31.268 16567-16567/? I/dex2oat﹕ /system/bin/dex2oat --runtime-arg -classpath --runtime-arg --instruction-set=arm --instruction-set-features=div --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --dex-file=/data/data/com.openapp.gearfitphone/cache/ads-1166370892.jar --oat-fd=22 --oat-location=/data/data/com.openapp.gearfitphone/cache/ads-1166370892.dex --runtime-arg -Xms64m --runtime-arg -Xmx512m

09-25 14:57:31.715 16536-16536/? D/GEARFIT_PHONE_SERVICE﹕ Service onCreate()

09-25 14:57:31.793 16536-16536/? D/GEARFIT_PHONE_SERVICE﹕ Service onStartCommand()

09-25 14:57:31.940 16536-16611/? D/GEARFIT_PHONE_SERVICE﹕ getListCallLog()

09-25 14:57:31.989 16612-16612/? D/ScupService﹕ findCupApp() appName = CAMERA REMOTE, packageName : com.sun.studios.gear_fit_camera_remote, iconPath = ic_launcher, appType = 1, serviceName = com.sun.studios.control.GearControlService, shortcut = true

09-25 14:57:31.989 16612-16612/? D/ScupAppInfo﹕ ScupAppInfo packageName = com.sun.studios.gear_fit_camera_remote

09-25 14:57:31.995 16612-16612/? D/ScupService﹕ packageName : com.sun.studios.gear_fit_camera_remote, appName = CAMERA REMOTE

09-25 14:57:32.055 833-863/? I/ActivityManager﹕ Displayed com.openapp.gearfitphone/.MainActivity: +1s452ms (total +18s580ms)

09-25 14:57:32.055 833-863/? I/Timeline﹕ Timeline: Activity_windows_visible id: ActivityRecord{1a380941 u0 com.openapp.gearfitphone/.MainActivity t1010} time:25190265

09-25 14:57:32.101 16612-16612/? D/ScupService﹕ Package Name : com.sun.studios.gear_fit_camera_remote, App name : CAMERA REMOTE, App Id : 1, App type : 1, Service name : com.sun.studios.control.GearControlService

09-25 14:57:32.101 16612-16612/? D/ScupService﹕ Package Name : com.sun.studios.gear_fit_camera_remote, App name : CAMERA REMOTE, App Id : 1, App type : 1, Service name : com.sun.studios.control.GearControlService

09-25 14:57:32.102 16612-16612/? D/ScupService﹕ Package name : com.sun.studios.gear_fit_camera_remote

09-25 14:57:32.109 16612-16612/? D/ScupService﹕ findCupApp() appName = Phone, packageName : com.openapp.gearfitphone, iconPath = ic_launcher, appType = 1, serviceName = com.openapp.gearfitphone.GearFitPhoneService, shortcut = true

09-25 14:57:32.109 16612-16612/? D/ScupAppInfo﹕ ScupAppInfo packageName = com.openapp.gearfitphone

09-25 14:57:32.109 16612-16612/? D/ScupService﹕ packageName : com.openapp.gearfitphone, appName = Phone

09-25 14:57:32.176 16612-16612/? D/ScupService﹕ Package Name : com.openapp.gearfitphone, App name : Phone, App Id : 2, App type : 1, Service name : com.openapp.gearfitphone.GearFitPhoneService

09-25 14:57:32.176 16612-16612/? D/ScupService﹕ Package Name : com.sun.studios.gear_fit_camera_remote, App name : CAMERA REMOTE, App Id : 1, App type : 1, Service name : com.sun.studios.control.GearControlService

09-25 14:57:32.176 16612-16612/? D/ScupService﹕ Package Name : com.openapp.gearfitphone, App name : Phone, App Id : 2, App type : 1, Service name : com.openapp.gearfitphone.GearFitPhoneService

09-25 14:57:32.176 16612-16612/? D/ScupService﹕ Package Name : com.sun.studios.gear_fit_camera_remote, App name : CAMERA REMOTE, App Id : 1, App type : 1, Service name : com.sun.studios.control.GearControlService

09-25 14:57:32.176 16612-16612/? D/ScupService﹕ Package name : com.sun.studios.gear_fit_camera_remote

09-25 14:57:32.176 16612-16612/? D/ScupService﹕ Package name : com.openapp.gearfitphone

09-25 14:57:32.188 16612-16612/? D/ScupService﹕ findCupApp() appName = Weather, packageName : com.webupclose.gearfitweather, iconPath = icon_name, appType = 1, serviceName = com.example.mouad.myapplication.FetchAddressIntentService, shortcut = true

09-25 14:57:32.189 16612-16612/? D/ScupAppInfo﹕ ScupAppInfo packageName = com.webupclose.gearfitweather

09-25 14:57:32.196 16612-16612/? D/ScupService﹕ packageName : com.webupclose.gearfitweather, appName = Weather

09-25 14:57:32.240 16612-16612/? D/ScupService﹕ Package Name : com.webupclose.gearfitweather, App name : Weather, App Id : 3, App type : 1, Service name : com.example.mouad.myapplication.FetchAddressIntentService

09-25 14:57:32.240 16612-16612/? D/ScupService﹕ Package Name : com.openapp.gearfitphone, App name : Phone, App Id : 2, App type : 1, Service name : com.openapp.gearfitphone.GearFitPhoneService

09-25 14:57:32.240 16612-16612/? D/ScupService﹕ Package Name : com.sun.studios.gear_fit_camera_remote, App name : CAMERA REMOTE, App Id : 1, App type : 1, Service name : com.sun.studios.control.GearControlService

09-25 14:57:32.240 16612-16612/? D/ScupService﹕ Package Name : com.webupclose.gearfitweather, App name : Weather, App Id : 3, App type : 1, Service name : com.example.mouad.myapplication.FetchAddressIntentService

09-25 14:57:32.240 16612-16612/? D/ScupService﹕ Package Name : com.openapp.gearfitphone, App name : Phone, App Id : 2, App type : 1, Service name : com.openapp.gearfitphone.GearFitPhoneService

09-25 14:57:32.240 16612-16612/? D/ScupService﹕ Package Name : com.sun.studios.gear_fit_camera_remote, App name : CAMERA REMOTE, App Id : 1, App type : 1, Service name : com.sun.studios.control.GearControlService

09-25 14:57:32.241 16612-16612/? D/ScupService﹕ Package name : com.openapp.gearfitphone

09-25 14:57:32.241 16612-16612/? D/ScupService﹕ Package name : com.webupclose.gearfitweather

09-25 14:57:32.241 16612-16612/? D/ScupService﹕ Package name : com.sun.studios.gear_fit_camera_remote

09-25 14:57:32.248 16612-16632/? I/ScupService﹕ setCallback from com.openapp.gearfitphone

09-25 14:57:32.287 16612-16632/? I/ScupService﹕ setCallback from com.openapp.gearfitphone

09-25 14:57:33.013 16536-16611/? D/GEARFIT_PHONE_SERVICE﹕ Number of Call Logs > 50, Stop query

Gearfit install a class call scupService. It is an API of the gear fit. This is what gearfit APPs call when starting.

If you install gearfit manager, even if does not work, the API is available and the message "You should install Gear Fit Manager application first" does not appear.

This is the code of the package receiver of the CUP API:

package com.samsung.android.sdk.cup;

import android.content.BroadcastReceiver;

import android.content.Context;

import android.content.Intent;

import android.content.pm.ApplicationInfo;

import android.content.pm.PackageInfo;

import android.content.pm.PackageManager;

import android.content.pm.PackageManager.NameNotFoundException;

import android.content.pm.ResolveInfo;

import android.content.res.Resources;

import android.content.res.Resources.NotFoundException;

import android.graphics.Bitmap;

import android.graphics.BitmapFactory;

import android.graphics.drawable.BitmapDrawable;

import android.os.Bundle;

import android.util.Log;

import com.samsung.android.wms.preference.DeviceProperties;

import java.util.List;

class ScupPackageReceiver extends BroadcastReceiver {

static final String META_DATA_KEY_CUIP_INFO = "SAMSUNG_CUP_APP";

private static final String TAG;

private NotifyListener mNotifyListener;

public interface NotifyListener {

void onPackageAdded(ScupAppInfo scupAppInfo);

void onPackageRemoved(String str);

}

ScupPackageReceiver() {

this.mNotifyListener = null;

}

static {

TAG = ScupPackageReceiver.class.getSimpleName();

}

public void onReceive(Context context, Intent intent) {

String packageName = intent.getData().getSchemeSpecificPart();

Log.d(TAG, "onReceive packageName : " + packageName);

String action = intent.getAction();

if (action.equals("android.intent.action.PACKAGE_ADDED")) {

Log.d(TAG, "onReceive ACTION_PACKAGE_ADDED");

PackageManager pm = context.getPackageManager();

try {

ApplicationInfo info = pm.getApplicationInfo(packageName, DeviceProperties.RESOLUTION_HEIGHT);

if (info != null) {

Bundle bundle = info.metaData;

if (bundle == null) {

Log.d(TAG, "bundle is null.");

return;

}

String cupAppData = bundle.getString(META_DATA_KEY_CUIP_INFO);

if (cupAppData == null) {

Log.d(TAG, "cuipInfoData is null.");

return;

}

String appName;

String iconPath = null;

String shortcut = null;

Bitmap customIcon = null;

try {

appName = cupAppData.split(";")[0];

iconPath = cupAppData.split(";")[1];

shortcut = cupAppData.split(";")[2];

try {

Resources res = pm.getResourcesForApplication(packageName);

int resId = res.getIdentifier(appName, "string", packageName);

Log.d(TAG, "app name resId : " + resId);

try {

appName = res.getString(resId);

Log.d(TAG, "app name : " + appName);

} catch (NotFoundException e) {

e.printStackTrace();

}

resId = res.getIdentifier(iconPath, "drawable", packageName);

Log.d(TAG, "app icon resId : " + resId);

try {

customIcon = BitmapFactory.decodeResource(res, resId);

} catch (OutOfMemoryError e2) {

e2.printStackTrace();

}

} catch (NameNotFoundException e1) {

e1.printStackTrace();

}

} catch (ArrayIndexOutOfBoundsException e3) {

appName = info.loadLabel(pm).toString();

e3.printStackTrace();

}

int appType = 0;

String serviceName = null;

try {

PackageInfo pInfo = pm.getPackageInfo(packageName, 4);

Log.d(TAG, "before appType = " + 0);

if (pInfo.services != null) {

if (pInfo.services.length > 0) {

Intent cupIntent = new Intent();

cupIntent.setAction("com.samsung.android.sdk.cup");

List<ResolveInfo> cupApps = pm.queryIntentServices(cupIntent, 0);

if (cupApps != null && cupApps.size() > 0) {

int size = cupApps.size();

for (int i = 0; i < size; i++) {

ResolveInfo serviceInfo = (ResolveInfo) cupApps.get(i);

if (!(serviceInfo == null || serviceInfo.serviceInfo == null)) {

if (serviceInfo.serviceInfo.packageName != null) {

if (serviceInfo.serviceInfo.packageName.compareTo(packageName) == 0) {

appType = 1;

serviceName = pInfo.services[0].name;

break;

}

} else {

continue;

}

}

}

}

Log.d(TAG, "after appType = " + appType);

}

}

} catch (NameNotFoundException e12) {

Log.d(TAG, "fail to getPackageInfo");

e12.printStackTrace();

}

boolean isVisible = false;

if (shortcut != null) {

if (shortcut.compareTo("true") == 0) {

isVisible = true;

}

}

Log.d(TAG, "appName = " + appName + ", iconPath = " + iconPath + ", appType = " + appType + ", serviceName = " + serviceName + ", shortcut = " + isVisible);

ScupAppInfo appInfo = new ScupAppInfo(packageName);

appInfo.setAppName(appName);

appInfo.setAppType(appType);

appInfo.setServiceName(serviceName);

appInfo.setAppRegistered(isVisible);

if (this.mNotifyListener == null) {

return;

}

if (customIcon != null) {

try {

appInfo.setIcon(customIcon);

this.mNotifyListener.onPackageAdded(appInfo);

return;

} catch (NameNotFoundException e4) {

e4.printStackTrace();

return;

}

}

appInfo.setIcon(((BitmapDrawable) pm.getApplicationIcon(packageName)).getBitmap());

this.mNotifyListener.onPackageAdded(appInfo);

return;

}

return;

} catch (NameNotFoundException e42) {

Log.d(TAG, "Fail to read meta data.");

e42.printStackTrace();

return;

}

}

if (action.equals("android.intent.action.PACKAGE_REMOVED") && this.mNotifyListener != null) {

this.mNotifyListener.onPackageRemoved(packageName);

}

}

public void setNotifyListener(NotifyListener listener) {

this.mNotifyListener = listener;

}

}

So in the description of the app there should be a: SAMSUNG_CUP_APP

And GearFitManager is listening to a Intent of:

IntentFilter intentFilter = new IntentFilter();

intentFilter.addAction("android.intent.action.PACKAGE_ADDED");

intentFilter.addAction("android.intent.action.PACKAGE_REMOVED");

intentFilter.addDataScheme("package");

registerReceiver(this.mPackageReceiver, intentFilter);

I hope this helps ....