Skip to content

Commit

Permalink
CHG: [droid] Generify Context
Browse files Browse the repository at this point in the history
  • Loading branch information
koying committed Jan 26, 2018
1 parent 6fbe59f commit 49dc1b4
Show file tree
Hide file tree
Showing 34 changed files with 137 additions and 135 deletions.
16 changes: 8 additions & 8 deletions xbmc/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -563,8 +563,8 @@ bool CApplication::Create()
bool extready = CXBMCApp::GetExternalStorage(extstorage);
CLog::Log(LOGNOTICE, "External storage path = %s; status = %s", extstorage.c_str(), extready ? "ok" : "nok");
CLog::Log(LOGNOTICE, "System library paths = %s", CJNISystem::getProperty("java.library.path").c_str());
CLog::Log(LOGNOTICE, "App library path = %s", CXBMCApp::getApplicationInfo().nativeLibraryDir.c_str());
CLog::Log(LOGNOTICE, "APK = %s", CXBMCApp::getPackageResourcePath().c_str());
CLog::Log(LOGNOTICE, "App library path = %s", CXBMCApp::get()->getApplicationInfo().nativeLibraryDir.c_str());
CLog::Log(LOGNOTICE, "APK = %s", CXBMCApp::get()->getPackageResourcePath().c_str());
CLog::Log(LOGNOTICE, "HasTouchScreen = %s", CAndroidFeatures::HasTouchScreen() ? "yes" : "no");
#endif

Expand Down Expand Up @@ -944,7 +944,7 @@ bool CApplication::InitDirectoriesLinux()
CSpecialProtocol::SetXBMCBinAddonPath(appBinPath + "/addons");

#if defined(TARGET_ANDROID)
CXBMCApp::InitDirectories();
CXBMCApp::get()->InitDirectories();
#endif

return true;
Expand Down Expand Up @@ -1528,7 +1528,7 @@ void CApplication::OnSettingAction(const CSetting *setting)
g_windowManager.ActivateWindow(WINDOW_PICTURES);
#ifdef TARGET_ANDROID
else if (settingId == CSettings::SETTING_DEBUG_UPLOADLOG)
CXBMCApp::uploadLog();
CXBMCApp::get()->uploadLog();
#endif
}

Expand Down Expand Up @@ -2414,7 +2414,7 @@ bool CApplication::OnAction(const CAction &action)

// Android has steps based on the max available volume level
#if defined(TARGET_ANDROID)
float step = (VOLUME_MAXIMUM - VOLUME_MINIMUM) / CXBMCApp::GetMaxSystemVolume();
float step = (VOLUME_MAXIMUM - VOLUME_MINIMUM) / CXBMCApp::get()->GetMaxSystemVolume();
#else
float step = (VOLUME_MAXIMUM - VOLUME_MINIMUM) / volumesteps;

Expand Down Expand Up @@ -2550,7 +2550,7 @@ void CApplication::OnApplicationMessage(ThreadMessage* pMsg)
#if defined(TARGET_ANDROID)
if (pMsg->params.size())
{
CXBMCApp::StartActivity(pMsg->params[0],
CXBMCApp::get()->StartActivity(pMsg->params[0],
pMsg->params.size() > 1 ? pMsg->params[1] : "",
pMsg->params.size() > 2 ? pMsg->params[2] : "",
pMsg->params.size() > 3 ? pMsg->params[3] : "");
Expand Down Expand Up @@ -3989,7 +3989,7 @@ bool CApplication::WakeUpScreenSaverAndDPMS(bool bPowerOffKeyPressed /* = false

#ifdef TARGET_ANDROID
// Screensaver deactivated -> acquire wake lock
CXBMCApp::EnableWakeLock(true);
CXBMCApp::get()->EnableWakeLock(true);
#endif

if(result)
Expand Down Expand Up @@ -4148,7 +4148,7 @@ void CApplication::ActivateScreenSaver(bool forceType /*= false */)
{
#ifdef TARGET_ANDROID
if (m_screenSaver->ID() == "screensaver.xbmc.builtin.system")
CXBMCApp::EnableWakeLock(false);
CXBMCApp::get()->EnableWakeLock(false);
#endif
return;
}
Expand Down
2 changes: 1 addition & 1 deletion xbmc/Util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1792,7 +1792,7 @@ std::string CUtil::ResolveExecutablePath()
else
strExecutablePath = buf;
#elif defined(TARGET_ANDROID)
strExecutablePath = CXBMCApp::getApplicationInfo().nativeLibraryDir;
strExecutablePath = CXBMCApp::get()->getApplicationInfo().nativeLibraryDir;

std::string appName = CCompileInfo::GetAppName();
std::string libName = "lib" + appName + ".so";
Expand Down
8 changes: 4 additions & 4 deletions xbmc/cores/AudioEngine/Sinks/AESinkAUDIOTRACK.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -665,8 +665,8 @@ bool CAESinkAUDIOTRACK::Initialize(AEAudioFormat &format, std::string &device)
if (m_passthrough && (m_wantsIECPassthrough && m_encoding != CJNIAudioFormat::ENCODING_IEC61937))
{
CXBMCApp::get()->AcquireAudioFocus();
m_volume = CXBMCApp::GetSystemVolume();
CXBMCApp::SetSystemVolume(1.0);
m_volume = CXBMCApp::get()->GetSystemVolume();
CXBMCApp::get()->SetSystemVolume(1.0);
}

return true;
Expand All @@ -680,7 +680,7 @@ void CAESinkAUDIOTRACK::Deinitialize()
// Restore volume
if (m_volume != -1)
{
CXBMCApp::SetSystemVolume(m_volume);
CXBMCApp::get()->SetSystemVolume(m_volume);
CXBMCApp::get()->ReleaseAudioFocus();
}

Expand Down Expand Up @@ -923,7 +923,7 @@ void CAESinkAUDIOTRACK::EnumerateDevicesEx(AEDeviceInfoList &list, bool force)
// Enumerate audio devices on API >= 23
if (CJNIAudioManager::GetSDKVersion() >= 23)
{
CJNIAudioManager audioManager(CJNIContext::getSystemService("audio"));
CJNIAudioManager audioManager(CXBMCApp::get()->getSystemService("audio"));
CJNIAudioDeviceInfos audiodevices = audioManager.getDevices(CJNIAudioManager::GET_DEVICES_OUTPUTS);
if (g_advancedSettings.CanLogComponent(LOGAUDIO))
LogAudoDevices("EnumerateDevicesEx", audiodevices);
Expand Down
2 changes: 1 addition & 1 deletion xbmc/cores/ExternalPlayer/ExternalPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ BOOL CExternalPlayer::ExecuteAppAndroid(const char* strSwitches,const char* strP
{
CLog::Log(LOGNOTICE, "%s: %s", __FUNCTION__, strSwitches);

bool ret = CXBMCApp::StartActivity(strSwitches, "android.intent.action.VIEW", "video/*", strPath);
bool ret = CXBMCApp::get()->StartActivity(strSwitches, "android.intent.action.VIEW", "video/*", strPath);

if (!ret)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ CRenderCaptureAndroid::CRenderCaptureAndroid()
CRenderCaptureAndroid::~CRenderCaptureAndroid()
{
if (g_advancedSettings.m_videoUseDroidProjectionCapture)
CXBMCApp::StopCapture();
CXBMCApp::get()->StopCapture();
delete[] m_pixels;
}

Expand All @@ -57,7 +57,7 @@ void CRenderCaptureAndroid::BeginRender()
if (g_advancedSettings.m_videoUseDroidProjectionCapture)
{
m_asyncSupported = true;
CXBMCApp::startCapture(m_width, m_height);
CXBMCApp::get()->startCapture(m_width, m_height);
}
}

Expand All @@ -84,7 +84,7 @@ void CRenderCaptureAndroid::ReadOut()
if (g_advancedSettings.m_videoUseDroidProjectionCapture)
{
jni::CJNIImage image;
if (CXBMCApp::GetCapture(image))
if (CXBMCApp::get()->GetCapture(image))
{
int iWidth = image.getWidth();
int iHeight = image.getHeight();
Expand Down
2 changes: 1 addition & 1 deletion xbmc/dialogs/GUIDialogKeyboardGeneric.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ void CGUIDialogKeyboardGeneric::OnVoiceRecognition()
CJNIIntent intent = CJNIIntent(CJNIRecognizerIntent::ACTION_RECOGNIZE_SPEECH);
intent.putExtra(CJNIRecognizerIntent::EXTRA_LANGUAGE_MODEL, CJNIRecognizerIntent::LANGUAGE_MODEL_FREE_FORM);
CJNIIntent result;
if (CXBMCApp::WaitForActivityResult(intent, ACTION_RECOGNIZE_SPEECH_REQID, result) == CJNIBase::RESULT_OK)
if (CXBMCApp::get()->WaitForActivityResult(intent, ACTION_RECOGNIZE_SPEECH_REQID, result) == CJNIBase::RESULT_OK)
{
CJNIArrayList<std::string> guesses = result.getStringArrayListExtra(CJNIRecognizerIntent::EXTRA_RESULTS);
if (guesses.size())
Expand Down
2 changes: 1 addition & 1 deletion xbmc/filesystem/AndroidAppDirectory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ bool CAndroidAppDirectory::GetDirectory(const CURL& url, CFileItemList &items)

if (dirname == "apps")
{
std::vector<androidPackage> applications = CXBMCApp::GetApplications();
std::vector<androidPackage> applications = CXBMCApp::get()->GetApplications();
if (applications.empty())
{
CLog::Log(LOGERROR, "CAndroidAppDirectory::GetDirectory Application lookup listing failed");
Expand Down
8 changes: 4 additions & 4 deletions xbmc/filesystem/AndroidAppFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ bool CFileAndroidApp::Open(const CURL& url)
m_packageName = URIUtils::GetFileName(url.Get());
m_packageName = m_packageName.substr(0, m_packageName.size() - 4);

std::vector<androidPackage> applications = CXBMCApp::GetApplications();
std::vector<androidPackage> applications = CXBMCApp::get()->GetApplications();
for(std::vector<androidPackage>::iterator i = applications.begin(); i != applications.end(); ++i)
{
if ((*i).packageName == m_packageName)
Expand All @@ -77,7 +77,7 @@ bool CFileAndroidApp::Exists(const CURL& url)
std::string appname = URIUtils::GetFileName(url.Get());
appname = appname.substr(0, appname.size() - 4);

std::vector<androidPackage> applications = CXBMCApp::GetApplications();
std::vector<androidPackage> applications = CXBMCApp::get()->GetApplications();
for(std::vector<androidPackage>::iterator i = applications.begin(); i != applications.end(); ++i)
{
if ((*i).packageName == appname)
Expand All @@ -98,7 +98,7 @@ unsigned int CFileAndroidApp::ReadIcon(unsigned char** lpBuf, unsigned int* widt

if (CJNIBuild::SDK_INT >= 15 && m_icon)
{
CJNIResources res = CJNIContext::GetPackageManager().getResourcesForApplication(m_packageName);
CJNIResources res = CXBMCApp::get()->GetPackageManager().getResourcesForApplication(m_packageName);
if (res)
{
for (int i=0; densities[i] != -1 && !bmp; ++i)
Expand All @@ -123,7 +123,7 @@ unsigned int CFileAndroidApp::ReadIcon(unsigned char** lpBuf, unsigned int* widt

if (!bmp)
{
CJNIDrawable drw = CJNIContext::GetPackageManager().getApplicationIcon(m_packageName);
CJNIDrawable drw = CXBMCApp::get()->GetPackageManager().getApplicationIcon(m_packageName);
if (xbmc_jnienv()->ExceptionCheck())
xbmc_jnienv()->ExceptionClear();
else if (!drw);
Expand Down
12 changes: 6 additions & 6 deletions xbmc/network/android/NetworkAndroid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ std::string& CNetworkInterfaceAndroid::GetName()

bool CNetworkInterfaceAndroid::IsEnabled()
{
CJNIConnectivityManager connman(CXBMCApp::getSystemService(CJNIContext::CONNECTIVITY_SERVICE));
CJNIConnectivityManager connman(CXBMCApp::get()->getSystemService(CJNIContext::CONNECTIVITY_SERVICE));
CJNINetworkInfo ni = connman.getNetworkInfo(m_network);
if (!ni)
return false;
Expand All @@ -76,7 +76,7 @@ bool CNetworkInterfaceAndroid::IsEnabled()

bool CNetworkInterfaceAndroid::IsConnected()
{
CJNIConnectivityManager connman(CXBMCApp::getSystemService(CJNIContext::CONNECTIVITY_SERVICE));
CJNIConnectivityManager connman(CXBMCApp::get()->getSystemService(CJNIContext::CONNECTIVITY_SERVICE));
CJNINetworkInfo ni = connman.getNetworkInfo(m_network);
if (!ni)
return false;
Expand All @@ -86,7 +86,7 @@ bool CNetworkInterfaceAndroid::IsConnected()

bool CNetworkInterfaceAndroid::IsWireless()
{
CJNIConnectivityManager connman(CXBMCApp::getSystemService(CJNIContext::CONNECTIVITY_SERVICE));
CJNIConnectivityManager connman(CXBMCApp::get()->getSystemService(CJNIContext::CONNECTIVITY_SERVICE));
CJNINetworkInfo ni = connman.getNetworkInfo(m_network);
if (!ni)
return false;
Expand Down Expand Up @@ -237,14 +237,14 @@ std::string CNetworkInterfaceAndroid::GetCurrentWirelessEssId()
{
std::string ret;

CJNIConnectivityManager connman(CXBMCApp::getSystemService(CJNIContext::CONNECTIVITY_SERVICE));
CJNIConnectivityManager connman(CXBMCApp::get()->getSystemService(CJNIContext::CONNECTIVITY_SERVICE));
CJNINetworkInfo ni = connman.getNetworkInfo(m_network);
if (!ni)
return "";

if (ni.getType() == CJNIConnectivityManager::TYPE_WIFI)
{
CJNIWifiManager wm = CXBMCApp::getSystemService("wifi");
CJNIWifiManager wm = CXBMCApp::get()->getSystemService("wifi");
if (wm.isWifiEnabled())
{
CJNIWifiInfo wi = wm.getConnectionInfo();
Expand Down Expand Up @@ -384,7 +384,7 @@ void CNetworkAndroid::RetrieveInterfaces()
m_oldInterfaces = m_interfaces;
m_interfaces.clear();

CJNIConnectivityManager connman(CXBMCApp::getSystemService(CJNIContext::CONNECTIVITY_SERVICE));
CJNIConnectivityManager connman(CXBMCApp::get()->getSystemService(CJNIContext::CONNECTIVITY_SERVICE));
std::vector<CJNINetwork> networks = connman.getAllNetworks();

for (auto n : networks)
Expand Down
4 changes: 2 additions & 2 deletions xbmc/network/android/ZeroconfAndroid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@

#include "ZeroconfAndroid.h"

#include <androidjni/Context.h>
#include "utils/log.h"

#include "platform/android/activity/XBMCApp.h"
#include "threads/SingleLock.h"

CZeroconfAndroid::CZeroconfAndroid()
{
m_manager = CJNIContext::getSystemService(CJNIContext::NSD_SERVICE);
m_manager = CXBMCApp::get()->getSystemService(CJNIContext::NSD_SERVICE);
}

CZeroconfAndroid::~CZeroconfAndroid()
Expand Down
4 changes: 2 additions & 2 deletions xbmc/network/android/ZeroconfBrowserAndroid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
#include "ZeroconfBrowserAndroid.h"

#include <androidjni/jutils-details.hpp>
#include <androidjni/Context.h>

#include "platform/android/activity/XBMCApp.h"
#include "guilib/GUIMessage.h"
#include "guilib/GUIWindowManager.h"
#include "GUIUserMessages.h"
Expand All @@ -35,7 +35,7 @@

CZeroconfBrowserAndroid::CZeroconfBrowserAndroid()
{
m_manager = CJNIContext::getSystemService(CJNIContext::NSD_SERVICE);
m_manager = CXBMCApp::get()->getSystemService(CJNIContext::NSD_SERVICE);
}

CZeroconfBrowserAndroid::~CZeroconfBrowserAndroid()
Expand Down
18 changes: 9 additions & 9 deletions xbmc/peripherals/bus/android/PeripheralBusAndroid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ CPeripheralBusAndroid::CPeripheralBusAndroid(CPeripherals *manager) :
m_bNeedsPolling = false;

// register for input device callbacks
CXBMCApp::RegisterInputDeviceCallbacks(this);
CXBMCApp::get()->RegisterInputDeviceCallbacks(this);

// register for input device events
CXBMCApp::RegisterInputDeviceEventHandler(this);
CXBMCApp::get()->RegisterInputDeviceEventHandler(this);

// get all currently connected input devices
m_scanResults = GetInputDevices();
Expand All @@ -54,10 +54,10 @@ CPeripheralBusAndroid::CPeripheralBusAndroid(CPeripherals *manager) :
CPeripheralBusAndroid::~CPeripheralBusAndroid()
{
// unregister from input device events
CXBMCApp::UnregisterInputDeviceEventHandler();
CXBMCApp::get()->UnregisterInputDeviceEventHandler();

// unregister from input device callbacks
CXBMCApp::UnregisterInputDeviceCallbacks();
CXBMCApp::get()->UnregisterInputDeviceCallbacks();
}

bool CPeripheralBusAndroid::InitializeProperties(CPeripheral& peripheral)
Expand All @@ -78,7 +78,7 @@ bool CPeripheralBusAndroid::InitializeProperties(CPeripheral& peripheral)
return false;
}

const CJNIViewInputDevice device = CXBMCApp::GetInputDevice(deviceId);
const CJNIViewInputDevice device = CXBMCApp::get()->GetInputDevice(deviceId);
if (!device)
{
CLog::Log(LOGWARNING, "CPeripheralBusAndroid: failed to get input device with ID %d", deviceId);
Expand Down Expand Up @@ -184,7 +184,7 @@ void CPeripheralBusAndroid::OnInputDeviceAdded(int deviceId)
return;
}

const CJNIViewInputDevice device = CXBMCApp::GetInputDevice(deviceId);
const CJNIViewInputDevice device = CXBMCApp::get()->GetInputDevice(deviceId);
if (!device)
{
CLog::Log(LOGWARNING, "CPeripheralBusAndroid: failed to add input device with ID %d because it couldn't be found", deviceId);
Expand Down Expand Up @@ -212,7 +212,7 @@ void CPeripheralBusAndroid::OnInputDeviceChanged(int deviceId)
{
if (result->m_strLocation == deviceLocation)
{
const CJNIViewInputDevice device = CXBMCApp::GetInputDevice(deviceId);
const CJNIViewInputDevice device = CXBMCApp::get()->GetInputDevice(deviceId);
if (!device)
{
CLog::Log(LOGWARNING, "CPeripheralBusAndroid: failed to update input device \"%s\" with ID %d because it couldn't be found", result->m_strDeviceName.c_str(), deviceId);
Expand Down Expand Up @@ -297,11 +297,11 @@ PeripheralScanResults CPeripheralBusAndroid::GetInputDevices()
CLog::Log(LOGINFO, "CPeripheralBusAndroid: scanning for input devices...");

PeripheralScanResults results;
std::vector<int> deviceIds = CXBMCApp::GetInputDeviceIds();
std::vector<int> deviceIds = CXBMCApp::get()->GetInputDeviceIds();

for (const auto& deviceId : deviceIds)
{
const CJNIViewInputDevice device = CXBMCApp::GetInputDevice(deviceId);
const CJNIViewInputDevice device = CXBMCApp::get()->GetInputDevice(deviceId);
if (!device)
{
CLog::Log(LOGWARNING, "CPeripheralBusAndroid: no input device with ID %d found", deviceId);
Expand Down
4 changes: 2 additions & 2 deletions xbmc/pictures/GUIWindowSlideShow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ void CGUIWindowSlideShow::OnDeinitWindow(int nextWindowID)

#if defined(TARGET_ANDROID)
// enable android screensaver
CXBMCApp::EnableWakeLock(false);
CXBMCApp::get()->EnableWakeLock(false);
#elif defined(TARGET_DARWIN_TVOS)
CDarwinUtils::EnableOSScreenSaver(true);
#endif
Expand Down Expand Up @@ -381,7 +381,7 @@ void CGUIWindowSlideShow::StartSlideShow()
{
#if defined(TARGET_ANDROID)
// disable android screensaver
CXBMCApp::EnableWakeLock(true);
CXBMCApp::get()->EnableWakeLock(true);
#elif defined(TARGET_DARWIN_TVOS)
CDarwinUtils::EnableOSScreenSaver(false);
#endif
Expand Down
6 changes: 3 additions & 3 deletions xbmc/platform/android/activity/AndroidFeatures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@

#include <cpu-features.h>
#include <androidjni/JNIThreading.h>
#include <androidjni/Context.h>
#include <androidjni/PackageManager.h>

#include "platform/android/activity/XBMCApp.h"
#include "utils/log.h"

bool CAndroidFeatures::HasNeon()
Expand Down Expand Up @@ -82,7 +82,7 @@ bool CAndroidFeatures::HasTouchScreen()
static int hastouchscreen = -1;
if (hastouchscreen == -1)
{
if (CJNIContext::GetPackageManager().hasSystemFeature("android.hardware.touchscreen"))
if (CXBMCApp::get()->GetPackageManager().hasSystemFeature("android.hardware.touchscreen"))
hastouchscreen = 1;
else
hastouchscreen = 0;
Expand All @@ -96,7 +96,7 @@ bool CAndroidFeatures::IsLeanback()
static int isleanback = -1;
if (isleanback == -1)
{
if (CJNIContext::GetPackageManager().hasSystemFeature("android.software.leanback"))
if (CXBMCApp::get()->GetPackageManager().hasSystemFeature("android.software.leanback"))
isleanback = 1;
else
isleanback = 0;
Expand Down
Loading

0 comments on commit 49dc1b4

Please sign in to comment.